mirror of
https://github.com/nodejs/node.git
synced 2026-10-14 10:26:26 -04:00
worker: expose BroadcastChannel as a global
Signed-off-by: James M Snell <jasnell@gmail.com> PR-URL: https://github.com/nodejs/node/pull/41271 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This commit is contained in:
6 files changed
+15
-2
No files matched your search
@@ -368,6 +368,7 @@ module.exports = {
|
||||
Event: 'readable',
|
||||
EventTarget: 'readable',
|
||||
MessageChannel: 'readable',
|
||||
BroadcastChannel: 'readable',
|
||||
MessageEvent: 'readable',
|
||||
MessagePort: 'readable',
|
||||
TextEncoder: 'readable',
|
||||
|
||||
@@ -239,6 +239,14 @@ added: v16.0.0
|
||||
|
||||
Global alias for [`buffer.atob()`][].
|
||||
|
||||
## `BroadcastChannel`
|
||||
|
||||
<!-- YAML
|
||||
added: REPLACEME
|
||||
-->
|
||||
|
||||
See {BroadcastChannel}.
|
||||
|
||||
## `btoa(data)`
|
||||
|
||||
<!-- YAML
|
||||
|
||||
@@ -349,7 +349,7 @@ if (isMainThread) {
|
||||
added: v15.4.0
|
||||
changes:
|
||||
- version: REPLACEME
|
||||
pr-url: https://github.com/nodejs/node/pull/00000
|
||||
pr-url: https://github.com/nodejs/node/pull/41271
|
||||
description: No longer experimental.
|
||||
-->
|
||||
|
||||
|
||||
@@ -51,6 +51,8 @@ rules:
|
||||
# disabled with --without-intl build flag.
|
||||
- name: Intl
|
||||
message: "Use `const { Intl } = globalThis;` instead of the global."
|
||||
- name: BroadcastChannel
|
||||
message: "Use `const { BroadcastChannel } = require('internal/worker/io');` instead of the global."
|
||||
- name: MessageChannel
|
||||
message: "Use `const { MessageChannel } = require('internal/worker/io');` instead of the global."
|
||||
- name: MessageEvent
|
||||
|
||||
@@ -251,10 +251,12 @@ if (!config.noBrowserGlobals) {
|
||||
MessageChannel,
|
||||
MessagePort,
|
||||
MessageEvent,
|
||||
BroadcastChannel,
|
||||
} = require('internal/worker/io');
|
||||
exposeInterface(globalThis, 'MessageChannel', MessageChannel);
|
||||
exposeInterface(globalThis, 'MessagePort', MessagePort);
|
||||
exposeInterface(globalThis, 'MessageEvent', MessageEvent);
|
||||
exposeInterface(globalThis, 'BroadcastChannel', BroadcastChannel);
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#windoworworkerglobalscope
|
||||
const timers = require('timers');
|
||||
|
||||
@@ -456,7 +456,7 @@ class BroadcastChannel extends EventTarget {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {*} message
|
||||
* @param {any} message
|
||||
* @returns {void}
|
||||
*/
|
||||
postMessage(message) {
|
||||
|
||||
Reference in new issue
Block a user