lib: move web global bootstrapping to the expected file

PR-URL: https://github.com/nodejs/node/pull/47881
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Khaidi Chu <i@2333.moe>
This commit is contained in:
Chengzhong Wu 2023-05-05 19:37:50 +08:00 committed by Node.js GitHub Bot
parent f3b713d187
commit 77df1d84c7
2 changed files with 13 additions and 13 deletions

View File

@ -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

View File

@ -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