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,170 @@
|
|
|
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<<feddf9cb00d4a097d348531773c9f0bd>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/DeltaBundler/types.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 {RequireContext} from '../lib/contextModule';
|
|
19
|
+
import type {RequireContextParams} from '../ModuleGraph/worker/collectDependencies';
|
|
20
|
+
import type {ReadonlySourceLocation} from '../shared/types';
|
|
21
|
+
import type {Graph} from './Graph';
|
|
22
|
+
import type {JsTransformOptions} from 'metro-transform-worker';
|
|
23
|
+
|
|
24
|
+
import CountingSet from '../lib/CountingSet';
|
|
25
|
+
|
|
26
|
+
export type MixedOutput = {readonly data: unknown; readonly type: string};
|
|
27
|
+
export type AsyncDependencyType = 'async' | 'maybeSync' | 'prefetch' | 'weak';
|
|
28
|
+
export type TransformResultDependency = Readonly<{
|
|
29
|
+
/**
|
|
30
|
+
* The literal name provided to a require or import call. For example 'foo' in
|
|
31
|
+
* case of `require('foo')`.
|
|
32
|
+
*/
|
|
33
|
+
name: string;
|
|
34
|
+
/**
|
|
35
|
+
* Extra data returned by the dependency extractor.
|
|
36
|
+
*/
|
|
37
|
+
data: Readonly<{
|
|
38
|
+
/**
|
|
39
|
+
* A locally unique key for this dependency within the current module.
|
|
40
|
+
*/
|
|
41
|
+
key: string;
|
|
42
|
+
/**
|
|
43
|
+
* If not null, this dependency is due to a dynamic `import()` or `__prefetchImport()` call.
|
|
44
|
+
*/
|
|
45
|
+
asyncType: AsyncDependencyType | null;
|
|
46
|
+
/**
|
|
47
|
+
* True if the dependency is declared with a static "import x from 'y'" or
|
|
48
|
+
* an import() call.
|
|
49
|
+
*/
|
|
50
|
+
isESMImport: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* The dependency is enclosed in a try/catch block.
|
|
53
|
+
*/
|
|
54
|
+
isOptional?: boolean;
|
|
55
|
+
locs: ReadonlyArray<ReadonlySourceLocation>;
|
|
56
|
+
/** Context for requiring a collection of modules. */
|
|
57
|
+
contextParams?: RequireContextParams;
|
|
58
|
+
}>;
|
|
59
|
+
}>;
|
|
60
|
+
export type ResolvedDependency = Readonly<{
|
|
61
|
+
absolutePath: string;
|
|
62
|
+
data: TransformResultDependency;
|
|
63
|
+
}>;
|
|
64
|
+
export type Dependency =
|
|
65
|
+
| ResolvedDependency
|
|
66
|
+
| Readonly<{data: TransformResultDependency}>;
|
|
67
|
+
export type Module<T = MixedOutput> = Readonly<{
|
|
68
|
+
dependencies: Map<string, Dependency>;
|
|
69
|
+
inverseDependencies: CountingSet<string>;
|
|
70
|
+
output: ReadonlyArray<T>;
|
|
71
|
+
path: string;
|
|
72
|
+
getSource: () => Buffer;
|
|
73
|
+
unstable_transformResultKey?: null | undefined | string;
|
|
74
|
+
}>;
|
|
75
|
+
export type ModuleData<T = MixedOutput> = Readonly<{
|
|
76
|
+
dependencies: ReadonlyMap<string, Dependency>;
|
|
77
|
+
resolvedContexts: ReadonlyMap<string, RequireContext>;
|
|
78
|
+
output: ReadonlyArray<T>;
|
|
79
|
+
getSource: () => Buffer;
|
|
80
|
+
unstable_transformResultKey?: null | undefined | string;
|
|
81
|
+
}>;
|
|
82
|
+
export type Dependencies<T = MixedOutput> = Map<string, Module<T>>;
|
|
83
|
+
export type ReadOnlyDependencies<T = MixedOutput> = ReadonlyMap<
|
|
84
|
+
string,
|
|
85
|
+
Module<T>
|
|
86
|
+
>;
|
|
87
|
+
export type TransformInputOptions = Omit<
|
|
88
|
+
JsTransformOptions,
|
|
89
|
+
'inlinePlatform' | 'inlineRequires'
|
|
90
|
+
>;
|
|
91
|
+
export type GraphInputOptions = Readonly<{
|
|
92
|
+
entryPoints: ReadonlySet<string>;
|
|
93
|
+
transformOptions: TransformInputOptions;
|
|
94
|
+
}>;
|
|
95
|
+
export interface ReadOnlyGraph<T = MixedOutput> {
|
|
96
|
+
readonly entryPoints: ReadonlySet<string>;
|
|
97
|
+
readonly transformOptions: Readonly<TransformInputOptions>;
|
|
98
|
+
readonly dependencies: ReadOnlyDependencies<T>;
|
|
99
|
+
}
|
|
100
|
+
export type {Graph};
|
|
101
|
+
export type TransformResult<T = MixedOutput> = Readonly<{
|
|
102
|
+
dependencies: ReadonlyArray<TransformResultDependency>;
|
|
103
|
+
output: ReadonlyArray<T>;
|
|
104
|
+
unstable_transformResultKey?: null | undefined | string;
|
|
105
|
+
}>;
|
|
106
|
+
export type TransformResultWithSource<T = MixedOutput> = Readonly<
|
|
107
|
+
Omit<TransformResult<T>, keyof {getSource: () => Buffer}> & {
|
|
108
|
+
getSource: () => Buffer;
|
|
109
|
+
}
|
|
110
|
+
>;
|
|
111
|
+
export type TransformFn<T = MixedOutput> = (
|
|
112
|
+
$$PARAM_0$$: string,
|
|
113
|
+
$$PARAM_1$$: null | undefined | RequireContext,
|
|
114
|
+
) => Promise<TransformResultWithSource<T>>;
|
|
115
|
+
export type ResolveFn = (
|
|
116
|
+
from: string,
|
|
117
|
+
dependency: TransformResultDependency,
|
|
118
|
+
) => BundlerResolution;
|
|
119
|
+
export type AllowOptionalDependenciesWithOptions = {
|
|
120
|
+
readonly exclude: Array<string>;
|
|
121
|
+
};
|
|
122
|
+
export type AllowOptionalDependencies =
|
|
123
|
+
| boolean
|
|
124
|
+
| AllowOptionalDependenciesWithOptions;
|
|
125
|
+
export type BundlerResolution = Readonly<{
|
|
126
|
+
type: 'sourceFile';
|
|
127
|
+
filePath: string;
|
|
128
|
+
}>;
|
|
129
|
+
export type Options<T = MixedOutput> = Readonly<{
|
|
130
|
+
resolve: ResolveFn;
|
|
131
|
+
transform: TransformFn<T>;
|
|
132
|
+
transformOptions: TransformInputOptions;
|
|
133
|
+
onProgress:
|
|
134
|
+
| null
|
|
135
|
+
| undefined
|
|
136
|
+
| ((numProcessed: number, total: number) => unknown);
|
|
137
|
+
lazy: boolean;
|
|
138
|
+
unstable_allowRequireContext: boolean;
|
|
139
|
+
unstable_enablePackageExports: boolean;
|
|
140
|
+
unstable_incrementalResolution: boolean;
|
|
141
|
+
shallow: boolean;
|
|
142
|
+
}>;
|
|
143
|
+
export type DeltaResult<T = MixedOutput> = {
|
|
144
|
+
readonly added: Map<string, Module<T>>;
|
|
145
|
+
readonly modified: Map<string, Module<T>>;
|
|
146
|
+
readonly deleted: Set<string>;
|
|
147
|
+
readonly reset: boolean;
|
|
148
|
+
};
|
|
149
|
+
export type SerializerOptions = Readonly<{
|
|
150
|
+
asyncRequireModulePath: string;
|
|
151
|
+
createModuleId: ($$PARAM_0$$: string) => number;
|
|
152
|
+
dev: boolean;
|
|
153
|
+
getRunModuleStatement: (
|
|
154
|
+
moduleId: number | string,
|
|
155
|
+
globalPrefix: string,
|
|
156
|
+
) => string;
|
|
157
|
+
globalPrefix: string;
|
|
158
|
+
includeAsyncPaths: boolean;
|
|
159
|
+
inlineSourceMap: null | undefined | boolean;
|
|
160
|
+
modulesOnly: boolean;
|
|
161
|
+
processModuleFilter: (module: Module) => boolean;
|
|
162
|
+
projectRoot: string;
|
|
163
|
+
runBeforeMainModule: ReadonlyArray<string>;
|
|
164
|
+
runModule: boolean;
|
|
165
|
+
serverRoot: string;
|
|
166
|
+
shouldAddToIgnoreList: ($$PARAM_0$$: Module) => boolean;
|
|
167
|
+
sourceMapUrl: null | undefined | string;
|
|
168
|
+
sourceUrl: null | undefined | string;
|
|
169
|
+
getSourceUrl: null | undefined | (($$PARAM_0$$: Module) => string);
|
|
170
|
+
}>;
|
|
@@ -0,0 +1,67 @@
|
|
|
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<<db564db653a99b07f3ad7585b2bed707>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/DeltaBundler.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
|
+
DeltaResult,
|
|
20
|
+
Graph,
|
|
21
|
+
MixedOutput,
|
|
22
|
+
Options,
|
|
23
|
+
ReadOnlyGraph,
|
|
24
|
+
} from './DeltaBundler/types';
|
|
25
|
+
import type EventEmitter from 'events';
|
|
26
|
+
|
|
27
|
+
import DeltaCalculator from './DeltaBundler/DeltaCalculator';
|
|
28
|
+
|
|
29
|
+
export type {
|
|
30
|
+
DeltaResult,
|
|
31
|
+
Graph,
|
|
32
|
+
Dependencies,
|
|
33
|
+
MixedOutput,
|
|
34
|
+
Module,
|
|
35
|
+
ReadOnlyGraph,
|
|
36
|
+
TransformFn,
|
|
37
|
+
TransformResult,
|
|
38
|
+
TransformResultDependency,
|
|
39
|
+
TransformResultWithSource,
|
|
40
|
+
} from './DeltaBundler/types';
|
|
41
|
+
/**
|
|
42
|
+
* `DeltaBundler` uses the `DeltaTransformer` to build bundle deltas. This
|
|
43
|
+
* module handles all the transformer instances so it can support multiple
|
|
44
|
+
* concurrent clients requesting their own deltas. This is done through the
|
|
45
|
+
* `clientId` param (which maps a client to a specific delta transformer).
|
|
46
|
+
*/
|
|
47
|
+
declare class DeltaBundler<T = MixedOutput> {
|
|
48
|
+
_changeEventSource: EventEmitter;
|
|
49
|
+
_deltaCalculators: Map<Graph<T>, DeltaCalculator<T>>;
|
|
50
|
+
constructor(changeEventSource: EventEmitter);
|
|
51
|
+
end(): void;
|
|
52
|
+
getDependencies(
|
|
53
|
+
entryPoints: ReadonlyArray<string>,
|
|
54
|
+
options: Options<T>,
|
|
55
|
+
): Promise<ReadOnlyGraph<T>['dependencies']>;
|
|
56
|
+
buildGraph(
|
|
57
|
+
entryPoints: ReadonlyArray<string>,
|
|
58
|
+
options: Options<T>,
|
|
59
|
+
): Promise<Graph<T>>;
|
|
60
|
+
getDelta(
|
|
61
|
+
graph: Graph<T>,
|
|
62
|
+
$$PARAM_1$$: {reset: boolean; shallow: boolean},
|
|
63
|
+
): Promise<DeltaResult<T>>;
|
|
64
|
+
listen(graph: Graph<T>, callback: () => Promise<void>): () => void;
|
|
65
|
+
endGraph(graph: Graph<T>): void;
|
|
66
|
+
}
|
|
67
|
+
export default DeltaBundler;
|
|
@@ -0,0 +1,86 @@
|
|
|
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<<759aad52b112d43c0af68fdad28e4453>>
|
|
9
|
+
*
|
|
10
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
11
|
+
* Original file: packages/metro/src/HmrServer.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 {
|
|
18
|
+
RevisionId,
|
|
19
|
+
default as IncrementalBundler,
|
|
20
|
+
} from './IncrementalBundler';
|
|
21
|
+
import type {GraphOptions} from './shared/types';
|
|
22
|
+
import type {ConfigT, RootPerfLogger} from 'metro-config';
|
|
23
|
+
import type {
|
|
24
|
+
HmrErrorMessage,
|
|
25
|
+
HmrUpdateMessage,
|
|
26
|
+
} from 'metro-runtime/src/modules/types';
|
|
27
|
+
|
|
28
|
+
export type Client = {
|
|
29
|
+
optedIntoHMR: boolean;
|
|
30
|
+
revisionIds: Array<RevisionId>;
|
|
31
|
+
readonly sendFn: ($$PARAM_0$$: string) => void;
|
|
32
|
+
};
|
|
33
|
+
type ClientGroup = {
|
|
34
|
+
readonly clients: Set<Client>;
|
|
35
|
+
clientUrl: URL;
|
|
36
|
+
revisionId: RevisionId;
|
|
37
|
+
readonly unlisten: () => void;
|
|
38
|
+
readonly graphOptions: GraphOptions;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* The HmrServer (Hot Module Reloading) implements a lightweight interface
|
|
42
|
+
* to communicate easily to the logic in the React Native repository (which
|
|
43
|
+
* is the one that handles the Web Socket connections).
|
|
44
|
+
*
|
|
45
|
+
* This interface allows the HmrServer to hook its own logic to WS clients
|
|
46
|
+
* getting connected, disconnected or having errors (through the
|
|
47
|
+
* `onClientConnect`, `onClientDisconnect` and `onClientError` methods).
|
|
48
|
+
*/
|
|
49
|
+
declare class HmrServer<TClient extends Client> {
|
|
50
|
+
_config: ConfigT;
|
|
51
|
+
_bundler: IncrementalBundler;
|
|
52
|
+
_createModuleId: (path: string) => number;
|
|
53
|
+
_clientGroups: Map<RevisionId, ClientGroup>;
|
|
54
|
+
constructor(
|
|
55
|
+
bundler: IncrementalBundler,
|
|
56
|
+
createModuleId: (path: string) => number,
|
|
57
|
+
config: ConfigT,
|
|
58
|
+
);
|
|
59
|
+
onClientConnect: (
|
|
60
|
+
requestUrl: string,
|
|
61
|
+
sendFn: (data: string) => void,
|
|
62
|
+
) => Promise<Client>;
|
|
63
|
+
_registerEntryPoint(
|
|
64
|
+
client: Client,
|
|
65
|
+
originalRequestUrl: string,
|
|
66
|
+
sendFn: (data: string) => void,
|
|
67
|
+
): Promise<void>;
|
|
68
|
+
onClientMessage: (
|
|
69
|
+
client: TClient,
|
|
70
|
+
message: string | Buffer | ArrayBuffer | Array<Buffer>,
|
|
71
|
+
sendFn: (data: string) => void,
|
|
72
|
+
) => Promise<void>;
|
|
73
|
+
onClientError: (client: TClient, e: Error) => void;
|
|
74
|
+
onClientDisconnect: (client: TClient) => void;
|
|
75
|
+
_handleFileChange(
|
|
76
|
+
group: ClientGroup,
|
|
77
|
+
options: {isInitialUpdate: boolean},
|
|
78
|
+
changeEvent: null | undefined | {logger: null | undefined | RootPerfLogger},
|
|
79
|
+
): Promise<void>;
|
|
80
|
+
_prepareMessage(
|
|
81
|
+
group: ClientGroup,
|
|
82
|
+
options: {isInitialUpdate: boolean},
|
|
83
|
+
changeEvent: null | undefined | {logger: null | undefined | RootPerfLogger},
|
|
84
|
+
): Promise<HmrUpdateMessage | HmrErrorMessage>;
|
|
85
|
+
}
|
|
86
|
+
export default HmrServer;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @noformat
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
* @generated SignedSource<<850ba6867e140fb0973cd13d0fd1bc60>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/IncrementalBundler/GraphNotFoundError.js
|
|
13
|
+
* To regenerate, run:
|
|
14
|
+
* js1 build metro-ts-defs (internal) OR
|
|
15
|
+
* yarn run build-ts-defs (OSS)
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import type {GraphId} from '../lib/getGraphId';
|
|
19
|
+
|
|
20
|
+
declare class GraphNotFoundError extends Error {
|
|
21
|
+
graphId: GraphId;
|
|
22
|
+
constructor(graphId: GraphId);
|
|
23
|
+
}
|
|
24
|
+
export default GraphNotFoundError;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @noformat
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
* @generated SignedSource<<6a9d75bc74b654362c3563ec8babda0b>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/IncrementalBundler/ResourceNotFoundError.js
|
|
13
|
+
* To regenerate, run:
|
|
14
|
+
* js1 build metro-ts-defs (internal) OR
|
|
15
|
+
* yarn run build-ts-defs (OSS)
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
declare class ResourceNotFoundError extends Error {
|
|
19
|
+
resourcePath: string;
|
|
20
|
+
constructor(resourcePath: string);
|
|
21
|
+
}
|
|
22
|
+
export default ResourceNotFoundError;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @noformat
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
* @generated SignedSource<<2c2d4a1a2d357eb73806a68bba897795>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/IncrementalBundler/RevisionNotFoundError.js
|
|
13
|
+
* To regenerate, run:
|
|
14
|
+
* js1 build metro-ts-defs (internal) OR
|
|
15
|
+
* yarn run build-ts-defs (OSS)
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import type {RevisionId} from '../IncrementalBundler';
|
|
19
|
+
|
|
20
|
+
declare class RevisionNotFoundError extends Error {
|
|
21
|
+
revisionId: RevisionId;
|
|
22
|
+
constructor(revisionId: RevisionId);
|
|
23
|
+
}
|
|
24
|
+
export default RevisionNotFoundError;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @noformat
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
* @generated SignedSource<<0ec72971869a882d97b381e3f1baa922>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/IncrementalBundler.js
|
|
13
|
+
* To regenerate, run:
|
|
14
|
+
* js1 build metro-ts-defs (internal) OR
|
|
15
|
+
* yarn run build-ts-defs (OSS)
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import type {DeltaResult, Graph, Module} from './DeltaBundler';
|
|
19
|
+
import type {
|
|
20
|
+
Options as DeltaBundlerOptions,
|
|
21
|
+
ReadOnlyDependencies,
|
|
22
|
+
TransformInputOptions,
|
|
23
|
+
} from './DeltaBundler/types';
|
|
24
|
+
import type {GraphId} from './lib/getGraphId';
|
|
25
|
+
import type {ResolverInputOptions} from './shared/types';
|
|
26
|
+
import type {ConfigT} from 'metro-config';
|
|
27
|
+
|
|
28
|
+
import Bundler from './Bundler';
|
|
29
|
+
import DeltaBundler from './DeltaBundler';
|
|
30
|
+
|
|
31
|
+
export declare type RevisionId = string;
|
|
32
|
+
export type OutputGraph = Graph;
|
|
33
|
+
type OtherOptions = Readonly<{
|
|
34
|
+
onProgress: DeltaBundlerOptions['onProgress'];
|
|
35
|
+
shallow: boolean;
|
|
36
|
+
lazy: boolean;
|
|
37
|
+
}>;
|
|
38
|
+
export type GraphRevision = {
|
|
39
|
+
readonly id: RevisionId;
|
|
40
|
+
readonly date: Date;
|
|
41
|
+
readonly graphId: GraphId;
|
|
42
|
+
readonly graph: OutputGraph;
|
|
43
|
+
readonly prepend: ReadonlyArray<Module>;
|
|
44
|
+
};
|
|
45
|
+
export type IncrementalBundlerOptions = Readonly<{
|
|
46
|
+
hasReducedPerformance?: boolean;
|
|
47
|
+
watch?: boolean;
|
|
48
|
+
}>;
|
|
49
|
+
declare class IncrementalBundler {
|
|
50
|
+
_config: ConfigT;
|
|
51
|
+
_bundler: Bundler;
|
|
52
|
+
_deltaBundler: DeltaBundler;
|
|
53
|
+
_revisionsById: Map<RevisionId, Promise<GraphRevision>>;
|
|
54
|
+
_revisionsByGraphId: Map<GraphId, Promise<GraphRevision>>;
|
|
55
|
+
static revisionIdFromString: (str: string) => RevisionId;
|
|
56
|
+
constructor(config: ConfigT, options?: IncrementalBundlerOptions);
|
|
57
|
+
end(): Promise<void>;
|
|
58
|
+
getBundler(): Bundler;
|
|
59
|
+
getDeltaBundler(): DeltaBundler;
|
|
60
|
+
getRevision(
|
|
61
|
+
revisionId: RevisionId,
|
|
62
|
+
): null | undefined | Promise<GraphRevision>;
|
|
63
|
+
getRevisionByGraphId(
|
|
64
|
+
graphId: GraphId,
|
|
65
|
+
): null | undefined | Promise<GraphRevision>;
|
|
66
|
+
buildGraphForEntries(
|
|
67
|
+
entryFiles: ReadonlyArray<string>,
|
|
68
|
+
transformOptions: TransformInputOptions,
|
|
69
|
+
resolverOptions: ResolverInputOptions,
|
|
70
|
+
otherOptions?: OtherOptions,
|
|
71
|
+
): Promise<OutputGraph>;
|
|
72
|
+
getDependencies(
|
|
73
|
+
entryFiles: ReadonlyArray<string>,
|
|
74
|
+
transformOptions: TransformInputOptions,
|
|
75
|
+
resolverOptions: ResolverInputOptions,
|
|
76
|
+
otherOptions?: OtherOptions,
|
|
77
|
+
): Promise<ReadOnlyDependencies>;
|
|
78
|
+
buildGraph(
|
|
79
|
+
entryFile: string,
|
|
80
|
+
transformOptions: TransformInputOptions,
|
|
81
|
+
resolverOptions: ResolverInputOptions,
|
|
82
|
+
otherOptions?: OtherOptions,
|
|
83
|
+
): Promise<{
|
|
84
|
+
readonly graph: OutputGraph;
|
|
85
|
+
readonly prepend: ReadonlyArray<Module>;
|
|
86
|
+
}>;
|
|
87
|
+
initializeGraph(
|
|
88
|
+
entryFile: string,
|
|
89
|
+
transformOptions: TransformInputOptions,
|
|
90
|
+
resolverOptions: ResolverInputOptions,
|
|
91
|
+
otherOptions?: OtherOptions,
|
|
92
|
+
): Promise<{delta: DeltaResult; revision: GraphRevision}>;
|
|
93
|
+
updateGraph(
|
|
94
|
+
revision: GraphRevision,
|
|
95
|
+
reset: boolean,
|
|
96
|
+
): Promise<{delta: DeltaResult; revision: GraphRevision}>;
|
|
97
|
+
endGraph(graphId: GraphId): Promise<void>;
|
|
98
|
+
_getAbsoluteEntryFiles(
|
|
99
|
+
entryFiles: ReadonlyArray<string>,
|
|
100
|
+
): Promise<ReadonlyArray<string>>;
|
|
101
|
+
ready(): Promise<void>;
|
|
102
|
+
}
|
|
103
|
+
export default IncrementalBundler;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @noformat
|
|
8
|
+
* @generated SignedSource<<ef37054bf63dff008ccc8b58a2411597>>
|
|
9
|
+
*
|
|
10
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
11
|
+
* Original file: packages/metro/src/ModuleGraph/worker/JsFileWrapping.js
|
|
12
|
+
* To regenerate, run:
|
|
13
|
+
* js1 build metro-ts-defs (internal) OR
|
|
14
|
+
* yarn run build-ts-defs (OSS)
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import type {File as BabelNodeFile} from '@babel/types';
|
|
18
|
+
|
|
19
|
+
declare const WRAP_NAME: '$$_REQUIRE';
|
|
20
|
+
declare function wrapModule(
|
|
21
|
+
fileAst: BabelNodeFile,
|
|
22
|
+
importDefaultName: string,
|
|
23
|
+
importAllName: string,
|
|
24
|
+
dependencyMapName: string,
|
|
25
|
+
globalPrefix: string,
|
|
26
|
+
skipRequireRename: boolean,
|
|
27
|
+
$$PARAM_6$$?: Readonly<{unstable_useStaticHermesModuleFactory?: boolean}>,
|
|
28
|
+
): {ast: BabelNodeFile; requireName: string};
|
|
29
|
+
declare function wrapPolyfill(fileAst: BabelNodeFile): BabelNodeFile;
|
|
30
|
+
declare function jsonToCommonJS(source: string): string;
|
|
31
|
+
declare function wrapJson(
|
|
32
|
+
source: string,
|
|
33
|
+
globalPrefix: string,
|
|
34
|
+
unstable_useStaticHermesModuleFactory?: boolean,
|
|
35
|
+
): string;
|
|
36
|
+
export {WRAP_NAME, wrapJson, jsonToCommonJS, wrapModule, wrapPolyfill};
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @noformat
|
|
8
|
+
* @generated SignedSource<<ab2d1203f736c3032c6b9d15cc74680b>>
|
|
9
|
+
*
|
|
10
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
11
|
+
* Original file: packages/metro/src/ModuleGraph/worker/collectDependencies.js
|
|
12
|
+
* To regenerate, run:
|
|
13
|
+
* js1 build metro-ts-defs (internal) OR
|
|
14
|
+
* yarn run build-ts-defs (OSS)
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import type {ReadonlySourceLocation} from '../../shared/types';
|
|
18
|
+
import type {NodePath} from '@babel/traverse';
|
|
19
|
+
import type {
|
|
20
|
+
CallExpression,
|
|
21
|
+
File as BabelNodeFile,
|
|
22
|
+
Identifier,
|
|
23
|
+
StringLiteral,
|
|
24
|
+
} from '@babel/types';
|
|
25
|
+
import type {
|
|
26
|
+
AllowOptionalDependencies,
|
|
27
|
+
AsyncDependencyType,
|
|
28
|
+
} from 'metro/private/DeltaBundler/types';
|
|
29
|
+
|
|
30
|
+
export type Dependency = Readonly<{data: DependencyData; name: string}>;
|
|
31
|
+
export type ContextMode = 'sync' | 'eager' | 'lazy' | 'lazy-once';
|
|
32
|
+
type ContextFilter = Readonly<{pattern: string; flags: string}>;
|
|
33
|
+
export type RequireContextParams = Readonly<{
|
|
34
|
+
recursive: boolean;
|
|
35
|
+
filter: Readonly<ContextFilter>;
|
|
36
|
+
/** Mode for resolving dynamic dependencies. Defaults to `sync` */
|
|
37
|
+
mode: ContextMode;
|
|
38
|
+
}>;
|
|
39
|
+
type DependencyData = Readonly<{
|
|
40
|
+
key: string;
|
|
41
|
+
asyncType: AsyncDependencyType | null;
|
|
42
|
+
isESMImport: boolean;
|
|
43
|
+
isOptional?: boolean;
|
|
44
|
+
locs: ReadonlyArray<ReadonlySourceLocation>;
|
|
45
|
+
/** Context for requiring a collection of modules. */
|
|
46
|
+
contextParams?: RequireContextParams;
|
|
47
|
+
}>;
|
|
48
|
+
export type MutableInternalDependency = Omit<
|
|
49
|
+
DependencyData,
|
|
50
|
+
keyof {locs: Array<ReadonlySourceLocation>; index: number; name: string}
|
|
51
|
+
> & {locs: Array<ReadonlySourceLocation>; index: number; name: string};
|
|
52
|
+
export type InternalDependency = Readonly<MutableInternalDependency>;
|
|
53
|
+
export type State = {
|
|
54
|
+
asyncRequireModulePathStringLiteral: null | undefined | StringLiteral;
|
|
55
|
+
dependencyCalls: Set<string>;
|
|
56
|
+
dependencyRegistry: DependencyRegistry;
|
|
57
|
+
dependencyTransformer: DependencyTransformer;
|
|
58
|
+
dynamicRequires: DynamicRequiresBehavior;
|
|
59
|
+
dependencyMapIdentifier: null | undefined | Identifier;
|
|
60
|
+
keepRequireNames: boolean;
|
|
61
|
+
allowOptionalDependencies: AllowOptionalDependencies;
|
|
62
|
+
/** Enable `require.context` statements which can be used to import multiple files in a directory. */
|
|
63
|
+
unstable_allowRequireContext: boolean;
|
|
64
|
+
unstable_isESMImportAtSource:
|
|
65
|
+
| null
|
|
66
|
+
| undefined
|
|
67
|
+
| (($$PARAM_0$$: ReadonlySourceLocation) => boolean);
|
|
68
|
+
};
|
|
69
|
+
export type Options = Readonly<{
|
|
70
|
+
asyncRequireModulePath: string;
|
|
71
|
+
dependencyMapName: null | undefined | string;
|
|
72
|
+
dynamicRequires: DynamicRequiresBehavior;
|
|
73
|
+
inlineableCalls: ReadonlyArray<string>;
|
|
74
|
+
keepRequireNames: boolean;
|
|
75
|
+
allowOptionalDependencies: AllowOptionalDependencies;
|
|
76
|
+
dependencyTransformer?: DependencyTransformer;
|
|
77
|
+
/** Enable `require.context` statements which can be used to import multiple files in a directory. */
|
|
78
|
+
unstable_allowRequireContext: boolean;
|
|
79
|
+
unstable_isESMImportAtSource?:
|
|
80
|
+
| null
|
|
81
|
+
| undefined
|
|
82
|
+
| (($$PARAM_0$$: ReadonlySourceLocation) => boolean);
|
|
83
|
+
}>;
|
|
84
|
+
export type CollectedDependencies = Readonly<{
|
|
85
|
+
ast: BabelNodeFile;
|
|
86
|
+
dependencyMapName: string;
|
|
87
|
+
dependencies: ReadonlyArray<Dependency>;
|
|
88
|
+
}>;
|
|
89
|
+
export interface DependencyTransformer {
|
|
90
|
+
transformSyncRequire(
|
|
91
|
+
path: NodePath<CallExpression>,
|
|
92
|
+
dependency: InternalDependency,
|
|
93
|
+
state: State,
|
|
94
|
+
): void;
|
|
95
|
+
transformImportCall(
|
|
96
|
+
path: NodePath,
|
|
97
|
+
dependency: InternalDependency,
|
|
98
|
+
state: State,
|
|
99
|
+
): void;
|
|
100
|
+
transformImportMaybeSyncCall(
|
|
101
|
+
path: NodePath,
|
|
102
|
+
dependency: InternalDependency,
|
|
103
|
+
state: State,
|
|
104
|
+
): void;
|
|
105
|
+
transformPrefetch(
|
|
106
|
+
path: NodePath,
|
|
107
|
+
dependency: InternalDependency,
|
|
108
|
+
state: State,
|
|
109
|
+
): void;
|
|
110
|
+
transformIllegalDynamicRequire(path: NodePath, state: State): void;
|
|
111
|
+
}
|
|
112
|
+
export type DynamicRequiresBehavior = 'throwAtRuntime' | 'reject';
|
|
113
|
+
/**
|
|
114
|
+
* Transform all the calls to `require()` and `import()` in a file into ID-
|
|
115
|
+
* independent code, and return the list of dependencies. For example, a call
|
|
116
|
+
* like `require('Foo')` could be transformed to `require(_depMap[3], 'Foo')`
|
|
117
|
+
* where `_depMap` is provided by the outer scope. As such, we don't need to
|
|
118
|
+
* know the actual module ID.
|
|
119
|
+
*
|
|
120
|
+
* The second argument is only provided for debugging purposes.
|
|
121
|
+
*/
|
|
122
|
+
declare function collectDependencies(
|
|
123
|
+
ast: BabelNodeFile,
|
|
124
|
+
options: Options,
|
|
125
|
+
): CollectedDependencies;
|
|
126
|
+
export default collectDependencies;
|
|
127
|
+
export type ImportQualifier = Readonly<{
|
|
128
|
+
name: string;
|
|
129
|
+
asyncType: AsyncDependencyType | null;
|
|
130
|
+
isESMImport: boolean;
|
|
131
|
+
optional: boolean;
|
|
132
|
+
contextParams?: RequireContextParams;
|
|
133
|
+
}>;
|
|
134
|
+
declare class DependencyRegistry {
|
|
135
|
+
_dependencies: Map<string, InternalDependency>;
|
|
136
|
+
registerDependency(qualifier: ImportQualifier): InternalDependency;
|
|
137
|
+
getDependencies(): Array<InternalDependency>;
|
|
138
|
+
}
|