metro 0.66.2 → 0.69.0
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 +22 -24
- package/src/Assets.js +9 -9
- package/src/Assets.js.flow +5 -7
- package/src/Bundler/util.js +16 -15
- package/src/Bundler/util.js.flow +11 -10
- package/src/Bundler.js +21 -8
- package/src/Bundler.js.flow +19 -7
- package/src/DeltaBundler/DeltaCalculator.js +15 -15
- package/src/DeltaBundler/DeltaCalculator.js.flow +7 -7
- package/src/DeltaBundler/Serializers/baseBytecodeBundle.js +13 -13
- package/src/DeltaBundler/Serializers/baseBytecodeBundle.js.flow +6 -7
- package/src/DeltaBundler/Serializers/baseJSBundle.js +4 -4
- package/src/DeltaBundler/Serializers/baseJSBundle.js.flow +4 -4
- package/src/DeltaBundler/Serializers/getAllFiles.js +1 -1
- package/src/DeltaBundler/Serializers/getAllFiles.js.flow +3 -3
- package/src/DeltaBundler/Serializers/getAssets.js +3 -3
- package/src/DeltaBundler/Serializers/getAssets.js.flow +4 -5
- package/src/DeltaBundler/Serializers/getExplodedSourceMap.js +4 -4
- package/src/DeltaBundler/Serializers/getExplodedSourceMap.js.flow +4 -4
- package/src/DeltaBundler/Serializers/getRamBundleInfo.js +20 -20
- package/src/DeltaBundler/Serializers/getRamBundleInfo.js.flow +9 -10
- package/src/DeltaBundler/Serializers/helpers/bytecode.js +11 -11
- package/src/DeltaBundler/Serializers/helpers/bytecode.js.flow +5 -6
- package/src/DeltaBundler/Serializers/helpers/getInlineSourceMappingURL.js +1 -1
- package/src/DeltaBundler/Serializers/helpers/getInlineSourceMappingURL.js.flow +1 -1
- package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.js +2 -2
- package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.js.flow +4 -4
- package/src/DeltaBundler/Serializers/helpers/getTransitiveDependencies.js +1 -1
- package/src/DeltaBundler/Serializers/helpers/getTransitiveDependencies.js.flow +1 -1
- package/src/DeltaBundler/Serializers/helpers/js.js +6 -6
- package/src/DeltaBundler/Serializers/helpers/js.js.flow +11 -12
- package/src/DeltaBundler/Serializers/helpers/processBytecodeModules.js +4 -4
- package/src/DeltaBundler/Serializers/helpers/processBytecodeModules.js.flow +3 -3
- package/src/DeltaBundler/Serializers/helpers/processModules.js +4 -4
- package/src/DeltaBundler/Serializers/helpers/processModules.js.flow +3 -3
- package/src/DeltaBundler/Serializers/hmrJSBundle.js +9 -9
- package/src/DeltaBundler/Serializers/hmrJSBundle.js.flow +9 -8
- package/src/DeltaBundler/Serializers/sourceMapGenerator.js +6 -6
- package/src/DeltaBundler/Serializers/sourceMapGenerator.js.flow +3 -4
- package/src/DeltaBundler/Serializers/sourceMapObject.js +5 -5
- package/src/DeltaBundler/Serializers/sourceMapObject.js.flow +4 -4
- package/src/DeltaBundler/Serializers/sourceMapString.js +2 -2
- package/src/DeltaBundler/Serializers/sourceMapString.js.flow +3 -3
- package/src/DeltaBundler/Transformer.js +9 -9
- package/src/DeltaBundler/Transformer.js.flow +7 -9
- package/src/DeltaBundler/Worker.js +8 -11
- package/src/DeltaBundler/Worker.js.flow +8 -11
- package/src/DeltaBundler/WorkerFarm.js +14 -17
- package/src/DeltaBundler/WorkerFarm.js.flow +7 -10
- package/src/DeltaBundler/__fixtures__/hasteImpl.js +2 -2
- package/src/DeltaBundler/computeDelta.js +2 -2
- package/src/DeltaBundler/computeDelta.js.flow +2 -2
- package/src/DeltaBundler/getTransformCacheKey.js +4 -4
- package/src/DeltaBundler/getTransformCacheKey.js.flow +5 -6
- package/src/DeltaBundler/mergeDeltas.js +2 -2
- package/src/DeltaBundler/mergeDeltas.js.flow +1 -1
- package/src/DeltaBundler/traverseDependencies.js +22 -22
- package/src/DeltaBundler/traverseDependencies.js.flow +3 -3
- package/src/DeltaBundler/types.flow.js +1 -1
- package/src/DeltaBundler/types.flow.js.flow +1 -1
- package/src/DeltaBundler.js +5 -5
- package/src/DeltaBundler.js.flow +4 -4
- package/src/HmrServer.js +71 -55
- package/src/HmrServer.js.flow +40 -37
- package/src/IncrementalBundler/GraphNotFoundError.js +1 -1
- package/src/IncrementalBundler/GraphNotFoundError.js.flow +1 -1
- package/src/IncrementalBundler/ResourceNotFoundError.js +1 -1
- package/src/IncrementalBundler/ResourceNotFoundError.js.flow +1 -1
- package/src/IncrementalBundler/RevisionNotFoundError.js +1 -1
- package/src/IncrementalBundler/RevisionNotFoundError.js.flow +1 -1
- package/src/IncrementalBundler.js +44 -32
- package/src/IncrementalBundler.js.flow +30 -24
- package/src/ModuleGraph/module.js +3 -3
- package/src/ModuleGraph/module.js.flow +1 -1
- package/src/ModuleGraph/node-haste/HasteFS.js +2 -2
- package/src/ModuleGraph/node-haste/HasteFS.js.flow +1 -1
- package/src/ModuleGraph/node-haste/Module.js +1 -1
- package/src/ModuleGraph/node-haste/Module.js.flow +1 -1
- package/src/ModuleGraph/node-haste/ModuleCache.js +1 -1
- package/src/ModuleGraph/node-haste/ModuleCache.js.flow +3 -3
- package/src/ModuleGraph/node-haste/Package.js +3 -3
- package/src/ModuleGraph/node-haste/Package.js.flow +3 -3
- package/src/ModuleGraph/node-haste/node-haste.flow.js +1 -1
- package/src/ModuleGraph/node-haste/node-haste.flow.js.flow +1 -1
- package/src/ModuleGraph/node-haste/node-haste.js +42 -32
- package/src/ModuleGraph/node-haste/node-haste.js.flow +28 -23
- package/src/ModuleGraph/output/indexed-ram-bundle.js +17 -17
- package/src/ModuleGraph/output/indexed-ram-bundle.js.flow +41 -9
- package/src/ModuleGraph/output/multiple-files-ram-bundle.js +18 -18
- package/src/ModuleGraph/output/multiple-files-ram-bundle.js.flow +21 -9
- package/src/ModuleGraph/output/plain-bundle.js +6 -6
- package/src/ModuleGraph/output/plain-bundle.js.flow +7 -7
- package/src/ModuleGraph/output/reverse-dependency-map-references.js +3 -3
- package/src/ModuleGraph/output/reverse-dependency-map-references.js.flow +4 -8
- package/src/ModuleGraph/output/util.js +31 -30
- package/src/ModuleGraph/output/util.js.flow +15 -16
- package/src/ModuleGraph/silent-console.js +2 -2
- package/src/ModuleGraph/silent-console.js.flow +1 -1
- package/src/ModuleGraph/test-helpers.js +7 -7
- package/src/ModuleGraph/types.flow.js +1 -1
- package/src/ModuleGraph/types.flow.js.flow +7 -7
- package/src/ModuleGraph/worker/JsFileWrapping.js +7 -7
- package/src/ModuleGraph/worker/JsFileWrapping.js.flow +3 -2
- package/src/ModuleGraph/worker/Platforms.js +2 -2
- package/src/ModuleGraph/worker/Platforms.js.flow +1 -1
- package/src/ModuleGraph/worker/collectDependencies.js +24 -25
- package/src/ModuleGraph/worker/collectDependencies.js.flow +15 -17
- package/src/ModuleGraph/worker/generate.js +2 -2
- package/src/ModuleGraph/worker/generate.js.flow +3 -3
- package/src/ModuleGraph/worker/generateImportNames.js +5 -5
- package/src/ModuleGraph/worker/generateImportNames.js.flow +3 -5
- package/src/ModuleGraph/worker/mergeSourceMaps.js +8 -7
- package/src/ModuleGraph/worker/mergeSourceMaps.js.flow +3 -3
- package/src/Server/MultipartResponse.js +4 -8
- package/src/Server/symbolicate.js +8 -8
- package/src/Server/symbolicate.js.flow +17 -5
- package/src/Server.js +202 -150
- package/src/Server.js.flow +129 -87
- package/src/cli-utils.js +4 -4
- package/src/cli-utils.js.flow +15 -13
- package/src/cli.js +4 -4
- package/src/cli.js.flow +2 -4
- package/src/commands/build.js +23 -24
- package/src/commands/build.js.flow +6 -9
- package/src/commands/dependencies.js +25 -19
- package/src/commands/serve.js +17 -18
- package/src/commands/serve.js.flow +6 -9
- package/src/index.js +116 -51
- package/src/index.js.flow +107 -41
- package/src/integration_tests/basic_bundle/AssetRegistry.js +2 -2
- package/src/integration_tests/basic_bundle/AssetRegistry.js.flow +1 -1
- package/src/integration_tests/basic_bundle/Bar.js +2 -2
- package/src/integration_tests/basic_bundle/Bar.js.flow +1 -1
- package/src/integration_tests/basic_bundle/ErrorBundle.js +2 -2
- package/src/integration_tests/basic_bundle/ErrorBundle.js.flow +1 -1
- package/src/integration_tests/basic_bundle/Foo.js +2 -2
- package/src/integration_tests/basic_bundle/Foo.js.flow +1 -1
- package/src/integration_tests/basic_bundle/TestBundle.js +3 -2
- package/src/integration_tests/basic_bundle/TestBundle.js.flow +3 -1
- package/src/integration_tests/basic_bundle/TestPolyfill.js +1 -1
- package/src/integration_tests/basic_bundle/TestPolyfill.js.flow +1 -1
- package/src/integration_tests/basic_bundle/TypeScript.ts +1 -1
- package/src/integration_tests/basic_bundle/import-export/export-1.js +2 -2
- package/src/integration_tests/basic_bundle/import-export/export-1.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/export-2.js +2 -2
- package/src/integration_tests/basic_bundle/import-export/export-2.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/export-3.js +2 -2
- package/src/integration_tests/basic_bundle/import-export/export-3.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/export-4.js +2 -2
- package/src/integration_tests/basic_bundle/import-export/export-4.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/export-5.js +2 -2
- package/src/integration_tests/basic_bundle/import-export/export-5.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/export-6.js +2 -2
- package/src/integration_tests/basic_bundle/import-export/export-6.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/export-null.js +2 -2
- package/src/integration_tests/basic_bundle/import-export/export-null.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/export-primitive-default.js +2 -2
- package/src/integration_tests/basic_bundle/import-export/export-primitive-default.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/index.js +8 -8
- package/src/integration_tests/basic_bundle/import-export/index.js.flow +1 -1
- package/src/integration_tests/basic_bundle/polyfill.js +1 -1
- package/src/integration_tests/execBundle.js +2 -2
- package/src/integration_tests/execBundle.js.flow +1 -1
- package/src/integration_tests/metro.config.js +8 -8
- package/src/lib/BatchProcessor.js +3 -3
- package/src/lib/BatchProcessor.js.flow +1 -1
- package/src/lib/JsonReporter.js +2 -2
- package/src/lib/JsonReporter.js.flow +1 -1
- package/src/lib/RamBundleParser.js +1 -1
- package/src/lib/RamBundleParser.js.flow +1 -1
- package/src/lib/TerminalReporter.js +14 -14
- package/src/lib/TerminalReporter.js.flow +9 -10
- package/src/lib/bundleToBytecode.js +6 -7
- package/src/lib/bundleToBytecode.js.flow +8 -7
- package/src/lib/bundleToString.js +3 -3
- package/src/lib/bundleToString.js.flow +5 -4
- package/src/lib/countLines.js +3 -7
- package/src/lib/countLines.js.flow +4 -7
- package/src/lib/createModuleIdFactory.js +2 -2
- package/src/lib/createModuleIdFactory.js.flow +1 -1
- package/src/lib/{attachWebsocketServer.js → createWebsocketServer.js} +18 -17
- package/src/lib/{attachWebsocketServer.js.flow → createWebsocketServer.js.flow} +12 -21
- package/src/lib/debounceAsyncQueue.js +2 -2
- package/src/lib/debounceAsyncQueue.js.flow +1 -1
- package/src/lib/formatBundlingError.js +21 -21
- package/src/lib/formatBundlingError.js.flow +6 -8
- package/src/lib/getAppendScripts.js +26 -27
- package/src/lib/getAppendScripts.js.flow +7 -8
- package/src/lib/getGraphId.js +3 -3
- package/src/lib/getGraphId.js.flow +3 -3
- package/src/lib/getMaxWorkers.js +2 -2
- package/src/lib/getMaxWorkers.js.flow +1 -1
- package/src/lib/getPreludeCode.js +2 -2
- package/src/lib/getPreludeCode.js.flow +1 -1
- package/src/lib/getPrependedScripts.js +15 -15
- package/src/lib/getPrependedScripts.js.flow +7 -8
- package/src/lib/logToConsole.js +1 -1
- package/src/lib/logToConsole.js.flow +3 -3
- package/src/lib/parseCustomTransformOptions.js +2 -2
- package/src/lib/parseCustomTransformOptions.js.flow +3 -3
- package/src/lib/parseOptionsFromUrl.js +7 -7
- package/src/lib/parseOptionsFromUrl.js.flow +29 -9
- package/src/lib/relativizeSourceMap.js +1 -1
- package/src/lib/relativizeSourceMap.js.flow +3 -3
- package/src/lib/reporting.js +5 -5
- package/src/lib/reporting.js.flow +16 -3
- package/src/lib/splitBundleOptions.js +5 -5
- package/src/lib/splitBundleOptions.js.flow +1 -1
- package/src/lib/transformHelpers.js +10 -10
- package/src/lib/transformHelpers.js.flow +5 -5
- package/src/node-haste/DependencyGraph/ModuleResolution.js +51 -30
- package/src/node-haste/DependencyGraph/ModuleResolution.js.flow +46 -42
- package/src/node-haste/DependencyGraph/createHasteMap.js +99 -0
- package/src/node-haste/DependencyGraph/createHasteMap.js.flow +88 -0
- package/src/node-haste/DependencyGraph/{assets/empty-module.js → types.js} +2 -2
- package/src/node-haste/DependencyGraph/types.js.flow +88 -0
- package/src/node-haste/DependencyGraph.js +49 -117
- package/src/node-haste/DependencyGraph.js.flow +36 -111
- package/src/node-haste/Module.js +1 -1
- package/src/node-haste/Module.js.flow +3 -3
- package/src/node-haste/ModuleCache.js +54 -13
- package/src/node-haste/ModuleCache.js.flow +53 -12
- package/src/node-haste/Package.js +7 -9
- package/src/node-haste/Package.js.flow +1 -8
- package/src/node-haste/lib/AssetPaths.js +5 -5
- package/src/node-haste/lib/AssetPaths.js.flow +2 -4
- package/src/node-haste/lib/parsePlatformFilePath.js +4 -4
- package/src/node-haste/lib/parsePlatformFilePath.js.flow +1 -1
- package/src/shared/output/RamBundle/as-assets.js +16 -17
- package/src/shared/output/RamBundle/as-assets.js.flow +11 -15
- package/src/shared/output/RamBundle/as-indexed-file.js +14 -15
- package/src/shared/output/RamBundle/as-indexed-file.js.flow +8 -12
- package/src/shared/output/RamBundle/buildSourcemapWithMetadata.js +7 -7
- package/src/shared/output/RamBundle/buildSourcemapWithMetadata.js.flow +4 -4
- package/src/shared/output/RamBundle/magic-number.js +1 -1
- package/src/shared/output/RamBundle/magic-number.js.flow +1 -1
- package/src/shared/output/RamBundle/util.js +21 -19
- package/src/shared/output/RamBundle/util.js.flow +5 -8
- package/src/shared/output/RamBundle/write-sourcemap.js +1 -1
- package/src/shared/output/RamBundle/write-sourcemap.js.flow +1 -1
- package/src/shared/output/RamBundle.js +2 -2
- package/src/shared/output/RamBundle.js.flow +4 -5
- package/src/shared/output/bundle.js +6 -6
- package/src/shared/output/bundle.js.flow +4 -5
- package/src/shared/output/meta.js +4 -5
- package/src/shared/output/meta.js.flow +2 -4
- package/src/shared/output/unbundle.js +1 -1
- package/src/shared/output/unbundle.js.flow +1 -1
- package/src/shared/output/writeFile.js +1 -1
- package/src/shared/output/writeFile.js.flow +1 -1
- package/src/shared/types.flow.js +1 -1
- package/src/shared/types.flow.js.flow +2 -2
- package/src/node-haste/DependencyGraph/assets/empty-module.js.flow +0 -9
- package/src/node-haste/types.js +0 -10
- package/src/node-haste/types.js.flow +0 -23
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -10,23 +10,22 @@
|
|
|
10
10
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
import type {NodePath} from '@babel/traverse';
|
|
14
|
+
import type {CallExpression, Identifier, StringLiteral} from '@babel/types';
|
|
15
|
+
import type {
|
|
16
|
+
AllowOptionalDependencies,
|
|
17
|
+
AsyncDependencyType,
|
|
18
|
+
} from 'metro/src/DeltaBundler/types.flow.js';
|
|
15
19
|
|
|
16
20
|
const generate = require('@babel/generator').default;
|
|
17
21
|
const template = require('@babel/template').default;
|
|
18
22
|
const traverse = require('@babel/traverse').default;
|
|
19
23
|
const types = require('@babel/types');
|
|
24
|
+
const invariant = require('invariant');
|
|
25
|
+
const nullthrows = require('nullthrows');
|
|
20
26
|
|
|
21
27
|
const {isImport} = types;
|
|
22
28
|
|
|
23
|
-
import type {NodePath} from '@babel/traverse';
|
|
24
|
-
import type {CallExpression, Identifier, StringLiteral} from '@babel/types';
|
|
25
|
-
import type {
|
|
26
|
-
AllowOptionalDependencies,
|
|
27
|
-
AsyncDependencyType,
|
|
28
|
-
} from 'metro/src/DeltaBundler/types.flow.js';
|
|
29
|
-
|
|
30
29
|
type ImportDependencyOptions = $ReadOnly<{
|
|
31
30
|
asyncType: AsyncDependencyType,
|
|
32
31
|
jsResource?: boolean,
|
|
@@ -224,9 +223,8 @@ function collectDependencies<TSplitCondition = void>(
|
|
|
224
223
|
options.dependencyMapName,
|
|
225
224
|
);
|
|
226
225
|
} else {
|
|
227
|
-
state.dependencyMapIdentifier =
|
|
228
|
-
'dependencyMap'
|
|
229
|
-
);
|
|
226
|
+
state.dependencyMapIdentifier =
|
|
227
|
+
path.scope.generateUidIdentifier('dependencyMap');
|
|
230
228
|
}
|
|
231
229
|
|
|
232
230
|
state.dependencyCalls = new Set(['require', ...options.inlineableCalls]);
|
|
@@ -549,15 +547,15 @@ function createModuleNameLiteral(dependency: InternalDependency<mixed>) {
|
|
|
549
547
|
}
|
|
550
548
|
|
|
551
549
|
class DefaultModuleDependencyRegistry<TSplitCondition = void>
|
|
552
|
-
implements ModuleDependencyRegistry<TSplitCondition>
|
|
550
|
+
implements ModuleDependencyRegistry<TSplitCondition>
|
|
551
|
+
{
|
|
553
552
|
_dependencies: Map<string, InternalDependency<TSplitCondition>> = new Map();
|
|
554
553
|
|
|
555
554
|
registerDependency(
|
|
556
555
|
qualifier: ImportQualifier,
|
|
557
556
|
): InternalDependency<TSplitCondition> {
|
|
558
|
-
let dependency: ?InternalDependency<TSplitCondition> =
|
|
559
|
-
qualifier.name
|
|
560
|
-
);
|
|
557
|
+
let dependency: ?InternalDependency<TSplitCondition> =
|
|
558
|
+
this._dependencies.get(qualifier.name);
|
|
561
559
|
|
|
562
560
|
if (dependency == null) {
|
|
563
561
|
const newDependency: MutableInternalDependency<TSplitCondition> = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -20,7 +20,7 @@ function generate(ast, filename, sourceCode) {
|
|
|
20
20
|
filename,
|
|
21
21
|
sourceFileName: filename,
|
|
22
22
|
sourceMaps: true,
|
|
23
|
-
sourceMapTarget: filename
|
|
23
|
+
sourceMapTarget: filename,
|
|
24
24
|
},
|
|
25
25
|
sourceCode
|
|
26
26
|
);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
-
const babelGenerate = require('@babel/generator').default;
|
|
14
|
-
|
|
15
13
|
import type {GeneratorResult} from '@babel/generator';
|
|
16
14
|
|
|
15
|
+
const babelGenerate = require('@babel/generator').default;
|
|
16
|
+
|
|
17
17
|
function generate(
|
|
18
18
|
ast: BabelNode,
|
|
19
19
|
filename: string,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
*/
|
|
10
10
|
"use strict";
|
|
11
11
|
|
|
12
|
-
const nullthrows = require("nullthrows");
|
|
13
|
-
|
|
14
12
|
const traverse = require("@babel/traverse").default;
|
|
13
|
+
|
|
14
|
+
const nullthrows = require("nullthrows");
|
|
15
15
|
/**
|
|
16
16
|
* Select unused names for "metroImportDefault" and "metroImportAll", by
|
|
17
17
|
* calling "generateUid".
|
|
@@ -25,11 +25,11 @@ function generateImportNames(ast) {
|
|
|
25
25
|
importAll = path.scope.generateUid("$$_IMPORT_ALL");
|
|
26
26
|
importDefault = path.scope.generateUid("$$_IMPORT_DEFAULT");
|
|
27
27
|
path.stop();
|
|
28
|
-
}
|
|
28
|
+
},
|
|
29
29
|
});
|
|
30
30
|
return {
|
|
31
31
|
importAll: nullthrows(importAll),
|
|
32
|
-
importDefault: nullthrows(importDefault)
|
|
32
|
+
importDefault: nullthrows(importDefault),
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -10,16 +10,14 @@
|
|
|
10
10
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
-
const nullthrows = require('nullthrows');
|
|
14
13
|
const traverse = require('@babel/traverse').default;
|
|
14
|
+
const nullthrows = require('nullthrows');
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Select unused names for "metroImportDefault" and "metroImportAll", by
|
|
18
18
|
* calling "generateUid".
|
|
19
19
|
*/
|
|
20
|
-
function generateImportNames(
|
|
21
|
-
ast: BabelNode,
|
|
22
|
-
): {
|
|
20
|
+
function generateImportNames(ast: BabelNode): {
|
|
23
21
|
importAll: string,
|
|
24
22
|
importDefault: string,
|
|
25
23
|
} {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -7,21 +7,22 @@
|
|
|
7
7
|
* @format
|
|
8
8
|
*
|
|
9
9
|
*/
|
|
10
|
-
"use strict";
|
|
10
|
+
"use strict";
|
|
11
11
|
|
|
12
|
+
// $FlowExpectedError: TODO(t67543266): `source-map` is hard to type.
|
|
12
13
|
const sourceMap = require("source-map");
|
|
13
14
|
|
|
14
15
|
function mergeSourceMaps(file, originalMap, secondMap) {
|
|
15
16
|
const merged = new sourceMap.SourceMapGenerator();
|
|
16
17
|
const inputMap = new sourceMap.SourceMapConsumer(originalMap);
|
|
17
|
-
new sourceMap.SourceMapConsumer(secondMap).eachMapping(mapping => {
|
|
18
|
+
new sourceMap.SourceMapConsumer(secondMap).eachMapping((mapping) => {
|
|
18
19
|
if (mapping.originalLine == null) {
|
|
19
20
|
return;
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
const original = inputMap.originalPositionFor({
|
|
23
24
|
line: mapping.originalLine,
|
|
24
|
-
column: mapping.originalColumn
|
|
25
|
+
column: mapping.originalColumn,
|
|
25
26
|
});
|
|
26
27
|
|
|
27
28
|
if (original.line == null) {
|
|
@@ -31,14 +32,14 @@ function mergeSourceMaps(file, originalMap, secondMap) {
|
|
|
31
32
|
merged.addMapping({
|
|
32
33
|
generated: {
|
|
33
34
|
line: mapping.generatedLine,
|
|
34
|
-
column: mapping.generatedColumn
|
|
35
|
+
column: mapping.generatedColumn,
|
|
35
36
|
},
|
|
36
37
|
original: {
|
|
37
38
|
line: original.line,
|
|
38
|
-
column: original.column || 0
|
|
39
|
+
column: original.column || 0,
|
|
39
40
|
},
|
|
40
41
|
source: file,
|
|
41
|
-
name: original.name || mapping.name
|
|
42
|
+
name: original.name || mapping.name,
|
|
42
43
|
});
|
|
43
44
|
});
|
|
44
45
|
return { ...merged.toJSON(), sources: inputMap.sources };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
+
import type {BasicSourceMap, MixedSourceMap} from 'metro-source-map';
|
|
14
|
+
|
|
13
15
|
// $FlowExpectedError: TODO(t67543266): `source-map` is hard to type.
|
|
14
16
|
const sourceMap = require('source-map');
|
|
15
17
|
|
|
16
|
-
import type {MixedSourceMap, BasicSourceMap} from 'metro-source-map';
|
|
17
|
-
|
|
18
18
|
function mergeSourceMaps(
|
|
19
19
|
file: string,
|
|
20
20
|
originalMap: MixedSourceMap,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -15,11 +15,7 @@ const BOUNDARY = "3beqjf3apnqeu3h5jqorms4i";
|
|
|
15
15
|
|
|
16
16
|
class MultipartResponse {
|
|
17
17
|
static wrap(req, res) {
|
|
18
|
-
if (
|
|
19
|
-
accepts(req)
|
|
20
|
-
.types()
|
|
21
|
-
.includes("multipart/mixed")
|
|
22
|
-
) {
|
|
18
|
+
if (accepts(req).types().includes("multipart/mixed")) {
|
|
23
19
|
return new MultipartResponse(res);
|
|
24
20
|
} // Ugly hack, ideally wrap function should always return a proxy
|
|
25
21
|
// object with the same interface
|
|
@@ -33,7 +29,7 @@ class MultipartResponse {
|
|
|
33
29
|
this.res = res;
|
|
34
30
|
this.headers = {};
|
|
35
31
|
res.writeHead(200, {
|
|
36
|
-
"Content-Type": `multipart/mixed; boundary="${BOUNDARY}"
|
|
32
|
+
"Content-Type": `multipart/mixed; boundary="${BOUNDARY}"`,
|
|
37
33
|
});
|
|
38
34
|
res.write(
|
|
39
35
|
"If you are seeing this, your client does not support multipart response"
|
|
@@ -85,7 +81,7 @@ class MultipartResponse {
|
|
|
85
81
|
|
|
86
82
|
static serializeHeaders(headers) {
|
|
87
83
|
return Object.keys(headers)
|
|
88
|
-
.map(key => `${key}: ${headers[key]}`)
|
|
84
|
+
.map((key) => `${key}: ${headers[key]}`)
|
|
89
85
|
.join(CRLF);
|
|
90
86
|
}
|
|
91
87
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
const { greatestLowerBound } = require("metro-source-map/src/Consumer/search");
|
|
13
13
|
|
|
14
14
|
const {
|
|
15
|
-
SourceMetadataMapConsumer
|
|
15
|
+
SourceMetadataMapConsumer,
|
|
16
16
|
} = require("metro-symbolicate/src/Symbolication");
|
|
17
17
|
|
|
18
18
|
function createFunctionNameGetter(module) {
|
|
@@ -22,16 +22,16 @@ function createFunctionNameGetter(module) {
|
|
|
22
22
|
mappings: "",
|
|
23
23
|
sources: ["dummy"],
|
|
24
24
|
names: [],
|
|
25
|
-
x_facebook_sources: [[module.functionMap]]
|
|
25
|
+
x_facebook_sources: [[module.functionMap]],
|
|
26
26
|
},
|
|
27
|
-
name => name
|
|
27
|
+
(name) => name
|
|
28
28
|
/* no normalization needed */
|
|
29
29
|
);
|
|
30
30
|
return ({ line1Based, column0Based }) =>
|
|
31
31
|
consumer.functionNameFor({
|
|
32
32
|
line: line1Based,
|
|
33
33
|
column: column0Based,
|
|
34
|
-
source: "dummy"
|
|
34
|
+
source: "dummy",
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
|
|
@@ -75,7 +75,7 @@ async function symbolicate(stack, maps, config) {
|
|
|
75
75
|
|
|
76
76
|
const generatedPosInModule = {
|
|
77
77
|
line1Based: frame.lineNumber - module.firstLine1Based + 1,
|
|
78
|
-
column0Based: frame.column
|
|
78
|
+
column0Based: frame.column,
|
|
79
79
|
};
|
|
80
80
|
const mappingIndex = greatestLowerBound(
|
|
81
81
|
module.map,
|
|
@@ -107,7 +107,7 @@ async function symbolicate(stack, maps, config) {
|
|
|
107
107
|
// $FlowFixMe: Length checks do not refine tuple unions.
|
|
108
108
|
line1Based: mapping[2],
|
|
109
109
|
// $FlowFixMe: Length checks do not refine tuple unions.
|
|
110
|
-
column0Based: mapping[3]
|
|
110
|
+
column0Based: mapping[3],
|
|
111
111
|
};
|
|
112
112
|
}
|
|
113
113
|
|
|
@@ -157,7 +157,7 @@ async function symbolicate(stack, maps, config) {
|
|
|
157
157
|
methodName,
|
|
158
158
|
file: module.path,
|
|
159
159
|
lineNumber: originalPos.line1Based,
|
|
160
|
-
column: originalPos.column0Based
|
|
160
|
+
column: originalPos.column0Based,
|
|
161
161
|
};
|
|
162
162
|
}
|
|
163
163
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -9,15 +9,19 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
'use strict';
|
|
12
|
+
import type {
|
|
13
|
+
MetroSourceMapSegmentTuple,
|
|
14
|
+
FBSourceFunctionMap,
|
|
15
|
+
} from '../../../metro-source-map/src/source-map';
|
|
16
|
+
|
|
17
|
+
import type {ExplodedSourceMap} from '../DeltaBundler/Serializers/getExplodedSourceMap';
|
|
18
|
+
import type {ConfigT} from 'metro-config/src/configTypes.flow';
|
|
12
19
|
|
|
13
20
|
const {greatestLowerBound} = require('metro-source-map/src/Consumer/search');
|
|
14
21
|
const {
|
|
15
22
|
SourceMetadataMapConsumer,
|
|
16
23
|
} = require('metro-symbolicate/src/Symbolication');
|
|
17
24
|
|
|
18
|
-
import type {ExplodedSourceMap} from '../DeltaBundler/Serializers/getExplodedSourceMap';
|
|
19
|
-
import type {ConfigT} from 'metro-config/src/configTypes.flow';
|
|
20
|
-
|
|
21
25
|
export type StackFrameInput = {
|
|
22
26
|
+file: ?string,
|
|
23
27
|
+lineNumber: ?number,
|
|
@@ -124,7 +128,15 @@ async function symbolicate(
|
|
|
124
128
|
};
|
|
125
129
|
}
|
|
126
130
|
|
|
127
|
-
function findFunctionName(
|
|
131
|
+
function findFunctionName(
|
|
132
|
+
originalPos: Position,
|
|
133
|
+
module: {
|
|
134
|
+
+firstLine1Based: number,
|
|
135
|
+
+functionMap: ?FBSourceFunctionMap,
|
|
136
|
+
+map: Array<MetroSourceMapSegmentTuple>,
|
|
137
|
+
+path: string,
|
|
138
|
+
},
|
|
139
|
+
): ?string {
|
|
128
140
|
if (module.functionMap) {
|
|
129
141
|
let getFunctionName = functionNameGetters.get(module);
|
|
130
142
|
if (!getFunctionName) {
|