metro 0.84.3 → 0.85.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 (56) hide show
  1. package/package.json +17 -18
  2. package/src/Assets.js +23 -14
  3. package/src/Assets.js.flow +51 -38
  4. package/src/Bundler.d.ts +1 -5
  5. package/src/DeltaBundler/DeltaCalculator.d.ts +1 -16
  6. package/src/DeltaBundler/DeltaCalculator.js.flow +1 -1
  7. package/src/DeltaBundler/Graph.d.ts +1 -102
  8. package/src/DeltaBundler/Graph.js.flow +7 -7
  9. package/src/DeltaBundler/Serializers/getAllFiles.js.flow +1 -1
  10. package/src/DeltaBundler/Serializers/getAssets.js.flow +1 -1
  11. package/src/DeltaBundler/Serializers/getExplodedSourceMap.js.flow +5 -5
  12. package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.js.flow +9 -9
  13. package/src/DeltaBundler/Serializers/hmrJSBundle.js.flow +3 -3
  14. package/src/DeltaBundler/Transformer.d.ts +2 -10
  15. package/src/DeltaBundler/Worker.flow.js.flow +1 -1
  16. package/src/DeltaBundler/WorkerFarm.d.ts +2 -47
  17. package/src/DeltaBundler/getTransformCacheKey.js.flow +3 -3
  18. package/src/DeltaBundler/types.js.flow +10 -10
  19. package/src/DeltaBundler.d.ts +1 -5
  20. package/src/HmrServer.d.ts +2 -45
  21. package/src/HmrServer.js.flow +10 -10
  22. package/src/IncrementalBundler.d.ts +1 -9
  23. package/src/IncrementalBundler.js.flow +9 -6
  24. package/src/ModuleGraph/worker/collectDependencies.d.ts +1 -2
  25. package/src/ModuleGraph/worker/collectDependencies.js +52 -0
  26. package/src/ModuleGraph/worker/collectDependencies.js.flow +67 -0
  27. package/src/Server/symbolicate.js.flow +13 -13
  28. package/src/Server.d.ts +3 -176
  29. package/src/Server.js +42 -5
  30. package/src/Server.js.flow +70 -28
  31. package/src/index.flow.js +2 -2
  32. package/src/index.flow.js.flow +2 -2
  33. package/src/lib/BatchProcessor.d.ts +1 -21
  34. package/src/lib/CountingSet.js.flow +1 -1
  35. package/src/lib/JsonReporter.d.ts +1 -2
  36. package/src/lib/JsonReporter.js.flow +4 -2
  37. package/src/lib/RamBundleParser.d.ts +1 -6
  38. package/src/lib/TerminalReporter.d.ts +2 -78
  39. package/src/lib/TerminalReporter.js +39 -41
  40. package/src/lib/TerminalReporter.js.flow +52 -33
  41. package/src/lib/bundleToString.js.flow +2 -2
  42. package/src/lib/createWebsocketServer.js.flow +4 -4
  43. package/src/lib/formatBundlingError.js.flow +1 -1
  44. package/src/lib/getPreludeCode.js.flow +5 -5
  45. package/src/lib/logToConsole.js +8 -7
  46. package/src/lib/logToConsole.js.flow +7 -7
  47. package/src/lib/reporting.js +16 -7
  48. package/src/lib/reporting.js.flow +16 -5
  49. package/src/node-haste/DependencyGraph/ModuleResolution.d.ts +1 -13
  50. package/src/node-haste/DependencyGraph/ModuleResolution.js.flow +1 -1
  51. package/src/node-haste/DependencyGraph/createFileMap.js +0 -2
  52. package/src/node-haste/DependencyGraph/createFileMap.js.flow +0 -2
  53. package/src/node-haste/DependencyGraph.d.ts +1 -30
  54. package/src/node-haste/DependencyGraph.js.flow +2 -2
  55. package/src/shared/output/RamBundle/util.js.flow +4 -2
  56. package/src/shared/types.js.flow +31 -31
package/src/Server.d.ts CHANGED
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * @noformat
8
8
  * @oncall react_native
9
- * @generated SignedSource<<161e77301d04ce6cc254f1dbf15ef06b>>
9
+ * @generated SignedSource<<a4fd26fa84b68e8bc2b3c32bcf36e7bc>>
10
10
  *
11
11
  * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
12
  * Original file: packages/metro/src/Server.js
@@ -16,38 +16,16 @@
16
16
  */
17
17
 
18
18
  import type {AssetData} from './Assets';
19
- import type {ExplodedSourceMap} from './DeltaBundler/Serializers/getExplodedSourceMap';
20
19
  import type {RamBundleInfo} from './DeltaBundler/Serializers/getRamBundleInfo';
21
- import type {
22
- Module,
23
- ReadOnlyDependencies,
24
- ReadOnlyGraph,
25
- TransformInputOptions,
26
- } from './DeltaBundler/types';
27
- import type {RevisionId} from './IncrementalBundler';
28
- import type {GraphId} from './lib/getGraphId';
29
- import type {Reporter} from './lib/reporting';
30
- import type {
31
- BuildOptions,
32
- BundleOptions,
33
- GraphOptions,
34
- ResolverInputOptions,
35
- SplitBundleOptions,
36
- } from './shared/types';
20
+ import type {BuildOptions, BundleOptions} from './shared/types';
37
21
  import type {IncomingMessage} from 'connect';
38
22
  import type {ServerResponse} from 'http';
39
- import type {ConfigT, RootPerfLogger} from 'metro-config';
40
- import type {
41
- ActionLogEntryData,
42
- ActionStartLogEntry,
43
- } from 'metro-core/private/Logger';
23
+ import type {ConfigT} from 'metro-config';
44
24
  import type {CustomResolverOptions} from 'metro-resolver/private/types';
45
25
  import type {CustomTransformOptions} from 'metro-transform-worker';
46
26
 
47
27
  import IncrementalBundler from './IncrementalBundler';
48
- import MultipartResponse from './Server/MultipartResponse';
49
28
  import {SourcePathsMode} from './shared/types';
50
- import {Logger} from 'metro-core';
51
29
 
52
30
  export type SegmentLoadData = {
53
31
  [$$Key$$: number]: [Array<number>, null | undefined | number];
@@ -59,180 +37,33 @@ export type BundleMetadata = {
59
37
  segmentHashes: Array<string>;
60
38
  segmentLoadData: SegmentLoadData;
61
39
  };
62
- type ProcessStartContext = Omit<
63
- SplitBundleOptions,
64
- keyof {
65
- readonly buildNumber: number;
66
- readonly bundleOptions: BundleOptions;
67
- readonly graphId: GraphId;
68
- readonly graphOptions: GraphOptions;
69
- readonly mres: MultipartResponse | ServerResponse;
70
- readonly req: IncomingMessage;
71
- readonly revisionId?: null | undefined | RevisionId;
72
- readonly bundlePerfLogger: RootPerfLogger;
73
- readonly requestStartTimestamp: number;
74
- }
75
- > & {
76
- readonly buildNumber: number;
77
- readonly bundleOptions: BundleOptions;
78
- readonly graphId: GraphId;
79
- readonly graphOptions: GraphOptions;
80
- readonly mres: MultipartResponse | ServerResponse;
81
- readonly req: IncomingMessage;
82
- readonly revisionId?: null | undefined | RevisionId;
83
- readonly bundlePerfLogger: RootPerfLogger;
84
- readonly requestStartTimestamp: number;
85
- };
86
- type ProcessDeleteContext = {
87
- readonly graphId: GraphId;
88
- readonly req: IncomingMessage;
89
- readonly res: ServerResponse;
90
- };
91
- type ProcessEndContext<T> = Omit<
92
- ProcessStartContext,
93
- keyof {readonly result: T}
94
- > & {readonly result: T};
95
40
  export type ServerOptions = Readonly<{
96
41
  hasReducedPerformance?: boolean;
97
42
  onBundleBuilt?: (bundlePath: string) => void;
98
43
  watch?: boolean;
99
44
  }>;
100
- type FetchTiming = {
101
- graphId: GraphId;
102
- startTime: number;
103
- endTime: number | null;
104
- isPrefetch: boolean;
105
- };
106
45
  declare class Server {
107
- _bundler: IncrementalBundler;
108
- _config: ConfigT;
109
- _createModuleId: (path: string) => number;
110
- _isEnded: boolean;
111
- _logger: typeof Logger;
112
- _nextBundleBuildNumber: number;
113
- _platforms: Set<string>;
114
- _reporter: Reporter;
115
- _serverOptions: ServerOptions | void;
116
- _allowedSuffixesForSourceRequests: ReadonlyArray<string>;
117
- _sourceRequestRoutingMap: ReadonlyArray<
118
- [pathnamePrefix: string, normalizedRootDir: string]
119
- >;
120
- _fetchTimings: Array<FetchTiming>;
121
- _activeFetchCount: number;
122
46
  constructor(config: ConfigT, options?: ServerOptions);
123
47
  end(): void;
124
48
  getBundler(): IncrementalBundler;
125
49
  getCreateModuleId(): (path: string) => number;
126
- _serializeGraph(
127
- $$PARAM_0$$: Readonly<{
128
- splitOptions: SplitBundleOptions;
129
- prepend: ReadonlyArray<Module>;
130
- graph: ReadOnlyGraph;
131
- }>,
132
- ): Promise<{code: string; map: string}>;
133
50
  build(
134
51
  bundleOptions: BundleOptions,
135
52
  $$PARAM_1$$?: BuildOptions,
136
53
  ): Promise<{code: string; map: string; assets?: ReadonlyArray<AssetData>}>;
137
54
  getRamBundleInfo(options: BundleOptions): Promise<RamBundleInfo>;
138
55
  getAssets(options: BundleOptions): Promise<ReadonlyArray<AssetData>>;
139
- _getAssetsFromDependencies(
140
- dependencies: ReadOnlyDependencies,
141
- platform: null | undefined | string,
142
- ): Promise<ReadonlyArray<AssetData>>;
143
56
  getOrderedDependencyPaths(options: {
144
57
  readonly dev: boolean;
145
58
  readonly entryFile: string;
146
59
  readonly minify: boolean;
147
60
  readonly platform: null | undefined | string;
148
61
  }): Promise<Array<string>>;
149
- _rangeRequestMiddleware(
150
- req: IncomingMessage,
151
- res: ServerResponse,
152
- data: string | Buffer,
153
- assetPath: string,
154
- ): Buffer | string;
155
- _processSingleAssetRequest(
156
- req: IncomingMessage,
157
- res: ServerResponse,
158
- ): Promise<void>;
159
62
  processRequest: (
160
63
  $$PARAM_0$$: IncomingMessage,
161
64
  $$PARAM_1$$: ServerResponse,
162
65
  $$PARAM_2$$: (e: null | undefined | Error) => void,
163
66
  ) => void;
164
- _parseOptions(url: string): BundleOptions;
165
- _rewriteAndNormalizeUrl(requestUrl: string): string;
166
- _processRequest(
167
- req: IncomingMessage,
168
- res: ServerResponse,
169
- next: ($$PARAM_0$$: null | undefined | Error) => void,
170
- ): Promise<void>;
171
- _processSourceRequest(
172
- relativeFilePathname: string,
173
- rootDir: string,
174
- res: ServerResponse,
175
- ): Promise<void>;
176
- _createRequestProcessor<T>($$PARAM_0$$: {
177
- readonly bundleType: 'assets' | 'bundle' | 'map';
178
- readonly createStartEntry: (
179
- context: ProcessStartContext,
180
- ) => ActionLogEntryData;
181
- readonly createEndEntry: (
182
- context: ProcessEndContext<T>,
183
- ) => Partial<ActionStartLogEntry>;
184
- readonly build: (context: ProcessStartContext) => Promise<T>;
185
- readonly delete?: (context: ProcessDeleteContext) => Promise<void>;
186
- readonly finish: (context: ProcessEndContext<T>) => void;
187
- }): (
188
- req: IncomingMessage,
189
- res: ServerResponse,
190
- bundleOptions: BundleOptions,
191
- buildContext: Readonly<{
192
- buildNumber: number;
193
- bundlePerfLogger: RootPerfLogger;
194
- }>,
195
- ) => Promise<void>;
196
- _processBundleRequest: (
197
- req: IncomingMessage,
198
- res: ServerResponse,
199
- bundleOptions: BundleOptions,
200
- buildContext: Readonly<{
201
- buildNumber: number;
202
- bundlePerfLogger: RootPerfLogger;
203
- }>,
204
- ) => Promise<void>;
205
- _getSortedModules(graph: ReadOnlyGraph): ReadonlyArray<Module>;
206
- _processSourceMapRequest: (
207
- req: IncomingMessage,
208
- res: ServerResponse,
209
- bundleOptions: BundleOptions,
210
- buildContext: Readonly<{
211
- buildNumber: number;
212
- bundlePerfLogger: RootPerfLogger;
213
- }>,
214
- ) => Promise<void>;
215
- _processAssetsRequest: (
216
- req: IncomingMessage,
217
- res: ServerResponse,
218
- bundleOptions: BundleOptions,
219
- buildContext: Readonly<{
220
- buildNumber: number;
221
- bundlePerfLogger: RootPerfLogger;
222
- }>,
223
- ) => Promise<void>;
224
- _symbolicate(req: IncomingMessage, res: ServerResponse): Promise<void>;
225
- _explodedSourceMapForBundleOptions(
226
- bundleOptions: BundleOptions,
227
- ): Promise<ExplodedSourceMap>;
228
- _resolveRelativePath(
229
- filePath: string,
230
- $$PARAM_1$$: Readonly<{
231
- relativeTo: 'project' | 'server';
232
- resolverOptions: ResolverInputOptions;
233
- transformOptions: TransformInputOptions;
234
- }>,
235
- ): Promise<string>;
236
67
  getNewBuildNumber(): number;
237
68
  getPlatforms(): ReadonlyArray<string>;
238
69
  getWatchFolders(): ReadonlyArray<string>;
@@ -269,10 +100,6 @@ declare class Server {
269
100
  sourceUrl: null;
270
101
  sourcePaths: SourcePathsMode;
271
102
  };
272
- _getServerRootDir(): string;
273
- _getEntryPointAbsolutePath(entryFile: string): string;
274
103
  ready(): Promise<void>;
275
- _shouldAddModuleToIgnoreList(module: Module): boolean;
276
- _getModuleSourceUrl(module: Module, mode: SourcePathsMode): string;
277
104
  }
278
105
  export default Server;
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() {
@@ -100,26 +100,26 @@ export type BundleMetadata = {
100
100
 
101
101
  type ProcessStartContext = {
102
102
  ...SplitBundleOptions,
103
- +buildNumber: number,
104
- +bundleOptions: BundleOptions,
105
- +graphId: GraphId,
106
- +graphOptions: GraphOptions,
107
- +mres: MultipartResponse | ServerResponse,
108
- +req: IncomingMessage,
109
- +revisionId?: ?RevisionId,
110
- +bundlePerfLogger: RootPerfLogger,
111
- +requestStartTimestamp: number,
103
+ readonly buildNumber: number,
104
+ readonly bundleOptions: BundleOptions,
105
+ readonly graphId: GraphId,
106
+ readonly graphOptions: GraphOptions,
107
+ readonly mres: MultipartResponse | ServerResponse,
108
+ readonly req: IncomingMessage,
109
+ readonly revisionId?: ?RevisionId,
110
+ readonly bundlePerfLogger: RootPerfLogger,
111
+ readonly requestStartTimestamp: number,
112
112
  };
113
113
 
114
114
  type ProcessDeleteContext = {
115
- +graphId: GraphId,
116
- +req: IncomingMessage,
117
- +res: ServerResponse,
115
+ readonly graphId: GraphId,
116
+ readonly req: IncomingMessage,
117
+ readonly res: ServerResponse,
118
118
  };
119
119
 
120
120
  type ProcessEndContext<T> = {
121
121
  ...ProcessStartContext,
122
- +result: T,
122
+ readonly result: T,
123
123
  };
124
124
 
125
125
  export type ServerOptions = Readonly<{
@@ -446,10 +446,10 @@ export default class Server {
446
446
  }
447
447
 
448
448
  async getOrderedDependencyPaths(options: {
449
- +dev: boolean,
450
- +entryFile: string,
451
- +minify: boolean,
452
- +platform: ?string,
449
+ readonly dev: boolean,
450
+ readonly entryFile: string,
451
+ readonly minify: boolean,
452
+ readonly platform: ?string,
453
453
  ...
454
454
  }): Promise<Array<string>> {
455
455
  const {
@@ -768,14 +768,16 @@ export default class Server {
768
768
  delete: deleteFn,
769
769
  finish,
770
770
  }: {
771
- +bundleType: 'assets' | 'bundle' | 'map',
772
- +createStartEntry: (context: ProcessStartContext) => ActionLogEntryData,
773
- +createEndEntry: (
771
+ readonly bundleType: 'assets' | 'bundle' | 'map',
772
+ readonly createStartEntry: (
773
+ context: ProcessStartContext,
774
+ ) => ActionLogEntryData,
775
+ readonly createEndEntry: (
774
776
  context: ProcessEndContext<T>,
775
777
  ) => Partial<ActionStartLogEntry>,
776
- +build: (context: ProcessStartContext) => Promise<T>,
777
- +delete?: (context: ProcessDeleteContext) => Promise<void>,
778
- +finish: (context: ProcessEndContext<T>) => void,
778
+ readonly build: (context: ProcessStartContext) => Promise<T>,
779
+ readonly delete?: (context: ProcessDeleteContext) => Promise<void>,
780
+ readonly finish: (context: ProcessEndContext<T>) => void,
779
781
  }): (
780
782
  req: IncomingMessage,
781
783
  res: ServerResponse,
@@ -1622,6 +1624,33 @@ export default class Server {
1622
1624
  );
1623
1625
  }
1624
1626
 
1627
+ _resolveWatchFolderPrefix(
1628
+ filePath: string,
1629
+ ): {rootDir: string, filePath: string} | null {
1630
+ const watchFolderMatch = filePath.match(
1631
+ /^\.\/\[metro-watchFolders\]\/(\d+)\/(.*)/,
1632
+ );
1633
+ if (watchFolderMatch != null) {
1634
+ const index = parseInt(watchFolderMatch[1], 10);
1635
+ const watchFolder = this._config.watchFolders[index];
1636
+ if (watchFolder != null) {
1637
+ return {
1638
+ rootDir: path.resolve(watchFolder),
1639
+ filePath:
1640
+ '.' + path.sep + watchFolderMatch[2].split('/').join(path.sep),
1641
+ };
1642
+ }
1643
+ }
1644
+ const projectMatch = filePath.match(/^\.\/\[metro-project\]\/(.*)/);
1645
+ if (projectMatch != null) {
1646
+ return {
1647
+ rootDir: path.resolve(this._config.projectRoot),
1648
+ filePath: '.' + path.sep + projectMatch[1].split('/').join(path.sep),
1649
+ };
1650
+ }
1651
+ return null;
1652
+ }
1653
+
1625
1654
  async _resolveRelativePath(
1626
1655
  filePath: string,
1627
1656
  {
@@ -1639,13 +1668,22 @@ export default class Server {
1639
1668
  transformOptions.platform,
1640
1669
  resolverOptions,
1641
1670
  );
1671
+ const resolved = this._resolveWatchFolderPrefix(filePath);
1642
1672
  const rootDir =
1643
- relativeTo === 'server'
1644
- ? this._getServerRootDir()
1645
- : this._config.projectRoot;
1673
+ resolved != null
1674
+ ? resolved.rootDir
1675
+ : relativeTo === 'server'
1676
+ ? this._getServerRootDir()
1677
+ : this._config.projectRoot;
1678
+ const resolvedFilePath = resolved != null ? resolved.filePath : filePath;
1646
1679
  return resolutionFn(`${rootDir}/.`, {
1647
- name: filePath,
1648
- data: {key: filePath, locs: [], asyncType: null, isESMImport: false},
1680
+ name: resolvedFilePath,
1681
+ data: {
1682
+ key: resolvedFilePath,
1683
+ locs: [],
1684
+ asyncType: null,
1685
+ isESMImport: false,
1686
+ },
1649
1687
  }).filePath;
1650
1688
  }
1651
1689
 
@@ -1706,6 +1744,10 @@ export default class Server {
1706
1744
  }
1707
1745
 
1708
1746
  _getEntryPointAbsolutePath(entryFile: string): string {
1747
+ const resolved = this._resolveWatchFolderPrefix(entryFile);
1748
+ if (resolved != null) {
1749
+ return path.resolve(resolved.rootDir, resolved.filePath);
1750
+ }
1709
1751
  return path.resolve(this._getServerRootDir(), entryFile);
1710
1752
  }
1711
1753
 
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
 
@@ -296,7 +296,7 @@ export const runServer = async (
296
296
  if (secure != null || secureCert != null || secureKey != null) {
297
297
  // eslint-disable-next-line no-console
298
298
  console.warn(
299
- chalk.inverse.yellow.bold(' DEPRECATED '),
299
+ util.styleText(['inverse', 'yellow', 'bold'], ' DEPRECATED '),
300
300
  'The `secure`, `secureCert`, and `secureKey` options are now deprecated. ' +
301
301
  'Please use the `secureServerOptions` object instead to pass options to ' +
302
302
  "Metro's https development server, or `config.server.tls` in Metro's configuration",
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * @noformat
8
8
  * @oncall react_native
9
- * @generated SignedSource<<5872ab26db1c8f4499c971170c5012c4>>
9
+ * @generated SignedSource<<44408f85f4340c918786727e30822c20>>
10
10
  *
11
11
  * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
12
  * Original file: packages/metro/src/lib/BatchProcessor.js
@@ -15,8 +15,6 @@
15
15
  * yarn run build-ts-defs (OSS)
16
16
  */
17
17
 
18
- import {setTimeout} from 'timers';
19
-
20
18
  type ProcessBatch<TItem, TResult> = (
21
19
  batch: Array<TItem>,
22
20
  ) => Promise<Array<TResult>>;
@@ -25,11 +23,6 @@ type BatchProcessorOptions = {
25
23
  maximumItems: number;
26
24
  concurrency: number;
27
25
  };
28
- type QueueItem<TItem, TResult> = {
29
- item: TItem;
30
- reject: (error: unknown) => unknown;
31
- resolve: (result: TResult) => unknown;
32
- };
33
26
  /**
34
27
  * We batch items together trying to minimize their processing, for example as
35
28
  * network queries. For that we wait a small moment before processing a batch.
@@ -38,23 +31,10 @@ type QueueItem<TItem, TResult> = {
38
31
  * processing right away.
39
32
  */
40
33
  declare class BatchProcessor<TItem, TResult> {
41
- _currentProcessCount: number;
42
- _options: BatchProcessorOptions;
43
- _processBatch: ProcessBatch<TItem, TResult>;
44
- _queue: Array<QueueItem<TItem, TResult>>;
45
- _timeoutHandle: null | undefined | ReturnType<typeof setTimeout>;
46
34
  constructor(
47
35
  options: BatchProcessorOptions,
48
36
  processBatch: ProcessBatch<TItem, TResult>,
49
37
  );
50
- _onBatchFinished(): void;
51
- _onBatchResults(
52
- jobs: Array<QueueItem<TItem, TResult>>,
53
- results: Array<TResult>,
54
- ): void;
55
- _onBatchError(jobs: Array<QueueItem<TItem, TResult>>, error: unknown): void;
56
- _processQueue(): void;
57
- _processQueueOnceReady(): void;
58
38
  queue(item: TItem): Promise<TResult>;
59
39
  getQueueLength(): number;
60
40
  }
@@ -11,7 +11,7 @@
11
11
 
12
12
  export interface ReadOnlyCountingSet<T> extends Iterable<T> {
13
13
  has(item: T): boolean;
14
- +size: number;
14
+ readonly size: number;
15
15
  count(item: T): number;
16
16
  forEach<ThisT>(
17
17
  callbackFn: (
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * @noformat
8
8
  * @oncall react_native
9
- * @generated SignedSource<<e7173f8dc5e076fd37b9a1cecd581f58>>
9
+ * @generated SignedSource<<bfc4caf223ec55afbed87fbd905607ea>>
10
10
  *
11
11
  * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
12
  * Original file: packages/metro/src/lib/JsonReporter.js
@@ -33,7 +33,6 @@ export type SerializedEvent<
33
33
  declare class JsonReporter<
34
34
  TEvent extends {readonly [$$Key$$: string]: unknown},
35
35
  > {
36
- _stream: Writable;
37
36
  constructor(stream: Writable);
38
37
  /**
39
38
  * There is a special case for errors because they have non-enumerable fields.
@@ -19,7 +19,7 @@ export type SerializedError = {
19
19
  ...
20
20
  };
21
21
 
22
- export type SerializedEvent<TEvent extends {+[string]: unknown, ...}> =
22
+ export type SerializedEvent<TEvent extends {readonly [string]: unknown, ...}> =
23
23
  TEvent extends {
24
24
  error: Error,
25
25
  ...
@@ -31,7 +31,9 @@ export type SerializedEvent<TEvent extends {+[string]: unknown, ...}> =
31
31
  }
32
32
  : TEvent;
33
33
 
34
- export default class JsonReporter<TEvent extends {+[string]: unknown, ...}> {
34
+ export default class JsonReporter<
35
+ TEvent extends {readonly [string]: unknown, ...},
36
+ > {
35
37
  _stream: Writable;
36
38
 
37
39
  constructor(stream: Writable) {
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @noformat
8
- * @generated SignedSource<<ebddbde1dcdecbbee129fd96caaf3bb0>>
8
+ * @generated SignedSource<<7be940ed3f4c6dffc465780640e301ec>>
9
9
  *
10
10
  * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
11
11
  * Original file: packages/metro/src/lib/RamBundleParser.js
@@ -24,12 +24,7 @@
24
24
  * getModule(): returns the code for the specified module.
25
25
  */
26
26
  declare class RamBundleParser {
27
- _buffer: Buffer;
28
- _numModules: number;
29
- _startupCodeLength: number;
30
- _startOffset: number;
31
27
  constructor(buffer: Buffer);
32
- _readPosition(pos: number): number;
33
28
  getStartupCode(): string;
34
29
  getModule(id: number): string;
35
30
  }