metro 0.83.5 → 0.83.6

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 (113) hide show
  1. package/package.json +15 -15
  2. package/src/Assets.d.ts +8 -1
  3. package/src/Bundler/util.d.ts +8 -1
  4. package/src/Bundler/util.js.flow +3 -3
  5. package/src/Bundler.d.ts +8 -1
  6. package/src/DeltaBundler/DeltaCalculator.d.ts +8 -11
  7. package/src/DeltaBundler/DeltaCalculator.js +55 -46
  8. package/src/DeltaBundler/DeltaCalculator.js.flow +72 -61
  9. package/src/DeltaBundler/Graph.d.ts +8 -1
  10. package/src/DeltaBundler/Serializers/baseJSBundle.d.ts +8 -1
  11. package/src/DeltaBundler/Serializers/getAllFiles.d.ts +8 -1
  12. package/src/DeltaBundler/Serializers/getAssets.d.ts +8 -1
  13. package/src/DeltaBundler/Serializers/getExplodedSourceMap.d.ts +8 -1
  14. package/src/DeltaBundler/Serializers/getRamBundleInfo.d.ts +8 -1
  15. package/src/DeltaBundler/Serializers/helpers/getInlineSourceMappingURL.d.ts +8 -1
  16. package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.d.ts +8 -1
  17. package/src/DeltaBundler/Serializers/helpers/getTransitiveDependencies.d.ts +8 -1
  18. package/src/DeltaBundler/Serializers/helpers/js.d.ts +8 -1
  19. package/src/DeltaBundler/Serializers/helpers/processModules.d.ts +8 -1
  20. package/src/DeltaBundler/Serializers/hmrJSBundle.d.ts +8 -1
  21. package/src/DeltaBundler/Serializers/sourceMapGenerator.d.ts +8 -1
  22. package/src/DeltaBundler/Serializers/sourceMapObject.d.ts +8 -1
  23. package/src/DeltaBundler/Serializers/sourceMapString.d.ts +8 -1
  24. package/src/DeltaBundler/Transformer.d.ts +8 -1
  25. package/src/DeltaBundler/Worker.d.ts +8 -1
  26. package/src/DeltaBundler/WorkerFarm.d.ts +8 -1
  27. package/src/DeltaBundler/buildSubgraph.d.ts +8 -1
  28. package/src/DeltaBundler/getTransformCacheKey.d.ts +8 -1
  29. package/src/DeltaBundler/getTransformCacheKey.js +3 -1
  30. package/src/DeltaBundler/getTransformCacheKey.js.flow +7 -2
  31. package/src/DeltaBundler/mergeDeltas.d.ts +8 -1
  32. package/src/DeltaBundler/types.d.ts +8 -1
  33. package/src/DeltaBundler.d.ts +8 -1
  34. package/src/HmrServer.d.ts +22 -3
  35. package/src/HmrServer.js +7 -0
  36. package/src/HmrServer.js.flow +15 -5
  37. package/src/IncrementalBundler/GraphNotFoundError.d.ts +8 -1
  38. package/src/IncrementalBundler/ResourceNotFoundError.d.ts +8 -1
  39. package/src/IncrementalBundler/RevisionNotFoundError.d.ts +8 -1
  40. package/src/IncrementalBundler.d.ts +8 -1
  41. package/src/ModuleGraph/worker/JsFileWrapping.d.ts +8 -1
  42. package/src/ModuleGraph/worker/collectDependencies.d.ts +8 -1
  43. package/src/ModuleGraph/worker/generateImportNames.d.ts +8 -1
  44. package/src/ModuleGraph/worker/importLocationsPlugin.d.ts +8 -1
  45. package/src/Server/MultipartResponse.d.ts +8 -1
  46. package/src/Server/symbolicate.d.ts +8 -1
  47. package/src/Server.d.ts +8 -1
  48. package/src/cli/parseKeyValueParamArray.d.ts +8 -1
  49. package/src/cli-utils.d.ts +8 -1
  50. package/src/commands/build.d.ts +8 -1
  51. package/src/commands/dependencies.d.ts +8 -1
  52. package/src/commands/serve.d.ts +8 -1
  53. package/src/index.d.ts +29 -3
  54. package/src/index.flow.js.flow +21 -2
  55. package/src/lib/BatchProcessor.d.ts +8 -1
  56. package/src/lib/CountingSet.d.ts +8 -1
  57. package/src/lib/JsonReporter.d.ts +8 -1
  58. package/src/lib/JsonReporter.js.flow +2 -2
  59. package/src/lib/RamBundleParser.d.ts +8 -1
  60. package/src/lib/TerminalReporter.d.ts +8 -1
  61. package/src/lib/bundleProgressUtils.d.ts +8 -1
  62. package/src/lib/bundleToString.d.ts +8 -1
  63. package/src/lib/contextModule.d.ts +8 -1
  64. package/src/lib/contextModuleTemplates.d.ts +8 -1
  65. package/src/lib/countLines.d.ts +8 -1
  66. package/src/lib/createWebsocketServer.d.ts +8 -1
  67. package/src/lib/debounceAsyncQueue.d.ts +8 -1
  68. package/src/lib/formatBundlingError.d.ts +8 -1
  69. package/src/lib/getAppendScripts.d.ts +8 -1
  70. package/src/lib/getAppendScripts.js.flow +2 -2
  71. package/src/lib/getGraphId.d.ts +8 -1
  72. package/src/lib/getPreludeCode.d.ts +8 -1
  73. package/src/lib/getPrependedScripts.d.ts +8 -1
  74. package/src/lib/isResolvedDependency.d.ts +8 -1
  75. package/src/lib/logToConsole.d.ts +8 -1
  76. package/src/lib/parseBundleOptionsFromBundleRequestUrl.d.ts +8 -1
  77. package/src/lib/parseCustomResolverOptions.d.ts +8 -1
  78. package/src/lib/parseCustomTransformOptions.d.ts +8 -1
  79. package/src/lib/parseJsonBody.d.ts +8 -1
  80. package/src/lib/pathUtils.d.ts +8 -1
  81. package/src/lib/relativizeSourceMap.d.ts +8 -1
  82. package/src/lib/reporting.d.ts +8 -1
  83. package/src/lib/splitBundleOptions.d.ts +8 -1
  84. package/src/lib/transformHelpers.d.ts +8 -1
  85. package/src/node-haste/DependencyGraph/ModuleResolution.d.ts +16 -22
  86. package/src/node-haste/DependencyGraph/ModuleResolution.js +4 -22
  87. package/src/node-haste/DependencyGraph/ModuleResolution.js.flow +10 -59
  88. package/src/node-haste/DependencyGraph/createFileMap.d.ts +8 -1
  89. package/src/node-haste/DependencyGraph/createFileMap.js +1 -1
  90. package/src/node-haste/DependencyGraph/createFileMap.js.flow +4 -2
  91. package/src/node-haste/DependencyGraph.d.ts +9 -5
  92. package/src/node-haste/DependencyGraph.js +22 -11
  93. package/src/node-haste/DependencyGraph.js.flow +24 -13
  94. package/src/node-haste/PackageCache.d.ts +19 -16
  95. package/src/node-haste/PackageCache.js +65 -54
  96. package/src/node-haste/PackageCache.js.flow +103 -79
  97. package/src/node-haste/lib/AssetPaths.d.ts +8 -1
  98. package/src/node-haste/lib/parsePlatformFilePath.d.ts +8 -1
  99. package/src/shared/output/RamBundle/as-assets.d.ts +8 -1
  100. package/src/shared/output/RamBundle/as-indexed-file.d.ts +8 -1
  101. package/src/shared/output/RamBundle/buildSourcemapWithMetadata.d.ts +8 -1
  102. package/src/shared/output/RamBundle/magic-number.d.ts +8 -1
  103. package/src/shared/output/RamBundle/util.d.ts +8 -1
  104. package/src/shared/output/RamBundle/write-sourcemap.d.ts +8 -1
  105. package/src/shared/output/RamBundle.d.ts +8 -1
  106. package/src/shared/output/bundle.d.ts +8 -1
  107. package/src/shared/output/meta.d.ts +8 -1
  108. package/src/shared/output/unbundle.d.ts +8 -1
  109. package/src/shared/output/writeFile.d.ts +8 -1
  110. package/src/shared/types.d.ts +8 -1
  111. package/src/node-haste/Package.d.ts +0 -21
  112. package/src/node-haste/Package.js +0 -28
  113. package/src/node-haste/Package.js.flow +0 -39
@@ -9,117 +9,141 @@
9
9
  * @oncall react_native
10
10
  */
11
11
 
12
- import Package from './Package';
12
+ import type {PackageJson} from 'metro-resolver/private/types';
13
+
14
+ import {readFileSync} from 'fs';
15
+ import {dirname, sep} from 'path';
13
16
 
14
17
  type GetClosestPackageFn = (absoluteFilePath: string) => ?{
15
18
  packageJsonPath: string,
16
19
  packageRelativePath: string,
17
20
  };
18
21
 
22
+ type PackageForModule = Readonly<{
23
+ packageJson: PackageJson,
24
+ rootPath: string,
25
+ packageRelativePath: string,
26
+ }>;
27
+
19
28
  export class PackageCache {
20
- _getClosestPackage: GetClosestPackageFn;
21
- _packageCache: {
22
- [filePath: string]: Package,
23
- __proto__: null,
24
- ...
25
- };
26
- // Cache for "closest package.json" queries by module path.
27
- _packagePathAndSubpathByModulePath: {
28
- [filePath: string]: ?{
29
- packageJsonPath: string,
30
- packageRelativePath: string,
29
+ #getClosestPackage: GetClosestPackageFn;
30
+ #packageCache: Map<
31
+ string,
32
+ {
33
+ rootPath: string,
34
+ packageJson: PackageJson,
31
35
  },
32
- __proto__: null,
33
- ...
34
- };
35
- // The inverse of _packagePathByModulePath.
36
- _modulePathsByPackagePath: {
37
- [filePath: string]: Set<string>,
38
- __proto__: null,
39
- ...
40
- };
36
+ >;
37
+ // Single cache: module path → pre-built result object, or null (no allocation on hit)
38
+ #resultByModulePath: Map<string, PackageForModule | null>;
39
+ // Reverse index for invalidation: package.json path → set of module paths
40
+ #modulePathsByPackagePath: Map<string, Set<string>>;
41
+ // Module paths that resolved to no package.json (null), for invalidation
42
+ #modulePathsWithNoPackage: Set<string>;
41
43
 
42
44
  constructor(options: {getClosestPackage: GetClosestPackageFn, ...}) {
43
- this._getClosestPackage = options.getClosestPackage;
44
- this._packageCache = Object.create(null);
45
- this._packagePathAndSubpathByModulePath = Object.create(null);
46
- this._modulePathsByPackagePath = Object.create(null);
45
+ this.#getClosestPackage = options.getClosestPackage;
46
+ this.#packageCache = new Map();
47
+ this.#resultByModulePath = new Map();
48
+ this.#modulePathsByPackagePath = new Map();
49
+ this.#modulePathsWithNoPackage = new Set();
47
50
  }
48
51
 
49
- getPackage(filePath: string): Package {
50
- if (!this._packageCache[filePath]) {
51
- this._packageCache[filePath] = new Package({
52
- file: filePath,
53
- });
52
+ getPackage(filePath: string): Readonly<{
53
+ rootPath: string,
54
+ packageJson: PackageJson,
55
+ }> {
56
+ let cached = this.#packageCache.get(filePath);
57
+ if (cached == null) {
58
+ cached = {
59
+ rootPath: dirname(filePath),
60
+ packageJson: JSON.parse(readFileSync(filePath, 'utf8')),
61
+ };
62
+ this.#packageCache.set(filePath, cached);
54
63
  }
55
- return this._packageCache[filePath];
64
+ return cached;
56
65
  }
57
66
 
58
- getPackageOf(
59
- absoluteModulePath: string,
60
- ): ?{pkg: Package, packageRelativePath: string} {
61
- let packagePathAndSubpath =
62
- this._packagePathAndSubpathByModulePath[absoluteModulePath];
63
- if (
64
- packagePathAndSubpath &&
65
- this._packageCache[packagePathAndSubpath.packageJsonPath]
66
- ) {
67
- return {
68
- pkg: this._packageCache[packagePathAndSubpath.packageJsonPath],
69
- packageRelativePath: packagePathAndSubpath.packageRelativePath,
70
- };
67
+ getPackageForModule(absoluteModulePath: string): ?PackageForModule {
68
+ const cached = this.#resultByModulePath.get(absoluteModulePath);
69
+
70
+ // Distinguish between `null` (positively no closest package) and
71
+ // `undefined` (no cached result yet)
72
+ // eslint-disable-next-line lint/strictly-null
73
+ if (cached !== undefined) {
74
+ return cached;
71
75
  }
72
76
 
73
- packagePathAndSubpath = this._getClosestPackage(absoluteModulePath);
74
- if (!packagePathAndSubpath) {
77
+ const closest = this.#getClosestPackage(absoluteModulePath);
78
+ if (closest == null) {
79
+ this.#resultByModulePath.set(absoluteModulePath, null);
80
+ this.#modulePathsWithNoPackage.add(absoluteModulePath);
75
81
  return null;
76
82
  }
77
83
 
78
- const packagePath = packagePathAndSubpath.packageJsonPath;
84
+ const packagePath = closest.packageJsonPath;
79
85
 
80
- this._packagePathAndSubpathByModulePath[absoluteModulePath] =
81
- packagePathAndSubpath;
82
- const modulePaths =
83
- this._modulePathsByPackagePath[packagePath] ?? new Set();
86
+ // Track module→package for invalidation
87
+ let modulePaths = this.#modulePathsByPackagePath.get(packagePath);
88
+ if (modulePaths == null) {
89
+ modulePaths = new Set();
90
+ this.#modulePathsByPackagePath.set(packagePath, modulePaths);
91
+ }
84
92
  modulePaths.add(absoluteModulePath);
85
- this._modulePathsByPackagePath[packagePath] = modulePaths;
86
93
 
87
- return {
88
- pkg: this.getPackage(packagePath),
89
- packageRelativePath: packagePathAndSubpath.packageRelativePath,
94
+ const pkg = this.getPackage(packagePath);
95
+ if (pkg == null) {
96
+ return null;
97
+ }
98
+
99
+ // Cache the pre-built result object — no allocation on future hits
100
+ const result: PackageForModule = {
101
+ packageJson: pkg.packageJson,
102
+ packageRelativePath: closest.packageRelativePath,
103
+ rootPath: pkg.rootPath,
90
104
  };
105
+ this.#resultByModulePath.set(absoluteModulePath, result);
106
+ return result;
91
107
  }
92
108
 
93
109
  invalidate(filePath: string) {
94
- if (this._packageCache[filePath]) {
95
- this._packageCache[filePath].invalidate();
96
- delete this._packageCache[filePath];
97
- }
98
- const packagePathAndSubpath =
99
- this._packagePathAndSubpathByModulePath[filePath];
100
- if (packagePathAndSubpath) {
101
- // filePath is a module inside a package.
102
- const packagePath = packagePathAndSubpath.packageJsonPath;
103
- delete this._packagePathAndSubpathByModulePath[filePath];
104
- // This change doesn't invalidate any cached "closest package.json"
105
- // queries for the package's other modules. Clean up only this module.
106
- const modulePaths = this._modulePathsByPackagePath[packagePath];
107
- if (modulePaths) {
108
- modulePaths.delete(filePath);
109
- if (modulePaths.size === 0) {
110
- delete this._modulePathsByPackagePath[packagePath];
110
+ this.#packageCache.delete(filePath);
111
+
112
+ // Clean up any cached result for this module path (including null).
113
+ // Derive the package.json path from the cached result to clean up the
114
+ // reverse index.
115
+ const cachedResult = this.#resultByModulePath.get(filePath);
116
+ this.#resultByModulePath.delete(filePath);
117
+ this.#modulePathsWithNoPackage.delete(filePath);
118
+
119
+ if (cachedResult != null) {
120
+ const packagePath = cachedResult.rootPath + sep + 'package.json';
121
+ const modules = this.#modulePathsByPackagePath.get(packagePath);
122
+ if (modules != null) {
123
+ modules.delete(filePath);
124
+ if (modules.size === 0) {
125
+ this.#modulePathsByPackagePath.delete(packagePath);
111
126
  }
112
127
  }
113
128
  }
114
- if (this._modulePathsByPackagePath[filePath]) {
115
- // filePath is a package. This change invalidates all cached "closest
116
- // package.json" queries for modules inside this package.
117
- const modulePaths = this._modulePathsByPackagePath[filePath];
129
+
130
+ // If filePath is a package.json, invalidate all module lookups pointing to it
131
+ const modulePaths = this.#modulePathsByPackagePath.get(filePath);
132
+ if (modulePaths != null) {
118
133
  for (const modulePath of modulePaths) {
119
- delete this._packagePathAndSubpathByModulePath[modulePath];
134
+ this.#resultByModulePath.delete(modulePath);
135
+ }
136
+ this.#modulePathsByPackagePath.delete(filePath);
137
+ }
138
+
139
+ // If a package.json was created, modified, or deleted, invalidate all
140
+ // null-cached module results, since modules that previously had no
141
+ // enclosing package.json may now resolve to this one.
142
+ if (filePath.endsWith(sep + 'package.json')) {
143
+ for (const modulePath of this.#modulePathsWithNoPackage) {
144
+ this.#resultByModulePath.delete(modulePath);
120
145
  }
121
- modulePaths.clear();
122
- delete this._modulePathsByPackagePath[filePath];
146
+ this.#modulePathsWithNoPackage.clear();
123
147
  }
124
148
  }
125
149
  }
@@ -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<<31b3384bffa191e4c3c9916d93df8571>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/node-haste/lib/AssetPaths.js
13
+ * To regenerate, run:
14
+ * js1 build metro-ts-defs (internal) OR
15
+ * yarn run build-ts-defs (OSS)
9
16
  */
10
17
 
11
18
  export type AssetPath = {
@@ -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<<61c16b5ef31517dc44347558a4dd431a>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/node-haste/lib/parsePlatformFilePath.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
  type PlatformFilePathParts = {
@@ -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<<02d7f6eec9c93d02612c9b2fdef18cef>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/shared/output/RamBundle/as-assets.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 {RamBundleInfo} from '../../../DeltaBundler/Serializers/getRamBundleInfo';
@@ -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<<cf05d2127a356bae7e3789c2fefa25d3>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/shared/output/RamBundle/as-indexed-file.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 {RamBundleInfo} from '../../../DeltaBundler/Serializers/getRamBundleInfo';
@@ -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<<669a46ab2a802ea2b93d98edf337fff0>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/shared/output/RamBundle/buildSourcemapWithMetadata.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 {ModuleGroups, ModuleTransportLike} from '../../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<<94cd41a2f04528e81f82e6c2feadaf52>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/shared/output/RamBundle/magic-number.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 const $$EXPORT_DEFAULT_DECLARATION$$: 0xfb0bd1e5;
@@ -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<<cb3371e2f23da9cd30e08ed76ec4f7db>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/shared/output/RamBundle/util.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 {ModuleGroups, ModuleTransportLike} from '../../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<<000f29900c01342de92d247507075575>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/shared/output/RamBundle/write-sourcemap.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 writeSourcemap(
@@ -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<<bef82861a3de459220bf62515fd5900c>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/shared/output/RamBundle.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 {RamBundleInfo} from '../../DeltaBundler/Serializers/getRamBundleInfo';
@@ -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<<d9877b2ba27e8e3f279901c80c7ad895>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/shared/output/bundle.flow.js
13
+ * To regenerate, run:
14
+ * js1 build metro-ts-defs (internal) OR
15
+ * yarn run build-ts-defs (OSS)
9
16
  */
10
17
 
11
18
  import type {AssetData} from '../../Assets';
@@ -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<<17ae3fc242dc6b3915a72d04dad032b8>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/shared/output/meta.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 meta(
@@ -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<<12b27507f799c8170067738c227bb2f3>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/shared/output/unbundle.js
13
+ * To regenerate, run:
14
+ * js1 build metro-ts-defs (internal) OR
15
+ * yarn run build-ts-defs (OSS)
9
16
  */
10
17
 
11
18
  export * from './RamBundle';
@@ -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<<37de849e415f8aa1e94b73289a573ee3>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/shared/output/writeFile.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 writeFile(
@@ -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<<31593693c0cafcd55eaf4885efddc6be>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/shared/types.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 {
@@ -1,21 +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
- * @format
8
- * @oncall react_native
9
- */
10
-
11
- import type {PackageJson} from 'metro-resolver/private/types';
12
-
13
- declare class Package {
14
- path: string;
15
- _root: string;
16
- _content: null | undefined | PackageJson;
17
- constructor($$PARAM_0$$: {file: string});
18
- invalidate(): void;
19
- read(): PackageJson;
20
- }
21
- export default Package;
@@ -1,28 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true,
5
- });
6
- exports.default = void 0;
7
- var _fs = _interopRequireDefault(require("fs"));
8
- var _path = _interopRequireDefault(require("path"));
9
- function _interopRequireDefault(e) {
10
- return e && e.__esModule ? e : { default: e };
11
- }
12
- class Package {
13
- constructor({ file }) {
14
- this.path = _path.default.resolve(file);
15
- this._root = _path.default.dirname(this.path);
16
- this._content = null;
17
- }
18
- invalidate() {
19
- this._content = null;
20
- }
21
- read() {
22
- if (this._content == null) {
23
- this._content = JSON.parse(_fs.default.readFileSync(this.path, "utf8"));
24
- }
25
- return this._content;
26
- }
27
- }
28
- exports.default = Package;
@@ -1,39 +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
- * @oncall react_native
10
- */
11
-
12
- import type {PackageJson} from 'metro-resolver/private/types';
13
-
14
- import fs from 'fs';
15
- import path from 'path';
16
-
17
- export default class Package {
18
- path: string;
19
-
20
- _root: string;
21
- _content: ?PackageJson;
22
-
23
- constructor({file}: {file: string, ...}) {
24
- this.path = path.resolve(file);
25
- this._root = path.dirname(this.path);
26
- this._content = null;
27
- }
28
-
29
- invalidate() {
30
- this._content = null;
31
- }
32
-
33
- read(): PackageJson {
34
- if (this._content == null) {
35
- this._content = JSON.parse(fs.readFileSync(this.path, 'utf8'));
36
- }
37
- return this._content;
38
- }
39
- }