From c1fc7b2cd511ce83566f696c8880d6718e5c6885 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Thu, 7 Dec 2023 14:21:01 +0100 Subject: [PATCH] refactor: pull 'core', 'internals', 'primordials' from ES module (#21462) This commit refactors how we access "core", "internals" and "primordials" objects coming from `deno_core`, in our internal JavaScript code. Instead of capturing them from "globalThis.__bootstrap" namespace, we import them from recently added "ext:core/mod.js" file. --- ext/broadcast_channel/01_broadcast_channel.js | 3 +-- ext/cache/01_cache.js | 3 +-- ext/console/01_console.js | 4 +--- ext/crypto/00_crypto.js | 3 +-- ext/fetch/20_headers.js | 2 +- ext/fetch/21_formdata.js | 3 +-- ext/fetch/22_body.js | 3 +-- ext/fetch/22_http_client.js | 2 +- ext/fetch/23_request.js | 2 +- ext/fetch/23_response.js | 3 +-- ext/fetch/26_fetch.js | 3 +-- ext/fetch/27_eventsource.js | 3 +-- ext/ffi/00_ffi.js | 3 +-- ext/fs/30_fs.js | 3 +-- ext/http/00_serve.js | 4 +--- ext/http/01_http.js | 4 +--- ext/io/12_io.js | 3 +-- ext/net/01_net.js | 3 +-- ext/net/02_tls.js | 3 +-- ext/node/polyfills/01_require.js | 4 +--- ext/node/polyfills/_process/process.ts | 2 +- ext/node/polyfills/http2.ts | 2 +- ext/node/polyfills/internal/crypto/_randomInt.ts | 3 ++- ext/node/polyfills/internal/crypto/random.ts | 2 +- ext/node/polyfills/internal/process/report.ts | 2 +- ext/node/polyfills/internal/timers.mjs | 2 +- ext/node/polyfills/internal/util/parse_args/parse_args.js | 2 +- ext/node/polyfills/internal/util/parse_args/utils.js | 2 +- ext/node/polyfills/internal/validators.mjs | 2 +- ext/node/polyfills/internal_binding/stream_wrap.ts | 2 +- ext/node/polyfills/internal_binding/udp_wrap.ts | 2 +- ext/node/polyfills/internal_binding/util.ts | 2 +- ext/node/polyfills/timers.ts | 2 +- ext/node/polyfills/util.ts | 2 +- ext/url/00_url.js | 3 +-- ext/url/01_urlpattern.js | 3 +-- ext/web/00_infra.js | 4 +--- ext/web/01_dom_exception.js | 2 +- ext/web/01_mimesniff.js | 2 +- ext/web/02_event.js | 3 +-- ext/web/02_structured_clone.js | 3 +-- ext/web/02_timers.js | 3 +-- ext/web/03_abort_signal.js | 2 +- ext/web/04_global_interfaces.js | 2 +- ext/web/05_base64.js | 3 +-- ext/web/06_streams.js | 4 +--- ext/web/08_text_encoding.js | 3 +-- ext/web/09_file.js | 3 +-- ext/web/10_filereader.js | 3 +-- ext/web/12_location.js | 2 +- ext/web/13_message_port.js | 3 +-- ext/web/14_compression.js | 3 +-- ext/web/15_performance.js | 2 +- ext/webidl/00_webidl.js | 3 +-- ext/websocket/01_websocket.js | 3 +-- ext/websocket/02_websocketstream.js | 3 +-- ext/webstorage/01_webstorage.js | 3 +-- runtime/js/01_errors.js | 3 +-- runtime/js/06_util.js | 3 +-- runtime/js/10_permissions.js | 4 +--- runtime/js/11_workers.js | 3 +-- runtime/js/30_os.js | 4 +--- runtime/js/40_fs_events.js | 3 +-- runtime/js/40_http.js | 2 +- runtime/js/40_process.js | 3 +-- runtime/js/40_signals.js | 3 +-- runtime/js/40_tty.js | 3 +-- runtime/js/41_prompt.js | 3 +-- runtime/js/90_deno_ns.js | 2 +- runtime/js/98_global_scope.js | 3 +-- runtime/js/99_main.js | 4 +--- 71 files changed, 72 insertions(+), 126 deletions(-) diff --git a/ext/broadcast_channel/01_broadcast_channel.js b/ext/broadcast_channel/01_broadcast_channel.js index a482a2dce7..6ee857474a 100644 --- a/ext/broadcast_channel/01_broadcast_channel.js +++ b/ext/broadcast_channel/01_broadcast_channel.js @@ -2,7 +2,7 @@ /// -const core = globalThis.Deno.core; +import { core, primordials } from "ext:core/mod.js"; const ops = core.ops; import * as webidl from "ext:deno_webidl/00_webidl.js"; import { createFilteredInspectProxy } from "ext:deno_console/01_console.js"; @@ -13,7 +13,6 @@ import { setTarget, } from "ext:deno_web/02_event.js"; import DOMException from "ext:deno_web/01_dom_exception.js"; -const primordials = globalThis.__bootstrap.primordials; const { ArrayPrototypeIndexOf, ArrayPrototypePush, diff --git a/ext/cache/01_cache.js b/ext/cache/01_cache.js index d3514a3f2f..ef5db61ccf 100644 --- a/ext/cache/01_cache.js +++ b/ext/cache/01_cache.js @@ -1,7 +1,6 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -const core = globalThis.Deno.core; +import { core, primordials } from "ext:core/mod.js"; import * as webidl from "ext:deno_webidl/00_webidl.js"; -const primordials = globalThis.__bootstrap.primordials; const { ArrayPrototypePush, ObjectPrototypeIsPrototypeOf, diff --git a/ext/console/01_console.js b/ext/console/01_console.js index 4f0ff63629..27203789f9 100644 --- a/ext/console/01_console.js +++ b/ext/console/01_console.js @@ -2,9 +2,7 @@ /// -const core = globalThis.Deno.core; -const internals = globalThis.__bootstrap.internals; -const primordials = globalThis.__bootstrap.primordials; +import { core, internals, primordials } from "ext:core/mod.js"; const { AggregateErrorPrototype, Array, diff --git a/ext/crypto/00_crypto.js b/ext/crypto/00_crypto.js index 58cbde7167..f20de7a409 100644 --- a/ext/crypto/00_crypto.js +++ b/ext/crypto/00_crypto.js @@ -6,9 +6,8 @@ /// /// -const core = globalThis.Deno.core; +import { core, primordials } from "ext:core/mod.js"; const ops = core.ops; -const primordials = globalThis.__bootstrap.primordials; import * as webidl from "ext:deno_webidl/00_webidl.js"; import { createFilteredInspectProxy } from "ext:deno_console/01_console.js"; import DOMException from "ext:deno_web/01_dom_exception.js"; diff --git a/ext/fetch/20_headers.js b/ext/fetch/20_headers.js index d03751d08b..4b95595ece 100644 --- a/ext/fetch/20_headers.js +++ b/ext/fetch/20_headers.js @@ -19,7 +19,7 @@ import { HTTP_TOKEN_CODE_POINT_RE, httpTrim, } from "ext:deno_web/00_infra.js"; -const primordials = globalThis.__bootstrap.primordials; +import { primordials } from "ext:core/mod.js"; const { ArrayIsArray, ArrayPrototypePush, diff --git a/ext/fetch/21_formdata.js b/ext/fetch/21_formdata.js index 12ce2bb587..0d9990fcd3 100644 --- a/ext/fetch/21_formdata.js +++ b/ext/fetch/21_formdata.js @@ -9,7 +9,7 @@ /// /// -const core = globalThis.Deno.core; +import { core, primordials } from "ext:core/mod.js"; import * as webidl from "ext:deno_webidl/00_webidl.js"; import { Blob, @@ -17,7 +17,6 @@ import { File, FilePrototype, } from "ext:deno_web/09_file.js"; -const primordials = globalThis.__bootstrap.primordials; const { ArrayPrototypePush, ArrayPrototypeSlice, diff --git a/ext/fetch/22_body.js b/ext/fetch/22_body.js index 644b9f76f8..54edb79997 100644 --- a/ext/fetch/22_body.js +++ b/ext/fetch/22_body.js @@ -11,7 +11,7 @@ /// /// -const core = globalThis.Deno.core; +import { core, primordials } from "ext:core/mod.js"; import * as webidl from "ext:deno_webidl/00_webidl.js"; import { parseUrlEncoded, @@ -36,7 +36,6 @@ import { readableStreamTee, readableStreamThrowIfErrored, } from "ext:deno_web/06_streams.js"; -const primordials = globalThis.__bootstrap.primordials; const { ArrayBufferPrototype, ArrayBufferIsView, diff --git a/ext/fetch/22_http_client.js b/ext/fetch/22_http_client.js index 45f5de80ea..25c3cba97f 100644 --- a/ext/fetch/22_http_client.js +++ b/ext/fetch/22_http_client.js @@ -10,7 +10,7 @@ /// /// -const core = globalThis.Deno.core; +import { core } from "ext:core/mod.js"; const ops = core.ops; import { SymbolDispose } from "ext:deno_web/00_infra.js"; diff --git a/ext/fetch/23_request.js b/ext/fetch/23_request.js index b78ed07be5..512355766e 100644 --- a/ext/fetch/23_request.js +++ b/ext/fetch/23_request.js @@ -30,7 +30,7 @@ import { } from "ext:deno_fetch/20_headers.js"; import { HttpClientPrototype } from "ext:deno_fetch/22_http_client.js"; import * as abortSignal from "ext:deno_web/03_abort_signal.js"; -const primordials = globalThis.__bootstrap.primordials; +import { primordials } from "ext:core/mod.js"; const { ArrayPrototypeMap, ArrayPrototypeSlice, diff --git a/ext/fetch/23_response.js b/ext/fetch/23_response.js index 0b37c12292..e5ec8fedfa 100644 --- a/ext/fetch/23_response.js +++ b/ext/fetch/23_response.js @@ -10,7 +10,7 @@ /// /// -const core = globalThis.Deno.core; +import { core, primordials } from "ext:core/mod.js"; import * as webidl from "ext:deno_webidl/00_webidl.js"; import { createFilteredInspectProxy } from "ext:deno_console/01_console.js"; import { @@ -30,7 +30,6 @@ import { headerListFromHeaders, headersFromHeaderList, } from "ext:deno_fetch/20_headers.js"; -const primordials = globalThis.__bootstrap.primordials; const { ArrayPrototypeMap, ArrayPrototypePush, diff --git a/ext/fetch/26_fetch.js b/ext/fetch/26_fetch.js index 8a71d9bcf0..b70d6d8733 100644 --- a/ext/fetch/26_fetch.js +++ b/ext/fetch/26_fetch.js @@ -10,7 +10,7 @@ /// /// -const core = globalThis.Deno.core; +import { core, primordials } from "ext:core/mod.js"; const ops = core.ops; import * as webidl from "ext:deno_webidl/00_webidl.js"; import { byteLowerCase } from "ext:deno_web/00_infra.js"; @@ -32,7 +32,6 @@ import { toInnerResponse, } from "ext:deno_fetch/23_response.js"; import * as abortSignal from "ext:deno_web/03_abort_signal.js"; -const primordials = globalThis.__bootstrap.primordials; const { ArrayPrototypePush, ArrayPrototypeSplice, diff --git a/ext/fetch/27_eventsource.js b/ext/fetch/27_eventsource.js index 1db65d748d..b8ceffb167 100644 --- a/ext/fetch/27_eventsource.js +++ b/ext/fetch/27_eventsource.js @@ -2,7 +2,7 @@ /// -const core = globalThis.Deno.core; +import { core, primordials } from "ext:core/mod.js"; import * as webidl from "ext:deno_webidl/00_webidl.js"; import { createFilteredInspectProxy } from "ext:deno_console/01_console.js"; @@ -19,7 +19,6 @@ import { getLocationHref } from "ext:deno_web/12_location.js"; import { newInnerRequest } from "ext:deno_fetch/23_request.js"; import { mainFetch } from "ext:deno_fetch/26_fetch.js"; -const primordials = globalThis.__bootstrap.primordials; const { ArrayPrototypeFind, Number, diff --git a/ext/ffi/00_ffi.js b/ext/ffi/00_ffi.js index 233935be94..ef9123442e 100644 --- a/ext/ffi/00_ffi.js +++ b/ext/ffi/00_ffi.js @@ -1,8 +1,7 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -const core = globalThis.Deno.core; +import { core, primordials } from "ext:core/mod.js"; const ops = core.ops; -const primordials = globalThis.__bootstrap.primordials; const { ArrayBufferIsView, ArrayBufferPrototype, diff --git a/ext/fs/30_fs.js b/ext/fs/30_fs.js index 8307032309..29c6c4aace 100644 --- a/ext/fs/30_fs.js +++ b/ext/fs/30_fs.js @@ -1,6 +1,6 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -const core = globalThis.Deno.core; +import { core, primordials } from "ext:core/mod.js"; const ops = core.ops; const { op_fs_chmod_async, @@ -9,7 +9,6 @@ const { op_fs_link_async, op_fs_flock_async, } = Deno.core.ensureFastOps(); -const primordials = globalThis.__bootstrap.primordials; const { ArrayPrototypeFilter, Date, diff --git a/ext/http/00_serve.js b/ext/http/00_serve.js index adb03a22c7..beac522895 100644 --- a/ext/http/00_serve.js +++ b/ext/http/00_serve.js @@ -1,8 +1,6 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -const core = globalThis.Deno.core; -const primordials = globalThis.__bootstrap.primordials; -const internals = globalThis.__bootstrap.internals; +import { core, internals, primordials } from "ext:core/mod.js"; const { BadResourcePrototype, InterruptedPrototype } = core; import { InnerBody } from "ext:deno_fetch/22_body.js"; diff --git a/ext/http/01_http.js b/ext/http/01_http.js index cfe0f710e8..acaea5e7c0 100644 --- a/ext/http/01_http.js +++ b/ext/http/01_http.js @@ -1,8 +1,6 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -const core = globalThis.Deno.core; -const internals = globalThis.__bootstrap.internals; -const primordials = globalThis.__bootstrap.primordials; +import { core, internals, primordials } from "ext:core/mod.js"; const { BadResourcePrototype, InterruptedPrototype, ops } = core; const { op_http_write } = Deno.core.ensureFastOps(); import * as webidl from "ext:deno_webidl/00_webidl.js"; diff --git a/ext/io/12_io.js b/ext/io/12_io.js index e1d72ffb54..c38ee12b0e 100644 --- a/ext/io/12_io.js +++ b/ext/io/12_io.js @@ -4,9 +4,8 @@ // Documentation liberally lifted from them too. // Thank you! We love Go! <3 -const core = globalThis.Deno.core; +import { core, primordials } from "ext:core/mod.js"; const ops = core.ops; -const primordials = globalThis.__bootstrap.primordials; import { readableStreamForRid, writableStreamForRid, diff --git a/ext/net/01_net.js b/ext/net/01_net.js index b4b8ca2189..c81ca61c55 100644 --- a/ext/net/01_net.js +++ b/ext/net/01_net.js @@ -1,6 +1,6 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -const core = globalThis.Deno.core; +import { core, primordials } from "ext:core/mod.js"; const { BadResourcePrototype, InterruptedPrototype, ops } = core; import { readableStreamForRidUnrefable, @@ -11,7 +11,6 @@ import { import * as abortSignal from "ext:deno_web/03_abort_signal.js"; import { SymbolDispose } from "ext:deno_web/00_infra.js"; -const primordials = globalThis.__bootstrap.primordials; const { Error, Number, diff --git a/ext/net/02_tls.js b/ext/net/02_tls.js index 4be2f08e0e..a73e3ef047 100644 --- a/ext/net/02_tls.js +++ b/ext/net/02_tls.js @@ -1,9 +1,8 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -const core = globalThis.Deno.core; +import { core, primordials } from "ext:core/mod.js"; const ops = core.ops; import { Conn, Listener } from "ext:deno_net/01_net.js"; -const primordials = globalThis.__bootstrap.primordials; const { Number, TypeError } = primordials; function opStartTls(args) { diff --git a/ext/node/polyfills/01_require.js b/ext/node/polyfills/01_require.js index eb845f2375..c6b84543ac 100644 --- a/ext/node/polyfills/01_require.js +++ b/ext/node/polyfills/01_require.js @@ -2,10 +2,8 @@ // deno-lint-ignore-file -const core = globalThis.Deno.core; +import { core, internals, primordials } from "ext:core/mod.js"; const ops = core.ops; -const internals = globalThis.__bootstrap.internals; -const primordials = globalThis.__bootstrap.primordials; const { ArrayIsArray, ArrayPrototypeIncludes, diff --git a/ext/node/polyfills/_process/process.ts b/ext/node/polyfills/_process/process.ts index 062effe071..b153c8e196 100644 --- a/ext/node/polyfills/_process/process.ts +++ b/ext/node/polyfills/_process/process.ts @@ -7,7 +7,7 @@ // The following are all the process APIs that don't depend on the stream module // They have to be split this way to prevent a circular dependency -const core = globalThis.Deno.core; +import { core } from "ext:core/mod.js"; import { nextTick as _nextTick } from "ext:deno_node/_next_tick.ts"; import { _exiting } from "ext:deno_node/_process/exiting.ts"; import * as fs from "ext:deno_fs/30_fs.js"; diff --git a/ext/node/polyfills/http2.ts b/ext/node/polyfills/http2.ts index afd9a22bca..bab607b80c 100644 --- a/ext/node/polyfills/http2.ts +++ b/ext/node/polyfills/http2.ts @@ -4,7 +4,7 @@ // TODO(petamoriken): enable prefer-primordials for node polyfills // deno-lint-ignore-file prefer-primordials -const core = globalThis.Deno.core; +import { core } from "ext:core/mod.js"; import { notImplemented, warnNotImplemented } from "ext:deno_node/_utils.ts"; import { EventEmitter } from "node:events"; import { Buffer } from "node:buffer"; diff --git a/ext/node/polyfills/internal/crypto/_randomInt.ts b/ext/node/polyfills/internal/crypto/_randomInt.ts index 9f161668d4..e5ab41ee7c 100644 --- a/ext/node/polyfills/internal/crypto/_randomInt.ts +++ b/ext/node/polyfills/internal/crypto/_randomInt.ts @@ -3,7 +3,8 @@ // TODO(petamoriken): enable prefer-primordials for node polyfills // deno-lint-ignore-file prefer-primordials -const ops = globalThis.Deno.core.ops; +import { core } from "ext:core/mod.js"; +const ops = core.ops; export default function randomInt(max: number): number; export default function randomInt(min: number, max: number): number; diff --git a/ext/node/polyfills/internal/crypto/random.ts b/ext/node/polyfills/internal/crypto/random.ts index e8776cdf0b..4a4b682743 100644 --- a/ext/node/polyfills/internal/crypto/random.ts +++ b/ext/node/polyfills/internal/crypto/random.ts @@ -32,7 +32,7 @@ export { } from "ext:deno_node/internal/crypto/_randomFill.mjs"; export { default as randomInt } from "ext:deno_node/internal/crypto/_randomInt.ts"; -const primordials = globalThis.__bootstrap.primordials; +import { primordials } from "ext:core/mod.js"; const { StringPrototypePadStart, StringPrototypeToString } = primordials; const { core } = globalThis.__bootstrap; diff --git a/ext/node/polyfills/internal/process/report.ts b/ext/node/polyfills/internal/process/report.ts index 7d178626c9..cd77eeda50 100644 --- a/ext/node/polyfills/internal/process/report.ts +++ b/ext/node/polyfills/internal/process/report.ts @@ -3,7 +3,7 @@ import { arch, versions } from "ext:deno_node/_process/process.ts"; import { cpus, hostname, networkInterfaces } from "node:os"; -const primordials = globalThis.__bootstrap.primordials; +import { primordials } from "ext:core/mod.js"; const { Error, StringPrototypeToUpperCase, diff --git a/ext/node/polyfills/internal/timers.mjs b/ext/node/polyfills/internal/timers.mjs index 3dc5073c63..92fb51d574 100644 --- a/ext/node/polyfills/internal/timers.mjs +++ b/ext/node/polyfills/internal/timers.mjs @@ -4,7 +4,7 @@ // TODO(petamoriken): enable prefer-primordials for node polyfills // deno-lint-ignore-file prefer-primordials -const primordials = globalThis.__bootstrap.primordials; +import { primordials } from "ext:core/mod.js"; const { MapPrototypeDelete, MapPrototypeSet, diff --git a/ext/node/polyfills/internal/util/parse_args/parse_args.js b/ext/node/polyfills/internal/util/parse_args/parse_args.js index 7980396203..910eef4365 100644 --- a/ext/node/polyfills/internal/util/parse_args/parse_args.js +++ b/ext/node/polyfills/internal/util/parse_args/parse_args.js @@ -1,7 +1,7 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. // Copyright Joyent and Node contributors. All rights reserved. MIT license. -const primordials = globalThis.__bootstrap.primordials; +import { primordials } from "ext:core/mod.js"; const { ArrayPrototypeForEach, ArrayPrototypeIncludes, diff --git a/ext/node/polyfills/internal/util/parse_args/utils.js b/ext/node/polyfills/internal/util/parse_args/utils.js index d101dd3fd5..8cbbbc6c22 100644 --- a/ext/node/polyfills/internal/util/parse_args/utils.js +++ b/ext/node/polyfills/internal/util/parse_args/utils.js @@ -1,7 +1,7 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. // Copyright Joyent and Node contributors. All rights reserved. MIT license. -const primordials = globalThis.__bootstrap.primordials; +import { primordials } from "ext:core/mod.js"; const { ArrayPrototypeFind, ObjectEntries, diff --git a/ext/node/polyfills/internal/validators.mjs b/ext/node/polyfills/internal/validators.mjs index b5b539088a..e728d40ad1 100644 --- a/ext/node/polyfills/internal/validators.mjs +++ b/ext/node/polyfills/internal/validators.mjs @@ -9,7 +9,7 @@ import { hideStackFrames } from "ext:deno_node/internal/hide_stack_frames.ts"; import { isArrayBufferView } from "ext:deno_node/internal/util/types.ts"; import { normalizeEncoding } from "ext:deno_node/internal/normalize_encoding.mjs"; -const primordials = globalThis.__bootstrap.primordials; +import { primordials } from "ext:core/mod.js"; const { ArrayPrototypeIncludes, ArrayPrototypeJoin, diff --git a/ext/node/polyfills/internal_binding/stream_wrap.ts b/ext/node/polyfills/internal_binding/stream_wrap.ts index 3e4d0be6ad..f381b21ce6 100644 --- a/ext/node/polyfills/internal_binding/stream_wrap.ts +++ b/ext/node/polyfills/internal_binding/stream_wrap.ts @@ -40,7 +40,7 @@ import { } from "ext:deno_node/internal_binding/async_wrap.ts"; import { codeMap } from "ext:deno_node/internal_binding/uv.ts"; -const core = globalThis.Deno.core; +import { core } from "ext:core/mod.js"; const { ops } = core; interface Reader { diff --git a/ext/node/polyfills/internal_binding/udp_wrap.ts b/ext/node/polyfills/internal_binding/udp_wrap.ts index d8b0bf0593..98ca5bb3a5 100644 --- a/ext/node/polyfills/internal_binding/udp_wrap.ts +++ b/ext/node/polyfills/internal_binding/udp_wrap.ts @@ -23,7 +23,7 @@ // TODO(petamoriken): enable prefer-primordials for node polyfills // deno-lint-ignore-file prefer-primordials -const core = globalThis.Deno.core; +import { core } from "ext:core/mod.js"; const ops = core.ops; import { AsyncWrap, diff --git a/ext/node/polyfills/internal_binding/util.ts b/ext/node/polyfills/internal_binding/util.ts index 59f1246fc4..302b2d57ce 100644 --- a/ext/node/polyfills/internal_binding/util.ts +++ b/ext/node/polyfills/internal_binding/util.ts @@ -28,7 +28,7 @@ // TODO(petamoriken): enable prefer-primordials for node polyfills // deno-lint-ignore-file prefer-primordials -const core = globalThis.Deno.core; +import { core } from "ext:core/mod.js"; const ops = core.ops; const handleTypes = ["TCP", "TTY", "UDP", "FILE", "PIPE", "UNKNOWN"]; diff --git a/ext/node/polyfills/timers.ts b/ext/node/polyfills/timers.ts index 2bedbe65bf..a9953a1e76 100644 --- a/ext/node/polyfills/timers.ts +++ b/ext/node/polyfills/timers.ts @@ -3,7 +3,7 @@ // TODO(petamoriken): enable prefer-primordials for node polyfills // deno-lint-ignore-file prefer-primordials -const primordials = globalThis.__bootstrap.primordials; +import { primordials } from "ext:core/mod.js"; const { MapPrototypeGet, MapPrototypeDelete, diff --git a/ext/node/polyfills/util.ts b/ext/node/polyfills/util.ts index 68c9626c9c..a77167253f 100644 --- a/ext/node/polyfills/util.ts +++ b/ext/node/polyfills/util.ts @@ -16,7 +16,7 @@ import { isDeepStrictEqual } from "ext:deno_node/internal/util/comparisons.ts"; import process from "node:process"; import { validateString } from "ext:deno_node/internal/validators.mjs"; import { parseArgs } from "ext:deno_node/internal/util/parse_args/parse_args.js"; -const primordials = globalThis.__bootstrap.primordials; +import { primordials } from "ext:core/mod.js"; const { ArrayIsArray, ArrayPrototypeJoin, diff --git a/ext/url/00_url.js b/ext/url/00_url.js index d0ec376d64..899a86aa06 100644 --- a/ext/url/00_url.js +++ b/ext/url/00_url.js @@ -5,11 +5,10 @@ /// /// -const core = globalThis.Deno.core; +import { core, primordials } from "ext:core/mod.js"; const ops = core.ops; import * as webidl from "ext:deno_webidl/00_webidl.js"; import { createFilteredInspectProxy } from "ext:deno_console/01_console.js"; -const primordials = globalThis.__bootstrap.primordials; const { ArrayIsArray, ArrayPrototypeMap, diff --git a/ext/url/01_urlpattern.js b/ext/url/01_urlpattern.js index 71962d4051..e0f63b7072 100644 --- a/ext/url/01_urlpattern.js +++ b/ext/url/01_urlpattern.js @@ -7,11 +7,10 @@ /// /// -const core = globalThis.Deno.core; +import { core, primordials } from "ext:core/mod.js"; const ops = core.ops; import * as webidl from "ext:deno_webidl/00_webidl.js"; import { createFilteredInspectProxy } from "ext:deno_console/01_console.js"; -const primordials = globalThis.__bootstrap.primordials; const { ArrayPrototypePop, RegExpPrototypeExec, diff --git a/ext/web/00_infra.js b/ext/web/00_infra.js index 4410816041..91bacb9e90 100644 --- a/ext/web/00_infra.js +++ b/ext/web/00_infra.js @@ -6,10 +6,8 @@ /// /// -const core = globalThis.Deno.core; -const internals = globalThis.__bootstrap.internals; +import { core, internals, primordials } from "ext:core/mod.js"; const ops = core.ops; -const primordials = globalThis.__bootstrap.primordials; const { ArrayPrototypeJoin, ArrayPrototypeMap, diff --git a/ext/web/01_dom_exception.js b/ext/web/01_dom_exception.js index 941b057e46..fcf96e77a4 100644 --- a/ext/web/01_dom_exception.js +++ b/ext/web/01_dom_exception.js @@ -7,7 +7,7 @@ /// /// -const primordials = globalThis.__bootstrap.primordials; +import { primordials } from "ext:core/mod.js"; const { ArrayPrototypeSlice, Error, diff --git a/ext/web/01_mimesniff.js b/ext/web/01_mimesniff.js index 7d402e0801..66cc41e2ca 100644 --- a/ext/web/01_mimesniff.js +++ b/ext/web/01_mimesniff.js @@ -6,7 +6,7 @@ /// /// -const primordials = globalThis.__bootstrap.primordials; +import { primordials } from "ext:core/mod.js"; const { ArrayPrototypeIncludes, MapPrototypeGet, diff --git a/ext/web/02_event.js b/ext/web/02_event.js index f0c24f3537..a171a19916 100644 --- a/ext/web/02_event.js +++ b/ext/web/02_event.js @@ -5,11 +5,10 @@ // parts still exists. This means you will observe a lot of strange structures // and impossible logic branches based on what Deno currently supports. -const core = globalThis.Deno.core; +import { core, primordials } from "ext:core/mod.js"; import * as webidl from "ext:deno_webidl/00_webidl.js"; import DOMException from "ext:deno_web/01_dom_exception.js"; import { createFilteredInspectProxy } from "ext:deno_console/01_console.js"; -const primordials = globalThis.__bootstrap.primordials; const { ArrayPrototypeFilter, ArrayPrototypeIncludes, diff --git a/ext/web/02_structured_clone.js b/ext/web/02_structured_clone.js index b0c7559c01..53e1466168 100644 --- a/ext/web/02_structured_clone.js +++ b/ext/web/02_structured_clone.js @@ -6,9 +6,8 @@ /// /// -const core = globalThis.Deno.core; +import { core, primordials } from "ext:core/mod.js"; import DOMException from "ext:deno_web/01_dom_exception.js"; -const primordials = globalThis.__bootstrap.primordials; const { ArrayBuffer, ArrayBufferPrototype, diff --git a/ext/web/02_timers.js b/ext/web/02_timers.js index ee974345b3..27a9fcbdef 100644 --- a/ext/web/02_timers.js +++ b/ext/web/02_timers.js @@ -1,8 +1,7 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -const core = globalThis.Deno.core; +import { core, primordials } from "ext:core/mod.js"; const ops = core.ops; -const primordials = globalThis.__bootstrap.primordials; const { ArrayPrototypePush, ArrayPrototypeShift, diff --git a/ext/web/03_abort_signal.js b/ext/web/03_abort_signal.js index f534ec04f3..acde8b42e3 100644 --- a/ext/web/03_abort_signal.js +++ b/ext/web/03_abort_signal.js @@ -13,7 +13,7 @@ import { listenerCount, setIsTrusted, } from "ext:deno_web/02_event.js"; -const primordials = globalThis.__bootstrap.primordials; +import { primordials } from "ext:core/mod.js"; const { ArrayPrototypeEvery, ArrayPrototypePush, diff --git a/ext/web/04_global_interfaces.js b/ext/web/04_global_interfaces.js index 375c981986..c68a5d1c30 100644 --- a/ext/web/04_global_interfaces.js +++ b/ext/web/04_global_interfaces.js @@ -4,7 +4,7 @@ /// import { EventTarget } from "ext:deno_web/02_event.js"; -const primordials = globalThis.__bootstrap.primordials; +import { primordials } from "ext:core/mod.js"; const { Symbol, SymbolToStringTag, diff --git a/ext/web/05_base64.js b/ext/web/05_base64.js index 3971b2e585..65792bd27b 100644 --- a/ext/web/05_base64.js +++ b/ext/web/05_base64.js @@ -6,11 +6,10 @@ /// /// -const core = globalThis.Deno.core; +import { core, primordials } from "ext:core/mod.js"; const ops = core.ops; import * as webidl from "ext:deno_webidl/00_webidl.js"; import DOMException from "ext:deno_web/01_dom_exception.js"; -const primordials = globalThis.__bootstrap.primordials; const { ObjectPrototypeIsPrototypeOf, TypeErrorPrototype, diff --git a/ext/web/06_streams.js b/ext/web/06_streams.js index 9fc15d1ad1..1df3753282 100644 --- a/ext/web/06_streams.js +++ b/ext/web/06_streams.js @@ -6,8 +6,7 @@ /// /// -const core = globalThis.Deno.core; -const internals = globalThis.__bootstrap.internals; +import { core, internals, primordials } from "ext:core/mod.js"; const { op_arraybuffer_was_detached, op_transfer_arraybuffer, @@ -29,7 +28,6 @@ import { remove, signalAbort, } from "ext:deno_web/03_abort_signal.js"; -const primordials = globalThis.__bootstrap.primordials; const { ArrayBuffer, ArrayBufferIsView, diff --git a/ext/web/08_text_encoding.js b/ext/web/08_text_encoding.js index 81a3425edf..e942fadea9 100644 --- a/ext/web/08_text_encoding.js +++ b/ext/web/08_text_encoding.js @@ -9,11 +9,10 @@ /// /// -const core = globalThis.Deno.core; +import { core, primordials } from "ext:core/mod.js"; const ops = core.ops; import * as webidl from "ext:deno_webidl/00_webidl.js"; import { createFilteredInspectProxy } from "ext:deno_console/01_console.js"; -const primordials = globalThis.__bootstrap.primordials; const { DataViewPrototypeGetBuffer, DataViewPrototypeGetByteLength, diff --git a/ext/web/09_file.js b/ext/web/09_file.js index 7ee029d8a5..6e91e24921 100644 --- a/ext/web/09_file.js +++ b/ext/web/09_file.js @@ -10,12 +10,11 @@ /// /// -const core = globalThis.Deno.core; +import { core, primordials } from "ext:core/mod.js"; const ops = core.ops; import * as webidl from "ext:deno_webidl/00_webidl.js"; import { ReadableStream } from "ext:deno_web/06_streams.js"; import { URL } from "ext:deno_url/00_url.js"; -const primordials = globalThis.__bootstrap.primordials; const { ArrayBufferPrototype, ArrayBufferPrototypeSlice, diff --git a/ext/web/10_filereader.js b/ext/web/10_filereader.js index 07a5a38ec6..4370868613 100644 --- a/ext/web/10_filereader.js +++ b/ext/web/10_filereader.js @@ -10,11 +10,10 @@ /// /// -const core = globalThis.Deno.core; +import { core, primordials } from "ext:core/mod.js"; const ops = core.ops; import * as webidl from "ext:deno_webidl/00_webidl.js"; import { createFilteredInspectProxy } from "ext:deno_console/01_console.js"; -const primordials = globalThis.__bootstrap.primordials; import { forgivingBase64Encode } from "ext:deno_web/00_infra.js"; import { EventTarget, ProgressEvent } from "ext:deno_web/02_event.js"; import { decode, TextDecoder } from "ext:deno_web/08_text_encoding.js"; diff --git a/ext/web/12_location.js b/ext/web/12_location.js index f469e9093e..ed44d7c518 100644 --- a/ext/web/12_location.js +++ b/ext/web/12_location.js @@ -4,7 +4,7 @@ import { URL } from "ext:deno_url/00_url.js"; import DOMException from "ext:deno_web/01_dom_exception.js"; -const primordials = globalThis.__bootstrap.primordials; +import { primordials } from "ext:core/mod.js"; const { Error, ObjectDefineProperties, diff --git a/ext/web/13_message_port.js b/ext/web/13_message_port.js index 2a0d864ba2..c1ba3f4c4b 100644 --- a/ext/web/13_message_port.js +++ b/ext/web/13_message_port.js @@ -6,7 +6,7 @@ /// /// -const core = globalThis.Deno.core; +import { core, primordials } from "ext:core/mod.js"; const { InterruptedPrototype, ops } = core; import * as webidl from "ext:deno_webidl/00_webidl.js"; import { createFilteredInspectProxy } from "ext:deno_console/01_console.js"; @@ -18,7 +18,6 @@ import { setIsTrusted, } from "ext:deno_web/02_event.js"; import DOMException from "ext:deno_web/01_dom_exception.js"; -const primordials = globalThis.__bootstrap.primordials; const { ArrayBufferPrototype, ArrayBufferPrototypeGetByteLength, diff --git a/ext/web/14_compression.js b/ext/web/14_compression.js index 0563861c29..d992c33f20 100644 --- a/ext/web/14_compression.js +++ b/ext/web/14_compression.js @@ -5,9 +5,8 @@ /// /// -const core = globalThis.Deno.core; +import { core, primordials } from "ext:core/mod.js"; const ops = core.ops; -const primordials = globalThis.__bootstrap.primordials; const { SymbolFor, ObjectPrototypeIsPrototypeOf, diff --git a/ext/web/15_performance.js b/ext/web/15_performance.js index 4527ff00cc..4a5b42ef62 100644 --- a/ext/web/15_performance.js +++ b/ext/web/15_performance.js @@ -1,6 +1,6 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -const primordials = globalThis.__bootstrap.primordials; +import { primordials } from "ext:core/mod.js"; const { ArrayPrototypeFilter, ArrayPrototypeFind, diff --git a/ext/webidl/00_webidl.js b/ext/webidl/00_webidl.js index 956def267c..30c515e24e 100644 --- a/ext/webidl/00_webidl.js +++ b/ext/webidl/00_webidl.js @@ -6,8 +6,7 @@ /// -const core = globalThis.Deno.core; -const primordials = globalThis.__bootstrap.primordials; +import { core, primordials } from "ext:core/mod.js"; const { ArrayBufferPrototype, ArrayBufferIsView, diff --git a/ext/websocket/01_websocket.js b/ext/websocket/01_websocket.js index a4e6b71a37..477f93b93d 100644 --- a/ext/websocket/01_websocket.js +++ b/ext/websocket/01_websocket.js @@ -2,7 +2,7 @@ /// -const core = globalThis.Deno.core; +import { core, primordials } from "ext:core/mod.js"; import { URL } from "ext:deno_url/00_url.js"; import * as webidl from "ext:deno_webidl/00_webidl.js"; import { createFilteredInspectProxy } from "ext:deno_console/01_console.js"; @@ -20,7 +20,6 @@ import { } from "ext:deno_web/02_event.js"; import { Blob, BlobPrototype } from "ext:deno_web/09_file.js"; import { getLocationHref } from "ext:deno_web/12_location.js"; -const primordials = globalThis.__bootstrap.primordials; const { ArrayBufferPrototype, ArrayBufferIsView, diff --git a/ext/websocket/02_websocketstream.js b/ext/websocket/02_websocketstream.js index ff24a72afe..16346e73b8 100644 --- a/ext/websocket/02_websocketstream.js +++ b/ext/websocket/02_websocketstream.js @@ -2,7 +2,7 @@ /// -const core = globalThis.Deno.core; +import { core, primordials } from "ext:core/mod.js"; const ops = core.ops; import * as webidl from "ext:deno_webidl/00_webidl.js"; import { createFilteredInspectProxy } from "ext:deno_console/01_console.js"; @@ -14,7 +14,6 @@ import { headerListFromHeaders, headersFromHeaderList, } from "ext:deno_fetch/20_headers.js"; -const primordials = globalThis.__bootstrap.primordials; const { ArrayPrototypeJoin, ArrayPrototypeMap, diff --git a/ext/webstorage/01_webstorage.js b/ext/webstorage/01_webstorage.js index 4e7c77aa0e..c58e7e6ba3 100644 --- a/ext/webstorage/01_webstorage.js +++ b/ext/webstorage/01_webstorage.js @@ -2,10 +2,9 @@ /// -const core = globalThis.Deno.core; +import { core, primordials } from "ext:core/mod.js"; const ops = core.ops; import * as webidl from "ext:deno_webidl/00_webidl.js"; -const primordials = globalThis.__bootstrap.primordials; const { Symbol, SymbolFor, diff --git a/runtime/js/01_errors.js b/runtime/js/01_errors.js index 0c54f65813..fb88f735b1 100644 --- a/runtime/js/01_errors.js +++ b/runtime/js/01_errors.js @@ -1,8 +1,7 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -const core = globalThis.Deno.core; +import { core, primordials } from "ext:core/mod.js"; const { BadResource, Interrupted } = core; -const primordials = globalThis.__bootstrap.primordials; const { Error } = primordials; class NotFound extends Error { diff --git a/runtime/js/06_util.js b/runtime/js/06_util.js index c9fd4befe3..838b1d18c7 100644 --- a/runtime/js/06_util.js +++ b/runtime/js/06_util.js @@ -1,8 +1,7 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -const core = globalThis.Deno.core; +import { core, primordials } from "ext:core/mod.js"; const ops = core.ops; -const primordials = globalThis.__bootstrap.primordials; const { Promise, SafeArrayIterator, diff --git a/runtime/js/10_permissions.js b/runtime/js/10_permissions.js index 075291a1b6..2d3295f854 100644 --- a/runtime/js/10_permissions.js +++ b/runtime/js/10_permissions.js @@ -1,11 +1,9 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -const core = globalThis.Deno.core; +import { core, internals, primordials } from "ext:core/mod.js"; const ops = core.ops; import { pathFromURL } from "ext:deno_web/00_infra.js"; import { Event, EventTarget } from "ext:deno_web/02_event.js"; -const internals = globalThis.__bootstrap.internals; -const primordials = globalThis.__bootstrap.primordials; const { ArrayIsArray, ArrayPrototypeIncludes, diff --git a/runtime/js/11_workers.js b/runtime/js/11_workers.js index bd0d1afc89..60ea94bf4a 100644 --- a/runtime/js/11_workers.js +++ b/runtime/js/11_workers.js @@ -1,8 +1,7 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -const core = globalThis.Deno.core; +import { core, primordials } from "ext:core/mod.js"; const ops = core.ops; -const primordials = globalThis.__bootstrap.primordials; const { ArrayPrototypeFilter, Error, diff --git a/runtime/js/30_os.js b/runtime/js/30_os.js index 5834490830..5bc96e54b2 100644 --- a/runtime/js/30_os.js +++ b/runtime/js/30_os.js @@ -1,10 +1,8 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -const core = globalThis.Deno.core; +import { core, internals, primordials } from "ext:core/mod.js"; const ops = core.ops; -const internals = globalThis.__bootstrap.internals; import { Event, EventTarget } from "ext:deno_web/02_event.js"; -const primordials = globalThis.__bootstrap.primordials; const { Error, FunctionPrototypeBind, diff --git a/runtime/js/40_fs_events.js b/runtime/js/40_fs_events.js index b10f6fd10e..c9d0f1feb6 100644 --- a/runtime/js/40_fs_events.js +++ b/runtime/js/40_fs_events.js @@ -1,8 +1,7 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -const core = globalThis.Deno.core; +import { core, primordials } from "ext:core/mod.js"; const { BadResourcePrototype, InterruptedPrototype, ops } = core; -const primordials = globalThis.__bootstrap.primordials; const { ArrayIsArray, ObjectPrototypeIsPrototypeOf, diff --git a/runtime/js/40_http.js b/runtime/js/40_http.js index 5ee2193604..223c7a3e66 100644 --- a/runtime/js/40_http.js +++ b/runtime/js/40_http.js @@ -1,5 +1,5 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -const core = globalThis.Deno.core; +import { core } from "ext:core/mod.js"; const ops = core.ops; import { HttpConn } from "ext:deno_http/01_http.js"; diff --git a/runtime/js/40_process.js b/runtime/js/40_process.js index 67093398a0..b8e05ce5a7 100644 --- a/runtime/js/40_process.js +++ b/runtime/js/40_process.js @@ -1,8 +1,7 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -const core = globalThis.Deno.core; +import { core, primordials } from "ext:core/mod.js"; const ops = core.ops; -const primordials = globalThis.__bootstrap.primordials; const { ArrayPrototypeMap, ArrayPrototypeSlice, diff --git a/runtime/js/40_signals.js b/runtime/js/40_signals.js index 3c5b83789d..20771da36a 100644 --- a/runtime/js/40_signals.js +++ b/runtime/js/40_signals.js @@ -1,8 +1,7 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -const core = globalThis.Deno.core; +import { core, primordials } from "ext:core/mod.js"; const ops = core.ops; -const primordials = globalThis.__bootstrap.primordials; const { SafeSet, SafeSetIterator, diff --git a/runtime/js/40_tty.js b/runtime/js/40_tty.js index 7476daad31..cb1a456a0d 100644 --- a/runtime/js/40_tty.js +++ b/runtime/js/40_tty.js @@ -1,7 +1,6 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -const core = globalThis.Deno.core; +import { core, primordials } from "ext:core/mod.js"; const ops = core.ops; -const primordials = globalThis.__bootstrap.primordials; const { Uint32Array, } = primordials; diff --git a/runtime/js/41_prompt.js b/runtime/js/41_prompt.js index 37fdaed77b..e665aae071 100644 --- a/runtime/js/41_prompt.js +++ b/runtime/js/41_prompt.js @@ -1,6 +1,5 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -const core = globalThis.Deno.core; -const primordials = globalThis.__bootstrap.primordials; +import { core, primordials } from "ext:core/mod.js"; import { isatty } from "ext:runtime/40_tty.js"; import { stdin } from "ext:deno_io/12_io.js"; const { ArrayPrototypePush, StringPrototypeCharCodeAt, Uint8Array } = diff --git a/runtime/js/90_deno_ns.js b/runtime/js/90_deno_ns.js index 5ab56d8d7d..834e5d1a3b 100644 --- a/runtime/js/90_deno_ns.js +++ b/runtime/js/90_deno_ns.js @@ -1,6 +1,6 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -const core = globalThis.Deno.core; +import { core } from "ext:core/mod.js"; const ops = core.ops; import * as timers from "ext:deno_web/02_timers.js"; diff --git a/runtime/js/98_global_scope.js b/runtime/js/98_global_scope.js index 406ea50f54..56354948e5 100644 --- a/runtime/js/98_global_scope.js +++ b/runtime/js/98_global_scope.js @@ -1,8 +1,7 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -const core = globalThis.Deno.core; +import { core, primordials } from "ext:core/mod.js"; const ops = core.ops; -const primordials = globalThis.__bootstrap.primordials; const { ObjectDefineProperties, ObjectPrototypeIsPrototypeOf, diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js index 050cd3bf88..22352bf292 100644 --- a/runtime/js/99_main.js +++ b/runtime/js/99_main.js @@ -3,10 +3,8 @@ // Remove Intl.v8BreakIterator because it is a non-standard API. delete Intl.v8BreakIterator; -const core = globalThis.Deno.core; +import { core, internals, primordials } from "ext:core/mod.js"; const ops = core.ops; -const internals = globalThis.__bootstrap.internals; -const primordials = globalThis.__bootstrap.primordials; const { ArrayPrototypeFilter, ArrayPrototypeIncludes,