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/Server.d.ts
ADDED
|
@@ -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;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @noformat
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
* @generated SignedSource<<ece5a9f14463102dc54489fe7db6b3c8>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/cli/parseKeyValueParamArray.js
|
|
13
|
+
* To regenerate, run:
|
|
14
|
+
* js1 build metro-ts-defs (internal) OR
|
|
15
|
+
* yarn run build-ts-defs (OSS)
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
declare function coerceKeyValueArray(keyValueArray: ReadonlyArray<string>): {
|
|
19
|
+
[key: string]: string;
|
|
20
|
+
};
|
|
21
|
+
export default coerceKeyValueArray;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @noformat
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
* @generated SignedSource<<b5035a5d26a55e608aca030ee9ee6afa>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/cli-utils.js
|
|
13
|
+
* To regenerate, run:
|
|
14
|
+
* js1 build metro-ts-defs (internal) OR
|
|
15
|
+
* yarn run build-ts-defs (OSS)
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
export declare const watchFile: (
|
|
19
|
+
filename: string,
|
|
20
|
+
callback: () => unknown,
|
|
21
|
+
) => Promise<void>;
|
|
22
|
+
export declare type watchFile = typeof watchFile;
|
|
23
|
+
export declare const makeAsyncCommand: <T>(
|
|
24
|
+
command: (argv: T) => Promise<void>,
|
|
25
|
+
) => (argv: T) => void;
|
|
26
|
+
export declare type makeAsyncCommand = typeof makeAsyncCommand;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @noformat
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
* @generated SignedSource<<10c41709fa9779dd0e12ef411eaef8eb>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/commands/build.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 {CommandModule} from 'yargs';
|
|
19
|
+
|
|
20
|
+
declare const $$EXPORT_DEFAULT_DECLARATION$$: () => CommandModule;
|
|
21
|
+
declare type $$EXPORT_DEFAULT_DECLARATION$$ =
|
|
22
|
+
typeof $$EXPORT_DEFAULT_DECLARATION$$;
|
|
23
|
+
export default $$EXPORT_DEFAULT_DECLARATION$$;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @noformat
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
* @generated SignedSource<<a73d915901dde7a679972b78a1e08a3e>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/commands/dependencies.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 {CommandModule} from 'yargs';
|
|
19
|
+
|
|
20
|
+
declare const $$EXPORT_DEFAULT_DECLARATION$$: () => CommandModule;
|
|
21
|
+
declare type $$EXPORT_DEFAULT_DECLARATION$$ =
|
|
22
|
+
typeof $$EXPORT_DEFAULT_DECLARATION$$;
|
|
23
|
+
export default $$EXPORT_DEFAULT_DECLARATION$$;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @noformat
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
* @generated SignedSource<<367f11c0b6933f8c8c58718c7dd41e78>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/commands/serve.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 {CommandModule} from 'yargs';
|
|
19
|
+
|
|
20
|
+
declare const $$EXPORT_DEFAULT_DECLARATION$$: () => CommandModule;
|
|
21
|
+
declare type $$EXPORT_DEFAULT_DECLARATION$$ =
|
|
22
|
+
typeof $$EXPORT_DEFAULT_DECLARATION$$;
|
|
23
|
+
export default $$EXPORT_DEFAULT_DECLARATION$$;
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
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<<3c6460427c6760887187d6b16151c609>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/index.flow.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 {ReadOnlyGraph} from './DeltaBundler';
|
|
20
|
+
import type {ServerOptions} from './Server';
|
|
21
|
+
import type {BuildOptions, OutputOptions, RequestOptions} from './shared/types';
|
|
22
|
+
import type {HandleFunction} from 'connect';
|
|
23
|
+
import type {Server as HttpServer} from 'http';
|
|
24
|
+
import type {
|
|
25
|
+
Server as HttpsServer,
|
|
26
|
+
ServerOptions as HttpsServerOptions,
|
|
27
|
+
} from 'https';
|
|
28
|
+
import type {TransformProfile} from 'metro-babel-transformer';
|
|
29
|
+
import type {
|
|
30
|
+
ConfigT,
|
|
31
|
+
InputConfigT,
|
|
32
|
+
MetroConfig,
|
|
33
|
+
Middleware,
|
|
34
|
+
} from 'metro-config';
|
|
35
|
+
import type {CustomResolverOptions} from 'metro-resolver';
|
|
36
|
+
import type {CustomTransformOptions} from 'metro-transform-worker';
|
|
37
|
+
import type {Server as WebSocketServer} from 'ws';
|
|
38
|
+
import type $$IMPORT_TYPEOF_1$$ from 'yargs';
|
|
39
|
+
|
|
40
|
+
import JsonReporter from './lib/JsonReporter';
|
|
41
|
+
import TerminalReporter from './lib/TerminalReporter';
|
|
42
|
+
import MetroServer from './Server';
|
|
43
|
+
import {loadConfig, mergeConfig, resolveConfig} from 'metro-config';
|
|
44
|
+
import {Terminal} from 'metro-core';
|
|
45
|
+
|
|
46
|
+
type Yargs = typeof $$IMPORT_TYPEOF_1$$;
|
|
47
|
+
type MetroMiddleWare = {
|
|
48
|
+
attachHmrServer: (httpServer: HttpServer | HttpsServer) => void;
|
|
49
|
+
end: () => Promise<void>;
|
|
50
|
+
metroServer: MetroServer;
|
|
51
|
+
middleware: Middleware;
|
|
52
|
+
};
|
|
53
|
+
export type RunMetroOptions = Omit<
|
|
54
|
+
ServerOptions,
|
|
55
|
+
keyof {waitForBundler?: boolean}
|
|
56
|
+
> & {waitForBundler?: boolean};
|
|
57
|
+
export type RunServerOptions = Readonly<{
|
|
58
|
+
hasReducedPerformance?: boolean;
|
|
59
|
+
host?: string;
|
|
60
|
+
onError?: ($$PARAM_0$$: Error & {code?: string}) => void;
|
|
61
|
+
onReady?: (server: HttpServer | HttpsServer) => void;
|
|
62
|
+
onClose?: () => void;
|
|
63
|
+
secureServerOptions?: HttpsServerOptions;
|
|
64
|
+
secure?: boolean;
|
|
65
|
+
secureCert?: string;
|
|
66
|
+
secureKey?: string;
|
|
67
|
+
unstable_extraMiddleware?: ReadonlyArray<HandleFunction>;
|
|
68
|
+
waitForBundler?: boolean;
|
|
69
|
+
watch?: boolean;
|
|
70
|
+
websocketEndpoints?: Readonly<{[path: string]: WebSocketServer}>;
|
|
71
|
+
}>;
|
|
72
|
+
export type RunServerResult = {httpServer: HttpServer | HttpsServer};
|
|
73
|
+
type BuildGraphOptions = {
|
|
74
|
+
entries: ReadonlyArray<string>;
|
|
75
|
+
customTransformOptions?: CustomTransformOptions;
|
|
76
|
+
dev?: boolean;
|
|
77
|
+
minify?: boolean;
|
|
78
|
+
onProgress?: (transformedFileCount: number, totalFileCount: number) => void;
|
|
79
|
+
platform?: string;
|
|
80
|
+
type?: 'module' | 'script';
|
|
81
|
+
};
|
|
82
|
+
export type RunBuildOptions = {
|
|
83
|
+
entry: string;
|
|
84
|
+
assets?: boolean;
|
|
85
|
+
dev?: boolean;
|
|
86
|
+
out?: string;
|
|
87
|
+
bundleOut?: string;
|
|
88
|
+
sourceMapOut?: string;
|
|
89
|
+
onBegin?: () => void;
|
|
90
|
+
onComplete?: () => void;
|
|
91
|
+
onProgress?: (transformedFileCount: number, totalFileCount: number) => void;
|
|
92
|
+
minify?: boolean;
|
|
93
|
+
output?: Readonly<{
|
|
94
|
+
build: (
|
|
95
|
+
$$PARAM_0$$: MetroServer,
|
|
96
|
+
$$PARAM_1$$: RequestOptions,
|
|
97
|
+
$$PARAM_2$$: void | BuildOptions,
|
|
98
|
+
) => Promise<{
|
|
99
|
+
code: string;
|
|
100
|
+
map: string;
|
|
101
|
+
assets?: ReadonlyArray<AssetData>;
|
|
102
|
+
}>;
|
|
103
|
+
save: (
|
|
104
|
+
$$PARAM_0$$: {code: string; map: string},
|
|
105
|
+
$$PARAM_1$$: OutputOptions,
|
|
106
|
+
$$PARAM_2$$: (logMessage: string) => void,
|
|
107
|
+
) => Promise<unknown>;
|
|
108
|
+
}>;
|
|
109
|
+
platform?: string;
|
|
110
|
+
sourceMap?: boolean;
|
|
111
|
+
sourceMapUrl?: string;
|
|
112
|
+
customResolverOptions?: CustomResolverOptions;
|
|
113
|
+
customTransformOptions?: CustomTransformOptions;
|
|
114
|
+
unstable_transformProfile?: TransformProfile;
|
|
115
|
+
};
|
|
116
|
+
export type RunBuildResult = {
|
|
117
|
+
code: string;
|
|
118
|
+
map: string;
|
|
119
|
+
assets?: ReadonlyArray<AssetData>;
|
|
120
|
+
};
|
|
121
|
+
type BuildCommandOptions = Readonly<{[$$Key$$: string]: unknown}> | null;
|
|
122
|
+
type ServeCommandOptions = Readonly<{[$$Key$$: string]: unknown}> | null;
|
|
123
|
+
type DependenciesCommandOptions = Readonly<{
|
|
124
|
+
[$$Key$$: string]: unknown;
|
|
125
|
+
}> | null;
|
|
126
|
+
export {Terminal, JsonReporter, TerminalReporter};
|
|
127
|
+
export type {AssetData} from './Assets';
|
|
128
|
+
export type {
|
|
129
|
+
AsyncDependencyType,
|
|
130
|
+
DeltaResult,
|
|
131
|
+
Dependency,
|
|
132
|
+
MixedOutput,
|
|
133
|
+
Module,
|
|
134
|
+
ReadOnlyDependencies,
|
|
135
|
+
ReadOnlyGraph,
|
|
136
|
+
SerializerOptions,
|
|
137
|
+
TransformInputOptions,
|
|
138
|
+
TransformResult,
|
|
139
|
+
TransformResultDependency,
|
|
140
|
+
} from './DeltaBundler/types';
|
|
141
|
+
export type {default as DependencyGraph} from './node-haste/DependencyGraph';
|
|
142
|
+
export type {BundleDetails, Reporter, ReportableEvent} from './lib/reporting';
|
|
143
|
+
export type {TerminalReportableEvent} from './lib/TerminalReporter';
|
|
144
|
+
export type {
|
|
145
|
+
ContextMode,
|
|
146
|
+
RequireContextParams,
|
|
147
|
+
} from './ModuleGraph/worker/collectDependencies';
|
|
148
|
+
export type {ServerOptions} from './Server';
|
|
149
|
+
export type {MetroConfig, MetroServer};
|
|
150
|
+
export declare function runMetro(
|
|
151
|
+
config: InputConfigT,
|
|
152
|
+
options?: RunMetroOptions,
|
|
153
|
+
): Promise<MetroServer>;
|
|
154
|
+
export {loadConfig, mergeConfig, resolveConfig};
|
|
155
|
+
export declare const createConnectMiddleware: (
|
|
156
|
+
config: ConfigT,
|
|
157
|
+
options?: RunMetroOptions,
|
|
158
|
+
) => Promise<MetroMiddleWare>;
|
|
159
|
+
export declare type createConnectMiddleware = typeof createConnectMiddleware;
|
|
160
|
+
export declare const runServer: (
|
|
161
|
+
config: ConfigT,
|
|
162
|
+
$$PARAM_1$$?: RunServerOptions,
|
|
163
|
+
) => Promise<RunServerResult>;
|
|
164
|
+
export declare type runServer = typeof runServer;
|
|
165
|
+
export declare const runBuild: (
|
|
166
|
+
config: ConfigT,
|
|
167
|
+
$$PARAM_1$$: RunBuildOptions,
|
|
168
|
+
) => Promise<RunBuildResult>;
|
|
169
|
+
export declare type runBuild = typeof runBuild;
|
|
170
|
+
export declare const buildGraph: (
|
|
171
|
+
config: InputConfigT,
|
|
172
|
+
$$PARAM_1$$: BuildGraphOptions,
|
|
173
|
+
) => Promise<ReadOnlyGraph>;
|
|
174
|
+
export declare type buildGraph = typeof buildGraph;
|
|
175
|
+
type AttachMetroCLIOptions = {
|
|
176
|
+
build?: BuildCommandOptions;
|
|
177
|
+
serve?: ServeCommandOptions;
|
|
178
|
+
dependencies?: DependenciesCommandOptions;
|
|
179
|
+
};
|
|
180
|
+
export declare const attachMetroCli: (
|
|
181
|
+
yargs: Yargs,
|
|
182
|
+
options?: AttachMetroCLIOptions,
|
|
183
|
+
) => Yargs;
|
|
184
|
+
export declare type attachMetroCli = typeof attachMetroCli;
|
|
185
|
+
/**
|
|
186
|
+
* Backwards-compatibility with CommonJS consumers using interopRequireDefault.
|
|
187
|
+
* Do not add to this list.
|
|
188
|
+
*
|
|
189
|
+
* @deprecated Default import from 'metro' is deprecated, use named exports.
|
|
190
|
+
*/
|
|
191
|
+
declare const $$EXPORT_DEFAULT_DECLARATION$$: {
|
|
192
|
+
attachMetroCli: typeof attachMetroCli;
|
|
193
|
+
runServer: typeof runServer;
|
|
194
|
+
Terminal: typeof Terminal;
|
|
195
|
+
JsonReporter: typeof JsonReporter;
|
|
196
|
+
TerminalReporter: typeof TerminalReporter;
|
|
197
|
+
loadConfig: typeof loadConfig;
|
|
198
|
+
mergeConfig: typeof mergeConfig;
|
|
199
|
+
resolveConfig: typeof resolveConfig;
|
|
200
|
+
createConnectMiddleware: typeof createConnectMiddleware;
|
|
201
|
+
runBuild: typeof runBuild;
|
|
202
|
+
buildGraph: typeof buildGraph;
|
|
203
|
+
};
|
|
204
|
+
declare type $$EXPORT_DEFAULT_DECLARATION$$ =
|
|
205
|
+
typeof $$EXPORT_DEFAULT_DECLARATION$$;
|
|
206
|
+
export default $$EXPORT_DEFAULT_DECLARATION$$;
|
package/src/index.flow.js.flow
CHANGED
|
@@ -156,9 +156,28 @@ type DependenciesCommandOptions = Readonly<{[string]: unknown}> | null;
|
|
|
156
156
|
export {Terminal, JsonReporter, TerminalReporter};
|
|
157
157
|
|
|
158
158
|
export type {AssetData} from './Assets';
|
|
159
|
-
export type {
|
|
159
|
+
export type {
|
|
160
|
+
AsyncDependencyType,
|
|
161
|
+
DeltaResult,
|
|
162
|
+
Dependency,
|
|
163
|
+
MixedOutput,
|
|
164
|
+
Module,
|
|
165
|
+
ReadOnlyDependencies,
|
|
166
|
+
ReadOnlyGraph,
|
|
167
|
+
SerializerOptions,
|
|
168
|
+
TransformInputOptions,
|
|
169
|
+
TransformResult,
|
|
170
|
+
TransformResultDependency,
|
|
171
|
+
} from './DeltaBundler/types';
|
|
172
|
+
export type {default as DependencyGraph} from './node-haste/DependencyGraph';
|
|
173
|
+
export type {BundleDetails, Reporter, ReportableEvent} from './lib/reporting';
|
|
160
174
|
export type {TerminalReportableEvent} from './lib/TerminalReporter';
|
|
161
|
-
export type {
|
|
175
|
+
export type {
|
|
176
|
+
ContextMode,
|
|
177
|
+
RequireContextParams,
|
|
178
|
+
} from './ModuleGraph/worker/collectDependencies';
|
|
179
|
+
export type {ServerOptions} from './Server';
|
|
180
|
+
export type {MetroConfig, MetroServer};
|
|
162
181
|
|
|
163
182
|
async function getConfig(config: InputConfigT): Promise<ConfigT> {
|
|
164
183
|
const defaultConfig = await getDefaultConfig(config.projectRoot);
|
|
@@ -0,0 +1,61 @@
|
|
|
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<<5872ab26db1c8f4499c971170c5012c4>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/lib/BatchProcessor.js
|
|
13
|
+
* To regenerate, run:
|
|
14
|
+
* js1 build metro-ts-defs (internal) OR
|
|
15
|
+
* yarn run build-ts-defs (OSS)
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import {setTimeout} from 'timers';
|
|
19
|
+
|
|
20
|
+
type ProcessBatch<TItem, TResult> = (
|
|
21
|
+
batch: Array<TItem>,
|
|
22
|
+
) => Promise<Array<TResult>>;
|
|
23
|
+
type BatchProcessorOptions = {
|
|
24
|
+
maximumDelayMs: number;
|
|
25
|
+
maximumItems: number;
|
|
26
|
+
concurrency: number;
|
|
27
|
+
};
|
|
28
|
+
type QueueItem<TItem, TResult> = {
|
|
29
|
+
item: TItem;
|
|
30
|
+
reject: (error: unknown) => unknown;
|
|
31
|
+
resolve: (result: TResult) => unknown;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* We batch items together trying to minimize their processing, for example as
|
|
35
|
+
* network queries. For that we wait a small moment before processing a batch.
|
|
36
|
+
* We limit also the number of items we try to process in a single batch so that
|
|
37
|
+
* if we have many items pending in a short amount of time, we can start
|
|
38
|
+
* processing right away.
|
|
39
|
+
*/
|
|
40
|
+
declare class BatchProcessor<TItem, TResult> {
|
|
41
|
+
_currentProcessCount: number;
|
|
42
|
+
_options: BatchProcessorOptions;
|
|
43
|
+
_processBatch: ProcessBatch<TItem, TResult>;
|
|
44
|
+
_queue: Array<QueueItem<TItem, TResult>>;
|
|
45
|
+
_timeoutHandle: null | undefined | ReturnType<typeof setTimeout>;
|
|
46
|
+
constructor(
|
|
47
|
+
options: BatchProcessorOptions,
|
|
48
|
+
processBatch: ProcessBatch<TItem, TResult>,
|
|
49
|
+
);
|
|
50
|
+
_onBatchFinished(): void;
|
|
51
|
+
_onBatchResults(
|
|
52
|
+
jobs: Array<QueueItem<TItem, TResult>>,
|
|
53
|
+
results: Array<TResult>,
|
|
54
|
+
): void;
|
|
55
|
+
_onBatchError(jobs: Array<QueueItem<TItem, TResult>>, error: unknown): void;
|
|
56
|
+
_processQueue(): void;
|
|
57
|
+
_processQueueOnceReady(): void;
|
|
58
|
+
queue(item: TItem): Promise<TResult>;
|
|
59
|
+
getQueueLength(): number;
|
|
60
|
+
}
|
|
61
|
+
export default BatchProcessor;
|