summaryrefslogtreecommitdiff
path: root/cli/js/runtime_main.ts
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2020-03-11 21:57:24 +0100
committerGitHub <noreply@github.com>2020-03-11 21:57:24 +0100
commit810e4a16bedbc77ef0651f4f24626d98ca566083 (patch)
treeae82b48442178e0d02292c208d48e4ea8a3d9ca9 /cli/js/runtime_main.ts
parentb8fa3fd5e7dd906e5616bf2ab8ad6df3f74f244d (diff)
reorg: Deno global initialization (#4317)
Diffstat (limited to 'cli/js/runtime_main.ts')
-rw-r--r--cli/js/runtime_main.ts27
1 files changed, 19 insertions, 8 deletions
diff --git a/cli/js/runtime_main.ts b/cli/js/runtime_main.ts
index 40987f33d..a59e7513b 100644
--- a/cli/js/runtime_main.ts
+++ b/cli/js/runtime_main.ts
@@ -20,9 +20,10 @@ import {
import { internalObject } from "./internals.ts";
import { setSignals } from "./signals.ts";
import { replLoop } from "./repl.ts";
+import { LocationImpl } from "./web/location.ts";
import * as runtime from "./runtime.ts";
import { symbols } from "./symbols.ts";
-import { log } from "./util.ts";
+import { log, immutableDefine } from "./util.ts";
// TODO: factor out `Deno` global assignment to separate function
// Add internal object to Deno object.
@@ -33,8 +34,6 @@ Deno[symbols.internal] = internalObject;
export const mainRuntimeGlobalProperties = {
window: readOnly(globalThis),
self: readOnly(globalThis),
- Deno: readOnly(Deno),
-
crypto: readOnly(csprng),
// TODO(bartlomieju): from MDN docs (https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope)
// it seems those two properties should be availble to workers as well
@@ -69,15 +68,27 @@ export function bootstrapMainRuntime(): void {
}
});
- const s = runtime.start(true);
+ const s = runtime.start();
+
+ const location = new LocationImpl(s.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))
+ });
+ // Setup `Deno` global - we're actually overriding already
+ // existing global `Deno` with `Deno` namespace from "./deno.ts".
+ immutableDefine(globalThis, "Deno", Deno);
+ Object.freeze(globalThis.Deno);
+ Object.freeze(globalThis.Deno.core);
+ Object.freeze(globalThis.Deno.core.sharedQueue);
setSignals();
log("cwd", s.cwd);
- for (let i = 0; i < s.args.length; i++) {
- Deno.args.push(s.args[i]);
- }
log("args", Deno.args);
- Object.freeze(Deno.args);
if (s.repl) {
replLoop();