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.
|
|
@@ -17,7 +17,7 @@ const vm = require("vm");
|
|
|
17
17
|
module.exports = function execBundle(code, context = {}) {
|
|
18
18
|
// Verify the code can run on older VMs by parsing it as ES5 (versus ES6+).
|
|
19
19
|
acorn.parse(code, {
|
|
20
|
-
ecmaVersion: 5
|
|
20
|
+
ecmaVersion: 5,
|
|
21
21
|
});
|
|
22
22
|
return vm.runInNewContext(code, context);
|
|
23
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.
|
|
@@ -17,14 +17,14 @@ module.exports = {
|
|
|
17
17
|
maxWorkers: 1,
|
|
18
18
|
projectRoot: ROOT_PATH,
|
|
19
19
|
reporter: {
|
|
20
|
-
update() {}
|
|
20
|
+
update() {},
|
|
21
21
|
},
|
|
22
22
|
watchFolders: [path.resolve(__dirname, "../../../")],
|
|
23
23
|
server: {
|
|
24
|
-
port: 10028
|
|
24
|
+
port: 10028,
|
|
25
25
|
},
|
|
26
26
|
resolver: {
|
|
27
|
-
useWatchman: false
|
|
27
|
+
useWatchman: false,
|
|
28
28
|
},
|
|
29
29
|
transformer: {
|
|
30
30
|
assetRegistryPath: path.join(ROOT_PATH, "AssetRegistry"),
|
|
@@ -39,10 +39,10 @@ module.exports = {
|
|
|
39
39
|
getTransformOptions: async () => ({
|
|
40
40
|
transform: {
|
|
41
41
|
experimentalImportSupport: true,
|
|
42
|
-
inlineRequires: false
|
|
42
|
+
inlineRequires: false,
|
|
43
43
|
},
|
|
44
44
|
preloadedModules: false,
|
|
45
|
-
ramGroups: []
|
|
46
|
-
})
|
|
47
|
-
}
|
|
45
|
+
ramGroups: [],
|
|
46
|
+
}),
|
|
47
|
+
},
|
|
48
48
|
};
|
|
@@ -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.
|
|
@@ -62,7 +62,7 @@ class BatchProcessor {
|
|
|
62
62
|
|
|
63
63
|
const jobs = this._queue.splice(0, this._options.maximumItems);
|
|
64
64
|
|
|
65
|
-
this._processBatch(jobs.map(job => job.item)).then(
|
|
65
|
+
this._processBatch(jobs.map((job) => job.item)).then(
|
|
66
66
|
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
|
67
67
|
this._onBatchResults.bind(this, jobs), // $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
|
68
68
|
this._onBatchError.bind(this, jobs)
|
|
@@ -92,7 +92,7 @@ class BatchProcessor {
|
|
|
92
92
|
this._queue.push({
|
|
93
93
|
item,
|
|
94
94
|
resolve,
|
|
95
|
-
reject
|
|
95
|
+
reject,
|
|
96
96
|
});
|
|
97
97
|
|
|
98
98
|
this._processQueueOnceReady();
|
package/src/lib/JsonReporter.js
CHANGED
|
@@ -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.
|
|
@@ -25,7 +25,7 @@ class JsonReporter {
|
|
|
25
25
|
if (Object.prototype.toString.call(event.error) === "[object Error]") {
|
|
26
26
|
event = Object.assign(event, {
|
|
27
27
|
message: event.error.message,
|
|
28
|
-
stack: event.error.stack
|
|
28
|
+
stack: event.error.stack,
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -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,18 +9,18 @@
|
|
|
9
9
|
*/
|
|
10
10
|
"use strict";
|
|
11
11
|
|
|
12
|
-
const chalk = require("chalk");
|
|
13
|
-
|
|
14
12
|
const logToConsole = require("./logToConsole");
|
|
15
13
|
|
|
16
|
-
const path = require("path");
|
|
17
|
-
|
|
18
14
|
const reporting = require("./reporting");
|
|
19
15
|
|
|
16
|
+
const chalk = require("chalk");
|
|
17
|
+
|
|
20
18
|
const throttle = require("lodash.throttle");
|
|
21
19
|
|
|
22
20
|
const { AmbiguousModuleResolutionError } = require("metro-core");
|
|
23
21
|
|
|
22
|
+
const path = require("path");
|
|
23
|
+
|
|
24
24
|
const GLOBAL_CACHE_DISABLED_MESSAGE_FORMAT =
|
|
25
25
|
"The global cache is now disabled because %s";
|
|
26
26
|
const DARK_BLOCK_CHAR = "\u2593";
|
|
@@ -39,7 +39,7 @@ class TerminalReporter {
|
|
|
39
39
|
*/
|
|
40
40
|
constructor(terminal) {
|
|
41
41
|
this._activeBundles = new Map();
|
|
42
|
-
this._scheduleUpdateBundleProgress = throttle(data => {
|
|
42
|
+
this._scheduleUpdateBundleProgress = throttle((data) => {
|
|
43
43
|
this.update({ ...data, type: "bundle_transform_progressed_throttled" });
|
|
44
44
|
}, 100);
|
|
45
45
|
this.terminal = terminal;
|
|
@@ -56,7 +56,7 @@ class TerminalReporter {
|
|
|
56
56
|
bundleDetails: { entryFile, bundleType, runtimeBytecodeVersion },
|
|
57
57
|
transformedFileCount,
|
|
58
58
|
totalFileCount,
|
|
59
|
-
ratio
|
|
59
|
+
ratio,
|
|
60
60
|
},
|
|
61
61
|
phase
|
|
62
62
|
) {
|
|
@@ -121,7 +121,7 @@ class TerminalReporter {
|
|
|
121
121
|
{
|
|
122
122
|
...progress,
|
|
123
123
|
ratio: 1,
|
|
124
|
-
transformedFileCount: progress.totalFileCount
|
|
124
|
+
transformedFileCount: progress.totalFileCount,
|
|
125
125
|
},
|
|
126
126
|
"done"
|
|
127
127
|
);
|
|
@@ -165,7 +165,7 @@ class TerminalReporter {
|
|
|
165
165
|
" ######### ######### ",
|
|
166
166
|
" ######### ",
|
|
167
167
|
" ",
|
|
168
|
-
" "
|
|
168
|
+
" ",
|
|
169
169
|
];
|
|
170
170
|
const color = hasReducedPerformance ? chalk.red : chalk.blue;
|
|
171
171
|
this.terminal.log(color(logo.join("\n")));
|
|
@@ -291,7 +291,7 @@ class TerminalReporter {
|
|
|
291
291
|
"or fix them: \n\n" +
|
|
292
292
|
Object.keys(he.duplicatesSet)
|
|
293
293
|
.sort()
|
|
294
|
-
.map(dupFilePath => ` * \`${dupFilePath}\`\n`)
|
|
294
|
+
.map((dupFilePath) => ` * \`${dupFilePath}\`\n`)
|
|
295
295
|
.join("");
|
|
296
296
|
reporting.logError(this.terminal, message);
|
|
297
297
|
return;
|
|
@@ -324,7 +324,7 @@ class TerminalReporter {
|
|
|
324
324
|
lines.splice(lines.length - 1, 1);
|
|
325
325
|
}
|
|
326
326
|
|
|
327
|
-
lines.forEach(line => {
|
|
327
|
+
lines.forEach((line) => {
|
|
328
328
|
this.terminal.log(`transform[${origin}]: ${line}`);
|
|
329
329
|
});
|
|
330
330
|
}
|
|
@@ -347,7 +347,7 @@ class TerminalReporter {
|
|
|
347
347
|
Object.assign(currentProgress, {
|
|
348
348
|
ratio,
|
|
349
349
|
transformedFileCount,
|
|
350
|
-
totalFileCount
|
|
350
|
+
totalFileCount,
|
|
351
351
|
});
|
|
352
352
|
}
|
|
353
353
|
/**
|
|
@@ -368,7 +368,7 @@ class TerminalReporter {
|
|
|
368
368
|
bundleDetails: event.bundleDetails,
|
|
369
369
|
transformedFileCount: 0,
|
|
370
370
|
totalFileCount: 1,
|
|
371
|
-
ratio: 0
|
|
371
|
+
ratio: 0,
|
|
372
372
|
};
|
|
373
373
|
|
|
374
374
|
this._activeBundles.set(event.buildID, bundleProgress);
|
|
@@ -392,7 +392,7 @@ class TerminalReporter {
|
|
|
392
392
|
.map(([_, progress]) =>
|
|
393
393
|
this._getBundleStatusMessage(progress, "in_progress")
|
|
394
394
|
)
|
|
395
|
-
.filter(str => str != null)
|
|
395
|
+
.filter((str) => str != null)
|
|
396
396
|
.join("\n");
|
|
397
397
|
}
|
|
398
398
|
|
|
@@ -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,21 +10,20 @@
|
|
|
10
10
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
-
const chalk = require('chalk');
|
|
14
|
-
const logToConsole = require('./logToConsole');
|
|
15
|
-
const path = require('path');
|
|
16
|
-
const reporting = require('./reporting');
|
|
17
|
-
const throttle = require('lodash.throttle');
|
|
18
|
-
|
|
19
|
-
const {AmbiguousModuleResolutionError} = require('metro-core');
|
|
20
|
-
|
|
21
13
|
import type {
|
|
22
14
|
BundleDetails,
|
|
23
|
-
ReportableEvent,
|
|
24
15
|
GlobalCacheDisabledReason,
|
|
16
|
+
ReportableEvent,
|
|
25
17
|
} from './reporting';
|
|
26
18
|
import type {Terminal} from 'metro-core';
|
|
27
19
|
|
|
20
|
+
const logToConsole = require('./logToConsole');
|
|
21
|
+
const reporting = require('./reporting');
|
|
22
|
+
const chalk = require('chalk');
|
|
23
|
+
const throttle = require('lodash.throttle');
|
|
24
|
+
const {AmbiguousModuleResolutionError} = require('metro-core');
|
|
25
|
+
const path = require('path');
|
|
26
|
+
|
|
28
27
|
type BundleProgress = {
|
|
29
28
|
bundleDetails: BundleDetails,
|
|
30
29
|
transformedFileCount: number,
|
|
@@ -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,14 @@
|
|
|
9
9
|
*/
|
|
10
10
|
"use strict";
|
|
11
11
|
|
|
12
|
-
const { getFileLength } = require("metro-hermes-compiler");
|
|
13
|
-
|
|
14
|
-
// The magic number is used as a header for bytecode.
|
|
12
|
+
const { getFileLength } = require("metro-hermes-compiler"); // The magic number is used as a header for bytecode.
|
|
15
13
|
// It represents a Metro tunnel in binary.
|
|
16
14
|
//
|
|
17
15
|
// 11111111
|
|
18
16
|
// 11100111
|
|
19
17
|
// 11000011
|
|
20
18
|
// 11000011
|
|
19
|
+
|
|
21
20
|
const MAGIC_NUMBER = 0xffe7c3c3;
|
|
22
21
|
|
|
23
22
|
function getFileHeader(moduleCount) {
|
|
@@ -71,13 +70,13 @@ function bundleToBytecode(bundle) {
|
|
|
71
70
|
return {
|
|
72
71
|
bytecode: Buffer.concat([
|
|
73
72
|
getFileHeader(buffers.length),
|
|
74
|
-
...buffers.flatMap(addModuleHeader)
|
|
73
|
+
...buffers.flatMap(addModuleHeader),
|
|
75
74
|
]),
|
|
76
75
|
metadata: {
|
|
77
76
|
pre: bundle.pre ? bundle.pre.length : 0,
|
|
78
77
|
post: bundle.post.length,
|
|
79
|
-
modules
|
|
80
|
-
}
|
|
78
|
+
modules,
|
|
79
|
+
},
|
|
81
80
|
};
|
|
82
81
|
}
|
|
83
82
|
|
|
@@ -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,13 +10,13 @@
|
|
|
10
10
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
-
const {getFileLength} = require('metro-hermes-compiler');
|
|
14
|
-
|
|
15
13
|
import type {
|
|
16
|
-
BytecodeBundle,
|
|
17
14
|
BundleMetadata,
|
|
15
|
+
BytecodeBundle,
|
|
18
16
|
} from 'metro-runtime/src/modules/types.flow';
|
|
19
17
|
|
|
18
|
+
const {getFileLength} = require('metro-hermes-compiler');
|
|
19
|
+
|
|
20
20
|
// The magic number is used as a header for bytecode.
|
|
21
21
|
// It represents a Metro tunnel in binary.
|
|
22
22
|
//
|
|
@@ -49,9 +49,10 @@ function addModuleHeader(buffer: Buffer): [Buffer, Buffer] {
|
|
|
49
49
|
* ...
|
|
50
50
|
*
|
|
51
51
|
*/
|
|
52
|
-
function bundleToBytecode(
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
function bundleToBytecode(bundle: BytecodeBundle): {|
|
|
53
|
+
+bytecode: Buffer,
|
|
54
|
+
+metadata: BundleMetadata,
|
|
55
|
+
|} {
|
|
55
56
|
const buffers = [];
|
|
56
57
|
|
|
57
58
|
if (bundle.pre.length) {
|
|
@@ -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.
|
|
@@ -39,8 +39,8 @@ function bundleToString(bundle) {
|
|
|
39
39
|
metadata: {
|
|
40
40
|
pre: bundle.pre.length,
|
|
41
41
|
post: bundle.post.length,
|
|
42
|
-
modules
|
|
43
|
-
}
|
|
42
|
+
modules,
|
|
43
|
+
},
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
46
|
|
|
@@ -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.
|
|
@@ -18,9 +18,10 @@ import type {
|
|
|
18
18
|
/**
|
|
19
19
|
* Serializes a bundle into a plain JS bundle.
|
|
20
20
|
*/
|
|
21
|
-
function bundleToString(
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
function bundleToString(bundle: Bundle): {|
|
|
22
|
+
+code: string,
|
|
23
|
+
+metadata: BundleMetadata,
|
|
24
|
+
|} {
|
|
24
25
|
let code = bundle.pre.length > 0 ? bundle.pre + '\n' : '';
|
|
25
26
|
const modules = [];
|
|
26
27
|
|
package/src/lib/countLines.js
CHANGED
|
@@ -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,12 +9,8 @@
|
|
|
9
9
|
*/
|
|
10
10
|
"use strict";
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const newline = /\r\n?|\n|\u2028|\u2029/g;
|
|
13
13
|
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
function countLines(s) {
|
|
17
|
-
return nullthrows(s.match(reLine)).length;
|
|
18
|
-
}
|
|
14
|
+
const countLines = (string) => (string.match(newline) || []).length + 1;
|
|
19
15
|
|
|
20
16
|
module.exports = countLines;
|
|
@@ -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,12 +10,9 @@
|
|
|
10
10
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
-
const
|
|
13
|
+
const newline = /\r\n?|\n|\u2028|\u2029/g;
|
|
14
14
|
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
function countLines(s: string): number {
|
|
18
|
-
return nullthrows(s.match(reLine)).length;
|
|
19
|
-
}
|
|
15
|
+
const countLines = (string: string): number =>
|
|
16
|
+
(string.match(newline) || []).length + 1;
|
|
20
17
|
|
|
21
18
|
module.exports = countLines;
|
|
@@ -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
|
function createModuleIdFactory() {
|
|
13
13
|
const fileToIdMap = new Map();
|
|
14
14
|
let nextId = 0;
|
|
15
|
-
return path => {
|
|
15
|
+
return (path) => {
|
|
16
16
|
let id = fileToIdMap.get(path);
|
|
17
17
|
|
|
18
18
|
if (typeof id !== "number") {
|
|
@@ -1,5 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _ws = _interopRequireDefault(require("ws"));
|
|
4
|
+
|
|
5
|
+
function _interopRequireDefault(obj) {
|
|
6
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
7
|
+
}
|
|
8
|
+
|
|
1
9
|
/**
|
|
2
|
-
* Copyright (c)
|
|
10
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
11
|
*
|
|
4
12
|
* This source code is licensed under the MIT license found in the
|
|
5
13
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -7,10 +15,9 @@
|
|
|
7
15
|
*
|
|
8
16
|
* @format
|
|
9
17
|
*/
|
|
10
|
-
"use strict";
|
|
11
18
|
|
|
12
19
|
/**
|
|
13
|
-
*
|
|
20
|
+
* Returns a WebSocketServer to be attached to an existing HTTP instance. It forwards
|
|
14
21
|
* the received events on the given "websocketServer" parameter. It must be an
|
|
15
22
|
* object with the following fields:
|
|
16
23
|
*
|
|
@@ -19,20 +26,13 @@
|
|
|
19
26
|
* - onClientMessage
|
|
20
27
|
* - onClientDisconnect
|
|
21
28
|
*/
|
|
22
|
-
module.exports = function
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
path
|
|
26
|
-
}) {
|
|
27
|
-
const WebSocketServer = require("ws").Server;
|
|
28
|
-
|
|
29
|
-
const wss = new WebSocketServer({
|
|
30
|
-
server: httpServer,
|
|
31
|
-
path
|
|
29
|
+
module.exports = function createWebsocketServer({ websocketServer }) {
|
|
30
|
+
const wss = new _ws.default.Server({
|
|
31
|
+
noServer: true,
|
|
32
32
|
});
|
|
33
|
-
wss.on("connection", async ws => {
|
|
33
|
+
wss.on("connection", async (ws, req) => {
|
|
34
34
|
let connected = true;
|
|
35
|
-
const url =
|
|
35
|
+
const url = req.url;
|
|
36
36
|
|
|
37
37
|
const sendFn = (...args) => {
|
|
38
38
|
if (connected) {
|
|
@@ -47,7 +47,7 @@ module.exports = function attachWebsocketServer({
|
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
ws.on("error", e => {
|
|
50
|
+
ws.on("error", (e) => {
|
|
51
51
|
websocketServer.onClientError && websocketServer.onClientError(client, e);
|
|
52
52
|
});
|
|
53
53
|
ws.on("close", () => {
|
|
@@ -55,9 +55,10 @@ module.exports = function attachWebsocketServer({
|
|
|
55
55
|
websocketServer.onClientDisconnect(client);
|
|
56
56
|
connected = false;
|
|
57
57
|
});
|
|
58
|
-
ws.on("message", message => {
|
|
58
|
+
ws.on("message", (message) => {
|
|
59
59
|
websocketServer.onClientMessage &&
|
|
60
60
|
websocketServer.onClientMessage(client, message, sendFn);
|
|
61
61
|
});
|
|
62
62
|
});
|
|
63
|
+
return wss;
|
|
63
64
|
};
|
|
@@ -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.
|
|
@@ -8,18 +8,14 @@
|
|
|
8
8
|
* @format
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
import type {Server as HttpServer} from 'http';
|
|
14
|
-
import type {Server as HttpsServer} from 'https';
|
|
15
|
-
|
|
11
|
+
import ws from 'ws';
|
|
16
12
|
type WebsocketServiceInterface<T> = interface {
|
|
17
13
|
+onClientConnect: (
|
|
18
14
|
url: string,
|
|
19
15
|
sendFn: (data: string) => void,
|
|
20
16
|
) => Promise<?T>,
|
|
21
17
|
+onClientDisconnect?: (client: T) => mixed,
|
|
22
|
-
+onClientError?: (client: T, e:
|
|
18
|
+
+onClientError?: (client: T, e: ErrorEvent) => mixed,
|
|
23
19
|
+onClientMessage?: (
|
|
24
20
|
client: T,
|
|
25
21
|
message: string,
|
|
@@ -28,14 +24,12 @@ type WebsocketServiceInterface<T> = interface {
|
|
|
28
24
|
};
|
|
29
25
|
|
|
30
26
|
type HMROptions<TClient> = {
|
|
31
|
-
httpServer: HttpServer | HttpsServer,
|
|
32
27
|
websocketServer: WebsocketServiceInterface<TClient>,
|
|
33
|
-
path: string,
|
|
34
28
|
...
|
|
35
29
|
};
|
|
36
30
|
|
|
37
31
|
/**
|
|
38
|
-
*
|
|
32
|
+
* Returns a WebSocketServer to be attached to an existing HTTP instance. It forwards
|
|
39
33
|
* the received events on the given "websocketServer" parameter. It must be an
|
|
40
34
|
* object with the following fields:
|
|
41
35
|
*
|
|
@@ -45,22 +39,18 @@ type HMROptions<TClient> = {
|
|
|
45
39
|
* - onClientDisconnect
|
|
46
40
|
*/
|
|
47
41
|
|
|
48
|
-
module.exports = function
|
|
49
|
-
httpServer,
|
|
42
|
+
module.exports = function createWebsocketServer<TClient: Object>({
|
|
50
43
|
websocketServer,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const wss = new WebSocketServer({
|
|
55
|
-
server: httpServer,
|
|
56
|
-
path,
|
|
44
|
+
}: HMROptions<TClient>): typeof ws.Server {
|
|
45
|
+
const wss = new ws.Server({
|
|
46
|
+
noServer: true,
|
|
57
47
|
});
|
|
58
48
|
|
|
59
|
-
wss.on('connection', async ws => {
|
|
49
|
+
wss.on('connection', async (ws, req) => {
|
|
60
50
|
let connected = true;
|
|
61
|
-
const url =
|
|
51
|
+
const url = req.url;
|
|
62
52
|
|
|
63
|
-
const sendFn = (...args) => {
|
|
53
|
+
const sendFn = (...args: Array<string>) => {
|
|
64
54
|
if (connected) {
|
|
65
55
|
ws.send(...args);
|
|
66
56
|
}
|
|
@@ -88,4 +78,5 @@ module.exports = function attachWebsocketServer<TClient: Object>({
|
|
|
88
78
|
websocketServer.onClientMessage(client, message, sendFn);
|
|
89
79
|
});
|
|
90
80
|
});
|
|
81
|
+
return wss;
|
|
91
82
|
};
|
|
@@ -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.
|
|
@@ -21,7 +21,7 @@ function debounceAsyncQueue(fn, delay) {
|
|
|
21
21
|
callbacks = [];
|
|
22
22
|
executing = true;
|
|
23
23
|
const res = await fn();
|
|
24
|
-
currentCallbacks.forEach(c => c(res));
|
|
24
|
+
currentCallbacks.forEach((c) => c(res));
|
|
25
25
|
executing = false;
|
|
26
26
|
|
|
27
27
|
if (callbacks.length > 0) {
|