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
|
@@ -0,0 +1,55 @@
|
|
|
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<<0fccda5d7f0eb38539316fa1fedae97b>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/lib/CountingSet.js
|
|
13
|
+
* To regenerate, run:
|
|
14
|
+
* js1 build metro-ts-defs (internal) OR
|
|
15
|
+
* yarn run build-ts-defs (OSS)
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
export interface ReadOnlyCountingSet<T> extends Iterable<T> {
|
|
19
|
+
has(item: T): boolean;
|
|
20
|
+
readonly size: number;
|
|
21
|
+
count(item: T): number;
|
|
22
|
+
forEach<ThisT>(
|
|
23
|
+
callbackFn: (
|
|
24
|
+
this: ThisT,
|
|
25
|
+
value: T,
|
|
26
|
+
key: T,
|
|
27
|
+
set: ReadOnlyCountingSet<T>,
|
|
28
|
+
) => unknown,
|
|
29
|
+
thisArg: ThisT,
|
|
30
|
+
): void;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* A Set that only deletes a given item when the number of delete(item) calls
|
|
34
|
+
* matches the number of add(item) calls. Iteration and `size` are in terms of
|
|
35
|
+
* *unique* items.
|
|
36
|
+
*/
|
|
37
|
+
declare class CountingSet<T> implements ReadOnlyCountingSet<T> {
|
|
38
|
+
constructor(items?: Iterable<T>);
|
|
39
|
+
has(item: T): boolean;
|
|
40
|
+
add(item: T): void;
|
|
41
|
+
delete(item: T): void;
|
|
42
|
+
keys(): Iterator<T>;
|
|
43
|
+
values(): Iterator<T>;
|
|
44
|
+
entries(): Iterator<[T, T]>;
|
|
45
|
+
[Symbol.iterator](): Iterator<T>;
|
|
46
|
+
get size(): number;
|
|
47
|
+
count(item: T): number;
|
|
48
|
+
clear(): void;
|
|
49
|
+
forEach<ThisT>(
|
|
50
|
+
callbackFn: (this: ThisT, value: T, key: T, set: CountingSet<T>) => unknown,
|
|
51
|
+
thisArg: ThisT,
|
|
52
|
+
): void;
|
|
53
|
+
toJSON(): unknown;
|
|
54
|
+
}
|
|
55
|
+
export default CountingSet;
|
|
@@ -0,0 +1,44 @@
|
|
|
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<<e7173f8dc5e076fd37b9a1cecd581f58>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/lib/JsonReporter.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 {Writable} from 'stream';
|
|
19
|
+
|
|
20
|
+
export type SerializedError = {
|
|
21
|
+
message: string;
|
|
22
|
+
stack: string;
|
|
23
|
+
errors?: ReadonlyArray<SerializedError>;
|
|
24
|
+
cause?: SerializedError;
|
|
25
|
+
};
|
|
26
|
+
export type SerializedEvent<
|
|
27
|
+
TEvent extends {readonly [$$Key$$: string]: unknown},
|
|
28
|
+
> = TEvent extends {error: Error}
|
|
29
|
+
? Omit<Omit<TEvent, 'error'>, keyof {error: SerializedError}> & {
|
|
30
|
+
error: SerializedError;
|
|
31
|
+
}
|
|
32
|
+
: TEvent;
|
|
33
|
+
declare class JsonReporter<
|
|
34
|
+
TEvent extends {readonly [$$Key$$: string]: unknown},
|
|
35
|
+
> {
|
|
36
|
+
_stream: Writable;
|
|
37
|
+
constructor(stream: Writable);
|
|
38
|
+
/**
|
|
39
|
+
* There is a special case for errors because they have non-enumerable fields.
|
|
40
|
+
* (Perhaps we should switch in favor of plain object?)
|
|
41
|
+
*/
|
|
42
|
+
update(event: TEvent): void;
|
|
43
|
+
}
|
|
44
|
+
export default JsonReporter;
|
|
@@ -19,7 +19,7 @@ export type SerializedError = {
|
|
|
19
19
|
...
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
export type SerializedEvent<TEvent
|
|
22
|
+
export type SerializedEvent<TEvent extends {+[string]: unknown, ...}> =
|
|
23
23
|
TEvent extends {
|
|
24
24
|
error: Error,
|
|
25
25
|
...
|
|
@@ -31,7 +31,7 @@ export type SerializedEvent<TEvent: {+[string]: unknown, ...}> =
|
|
|
31
31
|
}
|
|
32
32
|
: TEvent;
|
|
33
33
|
|
|
34
|
-
export default class JsonReporter<TEvent
|
|
34
|
+
export default class JsonReporter<TEvent extends {+[string]: unknown, ...}> {
|
|
35
35
|
_stream: Writable;
|
|
36
36
|
|
|
37
37
|
constructor(stream: Writable) {
|
|
@@ -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<<ebddbde1dcdecbbee129fd96caaf3bb0>>
|
|
9
|
+
*
|
|
10
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
11
|
+
* Original file: packages/metro/src/lib/RamBundleParser.js
|
|
12
|
+
* To regenerate, run:
|
|
13
|
+
* js1 build metro-ts-defs (internal) OR
|
|
14
|
+
* yarn run build-ts-defs (OSS)
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Implementation of a RAM bundle parser in JS.
|
|
19
|
+
*
|
|
20
|
+
* It receives a Buffer as an input and implements two main methods, which are
|
|
21
|
+
* able to run in constant time no matter the size of the bundle:
|
|
22
|
+
*
|
|
23
|
+
* getStartupCode(): returns the runtime and the startup code of the bundle.
|
|
24
|
+
* getModule(): returns the code for the specified module.
|
|
25
|
+
*/
|
|
26
|
+
declare class RamBundleParser {
|
|
27
|
+
_buffer: Buffer;
|
|
28
|
+
_numModules: number;
|
|
29
|
+
_startupCodeLength: number;
|
|
30
|
+
_startOffset: number;
|
|
31
|
+
constructor(buffer: Buffer);
|
|
32
|
+
_readPosition(pos: number): number;
|
|
33
|
+
getStartupCode(): string;
|
|
34
|
+
getModule(id: number): string;
|
|
35
|
+
}
|
|
36
|
+
export default RamBundleParser;
|
|
@@ -0,0 +1,125 @@
|
|
|
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<<8218e45d6b5186264c4bf9e54086708a>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/lib/TerminalReporter.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 {BundleDetails, ReportableEvent} from './reporting';
|
|
19
|
+
import type {Terminal} from 'metro-core';
|
|
20
|
+
import type {HealthCheckResult, WatcherStatus} from 'metro-file-map';
|
|
21
|
+
|
|
22
|
+
type BundleProgress = {
|
|
23
|
+
bundleDetails: BundleDetails;
|
|
24
|
+
transformedFileCount: number;
|
|
25
|
+
totalFileCount: number;
|
|
26
|
+
ratio: number;
|
|
27
|
+
isPrefetch?: boolean;
|
|
28
|
+
};
|
|
29
|
+
export type TerminalReportableEvent =
|
|
30
|
+
| ReportableEvent
|
|
31
|
+
| {
|
|
32
|
+
buildID: string;
|
|
33
|
+
type: 'bundle_transform_progressed_throttled';
|
|
34
|
+
transformedFileCount: number;
|
|
35
|
+
totalFileCount: number;
|
|
36
|
+
}
|
|
37
|
+
| {
|
|
38
|
+
type: 'unstable_server_log';
|
|
39
|
+
level: 'info' | 'warn' | 'error';
|
|
40
|
+
data: string | Array<unknown>;
|
|
41
|
+
}
|
|
42
|
+
| {type: 'unstable_server_menu_updated'; message: string}
|
|
43
|
+
| {type: 'unstable_server_menu_cleared'};
|
|
44
|
+
type BuildPhase = 'in_progress' | 'done' | 'failed';
|
|
45
|
+
interface SnippetError extends Error {
|
|
46
|
+
code?: string;
|
|
47
|
+
filename?: string;
|
|
48
|
+
snippet?: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* We try to print useful information to the terminal for interactive builds.
|
|
52
|
+
* This implements the `Reporter` interface from the './reporting' module.
|
|
53
|
+
*/
|
|
54
|
+
declare class TerminalReporter {
|
|
55
|
+
/**
|
|
56
|
+
* The bundle builds for which we are actively maintaining the status on the
|
|
57
|
+
* terminal, ie. showing a progress bar. There can be several bundles being
|
|
58
|
+
* built at the same time.
|
|
59
|
+
*/
|
|
60
|
+
_activeBundles: Map<string, BundleProgress>;
|
|
61
|
+
_interactionStatus: null | undefined | string;
|
|
62
|
+
_scheduleUpdateBundleProgress: {
|
|
63
|
+
(data: {
|
|
64
|
+
buildID: string;
|
|
65
|
+
transformedFileCount: number;
|
|
66
|
+
totalFileCount: number;
|
|
67
|
+
}): void;
|
|
68
|
+
cancel(): void;
|
|
69
|
+
};
|
|
70
|
+
_prevHealthCheckResult: null | undefined | HealthCheckResult;
|
|
71
|
+
readonly terminal: Terminal;
|
|
72
|
+
constructor(terminal: Terminal);
|
|
73
|
+
/**
|
|
74
|
+
* Construct a message that represents the progress of a
|
|
75
|
+
* single bundle build, for example:
|
|
76
|
+
*
|
|
77
|
+
* BUNDLE path/to/bundle.js ▓▓▓▓▓░░░░░░░░░░░ 36.6% (4790/7922)
|
|
78
|
+
*/
|
|
79
|
+
_getBundleStatusMessage(
|
|
80
|
+
$$PARAM_0$$: BundleProgress,
|
|
81
|
+
phase: BuildPhase,
|
|
82
|
+
): string;
|
|
83
|
+
_logBundleBuildDone(buildID: string): void;
|
|
84
|
+
_logBundleBuildFailed(buildID: string): void;
|
|
85
|
+
_logInitializing(port: number, hasReducedPerformance: boolean): void;
|
|
86
|
+
_logInitializingFailed(port: number, error: SnippetError): void;
|
|
87
|
+
/**
|
|
88
|
+
* This function is only concerned with logging and should not do state
|
|
89
|
+
* or terminal status updates.
|
|
90
|
+
*/
|
|
91
|
+
_log(event: TerminalReportableEvent): void;
|
|
92
|
+
/**
|
|
93
|
+
* We do not want to log the whole stacktrace for bundling error, because
|
|
94
|
+
* these are operational errors, not programming errors, and the stacktrace
|
|
95
|
+
* is not actionable to end users.
|
|
96
|
+
*/
|
|
97
|
+
_logBundlingError(error: SnippetError): void;
|
|
98
|
+
_logWorkerChunk(origin: 'stdout' | 'stderr', chunk: string): void;
|
|
99
|
+
_updateBundleProgress($$PARAM_0$$: {
|
|
100
|
+
buildID: string;
|
|
101
|
+
transformedFileCount: number;
|
|
102
|
+
totalFileCount: number;
|
|
103
|
+
}): void;
|
|
104
|
+
/**
|
|
105
|
+
* This function is exclusively concerned with updating the internal state.
|
|
106
|
+
* No logging or status updates should be done at this point.
|
|
107
|
+
*/
|
|
108
|
+
_updateState(event: TerminalReportableEvent): void;
|
|
109
|
+
/**
|
|
110
|
+
* Return a status message that is always consistent with the current state
|
|
111
|
+
* of the application. Having this single function ensures we don't have
|
|
112
|
+
* different callsites overriding each other status messages.
|
|
113
|
+
*/
|
|
114
|
+
_getStatusMessage(): string;
|
|
115
|
+
_logHmrClientError(e: Error): void;
|
|
116
|
+
_logWarning(message: string): void;
|
|
117
|
+
_logWatcherHealthCheckResult(result: HealthCheckResult): void;
|
|
118
|
+
_logWatcherStatus(status: WatcherStatus): void;
|
|
119
|
+
/**
|
|
120
|
+
* Single entry point for reporting events. That allows us to implement the
|
|
121
|
+
* corresponding JSON reporter easily and have a consistent reporting.
|
|
122
|
+
*/
|
|
123
|
+
update(event: TerminalReportableEvent): void;
|
|
124
|
+
}
|
|
125
|
+
export default TerminalReporter;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @noformat
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
* @generated SignedSource<<6f0cfa5c118fa3cbe65acee044b8c927>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/lib/bundleProgressUtils.js
|
|
13
|
+
* To regenerate, run:
|
|
14
|
+
* js1 build metro-ts-defs (internal) OR
|
|
15
|
+
* yarn run build-ts-defs (OSS)
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Calculates a conservative progress ratio for bundle building.
|
|
20
|
+
*
|
|
21
|
+
* Because we know the `totalFileCount` is going to progressively increase
|
|
22
|
+
* starting with 1:
|
|
23
|
+
* - We use Math.max(totalFileCount, 10) to prevent the ratio from raising too
|
|
24
|
+
* quickly when the total file count is low. (e.g 1/2 5/6)
|
|
25
|
+
* - We use Math.pow(ratio, 2) as a conservative measure of progress.
|
|
26
|
+
* - The ratio is capped at 0.999 to ensure we don't display 100% until done.
|
|
27
|
+
* - If previousRatio is provided, the ratio will not go backwards.
|
|
28
|
+
*/
|
|
29
|
+
export declare function calculateBundleProgressRatio(
|
|
30
|
+
transformedFileCount: number,
|
|
31
|
+
totalFileCount: number,
|
|
32
|
+
previousRatio?: number,
|
|
33
|
+
): number;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @noformat
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
* @generated SignedSource<<89a26e72bdd126e3feb0abc9b3186d33>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/lib/bundleToString.js
|
|
13
|
+
* To regenerate, run:
|
|
14
|
+
* js1 build metro-ts-defs (internal) OR
|
|
15
|
+
* yarn run build-ts-defs (OSS)
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import type {Bundle, BundleMetadata} from 'metro-runtime/src/modules/types';
|
|
19
|
+
/**
|
|
20
|
+
* Serializes a bundle into a plain JS bundle.
|
|
21
|
+
*/
|
|
22
|
+
declare function bundleToString(bundle: Bundle): {
|
|
23
|
+
readonly code: string;
|
|
24
|
+
readonly metadata: BundleMetadata;
|
|
25
|
+
};
|
|
26
|
+
export default bundleToString;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @noformat
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
* @generated SignedSource<<461f7a7b3b3d99d1f1e7eeeeb5125686>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/lib/contextModule.js
|
|
13
|
+
* To regenerate, run:
|
|
14
|
+
* js1 build metro-ts-defs (internal) OR
|
|
15
|
+
* yarn run build-ts-defs (OSS)
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import type {
|
|
19
|
+
ContextMode,
|
|
20
|
+
RequireContextParams,
|
|
21
|
+
} from '../ModuleGraph/worker/collectDependencies';
|
|
22
|
+
|
|
23
|
+
export type RequireContext = Readonly<{
|
|
24
|
+
recursive: boolean;
|
|
25
|
+
filter: RegExp;
|
|
26
|
+
/** Mode for resolving dynamic dependencies. Defaults to `sync` */
|
|
27
|
+
mode: ContextMode;
|
|
28
|
+
/** Absolute path of the directory to search in */
|
|
29
|
+
from: string;
|
|
30
|
+
}>;
|
|
31
|
+
/** Given a fully qualified require context, return a virtual file path that ensures uniqueness between paths with different contexts. */
|
|
32
|
+
export declare function deriveAbsolutePathFromContext(
|
|
33
|
+
from: string,
|
|
34
|
+
context: RequireContextParams,
|
|
35
|
+
): string;
|
|
36
|
+
/** Match a file against a require context. */
|
|
37
|
+
export declare function fileMatchesContext(
|
|
38
|
+
testPath: string,
|
|
39
|
+
context: RequireContext,
|
|
40
|
+
): boolean;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @noformat
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
* @generated SignedSource<<bcc2ba36a2edccb791b6d380f2c27ebe>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/lib/contextModuleTemplates.js
|
|
13
|
+
* To regenerate, run:
|
|
14
|
+
* js1 build metro-ts-defs (internal) OR
|
|
15
|
+
* yarn run build-ts-defs (OSS)
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import type {ContextMode} from '../ModuleGraph/worker/collectDependencies';
|
|
19
|
+
/**
|
|
20
|
+
* Generate a context module as a virtual file string.
|
|
21
|
+
*
|
|
22
|
+
* @prop {ContextMode} mode indicates how the modules should be loaded.
|
|
23
|
+
* @prop {string} modulePath virtual file path for the virtual module. Example: `require.context('./src')` -> `'/path/to/project/src'`.
|
|
24
|
+
* @prop {string[]} files list of absolute file paths that must be exported from the context module. Example: `['/path/to/project/src/index.js']`.
|
|
25
|
+
*
|
|
26
|
+
* @returns a string representing a context module (virtual file contents).
|
|
27
|
+
*/
|
|
28
|
+
export declare function getContextModuleTemplate(
|
|
29
|
+
mode: ContextMode,
|
|
30
|
+
modulePath: string,
|
|
31
|
+
files: string[],
|
|
32
|
+
): string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @noformat
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
* @generated SignedSource<<a9f443cc44465917ebb470200e0f80d2>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/lib/countLines.js
|
|
13
|
+
* To regenerate, run:
|
|
14
|
+
* js1 build metro-ts-defs (internal) OR
|
|
15
|
+
* yarn run build-ts-defs (OSS)
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
declare function countLines(string: string): number;
|
|
19
|
+
export default countLines;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @noformat
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
* @generated SignedSource<<cc8010b98646f8cfd713ae5505f71ef1>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/lib/createWebsocketServer.js
|
|
13
|
+
* To regenerate, run:
|
|
14
|
+
* js1 build metro-ts-defs (internal) OR
|
|
15
|
+
* yarn run build-ts-defs (OSS)
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import ws from 'ws';
|
|
19
|
+
|
|
20
|
+
type WebsocketServiceInterface<T> = {
|
|
21
|
+
readonly onClientConnect: (
|
|
22
|
+
url: string,
|
|
23
|
+
sendFn: (data: string) => void,
|
|
24
|
+
) => Promise<null | undefined | T>;
|
|
25
|
+
readonly onClientDisconnect?: (client: T) => unknown;
|
|
26
|
+
readonly onClientError?: (client: T, e: Error) => unknown;
|
|
27
|
+
readonly onClientMessage?: (
|
|
28
|
+
client: T,
|
|
29
|
+
message: string | Buffer | ArrayBuffer | Array<Buffer>,
|
|
30
|
+
sendFn: (data: string) => void,
|
|
31
|
+
) => unknown;
|
|
32
|
+
};
|
|
33
|
+
type HMROptions<TClient> = {
|
|
34
|
+
websocketServer: WebsocketServiceInterface<TClient>;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Returns a WebSocketServer to be attached to an existing HTTP instance. It forwards
|
|
38
|
+
* the received events on the given "websocketServer" parameter. It must be an
|
|
39
|
+
* object with the following fields:
|
|
40
|
+
*
|
|
41
|
+
* - onClientConnect
|
|
42
|
+
* - onClientError
|
|
43
|
+
* - onClientMessage
|
|
44
|
+
* - onClientDisconnect
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
declare function createWebsocketServer<TClient>(
|
|
48
|
+
$$PARAM_0$$: HMROptions<TClient>,
|
|
49
|
+
): ws.Server;
|
|
50
|
+
export default createWebsocketServer;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @noformat
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
* @generated SignedSource<<900f968546b7cc3e463e2de9d1f06200>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/lib/debounceAsyncQueue.js
|
|
13
|
+
* To regenerate, run:
|
|
14
|
+
* js1 build metro-ts-defs (internal) OR
|
|
15
|
+
* yarn run build-ts-defs (OSS)
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
declare function debounceAsyncQueue<T>(
|
|
19
|
+
fn: () => Promise<T>,
|
|
20
|
+
delay: number,
|
|
21
|
+
): () => Promise<T>;
|
|
22
|
+
export default debounceAsyncQueue;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @noformat
|
|
8
|
+
* @generated SignedSource<<0c18118765a7730747fbadfd10e5d8f6>>
|
|
9
|
+
*
|
|
10
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
11
|
+
* Original file: packages/metro/src/lib/formatBundlingError.js
|
|
12
|
+
* To regenerate, run:
|
|
13
|
+
* js1 build metro-ts-defs (internal) OR
|
|
14
|
+
* yarn run build-ts-defs (OSS)
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import type {FormattedError} from 'metro-runtime/src/modules/types';
|
|
18
|
+
|
|
19
|
+
export type CustomError = Error & {
|
|
20
|
+
readonly type?: string;
|
|
21
|
+
filename?: string;
|
|
22
|
+
lineNumber?: number;
|
|
23
|
+
errors?: Array<{
|
|
24
|
+
description: string;
|
|
25
|
+
filename: string;
|
|
26
|
+
lineNumber: number;
|
|
27
|
+
}>;
|
|
28
|
+
};
|
|
29
|
+
declare function formatBundlingError(error: CustomError): FormattedError;
|
|
30
|
+
export default formatBundlingError;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @noformat
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
* @generated SignedSource<<72fd04e53dc895f1305e10043f986edc>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/lib/getAppendScripts.js
|
|
13
|
+
* To regenerate, run:
|
|
14
|
+
* js1 build metro-ts-defs (internal) OR
|
|
15
|
+
* yarn run build-ts-defs (OSS)
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import type {Module} from '../DeltaBundler';
|
|
19
|
+
|
|
20
|
+
type Options<T extends number | string> = Readonly<{
|
|
21
|
+
asyncRequireModulePath: string;
|
|
22
|
+
createModuleId: ($$PARAM_0$$: string) => T;
|
|
23
|
+
getRunModuleStatement: (moduleId: T, globalPrefix: string) => string;
|
|
24
|
+
globalPrefix: string;
|
|
25
|
+
inlineSourceMap: null | undefined | boolean;
|
|
26
|
+
runBeforeMainModule: ReadonlyArray<string>;
|
|
27
|
+
runModule: boolean;
|
|
28
|
+
shouldAddToIgnoreList: ($$PARAM_0$$: Module) => boolean;
|
|
29
|
+
sourceMapUrl: null | undefined | string;
|
|
30
|
+
sourceUrl: null | undefined | string;
|
|
31
|
+
getSourceUrl: null | undefined | (($$PARAM_0$$: Module) => string);
|
|
32
|
+
}>;
|
|
33
|
+
declare function getAppendScripts<T extends number | string>(
|
|
34
|
+
entryPoint: string,
|
|
35
|
+
modules: ReadonlyArray<Module>,
|
|
36
|
+
options: Options<T>,
|
|
37
|
+
): ReadonlyArray<Module>;
|
|
38
|
+
export default getAppendScripts;
|
|
@@ -18,7 +18,7 @@ import CountingSet from './CountingSet';
|
|
|
18
18
|
import countLines from './countLines';
|
|
19
19
|
import nullthrows from 'nullthrows';
|
|
20
20
|
|
|
21
|
-
type Options<T
|
|
21
|
+
type Options<T extends number | string> = Readonly<{
|
|
22
22
|
asyncRequireModulePath: string,
|
|
23
23
|
createModuleId: string => T,
|
|
24
24
|
getRunModuleStatement: (moduleId: T, globalPrefix: string) => string,
|
|
@@ -33,7 +33,7 @@ type Options<T: number | string> = Readonly<{
|
|
|
33
33
|
...
|
|
34
34
|
}>;
|
|
35
35
|
|
|
36
|
-
export default function getAppendScripts<T
|
|
36
|
+
export default function getAppendScripts<T extends number | string>(
|
|
37
37
|
entryPoint: string,
|
|
38
38
|
modules: ReadonlyArray<Module<>>,
|
|
39
39
|
options: Options<T>,
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @noformat
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
* @generated SignedSource<<cb5003f203d26e24459419b5f28e4f06>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/lib/getGraphId.js
|
|
13
|
+
* To regenerate, run:
|
|
14
|
+
* js1 build metro-ts-defs (internal) OR
|
|
15
|
+
* yarn run build-ts-defs (OSS)
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import type {TransformInputOptions} from '../DeltaBundler/types';
|
|
19
|
+
import type {ResolverInputOptions} from '../shared/types';
|
|
20
|
+
|
|
21
|
+
export declare type GraphId = string;
|
|
22
|
+
declare function getGraphId(
|
|
23
|
+
entryFile: string,
|
|
24
|
+
options: TransformInputOptions,
|
|
25
|
+
$$PARAM_2$$: Readonly<{
|
|
26
|
+
shallow: boolean;
|
|
27
|
+
lazy: boolean;
|
|
28
|
+
unstable_allowRequireContext: boolean;
|
|
29
|
+
resolverOptions: ResolverInputOptions;
|
|
30
|
+
}>,
|
|
31
|
+
): GraphId;
|
|
32
|
+
export default getGraphId;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @noformat
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
* @generated SignedSource<<c57e62398654e4f07fea53d28c279b20>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/lib/getPreludeCode.js
|
|
13
|
+
* To regenerate, run:
|
|
14
|
+
* js1 build metro-ts-defs (internal) OR
|
|
15
|
+
* yarn run build-ts-defs (OSS)
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
declare function getPreludeCode($$PARAM_0$$: {
|
|
19
|
+
readonly extraVars?: {[$$Key$$: string]: unknown};
|
|
20
|
+
readonly isDev: boolean;
|
|
21
|
+
readonly globalPrefix: string;
|
|
22
|
+
readonly requireCycleIgnorePatterns: ReadonlyArray<RegExp>;
|
|
23
|
+
readonly unstable_forceFullRefreshPatterns: ReadonlyArray<RegExp>;
|
|
24
|
+
}): string;
|
|
25
|
+
export default getPreludeCode;
|