metro 0.65.2 → 0.67.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 +27 -27
- package/src/Assets.js +9 -9
- package/src/Assets.js.flow +5 -7
- package/src/Bundler/util.js +17 -15
- package/src/Bundler/util.js.flow +12 -10
- package/src/Bundler.js +22 -9
- package/src/Bundler.js.flow +20 -7
- package/src/DeltaBundler/DeltaCalculator.js +17 -15
- package/src/DeltaBundler/DeltaCalculator.js.flow +9 -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 +18 -8
- package/src/DeltaBundler/Serializers/helpers/js.js.flow +19 -10
- 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 +16 -14
- package/src/DeltaBundler/Transformer.js.flow +15 -15
- package/src/DeltaBundler/Worker.js +8 -11
- package/src/DeltaBundler/Worker.js.flow +8 -11
- package/src/DeltaBundler/WorkerFarm.js +15 -18
- package/src/DeltaBundler/WorkerFarm.js.flow +9 -11
- 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 +15 -1
- package/src/DeltaBundler.js +5 -5
- package/src/DeltaBundler.js.flow +4 -4
- package/src/HmrServer.js +73 -55
- package/src/HmrServer.js.flow +42 -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 +46 -32
- package/src/IncrementalBundler.js.flow +32 -24
- package/src/ModuleGraph/module.js +3 -3
- package/src/ModuleGraph/module.js.flow +1 -1
- package/src/ModuleGraph/node-haste/HasteFS.js +5 -3
- package/src/ModuleGraph/node-haste/HasteFS.js.flow +3 -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 +41 -31
- package/src/ModuleGraph/node-haste/node-haste.js.flow +28 -22
- 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 +61 -40
- package/src/ModuleGraph/output/util.js.flow +51 -28
- 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 +47 -31
- package/src/ModuleGraph/worker/JsFileWrapping.js +16 -16
- 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 +16 -18
- 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 +204 -150
- package/src/Server.js.flow +131 -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 +19 -19
- package/src/commands/serve.js.flow +7 -9
- package/src/index.js +117 -50
- package/src/index.js.flow +108 -40
- 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 +2 -2
- package/src/integration_tests/basic_bundle/TestBundle.js.flow +1 -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 +17 -17
- 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 +10 -6
- package/src/lib/BatchProcessor.js.flow +6 -1
- package/src/lib/JsonReporter.js +3 -2
- package/src/lib/JsonReporter.js.flow +2 -1
- package/src/lib/RamBundleParser.js +1 -1
- package/src/lib/RamBundleParser.js.flow +1 -1
- package/src/lib/TerminalReporter.js +15 -15
- package/src/lib/TerminalReporter.js.flow +15 -16
- 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} +13 -23
- 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 +18 -20
- 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 +16 -15
- package/src/lib/getPrependedScripts.js.flow +8 -8
- package/src/lib/logToConsole.js +12 -5
- package/src/lib/logToConsole.js.flow +19 -6
- 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 +18 -4
- package/src/lib/splitBundleOptions.js +5 -5
- package/src/lib/splitBundleOptions.js.flow +1 -1
- package/src/lib/transformHelpers.js +11 -10
- package/src/lib/transformHelpers.js.flow +6 -13
- package/src/node-haste/DependencyGraph/ModuleResolution.js +51 -30
- package/src/node-haste/DependencyGraph/ModuleResolution.js.flow +49 -48
- 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 +51 -118
- package/src/node-haste/DependencyGraph.js.flow +38 -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 +2 -2
- package/src/node-haste/Package.js.flow +1 -1
- package/src/node-haste/lib/AssetPaths.js +5 -5
- package/src/node-haste/lib/AssetPaths.js.flow +7 -6
- package/src/node-haste/lib/parsePlatformFilePath.js +4 -4
- package/src/node-haste/lib/parsePlatformFilePath.js.flow +2 -2
- package/src/shared/output/RamBundle/as-assets.js +14 -15
- package/src/shared/output/RamBundle/as-assets.js.flow +9 -11
- 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 +6 -4
- 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,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,35 +8,28 @@
|
|
|
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
|
-
|
|
16
|
-
type WebsocketServiceInterface<T> = {
|
|
11
|
+
import ws from 'ws';
|
|
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,
|
|
26
22
|
sendFn: (data: string) => void,
|
|
27
23
|
) => mixed,
|
|
28
|
-
...
|
|
29
24
|
};
|
|
30
25
|
|
|
31
26
|
type HMROptions<TClient> = {
|
|
32
|
-
httpServer: HttpServer | HttpsServer,
|
|
33
27
|
websocketServer: WebsocketServiceInterface<TClient>,
|
|
34
|
-
path: string,
|
|
35
28
|
...
|
|
36
29
|
};
|
|
37
30
|
|
|
38
31
|
/**
|
|
39
|
-
*
|
|
32
|
+
* Returns a WebSocketServer to be attached to an existing HTTP instance. It forwards
|
|
40
33
|
* the received events on the given "websocketServer" parameter. It must be an
|
|
41
34
|
* object with the following fields:
|
|
42
35
|
*
|
|
@@ -46,22 +39,18 @@ type HMROptions<TClient> = {
|
|
|
46
39
|
* - onClientDisconnect
|
|
47
40
|
*/
|
|
48
41
|
|
|
49
|
-
module.exports = function
|
|
50
|
-
httpServer,
|
|
42
|
+
module.exports = function createWebsocketServer<TClient: Object>({
|
|
51
43
|
websocketServer,
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const wss = new WebSocketServer({
|
|
56
|
-
server: httpServer,
|
|
57
|
-
path,
|
|
44
|
+
}: HMROptions<TClient>): typeof ws.Server {
|
|
45
|
+
const wss = new ws.Server({
|
|
46
|
+
noServer: true,
|
|
58
47
|
});
|
|
59
48
|
|
|
60
|
-
wss.on('connection', async ws => {
|
|
49
|
+
wss.on('connection', async (ws, req) => {
|
|
61
50
|
let connected = true;
|
|
62
|
-
const url =
|
|
51
|
+
const url = req.url;
|
|
63
52
|
|
|
64
|
-
const sendFn = (...args) => {
|
|
53
|
+
const sendFn = (...args: Array<string>) => {
|
|
65
54
|
if (connected) {
|
|
66
55
|
ws.send(...args);
|
|
67
56
|
}
|
|
@@ -89,4 +78,5 @@ module.exports = function attachWebsocketServer<TClient: Object>({
|
|
|
89
78
|
websocketServer.onClientMessage(client, message, sendFn);
|
|
90
79
|
});
|
|
91
80
|
});
|
|
81
|
+
return wss;
|
|
92
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) {
|
|
@@ -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,26 +9,26 @@
|
|
|
9
9
|
*/
|
|
10
10
|
"use strict";
|
|
11
11
|
|
|
12
|
-
const ErrorStackParser = require("error-stack-parser");
|
|
13
|
-
|
|
14
12
|
const GraphNotFoundError = require("../IncrementalBundler/GraphNotFoundError");
|
|
15
13
|
|
|
16
14
|
const ResourceNotFoundError = require("../IncrementalBundler/ResourceNotFoundError");
|
|
17
15
|
|
|
18
16
|
const RevisionNotFoundError = require("../IncrementalBundler/RevisionNotFoundError");
|
|
19
17
|
|
|
20
|
-
const fs = require("fs");
|
|
21
|
-
|
|
22
|
-
const serializeError = require("serialize-error");
|
|
23
|
-
|
|
24
18
|
const {
|
|
25
|
-
UnableToResolveError
|
|
19
|
+
UnableToResolveError,
|
|
26
20
|
} = require("../node-haste/DependencyGraph/ModuleResolution");
|
|
27
21
|
|
|
28
22
|
const { codeFrameColumns } = require("@babel/code-frame");
|
|
29
23
|
|
|
24
|
+
const ErrorStackParser = require("error-stack-parser");
|
|
25
|
+
|
|
26
|
+
const fs = require("fs");
|
|
27
|
+
|
|
30
28
|
const { AmbiguousModuleResolutionError } = require("metro-core");
|
|
31
29
|
|
|
30
|
+
const serializeError = require("serialize-error");
|
|
31
|
+
|
|
32
32
|
function formatBundlingError(error) {
|
|
33
33
|
if (error instanceof AmbiguousModuleResolutionError) {
|
|
34
34
|
const he = error.hasteError;
|
|
@@ -39,16 +39,16 @@ function formatBundlingError(error) {
|
|
|
39
39
|
"fix them: \n\n" +
|
|
40
40
|
Object.keys(he.duplicatesSet)
|
|
41
41
|
.sort()
|
|
42
|
-
.map(dupFilePath => `${dupFilePath}`)
|
|
42
|
+
.map((dupFilePath) => `${dupFilePath}`)
|
|
43
43
|
.join("\n\n");
|
|
44
44
|
return {
|
|
45
45
|
type: "AmbiguousModuleResolutionError",
|
|
46
46
|
message,
|
|
47
47
|
errors: [
|
|
48
48
|
{
|
|
49
|
-
description: message
|
|
50
|
-
}
|
|
51
|
-
]
|
|
49
|
+
description: message,
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
54
|
|
|
@@ -61,27 +61,27 @@ function formatBundlingError(error) {
|
|
|
61
61
|
{
|
|
62
62
|
description: error.message,
|
|
63
63
|
filename: error.filename,
|
|
64
|
-
lineNumber: error.lineNumber
|
|
65
|
-
}
|
|
64
|
+
lineNumber: error.lineNumber,
|
|
65
|
+
},
|
|
66
66
|
];
|
|
67
67
|
return serializeError(error);
|
|
68
68
|
} else if (error instanceof ResourceNotFoundError) {
|
|
69
69
|
return {
|
|
70
70
|
type: "ResourceNotFoundError",
|
|
71
71
|
errors: [],
|
|
72
|
-
message: error.message
|
|
72
|
+
message: error.message,
|
|
73
73
|
};
|
|
74
74
|
} else if (error instanceof GraphNotFoundError) {
|
|
75
75
|
return {
|
|
76
76
|
type: "GraphNotFoundError",
|
|
77
77
|
errors: [],
|
|
78
|
-
message: error.message
|
|
78
|
+
message: error.message,
|
|
79
79
|
};
|
|
80
80
|
} else if (error instanceof RevisionNotFoundError) {
|
|
81
81
|
return {
|
|
82
82
|
type: "RevisionNotFoundError",
|
|
83
83
|
errors: [],
|
|
84
|
-
message: error.message
|
|
84
|
+
message: error.message,
|
|
85
85
|
};
|
|
86
86
|
} else {
|
|
87
87
|
const stack = ErrorStackParser.parse(error);
|
|
@@ -97,11 +97,11 @@ function formatBundlingError(error) {
|
|
|
97
97
|
{
|
|
98
98
|
start: {
|
|
99
99
|
column,
|
|
100
|
-
line
|
|
101
|
-
}
|
|
100
|
+
line,
|
|
101
|
+
},
|
|
102
102
|
},
|
|
103
103
|
{
|
|
104
|
-
forceColor: true
|
|
104
|
+
forceColor: true,
|
|
105
105
|
}
|
|
106
106
|
);
|
|
107
107
|
} catch {}
|
|
@@ -109,7 +109,7 @@ function formatBundlingError(error) {
|
|
|
109
109
|
return {
|
|
110
110
|
type: "InternalError",
|
|
111
111
|
errors: [],
|
|
112
|
-
message: `Metro has encountered an error: ${error.message}: ${fileName} (${line}:${column})\n\n${codeFrame}
|
|
112
|
+
message: `Metro has encountered an error: ${error.message}: ${fileName} (${line}:${column})\n\n${codeFrame}`,
|
|
113
113
|
};
|
|
114
114
|
}
|
|
115
115
|
}
|
|
@@ -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,34 +10,32 @@
|
|
|
10
10
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
import type {FormattedError} from 'metro-runtime/src/modules/types.flow';
|
|
14
|
+
|
|
14
15
|
const GraphNotFoundError = require('../IncrementalBundler/GraphNotFoundError');
|
|
15
16
|
const ResourceNotFoundError = require('../IncrementalBundler/ResourceNotFoundError');
|
|
16
17
|
const RevisionNotFoundError = require('../IncrementalBundler/RevisionNotFoundError');
|
|
17
|
-
|
|
18
|
-
const fs = require('fs');
|
|
19
|
-
const serializeError = require('serialize-error');
|
|
20
|
-
|
|
21
18
|
const {
|
|
22
19
|
UnableToResolveError,
|
|
23
20
|
} = require('../node-haste/DependencyGraph/ModuleResolution');
|
|
24
21
|
const {codeFrameColumns} = require('@babel/code-frame');
|
|
22
|
+
const ErrorStackParser = require('error-stack-parser');
|
|
23
|
+
const fs = require('fs');
|
|
25
24
|
const {AmbiguousModuleResolutionError} = require('metro-core');
|
|
25
|
+
const serializeError = require('serialize-error');
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
...
|
|
40
|
-
};
|
|
27
|
+
export type CustomError = Error &
|
|
28
|
+
interface {
|
|
29
|
+
type?: string,
|
|
30
|
+
filename?: string,
|
|
31
|
+
lineNumber?: number,
|
|
32
|
+
errors?: Array<{
|
|
33
|
+
description: string,
|
|
34
|
+
filename: string,
|
|
35
|
+
lineNumber: number,
|
|
36
|
+
...
|
|
37
|
+
}>,
|
|
38
|
+
};
|
|
41
39
|
|
|
42
40
|
function formatBundlingError(error: CustomError): FormattedError {
|
|
43
41
|
if (error instanceof AmbiguousModuleResolutionError) {
|
|
@@ -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,26 +9,25 @@
|
|
|
9
9
|
*/
|
|
10
10
|
"use strict";
|
|
11
11
|
|
|
12
|
-
const countLines = require("./countLines");
|
|
13
|
-
|
|
14
12
|
const getInlineSourceMappingURL = require("../DeltaBundler/Serializers/helpers/getInlineSourceMappingURL");
|
|
15
13
|
|
|
14
|
+
const sourceMapString = require("../DeltaBundler/Serializers/sourceMapString");
|
|
15
|
+
|
|
16
|
+
const countLines = require("./countLines");
|
|
17
|
+
|
|
16
18
|
const nullthrows = require("nullthrows");
|
|
17
19
|
|
|
18
20
|
const path = require("path");
|
|
19
21
|
|
|
20
|
-
const sourceMapString = require("../DeltaBundler/Serializers/sourceMapString");
|
|
21
|
-
|
|
22
22
|
function getAppendScripts(entryPoint, modules, importBundleNames, options) {
|
|
23
23
|
const output = [];
|
|
24
24
|
|
|
25
25
|
if (importBundleNames.size) {
|
|
26
26
|
const importBundleNamesObject = Object.create(null);
|
|
27
|
-
importBundleNames.forEach(absolutePath => {
|
|
27
|
+
importBundleNames.forEach((absolutePath) => {
|
|
28
28
|
const bundlePath = path.relative(options.projectRoot, absolutePath);
|
|
29
|
-
importBundleNamesObject[
|
|
30
|
-
|
|
31
|
-
] = bundlePath.slice(0, -path.extname(bundlePath).length);
|
|
29
|
+
importBundleNamesObject[options.createModuleId(absolutePath)] =
|
|
30
|
+
bundlePath.slice(0, -path.extname(bundlePath).length);
|
|
32
31
|
});
|
|
33
32
|
const code = `(function(){var $$=${options.getRunModuleStatement(
|
|
34
33
|
options.createModuleId(options.asyncRequireModulePath)
|
|
@@ -46,10 +45,10 @@ function getAppendScripts(entryPoint, modules, importBundleNames, options) {
|
|
|
46
45
|
data: {
|
|
47
46
|
code,
|
|
48
47
|
lineCount: countLines(code),
|
|
49
|
-
map: []
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
]
|
|
48
|
+
map: [],
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
],
|
|
53
52
|
});
|
|
54
53
|
}
|
|
55
54
|
|
|
@@ -57,7 +56,7 @@ function getAppendScripts(entryPoint, modules, importBundleNames, options) {
|
|
|
57
56
|
const paths = [...options.runBeforeMainModule, entryPoint];
|
|
58
57
|
|
|
59
58
|
for (const path of paths) {
|
|
60
|
-
if (modules.some(module => module.path === path)) {
|
|
59
|
+
if (modules.some((module) => module.path === path)) {
|
|
61
60
|
const code = options.getRunModuleStatement(
|
|
62
61
|
options.createModuleId(path)
|
|
63
62
|
);
|
|
@@ -72,10 +71,10 @@ function getAppendScripts(entryPoint, modules, importBundleNames, options) {
|
|
|
72
71
|
data: {
|
|
73
72
|
code,
|
|
74
73
|
lineCount: countLines(code),
|
|
75
|
-
map: []
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
]
|
|
74
|
+
map: [],
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
],
|
|
79
78
|
});
|
|
80
79
|
}
|
|
81
80
|
}
|
|
@@ -86,7 +85,7 @@ function getAppendScripts(entryPoint, modules, importBundleNames, options) {
|
|
|
86
85
|
? getInlineSourceMappingURL(
|
|
87
86
|
sourceMapString(modules, {
|
|
88
87
|
processModuleFilter: () => true,
|
|
89
|
-
excludeSource: false
|
|
88
|
+
excludeSource: false,
|
|
90
89
|
})
|
|
91
90
|
)
|
|
92
91
|
: nullthrows(options.sourceMapUrl);
|
|
@@ -102,10 +101,10 @@ function getAppendScripts(entryPoint, modules, importBundleNames, options) {
|
|
|
102
101
|
data: {
|
|
103
102
|
code,
|
|
104
103
|
lineCount: countLines(code),
|
|
105
|
-
map: []
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
]
|
|
104
|
+
map: [],
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
],
|
|
109
108
|
});
|
|
110
109
|
}
|
|
111
110
|
|
|
@@ -122,10 +121,10 @@ function getAppendScripts(entryPoint, modules, importBundleNames, options) {
|
|
|
122
121
|
data: {
|
|
123
122
|
code,
|
|
124
123
|
lineCount: countLines(code),
|
|
125
|
-
map: []
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
]
|
|
124
|
+
map: [],
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
],
|
|
129
128
|
});
|
|
130
129
|
}
|
|
131
130
|
|
|
@@ -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
|
-
|
|
13
|
+
import type {Module} from '../DeltaBundler';
|
|
14
|
+
|
|
14
15
|
const getInlineSourceMappingURL = require('../DeltaBundler/Serializers/helpers/getInlineSourceMappingURL');
|
|
16
|
+
const sourceMapString = require('../DeltaBundler/Serializers/sourceMapString');
|
|
17
|
+
const countLines = require('./countLines');
|
|
15
18
|
const nullthrows = require('nullthrows');
|
|
16
19
|
const path = require('path');
|
|
17
|
-
const sourceMapString = require('../DeltaBundler/Serializers/sourceMapString');
|
|
18
|
-
|
|
19
|
-
import type {Module} from '../DeltaBundler';
|
|
20
20
|
|
|
21
21
|
type Options<T: number | string> = {
|
|
22
22
|
+asyncRequireModulePath: string,
|
|
@@ -43,9 +43,8 @@ function getAppendScripts<T: number | string>(
|
|
|
43
43
|
const importBundleNamesObject = Object.create(null);
|
|
44
44
|
importBundleNames.forEach(absolutePath => {
|
|
45
45
|
const bundlePath = path.relative(options.projectRoot, absolutePath);
|
|
46
|
-
importBundleNamesObject[
|
|
47
|
-
|
|
48
|
-
] = bundlePath.slice(0, -path.extname(bundlePath).length);
|
|
46
|
+
importBundleNamesObject[options.createModuleId(absolutePath)] =
|
|
47
|
+
bundlePath.slice(0, -path.extname(bundlePath).length);
|
|
49
48
|
});
|
|
50
49
|
const code = `(function(){var $$=${options.getRunModuleStatement(
|
|
51
50
|
options.createModuleId(options.asyncRequireModulePath),
|
package/src/lib/getGraphId.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.
|
|
@@ -35,8 +35,8 @@ function getGraphId(
|
|
|
35
35
|
experimentalImportBundleSupport,
|
|
36
36
|
shallow,
|
|
37
37
|
unstable_transformProfile:
|
|
38
|
-
options.unstable_transformProfile || "default"
|
|
39
|
-
}
|
|
38
|
+
options.unstable_transformProfile || "default",
|
|
39
|
+
},
|
|
40
40
|
},
|
|
41
41
|
canonicalize
|
|
42
42
|
);
|
|
@@ -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,9 +10,9 @@
|
|
|
10
10
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
import type {TransformInputOptions} from '../DeltaBundler/types.flow';
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
const canonicalize = require('metro-core/src/canonicalize');
|
|
16
16
|
|
|
17
17
|
export opaque type GraphId: string = string;
|
|
18
18
|
|
package/src/lib/getMaxWorkers.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.
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
const os = require("os");
|
|
13
13
|
|
|
14
|
-
module.exports = workers => {
|
|
14
|
+
module.exports = (workers) => {
|
|
15
15
|
const cores = os.cpus().length;
|
|
16
16
|
return typeof workers === "number" && Number.isInteger(workers)
|
|
17
17
|
? Math.min(cores, workers > 0 ? workers : 1)
|
|
@@ -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,7 +15,7 @@ function getPreludeCode({ extraVars, isDev, globalPrefix }) {
|
|
|
15
15
|
`__DEV__=${String(isDev)}`,
|
|
16
16
|
...formatExtraVars(extraVars),
|
|
17
17
|
"process=this.process||{}",
|
|
18
|
-
`__METRO_GLOBAL_PREFIX__='${globalPrefix}'
|
|
18
|
+
`__METRO_GLOBAL_PREFIX__='${globalPrefix}'`,
|
|
19
19
|
];
|
|
20
20
|
return `var ${vars.join(",")};${processEnv(
|
|
21
21
|
isDev ? "development" : "production"
|