metro 0.83.4 → 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.
Files changed (161) hide show
  1. package/package.json +17 -15
  2. package/src/Assets.d.ts +83 -0
  3. package/src/Assets.js +2 -9
  4. package/src/Bundler/util.d.ts +27 -0
  5. package/src/Bundler/util.js +2 -9
  6. package/src/Bundler.d.ts +38 -0
  7. package/src/Bundler.js +1 -5
  8. package/src/DeltaBundler/DeltaCalculator.d.ts +71 -0
  9. package/src/DeltaBundler/DeltaCalculator.js +1 -5
  10. package/src/DeltaBundler/Graph.d.ts +167 -0
  11. package/src/DeltaBundler/Graph.js +1 -5
  12. package/src/DeltaBundler/Serializers/baseJSBundle.d.ts +20 -0
  13. package/src/DeltaBundler/Serializers/baseJSBundle.js +1 -5
  14. package/src/DeltaBundler/Serializers/getAllFiles.d.ts +22 -0
  15. package/src/DeltaBundler/Serializers/getAssets.d.ts +25 -0
  16. package/src/DeltaBundler/Serializers/getAssets.js +1 -5
  17. package/src/DeltaBundler/Serializers/getExplodedSourceMap.d.ts +26 -0
  18. package/src/DeltaBundler/Serializers/getRamBundleInfo.d.ts +48 -0
  19. package/src/DeltaBundler/Serializers/getRamBundleInfo.js +1 -5
  20. package/src/DeltaBundler/Serializers/helpers/getInlineSourceMappingURL.d.ts +12 -0
  21. package/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.d.ts +33 -0
  22. package/src/DeltaBundler/Serializers/helpers/getTransitiveDependencies.d.ts +17 -0
  23. package/src/DeltaBundler/Serializers/helpers/js.d.ts +30 -0
  24. package/src/DeltaBundler/Serializers/helpers/js.js +2 -9
  25. package/src/DeltaBundler/Serializers/helpers/processModules.d.ts +25 -0
  26. package/src/DeltaBundler/Serializers/hmrJSBundle.d.ts +30 -0
  27. package/src/DeltaBundler/Serializers/hmrJSBundle.js +2 -9
  28. package/src/DeltaBundler/Serializers/sourceMapGenerator.d.ts +29 -0
  29. package/src/DeltaBundler/Serializers/sourceMapGenerator.js +1 -5
  30. package/src/DeltaBundler/Serializers/sourceMapObject.d.ts +23 -0
  31. package/src/DeltaBundler/Serializers/sourceMapString.d.ts +22 -0
  32. package/src/DeltaBundler/Transformer.d.ts +38 -0
  33. package/src/DeltaBundler/Transformer.js +1 -5
  34. package/src/DeltaBundler/Worker.d.ts +37 -0
  35. package/src/DeltaBundler/Worker.flow.js +1 -5
  36. package/src/DeltaBundler/WorkerFarm.d.ts +70 -0
  37. package/src/DeltaBundler/buildSubgraph.d.ts +30 -0
  38. package/src/DeltaBundler/buildSubgraph.js +1 -5
  39. package/src/DeltaBundler/getTransformCacheKey.d.ts +18 -0
  40. package/src/DeltaBundler/getTransformCacheKey.js +1 -5
  41. package/src/DeltaBundler/mergeDeltas.d.ts +17 -0
  42. package/src/DeltaBundler/types.d.ts +163 -0
  43. package/src/DeltaBundler/types.js +1 -5
  44. package/src/DeltaBundler.d.ts +60 -0
  45. package/src/DeltaBundler.js +1 -5
  46. package/src/HmrServer.d.ts +79 -0
  47. package/src/HmrServer.js +2 -9
  48. package/src/IncrementalBundler/GraphNotFoundError.d.ts +17 -0
  49. package/src/IncrementalBundler/ResourceNotFoundError.d.ts +15 -0
  50. package/src/IncrementalBundler/RevisionNotFoundError.d.ts +17 -0
  51. package/src/IncrementalBundler.d.ts +96 -0
  52. package/src/IncrementalBundler.js +2 -9
  53. package/src/ModuleGraph/worker/JsFileWrapping.d.ts +29 -0
  54. package/src/ModuleGraph/worker/JsFileWrapping.js +2 -9
  55. package/src/ModuleGraph/worker/collectDependencies.d.ts +131 -0
  56. package/src/ModuleGraph/worker/collectDependencies.js +2 -9
  57. package/src/ModuleGraph/worker/generateImportNames.d.ts +19 -0
  58. package/src/ModuleGraph/worker/generateImportNames.js +1 -5
  59. package/src/ModuleGraph/worker/importLocationsPlugin.d.ts +26 -0
  60. package/src/Server/MultipartResponse.d.ts +30 -0
  61. package/src/Server/MultipartResponse.js +1 -5
  62. package/src/Server/symbolicate.d.ts +31 -0
  63. package/src/Server.d.ts +271 -0
  64. package/src/Server.js +47 -15
  65. package/src/Server.js.flow +57 -10
  66. package/src/cli/parseKeyValueParamArray.d.ts +14 -0
  67. package/src/cli-utils.d.ts +19 -0
  68. package/src/cli-utils.js +1 -5
  69. package/src/commands/build.d.ts +16 -0
  70. package/src/commands/build.js +1 -5
  71. package/src/commands/dependencies.d.ts +16 -0
  72. package/src/commands/dependencies.js +1 -5
  73. package/src/commands/serve.d.ts +16 -0
  74. package/src/index.d.ts +180 -0
  75. package/src/index.flow.js +26 -19
  76. package/src/index.flow.js.flow +25 -10
  77. package/src/integration_tests/basic_bundle/build-errors/cannot-resolve-import.js +1 -5
  78. package/src/integration_tests/basic_bundle/build-errors/inline-requires-cannot-resolve-import.js +1 -5
  79. package/src/integration_tests/basic_bundle/import-export/index.js +2 -9
  80. package/src/integration_tests/execBundle.js +1 -5
  81. package/src/lib/BatchProcessor.d.ts +54 -0
  82. package/src/lib/BatchProcessor.js +1 -5
  83. package/src/lib/CountingSet.d.ts +48 -0
  84. package/src/lib/JsonReporter.d.ts +37 -0
  85. package/src/lib/RamBundleParser.d.ts +29 -0
  86. package/src/lib/RamBundleParser.js +1 -5
  87. package/src/lib/TerminalReporter.d.ts +118 -0
  88. package/src/lib/TerminalReporter.js +8 -16
  89. package/src/lib/TerminalReporter.js.flow +6 -15
  90. package/src/lib/bundleProgressUtils.d.ts +26 -0
  91. package/src/lib/bundleProgressUtils.js +19 -0
  92. package/src/lib/bundleProgressUtils.js.flow +35 -0
  93. package/src/lib/bundleToString.d.ts +19 -0
  94. package/src/lib/contextModule.d.ts +33 -0
  95. package/src/lib/contextModule.js +1 -5
  96. package/src/lib/contextModuleTemplates.d.ts +25 -0
  97. package/src/lib/contextModuleTemplates.js +1 -4
  98. package/src/lib/countLines.d.ts +12 -0
  99. package/src/lib/createWebsocketServer.d.ts +43 -0
  100. package/src/lib/createWebsocketServer.js +1 -5
  101. package/src/lib/debounceAsyncQueue.d.ts +15 -0
  102. package/src/lib/formatBundlingError.d.ts +23 -0
  103. package/src/lib/formatBundlingError.js +1 -5
  104. package/src/lib/getAppendScripts.d.ts +31 -0
  105. package/src/lib/getAppendScripts.js +1 -5
  106. package/src/lib/getGraphId.d.ts +25 -0
  107. package/src/lib/getGraphId.js +1 -5
  108. package/src/lib/getPreludeCode.d.ts +18 -0
  109. package/src/lib/getPrependedScripts.d.ts +24 -0
  110. package/src/lib/getPrependedScripts.js +2 -9
  111. package/src/lib/isResolvedDependency.d.ts +15 -0
  112. package/src/lib/logToConsole.d.ts +19 -0
  113. package/src/lib/logToConsole.js +1 -5
  114. package/src/lib/parseBundleOptionsFromBundleRequestUrl.d.ts +17 -0
  115. package/src/lib/parseBundleOptionsFromBundleRequestUrl.js +2 -9
  116. package/src/lib/parseCustomResolverOptions.d.ts +16 -0
  117. package/src/lib/parseCustomTransformOptions.d.ts +16 -0
  118. package/src/lib/parseJsonBody.d.ts +27 -0
  119. package/src/lib/pathUtils.d.ts +14 -0
  120. package/src/lib/pathUtils.js +1 -4
  121. package/src/lib/relativizeSourceMap.d.ts +17 -0
  122. package/src/lib/relativizeSourceMap.js +1 -5
  123. package/src/lib/reporting.d.ts +128 -0
  124. package/src/lib/reporting.js +1 -5
  125. package/src/lib/splitBundleOptions.d.ts +16 -0
  126. package/src/lib/transformHelpers.d.ts +35 -0
  127. package/src/lib/transformHelpers.js +1 -5
  128. package/src/node-haste/DependencyGraph/ModuleResolution.d.ts +126 -0
  129. package/src/node-haste/DependencyGraph/ModuleResolution.js +2 -9
  130. package/src/node-haste/DependencyGraph/createFileMap.d.ts +29 -0
  131. package/src/node-haste/DependencyGraph/createFileMap.js +2 -9
  132. package/src/node-haste/DependencyGraph.d.ts +86 -0
  133. package/src/node-haste/DependencyGraph.js +1 -5
  134. package/src/node-haste/Package.d.ts +21 -0
  135. package/src/node-haste/Package.js +1 -5
  136. package/src/node-haste/PackageCache.d.ts +34 -0
  137. package/src/node-haste/PackageCache.js +1 -5
  138. package/src/node-haste/lib/AssetPaths.d.ts +29 -0
  139. package/src/node-haste/lib/AssetPaths.js +1 -5
  140. package/src/node-haste/lib/parsePlatformFilePath.d.ts +25 -0
  141. package/src/node-haste/lib/parsePlatformFilePath.js +1 -5
  142. package/src/shared/output/RamBundle/as-assets.d.ts +25 -0
  143. package/src/shared/output/RamBundle/as-assets.js +1 -5
  144. package/src/shared/output/RamBundle/as-indexed-file.d.ts +38 -0
  145. package/src/shared/output/RamBundle/as-indexed-file.js +1 -5
  146. package/src/shared/output/RamBundle/buildSourcemapWithMetadata.d.ts +23 -0
  147. package/src/shared/output/RamBundle/magic-number.d.ts +14 -0
  148. package/src/shared/output/RamBundle/util.d.ts +41 -0
  149. package/src/shared/output/RamBundle/util.js +1 -5
  150. package/src/shared/output/RamBundle/write-sourcemap.d.ts +16 -0
  151. package/src/shared/output/RamBundle/write-sourcemap.js +1 -5
  152. package/src/shared/output/RamBundle.d.ts +26 -0
  153. package/src/shared/output/RamBundle.js +1 -5
  154. package/src/shared/output/bundle.d.ts +27 -0
  155. package/src/shared/output/bundle.flow.js +1 -5
  156. package/src/shared/output/meta.d.ts +15 -0
  157. package/src/shared/output/meta.js +1 -5
  158. package/src/shared/output/unbundle.d.ts +11 -0
  159. package/src/shared/output/writeFile.d.ts +16 -0
  160. package/src/shared/output/writeFile.js +1 -5
  161. package/src/shared/types.d.ts +145 -0
@@ -0,0 +1,163 @@
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 {RequireContext} from '../lib/contextModule';
12
+ import type {RequireContextParams} from '../ModuleGraph/worker/collectDependencies';
13
+ import type {ReadonlySourceLocation} from '../shared/types';
14
+ import type {Graph} from './Graph';
15
+ import type {JsTransformOptions} from 'metro-transform-worker';
16
+
17
+ import CountingSet from '../lib/CountingSet';
18
+
19
+ export type MixedOutput = {readonly data: unknown; readonly type: string};
20
+ export type AsyncDependencyType = 'async' | 'maybeSync' | 'prefetch' | 'weak';
21
+ export type TransformResultDependency = Readonly<{
22
+ /**
23
+ * The literal name provided to a require or import call. For example 'foo' in
24
+ * case of `require('foo')`.
25
+ */
26
+ name: string;
27
+ /**
28
+ * Extra data returned by the dependency extractor.
29
+ */
30
+ data: Readonly<{
31
+ /**
32
+ * A locally unique key for this dependency within the current module.
33
+ */
34
+ key: string;
35
+ /**
36
+ * If not null, this dependency is due to a dynamic `import()` or `__prefetchImport()` call.
37
+ */
38
+ asyncType: AsyncDependencyType | null;
39
+ /**
40
+ * True if the dependency is declared with a static "import x from 'y'" or
41
+ * an import() call.
42
+ */
43
+ isESMImport: boolean;
44
+ /**
45
+ * The dependency is enclosed in a try/catch block.
46
+ */
47
+ isOptional?: boolean;
48
+ locs: ReadonlyArray<ReadonlySourceLocation>;
49
+ /** Context for requiring a collection of modules. */
50
+ contextParams?: RequireContextParams;
51
+ }>;
52
+ }>;
53
+ export type ResolvedDependency = Readonly<{
54
+ absolutePath: string;
55
+ data: TransformResultDependency;
56
+ }>;
57
+ export type Dependency =
58
+ | ResolvedDependency
59
+ | Readonly<{data: TransformResultDependency}>;
60
+ export type Module<T = MixedOutput> = Readonly<{
61
+ dependencies: Map<string, Dependency>;
62
+ inverseDependencies: CountingSet<string>;
63
+ output: ReadonlyArray<T>;
64
+ path: string;
65
+ getSource: () => Buffer;
66
+ unstable_transformResultKey?: null | undefined | string;
67
+ }>;
68
+ export type ModuleData<T = MixedOutput> = Readonly<{
69
+ dependencies: ReadonlyMap<string, Dependency>;
70
+ resolvedContexts: ReadonlyMap<string, RequireContext>;
71
+ output: ReadonlyArray<T>;
72
+ getSource: () => Buffer;
73
+ unstable_transformResultKey?: null | undefined | string;
74
+ }>;
75
+ export type Dependencies<T = MixedOutput> = Map<string, Module<T>>;
76
+ export type ReadOnlyDependencies<T = MixedOutput> = ReadonlyMap<
77
+ string,
78
+ Module<T>
79
+ >;
80
+ export type TransformInputOptions = Omit<
81
+ JsTransformOptions,
82
+ 'inlinePlatform' | 'inlineRequires'
83
+ >;
84
+ export type GraphInputOptions = Readonly<{
85
+ entryPoints: ReadonlySet<string>;
86
+ transformOptions: TransformInputOptions;
87
+ }>;
88
+ export interface ReadOnlyGraph<T = MixedOutput> {
89
+ readonly entryPoints: ReadonlySet<string>;
90
+ readonly transformOptions: Readonly<TransformInputOptions>;
91
+ readonly dependencies: ReadOnlyDependencies<T>;
92
+ }
93
+ export type {Graph};
94
+ export type TransformResult<T = MixedOutput> = Readonly<{
95
+ dependencies: ReadonlyArray<TransformResultDependency>;
96
+ output: ReadonlyArray<T>;
97
+ unstable_transformResultKey?: null | undefined | string;
98
+ }>;
99
+ export type TransformResultWithSource<T = MixedOutput> = Readonly<
100
+ Omit<TransformResult<T>, keyof {getSource: () => Buffer}> & {
101
+ getSource: () => Buffer;
102
+ }
103
+ >;
104
+ export type TransformFn<T = MixedOutput> = (
105
+ $$PARAM_0$$: string,
106
+ $$PARAM_1$$: null | undefined | RequireContext,
107
+ ) => Promise<TransformResultWithSource<T>>;
108
+ export type ResolveFn = (
109
+ from: string,
110
+ dependency: TransformResultDependency,
111
+ ) => BundlerResolution;
112
+ export type AllowOptionalDependenciesWithOptions = {
113
+ readonly exclude: Array<string>;
114
+ };
115
+ export type AllowOptionalDependencies =
116
+ | boolean
117
+ | AllowOptionalDependenciesWithOptions;
118
+ export type BundlerResolution = Readonly<{
119
+ type: 'sourceFile';
120
+ filePath: string;
121
+ }>;
122
+ export type Options<T = MixedOutput> = Readonly<{
123
+ resolve: ResolveFn;
124
+ transform: TransformFn<T>;
125
+ transformOptions: TransformInputOptions;
126
+ onProgress:
127
+ | null
128
+ | undefined
129
+ | ((numProcessed: number, total: number) => unknown);
130
+ lazy: boolean;
131
+ unstable_allowRequireContext: boolean;
132
+ unstable_enablePackageExports: boolean;
133
+ unstable_incrementalResolution: boolean;
134
+ shallow: boolean;
135
+ }>;
136
+ export type DeltaResult<T = MixedOutput> = {
137
+ readonly added: Map<string, Module<T>>;
138
+ readonly modified: Map<string, Module<T>>;
139
+ readonly deleted: Set<string>;
140
+ readonly reset: boolean;
141
+ };
142
+ export type SerializerOptions = Readonly<{
143
+ asyncRequireModulePath: string;
144
+ createModuleId: ($$PARAM_0$$: string) => number;
145
+ dev: boolean;
146
+ getRunModuleStatement: (
147
+ moduleId: number | string,
148
+ globalPrefix: string,
149
+ ) => string;
150
+ globalPrefix: string;
151
+ includeAsyncPaths: boolean;
152
+ inlineSourceMap: null | undefined | boolean;
153
+ modulesOnly: boolean;
154
+ processModuleFilter: (module: Module) => boolean;
155
+ projectRoot: string;
156
+ runBeforeMainModule: ReadonlyArray<string>;
157
+ runModule: boolean;
158
+ serverRoot: string;
159
+ shouldAddToIgnoreList: ($$PARAM_0$$: Module) => boolean;
160
+ sourceMapUrl: null | undefined | string;
161
+ sourceUrl: null | undefined | string;
162
+ getSourceUrl: null | undefined | (($$PARAM_0$$: Module) => string);
163
+ }>;
@@ -2,9 +2,5 @@
2
2
 
3
3
  var _CountingSet = _interopRequireDefault(require("../lib/CountingSet"));
4
4
  function _interopRequireDefault(e) {
5
- return e && e.__esModule
6
- ? e
7
- : {
8
- default: e,
9
- };
5
+ return e && e.__esModule ? e : { default: e };
10
6
  }
@@ -0,0 +1,60 @@
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 {
12
+ DeltaResult,
13
+ Graph,
14
+ MixedOutput,
15
+ Options,
16
+ ReadOnlyGraph,
17
+ } from './DeltaBundler/types';
18
+ import type EventEmitter from 'events';
19
+
20
+ import DeltaCalculator from './DeltaBundler/DeltaCalculator';
21
+
22
+ export type {
23
+ DeltaResult,
24
+ Graph,
25
+ Dependencies,
26
+ MixedOutput,
27
+ Module,
28
+ ReadOnlyGraph,
29
+ TransformFn,
30
+ TransformResult,
31
+ TransformResultDependency,
32
+ TransformResultWithSource,
33
+ } from './DeltaBundler/types';
34
+ /**
35
+ * `DeltaBundler` uses the `DeltaTransformer` to build bundle deltas. This
36
+ * module handles all the transformer instances so it can support multiple
37
+ * concurrent clients requesting their own deltas. This is done through the
38
+ * `clientId` param (which maps a client to a specific delta transformer).
39
+ */
40
+ declare class DeltaBundler<T = MixedOutput> {
41
+ _changeEventSource: EventEmitter;
42
+ _deltaCalculators: Map<Graph<T>, DeltaCalculator<T>>;
43
+ constructor(changeEventSource: EventEmitter);
44
+ end(): void;
45
+ getDependencies(
46
+ entryPoints: ReadonlyArray<string>,
47
+ options: Options<T>,
48
+ ): Promise<ReadOnlyGraph<T>['dependencies']>;
49
+ buildGraph(
50
+ entryPoints: ReadonlyArray<string>,
51
+ options: Options<T>,
52
+ ): Promise<Graph<T>>;
53
+ getDelta(
54
+ graph: Graph<T>,
55
+ $$PARAM_1$$: {reset: boolean; shallow: boolean},
56
+ ): Promise<DeltaResult<T>>;
57
+ listen(graph: Graph<T>, callback: () => Promise<void>): () => void;
58
+ endGraph(graph: Graph<T>): void;
59
+ }
60
+ export default DeltaBundler;
@@ -8,11 +8,7 @@ var _DeltaCalculator = _interopRequireDefault(
8
8
  require("./DeltaBundler/DeltaCalculator"),
9
9
  );
10
10
  function _interopRequireDefault(e) {
11
- return e && e.__esModule
12
- ? e
13
- : {
14
- default: e,
15
- };
11
+ return e && e.__esModule ? e : { default: e };
16
12
  }
17
13
  class DeltaBundler {
18
14
  _deltaCalculators = new Map();
@@ -0,0 +1,79 @@
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
+ */
9
+
10
+ import type {
11
+ RevisionId,
12
+ default as IncrementalBundler,
13
+ } from './IncrementalBundler';
14
+ import type {GraphOptions} from './shared/types';
15
+ import type {ConfigT, RootPerfLogger} from 'metro-config';
16
+ import type {
17
+ HmrErrorMessage,
18
+ HmrUpdateMessage,
19
+ } from 'metro-runtime/src/modules/types';
20
+
21
+ export type Client = {
22
+ optedIntoHMR: boolean;
23
+ revisionIds: Array<RevisionId>;
24
+ readonly sendFn: ($$PARAM_0$$: string) => void;
25
+ };
26
+ type ClientGroup = {
27
+ readonly clients: Set<Client>;
28
+ clientUrl: URL;
29
+ revisionId: RevisionId;
30
+ readonly unlisten: () => void;
31
+ readonly graphOptions: GraphOptions;
32
+ };
33
+ /**
34
+ * The HmrServer (Hot Module Reloading) implements a lightweight interface
35
+ * to communicate easily to the logic in the React Native repository (which
36
+ * is the one that handles the Web Socket connections).
37
+ *
38
+ * This interface allows the HmrServer to hook its own logic to WS clients
39
+ * getting connected, disconnected or having errors (through the
40
+ * `onClientConnect`, `onClientDisconnect` and `onClientError` methods).
41
+ */
42
+ declare class HmrServer<TClient extends Client> {
43
+ _config: ConfigT;
44
+ _bundler: IncrementalBundler;
45
+ _createModuleId: (path: string) => number;
46
+ _clientGroups: Map<RevisionId, ClientGroup>;
47
+ constructor(
48
+ bundler: IncrementalBundler,
49
+ createModuleId: (path: string) => number,
50
+ config: ConfigT,
51
+ );
52
+ onClientConnect: (
53
+ requestUrl: string,
54
+ sendFn: (data: string) => void,
55
+ ) => Promise<Client>;
56
+ _registerEntryPoint(
57
+ client: Client,
58
+ originalRequestUrl: string,
59
+ sendFn: (data: string) => void,
60
+ ): Promise<void>;
61
+ onClientMessage: (
62
+ client: TClient,
63
+ message: string | Buffer | ArrayBuffer | Array<Buffer>,
64
+ sendFn: (data: string) => void,
65
+ ) => Promise<void>;
66
+ onClientError: (client: TClient, e: Error) => void;
67
+ onClientDisconnect: (client: TClient) => void;
68
+ _handleFileChange(
69
+ group: ClientGroup,
70
+ options: {isInitialUpdate: boolean},
71
+ changeEvent: null | undefined | {logger: null | undefined | RootPerfLogger},
72
+ ): Promise<void>;
73
+ _prepareMessage(
74
+ group: ClientGroup,
75
+ options: {isInitialUpdate: boolean},
76
+ changeEvent: null | undefined | {logger: null | undefined | RootPerfLogger},
77
+ ): Promise<HmrUpdateMessage | HmrErrorMessage>;
78
+ }
79
+ export default HmrServer;
package/src/HmrServer.js CHANGED
@@ -39,10 +39,7 @@ function _interopRequireWildcard(e, t) {
39
39
  if (!t && e && e.__esModule) return e;
40
40
  var o,
41
41
  i,
42
- f = {
43
- __proto__: null,
44
- default: e,
45
- };
42
+ f = { __proto__: null, default: e };
46
43
  if (null === e || ("object" != typeof e && "function" != typeof e))
47
44
  return f;
48
45
  if ((o = t ? n : r)) {
@@ -62,11 +59,7 @@ function _interopRequireWildcard(e, t) {
62
59
  })(e, t);
63
60
  }
64
61
  function _interopRequireDefault(e) {
65
- return e && e.__esModule
66
- ? e
67
- : {
68
- default: e,
69
- };
62
+ return e && e.__esModule ? e : { default: e };
70
63
  }
71
64
  const debug = require("debug")("Metro:HMR");
72
65
  const { createActionStartEntry, createActionEndEntry, log } = _metroCore.Logger;
@@ -0,0 +1,17 @@
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 {GraphId} from '../lib/getGraphId';
12
+
13
+ declare class GraphNotFoundError extends Error {
14
+ graphId: GraphId;
15
+ constructor(graphId: GraphId);
16
+ }
17
+ export default GraphNotFoundError;
@@ -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 class ResourceNotFoundError extends Error {
12
+ resourcePath: string;
13
+ constructor(resourcePath: string);
14
+ }
15
+ export default ResourceNotFoundError;
@@ -0,0 +1,17 @@
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 {RevisionId} from '../IncrementalBundler';
12
+
13
+ declare class RevisionNotFoundError extends Error {
14
+ revisionId: RevisionId;
15
+ constructor(revisionId: RevisionId);
16
+ }
17
+ export default RevisionNotFoundError;
@@ -0,0 +1,96 @@
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 {DeltaResult, Graph, Module} from './DeltaBundler';
12
+ import type {
13
+ Options as DeltaBundlerOptions,
14
+ ReadOnlyDependencies,
15
+ TransformInputOptions,
16
+ } from './DeltaBundler/types';
17
+ import type {GraphId} from './lib/getGraphId';
18
+ import type {ResolverInputOptions} from './shared/types';
19
+ import type {ConfigT} from 'metro-config';
20
+
21
+ import Bundler from './Bundler';
22
+ import DeltaBundler from './DeltaBundler';
23
+
24
+ export declare type RevisionId = string;
25
+ export type OutputGraph = Graph;
26
+ type OtherOptions = Readonly<{
27
+ onProgress: DeltaBundlerOptions['onProgress'];
28
+ shallow: boolean;
29
+ lazy: boolean;
30
+ }>;
31
+ export type GraphRevision = {
32
+ readonly id: RevisionId;
33
+ readonly date: Date;
34
+ readonly graphId: GraphId;
35
+ readonly graph: OutputGraph;
36
+ readonly prepend: ReadonlyArray<Module>;
37
+ };
38
+ export type IncrementalBundlerOptions = Readonly<{
39
+ hasReducedPerformance?: boolean;
40
+ watch?: boolean;
41
+ }>;
42
+ declare class IncrementalBundler {
43
+ _config: ConfigT;
44
+ _bundler: Bundler;
45
+ _deltaBundler: DeltaBundler;
46
+ _revisionsById: Map<RevisionId, Promise<GraphRevision>>;
47
+ _revisionsByGraphId: Map<GraphId, Promise<GraphRevision>>;
48
+ static revisionIdFromString: (str: string) => RevisionId;
49
+ constructor(config: ConfigT, options?: IncrementalBundlerOptions);
50
+ end(): Promise<void>;
51
+ getBundler(): Bundler;
52
+ getDeltaBundler(): DeltaBundler;
53
+ getRevision(
54
+ revisionId: RevisionId,
55
+ ): null | undefined | Promise<GraphRevision>;
56
+ getRevisionByGraphId(
57
+ graphId: GraphId,
58
+ ): null | undefined | Promise<GraphRevision>;
59
+ buildGraphForEntries(
60
+ entryFiles: ReadonlyArray<string>,
61
+ transformOptions: TransformInputOptions,
62
+ resolverOptions: ResolverInputOptions,
63
+ otherOptions?: OtherOptions,
64
+ ): Promise<OutputGraph>;
65
+ getDependencies(
66
+ entryFiles: ReadonlyArray<string>,
67
+ transformOptions: TransformInputOptions,
68
+ resolverOptions: ResolverInputOptions,
69
+ otherOptions?: OtherOptions,
70
+ ): Promise<ReadOnlyDependencies>;
71
+ buildGraph(
72
+ entryFile: string,
73
+ transformOptions: TransformInputOptions,
74
+ resolverOptions: ResolverInputOptions,
75
+ otherOptions?: OtherOptions,
76
+ ): Promise<{
77
+ readonly graph: OutputGraph;
78
+ readonly prepend: ReadonlyArray<Module>;
79
+ }>;
80
+ initializeGraph(
81
+ entryFile: string,
82
+ transformOptions: TransformInputOptions,
83
+ resolverOptions: ResolverInputOptions,
84
+ otherOptions?: OtherOptions,
85
+ ): Promise<{delta: DeltaResult; revision: GraphRevision}>;
86
+ updateGraph(
87
+ revision: GraphRevision,
88
+ reset: boolean,
89
+ ): Promise<{delta: DeltaResult; revision: GraphRevision}>;
90
+ endGraph(graphId: GraphId): Promise<void>;
91
+ _getAbsoluteEntryFiles(
92
+ entryFiles: ReadonlyArray<string>,
93
+ ): Promise<ReadonlyArray<string>>;
94
+ ready(): Promise<void>;
95
+ }
96
+ export default IncrementalBundler;
@@ -27,10 +27,7 @@ function _interopRequireWildcard(e, t) {
27
27
  if (!t && e && e.__esModule) return e;
28
28
  var o,
29
29
  i,
30
- f = {
31
- __proto__: null,
32
- default: e,
33
- };
30
+ f = { __proto__: null, default: e };
34
31
  if (null === e || ("object" != typeof e && "function" != typeof e))
35
32
  return f;
36
33
  if ((o = t ? n : r)) {
@@ -50,11 +47,7 @@ function _interopRequireWildcard(e, t) {
50
47
  })(e, t);
51
48
  }
52
49
  function _interopRequireDefault(e) {
53
- return e && e.__esModule
54
- ? e
55
- : {
56
- default: e,
57
- };
50
+ return e && e.__esModule ? e : { default: e };
58
51
  }
59
52
  function createRevisionId() {
60
53
  return _crypto.default.randomBytes(8).toString("hex");
@@ -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
+ * @format
8
+ */
9
+
10
+ import type {File as BabelNodeFile} from '@babel/types';
11
+
12
+ declare const WRAP_NAME: '$$_REQUIRE';
13
+ declare function wrapModule(
14
+ fileAst: BabelNodeFile,
15
+ importDefaultName: string,
16
+ importAllName: string,
17
+ dependencyMapName: string,
18
+ globalPrefix: string,
19
+ skipRequireRename: boolean,
20
+ $$PARAM_6$$?: Readonly<{unstable_useStaticHermesModuleFactory?: boolean}>,
21
+ ): {ast: BabelNodeFile; requireName: string};
22
+ declare function wrapPolyfill(fileAst: BabelNodeFile): BabelNodeFile;
23
+ declare function jsonToCommonJS(source: string): string;
24
+ declare function wrapJson(
25
+ source: string,
26
+ globalPrefix: string,
27
+ unstable_useStaticHermesModuleFactory?: boolean,
28
+ ): string;
29
+ export {WRAP_NAME, wrapJson, jsonToCommonJS, wrapModule, wrapPolyfill};
@@ -20,10 +20,7 @@ function _interopRequireWildcard(e, t) {
20
20
  if (!t && e && e.__esModule) return e;
21
21
  var o,
22
22
  i,
23
- f = {
24
- __proto__: null,
25
- default: e,
26
- };
23
+ f = { __proto__: null, default: e };
27
24
  if (null === e || ("object" != typeof e && "function" != typeof e))
28
25
  return f;
29
26
  if ((o = t ? n : r)) {
@@ -43,11 +40,7 @@ function _interopRequireWildcard(e, t) {
43
40
  })(e, t);
44
41
  }
45
42
  function _interopRequireDefault(e) {
46
- return e && e.__esModule
47
- ? e
48
- : {
49
- default: e,
50
- };
43
+ return e && e.__esModule ? e : { default: e };
51
44
  }
52
45
  const WRAP_NAME = (exports.WRAP_NAME = "$$_REQUIRE");
53
46
  const IIFE_PARAM = _template.default.expression(