metro 0.83.3 → 0.84.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 +28 -25
- package/src/Assets.js +42 -29
- package/src/Assets.js.flow +26 -15
- package/src/Bundler/util.js +25 -21
- package/src/Bundler/util.js.flow +2 -2
- package/src/Bundler.js.flow +1 -1
- package/src/DeltaBundler/DeltaCalculator.js +4 -4
- package/src/DeltaBundler/DeltaCalculator.js.flow +8 -8
- package/src/DeltaBundler/Graph.js +16 -16
- package/src/DeltaBundler/Graph.js.flow +30 -30
- package/src/DeltaBundler/Serializers/baseJSBundle.js.flow +1 -1
- package/src/DeltaBundler/Serializers/getAllFiles.js.flow +2 -2
- package/src/DeltaBundler/Serializers/getAssets.js.flow +2 -2
- package/src/DeltaBundler/Serializers/getExplodedSourceMap.js.flow +2 -2
- package/src/DeltaBundler/Serializers/getRamBundleInfo.js.flow +8 -8
- 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.js.flow +3 -3
- package/src/DeltaBundler/Serializers/hmrJSBundle.js +25 -21
- package/src/DeltaBundler/Serializers/hmrJSBundle.js.flow +5 -5
- package/src/DeltaBundler/Serializers/sourceMapGenerator.js.flow +6 -6
- package/src/DeltaBundler/Serializers/sourceMapObject.js.flow +2 -2
- package/src/DeltaBundler/Serializers/sourceMapString.js.flow +2 -2
- package/src/DeltaBundler/Transformer.js.flow +3 -3
- package/src/DeltaBundler/Worker.flow.js.flow +1 -1
- package/src/DeltaBundler/WorkerFarm.js +1 -1
- package/src/DeltaBundler/WorkerFarm.js.flow +26 -13
- package/src/DeltaBundler/buildSubgraph.js +4 -4
- package/src/DeltaBundler/buildSubgraph.js.flow +8 -8
- package/src/DeltaBundler/types.js.flow +36 -34
- package/src/DeltaBundler.js.flow +2 -2
- package/src/HmrServer.js +34 -29
- package/src/HmrServer.js.flow +17 -12
- package/src/IncrementalBundler.js +29 -21
- package/src/IncrementalBundler.js.flow +13 -9
- package/src/ModuleGraph/worker/JsFileWrapping.js +25 -21
- package/src/ModuleGraph/worker/JsFileWrapping.js.flow +10 -5
- package/src/ModuleGraph/worker/collectDependencies.js +25 -21
- package/src/ModuleGraph/worker/collectDependencies.js.flow +27 -21
- package/src/ModuleGraph/worker/generateImportNames.js.flow +4 -2
- package/src/ModuleGraph/worker/importLocationsPlugin.js.flow +7 -3
- package/src/Server/MultipartResponse.js.flow +1 -1
- package/src/Server/symbolicate.js.flow +4 -4
- package/src/Server.js +139 -39
- package/src/Server.js.flow +158 -47
- package/src/cli/parseKeyValueParamArray.js.flow +1 -1
- package/src/cli-utils.js.flow +2 -2
- package/src/commands/build.js.flow +11 -10
- package/src/commands/dependencies.js.flow +8 -4
- package/src/commands/serve.js +2 -0
- package/src/commands/serve.js.flow +14 -9
- package/src/index.flow.js +30 -26
- package/src/index.flow.js.flow +25 -20
- 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.js +5 -2
- package/src/lib/BatchProcessor.js.flow +10 -7
- package/src/lib/CountingSet.js.flow +4 -4
- package/src/lib/JsonReporter.js +5 -3
- package/src/lib/JsonReporter.js.flow +19 -17
- package/src/lib/RamBundleParser.js.flow +1 -1
- package/src/lib/TerminalReporter.js +31 -27
- package/src/lib/TerminalReporter.js.flow +15 -15
- package/src/lib/contextModule.js.flow +1 -1
- package/src/lib/contextModuleTemplates.js +25 -21
- package/src/lib/countLines.js +4 -3
- package/src/lib/countLines.js.flow +3 -4
- package/src/lib/createWebsocketServer.js +9 -2
- package/src/lib/createWebsocketServer.js.flow +16 -9
- package/src/lib/debounceAsyncQueue.js.flow +1 -1
- package/src/lib/formatBundlingError.js.flow +1 -1
- package/src/lib/getAppendScripts.js.flow +4 -4
- package/src/lib/getGraphId.js.flow +1 -1
- package/src/lib/getPreludeCode.js +4 -0
- package/src/lib/getPreludeCode.js.flow +10 -3
- package/src/lib/getPrependedScripts.js +36 -22
- package/src/lib/getPrependedScripts.js.flow +10 -3
- package/src/lib/logToConsole.js.flow +2 -2
- package/src/lib/parseBundleOptionsFromBundleRequestUrl.js +25 -21
- package/src/lib/parseCustomResolverOptions.js.flow +2 -2
- package/src/lib/parseCustomTransformOptions.js.flow +1 -1
- package/src/lib/parseJsonBody.js.flow +11 -1
- package/src/lib/pathUtils.js +25 -21
- package/src/lib/pathUtils.js.flow +1 -1
- package/src/lib/reporting.js.flow +4 -4
- package/src/lib/transformHelpers.js +11 -9
- package/src/lib/transformHelpers.js.flow +17 -15
- 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.js +56 -38
- package/src/node-haste/DependencyGraph/createFileMap.js.flow +44 -18
- package/src/node-haste/DependencyGraph.js +40 -31
- package/src/node-haste/DependencyGraph.js.flow +35 -37
- 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.js +6 -6
- package/src/node-haste/lib/parsePlatformFilePath.js.flow +4 -4
- package/src/shared/output/RamBundle/as-assets.js.flow +6 -6
- package/src/shared/output/RamBundle/as-indexed-file.js.flow +5 -5
- package/src/shared/output/RamBundle/buildSourcemapWithMetadata.js.flow +5 -5
- package/src/shared/output/RamBundle/util.js.flow +5 -5
- package/src/shared/output/RamBundle/write-sourcemap.js.flow +1 -1
- package/src/shared/output/RamBundle.js.flow +1 -1
- package/src/shared/output/bundle.flow.js.flow +3 -3
- package/src/shared/output/meta.js +2 -2
- package/src/shared/output/meta.js.flow +1 -1
- package/src/shared/output/writeFile.js +8 -3
- package/src/shared/output/writeFile.js.flow +8 -2
- package/src/shared/types.js.flow +20 -5
- package/src/Asset.d.ts +0 -25
- package/src/Bundler.d.ts +0 -39
- package/src/DeltaBundler/Graph.d.ts +0 -40
- package/src/DeltaBundler/Serializers/getExplodedSourceMap.d.ts +0 -26
- package/src/DeltaBundler/Serializers/getRamBundleInfo.d.ts +0 -18
- package/src/DeltaBundler/Worker.d.ts +0 -45
- package/src/DeltaBundler/types.d.ts +0 -166
- package/src/DeltaBundler.d.ts +0 -58
- package/src/IncrementalBundler.d.ts +0 -98
- package/src/ModuleGraph/test-helpers.js +0 -75
- package/src/ModuleGraph/worker/collectDependencies.d.ts +0 -27
- package/src/Server/MultipartResponse.d.ts +0 -31
- package/src/Server/symbolicate.d.ts +0 -31
- package/src/Server.d.ts +0 -118
- package/src/index.d.ts +0 -193
- package/src/lib/CountingSet.d.ts +0 -48
- package/src/lib/TerminalReporter.d.ts +0 -27
- package/src/lib/contextModule.d.ts +0 -22
- package/src/lib/getGraphId.d.ts +0 -11
- package/src/lib/reporting.d.ts +0 -144
- package/src/node-haste/DependencyGraph.d.ts +0 -62
- package/src/shared/output/bundle.d.ts +0 -35
- package/src/shared/types.d.ts +0 -130
package/src/index.flow.js
CHANGED
|
@@ -71,28 +71,32 @@ var _metroConfig = require("metro-config");
|
|
|
71
71
|
var _metroCore = require("metro-core");
|
|
72
72
|
var _net = _interopRequireDefault(require("net"));
|
|
73
73
|
var _nullthrows = _interopRequireDefault(require("nullthrows"));
|
|
74
|
-
function
|
|
75
|
-
if ("function"
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
return (
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
var n = { __proto__: null },
|
|
89
|
-
a = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
90
|
-
for (var u in e)
|
|
91
|
-
if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
|
|
92
|
-
var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;
|
|
93
|
-
i && (i.get || i.set) ? Object.defineProperty(n, u, i) : (n[u] = e[u]);
|
|
74
|
+
function _interopRequireWildcard(e, t) {
|
|
75
|
+
if ("function" == typeof WeakMap)
|
|
76
|
+
var r = new WeakMap(),
|
|
77
|
+
n = new WeakMap();
|
|
78
|
+
return (_interopRequireWildcard = function (e, t) {
|
|
79
|
+
if (!t && e && e.__esModule) return e;
|
|
80
|
+
var o,
|
|
81
|
+
i,
|
|
82
|
+
f = { __proto__: null, default: e };
|
|
83
|
+
if (null === e || ("object" != typeof e && "function" != typeof e))
|
|
84
|
+
return f;
|
|
85
|
+
if ((o = t ? n : r)) {
|
|
86
|
+
if (o.has(e)) return o.get(e);
|
|
87
|
+
o.set(e, f);
|
|
94
88
|
}
|
|
95
|
-
|
|
89
|
+
for (const t in e)
|
|
90
|
+
"default" !== t &&
|
|
91
|
+
{}.hasOwnProperty.call(e, t) &&
|
|
92
|
+
((i =
|
|
93
|
+
(o = Object.defineProperty) &&
|
|
94
|
+
Object.getOwnPropertyDescriptor(e, t)) &&
|
|
95
|
+
(i.get || i.set)
|
|
96
|
+
? o(f, t, i)
|
|
97
|
+
: (f[t] = e[t]));
|
|
98
|
+
return f;
|
|
99
|
+
})(e, t);
|
|
96
100
|
}
|
|
97
101
|
function _interopRequireDefault(e) {
|
|
98
102
|
return e && e.__esModule ? e : { default: e };
|
|
@@ -190,7 +194,7 @@ const runServer = async (
|
|
|
190
194
|
secureKey,
|
|
191
195
|
unstable_extraMiddleware,
|
|
192
196
|
waitForBundler = false,
|
|
193
|
-
websocketEndpoints = {},
|
|
197
|
+
websocketEndpoints: userWebsocketEndpoints = {},
|
|
194
198
|
watch,
|
|
195
199
|
} = {},
|
|
196
200
|
) => {
|
|
@@ -219,7 +223,7 @@ const runServer = async (
|
|
|
219
223
|
}
|
|
220
224
|
serverApp.use(middleware);
|
|
221
225
|
let httpServer;
|
|
222
|
-
if (secure || secureServerOptions != null) {
|
|
226
|
+
if (secure === true || secureServerOptions != null) {
|
|
223
227
|
let options = secureServerOptions;
|
|
224
228
|
if (typeof secureKey === "string" && typeof secureCert === "string") {
|
|
225
229
|
options = {
|
|
@@ -247,8 +251,8 @@ const runServer = async (
|
|
|
247
251
|
port,
|
|
248
252
|
family,
|
|
249
253
|
});
|
|
250
|
-
websocketEndpoints = {
|
|
251
|
-
...
|
|
254
|
+
const websocketEndpoints = {
|
|
255
|
+
...userWebsocketEndpoints,
|
|
252
256
|
"/hot": (0, _createWebsocketServer.default)({
|
|
253
257
|
websocketServer: new _HmrServer.default(
|
|
254
258
|
metroServer.getBundler(),
|
|
@@ -349,7 +353,7 @@ const runBuild = async (
|
|
|
349
353
|
if (onComplete) {
|
|
350
354
|
onComplete();
|
|
351
355
|
}
|
|
352
|
-
if (out || bundleOut) {
|
|
356
|
+
if (out != null || bundleOut != null) {
|
|
353
357
|
const bundleOutput =
|
|
354
358
|
bundleOut ?? (0, _nullthrows.default)(out).replace(/(\.js)?$/, ".js");
|
|
355
359
|
const sourcemapOutput =
|
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> => {
|
|
@@ -302,7 +307,7 @@ export const runServer = async (
|
|
|
302
307
|
|
|
303
308
|
let httpServer;
|
|
304
309
|
|
|
305
|
-
if (secure || secureServerOptions != null) {
|
|
310
|
+
if (secure === true || secureServerOptions != null) {
|
|
306
311
|
let options = secureServerOptions;
|
|
307
312
|
if (typeof secureKey === 'string' && typeof secureCert === 'string') {
|
|
308
313
|
options = {
|
|
@@ -333,8 +338,8 @@ export const runServer = async (
|
|
|
333
338
|
family,
|
|
334
339
|
});
|
|
335
340
|
|
|
336
|
-
websocketEndpoints = {
|
|
337
|
-
...
|
|
341
|
+
const websocketEndpoints = {
|
|
342
|
+
...userWebsocketEndpoints,
|
|
338
343
|
'/hot': createWebsocketServer({
|
|
339
344
|
websocketServer: new MetroHmrServer(
|
|
340
345
|
metroServer.getBundler(),
|
|
@@ -441,7 +446,7 @@ export const runBuild = async (
|
|
|
441
446
|
onComplete();
|
|
442
447
|
}
|
|
443
448
|
|
|
444
|
-
if (out || bundleOut) {
|
|
449
|
+
if (out != null || bundleOut != null) {
|
|
445
450
|
const bundleOutput =
|
|
446
451
|
bundleOut ?? nullthrows(out).replace(/(\.js)?$/, '.js');
|
|
447
452
|
|
|
@@ -510,7 +515,7 @@ export const buildGraph = async function (
|
|
|
510
515
|
type AttachMetroCLIOptions = {
|
|
511
516
|
build?: BuildCommandOptions,
|
|
512
517
|
serve?: ServeCommandOptions,
|
|
513
|
-
dependencies?:
|
|
518
|
+
dependencies?: DependenciesCommandOptions,
|
|
514
519
|
...
|
|
515
520
|
};
|
|
516
521
|
|
|
@@ -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
|
}
|
|
@@ -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();
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
|
|
12
12
|
export interface ReadOnlyCountingSet<T> extends Iterable<T> {
|
|
13
13
|
has(item: T): boolean;
|
|
14
|
-
@@iterator(): Iterator<T>;
|
|
15
14
|
+size: number;
|
|
16
15
|
count(item: T): number;
|
|
17
16
|
forEach<ThisT>(
|
|
@@ -20,7 +19,7 @@ export interface ReadOnlyCountingSet<T> extends Iterable<T> {
|
|
|
20
19
|
value: T,
|
|
21
20
|
key: T,
|
|
22
21
|
set: ReadOnlyCountingSet<T>,
|
|
23
|
-
) =>
|
|
22
|
+
) => unknown,
|
|
24
23
|
|
|
25
24
|
// NOTE: Should be optional, but Flow seems happy to infer undefined here
|
|
26
25
|
// which is what we want.
|
|
@@ -88,6 +87,7 @@ export default class CountingSet<T> implements ReadOnlyCountingSet<T> {
|
|
|
88
87
|
|
|
89
88
|
/*::
|
|
90
89
|
// For Flow's benefit
|
|
90
|
+
// $FlowFixMe[duplicate-class-member]
|
|
91
91
|
@@iterator(): Iterator<T> {
|
|
92
92
|
return this.values();
|
|
93
93
|
}
|
|
@@ -108,7 +108,7 @@ export default class CountingSet<T> implements ReadOnlyCountingSet<T> {
|
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
forEach<ThisT>(
|
|
111
|
-
callbackFn: (this: ThisT, value: T, key: T, set: CountingSet<T>) =>
|
|
111
|
+
callbackFn: (this: ThisT, value: T, key: T, set: CountingSet<T>) => unknown,
|
|
112
112
|
thisArg: ThisT,
|
|
113
113
|
): void {
|
|
114
114
|
for (const item of this) {
|
|
@@ -121,7 +121,7 @@ export default class CountingSet<T> implements ReadOnlyCountingSet<T> {
|
|
|
121
121
|
// extend to custom collection classes. Instead let's assume values are
|
|
122
122
|
// sortable ( = strings) and make this look like an array with some stable
|
|
123
123
|
// order.
|
|
124
|
-
toJSON():
|
|
124
|
+
toJSON(): unknown {
|
|
125
125
|
return [...this].sort();
|
|
126
126
|
}
|
|
127
127
|
}
|