metro 0.83.3 → 0.83.5

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 (229) hide show
  1. package/package.json +28 -24
  2. package/src/Assets.d.ts +83 -0
  3. package/src/Assets.js +42 -29
  4. package/src/Assets.js.flow +26 -15
  5. package/src/Bundler/util.d.ts +27 -0
  6. package/src/Bundler/util.js +25 -21
  7. package/src/Bundler/util.js.flow +2 -2
  8. package/src/Bundler.d.ts +14 -15
  9. package/src/Bundler.js.flow +1 -1
  10. package/src/DeltaBundler/DeltaCalculator.d.ts +71 -0
  11. package/src/DeltaBundler/DeltaCalculator.js +4 -4
  12. package/src/DeltaBundler/DeltaCalculator.js.flow +8 -8
  13. package/src/DeltaBundler/Graph.d.ts +135 -8
  14. package/src/DeltaBundler/Graph.js +16 -16
  15. package/src/DeltaBundler/Graph.js.flow +30 -30
  16. package/src/DeltaBundler/Serializers/baseJSBundle.d.ts +20 -0
  17. package/src/DeltaBundler/Serializers/baseJSBundle.js.flow +1 -1
  18. package/src/DeltaBundler/Serializers/getAllFiles.d.ts +22 -0
  19. package/src/DeltaBundler/Serializers/getAllFiles.js.flow +2 -2
  20. package/src/DeltaBundler/Serializers/getAssets.d.ts +25 -0
  21. package/src/DeltaBundler/Serializers/getAssets.js.flow +2 -2
  22. package/src/DeltaBundler/Serializers/getExplodedSourceMap.js.flow +2 -2
  23. package/src/DeltaBundler/Serializers/getRamBundleInfo.d.ts +36 -6
  24. package/src/DeltaBundler/Serializers/getRamBundleInfo.js.flow +8 -8
  25. package/src/DeltaBundler/Serializers/helpers/getInlineSourceMappingURL.d.ts +12 -0
  26. package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.d.ts +33 -0
  27. package/src/DeltaBundler/Serializers/helpers/getTransitiveDependencies.d.ts +17 -0
  28. package/src/DeltaBundler/Serializers/helpers/js.d.ts +30 -0
  29. package/src/DeltaBundler/Serializers/helpers/js.js +25 -21
  30. package/src/DeltaBundler/Serializers/helpers/js.js.flow +6 -6
  31. package/src/DeltaBundler/Serializers/helpers/processModules.d.ts +25 -0
  32. package/src/DeltaBundler/Serializers/helpers/processModules.js.flow +3 -3
  33. package/src/DeltaBundler/Serializers/hmrJSBundle.d.ts +30 -0
  34. package/src/DeltaBundler/Serializers/hmrJSBundle.js +25 -21
  35. package/src/DeltaBundler/Serializers/hmrJSBundle.js.flow +5 -5
  36. package/src/DeltaBundler/Serializers/sourceMapGenerator.d.ts +29 -0
  37. package/src/DeltaBundler/Serializers/sourceMapGenerator.js.flow +6 -6
  38. package/src/DeltaBundler/Serializers/sourceMapObject.d.ts +23 -0
  39. package/src/DeltaBundler/Serializers/sourceMapObject.js.flow +2 -2
  40. package/src/DeltaBundler/Serializers/sourceMapString.d.ts +22 -0
  41. package/src/DeltaBundler/Serializers/sourceMapString.js.flow +2 -2
  42. package/src/DeltaBundler/Transformer.d.ts +38 -0
  43. package/src/DeltaBundler/Transformer.js.flow +3 -3
  44. package/src/DeltaBundler/Worker.d.ts +19 -27
  45. package/src/DeltaBundler/Worker.flow.js.flow +1 -1
  46. package/src/DeltaBundler/WorkerFarm.d.ts +70 -0
  47. package/src/DeltaBundler/WorkerFarm.js +1 -1
  48. package/src/DeltaBundler/WorkerFarm.js.flow +26 -13
  49. package/src/DeltaBundler/buildSubgraph.d.ts +30 -0
  50. package/src/DeltaBundler/buildSubgraph.js +4 -4
  51. package/src/DeltaBundler/buildSubgraph.js.flow +8 -8
  52. package/src/DeltaBundler/getTransformCacheKey.d.ts +18 -0
  53. package/src/DeltaBundler/mergeDeltas.d.ts +17 -0
  54. package/src/DeltaBundler/types.d.ts +97 -100
  55. package/src/DeltaBundler/types.js.flow +36 -34
  56. package/src/DeltaBundler.d.ts +14 -12
  57. package/src/DeltaBundler.js.flow +2 -2
  58. package/src/HmrServer.d.ts +79 -0
  59. package/src/HmrServer.js +34 -29
  60. package/src/HmrServer.js.flow +17 -12
  61. package/src/IncrementalBundler/GraphNotFoundError.d.ts +17 -0
  62. package/src/IncrementalBundler/ResourceNotFoundError.d.ts +15 -0
  63. package/src/IncrementalBundler/RevisionNotFoundError.d.ts +17 -0
  64. package/src/IncrementalBundler.d.ts +43 -45
  65. package/src/IncrementalBundler.js +29 -21
  66. package/src/IncrementalBundler.js.flow +13 -9
  67. package/src/ModuleGraph/worker/JsFileWrapping.d.ts +29 -0
  68. package/src/ModuleGraph/worker/JsFileWrapping.js +25 -21
  69. package/src/ModuleGraph/worker/JsFileWrapping.js.flow +10 -5
  70. package/src/ModuleGraph/worker/collectDependencies.d.ts +118 -14
  71. package/src/ModuleGraph/worker/collectDependencies.js +25 -21
  72. package/src/ModuleGraph/worker/collectDependencies.js.flow +27 -21
  73. package/src/ModuleGraph/worker/generateImportNames.d.ts +19 -0
  74. package/src/ModuleGraph/worker/generateImportNames.js.flow +4 -2
  75. package/src/ModuleGraph/worker/importLocationsPlugin.d.ts +26 -0
  76. package/src/ModuleGraph/worker/importLocationsPlugin.js.flow +7 -3
  77. package/src/Server/MultipartResponse.d.ts +5 -6
  78. package/src/Server/MultipartResponse.js.flow +1 -1
  79. package/src/Server/symbolicate.js.flow +4 -4
  80. package/src/Server.d.ts +220 -67
  81. package/src/Server.js +149 -45
  82. package/src/Server.js.flow +167 -57
  83. package/src/cli/parseKeyValueParamArray.d.ts +14 -0
  84. package/src/cli/parseKeyValueParamArray.js.flow +1 -1
  85. package/src/cli-utils.d.ts +19 -0
  86. package/src/cli-utils.js.flow +2 -2
  87. package/src/commands/build.d.ts +16 -0
  88. package/src/commands/build.js.flow +11 -10
  89. package/src/commands/dependencies.d.ts +16 -0
  90. package/src/commands/dependencies.js.flow +8 -4
  91. package/src/commands/serve.d.ts +16 -0
  92. package/src/commands/serve.js +2 -0
  93. package/src/commands/serve.js.flow +14 -9
  94. package/src/index.d.ts +97 -110
  95. package/src/index.flow.js +53 -35
  96. package/src/index.flow.js.flow +49 -29
  97. package/src/integration_tests/basic_bundle/AssetRegistry.js.flow +1 -1
  98. package/src/integration_tests/basic_bundle/ErrorBundle.js.flow +1 -1
  99. package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-import.js.flow +1 -1
  100. package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-multi-line-import-with-escapes.js.flow +1 -1
  101. package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-multi-line-import.js.flow +1 -1
  102. package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-require-with-embedded-comment.js.flow +1 -1
  103. package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-require.js.flow +1 -1
  104. package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-specifier-with-escapes.js.flow +1 -1
  105. package/src/integration_tests/basic_bundle/build-errors/inline-requires-cannot-resolve-import.js.flow +1 -1
  106. package/src/integration_tests/basic_bundle/build-errors/inline-requires-cannot-resolve-require.js.flow +1 -1
  107. package/src/integration_tests/basic_bundle/import-export/index.js +25 -21
  108. package/src/integration_tests/basic_bundle/import-export/index.js.flow +3 -3
  109. package/src/integration_tests/basic_bundle/import-export/utils.js.flow +2 -2
  110. package/src/integration_tests/basic_bundle/loadBundleAsyncForTest.js.flow +1 -1
  111. package/src/integration_tests/basic_bundle/optional-dependencies/index.js.flow +1 -1
  112. package/src/integration_tests/basic_bundle/require-context/conflict.js.flow +1 -1
  113. package/src/integration_tests/basic_bundle/require-context/empty.js.flow +1 -1
  114. package/src/integration_tests/basic_bundle/require-context/matching.js.flow +1 -1
  115. package/src/integration_tests/basic_bundle/require-context/mode-eager.js.flow +1 -1
  116. package/src/integration_tests/basic_bundle/require-context/mode-lazy-once.js.flow +1 -1
  117. package/src/integration_tests/basic_bundle/require-context/mode-lazy.js.flow +1 -1
  118. package/src/integration_tests/basic_bundle/require-context/mode-sync.js.flow +2 -2
  119. package/src/integration_tests/basic_bundle/require-context/utils.js.flow +1 -1
  120. package/src/integration_tests/basic_bundle/require-resolveWeak/import-and-resolveWeak.js.flow +1 -1
  121. package/src/integration_tests/basic_bundle/require-resolveWeak/multiple.js.flow +1 -1
  122. package/src/integration_tests/basic_bundle/require-resolveWeak/never-required.js.flow +1 -1
  123. package/src/integration_tests/basic_bundle/require-resolveWeak/require-and-resolveWeak.js.flow +1 -1
  124. package/src/integration_tests/execBundle.js.flow +1 -1
  125. package/src/lib/BatchProcessor.d.ts +54 -0
  126. package/src/lib/BatchProcessor.js +5 -2
  127. package/src/lib/BatchProcessor.js.flow +10 -7
  128. package/src/lib/CountingSet.d.ts +10 -10
  129. package/src/lib/CountingSet.js.flow +4 -4
  130. package/src/lib/JsonReporter.d.ts +37 -0
  131. package/src/lib/JsonReporter.js +5 -3
  132. package/src/lib/JsonReporter.js.flow +19 -17
  133. package/src/lib/RamBundleParser.d.ts +29 -0
  134. package/src/lib/RamBundleParser.js.flow +1 -1
  135. package/src/lib/TerminalReporter.d.ts +97 -6
  136. package/src/lib/TerminalReporter.js +37 -34
  137. package/src/lib/TerminalReporter.js.flow +21 -30
  138. package/src/lib/bundleProgressUtils.d.ts +26 -0
  139. package/src/lib/bundleProgressUtils.js +19 -0
  140. package/src/lib/bundleProgressUtils.js.flow +35 -0
  141. package/src/lib/bundleToString.d.ts +19 -0
  142. package/src/lib/contextModule.d.ts +20 -9
  143. package/src/lib/contextModule.js.flow +1 -1
  144. package/src/lib/contextModuleTemplates.d.ts +25 -0
  145. package/src/lib/contextModuleTemplates.js +25 -21
  146. package/src/lib/countLines.d.ts +12 -0
  147. package/src/lib/countLines.js +4 -3
  148. package/src/lib/countLines.js.flow +3 -4
  149. package/src/lib/createWebsocketServer.d.ts +43 -0
  150. package/src/lib/createWebsocketServer.js +9 -2
  151. package/src/lib/createWebsocketServer.js.flow +16 -9
  152. package/src/lib/debounceAsyncQueue.d.ts +15 -0
  153. package/src/lib/debounceAsyncQueue.js.flow +1 -1
  154. package/src/lib/formatBundlingError.d.ts +23 -0
  155. package/src/lib/formatBundlingError.js.flow +1 -1
  156. package/src/lib/getAppendScripts.d.ts +31 -0
  157. package/src/lib/getAppendScripts.js.flow +4 -4
  158. package/src/lib/getGraphId.d.ts +15 -1
  159. package/src/lib/getGraphId.js.flow +1 -1
  160. package/src/lib/getPreludeCode.d.ts +18 -0
  161. package/src/lib/getPreludeCode.js +4 -0
  162. package/src/lib/getPreludeCode.js.flow +10 -3
  163. package/src/lib/getPrependedScripts.d.ts +24 -0
  164. package/src/lib/getPrependedScripts.js +36 -22
  165. package/src/lib/getPrependedScripts.js.flow +10 -3
  166. package/src/lib/isResolvedDependency.d.ts +15 -0
  167. package/src/lib/logToConsole.d.ts +19 -0
  168. package/src/lib/logToConsole.js.flow +2 -2
  169. package/src/lib/parseBundleOptionsFromBundleRequestUrl.d.ts +17 -0
  170. package/src/lib/parseBundleOptionsFromBundleRequestUrl.js +25 -21
  171. package/src/lib/parseCustomResolverOptions.d.ts +16 -0
  172. package/src/lib/parseCustomResolverOptions.js.flow +2 -2
  173. package/src/lib/parseCustomTransformOptions.d.ts +16 -0
  174. package/src/lib/parseCustomTransformOptions.js.flow +1 -1
  175. package/src/lib/parseJsonBody.d.ts +27 -0
  176. package/src/lib/parseJsonBody.js.flow +11 -1
  177. package/src/lib/pathUtils.d.ts +14 -0
  178. package/src/lib/pathUtils.js +25 -21
  179. package/src/lib/pathUtils.js.flow +1 -1
  180. package/src/lib/relativizeSourceMap.d.ts +17 -0
  181. package/src/lib/reporting.d.ts +65 -81
  182. package/src/lib/reporting.js.flow +4 -4
  183. package/src/lib/splitBundleOptions.d.ts +16 -0
  184. package/src/lib/transformHelpers.d.ts +35 -0
  185. package/src/lib/transformHelpers.js +11 -9
  186. package/src/lib/transformHelpers.js.flow +17 -15
  187. package/src/node-haste/DependencyGraph/ModuleResolution.d.ts +126 -0
  188. package/src/node-haste/DependencyGraph/ModuleResolution.js +48 -42
  189. package/src/node-haste/DependencyGraph/ModuleResolution.js.flow +35 -32
  190. package/src/node-haste/DependencyGraph/createFileMap.d.ts +29 -0
  191. package/src/node-haste/DependencyGraph/createFileMap.js +56 -38
  192. package/src/node-haste/DependencyGraph/createFileMap.js.flow +44 -18
  193. package/src/node-haste/DependencyGraph.d.ts +57 -33
  194. package/src/node-haste/DependencyGraph.js +40 -31
  195. package/src/node-haste/DependencyGraph.js.flow +35 -37
  196. package/src/node-haste/Package.d.ts +21 -0
  197. package/src/node-haste/PackageCache.d.ts +34 -0
  198. package/src/node-haste/lib/AssetPaths.d.ts +29 -0
  199. package/src/node-haste/lib/AssetPaths.js +2 -2
  200. package/src/node-haste/lib/AssetPaths.js.flow +4 -4
  201. package/src/node-haste/lib/parsePlatformFilePath.d.ts +25 -0
  202. package/src/node-haste/lib/parsePlatformFilePath.js +6 -6
  203. package/src/node-haste/lib/parsePlatformFilePath.js.flow +4 -4
  204. package/src/shared/output/RamBundle/as-assets.d.ts +25 -0
  205. package/src/shared/output/RamBundle/as-assets.js.flow +6 -6
  206. package/src/shared/output/RamBundle/as-indexed-file.d.ts +38 -0
  207. package/src/shared/output/RamBundle/as-indexed-file.js.flow +5 -5
  208. package/src/shared/output/RamBundle/buildSourcemapWithMetadata.d.ts +23 -0
  209. package/src/shared/output/RamBundle/buildSourcemapWithMetadata.js.flow +5 -5
  210. package/src/shared/output/RamBundle/magic-number.d.ts +14 -0
  211. package/src/shared/output/RamBundle/util.d.ts +41 -0
  212. package/src/shared/output/RamBundle/util.js.flow +5 -5
  213. package/src/shared/output/RamBundle/write-sourcemap.d.ts +16 -0
  214. package/src/shared/output/RamBundle/write-sourcemap.js.flow +1 -1
  215. package/src/shared/output/RamBundle.d.ts +26 -0
  216. package/src/shared/output/RamBundle.js.flow +1 -1
  217. package/src/shared/output/bundle.d.ts +9 -17
  218. package/src/shared/output/bundle.flow.js.flow +3 -3
  219. package/src/shared/output/meta.d.ts +15 -0
  220. package/src/shared/output/meta.js +2 -2
  221. package/src/shared/output/meta.js.flow +1 -1
  222. package/src/shared/output/unbundle.d.ts +11 -0
  223. package/src/shared/output/writeFile.d.ts +16 -0
  224. package/src/shared/output/writeFile.js +8 -3
  225. package/src/shared/output/writeFile.js.flow +8 -2
  226. package/src/shared/types.d.ts +81 -66
  227. package/src/shared/types.js.flow +20 -5
  228. package/src/Asset.d.ts +0 -25
  229. package/src/ModuleGraph/test-helpers.js +0 -75
@@ -0,0 +1,38 @@
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 {RamBundleInfo} from '../../../DeltaBundler/Serializers/getRamBundleInfo';
12
+ import type {
13
+ ModuleGroups,
14
+ ModuleTransportLike,
15
+ OutputOptions,
16
+ } from '../../types';
17
+ /**
18
+ * Saves all JS modules of an app as a single file, separated with null bytes.
19
+ * The file begins with an offset table that contains module ids and their
20
+ * lengths/offsets.
21
+ * The module id for the startup code (prelude, polyfills etc.) is the
22
+ * empty string.
23
+ */
24
+ export declare function save(
25
+ bundle: RamBundleInfo,
26
+ options: OutputOptions,
27
+ log: (...args: Array<string>) => void,
28
+ ): Promise<unknown>;
29
+ export declare function buildTableAndContents(
30
+ startupCode: string,
31
+ modules: ReadonlyArray<ModuleTransportLike>,
32
+ moduleGroups: ModuleGroups,
33
+ encoding?: 'utf8' | 'utf16le' | 'ascii',
34
+ ): Array<Buffer>;
35
+ export declare function createModuleGroups(
36
+ groups: Map<number, Set<number>>,
37
+ modules: ReadonlyArray<ModuleTransportLike>,
38
+ ): ModuleGroups;
@@ -37,7 +37,7 @@ export function save(
37
37
  bundle: RamBundleInfo,
38
38
  options: OutputOptions,
39
39
  log: (...args: Array<string>) => void,
40
- ): Promise<mixed> {
40
+ ): Promise<unknown> {
41
41
  const {
42
42
  bundleOutput,
43
43
  bundleEncoding: encoding,
@@ -96,7 +96,7 @@ function writeBuffers(
96
96
  buffers: Array<Buffer>,
97
97
  ): Promise<void> {
98
98
  buffers.forEach((buffer: Buffer) => stream.write(buffer));
99
- return new Promise((resolve: () => void, reject: mixed => mixed) => {
99
+ return new Promise((resolve: () => void, reject: unknown => unknown) => {
100
100
  stream.on('error', reject);
101
101
  stream.on('finish', () => resolve());
102
102
  stream.end();
@@ -196,7 +196,7 @@ function groupCode(
196
196
  }
197
197
 
198
198
  function buildModuleBuffers(
199
- modules: $ReadOnlyArray<ModuleTransportLike>,
199
+ modules: ReadonlyArray<ModuleTransportLike>,
200
200
  moduleGroups: ModuleGroups,
201
201
  encoding: void | 'ascii' | 'utf16le' | 'utf8',
202
202
  ): Array<{
@@ -217,7 +217,7 @@ function buildModuleBuffers(
217
217
 
218
218
  export function buildTableAndContents(
219
219
  startupCode: string,
220
- modules: $ReadOnlyArray<ModuleTransportLike>,
220
+ modules: ReadonlyArray<ModuleTransportLike>,
221
221
  moduleGroups: ModuleGroups,
222
222
  encoding?: 'utf8' | 'utf16le' | 'ascii',
223
223
  ): Array<Buffer> {
@@ -242,7 +242,7 @@ export function buildTableAndContents(
242
242
 
243
243
  export function createModuleGroups(
244
244
  groups: Map<number, Set<number>>,
245
- modules: $ReadOnlyArray<ModuleTransportLike>,
245
+ modules: ReadonlyArray<ModuleTransportLike>,
246
246
  ): ModuleGroups {
247
247
  return {
248
248
  groups,
@@ -0,0 +1,23 @@
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 {ModuleGroups, ModuleTransportLike} from '../../types';
12
+ import type {IndexMap} from 'metro-source-map';
13
+
14
+ type Params = {
15
+ fixWrapperOffset: boolean;
16
+ lazyModules: ReadonlyArray<ModuleTransportLike>;
17
+ moduleGroups: null | undefined | ModuleGroups;
18
+ startupModules: ReadonlyArray<ModuleTransportLike>;
19
+ };
20
+ declare const $$EXPORT_DEFAULT_DECLARATION$$: ($$PARAM_0$$: Params) => IndexMap;
21
+ declare type $$EXPORT_DEFAULT_DECLARATION$$ =
22
+ typeof $$EXPORT_DEFAULT_DECLARATION$$;
23
+ export default $$EXPORT_DEFAULT_DECLARATION$$;
@@ -20,17 +20,17 @@ import {
20
20
 
21
21
  type Params = {
22
22
  fixWrapperOffset: boolean,
23
- lazyModules: $ReadOnlyArray<ModuleTransportLike>,
23
+ lazyModules: ReadonlyArray<ModuleTransportLike>,
24
24
  moduleGroups: ?ModuleGroups,
25
- startupModules: $ReadOnlyArray<ModuleTransportLike>,
25
+ startupModules: ReadonlyArray<ModuleTransportLike>,
26
26
  };
27
27
 
28
- export default (({
28
+ export default ({
29
29
  fixWrapperOffset,
30
30
  lazyModules,
31
31
  moduleGroups,
32
32
  startupModules,
33
- }: Params) => {
33
+ }: Params): IndexMap => {
34
34
  const options = fixWrapperOffset ? {fixWrapperOffset: true} : undefined;
35
35
  const startupModule: ModuleTransportLike = {
36
36
  code: joinModules(startupModules),
@@ -59,4 +59,4 @@ export default (({
59
59
  }
60
60
 
61
61
  return map;
62
- }: Params => IndexMap);
62
+ };
@@ -0,0 +1,14 @@
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
+ declare const $$EXPORT_DEFAULT_DECLARATION$$: 0xfb0bd1e5;
12
+ declare type $$EXPORT_DEFAULT_DECLARATION$$ =
13
+ typeof $$EXPORT_DEFAULT_DECLARATION$$;
14
+ export default $$EXPORT_DEFAULT_DECLARATION$$;
@@ -0,0 +1,41 @@
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 {ModuleGroups, ModuleTransportLike} from '../../types';
12
+ import type {BasicSourceMap, IndexMap} from 'metro-source-map';
13
+
14
+ import countLines from '../../../lib/countLines';
15
+
16
+ declare function lineToLineSourceMap(
17
+ source: string,
18
+ filename?: string,
19
+ ): BasicSourceMap;
20
+ type CombineOptions = {fixWrapperOffset: boolean};
21
+ declare function combineSourceMaps(
22
+ modules: ReadonlyArray<ModuleTransportLike>,
23
+ moduleGroups?: ModuleGroups,
24
+ options?: null | undefined | CombineOptions,
25
+ ): IndexMap;
26
+ declare function combineSourceMapsAddingOffsets(
27
+ modules: ReadonlyArray<ModuleTransportLike>,
28
+ x_metro_module_paths: Array<string>,
29
+ moduleGroups?: null | undefined | ModuleGroups,
30
+ options?: null | undefined | CombineOptions,
31
+ ): IndexMap;
32
+ declare const joinModules: (
33
+ modules: ReadonlyArray<{readonly code: string}>,
34
+ ) => string;
35
+ export {
36
+ combineSourceMaps,
37
+ combineSourceMapsAddingOffsets,
38
+ countLines,
39
+ joinModules,
40
+ lineToLineSourceMap,
41
+ };
@@ -50,7 +50,7 @@ const Section = (line: number, column: number, map: MixedSourceMap) => ({
50
50
  type CombineOptions = {fixWrapperOffset: boolean, ...};
51
51
 
52
52
  function combineSourceMaps(
53
- modules: $ReadOnlyArray<ModuleTransportLike>,
53
+ modules: ReadonlyArray<ModuleTransportLike>,
54
54
  moduleGroups?: ModuleGroups,
55
55
  options?: ?CombineOptions,
56
56
  ): IndexMap {
@@ -59,7 +59,7 @@ function combineSourceMaps(
59
59
  }
60
60
 
61
61
  function combineSourceMapsAddingOffsets(
62
- modules: $ReadOnlyArray<ModuleTransportLike>,
62
+ modules: ReadonlyArray<ModuleTransportLike>,
63
63
  x_metro_module_paths: Array<string>,
64
64
  moduleGroups?: ?ModuleGroups,
65
65
  options?: ?CombineOptions,
@@ -75,7 +75,7 @@ function combineSourceMapsAddingOffsets(
75
75
  }
76
76
 
77
77
  function combineMaps(
78
- modules: $ReadOnlyArray<ModuleTransportLike>,
78
+ modules: ReadonlyArray<ModuleTransportLike>,
79
79
  offsets: ?Array<number>,
80
80
  moduleGroups: ?ModuleGroups,
81
81
  options: ?CombineOptions,
@@ -99,7 +99,7 @@ function combineMaps(
99
99
  group = moduleGroups && moduleGroups.groups.get(id);
100
100
  if (group && moduleGroups) {
101
101
  const {modulesById} = moduleGroups;
102
- const otherModules: $ReadOnlyArray<ModuleTransportLike> = Array.from(
102
+ const otherModules: ReadonlyArray<ModuleTransportLike> = Array.from(
103
103
  group || [],
104
104
  )
105
105
  .map((moduleId: number) => modulesById.get(moduleId))
@@ -135,7 +135,7 @@ function combineMaps(
135
135
  return sections;
136
136
  }
137
137
 
138
- const joinModules = (modules: $ReadOnlyArray<{+code: string, ...}>): string =>
138
+ const joinModules = (modules: ReadonlyArray<{+code: string, ...}>): string =>
139
139
  modules.map((m: {+code: string, ...}) => m.code).join('\n');
140
140
 
141
141
  export {
@@ -0,0 +1,16 @@
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
+ declare function writeSourcemap(
12
+ fileName: string,
13
+ contents: string,
14
+ log: (...args: Array<string>) => void,
15
+ ): Promise<unknown>;
16
+ export default writeSourcemap;
@@ -15,7 +15,7 @@ export default function writeSourcemap(
15
15
  fileName: string,
16
16
  contents: string,
17
17
  log: (...args: Array<string>) => void,
18
- ): Promise<mixed> {
18
+ ): Promise<unknown> {
19
19
  if (!fileName) {
20
20
  return Promise.resolve();
21
21
  }
@@ -0,0 +1,26 @@
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 {RamBundleInfo} from '../../DeltaBundler/Serializers/getRamBundleInfo';
12
+ import type {OutputOptions, RequestOptions} from '../types';
13
+
14
+ import Server from '../../Server';
15
+
16
+ export declare function build(
17
+ packagerClient: Server,
18
+ requestOptions: RequestOptions,
19
+ ): Promise<RamBundleInfo>;
20
+ export declare function save(
21
+ bundle: RamBundleInfo,
22
+ options: OutputOptions,
23
+ log: (x: string) => void,
24
+ ): Promise<unknown>;
25
+ export declare const formatName: 'bundle';
26
+ export declare type formatName = typeof formatName;
@@ -33,7 +33,7 @@ export function save(
33
33
  bundle: RamBundleInfo,
34
34
  options: OutputOptions,
35
35
  log: (x: string) => void,
36
- ): Promise<mixed> {
36
+ ): Promise<unknown> {
37
37
  // We fork here depending on the platform: while Android is pretty good at
38
38
  // loading individual assets, iOS has a large overhead when reading hundreds
39
39
  // of assets from disk.
@@ -8,28 +8,20 @@
8
8
  * @oncall react_native
9
9
  */
10
10
 
11
- import type {AssetData} from '../../Asset';
11
+ import type {AssetData} from '../../Assets';
12
+ import type {BuildOptions, OutputOptions, RequestOptions} from '../types';
12
13
 
13
14
  import Server from '../../Server';
14
- import {BuildOptions, OutputOptions, RequestOptions} from '../../shared/types';
15
15
 
16
- export function build(
16
+ export declare function build(
17
17
  packagerClient: Server,
18
18
  requestOptions: RequestOptions,
19
19
  buildOptions?: BuildOptions,
20
- ): Promise<{
21
- code: string;
22
- map: string;
23
- assets?: ReadonlyArray<AssetData>;
24
- }>;
25
-
26
- export function save(
27
- bundle: {
28
- code: string;
29
- map: string;
30
- },
20
+ ): Promise<{code: string; map: string; assets?: ReadonlyArray<AssetData>}>;
21
+ export declare function save(
22
+ bundle: {code: string; map: string},
31
23
  options: OutputOptions,
32
- log: (...args: string[]) => void,
24
+ log: ($$PARAM_0$$: string) => void,
33
25
  ): Promise<unknown>;
34
-
35
- export const formatName: string;
26
+ export declare const formatName: 'bundle';
27
+ export declare type formatName = typeof formatName;
@@ -26,7 +26,7 @@ export function build(
26
26
  ): Promise<{
27
27
  code: string,
28
28
  map: string,
29
- assets?: $ReadOnlyArray<AssetData>,
29
+ assets?: ReadonlyArray<AssetData>,
30
30
  ...
31
31
  }> {
32
32
  return packagerClient.build(
@@ -69,7 +69,7 @@ export async function save(
69
69
  },
70
70
  options: OutputOptions,
71
71
  log: string => void,
72
- ): Promise<mixed> {
72
+ ): Promise<unknown> {
73
73
  const {
74
74
  bundleOutput,
75
75
  bundleEncoding: encoding,
@@ -101,7 +101,7 @@ export async function save(
101
101
  }
102
102
 
103
103
  // Wait until everything is written to disk.
104
- await Promise.all(writeFns.map((cb: void => mixed) => cb()));
104
+ await Promise.all(writeFns.map((cb: void => unknown) => cb()));
105
105
  }
106
106
 
107
107
  export const formatName = 'bundle';
@@ -0,0 +1,15 @@
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
+ declare function meta(
12
+ code: Buffer | string,
13
+ encoding?: 'ascii' | 'utf16le' | 'utf8',
14
+ ): Buffer;
15
+ export default meta;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true,
5
5
  });
6
- exports.default = _default;
6
+ exports.default = meta;
7
7
  var _crypto = _interopRequireDefault(require("crypto"));
8
8
  function _interopRequireDefault(e) {
9
9
  return e && e.__esModule ? e : { default: e };
@@ -17,7 +17,7 @@ const constantFor = (encoding) =>
17
17
  : /^(?:utf-?16(?:le)?|ucs-?2)$/.test(encoding)
18
18
  ? 3
19
19
  : 0;
20
- function _default(code, encoding = "utf8") {
20
+ function meta(code, encoding = "utf8") {
21
21
  const buffer = asBuffer(code, encoding);
22
22
  const hash = _crypto.default.createHash("sha1");
23
23
  hash.update(buffer);
@@ -23,7 +23,7 @@ const constantFor = (encoding: 'ascii' | 'utf16le' | 'utf8') =>
23
23
  ? 3
24
24
  : 0;
25
25
 
26
- export default function (
26
+ export default function meta(
27
27
  code: Buffer | string,
28
28
  encoding: 'ascii' | 'utf16le' | 'utf8' = 'utf8',
29
29
  ): Buffer {
@@ -0,0 +1,11 @@
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
+ export * from './RamBundle';
@@ -0,0 +1,16 @@
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
+ declare function writeFile(
12
+ filePath: string,
13
+ data: string | Buffer | Uint8Array,
14
+ encoding?: string,
15
+ ): Promise<void>;
16
+ export default writeFile;
@@ -3,11 +3,16 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true,
5
5
  });
6
- exports.default = void 0;
6
+ exports.default = writeFile;
7
7
  var _fs = _interopRequireDefault(require("fs"));
8
8
  var _throat = _interopRequireDefault(require("throat"));
9
9
  function _interopRequireDefault(e) {
10
10
  return e && e.__esModule ? e : { default: e };
11
11
  }
12
- const writeFile = (0, _throat.default)(128, _fs.default.promises.writeFile);
13
- var _default = (exports.default = writeFile);
12
+ const writeFileWithThroat = (0, _throat.default)(
13
+ 128,
14
+ _fs.default.promises.writeFile,
15
+ );
16
+ function writeFile(filePath, data, encoding) {
17
+ return writeFileWithThroat(filePath, data, encoding);
18
+ }
@@ -12,9 +12,15 @@
12
12
  import fs from 'fs';
13
13
  import throat from 'throat';
14
14
 
15
- const writeFile: typeof fs.promises.writeFile = throat(
15
+ const writeFileWithThroat: typeof fs.promises.writeFile = throat(
16
16
  128,
17
17
  fs.promises.writeFile,
18
18
  );
19
19
 
20
- export default writeFile;
20
+ export default function writeFile(
21
+ filePath: string,
22
+ data: string | Buffer | Uint8Array,
23
+ encoding?: string,
24
+ ): Promise<void> {
25
+ return writeFileWithThroat(filePath, data, encoding);
26
+ }
@@ -23,9 +23,26 @@ import type {
23
23
  MinifierOptions,
24
24
  } from 'metro-transform-worker';
25
25
 
26
- type MetroSourceMapOrMappings = MixedSourceMap | MetroSourceMapSegmentTuple[];
27
-
28
- export interface BundleOptions {
26
+ type MetroSourceMapOrMappings =
27
+ | MixedSourceMap
28
+ | Array<MetroSourceMapSegmentTuple>;
29
+ export declare enum SourcePathsMode {
30
+ Absolute = 'absolute',
31
+ ServerUrl = 'url-server',
32
+ }
33
+ export declare namespace SourcePathsMode {
34
+ export function cast(value: string | null | undefined): SourcePathsMode;
35
+ export function isValid(
36
+ value: string | null | undefined,
37
+ ): value is SourcePathsMode;
38
+ export function members(): IterableIterator<SourcePathsMode>;
39
+ export function getName(value: SourcePathsMode): string;
40
+ }
41
+ export type ReadonlySourceLocation = Readonly<{
42
+ start: Readonly<{line: number; column: number}>;
43
+ end: Readonly<{line: number; column: number}>;
44
+ }>;
45
+ export type BundleOptions = {
29
46
  readonly customResolverOptions: CustomResolverOptions;
30
47
  customTransformOptions: CustomTransformOptions;
31
48
  dev: boolean;
@@ -35,77 +52,69 @@ export interface BundleOptions {
35
52
  readonly lazy: boolean;
36
53
  minify: boolean;
37
54
  readonly modulesOnly: boolean;
38
- onProgress?: (doneCont: number, totalCount: number) => unknown;
39
- readonly platform?: string;
55
+ onProgress:
56
+ | null
57
+ | undefined
58
+ | ((doneCont: number, totalCount: number) => unknown);
59
+ readonly platform: null | undefined | string;
40
60
  readonly runModule: boolean;
41
- runtimeBytecodeVersion?: number;
42
61
  readonly shallow: boolean;
43
- sourceMapUrl?: string;
44
- sourceUrl?: string;
62
+ sourceMapUrl: null | undefined | string;
63
+ sourceUrl: null | undefined | string;
45
64
  createModuleIdFactory?: () => (path: string) => number;
46
65
  readonly unstable_transformProfile: TransformProfile;
47
- }
48
-
49
- export interface BuildOptions {
50
- readonly withAssets?: boolean;
51
- }
52
-
53
- export interface ResolverInputOptions {
54
- readonly customResolverOptions?: CustomResolverOptions;
55
- }
56
-
57
- export interface SerializerOptions {
58
- readonly sourceMapUrl: string | null;
59
- readonly sourceUrl: string | null;
66
+ readonly sourcePaths: SourcePathsMode;
67
+ };
68
+ export type BuildOptions = Readonly<{withAssets?: boolean}>;
69
+ export type ResolverInputOptions = Readonly<{
70
+ customResolverOptions?: CustomResolverOptions;
71
+ dev: boolean;
72
+ }>;
73
+ export type SerializerOptions = {
74
+ readonly sourceMapUrl: null | undefined | string;
75
+ readonly sourceUrl: null | undefined | string;
60
76
  readonly runModule: boolean;
61
77
  readonly excludeSource: boolean;
62
78
  readonly inlineSourceMap: boolean;
63
79
  readonly modulesOnly: boolean;
64
- }
65
-
66
- export interface GraphOptions {
80
+ readonly sourcePaths: SourcePathsMode;
81
+ };
82
+ export type GraphOptions = {
67
83
  readonly lazy: boolean;
68
84
  readonly shallow: boolean;
69
- }
70
-
71
- // Stricter representation of BundleOptions.
72
- export interface SplitBundleOptions {
73
- readonly entryFile: string;
74
- readonly resolverOptions: ResolverInputOptions;
75
- readonly transformOptions: TransformInputOptions;
76
- readonly serializerOptions: SerializerOptions;
77
- readonly graphOptions: GraphOptions;
78
- readonly onProgress: DeltaBundlerOptions['onProgress'];
79
- }
80
-
81
- export interface ModuleGroups {
85
+ };
86
+ export type SplitBundleOptions = Readonly<{
87
+ entryFile: string;
88
+ resolverOptions: ResolverInputOptions;
89
+ transformOptions: TransformInputOptions;
90
+ serializerOptions: SerializerOptions;
91
+ graphOptions: GraphOptions;
92
+ onProgress: DeltaBundlerOptions['onProgress'];
93
+ }>;
94
+ export type ModuleGroups = {
82
95
  groups: Map<number, Set<number>>;
83
96
  modulesById: Map<number, ModuleTransportLike>;
84
97
  modulesInGroups: Set<number>;
85
- }
86
-
87
- export interface ModuleTransportLike {
98
+ };
99
+ export type ModuleTransportLike = {
88
100
  readonly code: string;
89
101
  readonly id: number;
90
- readonly map: MetroSourceMapOrMappings | null;
102
+ readonly map: null | undefined | MetroSourceMapOrMappings;
91
103
  readonly name?: string;
92
104
  readonly sourcePath: string;
93
- }
94
-
95
- export interface ModuleTransportLikeStrict {
105
+ };
106
+ export type ModuleTransportLikeStrict = {
96
107
  readonly code: string;
97
108
  readonly id: number;
98
- readonly map: MetroSourceMapOrMappings | null;
109
+ readonly map: null | undefined | MetroSourceMapOrMappings;
99
110
  readonly name?: string;
100
111
  readonly sourcePath: string;
101
- }
102
-
103
- export interface RamModuleTransport extends ModuleTransportLikeStrict {
104
- readonly source: string;
105
- readonly type: string;
106
- }
107
-
108
- export interface OutputOptions {
112
+ };
113
+ export type RamModuleTransport = Omit<
114
+ ModuleTransportLikeStrict,
115
+ keyof {readonly source: string; readonly type: string}
116
+ > & {readonly source: string; readonly type: string};
117
+ export type OutputOptions = {
109
118
  bundleOutput: string;
110
119
  bundleEncoding?: 'utf8' | 'utf16le' | 'ascii';
111
120
  dev?: boolean;
@@ -114,17 +123,23 @@ export interface OutputOptions {
114
123
  sourcemapOutput?: string;
115
124
  sourcemapSourcesRoot?: string;
116
125
  sourcemapUseAbsolutePath?: boolean;
117
- }
118
-
119
- export interface RequestOptions {
120
- entryFile: string;
121
- inlineSourceMap?: boolean;
122
- sourceMapUrl?: string;
123
- dev?: boolean;
124
- minify: boolean;
125
- platform: string;
126
- createModuleIdFactory?: () => (path: string) => number;
127
- onProgress?: (transformedFileCount: number, totalFileCount: number) => void;
128
- }
129
-
126
+ };
127
+ type SafeOptionalProps<T> = {
128
+ [K in keyof T]: T[K] extends void ? void | T[K] : T[K];
129
+ };
130
+ export type RequestOptions = Readonly<
131
+ SafeOptionalProps<{
132
+ entryFile: string;
133
+ inlineSourceMap?: boolean;
134
+ sourceMapUrl?: string;
135
+ dev?: boolean;
136
+ minify: boolean;
137
+ platform: string;
138
+ createModuleIdFactory?: () => (path: string) => number;
139
+ onProgress?: (transformedFileCount: number, totalFileCount: number) => void;
140
+ customResolverOptions?: CustomResolverOptions;
141
+ customTransformOptions?: CustomTransformOptions;
142
+ unstable_transformProfile?: TransformProfile;
143
+ }>
144
+ >;
130
145
  export type {MinifierOptions};