67 lines
2.0 KiB
TypeScript
67 lines
2.0 KiB
TypeScript
import type { CncDialect, CncEvent, CncParseOptions } from "./index";
|
|
|
|
export type WasmSimulator = {
|
|
parse(program: string, dialect?: CncDialect, options?: CncParseOptions): CncEvent[];
|
|
parseFile(path: string, dialect?: CncDialect, options?: CncParseOptions): Promise<CncEvent[]>;
|
|
parseWithParameterFile(
|
|
program: string,
|
|
parameterPath: string,
|
|
dialect?: CncDialect,
|
|
options?: CncParseOptions,
|
|
): Promise<CncEvent[]>;
|
|
parseFileWithParameterFile(
|
|
path: string,
|
|
parameterPath: string,
|
|
dialect?: CncDialect,
|
|
options?: CncParseOptions,
|
|
): Promise<CncEvent[]>;
|
|
dispose(): void;
|
|
fs: {
|
|
opfs: WasmOpfsWorkspace | null;
|
|
module: unknown;
|
|
};
|
|
};
|
|
|
|
export type WasmOpfsWorkspace = {
|
|
mountPoint: string;
|
|
workspacePath: string;
|
|
resolvePath(path: string): string;
|
|
readFile(path: string): Promise<Uint8Array>;
|
|
readDirectory(path: string): Promise<string[]>;
|
|
persistFile(path: string): Promise<Uint8Array>;
|
|
persistDirectory(path: string): Promise<string[]>;
|
|
writeFile(path: string, data: Uint8Array | string): Promise<void>;
|
|
copyFile(fromPath: string, toPath: string): Promise<Uint8Array>;
|
|
moveFile(fromPath: string, toPath: string): Promise<void>;
|
|
exists(path: string): Promise<boolean>;
|
|
stat(path: string): Promise<WasmOpfsEntryStat>;
|
|
loadParameterFile(path: string): Promise<Uint8Array | null>;
|
|
persistParameterFile(path: string): Promise<Uint8Array>;
|
|
removeFile(path: string): Promise<void>;
|
|
removeDirectory(path: string): Promise<void>;
|
|
clear(): Promise<void>;
|
|
};
|
|
|
|
export type WasmOpfsEntryStat =
|
|
| {
|
|
kind: "file";
|
|
size: number;
|
|
}
|
|
| {
|
|
kind: "directory";
|
|
size: null;
|
|
};
|
|
|
|
export type WasmModuleOptions = {
|
|
locateFile?: (file: string) => string;
|
|
print?: (text: string) => void;
|
|
printErr?: (text: string) => void;
|
|
opfs?: false | {
|
|
required?: boolean;
|
|
mountPoint?: string;
|
|
workspacePath?: string;
|
|
};
|
|
};
|
|
|
|
export function createWasmSimulator(moduleOptions?: WasmModuleOptions): Promise<WasmSimulator>;
|