From ffa75be48044255ed49a822a7a61a2a130123a4a Mon Sep 17 00:00:00 2001 From: Andreu Botella Date: Sat, 3 Jul 2021 23:33:36 +0200 Subject: feat: enable WebAssembly.instantiateStreaming and wasm async compilation (#11200) The WebAssembly streaming APIs used to be enabled, but used to take buffer sources as their first argument (see #6154 and #7259). This change re-enables them, requiring a Promise instead, as well as enabling asynchronous compilation of WebAssembly modules. --- cli/dts/lib.deno.shared_globals.d.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'cli/dts/lib.deno.shared_globals.d.ts') diff --git a/cli/dts/lib.deno.shared_globals.d.ts b/cli/dts/lib.deno.shared_globals.d.ts index be35fae01..849f9f835 100644 --- a/cli/dts/lib.deno.shared_globals.d.ts +++ b/cli/dts/lib.deno.shared_globals.d.ts @@ -224,6 +224,18 @@ declare namespace WebAssembly { */ export function compile(bytes: BufferSource): Promise; + /** + * The `WebAssembly.compileStreaming()` function compiles a `WebAssembly.Module` + * directly from a streamed underlying source. This function is useful if it is + * necessary to a compile a module before it can be instantiated (otherwise, the + * `WebAssembly.instantiateStreaming()` function should be used). + * + * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/compileStreaming) + */ + export function compileStreaming( + source: Response | Promise, + ): Promise; + /** * The WebAssembly.instantiate() function allows you to compile and instantiate * WebAssembly code. @@ -255,6 +267,18 @@ declare namespace WebAssembly { importObject?: Imports, ): Promise; + /** + * The `WebAssembly.instantiateStreaming()` function compiles and instantiates a + * WebAssembly module directly from a streamed underlying source. This is the most + * efficient, optimized way to load wasm code. + * + * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiateStreaming) + */ + export function instantiateStreaming( + response: Response | PromiseLike, + importObject?: Imports, + ): Promise; + /** * The `WebAssembly.validate()` function validates a given typed array of * WebAssembly binary code, returning whether the bytes form a valid wasm -- cgit v1.2.3