diff options
Diffstat (limited to 'cli/js/runtime_main.ts')
-rw-r--r-- | cli/js/runtime_main.ts | 43 |
1 files changed, 30 insertions, 13 deletions
diff --git a/cli/js/runtime_main.ts b/cli/js/runtime_main.ts index 6c6617be0..b2ed5d52b 100644 --- a/cli/js/runtime_main.ts +++ b/cli/js/runtime_main.ts @@ -7,7 +7,8 @@ // - `bootstrapMainRuntime` - must be called once, when Isolate is created. // It sets up runtime by providing globals for `WindowScope` and adds `Deno` global. -import * as Deno from "./deno.ts"; +import * as denoNs from "./deno.ts"; +import * as denoUnstableNs from "./deno_unstable.ts"; import * as csprng from "./ops/get_random_values.ts"; import { exit } from "./ops/os.ts"; import { @@ -19,6 +20,7 @@ import { eventTargetProperties, setEventTargetData, } from "./globals.ts"; +import { unstableMethods, unstableProperties } from "./globals_unstable.ts"; import { internalObject, internalSymbol } from "./internals.ts"; import { setSignals } from "./signals.ts"; import { replLoop } from "./repl.ts"; @@ -31,7 +33,7 @@ import { log, immutableDefine } from "./util.ts"; // Add internal object to Deno object. // This is not exposed as part of the Deno types. // @ts-ignore -Deno[internalSymbol] = internalObject; +denoNs[internalSymbol] = internalObject; let windowIsClosing = false; @@ -96,29 +98,44 @@ export function bootstrapMainRuntime(): void { } }); - const s = runtime.start(); + const { + args, + cwd, + location, + noColor, + pid, + repl, + unstableFlag, + } = runtime.start(); - const location = new LocationImpl(s.location); - immutableDefine(globalThis, "location", location); + const location_ = new LocationImpl(location); + immutableDefine(globalThis, "location", location_); Object.freeze(globalThis.location); - Object.defineProperties(Deno, { - pid: readOnly(s.pid), - noColor: readOnly(s.noColor), - args: readOnly(Object.freeze(s.args)), + Object.defineProperties(denoNs, { + pid: readOnly(pid), + noColor: readOnly(noColor), + args: readOnly(Object.freeze(args)), }); + + if (unstableFlag) { + Object.defineProperties(globalThis, unstableMethods); + Object.defineProperties(globalThis, unstableProperties); + Object.assign(denoNs, denoUnstableNs); + } + // Setup `Deno` global - we're actually overriding already // existing global `Deno` with `Deno` namespace from "./deno.ts". - immutableDefine(globalThis, "Deno", Deno); + immutableDefine(globalThis, "Deno", denoNs); Object.freeze(globalThis.Deno); Object.freeze(globalThis.Deno.core); Object.freeze(globalThis.Deno.core.sharedQueue); setSignals(); - log("cwd", s.cwd); - log("args", Deno.args); + log("cwd", cwd); + log("args", args); - if (s.repl) { + if (repl) { replLoop(); } } |