emscripten-wasm-loader
Version:
Common interface to load wasm module into isomorphic environment
48 lines • 1.75 kB
TypeScript
declare type stringToUTF8Signature = (str: string, outPtr: number, maxBytesToWrite: number) => void;
declare type cwrapArgType = 'number' | 'string' | 'array' | 'boolean';
/** @internal */
declare type cwrapSignature = <T = Function>(fn: string, returnType: cwrapArgType | null, parameterType?: Array<cwrapArgType>) => T;
declare type FILESYSTEMS = {
NODEFS: any;
MEMFS: any;
};
/**
* Subset of internal filesystem api for wasm module.
*/
declare type FS = {
filesystems: FILESYSTEMS;
stat: (path: string) => import('fs').Stats;
isDir: (mode: number) => boolean;
isFile: (mode: number) => boolean;
mkdir: (path: string, mode?: number) => void;
mount: (type: FILESYSTEMS, option: {
root?: string;
}, mountpoint: string) => void;
writeFile: (path: string, data: ArrayBufferView, opts: {
encoding?: string;
flags?: string;
}) => void;
unlink: (path: string) => void;
unmount: (mountpoint: string) => void;
rmdir: (path: string) => void;
};
interface AsmModule {
cwrap: cwrapSignature;
FS: FS;
stringToUTF8: stringToUTF8Signature;
getValue: <T = any>(ptr: number, type: string, nosafe?: boolean) => T;
allocateUTF8: (str: string) => number;
UTF8ToString: (ptr: number) => string;
_free: (ptr: number) => void;
_malloc: (size: number) => number;
}
/**
*
* Base interface for module generated by emscripten to load wasm binary.
* https://kripken.github.io/emscripten-site/docs/api_reference/preamble.js.html
*/
declare type BaseAsmModule = Partial<AsmModule> & {
initializeRuntime(): Promise<boolean>;
};
export { stringToUTF8Signature, cwrapSignature, FILESYSTEMS, FS, BaseAsmModule };
//# sourceMappingURL=BaseAsmModule.d.ts.map