metro 0.83.5 → 0.83.7

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 (126) hide show
  1. package/package.json +15 -16
  2. package/src/Assets.d.ts +8 -1
  3. package/src/Assets.js +20 -13
  4. package/src/Assets.js.flow +20 -13
  5. package/src/Bundler/util.d.ts +8 -1
  6. package/src/Bundler/util.js.flow +3 -3
  7. package/src/Bundler.d.ts +8 -1
  8. package/src/DeltaBundler/DeltaCalculator.d.ts +8 -11
  9. package/src/DeltaBundler/DeltaCalculator.js +55 -46
  10. package/src/DeltaBundler/DeltaCalculator.js.flow +72 -61
  11. package/src/DeltaBundler/Graph.d.ts +8 -1
  12. package/src/DeltaBundler/Serializers/baseJSBundle.d.ts +8 -1
  13. package/src/DeltaBundler/Serializers/getAllFiles.d.ts +8 -1
  14. package/src/DeltaBundler/Serializers/getAssets.d.ts +8 -1
  15. package/src/DeltaBundler/Serializers/getExplodedSourceMap.d.ts +8 -1
  16. package/src/DeltaBundler/Serializers/getRamBundleInfo.d.ts +8 -1
  17. package/src/DeltaBundler/Serializers/helpers/getInlineSourceMappingURL.d.ts +8 -1
  18. package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.d.ts +8 -1
  19. package/src/DeltaBundler/Serializers/helpers/getTransitiveDependencies.d.ts +8 -1
  20. package/src/DeltaBundler/Serializers/helpers/js.d.ts +8 -1
  21. package/src/DeltaBundler/Serializers/helpers/processModules.d.ts +8 -1
  22. package/src/DeltaBundler/Serializers/hmrJSBundle.d.ts +8 -1
  23. package/src/DeltaBundler/Serializers/sourceMapGenerator.d.ts +8 -1
  24. package/src/DeltaBundler/Serializers/sourceMapObject.d.ts +8 -1
  25. package/src/DeltaBundler/Serializers/sourceMapString.d.ts +8 -1
  26. package/src/DeltaBundler/Transformer.d.ts +8 -1
  27. package/src/DeltaBundler/Worker.d.ts +8 -1
  28. package/src/DeltaBundler/WorkerFarm.d.ts +8 -1
  29. package/src/DeltaBundler/buildSubgraph.d.ts +8 -1
  30. package/src/DeltaBundler/getTransformCacheKey.d.ts +8 -1
  31. package/src/DeltaBundler/getTransformCacheKey.js +3 -1
  32. package/src/DeltaBundler/getTransformCacheKey.js.flow +7 -2
  33. package/src/DeltaBundler/mergeDeltas.d.ts +8 -1
  34. package/src/DeltaBundler/types.d.ts +8 -1
  35. package/src/DeltaBundler.d.ts +8 -1
  36. package/src/HmrServer.d.ts +22 -3
  37. package/src/HmrServer.js +7 -0
  38. package/src/HmrServer.js.flow +15 -5
  39. package/src/IncrementalBundler/GraphNotFoundError.d.ts +8 -1
  40. package/src/IncrementalBundler/ResourceNotFoundError.d.ts +8 -1
  41. package/src/IncrementalBundler/RevisionNotFoundError.d.ts +8 -1
  42. package/src/IncrementalBundler.d.ts +8 -1
  43. package/src/ModuleGraph/worker/JsFileWrapping.d.ts +8 -1
  44. package/src/ModuleGraph/worker/collectDependencies.d.ts +8 -1
  45. package/src/ModuleGraph/worker/collectDependencies.js +52 -0
  46. package/src/ModuleGraph/worker/collectDependencies.js.flow +67 -0
  47. package/src/ModuleGraph/worker/generateImportNames.d.ts +8 -1
  48. package/src/ModuleGraph/worker/importLocationsPlugin.d.ts +8 -1
  49. package/src/Server/MultipartResponse.d.ts +8 -1
  50. package/src/Server/symbolicate.d.ts +8 -1
  51. package/src/Server.d.ts +11 -1
  52. package/src/Server.js +42 -5
  53. package/src/Server.js.flow +45 -5
  54. package/src/cli/parseKeyValueParamArray.d.ts +8 -1
  55. package/src/cli-utils.d.ts +8 -1
  56. package/src/commands/build.d.ts +8 -1
  57. package/src/commands/dependencies.d.ts +8 -1
  58. package/src/commands/serve.d.ts +8 -1
  59. package/src/index.d.ts +29 -3
  60. package/src/index.flow.js +2 -2
  61. package/src/index.flow.js.flow +23 -4
  62. package/src/lib/BatchProcessor.d.ts +8 -1
  63. package/src/lib/CountingSet.d.ts +8 -1
  64. package/src/lib/JsonReporter.d.ts +8 -1
  65. package/src/lib/JsonReporter.js.flow +2 -2
  66. package/src/lib/RamBundleParser.d.ts +8 -1
  67. package/src/lib/TerminalReporter.d.ts +8 -1
  68. package/src/lib/TerminalReporter.js +39 -41
  69. package/src/lib/TerminalReporter.js.flow +51 -32
  70. package/src/lib/bundleProgressUtils.d.ts +8 -1
  71. package/src/lib/bundleToString.d.ts +8 -1
  72. package/src/lib/contextModule.d.ts +8 -1
  73. package/src/lib/contextModuleTemplates.d.ts +8 -1
  74. package/src/lib/countLines.d.ts +8 -1
  75. package/src/lib/createWebsocketServer.d.ts +8 -1
  76. package/src/lib/debounceAsyncQueue.d.ts +8 -1
  77. package/src/lib/formatBundlingError.d.ts +8 -1
  78. package/src/lib/getAppendScripts.d.ts +8 -1
  79. package/src/lib/getAppendScripts.js.flow +2 -2
  80. package/src/lib/getGraphId.d.ts +8 -1
  81. package/src/lib/getPreludeCode.d.ts +8 -1
  82. package/src/lib/getPrependedScripts.d.ts +8 -1
  83. package/src/lib/isResolvedDependency.d.ts +8 -1
  84. package/src/lib/logToConsole.d.ts +8 -1
  85. package/src/lib/logToConsole.js +8 -7
  86. package/src/lib/logToConsole.js.flow +7 -7
  87. package/src/lib/parseBundleOptionsFromBundleRequestUrl.d.ts +8 -1
  88. package/src/lib/parseCustomResolverOptions.d.ts +8 -1
  89. package/src/lib/parseCustomTransformOptions.d.ts +8 -1
  90. package/src/lib/parseJsonBody.d.ts +8 -1
  91. package/src/lib/pathUtils.d.ts +8 -1
  92. package/src/lib/relativizeSourceMap.d.ts +8 -1
  93. package/src/lib/reporting.d.ts +8 -1
  94. package/src/lib/reporting.js +16 -7
  95. package/src/lib/reporting.js.flow +16 -5
  96. package/src/lib/splitBundleOptions.d.ts +8 -1
  97. package/src/lib/transformHelpers.d.ts +8 -1
  98. package/src/node-haste/DependencyGraph/ModuleResolution.d.ts +16 -22
  99. package/src/node-haste/DependencyGraph/ModuleResolution.js +4 -22
  100. package/src/node-haste/DependencyGraph/ModuleResolution.js.flow +10 -59
  101. package/src/node-haste/DependencyGraph/createFileMap.d.ts +8 -1
  102. package/src/node-haste/DependencyGraph/createFileMap.js +1 -2
  103. package/src/node-haste/DependencyGraph/createFileMap.js.flow +4 -3
  104. package/src/node-haste/DependencyGraph.d.ts +9 -5
  105. package/src/node-haste/DependencyGraph.js +22 -11
  106. package/src/node-haste/DependencyGraph.js.flow +24 -13
  107. package/src/node-haste/PackageCache.d.ts +19 -16
  108. package/src/node-haste/PackageCache.js +65 -54
  109. package/src/node-haste/PackageCache.js.flow +103 -79
  110. package/src/node-haste/lib/AssetPaths.d.ts +8 -1
  111. package/src/node-haste/lib/parsePlatformFilePath.d.ts +8 -1
  112. package/src/shared/output/RamBundle/as-assets.d.ts +8 -1
  113. package/src/shared/output/RamBundle/as-indexed-file.d.ts +8 -1
  114. package/src/shared/output/RamBundle/buildSourcemapWithMetadata.d.ts +8 -1
  115. package/src/shared/output/RamBundle/magic-number.d.ts +8 -1
  116. package/src/shared/output/RamBundle/util.d.ts +8 -1
  117. package/src/shared/output/RamBundle/write-sourcemap.d.ts +8 -1
  118. package/src/shared/output/RamBundle.d.ts +8 -1
  119. package/src/shared/output/bundle.d.ts +8 -1
  120. package/src/shared/output/meta.d.ts +8 -1
  121. package/src/shared/output/unbundle.d.ts +8 -1
  122. package/src/shared/output/writeFile.d.ts +8 -1
  123. package/src/shared/types.d.ts +8 -1
  124. package/src/node-haste/Package.d.ts +0 -21
  125. package/src/node-haste/Package.js +0 -28
  126. package/src/node-haste/Package.js.flow +0 -39
@@ -405,6 +405,9 @@ function isOptionalDependency(name, path, state) {
405
405
  if (!allowOptionalDependencies || isExcluded()) {
406
406
  return false;
407
407
  }
408
+ if (isInPromiseChainWithRejectionHandler(path)) {
409
+ return true;
410
+ }
408
411
  let sCount = 0;
409
412
  let p = path;
410
413
  while (p && sCount < 3) {
@@ -422,6 +425,55 @@ function isOptionalDependency(name, path, state) {
422
425
  }
423
426
  return false;
424
427
  }
428
+ function isInPromiseChainWithRejectionHandler(path) {
429
+ let current = path;
430
+ while (current.parentPath != null) {
431
+ const member = current.parentPath;
432
+ if (
433
+ member.node.type !== "MemberExpression" ||
434
+ member.node.object !== current.node ||
435
+ member.node.computed ||
436
+ member.node.property.type !== "Identifier" ||
437
+ member.parentPath == null
438
+ ) {
439
+ return false;
440
+ }
441
+ const call = member.parentPath;
442
+ if (
443
+ call.node.type !== "CallExpression" ||
444
+ call.node.callee !== member.node
445
+ ) {
446
+ return false;
447
+ }
448
+ const propertyName = member.node.property.name;
449
+ const args = call.node.arguments;
450
+ if (
451
+ propertyName === "catch" &&
452
+ args.length >= 1 &&
453
+ isNonNullishCallbackArg(args[0])
454
+ ) {
455
+ return true;
456
+ }
457
+ if (
458
+ propertyName === "then" &&
459
+ args.length >= 2 &&
460
+ isNonNullishCallbackArg(args[1])
461
+ ) {
462
+ return true;
463
+ }
464
+ current = call;
465
+ }
466
+ return false;
467
+ }
468
+ function isNonNullishCallbackArg(arg) {
469
+ if (arg.type === "NullLiteral") {
470
+ return false;
471
+ }
472
+ if (arg.type === "Identifier" && arg.name === "undefined") {
473
+ return false;
474
+ }
475
+ return true;
476
+ }
425
477
  function getModuleNameFromCallArgs(path) {
426
478
  const args = path.get("arguments");
427
479
  if (!Array.isArray(args) || args.length !== 1) {
@@ -630,6 +630,15 @@ function isOptionalDependency(
630
630
  return false;
631
631
  }
632
632
 
633
+ // Treat dynamic imports as optional when a rejection handler is attached
634
+ // close to the import call, e.g.
635
+ // import('x').catch(handler)
636
+ // import('x').then(handler, onReject)
637
+ // import('x').then(...).catch(handler)
638
+ if (isInPromiseChainWithRejectionHandler(path)) {
639
+ return true;
640
+ }
641
+
633
642
  // Valid statement stack for single-level try-block: expressionStatement -> blockStatement -> tryStatement
634
643
  let sCount = 0;
635
644
  let p: ?(NodePath<> | NodePath<BabelNode>) = path;
@@ -652,6 +661,64 @@ function isOptionalDependency(
652
661
  return false;
653
662
  }
654
663
 
664
+ // Walk up a chain of `.then(...)` / `.catch(...)` member calls starting from
665
+ // `path` (typically an `import()` CallExpression) and return true if any
666
+ // chained call provides a rejection handler — either `.catch(handler)` or
667
+ // `.then(_, handler)`. The chain must be unbroken: as soon as the parent is
668
+ // not a member call applied to the previous expression, we stop. This keeps
669
+ // the heuristic local to the import, matching the behaviour of the
670
+ // try/catch heuristic above.
671
+ function isInPromiseChainWithRejectionHandler(path: NodePath<>): boolean {
672
+ let current: NodePath<> = path;
673
+ while (current.parentPath != null) {
674
+ const member = current.parentPath;
675
+ if (
676
+ member.node.type !== 'MemberExpression' ||
677
+ member.node.object !== current.node ||
678
+ member.node.computed ||
679
+ member.node.property.type !== 'Identifier' ||
680
+ member.parentPath == null
681
+ ) {
682
+ return false;
683
+ }
684
+ const call = member.parentPath;
685
+ if (
686
+ call.node.type !== 'CallExpression' ||
687
+ call.node.callee !== member.node
688
+ ) {
689
+ return false;
690
+ }
691
+ const propertyName = member.node.property.name;
692
+ const args = call.node.arguments;
693
+ if (
694
+ propertyName === 'catch' &&
695
+ args.length >= 1 &&
696
+ isNonNullishCallbackArg(args[0])
697
+ ) {
698
+ return true;
699
+ }
700
+ if (
701
+ propertyName === 'then' &&
702
+ args.length >= 2 &&
703
+ isNonNullishCallbackArg(args[1])
704
+ ) {
705
+ return true;
706
+ }
707
+ current = call;
708
+ }
709
+ return false;
710
+ }
711
+
712
+ function isNonNullishCallbackArg(arg: BabelNode): boolean {
713
+ if (arg.type === 'NullLiteral') {
714
+ return false;
715
+ }
716
+ if (arg.type === 'Identifier' && arg.name === 'undefined') {
717
+ return false;
718
+ }
719
+ return true;
720
+ }
721
+
655
722
  function getModuleNameFromCallArgs(path: NodePath<CallExpression>): ?string {
656
723
  const args = path.get('arguments');
657
724
  if (!Array.isArray(args) || args.length !== 1) {
@@ -4,7 +4,14 @@
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
- * @format
7
+ * @noformat
8
+ * @generated SignedSource<<9632d9ca461f1fd6aad9131d7afb5839>>
9
+ *
10
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
11
+ * Original file: packages/metro/src/ModuleGraph/worker/generateImportNames.js
12
+ * To regenerate, run:
13
+ * js1 build metro-ts-defs (internal) OR
14
+ * yarn run build-ts-defs (OSS)
8
15
  */
9
16
 
10
17
  import type {Node} from '@babel/types';
@@ -4,8 +4,15 @@
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
- * @format
7
+ * @noformat
8
8
  * @oncall react_native
9
+ * @generated SignedSource<<644d25f2f9682a306271d052d09b1d2d>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/ModuleGraph/worker/importLocationsPlugin.js
13
+ * To regenerate, run:
14
+ * js1 build metro-ts-defs (internal) OR
15
+ * yarn run build-ts-defs (OSS)
9
16
  */
10
17
 
11
18
  import type {ReadonlySourceLocation} from '../../shared/types';
@@ -4,8 +4,15 @@
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
- * @format
7
+ * @noformat
8
8
  * @oncall react_native
9
+ * @generated SignedSource<<355f5514464c4989f90a211782db41e7>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/Server/MultipartResponse.js
13
+ * To regenerate, run:
14
+ * js1 build metro-ts-defs (internal) OR
15
+ * yarn run build-ts-defs (OSS)
9
16
  */
10
17
 
11
18
  import type {IncomingMessage, ServerResponse} from 'http';
@@ -4,8 +4,15 @@
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
- * @format
7
+ * @noformat
8
8
  * @oncall react_native
9
+ * @generated SignedSource<<74bba01977b0b5887c4bb38eb8fc78ea>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/Server/symbolicate.js
13
+ * To regenerate, run:
14
+ * js1 build metro-ts-defs (internal) OR
15
+ * yarn run build-ts-defs (OSS)
9
16
  */
10
17
 
11
18
  import type {ExplodedSourceMap} from '../DeltaBundler/Serializers/getExplodedSourceMap';
package/src/Server.d.ts CHANGED
@@ -4,8 +4,15 @@
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
- * @format
7
+ * @noformat
8
8
  * @oncall react_native
9
+ * @generated SignedSource<<03b526801403adb05b3b0f6c25b25ed5>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/Server.js
13
+ * To regenerate, run:
14
+ * js1 build metro-ts-defs (internal) OR
15
+ * yarn run build-ts-defs (OSS)
9
16
  */
10
17
 
11
18
  import type {AssetData} from './Assets';
@@ -218,6 +225,9 @@ declare class Server {
218
225
  _explodedSourceMapForBundleOptions(
219
226
  bundleOptions: BundleOptions,
220
227
  ): Promise<ExplodedSourceMap>;
228
+ _resolveWatchFolderPrefix(
229
+ filePath: string,
230
+ ): {rootDir: string; filePath: string} | null;
221
231
  _resolveRelativePath(
222
232
  filePath: string,
223
233
  $$PARAM_1$$: Readonly<{
package/src/Server.js CHANGED
@@ -1347,6 +1347,35 @@ class Server {
1347
1347
  },
1348
1348
  );
1349
1349
  }
1350
+ _resolveWatchFolderPrefix(filePath) {
1351
+ const watchFolderMatch = filePath.match(
1352
+ /^\.\/\[metro-watchFolders\]\/(\d+)\/(.*)/,
1353
+ );
1354
+ if (watchFolderMatch != null) {
1355
+ const index = parseInt(watchFolderMatch[1], 10);
1356
+ const watchFolder = this._config.watchFolders[index];
1357
+ if (watchFolder != null) {
1358
+ return {
1359
+ rootDir: _path.default.resolve(watchFolder),
1360
+ filePath:
1361
+ "." +
1362
+ _path.default.sep +
1363
+ watchFolderMatch[2].split("/").join(_path.default.sep),
1364
+ };
1365
+ }
1366
+ }
1367
+ const projectMatch = filePath.match(/^\.\/\[metro-project\]\/(.*)/);
1368
+ if (projectMatch != null) {
1369
+ return {
1370
+ rootDir: _path.default.resolve(this._config.projectRoot),
1371
+ filePath:
1372
+ "." +
1373
+ _path.default.sep +
1374
+ projectMatch[1].split("/").join(_path.default.sep),
1375
+ };
1376
+ }
1377
+ return null;
1378
+ }
1350
1379
  async _resolveRelativePath(
1351
1380
  filePath,
1352
1381
  { relativeTo, resolverOptions, transformOptions },
@@ -1356,14 +1385,18 @@ class Server {
1356
1385
  transformOptions.platform,
1357
1386
  resolverOptions,
1358
1387
  );
1388
+ const resolved = this._resolveWatchFolderPrefix(filePath);
1359
1389
  const rootDir =
1360
- relativeTo === "server"
1361
- ? this._getServerRootDir()
1362
- : this._config.projectRoot;
1390
+ resolved != null
1391
+ ? resolved.rootDir
1392
+ : relativeTo === "server"
1393
+ ? this._getServerRootDir()
1394
+ : this._config.projectRoot;
1395
+ const resolvedFilePath = resolved != null ? resolved.filePath : filePath;
1363
1396
  return resolutionFn(`${rootDir}/.`, {
1364
- name: filePath,
1397
+ name: resolvedFilePath,
1365
1398
  data: {
1366
- key: filePath,
1399
+ key: resolvedFilePath,
1367
1400
  locs: [],
1368
1401
  asyncType: null,
1369
1402
  isESMImport: false,
@@ -1403,6 +1436,10 @@ class Server {
1403
1436
  return this._config.server.unstable_serverRoot ?? this._config.projectRoot;
1404
1437
  }
1405
1438
  _getEntryPointAbsolutePath(entryFile) {
1439
+ const resolved = this._resolveWatchFolderPrefix(entryFile);
1440
+ if (resolved != null) {
1441
+ return _path.default.resolve(resolved.rootDir, resolved.filePath);
1442
+ }
1406
1443
  return _path.default.resolve(this._getServerRootDir(), entryFile);
1407
1444
  }
1408
1445
  async ready() {
@@ -1622,6 +1622,33 @@ export default class Server {
1622
1622
  );
1623
1623
  }
1624
1624
 
1625
+ _resolveWatchFolderPrefix(
1626
+ filePath: string,
1627
+ ): {rootDir: string, filePath: string} | null {
1628
+ const watchFolderMatch = filePath.match(
1629
+ /^\.\/\[metro-watchFolders\]\/(\d+)\/(.*)/,
1630
+ );
1631
+ if (watchFolderMatch != null) {
1632
+ const index = parseInt(watchFolderMatch[1], 10);
1633
+ const watchFolder = this._config.watchFolders[index];
1634
+ if (watchFolder != null) {
1635
+ return {
1636
+ rootDir: path.resolve(watchFolder),
1637
+ filePath:
1638
+ '.' + path.sep + watchFolderMatch[2].split('/').join(path.sep),
1639
+ };
1640
+ }
1641
+ }
1642
+ const projectMatch = filePath.match(/^\.\/\[metro-project\]\/(.*)/);
1643
+ if (projectMatch != null) {
1644
+ return {
1645
+ rootDir: path.resolve(this._config.projectRoot),
1646
+ filePath: '.' + path.sep + projectMatch[1].split('/').join(path.sep),
1647
+ };
1648
+ }
1649
+ return null;
1650
+ }
1651
+
1625
1652
  async _resolveRelativePath(
1626
1653
  filePath: string,
1627
1654
  {
@@ -1639,13 +1666,22 @@ export default class Server {
1639
1666
  transformOptions.platform,
1640
1667
  resolverOptions,
1641
1668
  );
1669
+ const resolved = this._resolveWatchFolderPrefix(filePath);
1642
1670
  const rootDir =
1643
- relativeTo === 'server'
1644
- ? this._getServerRootDir()
1645
- : this._config.projectRoot;
1671
+ resolved != null
1672
+ ? resolved.rootDir
1673
+ : relativeTo === 'server'
1674
+ ? this._getServerRootDir()
1675
+ : this._config.projectRoot;
1676
+ const resolvedFilePath = resolved != null ? resolved.filePath : filePath;
1646
1677
  return resolutionFn(`${rootDir}/.`, {
1647
- name: filePath,
1648
- data: {key: filePath, locs: [], asyncType: null, isESMImport: false},
1678
+ name: resolvedFilePath,
1679
+ data: {
1680
+ key: resolvedFilePath,
1681
+ locs: [],
1682
+ asyncType: null,
1683
+ isESMImport: false,
1684
+ },
1649
1685
  }).filePath;
1650
1686
  }
1651
1687
 
@@ -1706,6 +1742,10 @@ export default class Server {
1706
1742
  }
1707
1743
 
1708
1744
  _getEntryPointAbsolutePath(entryFile: string): string {
1745
+ const resolved = this._resolveWatchFolderPrefix(entryFile);
1746
+ if (resolved != null) {
1747
+ return path.resolve(resolved.rootDir, resolved.filePath);
1748
+ }
1709
1749
  return path.resolve(this._getServerRootDir(), entryFile);
1710
1750
  }
1711
1751
 
@@ -4,8 +4,15 @@
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
- * @format
7
+ * @noformat
8
8
  * @oncall react_native
9
+ * @generated SignedSource<<ece5a9f14463102dc54489fe7db6b3c8>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/cli/parseKeyValueParamArray.js
13
+ * To regenerate, run:
14
+ * js1 build metro-ts-defs (internal) OR
15
+ * yarn run build-ts-defs (OSS)
9
16
  */
10
17
 
11
18
  declare function coerceKeyValueArray(keyValueArray: ReadonlyArray<string>): {
@@ -4,8 +4,15 @@
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
- * @format
7
+ * @noformat
8
8
  * @oncall react_native
9
+ * @generated SignedSource<<b5035a5d26a55e608aca030ee9ee6afa>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/cli-utils.js
13
+ * To regenerate, run:
14
+ * js1 build metro-ts-defs (internal) OR
15
+ * yarn run build-ts-defs (OSS)
9
16
  */
10
17
 
11
18
  export declare const watchFile: (
@@ -4,8 +4,15 @@
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
- * @format
7
+ * @noformat
8
8
  * @oncall react_native
9
+ * @generated SignedSource<<10c41709fa9779dd0e12ef411eaef8eb>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/commands/build.js
13
+ * To regenerate, run:
14
+ * js1 build metro-ts-defs (internal) OR
15
+ * yarn run build-ts-defs (OSS)
9
16
  */
10
17
 
11
18
  import type {CommandModule} from 'yargs';
@@ -4,8 +4,15 @@
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
- * @format
7
+ * @noformat
8
8
  * @oncall react_native
9
+ * @generated SignedSource<<a73d915901dde7a679972b78a1e08a3e>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/commands/dependencies.js
13
+ * To regenerate, run:
14
+ * js1 build metro-ts-defs (internal) OR
15
+ * yarn run build-ts-defs (OSS)
9
16
  */
10
17
 
11
18
  import type {CommandModule} from 'yargs';
@@ -4,8 +4,15 @@
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
- * @format
7
+ * @noformat
8
8
  * @oncall react_native
9
+ * @generated SignedSource<<367f11c0b6933f8c8c58718c7dd41e78>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/commands/serve.js
13
+ * To regenerate, run:
14
+ * js1 build metro-ts-defs (internal) OR
15
+ * yarn run build-ts-defs (OSS)
9
16
  */
10
17
 
11
18
  import type {CommandModule} from 'yargs';
package/src/index.d.ts CHANGED
@@ -4,8 +4,15 @@
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
- * @format
7
+ * @noformat
8
8
  * @oncall react_native
9
+ * @generated SignedSource<<3c6460427c6760887187d6b16151c609>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/index.flow.js
13
+ * To regenerate, run:
14
+ * js1 build metro-ts-defs (internal) OR
15
+ * yarn run build-ts-defs (OSS)
9
16
  */
10
17
 
11
18
  import type {AssetData} from './Assets';
@@ -118,9 +125,28 @@ type DependenciesCommandOptions = Readonly<{
118
125
  }> | null;
119
126
  export {Terminal, JsonReporter, TerminalReporter};
120
127
  export type {AssetData} from './Assets';
121
- export type {Reporter, ReportableEvent} from './lib/reporting';
128
+ export type {
129
+ AsyncDependencyType,
130
+ DeltaResult,
131
+ Dependency,
132
+ MixedOutput,
133
+ Module,
134
+ ReadOnlyDependencies,
135
+ ReadOnlyGraph,
136
+ SerializerOptions,
137
+ TransformInputOptions,
138
+ TransformResult,
139
+ TransformResultDependency,
140
+ } from './DeltaBundler/types';
141
+ export type {default as DependencyGraph} from './node-haste/DependencyGraph';
142
+ export type {BundleDetails, Reporter, ReportableEvent} from './lib/reporting';
122
143
  export type {TerminalReportableEvent} from './lib/TerminalReporter';
123
- export type {MetroConfig};
144
+ export type {
145
+ ContextMode,
146
+ RequireContextParams,
147
+ } from './ModuleGraph/worker/collectDependencies';
148
+ export type {ServerOptions} from './Server';
149
+ export type {MetroConfig, MetroServer};
124
150
  export declare function runMetro(
125
151
  config: InputConfigT,
126
152
  options?: RunMetroOptions,
package/src/index.flow.js CHANGED
@@ -63,7 +63,6 @@ var _TerminalReporter = _interopRequireDefault(
63
63
  );
64
64
  var _Server = _interopRequireDefault(require("./Server"));
65
65
  var outputBundle = _interopRequireWildcard(require("./shared/output/bundle"));
66
- var _chalk = _interopRequireDefault(require("chalk"));
67
66
  var _fs = _interopRequireDefault(require("fs"));
68
67
  var _http = _interopRequireDefault(require("http"));
69
68
  var _https = _interopRequireDefault(require("https"));
@@ -71,6 +70,7 @@ var _metroConfig = require("metro-config");
71
70
  var _metroCore = require("metro-core");
72
71
  var _net = _interopRequireDefault(require("net"));
73
72
  var _nullthrows = _interopRequireDefault(require("nullthrows"));
73
+ var _util = _interopRequireDefault(require("util"));
74
74
  function _interopRequireWildcard(e, t) {
75
75
  if ("function" == typeof WeakMap)
76
76
  var r = new WeakMap(),
@@ -201,7 +201,7 @@ const runServer = async (
201
201
  await earlyPortCheck(host, config.server.port);
202
202
  if (secure != null || secureCert != null || secureKey != null) {
203
203
  console.warn(
204
- _chalk.default.inverse.yellow.bold(" DEPRECATED "),
204
+ _util.default.styleText(["inverse", "yellow", "bold"], " DEPRECATED "),
205
205
  "The `secure`, `secureCert`, and `secureKey` options are now deprecated. " +
206
206
  "Please use the `secureServerOptions` object instead to pass options to " +
207
207
  "Metro's https development server, or `config.server.tls` in Metro's configuration",
@@ -41,7 +41,6 @@ import JsonReporter from './lib/JsonReporter';
41
41
  import TerminalReporter from './lib/TerminalReporter';
42
42
  import MetroServer from './Server';
43
43
  import * as outputBundle from './shared/output/bundle';
44
- import chalk from 'chalk';
45
44
  import fs from 'fs';
46
45
  import http from 'http';
47
46
  import https from 'https';
@@ -54,6 +53,7 @@ import {
54
53
  import {Terminal} from 'metro-core';
55
54
  import net from 'net';
56
55
  import nullthrows from 'nullthrows';
56
+ import util from 'util';
57
57
 
58
58
  const DEFAULTS = MetroServer.DEFAULT_BUNDLE_OPTIONS;
59
59
 
@@ -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 {Reporter, ReportableEvent} from './lib/reporting';
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 {MetroConfig};
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);
@@ -277,7 +296,7 @@ export const runServer = async (
277
296
  if (secure != null || secureCert != null || secureKey != null) {
278
297
  // eslint-disable-next-line no-console
279
298
  console.warn(
280
- chalk.inverse.yellow.bold(' DEPRECATED '),
299
+ util.styleText(['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
302
  "Metro's https development server, or `config.server.tls` in Metro's configuration",
@@ -4,8 +4,15 @@
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
- * @format
7
+ * @noformat
8
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)
9
16
  */
10
17
 
11
18
  import {setTimeout} from 'timers';
@@ -4,8 +4,15 @@
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
- * @format
7
+ * @noformat
8
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)
9
16
  */
10
17
 
11
18
  export interface ReadOnlyCountingSet<T> extends Iterable<T> {
@@ -4,8 +4,15 @@
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
- * @format
7
+ * @noformat
8
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)
9
16
  */
10
17
 
11
18
  import type {Writable} from 'stream';
@@ -19,7 +19,7 @@ export type SerializedError = {
19
19
  ...
20
20
  };
21
21
 
22
- export type SerializedEvent<TEvent: {+[string]: unknown, ...}> =
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: {+[string]: unknown, ...}> {
34
+ export default class JsonReporter<TEvent extends {+[string]: unknown, ...}> {
35
35
  _stream: Writable;
36
36
 
37
37
  constructor(stream: Writable) {