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
@@ -0,0 +1,36 @@
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<<ef37054bf63dff008ccc8b58a2411597>>
9
+ *
10
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
11
+ * Original file: packages/metro/src/ModuleGraph/worker/JsFileWrapping.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 {File as BabelNodeFile} from '@babel/types';
18
+
19
+ declare const WRAP_NAME: '$$_REQUIRE';
20
+ declare function wrapModule(
21
+ fileAst: BabelNodeFile,
22
+ importDefaultName: string,
23
+ importAllName: string,
24
+ dependencyMapName: string,
25
+ globalPrefix: string,
26
+ skipRequireRename: boolean,
27
+ $$PARAM_6$$?: Readonly<{unstable_useStaticHermesModuleFactory?: boolean}>,
28
+ ): {ast: BabelNodeFile; requireName: string};
29
+ declare function wrapPolyfill(fileAst: BabelNodeFile): BabelNodeFile;
30
+ declare function jsonToCommonJS(source: string): string;
31
+ declare function wrapJson(
32
+ source: string,
33
+ globalPrefix: string,
34
+ unstable_useStaticHermesModuleFactory?: boolean,
35
+ ): string;
36
+ export {WRAP_NAME, wrapJson, jsonToCommonJS, wrapModule, wrapPolyfill};
@@ -20,10 +20,7 @@ function _interopRequireWildcard(e, t) {
20
20
  if (!t && e && e.__esModule) return e;
21
21
  var o,
22
22
  i,
23
- f = {
24
- __proto__: null,
25
- default: e,
26
- };
23
+ f = { __proto__: null, default: e };
27
24
  if (null === e || ("object" != typeof e && "function" != typeof e))
28
25
  return f;
29
26
  if ((o = t ? n : r)) {
@@ -43,11 +40,7 @@ function _interopRequireWildcard(e, t) {
43
40
  })(e, t);
44
41
  }
45
42
  function _interopRequireDefault(e) {
46
- return e && e.__esModule
47
- ? e
48
- : {
49
- default: e,
50
- };
43
+ return e && e.__esModule ? e : { default: e };
51
44
  }
52
45
  const WRAP_NAME = (exports.WRAP_NAME = "$$_REQUIRE");
53
46
  const IIFE_PARAM = _template.default.expression(
@@ -0,0 +1,138 @@
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<<ab2d1203f736c3032c6b9d15cc74680b>>
9
+ *
10
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
11
+ * Original file: packages/metro/src/ModuleGraph/worker/collectDependencies.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 {ReadonlySourceLocation} from '../../shared/types';
18
+ import type {NodePath} from '@babel/traverse';
19
+ import type {
20
+ CallExpression,
21
+ File as BabelNodeFile,
22
+ Identifier,
23
+ StringLiteral,
24
+ } from '@babel/types';
25
+ import type {
26
+ AllowOptionalDependencies,
27
+ AsyncDependencyType,
28
+ } from 'metro/private/DeltaBundler/types';
29
+
30
+ export type Dependency = Readonly<{data: DependencyData; name: string}>;
31
+ export type ContextMode = 'sync' | 'eager' | 'lazy' | 'lazy-once';
32
+ type ContextFilter = Readonly<{pattern: string; flags: string}>;
33
+ export type RequireContextParams = Readonly<{
34
+ recursive: boolean;
35
+ filter: Readonly<ContextFilter>;
36
+ /** Mode for resolving dynamic dependencies. Defaults to `sync` */
37
+ mode: ContextMode;
38
+ }>;
39
+ type DependencyData = Readonly<{
40
+ key: string;
41
+ asyncType: AsyncDependencyType | null;
42
+ isESMImport: boolean;
43
+ isOptional?: boolean;
44
+ locs: ReadonlyArray<ReadonlySourceLocation>;
45
+ /** Context for requiring a collection of modules. */
46
+ contextParams?: RequireContextParams;
47
+ }>;
48
+ export type MutableInternalDependency = Omit<
49
+ DependencyData,
50
+ keyof {locs: Array<ReadonlySourceLocation>; index: number; name: string}
51
+ > & {locs: Array<ReadonlySourceLocation>; index: number; name: string};
52
+ export type InternalDependency = Readonly<MutableInternalDependency>;
53
+ export type State = {
54
+ asyncRequireModulePathStringLiteral: null | undefined | StringLiteral;
55
+ dependencyCalls: Set<string>;
56
+ dependencyRegistry: DependencyRegistry;
57
+ dependencyTransformer: DependencyTransformer;
58
+ dynamicRequires: DynamicRequiresBehavior;
59
+ dependencyMapIdentifier: null | undefined | Identifier;
60
+ keepRequireNames: boolean;
61
+ allowOptionalDependencies: AllowOptionalDependencies;
62
+ /** Enable `require.context` statements which can be used to import multiple files in a directory. */
63
+ unstable_allowRequireContext: boolean;
64
+ unstable_isESMImportAtSource:
65
+ | null
66
+ | undefined
67
+ | (($$PARAM_0$$: ReadonlySourceLocation) => boolean);
68
+ };
69
+ export type Options = Readonly<{
70
+ asyncRequireModulePath: string;
71
+ dependencyMapName: null | undefined | string;
72
+ dynamicRequires: DynamicRequiresBehavior;
73
+ inlineableCalls: ReadonlyArray<string>;
74
+ keepRequireNames: boolean;
75
+ allowOptionalDependencies: AllowOptionalDependencies;
76
+ dependencyTransformer?: DependencyTransformer;
77
+ /** Enable `require.context` statements which can be used to import multiple files in a directory. */
78
+ unstable_allowRequireContext: boolean;
79
+ unstable_isESMImportAtSource?:
80
+ | null
81
+ | undefined
82
+ | (($$PARAM_0$$: ReadonlySourceLocation) => boolean);
83
+ }>;
84
+ export type CollectedDependencies = Readonly<{
85
+ ast: BabelNodeFile;
86
+ dependencyMapName: string;
87
+ dependencies: ReadonlyArray<Dependency>;
88
+ }>;
89
+ export interface DependencyTransformer {
90
+ transformSyncRequire(
91
+ path: NodePath<CallExpression>,
92
+ dependency: InternalDependency,
93
+ state: State,
94
+ ): void;
95
+ transformImportCall(
96
+ path: NodePath,
97
+ dependency: InternalDependency,
98
+ state: State,
99
+ ): void;
100
+ transformImportMaybeSyncCall(
101
+ path: NodePath,
102
+ dependency: InternalDependency,
103
+ state: State,
104
+ ): void;
105
+ transformPrefetch(
106
+ path: NodePath,
107
+ dependency: InternalDependency,
108
+ state: State,
109
+ ): void;
110
+ transformIllegalDynamicRequire(path: NodePath, state: State): void;
111
+ }
112
+ export type DynamicRequiresBehavior = 'throwAtRuntime' | 'reject';
113
+ /**
114
+ * Transform all the calls to `require()` and `import()` in a file into ID-
115
+ * independent code, and return the list of dependencies. For example, a call
116
+ * like `require('Foo')` could be transformed to `require(_depMap[3], 'Foo')`
117
+ * where `_depMap` is provided by the outer scope. As such, we don't need to
118
+ * know the actual module ID.
119
+ *
120
+ * The second argument is only provided for debugging purposes.
121
+ */
122
+ declare function collectDependencies(
123
+ ast: BabelNodeFile,
124
+ options: Options,
125
+ ): CollectedDependencies;
126
+ export default collectDependencies;
127
+ export type ImportQualifier = Readonly<{
128
+ name: string;
129
+ asyncType: AsyncDependencyType | null;
130
+ isESMImport: boolean;
131
+ optional: boolean;
132
+ contextParams?: RequireContextParams;
133
+ }>;
134
+ declare class DependencyRegistry {
135
+ _dependencies: Map<string, InternalDependency>;
136
+ registerDependency(qualifier: ImportQualifier): InternalDependency;
137
+ getDependencies(): Array<InternalDependency>;
138
+ }
@@ -20,10 +20,7 @@ function _interopRequireWildcard(e, t) {
20
20
  if (!t && e && e.__esModule) return e;
21
21
  var o,
22
22
  i,
23
- f = {
24
- __proto__: null,
25
- default: e,
26
- };
23
+ f = { __proto__: null, default: e };
27
24
  if (null === e || ("object" != typeof e && "function" != typeof e))
28
25
  return f;
29
26
  if ((o = t ? n : r)) {
@@ -43,11 +40,7 @@ function _interopRequireWildcard(e, t) {
43
40
  })(e, t);
44
41
  }
45
42
  function _interopRequireDefault(e) {
46
- return e && e.__esModule
47
- ? e
48
- : {
49
- default: e,
50
- };
43
+ return e && e.__esModule ? e : { default: e };
51
44
  }
52
45
  function collectDependencies(ast, options) {
53
46
  const visited = new WeakSet();
@@ -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<<9632d9ca461f1fd6aad9131d7afb5839>>
9
+ *
10
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
11
+ * Original file: packages/metro/src/ModuleGraph/worker/generateImportNames.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 {Node} from '@babel/types';
18
+ /**
19
+ * Select unused names for "metroImportDefault" and "metroImportAll", by
20
+ * calling "generateUid".
21
+ */
22
+ declare function generateImportNames(ast: Node): {
23
+ importAll: string;
24
+ importDefault: string;
25
+ };
26
+ export default generateImportNames;
@@ -7,11 +7,7 @@ exports.default = generateImportNames;
7
7
  var _traverse = _interopRequireDefault(require("@babel/traverse"));
8
8
  var _nullthrows = _interopRequireDefault(require("nullthrows"));
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
  function generateImportNames(ast) {
17
13
  let importDefault;
@@ -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<<644d25f2f9682a306271d052d09b1d2d>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/ModuleGraph/worker/importLocationsPlugin.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 {ReadonlySourceLocation} from '../../shared/types';
19
+ import type {PluginObj} from '@babel/core';
20
+ import type * as $$IMPORT_TYPEOF_1$$ from '@babel/types';
21
+ import type {MetroBabelFileMetadata} from 'metro-babel-transformer';
22
+
23
+ type Types = typeof $$IMPORT_TYPEOF_1$$;
24
+ type ImportDeclarationLocs = Set<string>;
25
+ type State = {
26
+ importDeclarationLocs: ImportDeclarationLocs;
27
+ file: {metadata?: MetroBabelFileMetadata};
28
+ };
29
+ declare function importLocationsPlugin($$PARAM_0$$: {
30
+ types: Types;
31
+ }): PluginObj<State>;
32
+ declare function locToKey(loc: ReadonlySourceLocation): string;
33
+ export {importLocationsPlugin, locToKey};
@@ -0,0 +1,37 @@
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<<355f5514464c4989f90a211782db41e7>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/Server/MultipartResponse.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, ServerResponse} from 'http';
19
+
20
+ type Data = string | Buffer | Uint8Array;
21
+ type Headers = {[$$Key$$: string]: string | number};
22
+ declare class MultipartResponse {
23
+ static wrapIfSupported(
24
+ req: IncomingMessage,
25
+ res: ServerResponse,
26
+ ): MultipartResponse | ServerResponse;
27
+ static serializeHeaders(headers: Headers): string;
28
+ res: ServerResponse;
29
+ headers: Headers;
30
+ constructor(res: ServerResponse);
31
+ writeChunk(headers: Headers | null, data?: Data, isLast?: boolean): void;
32
+ writeHead(status: number, headers?: Headers): void;
33
+ setHeader(name: string, value: string | number): void;
34
+ end(data?: Data): void;
35
+ once(name: string, fn: () => unknown): this;
36
+ }
37
+ export default MultipartResponse;
@@ -6,11 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _accepts = _interopRequireDefault(require("accepts"));
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
  const CRLF = "\r\n";
16
12
  const BOUNDARY = "3beqjf3apnqeu3h5jqorms4i";
@@ -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<<74bba01977b0b5887c4bb38eb8fc78ea>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/Server/symbolicate.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 {ExplodedSourceMap} from '../DeltaBundler/Serializers/getExplodedSourceMap';
19
+ import type {ConfigT} from 'metro-config';
20
+
21
+ export type StackFrameInput = {
22
+ readonly file: null | undefined | string;
23
+ readonly lineNumber: null | undefined | number;
24
+ readonly column: null | undefined | number;
25
+ readonly methodName: null | undefined | string;
26
+ };
27
+ export type IntermediateStackFrame = Omit<
28
+ StackFrameInput,
29
+ keyof {collapse?: boolean}
30
+ > & {collapse?: boolean};
31
+ export type StackFrameOutput = Readonly<IntermediateStackFrame>;
32
+ declare function symbolicate(
33
+ stack: ReadonlyArray<StackFrameInput>,
34
+ maps: Iterable<[string, ExplodedSourceMap]>,
35
+ config: ConfigT,
36
+ extraData: unknown,
37
+ ): Promise<ReadonlyArray<StackFrameOutput>>;
38
+ export default symbolicate;
@@ -0,0 +1,278 @@
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<<161e77301d04ce6cc254f1dbf15ef06b>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/Server.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 {AssetData} from './Assets';
19
+ import type {ExplodedSourceMap} from './DeltaBundler/Serializers/getExplodedSourceMap';
20
+ import type {RamBundleInfo} from './DeltaBundler/Serializers/getRamBundleInfo';
21
+ import type {
22
+ Module,
23
+ ReadOnlyDependencies,
24
+ ReadOnlyGraph,
25
+ TransformInputOptions,
26
+ } from './DeltaBundler/types';
27
+ import type {RevisionId} from './IncrementalBundler';
28
+ import type {GraphId} from './lib/getGraphId';
29
+ import type {Reporter} from './lib/reporting';
30
+ import type {
31
+ BuildOptions,
32
+ BundleOptions,
33
+ GraphOptions,
34
+ ResolverInputOptions,
35
+ SplitBundleOptions,
36
+ } from './shared/types';
37
+ import type {IncomingMessage} from 'connect';
38
+ import type {ServerResponse} from 'http';
39
+ import type {ConfigT, RootPerfLogger} from 'metro-config';
40
+ import type {
41
+ ActionLogEntryData,
42
+ ActionStartLogEntry,
43
+ } from 'metro-core/private/Logger';
44
+ import type {CustomResolverOptions} from 'metro-resolver/private/types';
45
+ import type {CustomTransformOptions} from 'metro-transform-worker';
46
+
47
+ import IncrementalBundler from './IncrementalBundler';
48
+ import MultipartResponse from './Server/MultipartResponse';
49
+ import {SourcePathsMode} from './shared/types';
50
+ import {Logger} from 'metro-core';
51
+
52
+ export type SegmentLoadData = {
53
+ [$$Key$$: number]: [Array<number>, null | undefined | number];
54
+ };
55
+ export type BundleMetadata = {
56
+ hash: string;
57
+ otaBuildNumber: null | undefined | string;
58
+ mobileConfigs: Array<string>;
59
+ segmentHashes: Array<string>;
60
+ segmentLoadData: SegmentLoadData;
61
+ };
62
+ type ProcessStartContext = Omit<
63
+ SplitBundleOptions,
64
+ keyof {
65
+ readonly buildNumber: number;
66
+ readonly bundleOptions: BundleOptions;
67
+ readonly graphId: GraphId;
68
+ readonly graphOptions: GraphOptions;
69
+ readonly mres: MultipartResponse | ServerResponse;
70
+ readonly req: IncomingMessage;
71
+ readonly revisionId?: null | undefined | RevisionId;
72
+ readonly bundlePerfLogger: RootPerfLogger;
73
+ readonly requestStartTimestamp: number;
74
+ }
75
+ > & {
76
+ readonly buildNumber: number;
77
+ readonly bundleOptions: BundleOptions;
78
+ readonly graphId: GraphId;
79
+ readonly graphOptions: GraphOptions;
80
+ readonly mres: MultipartResponse | ServerResponse;
81
+ readonly req: IncomingMessage;
82
+ readonly revisionId?: null | undefined | RevisionId;
83
+ readonly bundlePerfLogger: RootPerfLogger;
84
+ readonly requestStartTimestamp: number;
85
+ };
86
+ type ProcessDeleteContext = {
87
+ readonly graphId: GraphId;
88
+ readonly req: IncomingMessage;
89
+ readonly res: ServerResponse;
90
+ };
91
+ type ProcessEndContext<T> = Omit<
92
+ ProcessStartContext,
93
+ keyof {readonly result: T}
94
+ > & {readonly result: T};
95
+ export type ServerOptions = Readonly<{
96
+ hasReducedPerformance?: boolean;
97
+ onBundleBuilt?: (bundlePath: string) => void;
98
+ watch?: boolean;
99
+ }>;
100
+ type FetchTiming = {
101
+ graphId: GraphId;
102
+ startTime: number;
103
+ endTime: number | null;
104
+ isPrefetch: boolean;
105
+ };
106
+ declare class Server {
107
+ _bundler: IncrementalBundler;
108
+ _config: ConfigT;
109
+ _createModuleId: (path: string) => number;
110
+ _isEnded: boolean;
111
+ _logger: typeof Logger;
112
+ _nextBundleBuildNumber: number;
113
+ _platforms: Set<string>;
114
+ _reporter: Reporter;
115
+ _serverOptions: ServerOptions | void;
116
+ _allowedSuffixesForSourceRequests: ReadonlyArray<string>;
117
+ _sourceRequestRoutingMap: ReadonlyArray<
118
+ [pathnamePrefix: string, normalizedRootDir: string]
119
+ >;
120
+ _fetchTimings: Array<FetchTiming>;
121
+ _activeFetchCount: number;
122
+ constructor(config: ConfigT, options?: ServerOptions);
123
+ end(): void;
124
+ getBundler(): IncrementalBundler;
125
+ getCreateModuleId(): (path: string) => number;
126
+ _serializeGraph(
127
+ $$PARAM_0$$: Readonly<{
128
+ splitOptions: SplitBundleOptions;
129
+ prepend: ReadonlyArray<Module>;
130
+ graph: ReadOnlyGraph;
131
+ }>,
132
+ ): Promise<{code: string; map: string}>;
133
+ build(
134
+ bundleOptions: BundleOptions,
135
+ $$PARAM_1$$?: BuildOptions,
136
+ ): Promise<{code: string; map: string; assets?: ReadonlyArray<AssetData>}>;
137
+ getRamBundleInfo(options: BundleOptions): Promise<RamBundleInfo>;
138
+ getAssets(options: BundleOptions): Promise<ReadonlyArray<AssetData>>;
139
+ _getAssetsFromDependencies(
140
+ dependencies: ReadOnlyDependencies,
141
+ platform: null | undefined | string,
142
+ ): Promise<ReadonlyArray<AssetData>>;
143
+ getOrderedDependencyPaths(options: {
144
+ readonly dev: boolean;
145
+ readonly entryFile: string;
146
+ readonly minify: boolean;
147
+ readonly platform: null | undefined | string;
148
+ }): Promise<Array<string>>;
149
+ _rangeRequestMiddleware(
150
+ req: IncomingMessage,
151
+ res: ServerResponse,
152
+ data: string | Buffer,
153
+ assetPath: string,
154
+ ): Buffer | string;
155
+ _processSingleAssetRequest(
156
+ req: IncomingMessage,
157
+ res: ServerResponse,
158
+ ): Promise<void>;
159
+ processRequest: (
160
+ $$PARAM_0$$: IncomingMessage,
161
+ $$PARAM_1$$: ServerResponse,
162
+ $$PARAM_2$$: (e: null | undefined | Error) => void,
163
+ ) => void;
164
+ _parseOptions(url: string): BundleOptions;
165
+ _rewriteAndNormalizeUrl(requestUrl: string): string;
166
+ _processRequest(
167
+ req: IncomingMessage,
168
+ res: ServerResponse,
169
+ next: ($$PARAM_0$$: null | undefined | Error) => void,
170
+ ): Promise<void>;
171
+ _processSourceRequest(
172
+ relativeFilePathname: string,
173
+ rootDir: string,
174
+ res: ServerResponse,
175
+ ): Promise<void>;
176
+ _createRequestProcessor<T>($$PARAM_0$$: {
177
+ readonly bundleType: 'assets' | 'bundle' | 'map';
178
+ readonly createStartEntry: (
179
+ context: ProcessStartContext,
180
+ ) => ActionLogEntryData;
181
+ readonly createEndEntry: (
182
+ context: ProcessEndContext<T>,
183
+ ) => Partial<ActionStartLogEntry>;
184
+ readonly build: (context: ProcessStartContext) => Promise<T>;
185
+ readonly delete?: (context: ProcessDeleteContext) => Promise<void>;
186
+ readonly finish: (context: ProcessEndContext<T>) => void;
187
+ }): (
188
+ req: IncomingMessage,
189
+ res: ServerResponse,
190
+ bundleOptions: BundleOptions,
191
+ buildContext: Readonly<{
192
+ buildNumber: number;
193
+ bundlePerfLogger: RootPerfLogger;
194
+ }>,
195
+ ) => Promise<void>;
196
+ _processBundleRequest: (
197
+ req: IncomingMessage,
198
+ res: ServerResponse,
199
+ bundleOptions: BundleOptions,
200
+ buildContext: Readonly<{
201
+ buildNumber: number;
202
+ bundlePerfLogger: RootPerfLogger;
203
+ }>,
204
+ ) => Promise<void>;
205
+ _getSortedModules(graph: ReadOnlyGraph): ReadonlyArray<Module>;
206
+ _processSourceMapRequest: (
207
+ req: IncomingMessage,
208
+ res: ServerResponse,
209
+ bundleOptions: BundleOptions,
210
+ buildContext: Readonly<{
211
+ buildNumber: number;
212
+ bundlePerfLogger: RootPerfLogger;
213
+ }>,
214
+ ) => Promise<void>;
215
+ _processAssetsRequest: (
216
+ req: IncomingMessage,
217
+ res: ServerResponse,
218
+ bundleOptions: BundleOptions,
219
+ buildContext: Readonly<{
220
+ buildNumber: number;
221
+ bundlePerfLogger: RootPerfLogger;
222
+ }>,
223
+ ) => Promise<void>;
224
+ _symbolicate(req: IncomingMessage, res: ServerResponse): Promise<void>;
225
+ _explodedSourceMapForBundleOptions(
226
+ bundleOptions: BundleOptions,
227
+ ): Promise<ExplodedSourceMap>;
228
+ _resolveRelativePath(
229
+ filePath: string,
230
+ $$PARAM_1$$: Readonly<{
231
+ relativeTo: 'project' | 'server';
232
+ resolverOptions: ResolverInputOptions;
233
+ transformOptions: TransformInputOptions;
234
+ }>,
235
+ ): Promise<string>;
236
+ getNewBuildNumber(): number;
237
+ getPlatforms(): ReadonlyArray<string>;
238
+ getWatchFolders(): ReadonlyArray<string>;
239
+ static DEFAULT_GRAPH_OPTIONS: Readonly<{
240
+ customResolverOptions: CustomResolverOptions;
241
+ customTransformOptions: CustomTransformOptions;
242
+ dev: boolean;
243
+ minify: boolean;
244
+ unstable_transformProfile: 'default';
245
+ }>;
246
+ static DEFAULT_BUNDLE_OPTIONS: Omit<
247
+ typeof Server.DEFAULT_GRAPH_OPTIONS,
248
+ keyof {
249
+ excludeSource: false;
250
+ inlineSourceMap: false;
251
+ lazy: false;
252
+ modulesOnly: false;
253
+ onProgress: null;
254
+ runModule: true;
255
+ shallow: false;
256
+ sourceMapUrl: null;
257
+ sourceUrl: null;
258
+ sourcePaths: SourcePathsMode;
259
+ }
260
+ > & {
261
+ excludeSource: false;
262
+ inlineSourceMap: false;
263
+ lazy: false;
264
+ modulesOnly: false;
265
+ onProgress: null;
266
+ runModule: true;
267
+ shallow: false;
268
+ sourceMapUrl: null;
269
+ sourceUrl: null;
270
+ sourcePaths: SourcePathsMode;
271
+ };
272
+ _getServerRootDir(): string;
273
+ _getEntryPointAbsolutePath(entryFile: string): string;
274
+ ready(): Promise<void>;
275
+ _shouldAddModuleToIgnoreList(module: Module): boolean;
276
+ _getModuleSourceUrl(module: Module, mode: SourcePathsMode): string;
277
+ }
278
+ export default Server;