first commit

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

View File

@@ -0,0 +1,2 @@
import type { ExportsField, FileResolution, ResolutionContext } from "./types";
export declare function resolvePackageTargetFromExports(context: ResolutionContext, packagePath: string, modulePath: string, packageRelativePath: string, exportsField: ExportsField, platform: string | null): FileResolution;

View File

@@ -0,0 +1,2 @@
module.exports = require("metro-resolver/private/PackageExportsResolve");
module.exports.default = module.exports;

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 { ExportsLikeMap, FileResolution, ResolutionContext } from "./types";
/**
* Resolve a package subpath based on the entry points defined in the package's
* "imports" field. If there is no match for the given subpath (which may be
* augmented by resolution of conditional exports for the passed `context`),
* throws a `PackagePathNotExportedError`.
*
* Implementation of PACKAGE_IMPORTS_RESOLVE described in https://nodejs.org/api/esm.html
*
* @throws {InvalidPackageConfigurationError} Raised if configuration specified
* by `importsMap` is invalid.
*/
export declare function resolvePackageTargetFromImports(context: ResolutionContext, packagePath: string, importPath: string, importsMap: ExportsLikeMap, platform: string | null): FileResolution;

View File

@@ -0,0 +1,2 @@
module.exports = require("metro-resolver/private/PackageImportsResolve");
module.exports.default = module.exports;

View File

@@ -0,0 +1,34 @@
/**
* 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 { PackageInfo, ResolutionContext } from "./types";
/**
* Resolve the main entry point subpath for a package.
*
* Implements legacy (non-exports) package resolution behaviour based on the
* ["browser" field spec](https://github.com/defunctzombie/package-browser-field-spec).
*/
export declare function getPackageEntryPoint(context: ResolutionContext, packageInfo: PackageInfo, platform: string | null): string;
/**
* Get the resolved file path for the given import specifier based on any
* `package.json` rules. Returns `false` if the module should be
* [ignored](https://github.com/defunctzombie/package-browser-field-spec#ignore-a-module),
* and returns the original path if no `package.json` mapping is matched. Does
* not test file existence.
*
* Implements legacy (non-exports) package resolution behaviour based on the
* ["browser" field spec](https://github.com/defunctzombie/package-browser-field-spec).
*/
export declare function redirectModulePath(context: {
readonly getPackageForModule: ResolutionContext["getPackageForModule"];
readonly mainFields: ResolutionContext["mainFields"];
readonly originModulePath: ResolutionContext["originModulePath"];
}, modulePath: string): string | false;

View File

@@ -0,0 +1,2 @@
module.exports = require("metro-resolver/private/PackageResolve");
module.exports.default = module.exports;

View File

@@ -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 { ResolutionContext } from "./types";
import type { TransformResultDependency } from "../metro/DeltaBundler/types";
export interface PartialContext extends ResolutionContext {
readonly redirectModulePath?: ResolutionContext["redirectModulePath"];
}
/**
* Helper used by the `metro` package to create the `ResolutionContext` object.
* As context values can be overridden by callers, this occurs externally to
* `resolve.js`.
*/
declare function createDefaultContext(context: PartialContext, dependency: TransformResultDependency): ResolutionContext;
export default createDefaultContext;

View File

@@ -0,0 +1 @@
module.exports = require("metro-resolver/private/createDefaultContext");

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
*/
declare class FailedToResolveNameError extends Error {
dirPaths: ReadonlyArray<string>;
extraPaths: ReadonlyArray<string>;
constructor(dirPaths: ReadonlyArray<string>, extraPaths: ReadonlyArray<string>);
}
export default FailedToResolveNameError;

View File

@@ -0,0 +1 @@
module.exports = require("metro-resolver/private/errors/FailedToResolveNameError");

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 { FileAndDirCandidates } from "../types";
declare class FailedToResolvePathError extends Error {
candidates: FileAndDirCandidates;
constructor(candidates: FileAndDirCandidates);
}
export default FailedToResolvePathError;

View File

@@ -0,0 +1 @@
module.exports = require("metro-resolver/private/errors/FailedToResolvePathError");

View File

@@ -0,0 +1,15 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
* @format
* @oncall react_native
*/
declare class FailedToResolveUnsupportedError extends Error {
constructor(message: string);
}
export default FailedToResolveUnsupportedError;

View File

@@ -0,0 +1 @@
module.exports = require("metro-resolver/private/errors/FailedToResolveUnsupportedError");

View File

@@ -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
*/
/**
* Raised when a package contains an invalid `package.json` configuration.
*/
declare class InvalidPackageConfigurationError extends Error {
reason: string;
packagePath: string;
constructor(opts: {
readonly reason: string;
readonly packagePath: string;
});
}
export default InvalidPackageConfigurationError;

View File

@@ -0,0 +1 @@
module.exports = require("metro-resolver/private/errors/InvalidPackageConfigurationError");

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 { FileCandidates } from "../types";
declare class InvalidPackageError extends Error {
fileCandidates: FileCandidates;
indexCandidates: FileCandidates;
mainModulePath: string;
packageJsonPath: string;
constructor(opts: {
readonly fileCandidates: FileCandidates;
readonly indexCandidates: FileCandidates;
readonly mainModulePath: string;
readonly packageJsonPath: string;
});
}
export default InvalidPackageError;

View File

@@ -0,0 +1 @@
module.exports = require("metro-resolver/private/errors/InvalidPackageError");

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
*/
/**
* Raised when package imports do not define or permit a target subpath in the
* package for the given import specifier.
*/
declare class PackageImportNotResolvedError extends Error {
readonly importSpecifier: string;
readonly reason: string;
constructor(opts: {
readonly importSpecifier: string;
readonly reason: string;
});
}
export default PackageImportNotResolvedError;

View File

@@ -0,0 +1 @@
module.exports = require("metro-resolver/private/errors/PackageImportNotResolvedError");

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
*/
/**
* Raised when package exports do not define or permit a target subpath in the
* package for the given module.
*/
declare class PackagePathNotExportedError extends Error {}
export default PackagePathNotExportedError;

View File

@@ -0,0 +1 @@
module.exports = require("metro-resolver/private/errors/PackagePathNotExportedError");

View File

@@ -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 { FileCandidates } from "../types";
declare function formatFileCandidates(candidates: FileCandidates): string;
export default formatFileCandidates;

View File

@@ -0,0 +1 @@
module.exports = require("metro-resolver/private/errors/formatFileCandidates");

25
node_modules/@expo/metro/metro-resolver/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,25 @@
import FailedToResolveNameError from "./errors/FailedToResolveNameError";
import FailedToResolvePathError from "./errors/FailedToResolvePathError";
import FailedToResolveUnsupportedError from "./errors/FailedToResolveUnsupportedError";
import formatFileCandidates from "./errors/formatFileCandidates";
import InvalidPackageError from "./errors/InvalidPackageError";
import resolve from "./resolve";
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
* @oncall react_native
*/
export type { AssetFileResolution, CustomResolutionContext, CustomResolver, CustomResolverOptions, DoesFileExist, FileAndDirCandidates, FileCandidates, FileResolution, FileSystemLookup, ResolutionContext, Resolution, ResolveAsset, Result } from "./types";
export { FailedToResolveNameError, FailedToResolvePathError, FailedToResolveUnsupportedError, formatFileCandidates, InvalidPackageError, resolve };
/**
* Backwards-compatibility with CommonJS consumers using interopRequireDefault.
* Do not add to this list.
*
* @deprecated Default import from 'metro-resolver' is deprecated, use named exports.
*/

1
node_modules/@expo/metro/metro-resolver/index.js generated vendored Normal file
View File

@@ -0,0 +1 @@
module.exports = require("metro-resolver");

14
node_modules/@expo/metro/metro-resolver/resolve.d.ts generated vendored Normal file
View File

@@ -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 { Resolution, ResolutionContext } from "./types";
declare function resolve(context: ResolutionContext, moduleName: string, platform: string | null): Resolution;
export default resolve;

1
node_modules/@expo/metro/metro-resolver/resolve.js generated vendored Normal file
View File

@@ -0,0 +1 @@
module.exports = require("metro-resolver/private/resolve");

View File

@@ -0,0 +1,19 @@
/**
* 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 { AssetResolution, ResolutionContext } from "./types";
/**
* Resolve a file path as an asset. Returns the set of files found after
* expanding asset resolutions (e.g. `icon@2x.png`). Users may override this
* behaviour via `context.resolveAsset`.
*/
declare function resolveAsset(context: ResolutionContext, filePath: string): AssetResolution | null;
export default resolveAsset;

View File

@@ -0,0 +1 @@
module.exports = require("metro-resolver/private/resolveAsset");

191
node_modules/@expo/metro/metro-resolver/types.d.ts generated vendored Normal file
View File

@@ -0,0 +1,191 @@
/**
* 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 { TransformResultDependency } from "../metro/DeltaBundler/types";
export type Result<TResolution, TCandidates> = {
readonly type: "resolved";
readonly resolution: TResolution;
} | {
readonly type: "failed";
readonly candidates: TCandidates;
};
export type Resolution = FileResolution | {
readonly type: "empty";
};
export interface SourceFileResolution {
readonly type: "sourceFile";
readonly filePath: string;
}
export type AssetFileResolution = ReadonlyArray<string>;
export interface AssetResolution {
readonly type: "assetFiles";
readonly filePaths: AssetFileResolution;
}
export type FileResolution = AssetResolution | SourceFileResolution;
export interface FileAndDirCandidates {
readonly dir?: null | FileCandidates;
readonly file?: null | FileCandidates;
}
/**
* 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.
*/
export type FileCandidates = {
readonly type: "asset";
readonly name: string;
} | {
readonly type: "sourceFile";
filePathPrefix: string;
readonly candidateExts: ReadonlyArray<string>;
};
export interface ExportsLikeMap {
readonly [subpathOrCondition: string]: string | ExportsLikeMap | null;
}
/** "exports" mapping where values may be legacy Node.js <13.7 array format. */
export interface ExportMapWithFallbacks {
readonly [subpath: string]: ExportsLikeMap[keyof ExportsLikeMap] | ExportValueWithFallback;
}
/** "exports" subpath value when in legacy Node.js <13.7 array format. */
export type ExportValueWithFallback = ReadonlyArray<ExportsLikeMap | string> | ReadonlyArray<ReadonlyArray<any>>;
export type ExportsField = string | ReadonlyArray<string> | ExportValueWithFallback | ExportsLikeMap | ExportMapWithFallbacks;
export type FlattenedExportMap = ReadonlyMap<string, string | null>;
export type NormalizedExportsLikeMap = Map<string, null | string | ExportsLikeMap>;
export interface PackageJson {
readonly name?: string;
readonly main?: string;
readonly exports?: ExportsField;
readonly imports?: ExportsLikeMap;
}
export interface PackageInfo {
readonly packageJson: PackageJson;
readonly rootPath: string;
}
export interface PackageForModule extends PackageInfo {
readonly packageRelativePath: string;
}
/**
* Check existence of a single file.
*/
export 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.
*/
export 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`.
*/
export type ResolveAsset = (dirPath: string, assetName: string, extension: string) => null | undefined | ReadonlyArray<string>;
export interface _ResolutionContext_extraNodeModules {
[$$Key$$: string]: string;
}
export interface _ResolutionContext_unstable_conditionsByPlatform {
readonly [platform: string]: ReadonlyArray<string>;
}
export interface ResolutionContext {
readonly allowHaste: boolean;
readonly assetExts: ReadonlySet<string>;
readonly customResolverOptions: CustomResolverOptions;
readonly disableHierarchicalLookup: boolean;
/**
* Determine whether a regular file exists at the given path.
*
* @deprecated, prefer `fileSystemLookup`
*/
readonly doesFileExist: DoesFileExist;
readonly extraNodeModules?: null | _ResolutionContext_extraNodeModules;
/** Is resolving for a development bundle. */
readonly dev: boolean;
/**
* Get the parsed contents of the specified `package.json` file.
*/
readonly 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
*/
readonly 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.
*/
readonly 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.
*/
readonly 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.
*/
readonly fileSystemLookup: FileSystemLookup;
/**
* The ordered list of fields to read in `package.json` to resolve a main
* entry point based on the "browser" field spec.
*/
readonly 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.
*/
readonly originModulePath: string;
readonly nodeModulesPaths: ReadonlyArray<string>;
readonly preferNativePlatform: boolean;
readonly resolveAsset: ResolveAsset;
readonly 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`.
*/
readonly 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`.
*/
readonly resolveHastePackage: (name: string) => null | undefined | string;
readonly resolveRequest?: null | undefined | CustomResolver;
readonly sourceExts: ReadonlyArray<string>;
readonly unstable_conditionNames: ReadonlyArray<string>;
readonly unstable_conditionsByPlatform: _ResolutionContext_unstable_conditionsByPlatform;
readonly unstable_enablePackageExports: boolean;
readonly unstable_logWarning: (message: string) => void;
}
export interface CustomResolutionContext extends ResolutionContext {
readonly resolveRequest: CustomResolver;
}
export type CustomResolver = (context: CustomResolutionContext, moduleName: string, platform: string | null) => Resolution;
export interface CustomResolverOptions {
readonly [$$Key$$: string]: any;
}

1
node_modules/@expo/metro/metro-resolver/types.js generated vendored Normal file
View File

@@ -0,0 +1 @@
module.exports = require("metro-resolver/private/types");

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
*/
/**
* Determine if a file path should be considered an asset file based on the
* given `assetExts`.
*/
declare function isAssetFile(filePath: string, assetExts: ReadonlySet<string>): boolean;
export default isAssetFile;

View File

@@ -0,0 +1 @@
module.exports = require("metro-resolver/private/utils/isAssetFile");

View File

@@ -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
*/
/**
* Identifies whether the given subpath is defined in the given "exports"-like
* mapping. Does not reduce exports conditions (therefore does not identify
* whether the subpath is mapped to a value).
*/
import type { NormalizedExportsLikeMap } from "../types";
export declare function isSubpathDefinedInExportsLike(exportsLikeMap: NormalizedExportsLikeMap, subpath: string): boolean;

View File

@@ -0,0 +1,2 @@
module.exports = require("metro-resolver/private/utils/isSubpathDefinedInExportsLike");
module.exports.default = module.exports;

View File

@@ -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 { NormalizedExportsLikeMap, ResolutionContext } from "../types";
/**
* Get the mapped replacement for the given subpath.
*
* Implements modern package resolution behaviour based on the [Package Entry
* Points spec](https://nodejs.org/docs/latest-v19.x/api/packages.html#package-entry-points).
*/
export declare function matchSubpathFromExportsLike(context: ResolutionContext, subpath: string, exportsLikeMap: NormalizedExportsLikeMap, platform: string | null, createConfigError: (reason: string) => Error): {
readonly target?: string | null;
readonly patternMatch?: string | null;
};

View File

@@ -0,0 +1,2 @@
module.exports = require("metro-resolver/private/utils/matchSubpathFromExportsLike");
module.exports.default = module.exports;

View File

@@ -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
*/
/**
* If a subpath pattern expands to the passed subpath, return the subpath match
* (value to substitute for '*'). Otherwise, return `null`.
*
* See https://nodejs.org/docs/latest-v19.x/api/packages.html#subpath-patterns.
*/
export declare function matchSubpathPattern(subpathPattern: string, subpath: string): string | null;

View File

@@ -0,0 +1,2 @@
module.exports = require("metro-resolver/private/utils/matchSubpathPattern");
module.exports.default = module.exports;

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
*/
/**
* Reduce an "exports"-like mapping to a flat subpath mapping after resolving
* conditional exports.
*/
import type { FlattenedExportMap, NormalizedExportsLikeMap } from "../types";
export declare function reduceExportsLikeMap(exportsLikeMap: NormalizedExportsLikeMap, conditionNames: ReadonlySet<string>, createConfigError: (reason: string) => Error): FlattenedExportMap;

View File

@@ -0,0 +1,2 @@
module.exports = require("metro-resolver/private/utils/reduceExportsLikeMap");
module.exports.default = module.exports;

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
*/
/**
* Replace path separators in the passed string to coerce to a POSIX path. This
* is a no-op on POSIX systems.
*/
declare function toPosixPath(relativePathOrSpecifier: string): string;
export default toPosixPath;

View File

@@ -0,0 +1 @@
module.exports = require("metro-resolver/private/utils/toPosixPath");