metro 0.83.4 → 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 (171) hide show
  1. package/package.json +18 -16
  2. package/src/Assets.d.ts +90 -0
  3. package/src/Assets.js +2 -9
  4. package/src/Bundler/util.d.ts +34 -0
  5. package/src/Bundler/util.js +2 -9
  6. package/src/Bundler/util.js.flow +3 -3
  7. package/src/Bundler.d.ts +45 -0
  8. package/src/Bundler.js +1 -5
  9. package/src/DeltaBundler/DeltaCalculator.d.ts +68 -0
  10. package/src/DeltaBundler/DeltaCalculator.js +56 -51
  11. package/src/DeltaBundler/DeltaCalculator.js.flow +72 -61
  12. package/src/DeltaBundler/Graph.d.ts +174 -0
  13. package/src/DeltaBundler/Graph.js +1 -5
  14. package/src/DeltaBundler/Serializers/baseJSBundle.d.ts +27 -0
  15. package/src/DeltaBundler/Serializers/baseJSBundle.js +1 -5
  16. package/src/DeltaBundler/Serializers/getAllFiles.d.ts +29 -0
  17. package/src/DeltaBundler/Serializers/getAssets.d.ts +32 -0
  18. package/src/DeltaBundler/Serializers/getAssets.js +1 -5
  19. package/src/DeltaBundler/Serializers/getExplodedSourceMap.d.ts +33 -0
  20. package/src/DeltaBundler/Serializers/getRamBundleInfo.d.ts +55 -0
  21. package/src/DeltaBundler/Serializers/getRamBundleInfo.js +1 -5
  22. package/src/DeltaBundler/Serializers/helpers/getInlineSourceMappingURL.d.ts +19 -0
  23. package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.d.ts +40 -0
  24. package/src/DeltaBundler/Serializers/helpers/getTransitiveDependencies.d.ts +24 -0
  25. package/src/DeltaBundler/Serializers/helpers/js.d.ts +37 -0
  26. package/src/DeltaBundler/Serializers/helpers/js.js +2 -9
  27. package/src/DeltaBundler/Serializers/helpers/processModules.d.ts +32 -0
  28. package/src/DeltaBundler/Serializers/hmrJSBundle.d.ts +37 -0
  29. package/src/DeltaBundler/Serializers/hmrJSBundle.js +2 -9
  30. package/src/DeltaBundler/Serializers/sourceMapGenerator.d.ts +36 -0
  31. package/src/DeltaBundler/Serializers/sourceMapGenerator.js +1 -5
  32. package/src/DeltaBundler/Serializers/sourceMapObject.d.ts +30 -0
  33. package/src/DeltaBundler/Serializers/sourceMapString.d.ts +29 -0
  34. package/src/DeltaBundler/Transformer.d.ts +45 -0
  35. package/src/DeltaBundler/Transformer.js +1 -5
  36. package/src/DeltaBundler/Worker.d.ts +44 -0
  37. package/src/DeltaBundler/Worker.flow.js +1 -5
  38. package/src/DeltaBundler/WorkerFarm.d.ts +77 -0
  39. package/src/DeltaBundler/buildSubgraph.d.ts +37 -0
  40. package/src/DeltaBundler/buildSubgraph.js +1 -5
  41. package/src/DeltaBundler/getTransformCacheKey.d.ts +25 -0
  42. package/src/DeltaBundler/getTransformCacheKey.js +4 -6
  43. package/src/DeltaBundler/getTransformCacheKey.js.flow +7 -2
  44. package/src/DeltaBundler/mergeDeltas.d.ts +24 -0
  45. package/src/DeltaBundler/types.d.ts +170 -0
  46. package/src/DeltaBundler/types.js +1 -5
  47. package/src/DeltaBundler.d.ts +67 -0
  48. package/src/DeltaBundler.js +1 -5
  49. package/src/HmrServer.d.ts +98 -0
  50. package/src/HmrServer.js +9 -9
  51. package/src/HmrServer.js.flow +15 -5
  52. package/src/IncrementalBundler/GraphNotFoundError.d.ts +24 -0
  53. package/src/IncrementalBundler/ResourceNotFoundError.d.ts +22 -0
  54. package/src/IncrementalBundler/RevisionNotFoundError.d.ts +24 -0
  55. package/src/IncrementalBundler.d.ts +103 -0
  56. package/src/IncrementalBundler.js +2 -9
  57. package/src/ModuleGraph/worker/JsFileWrapping.d.ts +36 -0
  58. package/src/ModuleGraph/worker/JsFileWrapping.js +2 -9
  59. package/src/ModuleGraph/worker/collectDependencies.d.ts +138 -0
  60. package/src/ModuleGraph/worker/collectDependencies.js +2 -9
  61. package/src/ModuleGraph/worker/generateImportNames.d.ts +26 -0
  62. package/src/ModuleGraph/worker/generateImportNames.js +1 -5
  63. package/src/ModuleGraph/worker/importLocationsPlugin.d.ts +33 -0
  64. package/src/Server/MultipartResponse.d.ts +37 -0
  65. package/src/Server/MultipartResponse.js +1 -5
  66. package/src/Server/symbolicate.d.ts +38 -0
  67. package/src/Server.d.ts +278 -0
  68. package/src/Server.js +47 -15
  69. package/src/Server.js.flow +57 -10
  70. package/src/cli/parseKeyValueParamArray.d.ts +21 -0
  71. package/src/cli-utils.d.ts +26 -0
  72. package/src/cli-utils.js +1 -5
  73. package/src/commands/build.d.ts +23 -0
  74. package/src/commands/build.js +1 -5
  75. package/src/commands/dependencies.d.ts +23 -0
  76. package/src/commands/dependencies.js +1 -5
  77. package/src/commands/serve.d.ts +23 -0
  78. package/src/index.d.ts +206 -0
  79. package/src/index.flow.js +26 -19
  80. package/src/index.flow.js.flow +46 -12
  81. package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-import.js +1 -5
  82. package/src/integration_tests/basic_bundle/build-errors/inline-requires-cannot-resolve-import.js +1 -5
  83. package/src/integration_tests/basic_bundle/import-export/index.js +2 -9
  84. package/src/integration_tests/execBundle.js +1 -5
  85. package/src/lib/BatchProcessor.d.ts +61 -0
  86. package/src/lib/BatchProcessor.js +1 -5
  87. package/src/lib/CountingSet.d.ts +55 -0
  88. package/src/lib/JsonReporter.d.ts +44 -0
  89. package/src/lib/JsonReporter.js.flow +2 -2
  90. package/src/lib/RamBundleParser.d.ts +36 -0
  91. package/src/lib/RamBundleParser.js +1 -5
  92. package/src/lib/TerminalReporter.d.ts +125 -0
  93. package/src/lib/TerminalReporter.js +8 -16
  94. package/src/lib/TerminalReporter.js.flow +6 -15
  95. package/src/lib/bundleProgressUtils.d.ts +33 -0
  96. package/src/lib/bundleProgressUtils.js +19 -0
  97. package/src/lib/bundleProgressUtils.js.flow +35 -0
  98. package/src/lib/bundleToString.d.ts +26 -0
  99. package/src/lib/contextModule.d.ts +40 -0
  100. package/src/lib/contextModule.js +1 -5
  101. package/src/lib/contextModuleTemplates.d.ts +32 -0
  102. package/src/lib/contextModuleTemplates.js +1 -4
  103. package/src/lib/countLines.d.ts +19 -0
  104. package/src/lib/createWebsocketServer.d.ts +50 -0
  105. package/src/lib/createWebsocketServer.js +1 -5
  106. package/src/lib/debounceAsyncQueue.d.ts +22 -0
  107. package/src/lib/formatBundlingError.d.ts +30 -0
  108. package/src/lib/formatBundlingError.js +1 -5
  109. package/src/lib/getAppendScripts.d.ts +38 -0
  110. package/src/lib/getAppendScripts.js +1 -5
  111. package/src/lib/getAppendScripts.js.flow +2 -2
  112. package/src/lib/getGraphId.d.ts +32 -0
  113. package/src/lib/getGraphId.js +1 -5
  114. package/src/lib/getPreludeCode.d.ts +25 -0
  115. package/src/lib/getPrependedScripts.d.ts +31 -0
  116. package/src/lib/getPrependedScripts.js +2 -9
  117. package/src/lib/isResolvedDependency.d.ts +22 -0
  118. package/src/lib/logToConsole.d.ts +26 -0
  119. package/src/lib/logToConsole.js +1 -5
  120. package/src/lib/parseBundleOptionsFromBundleRequestUrl.d.ts +24 -0
  121. package/src/lib/parseBundleOptionsFromBundleRequestUrl.js +2 -9
  122. package/src/lib/parseCustomResolverOptions.d.ts +23 -0
  123. package/src/lib/parseCustomTransformOptions.d.ts +23 -0
  124. package/src/lib/parseJsonBody.d.ts +34 -0
  125. package/src/lib/pathUtils.d.ts +21 -0
  126. package/src/lib/pathUtils.js +1 -4
  127. package/src/lib/relativizeSourceMap.d.ts +24 -0
  128. package/src/lib/relativizeSourceMap.js +1 -5
  129. package/src/lib/reporting.d.ts +135 -0
  130. package/src/lib/reporting.js +1 -5
  131. package/src/lib/splitBundleOptions.d.ts +23 -0
  132. package/src/lib/transformHelpers.d.ts +42 -0
  133. package/src/lib/transformHelpers.js +1 -5
  134. package/src/node-haste/DependencyGraph/ModuleResolution.d.ts +120 -0
  135. package/src/node-haste/DependencyGraph/ModuleResolution.js +6 -31
  136. package/src/node-haste/DependencyGraph/ModuleResolution.js.flow +10 -59
  137. package/src/node-haste/DependencyGraph/createFileMap.d.ts +36 -0
  138. package/src/node-haste/DependencyGraph/createFileMap.js +3 -10
  139. package/src/node-haste/DependencyGraph/createFileMap.js.flow +4 -2
  140. package/src/node-haste/DependencyGraph.d.ts +90 -0
  141. package/src/node-haste/DependencyGraph.js +23 -16
  142. package/src/node-haste/DependencyGraph.js.flow +24 -13
  143. package/src/node-haste/PackageCache.d.ts +37 -0
  144. package/src/node-haste/PackageCache.js +65 -58
  145. package/src/node-haste/PackageCache.js.flow +103 -79
  146. package/src/node-haste/lib/AssetPaths.d.ts +36 -0
  147. package/src/node-haste/lib/AssetPaths.js +1 -5
  148. package/src/node-haste/lib/parsePlatformFilePath.d.ts +32 -0
  149. package/src/node-haste/lib/parsePlatformFilePath.js +1 -5
  150. package/src/shared/output/RamBundle/as-assets.d.ts +32 -0
  151. package/src/shared/output/RamBundle/as-assets.js +1 -5
  152. package/src/shared/output/RamBundle/as-indexed-file.d.ts +45 -0
  153. package/src/shared/output/RamBundle/as-indexed-file.js +1 -5
  154. package/src/shared/output/RamBundle/buildSourcemapWithMetadata.d.ts +30 -0
  155. package/src/shared/output/RamBundle/magic-number.d.ts +21 -0
  156. package/src/shared/output/RamBundle/util.d.ts +48 -0
  157. package/src/shared/output/RamBundle/util.js +1 -5
  158. package/src/shared/output/RamBundle/write-sourcemap.d.ts +23 -0
  159. package/src/shared/output/RamBundle/write-sourcemap.js +1 -5
  160. package/src/shared/output/RamBundle.d.ts +33 -0
  161. package/src/shared/output/RamBundle.js +1 -5
  162. package/src/shared/output/bundle.d.ts +34 -0
  163. package/src/shared/output/bundle.flow.js +1 -5
  164. package/src/shared/output/meta.d.ts +22 -0
  165. package/src/shared/output/meta.js +1 -5
  166. package/src/shared/output/unbundle.d.ts +18 -0
  167. package/src/shared/output/writeFile.d.ts +23 -0
  168. package/src/shared/output/writeFile.js +1 -5
  169. package/src/shared/types.d.ts +152 -0
  170. package/src/node-haste/Package.js +0 -32
  171. package/src/node-haste/Package.js.flow +0 -39
@@ -7,11 +7,7 @@ exports.default = void 0;
7
7
  var _chalk = _interopRequireDefault(require("chalk"));
8
8
  var _util = _interopRequireDefault(require("util"));
9
9
  function _interopRequireDefault(e) {
10
- return e && e.__esModule
11
- ? e
12
- : {
13
- default: e,
14
- };
10
+ return e && e.__esModule ? e : { default: e };
15
11
  }
16
12
  const groupStack = [];
17
13
  let collapsedGuardTimer;
@@ -0,0 +1,24 @@
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
+ * @noformat
8
+ * @oncall react_native
9
+ * @generated SignedSource<<972fc847af4a55ba0e4863c90532e99c>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/lib/parseBundleOptionsFromBundleRequestUrl.js
13
+ * To regenerate, run:
14
+ * js1 build metro-ts-defs (internal) OR
15
+ * yarn run build-ts-defs (OSS)
16
+ */
17
+
18
+ import type {BundleOptions} from '../shared/types';
19
+
20
+ declare function parseBundleOptionsFromBundleRequestUrl(
21
+ rawNonJscSafeUrlEncodedUrl: string,
22
+ platforms: Set<string>,
23
+ ): Omit<BundleOptions, keyof {bundleType: string}> & {bundleType: string};
24
+ export default parseBundleOptionsFromBundleRequestUrl;
@@ -24,10 +24,7 @@ function _interopRequireWildcard(e, t) {
24
24
  if (!t && e && e.__esModule) return e;
25
25
  var o,
26
26
  i,
27
- f = {
28
- __proto__: null,
29
- default: e,
30
- };
27
+ f = { __proto__: null, default: e };
31
28
  if (null === e || ("object" != typeof e && "function" != typeof e))
32
29
  return f;
33
30
  if ((o = t ? n : r)) {
@@ -47,11 +44,7 @@ function _interopRequireWildcard(e, t) {
47
44
  })(e, t);
48
45
  }
49
46
  function _interopRequireDefault(e) {
50
- return e && e.__esModule
51
- ? e
52
- : {
53
- default: e,
54
- };
47
+ return e && e.__esModule ? e : { default: e };
55
48
  }
56
49
  const debug = require("debug")(
57
50
  "Metro:Server:parseBundleOptionsFromBundleRequestUrl",
@@ -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
+ * @noformat
8
+ * @oncall react_native
9
+ * @generated SignedSource<<e0f212b1e687fef985215d8c152e7c04>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/lib/parseCustomResolverOptions.js
13
+ * To regenerate, run:
14
+ * js1 build metro-ts-defs (internal) OR
15
+ * yarn run build-ts-defs (OSS)
16
+ */
17
+
18
+ import type {CustomResolverOptions} from 'metro-resolver';
19
+
20
+ declare function parseCustomResolverOptions(
21
+ searchParams: URLSearchParams,
22
+ ): CustomResolverOptions;
23
+ export default parseCustomResolverOptions;
@@ -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
+ * @noformat
8
+ * @oncall react_native
9
+ * @generated SignedSource<<086e5d861160a99775fa58beba59492a>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/lib/parseCustomTransformOptions.js
13
+ * To regenerate, run:
14
+ * js1 build metro-ts-defs (internal) OR
15
+ * yarn run build-ts-defs (OSS)
16
+ */
17
+
18
+ import type {CustomTransformOptions} from 'metro-transform-worker';
19
+
20
+ declare function parseCustomTransformOptions(
21
+ searchParams: URLSearchParams,
22
+ ): CustomTransformOptions;
23
+ export default parseCustomTransformOptions;
@@ -0,0 +1,34 @@
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
+ * @noformat
8
+ * @oncall react_native
9
+ * @generated SignedSource<<cd5e7346556814416374b8c8e79a8674>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/lib/parseJsonBody.js
13
+ * To regenerate, run:
14
+ * js1 build metro-ts-defs (internal) OR
15
+ * yarn run build-ts-defs (OSS)
16
+ */
17
+
18
+ import type {IncomingMessage} from 'http';
19
+
20
+ export type JsonData =
21
+ | {[$$Key$$: string]: JsonData}
22
+ | Array<JsonData>
23
+ | string
24
+ | number
25
+ | boolean
26
+ | null;
27
+ /**
28
+ * Attempt to parse a request body as JSON.
29
+ */
30
+ declare function parseJsonBody(
31
+ req: IncomingMessage,
32
+ options?: {strict?: boolean},
33
+ ): Promise<JsonData>;
34
+ export default parseJsonBody;
@@ -0,0 +1,21 @@
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
+ * @noformat
8
+ * @generated SignedSource<<61d935169a7ad0d7f2d7b4c6e4eb0a96>>
9
+ *
10
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
11
+ * Original file: packages/metro/src/lib/pathUtils.js
12
+ * To regenerate, run:
13
+ * js1 build metro-ts-defs (internal) OR
14
+ * yarn run build-ts-defs (OSS)
15
+ */
16
+
17
+ export declare const normalizePathSeparatorsToPosix: (
18
+ $$PARAM_0$$: string,
19
+ ) => string;
20
+ export declare type normalizePathSeparatorsToPosix =
21
+ typeof normalizePathSeparatorsToPosix;
@@ -13,10 +13,7 @@ function _interopRequireWildcard(e, t) {
13
13
  if (!t && e && e.__esModule) return e;
14
14
  var o,
15
15
  i,
16
- f = {
17
- __proto__: null,
18
- default: e,
19
- };
16
+ f = { __proto__: null, default: e };
20
17
  if (null === e || ("object" != typeof e && "function" != typeof e))
21
18
  return f;
22
19
  if ((o = t ? n : r)) {
@@ -0,0 +1,24 @@
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
+ * @noformat
8
+ * @oncall react_native
9
+ * @generated SignedSource<<5282fe2c42baa79f957ef2a40bec560b>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/lib/relativizeSourceMap.js
13
+ * To regenerate, run:
14
+ * js1 build metro-ts-defs (internal) OR
15
+ * yarn run build-ts-defs (OSS)
16
+ */
17
+
18
+ import type {MixedSourceMap} from 'metro-source-map';
19
+
20
+ declare function relativizeSourceMapInline(
21
+ sourceMap: MixedSourceMap,
22
+ sourcesRoot: string,
23
+ ): void;
24
+ export default relativizeSourceMapInline;
@@ -6,11 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = relativizeSourceMapInline;
7
7
  var _path = _interopRequireDefault(require("path"));
8
8
  function _interopRequireDefault(e) {
9
- return e && e.__esModule
10
- ? e
11
- : {
12
- default: e,
13
- };
9
+ return e && e.__esModule ? e : { default: e };
14
10
  }
15
11
  function relativizeSourceMapInline(sourceMap, sourcesRoot) {
16
12
  if (sourceMap.mappings === undefined) {
@@ -0,0 +1,135 @@
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
+ * @noformat
8
+ * @oncall react_native
9
+ * @generated SignedSource<<1ff95f1ad6bb911f3d2c2bc41d59bc1a>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/lib/reporting.js
13
+ * To regenerate, run:
14
+ * js1 build metro-ts-defs (internal) OR
15
+ * yarn run build-ts-defs (OSS)
16
+ */
17
+
18
+ import type {Terminal} from 'metro-core';
19
+ import type {HealthCheckResult, WatcherStatus} from 'metro-file-map';
20
+ import type {CustomResolverOptions} from 'metro-resolver';
21
+ import type {CustomTransformOptions} from 'metro-transform-worker';
22
+
23
+ export type BundleDetails = {
24
+ bundleType: string;
25
+ customResolverOptions: CustomResolverOptions;
26
+ customTransformOptions: CustomTransformOptions;
27
+ dev: boolean;
28
+ entryFile: string;
29
+ minify: boolean;
30
+ platform: null | undefined | string;
31
+ };
32
+ /**
33
+ * A tagged union of all the actions that may happen and we may want to
34
+ * report to the tool user.
35
+ */
36
+ export type ReportableEvent =
37
+ | {port: number; hasReducedPerformance: boolean; type: 'initialize_started'}
38
+ | {type: 'initialize_failed'; port: number; error: Error}
39
+ | {type: 'initialize_done'; port: number}
40
+ | {buildID: string; type: 'bundle_build_done'}
41
+ | {buildID: string; type: 'bundle_build_failed'}
42
+ | {type: 'bundle_save_log'; message: string}
43
+ | {
44
+ buildID: string;
45
+ bundleDetails: BundleDetails;
46
+ isPrefetch?: boolean;
47
+ type: 'bundle_build_started';
48
+ }
49
+ | {error: Error; type: 'bundling_error'}
50
+ | {type: 'dep_graph_loading'; hasReducedPerformance: boolean}
51
+ | {type: 'dep_graph_loaded'}
52
+ | {
53
+ buildID: string;
54
+ type: 'bundle_transform_progressed';
55
+ transformedFileCount: number;
56
+ totalFileCount: number;
57
+ }
58
+ | {type: 'cache_read_error'; error: Error}
59
+ | {type: 'cache_write_error'; error: Error}
60
+ | {type: 'transform_cache_reset'}
61
+ | {type: 'worker_stdout_chunk'; chunk: string}
62
+ | {type: 'worker_stderr_chunk'; chunk: string}
63
+ | {type: 'hmr_client_error'; error: Error}
64
+ | {
65
+ type: 'client_log';
66
+ level:
67
+ | 'trace'
68
+ | 'info'
69
+ | 'warn'
70
+ | 'log'
71
+ | 'group'
72
+ | 'groupCollapsed'
73
+ | 'groupEnd'
74
+ | 'debug';
75
+ data: Array<unknown>;
76
+ }
77
+ | {type: 'resolver_warning'; message: string}
78
+ | {type: 'server_listening'; port: number; address: string; family: string}
79
+ | {type: 'transformer_load_started'}
80
+ | {type: 'transformer_load_done'}
81
+ | {type: 'transformer_load_failed'; error: Error}
82
+ | {type: 'watcher_health_check_result'; result: HealthCheckResult}
83
+ | {type: 'watcher_status'; status: WatcherStatus};
84
+ /**
85
+ * Code across the application takes a reporter as an option and calls the
86
+ * update whenever one of the ReportableEvent happens. Code does not directly
87
+ * write to the standard output, because a build would be:
88
+ *
89
+ * 1. ad-hoc, embedded into another tool, in which case we do not want to
90
+ * pollute that tool's own output. The tool is free to present the
91
+ * warnings/progress we generate any way they want, by specifing a custom
92
+ * reporter.
93
+ * 2. run as a background process from another tool, in which case we want
94
+ * to expose updates in a way that is easily machine-readable, for example
95
+ * a JSON-stream. We don't want to pollute it with textual messages.
96
+ *
97
+ * We centralize terminal reporting into a single place because we want the
98
+ * output to be robust and consistent. The most common reporter is
99
+ * TerminalReporter, that should be the only place in the application should
100
+ * access the `terminal` module (nor the `console`).
101
+ */
102
+ export type Reporter = {update(event: ReportableEvent): void};
103
+ /**
104
+ * A standard way to log a warning to the terminal. This should not be called
105
+ * from some arbitrary Metro logic, only from the reporters. Instead of
106
+ * calling this, add a new type of ReportableEvent instead, and implement a
107
+ * proper handler in the reporter(s).
108
+ */
109
+ export declare function logWarning(
110
+ terminal: Terminal,
111
+ format: string,
112
+ ...args: Array<unknown>
113
+ ): void;
114
+ /**
115
+ * Similar to `logWarning`, but for messages that require the user to act.
116
+ */
117
+ export declare function logError(
118
+ terminal: Terminal,
119
+ format: string,
120
+ ...args: Array<unknown>
121
+ ): void;
122
+ /**
123
+ * Similar to `logWarning`, but for informational messages.
124
+ */
125
+ export declare function logInfo(
126
+ terminal: Terminal,
127
+ format: string,
128
+ ...args: Array<unknown>
129
+ ): void;
130
+ /**
131
+ * A reporter that does nothing. Errors and warnings will be swallowed, that
132
+ * is generally not what you want.
133
+ */
134
+ export declare const nullReporter: {update(): void};
135
+ export declare type nullReporter = typeof nullReporter;
@@ -10,11 +10,7 @@ exports.nullReporter = void 0;
10
10
  var _chalk = _interopRequireDefault(require("chalk"));
11
11
  var _util = _interopRequireDefault(require("util"));
12
12
  function _interopRequireDefault(e) {
13
- return e && e.__esModule
14
- ? e
15
- : {
16
- default: e,
17
- };
13
+ return e && e.__esModule ? e : { default: e };
18
14
  }
19
15
  function logWarning(terminal, format, ...args) {
20
16
  const str = _util.default.format(format, ...args);
@@ -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
+ * @noformat
8
+ * @oncall react_native
9
+ * @generated SignedSource<<cf1e935fe7a5b1c8573b53b1c1921e70>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/lib/splitBundleOptions.js
13
+ * To regenerate, run:
14
+ * js1 build metro-ts-defs (internal) OR
15
+ * yarn run build-ts-defs (OSS)
16
+ */
17
+
18
+ import type {BundleOptions, SplitBundleOptions} from '../shared/types';
19
+ /**
20
+ * Splits a BundleOptions object into smaller, more manageable parts.
21
+ */
22
+ declare function splitBundleOptions(options: BundleOptions): SplitBundleOptions;
23
+ export default splitBundleOptions;
@@ -0,0 +1,42 @@
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
+ * @noformat
8
+ * @oncall react_native
9
+ * @generated SignedSource<<dfdfdf9ddb80994cc031e3767a87b56f>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/lib/transformHelpers.js
13
+ * To regenerate, run:
14
+ * js1 build metro-ts-defs (internal) OR
15
+ * yarn run build-ts-defs (OSS)
16
+ */
17
+
18
+ import type Bundler from '../Bundler';
19
+ import type {TransformFn, default as DeltaBundler} from '../DeltaBundler';
20
+ import type {
21
+ BundlerResolution,
22
+ TransformInputOptions,
23
+ TransformResultDependency,
24
+ } from '../DeltaBundler/types';
25
+ import type {ResolverInputOptions} from '../shared/types';
26
+ import type {ConfigT} from 'metro-config';
27
+
28
+ export declare function getTransformFn(
29
+ entryFiles: ReadonlyArray<string>,
30
+ bundler: Bundler,
31
+ deltaBundler: DeltaBundler,
32
+ config: ConfigT,
33
+ options: TransformInputOptions,
34
+ resolverOptions: ResolverInputOptions,
35
+ ): Promise<TransformFn>;
36
+ export declare function getResolveDependencyFn(
37
+ bundler: Bundler,
38
+ platform: null | undefined | string,
39
+ resolverOptions: ResolverInputOptions,
40
+ ): Promise<
41
+ (from: string, dependency: TransformResultDependency) => BundlerResolution
42
+ >;
@@ -10,11 +10,7 @@ var _isAssetFile = _interopRequireDefault(
10
10
  require("metro-resolver/private/utils/isAssetFile"),
11
11
  );
12
12
  function _interopRequireDefault(e) {
13
- return e && e.__esModule
14
- ? e
15
- : {
16
- default: e,
17
- };
13
+ return e && e.__esModule ? e : { default: e };
18
14
  }
19
15
  const baseIgnoredInlineRequires = [
20
16
  "React",
@@ -0,0 +1,120 @@
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
+ * @noformat
8
+ * @oncall react_native
9
+ * @generated SignedSource<<0024fd05b95efe19a24f9acc84ff474b>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/node-haste/DependencyGraph/ModuleResolution.js
13
+ * To regenerate, run:
14
+ * js1 build metro-ts-defs (internal) OR
15
+ * yarn run build-ts-defs (OSS)
16
+ */
17
+
18
+ import type {
19
+ BundlerResolution,
20
+ TransformResultDependency,
21
+ } from '../../DeltaBundler/types';
22
+ import type {Reporter} from '../../lib/reporting';
23
+ import type {ResolverInputOptions} from '../../shared/types';
24
+ import type {
25
+ CustomResolver,
26
+ DoesFileExist,
27
+ FileCandidates,
28
+ FileSystemLookup,
29
+ Resolution,
30
+ ResolveAsset,
31
+ } from 'metro-resolver';
32
+ import type {PackageForModule, PackageJson} from 'metro-resolver/private/types';
33
+
34
+ export type DirExistsFn = (filePath: string) => boolean;
35
+ type Options = Readonly<{
36
+ assetExts: ReadonlySet<string>;
37
+ dirExists: DirExistsFn;
38
+ disableHierarchicalLookup: boolean;
39
+ doesFileExist: DoesFileExist;
40
+ emptyModulePath: string;
41
+ extraNodeModules: null | undefined | object;
42
+ fileSystemLookup: FileSystemLookup;
43
+ getHasteModulePath: (
44
+ name: string,
45
+ platform: null | undefined | string,
46
+ ) => null | undefined | string;
47
+ getHastePackagePath: (
48
+ name: string,
49
+ platform: null | undefined | string,
50
+ ) => null | undefined | string;
51
+ mainFields: ReadonlyArray<string>;
52
+ getPackage: (packageJsonPath: string) => null | undefined | PackageJson;
53
+ getPackageForModule: (
54
+ absolutePath: string,
55
+ ) => null | undefined | PackageForModule;
56
+ nodeModulesPaths: ReadonlyArray<string>;
57
+ preferNativePlatform: boolean;
58
+ projectRoot: string;
59
+ reporter: Reporter;
60
+ resolveAsset: ResolveAsset;
61
+ resolveRequest: null | undefined | CustomResolver;
62
+ sourceExts: ReadonlyArray<string>;
63
+ unstable_conditionNames: ReadonlyArray<string>;
64
+ unstable_conditionsByPlatform: Readonly<{
65
+ [platform: string]: ReadonlyArray<string>;
66
+ }>;
67
+ unstable_enablePackageExports: boolean;
68
+ unstable_incrementalResolution: boolean;
69
+ }>;
70
+ export declare class ModuleResolver {
71
+ _options: Options;
72
+ _projectRootFakeModulePath: string;
73
+ _cachedEmptyModule: null | undefined | BundlerResolution;
74
+ constructor(options: Options);
75
+ _getEmptyModule(): BundlerResolution;
76
+ resolveDependency(
77
+ originModulePath: string,
78
+ dependency: TransformResultDependency,
79
+ allowHaste: boolean,
80
+ platform: string | null,
81
+ resolverOptions: ResolverInputOptions,
82
+ ): BundlerResolution;
83
+ /**
84
+ * TODO: Return Resolution instead of coercing to BundlerResolution here
85
+ */
86
+ _getFileResolvedModule(resolution: Resolution): BundlerResolution;
87
+ _logWarning: (message: string) => void;
88
+ _removeRoot(candidates: FileCandidates): FileCandidates;
89
+ }
90
+ export declare class UnableToResolveError extends Error {
91
+ /**
92
+ * File path of the module that tried to require a module, ex. `/js/foo.js`.
93
+ */
94
+ originModulePath: string;
95
+ /**
96
+ * The name of the module that was required, no necessarily a path,
97
+ * ex. `./bar`, or `invariant`.
98
+ */
99
+ targetModuleName: string;
100
+ /**
101
+ * Original error that causes this error
102
+ */
103
+ cause: null | undefined | Error;
104
+ /**
105
+ * Fixed type field in common with other Metro build errors.
106
+ */
107
+ readonly type: 'UnableToResolveError';
108
+ constructor(
109
+ originModulePath: string,
110
+ targetModuleName: string,
111
+ message: string,
112
+ options?: Readonly<{
113
+ dependency?: null | undefined | TransformResultDependency;
114
+ cause?: Error;
115
+ }>,
116
+ );
117
+ buildCodeFrameMessage(
118
+ dependency: null | undefined | TransformResultDependency,
119
+ ): null | undefined | string;
120
+ }
@@ -21,10 +21,7 @@ function _interopRequireWildcard(e, t) {
21
21
  if (!t && e && e.__esModule) return e;
22
22
  var o,
23
23
  i,
24
- f = {
25
- __proto__: null,
26
- default: e,
27
- };
24
+ f = { __proto__: null, default: e };
28
25
  if (null === e || ("object" != typeof e && "function" != typeof e))
29
26
  return f;
30
27
  if ((o = t ? n : r)) {
@@ -44,11 +41,7 @@ function _interopRequireWildcard(e, t) {
44
41
  })(e, t);
45
42
  }
46
43
  function _interopRequireDefault(e) {
47
- return e && e.__esModule
48
- ? e
49
- : {
50
- default: e,
51
- };
44
+ return e && e.__esModule ? e : { default: e };
52
45
  }
53
46
  class ModuleResolver {
54
47
  constructor(options) {
@@ -93,6 +86,8 @@ class ModuleResolver {
93
86
  doesFileExist,
94
87
  extraNodeModules,
95
88
  fileSystemLookup,
89
+ getPackage,
90
+ getPackageForModule,
96
91
  mainFields,
97
92
  nodeModulesPaths,
98
93
  preferNativePlatform,
@@ -116,9 +111,8 @@ class ModuleResolver {
116
111
  doesFileExist,
117
112
  extraNodeModules,
118
113
  fileSystemLookup,
119
- getPackage: this._getPackage,
120
- getPackageForModule: (absoluteModulePath) =>
121
- this._getPackageForModule(absoluteModulePath),
114
+ getPackage,
115
+ getPackageForModule,
122
116
  isESMImport: dependency.data.isESMImport,
123
117
  mainFields,
124
118
  nodeModulesPaths,
@@ -198,25 +192,6 @@ class ModuleResolver {
198
192
  throw error;
199
193
  }
200
194
  }
201
- _getPackage = (packageJsonPath) => {
202
- try {
203
- return this._options.packageCache.getPackage(packageJsonPath).read();
204
- } catch (e) {}
205
- return null;
206
- };
207
- _getPackageForModule = (absolutePath) => {
208
- let result;
209
- try {
210
- result = this._options.packageCache.getPackageOf(absolutePath);
211
- } catch (e) {}
212
- return result != null
213
- ? {
214
- packageJson: result.pkg.read(),
215
- packageRelativePath: result.packageRelativePath,
216
- rootPath: _path.default.dirname(result.pkg.path),
217
- }
218
- : null;
219
- };
220
195
  _getFileResolvedModule(resolution) {
221
196
  switch (resolution.type) {
222
197
  case "sourceFile":