metro 0.83.4 → 0.83.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +17 -15
- package/src/Assets.d.ts +83 -0
- package/src/Assets.js +2 -9
- package/src/Bundler/util.d.ts +27 -0
- package/src/Bundler/util.js +2 -9
- package/src/Bundler.d.ts +38 -0
- package/src/Bundler.js +1 -5
- package/src/DeltaBundler/DeltaCalculator.d.ts +71 -0
- package/src/DeltaBundler/DeltaCalculator.js +1 -5
- package/src/DeltaBundler/Graph.d.ts +167 -0
- package/src/DeltaBundler/Graph.js +1 -5
- package/src/DeltaBundler/Serializers/baseJSBundle.d.ts +20 -0
- package/src/DeltaBundler/Serializers/baseJSBundle.js +1 -5
- package/src/DeltaBundler/Serializers/getAllFiles.d.ts +22 -0
- package/src/DeltaBundler/Serializers/getAssets.d.ts +25 -0
- package/src/DeltaBundler/Serializers/getAssets.js +1 -5
- package/src/DeltaBundler/Serializers/getExplodedSourceMap.d.ts +26 -0
- package/src/DeltaBundler/Serializers/getRamBundleInfo.d.ts +48 -0
- package/src/DeltaBundler/Serializers/getRamBundleInfo.js +1 -5
- package/src/DeltaBundler/Serializers/helpers/getInlineSourceMappingURL.d.ts +12 -0
- package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.d.ts +33 -0
- package/src/DeltaBundler/Serializers/helpers/getTransitiveDependencies.d.ts +17 -0
- package/src/DeltaBundler/Serializers/helpers/js.d.ts +30 -0
- package/src/DeltaBundler/Serializers/helpers/js.js +2 -9
- package/src/DeltaBundler/Serializers/helpers/processModules.d.ts +25 -0
- package/src/DeltaBundler/Serializers/hmrJSBundle.d.ts +30 -0
- package/src/DeltaBundler/Serializers/hmrJSBundle.js +2 -9
- package/src/DeltaBundler/Serializers/sourceMapGenerator.d.ts +29 -0
- package/src/DeltaBundler/Serializers/sourceMapGenerator.js +1 -5
- package/src/DeltaBundler/Serializers/sourceMapObject.d.ts +23 -0
- package/src/DeltaBundler/Serializers/sourceMapString.d.ts +22 -0
- package/src/DeltaBundler/Transformer.d.ts +38 -0
- package/src/DeltaBundler/Transformer.js +1 -5
- package/src/DeltaBundler/Worker.d.ts +37 -0
- package/src/DeltaBundler/Worker.flow.js +1 -5
- package/src/DeltaBundler/WorkerFarm.d.ts +70 -0
- package/src/DeltaBundler/buildSubgraph.d.ts +30 -0
- package/src/DeltaBundler/buildSubgraph.js +1 -5
- package/src/DeltaBundler/getTransformCacheKey.d.ts +18 -0
- package/src/DeltaBundler/getTransformCacheKey.js +1 -5
- package/src/DeltaBundler/mergeDeltas.d.ts +17 -0
- package/src/DeltaBundler/types.d.ts +163 -0
- package/src/DeltaBundler/types.js +1 -5
- package/src/DeltaBundler.d.ts +60 -0
- package/src/DeltaBundler.js +1 -5
- package/src/HmrServer.d.ts +79 -0
- package/src/HmrServer.js +2 -9
- package/src/IncrementalBundler/GraphNotFoundError.d.ts +17 -0
- package/src/IncrementalBundler/ResourceNotFoundError.d.ts +15 -0
- package/src/IncrementalBundler/RevisionNotFoundError.d.ts +17 -0
- package/src/IncrementalBundler.d.ts +96 -0
- package/src/IncrementalBundler.js +2 -9
- package/src/ModuleGraph/worker/JsFileWrapping.d.ts +29 -0
- package/src/ModuleGraph/worker/JsFileWrapping.js +2 -9
- package/src/ModuleGraph/worker/collectDependencies.d.ts +131 -0
- package/src/ModuleGraph/worker/collectDependencies.js +2 -9
- package/src/ModuleGraph/worker/generateImportNames.d.ts +19 -0
- package/src/ModuleGraph/worker/generateImportNames.js +1 -5
- package/src/ModuleGraph/worker/importLocationsPlugin.d.ts +26 -0
- package/src/Server/MultipartResponse.d.ts +30 -0
- package/src/Server/MultipartResponse.js +1 -5
- package/src/Server/symbolicate.d.ts +31 -0
- package/src/Server.d.ts +271 -0
- package/src/Server.js +47 -15
- package/src/Server.js.flow +57 -10
- package/src/cli/parseKeyValueParamArray.d.ts +14 -0
- package/src/cli-utils.d.ts +19 -0
- package/src/cli-utils.js +1 -5
- package/src/commands/build.d.ts +16 -0
- package/src/commands/build.js +1 -5
- package/src/commands/dependencies.d.ts +16 -0
- package/src/commands/dependencies.js +1 -5
- package/src/commands/serve.d.ts +16 -0
- package/src/index.d.ts +180 -0
- package/src/index.flow.js +26 -19
- package/src/index.flow.js.flow +25 -10
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-import.js +1 -5
- package/src/integration_tests/basic_bundle/build-errors/inline-requires-cannot-resolve-import.js +1 -5
- package/src/integration_tests/basic_bundle/import-export/index.js +2 -9
- package/src/integration_tests/execBundle.js +1 -5
- package/src/lib/BatchProcessor.d.ts +54 -0
- package/src/lib/BatchProcessor.js +1 -5
- package/src/lib/CountingSet.d.ts +48 -0
- package/src/lib/JsonReporter.d.ts +37 -0
- package/src/lib/RamBundleParser.d.ts +29 -0
- package/src/lib/RamBundleParser.js +1 -5
- package/src/lib/TerminalReporter.d.ts +118 -0
- package/src/lib/TerminalReporter.js +8 -16
- package/src/lib/TerminalReporter.js.flow +6 -15
- package/src/lib/bundleProgressUtils.d.ts +26 -0
- package/src/lib/bundleProgressUtils.js +19 -0
- package/src/lib/bundleProgressUtils.js.flow +35 -0
- package/src/lib/bundleToString.d.ts +19 -0
- package/src/lib/contextModule.d.ts +33 -0
- package/src/lib/contextModule.js +1 -5
- package/src/lib/contextModuleTemplates.d.ts +25 -0
- package/src/lib/contextModuleTemplates.js +1 -4
- package/src/lib/countLines.d.ts +12 -0
- package/src/lib/createWebsocketServer.d.ts +43 -0
- package/src/lib/createWebsocketServer.js +1 -5
- package/src/lib/debounceAsyncQueue.d.ts +15 -0
- package/src/lib/formatBundlingError.d.ts +23 -0
- package/src/lib/formatBundlingError.js +1 -5
- package/src/lib/getAppendScripts.d.ts +31 -0
- package/src/lib/getAppendScripts.js +1 -5
- package/src/lib/getGraphId.d.ts +25 -0
- package/src/lib/getGraphId.js +1 -5
- package/src/lib/getPreludeCode.d.ts +18 -0
- package/src/lib/getPrependedScripts.d.ts +24 -0
- package/src/lib/getPrependedScripts.js +2 -9
- package/src/lib/isResolvedDependency.d.ts +15 -0
- package/src/lib/logToConsole.d.ts +19 -0
- package/src/lib/logToConsole.js +1 -5
- package/src/lib/parseBundleOptionsFromBundleRequestUrl.d.ts +17 -0
- package/src/lib/parseBundleOptionsFromBundleRequestUrl.js +2 -9
- package/src/lib/parseCustomResolverOptions.d.ts +16 -0
- package/src/lib/parseCustomTransformOptions.d.ts +16 -0
- package/src/lib/parseJsonBody.d.ts +27 -0
- package/src/lib/pathUtils.d.ts +14 -0
- package/src/lib/pathUtils.js +1 -4
- package/src/lib/relativizeSourceMap.d.ts +17 -0
- package/src/lib/relativizeSourceMap.js +1 -5
- package/src/lib/reporting.d.ts +128 -0
- package/src/lib/reporting.js +1 -5
- package/src/lib/splitBundleOptions.d.ts +16 -0
- package/src/lib/transformHelpers.d.ts +35 -0
- package/src/lib/transformHelpers.js +1 -5
- package/src/node-haste/DependencyGraph/ModuleResolution.d.ts +126 -0
- package/src/node-haste/DependencyGraph/ModuleResolution.js +2 -9
- package/src/node-haste/DependencyGraph/createFileMap.d.ts +29 -0
- package/src/node-haste/DependencyGraph/createFileMap.js +2 -9
- package/src/node-haste/DependencyGraph.d.ts +86 -0
- package/src/node-haste/DependencyGraph.js +1 -5
- package/src/node-haste/Package.d.ts +21 -0
- package/src/node-haste/Package.js +1 -5
- package/src/node-haste/PackageCache.d.ts +34 -0
- package/src/node-haste/PackageCache.js +1 -5
- package/src/node-haste/lib/AssetPaths.d.ts +29 -0
- package/src/node-haste/lib/AssetPaths.js +1 -5
- package/src/node-haste/lib/parsePlatformFilePath.d.ts +25 -0
- package/src/node-haste/lib/parsePlatformFilePath.js +1 -5
- package/src/shared/output/RamBundle/as-assets.d.ts +25 -0
- package/src/shared/output/RamBundle/as-assets.js +1 -5
- package/src/shared/output/RamBundle/as-indexed-file.d.ts +38 -0
- package/src/shared/output/RamBundle/as-indexed-file.js +1 -5
- package/src/shared/output/RamBundle/buildSourcemapWithMetadata.d.ts +23 -0
- package/src/shared/output/RamBundle/magic-number.d.ts +14 -0
- package/src/shared/output/RamBundle/util.d.ts +41 -0
- package/src/shared/output/RamBundle/util.js +1 -5
- package/src/shared/output/RamBundle/write-sourcemap.d.ts +16 -0
- package/src/shared/output/RamBundle/write-sourcemap.js +1 -5
- package/src/shared/output/RamBundle.d.ts +26 -0
- package/src/shared/output/RamBundle.js +1 -5
- package/src/shared/output/bundle.d.ts +27 -0
- package/src/shared/output/bundle.flow.js +1 -5
- package/src/shared/output/meta.d.ts +15 -0
- package/src/shared/output/meta.js +1 -5
- package/src/shared/output/unbundle.d.ts +11 -0
- package/src/shared/output/writeFile.d.ts +16 -0
- package/src/shared/output/writeFile.js +1 -5
- package/src/shared/types.d.ts +145 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type {ModuleTransportLike} from '../../shared/types';
|
|
12
|
+
import type {Module, ReadOnlyGraph, SerializerOptions} from '../types';
|
|
13
|
+
import type {SourceMapGeneratorOptions} from './sourceMapGenerator';
|
|
14
|
+
import type {GetTransformOptions} from 'metro-config';
|
|
15
|
+
|
|
16
|
+
type Options = Readonly<
|
|
17
|
+
Omit<
|
|
18
|
+
SerializerOptions,
|
|
19
|
+
| keyof SourceMapGeneratorOptions
|
|
20
|
+
| keyof {
|
|
21
|
+
getTransformOptions: null | undefined | GetTransformOptions;
|
|
22
|
+
platform: null | undefined | string;
|
|
23
|
+
}
|
|
24
|
+
> &
|
|
25
|
+
Omit<
|
|
26
|
+
SourceMapGeneratorOptions,
|
|
27
|
+
keyof {
|
|
28
|
+
getTransformOptions: null | undefined | GetTransformOptions;
|
|
29
|
+
platform: null | undefined | string;
|
|
30
|
+
}
|
|
31
|
+
> & {
|
|
32
|
+
getTransformOptions: null | undefined | GetTransformOptions;
|
|
33
|
+
platform: null | undefined | string;
|
|
34
|
+
}
|
|
35
|
+
>;
|
|
36
|
+
export type RamBundleInfo = {
|
|
37
|
+
getDependencies: ($$PARAM_0$$: string) => Set<string>;
|
|
38
|
+
startupModules: ReadonlyArray<ModuleTransportLike>;
|
|
39
|
+
lazyModules: ReadonlyArray<ModuleTransportLike>;
|
|
40
|
+
groups: Map<number, Set<number>>;
|
|
41
|
+
};
|
|
42
|
+
declare function getRamBundleInfo(
|
|
43
|
+
entryPoint: string,
|
|
44
|
+
pre: ReadonlyArray<Module>,
|
|
45
|
+
graph: ReadOnlyGraph,
|
|
46
|
+
options: Options,
|
|
47
|
+
): Promise<RamBundleInfo>;
|
|
48
|
+
export default getRamBundleInfo;
|
|
@@ -16,11 +16,7 @@ var _sourceMapObject = require("./sourceMapObject");
|
|
|
16
16
|
var _nullthrows = _interopRequireDefault(require("nullthrows"));
|
|
17
17
|
var _path = _interopRequireDefault(require("path"));
|
|
18
18
|
function _interopRequireDefault(e) {
|
|
19
|
-
return e && e.__esModule
|
|
20
|
-
? e
|
|
21
|
-
: {
|
|
22
|
-
default: e,
|
|
23
|
-
};
|
|
19
|
+
return e && e.__esModule ? e : { default: e };
|
|
24
20
|
}
|
|
25
21
|
async function getRamBundleInfo(entryPoint, pre, graph, options) {
|
|
26
22
|
let modules = [...pre, ...graph.dependencies.values()];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
declare function getInlineSourceMappingURL(sourceMap: string): string;
|
|
12
|
+
export default getInlineSourceMappingURL;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type {Module} from '../../types';
|
|
12
|
+
import type {
|
|
13
|
+
FBSourceFunctionMap,
|
|
14
|
+
MetroSourceMapSegmentTuple,
|
|
15
|
+
} from 'metro-source-map';
|
|
16
|
+
|
|
17
|
+
declare function getSourceMapInfo(
|
|
18
|
+
module: Module,
|
|
19
|
+
options: {
|
|
20
|
+
readonly excludeSource: boolean;
|
|
21
|
+
readonly shouldAddToIgnoreList: ($$PARAM_0$$: Module) => boolean;
|
|
22
|
+
getSourceUrl: null | undefined | ((module: Module) => string);
|
|
23
|
+
},
|
|
24
|
+
): {
|
|
25
|
+
readonly map: Array<MetroSourceMapSegmentTuple>;
|
|
26
|
+
readonly functionMap: null | undefined | FBSourceFunctionMap;
|
|
27
|
+
readonly code: string;
|
|
28
|
+
readonly path: string;
|
|
29
|
+
readonly source: string;
|
|
30
|
+
readonly lineCount: number;
|
|
31
|
+
readonly isIgnored: boolean;
|
|
32
|
+
};
|
|
33
|
+
export default getSourceMapInfo;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type {ReadOnlyGraph} from '../../types';
|
|
12
|
+
|
|
13
|
+
declare function getTransitiveDependencies<T>(
|
|
14
|
+
path: string,
|
|
15
|
+
graph: ReadOnlyGraph<T>,
|
|
16
|
+
): Set<string>;
|
|
17
|
+
export default getTransitiveDependencies;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type {MixedOutput, Module} from '../../types';
|
|
12
|
+
import type {JsOutput} from 'metro-transform-worker';
|
|
13
|
+
|
|
14
|
+
export type Options = Readonly<{
|
|
15
|
+
createModuleId: ($$PARAM_0$$: string) => number | string;
|
|
16
|
+
dev: boolean;
|
|
17
|
+
includeAsyncPaths: boolean;
|
|
18
|
+
projectRoot: string;
|
|
19
|
+
serverRoot: string;
|
|
20
|
+
sourceUrl: null | undefined | string;
|
|
21
|
+
}>;
|
|
22
|
+
export declare function wrapModule(module: Module, options: Options): string;
|
|
23
|
+
export declare function getModuleParams(
|
|
24
|
+
module: Module,
|
|
25
|
+
options: Options,
|
|
26
|
+
): Array<unknown>;
|
|
27
|
+
export declare function getJsOutput(
|
|
28
|
+
module: Readonly<{output: ReadonlyArray<MixedOutput>; path?: string}>,
|
|
29
|
+
): JsOutput;
|
|
30
|
+
export declare function isJsModule(module: Module): boolean;
|
|
@@ -21,10 +21,7 @@ function _interopRequireWildcard(e, t) {
|
|
|
21
21
|
if (!t && e && e.__esModule) return e;
|
|
22
22
|
var o,
|
|
23
23
|
i,
|
|
24
|
-
f = {
|
|
25
|
-
__proto__: null,
|
|
26
|
-
default: e,
|
|
27
|
-
};
|
|
24
|
+
f = { __proto__: null, default: e };
|
|
28
25
|
if (null === e || ("object" != typeof e && "function" != typeof e))
|
|
29
26
|
return f;
|
|
30
27
|
if ((o = t ? n : r)) {
|
|
@@ -44,11 +41,7 @@ function _interopRequireWildcard(e, t) {
|
|
|
44
41
|
})(e, t);
|
|
45
42
|
}
|
|
46
43
|
function _interopRequireDefault(e) {
|
|
47
|
-
return e && e.__esModule
|
|
48
|
-
? e
|
|
49
|
-
: {
|
|
50
|
-
default: e,
|
|
51
|
-
};
|
|
44
|
+
return e && e.__esModule ? e : { default: e };
|
|
52
45
|
}
|
|
53
46
|
function wrapModule(module, options) {
|
|
54
47
|
const output = getJsOutput(module);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type {Module} from '../../types';
|
|
12
|
+
|
|
13
|
+
declare function processModules(
|
|
14
|
+
modules: ReadonlyArray<Module>,
|
|
15
|
+
$$PARAM_1$$: Readonly<{
|
|
16
|
+
filter?: (module: Module) => boolean;
|
|
17
|
+
createModuleId: ($$PARAM_0$$: string) => number;
|
|
18
|
+
dev: boolean;
|
|
19
|
+
includeAsyncPaths: boolean;
|
|
20
|
+
projectRoot: string;
|
|
21
|
+
serverRoot: string;
|
|
22
|
+
sourceUrl: null | undefined | string;
|
|
23
|
+
}>,
|
|
24
|
+
): ReadonlyArray<[Module, string]>;
|
|
25
|
+
export default processModules;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type {DeltaResult, ReadOnlyGraph} from '../types';
|
|
12
|
+
import type {HmrModule} from 'metro-runtime/src/modules/types';
|
|
13
|
+
|
|
14
|
+
type Options = Readonly<{
|
|
15
|
+
clientUrl: URL;
|
|
16
|
+
createModuleId: ($$PARAM_0$$: string) => number;
|
|
17
|
+
includeAsyncPaths: boolean;
|
|
18
|
+
projectRoot: string;
|
|
19
|
+
serverRoot: string;
|
|
20
|
+
}>;
|
|
21
|
+
declare function hmrJSBundle(
|
|
22
|
+
delta: DeltaResult,
|
|
23
|
+
graph: ReadOnlyGraph,
|
|
24
|
+
options: Options,
|
|
25
|
+
): {
|
|
26
|
+
readonly added: ReadonlyArray<HmrModule>;
|
|
27
|
+
readonly deleted: ReadonlyArray<number>;
|
|
28
|
+
readonly modified: ReadonlyArray<HmrModule>;
|
|
29
|
+
};
|
|
30
|
+
export default hmrJSBundle;
|
|
@@ -9,11 +9,7 @@ var jscSafeUrl = _interopRequireWildcard(require("jsc-safe-url"));
|
|
|
9
9
|
var _metroTransformPlugins = require("metro-transform-plugins");
|
|
10
10
|
var _path = _interopRequireDefault(require("path"));
|
|
11
11
|
function _interopRequireDefault(e) {
|
|
12
|
-
return e && e.__esModule
|
|
13
|
-
? e
|
|
14
|
-
: {
|
|
15
|
-
default: e,
|
|
16
|
-
};
|
|
12
|
+
return e && e.__esModule ? e : { default: e };
|
|
17
13
|
}
|
|
18
14
|
function _interopRequireWildcard(e, t) {
|
|
19
15
|
if ("function" == typeof WeakMap)
|
|
@@ -23,10 +19,7 @@ function _interopRequireWildcard(e, t) {
|
|
|
23
19
|
if (!t && e && e.__esModule) return e;
|
|
24
20
|
var o,
|
|
25
21
|
i,
|
|
26
|
-
f = {
|
|
27
|
-
__proto__: null,
|
|
28
|
-
default: e,
|
|
29
|
-
};
|
|
22
|
+
f = { __proto__: null, default: e };
|
|
30
23
|
if (null === e || ("object" != typeof e && "function" != typeof e))
|
|
31
24
|
return f;
|
|
32
25
|
if ((o = t ? n : r)) {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type {Module} from '../types';
|
|
12
|
+
|
|
13
|
+
import {fromRawMappings, fromRawMappingsNonBlocking} from 'metro-source-map';
|
|
14
|
+
|
|
15
|
+
export type SourceMapGeneratorOptions = Readonly<{
|
|
16
|
+
excludeSource: boolean;
|
|
17
|
+
processModuleFilter: (module: Module) => boolean;
|
|
18
|
+
shouldAddToIgnoreList: (module: Module) => boolean;
|
|
19
|
+
getSourceUrl: null | undefined | ((module: Module) => string);
|
|
20
|
+
}>;
|
|
21
|
+
declare function sourceMapGenerator(
|
|
22
|
+
modules: ReadonlyArray<Module>,
|
|
23
|
+
options: SourceMapGeneratorOptions,
|
|
24
|
+
): ReturnType<typeof fromRawMappings>;
|
|
25
|
+
declare function sourceMapGeneratorNonBlocking(
|
|
26
|
+
modules: ReadonlyArray<Module>,
|
|
27
|
+
options: SourceMapGeneratorOptions,
|
|
28
|
+
): ReturnType<typeof fromRawMappingsNonBlocking>;
|
|
29
|
+
export {sourceMapGenerator, sourceMapGeneratorNonBlocking};
|
|
@@ -11,11 +11,7 @@ var _getSourceMapInfo = _interopRequireDefault(
|
|
|
11
11
|
var _js = require("./helpers/js");
|
|
12
12
|
var _metroSourceMap = require("metro-source-map");
|
|
13
13
|
function _interopRequireDefault(e) {
|
|
14
|
-
return e && e.__esModule
|
|
15
|
-
? e
|
|
16
|
-
: {
|
|
17
|
-
default: e,
|
|
18
|
-
};
|
|
14
|
+
return e && e.__esModule ? e : { default: e };
|
|
19
15
|
}
|
|
20
16
|
function getSourceMapInfosImpl(isBlocking, onDone, modules, options) {
|
|
21
17
|
const sourceMapInfos = [];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type {Module} from '../types';
|
|
12
|
+
import type {SourceMapGeneratorOptions} from './sourceMapGenerator';
|
|
13
|
+
import type {MixedSourceMap} from 'metro-source-map';
|
|
14
|
+
|
|
15
|
+
declare function sourceMapObject(
|
|
16
|
+
modules: ReadonlyArray<Module>,
|
|
17
|
+
options: SourceMapGeneratorOptions,
|
|
18
|
+
): MixedSourceMap;
|
|
19
|
+
declare function sourceMapObjectNonBlocking(
|
|
20
|
+
modules: ReadonlyArray<Module>,
|
|
21
|
+
options: SourceMapGeneratorOptions,
|
|
22
|
+
): Promise<MixedSourceMap>;
|
|
23
|
+
export {sourceMapObject, sourceMapObjectNonBlocking};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type {Module} from '../types';
|
|
12
|
+
import type {SourceMapGeneratorOptions} from './sourceMapGenerator';
|
|
13
|
+
|
|
14
|
+
declare function sourceMapString(
|
|
15
|
+
modules: ReadonlyArray<Module>,
|
|
16
|
+
options: SourceMapGeneratorOptions,
|
|
17
|
+
): string;
|
|
18
|
+
declare function sourceMapStringNonBlocking(
|
|
19
|
+
modules: ReadonlyArray<Module>,
|
|
20
|
+
options: SourceMapGeneratorOptions,
|
|
21
|
+
): Promise<string>;
|
|
22
|
+
export {sourceMapString, sourceMapStringNonBlocking};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type {TransformResult, TransformResultWithSource} from '../DeltaBundler';
|
|
12
|
+
import type {TransformOptions} from './Worker';
|
|
13
|
+
import type {ConfigT} from 'metro-config';
|
|
14
|
+
|
|
15
|
+
import WorkerFarm from './WorkerFarm';
|
|
16
|
+
import {Cache} from 'metro-cache';
|
|
17
|
+
|
|
18
|
+
type GetOrComputeSha1Fn = (
|
|
19
|
+
$$PARAM_0$$: string,
|
|
20
|
+
) => Promise<Readonly<{content?: Buffer; sha1: string}>>;
|
|
21
|
+
declare class Transformer {
|
|
22
|
+
_config: ConfigT;
|
|
23
|
+
_cache: Cache<TransformResult>;
|
|
24
|
+
_baseHash: string;
|
|
25
|
+
_getSha1: GetOrComputeSha1Fn;
|
|
26
|
+
_workerFarm: WorkerFarm;
|
|
27
|
+
constructor(
|
|
28
|
+
config: ConfigT,
|
|
29
|
+
opts: Readonly<{getOrComputeSha1: GetOrComputeSha1Fn}>,
|
|
30
|
+
);
|
|
31
|
+
transformFile(
|
|
32
|
+
filePath: string,
|
|
33
|
+
transformerOptions: TransformOptions,
|
|
34
|
+
fileBuffer?: Buffer,
|
|
35
|
+
): Promise<TransformResultWithSource>;
|
|
36
|
+
end(): Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
export default Transformer;
|
|
@@ -15,11 +15,7 @@ var _fs = _interopRequireDefault(require("fs"));
|
|
|
15
15
|
var _metroCache = require("metro-cache");
|
|
16
16
|
var _path = _interopRequireDefault(require("path"));
|
|
17
17
|
function _interopRequireDefault(e) {
|
|
18
|
-
return e && e.__esModule
|
|
19
|
-
? e
|
|
20
|
-
: {
|
|
21
|
-
default: e,
|
|
22
|
-
};
|
|
18
|
+
return e && e.__esModule ? e : { default: e };
|
|
23
19
|
}
|
|
24
20
|
const debug = require("debug")("Metro:Transformer");
|
|
25
21
|
class Transformer {
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type {TransformResult} from './types';
|
|
12
|
+
import type {LogEntry} from 'metro-core/private/Logger';
|
|
13
|
+
import type {
|
|
14
|
+
JsTransformerConfig,
|
|
15
|
+
JsTransformOptions,
|
|
16
|
+
} from 'metro-transform-worker';
|
|
17
|
+
|
|
18
|
+
export type {JsTransformOptions as TransformOptions} from 'metro-transform-worker';
|
|
19
|
+
export type TransformerConfig = {
|
|
20
|
+
transformerPath: string;
|
|
21
|
+
transformerConfig: JsTransformerConfig;
|
|
22
|
+
};
|
|
23
|
+
type Data = Readonly<{
|
|
24
|
+
result: TransformResult;
|
|
25
|
+
sha1: string;
|
|
26
|
+
transformFileStartLogEntry: LogEntry;
|
|
27
|
+
transformFileEndLogEntry: LogEntry;
|
|
28
|
+
}>;
|
|
29
|
+
export declare const transform: (
|
|
30
|
+
filename: string,
|
|
31
|
+
transformOptions: JsTransformOptions,
|
|
32
|
+
projectRoot: string,
|
|
33
|
+
transformerConfig: TransformerConfig,
|
|
34
|
+
fileBuffer?: Buffer,
|
|
35
|
+
) => Promise<Data>;
|
|
36
|
+
export declare type transform = typeof transform;
|
|
37
|
+
export type Worker = {readonly transform: typeof transform};
|
|
@@ -9,11 +9,7 @@ var _crypto = _interopRequireDefault(require("crypto"));
|
|
|
9
9
|
var _fs = _interopRequireDefault(require("fs"));
|
|
10
10
|
var _path = _interopRequireDefault(require("path"));
|
|
11
11
|
function _interopRequireDefault(e) {
|
|
12
|
-
return e && e.__esModule
|
|
13
|
-
? e
|
|
14
|
-
: {
|
|
15
|
-
default: e,
|
|
16
|
-
};
|
|
12
|
+
return e && e.__esModule ? e : { default: e };
|
|
17
13
|
}
|
|
18
14
|
function asDeserializedBuffer(value) {
|
|
19
15
|
if (Buffer.isBuffer(value)) {
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type {TransformResult} from '../DeltaBundler';
|
|
12
|
+
import type {TransformerConfig, TransformOptions, Worker} from './Worker';
|
|
13
|
+
import type {ConfigT} from 'metro-config';
|
|
14
|
+
import type {Readable} from 'stream';
|
|
15
|
+
|
|
16
|
+
type WorkerInterface = Readonly<
|
|
17
|
+
Omit<
|
|
18
|
+
Worker,
|
|
19
|
+
keyof {
|
|
20
|
+
end(): void | Promise<void>;
|
|
21
|
+
getStdout(): Readable;
|
|
22
|
+
getStderr(): Readable;
|
|
23
|
+
}
|
|
24
|
+
> & {
|
|
25
|
+
end(): void | Promise<void>;
|
|
26
|
+
getStdout(): Readable;
|
|
27
|
+
getStderr(): Readable;
|
|
28
|
+
}
|
|
29
|
+
>;
|
|
30
|
+
type TransformerResult = Readonly<{result: TransformResult; sha1: string}>;
|
|
31
|
+
declare class WorkerFarm {
|
|
32
|
+
_config: ConfigT;
|
|
33
|
+
_transformerConfig: TransformerConfig;
|
|
34
|
+
_worker: WorkerInterface | Worker;
|
|
35
|
+
constructor(config: ConfigT, transformerConfig: TransformerConfig);
|
|
36
|
+
kill(): Promise<void>;
|
|
37
|
+
transform(
|
|
38
|
+
filename: string,
|
|
39
|
+
options: TransformOptions,
|
|
40
|
+
fileBuffer?: Buffer,
|
|
41
|
+
): Promise<TransformerResult>;
|
|
42
|
+
_makeFarm(
|
|
43
|
+
absoluteWorkerPath: string,
|
|
44
|
+
exposedMethods: ReadonlyArray<string>,
|
|
45
|
+
numWorkers: number,
|
|
46
|
+
): WorkerInterface;
|
|
47
|
+
_computeWorkerKey(
|
|
48
|
+
method: string,
|
|
49
|
+
filename: string,
|
|
50
|
+
): null | undefined | string;
|
|
51
|
+
_formatGenericError(
|
|
52
|
+
err: Readonly<{message: string; stack?: string}>,
|
|
53
|
+
filename: string,
|
|
54
|
+
): TransformError;
|
|
55
|
+
_formatBabelError(
|
|
56
|
+
err: Readonly<{
|
|
57
|
+
message: string;
|
|
58
|
+
stack?: string;
|
|
59
|
+
type?: string;
|
|
60
|
+
codeFrame?: unknown;
|
|
61
|
+
loc: {line?: number; column?: number};
|
|
62
|
+
}>,
|
|
63
|
+
filename: string,
|
|
64
|
+
): TransformError;
|
|
65
|
+
}
|
|
66
|
+
export default WorkerFarm;
|
|
67
|
+
declare class TransformError extends SyntaxError {
|
|
68
|
+
type: string;
|
|
69
|
+
constructor(message: string);
|
|
70
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type {RequireContext} from '../lib/contextModule';
|
|
11
|
+
import type {
|
|
12
|
+
ModuleData,
|
|
13
|
+
ResolvedDependency,
|
|
14
|
+
ResolveFn,
|
|
15
|
+
TransformFn,
|
|
16
|
+
} from './types';
|
|
17
|
+
|
|
18
|
+
type Parameters<T> = Readonly<{
|
|
19
|
+
resolve: ResolveFn;
|
|
20
|
+
transform: TransformFn<T>;
|
|
21
|
+
shouldTraverse: ($$PARAM_0$$: ResolvedDependency) => boolean;
|
|
22
|
+
}>;
|
|
23
|
+
export declare function buildSubgraph<T>(
|
|
24
|
+
entryPaths: ReadonlySet<string>,
|
|
25
|
+
resolvedContexts: ReadonlyMap<string, null | undefined | RequireContext>,
|
|
26
|
+
$$PARAM_2$$: Parameters<T>,
|
|
27
|
+
): Promise<{
|
|
28
|
+
moduleData: Map<string, ModuleData<T>>;
|
|
29
|
+
errors: Map<string, Error>;
|
|
30
|
+
}>;
|
|
@@ -8,11 +8,7 @@ var _contextModule = require("../lib/contextModule");
|
|
|
8
8
|
var _isResolvedDependency = require("../lib/isResolvedDependency");
|
|
9
9
|
var _path = _interopRequireDefault(require("path"));
|
|
10
10
|
function _interopRequireDefault(e) {
|
|
11
|
-
return e && e.__esModule
|
|
12
|
-
? e
|
|
13
|
-
: {
|
|
14
|
-
default: e,
|
|
15
|
-
};
|
|
11
|
+
return e && e.__esModule ? e : { default: e };
|
|
16
12
|
}
|
|
17
13
|
function resolveDependencies(parentPath, dependencies, resolve) {
|
|
18
14
|
const maybeResolvedDeps = new Map();
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type {TransformerConfig} from './Worker';
|
|
12
|
+
|
|
13
|
+
declare function getTransformCacheKey(opts: {
|
|
14
|
+
readonly cacheVersion: string;
|
|
15
|
+
readonly projectRoot: string;
|
|
16
|
+
readonly transformerConfig: TransformerConfig;
|
|
17
|
+
}): string;
|
|
18
|
+
export default getTransformCacheKey;
|
|
@@ -7,11 +7,7 @@ exports.default = getTransformCacheKey;
|
|
|
7
7
|
var _crypto = _interopRequireDefault(require("crypto"));
|
|
8
8
|
var _metroCacheKey = require("metro-cache-key");
|
|
9
9
|
function _interopRequireDefault(e) {
|
|
10
|
-
return e && e.__esModule
|
|
11
|
-
? e
|
|
12
|
-
: {
|
|
13
|
-
default: e,
|
|
14
|
-
};
|
|
10
|
+
return e && e.__esModule ? e : { default: e };
|
|
15
11
|
}
|
|
16
12
|
const VERSION = require("../../package.json").version;
|
|
17
13
|
function getTransformCacheKey(opts) {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type {DeltaBundle} from 'metro-runtime/src/modules/types';
|
|
12
|
+
|
|
13
|
+
declare function mergeDeltas(
|
|
14
|
+
delta1: DeltaBundle,
|
|
15
|
+
delta2: DeltaBundle,
|
|
16
|
+
): DeltaBundle;
|
|
17
|
+
export default mergeDeltas;
|