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
|
@@ -10,16 +10,24 @@
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import type {DeltaResult, Options} from './types';
|
|
13
|
-
import type {RootPerfLogger} from 'metro-config';
|
|
14
13
|
import type {ChangeEvent} from 'metro-file-map';
|
|
15
14
|
|
|
16
15
|
import {Graph} from './Graph';
|
|
16
|
+
import crypto from 'crypto';
|
|
17
17
|
import EventEmitter from 'events';
|
|
18
18
|
import path from 'path';
|
|
19
19
|
|
|
20
20
|
// eslint-disable-next-line import/no-commonjs
|
|
21
21
|
const debug = require('debug')('Metro:DeltaCalculator');
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Assigns a unique, stable `changeId` to each `ChangeEvent` from the file
|
|
25
|
+
* watcher. Since all `DeltaCalculator` instances share the same
|
|
26
|
+
* `ChangeEvent` object reference per file system change, the `WeakMap`
|
|
27
|
+
* ensures each gets the same `changeId`.
|
|
28
|
+
*/
|
|
29
|
+
const changeEventIds: WeakMap<ChangeEvent, string> = new WeakMap();
|
|
30
|
+
|
|
23
31
|
/**
|
|
24
32
|
* This class is in charge of calculating the delta of changed modules that
|
|
25
33
|
* happen between calls. To do so, it subscribes to file changes, so it can
|
|
@@ -172,76 +180,79 @@ export default class DeltaCalculator<T> extends EventEmitter {
|
|
|
172
180
|
return this._graph;
|
|
173
181
|
}
|
|
174
182
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
183
|
+
#shouldReset(
|
|
184
|
+
canonicalPath: string,
|
|
185
|
+
metadata: {+isSymlink: boolean, ...},
|
|
186
|
+
): boolean {
|
|
187
|
+
if (metadata.isSymlink) {
|
|
188
|
+
return true;
|
|
189
|
+
}
|
|
180
190
|
|
|
181
|
-
/**
|
|
182
|
-
* Handles a single file change. To avoid doing any work before it's needed,
|
|
183
|
-
* the listener only stores the modified file, which will then be used later
|
|
184
|
-
* when the delta needs to be calculated.
|
|
185
|
-
*/
|
|
186
|
-
_handleFileChange = (
|
|
187
|
-
{type, filePath, metadata}: ChangeEvent['eventsQueue'][number],
|
|
188
|
-
logger: ?RootPerfLogger,
|
|
189
|
-
): unknown => {
|
|
190
|
-
debug('Handling %s: %s (type: %s)', type, filePath, metadata.type);
|
|
191
191
|
if (
|
|
192
|
-
|
|
193
|
-
(
|
|
194
|
-
|
|
192
|
+
this._options.unstable_enablePackageExports &&
|
|
193
|
+
(canonicalPath === 'package.json' ||
|
|
194
|
+
canonicalPath.endsWith(path.sep + 'package.json'))
|
|
195
195
|
) {
|
|
196
|
-
|
|
197
|
-
this.emit('change', {logger});
|
|
196
|
+
return true;
|
|
198
197
|
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
198
|
+
|
|
199
|
+
return false;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
_handleMultipleFileChanges = (changeEvent: ChangeEvent) => {
|
|
203
|
+
const {changes, logger, rootDir} = changeEvent;
|
|
204
|
+
|
|
205
|
+
// Process added files: deleted+added = modified, otherwise added
|
|
206
|
+
for (const [canonicalPath, metadata] of changes.addedFiles) {
|
|
207
|
+
debug('Handling add: %s', canonicalPath);
|
|
208
|
+
if (this.#shouldReset(canonicalPath, metadata)) {
|
|
209
|
+
this._requiresReset = true;
|
|
210
|
+
}
|
|
211
|
+
const absolutePath = path.join(rootDir, canonicalPath);
|
|
212
|
+
if (this._deletedFiles.has(absolutePath)) {
|
|
213
|
+
this._deletedFiles.delete(absolutePath);
|
|
214
|
+
this._modifiedFiles.add(absolutePath);
|
|
215
|
+
} else {
|
|
216
|
+
this._addedFiles.add(absolutePath);
|
|
217
|
+
this._modifiedFiles.delete(absolutePath);
|
|
218
|
+
}
|
|
206
219
|
}
|
|
207
220
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
221
|
+
// Process modified files: added+modified stays added, otherwise modified
|
|
222
|
+
for (const [canonicalPath, metadata] of changes.modifiedFiles) {
|
|
223
|
+
debug('Handling change: %s', canonicalPath);
|
|
224
|
+
if (this.#shouldReset(canonicalPath, metadata)) {
|
|
225
|
+
this._requiresReset = true;
|
|
226
|
+
}
|
|
227
|
+
const absolutePath = path.join(rootDir, canonicalPath);
|
|
228
|
+
if (!this._addedFiles.has(absolutePath)) {
|
|
229
|
+
this._modifiedFiles.add(absolutePath);
|
|
230
|
+
}
|
|
231
|
+
this._deletedFiles.delete(absolutePath);
|
|
218
232
|
}
|
|
219
233
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
this.
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
this.
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
this._deletedFiles.delete(filePath);
|
|
234
|
-
this._addedFiles.delete(filePath);
|
|
235
|
-
break;
|
|
236
|
-
default:
|
|
237
|
-
nextState as empty;
|
|
234
|
+
// Process removed files: added+deleted = no change, otherwise deleted
|
|
235
|
+
for (const [canonicalPath, metadata] of changes.removedFiles) {
|
|
236
|
+
debug('Handling delete: %s', canonicalPath);
|
|
237
|
+
if (this.#shouldReset(canonicalPath, metadata)) {
|
|
238
|
+
this._requiresReset = true;
|
|
239
|
+
}
|
|
240
|
+
const absolutePath = path.resolve(rootDir, canonicalPath);
|
|
241
|
+
if (this._addedFiles.has(absolutePath)) {
|
|
242
|
+
this._addedFiles.delete(absolutePath);
|
|
243
|
+
} else {
|
|
244
|
+
this._deletedFiles.add(absolutePath);
|
|
245
|
+
this._modifiedFiles.delete(absolutePath);
|
|
246
|
+
}
|
|
238
247
|
}
|
|
239
248
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
}
|
|
249
|
+
let changeId = changeEventIds.get(changeEvent);
|
|
250
|
+
if (changeId == null) {
|
|
251
|
+
changeId = crypto.randomUUID();
|
|
252
|
+
changeEventIds.set(changeEvent, changeId);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
this.emit('change', {logger, changeId});
|
|
245
256
|
};
|
|
246
257
|
|
|
247
258
|
async _getChangedDependencies(
|
|
@@ -0,0 +1,174 @@
|
|
|
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<<2af7aa3b61c2afa4d8794e127666c226>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/DeltaBundler/Graph.js
|
|
13
|
+
* To regenerate, run:
|
|
14
|
+
* js1 build metro-ts-defs (internal) OR
|
|
15
|
+
* yarn run build-ts-defs (OSS)
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Portions of this code are based on the Synchronous Cycle Collection
|
|
20
|
+
* algorithm described in:
|
|
21
|
+
*
|
|
22
|
+
* David F. Bacon and V. T. Rajan. 2001. Concurrent Cycle Collection in
|
|
23
|
+
* Reference Counted Systems. In Proceedings of the 15th European Conference on
|
|
24
|
+
* Object-Oriented Programming (ECOOP '01). Springer-Verlag, Berlin,
|
|
25
|
+
* Heidelberg, 207–235.
|
|
26
|
+
*
|
|
27
|
+
* Notable differences from the algorithm in the paper:
|
|
28
|
+
* 1. Our implementation uses the inverseDependencies set (which we already
|
|
29
|
+
* have to maintain) instead of a separate refcount variable. A module's
|
|
30
|
+
* reference count is equal to the size of its inverseDependencies set, plus
|
|
31
|
+
* 1 if it's an entry point of the graph.
|
|
32
|
+
* 2. We keep the "root buffer" (possibleCycleRoots) free of duplicates by
|
|
33
|
+
* making it a Set, instead of storing a "buffered" flag on each node.
|
|
34
|
+
* 3. On top of tracking edges between nodes, we also count references between
|
|
35
|
+
* nodes and entries in the importBundleNodes set.
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
import type {RequireContext} from '../lib/contextModule';
|
|
39
|
+
import type {
|
|
40
|
+
Dependencies,
|
|
41
|
+
Dependency,
|
|
42
|
+
GraphInputOptions,
|
|
43
|
+
MixedOutput,
|
|
44
|
+
Module,
|
|
45
|
+
ModuleData,
|
|
46
|
+
Options,
|
|
47
|
+
ResolvedDependency,
|
|
48
|
+
TransformInputOptions,
|
|
49
|
+
} from './types';
|
|
50
|
+
|
|
51
|
+
import CountingSet from '../lib/CountingSet';
|
|
52
|
+
|
|
53
|
+
export type Result<T> = {
|
|
54
|
+
added: Map<string, Module<T>>;
|
|
55
|
+
modified: Map<string, Module<T>>;
|
|
56
|
+
deleted: Set<string>;
|
|
57
|
+
};
|
|
58
|
+
type Delta<T> = Readonly<{
|
|
59
|
+
added: Set<string>;
|
|
60
|
+
touched: Set<string>;
|
|
61
|
+
deleted: Set<string>;
|
|
62
|
+
updatedModuleData: ReadonlyMap<string, ModuleData<T>>;
|
|
63
|
+
baseModuleData: Map<string, ModuleData<T>>;
|
|
64
|
+
errors: ReadonlyMap<string, Error>;
|
|
65
|
+
}>;
|
|
66
|
+
type InternalOptions<T> = Readonly<{
|
|
67
|
+
lazy: boolean;
|
|
68
|
+
onDependencyAdd: () => unknown;
|
|
69
|
+
onDependencyAdded: () => unknown;
|
|
70
|
+
resolve: Options<T>['resolve'];
|
|
71
|
+
transform: Options<T>['transform'];
|
|
72
|
+
shallow: boolean;
|
|
73
|
+
}>;
|
|
74
|
+
export declare class Graph<T = MixedOutput> {
|
|
75
|
+
readonly entryPoints: ReadonlySet<string>;
|
|
76
|
+
readonly transformOptions: TransformInputOptions;
|
|
77
|
+
readonly dependencies: Dependencies<T>;
|
|
78
|
+
constructor(options: GraphInputOptions);
|
|
79
|
+
/**
|
|
80
|
+
* Dependency Traversal logic for the Delta Bundler. This method calculates
|
|
81
|
+
* the modules that should be included in the bundle by traversing the
|
|
82
|
+
* dependency graph.
|
|
83
|
+
* Instead of traversing the whole graph each time, it just calculates the
|
|
84
|
+
* difference between runs by only traversing the added/removed dependencies.
|
|
85
|
+
* To do so, it uses the passed graph dependencies and it mutates it.
|
|
86
|
+
* The paths parameter contains the absolute paths of the root files that the
|
|
87
|
+
* method should traverse. Normally, these paths should be the modified files
|
|
88
|
+
* since the last traversal.
|
|
89
|
+
*/
|
|
90
|
+
traverseDependencies(
|
|
91
|
+
paths: ReadonlyArray<string>,
|
|
92
|
+
options: Options<T>,
|
|
93
|
+
): Promise<Result<T>>;
|
|
94
|
+
initialTraverseDependencies(options: Options<T>): Promise<Result<T>>;
|
|
95
|
+
_buildDelta(
|
|
96
|
+
pathsToVisit: ReadonlySet<string>,
|
|
97
|
+
options: InternalOptions<T>,
|
|
98
|
+
moduleFilter?: (path: string) => boolean,
|
|
99
|
+
): Promise<Delta<T>>;
|
|
100
|
+
_recursivelyCommitModule(
|
|
101
|
+
path: string,
|
|
102
|
+
delta: Delta<T>,
|
|
103
|
+
options: InternalOptions<T>,
|
|
104
|
+
commitOptions?: Readonly<{onlyRemove: boolean}>,
|
|
105
|
+
): Module<T>;
|
|
106
|
+
_addDependency(
|
|
107
|
+
parentModule: Module<T>,
|
|
108
|
+
key: string,
|
|
109
|
+
dependency: Dependency,
|
|
110
|
+
requireContext: null | undefined | RequireContext,
|
|
111
|
+
delta: Delta<T>,
|
|
112
|
+
options: InternalOptions<T>,
|
|
113
|
+
): void;
|
|
114
|
+
_removeDependency(
|
|
115
|
+
parentModule: Module<T>,
|
|
116
|
+
key: string,
|
|
117
|
+
dependency: Dependency,
|
|
118
|
+
delta: Delta<T>,
|
|
119
|
+
options: InternalOptions<T>,
|
|
120
|
+
): void;
|
|
121
|
+
/**
|
|
122
|
+
* Collect a list of context modules which include a given file.
|
|
123
|
+
*/
|
|
124
|
+
markModifiedContextModules(
|
|
125
|
+
filePath: string,
|
|
126
|
+
modifiedPaths: Set<string> | CountingSet<string>,
|
|
127
|
+
): void;
|
|
128
|
+
/**
|
|
129
|
+
* Gets the list of modules affected by the deletion of a given file. The
|
|
130
|
+
* caller is expected to mark these modules as modified in the next call to
|
|
131
|
+
* traverseDependencies. Note that the list may contain duplicates.
|
|
132
|
+
*/
|
|
133
|
+
getModifiedModulesForDeletedPath(filePath: string): Iterable<string>;
|
|
134
|
+
/**
|
|
135
|
+
* Re-traverse the dependency graph in DFS order to reorder the modules and
|
|
136
|
+
* guarantee the same order between runs. This method mutates the passed graph.
|
|
137
|
+
*/
|
|
138
|
+
reorderGraph(options: {shallow: boolean}): void;
|
|
139
|
+
_reorderDependencies(
|
|
140
|
+
module: Module<T>,
|
|
141
|
+
orderedDependencies: Map<string, Module<T>>,
|
|
142
|
+
options: {shallow: boolean},
|
|
143
|
+
): void;
|
|
144
|
+
/** Garbage collection functions */
|
|
145
|
+
|
|
146
|
+
_incrementImportBundleReference(
|
|
147
|
+
dependency: ResolvedDependency,
|
|
148
|
+
parentModule: Module<T>,
|
|
149
|
+
): void;
|
|
150
|
+
_decrementImportBundleReference(
|
|
151
|
+
dependency: ResolvedDependency,
|
|
152
|
+
parentModule: Module<T>,
|
|
153
|
+
): void;
|
|
154
|
+
_markModuleInUse(module: Module<T>): void;
|
|
155
|
+
_children(
|
|
156
|
+
module: Module<T>,
|
|
157
|
+
options: InternalOptions<T>,
|
|
158
|
+
): Iterator<Module<T>>;
|
|
159
|
+
_moduleSnapshot(module: Module<T>): ModuleData<T>;
|
|
160
|
+
_releaseModule(
|
|
161
|
+
module: Module<T>,
|
|
162
|
+
delta: Delta<T>,
|
|
163
|
+
options: InternalOptions<T>,
|
|
164
|
+
): void;
|
|
165
|
+
_freeModule(module: Module<T>, delta: Delta<T>): void;
|
|
166
|
+
_markAsPossibleCycleRoot(module: Module<T>): void;
|
|
167
|
+
_collectCycles(delta: Delta<T>, options: InternalOptions<T>): void;
|
|
168
|
+
_markGray(module: Module<T>, options: InternalOptions<T>): void;
|
|
169
|
+
_scan(module: Module<T>, options: InternalOptions<T>): void;
|
|
170
|
+
_scanBlack(module: Module<T>, options: InternalOptions<T>): void;
|
|
171
|
+
_collectWhite(module: Module<T>, delta: Delta<T>): void;
|
|
172
|
+
|
|
173
|
+
/** End of garbage collection functions */
|
|
174
|
+
}
|
|
@@ -11,11 +11,7 @@ var _buildSubgraph = require("./buildSubgraph");
|
|
|
11
11
|
var _invariant = _interopRequireDefault(require("invariant"));
|
|
12
12
|
var _nullthrows = _interopRequireDefault(require("nullthrows"));
|
|
13
13
|
function _interopRequireDefault(e) {
|
|
14
|
-
return e && e.__esModule
|
|
15
|
-
? e
|
|
16
|
-
: {
|
|
17
|
-
default: e,
|
|
18
|
-
};
|
|
14
|
+
return e && e.__esModule ? e : { default: e };
|
|
19
15
|
}
|
|
20
16
|
function getInternalOptions({ transform, resolve, onProgress, lazy, shallow }) {
|
|
21
17
|
let numProcessed = 0;
|
|
@@ -0,0 +1,27 @@
|
|
|
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<<e21aeb433f191f32b37d05733b0b76bd>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/DeltaBundler/Serializers/baseJSBundle.js
|
|
13
|
+
* To regenerate, run:
|
|
14
|
+
* js1 build metro-ts-defs (internal) OR
|
|
15
|
+
* yarn run build-ts-defs (OSS)
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import type {Module, ReadOnlyGraph, SerializerOptions} from '../types';
|
|
19
|
+
import type {Bundle} from 'metro-runtime/src/modules/types';
|
|
20
|
+
|
|
21
|
+
declare function baseJSBundle(
|
|
22
|
+
entryPoint: string,
|
|
23
|
+
preModules: ReadonlyArray<Module>,
|
|
24
|
+
graph: ReadOnlyGraph,
|
|
25
|
+
options: SerializerOptions,
|
|
26
|
+
): Bundle;
|
|
27
|
+
export default baseJSBundle;
|
|
@@ -11,11 +11,7 @@ var _processModules = _interopRequireDefault(
|
|
|
11
11
|
require("./helpers/processModules"),
|
|
12
12
|
);
|
|
13
13
|
function _interopRequireDefault(e) {
|
|
14
|
-
return e && e.__esModule
|
|
15
|
-
? e
|
|
16
|
-
: {
|
|
17
|
-
default: e,
|
|
18
|
-
};
|
|
14
|
+
return e && e.__esModule ? e : { default: e };
|
|
19
15
|
}
|
|
20
16
|
function baseJSBundle(entryPoint, preModules, graph, options) {
|
|
21
17
|
for (const module of graph.dependencies.values()) {
|
|
@@ -0,0 +1,29 @@
|
|
|
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<<1d044a890d1eebbef947f78609d7c58f>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/DeltaBundler/Serializers/getAllFiles.js
|
|
13
|
+
* To regenerate, run:
|
|
14
|
+
* js1 build metro-ts-defs (internal) OR
|
|
15
|
+
* yarn run build-ts-defs (OSS)
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import type {Module, ReadOnlyGraph} from '../types';
|
|
19
|
+
|
|
20
|
+
type Options = {
|
|
21
|
+
platform: null | undefined | string;
|
|
22
|
+
readonly processModuleFilter: (module: Module) => boolean;
|
|
23
|
+
};
|
|
24
|
+
declare function getAllFiles(
|
|
25
|
+
pre: ReadonlyArray<Module>,
|
|
26
|
+
graph: ReadOnlyGraph,
|
|
27
|
+
options: Options,
|
|
28
|
+
): Promise<ReadonlyArray<string>>;
|
|
29
|
+
export default getAllFiles;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @noformat
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
* @generated SignedSource<<0a49d828c4a80d52ccab4d4766b84c86>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/DeltaBundler/Serializers/getAssets.js
|
|
13
|
+
* To regenerate, run:
|
|
14
|
+
* js1 build metro-ts-defs (internal) OR
|
|
15
|
+
* yarn run build-ts-defs (OSS)
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import type {AssetData} from '../../Assets';
|
|
19
|
+
import type {Module, ReadOnlyDependencies} from '../types';
|
|
20
|
+
|
|
21
|
+
type Options = {
|
|
22
|
+
readonly processModuleFilter: (module: Module) => boolean;
|
|
23
|
+
assetPlugins: ReadonlyArray<string>;
|
|
24
|
+
platform: null | undefined | string;
|
|
25
|
+
projectRoot: string;
|
|
26
|
+
publicPath: string;
|
|
27
|
+
};
|
|
28
|
+
declare function getAssets(
|
|
29
|
+
dependencies: ReadOnlyDependencies,
|
|
30
|
+
options: Options,
|
|
31
|
+
): Promise<ReadonlyArray<AssetData>>;
|
|
32
|
+
export default getAssets;
|
|
@@ -8,11 +8,7 @@ var _Assets = require("../../Assets");
|
|
|
8
8
|
var _js = require("./helpers/js");
|
|
9
9
|
var _path = _interopRequireDefault(require("path"));
|
|
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
|
async function getAssets(dependencies, options) {
|
|
18
14
|
const promises = [];
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @noformat
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
* @generated SignedSource<<623892927b76c4f68802bb69f19d9974>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/DeltaBundler/Serializers/getExplodedSourceMap.js
|
|
13
|
+
* To regenerate, run:
|
|
14
|
+
* js1 build metro-ts-defs (internal) OR
|
|
15
|
+
* yarn run build-ts-defs (OSS)
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import type {Module} from '../types';
|
|
19
|
+
import type {
|
|
20
|
+
FBSourceFunctionMap,
|
|
21
|
+
MetroSourceMapSegmentTuple,
|
|
22
|
+
} from 'metro-source-map';
|
|
23
|
+
|
|
24
|
+
export type ExplodedSourceMap = ReadonlyArray<{
|
|
25
|
+
readonly map: Array<MetroSourceMapSegmentTuple>;
|
|
26
|
+
readonly firstLine1Based: number;
|
|
27
|
+
readonly functionMap: null | undefined | FBSourceFunctionMap;
|
|
28
|
+
readonly path: string;
|
|
29
|
+
}>;
|
|
30
|
+
export declare function getExplodedSourceMap(
|
|
31
|
+
modules: ReadonlyArray<Module>,
|
|
32
|
+
options: {readonly processModuleFilter: (module: Module) => boolean},
|
|
33
|
+
): ExplodedSourceMap;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @noformat
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
* @generated SignedSource<<b01899b6156596978e6b8e7ba93e97a4>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/DeltaBundler/Serializers/getRamBundleInfo.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 {ModuleTransportLike} from '../../shared/types';
|
|
19
|
+
import type {Module, ReadOnlyGraph, SerializerOptions} from '../types';
|
|
20
|
+
import type {SourceMapGeneratorOptions} from './sourceMapGenerator';
|
|
21
|
+
import type {GetTransformOptions} from 'metro-config';
|
|
22
|
+
|
|
23
|
+
type Options = Readonly<
|
|
24
|
+
Omit<
|
|
25
|
+
SerializerOptions,
|
|
26
|
+
| keyof SourceMapGeneratorOptions
|
|
27
|
+
| keyof {
|
|
28
|
+
getTransformOptions: null | undefined | GetTransformOptions;
|
|
29
|
+
platform: null | undefined | string;
|
|
30
|
+
}
|
|
31
|
+
> &
|
|
32
|
+
Omit<
|
|
33
|
+
SourceMapGeneratorOptions,
|
|
34
|
+
keyof {
|
|
35
|
+
getTransformOptions: null | undefined | GetTransformOptions;
|
|
36
|
+
platform: null | undefined | string;
|
|
37
|
+
}
|
|
38
|
+
> & {
|
|
39
|
+
getTransformOptions: null | undefined | GetTransformOptions;
|
|
40
|
+
platform: null | undefined | string;
|
|
41
|
+
}
|
|
42
|
+
>;
|
|
43
|
+
export type RamBundleInfo = {
|
|
44
|
+
getDependencies: ($$PARAM_0$$: string) => Set<string>;
|
|
45
|
+
startupModules: ReadonlyArray<ModuleTransportLike>;
|
|
46
|
+
lazyModules: ReadonlyArray<ModuleTransportLike>;
|
|
47
|
+
groups: Map<number, Set<number>>;
|
|
48
|
+
};
|
|
49
|
+
declare function getRamBundleInfo(
|
|
50
|
+
entryPoint: string,
|
|
51
|
+
pre: ReadonlyArray<Module>,
|
|
52
|
+
graph: ReadOnlyGraph,
|
|
53
|
+
options: Options,
|
|
54
|
+
): Promise<RamBundleInfo>;
|
|
55
|
+
export default getRamBundleInfo;
|
|
@@ -16,11 +16,7 @@ var _sourceMapObject = require("./sourceMapObject");
|
|
|
16
16
|
var _nullthrows = _interopRequireDefault(require("nullthrows"));
|
|
17
17
|
var _path = _interopRequireDefault(require("path"));
|
|
18
18
|
function _interopRequireDefault(e) {
|
|
19
|
-
return e && e.__esModule
|
|
20
|
-
? e
|
|
21
|
-
: {
|
|
22
|
-
default: e,
|
|
23
|
-
};
|
|
19
|
+
return e && e.__esModule ? e : { default: e };
|
|
24
20
|
}
|
|
25
21
|
async function getRamBundleInfo(entryPoint, pre, graph, options) {
|
|
26
22
|
let modules = [...pre, ...graph.dependencies.values()];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @noformat
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
* @generated SignedSource<<f9cd017db02091bdd4f6d114e4744087>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/DeltaBundler/Serializers/helpers/getInlineSourceMappingURL.js
|
|
13
|
+
* To regenerate, run:
|
|
14
|
+
* js1 build metro-ts-defs (internal) OR
|
|
15
|
+
* yarn run build-ts-defs (OSS)
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
declare function getInlineSourceMappingURL(sourceMap: string): string;
|
|
19
|
+
export default getInlineSourceMappingURL;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @noformat
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
* @generated SignedSource<<cd7e523b4fdfbff33e663b21c4529401>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.js
|
|
13
|
+
* To regenerate, run:
|
|
14
|
+
* js1 build metro-ts-defs (internal) OR
|
|
15
|
+
* yarn run build-ts-defs (OSS)
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import type {Module} from '../../types';
|
|
19
|
+
import type {
|
|
20
|
+
FBSourceFunctionMap,
|
|
21
|
+
MetroSourceMapSegmentTuple,
|
|
22
|
+
} from 'metro-source-map';
|
|
23
|
+
|
|
24
|
+
declare function getSourceMapInfo(
|
|
25
|
+
module: Module,
|
|
26
|
+
options: {
|
|
27
|
+
readonly excludeSource: boolean;
|
|
28
|
+
readonly shouldAddToIgnoreList: ($$PARAM_0$$: Module) => boolean;
|
|
29
|
+
getSourceUrl: null | undefined | ((module: Module) => string);
|
|
30
|
+
},
|
|
31
|
+
): {
|
|
32
|
+
readonly map: Array<MetroSourceMapSegmentTuple>;
|
|
33
|
+
readonly functionMap: null | undefined | FBSourceFunctionMap;
|
|
34
|
+
readonly code: string;
|
|
35
|
+
readonly path: string;
|
|
36
|
+
readonly source: string;
|
|
37
|
+
readonly lineCount: number;
|
|
38
|
+
readonly isIgnored: boolean;
|
|
39
|
+
};
|
|
40
|
+
export default getSourceMapInfo;
|
|
@@ -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<<55bd91c160900bb31ffe72e2ddfad85d>>
|
|
10
|
+
*
|
|
11
|
+
* This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
|
|
12
|
+
* Original file: packages/metro/src/DeltaBundler/Serializers/helpers/getTransitiveDependencies.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 {ReadOnlyGraph} from '../../types';
|
|
19
|
+
|
|
20
|
+
declare function getTransitiveDependencies<T>(
|
|
21
|
+
path: string,
|
|
22
|
+
graph: ReadOnlyGraph<T>,
|
|
23
|
+
): Set<string>;
|
|
24
|
+
export default getTransitiveDependencies;
|