summaryrefslogtreecommitdiff
path: root/core/lib.deno_core.d.ts
diff options
context:
space:
mode:
authorAndreu Botella <abb@randomunok.com>2021-07-03 23:33:36 +0200
committerGitHub <noreply@github.com>2021-07-03 23:33:36 +0200
commitffa75be48044255ed49a822a7a61a2a130123a4a (patch)
treefe6af45c9087fc030b3e87b6f56ee53152361b9f /core/lib.deno_core.d.ts
parent7ef0f43d87e3e45e8084bb7ae0dee2053968c010 (diff)
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<Response> instead, as well as enabling asynchronous compilation of WebAssembly modules.
Diffstat (limited to 'core/lib.deno_core.d.ts')
-rw-r--r--core/lib.deno_core.d.ts26
1 files changed, 26 insertions, 0 deletions
diff --git a/core/lib.deno_core.d.ts b/core/lib.deno_core.d.ts
index 2cec6be76..2c69782a6 100644
--- a/core/lib.deno_core.d.ts
+++ b/core/lib.deno_core.d.ts
@@ -41,5 +41,31 @@ declare namespace Deno {
/** Encode a string to its Uint8Array representation. */
function encode(input: string): Uint8Array;
+
+ /**
+ * Set a callback that will be called when the WebAssembly streaming APIs
+ * (`WebAssembly.compileStreaming` and `WebAssembly.instantiateStreaming`)
+ * are called in order to feed the source's bytes to the wasm compiler.
+ * The callback is called with the source argument passed to the streaming
+ * APIs and an rid to use with `Deno.core.wasmStreamingFeed`.
+ */
+ function setWasmStreamingCallback(
+ cb: (source: any, rid: number) => void,
+ ): void;
+
+ /**
+ * Affect the state of the WebAssembly streaming compiler, by either passing
+ * it bytes, aborting it, or indicating that all bytes were received.
+ * `rid` must be a resource ID that was passed to the callback set with
+ * `Deno.core.setWasmStreamingCallback`. Calling this function with `type`
+ * set to either "abort" or "finish" invalidates the rid.
+ */
+ function wasmStreamingFeed(
+ rid: number,
+ type: "bytes",
+ bytes: Uint8Array,
+ ): void;
+ function wasmStreamingFeed(rid: number, type: "abort", error: any): void;
+ function wasmStreamingFeed(rid: number, type: "finish"): void;
}
}