metro 0.83.3 → 0.83.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +28 -24
- package/src/Assets.d.ts +83 -0
- package/src/Assets.js +42 -29
- package/src/Assets.js.flow +26 -15
- package/src/Bundler/util.d.ts +27 -0
- package/src/Bundler/util.js +25 -21
- package/src/Bundler/util.js.flow +2 -2
- package/src/Bundler.d.ts +14 -15
- package/src/Bundler.js.flow +1 -1
- package/src/DeltaBundler/DeltaCalculator.d.ts +71 -0
- package/src/DeltaBundler/DeltaCalculator.js +4 -4
- package/src/DeltaBundler/DeltaCalculator.js.flow +8 -8
- package/src/DeltaBundler/Graph.d.ts +135 -8
- package/src/DeltaBundler/Graph.js +16 -16
- package/src/DeltaBundler/Graph.js.flow +30 -30
- package/src/DeltaBundler/Serializers/baseJSBundle.d.ts +20 -0
- package/src/DeltaBundler/Serializers/baseJSBundle.js.flow +1 -1
- package/src/DeltaBundler/Serializers/getAllFiles.d.ts +22 -0
- package/src/DeltaBundler/Serializers/getAllFiles.js.flow +2 -2
- package/src/DeltaBundler/Serializers/getAssets.d.ts +25 -0
- package/src/DeltaBundler/Serializers/getAssets.js.flow +2 -2
- package/src/DeltaBundler/Serializers/getExplodedSourceMap.js.flow +2 -2
- package/src/DeltaBundler/Serializers/getRamBundleInfo.d.ts +36 -6
- package/src/DeltaBundler/Serializers/getRamBundleInfo.js.flow +8 -8
- package/src/DeltaBundler/Serializers/helpers/getInlineSourceMappingURL.d.ts +12 -0
- package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.d.ts +33 -0
- package/src/DeltaBundler/Serializers/helpers/getTransitiveDependencies.d.ts +17 -0
- package/src/DeltaBundler/Serializers/helpers/js.d.ts +30 -0
- package/src/DeltaBundler/Serializers/helpers/js.js +25 -21
- package/src/DeltaBundler/Serializers/helpers/js.js.flow +6 -6
- package/src/DeltaBundler/Serializers/helpers/processModules.d.ts +25 -0
- package/src/DeltaBundler/Serializers/helpers/processModules.js.flow +3 -3
- package/src/DeltaBundler/Serializers/hmrJSBundle.d.ts +30 -0
- package/src/DeltaBundler/Serializers/hmrJSBundle.js +25 -21
- package/src/DeltaBundler/Serializers/hmrJSBundle.js.flow +5 -5
- package/src/DeltaBundler/Serializers/sourceMapGenerator.d.ts +29 -0
- package/src/DeltaBundler/Serializers/sourceMapGenerator.js.flow +6 -6
- package/src/DeltaBundler/Serializers/sourceMapObject.d.ts +23 -0
- package/src/DeltaBundler/Serializers/sourceMapObject.js.flow +2 -2
- package/src/DeltaBundler/Serializers/sourceMapString.d.ts +22 -0
- package/src/DeltaBundler/Serializers/sourceMapString.js.flow +2 -2
- package/src/DeltaBundler/Transformer.d.ts +38 -0
- package/src/DeltaBundler/Transformer.js.flow +3 -3
- package/src/DeltaBundler/Worker.d.ts +19 -27
- package/src/DeltaBundler/Worker.flow.js.flow +1 -1
- package/src/DeltaBundler/WorkerFarm.d.ts +70 -0
- package/src/DeltaBundler/WorkerFarm.js +1 -1
- package/src/DeltaBundler/WorkerFarm.js.flow +26 -13
- package/src/DeltaBundler/buildSubgraph.d.ts +30 -0
- package/src/DeltaBundler/buildSubgraph.js +4 -4
- package/src/DeltaBundler/buildSubgraph.js.flow +8 -8
- package/src/DeltaBundler/getTransformCacheKey.d.ts +18 -0
- package/src/DeltaBundler/mergeDeltas.d.ts +17 -0
- package/src/DeltaBundler/types.d.ts +97 -100
- package/src/DeltaBundler/types.js.flow +36 -34
- package/src/DeltaBundler.d.ts +14 -12
- package/src/DeltaBundler.js.flow +2 -2
- package/src/HmrServer.d.ts +79 -0
- package/src/HmrServer.js +34 -29
- package/src/HmrServer.js.flow +17 -12
- package/src/IncrementalBundler/GraphNotFoundError.d.ts +17 -0
- package/src/IncrementalBundler/ResourceNotFoundError.d.ts +15 -0
- package/src/IncrementalBundler/RevisionNotFoundError.d.ts +17 -0
- package/src/IncrementalBundler.d.ts +43 -45
- package/src/IncrementalBundler.js +29 -21
- package/src/IncrementalBundler.js.flow +13 -9
- package/src/ModuleGraph/worker/JsFileWrapping.d.ts +29 -0
- package/src/ModuleGraph/worker/JsFileWrapping.js +25 -21
- package/src/ModuleGraph/worker/JsFileWrapping.js.flow +10 -5
- package/src/ModuleGraph/worker/collectDependencies.d.ts +118 -14
- package/src/ModuleGraph/worker/collectDependencies.js +25 -21
- package/src/ModuleGraph/worker/collectDependencies.js.flow +27 -21
- package/src/ModuleGraph/worker/generateImportNames.d.ts +19 -0
- package/src/ModuleGraph/worker/generateImportNames.js.flow +4 -2
- package/src/ModuleGraph/worker/importLocationsPlugin.d.ts +26 -0
- package/src/ModuleGraph/worker/importLocationsPlugin.js.flow +7 -3
- package/src/Server/MultipartResponse.d.ts +5 -6
- package/src/Server/MultipartResponse.js.flow +1 -1
- package/src/Server/symbolicate.js.flow +4 -4
- package/src/Server.d.ts +220 -67
- package/src/Server.js +149 -45
- package/src/Server.js.flow +167 -57
- package/src/cli/parseKeyValueParamArray.d.ts +14 -0
- package/src/cli/parseKeyValueParamArray.js.flow +1 -1
- package/src/cli-utils.d.ts +19 -0
- package/src/cli-utils.js.flow +2 -2
- package/src/commands/build.d.ts +16 -0
- package/src/commands/build.js.flow +11 -10
- package/src/commands/dependencies.d.ts +16 -0
- package/src/commands/dependencies.js.flow +8 -4
- package/src/commands/serve.d.ts +16 -0
- package/src/commands/serve.js +2 -0
- package/src/commands/serve.js.flow +14 -9
- package/src/index.d.ts +97 -110
- package/src/index.flow.js +53 -35
- package/src/index.flow.js.flow +49 -29
- package/src/integration_tests/basic_bundle/AssetRegistry.js.flow +1 -1
- package/src/integration_tests/basic_bundle/ErrorBundle.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-import.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-multi-line-import-with-escapes.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-multi-line-import.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-require-with-embedded-comment.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-require.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-specifier-with-escapes.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/inline-requires-cannot-resolve-import.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/inline-requires-cannot-resolve-require.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/index.js +25 -21
- package/src/integration_tests/basic_bundle/import-export/index.js.flow +3 -3
- package/src/integration_tests/basic_bundle/import-export/utils.js.flow +2 -2
- package/src/integration_tests/basic_bundle/loadBundleAsyncForTest.js.flow +1 -1
- package/src/integration_tests/basic_bundle/optional-dependencies/index.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-context/conflict.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-context/empty.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-context/matching.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-context/mode-eager.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-context/mode-lazy-once.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-context/mode-lazy.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-context/mode-sync.js.flow +2 -2
- package/src/integration_tests/basic_bundle/require-context/utils.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-resolveWeak/import-and-resolveWeak.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-resolveWeak/multiple.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-resolveWeak/never-required.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-resolveWeak/require-and-resolveWeak.js.flow +1 -1
- package/src/integration_tests/execBundle.js.flow +1 -1
- package/src/lib/BatchProcessor.d.ts +54 -0
- package/src/lib/BatchProcessor.js +5 -2
- package/src/lib/BatchProcessor.js.flow +10 -7
- package/src/lib/CountingSet.d.ts +10 -10
- package/src/lib/CountingSet.js.flow +4 -4
- package/src/lib/JsonReporter.d.ts +37 -0
- package/src/lib/JsonReporter.js +5 -3
- package/src/lib/JsonReporter.js.flow +19 -17
- package/src/lib/RamBundleParser.d.ts +29 -0
- package/src/lib/RamBundleParser.js.flow +1 -1
- package/src/lib/TerminalReporter.d.ts +97 -6
- package/src/lib/TerminalReporter.js +37 -34
- package/src/lib/TerminalReporter.js.flow +21 -30
- package/src/lib/bundleProgressUtils.d.ts +26 -0
- package/src/lib/bundleProgressUtils.js +19 -0
- package/src/lib/bundleProgressUtils.js.flow +35 -0
- package/src/lib/bundleToString.d.ts +19 -0
- package/src/lib/contextModule.d.ts +20 -9
- package/src/lib/contextModule.js.flow +1 -1
- package/src/lib/contextModuleTemplates.d.ts +25 -0
- package/src/lib/contextModuleTemplates.js +25 -21
- package/src/lib/countLines.d.ts +12 -0
- package/src/lib/countLines.js +4 -3
- package/src/lib/countLines.js.flow +3 -4
- package/src/lib/createWebsocketServer.d.ts +43 -0
- package/src/lib/createWebsocketServer.js +9 -2
- package/src/lib/createWebsocketServer.js.flow +16 -9
- package/src/lib/debounceAsyncQueue.d.ts +15 -0
- package/src/lib/debounceAsyncQueue.js.flow +1 -1
- package/src/lib/formatBundlingError.d.ts +23 -0
- package/src/lib/formatBundlingError.js.flow +1 -1
- package/src/lib/getAppendScripts.d.ts +31 -0
- package/src/lib/getAppendScripts.js.flow +4 -4
- package/src/lib/getGraphId.d.ts +15 -1
- package/src/lib/getGraphId.js.flow +1 -1
- package/src/lib/getPreludeCode.d.ts +18 -0
- package/src/lib/getPreludeCode.js +4 -0
- package/src/lib/getPreludeCode.js.flow +10 -3
- package/src/lib/getPrependedScripts.d.ts +24 -0
- package/src/lib/getPrependedScripts.js +36 -22
- package/src/lib/getPrependedScripts.js.flow +10 -3
- package/src/lib/isResolvedDependency.d.ts +15 -0
- package/src/lib/logToConsole.d.ts +19 -0
- package/src/lib/logToConsole.js.flow +2 -2
- package/src/lib/parseBundleOptionsFromBundleRequestUrl.d.ts +17 -0
- package/src/lib/parseBundleOptionsFromBundleRequestUrl.js +25 -21
- package/src/lib/parseCustomResolverOptions.d.ts +16 -0
- package/src/lib/parseCustomResolverOptions.js.flow +2 -2
- package/src/lib/parseCustomTransformOptions.d.ts +16 -0
- package/src/lib/parseCustomTransformOptions.js.flow +1 -1
- package/src/lib/parseJsonBody.d.ts +27 -0
- package/src/lib/parseJsonBody.js.flow +11 -1
- package/src/lib/pathUtils.d.ts +14 -0
- package/src/lib/pathUtils.js +25 -21
- package/src/lib/pathUtils.js.flow +1 -1
- package/src/lib/relativizeSourceMap.d.ts +17 -0
- package/src/lib/reporting.d.ts +65 -81
- package/src/lib/reporting.js.flow +4 -4
- package/src/lib/splitBundleOptions.d.ts +16 -0
- package/src/lib/transformHelpers.d.ts +35 -0
- package/src/lib/transformHelpers.js +11 -9
- package/src/lib/transformHelpers.js.flow +17 -15
- package/src/node-haste/DependencyGraph/ModuleResolution.d.ts +126 -0
- package/src/node-haste/DependencyGraph/ModuleResolution.js +48 -42
- package/src/node-haste/DependencyGraph/ModuleResolution.js.flow +35 -32
- package/src/node-haste/DependencyGraph/createFileMap.d.ts +29 -0
- package/src/node-haste/DependencyGraph/createFileMap.js +56 -38
- package/src/node-haste/DependencyGraph/createFileMap.js.flow +44 -18
- package/src/node-haste/DependencyGraph.d.ts +57 -33
- package/src/node-haste/DependencyGraph.js +40 -31
- package/src/node-haste/DependencyGraph.js.flow +35 -37
- package/src/node-haste/Package.d.ts +21 -0
- package/src/node-haste/PackageCache.d.ts +34 -0
- package/src/node-haste/lib/AssetPaths.d.ts +29 -0
- package/src/node-haste/lib/AssetPaths.js +2 -2
- package/src/node-haste/lib/AssetPaths.js.flow +4 -4
- package/src/node-haste/lib/parsePlatformFilePath.d.ts +25 -0
- package/src/node-haste/lib/parsePlatformFilePath.js +6 -6
- package/src/node-haste/lib/parsePlatformFilePath.js.flow +4 -4
- package/src/shared/output/RamBundle/as-assets.d.ts +25 -0
- package/src/shared/output/RamBundle/as-assets.js.flow +6 -6
- package/src/shared/output/RamBundle/as-indexed-file.d.ts +38 -0
- package/src/shared/output/RamBundle/as-indexed-file.js.flow +5 -5
- package/src/shared/output/RamBundle/buildSourcemapWithMetadata.d.ts +23 -0
- package/src/shared/output/RamBundle/buildSourcemapWithMetadata.js.flow +5 -5
- package/src/shared/output/RamBundle/magic-number.d.ts +14 -0
- package/src/shared/output/RamBundle/util.d.ts +41 -0
- package/src/shared/output/RamBundle/util.js.flow +5 -5
- package/src/shared/output/RamBundle/write-sourcemap.d.ts +16 -0
- package/src/shared/output/RamBundle/write-sourcemap.js.flow +1 -1
- package/src/shared/output/RamBundle.d.ts +26 -0
- package/src/shared/output/RamBundle.js.flow +1 -1
- package/src/shared/output/bundle.d.ts +9 -17
- package/src/shared/output/bundle.flow.js.flow +3 -3
- package/src/shared/output/meta.d.ts +15 -0
- package/src/shared/output/meta.js +2 -2
- package/src/shared/output/meta.js.flow +1 -1
- package/src/shared/output/unbundle.d.ts +11 -0
- package/src/shared/output/writeFile.d.ts +16 -0
- package/src/shared/output/writeFile.js +8 -3
- package/src/shared/output/writeFile.js.flow +8 -2
- package/src/shared/types.d.ts +81 -66
- package/src/shared/types.js.flow +20 -5
- package/src/Asset.d.ts +0 -25
- package/src/ModuleGraph/test-helpers.js +0 -75
package/src/index.flow.js.flow
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
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.
|
|
6
6
|
*
|
|
7
|
-
* @flow
|
|
7
|
+
* @flow strict-local
|
|
8
8
|
* @format
|
|
9
9
|
* @oncall react_native
|
|
10
10
|
*/
|
|
@@ -15,7 +15,10 @@ import type {ServerOptions} from './Server';
|
|
|
15
15
|
import type {BuildOptions, OutputOptions, RequestOptions} from './shared/types';
|
|
16
16
|
import type {HandleFunction} from 'connect';
|
|
17
17
|
import type {Server as HttpServer} from 'http';
|
|
18
|
-
import type {
|
|
18
|
+
import type {
|
|
19
|
+
Server as HttpsServer,
|
|
20
|
+
ServerOptions as HttpsServerOptions,
|
|
21
|
+
} from 'https';
|
|
19
22
|
import type {TransformProfile} from 'metro-babel-transformer';
|
|
20
23
|
import type {
|
|
21
24
|
ConfigT,
|
|
@@ -25,6 +28,7 @@ import type {
|
|
|
25
28
|
} from 'metro-config';
|
|
26
29
|
import type {CustomResolverOptions} from 'metro-resolver';
|
|
27
30
|
import type {CustomTransformOptions} from 'metro-transform-worker';
|
|
31
|
+
import type {Server as WebSocketServer} from 'ws';
|
|
28
32
|
import typeof Yargs from 'yargs';
|
|
29
33
|
|
|
30
34
|
import makeBuildCommand from './commands/build';
|
|
@@ -65,21 +69,21 @@ export type RunMetroOptions = {
|
|
|
65
69
|
waitForBundler?: boolean,
|
|
66
70
|
};
|
|
67
71
|
|
|
68
|
-
export type RunServerOptions =
|
|
72
|
+
export type RunServerOptions = Readonly<{
|
|
69
73
|
hasReducedPerformance?: boolean,
|
|
70
74
|
host?: string,
|
|
71
75
|
onError?: (Error & {code?: string}) => void,
|
|
72
76
|
onReady?: (server: HttpServer | HttpsServer) => void,
|
|
73
77
|
onClose?: () => void,
|
|
74
|
-
secureServerOptions?:
|
|
78
|
+
secureServerOptions?: HttpsServerOptions,
|
|
75
79
|
secure?: boolean, // deprecated
|
|
76
80
|
secureCert?: string, // deprecated
|
|
77
81
|
secureKey?: string, // deprecated
|
|
78
|
-
unstable_extraMiddleware?:
|
|
82
|
+
unstable_extraMiddleware?: ReadonlyArray<HandleFunction>,
|
|
79
83
|
waitForBundler?: boolean,
|
|
80
84
|
watch?: boolean,
|
|
81
|
-
websocketEndpoints?:
|
|
82
|
-
[path: string]:
|
|
85
|
+
websocketEndpoints?: Readonly<{
|
|
86
|
+
[path: string]: WebSocketServer,
|
|
83
87
|
}>,
|
|
84
88
|
}>;
|
|
85
89
|
|
|
@@ -88,7 +92,7 @@ export type RunServerResult = {
|
|
|
88
92
|
};
|
|
89
93
|
|
|
90
94
|
type BuildGraphOptions = {
|
|
91
|
-
entries:
|
|
95
|
+
entries: ReadonlyArray<string>,
|
|
92
96
|
customTransformOptions?: CustomTransformOptions,
|
|
93
97
|
dev?: boolean,
|
|
94
98
|
minify?: boolean,
|
|
@@ -108,7 +112,7 @@ export type RunBuildOptions = {
|
|
|
108
112
|
onComplete?: () => void,
|
|
109
113
|
onProgress?: (transformedFileCount: number, totalFileCount: number) => void,
|
|
110
114
|
minify?: boolean,
|
|
111
|
-
output?:
|
|
115
|
+
output?: Readonly<{
|
|
112
116
|
build: (
|
|
113
117
|
MetroServer,
|
|
114
118
|
RequestOptions,
|
|
@@ -116,7 +120,7 @@ export type RunBuildOptions = {
|
|
|
116
120
|
) => Promise<{
|
|
117
121
|
code: string,
|
|
118
122
|
map: string,
|
|
119
|
-
assets?:
|
|
123
|
+
assets?: ReadonlyArray<AssetData>,
|
|
120
124
|
...
|
|
121
125
|
}>,
|
|
122
126
|
save: (
|
|
@@ -127,7 +131,7 @@ export type RunBuildOptions = {
|
|
|
127
131
|
},
|
|
128
132
|
OutputOptions,
|
|
129
133
|
(logMessage: string) => void,
|
|
130
|
-
) => Promise<
|
|
134
|
+
) => Promise<unknown>,
|
|
131
135
|
...
|
|
132
136
|
}>,
|
|
133
137
|
platform?: string,
|
|
@@ -141,12 +145,13 @@ export type RunBuildOptions = {
|
|
|
141
145
|
export type RunBuildResult = {
|
|
142
146
|
code: string,
|
|
143
147
|
map: string,
|
|
144
|
-
assets?:
|
|
148
|
+
assets?: ReadonlyArray<AssetData>,
|
|
145
149
|
...
|
|
146
150
|
};
|
|
147
151
|
|
|
148
|
-
type BuildCommandOptions = {} | null;
|
|
149
|
-
type ServeCommandOptions = {} | null;
|
|
152
|
+
type BuildCommandOptions = Readonly<{[string]: unknown}> | null;
|
|
153
|
+
type ServeCommandOptions = Readonly<{[string]: unknown}> | null;
|
|
154
|
+
type DependenciesCommandOptions = Readonly<{[string]: unknown}> | null;
|
|
150
155
|
|
|
151
156
|
export {Terminal, JsonReporter, TerminalReporter};
|
|
152
157
|
|
|
@@ -263,7 +268,7 @@ export const runServer = async (
|
|
|
263
268
|
secureKey, // deprecated
|
|
264
269
|
unstable_extraMiddleware,
|
|
265
270
|
waitForBundler = false,
|
|
266
|
-
websocketEndpoints = {},
|
|
271
|
+
websocketEndpoints: userWebsocketEndpoints = {},
|
|
267
272
|
watch,
|
|
268
273
|
}: RunServerOptions = {},
|
|
269
274
|
): Promise<RunServerResult> => {
|
|
@@ -275,7 +280,7 @@ export const runServer = async (
|
|
|
275
280
|
chalk.inverse.yellow.bold(' DEPRECATED '),
|
|
276
281
|
'The `secure`, `secureCert`, and `secureKey` options are now deprecated. ' +
|
|
277
282
|
'Please use the `secureServerOptions` object instead to pass options to ' +
|
|
278
|
-
"Metro's https development server.",
|
|
283
|
+
"Metro's https development server, or `config.server.tls` in Metro's configuration",
|
|
279
284
|
);
|
|
280
285
|
}
|
|
281
286
|
// Lazy require
|
|
@@ -302,15 +307,30 @@ export const runServer = async (
|
|
|
302
307
|
|
|
303
308
|
let httpServer;
|
|
304
309
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
310
|
+
const {tls} = config.server;
|
|
311
|
+
if (
|
|
312
|
+
secure === true ||
|
|
313
|
+
secureServerOptions != null ||
|
|
314
|
+
typeof tls === 'object'
|
|
315
|
+
) {
|
|
316
|
+
const options = {
|
|
317
|
+
key:
|
|
318
|
+
typeof tls === 'object'
|
|
319
|
+
? tls.key
|
|
320
|
+
: typeof secureKey === 'string'
|
|
321
|
+
? fs.readFileSync(secureKey)
|
|
322
|
+
: undefined,
|
|
323
|
+
cert:
|
|
324
|
+
typeof tls === 'object'
|
|
325
|
+
? tls.cert
|
|
326
|
+
: typeof secureCert === 'string'
|
|
327
|
+
? fs.readFileSync(secureCert)
|
|
328
|
+
: undefined,
|
|
329
|
+
ca: typeof tls === 'object' ? tls.ca : undefined,
|
|
330
|
+
requestCert: typeof tls === 'object' ? tls.requestCert : undefined,
|
|
331
|
+
...(secureServerOptions ?? {}),
|
|
332
|
+
};
|
|
333
|
+
|
|
314
334
|
// $FlowFixMe[incompatible-type] 'http' and 'https' Flow types do not match
|
|
315
335
|
httpServer = https.createServer(options, serverApp);
|
|
316
336
|
} else {
|
|
@@ -333,8 +353,8 @@ export const runServer = async (
|
|
|
333
353
|
family,
|
|
334
354
|
});
|
|
335
355
|
|
|
336
|
-
websocketEndpoints = {
|
|
337
|
-
...
|
|
356
|
+
const websocketEndpoints = {
|
|
357
|
+
...userWebsocketEndpoints,
|
|
338
358
|
'/hot': createWebsocketServer({
|
|
339
359
|
websocketServer: new MetroHmrServer(
|
|
340
360
|
metroServer.getBundler(),
|
|
@@ -441,7 +461,7 @@ export const runBuild = async (
|
|
|
441
461
|
onComplete();
|
|
442
462
|
}
|
|
443
463
|
|
|
444
|
-
if (out || bundleOut) {
|
|
464
|
+
if (out != null || bundleOut != null) {
|
|
445
465
|
const bundleOutput =
|
|
446
466
|
bundleOut ?? nullthrows(out).replace(/(\.js)?$/, '.js');
|
|
447
467
|
|
|
@@ -510,7 +530,7 @@ export const buildGraph = async function (
|
|
|
510
530
|
type AttachMetroCLIOptions = {
|
|
511
531
|
build?: BuildCommandOptions,
|
|
512
532
|
serve?: ServeCommandOptions,
|
|
513
|
-
dependencies?:
|
|
533
|
+
dependencies?: DependenciesCommandOptions,
|
|
514
534
|
...
|
|
515
535
|
};
|
|
516
536
|
|
|
@@ -32,28 +32,32 @@ var _export4 = require("./export-4");
|
|
|
32
32
|
function _interopRequireDefault(e) {
|
|
33
33
|
return e && e.__esModule ? e : { default: e };
|
|
34
34
|
}
|
|
35
|
-
function
|
|
36
|
-
if ("function"
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return (
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
var n = { __proto__: null },
|
|
50
|
-
a = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
51
|
-
for (var u in e)
|
|
52
|
-
if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
|
|
53
|
-
var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;
|
|
54
|
-
i && (i.get || i.set) ? Object.defineProperty(n, u, i) : (n[u] = e[u]);
|
|
35
|
+
function _interopRequireWildcard(e, t) {
|
|
36
|
+
if ("function" == typeof WeakMap)
|
|
37
|
+
var r = new WeakMap(),
|
|
38
|
+
n = new WeakMap();
|
|
39
|
+
return (_interopRequireWildcard = function (e, t) {
|
|
40
|
+
if (!t && e && e.__esModule) return e;
|
|
41
|
+
var o,
|
|
42
|
+
i,
|
|
43
|
+
f = { __proto__: null, default: e };
|
|
44
|
+
if (null === e || ("object" != typeof e && "function" != typeof e))
|
|
45
|
+
return f;
|
|
46
|
+
if ((o = t ? n : r)) {
|
|
47
|
+
if (o.has(e)) return o.get(e);
|
|
48
|
+
o.set(e, f);
|
|
55
49
|
}
|
|
56
|
-
|
|
50
|
+
for (const t in e)
|
|
51
|
+
"default" !== t &&
|
|
52
|
+
{}.hasOwnProperty.call(e, t) &&
|
|
53
|
+
((i =
|
|
54
|
+
(o = Object.defineProperty) &&
|
|
55
|
+
Object.getOwnPropertyDescriptor(e, t)) &&
|
|
56
|
+
(i.get || i.set)
|
|
57
|
+
? o(f, t, i)
|
|
58
|
+
: (f[t] = e[t]));
|
|
59
|
+
return f;
|
|
60
|
+
})(e, t);
|
|
57
61
|
}
|
|
58
62
|
const extraData = (exports.extraData = {
|
|
59
63
|
foo: _exportNull.foo,
|
|
@@ -29,7 +29,7 @@ export const extraData = {
|
|
|
29
29
|
importStar,
|
|
30
30
|
myDefault,
|
|
31
31
|
myFoo,
|
|
32
|
-
myFunction:
|
|
32
|
+
myFunction: myFunction() as string,
|
|
33
33
|
primitiveDefault,
|
|
34
34
|
primitiveFoo,
|
|
35
35
|
};
|
|
@@ -37,7 +37,7 @@ export const extraData = {
|
|
|
37
37
|
export const asyncImportCJS = import('./export-5');
|
|
38
38
|
export const asyncImportESM = import('./export-6');
|
|
39
39
|
|
|
40
|
-
export const asyncImportMaybeSyncCJS:
|
|
40
|
+
export const asyncImportMaybeSyncCJS: unknown =
|
|
41
41
|
require.unstable_importMaybeSync('./export-7');
|
|
42
|
-
export const asyncImportMaybeSyncESM:
|
|
42
|
+
export const asyncImportMaybeSyncESM: unknown =
|
|
43
43
|
require.unstable_importMaybeSync('./export-8');
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
13
|
declare var __METRO_GLOBAL_PREFIX__: string;
|
|
14
|
-
declare var __DOWNLOAD_AND_EXEC_FOR_TESTS__: (path: string) => Promise<
|
|
14
|
+
declare var __DOWNLOAD_AND_EXEC_FOR_TESTS__: (path: string) => Promise<unknown>;
|
|
15
15
|
|
|
16
16
|
const key = `${global.__METRO_GLOBAL_PREFIX__ ?? ''}__loadBundleAsync`;
|
|
17
17
|
|
|
@@ -14,11 +14,11 @@ import {copyContextToObject} from './utils';
|
|
|
14
14
|
|
|
15
15
|
declare var require: RequireWithContext;
|
|
16
16
|
|
|
17
|
-
function main():
|
|
17
|
+
function main(): unknown {
|
|
18
18
|
return copyContextToObject(
|
|
19
19
|
// $FlowFixMe[underconstrained-implicit-instantiation]
|
|
20
20
|
require.context('./subdir', undefined, undefined, 'sync'),
|
|
21
21
|
);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
module.exports =
|
|
24
|
+
module.exports = main() as unknown;
|
|
@@ -33,7 +33,7 @@ export function copyContextToObject<T>(ctx: ContextModule<T>): {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
export function awaitProperties<T>(
|
|
36
|
-
obj:
|
|
36
|
+
obj: Readonly<{[key: string]: Promise<T>}>,
|
|
37
37
|
): Promise<{[key: string]: T}> {
|
|
38
38
|
const result: {[string]: T} = {};
|
|
39
39
|
return Promise.all(
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
import vm from 'vm';
|
|
13
13
|
|
|
14
|
-
module.exports = function execBundle(code: string, context: any = {}):
|
|
14
|
+
module.exports = function execBundle(code: string, context: any = {}): unknown {
|
|
15
15
|
if (vm.isContext(context)) {
|
|
16
16
|
return vm.runInContext(code, context);
|
|
17
17
|
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import {setTimeout} from 'timers';
|
|
12
|
+
|
|
13
|
+
type ProcessBatch<TItem, TResult> = (
|
|
14
|
+
batch: Array<TItem>,
|
|
15
|
+
) => Promise<Array<TResult>>;
|
|
16
|
+
type BatchProcessorOptions = {
|
|
17
|
+
maximumDelayMs: number;
|
|
18
|
+
maximumItems: number;
|
|
19
|
+
concurrency: number;
|
|
20
|
+
};
|
|
21
|
+
type QueueItem<TItem, TResult> = {
|
|
22
|
+
item: TItem;
|
|
23
|
+
reject: (error: unknown) => unknown;
|
|
24
|
+
resolve: (result: TResult) => unknown;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* We batch items together trying to minimize their processing, for example as
|
|
28
|
+
* network queries. For that we wait a small moment before processing a batch.
|
|
29
|
+
* We limit also the number of items we try to process in a single batch so that
|
|
30
|
+
* if we have many items pending in a short amount of time, we can start
|
|
31
|
+
* processing right away.
|
|
32
|
+
*/
|
|
33
|
+
declare class BatchProcessor<TItem, TResult> {
|
|
34
|
+
_currentProcessCount: number;
|
|
35
|
+
_options: BatchProcessorOptions;
|
|
36
|
+
_processBatch: ProcessBatch<TItem, TResult>;
|
|
37
|
+
_queue: Array<QueueItem<TItem, TResult>>;
|
|
38
|
+
_timeoutHandle: null | undefined | ReturnType<typeof setTimeout>;
|
|
39
|
+
constructor(
|
|
40
|
+
options: BatchProcessorOptions,
|
|
41
|
+
processBatch: ProcessBatch<TItem, TResult>,
|
|
42
|
+
);
|
|
43
|
+
_onBatchFinished(): void;
|
|
44
|
+
_onBatchResults(
|
|
45
|
+
jobs: Array<QueueItem<TItem, TResult>>,
|
|
46
|
+
results: Array<TResult>,
|
|
47
|
+
): void;
|
|
48
|
+
_onBatchError(jobs: Array<QueueItem<TItem, TResult>>, error: unknown): void;
|
|
49
|
+
_processQueue(): void;
|
|
50
|
+
_processQueueOnceReady(): void;
|
|
51
|
+
queue(item: TItem): Promise<TResult>;
|
|
52
|
+
getQueueLength(): number;
|
|
53
|
+
}
|
|
54
|
+
export default BatchProcessor;
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _invariant = _interopRequireDefault(require("invariant"));
|
|
8
|
+
var _timers = require("timers");
|
|
8
9
|
function _interopRequireDefault(e) {
|
|
9
10
|
return e && e.__esModule ? e : { default: e };
|
|
10
11
|
}
|
|
@@ -50,12 +51,14 @@ class BatchProcessor {
|
|
|
50
51
|
}
|
|
51
52
|
_processQueueOnceReady() {
|
|
52
53
|
if (this._queue.length >= this._options.maximumItems) {
|
|
53
|
-
|
|
54
|
+
if (this._timeoutHandle != null) {
|
|
55
|
+
(0, _timers.clearTimeout)(this._timeoutHandle);
|
|
56
|
+
}
|
|
54
57
|
process.nextTick(() => this._processQueue());
|
|
55
58
|
return;
|
|
56
59
|
}
|
|
57
60
|
if (this._timeoutHandle == null) {
|
|
58
|
-
this._timeoutHandle = setTimeout(
|
|
61
|
+
this._timeoutHandle = (0, _timers.setTimeout)(
|
|
59
62
|
() => this._processQueue(),
|
|
60
63
|
this._options.maximumDelayMs,
|
|
61
64
|
);
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import invariant from 'invariant';
|
|
13
|
+
import {clearTimeout, setTimeout} from 'timers';
|
|
13
14
|
|
|
14
15
|
type ProcessBatch<TItem, TResult> = (
|
|
15
16
|
batch: Array<TItem>,
|
|
@@ -24,8 +25,8 @@ type BatchProcessorOptions = {
|
|
|
24
25
|
|
|
25
26
|
type QueueItem<TItem, TResult> = {
|
|
26
27
|
item: TItem,
|
|
27
|
-
reject: (error:
|
|
28
|
-
resolve: (result: TResult) =>
|
|
28
|
+
reject: (error: unknown) => unknown,
|
|
29
|
+
resolve: (result: TResult) => unknown,
|
|
29
30
|
...
|
|
30
31
|
};
|
|
31
32
|
|
|
@@ -41,7 +42,7 @@ export default class BatchProcessor<TItem, TResult> {
|
|
|
41
42
|
_options: BatchProcessorOptions;
|
|
42
43
|
_processBatch: ProcessBatch<TItem, TResult>;
|
|
43
44
|
_queue: Array<QueueItem<TItem, TResult>>;
|
|
44
|
-
_timeoutHandle: ?
|
|
45
|
+
_timeoutHandle: ?ReturnType<typeof setTimeout>;
|
|
45
46
|
|
|
46
47
|
constructor(
|
|
47
48
|
options: BatchProcessorOptions,
|
|
@@ -70,7 +71,7 @@ export default class BatchProcessor<TItem, TResult> {
|
|
|
70
71
|
this._onBatchFinished();
|
|
71
72
|
}
|
|
72
73
|
|
|
73
|
-
_onBatchError(jobs: Array<QueueItem<TItem, TResult>>, error:
|
|
74
|
+
_onBatchError(jobs: Array<QueueItem<TItem, TResult>>, error: unknown): void {
|
|
74
75
|
for (let i = 0; i < jobs.length; ++i) {
|
|
75
76
|
jobs[i].reject(error);
|
|
76
77
|
}
|
|
@@ -94,7 +95,9 @@ export default class BatchProcessor<TItem, TResult> {
|
|
|
94
95
|
|
|
95
96
|
_processQueueOnceReady(): void {
|
|
96
97
|
if (this._queue.length >= this._options.maximumItems) {
|
|
97
|
-
|
|
98
|
+
if (this._timeoutHandle != null) {
|
|
99
|
+
clearTimeout(this._timeoutHandle);
|
|
100
|
+
}
|
|
98
101
|
process.nextTick(() => this._processQueue());
|
|
99
102
|
return;
|
|
100
103
|
}
|
|
@@ -109,8 +112,8 @@ export default class BatchProcessor<TItem, TResult> {
|
|
|
109
112
|
queue(item: TItem): Promise<TResult> {
|
|
110
113
|
return new Promise(
|
|
111
114
|
(
|
|
112
|
-
resolve: (result: TResult) =>
|
|
113
|
-
reject: (error:
|
|
115
|
+
resolve: (result: TResult) => unknown,
|
|
116
|
+
reject: (error: unknown) => unknown,
|
|
114
117
|
) => {
|
|
115
118
|
this._queue.push({item, resolve, reject});
|
|
116
119
|
this._processQueueOnceReady();
|