metro 0.84.0 → 0.84.2
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 -14
- package/src/Assets.d.ts +90 -0
- package/src/Bundler/util.d.ts +34 -0
- package/src/Bundler.d.ts +45 -0
- package/src/DeltaBundler/DeltaCalculator.d.ts +78 -0
- 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/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 +86 -0
- 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/Server.js +10 -6
- package/src/Server.js.flow +9 -10
- 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 +187 -0
- package/src/index.flow.js +24 -10
- package/src/index.flow.js.flow +25 -10
- 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/RamBundleParser.d.ts +36 -0
- package/src/lib/TerminalReporter.d.ts +125 -0
- package/src/lib/TerminalReporter.js +6 -7
- package/src/lib/TerminalReporter.js.flow +6 -15
- package/src/lib/bundleProgressUtils.d.ts +33 -0
- package/src/lib/bundleProgressUtils.js +19 -0
- package/src/lib/bundleProgressUtils.js.flow +35 -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/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 +133 -0
- package/src/node-haste/DependencyGraph/createFileMap.d.ts +36 -0
- package/src/node-haste/DependencyGraph.d.ts +93 -0
- package/src/node-haste/Package.d.ts +28 -0
- package/src/node-haste/PackageCache.d.ts +41 -0
- 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
|
@@ -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;
|
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;
|
package/src/Server.js
CHANGED
|
@@ -25,6 +25,7 @@ var _IncrementalBundler = _interopRequireDefault(
|
|
|
25
25
|
var _ResourceNotFoundError = _interopRequireDefault(
|
|
26
26
|
require("./IncrementalBundler/ResourceNotFoundError"),
|
|
27
27
|
);
|
|
28
|
+
var _bundleProgressUtils = require("./lib/bundleProgressUtils");
|
|
28
29
|
var _bundleToString = _interopRequireDefault(require("./lib/bundleToString"));
|
|
29
30
|
var _formatBundlingError = _interopRequireDefault(
|
|
30
31
|
require("./lib/formatBundlingError"),
|
|
@@ -679,14 +680,16 @@ class Server {
|
|
|
679
680
|
}
|
|
680
681
|
const mres = _MultipartResponse.default.wrapIfSupported(req, res);
|
|
681
682
|
let onProgress = null;
|
|
682
|
-
let
|
|
683
|
+
let lastRatio = -1;
|
|
683
684
|
if (this._config.reporter) {
|
|
684
685
|
onProgress = (transformedFileCount, totalFileCount) => {
|
|
685
|
-
const
|
|
686
|
-
|
|
687
|
-
|
|
686
|
+
const newRatio = (0,
|
|
687
|
+
_bundleProgressUtils.calculateBundleProgressRatio)(
|
|
688
|
+
transformedFileCount,
|
|
689
|
+
totalFileCount,
|
|
690
|
+
lastRatio,
|
|
688
691
|
);
|
|
689
|
-
if (
|
|
692
|
+
if (newRatio > lastRatio) {
|
|
690
693
|
if (mres instanceof _MultipartResponse.default) {
|
|
691
694
|
mres.writeChunk(
|
|
692
695
|
{
|
|
@@ -695,13 +698,14 @@ class Server {
|
|
|
695
698
|
JSON.stringify({
|
|
696
699
|
done: transformedFileCount,
|
|
697
700
|
total: totalFileCount,
|
|
701
|
+
percent: Math.floor(newRatio * 100),
|
|
698
702
|
}),
|
|
699
703
|
);
|
|
700
704
|
}
|
|
701
705
|
if (res.socket != null && res.socket.uncork != null) {
|
|
702
706
|
res.socket.uncork();
|
|
703
707
|
}
|
|
704
|
-
|
|
708
|
+
lastRatio = newRatio;
|
|
705
709
|
}
|
|
706
710
|
this._reporter.update({
|
|
707
711
|
buildID: getBuildID(buildNumber),
|
package/src/Server.js.flow
CHANGED
|
@@ -52,6 +52,7 @@ import getRamBundleInfo from './DeltaBundler/Serializers/getRamBundleInfo';
|
|
|
52
52
|
import {sourceMapStringNonBlocking} from './DeltaBundler/Serializers/sourceMapString';
|
|
53
53
|
import IncrementalBundler from './IncrementalBundler';
|
|
54
54
|
import ResourceNotFoundError from './IncrementalBundler/ResourceNotFoundError';
|
|
55
|
+
import {calculateBundleProgressRatio} from './lib/bundleProgressUtils';
|
|
55
56
|
import bundleToString from './lib/bundleToString';
|
|
56
57
|
import formatBundlingError from './lib/formatBundlingError';
|
|
57
58
|
import getGraphId from './lib/getGraphId';
|
|
@@ -857,25 +858,23 @@ export default class Server {
|
|
|
857
858
|
const mres = MultipartResponse.wrapIfSupported(req, res);
|
|
858
859
|
|
|
859
860
|
let onProgress = null;
|
|
860
|
-
let
|
|
861
|
+
let lastRatio = -1;
|
|
861
862
|
if (this._config.reporter) {
|
|
862
863
|
onProgress = (transformedFileCount: number, totalFileCount: number) => {
|
|
863
|
-
const
|
|
864
|
-
|
|
865
|
-
|
|
864
|
+
const newRatio = calculateBundleProgressRatio(
|
|
865
|
+
transformedFileCount,
|
|
866
|
+
totalFileCount,
|
|
867
|
+
lastRatio,
|
|
866
868
|
);
|
|
867
869
|
|
|
868
|
-
|
|
869
|
-
// UI updates slow enough for the client to actually handle them. For
|
|
870
|
-
// that, we check the percentage, and only send percentages that are
|
|
871
|
-
// actually different and that have increased from the last one we sent.
|
|
872
|
-
if (currentProgress > lastProgress || totalFileCount < 10) {
|
|
870
|
+
if (newRatio > lastRatio) {
|
|
873
871
|
if (mres instanceof MultipartResponse) {
|
|
874
872
|
mres.writeChunk(
|
|
875
873
|
{'Content-Type': 'application/json'},
|
|
876
874
|
JSON.stringify({
|
|
877
875
|
done: transformedFileCount,
|
|
878
876
|
total: totalFileCount,
|
|
877
|
+
percent: Math.floor(newRatio * 100),
|
|
879
878
|
}),
|
|
880
879
|
);
|
|
881
880
|
}
|
|
@@ -891,7 +890,7 @@ export default class Server {
|
|
|
891
890
|
res.socket.uncork();
|
|
892
891
|
}
|
|
893
892
|
|
|
894
|
-
|
|
893
|
+
lastRatio = newRatio;
|
|
895
894
|
}
|
|
896
895
|
|
|
897
896
|
this._reporter.update({
|
|
@@ -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$$;
|