第 6 组:源码链接、构建和文档约束闭环完成

This commit is contained in:
cnc
2026-06-01 06:11:08 +08:00
parent 1498d9830d
commit 4c55ab3435
43 changed files with 8414 additions and 636 deletions

View File

@@ -2,13 +2,65 @@ 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>;