diff options
author | Leo K <crowlkats@toaxl.com> | 2021-08-10 00:28:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-10 00:28:17 +0200 |
commit | 2db381eba9768acf855219ec9560e20a62659994 (patch) | |
tree | c06a693b804c9a2bc3bf76f7ac66a02f57499ccb /runtime/js/99_main.js | |
parent | 7600a456dfc880a1eeff230f3f34c87978fedc58 (diff) |
feat: add experimental WebSocketStream API (#10365)
This commit adds the experimental WebSocketStream API when
using the --unstable flag.
The explainer for the API can be found here:
https://github.com/ricea/websocketstream-explainer
Diffstat (limited to 'runtime/js/99_main.js')
-rw-r--r-- | runtime/js/99_main.js | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js index a85c40eb9..6d5599e71 100644 --- a/runtime/js/99_main.js +++ b/runtime/js/99_main.js @@ -231,6 +231,18 @@ delete Object.prototype.__proto__; }, ); core.registerErrorBuilder( + "DOMExceptionNetworkError", + function DOMExceptionNetworkError(msg) { + return new domException.DOMException(msg, "NetworkError"); + }, + ); + core.registerErrorBuilder( + "DOMExceptionAbortError", + function DOMExceptionAbortError(msg) { + return new domException.DOMException(msg, "AbortError"); + }, + ); + core.registerErrorBuilder( "DOMExceptionInvalidCharacterError", function DOMExceptionInvalidCharacterError(msg) { return new domException.DOMException(msg, "InvalidCharacterError"); @@ -342,7 +354,6 @@ delete Object.prototype.__proto__; URL: util.nonEnumerable(url.URL), URLSearchParams: util.nonEnumerable(url.URLSearchParams), WebSocket: util.nonEnumerable(webSocket.WebSocket), - BroadcastChannel: util.nonEnumerable(broadcastChannel.BroadcastChannel), MessageChannel: util.nonEnumerable(messagePort.MessageChannel), MessagePort: util.nonEnumerable(messagePort.MessagePort), Worker: util.nonEnumerable(worker.Worker), @@ -377,6 +388,11 @@ delete Object.prototype.__proto__; setInterval: util.writable(timers.setInterval), setTimeout: util.writable(timers.setTimeout), structuredClone: util.writable(messagePort.structuredClone), + }; + + const unstableWindowOrWorkerGlobalScope = { + WebSocketStream: util.nonEnumerable(webSocket.WebSocketStream), + BroadcastChannel: util.nonEnumerable(broadcastChannel.BroadcastChannel), GPU: util.nonEnumerable(webgpu.GPU), GPUAdapter: util.nonEnumerable(webgpu.GPUAdapter), @@ -485,6 +501,9 @@ delete Object.prototype.__proto__; util.log("bootstrapMainRuntime"); hasBootstrapped = true; ObjectDefineProperties(globalThis, windowOrWorkerGlobalScope); + if (runtimeOptions.unstableFlag) { + ObjectDefineProperties(globalThis, unstableWindowOrWorkerGlobalScope); + } ObjectDefineProperties(globalThis, mainRuntimeGlobalProperties); ObjectSetPrototypeOf(globalThis, Window.prototype); @@ -573,6 +592,9 @@ delete Object.prototype.__proto__; util.log("bootstrapWorkerRuntime"); hasBootstrapped = true; ObjectDefineProperties(globalThis, windowOrWorkerGlobalScope); + if (runtimeOptions.unstableFlag) { + ObjectDefineProperties(globalThis, unstableWindowOrWorkerGlobalScope); + } ObjectDefineProperties(globalThis, workerRuntimeGlobalProperties); ObjectDefineProperties(globalThis, { name: util.readOnly(name) }); ObjectSetPrototypeOf(globalThis, DedicatedWorkerGlobalScope.prototype); |