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

33
node_modules/metro-babel-transformer/package.json generated vendored Normal file
View File

@@ -0,0 +1,33 @@
{
"name": "metro-babel-transformer",
"version": "0.83.3",
"description": "🚇 Base Babel transformer for Metro.",
"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"
},
"keywords": [
"transformer",
"metro"
],
"license": "MIT",
"dependencies": {
"@babel/core": "^7.25.2",
"flow-enums-runtime": "^0.0.6",
"hermes-parser": "0.32.0",
"nullthrows": "^1.1.1"
},
"engines": {
"node": ">=20.19.4"
}
}

59
node_modules/metro-babel-transformer/src/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,59 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
* @oncall react_native
*/
export interface CustomTransformOptions {
[key: string]: unknown;
}
export type TransformProfile = 'default' | 'hermes-stable' | 'hermes-canary';
export interface BabelTransformerOptions {
readonly customTransformOptions?: CustomTransformOptions;
readonly dev: boolean;
readonly enableBabelRCLookup?: boolean;
readonly enableBabelRuntime: boolean | string;
readonly extendsBabelConfigPath?: string;
readonly experimentalImportSupport?: boolean;
readonly hermesParser?: boolean;
readonly minify: boolean;
readonly platform: string | null;
readonly projectRoot: string;
readonly publicPath: string;
readonly unstable_transformProfile?: TransformProfile;
readonly globalPrefix: string;
}
export interface BabelTransformerArgs {
readonly filename: string;
readonly options: BabelTransformerOptions;
readonly plugins?: unknown;
readonly src: string;
}
export interface BabelTransformer {
transform: (args: BabelTransformerArgs) => {
ast: unknown;
metadata: unknown;
};
getCacheKey?: () => string;
}
export const transform: BabelTransformer['transform'];
/**
* Backwards-compatibility with CommonJS consumers using interopRequireDefault.
* Do not add to this list.
*
* @deprecated Default import from 'metro-babel-transformer' is deprecated, use named exports.
*/
declare const $$EXPORT_DEFAULT_DECLARATION$$: {transform: typeof transform};
declare type $$EXPORT_DEFAULT_DECLARATION$$ =
typeof $$EXPORT_DEFAULT_DECLARATION$$;
export default $$EXPORT_DEFAULT_DECLARATION$$;

58
node_modules/metro-babel-transformer/src/index.js generated vendored Normal file
View File

@@ -0,0 +1,58 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true,
});
exports.default = void 0;
exports.transform = transform;
var _core = require("@babel/core");
var _nullthrows = _interopRequireDefault(require("nullthrows"));
function _interopRequireDefault(e) {
return e && e.__esModule ? e : { default: e };
}
function transform({ filename, options, plugins, src }) {
const OLD_BABEL_ENV = process.env.BABEL_ENV;
process.env.BABEL_ENV = options.dev
? "development"
: process.env.BABEL_ENV || "production";
try {
const babelConfig = {
caller: {
name: "metro",
bundler: "metro",
platform: options.platform,
},
ast: true,
babelrc: options.enableBabelRCLookup,
code: false,
cwd: options.projectRoot,
highlightCode: true,
filename,
plugins,
sourceType: "module",
cloneInputAst: false,
};
const sourceAst = options.hermesParser
? require("hermes-parser").parse(src, {
babel: true,
sourceType: babelConfig.sourceType,
})
: (0, _core.parseSync)(src, babelConfig);
const transformResult = (0, _core.transformFromAstSync)(
sourceAst,
src,
babelConfig,
);
return {
ast: (0, _nullthrows.default)(transformResult.ast),
metadata: transformResult.metadata,
};
} finally {
if (OLD_BABEL_ENV) {
process.env.BABEL_ENV = OLD_BABEL_ENV;
}
}
}
var _default = (exports.default = {
transform,
});

148
node_modules/metro-babel-transformer/src/index.js.flow generated vendored Normal file
View File

@@ -0,0 +1,148 @@
/**
* 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 {BabelCoreOptions, BabelFileMetadata} from '@babel/core';
import {parseSync, transformFromAstSync} from '@babel/core';
import nullthrows from 'nullthrows';
export type CustomTransformOptions = {
[string]: mixed,
__proto__: null,
...
};
export type TransformProfile = 'default' | 'hermes-stable' | 'hermes-canary';
type BabelTransformerOptions = $ReadOnly<{
customTransformOptions?: CustomTransformOptions,
dev: boolean,
enableBabelRCLookup?: boolean,
enableBabelRuntime: boolean | string,
extendsBabelConfigPath?: string,
experimentalImportSupport?: boolean,
hermesParser?: boolean,
minify: boolean,
platform: ?string,
projectRoot: string,
publicPath: string,
unstable_transformProfile?: TransformProfile,
globalPrefix: string,
inlineRequires?: void,
...
}>;
export type BabelTransformerArgs = $ReadOnly<{
filename: string,
options: BabelTransformerOptions,
plugins?: BabelCoreOptions['plugins'],
src: string,
}>;
export type BabelFileFunctionMapMetadata = $ReadOnly<{
names: $ReadOnlyArray<string>,
mappings: string,
}>;
export type BabelFileImportLocsMetadata = $ReadOnlySet<string>;
export type MetroBabelFileMetadata = {
...BabelFileMetadata,
metro?: ?{
functionMap?: ?BabelFileFunctionMapMetadata,
unstable_importDeclarationLocs?: ?BabelFileImportLocsMetadata,
...
},
...
};
export type BabelTransformer = $ReadOnly<{
transform: BabelTransformerArgs => $ReadOnly<{
ast: BabelNodeFile,
// Deprecated, will be removed in a future breaking release. Function maps
// will be generated by an input Babel plugin instead and written into
// `metadata` - transformers don't need to return them explicitly.
functionMap?: BabelFileFunctionMapMetadata,
metadata?: MetroBabelFileMetadata,
...
}>,
getCacheKey?: () => string,
}>;
function transform({
filename,
options,
plugins,
src,
}: BabelTransformerArgs): ReturnType<BabelTransformer['transform']> {
const OLD_BABEL_ENV = process.env.BABEL_ENV;
process.env.BABEL_ENV = options.dev
? 'development'
: process.env.BABEL_ENV || 'production';
try {
const babelConfig: BabelCoreOptions = {
caller: {name: 'metro', bundler: 'metro', platform: options.platform},
ast: true,
babelrc: options.enableBabelRCLookup,
code: false,
cwd: options.projectRoot,
highlightCode: true,
filename,
plugins,
sourceType: 'module',
// NOTE(EvanBacon): We split the parse/transform steps up to accommodate
// Hermes parsing, but this defaults to cloning the AST which increases
// the transformation time by a fair amount.
// You get this behavior by default when using Babel's `transform` method directly.
cloneInputAst: false,
};
const sourceAst = options.hermesParser
? // eslint-disable-next-line import/no-commonjs
require('hermes-parser').parse(src, {
babel: true,
sourceType: babelConfig.sourceType,
})
: parseSync(src, babelConfig);
const transformResult = transformFromAstSync<MetroBabelFileMetadata>(
// $FlowFixMe[incompatible-type] BabelFile vs BabelNodeFile
sourceAst,
src,
babelConfig,
);
return {
ast: nullthrows(transformResult.ast),
metadata: transformResult.metadata,
};
} finally {
if (OLD_BABEL_ENV) {
process.env.BABEL_ENV = OLD_BABEL_ENV;
}
}
}
// Type check exports
/*::
({transform}) as BabelTransformer;
*/
export {transform};
/**
* Backwards-compatibility with CommonJS consumers using interopRequireDefault.
* Do not add to this list.
*
* @deprecated Default import from 'metro-babel-transformer' is deprecated, use named exports.
*/
export default {transform};