metro 0.83.3 → 0.83.5
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 +28 -24
- package/src/Assets.d.ts +83 -0
- package/src/Assets.js +42 -29
- package/src/Assets.js.flow +26 -15
- package/src/Bundler/util.d.ts +27 -0
- package/src/Bundler/util.js +25 -21
- package/src/Bundler/util.js.flow +2 -2
- package/src/Bundler.d.ts +14 -15
- package/src/Bundler.js.flow +1 -1
- package/src/DeltaBundler/DeltaCalculator.d.ts +71 -0
- package/src/DeltaBundler/DeltaCalculator.js +4 -4
- package/src/DeltaBundler/DeltaCalculator.js.flow +8 -8
- package/src/DeltaBundler/Graph.d.ts +135 -8
- package/src/DeltaBundler/Graph.js +16 -16
- package/src/DeltaBundler/Graph.js.flow +30 -30
- package/src/DeltaBundler/Serializers/baseJSBundle.d.ts +20 -0
- package/src/DeltaBundler/Serializers/baseJSBundle.js.flow +1 -1
- package/src/DeltaBundler/Serializers/getAllFiles.d.ts +22 -0
- package/src/DeltaBundler/Serializers/getAllFiles.js.flow +2 -2
- package/src/DeltaBundler/Serializers/getAssets.d.ts +25 -0
- package/src/DeltaBundler/Serializers/getAssets.js.flow +2 -2
- package/src/DeltaBundler/Serializers/getExplodedSourceMap.js.flow +2 -2
- package/src/DeltaBundler/Serializers/getRamBundleInfo.d.ts +36 -6
- package/src/DeltaBundler/Serializers/getRamBundleInfo.js.flow +8 -8
- package/src/DeltaBundler/Serializers/helpers/getInlineSourceMappingURL.d.ts +12 -0
- package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.d.ts +33 -0
- package/src/DeltaBundler/Serializers/helpers/getTransitiveDependencies.d.ts +17 -0
- package/src/DeltaBundler/Serializers/helpers/js.d.ts +30 -0
- package/src/DeltaBundler/Serializers/helpers/js.js +25 -21
- package/src/DeltaBundler/Serializers/helpers/js.js.flow +6 -6
- package/src/DeltaBundler/Serializers/helpers/processModules.d.ts +25 -0
- package/src/DeltaBundler/Serializers/helpers/processModules.js.flow +3 -3
- package/src/DeltaBundler/Serializers/hmrJSBundle.d.ts +30 -0
- package/src/DeltaBundler/Serializers/hmrJSBundle.js +25 -21
- package/src/DeltaBundler/Serializers/hmrJSBundle.js.flow +5 -5
- package/src/DeltaBundler/Serializers/sourceMapGenerator.d.ts +29 -0
- package/src/DeltaBundler/Serializers/sourceMapGenerator.js.flow +6 -6
- package/src/DeltaBundler/Serializers/sourceMapObject.d.ts +23 -0
- package/src/DeltaBundler/Serializers/sourceMapObject.js.flow +2 -2
- package/src/DeltaBundler/Serializers/sourceMapString.d.ts +22 -0
- package/src/DeltaBundler/Serializers/sourceMapString.js.flow +2 -2
- package/src/DeltaBundler/Transformer.d.ts +38 -0
- package/src/DeltaBundler/Transformer.js.flow +3 -3
- package/src/DeltaBundler/Worker.d.ts +19 -27
- package/src/DeltaBundler/Worker.flow.js.flow +1 -1
- package/src/DeltaBundler/WorkerFarm.d.ts +70 -0
- package/src/DeltaBundler/WorkerFarm.js +1 -1
- package/src/DeltaBundler/WorkerFarm.js.flow +26 -13
- package/src/DeltaBundler/buildSubgraph.d.ts +30 -0
- package/src/DeltaBundler/buildSubgraph.js +4 -4
- package/src/DeltaBundler/buildSubgraph.js.flow +8 -8
- package/src/DeltaBundler/getTransformCacheKey.d.ts +18 -0
- package/src/DeltaBundler/mergeDeltas.d.ts +17 -0
- package/src/DeltaBundler/types.d.ts +97 -100
- package/src/DeltaBundler/types.js.flow +36 -34
- package/src/DeltaBundler.d.ts +14 -12
- package/src/DeltaBundler.js.flow +2 -2
- package/src/HmrServer.d.ts +79 -0
- package/src/HmrServer.js +34 -29
- package/src/HmrServer.js.flow +17 -12
- package/src/IncrementalBundler/GraphNotFoundError.d.ts +17 -0
- package/src/IncrementalBundler/ResourceNotFoundError.d.ts +15 -0
- package/src/IncrementalBundler/RevisionNotFoundError.d.ts +17 -0
- package/src/IncrementalBundler.d.ts +43 -45
- package/src/IncrementalBundler.js +29 -21
- package/src/IncrementalBundler.js.flow +13 -9
- package/src/ModuleGraph/worker/JsFileWrapping.d.ts +29 -0
- package/src/ModuleGraph/worker/JsFileWrapping.js +25 -21
- package/src/ModuleGraph/worker/JsFileWrapping.js.flow +10 -5
- package/src/ModuleGraph/worker/collectDependencies.d.ts +118 -14
- package/src/ModuleGraph/worker/collectDependencies.js +25 -21
- package/src/ModuleGraph/worker/collectDependencies.js.flow +27 -21
- package/src/ModuleGraph/worker/generateImportNames.d.ts +19 -0
- package/src/ModuleGraph/worker/generateImportNames.js.flow +4 -2
- package/src/ModuleGraph/worker/importLocationsPlugin.d.ts +26 -0
- package/src/ModuleGraph/worker/importLocationsPlugin.js.flow +7 -3
- package/src/Server/MultipartResponse.d.ts +5 -6
- package/src/Server/MultipartResponse.js.flow +1 -1
- package/src/Server/symbolicate.js.flow +4 -4
- package/src/Server.d.ts +220 -67
- package/src/Server.js +149 -45
- package/src/Server.js.flow +167 -57
- package/src/cli/parseKeyValueParamArray.d.ts +14 -0
- package/src/cli/parseKeyValueParamArray.js.flow +1 -1
- package/src/cli-utils.d.ts +19 -0
- package/src/cli-utils.js.flow +2 -2
- package/src/commands/build.d.ts +16 -0
- package/src/commands/build.js.flow +11 -10
- package/src/commands/dependencies.d.ts +16 -0
- package/src/commands/dependencies.js.flow +8 -4
- package/src/commands/serve.d.ts +16 -0
- package/src/commands/serve.js +2 -0
- package/src/commands/serve.js.flow +14 -9
- package/src/index.d.ts +97 -110
- package/src/index.flow.js +53 -35
- package/src/index.flow.js.flow +49 -29
- package/src/integration_tests/basic_bundle/AssetRegistry.js.flow +1 -1
- package/src/integration_tests/basic_bundle/ErrorBundle.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-import.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-multi-line-import-with-escapes.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-multi-line-import.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-require-with-embedded-comment.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-require.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-specifier-with-escapes.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/inline-requires-cannot-resolve-import.js.flow +1 -1
- package/src/integration_tests/basic_bundle/build-errors/inline-requires-cannot-resolve-require.js.flow +1 -1
- package/src/integration_tests/basic_bundle/import-export/index.js +25 -21
- package/src/integration_tests/basic_bundle/import-export/index.js.flow +3 -3
- package/src/integration_tests/basic_bundle/import-export/utils.js.flow +2 -2
- package/src/integration_tests/basic_bundle/loadBundleAsyncForTest.js.flow +1 -1
- package/src/integration_tests/basic_bundle/optional-dependencies/index.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-context/conflict.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-context/empty.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-context/matching.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-context/mode-eager.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-context/mode-lazy-once.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-context/mode-lazy.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-context/mode-sync.js.flow +2 -2
- package/src/integration_tests/basic_bundle/require-context/utils.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-resolveWeak/import-and-resolveWeak.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-resolveWeak/multiple.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-resolveWeak/never-required.js.flow +1 -1
- package/src/integration_tests/basic_bundle/require-resolveWeak/require-and-resolveWeak.js.flow +1 -1
- package/src/integration_tests/execBundle.js.flow +1 -1
- package/src/lib/BatchProcessor.d.ts +54 -0
- package/src/lib/BatchProcessor.js +5 -2
- package/src/lib/BatchProcessor.js.flow +10 -7
- package/src/lib/CountingSet.d.ts +10 -10
- package/src/lib/CountingSet.js.flow +4 -4
- package/src/lib/JsonReporter.d.ts +37 -0
- package/src/lib/JsonReporter.js +5 -3
- package/src/lib/JsonReporter.js.flow +19 -17
- package/src/lib/RamBundleParser.d.ts +29 -0
- package/src/lib/RamBundleParser.js.flow +1 -1
- package/src/lib/TerminalReporter.d.ts +97 -6
- package/src/lib/TerminalReporter.js +37 -34
- package/src/lib/TerminalReporter.js.flow +21 -30
- package/src/lib/bundleProgressUtils.d.ts +26 -0
- package/src/lib/bundleProgressUtils.js +19 -0
- package/src/lib/bundleProgressUtils.js.flow +35 -0
- package/src/lib/bundleToString.d.ts +19 -0
- package/src/lib/contextModule.d.ts +20 -9
- package/src/lib/contextModule.js.flow +1 -1
- package/src/lib/contextModuleTemplates.d.ts +25 -0
- package/src/lib/contextModuleTemplates.js +25 -21
- package/src/lib/countLines.d.ts +12 -0
- package/src/lib/countLines.js +4 -3
- package/src/lib/countLines.js.flow +3 -4
- package/src/lib/createWebsocketServer.d.ts +43 -0
- package/src/lib/createWebsocketServer.js +9 -2
- package/src/lib/createWebsocketServer.js.flow +16 -9
- package/src/lib/debounceAsyncQueue.d.ts +15 -0
- package/src/lib/debounceAsyncQueue.js.flow +1 -1
- package/src/lib/formatBundlingError.d.ts +23 -0
- package/src/lib/formatBundlingError.js.flow +1 -1
- package/src/lib/getAppendScripts.d.ts +31 -0
- package/src/lib/getAppendScripts.js.flow +4 -4
- package/src/lib/getGraphId.d.ts +15 -1
- package/src/lib/getGraphId.js.flow +1 -1
- package/src/lib/getPreludeCode.d.ts +18 -0
- package/src/lib/getPreludeCode.js +4 -0
- package/src/lib/getPreludeCode.js.flow +10 -3
- package/src/lib/getPrependedScripts.d.ts +24 -0
- package/src/lib/getPrependedScripts.js +36 -22
- package/src/lib/getPrependedScripts.js.flow +10 -3
- package/src/lib/isResolvedDependency.d.ts +15 -0
- package/src/lib/logToConsole.d.ts +19 -0
- package/src/lib/logToConsole.js.flow +2 -2
- package/src/lib/parseBundleOptionsFromBundleRequestUrl.d.ts +17 -0
- package/src/lib/parseBundleOptionsFromBundleRequestUrl.js +25 -21
- package/src/lib/parseCustomResolverOptions.d.ts +16 -0
- package/src/lib/parseCustomResolverOptions.js.flow +2 -2
- package/src/lib/parseCustomTransformOptions.d.ts +16 -0
- package/src/lib/parseCustomTransformOptions.js.flow +1 -1
- package/src/lib/parseJsonBody.d.ts +27 -0
- package/src/lib/parseJsonBody.js.flow +11 -1
- package/src/lib/pathUtils.d.ts +14 -0
- package/src/lib/pathUtils.js +25 -21
- package/src/lib/pathUtils.js.flow +1 -1
- package/src/lib/relativizeSourceMap.d.ts +17 -0
- package/src/lib/reporting.d.ts +65 -81
- package/src/lib/reporting.js.flow +4 -4
- package/src/lib/splitBundleOptions.d.ts +16 -0
- package/src/lib/transformHelpers.d.ts +35 -0
- package/src/lib/transformHelpers.js +11 -9
- package/src/lib/transformHelpers.js.flow +17 -15
- package/src/node-haste/DependencyGraph/ModuleResolution.d.ts +126 -0
- package/src/node-haste/DependencyGraph/ModuleResolution.js +48 -42
- package/src/node-haste/DependencyGraph/ModuleResolution.js.flow +35 -32
- package/src/node-haste/DependencyGraph/createFileMap.d.ts +29 -0
- package/src/node-haste/DependencyGraph/createFileMap.js +56 -38
- package/src/node-haste/DependencyGraph/createFileMap.js.flow +44 -18
- package/src/node-haste/DependencyGraph.d.ts +57 -33
- package/src/node-haste/DependencyGraph.js +40 -31
- package/src/node-haste/DependencyGraph.js.flow +35 -37
- package/src/node-haste/Package.d.ts +21 -0
- package/src/node-haste/PackageCache.d.ts +34 -0
- package/src/node-haste/lib/AssetPaths.d.ts +29 -0
- package/src/node-haste/lib/AssetPaths.js +2 -2
- package/src/node-haste/lib/AssetPaths.js.flow +4 -4
- package/src/node-haste/lib/parsePlatformFilePath.d.ts +25 -0
- package/src/node-haste/lib/parsePlatformFilePath.js +6 -6
- package/src/node-haste/lib/parsePlatformFilePath.js.flow +4 -4
- package/src/shared/output/RamBundle/as-assets.d.ts +25 -0
- package/src/shared/output/RamBundle/as-assets.js.flow +6 -6
- package/src/shared/output/RamBundle/as-indexed-file.d.ts +38 -0
- package/src/shared/output/RamBundle/as-indexed-file.js.flow +5 -5
- package/src/shared/output/RamBundle/buildSourcemapWithMetadata.d.ts +23 -0
- package/src/shared/output/RamBundle/buildSourcemapWithMetadata.js.flow +5 -5
- package/src/shared/output/RamBundle/magic-number.d.ts +14 -0
- package/src/shared/output/RamBundle/util.d.ts +41 -0
- package/src/shared/output/RamBundle/util.js.flow +5 -5
- package/src/shared/output/RamBundle/write-sourcemap.d.ts +16 -0
- package/src/shared/output/RamBundle/write-sourcemap.js.flow +1 -1
- package/src/shared/output/RamBundle.d.ts +26 -0
- package/src/shared/output/RamBundle.js.flow +1 -1
- package/src/shared/output/bundle.d.ts +9 -17
- package/src/shared/output/bundle.flow.js.flow +3 -3
- package/src/shared/output/meta.d.ts +15 -0
- package/src/shared/output/meta.js +2 -2
- package/src/shared/output/meta.js.flow +1 -1
- package/src/shared/output/unbundle.d.ts +11 -0
- package/src/shared/output/writeFile.d.ts +16 -0
- package/src/shared/output/writeFile.js +8 -3
- package/src/shared/output/writeFile.js.flow +8 -2
- package/src/shared/types.d.ts +81 -66
- package/src/shared/types.js.flow +20 -5
- package/src/Asset.d.ts +0 -25
- package/src/ModuleGraph/test-helpers.js +0 -75
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type {RamBundleInfo} from '../../../DeltaBundler/Serializers/getRamBundleInfo';
|
|
12
|
+
import type {
|
|
13
|
+
ModuleGroups,
|
|
14
|
+
ModuleTransportLike,
|
|
15
|
+
OutputOptions,
|
|
16
|
+
} from '../../types';
|
|
17
|
+
/**
|
|
18
|
+
* Saves all JS modules of an app as a single file, separated with null bytes.
|
|
19
|
+
* The file begins with an offset table that contains module ids and their
|
|
20
|
+
* lengths/offsets.
|
|
21
|
+
* The module id for the startup code (prelude, polyfills etc.) is the
|
|
22
|
+
* empty string.
|
|
23
|
+
*/
|
|
24
|
+
export declare function save(
|
|
25
|
+
bundle: RamBundleInfo,
|
|
26
|
+
options: OutputOptions,
|
|
27
|
+
log: (...args: Array<string>) => void,
|
|
28
|
+
): Promise<unknown>;
|
|
29
|
+
export declare function buildTableAndContents(
|
|
30
|
+
startupCode: string,
|
|
31
|
+
modules: ReadonlyArray<ModuleTransportLike>,
|
|
32
|
+
moduleGroups: ModuleGroups,
|
|
33
|
+
encoding?: 'utf8' | 'utf16le' | 'ascii',
|
|
34
|
+
): Array<Buffer>;
|
|
35
|
+
export declare function createModuleGroups(
|
|
36
|
+
groups: Map<number, Set<number>>,
|
|
37
|
+
modules: ReadonlyArray<ModuleTransportLike>,
|
|
38
|
+
): ModuleGroups;
|
|
@@ -37,7 +37,7 @@ export function save(
|
|
|
37
37
|
bundle: RamBundleInfo,
|
|
38
38
|
options: OutputOptions,
|
|
39
39
|
log: (...args: Array<string>) => void,
|
|
40
|
-
): Promise<
|
|
40
|
+
): Promise<unknown> {
|
|
41
41
|
const {
|
|
42
42
|
bundleOutput,
|
|
43
43
|
bundleEncoding: encoding,
|
|
@@ -96,7 +96,7 @@ function writeBuffers(
|
|
|
96
96
|
buffers: Array<Buffer>,
|
|
97
97
|
): Promise<void> {
|
|
98
98
|
buffers.forEach((buffer: Buffer) => stream.write(buffer));
|
|
99
|
-
return new Promise((resolve: () => void, reject:
|
|
99
|
+
return new Promise((resolve: () => void, reject: unknown => unknown) => {
|
|
100
100
|
stream.on('error', reject);
|
|
101
101
|
stream.on('finish', () => resolve());
|
|
102
102
|
stream.end();
|
|
@@ -196,7 +196,7 @@ function groupCode(
|
|
|
196
196
|
}
|
|
197
197
|
|
|
198
198
|
function buildModuleBuffers(
|
|
199
|
-
modules:
|
|
199
|
+
modules: ReadonlyArray<ModuleTransportLike>,
|
|
200
200
|
moduleGroups: ModuleGroups,
|
|
201
201
|
encoding: void | 'ascii' | 'utf16le' | 'utf8',
|
|
202
202
|
): Array<{
|
|
@@ -217,7 +217,7 @@ function buildModuleBuffers(
|
|
|
217
217
|
|
|
218
218
|
export function buildTableAndContents(
|
|
219
219
|
startupCode: string,
|
|
220
|
-
modules:
|
|
220
|
+
modules: ReadonlyArray<ModuleTransportLike>,
|
|
221
221
|
moduleGroups: ModuleGroups,
|
|
222
222
|
encoding?: 'utf8' | 'utf16le' | 'ascii',
|
|
223
223
|
): Array<Buffer> {
|
|
@@ -242,7 +242,7 @@ export function buildTableAndContents(
|
|
|
242
242
|
|
|
243
243
|
export function createModuleGroups(
|
|
244
244
|
groups: Map<number, Set<number>>,
|
|
245
|
-
modules:
|
|
245
|
+
modules: ReadonlyArray<ModuleTransportLike>,
|
|
246
246
|
): ModuleGroups {
|
|
247
247
|
return {
|
|
248
248
|
groups,
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type {ModuleGroups, ModuleTransportLike} from '../../types';
|
|
12
|
+
import type {IndexMap} from 'metro-source-map';
|
|
13
|
+
|
|
14
|
+
type Params = {
|
|
15
|
+
fixWrapperOffset: boolean;
|
|
16
|
+
lazyModules: ReadonlyArray<ModuleTransportLike>;
|
|
17
|
+
moduleGroups: null | undefined | ModuleGroups;
|
|
18
|
+
startupModules: ReadonlyArray<ModuleTransportLike>;
|
|
19
|
+
};
|
|
20
|
+
declare const $$EXPORT_DEFAULT_DECLARATION$$: ($$PARAM_0$$: Params) => IndexMap;
|
|
21
|
+
declare type $$EXPORT_DEFAULT_DECLARATION$$ =
|
|
22
|
+
typeof $$EXPORT_DEFAULT_DECLARATION$$;
|
|
23
|
+
export default $$EXPORT_DEFAULT_DECLARATION$$;
|
|
@@ -20,17 +20,17 @@ import {
|
|
|
20
20
|
|
|
21
21
|
type Params = {
|
|
22
22
|
fixWrapperOffset: boolean,
|
|
23
|
-
lazyModules:
|
|
23
|
+
lazyModules: ReadonlyArray<ModuleTransportLike>,
|
|
24
24
|
moduleGroups: ?ModuleGroups,
|
|
25
|
-
startupModules:
|
|
25
|
+
startupModules: ReadonlyArray<ModuleTransportLike>,
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
export default (
|
|
28
|
+
export default ({
|
|
29
29
|
fixWrapperOffset,
|
|
30
30
|
lazyModules,
|
|
31
31
|
moduleGroups,
|
|
32
32
|
startupModules,
|
|
33
|
-
}: Params) => {
|
|
33
|
+
}: Params): IndexMap => {
|
|
34
34
|
const options = fixWrapperOffset ? {fixWrapperOffset: true} : undefined;
|
|
35
35
|
const startupModule: ModuleTransportLike = {
|
|
36
36
|
code: joinModules(startupModules),
|
|
@@ -59,4 +59,4 @@ export default (({
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
return map;
|
|
62
|
-
}
|
|
62
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
* @format
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
declare const $$EXPORT_DEFAULT_DECLARATION$$: 0xfb0bd1e5;
|
|
12
|
+
declare type $$EXPORT_DEFAULT_DECLARATION$$ =
|
|
13
|
+
typeof $$EXPORT_DEFAULT_DECLARATION$$;
|
|
14
|
+
export default $$EXPORT_DEFAULT_DECLARATION$$;
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
* @format
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type {ModuleGroups, ModuleTransportLike} from '../../types';
|
|
12
|
+
import type {BasicSourceMap, IndexMap} from 'metro-source-map';
|
|
13
|
+
|
|
14
|
+
import countLines from '../../../lib/countLines';
|
|
15
|
+
|
|
16
|
+
declare function lineToLineSourceMap(
|
|
17
|
+
source: string,
|
|
18
|
+
filename?: string,
|
|
19
|
+
): BasicSourceMap;
|
|
20
|
+
type CombineOptions = {fixWrapperOffset: boolean};
|
|
21
|
+
declare function combineSourceMaps(
|
|
22
|
+
modules: ReadonlyArray<ModuleTransportLike>,
|
|
23
|
+
moduleGroups?: ModuleGroups,
|
|
24
|
+
options?: null | undefined | CombineOptions,
|
|
25
|
+
): IndexMap;
|
|
26
|
+
declare function combineSourceMapsAddingOffsets(
|
|
27
|
+
modules: ReadonlyArray<ModuleTransportLike>,
|
|
28
|
+
x_metro_module_paths: Array<string>,
|
|
29
|
+
moduleGroups?: null | undefined | ModuleGroups,
|
|
30
|
+
options?: null | undefined | CombineOptions,
|
|
31
|
+
): IndexMap;
|
|
32
|
+
declare const joinModules: (
|
|
33
|
+
modules: ReadonlyArray<{readonly code: string}>,
|
|
34
|
+
) => string;
|
|
35
|
+
export {
|
|
36
|
+
combineSourceMaps,
|
|
37
|
+
combineSourceMapsAddingOffsets,
|
|
38
|
+
countLines,
|
|
39
|
+
joinModules,
|
|
40
|
+
lineToLineSourceMap,
|
|
41
|
+
};
|
|
@@ -50,7 +50,7 @@ const Section = (line: number, column: number, map: MixedSourceMap) => ({
|
|
|
50
50
|
type CombineOptions = {fixWrapperOffset: boolean, ...};
|
|
51
51
|
|
|
52
52
|
function combineSourceMaps(
|
|
53
|
-
modules:
|
|
53
|
+
modules: ReadonlyArray<ModuleTransportLike>,
|
|
54
54
|
moduleGroups?: ModuleGroups,
|
|
55
55
|
options?: ?CombineOptions,
|
|
56
56
|
): IndexMap {
|
|
@@ -59,7 +59,7 @@ function combineSourceMaps(
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
function combineSourceMapsAddingOffsets(
|
|
62
|
-
modules:
|
|
62
|
+
modules: ReadonlyArray<ModuleTransportLike>,
|
|
63
63
|
x_metro_module_paths: Array<string>,
|
|
64
64
|
moduleGroups?: ?ModuleGroups,
|
|
65
65
|
options?: ?CombineOptions,
|
|
@@ -75,7 +75,7 @@ function combineSourceMapsAddingOffsets(
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
function combineMaps(
|
|
78
|
-
modules:
|
|
78
|
+
modules: ReadonlyArray<ModuleTransportLike>,
|
|
79
79
|
offsets: ?Array<number>,
|
|
80
80
|
moduleGroups: ?ModuleGroups,
|
|
81
81
|
options: ?CombineOptions,
|
|
@@ -99,7 +99,7 @@ function combineMaps(
|
|
|
99
99
|
group = moduleGroups && moduleGroups.groups.get(id);
|
|
100
100
|
if (group && moduleGroups) {
|
|
101
101
|
const {modulesById} = moduleGroups;
|
|
102
|
-
const otherModules:
|
|
102
|
+
const otherModules: ReadonlyArray<ModuleTransportLike> = Array.from(
|
|
103
103
|
group || [],
|
|
104
104
|
)
|
|
105
105
|
.map((moduleId: number) => modulesById.get(moduleId))
|
|
@@ -135,7 +135,7 @@ function combineMaps(
|
|
|
135
135
|
return sections;
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
-
const joinModules = (modules:
|
|
138
|
+
const joinModules = (modules: ReadonlyArray<{+code: string, ...}>): string =>
|
|
139
139
|
modules.map((m: {+code: string, ...}) => m.code).join('\n');
|
|
140
140
|
|
|
141
141
|
export {
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
* @format
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
declare function writeSourcemap(
|
|
12
|
+
fileName: string,
|
|
13
|
+
contents: string,
|
|
14
|
+
log: (...args: Array<string>) => void,
|
|
15
|
+
): Promise<unknown>;
|
|
16
|
+
export default writeSourcemap;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type {RamBundleInfo} from '../../DeltaBundler/Serializers/getRamBundleInfo';
|
|
12
|
+
import type {OutputOptions, RequestOptions} from '../types';
|
|
13
|
+
|
|
14
|
+
import Server from '../../Server';
|
|
15
|
+
|
|
16
|
+
export declare function build(
|
|
17
|
+
packagerClient: Server,
|
|
18
|
+
requestOptions: RequestOptions,
|
|
19
|
+
): Promise<RamBundleInfo>;
|
|
20
|
+
export declare function save(
|
|
21
|
+
bundle: RamBundleInfo,
|
|
22
|
+
options: OutputOptions,
|
|
23
|
+
log: (x: string) => void,
|
|
24
|
+
): Promise<unknown>;
|
|
25
|
+
export declare const formatName: 'bundle';
|
|
26
|
+
export declare type formatName = typeof formatName;
|
|
@@ -33,7 +33,7 @@ export function save(
|
|
|
33
33
|
bundle: RamBundleInfo,
|
|
34
34
|
options: OutputOptions,
|
|
35
35
|
log: (x: string) => void,
|
|
36
|
-
): Promise<
|
|
36
|
+
): Promise<unknown> {
|
|
37
37
|
// We fork here depending on the platform: while Android is pretty good at
|
|
38
38
|
// loading individual assets, iOS has a large overhead when reading hundreds
|
|
39
39
|
// of assets from disk.
|
|
@@ -8,28 +8,20 @@
|
|
|
8
8
|
* @oncall react_native
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import type {AssetData} from '../../
|
|
11
|
+
import type {AssetData} from '../../Assets';
|
|
12
|
+
import type {BuildOptions, OutputOptions, RequestOptions} from '../types';
|
|
12
13
|
|
|
13
14
|
import Server from '../../Server';
|
|
14
|
-
import {BuildOptions, OutputOptions, RequestOptions} from '../../shared/types';
|
|
15
15
|
|
|
16
|
-
export function build(
|
|
16
|
+
export declare function build(
|
|
17
17
|
packagerClient: Server,
|
|
18
18
|
requestOptions: RequestOptions,
|
|
19
19
|
buildOptions?: BuildOptions,
|
|
20
|
-
): Promise<{
|
|
21
|
-
|
|
22
|
-
map: string
|
|
23
|
-
assets?: ReadonlyArray<AssetData>;
|
|
24
|
-
}>;
|
|
25
|
-
|
|
26
|
-
export function save(
|
|
27
|
-
bundle: {
|
|
28
|
-
code: string;
|
|
29
|
-
map: string;
|
|
30
|
-
},
|
|
20
|
+
): Promise<{code: string; map: string; assets?: ReadonlyArray<AssetData>}>;
|
|
21
|
+
export declare function save(
|
|
22
|
+
bundle: {code: string; map: string},
|
|
31
23
|
options: OutputOptions,
|
|
32
|
-
log: (
|
|
24
|
+
log: ($$PARAM_0$$: string) => void,
|
|
33
25
|
): Promise<unknown>;
|
|
34
|
-
|
|
35
|
-
export
|
|
26
|
+
export declare const formatName: 'bundle';
|
|
27
|
+
export declare type formatName = typeof formatName;
|
|
@@ -26,7 +26,7 @@ export function build(
|
|
|
26
26
|
): Promise<{
|
|
27
27
|
code: string,
|
|
28
28
|
map: string,
|
|
29
|
-
assets?:
|
|
29
|
+
assets?: ReadonlyArray<AssetData>,
|
|
30
30
|
...
|
|
31
31
|
}> {
|
|
32
32
|
return packagerClient.build(
|
|
@@ -69,7 +69,7 @@ export async function save(
|
|
|
69
69
|
},
|
|
70
70
|
options: OutputOptions,
|
|
71
71
|
log: string => void,
|
|
72
|
-
): Promise<
|
|
72
|
+
): Promise<unknown> {
|
|
73
73
|
const {
|
|
74
74
|
bundleOutput,
|
|
75
75
|
bundleEncoding: encoding,
|
|
@@ -101,7 +101,7 @@ export async function save(
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
// Wait until everything is written to disk.
|
|
104
|
-
await Promise.all(writeFns.map((cb: void =>
|
|
104
|
+
await Promise.all(writeFns.map((cb: void => unknown) => cb()));
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
export const formatName = 'bundle';
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
* @format
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
declare function meta(
|
|
12
|
+
code: Buffer | string,
|
|
13
|
+
encoding?: 'ascii' | 'utf16le' | 'utf8',
|
|
14
|
+
): Buffer;
|
|
15
|
+
export default meta;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true,
|
|
5
5
|
});
|
|
6
|
-
exports.default =
|
|
6
|
+
exports.default = meta;
|
|
7
7
|
var _crypto = _interopRequireDefault(require("crypto"));
|
|
8
8
|
function _interopRequireDefault(e) {
|
|
9
9
|
return e && e.__esModule ? e : { default: e };
|
|
@@ -17,7 +17,7 @@ const constantFor = (encoding) =>
|
|
|
17
17
|
: /^(?:utf-?16(?:le)?|ucs-?2)$/.test(encoding)
|
|
18
18
|
? 3
|
|
19
19
|
: 0;
|
|
20
|
-
function
|
|
20
|
+
function meta(code, encoding = "utf8") {
|
|
21
21
|
const buffer = asBuffer(code, encoding);
|
|
22
22
|
const hash = _crypto.default.createHash("sha1");
|
|
23
23
|
hash.update(buffer);
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
* @format
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export * from './RamBundle';
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
* @format
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
declare function writeFile(
|
|
12
|
+
filePath: string,
|
|
13
|
+
data: string | Buffer | Uint8Array,
|
|
14
|
+
encoding?: string,
|
|
15
|
+
): Promise<void>;
|
|
16
|
+
export default writeFile;
|
|
@@ -3,11 +3,16 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true,
|
|
5
5
|
});
|
|
6
|
-
exports.default =
|
|
6
|
+
exports.default = writeFile;
|
|
7
7
|
var _fs = _interopRequireDefault(require("fs"));
|
|
8
8
|
var _throat = _interopRequireDefault(require("throat"));
|
|
9
9
|
function _interopRequireDefault(e) {
|
|
10
10
|
return e && e.__esModule ? e : { default: e };
|
|
11
11
|
}
|
|
12
|
-
const
|
|
13
|
-
|
|
12
|
+
const writeFileWithThroat = (0, _throat.default)(
|
|
13
|
+
128,
|
|
14
|
+
_fs.default.promises.writeFile,
|
|
15
|
+
);
|
|
16
|
+
function writeFile(filePath, data, encoding) {
|
|
17
|
+
return writeFileWithThroat(filePath, data, encoding);
|
|
18
|
+
}
|
|
@@ -12,9 +12,15 @@
|
|
|
12
12
|
import fs from 'fs';
|
|
13
13
|
import throat from 'throat';
|
|
14
14
|
|
|
15
|
-
const
|
|
15
|
+
const writeFileWithThroat: typeof fs.promises.writeFile = throat(
|
|
16
16
|
128,
|
|
17
17
|
fs.promises.writeFile,
|
|
18
18
|
);
|
|
19
19
|
|
|
20
|
-
export default writeFile
|
|
20
|
+
export default function writeFile(
|
|
21
|
+
filePath: string,
|
|
22
|
+
data: string | Buffer | Uint8Array,
|
|
23
|
+
encoding?: string,
|
|
24
|
+
): Promise<void> {
|
|
25
|
+
return writeFileWithThroat(filePath, data, encoding);
|
|
26
|
+
}
|
package/src/shared/types.d.ts
CHANGED
|
@@ -23,9 +23,26 @@ import type {
|
|
|
23
23
|
MinifierOptions,
|
|
24
24
|
} from 'metro-transform-worker';
|
|
25
25
|
|
|
26
|
-
type MetroSourceMapOrMappings =
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
type MetroSourceMapOrMappings =
|
|
27
|
+
| MixedSourceMap
|
|
28
|
+
| Array<MetroSourceMapSegmentTuple>;
|
|
29
|
+
export declare enum SourcePathsMode {
|
|
30
|
+
Absolute = 'absolute',
|
|
31
|
+
ServerUrl = 'url-server',
|
|
32
|
+
}
|
|
33
|
+
export declare namespace SourcePathsMode {
|
|
34
|
+
export function cast(value: string | null | undefined): SourcePathsMode;
|
|
35
|
+
export function isValid(
|
|
36
|
+
value: string | null | undefined,
|
|
37
|
+
): value is SourcePathsMode;
|
|
38
|
+
export function members(): IterableIterator<SourcePathsMode>;
|
|
39
|
+
export function getName(value: SourcePathsMode): string;
|
|
40
|
+
}
|
|
41
|
+
export type ReadonlySourceLocation = Readonly<{
|
|
42
|
+
start: Readonly<{line: number; column: number}>;
|
|
43
|
+
end: Readonly<{line: number; column: number}>;
|
|
44
|
+
}>;
|
|
45
|
+
export type BundleOptions = {
|
|
29
46
|
readonly customResolverOptions: CustomResolverOptions;
|
|
30
47
|
customTransformOptions: CustomTransformOptions;
|
|
31
48
|
dev: boolean;
|
|
@@ -35,77 +52,69 @@ export interface BundleOptions {
|
|
|
35
52
|
readonly lazy: boolean;
|
|
36
53
|
minify: boolean;
|
|
37
54
|
readonly modulesOnly: boolean;
|
|
38
|
-
onProgress
|
|
39
|
-
|
|
55
|
+
onProgress:
|
|
56
|
+
| null
|
|
57
|
+
| undefined
|
|
58
|
+
| ((doneCont: number, totalCount: number) => unknown);
|
|
59
|
+
readonly platform: null | undefined | string;
|
|
40
60
|
readonly runModule: boolean;
|
|
41
|
-
runtimeBytecodeVersion?: number;
|
|
42
61
|
readonly shallow: boolean;
|
|
43
|
-
sourceMapUrl
|
|
44
|
-
sourceUrl
|
|
62
|
+
sourceMapUrl: null | undefined | string;
|
|
63
|
+
sourceUrl: null | undefined | string;
|
|
45
64
|
createModuleIdFactory?: () => (path: string) => number;
|
|
46
65
|
readonly unstable_transformProfile: TransformProfile;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
export
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
export interface SerializerOptions {
|
|
58
|
-
readonly sourceMapUrl: string | null;
|
|
59
|
-
readonly sourceUrl: string | null;
|
|
66
|
+
readonly sourcePaths: SourcePathsMode;
|
|
67
|
+
};
|
|
68
|
+
export type BuildOptions = Readonly<{withAssets?: boolean}>;
|
|
69
|
+
export type ResolverInputOptions = Readonly<{
|
|
70
|
+
customResolverOptions?: CustomResolverOptions;
|
|
71
|
+
dev: boolean;
|
|
72
|
+
}>;
|
|
73
|
+
export type SerializerOptions = {
|
|
74
|
+
readonly sourceMapUrl: null | undefined | string;
|
|
75
|
+
readonly sourceUrl: null | undefined | string;
|
|
60
76
|
readonly runModule: boolean;
|
|
61
77
|
readonly excludeSource: boolean;
|
|
62
78
|
readonly inlineSourceMap: boolean;
|
|
63
79
|
readonly modulesOnly: boolean;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
export
|
|
80
|
+
readonly sourcePaths: SourcePathsMode;
|
|
81
|
+
};
|
|
82
|
+
export type GraphOptions = {
|
|
67
83
|
readonly lazy: boolean;
|
|
68
84
|
readonly shallow: boolean;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export interface ModuleGroups {
|
|
85
|
+
};
|
|
86
|
+
export type SplitBundleOptions = Readonly<{
|
|
87
|
+
entryFile: string;
|
|
88
|
+
resolverOptions: ResolverInputOptions;
|
|
89
|
+
transformOptions: TransformInputOptions;
|
|
90
|
+
serializerOptions: SerializerOptions;
|
|
91
|
+
graphOptions: GraphOptions;
|
|
92
|
+
onProgress: DeltaBundlerOptions['onProgress'];
|
|
93
|
+
}>;
|
|
94
|
+
export type ModuleGroups = {
|
|
82
95
|
groups: Map<number, Set<number>>;
|
|
83
96
|
modulesById: Map<number, ModuleTransportLike>;
|
|
84
97
|
modulesInGroups: Set<number>;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export interface ModuleTransportLike {
|
|
98
|
+
};
|
|
99
|
+
export type ModuleTransportLike = {
|
|
88
100
|
readonly code: string;
|
|
89
101
|
readonly id: number;
|
|
90
|
-
readonly map:
|
|
102
|
+
readonly map: null | undefined | MetroSourceMapOrMappings;
|
|
91
103
|
readonly name?: string;
|
|
92
104
|
readonly sourcePath: string;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export interface ModuleTransportLikeStrict {
|
|
105
|
+
};
|
|
106
|
+
export type ModuleTransportLikeStrict = {
|
|
96
107
|
readonly code: string;
|
|
97
108
|
readonly id: number;
|
|
98
|
-
readonly map:
|
|
109
|
+
readonly map: null | undefined | MetroSourceMapOrMappings;
|
|
99
110
|
readonly name?: string;
|
|
100
111
|
readonly sourcePath: string;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
readonly source: string;
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
export interface OutputOptions {
|
|
112
|
+
};
|
|
113
|
+
export type RamModuleTransport = Omit<
|
|
114
|
+
ModuleTransportLikeStrict,
|
|
115
|
+
keyof {readonly source: string; readonly type: string}
|
|
116
|
+
> & {readonly source: string; readonly type: string};
|
|
117
|
+
export type OutputOptions = {
|
|
109
118
|
bundleOutput: string;
|
|
110
119
|
bundleEncoding?: 'utf8' | 'utf16le' | 'ascii';
|
|
111
120
|
dev?: boolean;
|
|
@@ -114,17 +123,23 @@ export interface OutputOptions {
|
|
|
114
123
|
sourcemapOutput?: string;
|
|
115
124
|
sourcemapSourcesRoot?: string;
|
|
116
125
|
sourcemapUseAbsolutePath?: boolean;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
126
|
+
};
|
|
127
|
+
type SafeOptionalProps<T> = {
|
|
128
|
+
[K in keyof T]: T[K] extends void ? void | T[K] : T[K];
|
|
129
|
+
};
|
|
130
|
+
export type RequestOptions = Readonly<
|
|
131
|
+
SafeOptionalProps<{
|
|
132
|
+
entryFile: string;
|
|
133
|
+
inlineSourceMap?: boolean;
|
|
134
|
+
sourceMapUrl?: string;
|
|
135
|
+
dev?: boolean;
|
|
136
|
+
minify: boolean;
|
|
137
|
+
platform: string;
|
|
138
|
+
createModuleIdFactory?: () => (path: string) => number;
|
|
139
|
+
onProgress?: (transformedFileCount: number, totalFileCount: number) => void;
|
|
140
|
+
customResolverOptions?: CustomResolverOptions;
|
|
141
|
+
customTransformOptions?: CustomTransformOptions;
|
|
142
|
+
unstable_transformProfile?: TransformProfile;
|
|
143
|
+
}>
|
|
144
|
+
>;
|
|
130
145
|
export type {MinifierOptions};
|