metro 0.84.0 → 0.84.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/package.json +15 -14
  2. package/src/Assets.d.ts +90 -0
  3. package/src/Bundler/util.d.ts +34 -0
  4. package/src/Bundler.d.ts +45 -0
  5. package/src/DeltaBundler/DeltaCalculator.d.ts +78 -0
  6. package/src/DeltaBundler/Graph.d.ts +174 -0
  7. package/src/DeltaBundler/Serializers/baseJSBundle.d.ts +27 -0
  8. package/src/DeltaBundler/Serializers/getAllFiles.d.ts +29 -0
  9. package/src/DeltaBundler/Serializers/getAssets.d.ts +32 -0
  10. package/src/DeltaBundler/Serializers/getExplodedSourceMap.d.ts +33 -0
  11. package/src/DeltaBundler/Serializers/getRamBundleInfo.d.ts +55 -0
  12. package/src/DeltaBundler/Serializers/helpers/getInlineSourceMappingURL.d.ts +19 -0
  13. package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.d.ts +40 -0
  14. package/src/DeltaBundler/Serializers/helpers/getTransitiveDependencies.d.ts +24 -0
  15. package/src/DeltaBundler/Serializers/helpers/js.d.ts +37 -0
  16. package/src/DeltaBundler/Serializers/helpers/processModules.d.ts +32 -0
  17. package/src/DeltaBundler/Serializers/hmrJSBundle.d.ts +37 -0
  18. package/src/DeltaBundler/Serializers/sourceMapGenerator.d.ts +36 -0
  19. package/src/DeltaBundler/Serializers/sourceMapObject.d.ts +30 -0
  20. package/src/DeltaBundler/Serializers/sourceMapString.d.ts +29 -0
  21. package/src/DeltaBundler/Transformer.d.ts +45 -0
  22. package/src/DeltaBundler/Worker.d.ts +44 -0
  23. package/src/DeltaBundler/WorkerFarm.d.ts +77 -0
  24. package/src/DeltaBundler/buildSubgraph.d.ts +37 -0
  25. package/src/DeltaBundler/getTransformCacheKey.d.ts +25 -0
  26. package/src/DeltaBundler/mergeDeltas.d.ts +24 -0
  27. package/src/DeltaBundler/types.d.ts +170 -0
  28. package/src/DeltaBundler.d.ts +67 -0
  29. package/src/HmrServer.d.ts +86 -0
  30. package/src/IncrementalBundler/GraphNotFoundError.d.ts +24 -0
  31. package/src/IncrementalBundler/ResourceNotFoundError.d.ts +22 -0
  32. package/src/IncrementalBundler/RevisionNotFoundError.d.ts +24 -0
  33. package/src/IncrementalBundler.d.ts +103 -0
  34. package/src/ModuleGraph/worker/JsFileWrapping.d.ts +36 -0
  35. package/src/ModuleGraph/worker/collectDependencies.d.ts +138 -0
  36. package/src/ModuleGraph/worker/generateImportNames.d.ts +26 -0
  37. package/src/ModuleGraph/worker/importLocationsPlugin.d.ts +33 -0
  38. package/src/Server/MultipartResponse.d.ts +37 -0
  39. package/src/Server/symbolicate.d.ts +38 -0
  40. package/src/Server.d.ts +278 -0
  41. package/src/Server.js +10 -6
  42. package/src/Server.js.flow +9 -10
  43. package/src/cli/parseKeyValueParamArray.d.ts +21 -0
  44. package/src/cli-utils.d.ts +26 -0
  45. package/src/commands/build.d.ts +23 -0
  46. package/src/commands/dependencies.d.ts +23 -0
  47. package/src/commands/serve.d.ts +23 -0
  48. package/src/index.d.ts +187 -0
  49. package/src/index.flow.js +24 -10
  50. package/src/index.flow.js.flow +25 -10
  51. package/src/lib/BatchProcessor.d.ts +61 -0
  52. package/src/lib/CountingSet.d.ts +55 -0
  53. package/src/lib/JsonReporter.d.ts +44 -0
  54. package/src/lib/RamBundleParser.d.ts +36 -0
  55. package/src/lib/TerminalReporter.d.ts +125 -0
  56. package/src/lib/TerminalReporter.js +6 -7
  57. package/src/lib/TerminalReporter.js.flow +6 -15
  58. package/src/lib/bundleProgressUtils.d.ts +33 -0
  59. package/src/lib/bundleProgressUtils.js +19 -0
  60. package/src/lib/bundleProgressUtils.js.flow +35 -0
  61. package/src/lib/bundleToString.d.ts +26 -0
  62. package/src/lib/contextModule.d.ts +40 -0
  63. package/src/lib/contextModuleTemplates.d.ts +32 -0
  64. package/src/lib/countLines.d.ts +19 -0
  65. package/src/lib/createWebsocketServer.d.ts +50 -0
  66. package/src/lib/debounceAsyncQueue.d.ts +22 -0
  67. package/src/lib/formatBundlingError.d.ts +30 -0
  68. package/src/lib/getAppendScripts.d.ts +38 -0
  69. package/src/lib/getGraphId.d.ts +32 -0
  70. package/src/lib/getPreludeCode.d.ts +25 -0
  71. package/src/lib/getPrependedScripts.d.ts +31 -0
  72. package/src/lib/isResolvedDependency.d.ts +22 -0
  73. package/src/lib/logToConsole.d.ts +26 -0
  74. package/src/lib/parseBundleOptionsFromBundleRequestUrl.d.ts +24 -0
  75. package/src/lib/parseCustomResolverOptions.d.ts +23 -0
  76. package/src/lib/parseCustomTransformOptions.d.ts +23 -0
  77. package/src/lib/parseJsonBody.d.ts +34 -0
  78. package/src/lib/pathUtils.d.ts +21 -0
  79. package/src/lib/relativizeSourceMap.d.ts +24 -0
  80. package/src/lib/reporting.d.ts +135 -0
  81. package/src/lib/splitBundleOptions.d.ts +23 -0
  82. package/src/lib/transformHelpers.d.ts +42 -0
  83. package/src/node-haste/DependencyGraph/ModuleResolution.d.ts +133 -0
  84. package/src/node-haste/DependencyGraph/createFileMap.d.ts +36 -0
  85. package/src/node-haste/DependencyGraph.d.ts +93 -0
  86. package/src/node-haste/Package.d.ts +28 -0
  87. package/src/node-haste/PackageCache.d.ts +41 -0
  88. package/src/node-haste/lib/AssetPaths.d.ts +36 -0
  89. package/src/node-haste/lib/parsePlatformFilePath.d.ts +32 -0
  90. package/src/shared/output/RamBundle/as-assets.d.ts +32 -0
  91. package/src/shared/output/RamBundle/as-indexed-file.d.ts +45 -0
  92. package/src/shared/output/RamBundle/buildSourcemapWithMetadata.d.ts +30 -0
  93. package/src/shared/output/RamBundle/magic-number.d.ts +21 -0
  94. package/src/shared/output/RamBundle/util.d.ts +48 -0
  95. package/src/shared/output/RamBundle/write-sourcemap.d.ts +23 -0
  96. package/src/shared/output/RamBundle.d.ts +33 -0
  97. package/src/shared/output/bundle.d.ts +34 -0
  98. package/src/shared/output/meta.d.ts +22 -0
  99. package/src/shared/output/unbundle.d.ts +18 -0
  100. package/src/shared/output/writeFile.d.ts +23 -0
  101. package/src/shared/types.d.ts +152 -0
@@ -0,0 +1,135 @@
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<<1ff95f1ad6bb911f3d2c2bc41d59bc1a>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/lib/reporting.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 {Terminal} from 'metro-core';
19
+ import type {HealthCheckResult, WatcherStatus} from 'metro-file-map';
20
+ import type {CustomResolverOptions} from 'metro-resolver';
21
+ import type {CustomTransformOptions} from 'metro-transform-worker';
22
+
23
+ export type BundleDetails = {
24
+ bundleType: string;
25
+ customResolverOptions: CustomResolverOptions;
26
+ customTransformOptions: CustomTransformOptions;
27
+ dev: boolean;
28
+ entryFile: string;
29
+ minify: boolean;
30
+ platform: null | undefined | string;
31
+ };
32
+ /**
33
+ * A tagged union of all the actions that may happen and we may want to
34
+ * report to the tool user.
35
+ */
36
+ export type ReportableEvent =
37
+ | {port: number; hasReducedPerformance: boolean; type: 'initialize_started'}
38
+ | {type: 'initialize_failed'; port: number; error: Error}
39
+ | {type: 'initialize_done'; port: number}
40
+ | {buildID: string; type: 'bundle_build_done'}
41
+ | {buildID: string; type: 'bundle_build_failed'}
42
+ | {type: 'bundle_save_log'; message: string}
43
+ | {
44
+ buildID: string;
45
+ bundleDetails: BundleDetails;
46
+ isPrefetch?: boolean;
47
+ type: 'bundle_build_started';
48
+ }
49
+ | {error: Error; type: 'bundling_error'}
50
+ | {type: 'dep_graph_loading'; hasReducedPerformance: boolean}
51
+ | {type: 'dep_graph_loaded'}
52
+ | {
53
+ buildID: string;
54
+ type: 'bundle_transform_progressed';
55
+ transformedFileCount: number;
56
+ totalFileCount: number;
57
+ }
58
+ | {type: 'cache_read_error'; error: Error}
59
+ | {type: 'cache_write_error'; error: Error}
60
+ | {type: 'transform_cache_reset'}
61
+ | {type: 'worker_stdout_chunk'; chunk: string}
62
+ | {type: 'worker_stderr_chunk'; chunk: string}
63
+ | {type: 'hmr_client_error'; error: Error}
64
+ | {
65
+ type: 'client_log';
66
+ level:
67
+ | 'trace'
68
+ | 'info'
69
+ | 'warn'
70
+ | 'log'
71
+ | 'group'
72
+ | 'groupCollapsed'
73
+ | 'groupEnd'
74
+ | 'debug';
75
+ data: Array<unknown>;
76
+ }
77
+ | {type: 'resolver_warning'; message: string}
78
+ | {type: 'server_listening'; port: number; address: string; family: string}
79
+ | {type: 'transformer_load_started'}
80
+ | {type: 'transformer_load_done'}
81
+ | {type: 'transformer_load_failed'; error: Error}
82
+ | {type: 'watcher_health_check_result'; result: HealthCheckResult}
83
+ | {type: 'watcher_status'; status: WatcherStatus};
84
+ /**
85
+ * Code across the application takes a reporter as an option and calls the
86
+ * update whenever one of the ReportableEvent happens. Code does not directly
87
+ * write to the standard output, because a build would be:
88
+ *
89
+ * 1. ad-hoc, embedded into another tool, in which case we do not want to
90
+ * pollute that tool's own output. The tool is free to present the
91
+ * warnings/progress we generate any way they want, by specifing a custom
92
+ * reporter.
93
+ * 2. run as a background process from another tool, in which case we want
94
+ * to expose updates in a way that is easily machine-readable, for example
95
+ * a JSON-stream. We don't want to pollute it with textual messages.
96
+ *
97
+ * We centralize terminal reporting into a single place because we want the
98
+ * output to be robust and consistent. The most common reporter is
99
+ * TerminalReporter, that should be the only place in the application should
100
+ * access the `terminal` module (nor the `console`).
101
+ */
102
+ export type Reporter = {update(event: ReportableEvent): void};
103
+ /**
104
+ * A standard way to log a warning to the terminal. This should not be called
105
+ * from some arbitrary Metro logic, only from the reporters. Instead of
106
+ * calling this, add a new type of ReportableEvent instead, and implement a
107
+ * proper handler in the reporter(s).
108
+ */
109
+ export declare function logWarning(
110
+ terminal: Terminal,
111
+ format: string,
112
+ ...args: Array<unknown>
113
+ ): void;
114
+ /**
115
+ * Similar to `logWarning`, but for messages that require the user to act.
116
+ */
117
+ export declare function logError(
118
+ terminal: Terminal,
119
+ format: string,
120
+ ...args: Array<unknown>
121
+ ): void;
122
+ /**
123
+ * Similar to `logWarning`, but for informational messages.
124
+ */
125
+ export declare function logInfo(
126
+ terminal: Terminal,
127
+ format: string,
128
+ ...args: Array<unknown>
129
+ ): void;
130
+ /**
131
+ * A reporter that does nothing. Errors and warnings will be swallowed, that
132
+ * is generally not what you want.
133
+ */
134
+ export declare const nullReporter: {update(): void};
135
+ export declare type nullReporter = typeof nullReporter;
@@ -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
+ * @noformat
8
+ * @oncall react_native
9
+ * @generated SignedSource<<cf1e935fe7a5b1c8573b53b1c1921e70>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/lib/splitBundleOptions.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 {BundleOptions, SplitBundleOptions} from '../shared/types';
19
+ /**
20
+ * Splits a BundleOptions object into smaller, more manageable parts.
21
+ */
22
+ declare function splitBundleOptions(options: BundleOptions): SplitBundleOptions;
23
+ export default splitBundleOptions;
@@ -0,0 +1,42 @@
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<<dfdfdf9ddb80994cc031e3767a87b56f>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/lib/transformHelpers.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 Bundler from '../Bundler';
19
+ import type {TransformFn, default as DeltaBundler} from '../DeltaBundler';
20
+ import type {
21
+ BundlerResolution,
22
+ TransformInputOptions,
23
+ TransformResultDependency,
24
+ } from '../DeltaBundler/types';
25
+ import type {ResolverInputOptions} from '../shared/types';
26
+ import type {ConfigT} from 'metro-config';
27
+
28
+ export declare function getTransformFn(
29
+ entryFiles: ReadonlyArray<string>,
30
+ bundler: Bundler,
31
+ deltaBundler: DeltaBundler,
32
+ config: ConfigT,
33
+ options: TransformInputOptions,
34
+ resolverOptions: ResolverInputOptions,
35
+ ): Promise<TransformFn>;
36
+ export declare function getResolveDependencyFn(
37
+ bundler: Bundler,
38
+ platform: null | undefined | string,
39
+ resolverOptions: ResolverInputOptions,
40
+ ): Promise<
41
+ (from: string, dependency: TransformResultDependency) => BundlerResolution
42
+ >;
@@ -0,0 +1,133 @@
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<<d5224d8913b7e0c52ac84b215b356422>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/node-haste/DependencyGraph/ModuleResolution.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
+ BundlerResolution,
20
+ TransformResultDependency,
21
+ } from '../../DeltaBundler/types';
22
+ import type {Reporter} from '../../lib/reporting';
23
+ import type {ResolverInputOptions} from '../../shared/types';
24
+ import type {
25
+ CustomResolver,
26
+ DoesFileExist,
27
+ FileCandidates,
28
+ FileSystemLookup,
29
+ Resolution,
30
+ ResolveAsset,
31
+ } from 'metro-resolver';
32
+ import type {PackageForModule, PackageJson} from 'metro-resolver/private/types';
33
+
34
+ export type DirExistsFn = (filePath: string) => boolean;
35
+ export type Packageish = {path: string; read(): PackageJson};
36
+ export type Moduleish = {readonly path: string};
37
+ export type PackageishCache<TPackage> = {
38
+ getPackage(
39
+ name: string,
40
+ platform?: string,
41
+ supportsNativePlatform?: boolean,
42
+ ): TPackage;
43
+ getPackageOf(
44
+ absolutePath: string,
45
+ ): null | undefined | {pkg: TPackage; packageRelativePath: string};
46
+ };
47
+ type Options<TPackage> = Readonly<{
48
+ assetExts: ReadonlySet<string>;
49
+ dirExists: DirExistsFn;
50
+ disableHierarchicalLookup: boolean;
51
+ doesFileExist: DoesFileExist;
52
+ emptyModulePath: string;
53
+ extraNodeModules: null | undefined | object;
54
+ fileSystemLookup: FileSystemLookup;
55
+ getHasteModulePath: (
56
+ name: string,
57
+ platform: null | undefined | string,
58
+ ) => null | undefined | string;
59
+ getHastePackagePath: (
60
+ name: string,
61
+ platform: null | undefined | string,
62
+ ) => null | undefined | string;
63
+ mainFields: ReadonlyArray<string>;
64
+ packageCache: PackageishCache<TPackage>;
65
+ nodeModulesPaths: ReadonlyArray<string>;
66
+ preferNativePlatform: boolean;
67
+ projectRoot: string;
68
+ reporter: Reporter;
69
+ resolveAsset: ResolveAsset;
70
+ resolveRequest: null | undefined | CustomResolver;
71
+ sourceExts: ReadonlyArray<string>;
72
+ unstable_conditionNames: ReadonlyArray<string>;
73
+ unstable_conditionsByPlatform: Readonly<{
74
+ [platform: string]: ReadonlyArray<string>;
75
+ }>;
76
+ unstable_enablePackageExports: boolean;
77
+ unstable_incrementalResolution: boolean;
78
+ }>;
79
+ export declare class ModuleResolver<TPackage extends Packageish> {
80
+ _options: Options<TPackage>;
81
+ _projectRootFakeModulePath: string;
82
+ _cachedEmptyModule: null | undefined | BundlerResolution;
83
+ constructor(options: Options<TPackage>);
84
+ _getEmptyModule(): BundlerResolution;
85
+ resolveDependency(
86
+ originModulePath: string,
87
+ dependency: TransformResultDependency,
88
+ allowHaste: boolean,
89
+ platform: string | null,
90
+ resolverOptions: ResolverInputOptions,
91
+ ): BundlerResolution;
92
+ _getPackage: (packageJsonPath: string) => null | undefined | PackageJson;
93
+ _getPackageForModule: (
94
+ absolutePath: string,
95
+ ) => null | undefined | PackageForModule;
96
+ /**
97
+ * TODO: Return Resolution instead of coercing to BundlerResolution here
98
+ */
99
+ _getFileResolvedModule(resolution: Resolution): BundlerResolution;
100
+ _logWarning: (message: string) => void;
101
+ _removeRoot(candidates: FileCandidates): FileCandidates;
102
+ }
103
+ export declare class UnableToResolveError extends Error {
104
+ /**
105
+ * File path of the module that tried to require a module, ex. `/js/foo.js`.
106
+ */
107
+ originModulePath: string;
108
+ /**
109
+ * The name of the module that was required, no necessarily a path,
110
+ * ex. `./bar`, or `invariant`.
111
+ */
112
+ targetModuleName: string;
113
+ /**
114
+ * Original error that causes this error
115
+ */
116
+ cause: null | undefined | Error;
117
+ /**
118
+ * Fixed type field in common with other Metro build errors.
119
+ */
120
+ readonly type: 'UnableToResolveError';
121
+ constructor(
122
+ originModulePath: string,
123
+ targetModuleName: string,
124
+ message: string,
125
+ options?: Readonly<{
126
+ dependency?: null | undefined | TransformResultDependency;
127
+ cause?: Error;
128
+ }>,
129
+ );
130
+ buildCodeFrameMessage(
131
+ dependency: null | undefined | TransformResultDependency,
132
+ ): null | undefined | string;
133
+ }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @noformat
8
+ * @oncall react_native
9
+ * @generated SignedSource<<c008adad2ea747972e2f301a6375b447>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/node-haste/DependencyGraph/createFileMap.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 {ConfigT} from 'metro-config';
19
+ import type {HasteMap} from 'metro-file-map';
20
+
21
+ import MetroFileMap, {DependencyPlugin} from 'metro-file-map';
22
+
23
+ declare function createFileMap(
24
+ config: ConfigT,
25
+ options?: Readonly<{
26
+ extractDependencies?: boolean;
27
+ watch?: boolean;
28
+ throwOnModuleCollision?: boolean;
29
+ cacheFilePrefix?: string;
30
+ }>,
31
+ ): {
32
+ fileMap: MetroFileMap;
33
+ hasteMap: HasteMap;
34
+ dependencyPlugin: null | undefined | DependencyPlugin;
35
+ };
36
+ export default createFileMap;
@@ -0,0 +1,93 @@
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<<eb945b3566e9ed370894adaada197736>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/node-haste/DependencyGraph.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
+ BundlerResolution,
20
+ TransformResultDependency,
21
+ } from '../DeltaBundler/types';
22
+ import type {ResolverInputOptions} from '../shared/types';
23
+ import type Package from './Package';
24
+ import type {ConfigT} from 'metro-config';
25
+ import type {
26
+ ChangeEvent,
27
+ FileSystem,
28
+ HasteMap,
29
+ HealthCheckResult,
30
+ WatcherStatus,
31
+ default as MetroFileMap,
32
+ } from 'metro-file-map';
33
+
34
+ import {ModuleResolver} from './DependencyGraph/ModuleResolution';
35
+ import {PackageCache} from './PackageCache';
36
+ import EventEmitter from 'events';
37
+
38
+ declare class DependencyGraph extends EventEmitter {
39
+ _config: ConfigT;
40
+ _haste: MetroFileMap;
41
+ _fileSystem: FileSystem;
42
+ _hasteMap: HasteMap;
43
+ _moduleResolver: ModuleResolver<Package>;
44
+ _resolutionCache: Map<
45
+ string | symbol,
46
+ Map<
47
+ string | symbol,
48
+ Map<string | symbol, Map<string | symbol, BundlerResolution>>
49
+ >
50
+ >;
51
+ _initializedPromise: Promise<void>;
52
+ constructor(
53
+ config: ConfigT,
54
+ options?: {
55
+ readonly hasReducedPerformance?: boolean;
56
+ readonly watch?: boolean;
57
+ },
58
+ );
59
+ _onWatcherHealthCheck(result: HealthCheckResult): void;
60
+ _onWatcherStatus(status: WatcherStatus): void;
61
+ ready(): Promise<void>;
62
+ _onHasteChange($$PARAM_0$$: ChangeEvent): void;
63
+ _createModuleResolver(): void;
64
+ _getClosestPackage(
65
+ absoluteModulePath: string,
66
+ ): null | undefined | {packageJsonPath: string; packageRelativePath: string};
67
+ _createPackageCache(): PackageCache;
68
+ getAllFiles(): Array<string>;
69
+ /**
70
+ * Used when watcher.unstable_lazySha1 is true
71
+ */
72
+ getOrComputeSha1(
73
+ mixedPath: string,
74
+ ): Promise<{content?: Buffer; sha1: string}>;
75
+ getWatcher(): EventEmitter;
76
+ end(): void;
77
+ /** Given a search context, return a list of file paths matching the query. */
78
+ matchFilesWithContext(
79
+ from: string,
80
+ context: Readonly<{recursive: boolean; filter: RegExp}>,
81
+ ): Iterable<string>;
82
+ resolveDependency(
83
+ originModulePath: string,
84
+ dependency: TransformResultDependency,
85
+ platform: string | null,
86
+ resolverOptions: ResolverInputOptions,
87
+ $$PARAM_4$$?: {assumeFlatNodeModules: boolean},
88
+ ): BundlerResolution;
89
+ doesFileExist: (filePath: string) => boolean;
90
+ getHasteName(filePath: string): string;
91
+ getDependencies(filePath: string): Array<string>;
92
+ }
93
+ export default DependencyGraph;
@@ -0,0 +1,28 @@
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<<17776d35467f02c7e07dcde4be309545>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/node-haste/Package.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 {PackageJson} from 'metro-resolver/private/types';
19
+
20
+ declare class Package {
21
+ path: string;
22
+ _root: string;
23
+ _content: null | undefined | PackageJson;
24
+ constructor($$PARAM_0$$: {file: string});
25
+ invalidate(): void;
26
+ read(): PackageJson;
27
+ }
28
+ export default Package;
@@ -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
+ * @noformat
8
+ * @oncall react_native
9
+ * @generated SignedSource<<eaea6d7e01d54353f700cdadd60c4bf2>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/node-haste/PackageCache.js
13
+ * To regenerate, run:
14
+ * js1 build metro-ts-defs (internal) OR
15
+ * yarn run build-ts-defs (OSS)
16
+ */
17
+
18
+ import Package from './Package';
19
+
20
+ type GetClosestPackageFn = (
21
+ absoluteFilePath: string,
22
+ ) => null | undefined | {packageJsonPath: string; packageRelativePath: string};
23
+ export declare class PackageCache {
24
+ _getClosestPackage: GetClosestPackageFn;
25
+ _packageCache: {[filePath: string]: Package};
26
+ _packagePathAndSubpathByModulePath: {
27
+ [filePath: string]:
28
+ | null
29
+ | undefined
30
+ | {packageJsonPath: string; packageRelativePath: string};
31
+ };
32
+ _modulePathsByPackagePath: {
33
+ [filePath: string]: Set<string>;
34
+ };
35
+ constructor(options: {getClosestPackage: GetClosestPackageFn});
36
+ getPackage(filePath: string): Package;
37
+ getPackageOf(
38
+ absoluteModulePath: string,
39
+ ): null | undefined | {pkg: Package; packageRelativePath: string};
40
+ invalidate(filePath: string): void;
41
+ }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @noformat
8
+ * @oncall react_native
9
+ * @generated SignedSource<<31b3384bffa191e4c3c9916d93df8571>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/node-haste/lib/AssetPaths.js
13
+ * To regenerate, run:
14
+ * js1 build metro-ts-defs (internal) OR
15
+ * yarn run build-ts-defs (OSS)
16
+ */
17
+
18
+ export type AssetPath = {
19
+ assetName: string;
20
+ name: string;
21
+ platform: null | undefined | string;
22
+ resolution: number;
23
+ type: string;
24
+ };
25
+ /**
26
+ * Return `null` if the `filePath` doesn't have a valid extension, required
27
+ * to describe the type of an asset.
28
+ */
29
+ export declare function tryParse(
30
+ filePath: string,
31
+ platforms: ReadonlySet<string>,
32
+ ): null | undefined | AssetPath;
33
+ export declare function parse(
34
+ filePath: string,
35
+ platforms: ReadonlySet<string>,
36
+ ): AssetPath;
@@ -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<<61c16b5ef31517dc44347558a4dd431a>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/node-haste/lib/parsePlatformFilePath.js
13
+ * To regenerate, run:
14
+ * js1 build metro-ts-defs (internal) OR
15
+ * yarn run build-ts-defs (OSS)
16
+ */
17
+
18
+ type PlatformFilePathParts = {
19
+ dirPath: string;
20
+ baseName: string;
21
+ platform: null | undefined | string;
22
+ extension: null | undefined | string;
23
+ };
24
+ /**
25
+ * Extract the components of a file path that can have a platform specifier: Ex.
26
+ * `index.ios.js` is specific to the `ios` platform and has the extension `js`.
27
+ */
28
+ declare function parsePlatformFilePath(
29
+ filePath: string,
30
+ platforms: ReadonlySet<string>,
31
+ ): PlatformFilePathParts;
32
+ export default parsePlatformFilePath;
@@ -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<<02d7f6eec9c93d02612c9b2fdef18cef>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/shared/output/RamBundle/as-assets.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 {RamBundleInfo} from '../../../DeltaBundler/Serializers/getRamBundleInfo';
19
+ import type {OutputOptions} from '../../types';
20
+ /**
21
+ * Saves all JS modules of an app as single files
22
+ * The startup code (prelude, polyfills etc.) are written to the file
23
+ * designated by the `bundleOuput` option.
24
+ * All other modules go into a 'js-modules' folder that in the same parent
25
+ * directory as the startup file.
26
+ */
27
+ declare function saveAsAssets(
28
+ bundle: RamBundleInfo,
29
+ options: OutputOptions,
30
+ log: (...args: Array<string>) => void,
31
+ ): Promise<unknown>;
32
+ export default saveAsAssets;
@@ -0,0 +1,45 @@
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<<cf05d2127a356bae7e3789c2fefa25d3>>
10
+ *
11
+ * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js
12
+ * Original file: packages/metro/src/shared/output/RamBundle/as-indexed-file.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 {RamBundleInfo} from '../../../DeltaBundler/Serializers/getRamBundleInfo';
19
+ import type {
20
+ ModuleGroups,
21
+ ModuleTransportLike,
22
+ OutputOptions,
23
+ } from '../../types';
24
+ /**
25
+ * Saves all JS modules of an app as a single file, separated with null bytes.
26
+ * The file begins with an offset table that contains module ids and their
27
+ * lengths/offsets.
28
+ * The module id for the startup code (prelude, polyfills etc.) is the
29
+ * empty string.
30
+ */
31
+ export declare function save(
32
+ bundle: RamBundleInfo,
33
+ options: OutputOptions,
34
+ log: (...args: Array<string>) => void,
35
+ ): Promise<unknown>;
36
+ export declare function buildTableAndContents(
37
+ startupCode: string,
38
+ modules: ReadonlyArray<ModuleTransportLike>,
39
+ moduleGroups: ModuleGroups,
40
+ encoding?: 'utf8' | 'utf16le' | 'ascii',
41
+ ): Array<Buffer>;
42
+ export declare function createModuleGroups(
43
+ groups: Map<number, Set<number>>,
44
+ modules: ReadonlyArray<ModuleTransportLike>,
45
+ ): ModuleGroups;