react-router 7.14.1 → 7.15.0
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/CHANGELOG.md +105 -0
- package/dist/development/{browser-D-3-U2Jj.d.mts → browser-CRsXgNrY.d.mts} +2 -2
- package/dist/{production/browser-D-3-U2Jj.d.mts → development/browser-wDl1FZEL.d.ts} +2 -2
- package/dist/{production/chunk-3SUPTI2U.js → development/chunk-2D5H3HU3.js} +7 -7
- package/dist/development/{chunk-OE4NN4TA.mjs → chunk-5KNZJZUH.mjs} +362 -213
- package/dist/development/{chunk-YMKMFAYZ.js → chunk-AM3XM4LS.js} +314 -172
- package/dist/development/{chunk-BFXCU3MI.mjs → chunk-RMD3H4O3.mjs} +81 -62
- package/dist/development/{chunk-3F6IB66O.js → chunk-Z5YQYACE.js} +146 -139
- package/dist/{production/context-BzhbVly6.d.mts → development/context-BQs41HrG.d.mts} +94 -42
- package/dist/development/{routeModules-CM_clkdE.d.ts → data-BVUf681J.d.mts} +89 -56
- package/dist/{production/routeModules-CM_clkdE.d.ts → development/data-BqZ2x964.d.ts} +79 -46
- package/dist/development/dom-export.d.mts +9 -9
- package/dist/development/dom-export.d.ts +9 -9
- package/dist/development/dom-export.js +37 -40
- package/dist/development/dom-export.mjs +12 -15
- package/dist/development/{index-react-server-client-CimaPp9o.d.ts → index-react-server-client-CSv-KZBk.d.ts} +123 -121
- package/dist/{production/index-react-server-client-WSaoxloq.d.mts → development/index-react-server-client-Ck_yZ1qL.d.mts} +102 -100
- package/dist/development/index-react-server-client.d.mts +3 -3
- package/dist/development/index-react-server-client.d.ts +3 -3
- package/dist/development/index-react-server-client.js +4 -4
- package/dist/development/index-react-server-client.mjs +2 -2
- package/dist/development/index-react-server.d.mts +107 -36
- package/dist/development/index-react-server.d.ts +107 -36
- package/dist/development/index-react-server.js +60 -33
- package/dist/development/index-react-server.mjs +60 -33
- package/dist/development/index.d.mts +11 -11
- package/dist/development/index.d.ts +11 -11
- package/dist/development/index.js +174 -155
- package/dist/development/index.mjs +3 -3
- package/dist/{production/instrumentation-CMVbvxj9.d.ts → development/instrumentation-DlJ2QV7d.d.ts} +73 -21
- package/dist/development/lib/types/internal.d.mts +2 -2
- package/dist/development/lib/types/internal.d.ts +2 -2
- package/dist/development/lib/types/internal.js +1 -1
- package/dist/development/lib/types/internal.mjs +1 -1
- package/dist/development/{register-D1WlEpq9.d.ts → register-Bsscfj79.d.ts} +1 -1
- package/dist/{production/register-D1WlEpq9.d.ts → development/register-Df8okEea.d.mts} +1 -1
- package/dist/production/{browser-CtktEGQs.d.ts → browser-CRsXgNrY.d.mts} +2 -2
- package/dist/{development/browser-CtktEGQs.d.ts → production/browser-wDl1FZEL.d.ts} +2 -2
- package/dist/production/{chunk-G5ZWO7Q6.mjs → chunk-23ZOHYE5.mjs} +81 -62
- package/dist/{development/chunk-7VLQJKNG.js → production/chunk-7YXKJMLN.js} +7 -7
- package/dist/production/{chunk-SPR7R4GU.mjs → chunk-GM3PW4GX.mjs} +362 -213
- package/dist/production/{chunk-UVEQGZIH.js → chunk-LCJTIOKZ.js} +314 -172
- package/dist/production/{chunk-LIOP3ILM.js → chunk-YBQJ3ABE.js} +146 -139
- package/dist/{development/context-BzhbVly6.d.mts → production/context-BQs41HrG.d.mts} +94 -42
- package/dist/{development/routeModules-Djumx26z.d.mts → production/data-BVUf681J.d.mts} +79 -46
- package/dist/production/{routeModules-Djumx26z.d.mts → data-BqZ2x964.d.ts} +89 -56
- package/dist/production/dom-export.d.mts +9 -9
- package/dist/production/dom-export.d.ts +9 -9
- package/dist/production/dom-export.js +37 -40
- package/dist/production/dom-export.mjs +12 -15
- package/dist/production/{index-react-server-client-CimaPp9o.d.ts → index-react-server-client-CSv-KZBk.d.ts} +123 -121
- package/dist/{development/index-react-server-client-WSaoxloq.d.mts → production/index-react-server-client-Ck_yZ1qL.d.mts} +102 -100
- package/dist/production/index-react-server-client.d.mts +3 -3
- package/dist/production/index-react-server-client.d.ts +3 -3
- package/dist/production/index-react-server-client.js +4 -4
- package/dist/production/index-react-server-client.mjs +2 -2
- package/dist/production/index-react-server.d.mts +107 -36
- package/dist/production/index-react-server.d.ts +107 -36
- package/dist/production/index-react-server.js +60 -33
- package/dist/production/index-react-server.mjs +60 -33
- package/dist/production/index.d.mts +11 -11
- package/dist/production/index.d.ts +11 -11
- package/dist/production/index.js +174 -155
- package/dist/production/index.mjs +3 -3
- package/dist/{development/instrumentation-CMVbvxj9.d.ts → production/instrumentation-DlJ2QV7d.d.ts} +73 -21
- package/dist/production/lib/types/internal.d.mts +2 -2
- package/dist/production/lib/types/internal.d.ts +2 -2
- package/dist/production/lib/types/internal.js +1 -1
- package/dist/production/lib/types/internal.mjs +1 -1
- package/dist/{development/register-aE9ob3TK.d.mts → production/register-Bsscfj79.d.ts} +1 -1
- package/dist/production/{register-aE9ob3TK.d.mts → register-Df8okEea.d.mts} +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v7.
|
|
2
|
+
* react-router v7.15.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -14,6 +14,7 @@ var __typeError = (msg) => {
|
|
|
14
14
|
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
15
15
|
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
16
16
|
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
17
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
17
18
|
|
|
18
19
|
// lib/router/history.ts
|
|
19
20
|
var Action = /* @__PURE__ */ ((Action2) => {
|
|
@@ -34,7 +35,7 @@ function createMemoryHistory(options = {}) {
|
|
|
34
35
|
entry,
|
|
35
36
|
typeof entry === "string" ? null : entry.state,
|
|
36
37
|
index2 === 0 ? "default" : void 0,
|
|
37
|
-
typeof entry === "string" ? void 0 : entry.
|
|
38
|
+
typeof entry === "string" ? void 0 : entry.mask
|
|
38
39
|
)
|
|
39
40
|
);
|
|
40
41
|
let index = clampIndex(
|
|
@@ -48,13 +49,13 @@ function createMemoryHistory(options = {}) {
|
|
|
48
49
|
function getCurrentLocation() {
|
|
49
50
|
return entries[index];
|
|
50
51
|
}
|
|
51
|
-
function createMemoryLocation(to, state = null, key,
|
|
52
|
+
function createMemoryLocation(to, state = null, key, mask) {
|
|
52
53
|
let location = createLocation(
|
|
53
54
|
entries ? getCurrentLocation().pathname : "/",
|
|
54
55
|
to,
|
|
55
56
|
state,
|
|
56
57
|
key,
|
|
57
|
-
|
|
58
|
+
mask
|
|
58
59
|
);
|
|
59
60
|
warning(
|
|
60
61
|
location.pathname.charAt(0) === "/",
|
|
@@ -216,14 +217,14 @@ function getHistoryState(location, index) {
|
|
|
216
217
|
usr: location.state,
|
|
217
218
|
key: location.key,
|
|
218
219
|
idx: index,
|
|
219
|
-
masked: location.
|
|
220
|
+
masked: location.mask ? {
|
|
220
221
|
pathname: location.pathname,
|
|
221
222
|
search: location.search,
|
|
222
223
|
hash: location.hash
|
|
223
224
|
} : void 0
|
|
224
225
|
};
|
|
225
226
|
}
|
|
226
|
-
function createLocation(current, to, state = null, key,
|
|
227
|
+
function createLocation(current, to, state = null, key, mask) {
|
|
227
228
|
let location = {
|
|
228
229
|
pathname: typeof current === "string" ? current : current.pathname,
|
|
229
230
|
search: "",
|
|
@@ -235,7 +236,7 @@ function createLocation(current, to, state = null, key, unstable_mask) {
|
|
|
235
236
|
// But that's a pretty big refactor to the current test suite so going to
|
|
236
237
|
// keep as is for the time being and just let any incoming keys take precedence
|
|
237
238
|
key: to && to.key || key || createKey(),
|
|
238
|
-
|
|
239
|
+
mask
|
|
239
240
|
};
|
|
240
241
|
return location;
|
|
241
242
|
}
|
|
@@ -298,7 +299,7 @@ function getUrlBasedHistory(getLocation, createHref2, validateLocation, options
|
|
|
298
299
|
if (validateLocation) validateLocation(location, to);
|
|
299
300
|
index = getIndex() + 1;
|
|
300
301
|
let historyState = getHistoryState(location, index);
|
|
301
|
-
let url = history.createHref(location.
|
|
302
|
+
let url = history.createHref(location.mask || location);
|
|
302
303
|
try {
|
|
303
304
|
globalHistory.pushState(historyState, "", url);
|
|
304
305
|
} catch (error) {
|
|
@@ -317,7 +318,7 @@ function getUrlBasedHistory(getLocation, createHref2, validateLocation, options
|
|
|
317
318
|
if (validateLocation) validateLocation(location, to);
|
|
318
319
|
index = getIndex();
|
|
319
320
|
let historyState = getHistoryState(location, index);
|
|
320
|
-
let url = history.createHref(location.
|
|
321
|
+
let url = history.createHref(location.mask || location);
|
|
321
322
|
globalHistory.replaceState(historyState, "", url);
|
|
322
323
|
if (v5Compat && listener) {
|
|
323
324
|
listener({ action, location: history.location, delta: 0 });
|
|
@@ -515,17 +516,16 @@ function mergeRouteUpdates(route, updates) {
|
|
|
515
516
|
function matchRoutes(routes, locationArg, basename = "/") {
|
|
516
517
|
return matchRoutesImpl(routes, locationArg, basename, false);
|
|
517
518
|
}
|
|
518
|
-
function matchRoutesImpl(routes, locationArg, basename, allowPartial) {
|
|
519
|
+
function matchRoutesImpl(routes, locationArg, basename, allowPartial, precomputedBranches) {
|
|
519
520
|
let location = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
|
|
520
521
|
let pathname = stripBasename(location.pathname || "/", basename);
|
|
521
522
|
if (pathname == null) {
|
|
522
523
|
return null;
|
|
523
524
|
}
|
|
524
|
-
let branches =
|
|
525
|
-
rankRouteBranches(branches);
|
|
525
|
+
let branches = precomputedBranches ?? flattenAndRankRoutes(routes);
|
|
526
526
|
let matches = null;
|
|
527
|
+
let decoded = decodePath(pathname);
|
|
527
528
|
for (let i = 0; matches == null && i < branches.length; ++i) {
|
|
528
|
-
let decoded = decodePath(pathname);
|
|
529
529
|
matches = matchRouteBranch(
|
|
530
530
|
branches[i],
|
|
531
531
|
decoded,
|
|
@@ -545,6 +545,11 @@ function convertRouteMatchToUiMatch(match, loaderData) {
|
|
|
545
545
|
handle: route.handle
|
|
546
546
|
};
|
|
547
547
|
}
|
|
548
|
+
function flattenAndRankRoutes(routes) {
|
|
549
|
+
let branches = flattenRoutes(routes);
|
|
550
|
+
rankRouteBranches(branches);
|
|
551
|
+
return branches;
|
|
552
|
+
}
|
|
548
553
|
function flattenRoutes(routes, branches = [], parentsMeta = [], parentPath = "", _hasParentOptionalSegments = false) {
|
|
549
554
|
let flattenRoute = (route, index, hasParentOptionalSegments = _hasParentOptionalSegments, relativePath) => {
|
|
550
555
|
let meta = {
|
|
@@ -723,8 +728,7 @@ function generatePath(originalPath, params = {}) {
|
|
|
723
728
|
const segments = path.split(/\/+/).map((segment, index, array) => {
|
|
724
729
|
const isLastSegment = index === array.length - 1;
|
|
725
730
|
if (isLastSegment && segment === "*") {
|
|
726
|
-
|
|
727
|
-
return stringify2(params[star]);
|
|
731
|
+
return stringify2(params["*"]);
|
|
728
732
|
}
|
|
729
733
|
const keyMatch = segment.match(/^:([\w-]+)(\??)(.*)/);
|
|
730
734
|
if (keyMatch) {
|
|
@@ -1253,11 +1257,11 @@ async function recurseRight(impls, info, handler, index) {
|
|
|
1253
1257
|
};
|
|
1254
1258
|
}
|
|
1255
1259
|
function getHandlerInfo(args) {
|
|
1256
|
-
let { request, context, params,
|
|
1260
|
+
let { request, context, params, pattern } = args;
|
|
1257
1261
|
return {
|
|
1258
1262
|
request: getReadonlyRequest(request),
|
|
1259
1263
|
params: { ...params },
|
|
1260
|
-
|
|
1264
|
+
pattern,
|
|
1261
1265
|
context: getReadonlyContext(context)
|
|
1262
1266
|
};
|
|
1263
1267
|
}
|
|
@@ -1347,6 +1351,55 @@ var defaultMapRouteProperties = (route) => ({
|
|
|
1347
1351
|
});
|
|
1348
1352
|
var TRANSITIONS_STORAGE_KEY = "remix-router-transitions";
|
|
1349
1353
|
var ResetLoaderDataSymbol = Symbol("ResetLoaderData");
|
|
1354
|
+
var _routes, _branches, _hmrRoutes, _hmrBranches;
|
|
1355
|
+
var DataRoutes = class {
|
|
1356
|
+
constructor(routes) {
|
|
1357
|
+
__privateAdd(this, _routes);
|
|
1358
|
+
__privateAdd(this, _branches);
|
|
1359
|
+
__privateAdd(this, _hmrRoutes);
|
|
1360
|
+
__privateAdd(this, _hmrBranches);
|
|
1361
|
+
__privateSet(this, _routes, routes);
|
|
1362
|
+
__privateSet(this, _branches, flattenAndRankRoutes(routes));
|
|
1363
|
+
}
|
|
1364
|
+
/** The stable route tree */
|
|
1365
|
+
get stableRoutes() {
|
|
1366
|
+
return __privateGet(this, _routes);
|
|
1367
|
+
}
|
|
1368
|
+
/** The in-flight route tree if one is active, otherwise the stable tree */
|
|
1369
|
+
get activeRoutes() {
|
|
1370
|
+
return __privateGet(this, _hmrRoutes) ?? __privateGet(this, _routes);
|
|
1371
|
+
}
|
|
1372
|
+
/** Pre-computed branches */
|
|
1373
|
+
get branches() {
|
|
1374
|
+
return __privateGet(this, _hmrBranches) ?? __privateGet(this, _branches);
|
|
1375
|
+
}
|
|
1376
|
+
get hasHMRRoutes() {
|
|
1377
|
+
return __privateGet(this, _hmrRoutes) != null;
|
|
1378
|
+
}
|
|
1379
|
+
/** Replace the stable route tree and recompute its branches */
|
|
1380
|
+
setRoutes(routes) {
|
|
1381
|
+
__privateSet(this, _routes, routes);
|
|
1382
|
+
__privateSet(this, _branches, flattenAndRankRoutes(routes));
|
|
1383
|
+
}
|
|
1384
|
+
/** Set a new in-flight route tree and recompute its branches */
|
|
1385
|
+
setHmrRoutes(routes) {
|
|
1386
|
+
__privateSet(this, _hmrRoutes, routes);
|
|
1387
|
+
__privateSet(this, _hmrBranches, flattenAndRankRoutes(routes));
|
|
1388
|
+
}
|
|
1389
|
+
/** Commit in-flight routes/branches to the stable slot and clear in-flight */
|
|
1390
|
+
commitHmrRoutes() {
|
|
1391
|
+
if (__privateGet(this, _hmrRoutes)) {
|
|
1392
|
+
__privateSet(this, _routes, __privateGet(this, _hmrRoutes));
|
|
1393
|
+
__privateSet(this, _branches, __privateGet(this, _hmrBranches));
|
|
1394
|
+
__privateSet(this, _hmrRoutes, void 0);
|
|
1395
|
+
__privateSet(this, _hmrBranches, void 0);
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1398
|
+
};
|
|
1399
|
+
_routes = new WeakMap();
|
|
1400
|
+
_branches = new WeakMap();
|
|
1401
|
+
_hmrRoutes = new WeakMap();
|
|
1402
|
+
_hmrBranches = new WeakMap();
|
|
1350
1403
|
function createRouter(init) {
|
|
1351
1404
|
const routerWindow = init.window ? init.window : typeof window !== "undefined" ? window : void 0;
|
|
1352
1405
|
const isBrowser3 = typeof routerWindow !== "undefined" && typeof routerWindow.document !== "undefined" && typeof routerWindow.document.createElement !== "undefined";
|
|
@@ -1357,8 +1410,8 @@ function createRouter(init) {
|
|
|
1357
1410
|
let hydrationRouteProperties2 = init.hydrationRouteProperties || [];
|
|
1358
1411
|
let _mapRouteProperties = init.mapRouteProperties || defaultMapRouteProperties;
|
|
1359
1412
|
let mapRouteProperties2 = _mapRouteProperties;
|
|
1360
|
-
if (init.
|
|
1361
|
-
let instrumentations = init.
|
|
1413
|
+
if (init.instrumentations) {
|
|
1414
|
+
let instrumentations = init.instrumentations;
|
|
1362
1415
|
mapRouteProperties2 = (route) => {
|
|
1363
1416
|
return {
|
|
1364
1417
|
..._mapRouteProperties(route),
|
|
@@ -1370,20 +1423,20 @@ function createRouter(init) {
|
|
|
1370
1423
|
};
|
|
1371
1424
|
}
|
|
1372
1425
|
let manifest = {};
|
|
1373
|
-
let dataRoutes =
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1426
|
+
let dataRoutes = new DataRoutes(
|
|
1427
|
+
convertRoutesToDataRoutes(
|
|
1428
|
+
init.routes,
|
|
1429
|
+
mapRouteProperties2,
|
|
1430
|
+
void 0,
|
|
1431
|
+
manifest
|
|
1432
|
+
)
|
|
1378
1433
|
);
|
|
1379
|
-
let inFlightDataRoutes;
|
|
1380
1434
|
let basename = init.basename || "/";
|
|
1381
1435
|
if (!basename.startsWith("/")) {
|
|
1382
1436
|
basename = `/${basename}`;
|
|
1383
1437
|
}
|
|
1384
1438
|
let dataStrategyImpl = init.dataStrategy || defaultDataStrategyWithMiddleware;
|
|
1385
1439
|
let future = {
|
|
1386
|
-
unstable_passThroughRequests: false,
|
|
1387
1440
|
...init.future
|
|
1388
1441
|
};
|
|
1389
1442
|
let unlistenHistory = null;
|
|
@@ -1392,7 +1445,13 @@ function createRouter(init) {
|
|
|
1392
1445
|
let getScrollRestorationKey2 = null;
|
|
1393
1446
|
let getScrollPosition = null;
|
|
1394
1447
|
let initialScrollRestored = init.hydrationData != null;
|
|
1395
|
-
let initialMatches =
|
|
1448
|
+
let initialMatches = matchRoutesImpl(
|
|
1449
|
+
dataRoutes.activeRoutes,
|
|
1450
|
+
init.history.location,
|
|
1451
|
+
basename,
|
|
1452
|
+
false,
|
|
1453
|
+
dataRoutes.branches
|
|
1454
|
+
);
|
|
1396
1455
|
let initialMatchesIsFOW = false;
|
|
1397
1456
|
let initialErrors = null;
|
|
1398
1457
|
let initialized;
|
|
@@ -1401,7 +1460,7 @@ function createRouter(init) {
|
|
|
1401
1460
|
let error = getInternalRouterError(404, {
|
|
1402
1461
|
pathname: init.history.location.pathname
|
|
1403
1462
|
});
|
|
1404
|
-
let { matches, route } = getShortCircuitMatches(dataRoutes);
|
|
1463
|
+
let { matches, route } = getShortCircuitMatches(dataRoutes.activeRoutes);
|
|
1405
1464
|
initialized = true;
|
|
1406
1465
|
renderFallback = !initialized;
|
|
1407
1466
|
initialMatches = matches;
|
|
@@ -1410,7 +1469,7 @@ function createRouter(init) {
|
|
|
1410
1469
|
if (initialMatches && !init.hydrationData) {
|
|
1411
1470
|
let fogOfWar = checkFogOfWar(
|
|
1412
1471
|
initialMatches,
|
|
1413
|
-
dataRoutes,
|
|
1472
|
+
dataRoutes.activeRoutes,
|
|
1414
1473
|
init.history.location.pathname
|
|
1415
1474
|
);
|
|
1416
1475
|
if (fogOfWar.active) {
|
|
@@ -1423,7 +1482,7 @@ function createRouter(init) {
|
|
|
1423
1482
|
initialMatches = [];
|
|
1424
1483
|
let fogOfWar = checkFogOfWar(
|
|
1425
1484
|
null,
|
|
1426
|
-
dataRoutes,
|
|
1485
|
+
dataRoutes.activeRoutes,
|
|
1427
1486
|
init.history.location.pathname
|
|
1428
1487
|
);
|
|
1429
1488
|
if (fogOfWar.active && fogOfWar.matches) {
|
|
@@ -1642,10 +1701,7 @@ function createRouter(init) {
|
|
|
1642
1701
|
}
|
|
1643
1702
|
let restoreScrollPosition = isUninterruptedRevalidation ? false : getSavedScrollPosition(location, newState.matches || state.matches);
|
|
1644
1703
|
let preventScrollReset = pendingPreventScrollReset === true || state.navigation.formMethod != null && isMutationMethod(state.navigation.formMethod) && location.state?._isRedirect !== true;
|
|
1645
|
-
|
|
1646
|
-
dataRoutes = inFlightDataRoutes;
|
|
1647
|
-
inFlightDataRoutes = void 0;
|
|
1648
|
-
}
|
|
1704
|
+
dataRoutes.commitHmrRoutes();
|
|
1649
1705
|
if (isUninterruptedRevalidation) {
|
|
1650
1706
|
} else if (pendingAction === "POP" /* Pop */) {
|
|
1651
1707
|
} else if (pendingAction === "PUSH" /* Push */) {
|
|
@@ -1736,10 +1792,10 @@ function createRouter(init) {
|
|
|
1736
1792
|
opts
|
|
1737
1793
|
);
|
|
1738
1794
|
let maskPath;
|
|
1739
|
-
if (opts?.
|
|
1740
|
-
let partialPath = typeof opts.
|
|
1741
|
-
...state.location.
|
|
1742
|
-
...opts.
|
|
1795
|
+
if (opts?.mask) {
|
|
1796
|
+
let partialPath = typeof opts.mask === "string" ? parsePath(opts.mask) : {
|
|
1797
|
+
...state.location.mask,
|
|
1798
|
+
...opts.mask
|
|
1743
1799
|
};
|
|
1744
1800
|
maskPath = {
|
|
1745
1801
|
pathname: "",
|
|
@@ -1805,7 +1861,7 @@ function createRouter(init) {
|
|
|
1805
1861
|
replace: opts && opts.replace,
|
|
1806
1862
|
enableViewTransition: opts && opts.viewTransition,
|
|
1807
1863
|
flushSync,
|
|
1808
|
-
callSiteDefaultShouldRevalidate: opts && opts.
|
|
1864
|
+
callSiteDefaultShouldRevalidate: opts && opts.defaultShouldRevalidate
|
|
1809
1865
|
});
|
|
1810
1866
|
}
|
|
1811
1867
|
function revalidate() {
|
|
@@ -1843,12 +1899,18 @@ function createRouter(init) {
|
|
|
1843
1899
|
saveScrollPosition(state.location, state.matches);
|
|
1844
1900
|
pendingPreventScrollReset = (opts && opts.preventScrollReset) === true;
|
|
1845
1901
|
pendingViewTransitionEnabled = (opts && opts.enableViewTransition) === true;
|
|
1846
|
-
let routesToUse =
|
|
1902
|
+
let routesToUse = dataRoutes.activeRoutes;
|
|
1847
1903
|
let loadingNavigation = opts && opts.overrideNavigation;
|
|
1848
1904
|
let matches = opts?.initialHydration && state.matches && state.matches.length > 0 && !initialMatchesIsFOW ? (
|
|
1849
1905
|
// `matchRoutes()` has already been called if we're in here via `router.initialize()`
|
|
1850
1906
|
state.matches
|
|
1851
|
-
) :
|
|
1907
|
+
) : matchRoutesImpl(
|
|
1908
|
+
routesToUse,
|
|
1909
|
+
location,
|
|
1910
|
+
basename,
|
|
1911
|
+
false,
|
|
1912
|
+
dataRoutes.branches
|
|
1913
|
+
);
|
|
1852
1914
|
let flushSync = (opts && opts.flushSync) === true;
|
|
1853
1915
|
if (matches && state.initialized && !isRevalidationRequired && isHashChangeOnly(state.location, location) && !(opts && opts.submission && isMutationMethod(opts.submission.formMethod))) {
|
|
1854
1916
|
completeNavigation(location, { matches }, { flushSync });
|
|
@@ -1973,7 +2035,9 @@ function createRouter(init) {
|
|
|
1973
2035
|
return { shortCircuited: true };
|
|
1974
2036
|
} else if (discoverResult.type === "error") {
|
|
1975
2037
|
if (discoverResult.partialMatches.length === 0) {
|
|
1976
|
-
let { matches: matches2, route } = getShortCircuitMatches(
|
|
2038
|
+
let { matches: matches2, route } = getShortCircuitMatches(
|
|
2039
|
+
dataRoutes.activeRoutes
|
|
2040
|
+
);
|
|
1977
2041
|
return {
|
|
1978
2042
|
matches: matches2,
|
|
1979
2043
|
pendingActionResult: [
|
|
@@ -2120,7 +2184,9 @@ function createRouter(init) {
|
|
|
2120
2184
|
return { shortCircuited: true };
|
|
2121
2185
|
} else if (discoverResult.type === "error") {
|
|
2122
2186
|
if (discoverResult.partialMatches.length === 0) {
|
|
2123
|
-
let { matches: matches2, route } = getShortCircuitMatches(
|
|
2187
|
+
let { matches: matches2, route } = getShortCircuitMatches(
|
|
2188
|
+
dataRoutes.activeRoutes
|
|
2189
|
+
);
|
|
2124
2190
|
return {
|
|
2125
2191
|
matches: matches2,
|
|
2126
2192
|
loaderData: {},
|
|
@@ -2152,7 +2218,7 @@ function createRouter(init) {
|
|
|
2152
2218
|
matches = discoverResult.matches;
|
|
2153
2219
|
}
|
|
2154
2220
|
}
|
|
2155
|
-
let routesToUse =
|
|
2221
|
+
let routesToUse = dataRoutes.activeRoutes;
|
|
2156
2222
|
let { dsMatches, revalidatingFetchers } = getMatchesToLoad(
|
|
2157
2223
|
request,
|
|
2158
2224
|
scopedContext,
|
|
@@ -2173,6 +2239,7 @@ function createRouter(init) {
|
|
|
2173
2239
|
routesToUse,
|
|
2174
2240
|
basename,
|
|
2175
2241
|
init.patchRoutesOnNavigation != null,
|
|
2242
|
+
dataRoutes.branches,
|
|
2176
2243
|
pendingActionResult,
|
|
2177
2244
|
callSiteDefaultShouldRevalidate
|
|
2178
2245
|
);
|
|
@@ -2302,7 +2369,7 @@ function createRouter(init) {
|
|
|
2302
2369
|
async function fetch2(key, routeId, href, opts) {
|
|
2303
2370
|
abortFetcher(key);
|
|
2304
2371
|
let flushSync = (opts && opts.flushSync) === true;
|
|
2305
|
-
let routesToUse =
|
|
2372
|
+
let routesToUse = dataRoutes.activeRoutes;
|
|
2306
2373
|
let normalizedPath = normalizeTo(
|
|
2307
2374
|
state.location,
|
|
2308
2375
|
state.matches,
|
|
@@ -2311,7 +2378,13 @@ function createRouter(init) {
|
|
|
2311
2378
|
routeId,
|
|
2312
2379
|
opts?.relative
|
|
2313
2380
|
);
|
|
2314
|
-
let matches =
|
|
2381
|
+
let matches = matchRoutesImpl(
|
|
2382
|
+
routesToUse,
|
|
2383
|
+
normalizedPath,
|
|
2384
|
+
basename,
|
|
2385
|
+
false,
|
|
2386
|
+
dataRoutes.branches
|
|
2387
|
+
);
|
|
2315
2388
|
let fogOfWar = checkFogOfWar(matches, routesToUse, normalizedPath);
|
|
2316
2389
|
if (fogOfWar.active && fogOfWar.matches) {
|
|
2317
2390
|
matches = fogOfWar.matches;
|
|
@@ -2347,7 +2420,7 @@ function createRouter(init) {
|
|
|
2347
2420
|
flushSync,
|
|
2348
2421
|
preventScrollReset,
|
|
2349
2422
|
submission,
|
|
2350
|
-
opts && opts.
|
|
2423
|
+
opts && opts.defaultShouldRevalidate
|
|
2351
2424
|
);
|
|
2352
2425
|
return;
|
|
2353
2426
|
}
|
|
@@ -2477,8 +2550,14 @@ function createRouter(init) {
|
|
|
2477
2550
|
nextLocation,
|
|
2478
2551
|
abortController.signal
|
|
2479
2552
|
);
|
|
2480
|
-
let routesToUse =
|
|
2481
|
-
let matches = state.navigation.state !== "idle" ?
|
|
2553
|
+
let routesToUse = dataRoutes.activeRoutes;
|
|
2554
|
+
let matches = state.navigation.state !== "idle" ? matchRoutesImpl(
|
|
2555
|
+
routesToUse,
|
|
2556
|
+
state.navigation.location,
|
|
2557
|
+
basename,
|
|
2558
|
+
false,
|
|
2559
|
+
dataRoutes.branches
|
|
2560
|
+
) : state.matches;
|
|
2482
2561
|
invariant(matches, "Didn't find any matches after fetcher action");
|
|
2483
2562
|
let loadId = ++incrementingLoadId;
|
|
2484
2563
|
fetchReloadIds.set(key, loadId);
|
|
@@ -2504,6 +2583,7 @@ function createRouter(init) {
|
|
|
2504
2583
|
routesToUse,
|
|
2505
2584
|
basename,
|
|
2506
2585
|
init.patchRoutesOnNavigation != null,
|
|
2586
|
+
dataRoutes.branches,
|
|
2507
2587
|
[match.route.id, actionResult],
|
|
2508
2588
|
callSiteDefaultShouldRevalidate
|
|
2509
2589
|
);
|
|
@@ -2659,6 +2739,14 @@ function createRouter(init) {
|
|
|
2659
2739
|
key
|
|
2660
2740
|
);
|
|
2661
2741
|
let result = results[match.route.id];
|
|
2742
|
+
if (!result) {
|
|
2743
|
+
for (let match2 of matches) {
|
|
2744
|
+
if (results[match2.route.id]) {
|
|
2745
|
+
result = results[match2.route.id];
|
|
2746
|
+
break;
|
|
2747
|
+
}
|
|
2748
|
+
}
|
|
2749
|
+
}
|
|
2662
2750
|
if (fetchControllers.get(key) === abortController) {
|
|
2663
2751
|
fetchControllers.delete(key);
|
|
2664
2752
|
}
|
|
@@ -3014,7 +3102,7 @@ function createRouter(init) {
|
|
|
3014
3102
|
}
|
|
3015
3103
|
function handleNavigational404(pathname) {
|
|
3016
3104
|
let error = getInternalRouterError(404, { pathname });
|
|
3017
|
-
let routesToUse =
|
|
3105
|
+
let routesToUse = dataRoutes.activeRoutes;
|
|
3018
3106
|
let { matches, route } = getShortCircuitMatches(routesToUse);
|
|
3019
3107
|
return { notFoundMatches: matches, route, error };
|
|
3020
3108
|
}
|
|
@@ -3063,12 +3151,14 @@ function createRouter(init) {
|
|
|
3063
3151
|
}
|
|
3064
3152
|
function checkFogOfWar(matches, routesToUse, pathname) {
|
|
3065
3153
|
if (init.patchRoutesOnNavigation) {
|
|
3154
|
+
let activeBranches = dataRoutes.branches;
|
|
3066
3155
|
if (!matches) {
|
|
3067
3156
|
let fogMatches = matchRoutesImpl(
|
|
3068
3157
|
routesToUse,
|
|
3069
3158
|
pathname,
|
|
3070
3159
|
basename,
|
|
3071
|
-
true
|
|
3160
|
+
true,
|
|
3161
|
+
activeBranches
|
|
3072
3162
|
);
|
|
3073
3163
|
return { active: true, matches: fogMatches || [] };
|
|
3074
3164
|
} else {
|
|
@@ -3077,7 +3167,8 @@ function createRouter(init) {
|
|
|
3077
3167
|
routesToUse,
|
|
3078
3168
|
pathname,
|
|
3079
3169
|
basename,
|
|
3080
|
-
true
|
|
3170
|
+
true,
|
|
3171
|
+
activeBranches
|
|
3081
3172
|
);
|
|
3082
3173
|
return { active: true, matches: partialMatches };
|
|
3083
3174
|
}
|
|
@@ -3091,8 +3182,6 @@ function createRouter(init) {
|
|
|
3091
3182
|
}
|
|
3092
3183
|
let partialMatches = matches;
|
|
3093
3184
|
while (true) {
|
|
3094
|
-
let isNonHMR = inFlightDataRoutes == null;
|
|
3095
|
-
let routesToUse = inFlightDataRoutes || dataRoutes;
|
|
3096
3185
|
let localManifest = manifest;
|
|
3097
3186
|
try {
|
|
3098
3187
|
await init.patchRoutesOnNavigation({
|
|
@@ -3105,7 +3194,7 @@ function createRouter(init) {
|
|
|
3105
3194
|
patchRoutesImpl(
|
|
3106
3195
|
routeId,
|
|
3107
3196
|
children,
|
|
3108
|
-
|
|
3197
|
+
dataRoutes,
|
|
3109
3198
|
localManifest,
|
|
3110
3199
|
mapRouteProperties2,
|
|
3111
3200
|
false
|
|
@@ -3114,25 +3203,29 @@ function createRouter(init) {
|
|
|
3114
3203
|
});
|
|
3115
3204
|
} catch (e) {
|
|
3116
3205
|
return { type: "error", error: e, partialMatches };
|
|
3117
|
-
} finally {
|
|
3118
|
-
if (isNonHMR && !signal.aborted) {
|
|
3119
|
-
dataRoutes = [...dataRoutes];
|
|
3120
|
-
}
|
|
3121
3206
|
}
|
|
3122
3207
|
if (signal.aborted) {
|
|
3123
3208
|
return { type: "aborted" };
|
|
3124
3209
|
}
|
|
3125
|
-
let
|
|
3210
|
+
let activeBranches = dataRoutes.branches;
|
|
3211
|
+
let newMatches = matchRoutesImpl(
|
|
3212
|
+
dataRoutes.activeRoutes,
|
|
3213
|
+
pathname,
|
|
3214
|
+
basename,
|
|
3215
|
+
false,
|
|
3216
|
+
activeBranches
|
|
3217
|
+
);
|
|
3126
3218
|
let newPartialMatches = null;
|
|
3127
3219
|
if (newMatches) {
|
|
3128
3220
|
if (Object.keys(newMatches[0].params).length === 0) {
|
|
3129
3221
|
return { type: "success", matches: newMatches };
|
|
3130
3222
|
} else {
|
|
3131
3223
|
newPartialMatches = matchRoutesImpl(
|
|
3132
|
-
|
|
3224
|
+
dataRoutes.activeRoutes,
|
|
3133
3225
|
pathname,
|
|
3134
3226
|
basename,
|
|
3135
|
-
true
|
|
3227
|
+
true,
|
|
3228
|
+
activeBranches
|
|
3136
3229
|
);
|
|
3137
3230
|
let matchedDeeper = newPartialMatches && partialMatches.length < newPartialMatches.length && compareMatches(
|
|
3138
3231
|
partialMatches,
|
|
@@ -3145,10 +3238,11 @@ function createRouter(init) {
|
|
|
3145
3238
|
}
|
|
3146
3239
|
if (!newPartialMatches) {
|
|
3147
3240
|
newPartialMatches = matchRoutesImpl(
|
|
3148
|
-
|
|
3241
|
+
dataRoutes.activeRoutes,
|
|
3149
3242
|
pathname,
|
|
3150
3243
|
basename,
|
|
3151
|
-
true
|
|
3244
|
+
true,
|
|
3245
|
+
activeBranches
|
|
3152
3246
|
);
|
|
3153
3247
|
}
|
|
3154
3248
|
if (!newPartialMatches || compareMatches(partialMatches, newPartialMatches)) {
|
|
@@ -3162,26 +3256,25 @@ function createRouter(init) {
|
|
|
3162
3256
|
}
|
|
3163
3257
|
function _internalSetRoutes(newRoutes) {
|
|
3164
3258
|
manifest = {};
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3259
|
+
dataRoutes.setHmrRoutes(
|
|
3260
|
+
convertRoutesToDataRoutes(
|
|
3261
|
+
newRoutes,
|
|
3262
|
+
mapRouteProperties2,
|
|
3263
|
+
void 0,
|
|
3264
|
+
manifest
|
|
3265
|
+
)
|
|
3170
3266
|
);
|
|
3171
3267
|
}
|
|
3172
3268
|
function patchRoutes(routeId, children, unstable_allowElementMutations = false) {
|
|
3173
|
-
let isNonHMR = inFlightDataRoutes == null;
|
|
3174
|
-
let routesToUse = inFlightDataRoutes || dataRoutes;
|
|
3175
3269
|
patchRoutesImpl(
|
|
3176
3270
|
routeId,
|
|
3177
3271
|
children,
|
|
3178
|
-
|
|
3272
|
+
dataRoutes,
|
|
3179
3273
|
manifest,
|
|
3180
3274
|
mapRouteProperties2,
|
|
3181
3275
|
unstable_allowElementMutations
|
|
3182
3276
|
);
|
|
3183
|
-
if (
|
|
3184
|
-
dataRoutes = [...dataRoutes];
|
|
3277
|
+
if (!dataRoutes.hasHMRRoutes) {
|
|
3185
3278
|
updateState({});
|
|
3186
3279
|
}
|
|
3187
3280
|
}
|
|
@@ -3196,7 +3289,13 @@ function createRouter(init) {
|
|
|
3196
3289
|
return state;
|
|
3197
3290
|
},
|
|
3198
3291
|
get routes() {
|
|
3199
|
-
return dataRoutes;
|
|
3292
|
+
return dataRoutes.stableRoutes;
|
|
3293
|
+
},
|
|
3294
|
+
get branches() {
|
|
3295
|
+
return dataRoutes.branches;
|
|
3296
|
+
},
|
|
3297
|
+
get manifest() {
|
|
3298
|
+
return manifest;
|
|
3200
3299
|
},
|
|
3201
3300
|
get window() {
|
|
3202
3301
|
return routerWindow;
|
|
@@ -3226,10 +3325,10 @@ function createRouter(init) {
|
|
|
3226
3325
|
updateState(newState);
|
|
3227
3326
|
}
|
|
3228
3327
|
};
|
|
3229
|
-
if (init.
|
|
3328
|
+
if (init.instrumentations) {
|
|
3230
3329
|
router = instrumentClientSideRouter(
|
|
3231
3330
|
router,
|
|
3232
|
-
init.
|
|
3331
|
+
init.instrumentations.map((i) => i.router).filter(Boolean)
|
|
3233
3332
|
);
|
|
3234
3333
|
}
|
|
3235
3334
|
return router;
|
|
@@ -3244,12 +3343,10 @@ function createStaticHandler(routes, opts) {
|
|
|
3244
3343
|
let _mapRouteProperties = opts?.mapRouteProperties || defaultMapRouteProperties;
|
|
3245
3344
|
let mapRouteProperties2 = _mapRouteProperties;
|
|
3246
3345
|
let future = {
|
|
3247
|
-
unstable_passThroughRequests: false,
|
|
3248
|
-
// unused in static handler
|
|
3249
3346
|
...opts?.future
|
|
3250
3347
|
};
|
|
3251
|
-
if (opts?.
|
|
3252
|
-
let instrumentations = opts.
|
|
3348
|
+
if (opts?.instrumentations) {
|
|
3349
|
+
let instrumentations = opts.instrumentations;
|
|
3253
3350
|
mapRouteProperties2 = (route) => {
|
|
3254
3351
|
return {
|
|
3255
3352
|
..._mapRouteProperties(route),
|
|
@@ -3266,6 +3363,7 @@ function createStaticHandler(routes, opts) {
|
|
|
3266
3363
|
void 0,
|
|
3267
3364
|
manifest
|
|
3268
3365
|
);
|
|
3366
|
+
let routeBranches = flattenAndRankRoutes(dataRoutes);
|
|
3269
3367
|
async function query(request, {
|
|
3270
3368
|
requestContext,
|
|
3271
3369
|
filterMatchesToLoad,
|
|
@@ -3273,12 +3371,23 @@ function createStaticHandler(routes, opts) {
|
|
|
3273
3371
|
skipRevalidation,
|
|
3274
3372
|
dataStrategy,
|
|
3275
3373
|
generateMiddlewareResponse,
|
|
3276
|
-
|
|
3374
|
+
normalizePath
|
|
3277
3375
|
} = {}) {
|
|
3278
|
-
let
|
|
3376
|
+
let normalizePathImpl = normalizePath || defaultNormalizePath;
|
|
3279
3377
|
let method = request.method;
|
|
3280
|
-
let location = createLocation(
|
|
3281
|
-
|
|
3378
|
+
let location = createLocation(
|
|
3379
|
+
"",
|
|
3380
|
+
normalizePathImpl(request),
|
|
3381
|
+
null,
|
|
3382
|
+
"default"
|
|
3383
|
+
);
|
|
3384
|
+
let matches = matchRoutesImpl(
|
|
3385
|
+
dataRoutes,
|
|
3386
|
+
location,
|
|
3387
|
+
basename,
|
|
3388
|
+
false,
|
|
3389
|
+
routeBranches
|
|
3390
|
+
);
|
|
3282
3391
|
requestContext = requestContext != null ? requestContext : new RouterContextProvider();
|
|
3283
3392
|
if (!isValidMethod(method) && method !== "HEAD") {
|
|
3284
3393
|
let error = getInternalRouterError(405, { method });
|
|
@@ -3330,8 +3439,8 @@ function createStaticHandler(routes, opts) {
|
|
|
3330
3439
|
let response = await runServerMiddlewarePipeline(
|
|
3331
3440
|
{
|
|
3332
3441
|
request,
|
|
3333
|
-
|
|
3334
|
-
|
|
3442
|
+
url: createDataFunctionUrl(request, location),
|
|
3443
|
+
pattern: getRoutePattern(matches),
|
|
3335
3444
|
matches,
|
|
3336
3445
|
params: matches[0].params,
|
|
3337
3446
|
// If we're calling middleware then it must be enabled so we can cast
|
|
@@ -3448,12 +3557,23 @@ function createStaticHandler(routes, opts) {
|
|
|
3448
3557
|
requestContext,
|
|
3449
3558
|
dataStrategy,
|
|
3450
3559
|
generateMiddlewareResponse,
|
|
3451
|
-
|
|
3560
|
+
normalizePath
|
|
3452
3561
|
} = {}) {
|
|
3453
|
-
let
|
|
3562
|
+
let normalizePathImpl = normalizePath || defaultNormalizePath;
|
|
3454
3563
|
let method = request.method;
|
|
3455
|
-
let location = createLocation(
|
|
3456
|
-
|
|
3564
|
+
let location = createLocation(
|
|
3565
|
+
"",
|
|
3566
|
+
normalizePathImpl(request),
|
|
3567
|
+
null,
|
|
3568
|
+
"default"
|
|
3569
|
+
);
|
|
3570
|
+
let matches = matchRoutesImpl(
|
|
3571
|
+
dataRoutes,
|
|
3572
|
+
location,
|
|
3573
|
+
basename,
|
|
3574
|
+
false,
|
|
3575
|
+
routeBranches
|
|
3576
|
+
);
|
|
3457
3577
|
requestContext = requestContext != null ? requestContext : new RouterContextProvider();
|
|
3458
3578
|
if (!isValidMethod(method) && method !== "HEAD" && method !== "OPTIONS") {
|
|
3459
3579
|
throw getInternalRouterError(405, { method });
|
|
@@ -3478,8 +3598,8 @@ function createStaticHandler(routes, opts) {
|
|
|
3478
3598
|
let response = await runServerMiddlewarePipeline(
|
|
3479
3599
|
{
|
|
3480
3600
|
request,
|
|
3481
|
-
|
|
3482
|
-
|
|
3601
|
+
url: createDataFunctionUrl(request, location),
|
|
3602
|
+
pattern: getRoutePattern(matches),
|
|
3483
3603
|
matches,
|
|
3484
3604
|
params: matches[0].params,
|
|
3485
3605
|
// If we're calling middleware then it must be enabled so we can cast
|
|
@@ -3865,6 +3985,7 @@ function createStaticHandler(routes, opts) {
|
|
|
3865
3985
|
}
|
|
3866
3986
|
return {
|
|
3867
3987
|
dataRoutes,
|
|
3988
|
+
_internalRouteBranches: routeBranches,
|
|
3868
3989
|
query,
|
|
3869
3990
|
queryRoute
|
|
3870
3991
|
};
|
|
@@ -4050,7 +4171,7 @@ function normalizeNavigateOptions(isFetcher, path, opts) {
|
|
|
4050
4171
|
parsedPath.search = `?${searchParams}`;
|
|
4051
4172
|
return { path: createPath(parsedPath), submission };
|
|
4052
4173
|
}
|
|
4053
|
-
function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest, history, state, matches, submission, location, lazyRoutePropertiesToSkip, initialHydration, isRevalidationRequired, cancelledFetcherLoads, fetchersQueuedForDeletion, fetchLoadMatches, fetchRedirectIds, routesToUse, basename, hasPatchRoutesOnNavigation, pendingActionResult, callSiteDefaultShouldRevalidate) {
|
|
4174
|
+
function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest, history, state, matches, submission, location, lazyRoutePropertiesToSkip, initialHydration, isRevalidationRequired, cancelledFetcherLoads, fetchersQueuedForDeletion, fetchLoadMatches, fetchRedirectIds, routesToUse, basename, hasPatchRoutesOnNavigation, branches, pendingActionResult, callSiteDefaultShouldRevalidate) {
|
|
4054
4175
|
let actionResult = pendingActionResult ? isErrorResult(pendingActionResult[1]) ? pendingActionResult[1].error : pendingActionResult[1].data : void 0;
|
|
4055
4176
|
let currentUrl = history.createURL(state.location);
|
|
4056
4177
|
let nextUrl = history.createURL(location);
|
|
@@ -4146,7 +4267,13 @@ function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest,
|
|
|
4146
4267
|
}
|
|
4147
4268
|
let fetcher = state.fetchers.get(key);
|
|
4148
4269
|
let isMidInitialLoad = fetcher && fetcher.state !== "idle" && fetcher.data === void 0;
|
|
4149
|
-
let fetcherMatches =
|
|
4270
|
+
let fetcherMatches = matchRoutesImpl(
|
|
4271
|
+
routesToUse,
|
|
4272
|
+
f.path,
|
|
4273
|
+
basename ?? "/",
|
|
4274
|
+
false,
|
|
4275
|
+
branches
|
|
4276
|
+
);
|
|
4150
4277
|
if (!fetcherMatches) {
|
|
4151
4278
|
if (hasPatchRoutesOnNavigation && isMidInitialLoad) {
|
|
4152
4279
|
return;
|
|
@@ -4287,7 +4414,7 @@ function shouldRevalidateLoader(loaderMatch, arg) {
|
|
|
4287
4414
|
}
|
|
4288
4415
|
return arg.defaultShouldRevalidate;
|
|
4289
4416
|
}
|
|
4290
|
-
function patchRoutesImpl(routeId, children,
|
|
4417
|
+
function patchRoutesImpl(routeId, children, dataRoutes, manifest, mapRouteProperties2, allowElementMutations) {
|
|
4291
4418
|
let childrenToPatch;
|
|
4292
4419
|
if (routeId) {
|
|
4293
4420
|
let route = manifest[routeId];
|
|
@@ -4300,7 +4427,7 @@ function patchRoutesImpl(routeId, children, routesToUse, manifest, mapRoutePrope
|
|
|
4300
4427
|
}
|
|
4301
4428
|
childrenToPatch = route.children;
|
|
4302
4429
|
} else {
|
|
4303
|
-
childrenToPatch =
|
|
4430
|
+
childrenToPatch = dataRoutes.activeRoutes;
|
|
4304
4431
|
}
|
|
4305
4432
|
let uniqueChildren = [];
|
|
4306
4433
|
let existingChildren = [];
|
|
@@ -4343,6 +4470,9 @@ function patchRoutesImpl(routeId, children, routesToUse, manifest, mapRoutePrope
|
|
|
4343
4470
|
});
|
|
4344
4471
|
}
|
|
4345
4472
|
}
|
|
4473
|
+
if (!dataRoutes.hasHMRRoutes) {
|
|
4474
|
+
dataRoutes.setRoutes([...dataRoutes.activeRoutes]);
|
|
4475
|
+
}
|
|
4346
4476
|
}
|
|
4347
4477
|
function isSameRoute(newRoute, existingRoute) {
|
|
4348
4478
|
if ("id" in newRoute && "id" in existingRoute && newRoute.id === existingRoute.id) {
|
|
@@ -4684,7 +4814,7 @@ function getDataStrategyMatchLazyPromises(mapRouteProperties2, manifest, request
|
|
|
4684
4814
|
handler: lazyRoutePromises.lazyHandlerPromise
|
|
4685
4815
|
};
|
|
4686
4816
|
}
|
|
4687
|
-
function getDataStrategyMatch(mapRouteProperties2, manifest, request, path,
|
|
4817
|
+
function getDataStrategyMatch(mapRouteProperties2, manifest, request, path, pattern, match, lazyRoutePropertiesToSkip, scopedContext, shouldLoad, shouldRevalidateArgs = null, callSiteDefaultShouldRevalidate) {
|
|
4688
4818
|
let isUsingNewApi = false;
|
|
4689
4819
|
let _lazyPromises = getDataStrategyMatchLazyPromises(
|
|
4690
4820
|
mapRouteProperties2,
|
|
@@ -4725,7 +4855,7 @@ function getDataStrategyMatch(mapRouteProperties2, manifest, request, path, unst
|
|
|
4725
4855
|
return callLoaderOrAction({
|
|
4726
4856
|
request,
|
|
4727
4857
|
path,
|
|
4728
|
-
|
|
4858
|
+
pattern,
|
|
4729
4859
|
match,
|
|
4730
4860
|
lazyHandlerPromise: _lazyPromises?.handler,
|
|
4731
4861
|
lazyRoutePromise: _lazyPromises?.route,
|
|
@@ -4775,8 +4905,8 @@ async function callDataStrategyImpl(dataStrategyImpl, request, path, matches, fe
|
|
|
4775
4905
|
}
|
|
4776
4906
|
let dataStrategyArgs = {
|
|
4777
4907
|
request,
|
|
4778
|
-
|
|
4779
|
-
|
|
4908
|
+
url: createDataFunctionUrl(request, path),
|
|
4909
|
+
pattern: getRoutePattern(matches),
|
|
4780
4910
|
params: matches[0].params,
|
|
4781
4911
|
context: scopedContext,
|
|
4782
4912
|
matches
|
|
@@ -4818,7 +4948,7 @@ async function callDataStrategyImpl(dataStrategyImpl, request, path, matches, fe
|
|
|
4818
4948
|
async function callLoaderOrAction({
|
|
4819
4949
|
request,
|
|
4820
4950
|
path,
|
|
4821
|
-
|
|
4951
|
+
pattern,
|
|
4822
4952
|
match,
|
|
4823
4953
|
lazyHandlerPromise,
|
|
4824
4954
|
lazyRoutePromise,
|
|
@@ -4845,8 +4975,8 @@ async function callLoaderOrAction({
|
|
|
4845
4975
|
return handler(
|
|
4846
4976
|
{
|
|
4847
4977
|
request,
|
|
4848
|
-
|
|
4849
|
-
|
|
4978
|
+
url: createDataFunctionUrl(request, path),
|
|
4979
|
+
pattern,
|
|
4850
4980
|
params: match.params,
|
|
4851
4981
|
context: scopedContext
|
|
4852
4982
|
},
|
|
@@ -5735,7 +5865,7 @@ function useOutlet(context) {
|
|
|
5735
5865
|
function useParams() {
|
|
5736
5866
|
let { matches } = React2.useContext(RouteContext);
|
|
5737
5867
|
let routeMatch = matches[matches.length - 1];
|
|
5738
|
-
return routeMatch
|
|
5868
|
+
return routeMatch?.params ?? {};
|
|
5739
5869
|
}
|
|
5740
5870
|
function useResolvedPath(to, { relative } = {}) {
|
|
5741
5871
|
let { matches } = React2.useContext(RouteContext);
|
|
@@ -5797,7 +5927,15 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
|
|
|
5797
5927
|
let segments = pathname.replace(/^\//, "").split("/");
|
|
5798
5928
|
remainingPathname = "/" + segments.slice(parentSegments.length).join("/");
|
|
5799
5929
|
}
|
|
5800
|
-
let matches =
|
|
5930
|
+
let matches = dataRouterOpts && dataRouterOpts.state.matches.length ? (
|
|
5931
|
+
// If we're in a data router, use the matches we've already identified but ensure
|
|
5932
|
+
// we have the latest route instances from the manifest in case elements have changed
|
|
5933
|
+
dataRouterOpts.state.matches.map(
|
|
5934
|
+
(m) => Object.assign(m, {
|
|
5935
|
+
route: dataRouterOpts.manifest[m.route.id] || m.route
|
|
5936
|
+
})
|
|
5937
|
+
)
|
|
5938
|
+
) : matchRoutes(routes, { pathname: remainingPathname });
|
|
5801
5939
|
if (ENABLE_DEV_WARNINGS) {
|
|
5802
5940
|
warning(
|
|
5803
5941
|
parentRoute || matches != null,
|
|
@@ -5848,7 +5986,7 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
|
|
|
5848
5986
|
hash: "",
|
|
5849
5987
|
state: null,
|
|
5850
5988
|
key: "default",
|
|
5851
|
-
|
|
5989
|
+
mask: void 0,
|
|
5852
5990
|
...location
|
|
5853
5991
|
},
|
|
5854
5992
|
navigationType: "POP" /* Pop */
|
|
@@ -6038,7 +6176,7 @@ function _renderMatches(matches, parentMatches = [], dataRouterOpts) {
|
|
|
6038
6176
|
onErrorHandler(error, {
|
|
6039
6177
|
location: dataRouterState.location,
|
|
6040
6178
|
params: dataRouterState.matches?.[0]?.params ?? {},
|
|
6041
|
-
|
|
6179
|
+
pattern: getRoutePattern(dataRouterState.matches),
|
|
6042
6180
|
errorInfo
|
|
6043
6181
|
});
|
|
6044
6182
|
} : void 0;
|
|
@@ -6369,7 +6507,7 @@ function createMemoryRouter(routes, opts) {
|
|
|
6369
6507
|
mapRouteProperties,
|
|
6370
6508
|
dataStrategy: opts?.dataStrategy,
|
|
6371
6509
|
patchRoutesOnNavigation: opts?.patchRoutesOnNavigation,
|
|
6372
|
-
|
|
6510
|
+
instrumentations: opts?.instrumentations
|
|
6373
6511
|
}).initialize();
|
|
6374
6512
|
}
|
|
6375
6513
|
var Deferred = class {
|
|
@@ -6395,10 +6533,10 @@ function RouterProvider({
|
|
|
6395
6533
|
router,
|
|
6396
6534
|
flushSync: reactDomFlushSyncImpl,
|
|
6397
6535
|
onError,
|
|
6398
|
-
|
|
6536
|
+
useTransitions
|
|
6399
6537
|
}) {
|
|
6400
6538
|
let unstable_rsc = useIsRSCRouterContext();
|
|
6401
|
-
|
|
6539
|
+
useTransitions = unstable_rsc || useTransitions;
|
|
6402
6540
|
let [_state, setStateImpl] = React3.useState(router.state);
|
|
6403
6541
|
let [state, setOptimisticState] = useOptimisticSafe(_state);
|
|
6404
6542
|
let [pendingState, setPendingState] = React3.useState();
|
|
@@ -6416,7 +6554,7 @@ function RouterProvider({
|
|
|
6416
6554
|
(error) => onError(error, {
|
|
6417
6555
|
location: newState.location,
|
|
6418
6556
|
params: newState.matches[0]?.params ?? {},
|
|
6419
|
-
|
|
6557
|
+
pattern: getRoutePattern(newState.matches)
|
|
6420
6558
|
})
|
|
6421
6559
|
);
|
|
6422
6560
|
}
|
|
@@ -6438,11 +6576,11 @@ function RouterProvider({
|
|
|
6438
6576
|
if (!viewTransitionOpts || !isViewTransitionAvailable) {
|
|
6439
6577
|
if (reactDomFlushSyncImpl && flushSync) {
|
|
6440
6578
|
reactDomFlushSyncImpl(() => setStateImpl(newState));
|
|
6441
|
-
} else if (
|
|
6579
|
+
} else if (useTransitions === false) {
|
|
6442
6580
|
setStateImpl(newState);
|
|
6443
6581
|
} else {
|
|
6444
6582
|
React3.startTransition(() => {
|
|
6445
|
-
if (
|
|
6583
|
+
if (useTransitions === true) {
|
|
6446
6584
|
setOptimisticState((s) => getOptimisticRouterState(s, newState));
|
|
6447
6585
|
}
|
|
6448
6586
|
setStateImpl(newState);
|
|
@@ -6500,7 +6638,7 @@ function RouterProvider({
|
|
|
6500
6638
|
reactDomFlushSyncImpl,
|
|
6501
6639
|
transition,
|
|
6502
6640
|
renderDfd,
|
|
6503
|
-
|
|
6641
|
+
useTransitions,
|
|
6504
6642
|
setOptimisticState,
|
|
6505
6643
|
onError
|
|
6506
6644
|
]
|
|
@@ -6526,11 +6664,11 @@ function RouterProvider({
|
|
|
6526
6664
|
let newState = pendingState;
|
|
6527
6665
|
let renderPromise = renderDfd.promise;
|
|
6528
6666
|
let transition2 = router.window.document.startViewTransition(async () => {
|
|
6529
|
-
if (
|
|
6667
|
+
if (useTransitions === false) {
|
|
6530
6668
|
setStateImpl(newState);
|
|
6531
6669
|
} else {
|
|
6532
6670
|
React3.startTransition(() => {
|
|
6533
|
-
if (
|
|
6671
|
+
if (useTransitions === true) {
|
|
6534
6672
|
setOptimisticState((s) => getOptimisticRouterState(s, newState));
|
|
6535
6673
|
}
|
|
6536
6674
|
setStateImpl(newState);
|
|
@@ -6550,7 +6688,7 @@ function RouterProvider({
|
|
|
6550
6688
|
pendingState,
|
|
6551
6689
|
renderDfd,
|
|
6552
6690
|
router.window,
|
|
6553
|
-
|
|
6691
|
+
useTransitions,
|
|
6554
6692
|
setOptimisticState
|
|
6555
6693
|
]);
|
|
6556
6694
|
React3.useEffect(() => {
|
|
@@ -6604,12 +6742,13 @@ function RouterProvider({
|
|
|
6604
6742
|
location: state.location,
|
|
6605
6743
|
navigationType: state.historyAction,
|
|
6606
6744
|
navigator,
|
|
6607
|
-
|
|
6745
|
+
useTransitions
|
|
6608
6746
|
},
|
|
6609
6747
|
/* @__PURE__ */ React3.createElement(
|
|
6610
6748
|
MemoizedDataRoutes,
|
|
6611
6749
|
{
|
|
6612
6750
|
routes: router.routes,
|
|
6751
|
+
manifest: router.manifest,
|
|
6613
6752
|
future: router.future,
|
|
6614
6753
|
state,
|
|
6615
6754
|
isStatic: false,
|
|
@@ -6632,22 +6771,29 @@ function getOptimisticRouterState(currentState, newState) {
|
|
|
6632
6771
|
fetchers: newState.fetchers
|
|
6633
6772
|
};
|
|
6634
6773
|
}
|
|
6635
|
-
var MemoizedDataRoutes = React3.memo(
|
|
6636
|
-
function
|
|
6774
|
+
var MemoizedDataRoutes = React3.memo(DataRoutes2);
|
|
6775
|
+
function DataRoutes2({
|
|
6637
6776
|
routes,
|
|
6777
|
+
manifest,
|
|
6638
6778
|
future,
|
|
6639
6779
|
state,
|
|
6640
6780
|
isStatic,
|
|
6641
6781
|
onError
|
|
6642
6782
|
}) {
|
|
6643
|
-
return useRoutesImpl(routes, void 0, {
|
|
6783
|
+
return useRoutesImpl(routes, void 0, {
|
|
6784
|
+
manifest,
|
|
6785
|
+
state,
|
|
6786
|
+
isStatic,
|
|
6787
|
+
onError,
|
|
6788
|
+
future
|
|
6789
|
+
});
|
|
6644
6790
|
}
|
|
6645
6791
|
function MemoryRouter({
|
|
6646
6792
|
basename,
|
|
6647
6793
|
children,
|
|
6648
6794
|
initialEntries,
|
|
6649
6795
|
initialIndex,
|
|
6650
|
-
|
|
6796
|
+
useTransitions
|
|
6651
6797
|
}) {
|
|
6652
6798
|
let historyRef = React3.useRef();
|
|
6653
6799
|
if (historyRef.current == null) {
|
|
@@ -6664,13 +6810,13 @@ function MemoryRouter({
|
|
|
6664
6810
|
});
|
|
6665
6811
|
let setState = React3.useCallback(
|
|
6666
6812
|
(newState) => {
|
|
6667
|
-
if (
|
|
6813
|
+
if (useTransitions === false) {
|
|
6668
6814
|
setStateImpl(newState);
|
|
6669
6815
|
} else {
|
|
6670
6816
|
React3.startTransition(() => setStateImpl(newState));
|
|
6671
6817
|
}
|
|
6672
6818
|
},
|
|
6673
|
-
[
|
|
6819
|
+
[useTransitions]
|
|
6674
6820
|
);
|
|
6675
6821
|
React3.useLayoutEffect(() => history.listen(setState), [history, setState]);
|
|
6676
6822
|
return /* @__PURE__ */ React3.createElement(
|
|
@@ -6681,7 +6827,7 @@ function MemoryRouter({
|
|
|
6681
6827
|
location: state.location,
|
|
6682
6828
|
navigationType: state.action,
|
|
6683
6829
|
navigator: history,
|
|
6684
|
-
|
|
6830
|
+
useTransitions
|
|
6685
6831
|
}
|
|
6686
6832
|
);
|
|
6687
6833
|
}
|
|
@@ -6733,7 +6879,7 @@ function Router({
|
|
|
6733
6879
|
navigationType = "POP" /* Pop */,
|
|
6734
6880
|
navigator,
|
|
6735
6881
|
static: staticProp = false,
|
|
6736
|
-
|
|
6882
|
+
useTransitions
|
|
6737
6883
|
}) {
|
|
6738
6884
|
invariant(
|
|
6739
6885
|
!useInRouterContext(),
|
|
@@ -6745,10 +6891,10 @@ function Router({
|
|
|
6745
6891
|
basename,
|
|
6746
6892
|
navigator,
|
|
6747
6893
|
static: staticProp,
|
|
6748
|
-
|
|
6894
|
+
useTransitions,
|
|
6749
6895
|
future: {}
|
|
6750
6896
|
}),
|
|
6751
|
-
[basename, navigator, staticProp,
|
|
6897
|
+
[basename, navigator, staticProp, useTransitions]
|
|
6752
6898
|
);
|
|
6753
6899
|
if (typeof locationProp === "string") {
|
|
6754
6900
|
locationProp = parsePath(locationProp);
|
|
@@ -6759,7 +6905,7 @@ function Router({
|
|
|
6759
6905
|
hash = "",
|
|
6760
6906
|
state = null,
|
|
6761
6907
|
key = "default",
|
|
6762
|
-
|
|
6908
|
+
mask
|
|
6763
6909
|
} = locationProp;
|
|
6764
6910
|
let locationContext = React3.useMemo(() => {
|
|
6765
6911
|
let trailingPathname = stripBasename(pathname, basename);
|
|
@@ -6773,20 +6919,11 @@ function Router({
|
|
|
6773
6919
|
hash,
|
|
6774
6920
|
state,
|
|
6775
6921
|
key,
|
|
6776
|
-
|
|
6922
|
+
mask
|
|
6777
6923
|
},
|
|
6778
6924
|
navigationType
|
|
6779
6925
|
};
|
|
6780
|
-
}, [
|
|
6781
|
-
basename,
|
|
6782
|
-
pathname,
|
|
6783
|
-
search,
|
|
6784
|
-
hash,
|
|
6785
|
-
state,
|
|
6786
|
-
key,
|
|
6787
|
-
navigationType,
|
|
6788
|
-
unstable_mask
|
|
6789
|
-
]);
|
|
6926
|
+
}, [basename, pathname, search, hash, state, key, navigationType, mask]);
|
|
6790
6927
|
warning(
|
|
6791
6928
|
locationContext != null,
|
|
6792
6929
|
`<Router basename="${basename}"> is not able to match the URL "${pathname}${search}${hash}" because it does not start with the basename, so the <Router> won't render anything.`
|
|
@@ -6815,7 +6952,7 @@ function Await({
|
|
|
6815
6952
|
dataRouterContext.onError(error, {
|
|
6816
6953
|
location: dataRouterStateContext.location,
|
|
6817
6954
|
params: dataRouterStateContext.matches[0]?.params || {},
|
|
6818
|
-
|
|
6955
|
+
pattern: getRoutePattern(dataRouterStateContext.matches),
|
|
6819
6956
|
errorInfo
|
|
6820
6957
|
});
|
|
6821
6958
|
}
|
|
@@ -7165,6 +7302,14 @@ var TYPE_SET = "S";
|
|
|
7165
7302
|
var TYPE_SYMBOL = "Y";
|
|
7166
7303
|
var TYPE_URL = "U";
|
|
7167
7304
|
var TYPE_PREVIOUS_RESOLVED = "Z";
|
|
7305
|
+
var SUPPORTED_ERROR_TYPES = [
|
|
7306
|
+
"EvalError",
|
|
7307
|
+
"RangeError",
|
|
7308
|
+
"ReferenceError",
|
|
7309
|
+
"SyntaxError",
|
|
7310
|
+
"TypeError",
|
|
7311
|
+
"URIError"
|
|
7312
|
+
];
|
|
7168
7313
|
var Deferred2 = class {
|
|
7169
7314
|
constructor() {
|
|
7170
7315
|
this.promise = new Promise((resolve, reject) => {
|
|
@@ -7526,7 +7671,7 @@ function hydrate(index) {
|
|
|
7526
7671
|
continue;
|
|
7527
7672
|
case TYPE_ERROR:
|
|
7528
7673
|
const [, message, errorType] = value;
|
|
7529
|
-
let error = errorType && globalObj && globalObj[errorType] ? new globalObj[errorType](message) : new Error(message);
|
|
7674
|
+
let error = errorType && globalObj && SUPPORTED_ERROR_TYPES.includes(errorType) && errorType in globalObj && typeof globalObj[errorType] === "function" ? new globalObj[errorType](message) : new Error(message);
|
|
7530
7675
|
hydrated[index2] = error;
|
|
7531
7676
|
set(error);
|
|
7532
7677
|
continue;
|
|
@@ -7961,11 +8106,9 @@ function getTurboStreamSingleFetchDataStrategy(getRouter, manifest, routeModules
|
|
|
7961
8106
|
(match) => {
|
|
7962
8107
|
let manifestRoute = manifest.routes[match.route.id];
|
|
7963
8108
|
invariant2(manifestRoute, "Route not found in manifest");
|
|
7964
|
-
let routeModule = routeModules[match.route.id];
|
|
7965
8109
|
return {
|
|
7966
8110
|
hasLoader: manifestRoute.hasLoader,
|
|
7967
|
-
hasClientLoader: manifestRoute.hasClientLoader
|
|
7968
|
-
hasShouldRevalidate: Boolean(routeModule?.shouldRevalidate)
|
|
8111
|
+
hasClientLoader: manifestRoute.hasClientLoader
|
|
7969
8112
|
};
|
|
7970
8113
|
},
|
|
7971
8114
|
fetchAndDecodeViaTurboStream,
|
|
@@ -8085,13 +8228,12 @@ async function singleFetchLoaderNavigationStrategy(args, router, getRouteInfo, f
|
|
|
8085
8228
|
async (m, i) => m.resolve(async (handler) => {
|
|
8086
8229
|
routeDfds[i].resolve();
|
|
8087
8230
|
let routeId = m.route.id;
|
|
8088
|
-
let { hasLoader, hasClientLoader
|
|
8231
|
+
let { hasLoader, hasClientLoader } = getRouteInfo(m);
|
|
8089
8232
|
let defaultShouldRevalidate = !m.shouldRevalidateArgs || m.shouldRevalidateArgs.actionStatus == null || m.shouldRevalidateArgs.actionStatus < 400;
|
|
8090
8233
|
let shouldCall = m.shouldCallHandler(defaultShouldRevalidate);
|
|
8091
8234
|
if (!shouldCall) {
|
|
8092
8235
|
foundOptOutRoute || (foundOptOutRoute = m.shouldRevalidateArgs != null && // This is a revalidation,
|
|
8093
|
-
hasLoader
|
|
8094
|
-
hasShouldRevalidate === true);
|
|
8236
|
+
hasLoader);
|
|
8095
8237
|
return;
|
|
8096
8238
|
}
|
|
8097
8239
|
if (shouldAllowOptOut(m) && hasClientLoader) {
|
|
@@ -8309,7 +8451,8 @@ function decodeViaTurboStream(body, global) {
|
|
|
8309
8451
|
if (type === "SanitizedError") {
|
|
8310
8452
|
let [name, message, stack] = rest;
|
|
8311
8453
|
let Constructor = Error;
|
|
8312
|
-
if (name && name in global &&
|
|
8454
|
+
if (name && SUPPORTED_ERROR_TYPES.includes(name) && name in global && // @ts-expect-error
|
|
8455
|
+
typeof global[name] === "function") {
|
|
8313
8456
|
Constructor = global[name];
|
|
8314
8457
|
}
|
|
8315
8458
|
let error = new Constructor(message);
|
|
@@ -8827,13 +8970,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
8827
8970
|
let hasInitialError = initialState && initialState.errors && route.id in initialState.errors;
|
|
8828
8971
|
let initialError = hasInitialError ? initialState?.errors?.[route.id] : void 0;
|
|
8829
8972
|
let isHydrationRequest = needsRevalidation == null && (routeModule.clientLoader?.hydrate === true || !route.hasLoader);
|
|
8830
|
-
dataRoute.loader = async ({
|
|
8831
|
-
request,
|
|
8832
|
-
params,
|
|
8833
|
-
context,
|
|
8834
|
-
unstable_pattern,
|
|
8835
|
-
unstable_url
|
|
8836
|
-
}, singleFetch) => {
|
|
8973
|
+
dataRoute.loader = async ({ request, params, context, pattern, url }, singleFetch) => {
|
|
8837
8974
|
try {
|
|
8838
8975
|
let result = await prefetchStylesAndCallHandler(async () => {
|
|
8839
8976
|
invariant2(
|
|
@@ -8847,8 +8984,8 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
8847
8984
|
request,
|
|
8848
8985
|
params,
|
|
8849
8986
|
context,
|
|
8850
|
-
|
|
8851
|
-
|
|
8987
|
+
pattern,
|
|
8988
|
+
url,
|
|
8852
8989
|
async serverLoader() {
|
|
8853
8990
|
preventInvalidServerHandlerCall("loader", route);
|
|
8854
8991
|
if (isHydrationRequest) {
|
|
@@ -8874,13 +9011,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
8874
9011
|
route.hasLoader,
|
|
8875
9012
|
isSpaMode
|
|
8876
9013
|
);
|
|
8877
|
-
dataRoute.action = ({
|
|
8878
|
-
request,
|
|
8879
|
-
params,
|
|
8880
|
-
context,
|
|
8881
|
-
unstable_pattern,
|
|
8882
|
-
unstable_url
|
|
8883
|
-
}, singleFetch) => {
|
|
9014
|
+
dataRoute.action = ({ request, params, context, pattern, url }, singleFetch) => {
|
|
8884
9015
|
return prefetchStylesAndCallHandler(async () => {
|
|
8885
9016
|
invariant2(
|
|
8886
9017
|
routeModule,
|
|
@@ -8896,8 +9027,8 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
8896
9027
|
request,
|
|
8897
9028
|
params,
|
|
8898
9029
|
context,
|
|
8899
|
-
|
|
8900
|
-
|
|
9030
|
+
pattern,
|
|
9031
|
+
url,
|
|
8901
9032
|
async serverAction() {
|
|
8902
9033
|
preventInvalidServerHandlerCall("action", route);
|
|
8903
9034
|
return fetchServerAction(singleFetch);
|
|
@@ -9092,7 +9223,13 @@ function getPartialManifest({ sri, ...manifest }, router) {
|
|
|
9092
9223
|
segments.pop();
|
|
9093
9224
|
}
|
|
9094
9225
|
paths.forEach((path) => {
|
|
9095
|
-
let matches =
|
|
9226
|
+
let matches = matchRoutesImpl(
|
|
9227
|
+
router.routes,
|
|
9228
|
+
path,
|
|
9229
|
+
router.basename || "/",
|
|
9230
|
+
false,
|
|
9231
|
+
router.branches
|
|
9232
|
+
);
|
|
9096
9233
|
if (matches) {
|
|
9097
9234
|
matches.forEach((m) => routeIds.add(m.route.id));
|
|
9098
9235
|
}
|
|
@@ -9839,6 +9976,7 @@ import(${JSON.stringify(manifest.entry.module)});`;
|
|
|
9839
9976
|
href: manifest.url,
|
|
9840
9977
|
crossOrigin: scriptProps.crossOrigin,
|
|
9841
9978
|
integrity: sri[manifest.url],
|
|
9979
|
+
nonce: scriptProps.nonce,
|
|
9842
9980
|
suppressHydrationWarning: true
|
|
9843
9981
|
}
|
|
9844
9982
|
) : null, /* @__PURE__ */ React8.createElement(
|
|
@@ -9848,6 +9986,7 @@ import(${JSON.stringify(manifest.entry.module)});`;
|
|
|
9848
9986
|
href: manifest.entry.module,
|
|
9849
9987
|
crossOrigin: scriptProps.crossOrigin,
|
|
9850
9988
|
integrity: sri[manifest.entry.module],
|
|
9989
|
+
nonce: scriptProps.nonce,
|
|
9851
9990
|
suppressHydrationWarning: true
|
|
9852
9991
|
}
|
|
9853
9992
|
), preloads.map((path) => /* @__PURE__ */ React8.createElement(
|
|
@@ -9858,6 +9997,7 @@ import(${JSON.stringify(manifest.entry.module)});`;
|
|
|
9858
9997
|
href: path,
|
|
9859
9998
|
crossOrigin: scriptProps.crossOrigin,
|
|
9860
9999
|
integrity: sri[path],
|
|
10000
|
+
nonce: scriptProps.nonce,
|
|
9861
10001
|
suppressHydrationWarning: true
|
|
9862
10002
|
}
|
|
9863
10003
|
)), initialScripts);
|
|
@@ -9980,7 +10120,7 @@ var isBrowser2 = typeof window !== "undefined" && typeof window.document !== "un
|
|
|
9980
10120
|
try {
|
|
9981
10121
|
if (isBrowser2) {
|
|
9982
10122
|
window.__reactRouterVersion = // @ts-expect-error
|
|
9983
|
-
"7.
|
|
10123
|
+
"7.15.0";
|
|
9984
10124
|
}
|
|
9985
10125
|
} catch (e) {
|
|
9986
10126
|
}
|
|
@@ -9997,7 +10137,7 @@ function createBrowserRouter(routes, opts) {
|
|
|
9997
10137
|
dataStrategy: opts?.dataStrategy,
|
|
9998
10138
|
patchRoutesOnNavigation: opts?.patchRoutesOnNavigation,
|
|
9999
10139
|
window: opts?.window,
|
|
10000
|
-
|
|
10140
|
+
instrumentations: opts?.instrumentations
|
|
10001
10141
|
}).initialize();
|
|
10002
10142
|
}
|
|
10003
10143
|
function createHashRouter(routes, opts) {
|
|
@@ -10013,7 +10153,7 @@ function createHashRouter(routes, opts) {
|
|
|
10013
10153
|
dataStrategy: opts?.dataStrategy,
|
|
10014
10154
|
patchRoutesOnNavigation: opts?.patchRoutesOnNavigation,
|
|
10015
10155
|
window: opts?.window,
|
|
10016
|
-
|
|
10156
|
+
instrumentations: opts?.instrumentations
|
|
10017
10157
|
}).initialize();
|
|
10018
10158
|
}
|
|
10019
10159
|
function parseHydrationData() {
|
|
@@ -10064,7 +10204,7 @@ function deserializeErrors(errors) {
|
|
|
10064
10204
|
function BrowserRouter({
|
|
10065
10205
|
basename,
|
|
10066
10206
|
children,
|
|
10067
|
-
|
|
10207
|
+
useTransitions,
|
|
10068
10208
|
window: window2
|
|
10069
10209
|
}) {
|
|
10070
10210
|
let historyRef = React10.useRef();
|
|
@@ -10078,13 +10218,13 @@ function BrowserRouter({
|
|
|
10078
10218
|
});
|
|
10079
10219
|
let setState = React10.useCallback(
|
|
10080
10220
|
(newState) => {
|
|
10081
|
-
if (
|
|
10221
|
+
if (useTransitions === false) {
|
|
10082
10222
|
setStateImpl(newState);
|
|
10083
10223
|
} else {
|
|
10084
10224
|
React10.startTransition(() => setStateImpl(newState));
|
|
10085
10225
|
}
|
|
10086
10226
|
},
|
|
10087
|
-
[
|
|
10227
|
+
[useTransitions]
|
|
10088
10228
|
);
|
|
10089
10229
|
React10.useLayoutEffect(() => history.listen(setState), [history, setState]);
|
|
10090
10230
|
return /* @__PURE__ */ React10.createElement(
|
|
@@ -10095,14 +10235,14 @@ function BrowserRouter({
|
|
|
10095
10235
|
location: state.location,
|
|
10096
10236
|
navigationType: state.action,
|
|
10097
10237
|
navigator: history,
|
|
10098
|
-
|
|
10238
|
+
useTransitions
|
|
10099
10239
|
}
|
|
10100
10240
|
);
|
|
10101
10241
|
}
|
|
10102
10242
|
function HashRouter({
|
|
10103
10243
|
basename,
|
|
10104
10244
|
children,
|
|
10105
|
-
|
|
10245
|
+
useTransitions,
|
|
10106
10246
|
window: window2
|
|
10107
10247
|
}) {
|
|
10108
10248
|
let historyRef = React10.useRef();
|
|
@@ -10116,13 +10256,13 @@ function HashRouter({
|
|
|
10116
10256
|
});
|
|
10117
10257
|
let setState = React10.useCallback(
|
|
10118
10258
|
(newState) => {
|
|
10119
|
-
if (
|
|
10259
|
+
if (useTransitions === false) {
|
|
10120
10260
|
setStateImpl(newState);
|
|
10121
10261
|
} else {
|
|
10122
10262
|
React10.startTransition(() => setStateImpl(newState));
|
|
10123
10263
|
}
|
|
10124
10264
|
},
|
|
10125
|
-
[
|
|
10265
|
+
[useTransitions]
|
|
10126
10266
|
);
|
|
10127
10267
|
React10.useLayoutEffect(() => history.listen(setState), [history, setState]);
|
|
10128
10268
|
return /* @__PURE__ */ React10.createElement(
|
|
@@ -10133,7 +10273,7 @@ function HashRouter({
|
|
|
10133
10273
|
location: state.location,
|
|
10134
10274
|
navigationType: state.action,
|
|
10135
10275
|
navigator: history,
|
|
10136
|
-
|
|
10276
|
+
useTransitions
|
|
10137
10277
|
}
|
|
10138
10278
|
);
|
|
10139
10279
|
}
|
|
@@ -10141,7 +10281,7 @@ function HistoryRouter({
|
|
|
10141
10281
|
basename,
|
|
10142
10282
|
children,
|
|
10143
10283
|
history,
|
|
10144
|
-
|
|
10284
|
+
useTransitions
|
|
10145
10285
|
}) {
|
|
10146
10286
|
let [state, setStateImpl] = React10.useState({
|
|
10147
10287
|
action: history.action,
|
|
@@ -10149,13 +10289,13 @@ function HistoryRouter({
|
|
|
10149
10289
|
});
|
|
10150
10290
|
let setState = React10.useCallback(
|
|
10151
10291
|
(newState) => {
|
|
10152
|
-
if (
|
|
10292
|
+
if (useTransitions === false) {
|
|
10153
10293
|
setStateImpl(newState);
|
|
10154
10294
|
} else {
|
|
10155
10295
|
React10.startTransition(() => setStateImpl(newState));
|
|
10156
10296
|
}
|
|
10157
10297
|
},
|
|
10158
|
-
[
|
|
10298
|
+
[useTransitions]
|
|
10159
10299
|
);
|
|
10160
10300
|
React10.useLayoutEffect(() => history.listen(setState), [history, setState]);
|
|
10161
10301
|
return /* @__PURE__ */ React10.createElement(
|
|
@@ -10166,7 +10306,7 @@ function HistoryRouter({
|
|
|
10166
10306
|
location: state.location,
|
|
10167
10307
|
navigationType: state.action,
|
|
10168
10308
|
navigator: history,
|
|
10169
|
-
|
|
10309
|
+
useTransitions
|
|
10170
10310
|
}
|
|
10171
10311
|
);
|
|
10172
10312
|
}
|
|
@@ -10180,27 +10320,27 @@ var Link = React10.forwardRef(
|
|
|
10180
10320
|
relative,
|
|
10181
10321
|
reloadDocument,
|
|
10182
10322
|
replace: replace2,
|
|
10183
|
-
|
|
10323
|
+
mask,
|
|
10184
10324
|
state,
|
|
10185
10325
|
target,
|
|
10186
10326
|
to,
|
|
10187
10327
|
preventScrollReset,
|
|
10188
10328
|
viewTransition,
|
|
10189
|
-
|
|
10329
|
+
defaultShouldRevalidate,
|
|
10190
10330
|
...rest
|
|
10191
10331
|
}, forwardedRef) {
|
|
10192
|
-
let { basename, navigator,
|
|
10332
|
+
let { basename, navigator, useTransitions } = React10.useContext(NavigationContext);
|
|
10193
10333
|
let isAbsolute = typeof to === "string" && ABSOLUTE_URL_REGEX2.test(to);
|
|
10194
10334
|
let parsed = parseToInfo(to, basename);
|
|
10195
10335
|
to = parsed.to;
|
|
10196
10336
|
let href = useHref(to, { relative });
|
|
10197
10337
|
let location = useLocation();
|
|
10198
10338
|
let maskedHref = null;
|
|
10199
|
-
if (
|
|
10339
|
+
if (mask) {
|
|
10200
10340
|
let resolved = resolveTo(
|
|
10201
|
-
|
|
10341
|
+
mask,
|
|
10202
10342
|
[],
|
|
10203
|
-
location.
|
|
10343
|
+
location.mask ? location.mask.pathname : "/",
|
|
10204
10344
|
true
|
|
10205
10345
|
);
|
|
10206
10346
|
if (basename !== "/") {
|
|
@@ -10214,14 +10354,14 @@ var Link = React10.forwardRef(
|
|
|
10214
10354
|
);
|
|
10215
10355
|
let internalOnClick = useLinkClickHandler(to, {
|
|
10216
10356
|
replace: replace2,
|
|
10217
|
-
|
|
10357
|
+
mask,
|
|
10218
10358
|
state,
|
|
10219
10359
|
target,
|
|
10220
10360
|
preventScrollReset,
|
|
10221
10361
|
relative,
|
|
10222
10362
|
viewTransition,
|
|
10223
|
-
|
|
10224
|
-
|
|
10363
|
+
defaultShouldRevalidate,
|
|
10364
|
+
useTransitions
|
|
10225
10365
|
});
|
|
10226
10366
|
function handleClick(event) {
|
|
10227
10367
|
if (onClick) onClick(event);
|
|
@@ -10330,10 +10470,10 @@ var Form = React10.forwardRef(
|
|
|
10330
10470
|
relative,
|
|
10331
10471
|
preventScrollReset,
|
|
10332
10472
|
viewTransition,
|
|
10333
|
-
|
|
10473
|
+
defaultShouldRevalidate,
|
|
10334
10474
|
...props
|
|
10335
10475
|
}, forwardedRef) => {
|
|
10336
|
-
let {
|
|
10476
|
+
let { useTransitions } = React10.useContext(NavigationContext);
|
|
10337
10477
|
let submit = useSubmit();
|
|
10338
10478
|
let formAction = useFormAction(action, { relative });
|
|
10339
10479
|
let formMethod = method.toLowerCase() === "get" ? "get" : "post";
|
|
@@ -10353,9 +10493,9 @@ var Form = React10.forwardRef(
|
|
|
10353
10493
|
relative,
|
|
10354
10494
|
preventScrollReset,
|
|
10355
10495
|
viewTransition,
|
|
10356
|
-
|
|
10496
|
+
defaultShouldRevalidate
|
|
10357
10497
|
});
|
|
10358
|
-
if (
|
|
10498
|
+
if (useTransitions && navigate !== false) {
|
|
10359
10499
|
React10.startTransition(() => doSubmit());
|
|
10360
10500
|
} else {
|
|
10361
10501
|
doSubmit();
|
|
@@ -10449,13 +10589,13 @@ function useDataRouterState2(hookName) {
|
|
|
10449
10589
|
function useLinkClickHandler(to, {
|
|
10450
10590
|
target,
|
|
10451
10591
|
replace: replaceProp,
|
|
10452
|
-
|
|
10592
|
+
mask,
|
|
10453
10593
|
state,
|
|
10454
10594
|
preventScrollReset,
|
|
10455
10595
|
relative,
|
|
10456
10596
|
viewTransition,
|
|
10457
|
-
|
|
10458
|
-
|
|
10597
|
+
defaultShouldRevalidate,
|
|
10598
|
+
useTransitions
|
|
10459
10599
|
} = {}) {
|
|
10460
10600
|
let navigate = useNavigate();
|
|
10461
10601
|
let location = useLocation();
|
|
@@ -10467,14 +10607,14 @@ function useLinkClickHandler(to, {
|
|
|
10467
10607
|
let replace2 = replaceProp !== void 0 ? replaceProp : createPath(location) === createPath(path);
|
|
10468
10608
|
let doNavigate = () => navigate(to, {
|
|
10469
10609
|
replace: replace2,
|
|
10470
|
-
|
|
10610
|
+
mask,
|
|
10471
10611
|
state,
|
|
10472
10612
|
preventScrollReset,
|
|
10473
10613
|
relative,
|
|
10474
10614
|
viewTransition,
|
|
10475
|
-
|
|
10615
|
+
defaultShouldRevalidate
|
|
10476
10616
|
});
|
|
10477
|
-
if (
|
|
10617
|
+
if (useTransitions) {
|
|
10478
10618
|
React10.startTransition(() => doNavigate());
|
|
10479
10619
|
} else {
|
|
10480
10620
|
doNavigate();
|
|
@@ -10486,15 +10626,15 @@ function useLinkClickHandler(to, {
|
|
|
10486
10626
|
navigate,
|
|
10487
10627
|
path,
|
|
10488
10628
|
replaceProp,
|
|
10489
|
-
|
|
10629
|
+
mask,
|
|
10490
10630
|
state,
|
|
10491
10631
|
target,
|
|
10492
10632
|
to,
|
|
10493
10633
|
preventScrollReset,
|
|
10494
10634
|
relative,
|
|
10495
10635
|
viewTransition,
|
|
10496
|
-
|
|
10497
|
-
|
|
10636
|
+
defaultShouldRevalidate,
|
|
10637
|
+
useTransitions
|
|
10498
10638
|
]
|
|
10499
10639
|
);
|
|
10500
10640
|
}
|
|
@@ -10548,7 +10688,7 @@ function useSubmit() {
|
|
|
10548
10688
|
if (options.navigate === false) {
|
|
10549
10689
|
let key = options.fetcherKey || getUniqueFetcherId();
|
|
10550
10690
|
await routerFetch(key, currentRouteId, options.action || action, {
|
|
10551
|
-
|
|
10691
|
+
defaultShouldRevalidate: options.defaultShouldRevalidate,
|
|
10552
10692
|
preventScrollReset: options.preventScrollReset,
|
|
10553
10693
|
formData,
|
|
10554
10694
|
body,
|
|
@@ -10558,7 +10698,7 @@ function useSubmit() {
|
|
|
10558
10698
|
});
|
|
10559
10699
|
} else {
|
|
10560
10700
|
await routerNavigate(options.action || action, {
|
|
10561
|
-
|
|
10701
|
+
defaultShouldRevalidate: options.defaultShouldRevalidate,
|
|
10562
10702
|
preventScrollReset: options.preventScrollReset,
|
|
10563
10703
|
formData,
|
|
10564
10704
|
body,
|
|
@@ -10868,7 +11008,7 @@ function StaticRouter({
|
|
|
10868
11008
|
hash: locationProp.hash || "",
|
|
10869
11009
|
state: locationProp.state != null ? locationProp.state : null,
|
|
10870
11010
|
key: locationProp.key || "default",
|
|
10871
|
-
|
|
11011
|
+
mask: void 0
|
|
10872
11012
|
};
|
|
10873
11013
|
let staticNavigator = getStatelessNavigator();
|
|
10874
11014
|
return /* @__PURE__ */ React11.createElement(
|
|
@@ -10880,7 +11020,7 @@ function StaticRouter({
|
|
|
10880
11020
|
navigationType: action,
|
|
10881
11021
|
navigator: staticNavigator,
|
|
10882
11022
|
static: true,
|
|
10883
|
-
|
|
11023
|
+
useTransitions: false
|
|
10884
11024
|
}
|
|
10885
11025
|
);
|
|
10886
11026
|
}
|
|
@@ -10921,11 +11061,12 @@ function StaticRouterProvider({
|
|
|
10921
11061
|
navigationType: state.historyAction,
|
|
10922
11062
|
navigator: dataRouterContext.navigator,
|
|
10923
11063
|
static: dataRouterContext.static,
|
|
10924
|
-
|
|
11064
|
+
useTransitions: false
|
|
10925
11065
|
},
|
|
10926
11066
|
/* @__PURE__ */ React11.createElement(
|
|
10927
|
-
|
|
11067
|
+
DataRoutes2,
|
|
10928
11068
|
{
|
|
11069
|
+
manifest: router.manifest,
|
|
10929
11070
|
routes: router.routes,
|
|
10930
11071
|
future: router.future,
|
|
10931
11072
|
state,
|
|
@@ -11024,7 +11165,7 @@ function createStaticRouter(routes, context, opts = {}) {
|
|
|
11024
11165
|
get future() {
|
|
11025
11166
|
return {
|
|
11026
11167
|
v8_middleware: false,
|
|
11027
|
-
|
|
11168
|
+
v8_passThroughRequests: false,
|
|
11028
11169
|
...opts?.future
|
|
11029
11170
|
};
|
|
11030
11171
|
},
|
|
@@ -11049,6 +11190,12 @@ function createStaticRouter(routes, context, opts = {}) {
|
|
|
11049
11190
|
get routes() {
|
|
11050
11191
|
return dataRoutes;
|
|
11051
11192
|
},
|
|
11193
|
+
get branches() {
|
|
11194
|
+
return opts.branches;
|
|
11195
|
+
},
|
|
11196
|
+
get manifest() {
|
|
11197
|
+
return manifest;
|
|
11198
|
+
},
|
|
11052
11199
|
get window() {
|
|
11053
11200
|
return void 0;
|
|
11054
11201
|
},
|
|
@@ -11129,6 +11276,7 @@ export {
|
|
|
11129
11276
|
RouterContextProvider,
|
|
11130
11277
|
convertRoutesToDataRoutes,
|
|
11131
11278
|
matchRoutes,
|
|
11279
|
+
matchRoutesImpl,
|
|
11132
11280
|
generatePath,
|
|
11133
11281
|
matchPath,
|
|
11134
11282
|
stripBasename,
|
|
@@ -11226,6 +11374,7 @@ export {
|
|
|
11226
11374
|
noActionDefinedError,
|
|
11227
11375
|
createClientRoutes,
|
|
11228
11376
|
shouldHydrateRouteLoader,
|
|
11377
|
+
URL_LIMIT,
|
|
11229
11378
|
getPatchRoutesOnNavigationFunction,
|
|
11230
11379
|
useFogOFWarDiscovery,
|
|
11231
11380
|
getManifestPath,
|