mirror of
https://github.com/denoland/deno.git
synced 2025-03-04 01:44:26 -05:00
refactor(core.js): provide window.__bootstrap (#10423)
This commit is contained in:
parent
a50dab683f
commit
8922639c1d
10 changed files with 3 additions and 27 deletions
|
@ -8,10 +8,6 @@ use crate::profiling::is_profiling;
|
||||||
pub fn create_js_runtime(setup: impl FnOnce(&mut JsRuntime)) -> JsRuntime {
|
pub fn create_js_runtime(setup: impl FnOnce(&mut JsRuntime)) -> JsRuntime {
|
||||||
let mut rt = JsRuntime::new(Default::default());
|
let mut rt = JsRuntime::new(Default::default());
|
||||||
|
|
||||||
// Setup bootstrap namespace
|
|
||||||
rt.execute("bootstrap", "globalThis.__bootstrap = {};")
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
// Caller provided setup
|
// Caller provided setup
|
||||||
setup(&mut rt);
|
setup(&mut rt);
|
||||||
|
|
||||||
|
|
|
@ -124,6 +124,9 @@
|
||||||
opSync("op_close", rid);
|
opSync("op_close", rid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Provide bootstrap namespace
|
||||||
|
window.__bootstrap = {};
|
||||||
|
// Extra Deno.core.* exports
|
||||||
Object.assign(window.Deno.core, {
|
Object.assign(window.Deno.core, {
|
||||||
opAsync,
|
opAsync,
|
||||||
opSync,
|
opSync,
|
||||||
|
|
|
@ -44,7 +44,6 @@
|
||||||
window.crypto = {
|
window.crypto = {
|
||||||
getRandomValues,
|
getRandomValues,
|
||||||
};
|
};
|
||||||
window.__bootstrap = window.__bootstrap || {};
|
|
||||||
window.__bootstrap.crypto = {
|
window.__bootstrap.crypto = {
|
||||||
getRandomValues,
|
getRandomValues,
|
||||||
};
|
};
|
||||||
|
|
|
@ -10,13 +10,6 @@ fn create_js_runtime() -> JsRuntime {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
|
|
||||||
runtime
|
|
||||||
.execute(
|
|
||||||
"bootstrap",
|
|
||||||
"globalThis.__bootstrap = (globalThis.__bootstrap || {});",
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
runtime.init_extension_js().unwrap();
|
runtime.init_extension_js().unwrap();
|
||||||
runtime.init_extension_ops().unwrap();
|
runtime.init_extension_ops().unwrap();
|
||||||
|
|
||||||
|
|
|
@ -1202,7 +1202,6 @@
|
||||||
window.dispatchEvent = EventTarget.prototype.dispatchEvent;
|
window.dispatchEvent = EventTarget.prototype.dispatchEvent;
|
||||||
window.addEventListener = EventTarget.prototype.addEventListener;
|
window.addEventListener = EventTarget.prototype.addEventListener;
|
||||||
window.removeEventListener = EventTarget.prototype.removeEventListener;
|
window.removeEventListener = EventTarget.prototype.removeEventListener;
|
||||||
window.__bootstrap = (window.__bootstrap || {});
|
|
||||||
window.__bootstrap.eventTarget = {
|
window.__bootstrap.eventTarget = {
|
||||||
EventTarget,
|
EventTarget,
|
||||||
setEventTargetData,
|
setEventTargetData,
|
||||||
|
|
|
@ -120,7 +120,6 @@
|
||||||
|
|
||||||
window.AbortSignal = AbortSignal;
|
window.AbortSignal = AbortSignal;
|
||||||
window.AbortController = AbortController;
|
window.AbortController = AbortController;
|
||||||
window.__bootstrap = window.__bootstrap || {};
|
|
||||||
window.__bootstrap.abortSignal = {
|
window.__bootstrap.abortSignal = {
|
||||||
add,
|
add,
|
||||||
signalAbort,
|
signalAbort,
|
||||||
|
|
|
@ -44,7 +44,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window.__bootstrap = (window.__bootstrap || {});
|
|
||||||
window.__bootstrap.globalInterfaces = {
|
window.__bootstrap.globalInterfaces = {
|
||||||
DedicatedWorkerGlobalScope,
|
DedicatedWorkerGlobalScope,
|
||||||
Window,
|
Window,
|
||||||
|
|
|
@ -4559,7 +4559,6 @@
|
||||||
window.TextDecoder = TextDecoder;
|
window.TextDecoder = TextDecoder;
|
||||||
window.atob = atob;
|
window.atob = atob;
|
||||||
window.btoa = btoa;
|
window.btoa = btoa;
|
||||||
window.__bootstrap = window.__bootstrap || {};
|
|
||||||
window.__bootstrap.encoding = { decode };
|
window.__bootstrap.encoding = { decode };
|
||||||
window.__bootstrap.base64 = base64;
|
window.__bootstrap.base64 = base64;
|
||||||
})(this);
|
})(this);
|
||||||
|
|
|
@ -348,7 +348,6 @@
|
||||||
workerLocation = new WorkerLocation(href, locationConstructorKey);
|
workerLocation = new WorkerLocation(href, locationConstructorKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
window.__bootstrap = (window.__bootstrap || {});
|
|
||||||
window.__bootstrap.location = {
|
window.__bootstrap.location = {
|
||||||
locationConstructorDescriptor: {
|
locationConstructorDescriptor: {
|
||||||
value: Location,
|
value: Location,
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
|
||||||
|
|
||||||
// The only purpose of this file is to set up "globalThis.__bootstrap" namespace,
|
|
||||||
// that is used by scripts in this directory to reference exports between
|
|
||||||
// the files.
|
|
||||||
|
|
||||||
// This namespace is removed during runtime bootstrapping process.
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
globalThis.__bootstrap = globalThis.__bootstrap || {};
|
|
Loading…
Add table
Reference in a new issue