Files
cocos4/@types/pal/wasm.d.ts
T

22 lines
1.0 KiB
TypeScript

declare module 'pal/wasm' {
/**
* The first parameter of standard `Webassembly.instantiate` interface is the arraybuffer of wasm.
* But the implementation on some platforms is not standard.
* So here we provide a more commonly used interface, whose first parameter is the url of wasm.
*
* @param wasmUrl the url of wasm, this should be a url relative from build output chunk.
* @param importObject the standard `WebAssembly.Imports` instance
*/
export function instantiateWasm (wasmUrl: string, importObject: WebAssembly.Imports): Promise<any>;
/**
* Fetch binary data from wasm url or js mem url.
* NOTE: This method should only use to instantiate asm.js compiled with `-O2` options,
* because not all platforms support instantiate wasm by wasm binary.
* eg. WeChat can only instantiate wasm by wasm url.
*
* @param binaryUrl the url of wasm or js mem, this should be a url relative from build output chunk.
*/
export function fetchBuffer (binaryUrl: string): Promise<ArrayBuffer>;
}