react-router 7.14.2 → 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 +59 -0
- package/dist/development/{browser-I6n6wVSO.d.mts → browser-CRsXgNrY.d.mts} +2 -2
- package/dist/{production/browser-I6n6wVSO.d.mts → development/browser-wDl1FZEL.d.ts} +2 -2
- package/dist/{production/chunk-PQL4HLVQ.js → development/chunk-2D5H3HU3.js} +7 -7
- package/dist/development/{chunk-EVOBXE3Y.mjs → chunk-5KNZJZUH.mjs} +341 -208
- package/dist/development/{chunk-ZZNWZ5Q3.js → chunk-AM3XM4LS.js} +331 -205
- package/dist/development/{chunk-YQSHRJWW.mjs → chunk-RMD3H4O3.mjs} +80 -61
- package/dist/development/{chunk-YZKCRDTN.js → chunk-Z5YQYACE.js} +146 -139
- package/dist/{production/context-DGGUoDIu.d.mts → development/context-BQs41HrG.d.mts} +94 -42
- package/dist/development/{routeModules-7rtk67cd.d.ts → data-BVUf681J.d.mts} +64 -46
- package/dist/development/{routeModules-BW4a8k3I.d.mts → data-BqZ2x964.d.ts} +64 -46
- package/dist/development/dom-export.d.mts +8 -8
- package/dist/development/dom-export.d.ts +8 -8
- package/dist/development/dom-export.js +37 -40
- package/dist/development/dom-export.mjs +12 -15
- package/dist/development/{index-react-server-client-BBd0A0TL.d.ts → index-react-server-client-CSv-KZBk.d.ts} +123 -121
- package/dist/{production/index-react-server-client-BjhKIe3u.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 +10 -10
- package/dist/development/index.d.ts +10 -10
- package/dist/development/index.js +173 -154
- package/dist/development/index.mjs +3 -3
- package/dist/{production/instrumentation-g0dG8UL0.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-DcBltf5q.d.ts → register-Bsscfj79.d.ts} +1 -1
- package/dist/{production/register-DcBltf5q.d.ts → development/register-Df8okEea.d.mts} +1 -1
- package/dist/production/{browser-C-UvoYvi.d.ts → browser-CRsXgNrY.d.mts} +2 -2
- package/dist/{development/browser-C-UvoYvi.d.ts → production/browser-wDl1FZEL.d.ts} +2 -2
- package/dist/production/{chunk-2WLZNCK5.mjs → chunk-23ZOHYE5.mjs} +80 -61
- package/dist/{development/chunk-PZFPF4X7.js → production/chunk-7YXKJMLN.js} +7 -7
- package/dist/production/{chunk-LK6U7ULH.mjs → chunk-GM3PW4GX.mjs} +341 -208
- package/dist/production/{chunk-X5SKXJ4A.js → chunk-LCJTIOKZ.js} +331 -205
- package/dist/production/{chunk-UJQ4OJF4.js → chunk-YBQJ3ABE.js} +146 -139
- package/dist/{development/context-DGGUoDIu.d.mts → production/context-BQs41HrG.d.mts} +94 -42
- package/dist/production/{routeModules-7rtk67cd.d.ts → data-BVUf681J.d.mts} +64 -46
- package/dist/production/{routeModules-BW4a8k3I.d.mts → data-BqZ2x964.d.ts} +64 -46
- package/dist/production/dom-export.d.mts +8 -8
- package/dist/production/dom-export.d.ts +8 -8
- package/dist/production/dom-export.js +37 -40
- package/dist/production/dom-export.mjs +12 -15
- package/dist/production/{index-react-server-client-BBd0A0TL.d.ts → index-react-server-client-CSv-KZBk.d.ts} +123 -121
- package/dist/{development/index-react-server-client-BjhKIe3u.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 +10 -10
- package/dist/production/index.d.ts +10 -10
- package/dist/production/index.js +173 -154
- package/dist/production/index.mjs +3 -3
- package/dist/{development/instrumentation-g0dG8UL0.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-D9d2sMQ7.d.mts → production/register-Bsscfj79.d.ts} +1 -1
- package/dist/production/{register-D9d2sMQ7.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 = {
|
|
@@ -1252,11 +1257,11 @@ async function recurseRight(impls, info, handler, index) {
|
|
|
1252
1257
|
};
|
|
1253
1258
|
}
|
|
1254
1259
|
function getHandlerInfo(args) {
|
|
1255
|
-
let { request, context, params,
|
|
1260
|
+
let { request, context, params, pattern } = args;
|
|
1256
1261
|
return {
|
|
1257
1262
|
request: getReadonlyRequest(request),
|
|
1258
1263
|
params: { ...params },
|
|
1259
|
-
|
|
1264
|
+
pattern,
|
|
1260
1265
|
context: getReadonlyContext(context)
|
|
1261
1266
|
};
|
|
1262
1267
|
}
|
|
@@ -1346,6 +1351,55 @@ var defaultMapRouteProperties = (route) => ({
|
|
|
1346
1351
|
});
|
|
1347
1352
|
var TRANSITIONS_STORAGE_KEY = "remix-router-transitions";
|
|
1348
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();
|
|
1349
1403
|
function createRouter(init) {
|
|
1350
1404
|
const routerWindow = init.window ? init.window : typeof window !== "undefined" ? window : void 0;
|
|
1351
1405
|
const isBrowser3 = typeof routerWindow !== "undefined" && typeof routerWindow.document !== "undefined" && typeof routerWindow.document.createElement !== "undefined";
|
|
@@ -1356,8 +1410,8 @@ function createRouter(init) {
|
|
|
1356
1410
|
let hydrationRouteProperties2 = init.hydrationRouteProperties || [];
|
|
1357
1411
|
let _mapRouteProperties = init.mapRouteProperties || defaultMapRouteProperties;
|
|
1358
1412
|
let mapRouteProperties2 = _mapRouteProperties;
|
|
1359
|
-
if (init.
|
|
1360
|
-
let instrumentations = init.
|
|
1413
|
+
if (init.instrumentations) {
|
|
1414
|
+
let instrumentations = init.instrumentations;
|
|
1361
1415
|
mapRouteProperties2 = (route) => {
|
|
1362
1416
|
return {
|
|
1363
1417
|
..._mapRouteProperties(route),
|
|
@@ -1369,20 +1423,20 @@ function createRouter(init) {
|
|
|
1369
1423
|
};
|
|
1370
1424
|
}
|
|
1371
1425
|
let manifest = {};
|
|
1372
|
-
let dataRoutes =
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1426
|
+
let dataRoutes = new DataRoutes(
|
|
1427
|
+
convertRoutesToDataRoutes(
|
|
1428
|
+
init.routes,
|
|
1429
|
+
mapRouteProperties2,
|
|
1430
|
+
void 0,
|
|
1431
|
+
manifest
|
|
1432
|
+
)
|
|
1377
1433
|
);
|
|
1378
|
-
let inFlightDataRoutes;
|
|
1379
1434
|
let basename = init.basename || "/";
|
|
1380
1435
|
if (!basename.startsWith("/")) {
|
|
1381
1436
|
basename = `/${basename}`;
|
|
1382
1437
|
}
|
|
1383
1438
|
let dataStrategyImpl = init.dataStrategy || defaultDataStrategyWithMiddleware;
|
|
1384
1439
|
let future = {
|
|
1385
|
-
unstable_passThroughRequests: false,
|
|
1386
1440
|
...init.future
|
|
1387
1441
|
};
|
|
1388
1442
|
let unlistenHistory = null;
|
|
@@ -1391,7 +1445,13 @@ function createRouter(init) {
|
|
|
1391
1445
|
let getScrollRestorationKey2 = null;
|
|
1392
1446
|
let getScrollPosition = null;
|
|
1393
1447
|
let initialScrollRestored = init.hydrationData != null;
|
|
1394
|
-
let initialMatches =
|
|
1448
|
+
let initialMatches = matchRoutesImpl(
|
|
1449
|
+
dataRoutes.activeRoutes,
|
|
1450
|
+
init.history.location,
|
|
1451
|
+
basename,
|
|
1452
|
+
false,
|
|
1453
|
+
dataRoutes.branches
|
|
1454
|
+
);
|
|
1395
1455
|
let initialMatchesIsFOW = false;
|
|
1396
1456
|
let initialErrors = null;
|
|
1397
1457
|
let initialized;
|
|
@@ -1400,7 +1460,7 @@ function createRouter(init) {
|
|
|
1400
1460
|
let error = getInternalRouterError(404, {
|
|
1401
1461
|
pathname: init.history.location.pathname
|
|
1402
1462
|
});
|
|
1403
|
-
let { matches, route } = getShortCircuitMatches(dataRoutes);
|
|
1463
|
+
let { matches, route } = getShortCircuitMatches(dataRoutes.activeRoutes);
|
|
1404
1464
|
initialized = true;
|
|
1405
1465
|
renderFallback = !initialized;
|
|
1406
1466
|
initialMatches = matches;
|
|
@@ -1409,7 +1469,7 @@ function createRouter(init) {
|
|
|
1409
1469
|
if (initialMatches && !init.hydrationData) {
|
|
1410
1470
|
let fogOfWar = checkFogOfWar(
|
|
1411
1471
|
initialMatches,
|
|
1412
|
-
dataRoutes,
|
|
1472
|
+
dataRoutes.activeRoutes,
|
|
1413
1473
|
init.history.location.pathname
|
|
1414
1474
|
);
|
|
1415
1475
|
if (fogOfWar.active) {
|
|
@@ -1422,7 +1482,7 @@ function createRouter(init) {
|
|
|
1422
1482
|
initialMatches = [];
|
|
1423
1483
|
let fogOfWar = checkFogOfWar(
|
|
1424
1484
|
null,
|
|
1425
|
-
dataRoutes,
|
|
1485
|
+
dataRoutes.activeRoutes,
|
|
1426
1486
|
init.history.location.pathname
|
|
1427
1487
|
);
|
|
1428
1488
|
if (fogOfWar.active && fogOfWar.matches) {
|
|
@@ -1641,10 +1701,7 @@ function createRouter(init) {
|
|
|
1641
1701
|
}
|
|
1642
1702
|
let restoreScrollPosition = isUninterruptedRevalidation ? false : getSavedScrollPosition(location, newState.matches || state.matches);
|
|
1643
1703
|
let preventScrollReset = pendingPreventScrollReset === true || state.navigation.formMethod != null && isMutationMethod(state.navigation.formMethod) && location.state?._isRedirect !== true;
|
|
1644
|
-
|
|
1645
|
-
dataRoutes = inFlightDataRoutes;
|
|
1646
|
-
inFlightDataRoutes = void 0;
|
|
1647
|
-
}
|
|
1704
|
+
dataRoutes.commitHmrRoutes();
|
|
1648
1705
|
if (isUninterruptedRevalidation) {
|
|
1649
1706
|
} else if (pendingAction === "POP" /* Pop */) {
|
|
1650
1707
|
} else if (pendingAction === "PUSH" /* Push */) {
|
|
@@ -1735,10 +1792,10 @@ function createRouter(init) {
|
|
|
1735
1792
|
opts
|
|
1736
1793
|
);
|
|
1737
1794
|
let maskPath;
|
|
1738
|
-
if (opts?.
|
|
1739
|
-
let partialPath = typeof opts.
|
|
1740
|
-
...state.location.
|
|
1741
|
-
...opts.
|
|
1795
|
+
if (opts?.mask) {
|
|
1796
|
+
let partialPath = typeof opts.mask === "string" ? parsePath(opts.mask) : {
|
|
1797
|
+
...state.location.mask,
|
|
1798
|
+
...opts.mask
|
|
1742
1799
|
};
|
|
1743
1800
|
maskPath = {
|
|
1744
1801
|
pathname: "",
|
|
@@ -1804,7 +1861,7 @@ function createRouter(init) {
|
|
|
1804
1861
|
replace: opts && opts.replace,
|
|
1805
1862
|
enableViewTransition: opts && opts.viewTransition,
|
|
1806
1863
|
flushSync,
|
|
1807
|
-
callSiteDefaultShouldRevalidate: opts && opts.
|
|
1864
|
+
callSiteDefaultShouldRevalidate: opts && opts.defaultShouldRevalidate
|
|
1808
1865
|
});
|
|
1809
1866
|
}
|
|
1810
1867
|
function revalidate() {
|
|
@@ -1842,12 +1899,18 @@ function createRouter(init) {
|
|
|
1842
1899
|
saveScrollPosition(state.location, state.matches);
|
|
1843
1900
|
pendingPreventScrollReset = (opts && opts.preventScrollReset) === true;
|
|
1844
1901
|
pendingViewTransitionEnabled = (opts && opts.enableViewTransition) === true;
|
|
1845
|
-
let routesToUse =
|
|
1902
|
+
let routesToUse = dataRoutes.activeRoutes;
|
|
1846
1903
|
let loadingNavigation = opts && opts.overrideNavigation;
|
|
1847
1904
|
let matches = opts?.initialHydration && state.matches && state.matches.length > 0 && !initialMatchesIsFOW ? (
|
|
1848
1905
|
// `matchRoutes()` has already been called if we're in here via `router.initialize()`
|
|
1849
1906
|
state.matches
|
|
1850
|
-
) :
|
|
1907
|
+
) : matchRoutesImpl(
|
|
1908
|
+
routesToUse,
|
|
1909
|
+
location,
|
|
1910
|
+
basename,
|
|
1911
|
+
false,
|
|
1912
|
+
dataRoutes.branches
|
|
1913
|
+
);
|
|
1851
1914
|
let flushSync = (opts && opts.flushSync) === true;
|
|
1852
1915
|
if (matches && state.initialized && !isRevalidationRequired && isHashChangeOnly(state.location, location) && !(opts && opts.submission && isMutationMethod(opts.submission.formMethod))) {
|
|
1853
1916
|
completeNavigation(location, { matches }, { flushSync });
|
|
@@ -1972,7 +2035,9 @@ function createRouter(init) {
|
|
|
1972
2035
|
return { shortCircuited: true };
|
|
1973
2036
|
} else if (discoverResult.type === "error") {
|
|
1974
2037
|
if (discoverResult.partialMatches.length === 0) {
|
|
1975
|
-
let { matches: matches2, route } = getShortCircuitMatches(
|
|
2038
|
+
let { matches: matches2, route } = getShortCircuitMatches(
|
|
2039
|
+
dataRoutes.activeRoutes
|
|
2040
|
+
);
|
|
1976
2041
|
return {
|
|
1977
2042
|
matches: matches2,
|
|
1978
2043
|
pendingActionResult: [
|
|
@@ -2119,7 +2184,9 @@ function createRouter(init) {
|
|
|
2119
2184
|
return { shortCircuited: true };
|
|
2120
2185
|
} else if (discoverResult.type === "error") {
|
|
2121
2186
|
if (discoverResult.partialMatches.length === 0) {
|
|
2122
|
-
let { matches: matches2, route } = getShortCircuitMatches(
|
|
2187
|
+
let { matches: matches2, route } = getShortCircuitMatches(
|
|
2188
|
+
dataRoutes.activeRoutes
|
|
2189
|
+
);
|
|
2123
2190
|
return {
|
|
2124
2191
|
matches: matches2,
|
|
2125
2192
|
loaderData: {},
|
|
@@ -2151,7 +2218,7 @@ function createRouter(init) {
|
|
|
2151
2218
|
matches = discoverResult.matches;
|
|
2152
2219
|
}
|
|
2153
2220
|
}
|
|
2154
|
-
let routesToUse =
|
|
2221
|
+
let routesToUse = dataRoutes.activeRoutes;
|
|
2155
2222
|
let { dsMatches, revalidatingFetchers } = getMatchesToLoad(
|
|
2156
2223
|
request,
|
|
2157
2224
|
scopedContext,
|
|
@@ -2172,6 +2239,7 @@ function createRouter(init) {
|
|
|
2172
2239
|
routesToUse,
|
|
2173
2240
|
basename,
|
|
2174
2241
|
init.patchRoutesOnNavigation != null,
|
|
2242
|
+
dataRoutes.branches,
|
|
2175
2243
|
pendingActionResult,
|
|
2176
2244
|
callSiteDefaultShouldRevalidate
|
|
2177
2245
|
);
|
|
@@ -2301,7 +2369,7 @@ function createRouter(init) {
|
|
|
2301
2369
|
async function fetch2(key, routeId, href, opts) {
|
|
2302
2370
|
abortFetcher(key);
|
|
2303
2371
|
let flushSync = (opts && opts.flushSync) === true;
|
|
2304
|
-
let routesToUse =
|
|
2372
|
+
let routesToUse = dataRoutes.activeRoutes;
|
|
2305
2373
|
let normalizedPath = normalizeTo(
|
|
2306
2374
|
state.location,
|
|
2307
2375
|
state.matches,
|
|
@@ -2310,7 +2378,13 @@ function createRouter(init) {
|
|
|
2310
2378
|
routeId,
|
|
2311
2379
|
opts?.relative
|
|
2312
2380
|
);
|
|
2313
|
-
let matches =
|
|
2381
|
+
let matches = matchRoutesImpl(
|
|
2382
|
+
routesToUse,
|
|
2383
|
+
normalizedPath,
|
|
2384
|
+
basename,
|
|
2385
|
+
false,
|
|
2386
|
+
dataRoutes.branches
|
|
2387
|
+
);
|
|
2314
2388
|
let fogOfWar = checkFogOfWar(matches, routesToUse, normalizedPath);
|
|
2315
2389
|
if (fogOfWar.active && fogOfWar.matches) {
|
|
2316
2390
|
matches = fogOfWar.matches;
|
|
@@ -2346,7 +2420,7 @@ function createRouter(init) {
|
|
|
2346
2420
|
flushSync,
|
|
2347
2421
|
preventScrollReset,
|
|
2348
2422
|
submission,
|
|
2349
|
-
opts && opts.
|
|
2423
|
+
opts && opts.defaultShouldRevalidate
|
|
2350
2424
|
);
|
|
2351
2425
|
return;
|
|
2352
2426
|
}
|
|
@@ -2476,8 +2550,14 @@ function createRouter(init) {
|
|
|
2476
2550
|
nextLocation,
|
|
2477
2551
|
abortController.signal
|
|
2478
2552
|
);
|
|
2479
|
-
let routesToUse =
|
|
2480
|
-
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;
|
|
2481
2561
|
invariant(matches, "Didn't find any matches after fetcher action");
|
|
2482
2562
|
let loadId = ++incrementingLoadId;
|
|
2483
2563
|
fetchReloadIds.set(key, loadId);
|
|
@@ -2503,6 +2583,7 @@ function createRouter(init) {
|
|
|
2503
2583
|
routesToUse,
|
|
2504
2584
|
basename,
|
|
2505
2585
|
init.patchRoutesOnNavigation != null,
|
|
2586
|
+
dataRoutes.branches,
|
|
2506
2587
|
[match.route.id, actionResult],
|
|
2507
2588
|
callSiteDefaultShouldRevalidate
|
|
2508
2589
|
);
|
|
@@ -3021,7 +3102,7 @@ function createRouter(init) {
|
|
|
3021
3102
|
}
|
|
3022
3103
|
function handleNavigational404(pathname) {
|
|
3023
3104
|
let error = getInternalRouterError(404, { pathname });
|
|
3024
|
-
let routesToUse =
|
|
3105
|
+
let routesToUse = dataRoutes.activeRoutes;
|
|
3025
3106
|
let { matches, route } = getShortCircuitMatches(routesToUse);
|
|
3026
3107
|
return { notFoundMatches: matches, route, error };
|
|
3027
3108
|
}
|
|
@@ -3070,12 +3151,14 @@ function createRouter(init) {
|
|
|
3070
3151
|
}
|
|
3071
3152
|
function checkFogOfWar(matches, routesToUse, pathname) {
|
|
3072
3153
|
if (init.patchRoutesOnNavigation) {
|
|
3154
|
+
let activeBranches = dataRoutes.branches;
|
|
3073
3155
|
if (!matches) {
|
|
3074
3156
|
let fogMatches = matchRoutesImpl(
|
|
3075
3157
|
routesToUse,
|
|
3076
3158
|
pathname,
|
|
3077
3159
|
basename,
|
|
3078
|
-
true
|
|
3160
|
+
true,
|
|
3161
|
+
activeBranches
|
|
3079
3162
|
);
|
|
3080
3163
|
return { active: true, matches: fogMatches || [] };
|
|
3081
3164
|
} else {
|
|
@@ -3084,7 +3167,8 @@ function createRouter(init) {
|
|
|
3084
3167
|
routesToUse,
|
|
3085
3168
|
pathname,
|
|
3086
3169
|
basename,
|
|
3087
|
-
true
|
|
3170
|
+
true,
|
|
3171
|
+
activeBranches
|
|
3088
3172
|
);
|
|
3089
3173
|
return { active: true, matches: partialMatches };
|
|
3090
3174
|
}
|
|
@@ -3098,8 +3182,6 @@ function createRouter(init) {
|
|
|
3098
3182
|
}
|
|
3099
3183
|
let partialMatches = matches;
|
|
3100
3184
|
while (true) {
|
|
3101
|
-
let isNonHMR = inFlightDataRoutes == null;
|
|
3102
|
-
let routesToUse = inFlightDataRoutes || dataRoutes;
|
|
3103
3185
|
let localManifest = manifest;
|
|
3104
3186
|
try {
|
|
3105
3187
|
await init.patchRoutesOnNavigation({
|
|
@@ -3112,7 +3194,7 @@ function createRouter(init) {
|
|
|
3112
3194
|
patchRoutesImpl(
|
|
3113
3195
|
routeId,
|
|
3114
3196
|
children,
|
|
3115
|
-
|
|
3197
|
+
dataRoutes,
|
|
3116
3198
|
localManifest,
|
|
3117
3199
|
mapRouteProperties2,
|
|
3118
3200
|
false
|
|
@@ -3121,25 +3203,29 @@ function createRouter(init) {
|
|
|
3121
3203
|
});
|
|
3122
3204
|
} catch (e) {
|
|
3123
3205
|
return { type: "error", error: e, partialMatches };
|
|
3124
|
-
} finally {
|
|
3125
|
-
if (isNonHMR && !signal.aborted) {
|
|
3126
|
-
dataRoutes = [...dataRoutes];
|
|
3127
|
-
}
|
|
3128
3206
|
}
|
|
3129
3207
|
if (signal.aborted) {
|
|
3130
3208
|
return { type: "aborted" };
|
|
3131
3209
|
}
|
|
3132
|
-
let
|
|
3210
|
+
let activeBranches = dataRoutes.branches;
|
|
3211
|
+
let newMatches = matchRoutesImpl(
|
|
3212
|
+
dataRoutes.activeRoutes,
|
|
3213
|
+
pathname,
|
|
3214
|
+
basename,
|
|
3215
|
+
false,
|
|
3216
|
+
activeBranches
|
|
3217
|
+
);
|
|
3133
3218
|
let newPartialMatches = null;
|
|
3134
3219
|
if (newMatches) {
|
|
3135
3220
|
if (Object.keys(newMatches[0].params).length === 0) {
|
|
3136
3221
|
return { type: "success", matches: newMatches };
|
|
3137
3222
|
} else {
|
|
3138
3223
|
newPartialMatches = matchRoutesImpl(
|
|
3139
|
-
|
|
3224
|
+
dataRoutes.activeRoutes,
|
|
3140
3225
|
pathname,
|
|
3141
3226
|
basename,
|
|
3142
|
-
true
|
|
3227
|
+
true,
|
|
3228
|
+
activeBranches
|
|
3143
3229
|
);
|
|
3144
3230
|
let matchedDeeper = newPartialMatches && partialMatches.length < newPartialMatches.length && compareMatches(
|
|
3145
3231
|
partialMatches,
|
|
@@ -3152,10 +3238,11 @@ function createRouter(init) {
|
|
|
3152
3238
|
}
|
|
3153
3239
|
if (!newPartialMatches) {
|
|
3154
3240
|
newPartialMatches = matchRoutesImpl(
|
|
3155
|
-
|
|
3241
|
+
dataRoutes.activeRoutes,
|
|
3156
3242
|
pathname,
|
|
3157
3243
|
basename,
|
|
3158
|
-
true
|
|
3244
|
+
true,
|
|
3245
|
+
activeBranches
|
|
3159
3246
|
);
|
|
3160
3247
|
}
|
|
3161
3248
|
if (!newPartialMatches || compareMatches(partialMatches, newPartialMatches)) {
|
|
@@ -3169,26 +3256,25 @@ function createRouter(init) {
|
|
|
3169
3256
|
}
|
|
3170
3257
|
function _internalSetRoutes(newRoutes) {
|
|
3171
3258
|
manifest = {};
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3259
|
+
dataRoutes.setHmrRoutes(
|
|
3260
|
+
convertRoutesToDataRoutes(
|
|
3261
|
+
newRoutes,
|
|
3262
|
+
mapRouteProperties2,
|
|
3263
|
+
void 0,
|
|
3264
|
+
manifest
|
|
3265
|
+
)
|
|
3177
3266
|
);
|
|
3178
3267
|
}
|
|
3179
3268
|
function patchRoutes(routeId, children, unstable_allowElementMutations = false) {
|
|
3180
|
-
let isNonHMR = inFlightDataRoutes == null;
|
|
3181
|
-
let routesToUse = inFlightDataRoutes || dataRoutes;
|
|
3182
3269
|
patchRoutesImpl(
|
|
3183
3270
|
routeId,
|
|
3184
3271
|
children,
|
|
3185
|
-
|
|
3272
|
+
dataRoutes,
|
|
3186
3273
|
manifest,
|
|
3187
3274
|
mapRouteProperties2,
|
|
3188
3275
|
unstable_allowElementMutations
|
|
3189
3276
|
);
|
|
3190
|
-
if (
|
|
3191
|
-
dataRoutes = [...dataRoutes];
|
|
3277
|
+
if (!dataRoutes.hasHMRRoutes) {
|
|
3192
3278
|
updateState({});
|
|
3193
3279
|
}
|
|
3194
3280
|
}
|
|
@@ -3203,7 +3289,13 @@ function createRouter(init) {
|
|
|
3203
3289
|
return state;
|
|
3204
3290
|
},
|
|
3205
3291
|
get routes() {
|
|
3206
|
-
return dataRoutes;
|
|
3292
|
+
return dataRoutes.stableRoutes;
|
|
3293
|
+
},
|
|
3294
|
+
get branches() {
|
|
3295
|
+
return dataRoutes.branches;
|
|
3296
|
+
},
|
|
3297
|
+
get manifest() {
|
|
3298
|
+
return manifest;
|
|
3207
3299
|
},
|
|
3208
3300
|
get window() {
|
|
3209
3301
|
return routerWindow;
|
|
@@ -3233,10 +3325,10 @@ function createRouter(init) {
|
|
|
3233
3325
|
updateState(newState);
|
|
3234
3326
|
}
|
|
3235
3327
|
};
|
|
3236
|
-
if (init.
|
|
3328
|
+
if (init.instrumentations) {
|
|
3237
3329
|
router = instrumentClientSideRouter(
|
|
3238
3330
|
router,
|
|
3239
|
-
init.
|
|
3331
|
+
init.instrumentations.map((i) => i.router).filter(Boolean)
|
|
3240
3332
|
);
|
|
3241
3333
|
}
|
|
3242
3334
|
return router;
|
|
@@ -3251,12 +3343,10 @@ function createStaticHandler(routes, opts) {
|
|
|
3251
3343
|
let _mapRouteProperties = opts?.mapRouteProperties || defaultMapRouteProperties;
|
|
3252
3344
|
let mapRouteProperties2 = _mapRouteProperties;
|
|
3253
3345
|
let future = {
|
|
3254
|
-
unstable_passThroughRequests: false,
|
|
3255
|
-
// unused in static handler
|
|
3256
3346
|
...opts?.future
|
|
3257
3347
|
};
|
|
3258
|
-
if (opts?.
|
|
3259
|
-
let instrumentations = opts.
|
|
3348
|
+
if (opts?.instrumentations) {
|
|
3349
|
+
let instrumentations = opts.instrumentations;
|
|
3260
3350
|
mapRouteProperties2 = (route) => {
|
|
3261
3351
|
return {
|
|
3262
3352
|
..._mapRouteProperties(route),
|
|
@@ -3273,6 +3363,7 @@ function createStaticHandler(routes, opts) {
|
|
|
3273
3363
|
void 0,
|
|
3274
3364
|
manifest
|
|
3275
3365
|
);
|
|
3366
|
+
let routeBranches = flattenAndRankRoutes(dataRoutes);
|
|
3276
3367
|
async function query(request, {
|
|
3277
3368
|
requestContext,
|
|
3278
3369
|
filterMatchesToLoad,
|
|
@@ -3280,12 +3371,23 @@ function createStaticHandler(routes, opts) {
|
|
|
3280
3371
|
skipRevalidation,
|
|
3281
3372
|
dataStrategy,
|
|
3282
3373
|
generateMiddlewareResponse,
|
|
3283
|
-
|
|
3374
|
+
normalizePath
|
|
3284
3375
|
} = {}) {
|
|
3285
|
-
let
|
|
3376
|
+
let normalizePathImpl = normalizePath || defaultNormalizePath;
|
|
3286
3377
|
let method = request.method;
|
|
3287
|
-
let location = createLocation(
|
|
3288
|
-
|
|
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
|
+
);
|
|
3289
3391
|
requestContext = requestContext != null ? requestContext : new RouterContextProvider();
|
|
3290
3392
|
if (!isValidMethod(method) && method !== "HEAD") {
|
|
3291
3393
|
let error = getInternalRouterError(405, { method });
|
|
@@ -3337,8 +3439,8 @@ function createStaticHandler(routes, opts) {
|
|
|
3337
3439
|
let response = await runServerMiddlewarePipeline(
|
|
3338
3440
|
{
|
|
3339
3441
|
request,
|
|
3340
|
-
|
|
3341
|
-
|
|
3442
|
+
url: createDataFunctionUrl(request, location),
|
|
3443
|
+
pattern: getRoutePattern(matches),
|
|
3342
3444
|
matches,
|
|
3343
3445
|
params: matches[0].params,
|
|
3344
3446
|
// If we're calling middleware then it must be enabled so we can cast
|
|
@@ -3455,12 +3557,23 @@ function createStaticHandler(routes, opts) {
|
|
|
3455
3557
|
requestContext,
|
|
3456
3558
|
dataStrategy,
|
|
3457
3559
|
generateMiddlewareResponse,
|
|
3458
|
-
|
|
3560
|
+
normalizePath
|
|
3459
3561
|
} = {}) {
|
|
3460
|
-
let
|
|
3562
|
+
let normalizePathImpl = normalizePath || defaultNormalizePath;
|
|
3461
3563
|
let method = request.method;
|
|
3462
|
-
let location = createLocation(
|
|
3463
|
-
|
|
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
|
+
);
|
|
3464
3577
|
requestContext = requestContext != null ? requestContext : new RouterContextProvider();
|
|
3465
3578
|
if (!isValidMethod(method) && method !== "HEAD" && method !== "OPTIONS") {
|
|
3466
3579
|
throw getInternalRouterError(405, { method });
|
|
@@ -3485,8 +3598,8 @@ function createStaticHandler(routes, opts) {
|
|
|
3485
3598
|
let response = await runServerMiddlewarePipeline(
|
|
3486
3599
|
{
|
|
3487
3600
|
request,
|
|
3488
|
-
|
|
3489
|
-
|
|
3601
|
+
url: createDataFunctionUrl(request, location),
|
|
3602
|
+
pattern: getRoutePattern(matches),
|
|
3490
3603
|
matches,
|
|
3491
3604
|
params: matches[0].params,
|
|
3492
3605
|
// If we're calling middleware then it must be enabled so we can cast
|
|
@@ -3872,6 +3985,7 @@ function createStaticHandler(routes, opts) {
|
|
|
3872
3985
|
}
|
|
3873
3986
|
return {
|
|
3874
3987
|
dataRoutes,
|
|
3988
|
+
_internalRouteBranches: routeBranches,
|
|
3875
3989
|
query,
|
|
3876
3990
|
queryRoute
|
|
3877
3991
|
};
|
|
@@ -4057,7 +4171,7 @@ function normalizeNavigateOptions(isFetcher, path, opts) {
|
|
|
4057
4171
|
parsedPath.search = `?${searchParams}`;
|
|
4058
4172
|
return { path: createPath(parsedPath), submission };
|
|
4059
4173
|
}
|
|
4060
|
-
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) {
|
|
4061
4175
|
let actionResult = pendingActionResult ? isErrorResult(pendingActionResult[1]) ? pendingActionResult[1].error : pendingActionResult[1].data : void 0;
|
|
4062
4176
|
let currentUrl = history.createURL(state.location);
|
|
4063
4177
|
let nextUrl = history.createURL(location);
|
|
@@ -4153,7 +4267,13 @@ function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest,
|
|
|
4153
4267
|
}
|
|
4154
4268
|
let fetcher = state.fetchers.get(key);
|
|
4155
4269
|
let isMidInitialLoad = fetcher && fetcher.state !== "idle" && fetcher.data === void 0;
|
|
4156
|
-
let fetcherMatches =
|
|
4270
|
+
let fetcherMatches = matchRoutesImpl(
|
|
4271
|
+
routesToUse,
|
|
4272
|
+
f.path,
|
|
4273
|
+
basename ?? "/",
|
|
4274
|
+
false,
|
|
4275
|
+
branches
|
|
4276
|
+
);
|
|
4157
4277
|
if (!fetcherMatches) {
|
|
4158
4278
|
if (hasPatchRoutesOnNavigation && isMidInitialLoad) {
|
|
4159
4279
|
return;
|
|
@@ -4294,7 +4414,7 @@ function shouldRevalidateLoader(loaderMatch, arg) {
|
|
|
4294
4414
|
}
|
|
4295
4415
|
return arg.defaultShouldRevalidate;
|
|
4296
4416
|
}
|
|
4297
|
-
function patchRoutesImpl(routeId, children,
|
|
4417
|
+
function patchRoutesImpl(routeId, children, dataRoutes, manifest, mapRouteProperties2, allowElementMutations) {
|
|
4298
4418
|
let childrenToPatch;
|
|
4299
4419
|
if (routeId) {
|
|
4300
4420
|
let route = manifest[routeId];
|
|
@@ -4307,7 +4427,7 @@ function patchRoutesImpl(routeId, children, routesToUse, manifest, mapRoutePrope
|
|
|
4307
4427
|
}
|
|
4308
4428
|
childrenToPatch = route.children;
|
|
4309
4429
|
} else {
|
|
4310
|
-
childrenToPatch =
|
|
4430
|
+
childrenToPatch = dataRoutes.activeRoutes;
|
|
4311
4431
|
}
|
|
4312
4432
|
let uniqueChildren = [];
|
|
4313
4433
|
let existingChildren = [];
|
|
@@ -4350,6 +4470,9 @@ function patchRoutesImpl(routeId, children, routesToUse, manifest, mapRoutePrope
|
|
|
4350
4470
|
});
|
|
4351
4471
|
}
|
|
4352
4472
|
}
|
|
4473
|
+
if (!dataRoutes.hasHMRRoutes) {
|
|
4474
|
+
dataRoutes.setRoutes([...dataRoutes.activeRoutes]);
|
|
4475
|
+
}
|
|
4353
4476
|
}
|
|
4354
4477
|
function isSameRoute(newRoute, existingRoute) {
|
|
4355
4478
|
if ("id" in newRoute && "id" in existingRoute && newRoute.id === existingRoute.id) {
|
|
@@ -4691,7 +4814,7 @@ function getDataStrategyMatchLazyPromises(mapRouteProperties2, manifest, request
|
|
|
4691
4814
|
handler: lazyRoutePromises.lazyHandlerPromise
|
|
4692
4815
|
};
|
|
4693
4816
|
}
|
|
4694
|
-
function getDataStrategyMatch(mapRouteProperties2, manifest, request, path,
|
|
4817
|
+
function getDataStrategyMatch(mapRouteProperties2, manifest, request, path, pattern, match, lazyRoutePropertiesToSkip, scopedContext, shouldLoad, shouldRevalidateArgs = null, callSiteDefaultShouldRevalidate) {
|
|
4695
4818
|
let isUsingNewApi = false;
|
|
4696
4819
|
let _lazyPromises = getDataStrategyMatchLazyPromises(
|
|
4697
4820
|
mapRouteProperties2,
|
|
@@ -4732,7 +4855,7 @@ function getDataStrategyMatch(mapRouteProperties2, manifest, request, path, unst
|
|
|
4732
4855
|
return callLoaderOrAction({
|
|
4733
4856
|
request,
|
|
4734
4857
|
path,
|
|
4735
|
-
|
|
4858
|
+
pattern,
|
|
4736
4859
|
match,
|
|
4737
4860
|
lazyHandlerPromise: _lazyPromises?.handler,
|
|
4738
4861
|
lazyRoutePromise: _lazyPromises?.route,
|
|
@@ -4782,8 +4905,8 @@ async function callDataStrategyImpl(dataStrategyImpl, request, path, matches, fe
|
|
|
4782
4905
|
}
|
|
4783
4906
|
let dataStrategyArgs = {
|
|
4784
4907
|
request,
|
|
4785
|
-
|
|
4786
|
-
|
|
4908
|
+
url: createDataFunctionUrl(request, path),
|
|
4909
|
+
pattern: getRoutePattern(matches),
|
|
4787
4910
|
params: matches[0].params,
|
|
4788
4911
|
context: scopedContext,
|
|
4789
4912
|
matches
|
|
@@ -4825,7 +4948,7 @@ async function callDataStrategyImpl(dataStrategyImpl, request, path, matches, fe
|
|
|
4825
4948
|
async function callLoaderOrAction({
|
|
4826
4949
|
request,
|
|
4827
4950
|
path,
|
|
4828
|
-
|
|
4951
|
+
pattern,
|
|
4829
4952
|
match,
|
|
4830
4953
|
lazyHandlerPromise,
|
|
4831
4954
|
lazyRoutePromise,
|
|
@@ -4852,8 +4975,8 @@ async function callLoaderOrAction({
|
|
|
4852
4975
|
return handler(
|
|
4853
4976
|
{
|
|
4854
4977
|
request,
|
|
4855
|
-
|
|
4856
|
-
|
|
4978
|
+
url: createDataFunctionUrl(request, path),
|
|
4979
|
+
pattern,
|
|
4857
4980
|
params: match.params,
|
|
4858
4981
|
context: scopedContext
|
|
4859
4982
|
},
|
|
@@ -5804,7 +5927,15 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
|
|
|
5804
5927
|
let segments = pathname.replace(/^\//, "").split("/");
|
|
5805
5928
|
remainingPathname = "/" + segments.slice(parentSegments.length).join("/");
|
|
5806
5929
|
}
|
|
5807
|
-
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 });
|
|
5808
5939
|
if (ENABLE_DEV_WARNINGS) {
|
|
5809
5940
|
warning(
|
|
5810
5941
|
parentRoute || matches != null,
|
|
@@ -5855,7 +5986,7 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
|
|
|
5855
5986
|
hash: "",
|
|
5856
5987
|
state: null,
|
|
5857
5988
|
key: "default",
|
|
5858
|
-
|
|
5989
|
+
mask: void 0,
|
|
5859
5990
|
...location
|
|
5860
5991
|
},
|
|
5861
5992
|
navigationType: "POP" /* Pop */
|
|
@@ -6045,7 +6176,7 @@ function _renderMatches(matches, parentMatches = [], dataRouterOpts) {
|
|
|
6045
6176
|
onErrorHandler(error, {
|
|
6046
6177
|
location: dataRouterState.location,
|
|
6047
6178
|
params: dataRouterState.matches?.[0]?.params ?? {},
|
|
6048
|
-
|
|
6179
|
+
pattern: getRoutePattern(dataRouterState.matches),
|
|
6049
6180
|
errorInfo
|
|
6050
6181
|
});
|
|
6051
6182
|
} : void 0;
|
|
@@ -6376,7 +6507,7 @@ function createMemoryRouter(routes, opts) {
|
|
|
6376
6507
|
mapRouteProperties,
|
|
6377
6508
|
dataStrategy: opts?.dataStrategy,
|
|
6378
6509
|
patchRoutesOnNavigation: opts?.patchRoutesOnNavigation,
|
|
6379
|
-
|
|
6510
|
+
instrumentations: opts?.instrumentations
|
|
6380
6511
|
}).initialize();
|
|
6381
6512
|
}
|
|
6382
6513
|
var Deferred = class {
|
|
@@ -6402,10 +6533,10 @@ function RouterProvider({
|
|
|
6402
6533
|
router,
|
|
6403
6534
|
flushSync: reactDomFlushSyncImpl,
|
|
6404
6535
|
onError,
|
|
6405
|
-
|
|
6536
|
+
useTransitions
|
|
6406
6537
|
}) {
|
|
6407
6538
|
let unstable_rsc = useIsRSCRouterContext();
|
|
6408
|
-
|
|
6539
|
+
useTransitions = unstable_rsc || useTransitions;
|
|
6409
6540
|
let [_state, setStateImpl] = React3.useState(router.state);
|
|
6410
6541
|
let [state, setOptimisticState] = useOptimisticSafe(_state);
|
|
6411
6542
|
let [pendingState, setPendingState] = React3.useState();
|
|
@@ -6423,7 +6554,7 @@ function RouterProvider({
|
|
|
6423
6554
|
(error) => onError(error, {
|
|
6424
6555
|
location: newState.location,
|
|
6425
6556
|
params: newState.matches[0]?.params ?? {},
|
|
6426
|
-
|
|
6557
|
+
pattern: getRoutePattern(newState.matches)
|
|
6427
6558
|
})
|
|
6428
6559
|
);
|
|
6429
6560
|
}
|
|
@@ -6445,11 +6576,11 @@ function RouterProvider({
|
|
|
6445
6576
|
if (!viewTransitionOpts || !isViewTransitionAvailable) {
|
|
6446
6577
|
if (reactDomFlushSyncImpl && flushSync) {
|
|
6447
6578
|
reactDomFlushSyncImpl(() => setStateImpl(newState));
|
|
6448
|
-
} else if (
|
|
6579
|
+
} else if (useTransitions === false) {
|
|
6449
6580
|
setStateImpl(newState);
|
|
6450
6581
|
} else {
|
|
6451
6582
|
React3.startTransition(() => {
|
|
6452
|
-
if (
|
|
6583
|
+
if (useTransitions === true) {
|
|
6453
6584
|
setOptimisticState((s) => getOptimisticRouterState(s, newState));
|
|
6454
6585
|
}
|
|
6455
6586
|
setStateImpl(newState);
|
|
@@ -6507,7 +6638,7 @@ function RouterProvider({
|
|
|
6507
6638
|
reactDomFlushSyncImpl,
|
|
6508
6639
|
transition,
|
|
6509
6640
|
renderDfd,
|
|
6510
|
-
|
|
6641
|
+
useTransitions,
|
|
6511
6642
|
setOptimisticState,
|
|
6512
6643
|
onError
|
|
6513
6644
|
]
|
|
@@ -6533,11 +6664,11 @@ function RouterProvider({
|
|
|
6533
6664
|
let newState = pendingState;
|
|
6534
6665
|
let renderPromise = renderDfd.promise;
|
|
6535
6666
|
let transition2 = router.window.document.startViewTransition(async () => {
|
|
6536
|
-
if (
|
|
6667
|
+
if (useTransitions === false) {
|
|
6537
6668
|
setStateImpl(newState);
|
|
6538
6669
|
} else {
|
|
6539
6670
|
React3.startTransition(() => {
|
|
6540
|
-
if (
|
|
6671
|
+
if (useTransitions === true) {
|
|
6541
6672
|
setOptimisticState((s) => getOptimisticRouterState(s, newState));
|
|
6542
6673
|
}
|
|
6543
6674
|
setStateImpl(newState);
|
|
@@ -6557,7 +6688,7 @@ function RouterProvider({
|
|
|
6557
6688
|
pendingState,
|
|
6558
6689
|
renderDfd,
|
|
6559
6690
|
router.window,
|
|
6560
|
-
|
|
6691
|
+
useTransitions,
|
|
6561
6692
|
setOptimisticState
|
|
6562
6693
|
]);
|
|
6563
6694
|
React3.useEffect(() => {
|
|
@@ -6611,12 +6742,13 @@ function RouterProvider({
|
|
|
6611
6742
|
location: state.location,
|
|
6612
6743
|
navigationType: state.historyAction,
|
|
6613
6744
|
navigator,
|
|
6614
|
-
|
|
6745
|
+
useTransitions
|
|
6615
6746
|
},
|
|
6616
6747
|
/* @__PURE__ */ React3.createElement(
|
|
6617
6748
|
MemoizedDataRoutes,
|
|
6618
6749
|
{
|
|
6619
6750
|
routes: router.routes,
|
|
6751
|
+
manifest: router.manifest,
|
|
6620
6752
|
future: router.future,
|
|
6621
6753
|
state,
|
|
6622
6754
|
isStatic: false,
|
|
@@ -6639,22 +6771,29 @@ function getOptimisticRouterState(currentState, newState) {
|
|
|
6639
6771
|
fetchers: newState.fetchers
|
|
6640
6772
|
};
|
|
6641
6773
|
}
|
|
6642
|
-
var MemoizedDataRoutes = React3.memo(
|
|
6643
|
-
function
|
|
6774
|
+
var MemoizedDataRoutes = React3.memo(DataRoutes2);
|
|
6775
|
+
function DataRoutes2({
|
|
6644
6776
|
routes,
|
|
6777
|
+
manifest,
|
|
6645
6778
|
future,
|
|
6646
6779
|
state,
|
|
6647
6780
|
isStatic,
|
|
6648
6781
|
onError
|
|
6649
6782
|
}) {
|
|
6650
|
-
return useRoutesImpl(routes, void 0, {
|
|
6783
|
+
return useRoutesImpl(routes, void 0, {
|
|
6784
|
+
manifest,
|
|
6785
|
+
state,
|
|
6786
|
+
isStatic,
|
|
6787
|
+
onError,
|
|
6788
|
+
future
|
|
6789
|
+
});
|
|
6651
6790
|
}
|
|
6652
6791
|
function MemoryRouter({
|
|
6653
6792
|
basename,
|
|
6654
6793
|
children,
|
|
6655
6794
|
initialEntries,
|
|
6656
6795
|
initialIndex,
|
|
6657
|
-
|
|
6796
|
+
useTransitions
|
|
6658
6797
|
}) {
|
|
6659
6798
|
let historyRef = React3.useRef();
|
|
6660
6799
|
if (historyRef.current == null) {
|
|
@@ -6671,13 +6810,13 @@ function MemoryRouter({
|
|
|
6671
6810
|
});
|
|
6672
6811
|
let setState = React3.useCallback(
|
|
6673
6812
|
(newState) => {
|
|
6674
|
-
if (
|
|
6813
|
+
if (useTransitions === false) {
|
|
6675
6814
|
setStateImpl(newState);
|
|
6676
6815
|
} else {
|
|
6677
6816
|
React3.startTransition(() => setStateImpl(newState));
|
|
6678
6817
|
}
|
|
6679
6818
|
},
|
|
6680
|
-
[
|
|
6819
|
+
[useTransitions]
|
|
6681
6820
|
);
|
|
6682
6821
|
React3.useLayoutEffect(() => history.listen(setState), [history, setState]);
|
|
6683
6822
|
return /* @__PURE__ */ React3.createElement(
|
|
@@ -6688,7 +6827,7 @@ function MemoryRouter({
|
|
|
6688
6827
|
location: state.location,
|
|
6689
6828
|
navigationType: state.action,
|
|
6690
6829
|
navigator: history,
|
|
6691
|
-
|
|
6830
|
+
useTransitions
|
|
6692
6831
|
}
|
|
6693
6832
|
);
|
|
6694
6833
|
}
|
|
@@ -6740,7 +6879,7 @@ function Router({
|
|
|
6740
6879
|
navigationType = "POP" /* Pop */,
|
|
6741
6880
|
navigator,
|
|
6742
6881
|
static: staticProp = false,
|
|
6743
|
-
|
|
6882
|
+
useTransitions
|
|
6744
6883
|
}) {
|
|
6745
6884
|
invariant(
|
|
6746
6885
|
!useInRouterContext(),
|
|
@@ -6752,10 +6891,10 @@ function Router({
|
|
|
6752
6891
|
basename,
|
|
6753
6892
|
navigator,
|
|
6754
6893
|
static: staticProp,
|
|
6755
|
-
|
|
6894
|
+
useTransitions,
|
|
6756
6895
|
future: {}
|
|
6757
6896
|
}),
|
|
6758
|
-
[basename, navigator, staticProp,
|
|
6897
|
+
[basename, navigator, staticProp, useTransitions]
|
|
6759
6898
|
);
|
|
6760
6899
|
if (typeof locationProp === "string") {
|
|
6761
6900
|
locationProp = parsePath(locationProp);
|
|
@@ -6766,7 +6905,7 @@ function Router({
|
|
|
6766
6905
|
hash = "",
|
|
6767
6906
|
state = null,
|
|
6768
6907
|
key = "default",
|
|
6769
|
-
|
|
6908
|
+
mask
|
|
6770
6909
|
} = locationProp;
|
|
6771
6910
|
let locationContext = React3.useMemo(() => {
|
|
6772
6911
|
let trailingPathname = stripBasename(pathname, basename);
|
|
@@ -6780,20 +6919,11 @@ function Router({
|
|
|
6780
6919
|
hash,
|
|
6781
6920
|
state,
|
|
6782
6921
|
key,
|
|
6783
|
-
|
|
6922
|
+
mask
|
|
6784
6923
|
},
|
|
6785
6924
|
navigationType
|
|
6786
6925
|
};
|
|
6787
|
-
}, [
|
|
6788
|
-
basename,
|
|
6789
|
-
pathname,
|
|
6790
|
-
search,
|
|
6791
|
-
hash,
|
|
6792
|
-
state,
|
|
6793
|
-
key,
|
|
6794
|
-
navigationType,
|
|
6795
|
-
unstable_mask
|
|
6796
|
-
]);
|
|
6926
|
+
}, [basename, pathname, search, hash, state, key, navigationType, mask]);
|
|
6797
6927
|
warning(
|
|
6798
6928
|
locationContext != null,
|
|
6799
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.`
|
|
@@ -6822,7 +6952,7 @@ function Await({
|
|
|
6822
6952
|
dataRouterContext.onError(error, {
|
|
6823
6953
|
location: dataRouterStateContext.location,
|
|
6824
6954
|
params: dataRouterStateContext.matches[0]?.params || {},
|
|
6825
|
-
|
|
6955
|
+
pattern: getRoutePattern(dataRouterStateContext.matches),
|
|
6826
6956
|
errorInfo
|
|
6827
6957
|
});
|
|
6828
6958
|
}
|
|
@@ -7976,11 +8106,9 @@ function getTurboStreamSingleFetchDataStrategy(getRouter, manifest, routeModules
|
|
|
7976
8106
|
(match) => {
|
|
7977
8107
|
let manifestRoute = manifest.routes[match.route.id];
|
|
7978
8108
|
invariant2(manifestRoute, "Route not found in manifest");
|
|
7979
|
-
let routeModule = routeModules[match.route.id];
|
|
7980
8109
|
return {
|
|
7981
8110
|
hasLoader: manifestRoute.hasLoader,
|
|
7982
|
-
hasClientLoader: manifestRoute.hasClientLoader
|
|
7983
|
-
hasShouldRevalidate: Boolean(routeModule?.shouldRevalidate)
|
|
8111
|
+
hasClientLoader: manifestRoute.hasClientLoader
|
|
7984
8112
|
};
|
|
7985
8113
|
},
|
|
7986
8114
|
fetchAndDecodeViaTurboStream,
|
|
@@ -8100,13 +8228,12 @@ async function singleFetchLoaderNavigationStrategy(args, router, getRouteInfo, f
|
|
|
8100
8228
|
async (m, i) => m.resolve(async (handler) => {
|
|
8101
8229
|
routeDfds[i].resolve();
|
|
8102
8230
|
let routeId = m.route.id;
|
|
8103
|
-
let { hasLoader, hasClientLoader
|
|
8231
|
+
let { hasLoader, hasClientLoader } = getRouteInfo(m);
|
|
8104
8232
|
let defaultShouldRevalidate = !m.shouldRevalidateArgs || m.shouldRevalidateArgs.actionStatus == null || m.shouldRevalidateArgs.actionStatus < 400;
|
|
8105
8233
|
let shouldCall = m.shouldCallHandler(defaultShouldRevalidate);
|
|
8106
8234
|
if (!shouldCall) {
|
|
8107
8235
|
foundOptOutRoute || (foundOptOutRoute = m.shouldRevalidateArgs != null && // This is a revalidation,
|
|
8108
|
-
hasLoader
|
|
8109
|
-
hasShouldRevalidate === true);
|
|
8236
|
+
hasLoader);
|
|
8110
8237
|
return;
|
|
8111
8238
|
}
|
|
8112
8239
|
if (shouldAllowOptOut(m) && hasClientLoader) {
|
|
@@ -8843,13 +8970,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
8843
8970
|
let hasInitialError = initialState && initialState.errors && route.id in initialState.errors;
|
|
8844
8971
|
let initialError = hasInitialError ? initialState?.errors?.[route.id] : void 0;
|
|
8845
8972
|
let isHydrationRequest = needsRevalidation == null && (routeModule.clientLoader?.hydrate === true || !route.hasLoader);
|
|
8846
|
-
dataRoute.loader = async ({
|
|
8847
|
-
request,
|
|
8848
|
-
params,
|
|
8849
|
-
context,
|
|
8850
|
-
unstable_pattern,
|
|
8851
|
-
unstable_url
|
|
8852
|
-
}, singleFetch) => {
|
|
8973
|
+
dataRoute.loader = async ({ request, params, context, pattern, url }, singleFetch) => {
|
|
8853
8974
|
try {
|
|
8854
8975
|
let result = await prefetchStylesAndCallHandler(async () => {
|
|
8855
8976
|
invariant2(
|
|
@@ -8863,8 +8984,8 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
8863
8984
|
request,
|
|
8864
8985
|
params,
|
|
8865
8986
|
context,
|
|
8866
|
-
|
|
8867
|
-
|
|
8987
|
+
pattern,
|
|
8988
|
+
url,
|
|
8868
8989
|
async serverLoader() {
|
|
8869
8990
|
preventInvalidServerHandlerCall("loader", route);
|
|
8870
8991
|
if (isHydrationRequest) {
|
|
@@ -8890,13 +9011,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
8890
9011
|
route.hasLoader,
|
|
8891
9012
|
isSpaMode
|
|
8892
9013
|
);
|
|
8893
|
-
dataRoute.action = ({
|
|
8894
|
-
request,
|
|
8895
|
-
params,
|
|
8896
|
-
context,
|
|
8897
|
-
unstable_pattern,
|
|
8898
|
-
unstable_url
|
|
8899
|
-
}, singleFetch) => {
|
|
9014
|
+
dataRoute.action = ({ request, params, context, pattern, url }, singleFetch) => {
|
|
8900
9015
|
return prefetchStylesAndCallHandler(async () => {
|
|
8901
9016
|
invariant2(
|
|
8902
9017
|
routeModule,
|
|
@@ -8912,8 +9027,8 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
8912
9027
|
request,
|
|
8913
9028
|
params,
|
|
8914
9029
|
context,
|
|
8915
|
-
|
|
8916
|
-
|
|
9030
|
+
pattern,
|
|
9031
|
+
url,
|
|
8917
9032
|
async serverAction() {
|
|
8918
9033
|
preventInvalidServerHandlerCall("action", route);
|
|
8919
9034
|
return fetchServerAction(singleFetch);
|
|
@@ -9108,7 +9223,13 @@ function getPartialManifest({ sri, ...manifest }, router) {
|
|
|
9108
9223
|
segments.pop();
|
|
9109
9224
|
}
|
|
9110
9225
|
paths.forEach((path) => {
|
|
9111
|
-
let matches =
|
|
9226
|
+
let matches = matchRoutesImpl(
|
|
9227
|
+
router.routes,
|
|
9228
|
+
path,
|
|
9229
|
+
router.basename || "/",
|
|
9230
|
+
false,
|
|
9231
|
+
router.branches
|
|
9232
|
+
);
|
|
9112
9233
|
if (matches) {
|
|
9113
9234
|
matches.forEach((m) => routeIds.add(m.route.id));
|
|
9114
9235
|
}
|
|
@@ -9855,6 +9976,7 @@ import(${JSON.stringify(manifest.entry.module)});`;
|
|
|
9855
9976
|
href: manifest.url,
|
|
9856
9977
|
crossOrigin: scriptProps.crossOrigin,
|
|
9857
9978
|
integrity: sri[manifest.url],
|
|
9979
|
+
nonce: scriptProps.nonce,
|
|
9858
9980
|
suppressHydrationWarning: true
|
|
9859
9981
|
}
|
|
9860
9982
|
) : null, /* @__PURE__ */ React8.createElement(
|
|
@@ -9864,6 +9986,7 @@ import(${JSON.stringify(manifest.entry.module)});`;
|
|
|
9864
9986
|
href: manifest.entry.module,
|
|
9865
9987
|
crossOrigin: scriptProps.crossOrigin,
|
|
9866
9988
|
integrity: sri[manifest.entry.module],
|
|
9989
|
+
nonce: scriptProps.nonce,
|
|
9867
9990
|
suppressHydrationWarning: true
|
|
9868
9991
|
}
|
|
9869
9992
|
), preloads.map((path) => /* @__PURE__ */ React8.createElement(
|
|
@@ -9874,6 +9997,7 @@ import(${JSON.stringify(manifest.entry.module)});`;
|
|
|
9874
9997
|
href: path,
|
|
9875
9998
|
crossOrigin: scriptProps.crossOrigin,
|
|
9876
9999
|
integrity: sri[path],
|
|
10000
|
+
nonce: scriptProps.nonce,
|
|
9877
10001
|
suppressHydrationWarning: true
|
|
9878
10002
|
}
|
|
9879
10003
|
)), initialScripts);
|
|
@@ -9996,7 +10120,7 @@ var isBrowser2 = typeof window !== "undefined" && typeof window.document !== "un
|
|
|
9996
10120
|
try {
|
|
9997
10121
|
if (isBrowser2) {
|
|
9998
10122
|
window.__reactRouterVersion = // @ts-expect-error
|
|
9999
|
-
"7.
|
|
10123
|
+
"7.15.0";
|
|
10000
10124
|
}
|
|
10001
10125
|
} catch (e) {
|
|
10002
10126
|
}
|
|
@@ -10013,7 +10137,7 @@ function createBrowserRouter(routes, opts) {
|
|
|
10013
10137
|
dataStrategy: opts?.dataStrategy,
|
|
10014
10138
|
patchRoutesOnNavigation: opts?.patchRoutesOnNavigation,
|
|
10015
10139
|
window: opts?.window,
|
|
10016
|
-
|
|
10140
|
+
instrumentations: opts?.instrumentations
|
|
10017
10141
|
}).initialize();
|
|
10018
10142
|
}
|
|
10019
10143
|
function createHashRouter(routes, opts) {
|
|
@@ -10029,7 +10153,7 @@ function createHashRouter(routes, opts) {
|
|
|
10029
10153
|
dataStrategy: opts?.dataStrategy,
|
|
10030
10154
|
patchRoutesOnNavigation: opts?.patchRoutesOnNavigation,
|
|
10031
10155
|
window: opts?.window,
|
|
10032
|
-
|
|
10156
|
+
instrumentations: opts?.instrumentations
|
|
10033
10157
|
}).initialize();
|
|
10034
10158
|
}
|
|
10035
10159
|
function parseHydrationData() {
|
|
@@ -10080,7 +10204,7 @@ function deserializeErrors(errors) {
|
|
|
10080
10204
|
function BrowserRouter({
|
|
10081
10205
|
basename,
|
|
10082
10206
|
children,
|
|
10083
|
-
|
|
10207
|
+
useTransitions,
|
|
10084
10208
|
window: window2
|
|
10085
10209
|
}) {
|
|
10086
10210
|
let historyRef = React10.useRef();
|
|
@@ -10094,13 +10218,13 @@ function BrowserRouter({
|
|
|
10094
10218
|
});
|
|
10095
10219
|
let setState = React10.useCallback(
|
|
10096
10220
|
(newState) => {
|
|
10097
|
-
if (
|
|
10221
|
+
if (useTransitions === false) {
|
|
10098
10222
|
setStateImpl(newState);
|
|
10099
10223
|
} else {
|
|
10100
10224
|
React10.startTransition(() => setStateImpl(newState));
|
|
10101
10225
|
}
|
|
10102
10226
|
},
|
|
10103
|
-
[
|
|
10227
|
+
[useTransitions]
|
|
10104
10228
|
);
|
|
10105
10229
|
React10.useLayoutEffect(() => history.listen(setState), [history, setState]);
|
|
10106
10230
|
return /* @__PURE__ */ React10.createElement(
|
|
@@ -10111,14 +10235,14 @@ function BrowserRouter({
|
|
|
10111
10235
|
location: state.location,
|
|
10112
10236
|
navigationType: state.action,
|
|
10113
10237
|
navigator: history,
|
|
10114
|
-
|
|
10238
|
+
useTransitions
|
|
10115
10239
|
}
|
|
10116
10240
|
);
|
|
10117
10241
|
}
|
|
10118
10242
|
function HashRouter({
|
|
10119
10243
|
basename,
|
|
10120
10244
|
children,
|
|
10121
|
-
|
|
10245
|
+
useTransitions,
|
|
10122
10246
|
window: window2
|
|
10123
10247
|
}) {
|
|
10124
10248
|
let historyRef = React10.useRef();
|
|
@@ -10132,13 +10256,13 @@ function HashRouter({
|
|
|
10132
10256
|
});
|
|
10133
10257
|
let setState = React10.useCallback(
|
|
10134
10258
|
(newState) => {
|
|
10135
|
-
if (
|
|
10259
|
+
if (useTransitions === false) {
|
|
10136
10260
|
setStateImpl(newState);
|
|
10137
10261
|
} else {
|
|
10138
10262
|
React10.startTransition(() => setStateImpl(newState));
|
|
10139
10263
|
}
|
|
10140
10264
|
},
|
|
10141
|
-
[
|
|
10265
|
+
[useTransitions]
|
|
10142
10266
|
);
|
|
10143
10267
|
React10.useLayoutEffect(() => history.listen(setState), [history, setState]);
|
|
10144
10268
|
return /* @__PURE__ */ React10.createElement(
|
|
@@ -10149,7 +10273,7 @@ function HashRouter({
|
|
|
10149
10273
|
location: state.location,
|
|
10150
10274
|
navigationType: state.action,
|
|
10151
10275
|
navigator: history,
|
|
10152
|
-
|
|
10276
|
+
useTransitions
|
|
10153
10277
|
}
|
|
10154
10278
|
);
|
|
10155
10279
|
}
|
|
@@ -10157,7 +10281,7 @@ function HistoryRouter({
|
|
|
10157
10281
|
basename,
|
|
10158
10282
|
children,
|
|
10159
10283
|
history,
|
|
10160
|
-
|
|
10284
|
+
useTransitions
|
|
10161
10285
|
}) {
|
|
10162
10286
|
let [state, setStateImpl] = React10.useState({
|
|
10163
10287
|
action: history.action,
|
|
@@ -10165,13 +10289,13 @@ function HistoryRouter({
|
|
|
10165
10289
|
});
|
|
10166
10290
|
let setState = React10.useCallback(
|
|
10167
10291
|
(newState) => {
|
|
10168
|
-
if (
|
|
10292
|
+
if (useTransitions === false) {
|
|
10169
10293
|
setStateImpl(newState);
|
|
10170
10294
|
} else {
|
|
10171
10295
|
React10.startTransition(() => setStateImpl(newState));
|
|
10172
10296
|
}
|
|
10173
10297
|
},
|
|
10174
|
-
[
|
|
10298
|
+
[useTransitions]
|
|
10175
10299
|
);
|
|
10176
10300
|
React10.useLayoutEffect(() => history.listen(setState), [history, setState]);
|
|
10177
10301
|
return /* @__PURE__ */ React10.createElement(
|
|
@@ -10182,7 +10306,7 @@ function HistoryRouter({
|
|
|
10182
10306
|
location: state.location,
|
|
10183
10307
|
navigationType: state.action,
|
|
10184
10308
|
navigator: history,
|
|
10185
|
-
|
|
10309
|
+
useTransitions
|
|
10186
10310
|
}
|
|
10187
10311
|
);
|
|
10188
10312
|
}
|
|
@@ -10196,27 +10320,27 @@ var Link = React10.forwardRef(
|
|
|
10196
10320
|
relative,
|
|
10197
10321
|
reloadDocument,
|
|
10198
10322
|
replace: replace2,
|
|
10199
|
-
|
|
10323
|
+
mask,
|
|
10200
10324
|
state,
|
|
10201
10325
|
target,
|
|
10202
10326
|
to,
|
|
10203
10327
|
preventScrollReset,
|
|
10204
10328
|
viewTransition,
|
|
10205
|
-
|
|
10329
|
+
defaultShouldRevalidate,
|
|
10206
10330
|
...rest
|
|
10207
10331
|
}, forwardedRef) {
|
|
10208
|
-
let { basename, navigator,
|
|
10332
|
+
let { basename, navigator, useTransitions } = React10.useContext(NavigationContext);
|
|
10209
10333
|
let isAbsolute = typeof to === "string" && ABSOLUTE_URL_REGEX2.test(to);
|
|
10210
10334
|
let parsed = parseToInfo(to, basename);
|
|
10211
10335
|
to = parsed.to;
|
|
10212
10336
|
let href = useHref(to, { relative });
|
|
10213
10337
|
let location = useLocation();
|
|
10214
10338
|
let maskedHref = null;
|
|
10215
|
-
if (
|
|
10339
|
+
if (mask) {
|
|
10216
10340
|
let resolved = resolveTo(
|
|
10217
|
-
|
|
10341
|
+
mask,
|
|
10218
10342
|
[],
|
|
10219
|
-
location.
|
|
10343
|
+
location.mask ? location.mask.pathname : "/",
|
|
10220
10344
|
true
|
|
10221
10345
|
);
|
|
10222
10346
|
if (basename !== "/") {
|
|
@@ -10230,14 +10354,14 @@ var Link = React10.forwardRef(
|
|
|
10230
10354
|
);
|
|
10231
10355
|
let internalOnClick = useLinkClickHandler(to, {
|
|
10232
10356
|
replace: replace2,
|
|
10233
|
-
|
|
10357
|
+
mask,
|
|
10234
10358
|
state,
|
|
10235
10359
|
target,
|
|
10236
10360
|
preventScrollReset,
|
|
10237
10361
|
relative,
|
|
10238
10362
|
viewTransition,
|
|
10239
|
-
|
|
10240
|
-
|
|
10363
|
+
defaultShouldRevalidate,
|
|
10364
|
+
useTransitions
|
|
10241
10365
|
});
|
|
10242
10366
|
function handleClick(event) {
|
|
10243
10367
|
if (onClick) onClick(event);
|
|
@@ -10346,10 +10470,10 @@ var Form = React10.forwardRef(
|
|
|
10346
10470
|
relative,
|
|
10347
10471
|
preventScrollReset,
|
|
10348
10472
|
viewTransition,
|
|
10349
|
-
|
|
10473
|
+
defaultShouldRevalidate,
|
|
10350
10474
|
...props
|
|
10351
10475
|
}, forwardedRef) => {
|
|
10352
|
-
let {
|
|
10476
|
+
let { useTransitions } = React10.useContext(NavigationContext);
|
|
10353
10477
|
let submit = useSubmit();
|
|
10354
10478
|
let formAction = useFormAction(action, { relative });
|
|
10355
10479
|
let formMethod = method.toLowerCase() === "get" ? "get" : "post";
|
|
@@ -10369,9 +10493,9 @@ var Form = React10.forwardRef(
|
|
|
10369
10493
|
relative,
|
|
10370
10494
|
preventScrollReset,
|
|
10371
10495
|
viewTransition,
|
|
10372
|
-
|
|
10496
|
+
defaultShouldRevalidate
|
|
10373
10497
|
});
|
|
10374
|
-
if (
|
|
10498
|
+
if (useTransitions && navigate !== false) {
|
|
10375
10499
|
React10.startTransition(() => doSubmit());
|
|
10376
10500
|
} else {
|
|
10377
10501
|
doSubmit();
|
|
@@ -10465,13 +10589,13 @@ function useDataRouterState2(hookName) {
|
|
|
10465
10589
|
function useLinkClickHandler(to, {
|
|
10466
10590
|
target,
|
|
10467
10591
|
replace: replaceProp,
|
|
10468
|
-
|
|
10592
|
+
mask,
|
|
10469
10593
|
state,
|
|
10470
10594
|
preventScrollReset,
|
|
10471
10595
|
relative,
|
|
10472
10596
|
viewTransition,
|
|
10473
|
-
|
|
10474
|
-
|
|
10597
|
+
defaultShouldRevalidate,
|
|
10598
|
+
useTransitions
|
|
10475
10599
|
} = {}) {
|
|
10476
10600
|
let navigate = useNavigate();
|
|
10477
10601
|
let location = useLocation();
|
|
@@ -10483,14 +10607,14 @@ function useLinkClickHandler(to, {
|
|
|
10483
10607
|
let replace2 = replaceProp !== void 0 ? replaceProp : createPath(location) === createPath(path);
|
|
10484
10608
|
let doNavigate = () => navigate(to, {
|
|
10485
10609
|
replace: replace2,
|
|
10486
|
-
|
|
10610
|
+
mask,
|
|
10487
10611
|
state,
|
|
10488
10612
|
preventScrollReset,
|
|
10489
10613
|
relative,
|
|
10490
10614
|
viewTransition,
|
|
10491
|
-
|
|
10615
|
+
defaultShouldRevalidate
|
|
10492
10616
|
});
|
|
10493
|
-
if (
|
|
10617
|
+
if (useTransitions) {
|
|
10494
10618
|
React10.startTransition(() => doNavigate());
|
|
10495
10619
|
} else {
|
|
10496
10620
|
doNavigate();
|
|
@@ -10502,15 +10626,15 @@ function useLinkClickHandler(to, {
|
|
|
10502
10626
|
navigate,
|
|
10503
10627
|
path,
|
|
10504
10628
|
replaceProp,
|
|
10505
|
-
|
|
10629
|
+
mask,
|
|
10506
10630
|
state,
|
|
10507
10631
|
target,
|
|
10508
10632
|
to,
|
|
10509
10633
|
preventScrollReset,
|
|
10510
10634
|
relative,
|
|
10511
10635
|
viewTransition,
|
|
10512
|
-
|
|
10513
|
-
|
|
10636
|
+
defaultShouldRevalidate,
|
|
10637
|
+
useTransitions
|
|
10514
10638
|
]
|
|
10515
10639
|
);
|
|
10516
10640
|
}
|
|
@@ -10564,7 +10688,7 @@ function useSubmit() {
|
|
|
10564
10688
|
if (options.navigate === false) {
|
|
10565
10689
|
let key = options.fetcherKey || getUniqueFetcherId();
|
|
10566
10690
|
await routerFetch(key, currentRouteId, options.action || action, {
|
|
10567
|
-
|
|
10691
|
+
defaultShouldRevalidate: options.defaultShouldRevalidate,
|
|
10568
10692
|
preventScrollReset: options.preventScrollReset,
|
|
10569
10693
|
formData,
|
|
10570
10694
|
body,
|
|
@@ -10574,7 +10698,7 @@ function useSubmit() {
|
|
|
10574
10698
|
});
|
|
10575
10699
|
} else {
|
|
10576
10700
|
await routerNavigate(options.action || action, {
|
|
10577
|
-
|
|
10701
|
+
defaultShouldRevalidate: options.defaultShouldRevalidate,
|
|
10578
10702
|
preventScrollReset: options.preventScrollReset,
|
|
10579
10703
|
formData,
|
|
10580
10704
|
body,
|
|
@@ -10884,7 +11008,7 @@ function StaticRouter({
|
|
|
10884
11008
|
hash: locationProp.hash || "",
|
|
10885
11009
|
state: locationProp.state != null ? locationProp.state : null,
|
|
10886
11010
|
key: locationProp.key || "default",
|
|
10887
|
-
|
|
11011
|
+
mask: void 0
|
|
10888
11012
|
};
|
|
10889
11013
|
let staticNavigator = getStatelessNavigator();
|
|
10890
11014
|
return /* @__PURE__ */ React11.createElement(
|
|
@@ -10896,7 +11020,7 @@ function StaticRouter({
|
|
|
10896
11020
|
navigationType: action,
|
|
10897
11021
|
navigator: staticNavigator,
|
|
10898
11022
|
static: true,
|
|
10899
|
-
|
|
11023
|
+
useTransitions: false
|
|
10900
11024
|
}
|
|
10901
11025
|
);
|
|
10902
11026
|
}
|
|
@@ -10937,11 +11061,12 @@ function StaticRouterProvider({
|
|
|
10937
11061
|
navigationType: state.historyAction,
|
|
10938
11062
|
navigator: dataRouterContext.navigator,
|
|
10939
11063
|
static: dataRouterContext.static,
|
|
10940
|
-
|
|
11064
|
+
useTransitions: false
|
|
10941
11065
|
},
|
|
10942
11066
|
/* @__PURE__ */ React11.createElement(
|
|
10943
|
-
|
|
11067
|
+
DataRoutes2,
|
|
10944
11068
|
{
|
|
11069
|
+
manifest: router.manifest,
|
|
10945
11070
|
routes: router.routes,
|
|
10946
11071
|
future: router.future,
|
|
10947
11072
|
state,
|
|
@@ -11040,7 +11165,7 @@ function createStaticRouter(routes, context, opts = {}) {
|
|
|
11040
11165
|
get future() {
|
|
11041
11166
|
return {
|
|
11042
11167
|
v8_middleware: false,
|
|
11043
|
-
|
|
11168
|
+
v8_passThroughRequests: false,
|
|
11044
11169
|
...opts?.future
|
|
11045
11170
|
};
|
|
11046
11171
|
},
|
|
@@ -11065,6 +11190,12 @@ function createStaticRouter(routes, context, opts = {}) {
|
|
|
11065
11190
|
get routes() {
|
|
11066
11191
|
return dataRoutes;
|
|
11067
11192
|
},
|
|
11193
|
+
get branches() {
|
|
11194
|
+
return opts.branches;
|
|
11195
|
+
},
|
|
11196
|
+
get manifest() {
|
|
11197
|
+
return manifest;
|
|
11198
|
+
},
|
|
11068
11199
|
get window() {
|
|
11069
11200
|
return void 0;
|
|
11070
11201
|
},
|
|
@@ -11145,6 +11276,7 @@ export {
|
|
|
11145
11276
|
RouterContextProvider,
|
|
11146
11277
|
convertRoutesToDataRoutes,
|
|
11147
11278
|
matchRoutes,
|
|
11279
|
+
matchRoutesImpl,
|
|
11148
11280
|
generatePath,
|
|
11149
11281
|
matchPath,
|
|
11150
11282
|
stripBasename,
|
|
@@ -11242,6 +11374,7 @@ export {
|
|
|
11242
11374
|
noActionDefinedError,
|
|
11243
11375
|
createClientRoutes,
|
|
11244
11376
|
shouldHydrateRouteLoader,
|
|
11377
|
+
URL_LIMIT,
|
|
11245
11378
|
getPatchRoutesOnNavigationFunction,
|
|
11246
11379
|
useFogOFWarDiscovery,
|
|
11247
11380
|
getManifestPath,
|