metro 0.70.3 → 0.71.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 (67) hide show
  1. package/package.json +20 -20
  2. package/src/Assets.js.flow +4 -4
  3. package/src/Bundler/util.js +1 -1
  4. package/src/Bundler/util.js.flow +2 -2
  5. package/src/Bundler.js +17 -10
  6. package/src/Bundler.js.flow +19 -14
  7. package/src/DeltaBundler/DeltaCalculator.js +13 -17
  8. package/src/DeltaBundler/DeltaCalculator.js.flow +15 -20
  9. package/src/DeltaBundler/Serializers/getAllFiles.js.flow +2 -2
  10. package/src/DeltaBundler/Serializers/getAssets.js.flow +2 -2
  11. package/src/DeltaBundler/Serializers/getExplodedSourceMap.js.flow +4 -4
  12. package/src/DeltaBundler/Serializers/getRamBundleInfo.js.flow +6 -6
  13. package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.js.flow +4 -4
  14. package/src/DeltaBundler/Serializers/helpers/processBytecodeModules.js.flow +2 -2
  15. package/src/DeltaBundler/Serializers/helpers/processModules.js.flow +2 -2
  16. package/src/DeltaBundler/Serializers/hmrJSBundle.js.flow +2 -2
  17. package/src/DeltaBundler/Serializers/sourceMapGenerator.js.flow +6 -6
  18. package/src/DeltaBundler/Serializers/sourceMapObject.js.flow +4 -4
  19. package/src/DeltaBundler/Serializers/sourceMapString.js.flow +2 -2
  20. package/src/DeltaBundler/Worker.js.flow +4 -4
  21. package/src/DeltaBundler/WorkerFarm.js.flow +4 -4
  22. package/src/DeltaBundler/getTransformCacheKey.js.flow +2 -2
  23. package/src/DeltaBundler/{traverseDependencies.js → graphOperations.js} +43 -32
  24. package/src/DeltaBundler/{traverseDependencies.js.flow → graphOperations.js.flow} +52 -37
  25. package/src/DeltaBundler/types.flow.js.flow +36 -30
  26. package/src/DeltaBundler.js +14 -6
  27. package/src/DeltaBundler.js.flow +14 -10
  28. package/src/HmrServer.js.flow +6 -6
  29. package/src/IncrementalBundler.js +1 -1
  30. package/src/IncrementalBundler.js.flow +8 -8
  31. package/src/ModuleGraph/node-haste/ModuleCache.js +1 -1
  32. package/src/ModuleGraph/node-haste/ModuleCache.js.flow +1 -1
  33. package/src/ModuleGraph/node-haste/node-haste.flow.js.flow +2 -2
  34. package/src/ModuleGraph/node-haste/node-haste.js +4 -4
  35. package/src/ModuleGraph/node-haste/node-haste.js.flow +13 -7
  36. package/src/ModuleGraph/output/indexed-ram-bundle.js.flow +2 -2
  37. package/src/ModuleGraph/output/plain-bundle.js.flow +2 -2
  38. package/src/ModuleGraph/output/reverse-dependency-map-references.js.flow +8 -8
  39. package/src/ModuleGraph/output/util.js.flow +2 -2
  40. package/src/ModuleGraph/types.flow.js.flow +37 -37
  41. package/src/ModuleGraph/worker/collectDependencies.js.flow +2 -2
  42. package/src/Server/symbolicate.js.flow +1 -1
  43. package/src/Server.js.flow +18 -18
  44. package/src/commands/build.js.flow +2 -2
  45. package/src/commands/serve.js.flow +2 -2
  46. package/src/index.js +32 -18
  47. package/src/index.js.flow +42 -32
  48. package/src/lib/bundleToBytecode.js.flow +2 -2
  49. package/src/lib/bundleToString.js.flow +2 -2
  50. package/src/lib/getPreludeCode.js.flow +2 -2
  51. package/src/lib/transformHelpers.js.flow +2 -2
  52. package/src/node-haste/DependencyGraph/ModuleResolution.js +2 -1
  53. package/src/node-haste/DependencyGraph/ModuleResolution.js.flow +5 -12
  54. package/src/node-haste/DependencyGraph/createHasteMap.js +9 -7
  55. package/src/node-haste/DependencyGraph/createHasteMap.js.flow +6 -9
  56. package/src/node-haste/DependencyGraph.js +31 -27
  57. package/src/node-haste/DependencyGraph.js.flow +43 -37
  58. package/src/node-haste/ModuleCache.js.flow +1 -1
  59. package/src/node-haste/lib/AssetPaths.js.flow +2 -2
  60. package/src/node-haste/lib/parsePlatformFilePath.js.flow +2 -2
  61. package/src/shared/output/RamBundle/as-indexed-file.js.flow +1 -1
  62. package/src/shared/output/RamBundle/buildSourcemapWithMetadata.js.flow +2 -2
  63. package/src/shared/types.flow.js.flow +14 -14
  64. package/src/DeltaBundler/computeDelta.js +0 -42
  65. package/src/DeltaBundler/computeDelta.js.flow +0 -47
  66. package/src/node-haste/DependencyGraph/types.js +0 -10
  67. package/src/node-haste/DependencyGraph/types.js.flow +0 -88
@@ -13,13 +13,13 @@
13
13
  const parsePlatformFilePath = require('./parsePlatformFilePath');
14
14
  const path = require('path');
15
15
 
16
- export type AssetPath = {|
16
+ export type AssetPath = {
17
17
  assetName: string,
18
18
  name: string,
19
19
  platform: ?string,
20
20
  resolution: number,
21
21
  type: string,
22
- |};
22
+ };
23
23
 
24
24
  const ASSET_BASE_NAME_RE = /(.+?)(@([\d.]+)x)?$/;
25
25
 
@@ -12,12 +12,12 @@
12
12
 
13
13
  const path = require('path');
14
14
 
15
- type PlatformFilePathParts = {|
15
+ type PlatformFilePathParts = {
16
16
  dirPath: string,
17
17
  baseName: string,
18
18
  platform: ?string,
19
19
  extension: ?string,
20
- |};
20
+ };
21
21
 
22
22
  const PATH_RE = /^(.+?)(\.([^.]+))?\.([^.]+)$/;
23
23
 
@@ -109,7 +109,7 @@ function moduleToBuffer(
109
109
  id: number,
110
110
  code: string,
111
111
  encoding: void | 'ascii' | 'utf16le' | 'utf8',
112
- ): {|buffer: Buffer, id: number|} {
112
+ ): {buffer: Buffer, id: number} {
113
113
  return {
114
114
  id,
115
115
  buffer: nullTerminatedBuffer(code, encoding),
@@ -19,12 +19,12 @@ const {
19
19
  joinModules,
20
20
  } = require('./util');
21
21
 
22
- type Params = {|
22
+ type Params = {
23
23
  fixWrapperOffset: boolean,
24
24
  lazyModules: $ReadOnlyArray<ModuleTransportLike>,
25
25
  moduleGroups: ?ModuleGroups,
26
26
  startupModules: $ReadOnlyArray<ModuleTransportLike>,
27
- |};
27
+ };
28
28
 
29
29
  module.exports = (({
30
30
  fixWrapperOffset,
@@ -61,33 +61,33 @@ export type BundleOptions = {
61
61
  ...
62
62
  };
63
63
 
64
- export type SerializerOptions = {|
64
+ export type SerializerOptions = {
65
65
  +sourceMapUrl: ?string,
66
66
  +sourceUrl: ?string,
67
67
  +runModule: boolean,
68
68
  +excludeSource: boolean,
69
69
  +inlineSourceMap: boolean,
70
70
  +modulesOnly: boolean,
71
- |};
71
+ };
72
72
 
73
- export type GraphOptions = {|
73
+ export type GraphOptions = {
74
74
  +shallow: boolean,
75
- |};
75
+ };
76
76
 
77
77
  // Stricter representation of BundleOptions.
78
- export type SplitBundleOptions = {|
78
+ export type SplitBundleOptions = {
79
79
  +entryFile: string,
80
80
  +transformOptions: TransformInputOptions,
81
81
  +serializerOptions: SerializerOptions,
82
82
  +graphOptions: GraphOptions,
83
83
  +onProgress: $PropertyType<DeltaBundlerOptions<>, 'onProgress'>,
84
- |};
84
+ };
85
85
 
86
- export type ModuleGroups = {|
86
+ export type ModuleGroups = {
87
87
  groups: Map<number, Set<number>>,
88
88
  modulesById: Map<number, ModuleTransportLike>,
89
89
  modulesInGroups: Set<number>,
90
- |};
90
+ };
91
91
 
92
92
  export type ModuleTransportLike = {
93
93
  +code: string,
@@ -97,18 +97,18 @@ export type ModuleTransportLike = {
97
97
  +sourcePath: string,
98
98
  ...
99
99
  };
100
- export type ModuleTransportLikeStrict = {|
100
+ export type ModuleTransportLikeStrict = {
101
101
  +code: string,
102
102
  +id: number,
103
103
  +map: ?MetroSourceMapOrMappings,
104
104
  +name?: string,
105
105
  +sourcePath: string,
106
- |};
107
- export type RamModuleTransport = {|
106
+ };
107
+ export type RamModuleTransport = {
108
108
  ...ModuleTransportLikeStrict,
109
109
  +source: string,
110
110
  +type: string,
111
- |};
111
+ };
112
112
 
113
113
  export type OutputOptions = {
114
114
  bundleOutput: string,
@@ -122,7 +122,7 @@ export type OutputOptions = {
122
122
  ...
123
123
  };
124
124
 
125
- export type RequestOptions = {|
125
+ export type RequestOptions = {
126
126
  entryFile: string,
127
127
  inlineSourceMap?: boolean,
128
128
  sourceMapUrl?: string,
@@ -131,6 +131,6 @@ export type RequestOptions = {|
131
131
  platform: string,
132
132
  createModuleIdFactory?: () => (path: string) => number,
133
133
  onProgress?: (transformedFileCount: number, totalFileCount: number) => void,
134
- |};
134
+ };
135
135
 
136
136
  export type {MinifierOptions};
@@ -1,42 +0,0 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- *
8
- * @format
9
- */
10
- "use strict";
11
-
12
- function computeDelta(entries1, entries2) {
13
- const modules1 = new Map(entries1);
14
- const modules2 = new Map(entries2);
15
- const added = new Map();
16
- const modified = new Map();
17
- const deleted = new Set();
18
-
19
- for (const [id, code] of modules1.entries()) {
20
- const newCode = modules2.get(id);
21
-
22
- if (newCode == null) {
23
- deleted.add(id);
24
- } else if (newCode !== code) {
25
- modified.set(id, newCode);
26
- }
27
- }
28
-
29
- for (const [id, code] of modules2.entries()) {
30
- if (!modules1.has(id)) {
31
- added.set(id, code);
32
- }
33
- }
34
-
35
- return {
36
- added: [...added.entries()],
37
- modified: [...modified.entries()],
38
- deleted: [...deleted],
39
- };
40
- }
41
-
42
- module.exports = computeDelta;
@@ -1,47 +0,0 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- * @flow strict-local
8
- * @format
9
- */
10
-
11
- 'use strict';
12
-
13
- import type {
14
- DeltaBundle,
15
- ModuleMap,
16
- } from 'metro-runtime/src/modules/types.flow';
17
-
18
- function computeDelta(entries1: ModuleMap, entries2: ModuleMap): DeltaBundle {
19
- const modules1 = new Map(entries1);
20
- const modules2 = new Map(entries2);
21
- const added = new Map();
22
- const modified = new Map();
23
- const deleted = new Set();
24
-
25
- for (const [id, code] of modules1.entries()) {
26
- const newCode = modules2.get(id);
27
- if (newCode == null) {
28
- deleted.add(id);
29
- } else if (newCode !== code) {
30
- modified.set(id, newCode);
31
- }
32
- }
33
-
34
- for (const [id, code] of modules2.entries()) {
35
- if (!modules1.has(id)) {
36
- added.set(id, code);
37
- }
38
- }
39
-
40
- return {
41
- added: [...added.entries()],
42
- modified: [...modified.entries()],
43
- deleted: [...deleted],
44
- };
45
- }
46
-
47
- module.exports = computeDelta;
@@ -1,10 +0,0 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- *
8
- * @format
9
- */
10
- "use strict";
@@ -1,88 +0,0 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- * @flow strict
8
- * @format
9
- */
10
-
11
- 'use strict';
12
-
13
- import type EventEmitter from 'events';
14
-
15
- // TODO(cpojer): Create a jest-types repo.
16
- export type HasteFS = {
17
- exists(filePath: string): boolean,
18
- getAllFiles(): Array<string>,
19
- getDependencies(filePath: string): Array<string>,
20
- getFileIterator(): Iterator<string>,
21
- getModuleName(filePath: string): ?string,
22
- getSha1(string): ?string,
23
- matchFiles(pattern: RegExp | string): Array<string>,
24
- ...
25
- };
26
-
27
- export type HasteConfig = $ReadOnly<{
28
- cacheDirectory?: ?string,
29
- computeDependencies?: ?boolean,
30
- computeSha1?: ?boolean,
31
- dependencyExtractor?: ?string | null,
32
- enableSymlinks?: ?boolean,
33
- extensions: $ReadOnlyArray<string>,
34
- forceNodeFilesystemAPI?: ?boolean,
35
- hasteImplModulePath?: ?string,
36
- hasteMapModulePath?: ?string,
37
- ignorePattern?: ?RegExp | ((str: string) => boolean),
38
- maxWorkers: number,
39
- mocksPattern?: ?string,
40
- name: string,
41
- platforms: $ReadOnlyArray<string>,
42
- resetCache?: ?boolean,
43
- retainAllFiles: boolean,
44
- rootDir: string,
45
- roots: $ReadOnlyArray<string>,
46
- skipPackageJson?: ?boolean,
47
- throwOnModuleCollision?: ?boolean,
48
- useWatchman?: ?boolean,
49
- watch?: ?boolean,
50
- ...
51
- }>;
52
-
53
- type ModuleMapItem = {[platform: string]: ModuleMetaData};
54
- type ModuleMetaData = [string, number];
55
- type MockData = Map<string, string>;
56
- type ModuleMapData = Map<string, ModuleMapItem>;
57
- type DuplicatesSet = Map<string, number>;
58
- type DuplicatesIndex = Map<string, Map<string, DuplicatesSet>>;
59
-
60
- type RawModuleMap = {
61
- rootDir: string,
62
- duplicates: DuplicatesIndex,
63
- map: ModuleMapData,
64
- mocks: MockData,
65
- };
66
-
67
- // `jest-haste-map`'s interface for ModuleMap.
68
- export type ModuleMap = {
69
- getModule(
70
- name: string,
71
- platform: string | null,
72
- supportsNativePlatform: ?boolean,
73
- ): ?string,
74
- getPackage(
75
- name: string,
76
- platform: string | null,
77
- supportsNativePlatform: ?boolean,
78
- ): ?string,
79
- getRawModuleMap(): RawModuleMap,
80
- ...
81
- };
82
-
83
- // Interface as used by node-haste / internal tools, satisfied by JestHasteMap
84
- export interface HasteMap extends EventEmitter {
85
- build: () => Promise<{hasteFS: HasteFS, moduleMap: ModuleMap}>;
86
- end: () => void;
87
- getCacheFilePath: () => string;
88
- }