From f87da5869aa7484a3ec8e22019906244ad516de6 Mon Sep 17 00:00:00 2001 From: Chengzhong Wu Date: Fri, 5 May 2023 19:37:50 +0800 Subject: [PATCH 1/2] lib: move web global bootstrapping to the expected file --- lib/internal/bootstrap/node.js | 13 +------------ .../bootstrap/web/exposed-window-or-worker.js | 13 ++++++++++++- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/internal/bootstrap/node.js b/lib/internal/bootstrap/node.js index 41a833885f9491..03ac2bc99c36d1 100644 --- a/lib/internal/bootstrap/node.js +++ b/lib/internal/bootstrap/node.js @@ -70,7 +70,6 @@ const internalTimers = require('internal/timers'); const { defineOperation, deprecate, - defineLazyProperties, } = require('internal/util'); const { validateInteger, @@ -208,22 +207,12 @@ internalBinding('async_wrap').setupHooks(nativeHooks); const { setupTaskQueue, - queueMicrotask, } = require('internal/process/task_queues'); - -// Non-standard extensions: -defineOperation(globalThis, 'queueMicrotask', queueMicrotask); - const timers = require('timers'); +// Non-standard extensions: defineOperation(globalThis, 'clearImmediate', timers.clearImmediate); defineOperation(globalThis, 'setImmediate', timers.setImmediate); -defineLazyProperties( - globalThis, - 'internal/structured_clone', - ['structuredClone'], -); - // Set the per-Environment callback that will be called // when the TrackingTraceStateObserver updates trace state. // Note that when NODE_USE_V8_PLATFORM is true, the observer is diff --git a/lib/internal/bootstrap/web/exposed-window-or-worker.js b/lib/internal/bootstrap/web/exposed-window-or-worker.js index 01c88c9679dfc0..8dc77493e1f152 100644 --- a/lib/internal/bootstrap/web/exposed-window-or-worker.js +++ b/lib/internal/bootstrap/web/exposed-window-or-worker.js @@ -26,12 +26,23 @@ defineOperation(globalThis, 'clearTimeout', timers.clearTimeout); defineOperation(globalThis, 'setInterval', timers.setInterval); defineOperation(globalThis, 'setTimeout', timers.setTimeout); +const { + queueMicrotask, +} = require('internal/process/task_queues'); +defineOperation(globalThis, 'queueMicrotask', queueMicrotask); + +defineLazyProperties( + globalThis, + 'internal/structured_clone', + ['structuredClone'], +); +defineLazyProperties(globalThis, 'buffer', ['atob', 'btoa']); + // https://html.spec.whatwg.org/multipage/web-messaging.html#broadcasting-to-other-browsing-contexts exposeLazyInterfaces(globalThis, 'internal/worker/io', ['BroadcastChannel']); exposeLazyInterfaces(globalThis, 'internal/worker/io', [ 'MessageChannel', 'MessagePort', 'MessageEvent', ]); -defineLazyProperties(globalThis, 'buffer', ['atob', 'btoa']); // https://www.w3.org/TR/FileAPI/#dfn-Blob exposeLazyInterfaces(globalThis, 'internal/blob', ['Blob']); // https://www.w3.org/TR/FileAPI/#dfn-file From fb1707da67c010eb396c3eff967ec1a1bc3fc532 Mon Sep 17 00:00:00 2001 From: Chengzhong Wu Date: Fri, 5 May 2023 19:38:13 +0800 Subject: [PATCH 2/2] lib: remove obsolete deletion of bufferBinding.zeroFill --- lib/internal/bootstrap/node.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/internal/bootstrap/node.js b/lib/internal/bootstrap/node.js index 03ac2bc99c36d1..52d02a571d8740 100644 --- a/lib/internal/bootstrap/node.js +++ b/lib/internal/bootstrap/node.js @@ -374,7 +374,6 @@ function setupBuffer() { // Only after this point can C++ use Buffer::New() bufferBinding.setBufferPrototype(Buffer.prototype); delete bufferBinding.setBufferPrototype; - delete bufferBinding.zeroFill; // Create global.Buffer as getters so that we have a // deprecation path for these in ES Modules.