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

5
node_modules/metro-core/README.md generated vendored Normal file
View File

@@ -0,0 +1,5 @@
# Metro
🚇 This package contains core files for [Metro](https://metrobundler.dev/).
(TODO)

28
node_modules/metro-core/package.json generated vendored Normal file
View File

@@ -0,0 +1,28 @@
{
"name": "metro-core",
"version": "0.83.3",
"description": "🚇 Metro's core package.",
"main": "src/index.js",
"exports": {
".": "./src/index.js",
"./package.json": "./package.json",
"./private/*": "./src/*.js"
},
"repository": {
"type": "git",
"url": "git@github.com:facebook/metro.git"
},
"scripts": {
"prepare-release": "test -d build && rm -rf src.real && mv src src.real && mv build src",
"cleanup-release": "test ! -e build && mv src build && mv src.real src"
},
"dependencies": {
"flow-enums-runtime": "^0.0.6",
"lodash.throttle": "^4.1.1",
"metro-resolver": "0.83.3"
},
"license": "MIT",
"engines": {
"node": ">=20.19.4"
}
}

52
node_modules/metro-core/src/Logger.d.ts generated vendored Normal file
View File

@@ -0,0 +1,52 @@
/**
* 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 {BundleOptions} from 'metro/private/shared/types';
export type ActionLogEntryData = {
action_name: string;
log_entry_label?: string;
};
export type ActionStartLogEntry = {
action_name?: string;
action_phase?: string;
log_entry_label: string;
log_session?: string;
start_timestamp?: [number, number];
};
export 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;
export {on, createEntry, createActionStartEntry, createActionEndEntry, log};

75
node_modules/metro-core/src/Logger.js generated vendored Normal file
View File

@@ -0,0 +1,75 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true,
});
exports.createActionEndEntry = createActionEndEntry;
exports.createActionStartEntry = createActionStartEntry;
exports.createEntry = createEntry;
exports.log = log;
exports.on = on;
var _events = _interopRequireDefault(require("events"));
var _os = _interopRequireDefault(require("os"));
function _interopRequireDefault(e) {
return e && e.__esModule ? e : { default: e };
}
const VERSION = require("../package.json").version;
const log_session = `${_os.default.hostname()}-${Date.now()}`;
const eventEmitter = new _events.default();
function on(event, handler) {
eventEmitter.on(event, handler);
}
function createEntry(data) {
const logEntry =
typeof data === "string"
? {
log_entry_label: data,
}
: data;
return {
...logEntry,
log_session,
metro_bundler_version: VERSION,
};
}
function createActionStartEntry(data) {
const logEntry =
typeof data === "string"
? {
action_name: data,
}
: data;
const { action_name } = logEntry;
return createEntry({
log_entry_label: action_name,
...logEntry,
action_name,
action_phase: "start",
start_timestamp: process.hrtime(),
});
}
function createActionEndEntry(logEntry, error) {
const { action_name, action_phase, start_timestamp } = logEntry;
if (action_phase !== "start" || !Array.isArray(start_timestamp)) {
throw new Error("Action has not started or has already ended");
}
const timeDelta = process.hrtime(start_timestamp);
const duration_ms = Math.round((timeDelta[0] * 1e9 + timeDelta[1]) / 1e6);
return createEntry({
log_entry_label: action_name,
...logEntry,
action_name,
action_phase: "end",
duration_ms,
...(error != null
? {
error_message: error.message,
error_stack: error.stack,
}
: null),
});
}
function log(logEntry) {
eventEmitter.emit("log", logEntry);
return logEntry;
}

116
node_modules/metro-core/src/Logger.js.flow generated vendored Normal file
View File

@@ -0,0 +1,116 @@
/**
* 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 {BundleOptions} from 'metro/private/shared/types';
import EventEmitter from 'events';
import os from 'os';
// eslint-disable-next-line import/no-commonjs
const VERSION = require('../package.json').version;
export type ActionLogEntryData = {
action_name: string,
log_entry_label?: string,
...
};
export type ActionStartLogEntry = {
action_name?: string,
action_phase?: string,
log_entry_label: string,
log_session?: string,
start_timestamp?: [number, number],
...
};
export 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,
...
};
const log_session = `${os.hostname()}-${Date.now()}`;
const eventEmitter = new EventEmitter();
function on(event: string, handler: (logEntry: LogEntry) => void): void {
eventEmitter.on(event, handler);
}
function createEntry(data: LogEntry | string): LogEntry {
const logEntry: LogEntry =
typeof data === 'string' ? {log_entry_label: data} : data;
return {
...logEntry,
log_session,
metro_bundler_version: VERSION,
};
}
function createActionStartEntry(data: ActionLogEntryData | string): LogEntry {
const logEntry = typeof data === 'string' ? {action_name: data} : data;
const {action_name} = logEntry;
return createEntry({
log_entry_label: action_name,
...logEntry,
action_name,
action_phase: 'start',
start_timestamp: process.hrtime(),
});
}
function createActionEndEntry(
logEntry: ActionStartLogEntry,
error?: ?Error,
): LogEntry {
const {action_name, action_phase, start_timestamp} = logEntry;
if (action_phase !== 'start' || !Array.isArray(start_timestamp)) {
throw new Error('Action has not started or has already ended');
}
const timeDelta = process.hrtime(start_timestamp);
const duration_ms = Math.round((timeDelta[0] * 1e9 + timeDelta[1]) / 1e6);
return createEntry({
log_entry_label: (action_name: ?string),
...logEntry,
action_name,
action_phase: 'end',
duration_ms,
...(error != null
? {error_message: error.message, error_stack: error.stack}
: null),
});
}
function log(logEntry: LogEntry): LogEntry {
eventEmitter.emit('log', logEntry);
return logEntry;
}
export {on, createEntry, createActionStartEntry, createActionEndEntry, log};

72
node_modules/metro-core/src/Terminal.d.ts generated vendored Normal file
View File

@@ -0,0 +1,72 @@
/**
* 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 {Socket} from 'net';
import type {Writable} from 'stream';
type UnderlyingStream = Socket | Writable;
/**
* We don't just print things to the console, sometimes we also want to show
* and update progress. This utility just ensures the output stays neat: no
* missing newlines, no mangled log lines.
*
* const terminal = Terminal.default;
* terminal.status('Updating... 38%');
* terminal.log('warning: Something happened.');
* terminal.status('Updating, done.');
* terminal.persistStatus();
*
* The final output:
*
* warning: Something happened.
* Updating, done.
*
* Without the status feature, we may get a mangled output:
*
* Updating... 38%warning: Something happened.
* Updating, done.
*
* This is meant to be user-readable and TTY-oriented. We use stdout by default
* because it's more about status information than diagnostics/errors (stderr).
*
* Do not add any higher-level functionality in this class such as "warning" and
* "error" printers, as it is not meant for formatting/reporting. It has the
* single responsibility of handling status messages.
*/
declare class Terminal {
constructor(stream: UnderlyingStream, opts?: {ttyPrint?: boolean});
waitForUpdates(): Promise<void>;
/**
* Useful for calling console/stdout directly after terminal logs
* Otherwise, you could end up with mangled output when the queued
* update starts writing to stream after a delay.
*/
flush(): Promise<void>;
/**
* Shows some text that is meant to be overriden later. Return the previous
* status that was shown and is no more. Calling `status()` with no argument
* removes the status altogether. The status is never shown in a
* non-interactive terminal: for example, if the output is redirected to a
* file, then we don't care too much about having a progress bar.
*/
status(format: string, ...args: Array<unknown>): string;
/**
* Similar to `console.log`, except it moves the status/progress text out of
* the way correctly. In non-interactive terminals this is the same as
* `console.log`.
*/
log(format: string, ...args: Array<unknown>): void;
/**
* Log the current status and start from scratch. This is useful if the last
* status was the last one of a series of updates.
*/
persistStatus(): void;
}
export default Terminal;

135
node_modules/metro-core/src/Terminal.js generated vendored Normal file
View File

@@ -0,0 +1,135 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true,
});
exports.default = void 0;
var _lodash = _interopRequireDefault(require("lodash.throttle"));
var _readline = _interopRequireDefault(require("readline"));
var _tty = _interopRequireDefault(require("tty"));
var _util = _interopRequireDefault(require("util"));
function _interopRequireDefault(e) {
return e && e.__esModule ? e : { default: e };
}
const { promisify } = _util.default;
const moveCursor = promisify(_readline.default.moveCursor);
const clearScreenDown = promisify(_readline.default.clearScreenDown);
const streamWrite = promisify((stream, chunk, callback) => {
return stream.write(chunk, callback);
});
function chunkString(str, size) {
const ANSI_COLOR = "\x1B\\[([0-9]{1,2}(;[0-9]{1,2})?)?m";
const SKIP_ANSI = `(?:${ANSI_COLOR})*`;
return str.match(new RegExp(`(?:${SKIP_ANSI}.){1,${size}}`, "g")) || [];
}
function getTTYStream(stream) {
if (
stream instanceof _tty.default.WriteStream &&
stream.isTTY &&
stream.columns >= 1
) {
return stream;
}
return null;
}
class Terminal {
#logLines;
#nextStatusStr;
#statusStr;
#stream;
#ttyStream;
#updatePromise;
#isUpdating;
#isPendingUpdate;
#shouldFlush;
#writeStatusThrottled;
constructor(stream, opts = {}) {
this.#logLines = [];
this.#nextStatusStr = "";
this.#statusStr = "";
this.#stream = stream;
this.#ttyStream = (opts.ttyPrint ?? true) ? getTTYStream(stream) : null;
this.#updatePromise = null;
this.#isUpdating = false;
this.#isPendingUpdate = false;
this.#shouldFlush = false;
this.#writeStatusThrottled = (0, _lodash.default)(
(status) => this.#stream.write(status),
3500,
);
}
#scheduleUpdate() {
if (this.#isUpdating) {
this.#isPendingUpdate = true;
return;
}
this.#isUpdating = true;
this.#updatePromise = this.#update().then(async () => {
while (this.#isPendingUpdate) {
if (!this.#shouldFlush) {
await new Promise((resolve) => setTimeout(resolve, 33));
}
this.#isPendingUpdate = false;
await this.#update();
}
this.#isUpdating = false;
this.#shouldFlush = false;
});
}
async waitForUpdates() {
await (this.#updatePromise || Promise.resolve());
}
async flush() {
if (this.#isUpdating) {
this.#shouldFlush = true;
}
await this.waitForUpdates();
this.#writeStatusThrottled.flush();
}
async #update() {
const ttyStream = this.#ttyStream;
const nextStatusStr = this.#nextStatusStr;
const statusStr = this.#statusStr;
const logLines = this.#logLines;
this.#statusStr = nextStatusStr;
this.#logLines = [];
if (statusStr === nextStatusStr && logLines.length === 0) {
return;
}
if (ttyStream && statusStr.length > 0) {
const statusLinesCount = statusStr.split("\n").length - 1;
await moveCursor(ttyStream, -ttyStream.columns, -statusLinesCount - 1);
await clearScreenDown(ttyStream);
}
if (logLines.length > 0) {
await streamWrite(this.#stream, logLines.join("\n") + "\n");
}
if (ttyStream) {
if (nextStatusStr.length > 0) {
await streamWrite(this.#stream, nextStatusStr + "\n");
}
} else {
this.#writeStatusThrottled(
nextStatusStr.length > 0 ? nextStatusStr + "\n" : "",
);
}
}
status(format, ...args) {
const nextStatusStr = this.#nextStatusStr;
const statusStr = _util.default.format(format, ...args);
this.#nextStatusStr = this.#ttyStream
? chunkString(statusStr, this.#ttyStream.columns).join("\n")
: statusStr;
this.#scheduleUpdate();
return nextStatusStr;
}
log(format, ...args) {
this.#logLines.push(_util.default.format(format, ...args));
this.#scheduleUpdate();
}
persistStatus() {
this.log(this.#nextStatusStr);
this.#nextStatusStr = "";
}
}
exports.default = Terminal;

247
node_modules/metro-core/src/Terminal.js.flow generated vendored Normal file
View File

@@ -0,0 +1,247 @@
/**
* 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 {Socket} from 'net';
import type {Writable} from 'stream';
import throttle from 'lodash.throttle';
import readline from 'readline';
import tty from 'tty';
import util from 'util';
const {promisify} = util;
type UnderlyingStream = Socket | Writable;
// use "readline/promises" instead when not experimental anymore
const moveCursor = promisify(readline.moveCursor);
const clearScreenDown = promisify(readline.clearScreenDown);
const streamWrite = promisify(
(
stream: UnderlyingStream,
chunk: Buffer | Uint8Array | string,
callback?: (data: any) => void,
) => {
return stream.write(chunk, callback);
},
);
/**
* Cut a string into an array of string of the specific maximum size. A newline
* ends a chunk immediately (it's not included in the "." RexExp operator), and
* is not included in the result.
* When counting we should ignore non-printable characters. In particular the
* ANSI escape sequences (regex: /\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?m/)
* (Not an exhaustive match, intended to match ANSI color escapes)
* https://en.wikipedia.org/wiki/ANSI_escape_code
*/
function chunkString(str: string, size: number): Array<string> {
const ANSI_COLOR = '\x1B\\[([0-9]{1,2}(;[0-9]{1,2})?)?m';
const SKIP_ANSI = `(?:${ANSI_COLOR})*`;
return str.match(new RegExp(`(?:${SKIP_ANSI}.){1,${size}}`, 'g')) || [];
}
/**
* Get the stream as a TTY if it effectively looks like a valid TTY.
*/
function getTTYStream(stream: UnderlyingStream): ?tty.WriteStream {
if (
stream instanceof tty.WriteStream &&
stream.isTTY &&
stream.columns >= 1
) {
return stream;
}
return null;
}
/**
* We don't just print things to the console, sometimes we also want to show
* and update progress. This utility just ensures the output stays neat: no
* missing newlines, no mangled log lines.
*
* const terminal = Terminal.default;
* terminal.status('Updating... 38%');
* terminal.log('warning: Something happened.');
* terminal.status('Updating, done.');
* terminal.persistStatus();
*
* The final output:
*
* warning: Something happened.
* Updating, done.
*
* Without the status feature, we may get a mangled output:
*
* Updating... 38%warning: Something happened.
* Updating, done.
*
* This is meant to be user-readable and TTY-oriented. We use stdout by default
* because it's more about status information than diagnostics/errors (stderr).
*
* Do not add any higher-level functionality in this class such as "warning" and
* "error" printers, as it is not meant for formatting/reporting. It has the
* single responsibility of handling status messages.
*/
export default class Terminal {
#logLines: Array<string>;
#nextStatusStr: string;
#statusStr: string;
#stream: UnderlyingStream;
#ttyStream: ?tty.WriteStream;
#updatePromise: Promise<void> | null;
#isUpdating: boolean;
#isPendingUpdate: boolean;
#shouldFlush: boolean;
#writeStatusThrottled: string => void;
constructor(stream: UnderlyingStream, opts: {ttyPrint?: boolean} = {}) {
this.#logLines = [];
this.#nextStatusStr = '';
this.#statusStr = '';
this.#stream = stream;
this.#ttyStream = (opts.ttyPrint ?? true) ? getTTYStream(stream) : null;
this.#updatePromise = null;
this.#isUpdating = false;
this.#isPendingUpdate = false;
this.#shouldFlush = false;
this.#writeStatusThrottled = throttle(
status => this.#stream.write(status),
3500,
);
}
/**
* Schedule an update of the status and log lines.
* If there's an ongoing update, schedule another one after the current one.
* If there are two updates scheduled, do nothing, as the second update will
* take care of the latest status and log lines.
*/
#scheduleUpdate() {
if (this.#isUpdating) {
this.#isPendingUpdate = true;
return;
}
this.#isUpdating = true;
this.#updatePromise = this.#update().then(async () => {
while (this.#isPendingUpdate) {
if (!this.#shouldFlush) {
await new Promise(resolve => setTimeout(resolve, 33));
}
this.#isPendingUpdate = false;
await this.#update();
}
this.#isUpdating = false;
this.#shouldFlush = false;
});
}
async waitForUpdates(): Promise<void> {
await (this.#updatePromise || Promise.resolve());
}
/**
* Useful for calling console/stdout directly after terminal logs
* Otherwise, you could end up with mangled output when the queued
* update starts writing to stream after a delay.
*/
async flush(): Promise<void> {
if (this.#isUpdating) {
this.#shouldFlush = true;
}
await this.waitForUpdates();
// $FlowFixMe[prop-missing]
this.#writeStatusThrottled.flush();
}
/**
* Clear and write the new status, logging in bulk in-between. Doing this in a
* throttled way (in a different tick than the calls to `log()` and
* `status()`) prevents us from repeatedly rewriting the status in case
* `terminal.log()` is called several times.
*/
async #update(): Promise<void> {
const ttyStream = this.#ttyStream;
const nextStatusStr = this.#nextStatusStr;
const statusStr = this.#statusStr;
const logLines = this.#logLines;
// reset these here to not have them changed while updating
this.#statusStr = nextStatusStr;
this.#logLines = [];
if (statusStr === nextStatusStr && logLines.length === 0) {
return;
}
if (ttyStream && statusStr.length > 0) {
const statusLinesCount = statusStr.split('\n').length - 1;
// extra -1 because we print the status with a trailing new line
await moveCursor(ttyStream, -ttyStream.columns, -statusLinesCount - 1);
await clearScreenDown(ttyStream);
}
if (logLines.length > 0) {
await streamWrite(this.#stream, logLines.join('\n') + '\n');
}
if (ttyStream) {
if (nextStatusStr.length > 0) {
await streamWrite(this.#stream, nextStatusStr + '\n');
}
} else {
this.#writeStatusThrottled(
nextStatusStr.length > 0 ? nextStatusStr + '\n' : '',
);
}
}
/**
* Shows some text that is meant to be overriden later. Return the previous
* status that was shown and is no more. Calling `status()` with no argument
* removes the status altogether. The status is never shown in a
* non-interactive terminal: for example, if the output is redirected to a
* file, then we don't care too much about having a progress bar.
*/
status(format: string, ...args: Array<mixed>): string {
const nextStatusStr = this.#nextStatusStr;
const statusStr = util.format(format, ...args);
this.#nextStatusStr = this.#ttyStream
? chunkString(statusStr, this.#ttyStream.columns).join('\n')
: statusStr;
this.#scheduleUpdate();
return nextStatusStr;
}
/**
* Similar to `console.log`, except it moves the status/progress text out of
* the way correctly. In non-interactive terminals this is the same as
* `console.log`.
*/
log(format: string, ...args: Array<mixed>): void {
this.#logLines.push(util.format(format, ...args));
this.#scheduleUpdate();
}
/**
* Log the current status and start from scratch. This is useful if the last
* status was the last one of a series of updates.
*/
persistStatus(): void {
this.log(this.#nextStatusStr);
this.#nextStatusStr = '';
}
}

12
node_modules/metro-core/src/canonicalize.d.ts generated vendored Normal file
View File

@@ -0,0 +1,12 @@
/**
* 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 canonicalize(key: string, value: unknown): unknown;
export default canonicalize;

18
node_modules/metro-core/src/canonicalize.js generated vendored Normal file
View File

@@ -0,0 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true,
});
exports.default = canonicalize;
function canonicalize(key, value) {
if (value === null || typeof value !== "object" || Array.isArray(value)) {
return value;
}
const keys = Object.keys(value).sort();
const length = keys.length;
const object = {};
for (let i = 0; i < length; i++) {
object[keys[i]] = value[keys[i]];
}
return object;
}

31
node_modules/metro-core/src/canonicalize.js.flow generated vendored Normal file
View File

@@ -0,0 +1,31 @@
/**
* 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 default function canonicalize(key: string, value: mixed): mixed {
if (
// eslint-disable-next-line lint/strictly-null
value === null ||
typeof value !== 'object' ||
Array.isArray(value)
) {
return value;
}
const keys = Object.keys(value).sort();
const length = keys.length;
const object: {[string]: mixed} = {};
for (let i = 0; i < length; i++) {
object[keys[i]] = value[keys[i]];
}
return object;
}

14
node_modules/metro-core/src/errors.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 AmbiguousModuleResolutionError from './errors/AmbiguousModuleResolutionError';
import PackageResolutionError from './errors/PackageResolutionError';
export {AmbiguousModuleResolutionError, PackageResolutionError};

26
node_modules/metro-core/src/errors.js generated vendored Normal file
View File

@@ -0,0 +1,26 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true,
});
Object.defineProperty(exports, "AmbiguousModuleResolutionError", {
enumerable: true,
get: function () {
return _AmbiguousModuleResolutionError.default;
},
});
Object.defineProperty(exports, "PackageResolutionError", {
enumerable: true,
get: function () {
return _PackageResolutionError.default;
},
});
var _AmbiguousModuleResolutionError = _interopRequireDefault(
require("./errors/AmbiguousModuleResolutionError"),
);
var _PackageResolutionError = _interopRequireDefault(
require("./errors/PackageResolutionError"),
);
function _interopRequireDefault(e) {
return e && e.__esModule ? e : { default: e };
}

15
node_modules/metro-core/src/errors.js.flow generated vendored Normal file
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.
*
* @flow strict-local
* @format
* @oncall react_native
*/
import AmbiguousModuleResolutionError from './errors/AmbiguousModuleResolutionError';
import PackageResolutionError from './errors/PackageResolutionError';
export {AmbiguousModuleResolutionError, PackageResolutionError};

View File

@@ -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
* @oncall react_native
*/
import type {DuplicateHasteCandidatesError} from 'metro-file-map';
declare class AmbiguousModuleResolutionError extends Error {
fromModulePath: string;
hasteError: DuplicateHasteCandidatesError;
constructor(
fromModulePath: string,
hasteError: DuplicateHasteCandidatesError,
);
}
export default AmbiguousModuleResolutionError;

View File

@@ -0,0 +1,17 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true,
});
exports.default = void 0;
class AmbiguousModuleResolutionError extends Error {
constructor(fromModulePath, hasteError) {
super(
`Ambiguous module resolution from \`${fromModulePath}\`: ` +
hasteError.message,
);
this.fromModulePath = fromModulePath;
this.hasteError = hasteError;
}
}
exports.default = AmbiguousModuleResolutionError;

View File

@@ -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.
*
* @flow strict-local
* @format
* @oncall react_native
*/
import type {DuplicateHasteCandidatesError} from 'metro-file-map';
export default class AmbiguousModuleResolutionError extends Error {
fromModulePath: string;
hasteError: DuplicateHasteCandidatesError;
constructor(
fromModulePath: string,
hasteError: DuplicateHasteCandidatesError,
) {
super(
`Ambiguous module resolution from \`${fromModulePath}\`: ` +
hasteError.message,
);
this.fromModulePath = fromModulePath;
this.hasteError = hasteError;
}
}

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 {InvalidPackageError} from 'metro-resolver';
declare class PackageResolutionError extends Error {
originModulePath: string;
packageError: InvalidPackageError;
targetModuleName: string;
constructor(opts: {
readonly originModulePath: string;
readonly packageError: InvalidPackageError;
readonly targetModuleName: string;
});
}
export default PackageResolutionError;

View File

@@ -0,0 +1,24 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true,
});
exports.default = void 0;
var _metroResolver = require("metro-resolver");
class PackageResolutionError extends Error {
constructor(opts) {
const perr = opts.packageError;
super(
`While trying to resolve module \`${opts.targetModuleName}\` from file ` +
`\`${opts.originModulePath}\`, the package ` +
`\`${perr.packageJsonPath}\` was successfully found. However, ` +
"this package itself specifies " +
"a `main` module field that could not be resolved (" +
`\`${perr.mainModulePath}\`. Indeed, none of these files exist:\n\n` +
` * ${(0, _metroResolver.formatFileCandidates)(perr.fileCandidates)}\n` +
` * ${(0, _metroResolver.formatFileCandidates)(perr.indexCandidates)}`,
);
Object.assign(this, opts);
}
}
exports.default = PackageResolutionError;

View File

@@ -0,0 +1,40 @@
/**
* 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 {InvalidPackageError} from 'metro-resolver';
import {formatFileCandidates} from 'metro-resolver';
export default class PackageResolutionError extends Error {
originModulePath: string;
packageError: InvalidPackageError;
targetModuleName: string;
constructor(opts: {
+originModulePath: string,
+packageError: InvalidPackageError,
+targetModuleName: string,
}) {
const perr = opts.packageError;
super(
`While trying to resolve module \`${opts.targetModuleName}\` from file ` +
`\`${opts.originModulePath}\`, the package ` +
`\`${perr.packageJsonPath}\` was successfully found. However, ` +
'this package itself specifies ' +
'a `main` module field that could not be resolved (' +
`\`${perr.mainModulePath}\`. Indeed, none of these files exist:\n\n` +
` * ${formatFileCandidates(perr.fileCandidates)}\n` +
` * ${formatFileCandidates(perr.indexCandidates)}`,
);
// $FlowFixMe[unsafe-object-assign]
Object.assign(this, opts);
}
}

36
node_modules/metro-core/src/index.d.ts generated vendored Normal file
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 AmbiguousModuleResolutionError from './errors/AmbiguousModuleResolutionError';
import PackageResolutionError from './errors/PackageResolutionError';
import * as Logger from './Logger';
import Terminal from './Terminal';
export {
AmbiguousModuleResolutionError,
Logger,
PackageResolutionError,
Terminal,
};
/**
* Backwards-compatibility with CommonJS consumers using interopRequireDefault.
* Do not add to this list.
*
* @deprecated Default import from 'metro-core' is deprecated, use named exports.
*/
declare const $$EXPORT_DEFAULT_DECLARATION$$: {
AmbiguousModuleResolutionError: typeof AmbiguousModuleResolutionError;
Logger: typeof Logger;
PackageResolutionError: typeof PackageResolutionError;
Terminal: typeof Terminal;
};
declare type $$EXPORT_DEFAULT_DECLARATION$$ =
typeof $$EXPORT_DEFAULT_DECLARATION$$;
export default $$EXPORT_DEFAULT_DECLARATION$$;

66
node_modules/metro-core/src/index.js generated vendored Normal file
View File

@@ -0,0 +1,66 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true,
});
Object.defineProperty(exports, "AmbiguousModuleResolutionError", {
enumerable: true,
get: function () {
return _AmbiguousModuleResolutionError.default;
},
});
exports.Logger = void 0;
Object.defineProperty(exports, "PackageResolutionError", {
enumerable: true,
get: function () {
return _PackageResolutionError.default;
},
});
Object.defineProperty(exports, "Terminal", {
enumerable: true,
get: function () {
return _Terminal.default;
},
});
exports.default = void 0;
var _AmbiguousModuleResolutionError = _interopRequireDefault(
require("./errors/AmbiguousModuleResolutionError"),
);
var _PackageResolutionError = _interopRequireDefault(
require("./errors/PackageResolutionError"),
);
var Logger = _interopRequireWildcard(require("./Logger"));
exports.Logger = Logger;
var _Terminal = _interopRequireDefault(require("./Terminal"));
function _getRequireWildcardCache(e) {
if ("function" != typeof WeakMap) return null;
var r = new WeakMap(),
t = new WeakMap();
return (_getRequireWildcardCache = function (e) {
return e ? t : r;
})(e);
}
function _interopRequireWildcard(e, r) {
if (!r && e && e.__esModule) return e;
if (null === e || ("object" != typeof e && "function" != typeof e))
return { default: e };
var t = _getRequireWildcardCache(r);
if (t && t.has(e)) return t.get(e);
var n = { __proto__: null },
a = Object.defineProperty && Object.getOwnPropertyDescriptor;
for (var u in e)
if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;
i && (i.get || i.set) ? Object.defineProperty(n, u, i) : (n[u] = e[u]);
}
return ((n.default = e), t && t.set(e, n), n);
}
function _interopRequireDefault(e) {
return e && e.__esModule ? e : { default: e };
}
var _default = (exports.default = {
AmbiguousModuleResolutionError: _AmbiguousModuleResolutionError.default,
Logger,
PackageResolutionError: _PackageResolutionError.default,
Terminal: _Terminal.default,
});

35
node_modules/metro-core/src/index.js.flow generated vendored Normal file
View File

@@ -0,0 +1,35 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
* @oncall react_native
*/
import AmbiguousModuleResolutionError from './errors/AmbiguousModuleResolutionError';
import PackageResolutionError from './errors/PackageResolutionError';
import * as Logger from './Logger';
import Terminal from './Terminal';
export {
AmbiguousModuleResolutionError,
Logger,
PackageResolutionError,
Terminal,
};
/**
* Backwards-compatibility with CommonJS consumers using interopRequireDefault.
* Do not add to this list.
*
* @deprecated Default import from 'metro-core' is deprecated, use named exports.
*/
export default {
AmbiguousModuleResolutionError,
Logger,
PackageResolutionError,
Terminal,
};