metro 0.83.4 → 0.83.6
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 +18 -16
- package/src/Assets.d.ts +90 -0
- package/src/Assets.js +2 -9
- package/src/Bundler/util.d.ts +34 -0
- package/src/Bundler/util.js +2 -9
- package/src/Bundler/util.js.flow +3 -3
- package/src/Bundler.d.ts +45 -0
- package/src/Bundler.js +1 -5
- package/src/DeltaBundler/DeltaCalculator.d.ts +68 -0
- package/src/DeltaBundler/DeltaCalculator.js +56 -51
- package/src/DeltaBundler/DeltaCalculator.js.flow +72 -61
- package/src/DeltaBundler/Graph.d.ts +174 -0
- package/src/DeltaBundler/Graph.js +1 -5
- package/src/DeltaBundler/Serializers/baseJSBundle.d.ts +27 -0
- package/src/DeltaBundler/Serializers/baseJSBundle.js +1 -5
- package/src/DeltaBundler/Serializers/getAllFiles.d.ts +29 -0
- package/src/DeltaBundler/Serializers/getAssets.d.ts +32 -0
- package/src/DeltaBundler/Serializers/getAssets.js +1 -5
- package/src/DeltaBundler/Serializers/getExplodedSourceMap.d.ts +33 -0
- package/src/DeltaBundler/Serializers/getRamBundleInfo.d.ts +55 -0
- package/src/DeltaBundler/Serializers/getRamBundleInfo.js +1 -5
- 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/js.js +2 -9
- package/src/DeltaBundler/Serializers/helpers/processModules.d.ts +32 -0
- package/src/DeltaBundler/Serializers/hmrJSBundle.d.ts +37 -0
- package/src/DeltaBundler/Serializers/hmrJSBundle.js +2 -9
- package/src/DeltaBundler/Serializers/sourceMapGenerator.d.ts +36 -0
- package/src/DeltaBundler/Serializers/sourceMapGenerator.js +1 -5
- 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/Transformer.js +1 -5
- package/src/DeltaBundler/Worker.d.ts +44 -0
- package/src/DeltaBundler/Worker.flow.js +1 -5
- package/src/DeltaBundler/WorkerFarm.d.ts +77 -0
- package/src/DeltaBundler/buildSubgraph.d.ts +37 -0
- package/src/DeltaBundler/buildSubgraph.js +1 -5
- package/src/DeltaBundler/getTransformCacheKey.d.ts +25 -0
- package/src/DeltaBundler/getTransformCacheKey.js +4 -6
- package/src/DeltaBundler/getTransformCacheKey.js.flow +7 -2
- package/src/DeltaBundler/mergeDeltas.d.ts +24 -0
- package/src/DeltaBundler/types.d.ts +170 -0
- package/src/DeltaBundler/types.js +1 -5
- package/src/DeltaBundler.d.ts +67 -0
- package/src/DeltaBundler.js +1 -5
- package/src/HmrServer.d.ts +98 -0
- package/src/HmrServer.js +9 -9
- package/src/HmrServer.js.flow +15 -5
- package/src/IncrementalBundler/GraphNotFoundError.d.ts +24 -0
- package/src/IncrementalBundler/ResourceNotFoundError.d.ts +22 -0
- package/src/IncrementalBundler/RevisionNotFoundError.d.ts +24 -0
- package/src/IncrementalBundler.d.ts +103 -0
- package/src/IncrementalBundler.js +2 -9
- package/src/ModuleGraph/worker/JsFileWrapping.d.ts +36 -0
- package/src/ModuleGraph/worker/JsFileWrapping.js +2 -9
- package/src/ModuleGraph/worker/collectDependencies.d.ts +138 -0
- package/src/ModuleGraph/worker/collectDependencies.js +2 -9
- package/src/ModuleGraph/worker/generateImportNames.d.ts +26 -0
- package/src/ModuleGraph/worker/generateImportNames.js +1 -5
- package/src/ModuleGraph/worker/importLocationsPlugin.d.ts +33 -0
- package/src/Server/MultipartResponse.d.ts +37 -0
- package/src/Server/MultipartResponse.js +1 -5
- package/src/Server/symbolicate.d.ts +38 -0
- package/src/Server.d.ts +278 -0
- package/src/Server.js +47 -15
- package/src/Server.js.flow +57 -10
- package/src/cli/parseKeyValueParamArray.d.ts +21 -0
- package/src/cli-utils.d.ts +26 -0
- package/src/cli-utils.js +1 -5
- package/src/commands/build.d.ts +23 -0
- package/src/commands/build.js +1 -5
- package/src/commands/dependencies.d.ts +23 -0
- package/src/commands/dependencies.js +1 -5
- package/src/commands/serve.d.ts +23 -0
- package/src/index.d.ts +206 -0
- package/src/index.flow.js +26 -19
- package/src/index.flow.js.flow +46 -12
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-import.js +1 -5
- package/src/integration_tests/basic_bundle/build-errors/inline-requires-cannot-resolve-import.js +1 -5
- package/src/integration_tests/basic_bundle/import-export/index.js +2 -9
- package/src/integration_tests/execBundle.js +1 -5
- package/src/lib/BatchProcessor.d.ts +61 -0
- package/src/lib/BatchProcessor.js +1 -5
- package/src/lib/CountingSet.d.ts +55 -0
- package/src/lib/JsonReporter.d.ts +44 -0
- package/src/lib/JsonReporter.js.flow +2 -2
- package/src/lib/RamBundleParser.d.ts +36 -0
- package/src/lib/RamBundleParser.js +1 -5
- package/src/lib/TerminalReporter.d.ts +125 -0
- package/src/lib/TerminalReporter.js +8 -16
- 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/contextModule.js +1 -5
- package/src/lib/contextModuleTemplates.d.ts +32 -0
- package/src/lib/contextModuleTemplates.js +1 -4
- package/src/lib/countLines.d.ts +19 -0
- package/src/lib/createWebsocketServer.d.ts +50 -0
- package/src/lib/createWebsocketServer.js +1 -5
- package/src/lib/debounceAsyncQueue.d.ts +22 -0
- package/src/lib/formatBundlingError.d.ts +30 -0
- package/src/lib/formatBundlingError.js +1 -5
- package/src/lib/getAppendScripts.d.ts +38 -0
- package/src/lib/getAppendScripts.js +1 -5
- package/src/lib/getAppendScripts.js.flow +2 -2
- package/src/lib/getGraphId.d.ts +32 -0
- package/src/lib/getGraphId.js +1 -5
- package/src/lib/getPreludeCode.d.ts +25 -0
- package/src/lib/getPrependedScripts.d.ts +31 -0
- package/src/lib/getPrependedScripts.js +2 -9
- package/src/lib/isResolvedDependency.d.ts +22 -0
- package/src/lib/logToConsole.d.ts +26 -0
- package/src/lib/logToConsole.js +1 -5
- package/src/lib/parseBundleOptionsFromBundleRequestUrl.d.ts +24 -0
- package/src/lib/parseBundleOptionsFromBundleRequestUrl.js +2 -9
- 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/pathUtils.js +1 -4
- package/src/lib/relativizeSourceMap.d.ts +24 -0
- package/src/lib/relativizeSourceMap.js +1 -5
- package/src/lib/reporting.d.ts +135 -0
- package/src/lib/reporting.js +1 -5
- package/src/lib/splitBundleOptions.d.ts +23 -0
- package/src/lib/transformHelpers.d.ts +42 -0
- package/src/lib/transformHelpers.js +1 -5
- package/src/node-haste/DependencyGraph/ModuleResolution.d.ts +120 -0
- package/src/node-haste/DependencyGraph/ModuleResolution.js +6 -31
- package/src/node-haste/DependencyGraph/ModuleResolution.js.flow +10 -59
- package/src/node-haste/DependencyGraph/createFileMap.d.ts +36 -0
- package/src/node-haste/DependencyGraph/createFileMap.js +3 -10
- package/src/node-haste/DependencyGraph/createFileMap.js.flow +4 -2
- package/src/node-haste/DependencyGraph.d.ts +90 -0
- package/src/node-haste/DependencyGraph.js +23 -16
- package/src/node-haste/DependencyGraph.js.flow +24 -13
- package/src/node-haste/PackageCache.d.ts +37 -0
- package/src/node-haste/PackageCache.js +65 -58
- package/src/node-haste/PackageCache.js.flow +103 -79
- package/src/node-haste/lib/AssetPaths.d.ts +36 -0
- package/src/node-haste/lib/AssetPaths.js +1 -5
- package/src/node-haste/lib/parsePlatformFilePath.d.ts +32 -0
- package/src/node-haste/lib/parsePlatformFilePath.js +1 -5
- package/src/shared/output/RamBundle/as-assets.d.ts +32 -0
- package/src/shared/output/RamBundle/as-assets.js +1 -5
- package/src/shared/output/RamBundle/as-indexed-file.d.ts +45 -0
- package/src/shared/output/RamBundle/as-indexed-file.js +1 -5
- 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/util.js +1 -5
- package/src/shared/output/RamBundle/write-sourcemap.d.ts +23 -0
- package/src/shared/output/RamBundle/write-sourcemap.js +1 -5
- package/src/shared/output/RamBundle.d.ts +33 -0
- package/src/shared/output/RamBundle.js +1 -5
- package/src/shared/output/bundle.d.ts +34 -0
- package/src/shared/output/bundle.flow.js +1 -5
- package/src/shared/output/meta.d.ts +22 -0
- package/src/shared/output/meta.js +1 -5
- package/src/shared/output/unbundle.d.ts +18 -0
- package/src/shared/output/writeFile.d.ts +23 -0
- package/src/shared/output/writeFile.js +1 -5
- package/src/shared/types.d.ts +152 -0
- package/src/node-haste/Package.js +0 -32
- package/src/node-haste/Package.js.flow +0 -39
|
@@ -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;
|
package/src/DeltaBundler.js
CHANGED
|
@@ -8,11 +8,7 @@ var _DeltaCalculator = _interopRequireDefault(
|
|
|
8
8
|
require("./DeltaBundler/DeltaCalculator"),
|
|
9
9
|
);
|
|
10
10
|
function _interopRequireDefault(e) {
|
|
11
|
-
return e && e.__esModule
|
|
12
|
-
? e
|
|
13
|
-
: {
|
|
14
|
-
default: e,
|
|
15
|
-
};
|
|
11
|
+
return e && e.__esModule ? e : { default: e };
|
|
16
12
|
}
|
|
17
13
|
class DeltaBundler {
|
|
18
14
|
_deltaCalculators = new Map();
|
|
@@ -0,0 +1,98 @@
|
|
|
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<<ab4c245134631e14db114a9d49da79d1>>
|
|
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:
|
|
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
|
+
}
|
|
98
|
+
export default HmrServer;
|
package/src/HmrServer.js
CHANGED
|
@@ -39,10 +39,7 @@ function _interopRequireWildcard(e, t) {
|
|
|
39
39
|
if (!t && e && e.__esModule) return e;
|
|
40
40
|
var o,
|
|
41
41
|
i,
|
|
42
|
-
f = {
|
|
43
|
-
__proto__: null,
|
|
44
|
-
default: e,
|
|
45
|
-
};
|
|
42
|
+
f = { __proto__: null, default: e };
|
|
46
43
|
if (null === e || ("object" != typeof e && "function" != typeof e))
|
|
47
44
|
return f;
|
|
48
45
|
if ((o = t ? n : r)) {
|
|
@@ -62,11 +59,7 @@ function _interopRequireWildcard(e, t) {
|
|
|
62
59
|
})(e, t);
|
|
63
60
|
}
|
|
64
61
|
function _interopRequireDefault(e) {
|
|
65
|
-
return e && e.__esModule
|
|
66
|
-
? e
|
|
67
|
-
: {
|
|
68
|
-
default: e,
|
|
69
|
-
};
|
|
62
|
+
return e && e.__esModule ? e : { default: e };
|
|
70
63
|
}
|
|
71
64
|
const debug = require("debug")("Metro:HMR");
|
|
72
65
|
const { createActionStartEntry, createActionEndEntry, log } = _metroCore.Logger;
|
|
@@ -221,6 +214,10 @@ class HmrServer {
|
|
|
221
214
|
case "log-opt-in":
|
|
222
215
|
client.optedIntoHMR = true;
|
|
223
216
|
break;
|
|
217
|
+
case "heartbeat":
|
|
218
|
+
debug("Heartbeat received");
|
|
219
|
+
sendFn(String(message));
|
|
220
|
+
break;
|
|
224
221
|
default:
|
|
225
222
|
break;
|
|
226
223
|
}
|
|
@@ -272,6 +269,9 @@ class HmrServer {
|
|
|
272
269
|
send(sendFns, message);
|
|
273
270
|
send(sendFns, {
|
|
274
271
|
type: "update-done",
|
|
272
|
+
body: {
|
|
273
|
+
changeId: changeEvent?.changeId,
|
|
274
|
+
},
|
|
275
275
|
});
|
|
276
276
|
log({
|
|
277
277
|
...createActionEndEntry(processingHmrChange),
|
package/src/HmrServer.js.flow
CHANGED
|
@@ -66,7 +66,7 @@ function send(sendFns: Array<(string) => void>, message: HmrMessage): void {
|
|
|
66
66
|
* getting connected, disconnected or having errors (through the
|
|
67
67
|
* `onClientConnect`, `onClientDisconnect` and `onClientError` methods).
|
|
68
68
|
*/
|
|
69
|
-
export default class HmrServer<TClient
|
|
69
|
+
export default class HmrServer<TClient extends Client> {
|
|
70
70
|
_config: ConfigT;
|
|
71
71
|
_bundler: IncrementalBundler;
|
|
72
72
|
_createModuleId: (path: string) => number;
|
|
@@ -181,7 +181,8 @@ export default class HmrServer<TClient: Client> {
|
|
|
181
181
|
this._clientGroups.set(id, clientGroup);
|
|
182
182
|
|
|
183
183
|
let latestChangeEvent: ?{
|
|
184
|
-
logger: ?RootPerfLogger,
|
|
184
|
+
+logger: ?RootPerfLogger,
|
|
185
|
+
+changeId: string,
|
|
185
186
|
} = null;
|
|
186
187
|
|
|
187
188
|
const debounceCallHandleFileChange = debounceAsyncQueue(async () => {
|
|
@@ -240,6 +241,10 @@ export default class HmrServer<TClient: Client> {
|
|
|
240
241
|
case 'log-opt-in':
|
|
241
242
|
client.optedIntoHMR = true;
|
|
242
243
|
break;
|
|
244
|
+
case 'heartbeat':
|
|
245
|
+
debug('Heartbeat received');
|
|
246
|
+
sendFn(String(message));
|
|
247
|
+
break;
|
|
243
248
|
default:
|
|
244
249
|
break;
|
|
245
250
|
}
|
|
@@ -273,7 +278,8 @@ export default class HmrServer<TClient: Client> {
|
|
|
273
278
|
group: ClientGroup,
|
|
274
279
|
options: {isInitialUpdate: boolean},
|
|
275
280
|
changeEvent: ?{
|
|
276
|
-
logger: ?RootPerfLogger,
|
|
281
|
+
+logger: ?RootPerfLogger,
|
|
282
|
+
+changeId?: string,
|
|
277
283
|
},
|
|
278
284
|
): Promise<void> {
|
|
279
285
|
const logger = !options.isInitialUpdate ? changeEvent?.logger : null;
|
|
@@ -308,7 +314,10 @@ export default class HmrServer<TClient: Client> {
|
|
|
308
314
|
|
|
309
315
|
const message = await this._prepareMessage(group, options, changeEvent);
|
|
310
316
|
send(sendFns, message);
|
|
311
|
-
send(sendFns, {
|
|
317
|
+
send(sendFns, {
|
|
318
|
+
type: 'update-done',
|
|
319
|
+
body: {changeId: changeEvent?.changeId},
|
|
320
|
+
});
|
|
312
321
|
|
|
313
322
|
log({
|
|
314
323
|
...createActionEndEntry(processingHmrChange),
|
|
@@ -328,7 +337,8 @@ export default class HmrServer<TClient: Client> {
|
|
|
328
337
|
group: ClientGroup,
|
|
329
338
|
options: {isInitialUpdate: boolean},
|
|
330
339
|
changeEvent: ?{
|
|
331
|
-
logger: ?RootPerfLogger,
|
|
340
|
+
+logger: ?RootPerfLogger,
|
|
341
|
+
+changeId?: string,
|
|
332
342
|
},
|
|
333
343
|
): Promise<HmrUpdateMessage | HmrErrorMessage> {
|
|
334
344
|
const logger = !options.isInitialUpdate ? changeEvent?.logger : null;
|
|
@@ -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;
|
|
@@ -27,10 +27,7 @@ function _interopRequireWildcard(e, t) {
|
|
|
27
27
|
if (!t && e && e.__esModule) return e;
|
|
28
28
|
var o,
|
|
29
29
|
i,
|
|
30
|
-
f = {
|
|
31
|
-
__proto__: null,
|
|
32
|
-
default: e,
|
|
33
|
-
};
|
|
30
|
+
f = { __proto__: null, default: e };
|
|
34
31
|
if (null === e || ("object" != typeof e && "function" != typeof e))
|
|
35
32
|
return f;
|
|
36
33
|
if ((o = t ? n : r)) {
|
|
@@ -50,11 +47,7 @@ function _interopRequireWildcard(e, t) {
|
|
|
50
47
|
})(e, t);
|
|
51
48
|
}
|
|
52
49
|
function _interopRequireDefault(e) {
|
|
53
|
-
return e && e.__esModule
|
|
54
|
-
? e
|
|
55
|
-
: {
|
|
56
|
-
default: e,
|
|
57
|
-
};
|
|
50
|
+
return e && e.__esModule ? e : { default: e };
|
|
58
51
|
}
|
|
59
52
|
function createRevisionId() {
|
|
60
53
|
return _crypto.default.randomBytes(8).toString("hex");
|