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
@@ -13,6 +13,7 @@ import type {BundleDetails, ReportableEvent} from './reporting';
13
13
  import type {Terminal} from 'metro-core';
14
14
  import type {HealthCheckResult, WatcherStatus} from 'metro-file-map';
15
15
 
16
+ import {calculateBundleProgressRatio} from './bundleProgressUtils';
16
17
  import logToConsole from './logToConsole';
17
18
  import * as reporting from './reporting';
18
19
  import chalk from 'chalk';
@@ -132,7 +133,7 @@ export default class TerminalReporter {
132
133
  chalk.bgWhite.white(
133
134
  LIGHT_BLOCK_CHAR.repeat(MAX_PROGRESS_BAR_CHAR_WIDTH - filledBar),
134
135
  ) +
135
- chalk.bold(` ${(100 * ratio).toFixed(1)}% `) +
136
+ chalk.bold(` ${Math.floor(100 * ratio)}% `) +
136
137
  chalk.dim(`(${transformedFileCount}/${totalFileCount})`)
137
138
  : '';
138
139
 
@@ -352,14 +353,6 @@ export default class TerminalReporter {
352
353
  });
353
354
  }
354
355
 
355
- /**
356
- * Because we know the `totalFileCount` is going to progressively increase
357
- * starting with 1:
358
- * - We use Math.max(totalFileCount, 10) to prevent the ratio to raise too
359
- * quickly when the total file count is low. (e.g 1/2 5/6)
360
- * - We prevent the ratio from going backwards.
361
- * - Instead, we use Math.pow(ratio, 2) to as a conservative measure of progress.
362
- */
363
356
  _updateBundleProgress({
364
357
  buildID,
365
358
  transformedFileCount,
@@ -375,12 +368,10 @@ export default class TerminalReporter {
375
368
  return;
376
369
  }
377
370
 
378
- const ratio = Math.min(
379
- Math.max(
380
- Math.pow(transformedFileCount / Math.max(totalFileCount, 10), 2),
381
- currentProgress.ratio,
382
- ),
383
- 0.999, // make sure not to go above 99.9% to not get rounded to 100%,
371
+ const ratio = calculateBundleProgressRatio(
372
+ transformedFileCount,
373
+ totalFileCount,
374
+ currentProgress.ratio,
384
375
  );
385
376
 
386
377
  // $FlowFixMe[unsafe-object-assign]
@@ -0,0 +1,33 @@
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<<6f0cfa5c118fa3cbe65acee044b8c927>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/lib/bundleProgressUtils.js
13
+ * To regenerate, run:
14
+ * js1 build metro-ts-defs (internal) OR
15
+ * yarn run build-ts-defs (OSS)
16
+ */
17
+
18
+ /**
19
+ * Calculates a conservative progress ratio for bundle building.
20
+ *
21
+ * Because we know the `totalFileCount` is going to progressively increase
22
+ * starting with 1:
23
+ * - We use Math.max(totalFileCount, 10) to prevent the ratio from raising too
24
+ * quickly when the total file count is low. (e.g 1/2 5/6)
25
+ * - We use Math.pow(ratio, 2) as a conservative measure of progress.
26
+ * - The ratio is capped at 0.999 to ensure we don't display 100% until done.
27
+ * - If previousRatio is provided, the ratio will not go backwards.
28
+ */
29
+ export declare function calculateBundleProgressRatio(
30
+ transformedFileCount: number,
31
+ totalFileCount: number,
32
+ previousRatio?: number,
33
+ ): number;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true,
5
+ });
6
+ exports.calculateBundleProgressRatio = calculateBundleProgressRatio;
7
+ function calculateBundleProgressRatio(
8
+ transformedFileCount,
9
+ totalFileCount,
10
+ previousRatio,
11
+ ) {
12
+ const baseRatio = Math.pow(
13
+ transformedFileCount / Math.max(totalFileCount, 10),
14
+ 2,
15
+ );
16
+ const ratio =
17
+ previousRatio != null ? Math.max(baseRatio, previousRatio) : baseRatio;
18
+ return Math.min(ratio, 0.999);
19
+ }
@@ -0,0 +1,35 @@
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
+ /**
13
+ * Calculates a conservative progress ratio for bundle building.
14
+ *
15
+ * Because we know the `totalFileCount` is going to progressively increase
16
+ * starting with 1:
17
+ * - We use Math.max(totalFileCount, 10) to prevent the ratio from raising too
18
+ * quickly when the total file count is low. (e.g 1/2 5/6)
19
+ * - We use Math.pow(ratio, 2) as a conservative measure of progress.
20
+ * - The ratio is capped at 0.999 to ensure we don't display 100% until done.
21
+ * - If previousRatio is provided, the ratio will not go backwards.
22
+ */
23
+ export function calculateBundleProgressRatio(
24
+ transformedFileCount: number,
25
+ totalFileCount: number,
26
+ previousRatio?: number,
27
+ ): number {
28
+ const baseRatio = Math.pow(
29
+ transformedFileCount / Math.max(totalFileCount, 10),
30
+ 2,
31
+ );
32
+ const ratio =
33
+ previousRatio != null ? Math.max(baseRatio, previousRatio) : baseRatio;
34
+ return Math.min(ratio, 0.999);
35
+ }
@@ -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
+ * @noformat
8
+ * @oncall react_native
9
+ * @generated SignedSource<<89a26e72bdd126e3feb0abc9b3186d33>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/lib/bundleToString.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 {Bundle, BundleMetadata} from 'metro-runtime/src/modules/types';
19
+ /**
20
+ * Serializes a bundle into a plain JS bundle.
21
+ */
22
+ declare function bundleToString(bundle: Bundle): {
23
+ readonly code: string;
24
+ readonly metadata: BundleMetadata;
25
+ };
26
+ export default bundleToString;
@@ -0,0 +1,40 @@
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<<461f7a7b3b3d99d1f1e7eeeeb5125686>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/lib/contextModule.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
+ ContextMode,
20
+ RequireContextParams,
21
+ } from '../ModuleGraph/worker/collectDependencies';
22
+
23
+ export type RequireContext = Readonly<{
24
+ recursive: boolean;
25
+ filter: RegExp;
26
+ /** Mode for resolving dynamic dependencies. Defaults to `sync` */
27
+ mode: ContextMode;
28
+ /** Absolute path of the directory to search in */
29
+ from: string;
30
+ }>;
31
+ /** Given a fully qualified require context, return a virtual file path that ensures uniqueness between paths with different contexts. */
32
+ export declare function deriveAbsolutePathFromContext(
33
+ from: string,
34
+ context: RequireContextParams,
35
+ ): string;
36
+ /** Match a file against a require context. */
37
+ export declare function fileMatchesContext(
38
+ testPath: string,
39
+ context: RequireContext,
40
+ ): boolean;
@@ -9,11 +9,7 @@ var _crypto = _interopRequireDefault(require("crypto"));
9
9
  var _nullthrows = _interopRequireDefault(require("nullthrows"));
10
10
  var _path = _interopRequireDefault(require("path"));
11
11
  function _interopRequireDefault(e) {
12
- return e && e.__esModule
13
- ? e
14
- : {
15
- default: e,
16
- };
12
+ return e && e.__esModule ? e : { default: e };
17
13
  }
18
14
  function toHash(value) {
19
15
  return _crypto.default.createHash("sha1").update(value).digest("hex");
@@ -0,0 +1,32 @@
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<<bcc2ba36a2edccb791b6d380f2c27ebe>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/lib/contextModuleTemplates.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 {ContextMode} from '../ModuleGraph/worker/collectDependencies';
19
+ /**
20
+ * Generate a context module as a virtual file string.
21
+ *
22
+ * @prop {ContextMode} mode indicates how the modules should be loaded.
23
+ * @prop {string} modulePath virtual file path for the virtual module. Example: `require.context('./src')` -> `'/path/to/project/src'`.
24
+ * @prop {string[]} files list of absolute file paths that must be exported from the context module. Example: `['/path/to/project/src/index.js']`.
25
+ *
26
+ * @returns a string representing a context module (virtual file contents).
27
+ */
28
+ export declare function getContextModuleTemplate(
29
+ mode: ContextMode,
30
+ modulePath: string,
31
+ files: string[],
32
+ ): string;
@@ -14,10 +14,7 @@ function _interopRequireWildcard(e, t) {
14
14
  if (!t && e && e.__esModule) return e;
15
15
  var o,
16
16
  i,
17
- f = {
18
- __proto__: null,
19
- default: e,
20
- };
17
+ f = { __proto__: null, default: e };
21
18
  if (null === e || ("object" != typeof e && "function" != typeof e))
22
19
  return f;
23
20
  if ((o = t ? n : r)) {
@@ -0,0 +1,19 @@
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<<a9f443cc44465917ebb470200e0f80d2>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/lib/countLines.js
13
+ * To regenerate, run:
14
+ * js1 build metro-ts-defs (internal) OR
15
+ * yarn run build-ts-defs (OSS)
16
+ */
17
+
18
+ declare function countLines(string: string): number;
19
+ export default countLines;
@@ -0,0 +1,50 @@
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<<cc8010b98646f8cfd713ae5505f71ef1>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/lib/createWebsocketServer.js
13
+ * To regenerate, run:
14
+ * js1 build metro-ts-defs (internal) OR
15
+ * yarn run build-ts-defs (OSS)
16
+ */
17
+
18
+ import ws from 'ws';
19
+
20
+ type WebsocketServiceInterface<T> = {
21
+ readonly onClientConnect: (
22
+ url: string,
23
+ sendFn: (data: string) => void,
24
+ ) => Promise<null | undefined | T>;
25
+ readonly onClientDisconnect?: (client: T) => unknown;
26
+ readonly onClientError?: (client: T, e: Error) => unknown;
27
+ readonly onClientMessage?: (
28
+ client: T,
29
+ message: string | Buffer | ArrayBuffer | Array<Buffer>,
30
+ sendFn: (data: string) => void,
31
+ ) => unknown;
32
+ };
33
+ type HMROptions<TClient> = {
34
+ websocketServer: WebsocketServiceInterface<TClient>;
35
+ };
36
+ /**
37
+ * Returns a WebSocketServer to be attached to an existing HTTP instance. It forwards
38
+ * the received events on the given "websocketServer" parameter. It must be an
39
+ * object with the following fields:
40
+ *
41
+ * - onClientConnect
42
+ * - onClientError
43
+ * - onClientMessage
44
+ * - onClientDisconnect
45
+ */
46
+
47
+ declare function createWebsocketServer<TClient>(
48
+ $$PARAM_0$$: HMROptions<TClient>,
49
+ ): ws.Server;
50
+ export default createWebsocketServer;
@@ -7,11 +7,7 @@ exports.default = createWebsocketServer;
7
7
  var _timers = require("timers");
8
8
  var _ws = _interopRequireDefault(require("ws"));
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 KEEP_ALIVE_INTERVAL_MS = 20000;
17
13
  function createWebsocketServer({ websocketServer }) {
@@ -0,0 +1,22 @@
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<<900f968546b7cc3e463e2de9d1f06200>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/lib/debounceAsyncQueue.js
13
+ * To regenerate, run:
14
+ * js1 build metro-ts-defs (internal) OR
15
+ * yarn run build-ts-defs (OSS)
16
+ */
17
+
18
+ declare function debounceAsyncQueue<T>(
19
+ fn: () => Promise<T>,
20
+ delay: number,
21
+ ): () => Promise<T>;
22
+ export default debounceAsyncQueue;
@@ -0,0 +1,30 @@
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<<0c18118765a7730747fbadfd10e5d8f6>>
9
+ *
10
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
11
+ * Original file: packages/metro/src/lib/formatBundlingError.js
12
+ * To regenerate, run:
13
+ * js1 build metro-ts-defs (internal) OR
14
+ * yarn run build-ts-defs (OSS)
15
+ */
16
+
17
+ import type {FormattedError} from 'metro-runtime/src/modules/types';
18
+
19
+ export type CustomError = Error & {
20
+ readonly type?: string;
21
+ filename?: string;
22
+ lineNumber?: number;
23
+ errors?: Array<{
24
+ description: string;
25
+ filename: string;
26
+ lineNumber: number;
27
+ }>;
28
+ };
29
+ declare function formatBundlingError(error: CustomError): FormattedError;
30
+ export default formatBundlingError;
@@ -20,11 +20,7 @@ var _fs = _interopRequireDefault(require("fs"));
20
20
  var _metroCore = require("metro-core");
21
21
  var _serializeError = _interopRequireDefault(require("serialize-error"));
22
22
  function _interopRequireDefault(e) {
23
- return e && e.__esModule
24
- ? e
25
- : {
26
- default: e,
27
- };
23
+ return e && e.__esModule ? e : { default: e };
28
24
  }
29
25
  function formatBundlingError(error) {
30
26
  if (error instanceof _metroCore.AmbiguousModuleResolutionError) {
@@ -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
+ * @noformat
8
+ * @oncall react_native
9
+ * @generated SignedSource<<72fd04e53dc895f1305e10043f986edc>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/lib/getAppendScripts.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 {Module} from '../DeltaBundler';
19
+
20
+ type Options<T extends number | string> = Readonly<{
21
+ asyncRequireModulePath: string;
22
+ createModuleId: ($$PARAM_0$$: string) => T;
23
+ getRunModuleStatement: (moduleId: T, globalPrefix: string) => string;
24
+ globalPrefix: string;
25
+ inlineSourceMap: null | undefined | boolean;
26
+ runBeforeMainModule: ReadonlyArray<string>;
27
+ runModule: boolean;
28
+ shouldAddToIgnoreList: ($$PARAM_0$$: Module) => boolean;
29
+ sourceMapUrl: null | undefined | string;
30
+ sourceUrl: null | undefined | string;
31
+ getSourceUrl: null | undefined | (($$PARAM_0$$: Module) => string);
32
+ }>;
33
+ declare function getAppendScripts<T extends number | string>(
34
+ entryPoint: string,
35
+ modules: ReadonlyArray<Module>,
36
+ options: Options<T>,
37
+ ): ReadonlyArray<Module>;
38
+ export default getAppendScripts;
@@ -12,11 +12,7 @@ var _CountingSet = _interopRequireDefault(require("./CountingSet"));
12
12
  var _countLines = _interopRequireDefault(require("./countLines"));
13
13
  var _nullthrows = _interopRequireDefault(require("nullthrows"));
14
14
  function _interopRequireDefault(e) {
15
- return e && e.__esModule
16
- ? e
17
- : {
18
- default: e,
19
- };
15
+ return e && e.__esModule ? e : { default: e };
20
16
  }
21
17
  function getAppendScripts(entryPoint, modules, options) {
22
18
  const output = [];
@@ -18,7 +18,7 @@ import CountingSet from './CountingSet';
18
18
  import countLines from './countLines';
19
19
  import nullthrows from 'nullthrows';
20
20
 
21
- type Options<T: number | string> = Readonly<{
21
+ type Options<T extends number | string> = Readonly<{
22
22
  asyncRequireModulePath: string,
23
23
  createModuleId: string => T,
24
24
  getRunModuleStatement: (moduleId: T, globalPrefix: string) => string,
@@ -33,7 +33,7 @@ type Options<T: number | string> = Readonly<{
33
33
  ...
34
34
  }>;
35
35
 
36
- export default function getAppendScripts<T: number | string>(
36
+ export default function getAppendScripts<T extends number | string>(
37
37
  entryPoint: string,
38
38
  modules: ReadonlyArray<Module<>>,
39
39
  options: Options<T>,
@@ -0,0 +1,32 @@
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<<cb5003f203d26e24459419b5f28e4f06>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/lib/getGraphId.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 {TransformInputOptions} from '../DeltaBundler/types';
19
+ import type {ResolverInputOptions} from '../shared/types';
20
+
21
+ export declare type GraphId = string;
22
+ declare function getGraphId(
23
+ entryFile: string,
24
+ options: TransformInputOptions,
25
+ $$PARAM_2$$: Readonly<{
26
+ shallow: boolean;
27
+ lazy: boolean;
28
+ unstable_allowRequireContext: boolean;
29
+ resolverOptions: ResolverInputOptions;
30
+ }>,
31
+ ): GraphId;
32
+ export default getGraphId;
@@ -8,11 +8,7 @@ var _canonicalize = _interopRequireDefault(
8
8
  require("metro-core/private/canonicalize"),
9
9
  );
10
10
  function _interopRequireDefault(e) {
11
- return e && e.__esModule
12
- ? e
13
- : {
14
- default: e,
15
- };
11
+ return e && e.__esModule ? e : { default: e };
16
12
  }
17
13
  function getGraphId(
18
14
  entryFile,
@@ -0,0 +1,25 @@
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<<c57e62398654e4f07fea53d28c279b20>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/lib/getPreludeCode.js
13
+ * To regenerate, run:
14
+ * js1 build metro-ts-defs (internal) OR
15
+ * yarn run build-ts-defs (OSS)
16
+ */
17
+
18
+ declare function getPreludeCode($$PARAM_0$$: {
19
+ readonly extraVars?: {[$$Key$$: string]: unknown};
20
+ readonly isDev: boolean;
21
+ readonly globalPrefix: string;
22
+ readonly requireCycleIgnorePatterns: ReadonlyArray<RegExp>;
23
+ readonly unstable_forceFullRefreshPatterns: ReadonlyArray<RegExp>;
24
+ }): string;
25
+ export default getPreludeCode;
@@ -0,0 +1,31 @@
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<<a85e80b79c0295e96824c17436edfcca>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/lib/getPrependedScripts.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 {Module, default as DeltaBundler} from '../DeltaBundler';
20
+ import type {TransformInputOptions} from '../DeltaBundler/types';
21
+ import type {ResolverInputOptions} from '../shared/types';
22
+ import type {ConfigT} from 'metro-config';
23
+
24
+ declare function getPrependedScripts(
25
+ config: ConfigT,
26
+ options: Omit<TransformInputOptions, 'type'>,
27
+ resolverOptions: ResolverInputOptions,
28
+ bundler: Bundler,
29
+ deltaBundler: DeltaBundler,
30
+ ): Promise<ReadonlyArray<Module>>;
31
+ export default getPrependedScripts;
@@ -19,10 +19,7 @@ function _interopRequireWildcard(e, t) {
19
19
  if (!t && e && e.__esModule) return e;
20
20
  var o,
21
21
  i,
22
- f = {
23
- __proto__: null,
24
- default: e,
25
- };
22
+ f = { __proto__: null, default: e };
26
23
  if (null === e || ("object" != typeof e && "function" != typeof e))
27
24
  return f;
28
25
  if ((o = t ? n : r)) {
@@ -42,11 +39,7 @@ function _interopRequireWildcard(e, t) {
42
39
  })(e, t);
43
40
  }
44
41
  function _interopRequireDefault(e) {
45
- return e && e.__esModule
46
- ? e
47
- : {
48
- default: e,
49
- };
42
+ return e && e.__esModule ? e : { default: e };
50
43
  }
51
44
  async function getPrependedScripts(
52
45
  config,
@@ -0,0 +1,22 @@
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<<f1d42fcf747b4fa7641e50b8d4ddc424>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/lib/isResolvedDependency.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 {Dependency, ResolvedDependency} from '../DeltaBundler/types';
19
+
20
+ export declare function isResolvedDependency(
21
+ dep: Dependency,
22
+ ): dep is ResolvedDependency;
@@ -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
+ * @noformat
8
+ * @generated SignedSource<<95cf7d414507e2035210d06882d858b3>>
9
+ *
10
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
11
+ * Original file: packages/metro/src/lib/logToConsole.js
12
+ * To regenerate, run:
13
+ * js1 build metro-ts-defs (internal) OR
14
+ * yarn run build-ts-defs (OSS)
15
+ */
16
+
17
+ import type {Terminal} from 'metro-core';
18
+
19
+ declare const $$EXPORT_DEFAULT_DECLARATION$$: (
20
+ terminal: Terminal,
21
+ level: string,
22
+ ...data: Array<unknown>
23
+ ) => void;
24
+ declare type $$EXPORT_DEFAULT_DECLARATION$$ =
25
+ typeof $$EXPORT_DEFAULT_DECLARATION$$;
26
+ export default $$EXPORT_DEFAULT_DECLARATION$$;