diff options
author | Nayeem Rahman <nayeemrmn99@gmail.com> | 2022-05-17 21:27:17 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-17 22:27:17 +0200 |
commit | 330c820ae8d7826dfe3d88c01ba07728121fa021 (patch) | |
tree | a5c0216f5cba4ea503e9cba3b0abdd8d4290c123 /runtime/js | |
parent | f57aac77ff9ce514730504066daca0a61a959d32 (diff) |
BREAKING(unstable): Enable Deno namespace in workers by default (#14581)
This commit removes "WorkerOptions.deno" option as a boolean,
as well as "WorkerOptions.deno.namespace" settings. Starting
with this commit all workers have access to "Deno" namespace
by default.
Diffstat (limited to 'runtime/js')
-rw-r--r-- | runtime/js/11_workers.js | 19 | ||||
-rw-r--r-- | runtime/js/99_main.js | 29 |
2 files changed, 12 insertions, 36 deletions
diff --git a/runtime/js/11_workers.js b/runtime/js/11_workers.js index 87949c1c0..948542d1c 100644 --- a/runtime/js/11_workers.js +++ b/runtime/js/11_workers.js @@ -27,7 +27,6 @@ specifier, hasSourceCode, sourceCode, - useDenoNamespace, permissions, name, workerType, @@ -38,7 +37,6 @@ permissions: serializePermissions(permissions), sourceCode, specifier, - useDenoNamespace, workerType, }); } @@ -79,20 +77,6 @@ type = "classic", } = options; - let namespace; - let permissions; - if (typeof deno == "object") { - namespace = deno.namespace ?? false; - permissions = deno.permissions ?? undefined; - } else { - // Assume `deno: boolean | undefined`. - // TODO(Soremwar) - // `deno: boolean` is kept for backwards compatibility with the previous - // worker options implementation. Remove for 2.0 - namespace = !!deno; - permissions = undefined; - } - const workerType = webidl.converters["WorkerType"](type); if ( @@ -120,8 +104,7 @@ specifier, hasSourceCode, sourceCode, - namespace, - permissions, + deno?.permissions, name, workerType, ); diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js index cf2525b06..b469a29dc 100644 --- a/runtime/js/99_main.js +++ b/runtime/js/99_main.js @@ -26,7 +26,6 @@ delete Object.prototype.__proto__; PromisePrototypeThen, TypeError, } = window.__bootstrap.primordials; - const infra = window.__bootstrap.infra; const util = window.__bootstrap.util; const eventTarget = window.__bootstrap.eventTarget; const globalInterfaces = window.__bootstrap.globalInterfaces; @@ -627,7 +626,6 @@ delete Object.prototype.__proto__; function bootstrapWorkerRuntime( runtimeOptions, name, - useDenoNamespace, internalName, ) { if (hasBootstrapped) { @@ -697,23 +695,18 @@ delete Object.prototype.__proto__; close: core.close, ...denoNs, }; - if (useDenoNamespace) { - if (unstableFlag) { - ObjectAssign(finalDenoNs, denoNsUnstable); - } - ObjectDefineProperties(finalDenoNs, { - pid: util.readOnly(pid), - noColor: util.readOnly(noColor), - args: util.readOnly(ObjectFreeze(args)), - }); - // Setup `Deno` global - we're actually overriding already - // existing global `Deno` with `Deno` namespace from "./deno.ts". - ObjectDefineProperty(globalThis, "Deno", util.readOnly(finalDenoNs)); - ObjectFreeze(globalThis.Deno.core); - } else { - delete globalThis.Deno; - infra.assert(globalThis.Deno === undefined); + if (unstableFlag) { + ObjectAssign(finalDenoNs, denoNsUnstable); } + ObjectDefineProperties(finalDenoNs, { + pid: util.readOnly(pid), + noColor: util.readOnly(noColor), + args: util.readOnly(ObjectFreeze(args)), + }); + // Setup `Deno` global - we're actually overriding already + // existing global `Deno` with `Deno` namespace from "./deno.ts". + ObjectDefineProperty(globalThis, "Deno", util.readOnly(finalDenoNs)); + ObjectFreeze(globalThis.Deno.core); } ObjectDefineProperties(globalThis, { |