From 0d58487e2bb4fbf1b3f912278aec3712ecbc16ce Mon Sep 17 00:00:00 2001 From: Chengzhong Wu Date: Fri, 5 May 2023 19:37:50 +0800 Subject: [PATCH] lib: move web global bootstrapping to the expected file PR-URL: https://github.com/nodejs/node/pull/47881 Reviewed-By: Joyee Cheung Reviewed-By: Minwoo Jung Reviewed-By: James M Snell Reviewed-By: Yagiz Nizipli Reviewed-By: Antoine du Hamel Reviewed-By: Khaidi Chu --- 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 c40c955ab29227..2814b7228aa2c1 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