FRE-600: Fix code review blockers

- Consolidated duplicate UndoManagers to single instance
- Fixed connection promise to only resolve on 'connected' status
- Fixed WebSocketProvider import (WebsocketProvider)
- Added proper doc.destroy() cleanup
- Renamed isPresenceInitialized property to avoid conflict

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
2026-04-25 00:08:01 -04:00
parent 65b552bb08
commit 7c684a42cc
48450 changed files with 5679671 additions and 383 deletions

180
node_modules/metro-runtime/src/modules/HMRClient.js generated vendored Normal file
View File

@@ -0,0 +1,180 @@
"use strict";
const EventEmitter = require("./vendor/eventemitter3");
const HEARTBEAT_INTERVAL_MS = 20_000;
const inject = ({ module: [id, code], sourceURL }) => {
if (global.globalEvalWithSourceUrl) {
global.globalEvalWithSourceUrl(code, sourceURL);
} else {
eval(code);
}
};
const injectUpdate = (update) => {
update.added.forEach(inject);
update.modified.forEach(inject);
};
class HMRClient extends EventEmitter {
_isEnabled = false;
_pendingUpdate = null;
_queue = [];
_state = "opening";
_heartbeatTimer = null;
constructor(url) {
super();
this._ws = new global.WebSocket(url);
this._ws.onopen = () => {
this._state = "open";
this._startHeartbeat();
this.emit("open");
this._flushQueue();
};
this._ws.onerror = (error) => {
this.emit("connection-error", error);
};
this._ws.onclose = (closeEvent) => {
this._state = "closed";
this._stopHeartbeat();
this.emit("close", closeEvent);
};
this._ws.onmessage = (message) => {
const data = JSON.parse(String(message.data));
switch (data.type) {
case "heartbeat":
break;
case "bundle-registered":
this.emit("bundle-registered");
break;
case "update-start":
this.emit("update-start", data.body);
break;
case "update":
this.emit("update", data.body);
break;
case "update-done":
this.emit("update-done", data.body);
break;
case "error":
this.emit("error", data.body);
break;
default:
this.emit("error", {
type: "unknown-message",
message: data,
});
}
};
this.on("update", (update) => {
if (this._isEnabled) {
injectUpdate(update);
} else if (this._pendingUpdate == null) {
this._pendingUpdate = update;
} else {
this._pendingUpdate = mergeUpdates(this._pendingUpdate, update);
}
});
}
close() {
this._ws.close();
}
send(message) {
switch (this._state) {
case "opening":
this._queue.push(message);
break;
case "open":
this._ws.send(message);
break;
case "closed":
break;
default:
throw new Error("[WebSocketHMRClient] Unknown state: " + this._state);
}
}
_flushQueue() {
this._queue.forEach((message) => this.send(message));
this._queue.length = 0;
}
_startHeartbeat() {
this._stopHeartbeat();
this._heartbeatTimer = setInterval(() => {
if (this._state === "open") {
this._ws.send('{"type":"heartbeat"}');
}
}, HEARTBEAT_INTERVAL_MS);
}
_stopHeartbeat() {
if (this._heartbeatTimer != null) {
clearInterval(this._heartbeatTimer);
this._heartbeatTimer = null;
}
}
enable() {
this._isEnabled = true;
const update = this._pendingUpdate;
this._pendingUpdate = null;
if (update != null) {
injectUpdate(update);
}
}
disable() {
this._isEnabled = false;
}
isEnabled() {
return this._isEnabled;
}
hasPendingUpdates() {
return this._pendingUpdate != null;
}
}
function mergeUpdates(base, next) {
const addedIDs = new Set();
const deletedIDs = new Set();
const moduleMap = new Map();
applyUpdateLocally(base);
applyUpdateLocally(next);
function applyUpdateLocally(update) {
update.deleted.forEach((id) => {
if (addedIDs.has(id)) {
addedIDs.delete(id);
} else {
deletedIDs.add(id);
}
moduleMap.delete(id);
});
update.added.forEach((item) => {
const id = item.module[0];
if (deletedIDs.has(id)) {
deletedIDs.delete(id);
} else {
addedIDs.add(id);
}
moduleMap.set(id, item);
});
update.modified.forEach((item) => {
const id = item.module[0];
moduleMap.set(id, item);
});
}
const result = {
isInitialUpdate: next.isInitialUpdate,
revisionId: next.revisionId,
added: [],
modified: [],
deleted: [],
};
deletedIDs.forEach((id) => {
result.deleted.push(id);
});
moduleMap.forEach((item, id) => {
if (deletedIDs.has(id)) {
return;
}
if (addedIDs.has(id)) {
result.added.push(item);
} else {
result.modified.push(item);
}
});
return result;
}
module.exports = HMRClient;

View File

@@ -0,0 +1,232 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
* @oncall react_native
*/
'use strict';
import type {HmrModule} from './types';
import type {HmrMessage, HmrUpdate} from './types';
const EventEmitter = require('./vendor/eventemitter3');
const HEARTBEAT_INTERVAL_MS = 20_000;
type SocketState = 'opening' | 'open' | 'closed';
const inject = ({module: [id, code], sourceURL}: HmrModule) => {
// Some engines do not support `sourceURL` as a comment. We expose a
// `globalEvalWithSourceUrl` function to handle updates in that case.
if (global.globalEvalWithSourceUrl) {
global.globalEvalWithSourceUrl(code, sourceURL);
} else {
// eslint-disable-next-line no-eval
eval(code);
}
};
const injectUpdate = (update: HmrUpdate) => {
update.added.forEach(inject);
update.modified.forEach(inject);
};
class HMRClient extends EventEmitter {
_isEnabled: boolean = false;
_pendingUpdate: HmrUpdate | null = null;
_queue: Array<string> = [];
_state: SocketState = 'opening';
_ws: WebSocket;
_heartbeatTimer: ?IntervalID = null;
constructor(url: string) {
super();
// Access the global WebSocket object only after enabling the client,
// since some polyfills do the initialization lazily.
this._ws = new global.WebSocket(url);
this._ws.onopen = () => {
this._state = 'open';
this._startHeartbeat();
this.emit('open');
this._flushQueue();
};
this._ws.onerror = error => {
this.emit('connection-error', error);
};
this._ws.onclose = closeEvent => {
this._state = 'closed';
this._stopHeartbeat();
this.emit('close', closeEvent);
};
this._ws.onmessage = message => {
const data: HmrMessage = JSON.parse(String(message.data));
switch (data.type) {
case 'heartbeat':
// Not exposed to consumers
break;
case 'bundle-registered':
this.emit('bundle-registered');
break;
case 'update-start':
this.emit('update-start', data.body);
break;
case 'update':
this.emit('update', data.body);
break;
case 'update-done':
this.emit('update-done', data.body);
break;
case 'error':
this.emit('error', data.body);
break;
default:
this.emit('error', {type: 'unknown-message', message: data});
}
};
this.on('update', (update: HmrUpdate) => {
if (this._isEnabled) {
injectUpdate(update);
} else if (this._pendingUpdate == null) {
this._pendingUpdate = update;
} else {
this._pendingUpdate = mergeUpdates(this._pendingUpdate, update);
}
});
}
close(): void {
this._ws.close();
}
send(message: string): void {
switch (this._state) {
case 'opening':
this._queue.push(message);
break;
case 'open':
this._ws.send(message);
break;
case 'closed':
// Ignore.
break;
default:
throw new Error('[WebSocketHMRClient] Unknown state: ' + this._state);
}
}
_flushQueue(): void {
this._queue.forEach(message => this.send(message));
this._queue.length = 0;
}
_startHeartbeat(): void {
this._stopHeartbeat();
this._heartbeatTimer = setInterval(() => {
if (this._state === 'open') {
this._ws.send('{"type":"heartbeat"}');
}
}, HEARTBEAT_INTERVAL_MS);
}
_stopHeartbeat(): void {
if (this._heartbeatTimer != null) {
clearInterval(this._heartbeatTimer);
this._heartbeatTimer = null;
}
}
enable() {
this._isEnabled = true;
const update = this._pendingUpdate;
this._pendingUpdate = null;
if (update != null) {
injectUpdate(update);
}
}
disable() {
this._isEnabled = false;
}
isEnabled(): boolean {
return this._isEnabled;
}
hasPendingUpdates(): boolean {
return this._pendingUpdate != null;
}
}
function mergeUpdates(base: HmrUpdate, next: HmrUpdate): HmrUpdate {
const addedIDs = new Set<number>();
const deletedIDs = new Set<number>();
const moduleMap = new Map<number, HmrModule>();
// Fill in the temporary maps and sets from both updates in their order.
applyUpdateLocally(base);
applyUpdateLocally(next);
function applyUpdateLocally(update: HmrUpdate) {
update.deleted.forEach(id => {
if (addedIDs.has(id)) {
addedIDs.delete(id);
} else {
deletedIDs.add(id);
}
moduleMap.delete(id);
});
update.added.forEach(item => {
const id = item.module[0];
if (deletedIDs.has(id)) {
deletedIDs.delete(id);
} else {
addedIDs.add(id);
}
moduleMap.set(id, item);
});
update.modified.forEach(item => {
const id = item.module[0];
moduleMap.set(id, item);
});
}
// Now reconstruct a unified update from our in-memory maps and sets.
// Applying it should be equivalent to applying both of them individually.
const result = {
isInitialUpdate: next.isInitialUpdate,
revisionId: next.revisionId,
added: [] as Array<HmrModule>,
modified: [] as Array<HmrModule>,
deleted: [] as Array<number>,
};
deletedIDs.forEach(id => {
result.deleted.push(id);
});
moduleMap.forEach((item, id) => {
if (deletedIDs.has(id)) {
return;
}
if (addedIDs.has(id)) {
result.added.push(item);
} else {
result.modified.push(item);
}
});
return result;
}
module.exports = HMRClient;

39
node_modules/metro-runtime/src/modules/asyncRequire.js generated vendored Normal file
View File

@@ -0,0 +1,39 @@
"use strict";
function maybeLoadBundle(moduleID, paths) {
const loadBundle = global[`${__METRO_GLOBAL_PREFIX__}__loadBundleAsync`];
if (loadBundle != null) {
const stringModuleID = String(moduleID);
if (paths != null) {
const bundlePath = paths[stringModuleID];
if (bundlePath != null) {
return loadBundle(bundlePath);
}
}
}
return undefined;
}
function asyncRequireImpl(moduleID, paths) {
const maybeLoadBundlePromise = maybeLoadBundle(moduleID, paths);
const importAll = () => require.importAll(moduleID);
if (maybeLoadBundlePromise != null) {
return maybeLoadBundlePromise.then(importAll);
}
return importAll();
}
async function asyncRequire(moduleID, paths, moduleName) {
return asyncRequireImpl(moduleID, paths);
}
asyncRequire.unstable_importMaybeSync = function unstable_importMaybeSync(
moduleID,
paths,
) {
return asyncRequireImpl(moduleID, paths);
};
asyncRequire.prefetch = function (moduleID, paths, moduleName) {
maybeLoadBundle(moduleID, paths)?.then(
() => {},
() => {},
);
};
module.exports = asyncRequire;

View File

@@ -0,0 +1,87 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
* @oncall react_native
*/
type MetroRequire = {
(number): unknown,
importAll: <T>(number) => T,
...
};
declare var require: MetroRequire;
type DependencyMapPaths = ?Readonly<{[moduleID: number | string]: unknown}>;
declare var __METRO_GLOBAL_PREFIX__: string;
function maybeLoadBundle(
moduleID: number,
paths: DependencyMapPaths,
): void | Promise<void> {
const loadBundle: (bundlePath: unknown) => Promise<void> =
global[`${__METRO_GLOBAL_PREFIX__}__loadBundleAsync`];
if (loadBundle != null) {
const stringModuleID = String(moduleID);
if (paths != null) {
const bundlePath = paths[stringModuleID];
if (bundlePath != null) {
// NOTE: Errors will be swallowed by asyncRequire.prefetch
return loadBundle(bundlePath);
}
}
}
return undefined;
}
function asyncRequireImpl<T>(
moduleID: number,
paths: DependencyMapPaths,
): Promise<T> | T {
const maybeLoadBundlePromise = maybeLoadBundle(moduleID, paths);
const importAll = () => require.importAll<T>(moduleID);
if (maybeLoadBundlePromise != null) {
return maybeLoadBundlePromise.then(importAll);
}
return importAll();
}
async function asyncRequire<T>(
moduleID: number,
paths: DependencyMapPaths,
moduleName?: string, // unused
): Promise<T> {
return asyncRequireImpl<T>(moduleID, paths);
}
// Synchronous version of asyncRequire, which can still return a promise
// if the module is split.
asyncRequire.unstable_importMaybeSync = function unstable_importMaybeSync<T>(
moduleID: number,
paths: DependencyMapPaths,
): Promise<T> | T {
return asyncRequireImpl(moduleID, paths);
};
asyncRequire.prefetch = function (
moduleID: number,
paths: DependencyMapPaths,
moduleName?: string, // unused
): void {
maybeLoadBundle(moduleID, paths)?.then(
() => {},
() => {},
);
};
module.exports = asyncRequire;

View File

@@ -0,0 +1 @@
"use strict";

View File

@@ -0,0 +1,9 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
* @flow strict
*/

View File

@@ -0,0 +1,3 @@
"use strict";
module.exports = null;

View File

@@ -0,0 +1,11 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
* @flow strict
*/
module.exports = null;

104
node_modules/metro-runtime/src/modules/types.d.ts generated vendored Normal file
View File

@@ -0,0 +1,104 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @noformat
* @oncall react_native
* @generated SignedSource<<117ae8d35a498c8c16f22a36d6ee14ef>>
*
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
* Original file: packages/metro-runtime/src/modules/types.js
* To regenerate, run:
* js1 build metro-ts-defs (internal) OR
* yarn run build-ts-defs (OSS)
*/
export type ModuleMap = ReadonlyArray<[number, string]>;
export type Bundle = {
readonly modules: ModuleMap;
readonly post: string;
readonly pre: string;
};
export type DeltaBundle = {
readonly added: ModuleMap;
readonly modified: ModuleMap;
readonly deleted: ReadonlyArray<number>;
};
export type BundleVariant =
| Readonly<
Omit<Bundle, keyof {base: true; revisionId: string}> & {
base: true;
revisionId: string;
}
>
| Readonly<
Omit<DeltaBundle, keyof {base: false; revisionId: string}> & {
base: false;
revisionId: string;
}
>;
export type BundleMetadata = {
readonly pre: number;
readonly post: number;
readonly modules: ReadonlyArray<[number, number]>;
};
export type FormattedError = {
readonly type: string;
readonly message: string;
readonly errors: Array<{description: string}>;
};
export type HmrModule = {
readonly module: [number, string];
readonly sourceMappingURL: string;
readonly sourceURL: string;
};
export type HmrUpdate = {
readonly added: ReadonlyArray<HmrModule>;
readonly deleted: ReadonlyArray<number>;
readonly isInitialUpdate: boolean;
readonly modified: ReadonlyArray<HmrModule>;
readonly revisionId: string;
};
export type HmrUpdateMessage = {
readonly type: 'update';
readonly body: HmrUpdate;
};
export type HmrErrorMessage = {
readonly type: 'error';
readonly body: FormattedError;
};
export type HmrClientMessage =
| {
readonly type: 'register-entrypoints';
readonly entryPoints: Array<string>;
}
| {
readonly type: 'log';
readonly level:
| 'trace'
| 'info'
| 'warn'
| 'log'
| 'group'
| 'groupCollapsed'
| 'groupEnd'
| 'debug';
readonly data: Array<unknown>;
}
| {readonly type: 'log-opt-in'}
| {readonly type: 'heartbeat'};
export type HmrMessage =
| {readonly type: 'bundle-registered'}
| {
readonly type: 'update-start';
readonly body: {readonly isInitialUpdate: boolean};
}
| {
readonly type: 'update-done';
readonly body?: {readonly changeId?: string};
}
| HmrUpdateMessage
| HmrErrorMessage
| {readonly type: 'heartbeat'};

1
node_modules/metro-runtime/src/modules/types.js generated vendored Normal file
View File

@@ -0,0 +1 @@
"use strict";

109
node_modules/metro-runtime/src/modules/types.js.flow generated vendored Normal file
View File

@@ -0,0 +1,109 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
* @oncall react_native
*/
export type ModuleMap = ReadonlyArray<[number, string]>;
export type Bundle = {
+modules: ModuleMap,
+post: string,
+pre: string,
};
export type DeltaBundle = {
+added: ModuleMap,
+modified: ModuleMap,
+deleted: ReadonlyArray<number>,
};
export type BundleVariant =
| Readonly<{...Bundle, base: true, revisionId: string}>
| Readonly<{...DeltaBundle, base: false, revisionId: string}>;
export type BundleMetadata = {
+pre: number,
+post: number,
+modules: ReadonlyArray<[number, number]>,
};
export type FormattedError = {
+type: string,
+message: string,
+errors: Array<{description: string, ...}>,
};
export type HmrModule = {
+module: [number, string],
+sourceMappingURL: string,
+sourceURL: string,
};
export type HmrUpdate = {
+added: ReadonlyArray<HmrModule>,
+deleted: ReadonlyArray<number>,
+isInitialUpdate: boolean,
+modified: ReadonlyArray<HmrModule>,
+revisionId: string,
};
export type HmrUpdateMessage = {
+type: 'update',
+body: HmrUpdate,
};
export type HmrErrorMessage = {
+type: 'error',
+body: FormattedError,
};
export type HmrClientMessage =
| {
+type: 'register-entrypoints',
+entryPoints: Array<string>,
}
| {
+type: 'log',
+level:
| 'trace'
| 'info'
| 'warn'
| 'log'
| 'group'
| 'groupCollapsed'
| 'groupEnd'
| 'debug',
+data: Array<unknown>,
}
| {
+type: 'log-opt-in',
}
| {
+type: 'heartbeat',
};
export type HmrMessage =
| {
+type: 'bundle-registered',
}
| {
+type: 'update-start',
+body: {
+isInitialUpdate: boolean,
},
}
| {
+type: 'update-done',
+body?: {+changeId?: string},
}
| HmrUpdateMessage
| HmrErrorMessage
| {
+type: 'heartbeat',
};

View File

@@ -0,0 +1,183 @@
"use strict";
var has = Object.prototype.hasOwnProperty,
prefix = "~";
function Events() {}
if (Object.create) {
Events.prototype = Object.create(null);
if (!new Events().__proto__) prefix = false;
}
function EE(fn, context, once) {
this.fn = fn;
this.context = context;
this.once = once || false;
}
function addListener(emitter, event, fn, context, once) {
if (typeof fn !== "function") {
throw new TypeError("The listener must be a function");
}
var listener = new EE(fn, context || emitter, once),
evt = prefix ? prefix + event : event;
if (!emitter._events[evt])
((emitter._events[evt] = listener), emitter._eventsCount++);
else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);
else emitter._events[evt] = [emitter._events[evt], listener];
return emitter;
}
function clearEvent(emitter, evt) {
if (--emitter._eventsCount === 0) emitter._events = new Events();
else delete emitter._events[evt];
}
function EventEmitter() {
this._events = new Events();
this._eventsCount = 0;
}
EventEmitter.prototype.eventNames = function eventNames() {
var names = [],
events,
name;
if (this._eventsCount === 0) return names;
for (name in (events = this._events)) {
if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
}
if (Object.getOwnPropertySymbols) {
return names.concat(Object.getOwnPropertySymbols(events));
}
return names;
};
EventEmitter.prototype.listeners = function listeners(event) {
var evt = prefix ? prefix + event : event,
handlers = this._events[evt];
if (!handlers) return [];
if (handlers.fn) return [handlers.fn];
for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {
ee[i] = handlers[i].fn;
}
return ee;
};
EventEmitter.prototype.listenerCount = function listenerCount(event) {
var evt = prefix ? prefix + event : event,
listeners = this._events[evt];
if (!listeners) return 0;
if (listeners.fn) return 1;
return listeners.length;
};
EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
var evt = prefix ? prefix + event : event;
if (!this._events[evt]) return false;
var listeners = this._events[evt],
len = arguments.length,
args,
i;
if (listeners.fn) {
if (listeners.once)
this.removeListener(event, listeners.fn, undefined, true);
switch (len) {
case 1:
return (listeners.fn.call(listeners.context), true);
case 2:
return (listeners.fn.call(listeners.context, a1), true);
case 3:
return (listeners.fn.call(listeners.context, a1, a2), true);
case 4:
return (listeners.fn.call(listeners.context, a1, a2, a3), true);
case 5:
return (listeners.fn.call(listeners.context, a1, a2, a3, a4), true);
case 6:
return (listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true);
}
for (i = 1, args = new Array(len - 1); i < len; i++) {
args[i - 1] = arguments[i];
}
listeners.fn.apply(listeners.context, args);
} else {
var length = listeners.length,
j;
for (i = 0; i < length; i++) {
if (listeners[i].once)
this.removeListener(event, listeners[i].fn, undefined, true);
switch (len) {
case 1:
listeners[i].fn.call(listeners[i].context);
break;
case 2:
listeners[i].fn.call(listeners[i].context, a1);
break;
case 3:
listeners[i].fn.call(listeners[i].context, a1, a2);
break;
case 4:
listeners[i].fn.call(listeners[i].context, a1, a2, a3);
break;
default:
if (!args)
for (j = 1, args = new Array(len - 1); j < len; j++) {
args[j - 1] = arguments[j];
}
listeners[i].fn.apply(listeners[i].context, args);
}
}
}
return true;
};
EventEmitter.prototype.on = function on(event, fn, context) {
return addListener(this, event, fn, context, false);
};
EventEmitter.prototype.once = function once(event, fn, context) {
return addListener(this, event, fn, context, true);
};
EventEmitter.prototype.removeListener = function removeListener(
event,
fn,
context,
once,
) {
var evt = prefix ? prefix + event : event;
if (!this._events[evt]) return this;
if (!fn) {
clearEvent(this, evt);
return this;
}
var listeners = this._events[evt];
if (listeners.fn) {
if (
listeners.fn === fn &&
(!once || listeners.once) &&
(!context || listeners.context === context)
) {
clearEvent(this, evt);
}
} else {
for (var i = 0, events = [], length = listeners.length; i < length; i++) {
if (
listeners[i].fn !== fn ||
(once && !listeners[i].once) ||
(context && listeners[i].context !== context)
) {
events.push(listeners[i]);
}
}
if (events.length)
this._events[evt] = events.length === 1 ? events[0] : events;
else clearEvent(this, evt);
}
return this;
};
EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
var evt;
if (event) {
evt = prefix ? prefix + event : event;
if (this._events[evt]) clearEvent(this, evt);
} else {
this._events = new Events();
this._eventsCount = 0;
}
return this;
};
EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
EventEmitter.prototype.addListener = EventEmitter.prototype.on;
EventEmitter.prefixed = prefix;
EventEmitter.EventEmitter = EventEmitter;
if ("undefined" !== typeof module) {
module.exports = EventEmitter;
}

View File

@@ -0,0 +1,41 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @format
*/
'use strict';
declare type ListenerFn = (...args: any[]) => unknown;
declare class EventEmitter {
static constructor(): EventEmitter;
static prefixed: string | boolean;
eventNames(): (string | Symbol)[];
listeners(event: string | Symbol): ListenerFn[];
listenerCount(event: string | Symbol): number;
on(event: string | Symbol, listener: ListenerFn, context?: any): this;
addListener(
event: string | Symbol,
listener: ListenerFn,
context?: any,
): this;
once(event: string | Symbol, listener: ListenerFn, context?: any): this;
removeAllListeners(event?: string | Symbol): this;
removeListener(
event: string | Symbol,
listener?: ListenerFn,
context?: any,
once?: boolean,
): this;
off(
event: string | Symbol,
listener?: ListenerFn,
context?: any,
once?: boolean,
): this;
emit(event: string, ...params?: any[]): this;
}
declare module.exports: Class<EventEmitter>;