UNPKG

@storybook/react-native

Version:

A better way to develop React Native Components for your app

1,361 lines (1,360 loc) 83.5 kB
import { t as WebsocketsOptions } from "../index-Dwx6-0Rh.js"; import { HandleFunction, IncomingMessage, Server } from "connect"; import EventEmitter from "events"; import { Readable } from "stream"; import { IncomingMessage as IncomingMessage$1, ServerResponse } from "http"; //#region \0rolldown/runtime.js //#endregion //#region ../../node_modules/metro-cache/src/types.d.ts /** * 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<<80dd2674720fe89c7a90a649a922cb1d>> * * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js * Original file: packages/metro-cache/src/types.js * To regenerate, run: * js1 build metro-ts-defs (internal) OR * yarn run build-ts-defs (OSS) */ interface CacheStore<T> { name?: string; get(key: Buffer): (null | undefined | T) | Promise<null | undefined | T>; set(key: Buffer, value: T): void | Promise<void>; clear(): void | Promise<void>; } //#endregion //#region ../../node_modules/metro-cache/src/Cache.d.ts /** * Main cache class. Receives an array of cache instances, and sequentially * traverses them to return a previously stored value. It also ensures setting * the value in all instances. * * All get/set operations are logged via Metro's logger. */ declare class Cache<T> { constructor(stores: ReadonlyArray<CacheStore<T>>); get(key: Buffer): Promise<null | undefined | T>; set(key: Buffer, value: T): Promise<void>; get isDisabled(): boolean; } //#endregion //#region ../../node_modules/metro-cache/src/stableHash.d.ts /** * 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<<36e0de65be0930a61b8ff46232052ea7>> * * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js * Original file: packages/metro-cache/src/stableHash.js * To regenerate, run: * js1 build metro-ts-defs (internal) OR * yarn run build-ts-defs (OSS) */ declare function stableHash(value: unknown): Buffer; //#endregion //#region ../../node_modules/metro-cache/src/stores/FileStore.d.ts /** * 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<<7de501c6653d300c594fcf37ce3b56f4>> * * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js * Original file: packages/metro-cache/src/stores/FileStore.js * To regenerate, run: * js1 build metro-ts-defs (internal) OR * yarn run build-ts-defs (OSS) */ type Options$3 = Readonly<{ root: string; }>; declare class FileStore<T> { constructor(options: Options$3); get(key: Buffer): Promise<null | undefined | T>; set(key: Buffer, value: T): Promise<void>; clear(): void; } //#endregion //#region ../../node_modules/metro-cache/src/stores/AutoCleanFileStore.d.ts type CleanOptions = Readonly<Omit<Options$3, keyof { intervalMs?: number; cleanupThresholdMs?: number; }> & { intervalMs?: number; cleanupThresholdMs?: number; }>; /** * A FileStore that, at a given interval, stats the content of the cache root * and deletes any file last modified a set threshold in the past. * * @deprecated This is not efficiently implemented and may cause significant * redundant I/O when caches are large. Prefer your own cleanup scripts, or a * custom Metro cache that uses watches, hooks get/set, and/or implements LRU. */ declare class AutoCleanFileStore<T> extends FileStore<T> { constructor(opts: CleanOptions); } //#endregion //#region ../../node_modules/metro-cache/src/stores/HttpError.d.ts /** * 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 * @generated SignedSource<<7a0b4b83fb44651820333ade6a980ef7>> * * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js * Original file: packages/metro-cache/src/stores/HttpError.js * To regenerate, run: * js1 build metro-ts-defs (internal) OR * yarn run build-ts-defs (OSS) */ declare class HttpError extends Error { code: number; constructor(message: string, code: number); } //#endregion //#region ../../node_modules/metro-cache/src/stores/NetworkError.d.ts /** * 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 * @generated SignedSource<<9a68fe7766e376b8525c589673853e54>> * * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js * Original file: packages/metro-cache/src/stores/NetworkError.js * To regenerate, run: * js1 build metro-ts-defs (internal) OR * yarn run build-ts-defs (OSS) */ declare class NetworkError extends Error { code: string; constructor(message: string, code: string); } //#endregion //#region ../../node_modules/metro-cache/src/stores/HttpStore.d.ts type Options$2 = EndpointOptions | { getOptions: EndpointOptions; setOptions: EndpointOptions; }; type EndpointOptions = { endpoint: string; family?: 4 | 6; timeout?: number; key?: string | ReadonlyArray<string> | Buffer | ReadonlyArray<Buffer>; cert?: string | ReadonlyArray<string> | Buffer | ReadonlyArray<Buffer>; ca?: string | ReadonlyArray<string> | Buffer | ReadonlyArray<Buffer>; params?: URLSearchParams; headers?: { [$$Key$$: string]: string; }; additionalSuccessStatuses?: ReadonlyArray<number>; /** * Whether to include additional debug information in error messages. */ debug?: boolean; /** * Retry configuration */ maxAttempts?: number; retryNetworkErrors?: boolean; retryStatuses?: ReadonlySet<number>; socketPath?: string; proxy?: string; }; declare class HttpStore<T> { static HttpError: typeof HttpError; static NetworkError: typeof NetworkError; constructor(options: Options$2); get(key: Buffer): Promise<null | undefined | T>; set(key: Buffer, value: T): Promise<void>; clear(): void; } //#endregion //#region ../../node_modules/metro-cache/src/stores/HttpGetStore.d.ts declare class HttpGetStore<T> extends HttpStore<T> { constructor(options: Options$2); get(key: Buffer): Promise<null | undefined | T>; set(_key: Buffer, _value: T): Promise<void>; } //#endregion //#region ../../node_modules/metro-cache/src/index.d.ts interface MetroCache { readonly AutoCleanFileStore: typeof AutoCleanFileStore; readonly Cache: typeof Cache; readonly FileStore: typeof FileStore; readonly HttpGetStore: typeof HttpGetStore; readonly HttpStore: typeof HttpStore; readonly stableHash: typeof stableHash; } //#endregion //#region ../../node_modules/metro-file-map/src/flow-types.d.ts type BuildParameters = Readonly<{ computeSha1: boolean; enableSymlinks: boolean; extensions: ReadonlyArray<string>; forceNodeFilesystemAPI: boolean; ignorePattern: RegExp; plugins: ReadonlyArray<InputFileMapPlugin>; retainAllFiles: boolean; rootDir: string; roots: ReadonlyArray<string>; cacheBreaker: string; }>; type BuildResult = { fileSystem: FileSystem; }; type CacheData = Readonly<{ clocks: WatchmanClocks; fileSystemData: unknown; plugins: ReadonlyMap<string, void | V8Serializable>; }>; interface CacheManager { /** * Called during startup to load initial state, if available. Provided to * a crawler, which will return the delta between the initial state and the * current file system state. */ read(): Promise<null | undefined | CacheData>; /** * Called when metro-file-map `build()` has applied changes returned by the * crawler - i.e. internal state reflects the current file system state. * * getSnapshot may be retained and called at any time before end(), such as * in response to eventSource 'change' events. */ write(getSnapshot: () => CacheData, opts: CacheManagerWriteOptions): Promise<void>; /** * The last call that will be made to this CacheManager. Any handles should * be closed by the time this settles. */ end(): Promise<void>; } interface CacheManagerEventSource { onChange(listener: () => void): () => void; } type CacheManagerFactory = (options: CacheManagerFactoryOptions) => CacheManager; type CacheManagerFactoryOptions = Readonly<{ buildParameters: BuildParameters; }>; type CacheManagerWriteOptions = Readonly<{ changedSinceCacheRead: boolean; eventSource: CacheManagerEventSource; onWriteError: (error: Error) => void; }>; type CanonicalPath = string; type ChangedFileMetadata = Readonly<{ isSymlink: boolean; modifiedTime?: null | undefined | number; }>; type ChangeEvent = Readonly<{ logger: null | undefined | RootPerfLogger; changes: ReadonlyFileSystemChanges<Readonly<ChangedFileMetadata>>; rootDir: string; }>; type Console = typeof global.console; type WatcherStatus = { type: 'watchman_slow_command'; timeElapsed: number; command: 'watch-project' | 'query'; } | { type: 'watchman_slow_command_complete'; timeElapsed: number; command: 'watch-project' | 'query'; } | { type: 'watchman_warning'; warning: unknown; command: 'watch-project' | 'query'; }; type FileMapPluginInitOptions<SerializableState, PerFileData = void> = Readonly<{ files: Readonly<{ fileIterator(opts: Readonly<{ includeNodeModules: boolean; includeSymlinks: boolean; }>): Iterable<{ baseName: string; canonicalPath: string; readonly pluginData: null | undefined | PerFileData; }>; lookup(mixedPath: string): { exists: false; } | { exists: true; type: 'f'; readonly pluginData: PerFileData; } | { exists: true; type: 'd'; }; }>; pluginState: null | undefined | SerializableState; }>; type FileMapPluginWorker = Readonly<{ worker: Readonly<{ modulePath: string; setupArgs: JsonData; }>; filter: ($$PARAM_0$$: { normalPath: string; isNodeModules: boolean; }) => boolean; }>; type V8Serializable = string | number | boolean | null | ReadonlyArray<V8Serializable> | ReadonlySet<V8Serializable> | ReadonlyMap<string, V8Serializable> | Readonly<{ [key: string]: V8Serializable; }>; interface FileMapPlugin<SerializableState extends void | V8Serializable = void | V8Serializable, PerFileData extends void | V8Serializable = void | V8Serializable> { readonly name: string; initialize(initOptions: FileMapPluginInitOptions<SerializableState, PerFileData>): Promise<void>; assertValid(): void; onChanged(changes: ReadonlyFileSystemChanges<null | undefined | PerFileData>): void; getSerializableSnapshot(): void | V8Serializable; getCacheKey(): string; getWorker(): null | undefined | FileMapPluginWorker; } type InputFileMapPlugin = FileMapPlugin< /** * > 235 | export type InputFileMapPlugin = FileMapPlugin<empty, empty>; * | ^^^^^ Unsupported feature: Translating "empty type" is currently not supported. **/ any, /** * > 235 | export type InputFileMapPlugin = FileMapPlugin<empty, empty>; * | ^^^^^ Unsupported feature: Translating "empty type" is currently not supported. **/ any>; type HType = { MTIME: 0; SIZE: 1; VISITED: 2; SHA1: 3; SYMLINK: 4; PLUGINDATA: number; PATH: 0; TYPE: 1; MODULE: 0; PACKAGE: 1; GENERIC_PLATFORM: 'g'; NATIVE_PLATFORM: 'native'; }; type HTypeValue = HType[keyof HType]; type FileData = Map<CanonicalPath, FileMetadata>; type FileMetadata = [null | undefined | number, number, 0 | 1, null | undefined | string, 0 | 1 | string, ...unknown[]]; type FileStats = Readonly<{ fileType: 'f' | 'l'; modifiedTime: null | undefined | number; size: null | undefined | number; }>; interface FileSystem { exists(file: Path): boolean; getAllFiles(): Array<Path>; /** * Given a map of files, determine which of them are new or modified * (changedFiles), and which of them are missing from the input * (removedFiles), vs the current state of this instance of FileSystem. */ getDifference(files: FileData, options?: Readonly<{ /** * Only consider files under this subpath (which should be a directory) * when computing removedFiles. If not provided, all files in the file * system are considered. */ subpath?: string; }>): { changedFiles: FileData; removedFiles: Set<string>; }; getSerializableSnapshot(): CacheData['fileSystemData']; getSha1(file: Path): null | undefined | string; getOrComputeSha1(file: Path): Promise<null | undefined | { sha1: string; content?: Buffer; }>; /** * Given a start path (which need not exist), a subpath and type, and * optionally a 'breakOnSegment', performs the following: * * X = mixedStartPath * do * if basename(X) === opts.breakOnSegment * return null * if X + subpath exists and has type opts.subpathType * return { * absolutePath: realpath(X + subpath) * containerRelativePath: relative(mixedStartPath, X) * } * X = dirname(X) * while X !== dirname(X) * * If opts.invalidatedBy is given, collects all absolute, real paths that if * added or removed may invalidate this result. * * Useful for finding the closest package scope (subpath: package.json, * type f, breakOnSegment: node_modules) or closest potential package root * (subpath: node_modules/pkg, type: d) in Node.js resolution. */ hierarchicalLookup(mixedStartPath: string, subpath: string, opts: { breakOnSegment: null | undefined | string; invalidatedBy: null | undefined | Set<string>; subpathType: 'f' | 'd'; }): null | undefined | { absolutePath: string; containerRelativePath: string; }; /** * Analogous to posix lstat. If the file at `file` is a symlink, return * information about the symlink without following it. */ linkStats(file: Path): null | undefined | FileStats; /** * Return information about the given path, whether a directory or file. * Always follow symlinks, and return a real path if it exists. */ lookup(mixedPath: Path): LookupResult; matchFiles(opts: { filter?: RegExp | null; filterCompareAbsolute?: boolean; filterComparePosix?: boolean; follow?: boolean; recursive?: boolean; rootDir?: Path | null; }): Iterable<Path>; } type JsonData = string | number | boolean | null | Array<JsonData> | { [key: string]: JsonData; }; type LookupResult = { exists: false; links: ReadonlySet<string>; missing: string; } | { exists: true; links: ReadonlySet<string>; realPath: string; type: 'd'; } | { exists: true; links: ReadonlySet<string>; realPath: string; type: 'f'; metadata: FileMetadata; }; type HasteConflict = { id: string; platform: string | null; absolutePaths: Array<string>; type: 'duplicate' | 'shadowing'; }; interface HasteMap { getModule(name: string, platform?: null | undefined | string, supportsNativePlatform?: null | undefined | boolean, type?: null | undefined | HTypeValue): null | undefined | Path; getModuleNameByPath(file: Path): null | undefined | string; getPackage(name: string, platform: null | undefined | string, _supportsNativePlatform: null | undefined | boolean): null | undefined | Path; computeConflicts(): Array<HasteConflict>; } interface ReadonlyFileSystemChanges<T = FileMetadata> { readonly addedDirectories: Iterable<CanonicalPath>; readonly removedDirectories: Iterable<CanonicalPath>; readonly addedFiles: Iterable<Readonly<[CanonicalPath, T]>>; readonly modifiedFiles: Iterable<Readonly<[CanonicalPath, T]>>; readonly removedFiles: Iterable<Readonly<[CanonicalPath, T]>>; } type Path = string; type WatchmanClockSpec = string | Readonly<{ scm: Readonly<{ 'mergebase-with': string; }>; }>; type WatchmanClocks = Map<Path, WatchmanClockSpec>; //#endregion //#region ../../node_modules/metro-file-map/src/Watcher.d.ts type HealthCheckResult = { type: 'error'; timeout: number; error: Error; watcher: null | undefined | string; } | { type: 'success'; timeout: number; timeElapsed: number; watcher: null | undefined | string; } | { type: 'timeout'; timeout: number; watcher: null | undefined | string; pauseReason: null | undefined | string; }; //#endregion //#region ../../node_modules/metro-file-map/src/index.d.ts type InputOptions = Readonly<{ computeSha1?: null | undefined | boolean; enableSymlinks?: null | undefined | boolean; extensions: ReadonlyArray<string>; forceNodeFilesystemAPI?: null | undefined | boolean; ignorePattern?: null | undefined | RegExp; plugins?: ReadonlyArray<InputFileMapPlugin>; retainAllFiles: boolean; rootDir: string; roots: ReadonlyArray<string>; cacheManagerFactory?: null | undefined | CacheManagerFactory; console?: Console; healthCheck: HealthCheckOptions; maxFilesPerWorker?: null | undefined | number; maxWorkers: number; perfLoggerFactory?: null | undefined | PerfLoggerFactory; resetCache?: null | undefined | boolean; useWatchman?: null | undefined | boolean; watch?: null | undefined | boolean; watchmanDeferStates?: ReadonlyArray<string>; }>; type HealthCheckOptions = Readonly<{ enabled: boolean; interval: number; timeout: number; filePrefix: string; }>; /** * FileMap includes a JavaScript implementation of Facebook's haste module system. * * This implementation is inspired by https://github.com/facebook/node-haste * and was built with for high-performance in large code repositories with * hundreds of thousands of files. This implementation is scalable and provides * predictable performance. * * Because the file map creation and synchronization is critical to startup * performance and most tasks are blocked by I/O this class makes heavy use of * synchronous operations. It uses worker processes for parallelizing file * access and metadata extraction. * * The data structures created by `metro-file-map` can be used directly from the * cache without further processing. The metadata objects in the `files` and * `map` objects contain cross-references: a metadata object from one can look * up the corresponding metadata object in the other map. Note that in most * projects, the number of files will be greater than the number of haste * modules one module can refer to many files based on platform extensions. * * type CacheData = { * clocks: WatchmanClocks, * files: {[filepath: string]: FileMetadata}, * map: {[id: string]: HasteMapItem}, * mocks: {[id: string]: string}, * } * * // Watchman clocks are used for query synchronization and file system deltas. * type WatchmanClocks = {[filepath: string]: string}; * * type FileMetadata = { * id: ?string, // used to look up module metadata objects in `map`. * mtime: number, // check for outdated files. * size: number, // size of the file in bytes. * visited: boolean, // whether the file has been parsed or not. * dependencies: Array<string>, // all relative dependencies of this file. * sha1: ?string, // SHA-1 of the file, if requested via options. * symlink: ?(1 | 0 | string), // Truthy if symlink, string is target * }; * * // Modules can be targeted to a specific platform based on the file name. * // Example: platform.ios.js and Platform.android.js will both map to the same * // `Platform` module. The platform should be specified during resolution. * type HasteMapItem = {[platform: string]: ModuleMetadata}; * * // * type ModuleMetadata = { * path: string, // the path to look up the file object in `files`. * type: string, // the module type (either `package` or `module`). * }; * * Note that the data structures described above are conceptual only. The actual * implementation uses arrays and constant keys for metadata storage. Instead of * `{id: 'flatMap', mtime: 3421, size: 42, visited: true, dependencies: []}` the real * representation is similar to `['flatMap', 3421, 42, 1, []]` to save storage space * and reduce parse and write time of a big JSON blob. * * The FileMap is created as follows: * 1. read data from the cache or create an empty structure. * * 2. crawl the file system. * * empty cache: crawl the entire file system. * * cache available: * * if watchman is available: get file system delta changes. * * if watchman is unavailable: crawl the entire file system. * * build metadata objects for every file. This builds the `files` part of * the `FileMap`. * * 3. visit and extract metadata from changed files, including sha1, * depedendencies, and any plugins. * * this is done in parallel over worker processes to improve performance. * * the worst case is to visit all files. * * the best case is no file system access and retrieving all data from * the cache. * * the average case is a small number of changed files. * * 4. serialize the new `FileMap` in a cache file. * */ declare class FileMap extends EventEmitter { static create(options: InputOptions): FileMap; constructor(options: InputOptions); build(): Promise<BuildResult>; /** * 1. read data from the cache or create an empty structure. */ read(): Promise<null | undefined | CacheData>; end(): Promise<void>; static H: HType; } //#endregion //#region ../../node_modules/metro-babel-transformer/src/index.d.ts type CustomTransformOptions = { [$$Key$$: string]: unknown; }; type TransformProfile = 'default' | 'hermes-stable' | 'hermes-canary'; //#endregion //#region ../../node_modules/metro-source-map/src/source-map.d.ts type GeneratedCodeMapping = [number, number]; type SourceMapping = [number, number, number, number]; type SourceMappingWithName = [number, number, number, number, string]; type MetroSourceMapSegmentTuple = SourceMappingWithName | SourceMapping | GeneratedCodeMapping; type HermesFunctionOffsets = { [$$Key$$: number]: ReadonlyArray<number>; }; type FBSourcesArray = ReadonlyArray<null | undefined | FBSourceMetadata>; type FBSourceMetadata = [null | undefined | FBSourceFunctionMap]; type FBSourceFunctionMap = { readonly names: ReadonlyArray<string>; readonly mappings: string; }; type FBSegmentMap = { [id: string]: MixedSourceMap; }; type BasicSourceMap = { readonly file?: string; readonly mappings: string; readonly names: Array<string>; readonly sourceRoot?: string; readonly sources: Array<string>; readonly sourcesContent?: Array<null | undefined | string>; readonly version: number; readonly x_facebook_offsets?: Array<number>; readonly x_metro_module_paths?: Array<string>; readonly x_facebook_sources?: FBSourcesArray; readonly x_facebook_segments?: FBSegmentMap; readonly x_hermes_function_offsets?: HermesFunctionOffsets; readonly x_google_ignoreList?: Array<number>; }; type IndexMapSection = { map: IndexMap | BasicSourceMap; offset: { line: number; column: number; }; }; type IndexMap = { readonly file?: string; readonly mappings?: void; readonly sourcesContent?: void; readonly sections: Array<IndexMapSection>; readonly version: number; readonly x_facebook_offsets?: Array<number>; readonly x_metro_module_paths?: Array<string>; readonly x_facebook_sources?: void; readonly x_facebook_segments?: FBSegmentMap; readonly x_hermes_function_offsets?: HermesFunctionOffsets; readonly x_google_ignoreList?: void; }; type MixedSourceMap = IndexMap | BasicSourceMap; //#endregion //#region ../../node_modules/metro/src/lib/CountingSet.d.ts /** * 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<<0fccda5d7f0eb38539316fa1fedae97b>> * * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js * Original file: packages/metro/src/lib/CountingSet.js * To regenerate, run: * js1 build metro-ts-defs (internal) OR * yarn run build-ts-defs (OSS) */ interface ReadOnlyCountingSet<T> extends Iterable<T> { has(item: T): boolean; readonly size: number; count(item: T): number; forEach<ThisT>(callbackFn: (this: ThisT, value: T, key: T, set: ReadOnlyCountingSet<T>) => unknown, 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. */ declare 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>; get size(): number; count(item: T): number; clear(): void; forEach<ThisT>(callbackFn: (this: ThisT, value: T, key: T, set: CountingSet<T>) => unknown, thisArg: ThisT): void; toJSON(): unknown; } //#endregion //#region ../../node_modules/metro/src/DeltaBundler/Graph.d.ts type Result<T> = { added: Map<string, Module<T>>; modified: Map<string, Module<T>>; deleted: Set<string>; }; type Delta<T> = Readonly<{ added: Set<string>; touched: Set<string>; deleted: Set<string>; updatedModuleData: ReadonlyMap<string, ModuleData<T>>; baseModuleData: Map<string, ModuleData<T>>; errors: ReadonlyMap<string, Error>; }>; type InternalOptions<T> = Readonly<{ lazy: boolean; onDependencyAdd: () => unknown; onDependencyAdded: () => unknown; resolve: Options$1<T>['resolve']; transform: Options$1<T>['transform']; shallow: boolean; }>; declare class Graph<T = MixedOutput> { readonly entryPoints: ReadonlySet<string>; readonly transformOptions: TransformInputOptions; readonly dependencies: Dependencies<T>; constructor(options: GraphInputOptions); /** * Dependency Traversal logic for the Delta Bundler. This method calculates * the modules that should be included in the bundle by traversing the * dependency graph. * Instead of traversing the whole graph each time, it just calculates the * difference between runs by only traversing the added/removed dependencies. * To do so, it uses the passed graph dependencies and it mutates it. * The paths parameter contains the absolute paths of the root files that the * method should traverse. Normally, these paths should be the modified files * since the last traversal. */ traverseDependencies(paths: ReadonlyArray<string>, options: Options$1<T>): Promise<Result<T>>; initialTraverseDependencies(options: Options$1<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; /** * Collect a list of context modules which include a given file. */ markModifiedContextModules(filePath: string, modifiedPaths: Set<string> | CountingSet<string>): void; /** * Gets the list of modules affected by the deletion of a given file. The * caller is expected to mark these modules as modified in the next call to * traverseDependencies. Note that the list may contain duplicates. */ getModifiedModulesForDeletedPath(filePath: string): Iterable<string>; /** * Re-traverse the dependency graph in DFS order to reorder the modules and * guarantee the same order between runs. This method mutates the passed graph. */ reorderGraph(options: { shallow: boolean; }): void; _reorderDependencies(module: Module<T>, orderedDependencies: Map<string, Module<T>>, options: { shallow: boolean; }): void; /** Garbage collection functions */ _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; /** End of garbage collection functions */ } //#endregion //#region ../../node_modules/metro/src/DeltaBundler/DeltaCalculator.d.ts /** * 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$1<T>; _currentBuildPromise: null | undefined | Promise<DeltaResult<T>>; _deletedFiles: Set<string>; _modifiedFiles: Set<string>; _addedFiles: Set<string>; _requiresReset: boolean; _graph: Graph<T>; constructor(entryPoints: ReadonlySet<string>, changeEventSource: EventEmitter, options: Options$1<T>); /** * Stops listening for file changes and clears all the caches. */ end(): void; /** * Main method to calculate the delta of modules. It returns a DeltaResult, * which contain the modified/added modules and the removed modules. */ getDelta($$PARAM_0$$: { reset: boolean; shallow: boolean; }): Promise<DeltaResult<T>>; /** * Returns the graph with all the dependencies. Each module contains the * needed information to do the traversing (dependencies, inverseDependencies) * plus some metadata. */ getGraph(): Graph<T>; _handleMultipleFileChanges: (changeEvent: ChangeEvent) => void; _getChangedDependencies(modifiedFiles: Set<string>, deletedFiles: Set<string>, addedFiles: Set<string>): Promise<DeltaResult<T>>; } //#endregion //#region ../../node_modules/metro/src/DeltaBundler.d.ts /** * `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$1<T>): Promise<ReadOnlyGraph<T>['dependencies']>; buildGraph(entryPoints: ReadonlyArray<string>, options: Options$1<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; } //#endregion //#region ../../node_modules/metro-transform-worker/src/index.d.ts type MinifierConfig = Readonly<{ [$$Key$$: string]: unknown; }>; type Type = 'script' | 'module' | 'asset'; type JsTransformerConfig = Readonly<{ assetPlugins: ReadonlyArray<string>; assetRegistryPath: string; asyncRequireModulePath: string; babelTransformerPath: string; dynamicDepsInPackages: DynamicRequiresBehavior; enableBabelRCLookup: boolean; enableBabelRuntime: boolean | string; globalPrefix: string; hermesParser: boolean; minifierConfig: MinifierConfig; minifierPath: string; optimizationSizeLimit: number; publicPath: string; allowOptionalDependencies: AllowOptionalDependencies; unstable_dependencyMapReservedName: null | undefined | string; unstable_disableModuleWrapping: boolean; unstable_disableNormalizePseudoGlobals: boolean; unstable_compactOutput: boolean; /** Enable `require.context` statements which can be used to import multiple files in a directory. */ unstable_allowRequireContext: boolean; /** With inlineRequires, enable a module-scope memo var and inline as (v || v=require('foo')) */ unstable_memoizeInlineRequires?: boolean; /** With inlineRequires, do not memoize these module specifiers */ unstable_nonMemoizedInlineRequires?: ReadonlyArray<string>; /** Whether to rename scoped `require` functions to `_$$_REQUIRE`, usually an extraneous operation when serializing to iife (default). */ unstable_renameRequire?: boolean; }>; type JsTransformOptions = Readonly<{ customTransformOptions?: CustomTransformOptions; dev: boolean; experimentalImportSupport?: boolean; inlinePlatform: boolean; inlineRequires: boolean; minify: boolean; nonInlinedRequires?: ReadonlyArray<string>; platform: null | undefined | string; type: Type; unstable_memoizeInlineRequires?: boolean; unstable_nonMemoizedInlineRequires?: ReadonlyArray<string>; unstable_staticHermesOptimizedRequire?: boolean; unstable_transformProfile: TransformProfile; }>; //#endregion //#region ../../node_modules/metro/src/shared/types.d.ts type MetroSourceMapOrMappings = MixedSourceMap | Array<MetroSourceMapSegmentTuple>; declare enum SourcePathsMode { Absolute = 'absolute', ServerUrl = 'url-server' } declare namespace SourcePathsMode { export function cast(value: string | null | undefined): SourcePathsMode; export function isValid(value: string | null | undefined): value is SourcePathsMode; export function members(): IterableIterator<SourcePathsMode>; export function getName(value: SourcePathsMode): string; } type ReadonlySourceLocation = Readonly<{ start: Readonly<{ line: number; column: number; }>; end: Readonly<{ line: number; column: number; }>; }>; type BundleOptions = { readonly customResolverOptions: CustomResolverOptions; customTransformOptions: CustomTransformOptions; dev: boolean; entryFile: string; readonly excludeSource: boolean; readonly inlineSourceMap: boolean; readonly lazy: boolean; minify: boolean; readonly modulesOnly: boolean; onProgress: null | undefined | ((doneCont: number, totalCount: number) => unknown); readonly platform: null | undefined | string; readonly runModule: boolean; readonly shallow: boolean; sourceMapUrl: null | undefined | string; sourceUrl: null | undefined | string; createModuleIdFactory?: () => (path: string) => number; readonly unstable_transformProfile: TransformProfile; readonly sourcePaths: SourcePathsMode; }; type BuildOptions = Readonly<{ withAssets?: boolean; }>; type ResolverInputOptions = Readonly<{ customResolverOptions?: CustomResolverOptions; dev: boolean; }>; type SerializerOptions$1 = { readonly sourceMapUrl: null | undefined | string; readonly sourceUrl: null | undefined | string; readonly runModule: boolean; readonly excludeSource: boolean; readonly inlineSourceMap: boolean; readonly modulesOnly: boolean; readonly sourcePaths: SourcePathsMode; }; type GraphOptions = { readonly lazy: boolean; readonly shallow: boolean; }; type SplitBundleOptions = Readonly<{ entryFile: string; resolverOptions: ResolverInputOptions; transformOptions: TransformInputOptions; serializerOptions: SerializerOptions$1; graphOptions: GraphOptions; onProgress: Options$1['onProgress']; }>; type ModuleTransportLike = { readonly code: string; readonly id: number; readonly map: null | undefined | MetroSourceMapOrMappings; readonly name?: string; readonly sourcePath: string; }; //#endregion //#region ../../node_modules/metro/src/ModuleGraph/worker/collectDependencies.d.ts type ContextMode = 'sync' | 'eager' | 'lazy' | 'lazy-once'; type ContextFilter = Readonly<{ pattern: string; flags: string; }>; type RequireContextParams = Readonly<{ recursive: boolean; filter: Readonly<ContextFilter>; /** Mode for resolving dynamic dependencies. Defaults to `sync` */ mode: ContextMode; }>; type DynamicRequiresBehavior = 'throwAtRuntime' | 'reject'; //#endregion //#region ../../node_modules/metro/src/lib/contextModule.d.ts type RequireContext = Readonly<{ recursive: boolean; filter: RegExp; /** Mode for resolving dynamic dependencies. Defaults to `sync` */ mode: ContextMode; /** Absolute path of the directory to search in */ from: string; }>; //#endregion //#region ../../node_modules/metro/src/DeltaBundler/types.d.ts type MixedOutput = { readonly data: unknown; readonly type: string; }; type AsyncDependencyType = 'async' | 'maybeSync' | 'prefetch' | 'weak'; type TransformResultDependency = Readonly<{ /** * The literal name provided to a require or import call. For example 'foo' in * case of `require('foo')`. */ name: string; /** * Extra data returned by the dependency extractor. */ data: Readonly<{ /** * A locally unique key for this dependency within the current module. */ key: string; /** * If not null, this dependency is due to a dynamic `import()` or `__prefetchImport()` call. */ asyncType: AsyncDependencyType | null; /** * True if the dependency is declared with a static "import x from 'y'" or * an import() call. */ isESMImport: boolean; /** * The dependency is enclosed in a try/catch block. */ isOptional?: boolean; locs: ReadonlyArray<ReadonlySourceLocation>; /** Context for requiring a collection of modules. */ contextParams?: RequireContextParams; }>; }>; type ResolvedDependency = Readonly<{ absolutePath: string; data: TransformResultDependency; }>; type Dependency = ResolvedDependency | Readonly<{ data: TransformResultDependency; }>; type Module<T = MixedOutput> = Readonly<{ dependencies: Map<string, Dependency>; inverseDependencies: CountingSet<string>; output: ReadonlyArray<T>; path: string; getSource: () => Buffer; unstable_transformResultKey?: null | undefined | string; }>; type ModuleData<T = MixedOutput> = Readonly<{ dependencies: ReadonlyMap<string, Dependency>; resolvedContexts: ReadonlyMap<string, RequireContext>; output: ReadonlyArray<T>; getSource: () => Buffer; unstable_transformResultKey?: null | undefined | string; }>; type Dependencies<T = MixedOutput> = Map<string, Module<T>>; type ReadOnlyDependencies<T = MixedOutput> = ReadonlyMap<string, Module<T>>; type TransformInputOptions = Omit<JsTransformOptions, 'inlinePlatform' | 'inlineRequires'>; type GraphInputOptions = Readonly<{ entryPoints: ReadonlySet<string>; transformOptions: TransformInputOptions; }>; interface ReadOnlyGraph<T = MixedOutput> { readonly entryPoints: ReadonlySet<string>; readonly transformOptions: Readonly<TransformInputOptions>; readonly dependencies: ReadOnlyDependencies<T>; } type TransformResult<T = MixedOutput> = Readonly<{ dependencies: ReadonlyArray<TransformResultDependency>; output: ReadonlyArray<T>; unstable_transformResultKey?: null | undefined | string; }>; type TransformResultWithSource<T = MixedOutput> = Readonly<Omit<TransformResult<T>, keyof { getSource: () => Buffer; }> & { getSource: () => Buffer; }>; type TransformFn<T = MixedOutput> = ($$PARAM_0$$: string, $$PARAM_1$$: null | undefined | RequireContext) => Promise<TransformResultWithSource<T>>; type ResolveFn = (from: string, dependency: TransformResultDependency) => BundlerResolution; type AllowOptionalDependenciesWithOptions = { readonly exclude: Array<string>; }; type AllowOptionalDependencies = boolean | AllowOptionalDependenciesWithOptions; type BundlerResolution = Readonly<{ type: 'sourceFile'; filePath: string; }>; type Options$1<T = MixedOutput> = Readonly<{ resolve: ResolveFn; transform: TransformFn<T>; transformOptions: TransformInputOptions; onProgress: null | undefined | ((numProcessed: number, total: number) => unknown); lazy: boolean; unstable_allowRequireContext: boolean; unstable_enablePackageExports: boolean; unstable_incrementalResolution: boolean; shallow: boolean; }>; type DeltaResult<T = MixedOutput> = { readonly added: Map<string, Module<T>>; readonly modified: Map<string, Module<T>>; readonly deleted: Set<string>; readonly reset: boolean; }; type SerializerOptions = Readonly<{ asyncRequireModulePath: string; createModuleId: ($$PARAM_0$$: string) => number; dev: boolean; getRunModuleStatement: (moduleId: number | string, globalPrefix: string) => string; globalPrefix: string; includeAsyncPaths: boolean; inlineSourceMap: null | undefined | boolean; modulesOnly: boolean; processModuleFilter: (module: Module) => boolean; projectRoot: string; runBeforeMainModule: ReadonlyArray<string>; runModule: boolean; serverRoot: string; shouldAddToIgnoreList: ($$PARAM_0$$: Module) => boolean; sourceMapUrl: null | undefined | string; sourceUrl: null | undefined | string; getSourceUrl: null | undefined | (($$PARAM_0$$: Module) => string); }>; //#endregion //#region ../../node_modules/metro-resolver/src/types.d.ts type Resolution = FileResolution | { readonly type: 'empty'; }; type SourceFileResolution = Readonly<{ type: 'sourceFile'; filePath: string; }>; type AssetFileResolution = ReadonlyArray<string>; type AssetResolution = Readonly<{ type: 'assetFiles'; filePaths: AssetFileResolution; }>; type FileResolution = AssetResolution | SourceFileResolution; /** * This is a way to describe what files we tried to look for when resolving * a module name as file. This is mainly used for error reporting, so that * we can explain why we cannot resolve a module. */ type FileCandidates = { readonly type: 'asset'; readonly name: string; } | { readonly type: 'sourceFile'; filePathPrefix: string; readonly candidateExts: ReadonlyArray<string>; }; type ExportsLikeMap = Readonly<{ [subpathOrCondition: string]: string | ExportsLikeMap | null; }>; /** "exports" mapping where values may be legacy Node.js <13.7 array format. */ type ExportMapWithFallbacks = Readonly<{ [subpath: string]: ExportsLikeMap[keyof ExportsLikeMap] | ExportValueWithFallback; }>; /** "exports" subpath value when in legacy Node.js <13.7 array format. */ type ExportValueWithFallback = ReadonlyArray<ExportsLikeMap | string> | ReadonlyArray<ReadonlyArray<unknown>>; type ExportsField = string | ReadonlyArray<string> | ExportValueWithFallback | ExportsLikeMap | ExportMapWithFallbacks; type PackageJson = Readonly<{ name?: string; main?: string; exports?: ExportsField; imports?: ExportsLikeMap; }>; type PackageInfo = Readonly<{ packageJson: PackageJson; rootPath: string; }>; type PackageForModule = Readonly<Omit<PackageInfo, keyof { packageRelativePath: string; }> & { packageRelativePath: string; }>; /** * Check existence of a single file. */ type DoesFileExist = (filePath: string) => boolean; /** * Performs a lookup against an absolute or project-relative path to determine * whether it exists as a file or directory. Follows any symlinks, and returns * a real absolute path on existence. */ type FileSystemLookup = (absoluteOrProjectRelativePath: string) => { exists: false; } | { exists: true; type: 'f' | 'd'; realPath: string; }; /** * Given a directory path and the base asset name, return a list of all the * asset file names that match the given base name in that directory. Return * null if there's no such named asset. `platform` is used to identify * platform-specific assets, ex. `foo.ios.js` instead of a generic `foo.js`. */ type ResolveAsset = (dirPath: string, assetName: string, extension: string) => null | undefined | ReadonlyArray<string>; type ResolutionContext = Readonly<{ allowHaste: boolean; assetExts: ReadonlySet<string>; customResolverOptions: CustomResolverOptions; disableHierarchicalLookup: boolean; /** * Determine whether a regular file exists at the given path. * * @deprecated, prefer `fileSystemLookup` */ doesFileExist: DoesFileExist; extraNodeModules: null | undefined | { [$$Key$$: string]: string; }; /** Is resolving for a development bundle. */ dev: boolean; /** * Get the parsed contents of the specified `package.json` file. */ getPackage: (packageJsonPath: string) => null | undefined | PackageJson; /** * Get the closest package scope, parsed `package.json` and relative subpath * for a given absolute candidate path (which need not exist), or null if * there is no package.json closer than the nearest node_modules directory. * * @deprecated See https://github.com/facebook/metro/commit/29c77bff31e2475a086bc3f04073f485da8f9ff0 */ getPackageForModule: (absoluteModulePath: string) => null | undefined | PackageForModule; /** * The dependency descriptor, within the origin module, corresponding to the * current resolution request. This is provided for diagnostic purposes ONLY * and may not be used for resolution purposes. */ dependency?: TransformResultDependency; /** * Whether the dependency to be resolved was declared with an ESM import, * ("import x from 'y'" or "await import('z')"), or a CommonJS "require". * Corresponds to the criteria Node.js uses to assert an "import" * resolution condition, vs "require". * * Always equal to dependency.data.isESMImport where dependency is provided, * but may be used for resolution. */ isESMImport?: boolean; /** * Synchonously returns information about a given absolute path, including * whether it exists, whether it is a file or directory, and its absolute * real path. */ fileSystemLookup: FileSystemLookup; /** * The ordered list of fields to read in `package.json` to resolve a main * entry point based on the "browser" field spec. */ mainFields: ReadonlyArray<string>; /** * Full path of the module that is requiring or importing the module to be * resolved. This may not be the only place this dependency was found, * as resolutions can be cached. */ originModulePath: string; nodeModulesPaths: ReadonlyArray<string>; preferNativePlatform: boolean; resolveAsset: ResolveAsset; redirectModulePath: (modulePath: string) => string | false; /** * Given a name, this should return the full path to the file that provides * a Haste module of that name. Ex. for `Foo` it may return `/smth/Foo.js`. */ resolveHasteModule: (name: string) => null | undefined | string; /** * Given a name, this should return the full path to the package manifest that * provides a Haste package of that name. Ex. for `Foo` it may return * `/smth/Foo/package.json`. */ resolveHastePackage: (name: string) => null | undefined | string; resolveRequest?: null | undefined | CustomResolver; sourceExts: ReadonlyArray<string>; unstable_conditionNames: ReadonlyArray<string>; unstable_conditionsByPlatform: Readonly<{ [platform: string]: ReadonlyArray<string>; }>; unstable_enablePackageExports: boolean; unstable_incrementalResolution: boolean; unstable_logWarning: (message: string) => void; }>; type CustomResolutionContext = Readonly<Omit<ResolutionContext, keyof { resolveRequest: CustomResolver; }> & { resolveRequest: CustomResolver; }>; type CustomResolver = (context: CustomResolutionContext, moduleName: string, platform: string | null) => Resolution; type CustomResolverOptions = { readonly [$$Key$$: string]: unknown; }; declare namespace Logger_d_exports { export { ActionLogEntryData, ActionStartLogEntry, LogEntry, createActionEndEntry, createActionStartEntry, createEntry, log, on }; } type ActionLogEntryData = { action_name: string; log_entry_label?: string; }; type ActionStartLogEntry = { action_name?: string; action_phase?: string; log_entry_label: string; log_session?: string; start_timestamp?: [number, number]; }; type LogEntry = { action_name?: string; action_phase?: string; action_result?: string; duration_ms?: number; entry_point?: string; file_name?: string; log_entry_label: string; log_session?: string; start_timestamp?: [number, number]; outdated_modules?: number; bundle_size?: number; bundle_options?: BundleOptions; bundle_hash?: string; build_id?: string; error_message?: string; error_stack?: string; }; declare function on(event: string, handler: (logEntry: LogEntry) => void): void; declare function createEntry(data: LogEntry | string): LogEntry; declare function createActionStartEntry(data: ActionLogEntryData | string): LogEntry; declare function createActionEndEntry(logEntry: ActionStartLogEntry, error?: null | undefined | Error): LogEntry; declare function log(logEntry: LogEntry): LogEntry; //#endregion //#region ../../node_modules/metro/src/lib/reporting.d.ts type BundleDetails = { bundleType: string; customResolverOptions: CustomResolverOptions; customTransformOptions: CustomTransformOptions; dev: boolean; entryFile: string; minify: boolean; platform: null | u