metro 0.83.2 → 0.83.4

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 (192) hide show
  1. package/package.json +25 -23
  2. package/src/Assets.js +50 -30
  3. package/src/Assets.js.flow +26 -15
  4. package/src/Bundler/util.js +33 -22
  5. package/src/Bundler/util.js.flow +2 -2
  6. package/src/Bundler.js +5 -1
  7. package/src/Bundler.js.flow +1 -1
  8. package/src/DeltaBundler/DeltaCalculator.js +9 -5
  9. package/src/DeltaBundler/DeltaCalculator.js.flow +8 -8
  10. package/src/DeltaBundler/Graph.js +21 -17
  11. package/src/DeltaBundler/Graph.js.flow +30 -30
  12. package/src/DeltaBundler/Serializers/baseJSBundle.js +5 -1
  13. package/src/DeltaBundler/Serializers/baseJSBundle.js.flow +1 -1
  14. package/src/DeltaBundler/Serializers/getAllFiles.js.flow +2 -2
  15. package/src/DeltaBundler/Serializers/getAssets.js +5 -1
  16. package/src/DeltaBundler/Serializers/getAssets.js.flow +2 -2
  17. package/src/DeltaBundler/Serializers/getExplodedSourceMap.js.flow +2 -2
  18. package/src/DeltaBundler/Serializers/getRamBundleInfo.js +5 -1
  19. package/src/DeltaBundler/Serializers/getRamBundleInfo.js.flow +8 -8
  20. package/src/DeltaBundler/Serializers/helpers/js.js +33 -22
  21. package/src/DeltaBundler/Serializers/helpers/js.js.flow +6 -6
  22. package/src/DeltaBundler/Serializers/helpers/processModules.js.flow +3 -3
  23. package/src/DeltaBundler/Serializers/hmrJSBundle.js +33 -22
  24. package/src/DeltaBundler/Serializers/hmrJSBundle.js.flow +5 -5
  25. package/src/DeltaBundler/Serializers/sourceMapGenerator.js +5 -1
  26. package/src/DeltaBundler/Serializers/sourceMapGenerator.js.flow +6 -6
  27. package/src/DeltaBundler/Serializers/sourceMapObject.js.flow +2 -2
  28. package/src/DeltaBundler/Serializers/sourceMapString.js.flow +2 -2
  29. package/src/DeltaBundler/Transformer.js +5 -1
  30. package/src/DeltaBundler/Transformer.js.flow +3 -3
  31. package/src/DeltaBundler/Worker.flow.js +5 -1
  32. package/src/DeltaBundler/Worker.flow.js.flow +1 -1
  33. package/src/DeltaBundler/WorkerFarm.js +1 -1
  34. package/src/DeltaBundler/WorkerFarm.js.flow +26 -13
  35. package/src/DeltaBundler/buildSubgraph.js +9 -5
  36. package/src/DeltaBundler/buildSubgraph.js.flow +8 -8
  37. package/src/DeltaBundler/getTransformCacheKey.js +5 -1
  38. package/src/DeltaBundler/types.js +5 -1
  39. package/src/DeltaBundler/types.js.flow +36 -34
  40. package/src/DeltaBundler.js +5 -1
  41. package/src/DeltaBundler.js.flow +2 -2
  42. package/src/HmrServer.js +42 -30
  43. package/src/HmrServer.js.flow +17 -12
  44. package/src/IncrementalBundler.js +37 -22
  45. package/src/IncrementalBundler.js.flow +13 -9
  46. package/src/ModuleGraph/worker/JsFileWrapping.js +33 -22
  47. package/src/ModuleGraph/worker/JsFileWrapping.js.flow +10 -5
  48. package/src/ModuleGraph/worker/collectDependencies.js +33 -22
  49. package/src/ModuleGraph/worker/collectDependencies.js.flow +27 -21
  50. package/src/ModuleGraph/worker/generateImportNames.js +5 -1
  51. package/src/ModuleGraph/worker/generateImportNames.js.flow +4 -2
  52. package/src/ModuleGraph/worker/importLocationsPlugin.js.flow +7 -3
  53. package/src/Server/MultipartResponse.js +5 -1
  54. package/src/Server/MultipartResponse.js.flow +1 -1
  55. package/src/Server/symbolicate.js.flow +4 -4
  56. package/src/Server.js +112 -40
  57. package/src/Server.js.flow +110 -47
  58. package/src/cli/parseKeyValueParamArray.js.flow +1 -1
  59. package/src/cli-utils.js +5 -1
  60. package/src/cli-utils.js.flow +2 -2
  61. package/src/commands/build.js +5 -1
  62. package/src/commands/build.js.flow +11 -10
  63. package/src/commands/dependencies.js +5 -1
  64. package/src/commands/dependencies.js.flow +8 -4
  65. package/src/commands/serve.js +2 -0
  66. package/src/commands/serve.js.flow +14 -9
  67. package/src/index.flow.js +38 -27
  68. package/src/index.flow.js.flow +25 -20
  69. package/src/integration_tests/basic_bundle/AssetRegistry.js.flow +1 -1
  70. package/src/integration_tests/basic_bundle/ErrorBundle.js.flow +1 -1
  71. package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-import.js +5 -1
  72. package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-import.js.flow +1 -1
  73. package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-multi-line-import-with-escapes.js.flow +1 -1
  74. package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-multi-line-import.js.flow +1 -1
  75. package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-require-with-embedded-comment.js.flow +1 -1
  76. package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-require.js.flow +1 -1
  77. package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-specifier-with-escapes.js.flow +1 -1
  78. package/src/integration_tests/basic_bundle/build-errors/inline-requires-cannot-resolve-import.js +5 -1
  79. package/src/integration_tests/basic_bundle/build-errors/inline-requires-cannot-resolve-import.js.flow +1 -1
  80. package/src/integration_tests/basic_bundle/build-errors/inline-requires-cannot-resolve-require.js.flow +1 -1
  81. package/src/integration_tests/basic_bundle/import-export/index.js +33 -22
  82. package/src/integration_tests/basic_bundle/import-export/index.js.flow +3 -3
  83. package/src/integration_tests/basic_bundle/import-export/utils.js.flow +2 -2
  84. package/src/integration_tests/basic_bundle/loadBundleAsyncForTest.js.flow +1 -1
  85. package/src/integration_tests/basic_bundle/optional-dependencies/index.js.flow +1 -1
  86. package/src/integration_tests/basic_bundle/require-context/conflict.js.flow +1 -1
  87. package/src/integration_tests/basic_bundle/require-context/empty.js.flow +1 -1
  88. package/src/integration_tests/basic_bundle/require-context/matching.js.flow +1 -1
  89. package/src/integration_tests/basic_bundle/require-context/mode-eager.js.flow +1 -1
  90. package/src/integration_tests/basic_bundle/require-context/mode-lazy-once.js.flow +1 -1
  91. package/src/integration_tests/basic_bundle/require-context/mode-lazy.js.flow +1 -1
  92. package/src/integration_tests/basic_bundle/require-context/mode-sync.js.flow +2 -2
  93. package/src/integration_tests/basic_bundle/require-context/utils.js.flow +1 -1
  94. package/src/integration_tests/basic_bundle/require-resolveWeak/import-and-resolveWeak.js.flow +1 -1
  95. package/src/integration_tests/basic_bundle/require-resolveWeak/multiple.js.flow +1 -1
  96. package/src/integration_tests/basic_bundle/require-resolveWeak/never-required.js.flow +1 -1
  97. package/src/integration_tests/basic_bundle/require-resolveWeak/require-and-resolveWeak.js.flow +1 -1
  98. package/src/integration_tests/execBundle.js +5 -1
  99. package/src/integration_tests/execBundle.js.flow +1 -1
  100. package/src/lib/BatchProcessor.js +10 -3
  101. package/src/lib/BatchProcessor.js.flow +10 -7
  102. package/src/lib/CountingSet.js.flow +4 -4
  103. package/src/lib/JsonReporter.js +5 -3
  104. package/src/lib/JsonReporter.js.flow +19 -17
  105. package/src/lib/RamBundleParser.js +5 -1
  106. package/src/lib/RamBundleParser.js.flow +1 -1
  107. package/src/lib/TerminalReporter.js +39 -28
  108. package/src/lib/TerminalReporter.js.flow +15 -15
  109. package/src/lib/contextModule.js +5 -1
  110. package/src/lib/contextModule.js.flow +1 -1
  111. package/src/lib/contextModuleTemplates.js +28 -21
  112. package/src/lib/countLines.js +4 -3
  113. package/src/lib/countLines.js.flow +3 -4
  114. package/src/lib/createWebsocketServer.js +14 -3
  115. package/src/lib/createWebsocketServer.js.flow +16 -9
  116. package/src/lib/debounceAsyncQueue.js.flow +1 -1
  117. package/src/lib/formatBundlingError.js +5 -1
  118. package/src/lib/formatBundlingError.js.flow +1 -1
  119. package/src/lib/getAppendScripts.js +5 -1
  120. package/src/lib/getAppendScripts.js.flow +4 -4
  121. package/src/lib/getGraphId.js +5 -1
  122. package/src/lib/getGraphId.js.flow +1 -1
  123. package/src/lib/getPreludeCode.js +4 -0
  124. package/src/lib/getPreludeCode.js.flow +10 -3
  125. package/src/lib/getPrependedScripts.js +44 -23
  126. package/src/lib/getPrependedScripts.js.flow +10 -3
  127. package/src/lib/logToConsole.js +5 -1
  128. package/src/lib/logToConsole.js.flow +2 -2
  129. package/src/lib/parseBundleOptionsFromBundleRequestUrl.js +33 -22
  130. package/src/lib/parseCustomResolverOptions.js.flow +2 -2
  131. package/src/lib/parseCustomTransformOptions.js.flow +1 -1
  132. package/src/lib/parseJsonBody.js.flow +11 -1
  133. package/src/lib/pathUtils.js +28 -21
  134. package/src/lib/pathUtils.js.flow +1 -1
  135. package/src/lib/relativizeSourceMap.js +5 -1
  136. package/src/lib/reporting.js +5 -1
  137. package/src/lib/reporting.js.flow +4 -4
  138. package/src/lib/transformHelpers.js +16 -10
  139. package/src/lib/transformHelpers.js.flow +17 -15
  140. package/src/node-haste/DependencyGraph/ModuleResolution.js +56 -43
  141. package/src/node-haste/DependencyGraph/ModuleResolution.js.flow +35 -32
  142. package/src/node-haste/DependencyGraph/createFileMap.js +64 -39
  143. package/src/node-haste/DependencyGraph/createFileMap.js.flow +44 -18
  144. package/src/node-haste/DependencyGraph.js +45 -32
  145. package/src/node-haste/DependencyGraph.js.flow +35 -37
  146. package/src/node-haste/Package.js +5 -1
  147. package/src/node-haste/PackageCache.js +5 -1
  148. package/src/node-haste/lib/AssetPaths.js +7 -3
  149. package/src/node-haste/lib/AssetPaths.js.flow +4 -4
  150. package/src/node-haste/lib/parsePlatformFilePath.js +11 -7
  151. package/src/node-haste/lib/parsePlatformFilePath.js.flow +4 -4
  152. package/src/shared/output/RamBundle/as-assets.js +5 -1
  153. package/src/shared/output/RamBundle/as-assets.js.flow +6 -6
  154. package/src/shared/output/RamBundle/as-indexed-file.js +5 -1
  155. package/src/shared/output/RamBundle/as-indexed-file.js.flow +5 -5
  156. package/src/shared/output/RamBundle/buildSourcemapWithMetadata.js.flow +5 -5
  157. package/src/shared/output/RamBundle/util.js +5 -1
  158. package/src/shared/output/RamBundle/util.js.flow +5 -5
  159. package/src/shared/output/RamBundle/write-sourcemap.js +5 -1
  160. package/src/shared/output/RamBundle/write-sourcemap.js.flow +1 -1
  161. package/src/shared/output/RamBundle.js +5 -1
  162. package/src/shared/output/RamBundle.js.flow +1 -1
  163. package/src/shared/output/bundle.flow.js +5 -1
  164. package/src/shared/output/bundle.flow.js.flow +3 -3
  165. package/src/shared/output/meta.js +7 -3
  166. package/src/shared/output/meta.js.flow +1 -1
  167. package/src/shared/output/writeFile.js +13 -4
  168. package/src/shared/output/writeFile.js.flow +8 -2
  169. package/src/shared/types.js.flow +20 -5
  170. package/src/Asset.d.ts +0 -25
  171. package/src/Bundler.d.ts +0 -39
  172. package/src/DeltaBundler/Graph.d.ts +0 -40
  173. package/src/DeltaBundler/Serializers/getExplodedSourceMap.d.ts +0 -26
  174. package/src/DeltaBundler/Serializers/getRamBundleInfo.d.ts +0 -18
  175. package/src/DeltaBundler/Worker.d.ts +0 -45
  176. package/src/DeltaBundler/types.d.ts +0 -166
  177. package/src/DeltaBundler.d.ts +0 -58
  178. package/src/IncrementalBundler.d.ts +0 -98
  179. package/src/ModuleGraph/test-helpers.js +0 -75
  180. package/src/ModuleGraph/worker/collectDependencies.d.ts +0 -27
  181. package/src/Server/MultipartResponse.d.ts +0 -31
  182. package/src/Server/symbolicate.d.ts +0 -31
  183. package/src/Server.d.ts +0 -118
  184. package/src/index.d.ts +0 -193
  185. package/src/lib/CountingSet.d.ts +0 -48
  186. package/src/lib/TerminalReporter.d.ts +0 -27
  187. package/src/lib/contextModule.d.ts +0 -22
  188. package/src/lib/getGraphId.d.ts +0 -11
  189. package/src/lib/reporting.d.ts +0 -144
  190. package/src/node-haste/DependencyGraph.d.ts +0 -62
  191. package/src/shared/output/bundle.d.ts +0 -35
  192. package/src/shared/types.d.ts +0 -130
@@ -1,27 +0,0 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- * @format
8
- * @oncall react_native
9
- */
10
-
11
- export type ContextMode = 'sync' | 'eager' | 'lazy' | 'lazy-once';
12
-
13
- export interface ContextFilter {
14
- pattern: string;
15
- flags: string;
16
- }
17
-
18
- export interface RequireContextParams {
19
- /* Should search for files recursively. Optional, default `true` when `require.context` is used */
20
- readonly recursive: boolean;
21
- /* Filename filter pattern for use in `require.context`. Optional, default `.*` (any file) when `require.context` is used */
22
- readonly filter: Readonly<ContextFilter>;
23
- /** Mode for resolving dynamic dependencies. Defaults to `sync` */
24
- readonly mode: ContextMode;
25
- }
26
-
27
- export type DynamicRequiresBehavior = 'throwAtRuntime' | 'reject';
@@ -1,31 +0,0 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- * @format
8
- * @oncall react_native
9
- */
10
-
11
- import type {IncomingMessage, ServerResponse} from 'http';
12
-
13
- export type Data = string | Buffer | Uint8Array;
14
- export interface Headers {
15
- [name: string]: string | number;
16
- }
17
-
18
- export default class MultipartResponse {
19
- static wrapIfSupported(
20
- req: IncomingMessage,
21
- res: ServerResponse,
22
- ): MultipartResponse | ServerResponse;
23
- static serializeHeaders(headers: Headers): string;
24
- res: ServerResponse;
25
- headers: Headers;
26
- constructor(res: ServerResponse);
27
- writeChunk(headers: Headers | null, data?: Data, isLast?: boolean): void;
28
- writeHead(status: number, headers?: Headers): void;
29
- setHeader(name: string, value: string | number): void;
30
- end(data?: Data): void;
31
- }
@@ -1,31 +0,0 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- * @format
8
- * @oncall react_native
9
- */
10
-
11
- import type {ExplodedSourceMap} from '../DeltaBundler/Serializers/getExplodedSourceMap';
12
- import type {ConfigT} from 'metro-config';
13
-
14
- export type StackFrameInput = {
15
- readonly file: null | undefined | string;
16
- readonly lineNumber: null | undefined | number;
17
- readonly column: null | undefined | number;
18
- readonly methodName: null | undefined | string;
19
- };
20
- export type IntermediateStackFrame = Omit<
21
- StackFrameInput,
22
- keyof {collapse?: boolean}
23
- > & {collapse?: boolean};
24
- export type StackFrameOutput = Readonly<IntermediateStackFrame>;
25
- declare function symbolicate(
26
- stack: ReadonlyArray<StackFrameInput>,
27
- maps: Iterable<[string, ExplodedSourceMap]>,
28
- config: ConfigT,
29
- extraData: unknown,
30
- ): Promise<ReadonlyArray<StackFrameOutput>>;
31
- export default symbolicate;
package/src/Server.d.ts DELETED
@@ -1,118 +0,0 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- * @format
8
- * @oncall react_native
9
- */
10
-
11
- import type {AssetData} from './Asset';
12
- import type {RamBundleInfo} from './DeltaBundler/Serializers/getRamBundleInfo';
13
- import type {GraphId} from './lib/getGraphId';
14
- import type MultipartResponse from './Server/MultipartResponse';
15
- import type {
16
- BuildOptions,
17
- BundleOptions,
18
- GraphOptions,
19
- SplitBundleOptions,
20
- } from './shared/types';
21
- import type {IncomingMessage, ServerResponse} from 'http';
22
- import type {
23
- CustomTransformOptions,
24
- TransformProfile,
25
- } from 'metro-babel-transformer';
26
- import type {ConfigT, RootPerfLogger} from 'metro-config';
27
- import type {CustomResolverOptions} from 'metro-resolver';
28
-
29
- import IncrementalBundler, {RevisionId} from './IncrementalBundler';
30
-
31
- export interface SegmentLoadData {
32
- [index: number]: [number[], number | null];
33
- }
34
-
35
- export interface BundleMetadata {
36
- hash: string;
37
- otaBuildNumber: string | null;
38
- mobileConfigs: string[];
39
- segmentHashes: string[];
40
- segmentLoadData: SegmentLoadData;
41
- }
42
-
43
- export interface ProcessStartContext extends SplitBundleOptions {
44
- readonly buildNumber: number;
45
- readonly bundleOptions: BundleOptions;
46
- readonly graphId: GraphId;
47
- readonly graphOptions: GraphOptions;
48
- readonly mres: MultipartResponse | ServerResponse;
49
- readonly req: IncomingMessage;
50
- readonly revisionId?: RevisionId | null;
51
- readonly bundlePerfLogger: RootPerfLogger;
52
- }
53
-
54
- export interface ProcessDeleteContext {
55
- readonly graphId: GraphId;
56
- readonly req: IncomingMessage;
57
- readonly res: ServerResponse;
58
- }
59
-
60
- export interface ProcessEndContext<T> extends ProcessStartContext {
61
- readonly result: T;
62
- }
63
-
64
- export type ServerOptions = Readonly<{
65
- hasReducedPerformance?: boolean;
66
- onBundleBuilt?: (bundlePath: string) => void;
67
- watch?: boolean;
68
- }>;
69
-
70
- export interface DefaultGraphOptions {
71
- customResolverOptions: CustomResolverOptions;
72
- customTransformOptions: CustomTransformOptions;
73
- dev: boolean;
74
- minify: boolean;
75
- runtimeBytecodeVersion?: number;
76
- unstable_transformProfile: TransformProfile;
77
- }
78
-
79
- export interface DefaultBundleOptions extends DefaultGraphOptions {
80
- excludeSource: false;
81
- inlineSourceMap: false;
82
- modulesOnly: false;
83
- onProgress: null;
84
- runModule: true;
85
- shallow: false;
86
- sourceMapUrl: null;
87
- sourceUrl: null;
88
- }
89
-
90
- export default class Server {
91
- static DEFAULT_GRAPH_OPTIONS: DefaultGraphOptions;
92
- static DEFAULT_BUNDLE_OPTIONS: BundleOptions;
93
- constructor(config: ConfigT, options?: ServerOptions);
94
- end(): void;
95
- getBundler(): IncrementalBundler;
96
- getCreateModuleId(): (path: string) => number;
97
- build(
98
- bundleOptions: BundleOptions,
99
- buildOptions?: BuildOptions,
100
- ): Promise<{
101
- code: string;
102
- map: string;
103
- assets?: ReadonlyArray<AssetData>;
104
- }>;
105
- getRamBundleInfo(options: BundleOptions): Promise<RamBundleInfo>;
106
- getAssets(options: BundleOptions): Promise<ReadonlyArray<AssetData>>;
107
- getOrderedDependencyPaths(options: {
108
- readonly dev: boolean;
109
- readonly entryFile: string;
110
- readonly minify: boolean;
111
- readonly platform: string;
112
- }): Promise<string[]>;
113
- processRequest(
114
- IncomingMessage: IncomingMessage,
115
- ServerResponse: ServerResponse,
116
- next: (e: Error | null) => unknown,
117
- ): void;
118
- }
package/src/index.d.ts DELETED
@@ -1,193 +0,0 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- * @format
8
- * @oncall react_native
9
- */
10
-
11
- export * from './Asset';
12
- export * from './DeltaBundler/types';
13
- export * from './ModuleGraph/worker/collectDependencies';
14
- export * from './Server';
15
- export * from './lib/reporting';
16
-
17
- import type {AssetData} from './Asset';
18
- import type {ReadOnlyGraph} from './DeltaBundler/types';
19
- import type {ServerOptions, default as MetroServer} from './Server';
20
- import type {BuildOptions, OutputOptions, RequestOptions} from './shared/types';
21
- import type {HandleFunction} from 'connect';
22
- import type {EventEmitter} from 'events';
23
- import type {IncomingMessage, Server as HttpServer} from 'http';
24
- import type {Server as HttpsServer} from 'https';
25
- import type {CustomTransformOptions} from 'metro-babel-transformer';
26
- import type {
27
- ConfigT,
28
- InputConfigT,
29
- MetroConfig,
30
- Middleware,
31
- } from 'metro-config';
32
- import type {Duplex} from 'stream';
33
- import type Yargs from 'yargs';
34
-
35
- import {TerminalReporter} from './lib/TerminalReporter';
36
- import {loadConfig, mergeConfig, resolveConfig} from 'metro-config';
37
- import {Terminal} from 'metro-core';
38
-
39
- export {HttpServer, HttpsServer};
40
- export {loadConfig, mergeConfig, resolveConfig, Terminal, TerminalReporter};
41
-
42
- interface MetroMiddleWare {
43
- attachHmrServer: (httpServer: HttpServer | HttpsServer) => void;
44
- end: () => void;
45
- metroServer: MetroServer;
46
- middleware: Middleware;
47
- }
48
-
49
- export interface RunMetroOptions extends ServerOptions {
50
- waitForBundler?: boolean;
51
- }
52
-
53
- interface WebsocketServer extends EventEmitter {
54
- handleUpgrade<T = WebsocketServer>(
55
- request: IncomingMessage,
56
- socket: Duplex,
57
- upgradeHead: Buffer,
58
- callback: (client: T, request: IncomingMessage) => void,
59
- ): void;
60
- }
61
-
62
- export interface RunServerOptions {
63
- hasReducedPerformance?: boolean;
64
- host?: string;
65
- onError?: (error: Error & {code?: string}) => void;
66
- onReady?: (server: HttpServer | HttpsServer) => void;
67
- secureServerOptions?: Record<string, unknown>;
68
-
69
- /** @deprecated since version 0.61 */
70
- secure?: boolean;
71
-
72
- /** @deprecated since version 0.61 */
73
- secureCert?: string;
74
-
75
- /** @deprecated since version 0.61 */
76
- secureKey?: string;
77
-
78
- unstable_extraMiddleware?: ReadonlyArray<HandleFunction>;
79
- waitForBundler?: boolean;
80
- watch?: boolean;
81
- websocketEndpoints?: {
82
- [path: string]: WebsocketServer;
83
- };
84
- }
85
-
86
- export interface RunServerResult {
87
- httpServer: HttpServer | HttpsServer;
88
- }
89
-
90
- export interface RunBuildOptions {
91
- entry: string;
92
- dev?: boolean;
93
- out?: string;
94
- onBegin?: () => void;
95
- onComplete?: () => void;
96
- onProgress?: (transformedFileCount: number, totalFileCount: number) => void;
97
- minify?: boolean;
98
- output?: {
99
- build: (
100
- server: MetroServer,
101
- requestOptions: RequestOptions,
102
- buildOptions?: BuildOptions,
103
- ) => Promise<{
104
- code: string;
105
- map: string;
106
- assets?: ReadonlyArray<AssetData>;
107
- }>;
108
- save: (
109
- entry: {
110
- code: string;
111
- map: string;
112
- },
113
- options: OutputOptions,
114
- postSave: (...args: string[]) => void,
115
- ) => Promise<unknown>;
116
- };
117
- platform?: string;
118
- sourceMap?: boolean;
119
- sourceMapUrl?: string;
120
- }
121
-
122
- interface BuildGraphOptions {
123
- entries: ReadonlyArray<string>;
124
- customTransformOptions?: CustomTransformOptions;
125
- dev?: boolean;
126
- minify?: boolean;
127
- onProgress?: (transformedFileCount: number, totalFileCount: number) => void;
128
- platform?: string;
129
- type?: 'module' | 'script';
130
- }
131
-
132
- export {MetroConfig};
133
-
134
- export function runMetro(
135
- config: InputConfigT,
136
- options?: RunMetroOptions,
137
- ): Promise<MetroServer>;
138
-
139
- export function createConnectMiddleware(
140
- config: ConfigT,
141
- options?: RunMetroOptions,
142
- ): Promise<MetroMiddleWare>;
143
-
144
- export function runServer(
145
- config: ConfigT,
146
- options: RunServerOptions,
147
- ): Promise<RunServerResult>;
148
-
149
- export function runBuild(
150
- config: ConfigT,
151
- options: RunBuildOptions,
152
- ): Promise<void>;
153
-
154
- export function buildGraph(
155
- config: ConfigT,
156
- options: BuildGraphOptions,
157
- ): Promise<ReadOnlyGraph<void>>;
158
-
159
- type BuildCommandOptions = Record<string, unknown> | null;
160
- type ServeCommandOptions = Record<string, unknown> | null;
161
-
162
- interface AttachMetroCLIOptions {
163
- build?: BuildCommandOptions;
164
- serve?: ServeCommandOptions;
165
- dependencies?: unknown;
166
- }
167
-
168
- export function attachMetroCli(
169
- yargs: Yargs.Argv,
170
- options?: AttachMetroCLIOptions,
171
- ): Yargs.Argv;
172
-
173
- /**
174
- * Backwards-compatibility with CommonJS consumers using interopRequireDefault.
175
- * Do not add to this list.
176
- *
177
- * @deprecated Default import from 'metro' is deprecated, use named exports.
178
- */
179
- declare const $$EXPORT_DEFAULT_DECLARATION$$: {
180
- attachMetroCli: typeof attachMetroCli;
181
- runServer: typeof runServer;
182
- Terminal: typeof Terminal;
183
- TerminalReporter: typeof TerminalReporter;
184
- loadConfig: typeof loadConfig;
185
- mergeConfig: typeof mergeConfig;
186
- resolveConfig: typeof resolveConfig;
187
- createConnectMiddleware: typeof createConnectMiddleware;
188
- runBuild: typeof runBuild;
189
- buildGraph: typeof buildGraph;
190
- };
191
- declare type $$EXPORT_DEFAULT_DECLARATION$$ =
192
- typeof $$EXPORT_DEFAULT_DECLARATION$$;
193
- export default $$EXPORT_DEFAULT_DECLARATION$$;
@@ -1,48 +0,0 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- * @format
8
- * @oncall react_native
9
- */
10
-
11
- export interface ReadOnlyCountingSet<T> extends Iterable<T> {
12
- has(item: T): boolean;
13
- [Symbol.iterator](): Iterator<T>;
14
- readonly size: number;
15
- count(item: T): number;
16
- forEach<ThisT>(
17
- callbackFn: (
18
- this: ThisT,
19
- value: T,
20
- key: T,
21
- set: ReadOnlyCountingSet<T>,
22
- ) => unknown,
23
- thisArg: ThisT,
24
- ): void;
25
- }
26
-
27
- export default class CountingSet<T> implements ReadOnlyCountingSet<T> {
28
- constructor(items?: Iterable<T>);
29
- get size(): number;
30
- has(item: T): boolean;
31
- add(item: T): void;
32
- delete(item: T): void;
33
- keys(): Iterator<T>;
34
- values(): Iterator<T>;
35
- [Symbol.iterator](): Iterator<T>;
36
- count(item: T): number;
37
- clear(): void;
38
- forEach<ThisT>(
39
- callbackFn: (
40
- this: ThisT,
41
- value: T,
42
- key: T,
43
- set: ReadOnlyCountingSet<T>,
44
- ) => unknown,
45
- thisArg: ThisT,
46
- ): void;
47
- toJSON(): unknown;
48
- }
@@ -1,27 +0,0 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- * @format
8
- * @oncall react_native
9
- */
10
-
11
- import {ReportableEvent} from './reporting';
12
- import {Terminal} from 'metro-core';
13
-
14
- export type TerminalReportableEvent =
15
- | ReportableEvent
16
- | {
17
- buildID: string;
18
- type: 'bundle_transform_progressed_throttled';
19
- transformedFileCount: number;
20
- totalFileCount: number;
21
- };
22
-
23
- export class TerminalReporter {
24
- constructor(terminal: Terminal);
25
- readonly terminal: Terminal;
26
- update(event: TerminalReportableEvent): void;
27
- }
@@ -1,22 +0,0 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- * @format
8
- * @oncall react_native
9
- */
10
-
11
- import type {ContextMode} from '../ModuleGraph/worker/collectDependencies';
12
-
13
- export interface RequireContext {
14
- /* Should search for files recursively. Optional, default `true` when `require.context` is used */
15
- readonly recursive: boolean;
16
- /* Filename filter pattern for use in `require.context`. Optional, default `.*` (any file) when `require.context` is used */
17
- readonly filter: RegExp;
18
- /** Mode for resolving dynamic dependencies. Defaults to `sync` */
19
- readonly mode: ContextMode;
20
- /** Absolute path of the directory to search in */
21
- readonly from: string;
22
- }
@@ -1,11 +0,0 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- * @format
8
- * @oncall react_native
9
- */
10
-
11
- export type GraphId = string;
@@ -1,144 +0,0 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- * @format
8
- * @oncall react_native
9
- */
10
-
11
- import type {HealthCheckResult, WatcherStatus} from 'metro-file-map';
12
-
13
- export interface BundleDetails {
14
- bundleType: string;
15
- dev: boolean;
16
- entryFile: string;
17
- minify: boolean;
18
- platform?: string;
19
- runtimeBytecodeVersion?: number;
20
- }
21
-
22
- /**
23
- * A tagged union of all the actions that may happen and we may want to
24
- * report to the tool user.
25
- */
26
- export type ReportableEvent =
27
- | {
28
- port: number;
29
- hasReducedPerformance: boolean;
30
- type: 'initialize_started';
31
- }
32
- | {
33
- type: 'initialize_failed';
34
- port: number;
35
- error: Error;
36
- }
37
- | {
38
- buildID: string;
39
- type: 'bundle_build_done';
40
- }
41
- | {
42
- buildID: string;
43
- type: 'bundle_build_failed';
44
- }
45
- | {
46
- buildID: string;
47
- bundleDetails: BundleDetails;
48
- type: 'bundle_build_started';
49
- }
50
- | {
51
- error: Error;
52
- type: 'bundling_error';
53
- }
54
- | {
55
- type: 'dep_graph_loading';
56
- hasReducedPerformance: boolean;
57
- }
58
- | {type: 'dep_graph_loaded'}
59
- | {
60
- buildID: string;
61
- type: 'bundle_transform_progressed';
62
- transformedFileCount: number;
63
- totalFileCount: number;
64
- }
65
- | {
66
- type: 'cache_read_error';
67
- error: Error;
68
- }
69
- | {
70
- type: 'cache_write_error';
71
- error: Error;
72
- }
73
- | {type: 'transform_cache_reset'}
74
- | {
75
- type: 'worker_stdout_chunk';
76
- chunk: string;
77
- }
78
- | {
79
- type: 'worker_stderr_chunk';
80
- chunk: string;
81
- }
82
- | {
83
- type: 'hmr_client_error';
84
- error: Error;
85
- }
86
- | {
87
- type: 'client_log';
88
- level:
89
- | 'trace'
90
- | 'info'
91
- | 'warn'
92
- | 'log'
93
- | 'group'
94
- | 'groupCollapsed'
95
- | 'groupEnd'
96
- | 'debug';
97
- data: unknown[];
98
- }
99
- | {
100
- type: 'server_listening';
101
- port: number;
102
- address: string;
103
- family: string;
104
- }
105
- | {
106
- type: 'transformer_load_started';
107
- }
108
- | {
109
- type: 'transformer_load_done';
110
- }
111
- | {
112
- type: 'transformer_load_failed';
113
- error: Error;
114
- }
115
- | {
116
- type: 'watcher_health_check_result';
117
- result: HealthCheckResult;
118
- }
119
- | {
120
- type: 'watcher_status';
121
- status: WatcherStatus;
122
- };
123
-
124
- /**
125
- * Code across the application takes a reporter as an option and calls the
126
- * update whenever one of the ReportableEvent happens. Code does not directly
127
- * write to the standard output, because a build would be:
128
- *
129
- * 1. ad-hoc, embedded into another tool, in which case we do not want to
130
- * pollute that tool's own output. The tool is free to present the
131
- * warnings/progress we generate any way they want, by specifing a custom
132
- * reporter.
133
- * 2. run as a background process from another tool, in which case we want
134
- * to expose updates in a way that is easily machine-readable, for example
135
- * a JSON-stream. We don't want to pollute it with textual messages.
136
- *
137
- * We centralize terminal reporting into a single place because we want the
138
- * output to be robust and consistent. The most common reporter is
139
- * TerminalReporter, that should be the only place in the application should
140
- * access the `terminal` module (nor the `console`).
141
- */
142
- export interface Reporter {
143
- update: (event: ReportableEvent) => void;
144
- }