metro 0.84.1 → 0.84.3
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.
- package/package.json +15 -15
- package/src/Assets.d.ts +90 -0
- package/src/Bundler/util.d.ts +34 -0
- package/src/Bundler/util.js.flow +3 -3
- package/src/Bundler.d.ts +45 -0
- package/src/DeltaBundler/DeltaCalculator.d.ts +68 -0
- package/src/DeltaBundler/DeltaCalculator.js +55 -46
- package/src/DeltaBundler/DeltaCalculator.js.flow +72 -61
- package/src/DeltaBundler/Graph.d.ts +174 -0
- package/src/DeltaBundler/Serializers/baseJSBundle.d.ts +27 -0
- package/src/DeltaBundler/Serializers/getAllFiles.d.ts +29 -0
- package/src/DeltaBundler/Serializers/getAssets.d.ts +32 -0
- package/src/DeltaBundler/Serializers/getExplodedSourceMap.d.ts +33 -0
- package/src/DeltaBundler/Serializers/getRamBundleInfo.d.ts +55 -0
- package/src/DeltaBundler/Serializers/helpers/getInlineSourceMappingURL.d.ts +19 -0
- package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.d.ts +40 -0
- package/src/DeltaBundler/Serializers/helpers/getTransitiveDependencies.d.ts +24 -0
- package/src/DeltaBundler/Serializers/helpers/js.d.ts +37 -0
- package/src/DeltaBundler/Serializers/helpers/processModules.d.ts +32 -0
- package/src/DeltaBundler/Serializers/hmrJSBundle.d.ts +37 -0
- package/src/DeltaBundler/Serializers/sourceMapGenerator.d.ts +36 -0
- package/src/DeltaBundler/Serializers/sourceMapObject.d.ts +30 -0
- package/src/DeltaBundler/Serializers/sourceMapString.d.ts +29 -0
- package/src/DeltaBundler/Transformer.d.ts +45 -0
- package/src/DeltaBundler/Worker.d.ts +44 -0
- package/src/DeltaBundler/WorkerFarm.d.ts +77 -0
- package/src/DeltaBundler/buildSubgraph.d.ts +37 -0
- package/src/DeltaBundler/getTransformCacheKey.d.ts +25 -0
- package/src/DeltaBundler/getTransformCacheKey.js +3 -1
- package/src/DeltaBundler/getTransformCacheKey.js.flow +7 -2
- package/src/DeltaBundler/mergeDeltas.d.ts +24 -0
- package/src/DeltaBundler/types.d.ts +170 -0
- package/src/DeltaBundler.d.ts +67 -0
- package/src/HmrServer.d.ts +98 -0
- package/src/HmrServer.js +7 -0
- package/src/HmrServer.js.flow +15 -5
- package/src/IncrementalBundler/GraphNotFoundError.d.ts +24 -0
- package/src/IncrementalBundler/ResourceNotFoundError.d.ts +22 -0
- package/src/IncrementalBundler/RevisionNotFoundError.d.ts +24 -0
- package/src/IncrementalBundler.d.ts +103 -0
- package/src/ModuleGraph/worker/JsFileWrapping.d.ts +36 -0
- package/src/ModuleGraph/worker/collectDependencies.d.ts +138 -0
- package/src/ModuleGraph/worker/generateImportNames.d.ts +26 -0
- package/src/ModuleGraph/worker/importLocationsPlugin.d.ts +33 -0
- package/src/Server/MultipartResponse.d.ts +37 -0
- package/src/Server/symbolicate.d.ts +38 -0
- package/src/Server.d.ts +278 -0
- package/src/cli/parseKeyValueParamArray.d.ts +21 -0
- package/src/cli-utils.d.ts +26 -0
- package/src/commands/build.d.ts +23 -0
- package/src/commands/dependencies.d.ts +23 -0
- package/src/commands/serve.d.ts +23 -0
- package/src/index.d.ts +206 -0
- package/src/index.flow.js.flow +21 -2
- package/src/lib/BatchProcessor.d.ts +61 -0
- package/src/lib/CountingSet.d.ts +55 -0
- package/src/lib/JsonReporter.d.ts +44 -0
- package/src/lib/JsonReporter.js.flow +2 -2
- package/src/lib/RamBundleParser.d.ts +36 -0
- package/src/lib/TerminalReporter.d.ts +125 -0
- package/src/lib/bundleProgressUtils.d.ts +33 -0
- package/src/lib/bundleToString.d.ts +26 -0
- package/src/lib/contextModule.d.ts +40 -0
- package/src/lib/contextModuleTemplates.d.ts +32 -0
- package/src/lib/countLines.d.ts +19 -0
- package/src/lib/createWebsocketServer.d.ts +50 -0
- package/src/lib/debounceAsyncQueue.d.ts +22 -0
- package/src/lib/formatBundlingError.d.ts +30 -0
- package/src/lib/getAppendScripts.d.ts +38 -0
- package/src/lib/getAppendScripts.js.flow +2 -2
- package/src/lib/getGraphId.d.ts +32 -0
- package/src/lib/getPreludeCode.d.ts +25 -0
- package/src/lib/getPrependedScripts.d.ts +31 -0
- package/src/lib/isResolvedDependency.d.ts +22 -0
- package/src/lib/logToConsole.d.ts +26 -0
- package/src/lib/parseBundleOptionsFromBundleRequestUrl.d.ts +24 -0
- package/src/lib/parseCustomResolverOptions.d.ts +23 -0
- package/src/lib/parseCustomTransformOptions.d.ts +23 -0
- package/src/lib/parseJsonBody.d.ts +34 -0
- package/src/lib/pathUtils.d.ts +21 -0
- package/src/lib/relativizeSourceMap.d.ts +24 -0
- package/src/lib/reporting.d.ts +135 -0
- package/src/lib/splitBundleOptions.d.ts +23 -0
- package/src/lib/transformHelpers.d.ts +42 -0
- package/src/node-haste/DependencyGraph/ModuleResolution.d.ts +120 -0
- package/src/node-haste/DependencyGraph/ModuleResolution.js +4 -22
- package/src/node-haste/DependencyGraph/ModuleResolution.js.flow +10 -59
- package/src/node-haste/DependencyGraph/createFileMap.d.ts +36 -0
- package/src/node-haste/DependencyGraph/createFileMap.js +1 -1
- package/src/node-haste/DependencyGraph/createFileMap.js.flow +4 -2
- package/src/node-haste/DependencyGraph.d.ts +90 -0
- package/src/node-haste/DependencyGraph.js +22 -11
- package/src/node-haste/DependencyGraph.js.flow +24 -13
- package/src/node-haste/PackageCache.d.ts +37 -0
- package/src/node-haste/PackageCache.js +65 -54
- package/src/node-haste/PackageCache.js.flow +103 -79
- package/src/node-haste/lib/AssetPaths.d.ts +36 -0
- package/src/node-haste/lib/parsePlatformFilePath.d.ts +32 -0
- package/src/shared/output/RamBundle/as-assets.d.ts +32 -0
- package/src/shared/output/RamBundle/as-indexed-file.d.ts +45 -0
- package/src/shared/output/RamBundle/buildSourcemapWithMetadata.d.ts +30 -0
- package/src/shared/output/RamBundle/magic-number.d.ts +21 -0
- package/src/shared/output/RamBundle/util.d.ts +48 -0
- package/src/shared/output/RamBundle/write-sourcemap.d.ts +23 -0
- package/src/shared/output/RamBundle.d.ts +33 -0
- package/src/shared/output/bundle.d.ts +34 -0
- package/src/shared/output/meta.d.ts +22 -0
- package/src/shared/output/unbundle.d.ts +18 -0
- package/src/shared/output/writeFile.d.ts +23 -0
- package/src/shared/types.d.ts +152 -0
- package/src/node-haste/Package.js +0 -28
- package/src/node-haste/Package.js.flow +0 -39
package/src/HmrServer.js.flow
CHANGED
|
@@ -66,7 +66,7 @@ function send(sendFns: Array<(string) => void>, message: HmrMessage): void {
|
|
|
66
66
|
* getting connected, disconnected or having errors (through the
|
|
67
67
|
* `onClientConnect`, `onClientDisconnect` and `onClientError` methods).
|
|
68
68
|
*/
|
|
69
|
-
export default class HmrServer<TClient
|
|
69
|
+
export default class HmrServer<TClient extends Client> {
|
|
70
70
|
_config: ConfigT;
|
|
71
71
|
_bundler: IncrementalBundler;
|
|
72
72
|
_createModuleId: (path: string) => number;
|
|
@@ -181,7 +181,8 @@ export default class HmrServer<TClient: Client> {
|
|
|
181
181
|
this._clientGroups.set(id, clientGroup);
|
|
182
182
|
|
|
183
183
|
let latestChangeEvent: ?{
|
|
184
|
-
logger: ?RootPerfLogger,
|
|
184
|
+
+logger: ?RootPerfLogger,
|
|
185
|
+
+changeId: string,
|
|
185
186
|
} = null;
|
|
186
187
|
|
|
187
188
|
const debounceCallHandleFileChange = debounceAsyncQueue(async () => {
|
|
@@ -240,6 +241,10 @@ export default class HmrServer<TClient: Client> {
|
|
|
240
241
|
case 'log-opt-in':
|
|
241
242
|
client.optedIntoHMR = true;
|
|
242
243
|
break;
|
|
244
|
+
case 'heartbeat':
|
|
245
|
+
debug('Heartbeat received');
|
|
246
|
+
sendFn(String(message));
|
|
247
|
+
break;
|
|
243
248
|
default:
|
|
244
249
|
break;
|
|
245
250
|
}
|
|
@@ -273,7 +278,8 @@ export default class HmrServer<TClient: Client> {
|
|
|
273
278
|
group: ClientGroup,
|
|
274
279
|
options: {isInitialUpdate: boolean},
|
|
275
280
|
changeEvent: ?{
|
|
276
|
-
logger: ?RootPerfLogger,
|
|
281
|
+
+logger: ?RootPerfLogger,
|
|
282
|
+
+changeId?: string,
|
|
277
283
|
},
|
|
278
284
|
): Promise<void> {
|
|
279
285
|
const logger = !options.isInitialUpdate ? changeEvent?.logger : null;
|
|
@@ -308,7 +314,10 @@ export default class HmrServer<TClient: Client> {
|
|
|
308
314
|
|
|
309
315
|
const message = await this._prepareMessage(group, options, changeEvent);
|
|
310
316
|
send(sendFns, message);
|
|
311
|
-
send(sendFns, {
|
|
317
|
+
send(sendFns, {
|
|
318
|
+
type: 'update-done',
|
|
319
|
+
body: {changeId: changeEvent?.changeId},
|
|
320
|
+
});
|
|
312
321
|
|
|
313
322
|
log({
|
|
314
323
|
...createActionEndEntry(processingHmrChange),
|
|
@@ -328,7 +337,8 @@ export default class HmrServer<TClient: Client> {
|
|
|
328
337
|
group: ClientGroup,
|
|
329
338
|
options: {isInitialUpdate: boolean},
|
|
330
339
|
changeEvent: ?{
|
|
331
|
-
logger: ?RootPerfLogger,
|
|
340
|
+
+logger: ?RootPerfLogger,
|
|
341
|
+
+changeId?: string,
|
|
332
342
|
},
|
|
333
343
|
): Promise<HmrUpdateMessage | HmrErrorMessage> {
|
|
334
344
|
const logger = !options.isInitialUpdate ? changeEvent?.logger : null;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @noformat
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
* @generated SignedSource<<850ba6867e140fb0973cd13d0fd1bc60>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/IncrementalBundler/GraphNotFoundError.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 {GraphId} from '../lib/getGraphId';
|
|
19
|
+
|
|
20
|
+
declare class GraphNotFoundError extends Error {
|
|
21
|
+
graphId: GraphId;
|
|
22
|
+
constructor(graphId: GraphId);
|
|
23
|
+
}
|
|
24
|
+
export default GraphNotFoundError;
|
|
@@ -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<<6a9d75bc74b654362c3563ec8babda0b>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/IncrementalBundler/ResourceNotFoundError.js
|
|
13
|
+
* To regenerate, run:
|
|
14
|
+
* js1 build metro-ts-defs (internal) OR
|
|
15
|
+
* yarn run build-ts-defs (OSS)
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
declare class ResourceNotFoundError extends Error {
|
|
19
|
+
resourcePath: string;
|
|
20
|
+
constructor(resourcePath: string);
|
|
21
|
+
}
|
|
22
|
+
export default ResourceNotFoundError;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @noformat
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
* @generated SignedSource<<2c2d4a1a2d357eb73806a68bba897795>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/IncrementalBundler/RevisionNotFoundError.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 {RevisionId} from '../IncrementalBundler';
|
|
19
|
+
|
|
20
|
+
declare class RevisionNotFoundError extends Error {
|
|
21
|
+
revisionId: RevisionId;
|
|
22
|
+
constructor(revisionId: RevisionId);
|
|
23
|
+
}
|
|
24
|
+
export default RevisionNotFoundError;
|
|
@@ -0,0 +1,103 @@
|
|
|
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<<0ec72971869a882d97b381e3f1baa922>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/IncrementalBundler.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 {DeltaResult, Graph, Module} from './DeltaBundler';
|
|
19
|
+
import type {
|
|
20
|
+
Options as DeltaBundlerOptions,
|
|
21
|
+
ReadOnlyDependencies,
|
|
22
|
+
TransformInputOptions,
|
|
23
|
+
} from './DeltaBundler/types';
|
|
24
|
+
import type {GraphId} from './lib/getGraphId';
|
|
25
|
+
import type {ResolverInputOptions} from './shared/types';
|
|
26
|
+
import type {ConfigT} from 'metro-config';
|
|
27
|
+
|
|
28
|
+
import Bundler from './Bundler';
|
|
29
|
+
import DeltaBundler from './DeltaBundler';
|
|
30
|
+
|
|
31
|
+
export declare type RevisionId = string;
|
|
32
|
+
export type OutputGraph = Graph;
|
|
33
|
+
type OtherOptions = Readonly<{
|
|
34
|
+
onProgress: DeltaBundlerOptions['onProgress'];
|
|
35
|
+
shallow: boolean;
|
|
36
|
+
lazy: boolean;
|
|
37
|
+
}>;
|
|
38
|
+
export type GraphRevision = {
|
|
39
|
+
readonly id: RevisionId;
|
|
40
|
+
readonly date: Date;
|
|
41
|
+
readonly graphId: GraphId;
|
|
42
|
+
readonly graph: OutputGraph;
|
|
43
|
+
readonly prepend: ReadonlyArray<Module>;
|
|
44
|
+
};
|
|
45
|
+
export type IncrementalBundlerOptions = Readonly<{
|
|
46
|
+
hasReducedPerformance?: boolean;
|
|
47
|
+
watch?: boolean;
|
|
48
|
+
}>;
|
|
49
|
+
declare class IncrementalBundler {
|
|
50
|
+
_config: ConfigT;
|
|
51
|
+
_bundler: Bundler;
|
|
52
|
+
_deltaBundler: DeltaBundler;
|
|
53
|
+
_revisionsById: Map<RevisionId, Promise<GraphRevision>>;
|
|
54
|
+
_revisionsByGraphId: Map<GraphId, Promise<GraphRevision>>;
|
|
55
|
+
static revisionIdFromString: (str: string) => RevisionId;
|
|
56
|
+
constructor(config: ConfigT, options?: IncrementalBundlerOptions);
|
|
57
|
+
end(): Promise<void>;
|
|
58
|
+
getBundler(): Bundler;
|
|
59
|
+
getDeltaBundler(): DeltaBundler;
|
|
60
|
+
getRevision(
|
|
61
|
+
revisionId: RevisionId,
|
|
62
|
+
): null | undefined | Promise<GraphRevision>;
|
|
63
|
+
getRevisionByGraphId(
|
|
64
|
+
graphId: GraphId,
|
|
65
|
+
): null | undefined | Promise<GraphRevision>;
|
|
66
|
+
buildGraphForEntries(
|
|
67
|
+
entryFiles: ReadonlyArray<string>,
|
|
68
|
+
transformOptions: TransformInputOptions,
|
|
69
|
+
resolverOptions: ResolverInputOptions,
|
|
70
|
+
otherOptions?: OtherOptions,
|
|
71
|
+
): Promise<OutputGraph>;
|
|
72
|
+
getDependencies(
|
|
73
|
+
entryFiles: ReadonlyArray<string>,
|
|
74
|
+
transformOptions: TransformInputOptions,
|
|
75
|
+
resolverOptions: ResolverInputOptions,
|
|
76
|
+
otherOptions?: OtherOptions,
|
|
77
|
+
): Promise<ReadOnlyDependencies>;
|
|
78
|
+
buildGraph(
|
|
79
|
+
entryFile: string,
|
|
80
|
+
transformOptions: TransformInputOptions,
|
|
81
|
+
resolverOptions: ResolverInputOptions,
|
|
82
|
+
otherOptions?: OtherOptions,
|
|
83
|
+
): Promise<{
|
|
84
|
+
readonly graph: OutputGraph;
|
|
85
|
+
readonly prepend: ReadonlyArray<Module>;
|
|
86
|
+
}>;
|
|
87
|
+
initializeGraph(
|
|
88
|
+
entryFile: string,
|
|
89
|
+
transformOptions: TransformInputOptions,
|
|
90
|
+
resolverOptions: ResolverInputOptions,
|
|
91
|
+
otherOptions?: OtherOptions,
|
|
92
|
+
): Promise<{delta: DeltaResult; revision: GraphRevision}>;
|
|
93
|
+
updateGraph(
|
|
94
|
+
revision: GraphRevision,
|
|
95
|
+
reset: boolean,
|
|
96
|
+
): Promise<{delta: DeltaResult; revision: GraphRevision}>;
|
|
97
|
+
endGraph(graphId: GraphId): Promise<void>;
|
|
98
|
+
_getAbsoluteEntryFiles(
|
|
99
|
+
entryFiles: ReadonlyArray<string>,
|
|
100
|
+
): Promise<ReadonlyArray<string>>;
|
|
101
|
+
ready(): Promise<void>;
|
|
102
|
+
}
|
|
103
|
+
export default IncrementalBundler;
|
|
@@ -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};
|
|
@@ -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
|
+
}
|
|
@@ -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;
|
|
@@ -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;
|
|
@@ -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;
|