mirror of
https://github.com/denoland/deno.git
synced 2025-08-03 18:38:33 +00:00
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.
This commit is contained in:
parent
f57aac77ff
commit
330c820ae8
15 changed files with 50 additions and 198 deletions
|
@ -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,
|
||||
);
|
||||
|
|
|
@ -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, {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue