summaryrefslogtreecommitdiff
path: root/core/01_core.js
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2023-03-05 18:18:13 -0400
committerGitHub <noreply@github.com>2023-03-05 22:18:13 +0000
commit5f34c9be91a42e9087536d63b7e319439ceba756 (patch)
tree529a4414ef89104fa39ab422181028670f6f718b /core/01_core.js
parent273777f7d9201de92b6f8c6f2f9579321165ec17 (diff)
refactor: move definition of Deno.build from "runtime" to "core" (#18036)
We use information about build in several extension crates like "ext/node" or "runtime/". In an effort to move "fs" APIs to a separate crate it is a prerequisite to have this information available outside of the "runtime/" crate. This commit moves definition of "build" object to "Deno.core" that is later forwarded to "Deno.build".
Diffstat (limited to 'core/01_core.js')
-rw-r--r--core/01_core.js50
1 files changed, 38 insertions, 12 deletions
diff --git a/core/01_core.js b/core/01_core.js
index 5a622b0ea..07ab758f1 100644
--- a/core/01_core.js
+++ b/core/01_core.js
@@ -3,33 +3,57 @@
((window) => {
const {
- Error,
- RangeError,
- ReferenceError,
- SyntaxError,
- TypeError,
- URIError,
Array,
ArrayPrototypeFill,
- ArrayPrototypePush,
ArrayPrototypeMap,
+ ArrayPrototypePush,
+ Error,
ErrorCaptureStackTrace,
- Promise,
- ObjectAssign,
- ObjectFromEntries,
Map,
+ MapPrototypeDelete,
MapPrototypeGet,
MapPrototypeHas,
- MapPrototypeDelete,
MapPrototypeSet,
+ ObjectAssign,
+ ObjectFreeze,
+ ObjectFromEntries,
+ Promise,
PromisePrototypeThen,
+ RangeError,
+ ReferenceError,
SafePromisePrototypeFinally,
+ setQueueMicrotask,
StringPrototypeSlice,
+ StringPrototypeSplit,
SymbolFor,
- setQueueMicrotask,
+ SyntaxError,
+ TypeError,
+ URIError,
} = window.__bootstrap.primordials;
const { ops } = window.Deno.core;
+ const build = {
+ target: "unknown",
+ arch: "unknown",
+ os: "unknown",
+ vendor: "unknown",
+ env: undefined,
+ };
+
+ function setBuildInfo(target) {
+ const { 0: arch, 1: vendor, 2: os, 3: env } = StringPrototypeSplit(
+ target,
+ "-",
+ 4,
+ );
+ build.target = target;
+ build.arch = arch;
+ build.vendor = vendor;
+ build.os = os;
+ build.env = env;
+ ObjectFreeze(build);
+ }
+
const errorMap = {};
// Builtin v8 / JS errors
registerErrorClass("Error", Error);
@@ -408,6 +432,8 @@
eventLoopHasMoreWork: () => ops.op_event_loop_has_more_work(),
setPromiseRejectCallback: (fn) => ops.op_set_promise_reject_callback(fn),
byteLength: (str) => ops.op_str_byte_length(str),
+ build,
+ setBuildInfo,
});
ObjectAssign(globalThis.__bootstrap, { core });