first commit

This commit is contained in:
2026-03-10 16:18:05 +00:00
commit 11f9c069b5
31635 changed files with 3187747 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
/**
* 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
* @oncall react_native
*/
import type { HmrUpdate } from "./types";
import EventEmitter from "./vendor/eventemitter3";
export declare const enum _SocketState {
opening = "opening",
open = "open",
closed = "closed",
}
export type SocketState = `${_SocketState}`;
declare class HMRClient extends EventEmitter {
_isEnabled: boolean;
_pendingUpdate: HmrUpdate | null;
_queue: Array<string>;
_state: SocketState;
_ws: WebSocket;
constructor(url: string);
close(): void;
send(message: string): void;
_flushQueue(): void;
enable(): void;
disable(): void;
isEnabled(): boolean;
hasPendingUpdates(): boolean;
}
export default HMRClient;

View File

@@ -0,0 +1 @@
module.exports = require("metro-runtime/src/modules/HMRClient.js");

View File

@@ -0,0 +1,15 @@
/**
* 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
* @oncall react_native
*/
type DependencyMapPaths = null | undefined | {
readonly [moduleID: number | string]: any;
};
declare function asyncRequire<T>(moduleID: number, paths: DependencyMapPaths, moduleName?: string): Promise<T>;
export default asyncRequire;

View File

@@ -0,0 +1 @@
module.exports = require("metro-runtime/src/modules/asyncRequire.js");

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
*
*/

View File

@@ -0,0 +1 @@
module.exports = require("metro-runtime/src/modules/empty-module.js");

View File

@@ -0,0 +1,2 @@
declare const $$EXPORT_DEFAULT_DECLARATION$$: null;
export default $$EXPORT_DEFAULT_DECLARATION$$;

View File

@@ -0,0 +1 @@
module.exports = require("metro-runtime/src/modules/null-module.js");

View File

@@ -0,0 +1,81 @@
/**
* 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
* @oncall react_native
*/
export type ModuleMap = ReadonlyArray<[number, string]>;
export interface Bundle {
readonly modules: ModuleMap;
readonly post: string;
readonly pre: string;
}
export interface DeltaBundle {
readonly added: ModuleMap;
readonly modified: ModuleMap;
readonly deleted: ReadonlyArray<number>;
}
export type BundleVariant = ({
readonly base: true;
readonly revisionId: string;
} & Bundle) | ({
readonly base: false;
readonly revisionId: string;
} & DeltaBundle);
export interface BundleMetadata {
readonly pre: number;
readonly post: number;
readonly modules: ReadonlyArray<[number, number]>;
}
export interface FormattedError {
readonly type: string;
readonly message: string;
readonly errors: Array<{
description: string;
}>;
}
export interface HmrModule {
readonly module: [number, string];
readonly sourceMappingURL: string;
readonly sourceURL: string;
}
export interface HmrUpdate {
readonly added: ReadonlyArray<HmrModule>;
readonly deleted: ReadonlyArray<number>;
readonly isInitialUpdate: boolean;
readonly modified: ReadonlyArray<HmrModule>;
readonly revisionId: string;
}
export interface HmrUpdateMessage {
readonly type: "update";
readonly body: HmrUpdate;
}
export interface 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<any>;
} | {
readonly type: "log-opt-in";
};
export type HmrMessage = {
readonly type: "bundle-registered";
} | {
readonly type: "update-start";
readonly body: {
readonly isInitialUpdate: boolean;
};
} | {
readonly type: "update-done";
} | HmrUpdateMessage | HmrErrorMessage;

View File

@@ -0,0 +1 @@
module.exports = require("metro-runtime/src/modules/types.js");

View File

@@ -0,0 +1,66 @@
// See: https://github.com/facebook/metro/blob/v0.83.2/packages/metro-runtime/src/modules/vendor/eventemitter3.js
/**
* `object` should be in either of the following forms:
* ```
* interface EventTypes {
* 'event-with-parameters': any[]
* 'event-with-example-handler': (...args: any[]) => void
* }
* ```
*/
export type ValidEventTypes = string | symbol | object;
export type EventNames<T extends ValidEventTypes> = T extends string | symbol ? T : keyof T;
export type ArgumentMap<T extends object> = {
[K in keyof T]: T[K] extends (...args: any[]) => void ? Parameters<T[K]> : T[K] extends any[] ? T[K] : any[];
};
export type EventListener<T extends ValidEventTypes, K extends EventNames<T>> = T extends string | symbol
? (...args: any[]) => void
: (...args: ArgumentMap<Exclude<T, string | symbol>>[Extract<K, keyof T>]) => void;
export type EventArgs<T extends ValidEventTypes, K extends EventNames<T>> = Parameters<EventListener<T, K>>;
export class EventEmitter<EventTypes extends ValidEventTypes = string | symbol, Context extends any = any> {
static prefixed: string | boolean;
/** Return an array listing the events for which the emitter has registered listeners. */
eventNames(): Array<EventNames<EventTypes>>;
/** Return the listeners registered for a given event. */
listeners<T extends EventNames<EventTypes>>(event: T): Array<EventListener<EventTypes, T>>;
/** Return the number of listeners listening to a given event. */
listenerCount(event: EventNames<EventTypes>): number;
/** Calls each of the listeners registered for a given event. */
emit<T extends EventNames<EventTypes>>(event: T, ...args: EventArgs<EventTypes, T>): boolean;
/** Add a listener for a given event. */
on<T extends EventNames<EventTypes>>(event: T, fn: EventListener<EventTypes, T>, context?: Context): this;
addListener<T extends EventNames<EventTypes>>(event: T, fn: EventListener<EventTypes, T>, context?: Context): this;
/** Add a one-time listener for a given event. */
once<T extends EventNames<EventTypes>>(event: T, fn: EventListener<EventTypes, T>, context?: Context): this;
/** Remove the listeners of a given event. */
removeListener<T extends EventNames<EventTypes>>(
event: T,
fn?: EventListener<EventTypes, T>,
context?: Context,
once?: boolean
): this;
off<T extends EventNames<EventTypes>>(
event: T,
fn?: EventListener<EventTypes, T>,
context?: Context,
once?: boolean
): this;
/** Remove all listeners, or those of the specified event. */
removeAllListeners(event?: EventNames<EventTypes>): this;
}
export default EventEmitter;

View File

@@ -0,0 +1 @@
module.exports = require("metro-runtime/src/modules/vendor/eventemitter3.js");

View File

@@ -0,0 +1,32 @@
/**
* 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
* @oncall react_native
* @polyfill
*/
type ArrayIndexable<T> = {
readonly [indexer: number]: T;
};
export interface _DependencyMap_paths {
[id: ModuleID]: string;
}
export interface DependencyMap extends Readonly<ArrayIndexable<ModuleID>> {
readonly paths?: _DependencyMap_paths;
}
export interface InverseDependencyMap {
[key: ModuleID]: Array<ModuleID>;
}
type Exports = any;
type FactoryFn = (global: Object, require: RequireFn, metroImportDefault: RequireFn, metroImportAll: RequireFn, moduleObject: {
exports: {};
}, exports: {}, dependencyMap: null | undefined | DependencyMap) => void;
type ModuleID = number;
export type RequireFn = (id: ModuleID | VerboseModuleNameForDev) => Exports;
export type DefineFn = (factory: FactoryFn, moduleId: number, dependencyMap?: DependencyMap, verboseName?: string, inverseDependencies?: InverseDependencyMap) => void;
type VerboseModuleNameForDev = string;

View File

@@ -0,0 +1 @@
module.exports = require("metro-runtime/src/polyfills/require.js");