diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2023-01-24 18:54:10 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-24 18:54:10 +0100 |
commit | abd96105300a7729a4d8eb69af2e81dd6307a163 (patch) | |
tree | 75b7556f876b2a2df3e22b905922dfb11572ef6d | |
parent | 1084027d502d54ebf256c867fe85600b295d8a06 (diff) |
refactor: remove Deno.core (#16881)
This commit removes "Deno.core" namespace. It is strictly private API
that has no stability guarantees, we were supposed to remove it long time ago.
Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
43 files changed, 104 insertions, 89 deletions
diff --git a/cli/bench/async_ops.js b/cli/bench/async_ops.js index d608e7a9e..fe041efe8 100644 --- a/cli/bench/async_ops.js +++ b/cli/bench/async_ops.js @@ -16,5 +16,5 @@ async function bench(fun) { if (--total) queueMicrotask(() => bench(fun)); } -const { ops } = Deno.core; +const { ops } = Deno[Deno.internal].core; bench(() => ops.op_void_async()); diff --git a/cli/bench/deno_common.js b/cli/bench/deno_common.js index 2676fc8de..31ab05fba 100644 --- a/cli/bench/deno_common.js +++ b/cli/bench/deno_common.js @@ -8,7 +8,7 @@ Deno.bench("date_now", { n: 5e5 }, () => { // Fast API calls { // deno-lint-ignore camelcase - const { op_add } = Deno.core.ops; + const { op_add } = Deno[Deno.internal].core.ops; // deno-lint-ignore no-inner-declarations function add(a, b) { return op_add(a, b); @@ -22,7 +22,7 @@ Deno.bench("date_now", { n: 5e5 }, () => { } // deno-lint-ignore camelcase -const { op_void_sync } = Deno.core.ops; +const { op_void_sync } = Deno[Deno.internal].core.ops; function sync() { return op_void_sync(); } @@ -34,7 +34,7 @@ Deno.bench("op_void_sync", () => sync()); Deno.bench( "op_void_async", { n: 1e6 }, - () => Deno.core.opAsync("op_void_async"), + () => Deno[Deno.internal].core.opAsync("op_void_async"), ); // A very lightweight op, that should be highly optimizable diff --git a/cli/bench/http/deno_http_flash_ops.js b/cli/bench/http/deno_http_flash_ops.js index 1ef2f65ed..7b024f9af 100644 --- a/cli/bench/http/deno_http_flash_ops.js +++ b/cli/bench/http/deno_http_flash_ops.js @@ -3,12 +3,10 @@ // deno-lint-ignore-file const { - core: { - opAsync, - ops: { op_flash_make_request, op_flash_serve }, - encode, - }, -} = Deno; + opAsync, + ops: { op_flash_make_request, op_flash_serve }, + encode, +} = Deno[Deno.internal].core; const addr = Deno.args[0] || "127.0.0.1:4500"; const [hostname, port] = addr.split(":"); const serverId = op_flash_serve({ hostname, port, reuseport: true }); diff --git a/cli/bench/http/deno_http_ops.js b/cli/bench/http/deno_http_ops.js index 3fd0bef31..216a47905 100644 --- a/cli/bench/http/deno_http_ops.js +++ b/cli/bench/http/deno_http_ops.js @@ -13,7 +13,10 @@ class Http { [Symbol.asyncIterator]() { return { next: async () => { - const reqEvt = await Deno.core.opAsync("op_http_accept", this.id); + const reqEvt = await Deno[Deno.internal].core.opAsync( + "op_http_accept", + this.id, + ); return { value: reqEvt ?? undefined, done: reqEvt === null }; }, }; @@ -21,20 +24,20 @@ class Http { } for await (const conn of tcp) { - const id = Deno.core.ops.op_http_start(conn.rid); + const id = Deno[Deno.internal].core.ops.op_http_start(conn.rid); const http = new Http(id); (async () => { for await (const req of http) { if (req == null) continue; const { 0: stream } = req; - await Deno.core.opAsync( + await Deno[Deno.internal].core.opAsync( "op_http_write_headers", stream, 200, [], "Hello World", ); - Deno.core.close(stream); + Deno[Deno.internal].core.close(stream); } })(); } diff --git a/cli/bench/testdata/deno_upgrade_http.js b/cli/bench/testdata/deno_upgrade_http.js index db14f8589..ca5533411 100644 --- a/cli/bench/testdata/deno_upgrade_http.js +++ b/cli/bench/testdata/deno_upgrade_http.js @@ -1,5 +1,7 @@ const { serve, upgradeHttpRaw } = Deno; -const u8 = Deno.core.encode("HTTP/1.1 101 Switching Protocols\r\n\r\n"); +const u8 = Deno[Deno.internal].core.encode( + "HTTP/1.1 101 Switching Protocols\r\n\r\n", +); async function handler(req) { const [conn, _firstPacket] = upgradeHttpRaw(req); diff --git a/cli/tests/integration/inspector_tests.rs b/cli/tests/integration/inspector_tests.rs index e291c17bb..5b01522d5 100644 --- a/cli/tests/integration/inspector_tests.rs +++ b/cli/tests/integration/inspector_tests.rs @@ -318,7 +318,7 @@ async fn inspector_break_on_first_line() { "id":4, "method":"Runtime.evaluate", "params":{ - "expression":"Deno.core.print(\"hello from the inspector\\n\")", + "expression":"Deno[Deno.internal].core.print(\"hello from the inspector\\n\")", "contextId":1, "includeCommandLineAPI":true, "silent":false, diff --git a/cli/tests/testdata/bench/recursive_permissions_pledge.js b/cli/tests/testdata/bench/recursive_permissions_pledge.js index dbba96f26..9bf320c37 100644 --- a/cli/tests/testdata/bench/recursive_permissions_pledge.js +++ b/cli/tests/testdata/bench/recursive_permissions_pledge.js @@ -1,6 +1,6 @@ -Deno.core.ops.op_pledge_test_permissions( +Deno[Deno.internal].core.ops.op_pledge_test_permissions( "none", ); -Deno.core.ops.op_pledge_test_permissions( +Deno[Deno.internal].core.ops.op_pledge_test_permissions( "inherit", ); diff --git a/cli/tests/testdata/npm/registry/@denotest/child-process-fork/1.0.0/index.js b/cli/tests/testdata/npm/registry/@denotest/child-process-fork/1.0.0/index.js index 674268e6f..6f7dceb98 100644 --- a/cli/tests/testdata/npm/registry/@denotest/child-process-fork/1.0.0/index.js +++ b/cli/tests/testdata/npm/registry/@denotest/child-process-fork/1.0.0/index.js @@ -4,7 +4,7 @@ function childProcessFork(path) { const p = Deno.run({ cmd: [Deno.execPath(), "run", "--unstable", "-A", path], env: { - "DENO_DONT_USE_INTERNAL_NODE_COMPAT_STATE": Deno.core.ops.op_npm_process_state(), + "DENO_DONT_USE_INTERNAL_NODE_COMPAT_STATE": Deno[Deno.internal].core.ops.op_npm_process_state(), } }); p.status().then(() => { diff --git a/cli/tests/testdata/run/042_dyn_import_evalcontext.ts b/cli/tests/testdata/run/042_dyn_import_evalcontext.ts index ccda3a972..6a9ffb971 100644 --- a/cli/tests/testdata/run/042_dyn_import_evalcontext.ts +++ b/cli/tests/testdata/run/042_dyn_import_evalcontext.ts @@ -1,4 +1,4 @@ -// @ts-expect-error "Deno.core" is not a public interface -Deno.core.evalContext( +// @ts-expect-error "Deno[Deno.internal].core" is not a public interface +Deno[Deno.internal].core.evalContext( "(async () => console.log(await import('./subdir/mod4.js')))()", ); diff --git a/cli/tests/testdata/run/eval_context_throw_dom_exception.js b/cli/tests/testdata/run/eval_context_throw_dom_exception.js index b8e99d498..31baeedfc 100644 --- a/cli/tests/testdata/run/eval_context_throw_dom_exception.js +++ b/cli/tests/testdata/run/eval_context_throw_dom_exception.js @@ -1,2 +1,4 @@ -const [, errorInfo] = Deno.core.evalContext('throw new DOMException("foo")'); +const [, errorInfo] = Deno[Deno.internal].core.evalContext( + 'throw new DOMException("foo")', +); console.log(errorInfo); diff --git a/cli/tests/testdata/run/event_listener_error_immediate_exit.ts b/cli/tests/testdata/run/event_listener_error_immediate_exit.ts index c9e94c01b..292a0df00 100644 --- a/cli/tests/testdata/run/event_listener_error_immediate_exit.ts +++ b/cli/tests/testdata/run/event_listener_error_immediate_exit.ts @@ -4,9 +4,9 @@ addEventListener("foo", () => { throw new Error("bar"); }); console.log(1); -// @ts-ignore Deno.core -Deno.core.setNextTickCallback(() => console.log("nextTick")); -// @ts-ignore Deno.core -Deno.core.setHasTickScheduled(true); +// @ts-ignore Deno[Deno.internal].core +Deno[Deno.internal].core.setNextTickCallback(() => console.log("nextTick")); +// @ts-ignore Deno[Deno.internal].core +Deno[Deno.internal].core.setHasTickScheduled(true); dispatchEvent(new CustomEvent("foo")); console.log(2); diff --git a/cli/tests/testdata/run/ffi/unstable_ffi_1.js b/cli/tests/testdata/run/ffi/unstable_ffi_1.js index 8ca6c3a60..8ef77e71e 100644 --- a/cli/tests/testdata/run/ffi/unstable_ffi_1.js +++ b/cli/tests/testdata/run/ffi/unstable_ffi_1.js @@ -1 +1 @@ -Deno.core.ops.op_ffi_load({ path: "", symbols: {} }); +Deno[Deno.internal].core.ops.op_ffi_load({ path: "", symbols: {} }); diff --git a/cli/tests/testdata/run/ffi/unstable_ffi_10.js b/cli/tests/testdata/run/ffi/unstable_ffi_10.js index 80ee896bd..da1c5b3a2 100644 --- a/cli/tests/testdata/run/ffi/unstable_ffi_10.js +++ b/cli/tests/testdata/run/ffi/unstable_ffi_10.js @@ -1 +1 @@ -Deno.core.ops.op_ffi_read_i16(0n, 0); +Deno[Deno.internal].core.ops.op_ffi_read_i16(0n, 0); diff --git a/cli/tests/testdata/run/ffi/unstable_ffi_11.js b/cli/tests/testdata/run/ffi/unstable_ffi_11.js index 6324a8fbd..c2d9213b4 100644 --- a/cli/tests/testdata/run/ffi/unstable_ffi_11.js +++ b/cli/tests/testdata/run/ffi/unstable_ffi_11.js @@ -1 +1 @@ -Deno.core.ops.op_ffi_read_u32(0n, 0); +Deno[Deno.internal].core.ops.op_ffi_read_u32(0n, 0); diff --git a/cli/tests/testdata/run/ffi/unstable_ffi_12.js b/cli/tests/testdata/run/ffi/unstable_ffi_12.js index 7888684e9..d3aaa7a71 100644 --- a/cli/tests/testdata/run/ffi/unstable_ffi_12.js +++ b/cli/tests/testdata/run/ffi/unstable_ffi_12.js @@ -1 +1 @@ -Deno.core.ops.op_ffi_read_i32(0n, 0); +Deno[Deno.internal].core.ops.op_ffi_read_i32(0n, 0); diff --git a/cli/tests/testdata/run/ffi/unstable_ffi_13.js b/cli/tests/testdata/run/ffi/unstable_ffi_13.js index b9afff9de..859fbad60 100644 --- a/cli/tests/testdata/run/ffi/unstable_ffi_13.js +++ b/cli/tests/testdata/run/ffi/unstable_ffi_13.js @@ -1 +1 @@ -Deno.core.ops.op_ffi_read_u64(0n, 0, new Uint32Array(2)); +Deno[Deno.internal].core.ops.op_ffi_read_u64(0n, 0, new Uint32Array(2)); diff --git a/cli/tests/testdata/run/ffi/unstable_ffi_14.js b/cli/tests/testdata/run/ffi/unstable_ffi_14.js index b8c1bf5b5..19f8a48c8 100644 --- a/cli/tests/testdata/run/ffi/unstable_ffi_14.js +++ b/cli/tests/testdata/run/ffi/unstable_ffi_14.js @@ -1 +1 @@ -Deno.core.ops.op_ffi_read_f32(0n, 0); +Deno[Deno.internal].core.ops.op_ffi_read_f32(0n, 0); diff --git a/cli/tests/testdata/run/ffi/unstable_ffi_15.js b/cli/tests/testdata/run/ffi/unstable_ffi_15.js index 92242fe3f..3a4c0252b 100644 --- a/cli/tests/testdata/run/ffi/unstable_ffi_15.js +++ b/cli/tests/testdata/run/ffi/unstable_ffi_15.js @@ -1 +1 @@ -Deno.core.ops.op_ffi_read_f64(0n, 0); +Deno[Deno.internal].core.ops.op_ffi_read_f64(0n, 0); diff --git a/cli/tests/testdata/run/ffi/unstable_ffi_2.js b/cli/tests/testdata/run/ffi/unstable_ffi_2.js index 7f3f34f37..4ed91a9c2 100644 --- a/cli/tests/testdata/run/ffi/unstable_ffi_2.js +++ b/cli/tests/testdata/run/ffi/unstable_ffi_2.js @@ -1,4 +1,4 @@ -Deno.core.ops.op_ffi_call_ptr(0n, { +Deno[Deno.internal].core.ops.op_ffi_call_ptr(0n, { name: null, parameters: [], result: "void", diff --git a/cli/tests/testdata/run/ffi/unstable_ffi_3.js b/cli/tests/testdata/run/ffi/unstable_ffi_3.js index a8f7f4180..284ecbc91 100644 --- a/cli/tests/testdata/run/ffi/unstable_ffi_3.js +++ b/cli/tests/testdata/run/ffi/unstable_ffi_3.js @@ -1,4 +1,4 @@ -Deno.core.opAsync("op_ffi_call_ptr_nonblocking", 0n, { +Deno[Deno.internal].core.opAsync("op_ffi_call_ptr_nonblocking", 0n, { name: null, parameters: [], result: "void", diff --git a/cli/tests/testdata/run/ffi/unstable_ffi_4.js b/cli/tests/testdata/run/ffi/unstable_ffi_4.js index 150791233..c62905ead 100644 --- a/cli/tests/testdata/run/ffi/unstable_ffi_4.js +++ b/cli/tests/testdata/run/ffi/unstable_ffi_4.js @@ -1 +1,4 @@ -Deno.core.ops.op_ffi_ptr_of(new Uint8Array(0), new Uint32Array(2)); +Deno[Deno.internal].core.ops.op_ffi_ptr_of( + new Uint8Array(0), + new Uint32Array(2), +); diff --git a/cli/tests/testdata/run/ffi/unstable_ffi_5.js b/cli/tests/testdata/run/ffi/unstable_ffi_5.js index 9834a9a80..278c3c9d2 100644 --- a/cli/tests/testdata/run/ffi/unstable_ffi_5.js +++ b/cli/tests/testdata/run/ffi/unstable_ffi_5.js @@ -1 +1 @@ -Deno.core.ops.op_ffi_buf_copy_into(0n, 0, new Uint8Array(0), 0); +Deno[Deno.internal].core.ops.op_ffi_buf_copy_into(0n, 0, new Uint8Array(0), 0); diff --git a/cli/tests/testdata/run/ffi/unstable_ffi_6.js b/cli/tests/testdata/run/ffi/unstable_ffi_6.js index 0bd847f8c..e6add70d6 100644 --- a/cli/tests/testdata/run/ffi/unstable_ffi_6.js +++ b/cli/tests/testdata/run/ffi/unstable_ffi_6.js @@ -1 +1 @@ -Deno.core.ops.op_ffi_cstr_read(0n, 0); +Deno[Deno.internal].core.ops.op_ffi_cstr_read(0n, 0); diff --git a/cli/tests/testdata/run/ffi/unstable_ffi_7.js b/cli/tests/testdata/run/ffi/unstable_ffi_7.js index 143138a6a..6ba28b3e3 100644 --- a/cli/tests/testdata/run/ffi/unstable_ffi_7.js +++ b/cli/tests/testdata/run/ffi/unstable_ffi_7.js @@ -1 +1 @@ -Deno.core.ops.op_ffi_read_u8(0n, 0); +Deno[Deno.internal].core.ops.op_ffi_read_u8(0n, 0); diff --git a/cli/tests/testdata/run/ffi/unstable_ffi_8.js b/cli/tests/testdata/run/ffi/unstable_ffi_8.js index 6b2d89a48..2b0e0343b 100644 --- a/cli/tests/testdata/run/ffi/unstable_ffi_8.js +++ b/cli/tests/testdata/run/ffi/unstable_ffi_8.js @@ -1 +1 @@ -Deno.core.ops.op_ffi_read_i8(0n, 0); +Deno[Deno.internal].core.ops.op_ffi_read_i8(0n, 0); diff --git a/cli/tests/testdata/run/ffi/unstable_ffi_9.js b/cli/tests/testdata/run/ffi/unstable_ffi_9.js index 852e11f10..729a8584e 100644 --- a/cli/tests/testdata/run/ffi/unstable_ffi_9.js +++ b/cli/tests/testdata/run/ffi/unstable_ffi_9.js @@ -1 +1 @@ -Deno.core.ops.op_ffi_read_u16(0n, 0); +Deno[Deno.internal].core.ops.op_ffi_read_u16(0n, 0); diff --git a/cli/tests/testdata/run/finalization_registry.js b/cli/tests/testdata/run/finalization_registry.js index dd3ea7671..dd2395085 100644 --- a/cli/tests/testdata/run/finalization_registry.js +++ b/cli/tests/testdata/run/finalization_registry.js @@ -8,7 +8,7 @@ function assertEquals(a, b) { const registry = new FinalizationRegistry((value) => { assertEquals(value, "called!"); - Deno.core.print("FinalizationRegistry called!\n"); + Deno[Deno.internal].core.print("FinalizationRegistry called!\n"); }); (function () { diff --git a/cli/tests/testdata/run/op_exit_op_set_exit_code_in_worker.ts b/cli/tests/testdata/run/op_exit_op_set_exit_code_in_worker.ts index b2ed912de..b6a776439 100644 --- a/cli/tests/testdata/run/op_exit_op_set_exit_code_in_worker.ts +++ b/cli/tests/testdata/run/op_exit_op_set_exit_code_in_worker.ts @@ -2,8 +2,8 @@ // setting exit code in worker context is a no-op and is an alias for // `self.close()`. -// @ts-ignore Deno.core doesn't have type-defs -Deno.core.ops.op_set_exit_code(21); +// @ts-ignore Deno[Deno.internal].core doesn't have type-defs +Deno[Deno.internal].core.ops.op_set_exit_code(21); const worker = new Worker( import.meta.resolve("./op_exit_op_set_exit_code_worker.js"), diff --git a/cli/tests/testdata/run/op_exit_op_set_exit_code_worker.js b/cli/tests/testdata/run/op_exit_op_set_exit_code_worker.js index 3e6055747..9b284c37d 100644 --- a/cli/tests/testdata/run/op_exit_op_set_exit_code_worker.js +++ b/cli/tests/testdata/run/op_exit_op_set_exit_code_worker.js @@ -1,4 +1,4 @@ self.onmessage = () => { - Deno.core.ops.op_set_exit_code(42); + Deno[Deno.internal].core.ops.op_set_exit_code(42); Deno.exit(); }; diff --git a/cli/tests/testdata/run/set_exit_code_0.ts b/cli/tests/testdata/run/set_exit_code_0.ts index 362a9f28a..8a0103c8f 100644 --- a/cli/tests/testdata/run/set_exit_code_0.ts +++ b/cli/tests/testdata/run/set_exit_code_0.ts @@ -1,2 +1,2 @@ -Deno.core.ops.op_set_exit_code(42); +Deno[Deno.internal].core.ops.op_set_exit_code(42); Deno.exit(0); // Takes precedence. diff --git a/cli/tests/testdata/run/set_exit_code_1.ts b/cli/tests/testdata/run/set_exit_code_1.ts index b10863568..45027ccf7 100644 --- a/cli/tests/testdata/run/set_exit_code_1.ts +++ b/cli/tests/testdata/run/set_exit_code_1.ts @@ -1,2 +1,2 @@ -Deno.core.ops.op_set_exit_code(42); +Deno[Deno.internal].core.ops.op_set_exit_code(42); Deno.exit(); diff --git a/cli/tests/testdata/run/set_exit_code_2.ts b/cli/tests/testdata/run/set_exit_code_2.ts index d68812cae..48469c17d 100644 --- a/cli/tests/testdata/run/set_exit_code_2.ts +++ b/cli/tests/testdata/run/set_exit_code_2.ts @@ -1,2 +1,2 @@ -Deno.core.ops.op_set_exit_code(42); +Deno[Deno.internal].core.ops.op_set_exit_code(42); // Exits naturally. diff --git a/cli/tests/testdata/test/recursive_permissions_pledge.js b/cli/tests/testdata/test/recursive_permissions_pledge.js index dbba96f26..9bf320c37 100644 --- a/cli/tests/testdata/test/recursive_permissions_pledge.js +++ b/cli/tests/testdata/test/recursive_permissions_pledge.js @@ -1,6 +1,6 @@ -Deno.core.ops.op_pledge_test_permissions( +Deno[Deno.internal].core.ops.op_pledge_test_permissions( "none", ); -Deno.core.ops.op_pledge_test_permissions( +Deno[Deno.internal].core.ops.op_pledge_test_permissions( "inherit", ); diff --git a/cli/tests/unit/globals_test.ts b/cli/tests/unit/globals_test.ts index cf7293bba..c63b28973 100644 --- a/cli/tests/unit/globals_test.ts +++ b/cli/tests/unit/globals_test.ts @@ -71,12 +71,8 @@ Deno.test(function webAssemblyExists() { assert(typeof WebAssembly.compile === "function"); }); -declare global { - namespace Deno { - // deno-lint-ignore no-explicit-any, no-var - var core: any; - } -} +// @ts-ignore This is not publicly typed namespace, but it's there for sure. +const core = Deno[Deno.internal].core; Deno.test(function DenoNamespaceConfigurable() { const desc = Object.getOwnPropertyDescriptor(globalThis, "Deno"); @@ -86,19 +82,19 @@ Deno.test(function DenoNamespaceConfigurable() { }); Deno.test(function DenoCoreNamespaceIsImmutable() { - const { print } = Deno.core; + const { print } = core; try { - Deno.core.print = 1; + core.print = 1; } catch { // pass } - assert(print === Deno.core.print); + assert(print === core.print); try { - delete Deno.core.print; + delete core.print; } catch { // pass } - assert(print === Deno.core.print); + assert(print === core.print); }); Deno.test(async function windowQueueMicrotask() { diff --git a/cli/tests/unit/metrics_test.ts b/cli/tests/unit/metrics_test.ts index 5ada58b97..df2f1b2be 100644 --- a/cli/tests/unit/metrics_test.ts +++ b/cli/tests/unit/metrics_test.ts @@ -77,13 +77,15 @@ Deno.test(function metricsForOpCrates() { assert(m1.opsCompleted > 0); }); -// Test that op_names == Objects.keys(Deno.core.ops) +// Test that op_names == Objects.keys(Deno[Deno.internal].core.ops) // since building the per-op metrics depends on op_names being complete Deno.test(function opNamesMatch() { assertEquals( - // @ts-ignore: Deno.core allowed - Deno.core.opNames().sort(), - // @ts-ignore: Deno.core allowed - Object.keys(Deno.core.ops).sort().filter((name) => name !== "asyncOpsInfo"), + // @ts-ignore: Deno[Deno.internal].core allowed + Deno[Deno.internal].core.opNames().sort(), + // @ts-ignore: Deno[Deno.internal].core allowed + Object.keys(Deno[Deno.internal].core.ops).sort().filter((name) => + name !== "asyncOpsInfo" + ), ); }); diff --git a/cli/tests/unit/opcall_test.ts b/cli/tests/unit/opcall_test.ts index 61c3c8849..3f4f4472c 100644 --- a/cli/tests/unit/opcall_test.ts +++ b/cli/tests/unit/opcall_test.ts @@ -22,17 +22,13 @@ Deno.test(async function sendAsyncStackTrace() { } }); -declare global { - namespace Deno { - // deno-lint-ignore no-explicit-any, no-var - var core: any; - } -} +// @ts-ignore This is not publicly typed namespace, but it's there for sure. +const core = Deno[Deno.internal].core; Deno.test(async function opsAsyncBadResource() { try { const nonExistingRid = 9999; - await Deno.core.read( + await core.read( nonExistingRid, new Uint8Array(0), ); @@ -46,7 +42,10 @@ Deno.test(async function opsAsyncBadResource() { Deno.test(function opsSyncBadResource() { try { const nonExistingRid = 9999; - Deno.core.ops.op_read_sync(nonExistingRid, new Uint8Array(0)); + core.ops.op_read_sync( + nonExistingRid, + new Uint8Array(0), + ); } catch (e) { if (!(e instanceof Deno.errors.BadResource)) { throw e; diff --git a/cli/tests/unit/promise_hooks_test.ts b/cli/tests/unit/promise_hooks_test.ts index cbdb6320a..a0883d4b5 100644 --- a/cli/tests/unit/promise_hooks_test.ts +++ b/cli/tests/unit/promise_hooks_test.ts @@ -12,8 +12,8 @@ function monitorPromises(outputArray: string[]) { return promiseIds.get(promise); } - // @ts-ignore: Deno.core allowed - Deno.core.setPromiseHooks( + // @ts-ignore: Deno[Deno.internal].core allowed + Deno[Deno.internal].core.setPromiseHooks( (promise: Promise<unknown>, parentPromise?: Promise<unknown>) => { outputArray.push( `init ${identify(promise)}` + diff --git a/cli/tests/unit/ref_unref_test.ts b/cli/tests/unit/ref_unref_test.ts index 7ce72a170..eea93b165 100644 --- a/cli/tests/unit/ref_unref_test.ts +++ b/cli/tests/unit/ref_unref_test.ts @@ -4,7 +4,7 @@ import { assertNotEquals, execCode } from "./test_util.ts"; Deno.test("[unrefOp] unref'ing invalid ops does not have effects", async () => { const [statusCode, _] = await execCode(` - Deno.core.unrefOp(-1); + Deno[Deno.internal].core.unrefOp(-1); setTimeout(() => { throw new Error() }, 10) `); // Invalid unrefOp call doesn't affect exit condition of event loop diff --git a/cli/tests/unit/text_encoding_test.ts b/cli/tests/unit/text_encoding_test.ts index 78e4267a9..940dd9f74 100644 --- a/cli/tests/unit/text_encoding_test.ts +++ b/cli/tests/unit/text_encoding_test.ts @@ -264,8 +264,8 @@ Deno.test(function textEncoderShouldCoerceToString() { }); Deno.test(function binaryEncode() { - // @ts-ignore: Deno.core allowed - const ops = Deno.core.ops; + // @ts-ignore: Deno[Deno.internal].core allowed + const ops = Deno[Deno.internal].core.ops; function asBinaryString(bytes: Uint8Array): string { return Array.from(bytes).map( (v: number) => String.fromCodePoint(v), diff --git a/cli/worker.rs b/cli/worker.rs index b6ebd7930..591889ccd 100644 --- a/cli/worker.rs +++ b/cli/worker.rs @@ -186,7 +186,7 @@ impl CliMainWorker { if self.ps.options.trace_ops() { self.worker.js_runtime.execute_script( &located_script_name!(), - "Deno.core.enableOpCallTracing();", + "Deno[Deno.internal].core.enableOpCallTracing();", )?; } @@ -231,7 +231,7 @@ impl CliMainWorker { self.worker.execute_script( &located_script_name!(), - "Deno.core.enableOpCallTracing();", + "Deno[Deno.internal].core.enableOpCallTracing();", )?; if mode != TestMode::Documentation { diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js index ea519cb35..e1d089bc5 100644 --- a/runtime/js/99_main.js +++ b/runtime/js/99_main.js @@ -485,8 +485,14 @@ delete Intl.v8BreakIterator; }, }); - const finalDenoNs = { + // FIXME(bartlomieju): temporarily add whole `Deno.core` to + // `Deno[Deno.internal]` namespace. It should be removed and only necessary + // methods should be left there. + ObjectAssign(internals, { core, + }); + + const finalDenoNs = { internal: internalSymbol, [internalSymbol]: internals, resources: core.resources, @@ -524,7 +530,6 @@ delete Intl.v8BreakIterator; // Setup `Deno` global - we're actually overriding already existing global // `Deno` with `Deno` namespace from "./deno.ts". ObjectDefineProperty(globalThis, "Deno", util.readOnly(finalDenoNs)); - ObjectFreeze(globalThis.Deno.core); util.log("args", runtimeOptions.args); } @@ -625,8 +630,14 @@ delete Intl.v8BreakIterator; }, }); - const finalDenoNs = { + // FIXME(bartlomieju): temporarily add whole `Deno.core` to + // `Deno[Deno.internal]` namespace. It should be removed and only necessary + // methods should be left there. + ObjectAssign(internals, { core, + }); + + const finalDenoNs = { internal: internalSymbol, [internalSymbol]: internals, resources: core.resources, @@ -660,7 +671,6 @@ delete Intl.v8BreakIterator; // Setup `Deno` global - we're actually overriding already // existing global `Deno` with `Deno` namespace from "./deno.ts". ObjectDefineProperty(globalThis, "Deno", util.readOnly(finalDenoNs)); - ObjectFreeze(globalThis.Deno.core); } ObjectDefineProperties(globalThis, { diff --git a/test_napi/common.js b/test_napi/common.js index 23f58c60c..915a43818 100644 --- a/test_napi/common.js +++ b/test_napi/common.js @@ -17,5 +17,5 @@ const [libPrefix, libSuffix] = { export function loadTestLibrary() { const specifier = `${targetDir}/${libPrefix}test_napi.${libSuffix}`; - return Deno.core.ops.op_napi_open(specifier); // Internal, used in ext/node + return Deno[Deno.internal].core.ops.op_napi_open(specifier); // Internal, used in ext/node } diff --git a/tools/wpt/runner.ts b/tools/wpt/runner.ts index ce6d41841..a3c22006a 100644 --- a/tools/wpt/runner.ts +++ b/tools/wpt/runner.ts @@ -185,9 +185,9 @@ async function generateBundle(location: URL): Promise<string> { return scriptContents.map(([url, contents]) => ` (function() { - const [_,err] = Deno.core.evalContext(${JSON.stringify(contents)}, ${ - JSON.stringify(url) - }); + const [_,err] = Deno[Deno.internal].core.evalContext(${ + JSON.stringify(contents) + }, ${JSON.stringify(url)}); if (err !== null) { throw err?.thrown; } |