metro-runtime 0.83.3 → 0.83.4
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "metro-runtime",
|
|
3
|
-
"version": "0.83.
|
|
3
|
+
"version": "0.83.4",
|
|
4
4
|
"description": "🚇 Module required for evaluating Metro bundles.",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./package.json": "./package.json",
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@babel/core": "^7.25.2",
|
|
31
|
-
"react": "19.
|
|
31
|
+
"react": "19.2.3",
|
|
32
32
|
"react-refresh": "^0.14.0",
|
|
33
|
-
"react-test-renderer": "19.
|
|
33
|
+
"react-test-renderer": "19.2.3"
|
|
34
34
|
},
|
|
35
35
|
"engines": {
|
|
36
36
|
"node": ">=20.19.4"
|
|
@@ -183,9 +183,9 @@ function mergeUpdates(base: HmrUpdate, next: HmrUpdate): HmrUpdate {
|
|
|
183
183
|
const result = {
|
|
184
184
|
isInitialUpdate: next.isInitialUpdate,
|
|
185
185
|
revisionId: next.revisionId,
|
|
186
|
-
added:
|
|
187
|
-
modified:
|
|
188
|
-
deleted:
|
|
186
|
+
added: [] as Array<HmrModule>,
|
|
187
|
+
modified: [] as Array<HmrModule>,
|
|
188
|
+
deleted: [] as Array<number>,
|
|
189
189
|
};
|
|
190
190
|
deletedIDs.forEach(id => {
|
|
191
191
|
result.deleted.push(id);
|
|
@@ -10,14 +10,14 @@
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
type MetroRequire = {
|
|
13
|
-
(number):
|
|
13
|
+
(number): unknown,
|
|
14
14
|
importAll: <T>(number) => T,
|
|
15
15
|
...
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
declare var require: MetroRequire;
|
|
19
19
|
|
|
20
|
-
type DependencyMapPaths =
|
|
20
|
+
type DependencyMapPaths = ?Readonly<{[moduleID: number | string]: unknown}>;
|
|
21
21
|
|
|
22
22
|
declare var __METRO_GLOBAL_PREFIX__: string;
|
|
23
23
|
|
|
@@ -25,7 +25,7 @@ function maybeLoadBundle(
|
|
|
25
25
|
moduleID: number,
|
|
26
26
|
paths: DependencyMapPaths,
|
|
27
27
|
): void | Promise<void> {
|
|
28
|
-
const loadBundle: (bundlePath:
|
|
28
|
+
const loadBundle: (bundlePath: unknown) => Promise<void> =
|
|
29
29
|
global[`${__METRO_GLOBAL_PREFIX__}__loadBundleAsync`];
|
|
30
30
|
|
|
31
31
|
if (loadBundle != null) {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* @oncall react_native
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
export type ModuleMap =
|
|
12
|
+
export type ModuleMap = ReadonlyArray<[number, string]>;
|
|
13
13
|
|
|
14
14
|
export type Bundle = {
|
|
15
15
|
+modules: ModuleMap,
|
|
@@ -20,17 +20,17 @@ export type Bundle = {
|
|
|
20
20
|
export type DeltaBundle = {
|
|
21
21
|
+added: ModuleMap,
|
|
22
22
|
+modified: ModuleMap,
|
|
23
|
-
+deleted:
|
|
23
|
+
+deleted: ReadonlyArray<number>,
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
export type BundleVariant =
|
|
27
|
-
| {
|
|
28
|
-
| {
|
|
27
|
+
| Readonly<{...Bundle, base: true, revisionId: string}>
|
|
28
|
+
| Readonly<{...DeltaBundle, base: false, revisionId: string}>;
|
|
29
29
|
|
|
30
30
|
export type BundleMetadata = {
|
|
31
31
|
+pre: number,
|
|
32
32
|
+post: number,
|
|
33
|
-
+modules:
|
|
33
|
+
+modules: ReadonlyArray<[number, number]>,
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
export type FormattedError = {
|
|
@@ -46,10 +46,10 @@ export type HmrModule = {
|
|
|
46
46
|
};
|
|
47
47
|
|
|
48
48
|
export type HmrUpdate = {
|
|
49
|
-
+added:
|
|
50
|
-
+deleted:
|
|
49
|
+
+added: ReadonlyArray<HmrModule>,
|
|
50
|
+
+deleted: ReadonlyArray<number>,
|
|
51
51
|
+isInitialUpdate: boolean,
|
|
52
|
-
+modified:
|
|
52
|
+
+modified: ReadonlyArray<HmrModule>,
|
|
53
53
|
+revisionId: string,
|
|
54
54
|
};
|
|
55
55
|
|
|
@@ -79,7 +79,7 @@ export type HmrClientMessage =
|
|
|
79
79
|
| 'groupCollapsed'
|
|
80
80
|
| 'groupEnd'
|
|
81
81
|
| 'debug',
|
|
82
|
-
+data: Array<
|
|
82
|
+
+data: Array<unknown>,
|
|
83
83
|
}
|
|
84
84
|
| {
|
|
85
85
|
+type: 'log-opt-in',
|
package/src/polyfills/require.js
CHANGED
|
@@ -371,6 +371,21 @@ if (__DEV__) {
|
|
|
371
371
|
}
|
|
372
372
|
throw unknownModuleError(id);
|
|
373
373
|
}
|
|
374
|
+
const forceFullRefreshPatterns =
|
|
375
|
+
global[__METRO_GLOBAL_PREFIX__ + "__unstable_forceFullRefreshPatterns"];
|
|
376
|
+
if (
|
|
377
|
+
forceFullRefreshPatterns != null &&
|
|
378
|
+
Array.isArray(forceFullRefreshPatterns) &&
|
|
379
|
+
mod.verboseName != null &&
|
|
380
|
+
forceFullRefreshPatterns.some((pattern) =>
|
|
381
|
+
pattern.test(mod.verboseName ?? ""),
|
|
382
|
+
)
|
|
383
|
+
) {
|
|
384
|
+
performFullRefresh("Module matched unstable_forceFullRefreshPatterns", {
|
|
385
|
+
source: mod,
|
|
386
|
+
});
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
374
389
|
if (!mod.hasError && !mod.isInitialized) {
|
|
375
390
|
mod.factory = factory;
|
|
376
391
|
mod.dependencyMap = dependencyMap;
|
|
@@ -23,7 +23,7 @@ declare var __METRO_GLOBAL_PREFIX__: string;
|
|
|
23
23
|
type ArrayIndexable<T> = interface {
|
|
24
24
|
+[indexer: number]: T,
|
|
25
25
|
};
|
|
26
|
-
type DependencyMap =
|
|
26
|
+
type DependencyMap = Readonly<
|
|
27
27
|
ArrayIndexable<ModuleID> & {
|
|
28
28
|
paths?: {[id: ModuleID]: string},
|
|
29
29
|
},
|
|
@@ -80,8 +80,8 @@ export type DefineFn = (
|
|
|
80
80
|
type VerboseModuleNameForDev = string;
|
|
81
81
|
type ModuleDefiner = (moduleId: ModuleID) => void;
|
|
82
82
|
|
|
83
|
-
global.__r =
|
|
84
|
-
global[`${__METRO_GLOBAL_PREFIX__}__d`] =
|
|
83
|
+
global.__r = metroRequire as RequireFn;
|
|
84
|
+
global[`${__METRO_GLOBAL_PREFIX__}__d`] = define as DefineFn;
|
|
85
85
|
global.__c = clear;
|
|
86
86
|
global.__registerSegment = registerSegment;
|
|
87
87
|
|
|
@@ -222,7 +222,7 @@ function metroRequire(
|
|
|
222
222
|
|
|
223
223
|
// We print require cycles unless they match a pattern in the
|
|
224
224
|
// `requireCycleIgnorePatterns` configuration.
|
|
225
|
-
function shouldPrintRequireCycle(modules:
|
|
225
|
+
function shouldPrintRequireCycle(modules: ReadonlyArray<?string>): boolean {
|
|
226
226
|
const regExps =
|
|
227
227
|
global[__METRO_GLOBAL_PREFIX__ + '__requireCycleIgnorePatterns'];
|
|
228
228
|
if (!Array.isArray(regExps)) {
|
|
@@ -291,7 +291,7 @@ function metroImportAll(
|
|
|
291
291
|
if (exports && exports.__esModule) {
|
|
292
292
|
importedAll = exports;
|
|
293
293
|
} else {
|
|
294
|
-
importedAll =
|
|
294
|
+
importedAll = {} as {[string]: any};
|
|
295
295
|
|
|
296
296
|
// Refrain from using Object.assign, it has to work in ES3 environments.
|
|
297
297
|
if (exports) {
|
|
@@ -387,7 +387,7 @@ const definingSegmentByModuleID: Map<ModuleID, number> = new Map();
|
|
|
387
387
|
function registerSegment(
|
|
388
388
|
segmentId: number,
|
|
389
389
|
moduleDefiner: ModuleDefiner,
|
|
390
|
-
moduleIds:
|
|
390
|
+
moduleIds: ?ReadonlyArray<ModuleID>,
|
|
391
391
|
): void {
|
|
392
392
|
moduleDefinersBySegmentID[segmentId] = moduleDefiner;
|
|
393
393
|
if (__DEV__) {
|
|
@@ -594,6 +594,28 @@ if (__DEV__) {
|
|
|
594
594
|
throw unknownModuleError(id);
|
|
595
595
|
}
|
|
596
596
|
|
|
597
|
+
// Some modules have known issues with hot reloading where their side effects
|
|
598
|
+
// (such as style registration) don't properly re-execute in the correct
|
|
599
|
+
// dependency order. The `unstable_forceFullRefreshPatterns` configuration allows
|
|
600
|
+
// specifying patterns for modules that should trigger a full refresh
|
|
601
|
+
// instead of attempting hot reload.
|
|
602
|
+
const forceFullRefreshPatterns =
|
|
603
|
+
global[__METRO_GLOBAL_PREFIX__ + '__unstable_forceFullRefreshPatterns'];
|
|
604
|
+
|
|
605
|
+
if (
|
|
606
|
+
forceFullRefreshPatterns != null &&
|
|
607
|
+
Array.isArray(forceFullRefreshPatterns) &&
|
|
608
|
+
mod.verboseName != null &&
|
|
609
|
+
forceFullRefreshPatterns.some(pattern =>
|
|
610
|
+
pattern.test(mod.verboseName ?? ''),
|
|
611
|
+
)
|
|
612
|
+
) {
|
|
613
|
+
performFullRefresh('Module matched unstable_forceFullRefreshPatterns', {
|
|
614
|
+
source: mod,
|
|
615
|
+
});
|
|
616
|
+
return;
|
|
617
|
+
}
|
|
618
|
+
|
|
597
619
|
if (!mod.hasError && !mod.isInitialized) {
|
|
598
620
|
// The module hasn't actually been executed yet,
|
|
599
621
|
// so we can always safely replace it.
|
|
@@ -799,8 +821,8 @@ if (__DEV__) {
|
|
|
799
821
|
earlyStop: T => boolean,
|
|
800
822
|
): Array<T> {
|
|
801
823
|
const result = [];
|
|
802
|
-
const visited = new Set<
|
|
803
|
-
const stack = new Set<
|
|
824
|
+
const visited = new Set<unknown>();
|
|
825
|
+
const stack = new Set<unknown>();
|
|
804
826
|
function traverseDependentNodes(node: T): void {
|
|
805
827
|
if (stack.has(node)) {
|
|
806
828
|
throw CYCLE_DETECTED;
|
|
@@ -902,7 +924,7 @@ if (__DEV__) {
|
|
|
902
924
|
|
|
903
925
|
const performFullRefresh = (
|
|
904
926
|
reason: string,
|
|
905
|
-
modules:
|
|
927
|
+
modules: Readonly<{
|
|
906
928
|
source?: ModuleDefinition,
|
|
907
929
|
failed?: ModuleDefinition,
|
|
908
930
|
}>,
|
|
@@ -996,7 +1018,7 @@ if (__DEV__) {
|
|
|
996
1018
|
var getRefreshBoundarySignature = (
|
|
997
1019
|
Refresh: any,
|
|
998
1020
|
moduleExports: Exports,
|
|
999
|
-
): Array<
|
|
1021
|
+
): Array<unknown> => {
|
|
1000
1022
|
const signature = [];
|
|
1001
1023
|
signature.push(Refresh.getFamilyByType(moduleExports));
|
|
1002
1024
|
if (moduleExports == null || typeof moduleExports !== 'object') {
|