metro 0.83.4 → 0.83.6
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 +18 -16
- package/src/Assets.d.ts +90 -0
- package/src/Assets.js +2 -9
- package/src/Bundler/util.d.ts +34 -0
- package/src/Bundler/util.js +2 -9
- package/src/Bundler/util.js.flow +3 -3
- package/src/Bundler.d.ts +45 -0
- package/src/Bundler.js +1 -5
- package/src/DeltaBundler/DeltaCalculator.d.ts +68 -0
- package/src/DeltaBundler/DeltaCalculator.js +56 -51
- package/src/DeltaBundler/DeltaCalculator.js.flow +72 -61
- package/src/DeltaBundler/Graph.d.ts +174 -0
- package/src/DeltaBundler/Graph.js +1 -5
- package/src/DeltaBundler/Serializers/baseJSBundle.d.ts +27 -0
- package/src/DeltaBundler/Serializers/baseJSBundle.js +1 -5
- package/src/DeltaBundler/Serializers/getAllFiles.d.ts +29 -0
- package/src/DeltaBundler/Serializers/getAssets.d.ts +32 -0
- package/src/DeltaBundler/Serializers/getAssets.js +1 -5
- package/src/DeltaBundler/Serializers/getExplodedSourceMap.d.ts +33 -0
- package/src/DeltaBundler/Serializers/getRamBundleInfo.d.ts +55 -0
- package/src/DeltaBundler/Serializers/getRamBundleInfo.js +1 -5
- package/src/DeltaBundler/Serializers/helpers/getInlineSourceMappingURL.d.ts +19 -0
- package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.d.ts +40 -0
- package/src/DeltaBundler/Serializers/helpers/getTransitiveDependencies.d.ts +24 -0
- package/src/DeltaBundler/Serializers/helpers/js.d.ts +37 -0
- package/src/DeltaBundler/Serializers/helpers/js.js +2 -9
- package/src/DeltaBundler/Serializers/helpers/processModules.d.ts +32 -0
- package/src/DeltaBundler/Serializers/hmrJSBundle.d.ts +37 -0
- package/src/DeltaBundler/Serializers/hmrJSBundle.js +2 -9
- package/src/DeltaBundler/Serializers/sourceMapGenerator.d.ts +36 -0
- package/src/DeltaBundler/Serializers/sourceMapGenerator.js +1 -5
- package/src/DeltaBundler/Serializers/sourceMapObject.d.ts +30 -0
- package/src/DeltaBundler/Serializers/sourceMapString.d.ts +29 -0
- package/src/DeltaBundler/Transformer.d.ts +45 -0
- package/src/DeltaBundler/Transformer.js +1 -5
- package/src/DeltaBundler/Worker.d.ts +44 -0
- package/src/DeltaBundler/Worker.flow.js +1 -5
- package/src/DeltaBundler/WorkerFarm.d.ts +77 -0
- package/src/DeltaBundler/buildSubgraph.d.ts +37 -0
- package/src/DeltaBundler/buildSubgraph.js +1 -5
- package/src/DeltaBundler/getTransformCacheKey.d.ts +25 -0
- package/src/DeltaBundler/getTransformCacheKey.js +4 -6
- package/src/DeltaBundler/getTransformCacheKey.js.flow +7 -2
- package/src/DeltaBundler/mergeDeltas.d.ts +24 -0
- package/src/DeltaBundler/types.d.ts +170 -0
- package/src/DeltaBundler/types.js +1 -5
- package/src/DeltaBundler.d.ts +67 -0
- package/src/DeltaBundler.js +1 -5
- package/src/HmrServer.d.ts +98 -0
- package/src/HmrServer.js +9 -9
- package/src/HmrServer.js.flow +15 -5
- package/src/IncrementalBundler/GraphNotFoundError.d.ts +24 -0
- package/src/IncrementalBundler/ResourceNotFoundError.d.ts +22 -0
- package/src/IncrementalBundler/RevisionNotFoundError.d.ts +24 -0
- package/src/IncrementalBundler.d.ts +103 -0
- package/src/IncrementalBundler.js +2 -9
- package/src/ModuleGraph/worker/JsFileWrapping.d.ts +36 -0
- package/src/ModuleGraph/worker/JsFileWrapping.js +2 -9
- package/src/ModuleGraph/worker/collectDependencies.d.ts +138 -0
- package/src/ModuleGraph/worker/collectDependencies.js +2 -9
- package/src/ModuleGraph/worker/generateImportNames.d.ts +26 -0
- package/src/ModuleGraph/worker/generateImportNames.js +1 -5
- package/src/ModuleGraph/worker/importLocationsPlugin.d.ts +33 -0
- package/src/Server/MultipartResponse.d.ts +37 -0
- package/src/Server/MultipartResponse.js +1 -5
- package/src/Server/symbolicate.d.ts +38 -0
- package/src/Server.d.ts +278 -0
- package/src/Server.js +47 -15
- package/src/Server.js.flow +57 -10
- package/src/cli/parseKeyValueParamArray.d.ts +21 -0
- package/src/cli-utils.d.ts +26 -0
- package/src/cli-utils.js +1 -5
- package/src/commands/build.d.ts +23 -0
- package/src/commands/build.js +1 -5
- package/src/commands/dependencies.d.ts +23 -0
- package/src/commands/dependencies.js +1 -5
- package/src/commands/serve.d.ts +23 -0
- package/src/index.d.ts +206 -0
- package/src/index.flow.js +26 -19
- package/src/index.flow.js.flow +46 -12
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-import.js +1 -5
- package/src/integration_tests/basic_bundle/build-errors/inline-requires-cannot-resolve-import.js +1 -5
- package/src/integration_tests/basic_bundle/import-export/index.js +2 -9
- package/src/integration_tests/execBundle.js +1 -5
- package/src/lib/BatchProcessor.d.ts +61 -0
- package/src/lib/BatchProcessor.js +1 -5
- package/src/lib/CountingSet.d.ts +55 -0
- package/src/lib/JsonReporter.d.ts +44 -0
- package/src/lib/JsonReporter.js.flow +2 -2
- package/src/lib/RamBundleParser.d.ts +36 -0
- package/src/lib/RamBundleParser.js +1 -5
- package/src/lib/TerminalReporter.d.ts +125 -0
- package/src/lib/TerminalReporter.js +8 -16
- package/src/lib/TerminalReporter.js.flow +6 -15
- package/src/lib/bundleProgressUtils.d.ts +33 -0
- package/src/lib/bundleProgressUtils.js +19 -0
- package/src/lib/bundleProgressUtils.js.flow +35 -0
- package/src/lib/bundleToString.d.ts +26 -0
- package/src/lib/contextModule.d.ts +40 -0
- package/src/lib/contextModule.js +1 -5
- package/src/lib/contextModuleTemplates.d.ts +32 -0
- package/src/lib/contextModuleTemplates.js +1 -4
- package/src/lib/countLines.d.ts +19 -0
- package/src/lib/createWebsocketServer.d.ts +50 -0
- package/src/lib/createWebsocketServer.js +1 -5
- package/src/lib/debounceAsyncQueue.d.ts +22 -0
- package/src/lib/formatBundlingError.d.ts +30 -0
- package/src/lib/formatBundlingError.js +1 -5
- package/src/lib/getAppendScripts.d.ts +38 -0
- package/src/lib/getAppendScripts.js +1 -5
- package/src/lib/getAppendScripts.js.flow +2 -2
- package/src/lib/getGraphId.d.ts +32 -0
- package/src/lib/getGraphId.js +1 -5
- package/src/lib/getPreludeCode.d.ts +25 -0
- package/src/lib/getPrependedScripts.d.ts +31 -0
- package/src/lib/getPrependedScripts.js +2 -9
- package/src/lib/isResolvedDependency.d.ts +22 -0
- package/src/lib/logToConsole.d.ts +26 -0
- package/src/lib/logToConsole.js +1 -5
- package/src/lib/parseBundleOptionsFromBundleRequestUrl.d.ts +24 -0
- package/src/lib/parseBundleOptionsFromBundleRequestUrl.js +2 -9
- package/src/lib/parseCustomResolverOptions.d.ts +23 -0
- package/src/lib/parseCustomTransformOptions.d.ts +23 -0
- package/src/lib/parseJsonBody.d.ts +34 -0
- package/src/lib/pathUtils.d.ts +21 -0
- package/src/lib/pathUtils.js +1 -4
- package/src/lib/relativizeSourceMap.d.ts +24 -0
- package/src/lib/relativizeSourceMap.js +1 -5
- package/src/lib/reporting.d.ts +135 -0
- package/src/lib/reporting.js +1 -5
- package/src/lib/splitBundleOptions.d.ts +23 -0
- package/src/lib/transformHelpers.d.ts +42 -0
- package/src/lib/transformHelpers.js +1 -5
- package/src/node-haste/DependencyGraph/ModuleResolution.d.ts +120 -0
- package/src/node-haste/DependencyGraph/ModuleResolution.js +6 -31
- package/src/node-haste/DependencyGraph/ModuleResolution.js.flow +10 -59
- package/src/node-haste/DependencyGraph/createFileMap.d.ts +36 -0
- package/src/node-haste/DependencyGraph/createFileMap.js +3 -10
- package/src/node-haste/DependencyGraph/createFileMap.js.flow +4 -2
- package/src/node-haste/DependencyGraph.d.ts +90 -0
- package/src/node-haste/DependencyGraph.js +23 -16
- package/src/node-haste/DependencyGraph.js.flow +24 -13
- package/src/node-haste/PackageCache.d.ts +37 -0
- package/src/node-haste/PackageCache.js +65 -58
- package/src/node-haste/PackageCache.js.flow +103 -79
- package/src/node-haste/lib/AssetPaths.d.ts +36 -0
- package/src/node-haste/lib/AssetPaths.js +1 -5
- package/src/node-haste/lib/parsePlatformFilePath.d.ts +32 -0
- package/src/node-haste/lib/parsePlatformFilePath.js +1 -5
- package/src/shared/output/RamBundle/as-assets.d.ts +32 -0
- package/src/shared/output/RamBundle/as-assets.js +1 -5
- package/src/shared/output/RamBundle/as-indexed-file.d.ts +45 -0
- package/src/shared/output/RamBundle/as-indexed-file.js +1 -5
- package/src/shared/output/RamBundle/buildSourcemapWithMetadata.d.ts +30 -0
- package/src/shared/output/RamBundle/magic-number.d.ts +21 -0
- package/src/shared/output/RamBundle/util.d.ts +48 -0
- package/src/shared/output/RamBundle/util.js +1 -5
- package/src/shared/output/RamBundle/write-sourcemap.d.ts +23 -0
- package/src/shared/output/RamBundle/write-sourcemap.js +1 -5
- package/src/shared/output/RamBundle.d.ts +33 -0
- package/src/shared/output/RamBundle.js +1 -5
- package/src/shared/output/bundle.d.ts +34 -0
- package/src/shared/output/bundle.flow.js +1 -5
- package/src/shared/output/meta.d.ts +22 -0
- package/src/shared/output/meta.js +1 -5
- package/src/shared/output/unbundle.d.ts +18 -0
- package/src/shared/output/writeFile.d.ts +23 -0
- package/src/shared/output/writeFile.js +1 -5
- package/src/shared/types.d.ts +152 -0
- package/src/node-haste/Package.js +0 -32
- package/src/node-haste/Package.js.flow +0 -39
package/src/index.flow.js
CHANGED
|
@@ -79,10 +79,7 @@ function _interopRequireWildcard(e, t) {
|
|
|
79
79
|
if (!t && e && e.__esModule) return e;
|
|
80
80
|
var o,
|
|
81
81
|
i,
|
|
82
|
-
f = {
|
|
83
|
-
__proto__: null,
|
|
84
|
-
default: e,
|
|
85
|
-
};
|
|
82
|
+
f = { __proto__: null, default: e };
|
|
86
83
|
if (null === e || ("object" != typeof e && "function" != typeof e))
|
|
87
84
|
return f;
|
|
88
85
|
if ((o = t ? n : r)) {
|
|
@@ -102,11 +99,7 @@ function _interopRequireWildcard(e, t) {
|
|
|
102
99
|
})(e, t);
|
|
103
100
|
}
|
|
104
101
|
function _interopRequireDefault(e) {
|
|
105
|
-
return e && e.__esModule
|
|
106
|
-
? e
|
|
107
|
-
: {
|
|
108
|
-
default: e,
|
|
109
|
-
};
|
|
102
|
+
return e && e.__esModule ? e : { default: e };
|
|
110
103
|
}
|
|
111
104
|
const DEFAULTS = _Server.default.DEFAULT_BUNDLE_OPTIONS;
|
|
112
105
|
async function getConfig(config) {
|
|
@@ -211,7 +204,7 @@ const runServer = async (
|
|
|
211
204
|
_chalk.default.inverse.yellow.bold(" DEPRECATED "),
|
|
212
205
|
"The `secure`, `secureCert`, and `secureKey` options are now deprecated. " +
|
|
213
206
|
"Please use the `secureServerOptions` object instead to pass options to " +
|
|
214
|
-
"Metro's https development server.",
|
|
207
|
+
"Metro's https development server, or `config.server.tls` in Metro's configuration",
|
|
215
208
|
);
|
|
216
209
|
}
|
|
217
210
|
const connect = require("connect");
|
|
@@ -230,15 +223,29 @@ const runServer = async (
|
|
|
230
223
|
}
|
|
231
224
|
serverApp.use(middleware);
|
|
232
225
|
let httpServer;
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
226
|
+
const { tls } = config.server;
|
|
227
|
+
if (
|
|
228
|
+
secure === true ||
|
|
229
|
+
secureServerOptions != null ||
|
|
230
|
+
typeof tls === "object"
|
|
231
|
+
) {
|
|
232
|
+
const options = {
|
|
233
|
+
key:
|
|
234
|
+
typeof tls === "object"
|
|
235
|
+
? tls.key
|
|
236
|
+
: typeof secureKey === "string"
|
|
237
|
+
? _fs.default.readFileSync(secureKey)
|
|
238
|
+
: undefined,
|
|
239
|
+
cert:
|
|
240
|
+
typeof tls === "object"
|
|
241
|
+
? tls.cert
|
|
242
|
+
: typeof secureCert === "string"
|
|
243
|
+
? _fs.default.readFileSync(secureCert)
|
|
244
|
+
: undefined,
|
|
245
|
+
ca: typeof tls === "object" ? tls.ca : undefined,
|
|
246
|
+
requestCert: typeof tls === "object" ? tls.requestCert : undefined,
|
|
247
|
+
...(secureServerOptions ?? {}),
|
|
248
|
+
};
|
|
242
249
|
httpServer = _https.default.createServer(options, serverApp);
|
|
243
250
|
} else {
|
|
244
251
|
httpServer = _http.default.createServer(serverApp);
|
package/src/index.flow.js.flow
CHANGED
|
@@ -156,9 +156,28 @@ type DependenciesCommandOptions = Readonly<{[string]: unknown}> | null;
|
|
|
156
156
|
export {Terminal, JsonReporter, TerminalReporter};
|
|
157
157
|
|
|
158
158
|
export type {AssetData} from './Assets';
|
|
159
|
-
export type {
|
|
159
|
+
export type {
|
|
160
|
+
AsyncDependencyType,
|
|
161
|
+
DeltaResult,
|
|
162
|
+
Dependency,
|
|
163
|
+
MixedOutput,
|
|
164
|
+
Module,
|
|
165
|
+
ReadOnlyDependencies,
|
|
166
|
+
ReadOnlyGraph,
|
|
167
|
+
SerializerOptions,
|
|
168
|
+
TransformInputOptions,
|
|
169
|
+
TransformResult,
|
|
170
|
+
TransformResultDependency,
|
|
171
|
+
} from './DeltaBundler/types';
|
|
172
|
+
export type {default as DependencyGraph} from './node-haste/DependencyGraph';
|
|
173
|
+
export type {BundleDetails, Reporter, ReportableEvent} from './lib/reporting';
|
|
160
174
|
export type {TerminalReportableEvent} from './lib/TerminalReporter';
|
|
161
|
-
export type {
|
|
175
|
+
export type {
|
|
176
|
+
ContextMode,
|
|
177
|
+
RequireContextParams,
|
|
178
|
+
} from './ModuleGraph/worker/collectDependencies';
|
|
179
|
+
export type {ServerOptions} from './Server';
|
|
180
|
+
export type {MetroConfig, MetroServer};
|
|
162
181
|
|
|
163
182
|
async function getConfig(config: InputConfigT): Promise<ConfigT> {
|
|
164
183
|
const defaultConfig = await getDefaultConfig(config.projectRoot);
|
|
@@ -280,7 +299,7 @@ export const runServer = async (
|
|
|
280
299
|
chalk.inverse.yellow.bold(' DEPRECATED '),
|
|
281
300
|
'The `secure`, `secureCert`, and `secureKey` options are now deprecated. ' +
|
|
282
301
|
'Please use the `secureServerOptions` object instead to pass options to ' +
|
|
283
|
-
"Metro's https development server.",
|
|
302
|
+
"Metro's https development server, or `config.server.tls` in Metro's configuration",
|
|
284
303
|
);
|
|
285
304
|
}
|
|
286
305
|
// Lazy require
|
|
@@ -307,15 +326,30 @@ export const runServer = async (
|
|
|
307
326
|
|
|
308
327
|
let httpServer;
|
|
309
328
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
329
|
+
const {tls} = config.server;
|
|
330
|
+
if (
|
|
331
|
+
secure === true ||
|
|
332
|
+
secureServerOptions != null ||
|
|
333
|
+
typeof tls === 'object'
|
|
334
|
+
) {
|
|
335
|
+
const options = {
|
|
336
|
+
key:
|
|
337
|
+
typeof tls === 'object'
|
|
338
|
+
? tls.key
|
|
339
|
+
: typeof secureKey === 'string'
|
|
340
|
+
? fs.readFileSync(secureKey)
|
|
341
|
+
: undefined,
|
|
342
|
+
cert:
|
|
343
|
+
typeof tls === 'object'
|
|
344
|
+
? tls.cert
|
|
345
|
+
: typeof secureCert === 'string'
|
|
346
|
+
? fs.readFileSync(secureCert)
|
|
347
|
+
: undefined,
|
|
348
|
+
ca: typeof tls === 'object' ? tls.ca : undefined,
|
|
349
|
+
requestCert: typeof tls === 'object' ? tls.requestCert : undefined,
|
|
350
|
+
...(secureServerOptions ?? {}),
|
|
351
|
+
};
|
|
352
|
+
|
|
319
353
|
// $FlowFixMe[incompatible-type] 'http' and 'https' Flow types do not match
|
|
320
354
|
httpServer = https.createServer(options, serverApp);
|
|
321
355
|
} else {
|
|
@@ -2,10 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
var _doesNotExist = _interopRequireDefault(require("./does-not-exist"));
|
|
4
4
|
function _interopRequireDefault(e) {
|
|
5
|
-
return e && e.__esModule
|
|
6
|
-
? e
|
|
7
|
-
: {
|
|
8
|
-
default: e,
|
|
9
|
-
};
|
|
5
|
+
return e && e.__esModule ? e : { default: e };
|
|
10
6
|
}
|
|
11
7
|
global.x = _doesNotExist.default;
|
package/src/integration_tests/basic_bundle/build-errors/inline-requires-cannot-resolve-import.js
CHANGED
|
@@ -2,10 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
var _doesNotExist = _interopRequireDefault(require("./does-not-exist"));
|
|
4
4
|
function _interopRequireDefault(e) {
|
|
5
|
-
return e && e.__esModule
|
|
6
|
-
? e
|
|
7
|
-
: {
|
|
8
|
-
default: e,
|
|
9
|
-
};
|
|
5
|
+
return e && e.__esModule ? e : { default: e };
|
|
10
6
|
}
|
|
11
7
|
global.x = _doesNotExist.default;
|
|
@@ -30,11 +30,7 @@ var _exportPrimitiveDefault = _interopRequireWildcard(
|
|
|
30
30
|
var _export3 = _interopRequireDefault(require("./export-3"));
|
|
31
31
|
var _export4 = require("./export-4");
|
|
32
32
|
function _interopRequireDefault(e) {
|
|
33
|
-
return e && e.__esModule
|
|
34
|
-
? e
|
|
35
|
-
: {
|
|
36
|
-
default: e,
|
|
37
|
-
};
|
|
33
|
+
return e && e.__esModule ? e : { default: e };
|
|
38
34
|
}
|
|
39
35
|
function _interopRequireWildcard(e, t) {
|
|
40
36
|
if ("function" == typeof WeakMap)
|
|
@@ -44,10 +40,7 @@ function _interopRequireWildcard(e, t) {
|
|
|
44
40
|
if (!t && e && e.__esModule) return e;
|
|
45
41
|
var o,
|
|
46
42
|
i,
|
|
47
|
-
f = {
|
|
48
|
-
__proto__: null,
|
|
49
|
-
default: e,
|
|
50
|
-
};
|
|
43
|
+
f = { __proto__: null, default: e };
|
|
51
44
|
if (null === e || ("object" != typeof e && "function" != typeof e))
|
|
52
45
|
return f;
|
|
53
46
|
if ((o = t ? n : r)) {
|
|
@@ -2,11 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var _vm = _interopRequireDefault(require("vm"));
|
|
4
4
|
function _interopRequireDefault(e) {
|
|
5
|
-
return e && e.__esModule
|
|
6
|
-
? e
|
|
7
|
-
: {
|
|
8
|
-
default: e,
|
|
9
|
-
};
|
|
5
|
+
return e && e.__esModule ? e : { default: e };
|
|
10
6
|
}
|
|
11
7
|
module.exports = function execBundle(code, context = {}) {
|
|
12
8
|
if (_vm.default.isContext(context)) {
|
|
@@ -0,0 +1,61 @@
|
|
|
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
|
+
* @noformat
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
* @generated SignedSource<<5872ab26db1c8f4499c971170c5012c4>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/lib/BatchProcessor.js
|
|
13
|
+
* To regenerate, run:
|
|
14
|
+
* js1 build metro-ts-defs (internal) OR
|
|
15
|
+
* yarn run build-ts-defs (OSS)
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import {setTimeout} from 'timers';
|
|
19
|
+
|
|
20
|
+
type ProcessBatch<TItem, TResult> = (
|
|
21
|
+
batch: Array<TItem>,
|
|
22
|
+
) => Promise<Array<TResult>>;
|
|
23
|
+
type BatchProcessorOptions = {
|
|
24
|
+
maximumDelayMs: number;
|
|
25
|
+
maximumItems: number;
|
|
26
|
+
concurrency: number;
|
|
27
|
+
};
|
|
28
|
+
type QueueItem<TItem, TResult> = {
|
|
29
|
+
item: TItem;
|
|
30
|
+
reject: (error: unknown) => unknown;
|
|
31
|
+
resolve: (result: TResult) => unknown;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* We batch items together trying to minimize their processing, for example as
|
|
35
|
+
* network queries. For that we wait a small moment before processing a batch.
|
|
36
|
+
* We limit also the number of items we try to process in a single batch so that
|
|
37
|
+
* if we have many items pending in a short amount of time, we can start
|
|
38
|
+
* processing right away.
|
|
39
|
+
*/
|
|
40
|
+
declare class BatchProcessor<TItem, TResult> {
|
|
41
|
+
_currentProcessCount: number;
|
|
42
|
+
_options: BatchProcessorOptions;
|
|
43
|
+
_processBatch: ProcessBatch<TItem, TResult>;
|
|
44
|
+
_queue: Array<QueueItem<TItem, TResult>>;
|
|
45
|
+
_timeoutHandle: null | undefined | ReturnType<typeof setTimeout>;
|
|
46
|
+
constructor(
|
|
47
|
+
options: BatchProcessorOptions,
|
|
48
|
+
processBatch: ProcessBatch<TItem, TResult>,
|
|
49
|
+
);
|
|
50
|
+
_onBatchFinished(): void;
|
|
51
|
+
_onBatchResults(
|
|
52
|
+
jobs: Array<QueueItem<TItem, TResult>>,
|
|
53
|
+
results: Array<TResult>,
|
|
54
|
+
): void;
|
|
55
|
+
_onBatchError(jobs: Array<QueueItem<TItem, TResult>>, error: unknown): void;
|
|
56
|
+
_processQueue(): void;
|
|
57
|
+
_processQueueOnceReady(): void;
|
|
58
|
+
queue(item: TItem): Promise<TResult>;
|
|
59
|
+
getQueueLength(): number;
|
|
60
|
+
}
|
|
61
|
+
export default BatchProcessor;
|
|
@@ -7,11 +7,7 @@ exports.default = void 0;
|
|
|
7
7
|
var _invariant = _interopRequireDefault(require("invariant"));
|
|
8
8
|
var _timers = require("timers");
|
|
9
9
|
function _interopRequireDefault(e) {
|
|
10
|
-
return e && e.__esModule
|
|
11
|
-
? e
|
|
12
|
-
: {
|
|
13
|
-
default: e,
|
|
14
|
-
};
|
|
10
|
+
return e && e.__esModule ? e : { default: e };
|
|
15
11
|
}
|
|
16
12
|
class BatchProcessor {
|
|
17
13
|
constructor(options, processBatch) {
|
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
* @noformat
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
* @generated SignedSource<<0fccda5d7f0eb38539316fa1fedae97b>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/lib/CountingSet.js
|
|
13
|
+
* To regenerate, run:
|
|
14
|
+
* js1 build metro-ts-defs (internal) OR
|
|
15
|
+
* yarn run build-ts-defs (OSS)
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
export interface ReadOnlyCountingSet<T> extends Iterable<T> {
|
|
19
|
+
has(item: T): boolean;
|
|
20
|
+
readonly size: number;
|
|
21
|
+
count(item: T): number;
|
|
22
|
+
forEach<ThisT>(
|
|
23
|
+
callbackFn: (
|
|
24
|
+
this: ThisT,
|
|
25
|
+
value: T,
|
|
26
|
+
key: T,
|
|
27
|
+
set: ReadOnlyCountingSet<T>,
|
|
28
|
+
) => unknown,
|
|
29
|
+
thisArg: ThisT,
|
|
30
|
+
): void;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* A Set that only deletes a given item when the number of delete(item) calls
|
|
34
|
+
* matches the number of add(item) calls. Iteration and `size` are in terms of
|
|
35
|
+
* *unique* items.
|
|
36
|
+
*/
|
|
37
|
+
declare class CountingSet<T> implements ReadOnlyCountingSet<T> {
|
|
38
|
+
constructor(items?: Iterable<T>);
|
|
39
|
+
has(item: T): boolean;
|
|
40
|
+
add(item: T): void;
|
|
41
|
+
delete(item: T): void;
|
|
42
|
+
keys(): Iterator<T>;
|
|
43
|
+
values(): Iterator<T>;
|
|
44
|
+
entries(): Iterator<[T, T]>;
|
|
45
|
+
[Symbol.iterator](): Iterator<T>;
|
|
46
|
+
get size(): number;
|
|
47
|
+
count(item: T): number;
|
|
48
|
+
clear(): void;
|
|
49
|
+
forEach<ThisT>(
|
|
50
|
+
callbackFn: (this: ThisT, value: T, key: T, set: CountingSet<T>) => unknown,
|
|
51
|
+
thisArg: ThisT,
|
|
52
|
+
): void;
|
|
53
|
+
toJSON(): unknown;
|
|
54
|
+
}
|
|
55
|
+
export default CountingSet;
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
* @noformat
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
* @generated SignedSource<<e7173f8dc5e076fd37b9a1cecd581f58>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/lib/JsonReporter.js
|
|
13
|
+
* To regenerate, run:
|
|
14
|
+
* js1 build metro-ts-defs (internal) OR
|
|
15
|
+
* yarn run build-ts-defs (OSS)
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import type {Writable} from 'stream';
|
|
19
|
+
|
|
20
|
+
export type SerializedError = {
|
|
21
|
+
message: string;
|
|
22
|
+
stack: string;
|
|
23
|
+
errors?: ReadonlyArray<SerializedError>;
|
|
24
|
+
cause?: SerializedError;
|
|
25
|
+
};
|
|
26
|
+
export type SerializedEvent<
|
|
27
|
+
TEvent extends {readonly [$$Key$$: string]: unknown},
|
|
28
|
+
> = TEvent extends {error: Error}
|
|
29
|
+
? Omit<Omit<TEvent, 'error'>, keyof {error: SerializedError}> & {
|
|
30
|
+
error: SerializedError;
|
|
31
|
+
}
|
|
32
|
+
: TEvent;
|
|
33
|
+
declare class JsonReporter<
|
|
34
|
+
TEvent extends {readonly [$$Key$$: string]: unknown},
|
|
35
|
+
> {
|
|
36
|
+
_stream: Writable;
|
|
37
|
+
constructor(stream: Writable);
|
|
38
|
+
/**
|
|
39
|
+
* There is a special case for errors because they have non-enumerable fields.
|
|
40
|
+
* (Perhaps we should switch in favor of plain object?)
|
|
41
|
+
*/
|
|
42
|
+
update(event: TEvent): void;
|
|
43
|
+
}
|
|
44
|
+
export default JsonReporter;
|
|
@@ -19,7 +19,7 @@ export type SerializedError = {
|
|
|
19
19
|
...
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
export type SerializedEvent<TEvent
|
|
22
|
+
export type SerializedEvent<TEvent extends {+[string]: unknown, ...}> =
|
|
23
23
|
TEvent extends {
|
|
24
24
|
error: Error,
|
|
25
25
|
...
|
|
@@ -31,7 +31,7 @@ export type SerializedEvent<TEvent: {+[string]: unknown, ...}> =
|
|
|
31
31
|
}
|
|
32
32
|
: TEvent;
|
|
33
33
|
|
|
34
|
-
export default class JsonReporter<TEvent
|
|
34
|
+
export default class JsonReporter<TEvent extends {+[string]: unknown, ...}> {
|
|
35
35
|
_stream: Writable;
|
|
36
36
|
|
|
37
37
|
constructor(stream: Writable) {
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
* @noformat
|
|
8
|
+
* @generated SignedSource<<ebddbde1dcdecbbee129fd96caaf3bb0>>
|
|
9
|
+
*
|
|
10
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
11
|
+
* Original file: packages/metro/src/lib/RamBundleParser.js
|
|
12
|
+
* To regenerate, run:
|
|
13
|
+
* js1 build metro-ts-defs (internal) OR
|
|
14
|
+
* yarn run build-ts-defs (OSS)
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Implementation of a RAM bundle parser in JS.
|
|
19
|
+
*
|
|
20
|
+
* It receives a Buffer as an input and implements two main methods, which are
|
|
21
|
+
* able to run in constant time no matter the size of the bundle:
|
|
22
|
+
*
|
|
23
|
+
* getStartupCode(): returns the runtime and the startup code of the bundle.
|
|
24
|
+
* getModule(): returns the code for the specified module.
|
|
25
|
+
*/
|
|
26
|
+
declare class RamBundleParser {
|
|
27
|
+
_buffer: Buffer;
|
|
28
|
+
_numModules: number;
|
|
29
|
+
_startupCodeLength: number;
|
|
30
|
+
_startOffset: number;
|
|
31
|
+
constructor(buffer: Buffer);
|
|
32
|
+
_readPosition(pos: number): number;
|
|
33
|
+
getStartupCode(): string;
|
|
34
|
+
getModule(id: number): string;
|
|
35
|
+
}
|
|
36
|
+
export default RamBundleParser;
|
|
@@ -8,11 +8,7 @@ var _magicNumber = _interopRequireDefault(
|
|
|
8
8
|
require("../shared/output/RamBundle/magic-number"),
|
|
9
9
|
);
|
|
10
10
|
function _interopRequireDefault(e) {
|
|
11
|
-
return e && e.__esModule
|
|
12
|
-
? e
|
|
13
|
-
: {
|
|
14
|
-
default: e,
|
|
15
|
-
};
|
|
11
|
+
return e && e.__esModule ? e : { default: e };
|
|
16
12
|
}
|
|
17
13
|
const SIZEOF_UINT32 = 4;
|
|
18
14
|
const HEADER_SIZE = 3;
|
|
@@ -0,0 +1,125 @@
|
|
|
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
|
+
* @noformat
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
* @generated SignedSource<<8218e45d6b5186264c4bf9e54086708a>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/lib/TerminalReporter.js
|
|
13
|
+
* To regenerate, run:
|
|
14
|
+
* js1 build metro-ts-defs (internal) OR
|
|
15
|
+
* yarn run build-ts-defs (OSS)
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import type {BundleDetails, ReportableEvent} from './reporting';
|
|
19
|
+
import type {Terminal} from 'metro-core';
|
|
20
|
+
import type {HealthCheckResult, WatcherStatus} from 'metro-file-map';
|
|
21
|
+
|
|
22
|
+
type BundleProgress = {
|
|
23
|
+
bundleDetails: BundleDetails;
|
|
24
|
+
transformedFileCount: number;
|
|
25
|
+
totalFileCount: number;
|
|
26
|
+
ratio: number;
|
|
27
|
+
isPrefetch?: boolean;
|
|
28
|
+
};
|
|
29
|
+
export type TerminalReportableEvent =
|
|
30
|
+
| ReportableEvent
|
|
31
|
+
| {
|
|
32
|
+
buildID: string;
|
|
33
|
+
type: 'bundle_transform_progressed_throttled';
|
|
34
|
+
transformedFileCount: number;
|
|
35
|
+
totalFileCount: number;
|
|
36
|
+
}
|
|
37
|
+
| {
|
|
38
|
+
type: 'unstable_server_log';
|
|
39
|
+
level: 'info' | 'warn' | 'error';
|
|
40
|
+
data: string | Array<unknown>;
|
|
41
|
+
}
|
|
42
|
+
| {type: 'unstable_server_menu_updated'; message: string}
|
|
43
|
+
| {type: 'unstable_server_menu_cleared'};
|
|
44
|
+
type BuildPhase = 'in_progress' | 'done' | 'failed';
|
|
45
|
+
interface SnippetError extends Error {
|
|
46
|
+
code?: string;
|
|
47
|
+
filename?: string;
|
|
48
|
+
snippet?: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* We try to print useful information to the terminal for interactive builds.
|
|
52
|
+
* This implements the `Reporter` interface from the './reporting' module.
|
|
53
|
+
*/
|
|
54
|
+
declare class TerminalReporter {
|
|
55
|
+
/**
|
|
56
|
+
* The bundle builds for which we are actively maintaining the status on the
|
|
57
|
+
* terminal, ie. showing a progress bar. There can be several bundles being
|
|
58
|
+
* built at the same time.
|
|
59
|
+
*/
|
|
60
|
+
_activeBundles: Map<string, BundleProgress>;
|
|
61
|
+
_interactionStatus: null | undefined | string;
|
|
62
|
+
_scheduleUpdateBundleProgress: {
|
|
63
|
+
(data: {
|
|
64
|
+
buildID: string;
|
|
65
|
+
transformedFileCount: number;
|
|
66
|
+
totalFileCount: number;
|
|
67
|
+
}): void;
|
|
68
|
+
cancel(): void;
|
|
69
|
+
};
|
|
70
|
+
_prevHealthCheckResult: null | undefined | HealthCheckResult;
|
|
71
|
+
readonly terminal: Terminal;
|
|
72
|
+
constructor(terminal: Terminal);
|
|
73
|
+
/**
|
|
74
|
+
* Construct a message that represents the progress of a
|
|
75
|
+
* single bundle build, for example:
|
|
76
|
+
*
|
|
77
|
+
* BUNDLE path/to/bundle.js ▓▓▓▓▓░░░░░░░░░░░ 36.6% (4790/7922)
|
|
78
|
+
*/
|
|
79
|
+
_getBundleStatusMessage(
|
|
80
|
+
$$PARAM_0$$: BundleProgress,
|
|
81
|
+
phase: BuildPhase,
|
|
82
|
+
): string;
|
|
83
|
+
_logBundleBuildDone(buildID: string): void;
|
|
84
|
+
_logBundleBuildFailed(buildID: string): void;
|
|
85
|
+
_logInitializing(port: number, hasReducedPerformance: boolean): void;
|
|
86
|
+
_logInitializingFailed(port: number, error: SnippetError): void;
|
|
87
|
+
/**
|
|
88
|
+
* This function is only concerned with logging and should not do state
|
|
89
|
+
* or terminal status updates.
|
|
90
|
+
*/
|
|
91
|
+
_log(event: TerminalReportableEvent): void;
|
|
92
|
+
/**
|
|
93
|
+
* We do not want to log the whole stacktrace for bundling error, because
|
|
94
|
+
* these are operational errors, not programming errors, and the stacktrace
|
|
95
|
+
* is not actionable to end users.
|
|
96
|
+
*/
|
|
97
|
+
_logBundlingError(error: SnippetError): void;
|
|
98
|
+
_logWorkerChunk(origin: 'stdout' | 'stderr', chunk: string): void;
|
|
99
|
+
_updateBundleProgress($$PARAM_0$$: {
|
|
100
|
+
buildID: string;
|
|
101
|
+
transformedFileCount: number;
|
|
102
|
+
totalFileCount: number;
|
|
103
|
+
}): void;
|
|
104
|
+
/**
|
|
105
|
+
* This function is exclusively concerned with updating the internal state.
|
|
106
|
+
* No logging or status updates should be done at this point.
|
|
107
|
+
*/
|
|
108
|
+
_updateState(event: TerminalReportableEvent): void;
|
|
109
|
+
/**
|
|
110
|
+
* Return a status message that is always consistent with the current state
|
|
111
|
+
* of the application. Having this single function ensures we don't have
|
|
112
|
+
* different callsites overriding each other status messages.
|
|
113
|
+
*/
|
|
114
|
+
_getStatusMessage(): string;
|
|
115
|
+
_logHmrClientError(e: Error): void;
|
|
116
|
+
_logWarning(message: string): void;
|
|
117
|
+
_logWatcherHealthCheckResult(result: HealthCheckResult): void;
|
|
118
|
+
_logWatcherStatus(status: WatcherStatus): void;
|
|
119
|
+
/**
|
|
120
|
+
* Single entry point for reporting events. That allows us to implement the
|
|
121
|
+
* corresponding JSON reporter easily and have a consistent reporting.
|
|
122
|
+
*/
|
|
123
|
+
update(event: TerminalReportableEvent): void;
|
|
124
|
+
}
|
|
125
|
+
export default TerminalReporter;
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true,
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
var _bundleProgressUtils = require("./bundleProgressUtils");
|
|
7
8
|
var _logToConsole = _interopRequireDefault(require("./logToConsole"));
|
|
8
9
|
var reporting = _interopRequireWildcard(require("./reporting"));
|
|
9
10
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
@@ -18,10 +19,7 @@ function _interopRequireWildcard(e, t) {
|
|
|
18
19
|
if (!t && e && e.__esModule) return e;
|
|
19
20
|
var o,
|
|
20
21
|
i,
|
|
21
|
-
f = {
|
|
22
|
-
__proto__: null,
|
|
23
|
-
default: e,
|
|
24
|
-
};
|
|
22
|
+
f = { __proto__: null, default: e };
|
|
25
23
|
if (null === e || ("object" != typeof e && "function" != typeof e))
|
|
26
24
|
return f;
|
|
27
25
|
if ((o = t ? n : r)) {
|
|
@@ -41,11 +39,7 @@ function _interopRequireWildcard(e, t) {
|
|
|
41
39
|
})(e, t);
|
|
42
40
|
}
|
|
43
41
|
function _interopRequireDefault(e) {
|
|
44
|
-
return e && e.__esModule
|
|
45
|
-
? e
|
|
46
|
-
: {
|
|
47
|
-
default: e,
|
|
48
|
-
};
|
|
42
|
+
return e && e.__esModule ? e : { default: e };
|
|
49
43
|
}
|
|
50
44
|
const DARK_BLOCK_CHAR = "\u2593";
|
|
51
45
|
const LIGHT_BLOCK_CHAR = "\u2591";
|
|
@@ -85,7 +79,7 @@ class TerminalReporter {
|
|
|
85
79
|
_chalk.default.bgWhite.white(
|
|
86
80
|
LIGHT_BLOCK_CHAR.repeat(MAX_PROGRESS_BAR_CHAR_WIDTH - filledBar),
|
|
87
81
|
) +
|
|
88
|
-
_chalk.default.bold(` ${(100 * ratio)
|
|
82
|
+
_chalk.default.bold(` ${Math.floor(100 * ratio)}% `) +
|
|
89
83
|
_chalk.default.dim(`(${transformedFileCount}/${totalFileCount})`)
|
|
90
84
|
: "";
|
|
91
85
|
return (
|
|
@@ -294,12 +288,10 @@ class TerminalReporter {
|
|
|
294
288
|
if (currentProgress == null) {
|
|
295
289
|
return;
|
|
296
290
|
}
|
|
297
|
-
const ratio =
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
),
|
|
302
|
-
0.999,
|
|
291
|
+
const ratio = (0, _bundleProgressUtils.calculateBundleProgressRatio)(
|
|
292
|
+
transformedFileCount,
|
|
293
|
+
totalFileCount,
|
|
294
|
+
currentProgress.ratio,
|
|
303
295
|
);
|
|
304
296
|
Object.assign(currentProgress, {
|
|
305
297
|
ratio,
|