chore: add mobile app

This commit is contained in:
2026-02-07 22:33:02 +01:00
parent db34640acc
commit e89384ad4e
29327 changed files with 3886944 additions and 12 deletions
+65
View File
@@ -0,0 +1,65 @@
/**
* 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 interface AssetInfo {
readonly files: Array<string>;
readonly hash: string;
readonly name: string;
readonly scales: Array<number>;
readonly type: string;
}
export interface AssetDataWithoutFiles {
readonly __packager_asset: boolean;
readonly fileSystemLocation: string;
readonly hash: string;
readonly height?: null | number;
readonly httpServerLocation: string;
readonly name: string;
readonly scales: Array<number>;
readonly type: string;
readonly width?: null | number;
}
export interface AssetDataFiltered {
readonly __packager_asset: boolean;
readonly hash: string;
readonly height?: null | number;
readonly httpServerLocation: string;
readonly name: string;
readonly scales: Array<number>;
readonly type: string;
readonly width?: null | number;
}
export declare function isAssetTypeAnImage(type: string): boolean;
export declare function getAssetSize(type: string, content: Buffer, filePath: string): null | undefined | {
readonly width: number;
readonly height: number;
};
export interface AssetData extends AssetDataWithoutFiles {
readonly files: Array<string>;
}
export type AssetDataPlugin = (assetData: AssetData) => AssetData | Promise<AssetData>;
export declare function getAssetData(assetPath: string, localPath: string, assetDataPlugins: ReadonlyArray<string>, platform: null | undefined | string, publicPath: string): Promise<AssetData>;
/**
* Returns all the associated files (for different resolutions) of an asset.
**/
export declare function getAssetFiles(assetPath: string, platform?: null | undefined | string): Promise<Array<string>>;
/**
* Return a buffer with the actual image given a request for an image by path.
* The relativePath can contain a resolution postfix, in this case we need to
* find that image (or the closest one to it's resolution) in one of the
* project roots:
*
* 1. We first parse the directory of the asset
* 2. We then build a map of all assets and their scales in this directory
* 3. Then try to pick platform-specific asset records
* 4. Then pick the closest resolution (rounding up) to the requested one
*/
export declare function getAsset(relativePath: string, projectRoot: string, watchFolders: ReadonlyArray<string>, platform: null | undefined | string, assetExts: ReadonlyArray<string>): Promise<Buffer>;
+2
View File
@@ -0,0 +1,2 @@
module.exports = require("metro/private/Assets");
module.exports.default = module.exports;
+33
View File
@@ -0,0 +1,33 @@
/**
* 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 { TransformResultWithSource } from "./DeltaBundler";
import type { TransformOptions } from "./DeltaBundler/Worker";
import type EventEmitter from "node:events";
import type { ConfigT } from "../metro-config";
import Transformer from "./DeltaBundler/Transformer";
import DependencyGraph from "./node-haste/DependencyGraph";
export interface BundlerOptions {
readonly hasReducedPerformance?: boolean;
readonly watch?: boolean;
}
declare class Bundler {
_depGraph: DependencyGraph;
_initializedPromise: Promise<void>;
_transformer: Transformer;
constructor(config: ConfigT, options?: BundlerOptions);
getWatcher(): EventEmitter;
end(): Promise<void>;
getDependencyGraph(): Promise<DependencyGraph>;
transformFile(filePath: string, transformOptions: TransformOptions, fileBuffer?: Buffer): Promise<TransformResultWithSource>;
ready(): Promise<void>;
}
export default Bundler;
+1
View File
@@ -0,0 +1 @@
module.exports = require("metro/private/Bundler");
+17
View File
@@ -0,0 +1,17 @@
/**
* 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 { AssetDataWithoutFiles } from "../Assets";
import type { ModuleTransportLike } from "../shared/types";
import type { File } from "@babel/types";
type SubTree<T extends ModuleTransportLike> = (moduleTransport: T, moduleTransportsByPath: Map<string, T>) => Iterable<number>;
export declare function generateAssetCodeFileAst(assetRegistryPath: string, assetDescriptor: AssetDataWithoutFiles): File;
export declare function createRamBundleGroups<T extends ModuleTransportLike>(ramGroups: ReadonlyArray<string>, groupableModules: ReadonlyArray<T>, subtree: SubTree<T>): Map<number, Set<number>>;
+2
View File
@@ -0,0 +1,2 @@
module.exports = require("metro/private/Bundler/util");
module.exports.default = module.exports;
+36
View File
@@ -0,0 +1,36 @@
/**
* 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 { DeltaResult, Graph, MixedOutput, Options, ReadOnlyGraph } from "./DeltaBundler/types";
import type EventEmitter from "node:events";
import DeltaCalculator from "./DeltaBundler/DeltaCalculator";
export type { DeltaResult, Graph, Dependencies, MixedOutput, Module, ReadOnlyGraph, TransformFn, TransformResult, TransformResultDependency, TransformResultWithSource } from "./DeltaBundler/types";
/**
* `DeltaBundler` uses the `DeltaTransformer` to build bundle deltas. This
* module handles all the transformer instances so it can support multiple
* concurrent clients requesting their own deltas. This is done through the
* `clientId` param (which maps a client to a specific delta transformer).
*/
declare class DeltaBundler<T = MixedOutput> {
_changeEventSource: EventEmitter;
_deltaCalculators: Map<Graph<T>, DeltaCalculator<T>>;
constructor(changeEventSource: EventEmitter);
end(): void;
getDependencies(entryPoints: ReadonlyArray<string>, options: Options<T>): Promise<ReadOnlyGraph<T>["dependencies"]>;
buildGraph(entryPoints: ReadonlyArray<string>, options: Options<T>): Promise<Graph<T>>;
getDelta(graph: Graph<T>, $$PARAM_1$$: {
reset: boolean;
shallow: boolean;
}): Promise<DeltaResult<T>>;
listen(graph: Graph<T>, callback: () => Promise<void>): () => void;
endGraph(graph: Graph<T>): void;
}
export default DeltaBundler;
+1
View File
@@ -0,0 +1 @@
module.exports = require("metro/private/DeltaBundler");
@@ -0,0 +1,41 @@
/**
* 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 { DeltaResult, Options } from "./types";
import { Graph } from "./Graph";
import EventEmitter from "node:events";
/**
* This class is in charge of calculating the delta of changed modules that
* happen between calls. To do so, it subscribes to file changes, so it can
* traverse the files that have been changed between calls and avoid having to
* traverse the whole dependency tree for trivial small changes.
*/
declare class DeltaCalculator<T> extends EventEmitter {
_changeEventSource: EventEmitter;
_options: Options<T>;
_currentBuildPromise: null | undefined | Promise<DeltaResult<T>>;
_deletedFiles: Set<string>;
_modifiedFiles: Set<string>;
_addedFiles: Set<string>;
_requiresReset: any;
_graph: Graph<T>;
constructor(entryPoints: ReadonlySet<string>, changeEventSource: EventEmitter, options: Options<T>);
end(): void;
getDelta($$PARAM_0$$: {
reset: boolean;
shallow: boolean;
}): Promise<DeltaResult<T>>;
getGraph(): Graph<T>;
_handleMultipleFileChanges: any;
_handleFileChange: any;
_getChangedDependencies(modifiedFiles: Set<string>, deletedFiles: Set<string>, addedFiles: Set<string>): Promise<DeltaResult<T>>;
}
export default DeltaCalculator;
@@ -0,0 +1 @@
module.exports = require("metro/private/DeltaBundler/DeltaCalculator");
+100
View File
@@ -0,0 +1,100 @@
/**
* 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
*/
/**
* Portions of this code are based on the Synchronous Cycle Collection
* algorithm described in:
*
* David F. Bacon and V. T. Rajan. 2001. Concurrent Cycle Collection in
* Reference Counted Systems. In Proceedings of the 15th European Conference on
* Object-Oriented Programming (ECOOP '01). Springer-Verlag, Berlin,
* Heidelberg, 207235.
*
* Notable differences from the algorithm in the paper:
* 1. Our implementation uses the inverseDependencies set (which we already
* have to maintain) instead of a separate refcount variable. A module's
* reference count is equal to the size of its inverseDependencies set, plus
* 1 if it's an entry point of the graph.
* 2. We keep the "root buffer" (possibleCycleRoots) free of duplicates by
* making it a Set, instead of storing a "buffered" flag on each node.
* 3. On top of tracking edges between nodes, we also count references between
* nodes and entries in the importBundleNodes set.
*/
import type { RequireContext } from "../lib/contextModule";
import type { Dependencies, Dependency, GraphInputOptions, MixedOutput, Module, ModuleData, Options, ResolvedDependency, TransformInputOptions } from "./types";
import CountingSet from "../lib/CountingSet";
export interface Result<T> {
added: Map<string, Module<T>>;
modified: Map<string, Module<T>>;
deleted: Set<string>;
}
/**
* Internal data structure that the traversal logic uses to know which of the
* files have been modified. This allows to return the added modules before the
* modified ones (which is useful for things like Hot Module Reloading).
**/
/**
* Internal data structure that the traversal logic uses to know which of the
* files have been modified. This allows to return the added modules before the
* modified ones (which is useful for things like Hot Module Reloading).
**/
export interface Delta<T> {
readonly added: Set<string>;
readonly touched: Set<string>;
readonly deleted: Set<string>;
readonly updatedModuleData: ReadonlyMap<string, ModuleData<T>>;
readonly baseModuleData: Map<string, ModuleData<T>>;
readonly errors: ReadonlyMap<string, Error>;
}
export interface InternalOptions<T> {
readonly lazy: boolean;
readonly onDependencyAdd: () => any;
readonly onDependencyAdded: () => any;
readonly resolve: Options<T>["resolve"];
readonly transform: Options<T>["transform"];
readonly shallow: boolean;
}
export declare class Graph<T = MixedOutput> {
readonly entryPoints: ReadonlySet<string>;
readonly transformOptions: TransformInputOptions;
readonly dependencies: Dependencies<T>;
constructor(options: GraphInputOptions);
traverseDependencies(paths: ReadonlyArray<string>, options: Options<T>): Promise<Result<T>>;
initialTraverseDependencies(options: Options<T>): Promise<Result<T>>;
_buildDelta(pathsToVisit: ReadonlySet<string>, options: InternalOptions<T>, moduleFilter?: (path: string) => boolean): Promise<Delta<T>>;
_recursivelyCommitModule(path: string, delta: Delta<T>, options: InternalOptions<T>, commitOptions: {
readonly onlyRemove: boolean;
}): Module<T>;
_addDependency(parentModule: Module<T>, key: string, dependency: Dependency, requireContext: null | undefined | RequireContext, delta: Delta<T>, options: InternalOptions<T>): void;
_removeDependency(parentModule: Module<T>, key: string, dependency: Dependency, delta: Delta<T>, options: InternalOptions<T>): void;
markModifiedContextModules(filePath: string, modifiedPaths: Set<string> | CountingSet<string>): void;
getModifiedModulesForDeletedPath(filePath: string): Iterable<string>;
reorderGraph(options: {
shallow: boolean;
}): void;
_reorderDependencies(module: Module<T>, orderedDependencies: Map<string, Module<T>>, options: {
shallow: boolean;
}): void;
_incrementImportBundleReference(dependency: ResolvedDependency, parentModule: Module<T>): void;
_decrementImportBundleReference(dependency: ResolvedDependency, parentModule: Module<T>): void;
_markModuleInUse(module: Module<T>): void;
_children(module: Module<T>, options: InternalOptions<T>): Iterator<Module<T>>;
_moduleSnapshot(module: Module<T>): ModuleData<T>;
_releaseModule(module: Module<T>, delta: Delta<T>, options: InternalOptions<T>): void;
_freeModule(module: Module<T>, delta: Delta<T>): void;
_markAsPossibleCycleRoot(module: Module<T>): void;
_collectCycles(delta: Delta<T>, options: InternalOptions<T>): void;
_markGray(module: Module<T>, options: InternalOptions<T>): void;
_scan(module: Module<T>, options: InternalOptions<T>): void;
_scanBlack(module: Module<T>, options: InternalOptions<T>): void;
_collectWhite(module: Module<T>, delta: Delta<T>): void;
}
+2
View File
@@ -0,0 +1,2 @@
module.exports = require("metro/private/DeltaBundler/Graph");
module.exports.default = module.exports;
@@ -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
*/
import type { Module, ReadOnlyGraph, SerializerOptions } from "../types";
import type { Bundle } from "../../../metro-runtime/modules/types";
declare function baseJSBundle(entryPoint: string, preModules: ReadonlyArray<Module>, graph: ReadOnlyGraph, options: SerializerOptions): Bundle;
export default baseJSBundle;
@@ -0,0 +1 @@
module.exports = require("metro/private/DeltaBundler/Serializers/baseJSBundle");
@@ -0,0 +1,18 @@
/**
* 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 { Module, ReadOnlyGraph } from "../types";
export interface Options {
platform?: null | string;
readonly processModuleFilter: (module: Module) => boolean;
}
declare function getAllFiles(pre: ReadonlyArray<Module>, graph: ReadOnlyGraph, options: Options): Promise<ReadonlyArray<string>>;
export default getAllFiles;
@@ -0,0 +1 @@
module.exports = require("metro/private/DeltaBundler/Serializers/getAllFiles");
@@ -0,0 +1,22 @@
/**
* 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 { AssetData } from "../../Assets";
import type { Module, ReadOnlyDependencies } from "../types";
export interface Options {
readonly processModuleFilter: (module: Module) => boolean;
assetPlugins: ReadonlyArray<string>;
platform?: null | string;
projectRoot: string;
publicPath: string;
}
declare function getAssets(dependencies: ReadOnlyDependencies, options: Options): Promise<ReadonlyArray<AssetData>>;
export default getAssets;
@@ -0,0 +1 @@
module.exports = require("metro/private/DeltaBundler/Serializers/getAssets");
@@ -0,0 +1,22 @@
/**
* 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 { Module } from "../types";
import type { FBSourceFunctionMap, MetroSourceMapSegmentTuple } from "../../../metro-source-map";
export type ExplodedSourceMap = ReadonlyArray<{
readonly map: Array<MetroSourceMapSegmentTuple>;
readonly firstLine1Based: number;
readonly functionMap?: null | FBSourceFunctionMap;
readonly path: string;
}>;
export declare function getExplodedSourceMap(modules: ReadonlyArray<Module>, options: {
readonly processModuleFilter: (module: Module) => boolean;
}): ExplodedSourceMap;
@@ -0,0 +1,2 @@
module.exports = require("metro/private/DeltaBundler/Serializers/getExplodedSourceMap");
module.exports.default = module.exports;
@@ -0,0 +1,27 @@
/**
* 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 { ModuleTransportLike } from "../../shared/types";
import type { Module, ReadOnlyGraph, SerializerOptions } from "../types";
import type { SourceMapGeneratorOptions } from "./sourceMapGenerator";
import type { GetTransformOptions } from "../../../metro-config";
export interface Options extends SerializerOptions, SourceMapGeneratorOptions {
readonly getTransformOptions?: null | GetTransformOptions;
readonly platform?: null | string;
}
export interface RamBundleInfo {
getDependencies: ($$PARAM_0$$: string) => Set<string>;
startupModules: ReadonlyArray<ModuleTransportLike>;
lazyModules: ReadonlyArray<ModuleTransportLike>;
groups: Map<number, Set<number>>;
}
declare function getRamBundleInfo(entryPoint: string, pre: ReadonlyArray<Module>, graph: ReadOnlyGraph, options: Options): Promise<RamBundleInfo>;
export default getRamBundleInfo;
@@ -0,0 +1 @@
module.exports = require("metro/private/DeltaBundler/Serializers/getRamBundleInfo");
@@ -0,0 +1,13 @@
/**
* 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
*/
declare function getInlineSourceMappingURL(sourceMap: string): string;
export default getInlineSourceMappingURL;
@@ -0,0 +1 @@
module.exports = require("metro/private/DeltaBundler/Serializers/helpers/getInlineSourceMappingURL");
@@ -0,0 +1,27 @@
/**
* 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 { Module } from "../../types";
import type { FBSourceFunctionMap, MetroSourceMapSegmentTuple } from "../../../../metro-source-map";
declare function getSourceMapInfo(module: Module, options: {
readonly excludeSource: boolean;
readonly shouldAddToIgnoreList: ($$PARAM_0$$: Module) => boolean;
getSourceUrl?: null | ((module: Module) => string);
}): {
readonly map: Array<MetroSourceMapSegmentTuple>;
readonly functionMap?: null | FBSourceFunctionMap;
readonly code: string;
readonly path: string;
readonly source: string;
readonly lineCount: number;
readonly isIgnored: boolean;
};
export default getSourceMapInfo;
@@ -0,0 +1 @@
module.exports = require("metro/private/DeltaBundler/Serializers/helpers/getSourceMapInfo");
@@ -0,0 +1,14 @@
/**
* 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 { ReadOnlyGraph } from "../../types";
declare function getTransitiveDependencies<T>(path: string, graph: ReadOnlyGraph<T>): Set<string>;
export default getTransitiveDependencies;
@@ -0,0 +1 @@
module.exports = require("metro/private/DeltaBundler/Serializers/helpers/getTransitiveDependencies");
@@ -0,0 +1,28 @@
/**
* 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 { MixedOutput, Module } from "../../types";
import type { JsOutput } from "../../../../metro-transform-worker";
export interface Options {
readonly createModuleId: ($$PARAM_0$$: string) => number | string;
readonly dev: boolean;
readonly includeAsyncPaths: boolean;
readonly projectRoot: string;
readonly serverRoot: string;
readonly sourceUrl?: null | string;
}
export declare function wrapModule(module: Module, options: Options): string;
export declare function getModuleParams(module: Module, options: Options): Array<any>;
export declare function getJsOutput(module: {
readonly output: ReadonlyArray<MixedOutput>;
readonly path?: string;
}): JsOutput;
export declare function isJsModule(module: Module): boolean;
@@ -0,0 +1,2 @@
module.exports = require("metro/private/DeltaBundler/Serializers/helpers/js");
module.exports.default = module.exports;
@@ -0,0 +1,22 @@
/**
* 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 { Module } from "../../types";
declare function processModules(modules: ReadonlyArray<Module>, $$PARAM_1$$: {
readonly filter?: (module: Module) => boolean;
readonly createModuleId: ($$PARAM_0$$: string) => number;
readonly dev: boolean;
readonly includeAsyncPaths: boolean;
readonly projectRoot: string;
readonly serverRoot: string;
readonly sourceUrl?: null | string;
}): ReadonlyArray<[Module, string]>;
export default processModules;
@@ -0,0 +1 @@
module.exports = require("metro/private/DeltaBundler/Serializers/helpers/processModules");
@@ -0,0 +1,26 @@
/**
* 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 { DeltaResult, ReadOnlyGraph } from "../types";
import type { HmrModule } from "../../../metro-runtime/modules/types";
export interface Options {
readonly clientUrl: URL;
readonly createModuleId: ($$PARAM_0$$: string) => number;
readonly includeAsyncPaths: boolean;
readonly projectRoot: string;
readonly serverRoot: string;
}
declare function hmrJSBundle(delta: DeltaResult, graph: ReadOnlyGraph, options: Options): {
readonly added: ReadonlyArray<HmrModule>;
readonly deleted: ReadonlyArray<number>;
readonly modified: ReadonlyArray<HmrModule>;
};
export default hmrJSBundle;
@@ -0,0 +1 @@
module.exports = require("metro/private/DeltaBundler/Serializers/hmrJSBundle");
@@ -0,0 +1,22 @@
/**
* 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 { Module } from "../types";
import { fromRawMappings, fromRawMappingsNonBlocking } from "../../../metro-source-map";
export interface SourceMapGeneratorOptions {
readonly excludeSource: boolean;
readonly processModuleFilter: (module: Module) => boolean;
readonly shouldAddToIgnoreList: (module: Module) => boolean;
readonly getSourceUrl?: null | ((module: Module) => string);
}
declare function sourceMapGenerator(modules: ReadonlyArray<Module>, options: SourceMapGeneratorOptions): ReturnType<typeof fromRawMappings>;
declare function sourceMapGeneratorNonBlocking(modules: ReadonlyArray<Module>, options: SourceMapGeneratorOptions): ReturnType<typeof fromRawMappingsNonBlocking>;
export { sourceMapGenerator, sourceMapGeneratorNonBlocking };
@@ -0,0 +1,2 @@
module.exports = require("metro/private/DeltaBundler/Serializers/sourceMapGenerator");
module.exports.default = module.exports;
@@ -0,0 +1,17 @@
/**
* 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 { Module } from "../types";
import type { SourceMapGeneratorOptions } from "./sourceMapGenerator";
import type { MixedSourceMap } from "../../../metro-source-map";
declare function sourceMapObject(modules: ReadonlyArray<Module>, options: SourceMapGeneratorOptions): MixedSourceMap;
declare function sourceMapObjectNonBlocking(modules: ReadonlyArray<Module>, options: SourceMapGeneratorOptions): Promise<MixedSourceMap>;
export { sourceMapObject, sourceMapObjectNonBlocking };
@@ -0,0 +1,2 @@
module.exports = require("metro/private/DeltaBundler/Serializers/sourceMapObject");
module.exports.default = module.exports;
@@ -0,0 +1,16 @@
/**
* 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 { Module } from "../types";
import type { SourceMapGeneratorOptions } from "./sourceMapGenerator";
declare function sourceMapString(modules: ReadonlyArray<Module>, options: SourceMapGeneratorOptions): string;
declare function sourceMapStringNonBlocking(modules: ReadonlyArray<Module>, options: SourceMapGeneratorOptions): Promise<string>;
export { sourceMapString, sourceMapStringNonBlocking };
@@ -0,0 +1,2 @@
module.exports = require("metro/private/DeltaBundler/Serializers/sourceMapString");
module.exports.default = module.exports;
@@ -0,0 +1,33 @@
/**
* 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 { TransformResult, TransformResultWithSource } from "../DeltaBundler";
import type { TransformOptions } from "./Worker";
import type { ConfigT } from "../../metro-config";
import WorkerFarm from "./WorkerFarm";
import { Cache } from "../../metro-cache";
type GetOrComputeSha1Fn = ($$PARAM_0$$: string) => Promise<{
readonly content?: Buffer;
readonly sha1: string;
}>;
declare class Transformer {
_config: ConfigT;
_cache: Cache<TransformResult>;
_baseHash: string;
_getSha1: GetOrComputeSha1Fn;
_workerFarm: WorkerFarm;
constructor(config: ConfigT, opts: {
readonly getOrComputeSha1: GetOrComputeSha1Fn;
});
transformFile(filePath: string, transformerOptions: TransformOptions, fileBuffer?: Buffer): Promise<TransformResultWithSource>;
end(): Promise<void>;
}
export default Transformer;
@@ -0,0 +1 @@
module.exports = require("metro/private/DeltaBundler/Transformer");
@@ -0,0 +1,2 @@
import * as _namespace from "./Worker.flow";
export = _namespace;
@@ -0,0 +1,29 @@
/**
* 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 { TransformResult } from "./types";
import type { LogEntry } from "../../metro-core/Logger";
import type { JsTransformerConfig, JsTransformOptions } from "../../metro-transform-worker";
export type { JsTransformOptions as TransformOptions } from "../../metro-transform-worker";
export interface TransformerConfig {
transformerPath: string;
transformerConfig: JsTransformerConfig;
}
export interface Data {
readonly result: TransformResult;
readonly sha1: string;
readonly transformFileStartLogEntry: LogEntry;
readonly transformFileEndLogEntry: LogEntry;
}
export declare const transform: (filename: string, transformOptions: JsTransformOptions, projectRoot: string, transformerConfig: TransformerConfig, fileBuffer?: Buffer) => Promise<Data>;
export interface Worker {
readonly transform: typeof transform;
}
@@ -0,0 +1,2 @@
module.exports = require("metro/private/DeltaBundler/Worker.flow");
module.exports.default = module.exports;
+1
View File
@@ -0,0 +1 @@
module.exports = require("metro/private/DeltaBundler/Worker");
@@ -0,0 +1,41 @@
/**
* 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 { TransformResult } from "../DeltaBundler";
import type { TransformerConfig, TransformOptions, Worker } from "./Worker";
import type { ConfigT } from "../../metro-config";
import type { Readable } from "node:stream";
export interface WorkerInterface extends Worker {
getStdout(): Readable;
getStderr(): Readable;
end(): void;
}
export interface TransformerResult {
readonly result: TransformResult;
readonly sha1: string;
}
declare class WorkerFarm {
_config: ConfigT;
_transformerConfig: TransformerConfig;
_worker: WorkerInterface | Worker;
constructor(config: ConfigT, transformerConfig: TransformerConfig);
kill(): Promise<void>;
transform(filename: string, options: TransformOptions, fileBuffer?: Buffer): Promise<TransformerResult>;
_makeFarm(absoluteWorkerPath: string, exposedMethods: ReadonlyArray<string>, numWorkers: number): any;
_computeWorkerKey(method: string, filename: string): null | undefined | string;
_formatGenericError(err: any, filename: string): TransformError;
_formatBabelError(err: any, filename: string): TransformError;
}
export default WorkerFarm;
declare class TransformError extends SyntaxError {
type: string;
constructor(message: string);
}
@@ -0,0 +1 @@
module.exports = require("metro/private/DeltaBundler/WorkerFarm");
@@ -0,0 +1,21 @@
/**
* 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
*/
import type { RequireContext } from "../lib/contextModule";
import type { ModuleData, ResolvedDependency, ResolveFn, TransformFn } from "./types";
export interface Parameters<T> {
readonly resolve: ResolveFn;
readonly transform: TransformFn<T>;
readonly shouldTraverse: ($$PARAM_0$$: ResolvedDependency) => boolean;
}
export declare function buildSubgraph<T>(entryPaths: ReadonlySet<string>, resolvedContexts: ReadonlyMap<string, null | undefined | RequireContext>, $$PARAM_2$$: Parameters<T>): Promise<{
moduleData: Map<string, ModuleData<T>>;
errors: Map<string, Error>;
}>;
@@ -0,0 +1,2 @@
module.exports = require("metro/private/DeltaBundler/buildSubgraph");
module.exports.default = module.exports;
@@ -0,0 +1,18 @@
/**
* 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 { TransformerConfig } from "./Worker";
declare function getTransformCacheKey(opts: {
readonly cacheVersion: string;
readonly projectRoot: string;
readonly transformerConfig: TransformerConfig;
}): string;
export default getTransformCacheKey;
@@ -0,0 +1 @@
module.exports = require("metro/private/DeltaBundler/getTransformCacheKey");
@@ -0,0 +1,14 @@
/**
* 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 { DeltaBundle } from "../../metro-runtime/modules/types";
declare function mergeDeltas(delta1: DeltaBundle, delta2: DeltaBundle): DeltaBundle;
export default mergeDeltas;
@@ -0,0 +1 @@
module.exports = require("metro/private/DeltaBundler/mergeDeltas");
+149
View File
@@ -0,0 +1,149 @@
import type * as _babel_types from "@babel/types";
/**
* 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
*/
import type { RequireContext } from "../lib/contextModule";
import type { RequireContextParams } from "../ModuleGraph/worker/collectDependencies";
import type { Graph } from "./Graph";
import type { JsTransformOptions } from "../../metro-transform-worker";
import CountingSet from "../lib/CountingSet";
export interface MixedOutput {
readonly data: any;
readonly type: string;
}
export declare const enum _AsyncDependencyType {
async = "async",
maybeSync = "maybeSync",
prefetch = "prefetch",
weak = "weak",
}
export type AsyncDependencyType = `${_AsyncDependencyType}`;
export interface _TransformResultDependency_data {
/**
* A locally unique key for this dependency within the current module.
*/
readonly key: string;
/**
* If not null, this dependency is due to a dynamic `import()` or `__prefetchImport()` call.
*/
readonly asyncType?: AsyncDependencyType | null;
/**
* True if the dependency is declared with a static "import x from 'y'" or
* an import() call.
*/
readonly isESMImport: boolean;
/**
* The dependency is enclosed in a try/catch block.
*/
readonly isOptional?: boolean;
readonly locs: ReadonlyArray<_babel_types.SourceLocation>;
/** Context for requiring a collection of modules. */
readonly contextParams?: RequireContextParams;
}
export interface TransformResultDependency {
/**
* The literal name provided to a require or import call. For example 'foo' in
* case of `require('foo')`.
*/
readonly name: string;
/**
* Extra data returned by the dependency extractor.
*/
readonly data: _TransformResultDependency_data;
}
export interface ResolvedDependency {
readonly absolutePath: string;
readonly data: TransformResultDependency;
}
export type Dependency = ResolvedDependency | {
readonly data: TransformResultDependency;
};
export interface Module<T = MixedOutput> {
readonly dependencies: Map<string, Dependency>;
readonly inverseDependencies: CountingSet<string>;
readonly output: ReadonlyArray<T>;
readonly path: string;
readonly getSource: () => Buffer;
readonly unstable_transformResultKey?: null | undefined | string;
}
export interface ModuleData<T = MixedOutput> {
readonly dependencies: ReadonlyMap<string, Dependency>;
readonly resolvedContexts: ReadonlyMap<string, RequireContext>;
readonly output: ReadonlyArray<T>;
readonly getSource: () => Buffer;
readonly unstable_transformResultKey?: null | undefined | string;
}
export type Dependencies<T = MixedOutput> = Map<string, Module<T>>;
export type ReadOnlyDependencies<T = MixedOutput> = ReadonlyMap<string, Module<T>>;
export type TransformInputOptions = Omit<JsTransformOptions, "inlinePlatform" | "inlineRequires">;
export interface GraphInputOptions {
readonly entryPoints: ReadonlySet<string>;
readonly transformOptions: TransformInputOptions;
}
export interface ReadOnlyGraph<T = MixedOutput> {
readonly entryPoints: ReadonlySet<string>;
readonly transformOptions: Readonly<TransformInputOptions>;
readonly dependencies: ReadOnlyDependencies<T>;
}
export type { Graph };
export interface TransformResult<T = MixedOutput> {
readonly dependencies: ReadonlyArray<TransformResultDependency>;
readonly output: ReadonlyArray<T>;
readonly unstable_transformResultKey?: null | undefined | string;
}
export interface TransformResultWithSource<T = MixedOutput> extends TransformResult<T> {
readonly getSource: () => Buffer;
}
export type TransformFn<T = MixedOutput> = ($$PARAM_0$$: string, $$PARAM_1$$: null | undefined | RequireContext) => Promise<TransformResultWithSource<T>>;
export type ResolveFn = (from: string, dependency: TransformResultDependency) => BundlerResolution;
export interface AllowOptionalDependenciesWithOptions {
readonly exclude: Array<string>;
}
export type AllowOptionalDependencies = boolean | AllowOptionalDependenciesWithOptions;
export interface BundlerResolution {
readonly type: "sourceFile";
readonly filePath: string;
}
export interface Options<T = MixedOutput> {
readonly resolve: ResolveFn;
readonly transform: TransformFn<T>;
readonly transformOptions: TransformInputOptions;
readonly onProgress?: null | ((numProcessed: number, total: number) => any);
readonly lazy: boolean;
readonly unstable_allowRequireContext: boolean;
readonly unstable_enablePackageExports: boolean;
readonly shallow: boolean;
}
export interface DeltaResult<T = MixedOutput> {
readonly added: Map<string, Module<T>>;
readonly modified: Map<string, Module<T>>;
readonly deleted: Set<string>;
readonly reset: boolean;
}
export interface SerializerOptions<T = MixedOutput> {
readonly asyncRequireModulePath: string;
readonly createModuleId: ($$PARAM_0$$: string) => number;
readonly dev: boolean;
readonly getRunModuleStatement: (moduleId: number | string, globalPrefix: string) => string;
readonly globalPrefix: string;
readonly includeAsyncPaths: boolean;
readonly inlineSourceMap?: null | boolean;
readonly modulesOnly: boolean;
readonly processModuleFilter: (module: Module<T>) => boolean;
readonly projectRoot: string;
readonly runBeforeMainModule: ReadonlyArray<string>;
readonly runModule: boolean;
readonly serverRoot: string;
readonly shouldAddToIgnoreList: ($$PARAM_0$$: Module<T>) => boolean;
readonly sourceMapUrl?: null | string;
readonly sourceUrl?: null | string;
readonly getSourceUrl?: null | (($$PARAM_0$$: Module<T>) => string);
}
+1
View File
@@ -0,0 +1 @@
module.exports = require("metro/private/DeltaBundler/types");
+58
View File
@@ -0,0 +1,58 @@
import type { GraphOptions } from "./shared/types";
import type { ConfigT, RootPerfLogger } from "../metro-config";
import type { HmrErrorMessage, HmrUpdateMessage } from "../metro-runtime/modules/types";
/**
* 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
*/
import type IncrementalBundler from "./IncrementalBundler";
import type { RevisionId } from "./IncrementalBundler";
export interface Client {
optedIntoHMR: boolean;
revisionIds: Array<RevisionId>;
readonly sendFn: ($$PARAM_0$$: string) => void;
}
export interface ClientGroup {
readonly clients: Set<Client>;
clientUrl: URL;
revisionId: RevisionId;
readonly unlisten: () => void;
readonly graphOptions: GraphOptions;
}
/**
* The HmrServer (Hot Module Reloading) implements a lightweight interface
* to communicate easily to the logic in the React Native repository (which
* is the one that handles the Web Socket connections).
*
* This interface allows the HmrServer to hook its own logic to WS clients
* getting connected, disconnected or having errors (through the
* `onClientConnect`, `onClientDisconnect` and `onClientError` methods).
*/
declare class HmrServer<TClient extends Client> {
_config: ConfigT;
_bundler: IncrementalBundler;
_createModuleId: (path: string) => number;
_clientGroups: Map<RevisionId, ClientGroup>;
constructor(bundler: IncrementalBundler, createModuleId: (path: string) => number, config: ConfigT);
onClientConnect: (requestUrl: string, sendFn: (data: string) => void) => Promise<Client>;
_registerEntryPoint(client: Client, requestUrl: string, sendFn: (data: string) => void): Promise<void>;
onClientMessage: (client: TClient, message: string | Buffer | ArrayBuffer | Array<Buffer>, sendFn: (data: string) => void) => Promise<void>;
onClientError: (client: TClient, e: Event) => void;
onClientDisconnect: (client: TClient) => void;
_handleFileChange(group: ClientGroup, options: {
isInitialUpdate: boolean;
}, changeEvent: null | undefined | {
logger?: null | RootPerfLogger;
}): Promise<void>;
_prepareMessage(group: ClientGroup, options: {
isInitialUpdate: boolean;
}, changeEvent: null | undefined | {
logger?: null | RootPerfLogger;
}): Promise<HmrUpdateMessage | HmrErrorMessage>;
}
export default HmrServer;
+1
View File
@@ -0,0 +1 @@
module.exports = require("metro/private/HmrServer");
+68
View File
@@ -0,0 +1,68 @@
/**
* 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 { DeltaResult, Graph, Module } from "./DeltaBundler";
import type { Options as DeltaBundlerOptions, ReadOnlyDependencies, TransformInputOptions } from "./DeltaBundler/types";
import type { GraphId } from "./lib/getGraphId";
import type { ResolverInputOptions } from "./shared/types";
import type { ConfigT } from "../metro-config";
import Bundler from "./Bundler";
import DeltaBundler from "./DeltaBundler";
export declare type RevisionId = string;
export type OutputGraph = Graph;
export interface OtherOptions {
readonly onProgress: DeltaBundlerOptions["onProgress"];
readonly shallow: boolean;
readonly lazy: boolean;
}
export interface GraphRevision {
readonly id: RevisionId;
readonly date: Date;
readonly graphId: GraphId;
readonly graph: OutputGraph;
readonly prepend: ReadonlyArray<Module>;
}
export interface IncrementalBundlerOptions {
readonly hasReducedPerformance?: boolean;
readonly watch?: boolean;
}
declare class IncrementalBundler {
_config: ConfigT;
_bundler: Bundler;
_deltaBundler: DeltaBundler;
_revisionsById: Map<RevisionId, Promise<GraphRevision>>;
_revisionsByGraphId: Map<GraphId, Promise<GraphRevision>>;
static revisionIdFromString: (str: string) => RevisionId;
constructor(config: ConfigT, options?: IncrementalBundlerOptions);
end(): Promise<void>;
getBundler(): Bundler;
getDeltaBundler(): DeltaBundler;
getRevision(revisionId: RevisionId): null | undefined | Promise<GraphRevision>;
getRevisionByGraphId(graphId: GraphId): null | undefined | Promise<GraphRevision>;
buildGraphForEntries(entryFiles: ReadonlyArray<string>, transformOptions: TransformInputOptions, resolverOptions: ResolverInputOptions, otherOptions?: OtherOptions): Promise<OutputGraph>;
getDependencies(entryFiles: ReadonlyArray<string>, transformOptions: TransformInputOptions, resolverOptions: ResolverInputOptions, otherOptions?: OtherOptions): Promise<ReadOnlyDependencies>;
buildGraph(entryFile: string, transformOptions: TransformInputOptions, resolverOptions: ResolverInputOptions, otherOptions?: OtherOptions): Promise<{
readonly graph: OutputGraph;
readonly prepend: ReadonlyArray<Module>;
}>;
initializeGraph(entryFile: string, transformOptions: TransformInputOptions, resolverOptions: ResolverInputOptions, otherOptions?: OtherOptions): Promise<{
delta: DeltaResult;
revision: GraphRevision;
}>;
updateGraph(revision: GraphRevision, reset: boolean): Promise<{
delta: DeltaResult;
revision: GraphRevision;
}>;
endGraph(graphId: GraphId): Promise<void>;
_getAbsoluteEntryFiles(entryFiles: ReadonlyArray<string>): Promise<ReadonlyArray<string>>;
ready(): Promise<void>;
}
export default IncrementalBundler;
+1
View File
@@ -0,0 +1 @@
module.exports = require("metro/private/IncrementalBundler");
@@ -0,0 +1,17 @@
/**
* 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 { GraphId } from "../lib/getGraphId";
declare class GraphNotFoundError extends Error {
graphId: GraphId;
constructor(graphId: GraphId);
}
export default GraphNotFoundError;
@@ -0,0 +1 @@
module.exports = require("metro/private/IncrementalBundler/GraphNotFoundError");
@@ -0,0 +1,16 @@
/**
* 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
*/
declare class ResourceNotFoundError extends Error {
resourcePath: string;
constructor(resourcePath: string);
}
export default ResourceNotFoundError;
@@ -0,0 +1 @@
module.exports = require("metro/private/IncrementalBundler/ResourceNotFoundError");
@@ -0,0 +1,17 @@
/**
* 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 { RevisionId } from "../IncrementalBundler";
declare class RevisionNotFoundError extends Error {
revisionId: RevisionId;
constructor(revisionId: RevisionId);
}
export default RevisionNotFoundError;
@@ -0,0 +1 @@
module.exports = require("metro/private/IncrementalBundler/RevisionNotFoundError");
@@ -0,0 +1,22 @@
/**
* 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
*
*/
import type { File } from "@babel/types";
declare const WRAP_NAME: "$$_REQUIRE";
declare function wrapModule(fileAst: File, importDefaultName: string, importAllName: string, dependencyMapName: string, globalPrefix: string, skipRequireRename: boolean, _optionalArg?: {
readonly unstable_useStaticHermesModuleFactory?: boolean;
}): {
ast: File;
requireName: string;
};
declare function wrapPolyfill(fileAst: File): File;
declare function jsonToCommonJS(source: string): string;
declare function wrapJson(source: string, globalPrefix: string, unstable_useStaticHermesModuleFactory?: boolean): string;
export { WRAP_NAME, wrapJson, jsonToCommonJS, wrapModule, wrapPolyfill };
@@ -0,0 +1,2 @@
module.exports = require("metro/private/ModuleGraph/worker/JsFileWrapping");
module.exports.default = module.exports;
@@ -0,0 +1,91 @@
import type { NodePath } from "@babel/traverse";
import type { CallExpression, Identifier, StringLiteral, SourceLocation, File } from "@babel/types";
import type { AllowOptionalDependencies, AsyncDependencyType } from "../../DeltaBundler/types";
export interface Dependency {
readonly data: DependencyData;
readonly name: string;
}
export declare const enum _ContextMode {
sync = "sync",
eager = "eager",
lazy = "lazy",
lazyOnce = "lazy-once",
}
export type ContextMode = `${_ContextMode}`;
export interface ContextFilter {
readonly pattern: string;
readonly flags: string;
}
export interface RequireContextParams {
readonly recursive: boolean;
readonly filter: Readonly<ContextFilter>;
readonly mode: ContextMode;
}
export interface DependencyData {
readonly key: string;
readonly asyncType?: AsyncDependencyType | null;
readonly isESMImport: boolean;
readonly isOptional?: boolean;
readonly locs: ReadonlyArray<SourceLocation>;
readonly contextParams?: RequireContextParams;
}
export interface MutableInternalDependency extends DependencyData {
locs: Array<SourceLocation>;
index: number;
name: string;
}
export type InternalDependency = Readonly<MutableInternalDependency>;
export interface State {
asyncRequireModulePathStringLiteral?: null | StringLiteral;
dependencyCalls: Set<string>;
dependencyRegistry: DependencyRegistry;
dependencyTransformer: DependencyTransformer;
dynamicRequires: DynamicRequiresBehavior;
dependencyMapIdentifier?: null | Identifier;
keepRequireNames: boolean;
allowOptionalDependencies: AllowOptionalDependencies;
unstable_allowRequireContext: boolean;
unstable_isESMImportAtSource?: null | (($$PARAM_0$$: SourceLocation) => boolean);
}
export interface Options {
readonly asyncRequireModulePath: string;
readonly dependencyMapName?: null | string;
readonly dynamicRequires: DynamicRequiresBehavior;
readonly inlineableCalls: ReadonlyArray<string>;
readonly keepRequireNames: boolean;
readonly allowOptionalDependencies: AllowOptionalDependencies;
readonly dependencyTransformer?: DependencyTransformer;
readonly unstable_allowRequireContext: boolean;
readonly unstable_isESMImportAtSource?: null | undefined | (($$PARAM_0$$: SourceLocation) => boolean);
}
export interface CollectedDependencies {
readonly ast: File;
readonly dependencyMapName: string;
readonly dependencies: ReadonlyArray<Dependency>;
}
export interface DependencyTransformer {
transformSyncRequire(path: NodePath<CallExpression>, dependency: InternalDependency, state: State): void;
transformImportCall(path: NodePath, dependency: InternalDependency, state: State): void;
transformImportMaybeSyncCall(path: NodePath, dependency: InternalDependency, state: State): void;
transformPrefetch(path: NodePath, dependency: InternalDependency, state: State): void;
transformIllegalDynamicRequire(path: NodePath, state: State): void;
}
export declare const enum _DynamicRequiresBehavior {
throwAtRuntime = "throwAtRuntime",
reject = "reject",
}
export type DynamicRequiresBehavior = `${_DynamicRequiresBehavior}`;
declare function collectDependencies(ast: File, options: Options): CollectedDependencies;
export default collectDependencies;
export interface ImportQualifier {
readonly name: string;
readonly asyncType?: AsyncDependencyType | null;
readonly isESMImport: boolean;
readonly optional: boolean;
readonly contextParams?: RequireContextParams;
}
declare class DependencyRegistry {
_dependencies: Map<string, InternalDependency>;
registerDependency(qualifier: ImportQualifier): InternalDependency;
getDependencies(): Array<InternalDependency>;
}
@@ -0,0 +1 @@
module.exports = require("metro/private/ModuleGraph/worker/collectDependencies");
@@ -0,0 +1,10 @@
import type * as _babel_types from "@babel/types";
/**
* Select unused names for "metroImportDefault" and "metroImportAll", by
* calling "generateUid".
*/
declare function generateImportNames(ast: _babel_types.Node): {
importAll: string;
importDefault: string;
};
export default generateImportNames;
@@ -0,0 +1 @@
module.exports = require("metro/private/ModuleGraph/worker/generateImportNames");
@@ -0,0 +1,23 @@
/**
* 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 { PluginObj, BabelFile } from "@babel/core";
import * as Types from "@babel/types";
type ImportDeclarationLocs = Set<string>;
export interface State {
importDeclarationLocs: ImportDeclarationLocs;
file: BabelFile;
}
declare function importLocationsPlugin($$PARAM_0$$: {
types: typeof Types;
}): PluginObj<State>;
declare function locToKey(loc: Types.SourceLocation): string;
export { importLocationsPlugin, locToKey };
@@ -0,0 +1,2 @@
module.exports = require("metro/private/ModuleGraph/worker/importLocationsPlugin");
module.exports.default = module.exports;
+157
View File
@@ -0,0 +1,157 @@
import type { AssetData } from "./Assets";
import type { ExplodedSourceMap } from "./DeltaBundler/Serializers/getExplodedSourceMap";
import type { RamBundleInfo } from "./DeltaBundler/Serializers/getRamBundleInfo";
import type { Module, ReadOnlyDependencies, ReadOnlyGraph, TransformInputOptions } from "./DeltaBundler/types";
import type { RevisionId } from "./IncrementalBundler";
import type { GraphId } from "./lib/getGraphId";
import type { Reporter } from "./lib/reporting";
import type { BuildOptions, BundleOptions, GraphOptions, ResolverInputOptions, SplitBundleOptions } from "./shared/types";
import type { IncomingMessage } from "connect";
import type { ServerResponse } from "node:http";
import type { ConfigT, RootPerfLogger } from "../metro-config";
import type { ActionLogEntryData, ActionStartLogEntry } from "../metro-core/Logger";
import type { CustomResolverOptions } from "../metro-resolver/types";
import type { CustomTransformOptions } from "../metro-transform-worker";
import IncrementalBundler from "./IncrementalBundler";
import MultipartResponse from "./Server/MultipartResponse";
import { SourcePathsMode } from "./shared/types";
import { Logger } from "../metro-core";
export interface SegmentLoadData {
[$$Key$$: number]: [Array<number>, null | undefined | number];
}
export interface BundleMetadata {
hash: string;
otaBuildNumber?: null | string;
mobileConfigs: Array<string>;
segmentHashes: Array<string>;
segmentLoadData: SegmentLoadData;
}
export interface ProcessStartContext extends SplitBundleOptions {
readonly buildNumber: number;
readonly bundleOptions: BundleOptions;
readonly graphId: GraphId;
readonly graphOptions: GraphOptions;
readonly mres?: MultipartResponse | ServerResponse;
readonly req: IncomingMessage;
readonly revisionId?: null | undefined | RevisionId;
readonly bundlePerfLogger: RootPerfLogger;
readonly requestStartTimestamp: number;
}
export interface ProcessDeleteContext {
readonly graphId: GraphId;
readonly req: IncomingMessage;
readonly res: ServerResponse;
}
export interface ProcessEndContext<T> extends ProcessStartContext {
readonly result: T;
}
export interface ServerOptions {
readonly hasReducedPerformance?: boolean;
readonly onBundleBuilt?: (bundlePath: string) => void;
readonly watch?: boolean;
}
declare class Server {
_bundler: IncrementalBundler;
_config: ConfigT;
_createModuleId: (path: string) => number;
_isEnded: boolean;
_logger: typeof Logger;
_nextBundleBuildNumber: number;
_platforms: Set<string>;
_reporter: Reporter;
_serverOptions: ServerOptions | void;
_allowedSuffixesForSourceRequests: ReadonlyArray<string>;
_sourceRequestRoutingMap: ReadonlyArray<[any, any]>;
constructor(config: ConfigT, options?: ServerOptions);
end(): Promise<void>;
getBundler(): IncrementalBundler;
getCreateModuleId(): (path: string) => number;
_serializeGraph($$PARAM_0$$: {
readonly splitOptions: SplitBundleOptions;
readonly prepend: ReadonlyArray<Module>;
readonly graph: ReadOnlyGraph;
}): Promise<{
code: string;
map: string;
}>;
build(bundleOptions: BundleOptions, $$PARAM_1$$: BuildOptions): Promise<{
code: string;
map: string;
assets?: ReadonlyArray<AssetData>;
}>;
getRamBundleInfo(options: BundleOptions): Promise<RamBundleInfo>;
getAssets(options: BundleOptions): Promise<ReadonlyArray<AssetData>>;
_getAssetsFromDependencies(dependencies: ReadOnlyDependencies, platform: null | undefined | string): Promise<ReadonlyArray<AssetData>>;
getOrderedDependencyPaths(options: {
readonly dev: boolean;
readonly entryFile: string;
readonly minify: boolean;
readonly platform?: null | string;
}): Promise<Array<string>>;
_rangeRequestMiddleware(req: IncomingMessage, res: ServerResponse, data: string | Buffer, assetPath: string): Buffer | string;
_processSingleAssetRequest(req: IncomingMessage, res: ServerResponse): Promise<void>;
processRequest: ($$PARAM_0$$: IncomingMessage, $$PARAM_1$$: ServerResponse, $$PARAM_2$$: (e: null | undefined | Error) => void) => void;
_parseOptions(url: string): BundleOptions;
_rewriteAndNormalizeUrl(requestUrl: string): string;
_processRequest(req: IncomingMessage, res: ServerResponse, next: ($$PARAM_0$$: null | undefined | Error) => void): Promise<void>;
_processSourceRequest(relativeFilePathname: string, rootDir: string, res: ServerResponse): Promise<void>;
_createRequestProcessor<T>($$PARAM_0$$: {
readonly bundleType?: "assets" | "bundle" | "map";
readonly createStartEntry: (context: ProcessStartContext) => ActionLogEntryData;
readonly createEndEntry: (context: ProcessEndContext<T>) => Partial<ActionStartLogEntry>;
readonly build: (context: ProcessStartContext) => Promise<T>;
readonly delete?: (context: ProcessDeleteContext) => Promise<void>;
readonly finish: (context: ProcessEndContext<T>) => void;
}): (req: IncomingMessage, res: ServerResponse, bundleOptions: BundleOptions, buildContext: {
readonly buildNumber: number;
readonly bundlePerfLogger: RootPerfLogger;
}) => Promise<void>;
_processBundleRequest: (req: IncomingMessage, res: ServerResponse, bundleOptions: BundleOptions, buildContext: {
readonly buildNumber: number;
readonly bundlePerfLogger: RootPerfLogger;
}) => Promise<void>;
_getSortedModules(graph: ReadOnlyGraph): ReadonlyArray<Module>;
_processSourceMapRequest: (req: IncomingMessage, res: ServerResponse, bundleOptions: BundleOptions, buildContext: {
readonly buildNumber: number;
readonly bundlePerfLogger: RootPerfLogger;
}) => Promise<void>;
_processAssetsRequest: (req: IncomingMessage, res: ServerResponse, bundleOptions: BundleOptions, buildContext: {
readonly buildNumber: number;
readonly bundlePerfLogger: RootPerfLogger;
}) => Promise<void>;
_symbolicate(req: IncomingMessage, res: ServerResponse): Promise<void>;
_explodedSourceMapForBundleOptions(bundleOptions: BundleOptions): Promise<ExplodedSourceMap>;
_resolveRelativePath(filePath: string, $$PARAM_1$$: {
readonly relativeTo?: "project" | "server";
readonly resolverOptions: ResolverInputOptions;
readonly transformOptions: TransformInputOptions;
}): Promise<string>;
getNewBuildNumber(): number;
getPlatforms(): ReadonlyArray<string>;
getWatchFolders(): ReadonlyArray<string>;
static DEFAULT_GRAPH_OPTIONS: {
readonly customResolverOptions: CustomResolverOptions;
readonly customTransformOptions: CustomTransformOptions;
readonly dev: boolean;
readonly minify: boolean;
readonly unstable_transformProfile: "default";
};
static DEFAULT_BUNDLE_OPTIONS: {
excludeSource: false;
inlineSourceMap: false;
lazy: false;
modulesOnly: false;
onProgress: null;
runModule: true;
shallow: false;
sourceMapUrl: null;
sourceUrl: null;
sourcePaths: SourcePathsMode;
} & typeof Server.DEFAULT_GRAPH_OPTIONS;
_getServerRootDir(): string;
_getEntryPointAbsolutePath(entryFile: string): string;
ready(): Promise<void>;
_shouldAddModuleToIgnoreList(module: Module): boolean;
_getModuleSourceUrl(module: Module, mode: SourcePathsMode): string;
}
export default Server;
+1
View File
@@ -0,0 +1 @@
module.exports = require("metro/private/Server");
@@ -0,0 +1,29 @@
/**
* 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 { IncomingMessage, ServerResponse } from "node:http";
type Data = string | Buffer | Uint8Array;
export interface Headers {
[$$Key$$: string]: string | number;
}
declare class MultipartResponse {
static wrapIfSupported(req: IncomingMessage, res: ServerResponse): MultipartResponse | ServerResponse;
static serializeHeaders(headers: Headers): string;
res: ServerResponse;
headers: Headers;
constructor(res: ServerResponse);
writeChunk(headers: Headers | null, data?: Data, isLast?: boolean): void;
writeHead(status: number, headers?: Headers): void;
setHeader(name: string, value: string | number): void;
end(data?: Data): void;
once(name: string, fn: () => any): this;
}
export default MultipartResponse;
@@ -0,0 +1 @@
module.exports = require("metro/private/Server/MultipartResponse");
+25
View File
@@ -0,0 +1,25 @@
/**
* 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 { ExplodedSourceMap } from "../DeltaBundler/Serializers/getExplodedSourceMap";
import type { ConfigT } from "../../metro-config";
export interface StackFrameInput {
readonly file?: null | string;
readonly lineNumber?: null | number;
readonly column?: null | number;
readonly methodName?: null | string;
}
export interface IntermediateStackFrame extends StackFrameInput {
collapse?: boolean;
}
export type StackFrameOutput = Readonly<IntermediateStackFrame>;
declare function symbolicate(stack: ReadonlyArray<StackFrameInput>, maps: Iterable<[string, ExplodedSourceMap]>, config: ConfigT, extraData: any): Promise<ReadonlyArray<StackFrameOutput>>;
export default symbolicate;
+1
View File
@@ -0,0 +1 @@
module.exports = require("metro/private/Server/symbolicate");
+2
View File
@@ -0,0 +1,2 @@
import * as _namespace from "./index.flow";
export = _namespace;
+131
View File
@@ -0,0 +1,131 @@
import type * as _ws from "ws";
/**
* 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
* @format
* @oncall react_native
*/
import type { AssetData } from "./Assets";
import type { ReadOnlyGraph } from "./DeltaBundler";
import type { ServerOptions } from "./Server";
import type { BuildOptions, OutputOptions, RequestOptions } from "./shared/types";
import type { HandleFunction } from "connect";
import type { Server as HttpServer } from "node:http";
import type { Server as HttpsServer } from "node:https";
import type { TransformProfile } from "../metro-babel-transformer";
import type { ConfigT, InputConfigT, MetroConfig, Middleware } from "../metro-config";
import type { CustomResolverOptions } from "../metro-resolver";
import type { CustomTransformOptions } from "../metro-transform-worker";
import type $$IMPORT_TYPEOF_1$$ from "yargs";
type Yargs = typeof $$IMPORT_TYPEOF_1$$;
import JsonReporter from "./lib/JsonReporter";
import TerminalReporter from "./lib/TerminalReporter";
import MetroServer from "./Server";
import { loadConfig, mergeConfig, resolveConfig } from "../metro-config";
import { Terminal } from "../metro-core";
export interface MetroMiddleWare {
attachHmrServer: (httpServer: HttpServer | HttpsServer) => void;
end: () => Promise<void>;
metroServer: MetroServer;
middleware: Middleware;
}
export interface RunMetroOptions extends ServerOptions {
waitForBundler?: boolean;
}
export interface _RunServerOptions_websocketEndpoints {
readonly [path: string]: _ws.WebSocketServer;
}
export interface RunServerOptions {
readonly hasReducedPerformance?: boolean;
readonly host?: string;
readonly onError?: ($$PARAM_0$$: Error & {
code?: string;
}) => void;
readonly onReady?: (server: HttpServer | HttpsServer) => void;
readonly onClose?: () => void;
readonly secureServerOptions?: Object;
readonly secure?: boolean;
readonly secureCert?: string;
readonly secureKey?: string;
readonly unstable_extraMiddleware?: ReadonlyArray<HandleFunction>;
readonly waitForBundler?: boolean;
readonly watch?: boolean;
readonly websocketEndpoints?: _RunServerOptions_websocketEndpoints;
}
export interface RunServerResult {
httpServer?: HttpServer | HttpsServer;
}
export interface BuildGraphOptions {
entries: ReadonlyArray<string>;
customTransformOptions?: CustomTransformOptions;
dev?: boolean;
minify?: boolean;
onProgress?: (transformedFileCount: number, totalFileCount: number) => void;
platform?: string;
type?: "module" | "script";
}
export interface _RunBuildOptions_output {
readonly build: ($$PARAM_0$$: MetroServer, $$PARAM_1$$: RequestOptions, $$PARAM_2$$: void | BuildOptions) => Promise<{
code: string;
map: string;
assets?: ReadonlyArray<AssetData>;
}>;
readonly save: ($$PARAM_0$$: {
code: string;
map: string;
}, $$PARAM_1$$: OutputOptions, $$PARAM_2$$: (logMessage: string) => void) => Promise<any>;
}
export interface RunBuildOptions {
entry: string;
assets?: boolean;
dev?: boolean;
out?: string;
bundleOut?: string;
sourceMapOut?: string;
onBegin?: () => void;
onComplete?: () => void;
onProgress?: (transformedFileCount: number, totalFileCount: number) => void;
minify?: boolean;
output?: _RunBuildOptions_output;
platform?: string;
sourceMap?: boolean;
sourceMapUrl?: string;
customResolverOptions?: CustomResolverOptions;
customTransformOptions?: CustomTransformOptions;
unstable_transformProfile?: TransformProfile;
}
export interface RunBuildResult {
code: string;
map: string;
assets?: ReadonlyArray<AssetData>;
}
type BuildCommandOptions = {} | null;
type ServeCommandOptions = {} | null;
export { Terminal, JsonReporter, TerminalReporter };
export type { AssetData } from "./Assets";
export type { Reporter, ReportableEvent } from "./lib/reporting";
export type { TerminalReportableEvent } from "./lib/TerminalReporter";
export type { MetroConfig };
export declare function runMetro(config: InputConfigT, options?: RunMetroOptions): Promise<MetroServer>;
export { loadConfig, mergeConfig, resolveConfig };
export declare const createConnectMiddleware: (config: ConfigT, options?: RunMetroOptions) => Promise<MetroMiddleWare>;
export declare const runServer: (config: ConfigT, $$PARAM_1$$: RunServerOptions) => Promise<RunServerResult>;
export declare const runBuild: (config: ConfigT, $$PARAM_1$$: RunBuildOptions) => Promise<RunBuildResult>;
export declare const buildGraph: (config: InputConfigT, $$PARAM_1$$: BuildGraphOptions) => Promise<ReadOnlyGraph>;
export interface AttachMetroCLIOptions {
build?: BuildCommandOptions;
serve?: ServeCommandOptions;
dependencies?: any;
}
export declare const attachMetroCli: (yargs: Yargs, options?: AttachMetroCLIOptions) => Yargs;
/**
* Backwards-compatibility with CommonJS consumers using interopRequireDefault.
* Do not add to this list.
*
* @deprecated Default import from 'metro' is deprecated, use named exports.
*/
+1
View File
@@ -0,0 +1 @@
module.exports = require("metro/private/index.flow");
+1
View File
@@ -0,0 +1 @@
module.exports = require("metro");
+45
View File
@@ -0,0 +1,45 @@
/**
* 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 ProcessBatch<TItem, TResult> = (batch: Array<TItem>) => Promise<Array<TResult>>;
export interface BatchProcessorOptions {
maximumDelayMs: number;
maximumItems: number;
concurrency: number;
}
export interface QueueItem<TItem, TResult> {
item: TItem;
reject: (error: any) => any;
resolve: (result: TResult) => any;
}
/**
* We batch items together trying to minimize their processing, for example as
* network queries. For that we wait a small moment before processing a batch.
* We limit also the number of items we try to process in a single batch so that
* if we have many items pending in a short amount of time, we can start
* processing right away.
*/
declare class BatchProcessor<TItem, TResult> {
_currentProcessCount: number;
_options: BatchProcessorOptions;
_processBatch: ProcessBatch<TItem, TResult>;
_queue: Array<QueueItem<TItem, TResult>>;
_timeoutHandle: null | undefined | NodeJS.Timeout;
constructor(options: BatchProcessorOptions, processBatch: ProcessBatch<TItem, TResult>);
_onBatchFinished(): void;
_onBatchResults(jobs: Array<QueueItem<TItem, TResult>>, results: Array<TResult>): void;
_onBatchError(jobs: Array<QueueItem<TItem, TResult>>, error: any): void;
_processQueue(): void;
_processQueueOnceReady(): void;
queue(item: TItem): Promise<TResult>;
getQueueLength(): number;
}
export default BatchProcessor;
+1
View File
@@ -0,0 +1 @@
module.exports = require("metro/private/lib/BatchProcessor");
+45
View File
@@ -0,0 +1,45 @@
// See: https://github.com/facebook/metro/blob/v0.83.2/packages/metro/src/lib/CountingSet.js
export interface ReadOnlyCountingSet<T> extends Iterable<T> {
get size(): number;
has(item: T): boolean;
[Symbol.iterator](): Iterator<T>; // NOTE(cedric): Flow doesn't like this, and causes failures when converting to TSD
count(item: T): number;
forEach<ThisT>(
callbackFn: (this: ThisT, value: T, key: T, set: ReadOnlyCountingSet<T>) => any,
// NOTE: Should be optional, but Flow seems happy to infer undefined here
// which is what we want.
thisArg: ThisT
): void;
}
/**
* A Set that only deletes a given item when the number of delete(item) calls
* matches the number of add(item) calls. Iteration and `size` are in terms of
* *unique* items.
*/
export default class CountingSet<T> implements ReadOnlyCountingSet<T> {
constructor(items?: Iterable<T>);
has(item: T): boolean;
add(item: T): void;
delete(item: T): void;
keys(): Iterator<T>;
values(): Iterator<T>;
entries(): Iterator<[T, T]>;
[Symbol.iterator](): Iterator<T>; // NOTE(cedric): Flow doesn't like this, and causes failures when converting to TSD
get size(): number;
count(item: T): number;
clear(): void;
forEach<ThisT>(
callbackFn: (this: ThisT, value: T, key: T, set: CountingSet<T>) => any,
thisArg: ThisT
): void;
/**
* For Jest purposes. Ideally a custom serializer would be enough, but in
* practice there is hardcoded magic for Set in toEqual (etc) that we cannot
* extend to custom collection classes. Instead let's assume values are
* sortable ( = strings) and make this look like an array with some stable
* order.
*/
toJSON(): any;
}
+1
View File
@@ -0,0 +1 @@
module.exports = require("metro/private/lib/CountingSet");
+18
View File
@@ -0,0 +1,18 @@
import type { Writable } from "node:stream";
export interface SerializedError {
message: string;
stack: string;
errors?: ReadonlyArray<SerializedError>;
cause?: SerializedError;
}
export type SerializedEvent<TEvent extends {
[$$Key$$: string]: any;
}> = any;
declare class JsonReporter<TEvent extends {
[$$Key$$: string]: any;
}> {
_stream: Writable;
constructor(stream: Writable);
update(event: TEvent): void;
}
export default JsonReporter;
+1
View File
@@ -0,0 +1 @@
module.exports = require("metro/private/lib/JsonReporter");
+30
View File
@@ -0,0 +1,30 @@
/**
* 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
*
*/
/**
* Implementation of a RAM bundle parser in JS.
*
* It receives a Buffer as an input and implements two main methods, which are
* able to run in constant time no matter the size of the bundle:
*
* getStartupCode(): returns the runtime and the startup code of the bundle.
* getModule(): returns the code for the specified module.
*/
declare class RamBundleParser {
_buffer: Buffer;
_numModules: number;
_startupCodeLength: number;
_startOffset: number;
constructor(buffer: Buffer);
_readPosition(pos: number): number;
getStartupCode(): string;
getModule(id: number): string;
}
export default RamBundleParser;
+1
View File
@@ -0,0 +1 @@
module.exports = require("metro/private/lib/RamBundleParser");
@@ -0,0 +1,86 @@
/**
* 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 { BundleDetails, ReportableEvent } from "./reporting";
import type { Terminal } from "../../metro-core";
import type { HealthCheckResult, WatcherStatus } from "../../metro-file-map";
export interface BundleProgress {
bundleDetails: BundleDetails;
transformedFileCount: number;
totalFileCount: number;
ratio: number;
isPrefetch?: boolean;
}
export type TerminalReportableEvent = ReportableEvent | {
buildID: string;
type: "bundle_transform_progressed_throttled";
transformedFileCount: number;
totalFileCount: number;
} | {
type: "unstable_server_log";
level?: "info" | "warn" | "error";
data?: string | Array<any>;
} | {
type: "unstable_server_menu_updated";
message: string;
} | {
type: "unstable_server_menu_cleared";
};
export declare const enum _BuildPhase {
in_progress = "in_progress",
done = "done",
failed = "failed",
}
export type BuildPhase = `${_BuildPhase}`;
type SnippetError = any & {
filename?: string;
snippet?: string;
};
/**
* We try to print useful information to the terminal for interactive builds.
* This implements the `Reporter` interface from the './reporting' module.
*/
declare class TerminalReporter {
_activeBundles: Map<string, BundleProgress>;
_interactionStatus: null | undefined | string;
_scheduleUpdateBundleProgress: {
cancel(): void;
(data: {
buildID: string;
transformedFileCount: number;
totalFileCount: number;
}): void;
};
_prevHealthCheckResult: null | undefined | HealthCheckResult;
readonly terminal: Terminal;
constructor(terminal: Terminal);
_getBundleStatusMessage($$PARAM_0$$: BundleProgress, phase: BuildPhase): string;
_logBundleBuildDone(buildID: string): void;
_logBundleBuildFailed(buildID: string): void;
_logInitializing(port: number, hasReducedPerformance: boolean): void;
_logInitializingFailed(port: number, error: SnippetError): void;
_log(event: TerminalReportableEvent): void;
_logBundlingError(error: SnippetError): void;
_logWorkerChunk(origin: "stdout" | "stderr", chunk: string): void;
_updateBundleProgress($$PARAM_0$$: {
buildID: string;
transformedFileCount: number;
totalFileCount: number;
}): void;
_updateState(event: TerminalReportableEvent): void;
_getStatusMessage(): string;
_logHmrClientError(e: Error): void;
_logWarning(message: string): void;
_logWatcherHealthCheckResult(result: HealthCheckResult): void;
_logWatcherStatus(status: WatcherStatus): void;
update(event: TerminalReportableEvent): void;
}
export default TerminalReporter;
@@ -0,0 +1 @@
module.exports = require("metro/private/lib/TerminalReporter");
+20
View File
@@ -0,0 +1,20 @@
/**
* 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 { Bundle, BundleMetadata } from "../../metro-runtime/modules/types";
/**
* Serializes a bundle into a plain JS bundle.
*/
declare function bundleToString(bundle: Bundle): {
readonly code: string;
readonly metadata: BundleMetadata;
};
export default bundleToString;
+1
View File
@@ -0,0 +1 @@
module.exports = require("metro/private/lib/bundleToString");
+24
View File
@@ -0,0 +1,24 @@
/**
* 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 { ContextMode, RequireContextParams } from "../ModuleGraph/worker/collectDependencies";
export interface RequireContext {
readonly recursive: boolean;
readonly filter: RegExp;
/** Mode for resolving dynamic dependencies. Defaults to `sync` */
readonly mode: ContextMode;
/** Absolute path of the directory to search in */
readonly from: string;
}
/** Given a fully qualified require context, return a virtual file path that ensures uniqueness between paths with different contexts. */
export declare function deriveAbsolutePathFromContext(from: string, context: RequireContextParams): string;
/** Match a file against a require context. */
export declare function fileMatchesContext(testPath: string, context: RequireContext): boolean;
+2
View File
@@ -0,0 +1,2 @@
module.exports = require("metro/private/lib/contextModule");
module.exports.default = module.exports;
@@ -0,0 +1,22 @@
/**
* 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 { ContextMode } from "../ModuleGraph/worker/collectDependencies";
/**
* Generate a context module as a virtual file string.
*
* @prop {ContextMode} mode indicates how the modules should be loaded.
* @prop {string} modulePath virtual file path for the virtual module. Example: `require.context('./src')` -> `'/path/to/project/src'`.
* @prop {string[]} files list of absolute file paths that must be exported from the context module. Example: `['/path/to/project/src/index.js']`.
*
* @returns a string representing a context module (virtual file contents).
*/
export declare function getContextModuleTemplate(mode: ContextMode, modulePath: string, files: string[]): string;
@@ -0,0 +1,2 @@
module.exports = require("metro/private/lib/contextModuleTemplates");
module.exports.default = module.exports;

Some files were not shown because too many files have changed in this diff Show More