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
@@ -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<<ebddbde1dcdecbbee129fd96caaf3bb0>>
9
+ *
10
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
11
+ * Original file: packages/metro/src/lib/RamBundleParser.js
12
+ * To regenerate, run:
13
+ * js1 build metro-ts-defs (internal) OR
14
+ * yarn run build-ts-defs (OSS)
8
15
  */
9
16
 
10
17
  /**
@@ -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<<8218e45d6b5186264c4bf9e54086708a>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/lib/TerminalReporter.js
13
+ * To regenerate, run:
14
+ * js1 build metro-ts-defs (internal) OR
15
+ * yarn run build-ts-defs (OSS)
9
16
  */
10
17
 
11
18
  import type {BundleDetails, ReportableEvent} from './reporting';
@@ -7,10 +7,10 @@ exports.default = void 0;
7
7
  var _bundleProgressUtils = require("./bundleProgressUtils");
8
8
  var _logToConsole = _interopRequireDefault(require("./logToConsole"));
9
9
  var reporting = _interopRequireWildcard(require("./reporting"));
10
- var _chalk = _interopRequireDefault(require("chalk"));
11
10
  var _lodash = _interopRequireDefault(require("lodash.throttle"));
12
11
  var _metroCore = require("metro-core");
13
12
  var _path = _interopRequireDefault(require("path"));
13
+ var _util = _interopRequireDefault(require("util"));
14
14
  function _interopRequireWildcard(e, t) {
15
15
  if ("function" == typeof WeakMap)
16
16
  var r = new WeakMap(),
@@ -41,6 +41,7 @@ function _interopRequireWildcard(e, t) {
41
41
  function _interopRequireDefault(e) {
42
42
  return e && e.__esModule ? e : { default: e };
43
43
  }
44
+ const style = (format, text) => _util.default.styleText(format, text);
44
45
  const DARK_BLOCK_CHAR = "\u2593";
45
46
  const LIGHT_BLOCK_CHAR = "\u2591";
46
47
  const MAX_PROGRESS_BAR_CHAR_WIDTH = 16;
@@ -68,26 +69,24 @@ class TerminalReporter {
68
69
  const localPath = _path.default.relative(".", entryFile);
69
70
  const filledBar = Math.floor(ratio * MAX_PROGRESS_BAR_CHAR_WIDTH);
70
71
  const bundleTypeColor =
71
- phase === "done"
72
- ? _chalk.default.green
73
- : phase === "failed"
74
- ? _chalk.default.red
75
- : _chalk.default.yellow;
72
+ phase === "done" ? ["green"] : phase === "failed" ? ["red"] : ["yellow"];
76
73
  const progress =
77
74
  phase === "in_progress"
78
- ? _chalk.default.green.bgGreen(DARK_BLOCK_CHAR.repeat(filledBar)) +
79
- _chalk.default.bgWhite.white(
75
+ ? style(["green", "bgGreen"], DARK_BLOCK_CHAR.repeat(filledBar)) +
76
+ style(
77
+ ["bgWhite", "white"],
80
78
  LIGHT_BLOCK_CHAR.repeat(MAX_PROGRESS_BAR_CHAR_WIDTH - filledBar),
81
79
  ) +
82
- _chalk.default.bold(` ${Math.floor(100 * ratio)}% `) +
83
- _chalk.default.dim(`(${transformedFileCount}/${totalFileCount})`)
80
+ style(["bold"], ` ${Math.floor(100 * ratio)}% `) +
81
+ style(["dim"], `(${transformedFileCount}/${totalFileCount})`)
84
82
  : "";
85
83
  return (
86
- bundleTypeColor.inverse.bold(
84
+ style(
85
+ [...bundleTypeColor, "inverse", "bold"],
87
86
  ` ${isPrefetch === true ? "PREBUNDLE" : bundleType.toUpperCase()} `,
88
87
  ) +
89
- _chalk.default.reset.dim(` ${_path.default.dirname(localPath)}/`) +
90
- _chalk.default.bold(_path.default.basename(localPath)) +
88
+ style(["reset", "dim"], ` ${_path.default.dirname(localPath)}/`) +
89
+ style(["bold"], _path.default.basename(localPath)) +
91
90
  " " +
92
91
  progress
93
92
  );
@@ -132,38 +131,36 @@ class TerminalReporter {
132
131
  "",
133
132
  "",
134
133
  ];
135
- const color = hasReducedPerformance
136
- ? _chalk.default.red
137
- : _chalk.default.blue;
138
- this.terminal.log(color(logo.join("\n")));
134
+ const color = hasReducedPerformance ? ["red"] : ["blue"];
135
+ this.terminal.log(style(color, logo.join("\n")));
139
136
  }
140
137
  _logInitializingFailed(port, error) {
141
138
  if (error.code === "EADDRINUSE") {
142
139
  this.terminal.log(
143
- _chalk.default.bgRed.bold(" ERROR "),
144
- _chalk.default.red(
145
- "Metro can't listen on port",
146
- _chalk.default.bold(String(port)),
140
+ style(["bgRed", "bold"], " ERROR "),
141
+ style(
142
+ ["red"],
143
+ `Metro can't listen on port ${style(["bold"], String(port))}`,
147
144
  ),
148
145
  );
149
146
  this.terminal.log(
150
147
  "Most likely another process is already using this port",
151
148
  );
152
149
  this.terminal.log("Run the following command to find out which process:");
153
- this.terminal.log("\n ", _chalk.default.bold("lsof -i :" + port), "\n");
150
+ this.terminal.log("\n ", style(["bold"], "lsof -i :" + port), "\n");
154
151
  this.terminal.log("Then, you can either shut down the other process:");
155
- this.terminal.log("\n ", _chalk.default.bold("kill -9 <PID>"), "\n");
152
+ this.terminal.log("\n ", style(["bold"], "kill -9 <PID>"), "\n");
156
153
  this.terminal.log("or run Metro on different port.");
157
154
  } else {
158
155
  this.terminal.log(
159
- _chalk.default.bgRed.bold(" ERROR "),
160
- _chalk.default.red(error.message),
156
+ style(["bgRed", "bold"], " ERROR "),
157
+ style(["red"], error.message),
161
158
  );
162
159
  const errorAttributes = JSON.stringify(error);
163
160
  if (errorAttributes !== "{}") {
164
- this.terminal.log(_chalk.default.red(errorAttributes));
161
+ this.terminal.log(style(["red"], errorAttributes));
165
162
  }
166
- this.terminal.log(_chalk.default.red(error.stack));
163
+ this.terminal.log(style(["red"], String(error.stack)));
167
164
  }
168
165
  }
169
166
  _log(event) {
@@ -214,22 +211,21 @@ class TerminalReporter {
214
211
  logFn(this.terminal, String(format), ...args);
215
212
  break;
216
213
  case "dep_graph_loading":
217
- const color = event.hasReducedPerformance
218
- ? _chalk.default.red
219
- : _chalk.default.blue;
214
+ const color = event.hasReducedPerformance ? ["red"] : ["blue"];
220
215
  const version = "v" + require("../../package.json").version;
221
216
  this.terminal.log(
222
- color.bold(
223
- " ".repeat(19 - version.length / 2),
224
- "Welcome to Metro " + _chalk.default.white(version) + "\n",
225
- ) +
226
- _chalk.default.dim(
227
- " Fast - Scalable - Integrated\n\n",
228
- ),
217
+ style(
218
+ [...color, "bold"],
219
+ " ".repeat(19 - version.length / 2) +
220
+ " Welcome to Metro " +
221
+ style(["white"], version) +
222
+ "\n",
223
+ ) + style(["dim"], " Fast - Scalable - Integrated\n\n"),
229
224
  );
230
225
  if (event.hasReducedPerformance) {
231
226
  this.terminal.log(
232
- _chalk.default.red(
227
+ style(
228
+ ["red"],
233
229
  "Metro is operating with reduced performance.\n" +
234
230
  "Please fix the problem above and restart Metro.\n\n",
235
231
  ),
@@ -360,7 +356,7 @@ class TerminalReporter {
360
356
  case "success":
361
357
  if (this._prevHealthCheckResult) {
362
358
  this.terminal.log(
363
- _chalk.default.green(`Watcher ${watcherName} is now healthy.`),
359
+ style(["green"], `Watcher ${watcherName} is now healthy.`),
364
360
  );
365
361
  }
366
362
  break;
@@ -399,14 +395,16 @@ class TerminalReporter {
399
395
  break;
400
396
  case "watchman_slow_command":
401
397
  this.terminal.log(
402
- _chalk.default.dim(
398
+ style(
399
+ ["dim"],
403
400
  `Waiting for Watchman \`${status.command}\` (${Math.round(status.timeElapsed / 1000)}s)...`,
404
401
  ),
405
402
  );
406
403
  break;
407
404
  case "watchman_slow_command_complete":
408
405
  this.terminal.log(
409
- _chalk.default.green(
406
+ style(
407
+ ["green"],
410
408
  `Watchman \`${status.command}\` finished after ${(status.timeElapsed / 1000).toFixed(1)}s.`,
411
409
  ),
412
410
  );
@@ -12,15 +12,22 @@
12
12
  import type {BundleDetails, ReportableEvent} from './reporting';
13
13
  import type {Terminal} from 'metro-core';
14
14
  import type {HealthCheckResult, WatcherStatus} from 'metro-file-map';
15
+ import type {BackgroundColors, ForegroundColors, Modifiers} from 'util';
15
16
 
16
17
  import {calculateBundleProgressRatio} from './bundleProgressUtils';
17
18
  import logToConsole from './logToConsole';
18
19
  import * as reporting from './reporting';
19
- import chalk from 'chalk';
20
20
  // $FlowFixMe[untyped-import] lodash.throttle
21
21
  import throttle from 'lodash.throttle';
22
22
  import {AmbiguousModuleResolutionError} from 'metro-core';
23
23
  import path from 'path';
24
+ import util from 'util';
25
+
26
+ type StyleFormat = ReadonlyArray<
27
+ ForegroundColors | BackgroundColors | Modifiers,
28
+ >;
29
+ const style = (format: StyleFormat, text: string): string =>
30
+ util.styleText(format, text);
24
31
 
25
32
  type BundleProgress = {
26
33
  bundleDetails: BundleDetails,
@@ -121,28 +128,26 @@ export default class TerminalReporter {
121
128
  ): string {
122
129
  const localPath = path.relative('.', entryFile);
123
130
  const filledBar = Math.floor(ratio * MAX_PROGRESS_BAR_CHAR_WIDTH);
124
- const bundleTypeColor =
125
- phase === 'done'
126
- ? chalk.green
127
- : phase === 'failed'
128
- ? chalk.red
129
- : chalk.yellow;
131
+ const bundleTypeColor: StyleFormat =
132
+ phase === 'done' ? ['green'] : phase === 'failed' ? ['red'] : ['yellow'];
130
133
  const progress =
131
134
  phase === 'in_progress'
132
- ? chalk.green.bgGreen(DARK_BLOCK_CHAR.repeat(filledBar)) +
133
- chalk.bgWhite.white(
135
+ ? style(['green', 'bgGreen'], DARK_BLOCK_CHAR.repeat(filledBar)) +
136
+ style(
137
+ ['bgWhite', 'white'],
134
138
  LIGHT_BLOCK_CHAR.repeat(MAX_PROGRESS_BAR_CHAR_WIDTH - filledBar),
135
139
  ) +
136
- chalk.bold(` ${Math.floor(100 * ratio)}% `) +
137
- chalk.dim(`(${transformedFileCount}/${totalFileCount})`)
140
+ style(['bold'], ` ${Math.floor(100 * ratio)}% `) +
141
+ style(['dim'], `(${transformedFileCount}/${totalFileCount})`)
138
142
  : '';
139
143
 
140
144
  return (
141
- bundleTypeColor.inverse.bold(
145
+ style(
146
+ [...bundleTypeColor, 'inverse', 'bold'],
142
147
  ` ${isPrefetch === true ? 'PREBUNDLE' : bundleType.toUpperCase()} `,
143
148
  ) +
144
- chalk.reset.dim(` ${path.dirname(localPath)}/`) +
145
- chalk.bold(path.basename(localPath)) +
149
+ style(['reset', 'dim'], ` ${path.dirname(localPath)}/`) +
150
+ style(['bold'], path.basename(localPath)) +
146
151
  ' ' +
147
152
  progress
148
153
  );
@@ -191,31 +196,37 @@ export default class TerminalReporter {
191
196
  '',
192
197
  ];
193
198
 
194
- const color = hasReducedPerformance ? chalk.red : chalk.blue;
195
- this.terminal.log(color(logo.join('\n')));
199
+ const color: StyleFormat = hasReducedPerformance ? ['red'] : ['blue'];
200
+ this.terminal.log(style(color, logo.join('\n')));
196
201
  }
197
202
 
198
203
  _logInitializingFailed(port: number, error: SnippetError): void {
199
204
  if (error.code === 'EADDRINUSE') {
200
205
  this.terminal.log(
201
- chalk.bgRed.bold(' ERROR '),
202
- chalk.red("Metro can't listen on port", chalk.bold(String(port))),
206
+ style(['bgRed', 'bold'], ' ERROR '),
207
+ style(
208
+ ['red'],
209
+ `Metro can't listen on port ${style(['bold'], String(port))}`,
210
+ ),
203
211
  );
204
212
  this.terminal.log(
205
213
  'Most likely another process is already using this port',
206
214
  );
207
215
  this.terminal.log('Run the following command to find out which process:');
208
- this.terminal.log('\n ', chalk.bold('lsof -i :' + port), '\n');
216
+ this.terminal.log('\n ', style(['bold'], 'lsof -i :' + port), '\n');
209
217
  this.terminal.log('Then, you can either shut down the other process:');
210
- this.terminal.log('\n ', chalk.bold('kill -9 <PID>'), '\n');
218
+ this.terminal.log('\n ', style(['bold'], 'kill -9 <PID>'), '\n');
211
219
  this.terminal.log('or run Metro on different port.');
212
220
  } else {
213
- this.terminal.log(chalk.bgRed.bold(' ERROR '), chalk.red(error.message));
221
+ this.terminal.log(
222
+ style(['bgRed', 'bold'], ' ERROR '),
223
+ style(['red'], error.message),
224
+ );
214
225
  const errorAttributes = JSON.stringify(error);
215
226
  if (errorAttributes !== '{}') {
216
- this.terminal.log(chalk.red(errorAttributes));
227
+ this.terminal.log(style(['red'], errorAttributes));
217
228
  }
218
- this.terminal.log(chalk.red(error.stack));
229
+ this.terminal.log(style(['red'], String(error.stack)));
219
230
  }
220
231
  }
221
232
 
@@ -271,20 +282,26 @@ export default class TerminalReporter {
271
282
  logFn(this.terminal, String(format), ...args);
272
283
  break;
273
284
  case 'dep_graph_loading':
274
- const color = event.hasReducedPerformance ? chalk.red : chalk.blue;
285
+ const color: StyleFormat = event.hasReducedPerformance
286
+ ? ['red']
287
+ : ['blue'];
275
288
  // eslint-disable-next-line import/no-commonjs
276
289
  // $FlowFixMe[untyped-import] package.json
277
290
  const version = 'v' + require('../../package.json').version;
278
291
  this.terminal.log(
279
- color.bold(
280
- ' '.repeat(19 - version.length / 2),
281
- 'Welcome to Metro ' + chalk.white(version) + '\n',
282
- ) + chalk.dim(' Fast - Scalable - Integrated\n\n'),
292
+ style(
293
+ [...color, 'bold'],
294
+ ' '.repeat(19 - version.length / 2) +
295
+ ' Welcome to Metro ' +
296
+ style(['white'], version) +
297
+ '\n',
298
+ ) + style(['dim'], ' Fast - Scalable - Integrated\n\n'),
283
299
  );
284
300
 
285
301
  if (event.hasReducedPerformance) {
286
302
  this.terminal.log(
287
- chalk.red(
303
+ style(
304
+ ['red'],
288
305
  'Metro is operating with reduced performance.\n' +
289
306
  'Please fix the problem above and restart Metro.\n\n',
290
307
  ),
@@ -459,7 +476,7 @@ export default class TerminalReporter {
459
476
  // Only report success after a prior failure.
460
477
  if (this._prevHealthCheckResult) {
461
478
  this.terminal.log(
462
- chalk.green(`Watcher ${watcherName} is now healthy.`),
479
+ style(['green'], `Watcher ${watcherName} is now healthy.`),
463
480
  );
464
481
  }
465
482
  break;
@@ -499,7 +516,8 @@ export default class TerminalReporter {
499
516
  break;
500
517
  case 'watchman_slow_command':
501
518
  this.terminal.log(
502
- chalk.dim(
519
+ style(
520
+ ['dim'],
503
521
  `Waiting for Watchman \`${status.command}\` (${Math.round(
504
522
  status.timeElapsed / 1000,
505
523
  )}s)...`,
@@ -508,7 +526,8 @@ export default class TerminalReporter {
508
526
  break;
509
527
  case 'watchman_slow_command_complete':
510
528
  this.terminal.log(
511
- chalk.green(
529
+ style(
530
+ ['green'],
512
531
  `Watchman \`${status.command}\` finished after ${(
513
532
  status.timeElapsed / 1000
514
533
  ).toFixed(1)}s.`,
@@ -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<<6f0cfa5c118fa3cbe65acee044b8c927>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/lib/bundleProgressUtils.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
  /**
@@ -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<<89a26e72bdd126e3feb0abc9b3186d33>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/lib/bundleToString.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 {Bundle, BundleMetadata} from 'metro-runtime/src/modules/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<<461f7a7b3b3d99d1f1e7eeeeb5125686>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/lib/contextModule.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 {
@@ -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<<bcc2ba36a2edccb791b6d380f2c27ebe>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/lib/contextModuleTemplates.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 {ContextMode} from '../ModuleGraph/worker/collectDependencies';
@@ -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<<a9f443cc44465917ebb470200e0f80d2>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/lib/countLines.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 countLines(string: string): number;
@@ -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<<cc8010b98646f8cfd713ae5505f71ef1>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/lib/createWebsocketServer.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 ws from 'ws';
@@ -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<<900f968546b7cc3e463e2de9d1f06200>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/lib/debounceAsyncQueue.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 debounceAsyncQueue<T>(
@@ -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<<0c18118765a7730747fbadfd10e5d8f6>>
9
+ *
10
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
11
+ * Original file: packages/metro/src/lib/formatBundlingError.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 {FormattedError} from 'metro-runtime/src/modules/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<<72fd04e53dc895f1305e10043f986edc>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/lib/getAppendScripts.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 {Module} from '../DeltaBundler';
@@ -18,7 +18,7 @@ import CountingSet from './CountingSet';
18
18
  import countLines from './countLines';
19
19
  import nullthrows from 'nullthrows';
20
20
 
21
- type Options<T: number | string> = Readonly<{
21
+ type Options<T extends number | string> = Readonly<{
22
22
  asyncRequireModulePath: string,
23
23
  createModuleId: string => T,
24
24
  getRunModuleStatement: (moduleId: T, globalPrefix: string) => string,
@@ -33,7 +33,7 @@ type Options<T: number | string> = Readonly<{
33
33
  ...
34
34
  }>;
35
35
 
36
- export default function getAppendScripts<T: number | string>(
36
+ export default function getAppendScripts<T extends number | string>(
37
37
  entryPoint: string,
38
38
  modules: ReadonlyArray<Module<>>,
39
39
  options: Options<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<<cb5003f203d26e24459419b5f28e4f06>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/lib/getGraphId.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 {TransformInputOptions} from '../DeltaBundler/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<<c57e62398654e4f07fea53d28c279b20>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/lib/getPreludeCode.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 getPreludeCode($$PARAM_0$$: {
@@ -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<<a85e80b79c0295e96824c17436edfcca>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/lib/getPrependedScripts.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 Bundler from '../Bundler';
@@ -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<<f1d42fcf747b4fa7641e50b8d4ddc424>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/lib/isResolvedDependency.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 {Dependency, ResolvedDependency} from '../DeltaBundler/types';
@@ -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<<95cf7d414507e2035210d06882d858b3>>
9
+ *
10
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
11
+ * Original file: packages/metro/src/lib/logToConsole.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 {Terminal} from 'metro-core';