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.
Files changed (158) hide show
  1. package/package.json +28 -25
  2. package/src/Assets.js +42 -29
  3. package/src/Assets.js.flow +26 -15
  4. package/src/Bundler/util.js +25 -21
  5. package/src/Bundler/util.js.flow +2 -2
  6. package/src/Bundler.js.flow +1 -1
  7. package/src/DeltaBundler/DeltaCalculator.js +4 -4
  8. package/src/DeltaBundler/DeltaCalculator.js.flow +8 -8
  9. package/src/DeltaBundler/Graph.js +16 -16
  10. package/src/DeltaBundler/Graph.js.flow +30 -30
  11. package/src/DeltaBundler/Serializers/baseJSBundle.js.flow +1 -1
  12. package/src/DeltaBundler/Serializers/getAllFiles.js.flow +2 -2
  13. package/src/DeltaBundler/Serializers/getAssets.js.flow +2 -2
  14. package/src/DeltaBundler/Serializers/getExplodedSourceMap.js.flow +2 -2
  15. package/src/DeltaBundler/Serializers/getRamBundleInfo.js.flow +8 -8
  16. package/src/DeltaBundler/Serializers/helpers/js.js +25 -21
  17. package/src/DeltaBundler/Serializers/helpers/js.js.flow +6 -6
  18. package/src/DeltaBundler/Serializers/helpers/processModules.js.flow +3 -3
  19. package/src/DeltaBundler/Serializers/hmrJSBundle.js +25 -21
  20. package/src/DeltaBundler/Serializers/hmrJSBundle.js.flow +5 -5
  21. package/src/DeltaBundler/Serializers/sourceMapGenerator.js.flow +6 -6
  22. package/src/DeltaBundler/Serializers/sourceMapObject.js.flow +2 -2
  23. package/src/DeltaBundler/Serializers/sourceMapString.js.flow +2 -2
  24. package/src/DeltaBundler/Transformer.js.flow +3 -3
  25. package/src/DeltaBundler/Worker.flow.js.flow +1 -1
  26. package/src/DeltaBundler/WorkerFarm.js +1 -1
  27. package/src/DeltaBundler/WorkerFarm.js.flow +26 -13
  28. package/src/DeltaBundler/buildSubgraph.js +4 -4
  29. package/src/DeltaBundler/buildSubgraph.js.flow +8 -8
  30. package/src/DeltaBundler/types.js.flow +36 -34
  31. package/src/DeltaBundler.js.flow +2 -2
  32. package/src/HmrServer.js +34 -29
  33. package/src/HmrServer.js.flow +17 -12
  34. package/src/IncrementalBundler.js +29 -21
  35. package/src/IncrementalBundler.js.flow +13 -9
  36. package/src/ModuleGraph/worker/JsFileWrapping.js +25 -21
  37. package/src/ModuleGraph/worker/JsFileWrapping.js.flow +10 -5
  38. package/src/ModuleGraph/worker/collectDependencies.js +25 -21
  39. package/src/ModuleGraph/worker/collectDependencies.js.flow +27 -21
  40. package/src/ModuleGraph/worker/generateImportNames.js.flow +4 -2
  41. package/src/ModuleGraph/worker/importLocationsPlugin.js.flow +7 -3
  42. package/src/Server/MultipartResponse.js.flow +1 -1
  43. package/src/Server/symbolicate.js.flow +4 -4
  44. package/src/Server.js +139 -39
  45. package/src/Server.js.flow +158 -47
  46. package/src/cli/parseKeyValueParamArray.js.flow +1 -1
  47. package/src/cli-utils.js.flow +2 -2
  48. package/src/commands/build.js.flow +11 -10
  49. package/src/commands/dependencies.js.flow +8 -4
  50. package/src/commands/serve.js +2 -0
  51. package/src/commands/serve.js.flow +14 -9
  52. package/src/index.flow.js +30 -26
  53. package/src/index.flow.js.flow +25 -20
  54. package/src/integration_tests/basic_bundle/AssetRegistry.js.flow +1 -1
  55. package/src/integration_tests/basic_bundle/ErrorBundle.js.flow +1 -1
  56. package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-import.js.flow +1 -1
  57. package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-multi-line-import-with-escapes.js.flow +1 -1
  58. package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-multi-line-import.js.flow +1 -1
  59. package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-require-with-embedded-comment.js.flow +1 -1
  60. package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-require.js.flow +1 -1
  61. package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-specifier-with-escapes.js.flow +1 -1
  62. package/src/integration_tests/basic_bundle/build-errors/inline-requires-cannot-resolve-import.js.flow +1 -1
  63. package/src/integration_tests/basic_bundle/build-errors/inline-requires-cannot-resolve-require.js.flow +1 -1
  64. package/src/integration_tests/basic_bundle/import-export/index.js +25 -21
  65. package/src/integration_tests/basic_bundle/import-export/index.js.flow +3 -3
  66. package/src/integration_tests/basic_bundle/import-export/utils.js.flow +2 -2
  67. package/src/integration_tests/basic_bundle/loadBundleAsyncForTest.js.flow +1 -1
  68. package/src/integration_tests/basic_bundle/optional-dependencies/index.js.flow +1 -1
  69. package/src/integration_tests/basic_bundle/require-context/conflict.js.flow +1 -1
  70. package/src/integration_tests/basic_bundle/require-context/empty.js.flow +1 -1
  71. package/src/integration_tests/basic_bundle/require-context/matching.js.flow +1 -1
  72. package/src/integration_tests/basic_bundle/require-context/mode-eager.js.flow +1 -1
  73. package/src/integration_tests/basic_bundle/require-context/mode-lazy-once.js.flow +1 -1
  74. package/src/integration_tests/basic_bundle/require-context/mode-lazy.js.flow +1 -1
  75. package/src/integration_tests/basic_bundle/require-context/mode-sync.js.flow +2 -2
  76. package/src/integration_tests/basic_bundle/require-context/utils.js.flow +1 -1
  77. package/src/integration_tests/basic_bundle/require-resolveWeak/import-and-resolveWeak.js.flow +1 -1
  78. package/src/integration_tests/basic_bundle/require-resolveWeak/multiple.js.flow +1 -1
  79. package/src/integration_tests/basic_bundle/require-resolveWeak/never-required.js.flow +1 -1
  80. package/src/integration_tests/basic_bundle/require-resolveWeak/require-and-resolveWeak.js.flow +1 -1
  81. package/src/integration_tests/execBundle.js.flow +1 -1
  82. package/src/lib/BatchProcessor.js +5 -2
  83. package/src/lib/BatchProcessor.js.flow +10 -7
  84. package/src/lib/CountingSet.js.flow +4 -4
  85. package/src/lib/JsonReporter.js +5 -3
  86. package/src/lib/JsonReporter.js.flow +19 -17
  87. package/src/lib/RamBundleParser.js.flow +1 -1
  88. package/src/lib/TerminalReporter.js +31 -27
  89. package/src/lib/TerminalReporter.js.flow +15 -15
  90. package/src/lib/contextModule.js.flow +1 -1
  91. package/src/lib/contextModuleTemplates.js +25 -21
  92. package/src/lib/countLines.js +4 -3
  93. package/src/lib/countLines.js.flow +3 -4
  94. package/src/lib/createWebsocketServer.js +9 -2
  95. package/src/lib/createWebsocketServer.js.flow +16 -9
  96. package/src/lib/debounceAsyncQueue.js.flow +1 -1
  97. package/src/lib/formatBundlingError.js.flow +1 -1
  98. package/src/lib/getAppendScripts.js.flow +4 -4
  99. package/src/lib/getGraphId.js.flow +1 -1
  100. package/src/lib/getPreludeCode.js +4 -0
  101. package/src/lib/getPreludeCode.js.flow +10 -3
  102. package/src/lib/getPrependedScripts.js +36 -22
  103. package/src/lib/getPrependedScripts.js.flow +10 -3
  104. package/src/lib/logToConsole.js.flow +2 -2
  105. package/src/lib/parseBundleOptionsFromBundleRequestUrl.js +25 -21
  106. package/src/lib/parseCustomResolverOptions.js.flow +2 -2
  107. package/src/lib/parseCustomTransformOptions.js.flow +1 -1
  108. package/src/lib/parseJsonBody.js.flow +11 -1
  109. package/src/lib/pathUtils.js +25 -21
  110. package/src/lib/pathUtils.js.flow +1 -1
  111. package/src/lib/reporting.js.flow +4 -4
  112. package/src/lib/transformHelpers.js +11 -9
  113. package/src/lib/transformHelpers.js.flow +17 -15
  114. package/src/node-haste/DependencyGraph/ModuleResolution.js +48 -42
  115. package/src/node-haste/DependencyGraph/ModuleResolution.js.flow +35 -32
  116. package/src/node-haste/DependencyGraph/createFileMap.js +56 -38
  117. package/src/node-haste/DependencyGraph/createFileMap.js.flow +44 -18
  118. package/src/node-haste/DependencyGraph.js +40 -31
  119. package/src/node-haste/DependencyGraph.js.flow +35 -37
  120. package/src/node-haste/lib/AssetPaths.js +2 -2
  121. package/src/node-haste/lib/AssetPaths.js.flow +4 -4
  122. package/src/node-haste/lib/parsePlatformFilePath.js +6 -6
  123. package/src/node-haste/lib/parsePlatformFilePath.js.flow +4 -4
  124. package/src/shared/output/RamBundle/as-assets.js.flow +6 -6
  125. package/src/shared/output/RamBundle/as-indexed-file.js.flow +5 -5
  126. package/src/shared/output/RamBundle/buildSourcemapWithMetadata.js.flow +5 -5
  127. package/src/shared/output/RamBundle/util.js.flow +5 -5
  128. package/src/shared/output/RamBundle/write-sourcemap.js.flow +1 -1
  129. package/src/shared/output/RamBundle.js.flow +1 -1
  130. package/src/shared/output/bundle.flow.js.flow +3 -3
  131. package/src/shared/output/meta.js +2 -2
  132. package/src/shared/output/meta.js.flow +1 -1
  133. package/src/shared/output/writeFile.js +8 -3
  134. package/src/shared/output/writeFile.js.flow +8 -2
  135. package/src/shared/types.js.flow +20 -5
  136. package/src/Asset.d.ts +0 -25
  137. package/src/Bundler.d.ts +0 -39
  138. package/src/DeltaBundler/Graph.d.ts +0 -40
  139. package/src/DeltaBundler/Serializers/getExplodedSourceMap.d.ts +0 -26
  140. package/src/DeltaBundler/Serializers/getRamBundleInfo.d.ts +0 -18
  141. package/src/DeltaBundler/Worker.d.ts +0 -45
  142. package/src/DeltaBundler/types.d.ts +0 -166
  143. package/src/DeltaBundler.d.ts +0 -58
  144. package/src/IncrementalBundler.d.ts +0 -98
  145. package/src/ModuleGraph/test-helpers.js +0 -75
  146. package/src/ModuleGraph/worker/collectDependencies.d.ts +0 -27
  147. package/src/Server/MultipartResponse.d.ts +0 -31
  148. package/src/Server/symbolicate.d.ts +0 -31
  149. package/src/Server.d.ts +0 -118
  150. package/src/index.d.ts +0 -193
  151. package/src/lib/CountingSet.d.ts +0 -48
  152. package/src/lib/TerminalReporter.d.ts +0 -27
  153. package/src/lib/contextModule.d.ts +0 -22
  154. package/src/lib/getGraphId.d.ts +0 -11
  155. package/src/lib/reporting.d.ts +0 -144
  156. package/src/node-haste/DependencyGraph.d.ts +0 -62
  157. package/src/shared/output/bundle.d.ts +0 -35
  158. 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 _getRequireWildcardCache(e) {
75
- if ("function" != typeof WeakMap) return null;
76
- var r = new WeakMap(),
77
- t = new WeakMap();
78
- return (_getRequireWildcardCache = function (e) {
79
- return e ? t : r;
80
- })(e);
81
- }
82
- function _interopRequireWildcard(e, r) {
83
- if (!r && e && e.__esModule) return e;
84
- if (null === e || ("object" != typeof e && "function" != typeof e))
85
- return { default: e };
86
- var t = _getRequireWildcardCache(r);
87
- if (t && t.has(e)) return t.get(e);
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
- return ((n.default = e), t && t.set(e, n), n);
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
- ...websocketEndpoints,
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 =
@@ -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 {Server as HttpsServer} from 'https';
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 = $ReadOnly<{
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?: Object,
78
+ secureServerOptions?: HttpsServerOptions,
75
79
  secure?: boolean, // deprecated
76
80
  secureCert?: string, // deprecated
77
81
  secureKey?: string, // deprecated
78
- unstable_extraMiddleware?: $ReadOnlyArray<HandleFunction>,
82
+ unstable_extraMiddleware?: ReadonlyArray<HandleFunction>,
79
83
  waitForBundler?: boolean,
80
84
  watch?: boolean,
81
- websocketEndpoints?: $ReadOnly<{
82
- [path: string]: ws$WebSocketServer,
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: $ReadOnlyArray<string>,
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?: $ReadOnly<{
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?: $ReadOnlyArray<AssetData>,
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<mixed>,
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?: $ReadOnlyArray<AssetData>,
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
- ...websocketEndpoints,
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?: any,
518
+ dependencies?: DependenciesCommandOptions,
514
519
  ...
515
520
  };
516
521
 
@@ -11,7 +11,7 @@
11
11
  'use strict';
12
12
 
13
13
  module.exports = {
14
- registerAsset(data: mixed): mixed {
14
+ registerAsset(data: unknown): unknown {
15
15
  return data;
16
16
  },
17
17
  };
@@ -20,4 +20,4 @@ const calcSum = (value: string) => {
20
20
  return error;
21
21
  };
22
22
 
23
- module.exports = (calcSum('anything'): Error);
23
+ module.exports = calcSum('anything') as Error;
@@ -14,4 +14,4 @@ import type DoesNotExistT from './does-not-exist';
14
14
  // $FlowExpectedError[cannot-resolve-module]
15
15
  import DoesNotExist from './does-not-exist';
16
16
 
17
- global.x = (DoesNotExist: DoesNotExistT);
17
+ global.x = DoesNotExist as DoesNotExistT;
@@ -26,4 +26,4 @@ import {
26
26
  // $FlowExpectedError[cannot-resolve-module]
27
27
  } from './does-not\'"-exist';
28
28
 
29
- global.x = (aaaaaaaaaa: DoesNotExistT);
29
+ global.x = aaaaaaaaaa as DoesNotExistT;
@@ -26,4 +26,4 @@ import {
26
26
  // $FlowExpectedError[cannot-resolve-module]
27
27
  } from './does-not-exist';
28
28
 
29
- global.x = (aaaaaaaaaa: DoesNotExistT);
29
+ global.x = aaaaaaaaaa as DoesNotExistT;
@@ -14,4 +14,4 @@ import type DoesNotExistT from './foo';
14
14
  // $FlowExpectedError[cannot-resolve-module]
15
15
  const DoesNotExist = require('./foo' /* ./foo */);
16
16
 
17
- global.x = (DoesNotExist: DoesNotExistT);
17
+ global.x = DoesNotExist as DoesNotExistT;
@@ -14,4 +14,4 @@ import type DoesNotExistT from './does-not-exist';
14
14
  // $FlowExpectedError[cannot-resolve-module]
15
15
  const DoesNotExist = require('./does-not-exist');
16
16
 
17
- global.x = (DoesNotExist: DoesNotExistT);
17
+ global.x = DoesNotExist as DoesNotExistT;
@@ -16,4 +16,4 @@ import type DoesNotExistT from './does-not\'"-exist';
16
16
  // $FlowExpectedError[cannot-resolve-module]
17
17
  import {DoesNotExist} from './does-not\'"-exist';
18
18
 
19
- global.x = (DoesNotExist: DoesNotExistT);
19
+ global.x = DoesNotExist as DoesNotExistT;
@@ -14,4 +14,4 @@ import type DoesNotExistT from './does-not-exist';
14
14
  // $FlowExpectedError[cannot-resolve-module]
15
15
  import DoesNotExist from './does-not-exist';
16
16
 
17
- global.x = (DoesNotExist: DoesNotExistT);
17
+ global.x = DoesNotExist as DoesNotExistT;
@@ -14,4 +14,4 @@ import type DoesNotExistT from './does-not-exist';
14
14
  // $FlowExpectedError[cannot-resolve-module]
15
15
  const DoesNotExist = require('./does-not-exist');
16
16
 
17
- global.x = (DoesNotExist: DoesNotExistT);
17
+ global.x = DoesNotExist as DoesNotExistT;
@@ -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 _getRequireWildcardCache(e) {
36
- if ("function" != typeof WeakMap) return null;
37
- var r = new WeakMap(),
38
- t = new WeakMap();
39
- return (_getRequireWildcardCache = function (e) {
40
- return e ? t : r;
41
- })(e);
42
- }
43
- function _interopRequireWildcard(e, r) {
44
- if (!r && e && e.__esModule) return e;
45
- if (null === e || ("object" != typeof e && "function" != typeof e))
46
- return { default: e };
47
- var t = _getRequireWildcardCache(r);
48
- if (t && t.has(e)) return t.get(e);
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
- return ((n.default = e), t && t.set(e, n), n);
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: (myFunction(): string),
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: mixed =
40
+ export const asyncImportMaybeSyncCJS: unknown =
41
41
  require.unstable_importMaybeSync('./export-7');
42
- export const asyncImportMaybeSyncESM: mixed =
42
+ export const asyncImportMaybeSyncESM: unknown =
43
43
  require.unstable_importMaybeSync('./export-8');
@@ -9,6 +9,6 @@
9
9
  */
10
10
 
11
11
  export type RequireWithUnstableImportMaybeSync = {
12
- (id: string | number): mixed,
13
- unstable_importMaybeSync: (id: string) => mixed,
12
+ (id: string | number): unknown,
13
+ unstable_importMaybeSync: (id: string) => unknown,
14
14
  };
@@ -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<mixed>;
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
 
@@ -10,7 +10,7 @@
10
10
 
11
11
  'use strict';
12
12
 
13
- let shouldBeB: mixed, shouldBeC: mixed;
13
+ let shouldBeB: unknown, shouldBeC: unknown;
14
14
  try {
15
15
  // $FlowExpectedError[cannot-resolve-module]
16
16
  shouldBeB = require('./not-exists');
@@ -24,4 +24,4 @@ function main() {
24
24
  };
25
25
  }
26
26
 
27
- module.exports = (main(): mixed);
27
+ module.exports = main() as unknown;
@@ -23,4 +23,4 @@ function main() {
23
23
  return null;
24
24
  }
25
25
 
26
- module.exports = (main(): mixed);
26
+ module.exports = main() as unknown;
@@ -24,4 +24,4 @@ function main() {
24
24
  };
25
25
  }
26
26
 
27
- module.exports = (main(): mixed);
27
+ module.exports = main() as unknown;
@@ -22,4 +22,4 @@ function main() {
22
22
  );
23
23
  }
24
24
 
25
- module.exports = (main(): mixed);
25
+ module.exports = main() as unknown;
@@ -22,4 +22,4 @@ function main() {
22
22
  );
23
23
  }
24
24
 
25
- module.exports = (main(): mixed);
25
+ module.exports = main() as unknown;
@@ -22,4 +22,4 @@ function main() {
22
22
  );
23
23
  }
24
24
 
25
- module.exports = (main(): mixed);
25
+ module.exports = main() as unknown;
@@ -14,11 +14,11 @@ import {copyContextToObject} from './utils';
14
14
 
15
15
  declare var require: RequireWithContext;
16
16
 
17
- function main(): mixed {
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 = (main(): mixed);
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: $ReadOnly<{[key: string]: Promise<T>}>,
36
+ obj: Readonly<{[key: string]: Promise<T>}>,
37
37
  ): Promise<{[key: string]: T}> {
38
38
  const result: {[string]: T} = {};
39
39
  return Promise.all(
@@ -30,4 +30,4 @@ async function main() {
30
30
  };
31
31
  }
32
32
 
33
- module.exports = (main(): mixed);
33
+ module.exports = main() as unknown;
@@ -20,4 +20,4 @@ async function main() {
20
20
  };
21
21
  }
22
22
 
23
- module.exports = (main(): mixed);
23
+ module.exports = main() as unknown;
@@ -18,4 +18,4 @@ function main() {
18
18
  };
19
19
  }
20
20
 
21
- module.exports = (main(): mixed);
21
+ module.exports = main() as unknown;
@@ -30,4 +30,4 @@ function main() {
30
30
  };
31
31
  }
32
32
 
33
- module.exports = (main(): mixed);
33
+ module.exports = main() as unknown;
@@ -11,7 +11,7 @@
11
11
 
12
12
  import vm from 'vm';
13
13
 
14
- module.exports = function execBundle(code: string, context: any = {}): mixed {
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
- clearTimeout(this._timeoutHandle);
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: mixed) => mixed,
28
- resolve: (result: TResult) => mixed,
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: ?TimeoutID;
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: mixed): void {
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
- clearTimeout(this._timeoutHandle);
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) => mixed,
113
- reject: (error: mixed) => mixed,
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
- ) => mixed,
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>) => mixed,
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(): mixed {
124
+ toJSON(): unknown {
125
125
  return [...this].sort();
126
126
  }
127
127
  }