metro 0.84.4 → 0.85.0
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 +17 -17
- package/src/Assets.js +3 -1
- package/src/Assets.js.flow +31 -25
- package/src/Bundler.d.ts +1 -5
- package/src/DeltaBundler/DeltaCalculator.d.ts +1 -16
- package/src/DeltaBundler/DeltaCalculator.js.flow +1 -1
- package/src/DeltaBundler/Graph.d.ts +1 -102
- package/src/DeltaBundler/Graph.js.flow +7 -7
- package/src/DeltaBundler/Serializers/getAllFiles.js.flow +1 -1
- package/src/DeltaBundler/Serializers/getAssets.js.flow +1 -1
- package/src/DeltaBundler/Serializers/getExplodedSourceMap.js.flow +5 -5
- package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.js.flow +9 -9
- package/src/DeltaBundler/Serializers/hmrJSBundle.js.flow +3 -3
- package/src/DeltaBundler/Transformer.d.ts +2 -10
- package/src/DeltaBundler/Worker.flow.js.flow +1 -1
- package/src/DeltaBundler/WorkerFarm.d.ts +2 -47
- package/src/DeltaBundler/getTransformCacheKey.js.flow +3 -3
- package/src/DeltaBundler/types.js.flow +10 -10
- package/src/DeltaBundler.d.ts +1 -5
- package/src/HmrServer.d.ts +2 -45
- package/src/HmrServer.js.flow +10 -10
- package/src/IncrementalBundler.d.ts +1 -9
- package/src/IncrementalBundler.js.flow +9 -6
- package/src/ModuleGraph/worker/collectDependencies.d.ts +1 -2
- package/src/Server/symbolicate.js.flow +13 -13
- package/src/Server.d.ts +3 -179
- package/src/Server.js.flow +25 -23
- package/src/lib/BatchProcessor.d.ts +1 -21
- package/src/lib/CountingSet.js.flow +1 -1
- package/src/lib/JsonReporter.d.ts +1 -2
- package/src/lib/JsonReporter.js.flow +4 -2
- package/src/lib/RamBundleParser.d.ts +1 -6
- package/src/lib/TerminalReporter.d.ts +2 -78
- package/src/lib/TerminalReporter.js.flow +1 -1
- package/src/lib/bundleToString.js.flow +2 -2
- package/src/lib/createWebsocketServer.js.flow +4 -4
- package/src/lib/formatBundlingError.js.flow +1 -1
- package/src/lib/getPreludeCode.js.flow +5 -5
- package/src/node-haste/DependencyGraph/ModuleResolution.d.ts +1 -13
- package/src/node-haste/DependencyGraph/ModuleResolution.js.flow +1 -1
- package/src/node-haste/DependencyGraph/createFileMap.js +0 -1
- package/src/node-haste/DependencyGraph/createFileMap.js.flow +0 -1
- package/src/node-haste/DependencyGraph.d.ts +1 -30
- package/src/node-haste/DependencyGraph.js.flow +2 -2
- package/src/shared/output/RamBundle/util.js.flow +4 -2
- package/src/shared/types.js.flow +31 -31
|
@@ -18,8 +18,8 @@ import type {JsTransformOptions} from 'metro-transform-worker';
|
|
|
18
18
|
import CountingSet from '../lib/CountingSet';
|
|
19
19
|
|
|
20
20
|
export type MixedOutput = {
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
readonly data: unknown,
|
|
22
|
+
readonly type: string,
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
export type AsyncDependencyType = 'async' | 'maybeSync' | 'prefetch' | 'weak';
|
|
@@ -106,10 +106,10 @@ export type GraphInputOptions = Readonly<{
|
|
|
106
106
|
}>;
|
|
107
107
|
|
|
108
108
|
export interface ReadOnlyGraph<T = MixedOutput> {
|
|
109
|
-
|
|
109
|
+
readonly entryPoints: ReadonlySet<string>;
|
|
110
110
|
// Unused in core but useful for custom serializers / experimentalSerializerHook
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
readonly transformOptions: Readonly<TransformInputOptions>;
|
|
112
|
+
readonly dependencies: ReadOnlyDependencies<T>;
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
export type {Graph};
|
|
@@ -136,7 +136,7 @@ export type ResolveFn = (
|
|
|
136
136
|
) => BundlerResolution;
|
|
137
137
|
|
|
138
138
|
export type AllowOptionalDependenciesWithOptions = {
|
|
139
|
-
|
|
139
|
+
readonly exclude: Array<string>,
|
|
140
140
|
};
|
|
141
141
|
export type AllowOptionalDependencies =
|
|
142
142
|
| boolean
|
|
@@ -160,10 +160,10 @@ export type Options<T = MixedOutput> = Readonly<{
|
|
|
160
160
|
}>;
|
|
161
161
|
|
|
162
162
|
export type DeltaResult<T = MixedOutput> = {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
163
|
+
readonly added: Map<string, Module<T>>,
|
|
164
|
+
readonly modified: Map<string, Module<T>>,
|
|
165
|
+
readonly deleted: Set<string>,
|
|
166
|
+
readonly reset: boolean,
|
|
167
167
|
};
|
|
168
168
|
|
|
169
169
|
export type SerializerOptions = Readonly<{
|
package/src/DeltaBundler.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @noformat
|
|
8
8
|
* @oncall react_native
|
|
9
|
-
* @generated SignedSource<<
|
|
9
|
+
* @generated SignedSource<<4392a52adb92ee60889197cf5c38516d>>
|
|
10
10
|
*
|
|
11
11
|
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
12
|
* Original file: packages/metro/src/DeltaBundler.js
|
|
@@ -24,8 +24,6 @@ import type {
|
|
|
24
24
|
} from './DeltaBundler/types';
|
|
25
25
|
import type EventEmitter from 'events';
|
|
26
26
|
|
|
27
|
-
import DeltaCalculator from './DeltaBundler/DeltaCalculator';
|
|
28
|
-
|
|
29
27
|
export type {
|
|
30
28
|
DeltaResult,
|
|
31
29
|
Graph,
|
|
@@ -45,8 +43,6 @@ export type {
|
|
|
45
43
|
* `clientId` param (which maps a client to a specific delta transformer).
|
|
46
44
|
*/
|
|
47
45
|
declare class DeltaBundler<T = MixedOutput> {
|
|
48
|
-
_changeEventSource: EventEmitter;
|
|
49
|
-
_deltaCalculators: Map<Graph<T>, DeltaCalculator<T>>;
|
|
50
46
|
constructor(changeEventSource: EventEmitter);
|
|
51
47
|
end(): void;
|
|
52
48
|
getDependencies(
|
package/src/HmrServer.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
* @noformat
|
|
8
|
-
* @generated SignedSource<<
|
|
8
|
+
* @generated SignedSource<<48bfe42125bd22a8329f95a30fa90b64>>
|
|
9
9
|
*
|
|
10
10
|
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
11
11
|
* Original file: packages/metro/src/HmrServer.js
|
|
@@ -18,25 +18,13 @@ import type {
|
|
|
18
18
|
RevisionId,
|
|
19
19
|
default as IncrementalBundler,
|
|
20
20
|
} from './IncrementalBundler';
|
|
21
|
-
import type {
|
|
22
|
-
import type {ConfigT, RootPerfLogger} from 'metro-config';
|
|
23
|
-
import type {
|
|
24
|
-
HmrErrorMessage,
|
|
25
|
-
HmrUpdateMessage,
|
|
26
|
-
} from 'metro-runtime/src/modules/types';
|
|
21
|
+
import type {ConfigT} from 'metro-config';
|
|
27
22
|
|
|
28
23
|
export type Client = {
|
|
29
24
|
optedIntoHMR: boolean;
|
|
30
25
|
revisionIds: Array<RevisionId>;
|
|
31
26
|
readonly sendFn: ($$PARAM_0$$: string) => void;
|
|
32
27
|
};
|
|
33
|
-
type ClientGroup = {
|
|
34
|
-
readonly clients: Set<Client>;
|
|
35
|
-
clientUrl: URL;
|
|
36
|
-
revisionId: RevisionId;
|
|
37
|
-
readonly unlisten: () => void;
|
|
38
|
-
readonly graphOptions: GraphOptions;
|
|
39
|
-
};
|
|
40
28
|
/**
|
|
41
29
|
* The HmrServer (Hot Module Reloading) implements a lightweight interface
|
|
42
30
|
* to communicate easily to the logic in the React Native repository (which
|
|
@@ -47,10 +35,6 @@ type ClientGroup = {
|
|
|
47
35
|
* `onClientConnect`, `onClientDisconnect` and `onClientError` methods).
|
|
48
36
|
*/
|
|
49
37
|
declare class HmrServer<TClient extends Client> {
|
|
50
|
-
_config: ConfigT;
|
|
51
|
-
_bundler: IncrementalBundler;
|
|
52
|
-
_createModuleId: (path: string) => number;
|
|
53
|
-
_clientGroups: Map<RevisionId, ClientGroup>;
|
|
54
38
|
constructor(
|
|
55
39
|
bundler: IncrementalBundler,
|
|
56
40
|
createModuleId: (path: string) => number,
|
|
@@ -60,11 +44,6 @@ declare class HmrServer<TClient extends Client> {
|
|
|
60
44
|
requestUrl: string,
|
|
61
45
|
sendFn: (data: string) => void,
|
|
62
46
|
) => Promise<Client>;
|
|
63
|
-
_registerEntryPoint(
|
|
64
|
-
client: Client,
|
|
65
|
-
originalRequestUrl: string,
|
|
66
|
-
sendFn: (data: string) => void,
|
|
67
|
-
): Promise<void>;
|
|
68
47
|
onClientMessage: (
|
|
69
48
|
client: TClient,
|
|
70
49
|
message: string | Buffer | ArrayBuffer | Array<Buffer>,
|
|
@@ -72,27 +51,5 @@ declare class HmrServer<TClient extends Client> {
|
|
|
72
51
|
) => Promise<void>;
|
|
73
52
|
onClientError: (client: TClient, e: Error) => void;
|
|
74
53
|
onClientDisconnect: (client: TClient) => void;
|
|
75
|
-
_handleFileChange(
|
|
76
|
-
group: ClientGroup,
|
|
77
|
-
options: {isInitialUpdate: boolean},
|
|
78
|
-
changeEvent:
|
|
79
|
-
| null
|
|
80
|
-
| undefined
|
|
81
|
-
| {
|
|
82
|
-
readonly logger: null | undefined | RootPerfLogger;
|
|
83
|
-
readonly changeId?: string;
|
|
84
|
-
},
|
|
85
|
-
): Promise<void>;
|
|
86
|
-
_prepareMessage(
|
|
87
|
-
group: ClientGroup,
|
|
88
|
-
options: {isInitialUpdate: boolean},
|
|
89
|
-
changeEvent:
|
|
90
|
-
| null
|
|
91
|
-
| undefined
|
|
92
|
-
| {
|
|
93
|
-
readonly logger: null | undefined | RootPerfLogger;
|
|
94
|
-
readonly changeId?: string;
|
|
95
|
-
},
|
|
96
|
-
): Promise<HmrUpdateMessage | HmrErrorMessage>;
|
|
97
54
|
}
|
|
98
55
|
export default HmrServer;
|
package/src/HmrServer.js.flow
CHANGED
|
@@ -41,15 +41,15 @@ const {createActionStartEntry, createActionEndEntry, log} = Logger;
|
|
|
41
41
|
export type Client = {
|
|
42
42
|
optedIntoHMR: boolean,
|
|
43
43
|
revisionIds: Array<RevisionId>,
|
|
44
|
-
|
|
44
|
+
readonly sendFn: string => void,
|
|
45
45
|
};
|
|
46
46
|
|
|
47
47
|
type ClientGroup = {
|
|
48
|
-
|
|
48
|
+
readonly clients: Set<Client>,
|
|
49
49
|
clientUrl: URL,
|
|
50
50
|
revisionId: RevisionId,
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
readonly unlisten: () => void,
|
|
52
|
+
readonly graphOptions: GraphOptions,
|
|
53
53
|
};
|
|
54
54
|
|
|
55
55
|
function send(sendFns: Array<(string) => void>, message: HmrMessage): void {
|
|
@@ -181,8 +181,8 @@ export default class HmrServer<TClient extends Client> {
|
|
|
181
181
|
this._clientGroups.set(id, clientGroup);
|
|
182
182
|
|
|
183
183
|
let latestChangeEvent: ?{
|
|
184
|
-
|
|
185
|
-
|
|
184
|
+
readonly logger: ?RootPerfLogger,
|
|
185
|
+
readonly changeId: string,
|
|
186
186
|
} = null;
|
|
187
187
|
|
|
188
188
|
const debounceCallHandleFileChange = debounceAsyncQueue(async () => {
|
|
@@ -278,8 +278,8 @@ export default class HmrServer<TClient extends Client> {
|
|
|
278
278
|
group: ClientGroup,
|
|
279
279
|
options: {isInitialUpdate: boolean},
|
|
280
280
|
changeEvent: ?{
|
|
281
|
-
|
|
282
|
-
|
|
281
|
+
readonly logger: ?RootPerfLogger,
|
|
282
|
+
readonly changeId?: string,
|
|
283
283
|
},
|
|
284
284
|
): Promise<void> {
|
|
285
285
|
const logger = !options.isInitialUpdate ? changeEvent?.logger : null;
|
|
@@ -337,8 +337,8 @@ export default class HmrServer<TClient extends Client> {
|
|
|
337
337
|
group: ClientGroup,
|
|
338
338
|
options: {isInitialUpdate: boolean},
|
|
339
339
|
changeEvent: ?{
|
|
340
|
-
|
|
341
|
-
|
|
340
|
+
readonly logger: ?RootPerfLogger,
|
|
341
|
+
readonly changeId?: string,
|
|
342
342
|
},
|
|
343
343
|
): Promise<HmrUpdateMessage | HmrErrorMessage> {
|
|
344
344
|
const logger = !options.isInitialUpdate ? changeEvent?.logger : null;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @noformat
|
|
8
8
|
* @oncall react_native
|
|
9
|
-
* @generated SignedSource<<
|
|
9
|
+
* @generated SignedSource<<7ce634e158aa8f2ac74e32940e9e97c1>>
|
|
10
10
|
*
|
|
11
11
|
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
12
|
* Original file: packages/metro/src/IncrementalBundler.js
|
|
@@ -47,11 +47,6 @@ export type IncrementalBundlerOptions = Readonly<{
|
|
|
47
47
|
watch?: boolean;
|
|
48
48
|
}>;
|
|
49
49
|
declare class IncrementalBundler {
|
|
50
|
-
_config: ConfigT;
|
|
51
|
-
_bundler: Bundler;
|
|
52
|
-
_deltaBundler: DeltaBundler;
|
|
53
|
-
_revisionsById: Map<RevisionId, Promise<GraphRevision>>;
|
|
54
|
-
_revisionsByGraphId: Map<GraphId, Promise<GraphRevision>>;
|
|
55
50
|
static revisionIdFromString: (str: string) => RevisionId;
|
|
56
51
|
constructor(config: ConfigT, options?: IncrementalBundlerOptions);
|
|
57
52
|
end(): Promise<void>;
|
|
@@ -95,9 +90,6 @@ declare class IncrementalBundler {
|
|
|
95
90
|
reset: boolean,
|
|
96
91
|
): Promise<{delta: DeltaResult; revision: GraphRevision}>;
|
|
97
92
|
endGraph(graphId: GraphId): Promise<void>;
|
|
98
|
-
_getAbsoluteEntryFiles(
|
|
99
|
-
entryFiles: ReadonlyArray<string>,
|
|
100
|
-
): Promise<ReadonlyArray<string>>;
|
|
101
93
|
ready(): Promise<void>;
|
|
102
94
|
}
|
|
103
95
|
export default IncrementalBundler;
|
|
@@ -41,11 +41,11 @@ type OtherOptions = Readonly<{
|
|
|
41
41
|
|
|
42
42
|
export type GraphRevision = {
|
|
43
43
|
// Identifies the last computed revision.
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
readonly id: RevisionId,
|
|
45
|
+
readonly date: Date,
|
|
46
|
+
readonly graphId: GraphId,
|
|
47
|
+
readonly graph: OutputGraph,
|
|
48
|
+
readonly prepend: ReadonlyArray<Module<>>,
|
|
49
49
|
};
|
|
50
50
|
|
|
51
51
|
export type IncrementalBundlerOptions = Readonly<{
|
|
@@ -199,7 +199,10 @@ export default class IncrementalBundler {
|
|
|
199
199
|
shallow: false,
|
|
200
200
|
lazy: false,
|
|
201
201
|
},
|
|
202
|
-
): Promise<{
|
|
202
|
+
): Promise<{
|
|
203
|
+
readonly graph: OutputGraph,
|
|
204
|
+
readonly prepend: ReadonlyArray<Module<>>,
|
|
205
|
+
}> {
|
|
203
206
|
const graph = await this.buildGraphForEntries(
|
|
204
207
|
[entryFile],
|
|
205
208
|
transformOptions,
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
* @noformat
|
|
8
|
-
* @generated SignedSource<<
|
|
8
|
+
* @generated SignedSource<<f072a86187014259ece27c02d9abfd6a>>
|
|
9
9
|
*
|
|
10
10
|
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
11
11
|
* Original file: packages/metro/src/ModuleGraph/worker/collectDependencies.js
|
|
@@ -132,7 +132,6 @@ export type ImportQualifier = Readonly<{
|
|
|
132
132
|
contextParams?: RequireContextParams;
|
|
133
133
|
}>;
|
|
134
134
|
declare class DependencyRegistry {
|
|
135
|
-
_dependencies: Map<string, InternalDependency>;
|
|
136
135
|
registerDependency(qualifier: ImportQualifier): InternalDependency;
|
|
137
136
|
getDependencies(): Array<InternalDependency>;
|
|
138
137
|
}
|
|
@@ -20,10 +20,10 @@ import {greatestLowerBound} from 'metro-source-map/private/Consumer/search';
|
|
|
20
20
|
import {SourceMetadataMapConsumer} from 'metro-symbolicate/private/Symbolication';
|
|
21
21
|
|
|
22
22
|
export type StackFrameInput = {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
readonly file: ?string,
|
|
24
|
+
readonly lineNumber: ?number,
|
|
25
|
+
readonly column: ?number,
|
|
26
|
+
readonly methodName: ?string,
|
|
27
27
|
...
|
|
28
28
|
};
|
|
29
29
|
export type IntermediateStackFrame = {
|
|
@@ -33,7 +33,7 @@ export type IntermediateStackFrame = {
|
|
|
33
33
|
};
|
|
34
34
|
export type StackFrameOutput = Readonly<IntermediateStackFrame>;
|
|
35
35
|
type ExplodedSourceMapModule = ExplodedSourceMap[number];
|
|
36
|
-
type Position = {
|
|
36
|
+
type Position = {readonly line1Based: number, column0Based: number};
|
|
37
37
|
|
|
38
38
|
function createFunctionNameGetter(
|
|
39
39
|
module: ExplodedSourceMapModule,
|
|
@@ -68,10 +68,10 @@ export default async function symbolicate(
|
|
|
68
68
|
}
|
|
69
69
|
const functionNameGetters = new Map<
|
|
70
70
|
{
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
readonly firstLine1Based: number,
|
|
72
|
+
readonly functionMap: ?FBSourceFunctionMap,
|
|
73
|
+
readonly map: Array<MetroSourceMapSegmentTuple>,
|
|
74
|
+
readonly path: string,
|
|
75
75
|
},
|
|
76
76
|
(Position) => ?string,
|
|
77
77
|
>();
|
|
@@ -138,10 +138,10 @@ export default async function symbolicate(
|
|
|
138
138
|
function findFunctionName(
|
|
139
139
|
originalPos: Position,
|
|
140
140
|
module: {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
141
|
+
readonly firstLine1Based: number,
|
|
142
|
+
readonly functionMap: ?FBSourceFunctionMap,
|
|
143
|
+
readonly map: Array<MetroSourceMapSegmentTuple>,
|
|
144
|
+
readonly path: string,
|
|
145
145
|
},
|
|
146
146
|
): ?string {
|
|
147
147
|
if (module.functionMap) {
|
package/src/Server.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @noformat
|
|
8
8
|
* @oncall react_native
|
|
9
|
-
* @generated SignedSource<<
|
|
9
|
+
* @generated SignedSource<<a4fd26fa84b68e8bc2b3c32bcf36e7bc>>
|
|
10
10
|
*
|
|
11
11
|
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
12
|
* Original file: packages/metro/src/Server.js
|
|
@@ -16,38 +16,16 @@
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
import type {AssetData} from './Assets';
|
|
19
|
-
import type {ExplodedSourceMap} from './DeltaBundler/Serializers/getExplodedSourceMap';
|
|
20
19
|
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';
|
|
20
|
+
import type {BuildOptions, BundleOptions} from './shared/types';
|
|
37
21
|
import type {IncomingMessage} from 'connect';
|
|
38
22
|
import type {ServerResponse} from 'http';
|
|
39
|
-
import type {ConfigT
|
|
40
|
-
import type {
|
|
41
|
-
ActionLogEntryData,
|
|
42
|
-
ActionStartLogEntry,
|
|
43
|
-
} from 'metro-core/private/Logger';
|
|
23
|
+
import type {ConfigT} from 'metro-config';
|
|
44
24
|
import type {CustomResolverOptions} from 'metro-resolver/private/types';
|
|
45
25
|
import type {CustomTransformOptions} from 'metro-transform-worker';
|
|
46
26
|
|
|
47
27
|
import IncrementalBundler from './IncrementalBundler';
|
|
48
|
-
import MultipartResponse from './Server/MultipartResponse';
|
|
49
28
|
import {SourcePathsMode} from './shared/types';
|
|
50
|
-
import {Logger} from 'metro-core';
|
|
51
29
|
|
|
52
30
|
export type SegmentLoadData = {
|
|
53
31
|
[$$Key$$: number]: [Array<number>, null | undefined | number];
|
|
@@ -59,183 +37,33 @@ export type BundleMetadata = {
|
|
|
59
37
|
segmentHashes: Array<string>;
|
|
60
38
|
segmentLoadData: SegmentLoadData;
|
|
61
39
|
};
|
|
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
40
|
export type ServerOptions = Readonly<{
|
|
96
41
|
hasReducedPerformance?: boolean;
|
|
97
42
|
onBundleBuilt?: (bundlePath: string) => void;
|
|
98
43
|
watch?: boolean;
|
|
99
44
|
}>;
|
|
100
|
-
type FetchTiming = {
|
|
101
|
-
graphId: GraphId;
|
|
102
|
-
startTime: number;
|
|
103
|
-
endTime: number | null;
|
|
104
|
-
isPrefetch: boolean;
|
|
105
|
-
};
|
|
106
45
|
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
46
|
constructor(config: ConfigT, options?: ServerOptions);
|
|
123
47
|
end(): void;
|
|
124
48
|
getBundler(): IncrementalBundler;
|
|
125
49
|
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
50
|
build(
|
|
134
51
|
bundleOptions: BundleOptions,
|
|
135
52
|
$$PARAM_1$$?: BuildOptions,
|
|
136
53
|
): Promise<{code: string; map: string; assets?: ReadonlyArray<AssetData>}>;
|
|
137
54
|
getRamBundleInfo(options: BundleOptions): Promise<RamBundleInfo>;
|
|
138
55
|
getAssets(options: BundleOptions): Promise<ReadonlyArray<AssetData>>;
|
|
139
|
-
_getAssetsFromDependencies(
|
|
140
|
-
dependencies: ReadOnlyDependencies,
|
|
141
|
-
platform: null | undefined | string,
|
|
142
|
-
): Promise<ReadonlyArray<AssetData>>;
|
|
143
56
|
getOrderedDependencyPaths(options: {
|
|
144
57
|
readonly dev: boolean;
|
|
145
58
|
readonly entryFile: string;
|
|
146
59
|
readonly minify: boolean;
|
|
147
60
|
readonly platform: null | undefined | string;
|
|
148
61
|
}): 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
62
|
processRequest: (
|
|
160
63
|
$$PARAM_0$$: IncomingMessage,
|
|
161
64
|
$$PARAM_1$$: ServerResponse,
|
|
162
65
|
$$PARAM_2$$: (e: null | undefined | Error) => void,
|
|
163
66
|
) => 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
|
-
_resolveWatchFolderPrefix(
|
|
229
|
-
filePath: string,
|
|
230
|
-
): {rootDir: string; filePath: string} | null;
|
|
231
|
-
_resolveRelativePath(
|
|
232
|
-
filePath: string,
|
|
233
|
-
$$PARAM_1$$: Readonly<{
|
|
234
|
-
relativeTo: 'project' | 'server';
|
|
235
|
-
resolverOptions: ResolverInputOptions;
|
|
236
|
-
transformOptions: TransformInputOptions;
|
|
237
|
-
}>,
|
|
238
|
-
): Promise<string>;
|
|
239
67
|
getNewBuildNumber(): number;
|
|
240
68
|
getPlatforms(): ReadonlyArray<string>;
|
|
241
69
|
getWatchFolders(): ReadonlyArray<string>;
|
|
@@ -272,10 +100,6 @@ declare class Server {
|
|
|
272
100
|
sourceUrl: null;
|
|
273
101
|
sourcePaths: SourcePathsMode;
|
|
274
102
|
};
|
|
275
|
-
_getServerRootDir(): string;
|
|
276
|
-
_getEntryPointAbsolutePath(entryFile: string): string;
|
|
277
103
|
ready(): Promise<void>;
|
|
278
|
-
_shouldAddModuleToIgnoreList(module: Module): boolean;
|
|
279
|
-
_getModuleSourceUrl(module: Module, mode: SourcePathsMode): string;
|
|
280
104
|
}
|
|
281
105
|
export default Server;
|
package/src/Server.js.flow
CHANGED
|
@@ -100,26 +100,26 @@ export type BundleMetadata = {
|
|
|
100
100
|
|
|
101
101
|
type ProcessStartContext = {
|
|
102
102
|
...SplitBundleOptions,
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
103
|
+
readonly buildNumber: number,
|
|
104
|
+
readonly bundleOptions: BundleOptions,
|
|
105
|
+
readonly graphId: GraphId,
|
|
106
|
+
readonly graphOptions: GraphOptions,
|
|
107
|
+
readonly mres: MultipartResponse | ServerResponse,
|
|
108
|
+
readonly req: IncomingMessage,
|
|
109
|
+
readonly revisionId?: ?RevisionId,
|
|
110
|
+
readonly bundlePerfLogger: RootPerfLogger,
|
|
111
|
+
readonly requestStartTimestamp: number,
|
|
112
112
|
};
|
|
113
113
|
|
|
114
114
|
type ProcessDeleteContext = {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
115
|
+
readonly graphId: GraphId,
|
|
116
|
+
readonly req: IncomingMessage,
|
|
117
|
+
readonly res: ServerResponse,
|
|
118
118
|
};
|
|
119
119
|
|
|
120
120
|
type ProcessEndContext<T> = {
|
|
121
121
|
...ProcessStartContext,
|
|
122
|
-
|
|
122
|
+
readonly result: T,
|
|
123
123
|
};
|
|
124
124
|
|
|
125
125
|
export type ServerOptions = Readonly<{
|
|
@@ -446,10 +446,10 @@ export default class Server {
|
|
|
446
446
|
}
|
|
447
447
|
|
|
448
448
|
async getOrderedDependencyPaths(options: {
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
449
|
+
readonly dev: boolean,
|
|
450
|
+
readonly entryFile: string,
|
|
451
|
+
readonly minify: boolean,
|
|
452
|
+
readonly platform: ?string,
|
|
453
453
|
...
|
|
454
454
|
}): Promise<Array<string>> {
|
|
455
455
|
const {
|
|
@@ -768,14 +768,16 @@ export default class Server {
|
|
|
768
768
|
delete: deleteFn,
|
|
769
769
|
finish,
|
|
770
770
|
}: {
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
771
|
+
readonly bundleType: 'assets' | 'bundle' | 'map',
|
|
772
|
+
readonly createStartEntry: (
|
|
773
|
+
context: ProcessStartContext,
|
|
774
|
+
) => ActionLogEntryData,
|
|
775
|
+
readonly createEndEntry: (
|
|
774
776
|
context: ProcessEndContext<T>,
|
|
775
777
|
) => Partial<ActionStartLogEntry>,
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
778
|
+
readonly build: (context: ProcessStartContext) => Promise<T>,
|
|
779
|
+
readonly delete?: (context: ProcessDeleteContext) => Promise<void>,
|
|
780
|
+
readonly finish: (context: ProcessEndContext<T>) => void,
|
|
779
781
|
}): (
|
|
780
782
|
req: IncomingMessage,
|
|
781
783
|
res: ServerResponse,
|