UNPKG

@toybox-labs/cura-wasm

Version:

Cura Engine powered by Web Assembly (WASM)

94 lines (93 loc) 2.8 kB
/** * @fileoverview Cura WASM */ /// <reference types="node" /> import { CombinedDefinition } from 'cura-wasm-definitions/src/types'; import { EventEmitter } from 'events'; import type { override } from './types'; /** * Configuration for Cura WASM */ interface config { /** * The Cura Engine launch command (Instead of setting overrides) * * There's a 99% chance you want to start your command with * `slice -j definitions/printer.def.json -l Model.stl -o Model.gcode` * regardless of what overrides you're using. * * Note: You cannot use overrides with this setting! */ command: string | null; /** * The 3D printer definition to use * * Default: `fdmprinter` */ definition: CombinedDefinition; /** * Overrides for the specified 3D printer definition (Instead of a launch command) * * Note: You cannot use the command setting with this setting! */ overrides: override[]; /** * Wether or not to transfer the ArrayBuffer to the worker * * (Prevents duplicating large amounts of memory but empties * the ArrayBuffer on the main thread preventing other code from using * the ArrayBuffer) */ transfer: boolean; /** * Wether to enable verbose logging or not (Useful for debugging) */ verbose: boolean; } /** * @class Cura compiled to Web Assembly (WASM) */ export declare class CuraWASM extends EventEmitter { /** * Consumer provided configuration for Cura WASM */ private config; /** * Wether the consumer has called the `load` function or not */ private loaded; /** * A number holding the previous progress to prevent duplicate progress events */ private oldProgress; /** * Cura WASM runs in multiple threads to avoid blocking the main thread, * this worker is what runs Cura Engine in a separate thread */ private worker; constructor(config: Partial<config>); /** * Load emscripten and add definitions (Internal use only) */ private load; /** * Slice the provided file using the settings specified in the constructor * @param file The raw file to slice * @param extension The file extension (Used for determining the correct parser) * @returns The raw, sliced GCODE and the print metadata */ slice(file: ArrayBuffer, extension: string): Promise<{ gcode: ArrayBuffer; metadata: null; }>; /** * Cleanup all assets and destroy the worker */ destroy(): Promise<void>; /** * Verbose logging method (Internal use only) * @param msg */ private log; } export {};