metro 0.84.4 → 0.86.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 (55) hide show
  1. package/package.json +17 -17
  2. package/src/Assets.js +3 -1
  3. package/src/Assets.js.flow +31 -25
  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.d.ts +3 -2
  12. package/src/DeltaBundler/Serializers/getExplodedSourceMap.js.flow +6 -5
  13. package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.d.ts +3 -2
  14. package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.js.flow +10 -9
  15. package/src/DeltaBundler/Serializers/hmrJSBundle.js.flow +3 -3
  16. package/src/DeltaBundler/Serializers/sourceMapGenerator.d.ts +4 -4
  17. package/src/DeltaBundler/Serializers/sourceMapGenerator.js +2 -2
  18. package/src/DeltaBundler/Serializers/sourceMapGenerator.js.flow +7 -5
  19. package/src/DeltaBundler/Transformer.d.ts +2 -10
  20. package/src/DeltaBundler/Worker.flow.js.flow +1 -1
  21. package/src/DeltaBundler/WorkerFarm.d.ts +2 -47
  22. package/src/DeltaBundler/getTransformCacheKey.js.flow +3 -3
  23. package/src/DeltaBundler/types.js.flow +10 -10
  24. package/src/DeltaBundler.d.ts +1 -5
  25. package/src/HmrServer.d.ts +2 -45
  26. package/src/HmrServer.js.flow +10 -10
  27. package/src/IncrementalBundler.d.ts +1 -9
  28. package/src/IncrementalBundler.js.flow +9 -6
  29. package/src/ModuleGraph/worker/collectDependencies.d.ts +1 -2
  30. package/src/Server/symbolicate.js +66 -33
  31. package/src/Server/symbolicate.js.flow +90 -51
  32. package/src/Server.d.ts +3 -179
  33. package/src/Server.js.flow +25 -23
  34. package/src/index.d.ts +1 -23
  35. package/src/index.flow.js +1 -15
  36. package/src/index.flow.js.flow +0 -20
  37. package/src/lib/BatchProcessor.d.ts +1 -21
  38. package/src/lib/CountingSet.js.flow +1 -1
  39. package/src/lib/JsonReporter.d.ts +1 -2
  40. package/src/lib/JsonReporter.js.flow +4 -2
  41. package/src/lib/RamBundleParser.d.ts +1 -6
  42. package/src/lib/TerminalReporter.d.ts +2 -78
  43. package/src/lib/TerminalReporter.js.flow +1 -1
  44. package/src/lib/bundleToString.js.flow +2 -2
  45. package/src/lib/createWebsocketServer.js.flow +4 -4
  46. package/src/lib/formatBundlingError.js.flow +1 -1
  47. package/src/lib/getPreludeCode.js.flow +5 -5
  48. package/src/node-haste/DependencyGraph/ModuleResolution.d.ts +1 -13
  49. package/src/node-haste/DependencyGraph/ModuleResolution.js.flow +1 -1
  50. package/src/node-haste/DependencyGraph/createFileMap.js +23 -31
  51. package/src/node-haste/DependencyGraph/createFileMap.js.flow +23 -38
  52. package/src/node-haste/DependencyGraph.d.ts +1 -30
  53. package/src/node-haste/DependencyGraph.js.flow +2 -2
  54. package/src/shared/output/RamBundle/util.js.flow +4 -2
  55. package/src/shared/types.js.flow +31 -31
@@ -12,18 +12,20 @@
12
12
  import type {
13
13
  FBSourceFunctionMap,
14
14
  MetroSourceMapSegmentTuple,
15
+ VlqMap,
15
16
  } from '../../../metro-source-map/src/source-map';
16
17
  import type {ExplodedSourceMap} from '../DeltaBundler/Serializers/getExplodedSourceMap';
17
18
  import type {ConfigT} from 'metro-config';
18
19
 
19
20
  import {greatestLowerBound} from 'metro-source-map/private/Consumer/search';
21
+ import LineIndexedMappings from 'metro-source-map/private/LineIndexedMappings';
20
22
  import {SourceMetadataMapConsumer} from 'metro-symbolicate/private/Symbolication';
21
23
 
22
24
  export type StackFrameInput = {
23
- +file: ?string,
24
- +lineNumber: ?number,
25
- +column: ?number,
26
- +methodName: ?string,
25
+ readonly file: ?string,
26
+ readonly lineNumber: ?number,
27
+ readonly column: ?number,
28
+ readonly methodName: ?string,
27
29
  ...
28
30
  };
29
31
  export type IntermediateStackFrame = {
@@ -33,7 +35,76 @@ export type IntermediateStackFrame = {
33
35
  };
34
36
  export type StackFrameOutput = Readonly<IntermediateStackFrame>;
35
37
  type ExplodedSourceMapModule = ExplodedSourceMap[number];
36
- type Position = {+line1Based: number, column0Based: number};
38
+ type Position = {readonly line1Based: number, column0Based: number};
39
+
40
+ // Cache of per-line indices, keyed on the VlqMap held by the module graph. A
41
+ // WeakMap lets an index outlive the request that built it, so later requests
42
+ // resolving frames in the same module reuse it, and releases it automatically
43
+ // when the module leaves the graph. The index references the graph's existing
44
+ // mappings string and adds only O(lines) integers, so retaining it alongside
45
+ // the graph stays cheap.
46
+ const lineIndexCache: WeakMap<VlqMap, LineIndexedMappings> = new WeakMap();
47
+
48
+ // Resolve a generated (line, column) within a module to its original position.
49
+ // Tuple-backed modules keep their decoded segments, so we search them directly;
50
+ // VLQ-backed modules go through a compact per-line `LineIndexedMappings` that
51
+ // decodes only the target line. Byte-identical either way.
52
+ function originalPositionInModule(
53
+ map: Array<MetroSourceMapSegmentTuple> | VlqMap,
54
+ generatedLine1Based: number,
55
+ generatedColumn0Based: number,
56
+ ): ?Position {
57
+ if (Array.isArray(map)) {
58
+ return originalPositionInTuples(
59
+ map,
60
+ generatedLine1Based,
61
+ generatedColumn0Based,
62
+ );
63
+ }
64
+ let decoded = lineIndexCache.get(map);
65
+ if (decoded == null) {
66
+ decoded = new LineIndexedMappings(map.mappings);
67
+ lineIndexCache.set(map, decoded);
68
+ }
69
+ return decoded.originalPositionFor(
70
+ generatedLine1Based,
71
+ generatedColumn0Based,
72
+ );
73
+ }
74
+
75
+ // greatestLowerBound over pre-decoded tuples, ordered by (line, column).
76
+ function originalPositionInTuples(
77
+ mappings: Array<MetroSourceMapSegmentTuple>,
78
+ generatedLine1Based: number,
79
+ generatedColumn0Based: number,
80
+ ): ?Position {
81
+ const target = {
82
+ line1Based: generatedLine1Based,
83
+ column0Based: generatedColumn0Based,
84
+ };
85
+ const mappingIndex = greatestLowerBound(mappings, target, (t, candidate) => {
86
+ if (t.line1Based === candidate[0]) {
87
+ return t.column0Based - candidate[1];
88
+ }
89
+ return t.line1Based - candidate[0];
90
+ });
91
+ if (mappingIndex == null) {
92
+ return null;
93
+ }
94
+ const mapping = mappings[mappingIndex];
95
+ if (
96
+ mapping[0] !== target.line1Based ||
97
+ mapping.length < 4 /* no source line/column info */
98
+ ) {
99
+ return null;
100
+ }
101
+ return {
102
+ // $FlowFixMe[invalid-tuple-index]: Length checks do not refine tuple unions.
103
+ line1Based: mapping[2],
104
+ // $FlowFixMe[invalid-tuple-index]: Length checks do not refine tuple unions.
105
+ column0Based: mapping[3],
106
+ };
107
+ }
37
108
 
38
109
  function createFunctionNameGetter(
39
110
  module: ExplodedSourceMapModule,
@@ -68,10 +139,10 @@ export default async function symbolicate(
68
139
  }
69
140
  const functionNameGetters = new Map<
70
141
  {
71
- +firstLine1Based: number,
72
- +functionMap: ?FBSourceFunctionMap,
73
- +map: Array<MetroSourceMapSegmentTuple>,
74
- +path: string,
142
+ readonly firstLine1Based: number,
143
+ readonly functionMap: ?FBSourceFunctionMap,
144
+ readonly map: Array<MetroSourceMapSegmentTuple> | VlqMap,
145
+ readonly path: string,
75
146
  },
76
147
  (Position) => ?string,
77
148
  >();
@@ -96,52 +167,25 @@ export default async function symbolicate(
96
167
  frame: StackFrameInput,
97
168
  module: ExplodedSourceMapModule,
98
169
  ): ?Position {
99
- if (
100
- module.map == null ||
101
- frame.lineNumber == null ||
102
- frame.column == null
103
- ) {
170
+ const lineNumber = frame.lineNumber;
171
+ const column = frame.column;
172
+ if (module.map == null || lineNumber == null || column == null) {
104
173
  return null;
105
174
  }
106
- const generatedPosInModule = {
107
- line1Based: frame.lineNumber - module.firstLine1Based + 1,
108
- column0Based: frame.column,
109
- };
110
- const mappingIndex = greatestLowerBound(
175
+ return originalPositionInModule(
111
176
  module.map,
112
- generatedPosInModule,
113
- (target, candidate) => {
114
- if (target.line1Based === candidate[0]) {
115
- return target.column0Based - candidate[1];
116
- }
117
- return target.line1Based - candidate[0];
118
- },
177
+ lineNumber - module.firstLine1Based + 1,
178
+ column,
119
179
  );
120
- if (mappingIndex == null) {
121
- return null;
122
- }
123
- const mapping = module.map[mappingIndex];
124
- if (
125
- mapping[0] !== generatedPosInModule.line1Based ||
126
- mapping.length < 4 /* no source line/column info */
127
- ) {
128
- return null;
129
- }
130
- return {
131
- // $FlowFixMe[invalid-tuple-index]: Length checks do not refine tuple unions.
132
- line1Based: mapping[2],
133
- // $FlowFixMe[invalid-tuple-index]: Length checks do not refine tuple unions.
134
- column0Based: mapping[3],
135
- };
136
180
  }
137
181
 
138
182
  function findFunctionName(
139
183
  originalPos: Position,
140
184
  module: {
141
- +firstLine1Based: number,
142
- +functionMap: ?FBSourceFunctionMap,
143
- +map: Array<MetroSourceMapSegmentTuple>,
144
- +path: string,
185
+ readonly firstLine1Based: number,
186
+ readonly functionMap: ?FBSourceFunctionMap,
187
+ readonly map: Array<MetroSourceMapSegmentTuple> | VlqMap,
188
+ readonly path: string,
145
189
  },
146
190
  ): ?string {
147
191
  if (module.functionMap) {
@@ -160,11 +204,6 @@ export default async function symbolicate(
160
204
  if (!module) {
161
205
  return {...frame};
162
206
  }
163
- if (!Array.isArray(module.map)) {
164
- throw new Error(
165
- `Unexpected module with serialized source map found: ${module.path}`,
166
- );
167
- }
168
207
  const originalPos = findOriginalPos(frame, module);
169
208
  if (!originalPos) {
170
209
  return {...frame};
package/src/Server.d.ts CHANGED
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * @noformat
8
8
  * @oncall react_native
9
- * @generated SignedSource<<03b526801403adb05b3b0f6c25b25ed5>>
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,183 +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
- _resolveWatchFolderPrefix(
229
- filePath: string,
230
- ): {rootDir: string; filePath: string} | null;
231
- _resolveRelativePath(
232
- filePath: string,
233
- $$PARAM_1$$: Readonly<{
234
- relativeTo: 'project' | 'server';
235
- resolverOptions: ResolverInputOptions;
236
- transformOptions: TransformInputOptions;
237
- }>,
238
- ): Promise<string>;
239
67
  getNewBuildNumber(): number;
240
68
  getPlatforms(): ReadonlyArray<string>;
241
69
  getWatchFolders(): ReadonlyArray<string>;
@@ -272,10 +100,6 @@ declare class Server {
272
100
  sourceUrl: null;
273
101
  sourcePaths: SourcePathsMode;
274
102
  };
275
- _getServerRootDir(): string;
276
- _getEntryPointAbsolutePath(entryFile: string): string;
277
103
  ready(): Promise<void>;
278
- _shouldAddModuleToIgnoreList(module: Module): boolean;
279
- _getModuleSourceUrl(module: Module, mode: SourcePathsMode): string;
280
104
  }
281
105
  export default Server;
@@ -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,
package/src/index.d.ts CHANGED
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * @noformat
8
8
  * @oncall react_native
9
- * @generated SignedSource<<3c6460427c6760887187d6b16151c609>>
9
+ * @generated SignedSource<<8cfd5068558051749a42bc72eb4b915f>>
10
10
  *
11
11
  * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
12
  * Original file: packages/metro/src/index.flow.js
@@ -182,25 +182,3 @@ export declare const attachMetroCli: (
182
182
  options?: AttachMetroCLIOptions,
183
183
  ) => Yargs;
184
184
  export declare type attachMetroCli = typeof attachMetroCli;
185
- /**
186
- * Backwards-compatibility with CommonJS consumers using interopRequireDefault.
187
- * Do not add to this list.
188
- *
189
- * @deprecated Default import from 'metro' is deprecated, use named exports.
190
- */
191
- declare const $$EXPORT_DEFAULT_DECLARATION$$: {
192
- attachMetroCli: typeof attachMetroCli;
193
- runServer: typeof runServer;
194
- Terminal: typeof Terminal;
195
- JsonReporter: typeof JsonReporter;
196
- TerminalReporter: typeof TerminalReporter;
197
- loadConfig: typeof loadConfig;
198
- mergeConfig: typeof mergeConfig;
199
- resolveConfig: typeof resolveConfig;
200
- createConnectMiddleware: typeof createConnectMiddleware;
201
- runBuild: typeof runBuild;
202
- buildGraph: typeof buildGraph;
203
- };
204
- declare type $$EXPORT_DEFAULT_DECLARATION$$ =
205
- typeof $$EXPORT_DEFAULT_DECLARATION$$;
206
- export default $$EXPORT_DEFAULT_DECLARATION$$;
package/src/index.flow.js CHANGED
@@ -21,8 +21,7 @@ Object.defineProperty(exports, "TerminalReporter", {
21
21
  return _TerminalReporter.default;
22
22
  },
23
23
  });
24
- exports.default =
25
- exports.createConnectMiddleware =
24
+ exports.createConnectMiddleware =
26
25
  exports.buildGraph =
27
26
  exports.attachMetroCli =
28
27
  void 0;
@@ -458,16 +457,3 @@ async function earlyPortCheck(host, port) {
458
457
  await new Promise((resolve) => server.close(() => resolve()));
459
458
  }
460
459
  }
461
- var _default = (exports.default = {
462
- attachMetroCli,
463
- runServer,
464
- Terminal: _metroCore.Terminal,
465
- JsonReporter: _JsonReporter.default,
466
- TerminalReporter: _TerminalReporter.default,
467
- loadConfig: _metroConfig.loadConfig,
468
- mergeConfig: _metroConfig.mergeConfig,
469
- resolveConfig: _metroConfig.resolveConfig,
470
- createConnectMiddleware,
471
- runBuild,
472
- buildGraph,
473
- });
@@ -587,23 +587,3 @@ async function earlyPortCheck(host: void | string, port: number) {
587
587
  await new Promise(resolve => server.close(() => resolve()));
588
588
  }
589
589
  }
590
-
591
- /**
592
- * Backwards-compatibility with CommonJS consumers using interopRequireDefault.
593
- * Do not add to this list.
594
- *
595
- * @deprecated Default import from 'metro' is deprecated, use named exports.
596
- */
597
- export default {
598
- attachMetroCli,
599
- runServer,
600
- Terminal,
601
- JsonReporter,
602
- TerminalReporter,
603
- loadConfig,
604
- mergeConfig,
605
- resolveConfig,
606
- createConnectMiddleware,
607
- runBuild,
608
- buildGraph,
609
- };
@@ -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.