react-router 7.14.2 → 7.15.1
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 +99 -0
- package/dist/development/{browser-I6n6wVSO.d.mts → browser-3AnU12UI.d.mts} +2 -2
- package/dist/{production/browser-I6n6wVSO.d.mts → development/browser-BOdXz9dK.d.ts} +2 -2
- package/dist/development/{chunk-EVOBXE3Y.mjs → chunk-4N6VE7H7.mjs} +567 -317
- package/dist/{production/chunk-PQL4HLVQ.js → development/chunk-4YRVXM2U.js} +7 -7
- package/dist/{production/chunk-UJQ4OJF4.js → development/chunk-66UKHEGQ.js} +153 -143
- package/dist/development/{chunk-ZZNWZ5Q3.js → chunk-D6LUOGOQ.js} +550 -310
- package/dist/development/{chunk-YQSHRJWW.mjs → chunk-RJYABSBD.mjs} +100 -80
- package/dist/{production/context-DGGUoDIu.d.mts → development/context-ByvtofY2.d.mts} +100 -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 +57 -62
- package/dist/development/dom-export.mjs +32 -37
- package/dist/{production/index-react-server-client-BBd0A0TL.d.ts → development/index-react-server-client-BS5F89FR.d.ts} +132 -122
- package/dist/{production/index-react-server-client-BjhKIe3u.d.mts → development/index-react-server-client-DY04-103.d.mts} +111 -101
- 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 +113 -36
- package/dist/development/index-react-server.d.ts +113 -36
- package/dist/development/index-react-server.js +63 -36
- package/dist/development/index-react-server.mjs +63 -36
- package/dist/development/index.d.mts +94 -12
- package/dist/development/index.d.ts +94 -12
- package/dist/development/index.js +193 -171
- package/dist/development/index.mjs +5 -3
- package/dist/{production/instrumentation-g0dG8UL0.d.ts → development/instrumentation-cRWWLfsU.d.ts} +79 -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-3AnU12UI.d.mts} +2 -2
- package/dist/{development/browser-C-UvoYvi.d.ts → production/browser-BOdXz9dK.d.ts} +2 -2
- package/dist/production/{chunk-2WLZNCK5.mjs → chunk-6S4627ZB.mjs} +100 -80
- package/dist/production/{chunk-X5SKXJ4A.js → chunk-HUBUW7R3.js} +550 -310
- package/dist/production/{chunk-LK6U7ULH.mjs → chunk-JAKZPQZC.mjs} +567 -317
- package/dist/{development/chunk-YZKCRDTN.js → production/chunk-PNZCCTKT.js} +153 -143
- package/dist/{development/chunk-PZFPF4X7.js → production/chunk-Y6IFXO7V.js} +7 -7
- package/dist/{development/context-DGGUoDIu.d.mts → production/context-ByvtofY2.d.mts} +100 -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 +57 -62
- package/dist/production/dom-export.mjs +32 -37
- package/dist/{development/index-react-server-client-BBd0A0TL.d.ts → production/index-react-server-client-BS5F89FR.d.ts} +132 -122
- package/dist/{development/index-react-server-client-BjhKIe3u.d.mts → production/index-react-server-client-DY04-103.d.mts} +111 -101
- 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 +113 -36
- package/dist/production/index-react-server.d.ts +113 -36
- package/dist/production/index-react-server.js +63 -36
- package/dist/production/index-react-server.mjs +63 -36
- package/dist/production/index.d.mts +94 -12
- package/dist/production/index.d.ts +94 -12
- package/dist/production/index.js +193 -171
- package/dist/production/index.mjs +5 -3
- package/dist/{development/instrumentation-g0dG8UL0.d.ts → production/instrumentation-cRWWLfsU.d.ts} +79 -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
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }/**
|
|
2
|
-
* react-router v7.
|
|
2
|
+
* react-router v7.15.1
|
|
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, createHref, 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, createHref, 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 = _nullishCoalesce(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
|
}
|
|
@@ -1318,6 +1323,8 @@ var redirectPreserveMethodStatusCodes = /* @__PURE__ */ new Set([307, 308]);
|
|
|
1318
1323
|
var IDLE_NAVIGATION = {
|
|
1319
1324
|
state: "idle",
|
|
1320
1325
|
location: void 0,
|
|
1326
|
+
matches: void 0,
|
|
1327
|
+
historyAction: void 0,
|
|
1321
1328
|
formMethod: void 0,
|
|
1322
1329
|
formAction: void 0,
|
|
1323
1330
|
formEncType: void 0,
|
|
@@ -1346,6 +1353,55 @@ var defaultMapRouteProperties = (route) => ({
|
|
|
1346
1353
|
});
|
|
1347
1354
|
var TRANSITIONS_STORAGE_KEY = "remix-router-transitions";
|
|
1348
1355
|
var ResetLoaderDataSymbol = Symbol("ResetLoaderData");
|
|
1356
|
+
var _routes, _branches, _hmrRoutes, _hmrBranches;
|
|
1357
|
+
var DataRoutes = class {
|
|
1358
|
+
constructor(routes) {
|
|
1359
|
+
__privateAdd(this, _routes);
|
|
1360
|
+
__privateAdd(this, _branches);
|
|
1361
|
+
__privateAdd(this, _hmrRoutes);
|
|
1362
|
+
__privateAdd(this, _hmrBranches);
|
|
1363
|
+
__privateSet(this, _routes, routes);
|
|
1364
|
+
__privateSet(this, _branches, flattenAndRankRoutes(routes));
|
|
1365
|
+
}
|
|
1366
|
+
/** The stable route tree */
|
|
1367
|
+
get stableRoutes() {
|
|
1368
|
+
return __privateGet(this, _routes);
|
|
1369
|
+
}
|
|
1370
|
+
/** The in-flight route tree if one is active, otherwise the stable tree */
|
|
1371
|
+
get activeRoutes() {
|
|
1372
|
+
return _nullishCoalesce(__privateGet(this, _hmrRoutes), () => ( __privateGet(this, _routes)));
|
|
1373
|
+
}
|
|
1374
|
+
/** Pre-computed branches */
|
|
1375
|
+
get branches() {
|
|
1376
|
+
return _nullishCoalesce(__privateGet(this, _hmrBranches), () => ( __privateGet(this, _branches)));
|
|
1377
|
+
}
|
|
1378
|
+
get hasHMRRoutes() {
|
|
1379
|
+
return __privateGet(this, _hmrRoutes) != null;
|
|
1380
|
+
}
|
|
1381
|
+
/** Replace the stable route tree and recompute its branches */
|
|
1382
|
+
setRoutes(routes) {
|
|
1383
|
+
__privateSet(this, _routes, routes);
|
|
1384
|
+
__privateSet(this, _branches, flattenAndRankRoutes(routes));
|
|
1385
|
+
}
|
|
1386
|
+
/** Set a new in-flight route tree and recompute its branches */
|
|
1387
|
+
setHmrRoutes(routes) {
|
|
1388
|
+
__privateSet(this, _hmrRoutes, routes);
|
|
1389
|
+
__privateSet(this, _hmrBranches, flattenAndRankRoutes(routes));
|
|
1390
|
+
}
|
|
1391
|
+
/** Commit in-flight routes/branches to the stable slot and clear in-flight */
|
|
1392
|
+
commitHmrRoutes() {
|
|
1393
|
+
if (__privateGet(this, _hmrRoutes)) {
|
|
1394
|
+
__privateSet(this, _routes, __privateGet(this, _hmrRoutes));
|
|
1395
|
+
__privateSet(this, _branches, __privateGet(this, _hmrBranches));
|
|
1396
|
+
__privateSet(this, _hmrRoutes, void 0);
|
|
1397
|
+
__privateSet(this, _hmrBranches, void 0);
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
};
|
|
1401
|
+
_routes = new WeakMap();
|
|
1402
|
+
_branches = new WeakMap();
|
|
1403
|
+
_hmrRoutes = new WeakMap();
|
|
1404
|
+
_hmrBranches = new WeakMap();
|
|
1349
1405
|
function createRouter(init) {
|
|
1350
1406
|
const routerWindow = init.window ? init.window : typeof window !== "undefined" ? window : void 0;
|
|
1351
1407
|
const isBrowser2 = typeof routerWindow !== "undefined" && typeof routerWindow.document !== "undefined" && typeof routerWindow.document.createElement !== "undefined";
|
|
@@ -1356,8 +1412,8 @@ function createRouter(init) {
|
|
|
1356
1412
|
let hydrationRouteProperties2 = init.hydrationRouteProperties || [];
|
|
1357
1413
|
let _mapRouteProperties = init.mapRouteProperties || defaultMapRouteProperties;
|
|
1358
1414
|
let mapRouteProperties2 = _mapRouteProperties;
|
|
1359
|
-
if (init.
|
|
1360
|
-
let instrumentations = init.
|
|
1415
|
+
if (init.instrumentations) {
|
|
1416
|
+
let instrumentations = init.instrumentations;
|
|
1361
1417
|
mapRouteProperties2 = (route) => {
|
|
1362
1418
|
return {
|
|
1363
1419
|
..._mapRouteProperties(route),
|
|
@@ -1369,29 +1425,36 @@ function createRouter(init) {
|
|
|
1369
1425
|
};
|
|
1370
1426
|
}
|
|
1371
1427
|
let manifest = {};
|
|
1372
|
-
let dataRoutes =
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1428
|
+
let dataRoutes = new DataRoutes(
|
|
1429
|
+
convertRoutesToDataRoutes(
|
|
1430
|
+
init.routes,
|
|
1431
|
+
mapRouteProperties2,
|
|
1432
|
+
void 0,
|
|
1433
|
+
manifest
|
|
1434
|
+
)
|
|
1377
1435
|
);
|
|
1378
|
-
let inFlightDataRoutes;
|
|
1379
1436
|
let basename = init.basename || "/";
|
|
1380
1437
|
if (!basename.startsWith("/")) {
|
|
1381
1438
|
basename = `/${basename}`;
|
|
1382
1439
|
}
|
|
1383
1440
|
let dataStrategyImpl = init.dataStrategy || defaultDataStrategyWithMiddleware;
|
|
1384
1441
|
let future = {
|
|
1385
|
-
unstable_passThroughRequests: false,
|
|
1386
1442
|
...init.future
|
|
1387
1443
|
};
|
|
1388
1444
|
let unlistenHistory = null;
|
|
1389
1445
|
let subscribers = /* @__PURE__ */ new Set();
|
|
1446
|
+
let bufferedInitialStateUpdate = null;
|
|
1390
1447
|
let savedScrollPositions = null;
|
|
1391
1448
|
let getScrollRestorationKey = null;
|
|
1392
1449
|
let getScrollPosition = null;
|
|
1393
1450
|
let initialScrollRestored = init.hydrationData != null;
|
|
1394
|
-
let initialMatches =
|
|
1451
|
+
let initialMatches = matchRoutesImpl(
|
|
1452
|
+
dataRoutes.activeRoutes,
|
|
1453
|
+
init.history.location,
|
|
1454
|
+
basename,
|
|
1455
|
+
false,
|
|
1456
|
+
dataRoutes.branches
|
|
1457
|
+
);
|
|
1395
1458
|
let initialMatchesIsFOW = false;
|
|
1396
1459
|
let initialErrors = null;
|
|
1397
1460
|
let initialized;
|
|
@@ -1400,7 +1463,7 @@ function createRouter(init) {
|
|
|
1400
1463
|
let error = getInternalRouterError(404, {
|
|
1401
1464
|
pathname: init.history.location.pathname
|
|
1402
1465
|
});
|
|
1403
|
-
let { matches, route } = getShortCircuitMatches(dataRoutes);
|
|
1466
|
+
let { matches, route } = getShortCircuitMatches(dataRoutes.activeRoutes);
|
|
1404
1467
|
initialized = true;
|
|
1405
1468
|
renderFallback = !initialized;
|
|
1406
1469
|
initialMatches = matches;
|
|
@@ -1409,7 +1472,7 @@ function createRouter(init) {
|
|
|
1409
1472
|
if (initialMatches && !init.hydrationData) {
|
|
1410
1473
|
let fogOfWar = checkFogOfWar(
|
|
1411
1474
|
initialMatches,
|
|
1412
|
-
dataRoutes,
|
|
1475
|
+
dataRoutes.activeRoutes,
|
|
1413
1476
|
init.history.location.pathname
|
|
1414
1477
|
);
|
|
1415
1478
|
if (fogOfWar.active) {
|
|
@@ -1422,7 +1485,7 @@ function createRouter(init) {
|
|
|
1422
1485
|
initialMatches = [];
|
|
1423
1486
|
let fogOfWar = checkFogOfWar(
|
|
1424
1487
|
null,
|
|
1425
|
-
dataRoutes,
|
|
1488
|
+
dataRoutes.activeRoutes,
|
|
1426
1489
|
init.history.location.pathname
|
|
1427
1490
|
);
|
|
1428
1491
|
if (fogOfWar.active && fogOfWar.matches) {
|
|
@@ -1562,11 +1625,21 @@ function createRouter(init) {
|
|
|
1562
1625
|
}
|
|
1563
1626
|
subscribers.clear();
|
|
1564
1627
|
pendingNavigationController && pendingNavigationController.abort();
|
|
1565
|
-
state.fetchers.forEach((_, key) => deleteFetcher(key));
|
|
1628
|
+
state.fetchers.forEach((_, key) => deleteFetcher(state.fetchers, key));
|
|
1566
1629
|
state.blockers.forEach((_, key) => deleteBlocker(key));
|
|
1567
1630
|
}
|
|
1568
1631
|
function subscribe(fn) {
|
|
1569
1632
|
subscribers.add(fn);
|
|
1633
|
+
if (bufferedInitialStateUpdate) {
|
|
1634
|
+
let { newErrors } = bufferedInitialStateUpdate;
|
|
1635
|
+
bufferedInitialStateUpdate = null;
|
|
1636
|
+
fn(state, {
|
|
1637
|
+
deletedFetchers: [],
|
|
1638
|
+
newErrors,
|
|
1639
|
+
viewTransitionOpts: void 0,
|
|
1640
|
+
flushSync: false
|
|
1641
|
+
});
|
|
1642
|
+
}
|
|
1570
1643
|
return () => subscribers.delete(fn);
|
|
1571
1644
|
}
|
|
1572
1645
|
function updateState(newState, opts = {}) {
|
|
@@ -1603,6 +1676,9 @@ function createRouter(init) {
|
|
|
1603
1676
|
unmountedFetchers.push(key);
|
|
1604
1677
|
}
|
|
1605
1678
|
});
|
|
1679
|
+
if (subscribers.size === 0) {
|
|
1680
|
+
bufferedInitialStateUpdate = { newErrors: _nullishCoalesce(newState.errors, () => ( null)) };
|
|
1681
|
+
}
|
|
1606
1682
|
[...subscribers].forEach(
|
|
1607
1683
|
(subscriber) => subscriber(state, {
|
|
1608
1684
|
deletedFetchers: unmountedFetchers,
|
|
@@ -1611,7 +1687,7 @@ function createRouter(init) {
|
|
|
1611
1687
|
flushSync: opts.flushSync === true
|
|
1612
1688
|
})
|
|
1613
1689
|
);
|
|
1614
|
-
unmountedFetchers.forEach((key) => deleteFetcher(key));
|
|
1690
|
+
unmountedFetchers.forEach((key) => deleteFetcher(state.fetchers, key));
|
|
1615
1691
|
mountedFetchers.forEach((key) => state.fetchers.delete(key));
|
|
1616
1692
|
}
|
|
1617
1693
|
function completeNavigation(location, newState, { flushSync } = {}) {
|
|
@@ -1641,10 +1717,7 @@ function createRouter(init) {
|
|
|
1641
1717
|
}
|
|
1642
1718
|
let restoreScrollPosition = isUninterruptedRevalidation ? false : getSavedScrollPosition(location, newState.matches || state.matches);
|
|
1643
1719
|
let preventScrollReset = pendingPreventScrollReset === true || state.navigation.formMethod != null && isMutationMethod(state.navigation.formMethod) && _optionalChain([location, 'access', _11 => _11.state, 'optionalAccess', _12 => _12._isRedirect]) !== true;
|
|
1644
|
-
|
|
1645
|
-
dataRoutes = inFlightDataRoutes;
|
|
1646
|
-
inFlightDataRoutes = void 0;
|
|
1647
|
-
}
|
|
1720
|
+
dataRoutes.commitHmrRoutes();
|
|
1648
1721
|
if (isUninterruptedRevalidation) {
|
|
1649
1722
|
} else if (pendingAction === "POP" /* Pop */) {
|
|
1650
1723
|
} else if (pendingAction === "PUSH" /* Push */) {
|
|
@@ -1735,10 +1808,10 @@ function createRouter(init) {
|
|
|
1735
1808
|
opts
|
|
1736
1809
|
);
|
|
1737
1810
|
let maskPath;
|
|
1738
|
-
if (_optionalChain([opts, 'optionalAccess', _21 => _21.
|
|
1739
|
-
let partialPath = typeof opts.
|
|
1740
|
-
...state.location.
|
|
1741
|
-
...opts.
|
|
1811
|
+
if (_optionalChain([opts, 'optionalAccess', _21 => _21.mask])) {
|
|
1812
|
+
let partialPath = typeof opts.mask === "string" ? parsePath(opts.mask) : {
|
|
1813
|
+
...state.location.mask,
|
|
1814
|
+
...opts.mask
|
|
1742
1815
|
};
|
|
1743
1816
|
maskPath = {
|
|
1744
1817
|
pathname: "",
|
|
@@ -1804,7 +1877,7 @@ function createRouter(init) {
|
|
|
1804
1877
|
replace: opts && opts.replace,
|
|
1805
1878
|
enableViewTransition: opts && opts.viewTransition,
|
|
1806
1879
|
flushSync,
|
|
1807
|
-
callSiteDefaultShouldRevalidate: opts && opts.
|
|
1880
|
+
callSiteDefaultShouldRevalidate: opts && opts.defaultShouldRevalidate
|
|
1808
1881
|
});
|
|
1809
1882
|
}
|
|
1810
1883
|
function revalidate() {
|
|
@@ -1842,12 +1915,17 @@ function createRouter(init) {
|
|
|
1842
1915
|
saveScrollPosition(state.location, state.matches);
|
|
1843
1916
|
pendingPreventScrollReset = (opts && opts.preventScrollReset) === true;
|
|
1844
1917
|
pendingViewTransitionEnabled = (opts && opts.enableViewTransition) === true;
|
|
1845
|
-
let routesToUse =
|
|
1846
|
-
let loadingNavigation = opts && opts.overrideNavigation;
|
|
1918
|
+
let routesToUse = dataRoutes.activeRoutes;
|
|
1847
1919
|
let matches = _optionalChain([opts, 'optionalAccess', _22 => _22.initialHydration]) && state.matches && state.matches.length > 0 && !initialMatchesIsFOW ? (
|
|
1848
1920
|
// `matchRoutes()` has already been called if we're in here via `router.initialize()`
|
|
1849
1921
|
state.matches
|
|
1850
|
-
) :
|
|
1922
|
+
) : matchRoutesImpl(
|
|
1923
|
+
routesToUse,
|
|
1924
|
+
location,
|
|
1925
|
+
basename,
|
|
1926
|
+
false,
|
|
1927
|
+
dataRoutes.branches
|
|
1928
|
+
);
|
|
1851
1929
|
let flushSync = (opts && opts.flushSync) === true;
|
|
1852
1930
|
if (matches && state.initialized && !isRevalidationRequired && isHashChangeOnly(state.location, location) && !(opts && opts.submission && isMutationMethod(opts.submission.formMethod))) {
|
|
1853
1931
|
completeNavigation(location, { matches }, { flushSync });
|
|
@@ -1874,6 +1952,11 @@ function createRouter(init) {
|
|
|
1874
1952
|
);
|
|
1875
1953
|
return;
|
|
1876
1954
|
}
|
|
1955
|
+
let loadingNavigation = opts && opts.overrideNavigation ? {
|
|
1956
|
+
...opts.overrideNavigation,
|
|
1957
|
+
matches,
|
|
1958
|
+
historyAction
|
|
1959
|
+
} : void 0;
|
|
1877
1960
|
pendingNavigationController = new AbortController();
|
|
1878
1961
|
let request = createClientSideRequest(
|
|
1879
1962
|
init.history,
|
|
@@ -1894,6 +1977,7 @@ function createRouter(init) {
|
|
|
1894
1977
|
location,
|
|
1895
1978
|
opts.submission,
|
|
1896
1979
|
matches,
|
|
1980
|
+
historyAction,
|
|
1897
1981
|
scopedContext,
|
|
1898
1982
|
fogOfWar.active,
|
|
1899
1983
|
opts && opts.initialHydration === true,
|
|
@@ -1918,7 +2002,12 @@ function createRouter(init) {
|
|
|
1918
2002
|
}
|
|
1919
2003
|
matches = actionResult.matches || matches;
|
|
1920
2004
|
pendingActionResult = actionResult.pendingActionResult;
|
|
1921
|
-
loadingNavigation = getLoadingNavigation(
|
|
2005
|
+
loadingNavigation = getLoadingNavigation(
|
|
2006
|
+
location,
|
|
2007
|
+
matches,
|
|
2008
|
+
historyAction,
|
|
2009
|
+
opts.submission
|
|
2010
|
+
);
|
|
1922
2011
|
flushSync = false;
|
|
1923
2012
|
fogOfWar.active = false;
|
|
1924
2013
|
request = createClientSideRequest(
|
|
@@ -1931,11 +2020,13 @@ function createRouter(init) {
|
|
|
1931
2020
|
shortCircuited,
|
|
1932
2021
|
matches: updatedMatches,
|
|
1933
2022
|
loaderData,
|
|
1934
|
-
errors
|
|
2023
|
+
errors,
|
|
2024
|
+
workingFetchers
|
|
1935
2025
|
} = await handleLoaders(
|
|
1936
2026
|
request,
|
|
1937
2027
|
location,
|
|
1938
2028
|
matches,
|
|
2029
|
+
historyAction,
|
|
1939
2030
|
scopedContext,
|
|
1940
2031
|
fogOfWar.active,
|
|
1941
2032
|
loadingNavigation,
|
|
@@ -1955,12 +2046,18 @@ function createRouter(init) {
|
|
|
1955
2046
|
matches: updatedMatches || matches,
|
|
1956
2047
|
...getActionDataForCommit(pendingActionResult),
|
|
1957
2048
|
loaderData,
|
|
1958
|
-
errors
|
|
2049
|
+
errors,
|
|
2050
|
+
...workingFetchers ? { fetchers: workingFetchers } : {}
|
|
1959
2051
|
});
|
|
1960
2052
|
}
|
|
1961
|
-
async function handleAction(request, location, submission, matches, scopedContext, isFogOfWar, initialHydration, opts = {}) {
|
|
2053
|
+
async function handleAction(request, location, submission, matches, historyAction, scopedContext, isFogOfWar, initialHydration, opts = {}) {
|
|
1962
2054
|
interruptActiveLoads();
|
|
1963
|
-
let navigation = getSubmittingNavigation(
|
|
2055
|
+
let navigation = getSubmittingNavigation(
|
|
2056
|
+
location,
|
|
2057
|
+
matches,
|
|
2058
|
+
historyAction,
|
|
2059
|
+
submission
|
|
2060
|
+
);
|
|
1964
2061
|
updateState({ navigation }, { flushSync: opts.flushSync === true });
|
|
1965
2062
|
if (isFogOfWar) {
|
|
1966
2063
|
let discoverResult = await discoverRoutes(
|
|
@@ -1972,7 +2069,9 @@ function createRouter(init) {
|
|
|
1972
2069
|
return { shortCircuited: true };
|
|
1973
2070
|
} else if (discoverResult.type === "error") {
|
|
1974
2071
|
if (discoverResult.partialMatches.length === 0) {
|
|
1975
|
-
let { matches: matches2, route } = getShortCircuitMatches(
|
|
2072
|
+
let { matches: matches2, route } = getShortCircuitMatches(
|
|
2073
|
+
dataRoutes.activeRoutes
|
|
2074
|
+
);
|
|
1976
2075
|
return {
|
|
1977
2076
|
matches: matches2,
|
|
1978
2077
|
pendingActionResult: [
|
|
@@ -2093,8 +2192,8 @@ function createRouter(init) {
|
|
|
2093
2192
|
pendingActionResult: [actionMatch.route.id, result]
|
|
2094
2193
|
};
|
|
2095
2194
|
}
|
|
2096
|
-
async function handleLoaders(request, location, matches, scopedContext, isFogOfWar, overrideNavigation, submission, fetcherSubmission, replace2, initialHydration, flushSync, pendingActionResult, callSiteDefaultShouldRevalidate) {
|
|
2097
|
-
let loadingNavigation = overrideNavigation || getLoadingNavigation(location, submission);
|
|
2195
|
+
async function handleLoaders(request, location, matches, historyAction, scopedContext, isFogOfWar, overrideNavigation, submission, fetcherSubmission, replace2, initialHydration, flushSync, pendingActionResult, callSiteDefaultShouldRevalidate) {
|
|
2196
|
+
let loadingNavigation = overrideNavigation || getLoadingNavigation(location, matches, historyAction, submission);
|
|
2098
2197
|
let activeSubmission = submission || fetcherSubmission || getSubmissionFromNavigation(loadingNavigation);
|
|
2099
2198
|
let shouldUpdateNavigationState = !isUninterruptedRevalidation && !initialHydration;
|
|
2100
2199
|
if (isFogOfWar) {
|
|
@@ -2119,7 +2218,9 @@ function createRouter(init) {
|
|
|
2119
2218
|
return { shortCircuited: true };
|
|
2120
2219
|
} else if (discoverResult.type === "error") {
|
|
2121
2220
|
if (discoverResult.partialMatches.length === 0) {
|
|
2122
|
-
let { matches: matches2, route } = getShortCircuitMatches(
|
|
2221
|
+
let { matches: matches2, route } = getShortCircuitMatches(
|
|
2222
|
+
dataRoutes.activeRoutes
|
|
2223
|
+
);
|
|
2123
2224
|
return {
|
|
2124
2225
|
matches: matches2,
|
|
2125
2226
|
loaderData: {},
|
|
@@ -2151,7 +2252,7 @@ function createRouter(init) {
|
|
|
2151
2252
|
matches = discoverResult.matches;
|
|
2152
2253
|
}
|
|
2153
2254
|
}
|
|
2154
|
-
let routesToUse =
|
|
2255
|
+
let routesToUse = dataRoutes.activeRoutes;
|
|
2155
2256
|
let { dsMatches, revalidatingFetchers } = getMatchesToLoad(
|
|
2156
2257
|
request,
|
|
2157
2258
|
scopedContext,
|
|
@@ -2172,6 +2273,7 @@ function createRouter(init) {
|
|
|
2172
2273
|
routesToUse,
|
|
2173
2274
|
basename,
|
|
2174
2275
|
init.patchRoutesOnNavigation != null,
|
|
2276
|
+
dataRoutes.branches,
|
|
2175
2277
|
pendingActionResult,
|
|
2176
2278
|
callSiteDefaultShouldRevalidate
|
|
2177
2279
|
);
|
|
@@ -2179,7 +2281,8 @@ function createRouter(init) {
|
|
|
2179
2281
|
if (!init.dataStrategy && !dsMatches.some((m) => m.shouldLoad) && !dsMatches.some(
|
|
2180
2282
|
(m) => m.route.middleware && m.route.middleware.length > 0
|
|
2181
2283
|
) && revalidatingFetchers.length === 0) {
|
|
2182
|
-
let
|
|
2284
|
+
let workingFetchers2 = new Map(state.fetchers);
|
|
2285
|
+
let didUpdateFetcherRedirects2 = markFetchRedirectsDone(workingFetchers2);
|
|
2183
2286
|
completeNavigation(
|
|
2184
2287
|
location,
|
|
2185
2288
|
{
|
|
@@ -2188,7 +2291,7 @@ function createRouter(init) {
|
|
|
2188
2291
|
// Commit pending error if we're short circuiting
|
|
2189
2292
|
errors: pendingActionResult && isErrorResult(pendingActionResult[1]) ? { [pendingActionResult[0]]: pendingActionResult[1].error } : null,
|
|
2190
2293
|
...getActionDataForCommit(pendingActionResult),
|
|
2191
|
-
...
|
|
2294
|
+
...didUpdateFetcherRedirects2 ? { fetchers: workingFetchers2 } : {}
|
|
2192
2295
|
},
|
|
2193
2296
|
{ flushSync }
|
|
2194
2297
|
);
|
|
@@ -2253,25 +2356,30 @@ function createRouter(init) {
|
|
|
2253
2356
|
});
|
|
2254
2357
|
return { shortCircuited: true };
|
|
2255
2358
|
}
|
|
2359
|
+
let workingFetchers = new Map(state.fetchers);
|
|
2256
2360
|
let { loaderData, errors } = processLoaderData(
|
|
2257
2361
|
state,
|
|
2258
2362
|
matches,
|
|
2259
2363
|
loaderResults,
|
|
2260
2364
|
pendingActionResult,
|
|
2261
2365
|
revalidatingFetchers,
|
|
2262
|
-
fetcherResults
|
|
2366
|
+
fetcherResults,
|
|
2367
|
+
workingFetchers
|
|
2263
2368
|
);
|
|
2264
2369
|
if (initialHydration && state.errors) {
|
|
2265
2370
|
errors = { ...state.errors, ...errors };
|
|
2266
2371
|
}
|
|
2267
|
-
let
|
|
2268
|
-
let didAbortFetchLoads = abortStaleFetchLoads(
|
|
2269
|
-
|
|
2372
|
+
let didUpdateFetcherRedirects = markFetchRedirectsDone(workingFetchers);
|
|
2373
|
+
let didAbortFetchLoads = abortStaleFetchLoads(
|
|
2374
|
+
pendingNavigationLoadId,
|
|
2375
|
+
workingFetchers
|
|
2376
|
+
);
|
|
2377
|
+
let shouldUpdateFetchers = didUpdateFetcherRedirects || didAbortFetchLoads || revalidatingFetchers.length > 0;
|
|
2270
2378
|
return {
|
|
2271
2379
|
matches,
|
|
2272
2380
|
loaderData,
|
|
2273
2381
|
errors,
|
|
2274
|
-
...shouldUpdateFetchers ? {
|
|
2382
|
+
...shouldUpdateFetchers ? { workingFetchers } : {}
|
|
2275
2383
|
};
|
|
2276
2384
|
}
|
|
2277
2385
|
function getUpdatedActionData(pendingActionResult) {
|
|
@@ -2288,20 +2396,21 @@ function createRouter(init) {
|
|
|
2288
2396
|
}
|
|
2289
2397
|
}
|
|
2290
2398
|
function getUpdatedRevalidatingFetchers(revalidatingFetchers) {
|
|
2399
|
+
let workingFetchers = new Map(state.fetchers);
|
|
2291
2400
|
revalidatingFetchers.forEach((rf) => {
|
|
2292
|
-
let fetcher =
|
|
2401
|
+
let fetcher = workingFetchers.get(rf.key);
|
|
2293
2402
|
let revalidatingFetcher = getLoadingFetcher(
|
|
2294
2403
|
void 0,
|
|
2295
2404
|
fetcher ? fetcher.data : void 0
|
|
2296
2405
|
);
|
|
2297
|
-
|
|
2406
|
+
workingFetchers.set(rf.key, revalidatingFetcher);
|
|
2298
2407
|
});
|
|
2299
|
-
return
|
|
2408
|
+
return workingFetchers;
|
|
2300
2409
|
}
|
|
2301
2410
|
async function fetch2(key, routeId, href, opts) {
|
|
2302
2411
|
abortFetcher(key);
|
|
2303
2412
|
let flushSync = (opts && opts.flushSync) === true;
|
|
2304
|
-
let routesToUse =
|
|
2413
|
+
let routesToUse = dataRoutes.activeRoutes;
|
|
2305
2414
|
let normalizedPath = normalizeTo(
|
|
2306
2415
|
state.location,
|
|
2307
2416
|
state.matches,
|
|
@@ -2310,7 +2419,13 @@ function createRouter(init) {
|
|
|
2310
2419
|
routeId,
|
|
2311
2420
|
_optionalChain([opts, 'optionalAccess', _23 => _23.relative])
|
|
2312
2421
|
);
|
|
2313
|
-
let matches =
|
|
2422
|
+
let matches = matchRoutesImpl(
|
|
2423
|
+
routesToUse,
|
|
2424
|
+
normalizedPath,
|
|
2425
|
+
basename,
|
|
2426
|
+
false,
|
|
2427
|
+
dataRoutes.branches
|
|
2428
|
+
);
|
|
2314
2429
|
let fogOfWar = checkFogOfWar(matches, routesToUse, normalizedPath);
|
|
2315
2430
|
if (fogOfWar.active && fogOfWar.matches) {
|
|
2316
2431
|
matches = fogOfWar.matches;
|
|
@@ -2346,7 +2461,7 @@ function createRouter(init) {
|
|
|
2346
2461
|
flushSync,
|
|
2347
2462
|
preventScrollReset,
|
|
2348
2463
|
submission,
|
|
2349
|
-
opts && opts.
|
|
2464
|
+
opts && opts.defaultShouldRevalidate
|
|
2350
2465
|
);
|
|
2351
2466
|
return;
|
|
2352
2467
|
}
|
|
@@ -2476,13 +2591,17 @@ function createRouter(init) {
|
|
|
2476
2591
|
nextLocation,
|
|
2477
2592
|
abortController.signal
|
|
2478
2593
|
);
|
|
2479
|
-
let routesToUse =
|
|
2480
|
-
let matches = state.navigation.state !== "idle" ?
|
|
2594
|
+
let routesToUse = dataRoutes.activeRoutes;
|
|
2595
|
+
let matches = state.navigation.state !== "idle" ? matchRoutesImpl(
|
|
2596
|
+
routesToUse,
|
|
2597
|
+
state.navigation.location,
|
|
2598
|
+
basename,
|
|
2599
|
+
false,
|
|
2600
|
+
dataRoutes.branches
|
|
2601
|
+
) : state.matches;
|
|
2481
2602
|
invariant(matches, "Didn't find any matches after fetcher action");
|
|
2482
2603
|
let loadId = ++incrementingLoadId;
|
|
2483
2604
|
fetchReloadIds.set(key, loadId);
|
|
2484
|
-
let loadFetcher = getLoadingFetcher(submission, actionResult.data);
|
|
2485
|
-
state.fetchers.set(key, loadFetcher);
|
|
2486
2605
|
let { dsMatches, revalidatingFetchers } = getMatchesToLoad(
|
|
2487
2606
|
revalidationRequest,
|
|
2488
2607
|
scopedContext,
|
|
@@ -2503,23 +2622,27 @@ function createRouter(init) {
|
|
|
2503
2622
|
routesToUse,
|
|
2504
2623
|
basename,
|
|
2505
2624
|
init.patchRoutesOnNavigation != null,
|
|
2625
|
+
dataRoutes.branches,
|
|
2506
2626
|
[match.route.id, actionResult],
|
|
2507
2627
|
callSiteDefaultShouldRevalidate
|
|
2508
2628
|
);
|
|
2629
|
+
let loadFetcher = getLoadingFetcher(submission, actionResult.data);
|
|
2630
|
+
let workingFetchers = new Map(state.fetchers);
|
|
2631
|
+
workingFetchers.set(key, loadFetcher);
|
|
2509
2632
|
revalidatingFetchers.filter((rf) => rf.key !== key).forEach((rf) => {
|
|
2510
2633
|
let staleKey = rf.key;
|
|
2511
|
-
let existingFetcher2 =
|
|
2634
|
+
let existingFetcher2 = workingFetchers.get(staleKey);
|
|
2512
2635
|
let revalidatingFetcher = getLoadingFetcher(
|
|
2513
2636
|
void 0,
|
|
2514
2637
|
existingFetcher2 ? existingFetcher2.data : void 0
|
|
2515
2638
|
);
|
|
2516
|
-
|
|
2639
|
+
workingFetchers.set(staleKey, revalidatingFetcher);
|
|
2517
2640
|
abortFetcher(staleKey);
|
|
2518
2641
|
if (rf.controller) {
|
|
2519
2642
|
fetchControllers.set(staleKey, rf.controller);
|
|
2520
2643
|
}
|
|
2521
2644
|
});
|
|
2522
|
-
updateState({ fetchers:
|
|
2645
|
+
updateState({ fetchers: workingFetchers });
|
|
2523
2646
|
let abortPendingFetchRevalidations = () => revalidatingFetchers.forEach((rf) => abortFetcher(rf.key));
|
|
2524
2647
|
abortController.signal.addEventListener(
|
|
2525
2648
|
"abort",
|
|
@@ -2542,12 +2665,16 @@ function createRouter(init) {
|
|
|
2542
2665
|
fetchReloadIds.delete(key);
|
|
2543
2666
|
fetchControllers.delete(key);
|
|
2544
2667
|
revalidatingFetchers.forEach((r) => fetchControllers.delete(r.key));
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2668
|
+
let fetcherIsMounted = state.fetchers.has(key);
|
|
2669
|
+
let getRedirectStateWithDoneFetcher = (s) => {
|
|
2670
|
+
if (!fetcherIsMounted) return s;
|
|
2671
|
+
let workingFetchers2 = new Map(s.fetchers);
|
|
2672
|
+
workingFetchers2.set(key, getDoneFetcher(actionResult.data));
|
|
2673
|
+
return { ...s, fetchers: workingFetchers2 };
|
|
2674
|
+
};
|
|
2549
2675
|
let redirect2 = findRedirect(loaderResults);
|
|
2550
2676
|
if (redirect2) {
|
|
2677
|
+
state = getRedirectStateWithDoneFetcher(state);
|
|
2551
2678
|
return startRedirectNavigation(
|
|
2552
2679
|
revalidationRequest,
|
|
2553
2680
|
redirect2.result,
|
|
@@ -2558,6 +2685,7 @@ function createRouter(init) {
|
|
|
2558
2685
|
redirect2 = findRedirect(fetcherResults);
|
|
2559
2686
|
if (redirect2) {
|
|
2560
2687
|
fetchRedirectIds.add(redirect2.key);
|
|
2688
|
+
state = getRedirectStateWithDoneFetcher(state);
|
|
2561
2689
|
return startRedirectNavigation(
|
|
2562
2690
|
revalidationRequest,
|
|
2563
2691
|
redirect2.result,
|
|
@@ -2565,15 +2693,20 @@ function createRouter(init) {
|
|
|
2565
2693
|
{ preventScrollReset }
|
|
2566
2694
|
);
|
|
2567
2695
|
}
|
|
2696
|
+
let finalFetchers = new Map(state.fetchers);
|
|
2697
|
+
if (fetcherIsMounted) {
|
|
2698
|
+
finalFetchers.set(key, getDoneFetcher(actionResult.data));
|
|
2699
|
+
}
|
|
2568
2700
|
let { loaderData, errors } = processLoaderData(
|
|
2569
2701
|
state,
|
|
2570
2702
|
matches,
|
|
2571
2703
|
loaderResults,
|
|
2572
2704
|
void 0,
|
|
2573
2705
|
revalidatingFetchers,
|
|
2574
|
-
fetcherResults
|
|
2706
|
+
fetcherResults,
|
|
2707
|
+
finalFetchers
|
|
2575
2708
|
);
|
|
2576
|
-
abortStaleFetchLoads(loadId);
|
|
2709
|
+
abortStaleFetchLoads(loadId, finalFetchers);
|
|
2577
2710
|
if (state.navigation.state === "loading" && loadId > pendingNavigationLoadId) {
|
|
2578
2711
|
invariant(pendingAction, "Expected pending action");
|
|
2579
2712
|
pendingNavigationController && pendingNavigationController.abort();
|
|
@@ -2581,7 +2714,7 @@ function createRouter(init) {
|
|
|
2581
2714
|
matches,
|
|
2582
2715
|
loaderData,
|
|
2583
2716
|
errors,
|
|
2584
|
-
fetchers:
|
|
2717
|
+
fetchers: finalFetchers
|
|
2585
2718
|
});
|
|
2586
2719
|
} else {
|
|
2587
2720
|
updateState({
|
|
@@ -2592,7 +2725,7 @@ function createRouter(init) {
|
|
|
2592
2725
|
matches,
|
|
2593
2726
|
errors
|
|
2594
2727
|
),
|
|
2595
|
-
fetchers:
|
|
2728
|
+
fetchers: finalFetchers
|
|
2596
2729
|
});
|
|
2597
2730
|
isRevalidationRequired = false;
|
|
2598
2731
|
}
|
|
@@ -2757,6 +2890,8 @@ function createRouter(init) {
|
|
|
2757
2890
|
} else {
|
|
2758
2891
|
let overrideNavigation = getLoadingNavigation(
|
|
2759
2892
|
redirectLocation,
|
|
2893
|
+
[],
|
|
2894
|
+
redirectNavigationType,
|
|
2760
2895
|
submission
|
|
2761
2896
|
);
|
|
2762
2897
|
await startNavigation(redirectNavigationType, redirectLocation, {
|
|
@@ -2880,21 +3015,23 @@ function createRouter(init) {
|
|
|
2880
3015
|
});
|
|
2881
3016
|
}
|
|
2882
3017
|
function updateFetcherState(key, fetcher, opts = {}) {
|
|
2883
|
-
state.fetchers
|
|
3018
|
+
let workingFetchers = new Map(state.fetchers);
|
|
3019
|
+
workingFetchers.set(key, fetcher);
|
|
2884
3020
|
updateState(
|
|
2885
|
-
{ fetchers:
|
|
3021
|
+
{ fetchers: workingFetchers },
|
|
2886
3022
|
{ flushSync: (opts && opts.flushSync) === true }
|
|
2887
3023
|
);
|
|
2888
3024
|
}
|
|
2889
3025
|
function setFetcherError(key, routeId, error, opts = {}) {
|
|
2890
3026
|
let boundaryMatch = findNearestBoundary(state.matches, routeId);
|
|
2891
|
-
|
|
3027
|
+
let workingFetchers = new Map(state.fetchers);
|
|
3028
|
+
deleteFetcher(workingFetchers, key);
|
|
2892
3029
|
updateState(
|
|
2893
3030
|
{
|
|
2894
3031
|
errors: {
|
|
2895
3032
|
[boundaryMatch.route.id]: error
|
|
2896
3033
|
},
|
|
2897
|
-
fetchers:
|
|
3034
|
+
fetchers: workingFetchers
|
|
2898
3035
|
},
|
|
2899
3036
|
{ flushSync: (opts && opts.flushSync) === true }
|
|
2900
3037
|
);
|
|
@@ -2910,7 +3047,7 @@ function createRouter(init) {
|
|
|
2910
3047
|
abortFetcher(key, _optionalChain([opts, 'optionalAccess', _28 => _28.reason]));
|
|
2911
3048
|
updateFetcherState(key, getDoneFetcher(null));
|
|
2912
3049
|
}
|
|
2913
|
-
function deleteFetcher(key) {
|
|
3050
|
+
function deleteFetcher(fetchers, key) {
|
|
2914
3051
|
let fetcher = state.fetchers.get(key);
|
|
2915
3052
|
if (fetchControllers.has(key) && !(fetcher && fetcher.state === "loading" && fetchReloadIds.has(key))) {
|
|
2916
3053
|
abortFetcher(key);
|
|
@@ -2920,7 +3057,7 @@ function createRouter(init) {
|
|
|
2920
3057
|
fetchRedirectIds.delete(key);
|
|
2921
3058
|
fetchersQueuedForDeletion.delete(key);
|
|
2922
3059
|
cancelledFetcherLoads.delete(key);
|
|
2923
|
-
|
|
3060
|
+
fetchers.delete(key);
|
|
2924
3061
|
}
|
|
2925
3062
|
function queueFetcherForDeletion(key) {
|
|
2926
3063
|
let count = (activeFetchers.get(key) || 0) - 1;
|
|
@@ -2939,33 +3076,34 @@ function createRouter(init) {
|
|
|
2939
3076
|
fetchControllers.delete(key);
|
|
2940
3077
|
}
|
|
2941
3078
|
}
|
|
2942
|
-
function markFetchersDone(keys) {
|
|
3079
|
+
function markFetchersDone(keys, fetchers) {
|
|
2943
3080
|
for (let key of keys) {
|
|
2944
|
-
let fetcher =
|
|
3081
|
+
let fetcher = fetchers.get(key);
|
|
3082
|
+
invariant(fetcher, `Expected fetcher: ${key}`);
|
|
2945
3083
|
let doneFetcher = getDoneFetcher(fetcher.data);
|
|
2946
|
-
|
|
3084
|
+
fetchers.set(key, doneFetcher);
|
|
2947
3085
|
}
|
|
2948
3086
|
}
|
|
2949
|
-
function markFetchRedirectsDone() {
|
|
3087
|
+
function markFetchRedirectsDone(fetchers) {
|
|
2950
3088
|
let doneKeys = [];
|
|
2951
|
-
let
|
|
3089
|
+
let didUpdateFetchers = false;
|
|
2952
3090
|
for (let key of fetchRedirectIds) {
|
|
2953
|
-
let fetcher =
|
|
3091
|
+
let fetcher = fetchers.get(key);
|
|
2954
3092
|
invariant(fetcher, `Expected fetcher: ${key}`);
|
|
2955
3093
|
if (fetcher.state === "loading") {
|
|
2956
3094
|
fetchRedirectIds.delete(key);
|
|
2957
3095
|
doneKeys.push(key);
|
|
2958
|
-
|
|
3096
|
+
didUpdateFetchers = true;
|
|
2959
3097
|
}
|
|
2960
3098
|
}
|
|
2961
|
-
markFetchersDone(doneKeys);
|
|
2962
|
-
return
|
|
3099
|
+
markFetchersDone(doneKeys, fetchers);
|
|
3100
|
+
return didUpdateFetchers;
|
|
2963
3101
|
}
|
|
2964
|
-
function abortStaleFetchLoads(landedId) {
|
|
3102
|
+
function abortStaleFetchLoads(landedId, fetchers) {
|
|
2965
3103
|
let yeetedKeys = [];
|
|
2966
3104
|
for (let [key, id] of fetchReloadIds) {
|
|
2967
3105
|
if (id < landedId) {
|
|
2968
|
-
let fetcher =
|
|
3106
|
+
let fetcher = fetchers.get(key);
|
|
2969
3107
|
invariant(fetcher, `Expected fetcher: ${key}`);
|
|
2970
3108
|
if (fetcher.state === "loading") {
|
|
2971
3109
|
abortFetcher(key);
|
|
@@ -2974,7 +3112,7 @@ function createRouter(init) {
|
|
|
2974
3112
|
}
|
|
2975
3113
|
}
|
|
2976
3114
|
}
|
|
2977
|
-
markFetchersDone(yeetedKeys);
|
|
3115
|
+
markFetchersDone(yeetedKeys, fetchers);
|
|
2978
3116
|
return yeetedKeys.length > 0;
|
|
2979
3117
|
}
|
|
2980
3118
|
function getBlocker(key, fn) {
|
|
@@ -3021,7 +3159,7 @@ function createRouter(init) {
|
|
|
3021
3159
|
}
|
|
3022
3160
|
function handleNavigational404(pathname) {
|
|
3023
3161
|
let error = getInternalRouterError(404, { pathname });
|
|
3024
|
-
let routesToUse =
|
|
3162
|
+
let routesToUse = dataRoutes.activeRoutes;
|
|
3025
3163
|
let { matches, route } = getShortCircuitMatches(routesToUse);
|
|
3026
3164
|
return { notFoundMatches: matches, route, error };
|
|
3027
3165
|
}
|
|
@@ -3070,12 +3208,14 @@ function createRouter(init) {
|
|
|
3070
3208
|
}
|
|
3071
3209
|
function checkFogOfWar(matches, routesToUse, pathname) {
|
|
3072
3210
|
if (init.patchRoutesOnNavigation) {
|
|
3211
|
+
let activeBranches = dataRoutes.branches;
|
|
3073
3212
|
if (!matches) {
|
|
3074
3213
|
let fogMatches = matchRoutesImpl(
|
|
3075
3214
|
routesToUse,
|
|
3076
3215
|
pathname,
|
|
3077
3216
|
basename,
|
|
3078
|
-
true
|
|
3217
|
+
true,
|
|
3218
|
+
activeBranches
|
|
3079
3219
|
);
|
|
3080
3220
|
return { active: true, matches: fogMatches || [] };
|
|
3081
3221
|
} else {
|
|
@@ -3084,7 +3224,8 @@ function createRouter(init) {
|
|
|
3084
3224
|
routesToUse,
|
|
3085
3225
|
pathname,
|
|
3086
3226
|
basename,
|
|
3087
|
-
true
|
|
3227
|
+
true,
|
|
3228
|
+
activeBranches
|
|
3088
3229
|
);
|
|
3089
3230
|
return { active: true, matches: partialMatches };
|
|
3090
3231
|
}
|
|
@@ -3098,8 +3239,6 @@ function createRouter(init) {
|
|
|
3098
3239
|
}
|
|
3099
3240
|
let partialMatches = matches;
|
|
3100
3241
|
while (true) {
|
|
3101
|
-
let isNonHMR = inFlightDataRoutes == null;
|
|
3102
|
-
let routesToUse = inFlightDataRoutes || dataRoutes;
|
|
3103
3242
|
let localManifest = manifest;
|
|
3104
3243
|
try {
|
|
3105
3244
|
await init.patchRoutesOnNavigation({
|
|
@@ -3112,7 +3251,7 @@ function createRouter(init) {
|
|
|
3112
3251
|
patchRoutesImpl(
|
|
3113
3252
|
routeId,
|
|
3114
3253
|
children,
|
|
3115
|
-
|
|
3254
|
+
dataRoutes,
|
|
3116
3255
|
localManifest,
|
|
3117
3256
|
mapRouteProperties2,
|
|
3118
3257
|
false
|
|
@@ -3121,25 +3260,29 @@ function createRouter(init) {
|
|
|
3121
3260
|
});
|
|
3122
3261
|
} catch (e) {
|
|
3123
3262
|
return { type: "error", error: e, partialMatches };
|
|
3124
|
-
} finally {
|
|
3125
|
-
if (isNonHMR && !signal.aborted) {
|
|
3126
|
-
dataRoutes = [...dataRoutes];
|
|
3127
|
-
}
|
|
3128
3263
|
}
|
|
3129
3264
|
if (signal.aborted) {
|
|
3130
3265
|
return { type: "aborted" };
|
|
3131
3266
|
}
|
|
3132
|
-
let
|
|
3267
|
+
let activeBranches = dataRoutes.branches;
|
|
3268
|
+
let newMatches = matchRoutesImpl(
|
|
3269
|
+
dataRoutes.activeRoutes,
|
|
3270
|
+
pathname,
|
|
3271
|
+
basename,
|
|
3272
|
+
false,
|
|
3273
|
+
activeBranches
|
|
3274
|
+
);
|
|
3133
3275
|
let newPartialMatches = null;
|
|
3134
3276
|
if (newMatches) {
|
|
3135
3277
|
if (Object.keys(newMatches[0].params).length === 0) {
|
|
3136
3278
|
return { type: "success", matches: newMatches };
|
|
3137
3279
|
} else {
|
|
3138
3280
|
newPartialMatches = matchRoutesImpl(
|
|
3139
|
-
|
|
3281
|
+
dataRoutes.activeRoutes,
|
|
3140
3282
|
pathname,
|
|
3141
3283
|
basename,
|
|
3142
|
-
true
|
|
3284
|
+
true,
|
|
3285
|
+
activeBranches
|
|
3143
3286
|
);
|
|
3144
3287
|
let matchedDeeper = newPartialMatches && partialMatches.length < newPartialMatches.length && compareMatches(
|
|
3145
3288
|
partialMatches,
|
|
@@ -3152,10 +3295,11 @@ function createRouter(init) {
|
|
|
3152
3295
|
}
|
|
3153
3296
|
if (!newPartialMatches) {
|
|
3154
3297
|
newPartialMatches = matchRoutesImpl(
|
|
3155
|
-
|
|
3298
|
+
dataRoutes.activeRoutes,
|
|
3156
3299
|
pathname,
|
|
3157
3300
|
basename,
|
|
3158
|
-
true
|
|
3301
|
+
true,
|
|
3302
|
+
activeBranches
|
|
3159
3303
|
);
|
|
3160
3304
|
}
|
|
3161
3305
|
if (!newPartialMatches || compareMatches(partialMatches, newPartialMatches)) {
|
|
@@ -3169,26 +3313,25 @@ function createRouter(init) {
|
|
|
3169
3313
|
}
|
|
3170
3314
|
function _internalSetRoutes(newRoutes) {
|
|
3171
3315
|
manifest = {};
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3316
|
+
dataRoutes.setHmrRoutes(
|
|
3317
|
+
convertRoutesToDataRoutes(
|
|
3318
|
+
newRoutes,
|
|
3319
|
+
mapRouteProperties2,
|
|
3320
|
+
void 0,
|
|
3321
|
+
manifest
|
|
3322
|
+
)
|
|
3177
3323
|
);
|
|
3178
3324
|
}
|
|
3179
3325
|
function patchRoutes(routeId, children, unstable_allowElementMutations = false) {
|
|
3180
|
-
let isNonHMR = inFlightDataRoutes == null;
|
|
3181
|
-
let routesToUse = inFlightDataRoutes || dataRoutes;
|
|
3182
3326
|
patchRoutesImpl(
|
|
3183
3327
|
routeId,
|
|
3184
3328
|
children,
|
|
3185
|
-
|
|
3329
|
+
dataRoutes,
|
|
3186
3330
|
manifest,
|
|
3187
3331
|
mapRouteProperties2,
|
|
3188
3332
|
unstable_allowElementMutations
|
|
3189
3333
|
);
|
|
3190
|
-
if (
|
|
3191
|
-
dataRoutes = [...dataRoutes];
|
|
3334
|
+
if (!dataRoutes.hasHMRRoutes) {
|
|
3192
3335
|
updateState({});
|
|
3193
3336
|
}
|
|
3194
3337
|
}
|
|
@@ -3203,7 +3346,13 @@ function createRouter(init) {
|
|
|
3203
3346
|
return state;
|
|
3204
3347
|
},
|
|
3205
3348
|
get routes() {
|
|
3206
|
-
return dataRoutes;
|
|
3349
|
+
return dataRoutes.stableRoutes;
|
|
3350
|
+
},
|
|
3351
|
+
get branches() {
|
|
3352
|
+
return dataRoutes.branches;
|
|
3353
|
+
},
|
|
3354
|
+
get manifest() {
|
|
3355
|
+
return manifest;
|
|
3207
3356
|
},
|
|
3208
3357
|
get window() {
|
|
3209
3358
|
return routerWindow;
|
|
@@ -3233,10 +3382,10 @@ function createRouter(init) {
|
|
|
3233
3382
|
updateState(newState);
|
|
3234
3383
|
}
|
|
3235
3384
|
};
|
|
3236
|
-
if (init.
|
|
3385
|
+
if (init.instrumentations) {
|
|
3237
3386
|
router = instrumentClientSideRouter(
|
|
3238
3387
|
router,
|
|
3239
|
-
init.
|
|
3388
|
+
init.instrumentations.map((i) => i.router).filter(Boolean)
|
|
3240
3389
|
);
|
|
3241
3390
|
}
|
|
3242
3391
|
return router;
|
|
@@ -3251,12 +3400,10 @@ function createStaticHandler(routes, opts) {
|
|
|
3251
3400
|
let _mapRouteProperties = _optionalChain([opts, 'optionalAccess', _29 => _29.mapRouteProperties]) || defaultMapRouteProperties;
|
|
3252
3401
|
let mapRouteProperties2 = _mapRouteProperties;
|
|
3253
3402
|
let future = {
|
|
3254
|
-
unstable_passThroughRequests: false,
|
|
3255
|
-
// unused in static handler
|
|
3256
3403
|
..._optionalChain([opts, 'optionalAccess', _30 => _30.future])
|
|
3257
3404
|
};
|
|
3258
|
-
if (_optionalChain([opts, 'optionalAccess', _31 => _31.
|
|
3259
|
-
let instrumentations = opts.
|
|
3405
|
+
if (_optionalChain([opts, 'optionalAccess', _31 => _31.instrumentations])) {
|
|
3406
|
+
let instrumentations = opts.instrumentations;
|
|
3260
3407
|
mapRouteProperties2 = (route) => {
|
|
3261
3408
|
return {
|
|
3262
3409
|
..._mapRouteProperties(route),
|
|
@@ -3273,6 +3420,7 @@ function createStaticHandler(routes, opts) {
|
|
|
3273
3420
|
void 0,
|
|
3274
3421
|
manifest
|
|
3275
3422
|
);
|
|
3423
|
+
let routeBranches = flattenAndRankRoutes(dataRoutes);
|
|
3276
3424
|
async function query(request, {
|
|
3277
3425
|
requestContext,
|
|
3278
3426
|
filterMatchesToLoad,
|
|
@@ -3280,12 +3428,23 @@ function createStaticHandler(routes, opts) {
|
|
|
3280
3428
|
skipRevalidation,
|
|
3281
3429
|
dataStrategy,
|
|
3282
3430
|
generateMiddlewareResponse,
|
|
3283
|
-
|
|
3431
|
+
normalizePath
|
|
3284
3432
|
} = {}) {
|
|
3285
|
-
let
|
|
3433
|
+
let normalizePathImpl = normalizePath || defaultNormalizePath;
|
|
3286
3434
|
let method = request.method;
|
|
3287
|
-
let location = createLocation(
|
|
3288
|
-
|
|
3435
|
+
let location = createLocation(
|
|
3436
|
+
"",
|
|
3437
|
+
normalizePathImpl(request),
|
|
3438
|
+
null,
|
|
3439
|
+
"default"
|
|
3440
|
+
);
|
|
3441
|
+
let matches = matchRoutesImpl(
|
|
3442
|
+
dataRoutes,
|
|
3443
|
+
location,
|
|
3444
|
+
basename,
|
|
3445
|
+
false,
|
|
3446
|
+
routeBranches
|
|
3447
|
+
);
|
|
3289
3448
|
requestContext = requestContext != null ? requestContext : new RouterContextProvider();
|
|
3290
3449
|
if (!isValidMethod(method) && method !== "HEAD") {
|
|
3291
3450
|
let error = getInternalRouterError(405, { method });
|
|
@@ -3337,8 +3496,8 @@ function createStaticHandler(routes, opts) {
|
|
|
3337
3496
|
let response = await runServerMiddlewarePipeline(
|
|
3338
3497
|
{
|
|
3339
3498
|
request,
|
|
3340
|
-
|
|
3341
|
-
|
|
3499
|
+
url: createDataFunctionUrl(request, location),
|
|
3500
|
+
pattern: getRoutePattern(matches),
|
|
3342
3501
|
matches,
|
|
3343
3502
|
params: matches[0].params,
|
|
3344
3503
|
// If we're calling middleware then it must be enabled so we can cast
|
|
@@ -3455,12 +3614,23 @@ function createStaticHandler(routes, opts) {
|
|
|
3455
3614
|
requestContext,
|
|
3456
3615
|
dataStrategy,
|
|
3457
3616
|
generateMiddlewareResponse,
|
|
3458
|
-
|
|
3617
|
+
normalizePath
|
|
3459
3618
|
} = {}) {
|
|
3460
|
-
let
|
|
3619
|
+
let normalizePathImpl = normalizePath || defaultNormalizePath;
|
|
3461
3620
|
let method = request.method;
|
|
3462
|
-
let location = createLocation(
|
|
3463
|
-
|
|
3621
|
+
let location = createLocation(
|
|
3622
|
+
"",
|
|
3623
|
+
normalizePathImpl(request),
|
|
3624
|
+
null,
|
|
3625
|
+
"default"
|
|
3626
|
+
);
|
|
3627
|
+
let matches = matchRoutesImpl(
|
|
3628
|
+
dataRoutes,
|
|
3629
|
+
location,
|
|
3630
|
+
basename,
|
|
3631
|
+
false,
|
|
3632
|
+
routeBranches
|
|
3633
|
+
);
|
|
3464
3634
|
requestContext = requestContext != null ? requestContext : new RouterContextProvider();
|
|
3465
3635
|
if (!isValidMethod(method) && method !== "HEAD" && method !== "OPTIONS") {
|
|
3466
3636
|
throw getInternalRouterError(405, { method });
|
|
@@ -3485,8 +3655,8 @@ function createStaticHandler(routes, opts) {
|
|
|
3485
3655
|
let response = await runServerMiddlewarePipeline(
|
|
3486
3656
|
{
|
|
3487
3657
|
request,
|
|
3488
|
-
|
|
3489
|
-
|
|
3658
|
+
url: createDataFunctionUrl(request, location),
|
|
3659
|
+
pattern: getRoutePattern(matches),
|
|
3490
3660
|
matches,
|
|
3491
3661
|
params: matches[0].params,
|
|
3492
3662
|
// If we're calling middleware then it must be enabled so we can cast
|
|
@@ -3872,6 +4042,7 @@ function createStaticHandler(routes, opts) {
|
|
|
3872
4042
|
}
|
|
3873
4043
|
return {
|
|
3874
4044
|
dataRoutes,
|
|
4045
|
+
_internalRouteBranches: routeBranches,
|
|
3875
4046
|
query,
|
|
3876
4047
|
queryRoute
|
|
3877
4048
|
};
|
|
@@ -4057,7 +4228,7 @@ function normalizeNavigateOptions(isFetcher, path, opts) {
|
|
|
4057
4228
|
parsedPath.search = `?${searchParams}`;
|
|
4058
4229
|
return { path: createPath(parsedPath), submission };
|
|
4059
4230
|
}
|
|
4060
|
-
function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest, history, state, matches, submission, location, lazyRoutePropertiesToSkip, initialHydration, isRevalidationRequired, cancelledFetcherLoads, fetchersQueuedForDeletion, fetchLoadMatches, fetchRedirectIds, routesToUse, basename, hasPatchRoutesOnNavigation, pendingActionResult, callSiteDefaultShouldRevalidate) {
|
|
4231
|
+
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
4232
|
let actionResult = pendingActionResult ? isErrorResult(pendingActionResult[1]) ? pendingActionResult[1].error : pendingActionResult[1].data : void 0;
|
|
4062
4233
|
let currentUrl = history.createURL(state.location);
|
|
4063
4234
|
let nextUrl = history.createURL(location);
|
|
@@ -4153,7 +4324,13 @@ function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest,
|
|
|
4153
4324
|
}
|
|
4154
4325
|
let fetcher = state.fetchers.get(key);
|
|
4155
4326
|
let isMidInitialLoad = fetcher && fetcher.state !== "idle" && fetcher.data === void 0;
|
|
4156
|
-
let fetcherMatches =
|
|
4327
|
+
let fetcherMatches = matchRoutesImpl(
|
|
4328
|
+
routesToUse,
|
|
4329
|
+
f.path,
|
|
4330
|
+
_nullishCoalesce(basename, () => ( "/")),
|
|
4331
|
+
false,
|
|
4332
|
+
branches
|
|
4333
|
+
);
|
|
4157
4334
|
if (!fetcherMatches) {
|
|
4158
4335
|
if (hasPatchRoutesOnNavigation && isMidInitialLoad) {
|
|
4159
4336
|
return;
|
|
@@ -4294,7 +4471,7 @@ function shouldRevalidateLoader(loaderMatch, arg) {
|
|
|
4294
4471
|
}
|
|
4295
4472
|
return arg.defaultShouldRevalidate;
|
|
4296
4473
|
}
|
|
4297
|
-
function patchRoutesImpl(routeId, children,
|
|
4474
|
+
function patchRoutesImpl(routeId, children, dataRoutes, manifest, mapRouteProperties2, allowElementMutations) {
|
|
4298
4475
|
let childrenToPatch;
|
|
4299
4476
|
if (routeId) {
|
|
4300
4477
|
let route = manifest[routeId];
|
|
@@ -4307,7 +4484,7 @@ function patchRoutesImpl(routeId, children, routesToUse, manifest, mapRoutePrope
|
|
|
4307
4484
|
}
|
|
4308
4485
|
childrenToPatch = route.children;
|
|
4309
4486
|
} else {
|
|
4310
|
-
childrenToPatch =
|
|
4487
|
+
childrenToPatch = dataRoutes.activeRoutes;
|
|
4311
4488
|
}
|
|
4312
4489
|
let uniqueChildren = [];
|
|
4313
4490
|
let existingChildren = [];
|
|
@@ -4350,6 +4527,9 @@ function patchRoutesImpl(routeId, children, routesToUse, manifest, mapRoutePrope
|
|
|
4350
4527
|
});
|
|
4351
4528
|
}
|
|
4352
4529
|
}
|
|
4530
|
+
if (!dataRoutes.hasHMRRoutes) {
|
|
4531
|
+
dataRoutes.setRoutes([...dataRoutes.activeRoutes]);
|
|
4532
|
+
}
|
|
4353
4533
|
}
|
|
4354
4534
|
function isSameRoute(newRoute, existingRoute) {
|
|
4355
4535
|
if ("id" in newRoute && "id" in existingRoute && newRoute.id === existingRoute.id) {
|
|
@@ -4691,7 +4871,7 @@ function getDataStrategyMatchLazyPromises(mapRouteProperties2, manifest, request
|
|
|
4691
4871
|
handler: lazyRoutePromises.lazyHandlerPromise
|
|
4692
4872
|
};
|
|
4693
4873
|
}
|
|
4694
|
-
function getDataStrategyMatch(mapRouteProperties2, manifest, request, path,
|
|
4874
|
+
function getDataStrategyMatch(mapRouteProperties2, manifest, request, path, pattern, match, lazyRoutePropertiesToSkip, scopedContext, shouldLoad, shouldRevalidateArgs = null, callSiteDefaultShouldRevalidate) {
|
|
4695
4875
|
let isUsingNewApi = false;
|
|
4696
4876
|
let _lazyPromises = getDataStrategyMatchLazyPromises(
|
|
4697
4877
|
mapRouteProperties2,
|
|
@@ -4732,7 +4912,7 @@ function getDataStrategyMatch(mapRouteProperties2, manifest, request, path, unst
|
|
|
4732
4912
|
return callLoaderOrAction({
|
|
4733
4913
|
request,
|
|
4734
4914
|
path,
|
|
4735
|
-
|
|
4915
|
+
pattern,
|
|
4736
4916
|
match,
|
|
4737
4917
|
lazyHandlerPromise: _optionalChain([_lazyPromises, 'optionalAccess', _56 => _56.handler]),
|
|
4738
4918
|
lazyRoutePromise: _optionalChain([_lazyPromises, 'optionalAccess', _57 => _57.route]),
|
|
@@ -4782,8 +4962,8 @@ async function callDataStrategyImpl(dataStrategyImpl, request, path, matches, fe
|
|
|
4782
4962
|
}
|
|
4783
4963
|
let dataStrategyArgs = {
|
|
4784
4964
|
request,
|
|
4785
|
-
|
|
4786
|
-
|
|
4965
|
+
url: createDataFunctionUrl(request, path),
|
|
4966
|
+
pattern: getRoutePattern(matches),
|
|
4787
4967
|
params: matches[0].params,
|
|
4788
4968
|
context: scopedContext,
|
|
4789
4969
|
matches
|
|
@@ -4825,7 +5005,7 @@ async function callDataStrategyImpl(dataStrategyImpl, request, path, matches, fe
|
|
|
4825
5005
|
async function callLoaderOrAction({
|
|
4826
5006
|
request,
|
|
4827
5007
|
path,
|
|
4828
|
-
|
|
5008
|
+
pattern,
|
|
4829
5009
|
match,
|
|
4830
5010
|
lazyHandlerPromise,
|
|
4831
5011
|
lazyRoutePromise,
|
|
@@ -4852,8 +5032,8 @@ async function callLoaderOrAction({
|
|
|
4852
5032
|
return handler(
|
|
4853
5033
|
{
|
|
4854
5034
|
request,
|
|
4855
|
-
|
|
4856
|
-
|
|
5035
|
+
url: createDataFunctionUrl(request, path),
|
|
5036
|
+
pattern,
|
|
4857
5037
|
params: match.params,
|
|
4858
5038
|
context: scopedContext
|
|
4859
5039
|
},
|
|
@@ -5160,7 +5340,7 @@ function processRouteLoaderData(matches, results, pendingActionResult, isStaticH
|
|
|
5160
5340
|
loaderHeaders
|
|
5161
5341
|
};
|
|
5162
5342
|
}
|
|
5163
|
-
function processLoaderData(state, matches, results, pendingActionResult, revalidatingFetchers, fetcherResults) {
|
|
5343
|
+
function processLoaderData(state, matches, results, pendingActionResult, revalidatingFetchers, fetcherResults, workingFetchers) {
|
|
5164
5344
|
let { loaderData, errors } = processRouteLoaderData(
|
|
5165
5345
|
matches,
|
|
5166
5346
|
results,
|
|
@@ -5181,12 +5361,12 @@ function processLoaderData(state, matches, results, pendingActionResult, revalid
|
|
|
5181
5361
|
[boundaryMatch.route.id]: result.error
|
|
5182
5362
|
};
|
|
5183
5363
|
}
|
|
5184
|
-
|
|
5364
|
+
workingFetchers.delete(key);
|
|
5185
5365
|
} else if (isRedirectResult(result)) {
|
|
5186
5366
|
invariant(false, "Unhandled fetcher revalidation redirect");
|
|
5187
5367
|
} else {
|
|
5188
5368
|
let doneFetcher = getDoneFetcher(result.data);
|
|
5189
|
-
|
|
5369
|
+
workingFetchers.set(key, doneFetcher);
|
|
5190
5370
|
}
|
|
5191
5371
|
});
|
|
5192
5372
|
return { loaderData, errors };
|
|
@@ -5393,11 +5573,13 @@ function getSubmissionFromNavigation(navigation) {
|
|
|
5393
5573
|
};
|
|
5394
5574
|
}
|
|
5395
5575
|
}
|
|
5396
|
-
function getLoadingNavigation(location, submission) {
|
|
5576
|
+
function getLoadingNavigation(location, matches, historyAction, submission) {
|
|
5397
5577
|
if (submission) {
|
|
5398
5578
|
let navigation = {
|
|
5399
5579
|
state: "loading",
|
|
5400
5580
|
location,
|
|
5581
|
+
matches,
|
|
5582
|
+
historyAction,
|
|
5401
5583
|
formMethod: submission.formMethod,
|
|
5402
5584
|
formAction: submission.formAction,
|
|
5403
5585
|
formEncType: submission.formEncType,
|
|
@@ -5410,6 +5592,8 @@ function getLoadingNavigation(location, submission) {
|
|
|
5410
5592
|
let navigation = {
|
|
5411
5593
|
state: "loading",
|
|
5412
5594
|
location,
|
|
5595
|
+
matches,
|
|
5596
|
+
historyAction,
|
|
5413
5597
|
formMethod: void 0,
|
|
5414
5598
|
formAction: void 0,
|
|
5415
5599
|
formEncType: void 0,
|
|
@@ -5420,10 +5604,12 @@ function getLoadingNavigation(location, submission) {
|
|
|
5420
5604
|
return navigation;
|
|
5421
5605
|
}
|
|
5422
5606
|
}
|
|
5423
|
-
function getSubmittingNavigation(location, submission) {
|
|
5607
|
+
function getSubmittingNavigation(location, matches, historyAction, submission) {
|
|
5424
5608
|
let navigation = {
|
|
5425
5609
|
state: "submitting",
|
|
5426
5610
|
location,
|
|
5611
|
+
matches,
|
|
5612
|
+
historyAction,
|
|
5427
5613
|
formMethod: submission.formMethod,
|
|
5428
5614
|
formAction: submission.formAction,
|
|
5429
5615
|
formEncType: submission.formEncType,
|
|
@@ -6375,11 +6561,9 @@ function getTurboStreamSingleFetchDataStrategy(getRouter, manifest, routeModules
|
|
|
6375
6561
|
(match) => {
|
|
6376
6562
|
let manifestRoute = manifest.routes[match.route.id];
|
|
6377
6563
|
invariant2(manifestRoute, "Route not found in manifest");
|
|
6378
|
-
let routeModule = routeModules[match.route.id];
|
|
6379
6564
|
return {
|
|
6380
6565
|
hasLoader: manifestRoute.hasLoader,
|
|
6381
|
-
hasClientLoader: manifestRoute.hasClientLoader
|
|
6382
|
-
hasShouldRevalidate: Boolean(_optionalChain([routeModule, 'optionalAccess', _83 => _83.shouldRevalidate]))
|
|
6566
|
+
hasClientLoader: manifestRoute.hasClientLoader
|
|
6383
6567
|
};
|
|
6384
6568
|
},
|
|
6385
6569
|
fetchAndDecodeViaTurboStream,
|
|
@@ -6499,13 +6683,12 @@ async function singleFetchLoaderNavigationStrategy(args, router, getRouteInfo, f
|
|
|
6499
6683
|
async (m, i) => m.resolve(async (handler) => {
|
|
6500
6684
|
routeDfds[i].resolve();
|
|
6501
6685
|
let routeId = m.route.id;
|
|
6502
|
-
let { hasLoader, hasClientLoader
|
|
6686
|
+
let { hasLoader, hasClientLoader } = getRouteInfo(m);
|
|
6503
6687
|
let defaultShouldRevalidate = !m.shouldRevalidateArgs || m.shouldRevalidateArgs.actionStatus == null || m.shouldRevalidateArgs.actionStatus < 400;
|
|
6504
6688
|
let shouldCall = m.shouldCallHandler(defaultShouldRevalidate);
|
|
6505
6689
|
if (!shouldCall) {
|
|
6506
6690
|
foundOptOutRoute || (foundOptOutRoute = m.shouldRevalidateArgs != null && // This is a revalidation,
|
|
6507
|
-
hasLoader
|
|
6508
|
-
hasShouldRevalidate === true);
|
|
6691
|
+
hasLoader);
|
|
6509
6692
|
return;
|
|
6510
6693
|
}
|
|
6511
6694
|
if (shouldAllowOptOut(m) && hasClientLoader) {
|
|
@@ -6580,7 +6763,7 @@ async function bubbleMiddlewareErrors(singleFetchPromise, matches, routesParams,
|
|
|
6580
6763
|
let routeResult = fetchedData.routes[match.route.id];
|
|
6581
6764
|
if ("error" in routeResult) {
|
|
6582
6765
|
middlewareError = routeResult.error;
|
|
6583
|
-
if (_optionalChain([results, 'access',
|
|
6766
|
+
if (_optionalChain([results, 'access', _83 => _83[match.route.id], 'optionalAccess', _84 => _84.result]) == null) {
|
|
6584
6767
|
results[match.route.id] = {
|
|
6585
6768
|
type: "error",
|
|
6586
6769
|
result: middlewareError
|
|
@@ -6703,7 +6886,7 @@ async function fetchAndDecodeViaTurboStream(args, basename, trailingSlashAware,
|
|
|
6703
6886
|
}
|
|
6704
6887
|
} else {
|
|
6705
6888
|
let typed = decoded.value;
|
|
6706
|
-
let routeId = _optionalChain([targetRoutes, 'optionalAccess',
|
|
6889
|
+
let routeId = _optionalChain([targetRoutes, 'optionalAccess', _85 => _85[0]]);
|
|
6707
6890
|
invariant2(routeId, "No routeId found for single fetch call decoding");
|
|
6708
6891
|
if ("redirect" in typed) {
|
|
6709
6892
|
data2 = { redirect: typed };
|
|
@@ -7003,7 +7186,7 @@ function useOutlet(context) {
|
|
|
7003
7186
|
function useParams() {
|
|
7004
7187
|
let { matches } = React3.useContext(RouteContext);
|
|
7005
7188
|
let routeMatch = matches[matches.length - 1];
|
|
7006
|
-
return _nullishCoalesce(_optionalChain([routeMatch, 'optionalAccess',
|
|
7189
|
+
return _nullishCoalesce(_optionalChain([routeMatch, 'optionalAccess', _86 => _86.params]), () => ( {}));
|
|
7007
7190
|
}
|
|
7008
7191
|
function useResolvedPath(to, { relative } = {}) {
|
|
7009
7192
|
let { matches } = React3.useContext(RouteContext);
|
|
@@ -7051,7 +7234,7 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
|
|
|
7051
7234
|
if (locationArg) {
|
|
7052
7235
|
let parsedLocationArg = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
|
|
7053
7236
|
invariant(
|
|
7054
|
-
parentPathnameBase === "/" || _optionalChain([parsedLocationArg, 'access',
|
|
7237
|
+
parentPathnameBase === "/" || _optionalChain([parsedLocationArg, 'access', _87 => _87.pathname, 'optionalAccess', _88 => _88.startsWith, 'call', _89 => _89(parentPathnameBase)]),
|
|
7055
7238
|
`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${parentPathnameBase}" but pathname "${parsedLocationArg.pathname}" was given in the \`location\` prop.`
|
|
7056
7239
|
);
|
|
7057
7240
|
location = parsedLocationArg;
|
|
@@ -7065,7 +7248,15 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
|
|
|
7065
7248
|
let segments = pathname.replace(/^\//, "").split("/");
|
|
7066
7249
|
remainingPathname = "/" + segments.slice(parentSegments.length).join("/");
|
|
7067
7250
|
}
|
|
7068
|
-
let matches =
|
|
7251
|
+
let matches = dataRouterOpts && dataRouterOpts.state.matches.length ? (
|
|
7252
|
+
// If we're in a data router, use the matches we've already identified but ensure
|
|
7253
|
+
// we have the latest route instances from the manifest in case elements have changed
|
|
7254
|
+
dataRouterOpts.state.matches.map(
|
|
7255
|
+
(m) => Object.assign(m, {
|
|
7256
|
+
route: dataRouterOpts.manifest[m.route.id] || m.route
|
|
7257
|
+
})
|
|
7258
|
+
)
|
|
7259
|
+
) : matchRoutes(routes, { pathname: remainingPathname });
|
|
7069
7260
|
if (ENABLE_DEV_WARNINGS) {
|
|
7070
7261
|
warning(
|
|
7071
7262
|
parentRoute || matches != null,
|
|
@@ -7116,7 +7307,7 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
|
|
|
7116
7307
|
hash: "",
|
|
7117
7308
|
state: null,
|
|
7118
7309
|
key: "default",
|
|
7119
|
-
|
|
7310
|
+
mask: void 0,
|
|
7120
7311
|
...location
|
|
7121
7312
|
},
|
|
7122
7313
|
navigationType: "POP" /* Pop */
|
|
@@ -7245,7 +7436,7 @@ function RenderedRoute({ routeContext, match, children }) {
|
|
|
7245
7436
|
return /* @__PURE__ */ React3.createElement(RouteContext.Provider, { value: routeContext }, children);
|
|
7246
7437
|
}
|
|
7247
7438
|
function _renderMatches(matches, parentMatches = [], dataRouterOpts) {
|
|
7248
|
-
let dataRouterState = _optionalChain([dataRouterOpts, 'optionalAccess',
|
|
7439
|
+
let dataRouterState = _optionalChain([dataRouterOpts, 'optionalAccess', _90 => _90.state]);
|
|
7249
7440
|
if (matches == null) {
|
|
7250
7441
|
if (!dataRouterState) {
|
|
7251
7442
|
return null;
|
|
@@ -7259,10 +7450,10 @@ function _renderMatches(matches, parentMatches = [], dataRouterOpts) {
|
|
|
7259
7450
|
}
|
|
7260
7451
|
}
|
|
7261
7452
|
let renderedMatches = matches;
|
|
7262
|
-
let errors = _optionalChain([dataRouterState, 'optionalAccess',
|
|
7453
|
+
let errors = _optionalChain([dataRouterState, 'optionalAccess', _91 => _91.errors]);
|
|
7263
7454
|
if (errors != null) {
|
|
7264
7455
|
let errorIndex = renderedMatches.findIndex(
|
|
7265
|
-
(m) => m.route.id && _optionalChain([errors, 'optionalAccess',
|
|
7456
|
+
(m) => m.route.id && _optionalChain([errors, 'optionalAccess', _92 => _92[m.route.id]]) !== void 0
|
|
7266
7457
|
);
|
|
7267
7458
|
invariant(
|
|
7268
7459
|
errorIndex >= 0,
|
|
@@ -7301,12 +7492,12 @@ function _renderMatches(matches, parentMatches = [], dataRouterOpts) {
|
|
|
7301
7492
|
}
|
|
7302
7493
|
}
|
|
7303
7494
|
}
|
|
7304
|
-
let onErrorHandler = _optionalChain([dataRouterOpts, 'optionalAccess',
|
|
7495
|
+
let onErrorHandler = _optionalChain([dataRouterOpts, 'optionalAccess', _93 => _93.onError]);
|
|
7305
7496
|
let onError = dataRouterState && onErrorHandler ? (error, errorInfo) => {
|
|
7306
7497
|
onErrorHandler(error, {
|
|
7307
7498
|
location: dataRouterState.location,
|
|
7308
|
-
params: _nullishCoalesce(_optionalChain([dataRouterState, 'access',
|
|
7309
|
-
|
|
7499
|
+
params: _nullishCoalesce(_optionalChain([dataRouterState, 'access', _94 => _94.matches, 'optionalAccess', _95 => _95[0], 'optionalAccess', _96 => _96.params]), () => ( {})),
|
|
7500
|
+
pattern: getRoutePattern(dataRouterState.matches),
|
|
7310
7501
|
errorInfo
|
|
7311
7502
|
});
|
|
7312
7503
|
} : void 0;
|
|
@@ -7409,7 +7600,10 @@ function useRouteId() {
|
|
|
7409
7600
|
}
|
|
7410
7601
|
function useNavigation() {
|
|
7411
7602
|
let state = useDataRouterState("useNavigation" /* UseNavigation */);
|
|
7412
|
-
return
|
|
7603
|
+
return React3.useMemo(() => {
|
|
7604
|
+
let { matches, historyAction, ...rest } = state.navigation;
|
|
7605
|
+
return rest;
|
|
7606
|
+
}, [state.navigation]);
|
|
7413
7607
|
}
|
|
7414
7608
|
function useRevalidator() {
|
|
7415
7609
|
let dataRouterContext = useDataRouterContext("useRevalidator" /* UseRevalidator */);
|
|
@@ -7452,15 +7646,15 @@ function useRouteError() {
|
|
|
7452
7646
|
if (error !== void 0) {
|
|
7453
7647
|
return error;
|
|
7454
7648
|
}
|
|
7455
|
-
return _optionalChain([state, 'access',
|
|
7649
|
+
return _optionalChain([state, 'access', _97 => _97.errors, 'optionalAccess', _98 => _98[routeId]]);
|
|
7456
7650
|
}
|
|
7457
7651
|
function useAsyncValue() {
|
|
7458
7652
|
let value = React3.useContext(AwaitContext);
|
|
7459
|
-
return _optionalChain([value, 'optionalAccess',
|
|
7653
|
+
return _optionalChain([value, 'optionalAccess', _99 => _99._data]);
|
|
7460
7654
|
}
|
|
7461
7655
|
function useAsyncError() {
|
|
7462
7656
|
let value = React3.useContext(AwaitContext);
|
|
7463
|
-
return _optionalChain([value, 'optionalAccess',
|
|
7657
|
+
return _optionalChain([value, 'optionalAccess', _100 => _100._error]);
|
|
7464
7658
|
}
|
|
7465
7659
|
var blockerId = 0;
|
|
7466
7660
|
function useBlocker(shouldBlock) {
|
|
@@ -7541,9 +7735,68 @@ function useRoute(...args) {
|
|
|
7541
7735
|
return {
|
|
7542
7736
|
handle: route.route.handle,
|
|
7543
7737
|
loaderData: state.loaderData[id],
|
|
7544
|
-
actionData: _optionalChain([state, 'access',
|
|
7738
|
+
actionData: _optionalChain([state, 'access', _101 => _101.actionData, 'optionalAccess', _102 => _102[id]])
|
|
7545
7739
|
};
|
|
7546
7740
|
}
|
|
7741
|
+
function toRouterStateMatch(match) {
|
|
7742
|
+
return {
|
|
7743
|
+
id: match.route.id,
|
|
7744
|
+
pathname: match.pathname,
|
|
7745
|
+
params: match.params,
|
|
7746
|
+
handle: match.route.handle
|
|
7747
|
+
};
|
|
7748
|
+
}
|
|
7749
|
+
function useRouterState() {
|
|
7750
|
+
let {
|
|
7751
|
+
location,
|
|
7752
|
+
historyAction: type,
|
|
7753
|
+
matches,
|
|
7754
|
+
navigation
|
|
7755
|
+
} = useDataRouterState("unstable_useRouterState" /* UseRouterState */);
|
|
7756
|
+
let active = React3.useMemo(
|
|
7757
|
+
() => ({
|
|
7758
|
+
type,
|
|
7759
|
+
location,
|
|
7760
|
+
searchParams: new URLSearchParams(location.search),
|
|
7761
|
+
params: _nullishCoalesce(_optionalChain([matches, 'access', _103 => _103[matches.length - 1], 'optionalAccess', _104 => _104.params]), () => ( {})),
|
|
7762
|
+
matches: matches.map((m) => toRouterStateMatch(m))
|
|
7763
|
+
}),
|
|
7764
|
+
[location, matches, type]
|
|
7765
|
+
);
|
|
7766
|
+
let pending = React3.useMemo(() => {
|
|
7767
|
+
if (navigation.state === "idle") return null;
|
|
7768
|
+
let shared = {
|
|
7769
|
+
type: navigation.historyAction,
|
|
7770
|
+
location: navigation.location,
|
|
7771
|
+
searchParams: new URLSearchParams(navigation.location.search),
|
|
7772
|
+
params: _nullishCoalesce(_optionalChain([navigation, 'access', _105 => _105.matches, 'access', _106 => _106[navigation.matches.length - 1], 'optionalAccess', _107 => _107.params]), () => ( {})),
|
|
7773
|
+
matches: navigation.matches.map((m) => toRouterStateMatch(m))
|
|
7774
|
+
};
|
|
7775
|
+
return navigation.state === "loading" ? {
|
|
7776
|
+
...shared,
|
|
7777
|
+
state: "loading",
|
|
7778
|
+
formMethod: navigation.formMethod,
|
|
7779
|
+
formAction: navigation.formAction,
|
|
7780
|
+
formEncType: navigation.formEncType,
|
|
7781
|
+
formData: navigation.formData,
|
|
7782
|
+
json: navigation.json,
|
|
7783
|
+
text: navigation.text
|
|
7784
|
+
} : {
|
|
7785
|
+
...shared,
|
|
7786
|
+
state: "submitting",
|
|
7787
|
+
formMethod: navigation.formMethod,
|
|
7788
|
+
formAction: navigation.formAction,
|
|
7789
|
+
formEncType: navigation.formEncType,
|
|
7790
|
+
formData: navigation.formData,
|
|
7791
|
+
json: navigation.json,
|
|
7792
|
+
text: navigation.text
|
|
7793
|
+
};
|
|
7794
|
+
}, [navigation]);
|
|
7795
|
+
return React3.useMemo(
|
|
7796
|
+
() => ({ active, pending }),
|
|
7797
|
+
[active, pending]
|
|
7798
|
+
);
|
|
7799
|
+
}
|
|
7547
7800
|
|
|
7548
7801
|
// lib/dom/ssr/errorBoundaries.tsx
|
|
7549
7802
|
|
|
@@ -7586,7 +7839,7 @@ function getKeyedLinksForMatches(matches, routeModules, manifest) {
|
|
|
7586
7839
|
let route = manifest.routes[match.route.id];
|
|
7587
7840
|
return [
|
|
7588
7841
|
route && route.css ? route.css.map((href) => ({ rel: "stylesheet", href })) : [],
|
|
7589
|
-
_optionalChain([module, 'optionalAccess',
|
|
7842
|
+
_optionalChain([module, 'optionalAccess', _108 => _108.links, 'optionalCall', _109 => _109()]) || []
|
|
7590
7843
|
];
|
|
7591
7844
|
}).flat(2);
|
|
7592
7845
|
let preloads = getModuleLinkHrefs(matches, manifest);
|
|
@@ -7687,7 +7940,7 @@ function getNewMatchesForLinks(page, nextMatches, currentMatches, manifest, loca
|
|
|
7687
7940
|
// param change, /users/123 -> /users/456
|
|
7688
7941
|
currentMatches[index].pathname !== match.pathname || // splat param changed, which is not present in match.path
|
|
7689
7942
|
// e.g. /files/images/avatar.jpg -> files/finances.xls
|
|
7690
|
-
_optionalChain([currentMatches, 'access',
|
|
7943
|
+
_optionalChain([currentMatches, 'access', _110 => _110[index], 'access', _111 => _111.route, 'access', _112 => _112.path, 'optionalAccess', _113 => _113.endsWith, 'call', _114 => _114("*")]) && currentMatches[index].params["*"] !== match.params["*"]
|
|
7691
7944
|
);
|
|
7692
7945
|
};
|
|
7693
7946
|
if (mode === "assets") {
|
|
@@ -7710,7 +7963,7 @@ function getNewMatchesForLinks(page, nextMatches, currentMatches, manifest, loca
|
|
|
7710
7963
|
location.pathname + location.search + location.hash,
|
|
7711
7964
|
window.origin
|
|
7712
7965
|
),
|
|
7713
|
-
currentParams: _optionalChain([currentMatches, 'access',
|
|
7966
|
+
currentParams: _optionalChain([currentMatches, 'access', _115 => _115[0], 'optionalAccess', _116 => _116.params]) || {},
|
|
7714
7967
|
nextUrl: new URL(page, window.origin),
|
|
7715
7968
|
nextParams: match.params,
|
|
7716
7969
|
defaultShouldRevalidate: true
|
|
@@ -7982,50 +8235,42 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
7982
8235
|
)
|
|
7983
8236
|
});
|
|
7984
8237
|
let hasInitialData = initialState && initialState.loaderData && route.id in initialState.loaderData;
|
|
7985
|
-
let initialData = hasInitialData ? _optionalChain([initialState, 'optionalAccess',
|
|
8238
|
+
let initialData = hasInitialData ? _optionalChain([initialState, 'optionalAccess', _117 => _117.loaderData, 'optionalAccess', _118 => _118[route.id]]) : void 0;
|
|
7986
8239
|
let hasInitialError = initialState && initialState.errors && route.id in initialState.errors;
|
|
7987
|
-
let initialError = hasInitialError ? _optionalChain([initialState, 'optionalAccess',
|
|
7988
|
-
let isHydrationRequest = needsRevalidation == null && (_optionalChain([routeModule, 'access',
|
|
7989
|
-
dataRoute.loader = async ({
|
|
7990
|
-
|
|
7991
|
-
|
|
7992
|
-
|
|
7993
|
-
|
|
7994
|
-
|
|
7995
|
-
|
|
7996
|
-
|
|
7997
|
-
|
|
7998
|
-
|
|
7999
|
-
|
|
8000
|
-
|
|
8001
|
-
|
|
8002
|
-
|
|
8003
|
-
|
|
8004
|
-
|
|
8005
|
-
|
|
8006
|
-
|
|
8007
|
-
|
|
8008
|
-
|
|
8009
|
-
|
|
8010
|
-
|
|
8011
|
-
|
|
8012
|
-
|
|
8013
|
-
|
|
8014
|
-
if (hasInitialData) {
|
|
8015
|
-
return initialData;
|
|
8016
|
-
}
|
|
8017
|
-
if (hasInitialError) {
|
|
8018
|
-
throw initialError;
|
|
8019
|
-
}
|
|
8240
|
+
let initialError = hasInitialError ? _optionalChain([initialState, 'optionalAccess', _119 => _119.errors, 'optionalAccess', _120 => _120[route.id]]) : void 0;
|
|
8241
|
+
let isHydrationRequest = needsRevalidation == null && (_optionalChain([routeModule, 'access', _121 => _121.clientLoader, 'optionalAccess', _122 => _122.hydrate]) === true || !route.hasLoader);
|
|
8242
|
+
dataRoute.loader = async ({ request, params, context, pattern, url }, singleFetch) => {
|
|
8243
|
+
let _isHydrationRequest = isHydrationRequest;
|
|
8244
|
+
isHydrationRequest = false;
|
|
8245
|
+
let result = await prefetchStylesAndCallHandler(async () => {
|
|
8246
|
+
invariant2(
|
|
8247
|
+
routeModule,
|
|
8248
|
+
"No `routeModule` available for critical-route loader"
|
|
8249
|
+
);
|
|
8250
|
+
if (!routeModule.clientLoader) {
|
|
8251
|
+
return fetchServerLoader(singleFetch);
|
|
8252
|
+
}
|
|
8253
|
+
return routeModule.clientLoader({
|
|
8254
|
+
request,
|
|
8255
|
+
params,
|
|
8256
|
+
context,
|
|
8257
|
+
pattern,
|
|
8258
|
+
url,
|
|
8259
|
+
async serverLoader() {
|
|
8260
|
+
preventInvalidServerHandlerCall("loader", route);
|
|
8261
|
+
if (_isHydrationRequest) {
|
|
8262
|
+
if (hasInitialData) {
|
|
8263
|
+
return initialData;
|
|
8264
|
+
}
|
|
8265
|
+
if (hasInitialError) {
|
|
8266
|
+
throw initialError;
|
|
8020
8267
|
}
|
|
8021
|
-
return fetchServerLoader(singleFetch);
|
|
8022
8268
|
}
|
|
8023
|
-
|
|
8269
|
+
return fetchServerLoader(singleFetch);
|
|
8270
|
+
}
|
|
8024
8271
|
});
|
|
8025
|
-
|
|
8026
|
-
|
|
8027
|
-
isHydrationRequest = false;
|
|
8028
|
-
}
|
|
8272
|
+
});
|
|
8273
|
+
return result;
|
|
8029
8274
|
};
|
|
8030
8275
|
dataRoute.loader.hydrate = shouldHydrateRouteLoader(
|
|
8031
8276
|
route.id,
|
|
@@ -8033,13 +8278,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
8033
8278
|
route.hasLoader,
|
|
8034
8279
|
isSpaMode
|
|
8035
8280
|
);
|
|
8036
|
-
dataRoute.action = ({
|
|
8037
|
-
request,
|
|
8038
|
-
params,
|
|
8039
|
-
context,
|
|
8040
|
-
unstable_pattern,
|
|
8041
|
-
unstable_url
|
|
8042
|
-
}, singleFetch) => {
|
|
8281
|
+
dataRoute.action = ({ request, params, context, pattern, url }, singleFetch) => {
|
|
8043
8282
|
return prefetchStylesAndCallHandler(async () => {
|
|
8044
8283
|
invariant2(
|
|
8045
8284
|
routeModule,
|
|
@@ -8055,8 +8294,8 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
8055
8294
|
request,
|
|
8056
8295
|
params,
|
|
8057
8296
|
context,
|
|
8058
|
-
|
|
8059
|
-
|
|
8297
|
+
pattern,
|
|
8298
|
+
url,
|
|
8060
8299
|
async serverAction() {
|
|
8061
8300
|
preventInvalidServerHandlerCall("action", route);
|
|
8062
8301
|
return fetchServerAction(singleFetch);
|
|
@@ -8251,7 +8490,13 @@ function getPartialManifest({ sri, ...manifest }, router) {
|
|
|
8251
8490
|
segments.pop();
|
|
8252
8491
|
}
|
|
8253
8492
|
paths.forEach((path) => {
|
|
8254
|
-
let matches =
|
|
8493
|
+
let matches = matchRoutesImpl(
|
|
8494
|
+
router.routes,
|
|
8495
|
+
path,
|
|
8496
|
+
router.basename || "/",
|
|
8497
|
+
false,
|
|
8498
|
+
router.branches
|
|
8499
|
+
);
|
|
8255
8500
|
if (matches) {
|
|
8256
8501
|
matches.forEach((m) => routeIds.add(m.route.id));
|
|
8257
8502
|
}
|
|
@@ -8294,7 +8539,7 @@ function getPatchRoutesOnNavigationFunction(getRouter, manifest, routeModules, s
|
|
|
8294
8539
|
function useFogOFWarDiscovery(router, manifest, routeModules, ssr, routeDiscovery, isSpaMode) {
|
|
8295
8540
|
React6.useEffect(() => {
|
|
8296
8541
|
if (!isFogOfWarEnabled(routeDiscovery, ssr) || // @ts-expect-error - TS doesn't know about this yet
|
|
8297
|
-
_optionalChain([window, 'access',
|
|
8542
|
+
_optionalChain([window, 'access', _123 => _123.navigator, 'optionalAccess', _124 => _124.connection, 'optionalAccess', _125 => _125.saveData]) === true) {
|
|
8298
8543
|
return;
|
|
8299
8544
|
}
|
|
8300
8545
|
function registerElement(el) {
|
|
@@ -8400,7 +8645,7 @@ async function fetchAndApplyManifestPatches(paths, errorReloadPath, manifest, ro
|
|
|
8400
8645
|
}
|
|
8401
8646
|
serverPatches = await res.json();
|
|
8402
8647
|
} catch (e) {
|
|
8403
|
-
if (_optionalChain([signal, 'optionalAccess',
|
|
8648
|
+
if (_optionalChain([signal, 'optionalAccess', _126 => _126.aborted])) return;
|
|
8404
8649
|
throw e;
|
|
8405
8650
|
}
|
|
8406
8651
|
let knownRoutes = new Set(Object.keys(manifest.routes));
|
|
@@ -8703,7 +8948,7 @@ function PrefetchPageLinksImpl({
|
|
|
8703
8948
|
if (!manifestRoute || !manifestRoute.hasLoader) {
|
|
8704
8949
|
return;
|
|
8705
8950
|
}
|
|
8706
|
-
if (!newMatchesForData.some((m2) => m2.route.id === m.route.id) && m.route.id in loaderData && _optionalChain([routeModules, 'access',
|
|
8951
|
+
if (!newMatchesForData.some((m2) => m2.route.id === m.route.id) && m.route.id in loaderData && _optionalChain([routeModules, 'access', _127 => _127[m.route.id], 'optionalAccess', _128 => _128.shouldRevalidate])) {
|
|
8707
8952
|
foundOptOutRoute = true;
|
|
8708
8953
|
} else if (manifestRoute.hasClientLoader) {
|
|
8709
8954
|
foundOptOutRoute = true;
|
|
@@ -8791,7 +9036,7 @@ function Meta() {
|
|
|
8791
9036
|
error
|
|
8792
9037
|
};
|
|
8793
9038
|
matches[i] = match;
|
|
8794
|
-
if (_optionalChain([routeModule, 'optionalAccess',
|
|
9039
|
+
if (_optionalChain([routeModule, 'optionalAccess', _129 => _129.meta])) {
|
|
8795
9040
|
routeMeta = typeof routeModule.meta === "function" ? routeModule.meta({
|
|
8796
9041
|
data: data2,
|
|
8797
9042
|
loaderData: data2,
|
|
@@ -8850,7 +9095,7 @@ function Meta() {
|
|
|
8850
9095
|
dangerouslySetInnerHTML: { __html: escapeHtml(json) }
|
|
8851
9096
|
}
|
|
8852
9097
|
);
|
|
8853
|
-
} catch (
|
|
9098
|
+
} catch (e) {
|
|
8854
9099
|
return null;
|
|
8855
9100
|
}
|
|
8856
9101
|
}
|
|
@@ -8890,7 +9135,7 @@ function Scripts(scriptProps) {
|
|
|
8890
9135
|
}
|
|
8891
9136
|
let streamScript = "window.__reactRouterContext.stream = new ReadableStream({start(controller){window.__reactRouterContext.streamController = controller;}}).pipeThrough(new TextEncoderStream());";
|
|
8892
9137
|
let contextScript = staticContext ? `window.__reactRouterContext = ${serverHandoffString};${streamScript}` : " ";
|
|
8893
|
-
let routeModulesScript = !isStatic ? " " : `${_optionalChain([manifest, 'access',
|
|
9138
|
+
let routeModulesScript = !isStatic ? " " : `${_optionalChain([manifest, 'access', _130 => _130.hmr, 'optionalAccess', _131 => _131.runtime]) ? `import ${JSON.stringify(manifest.hmr.runtime)};` : ""}${!enableFogOfWar ? `import ${JSON.stringify(manifest.url)}` : ""};
|
|
8894
9139
|
${matches.map((match, routeIndex) => {
|
|
8895
9140
|
let routeVarName = `route${routeIndex}`;
|
|
8896
9141
|
let manifestEntry = manifest.routes[match.route.id];
|
|
@@ -8966,13 +9211,16 @@ import(${JSON.stringify(manifest.entry.module)});`;
|
|
|
8966
9211
|
}
|
|
8967
9212
|
));
|
|
8968
9213
|
}, []);
|
|
8969
|
-
let preloads = isHydrated || isRSCRouterContext ? [] :
|
|
8970
|
-
|
|
8971
|
-
|
|
8972
|
-
|
|
8973
|
-
|
|
9214
|
+
let preloads = isHydrated || isRSCRouterContext ? [] : [
|
|
9215
|
+
// Dedupe through a Set
|
|
9216
|
+
...new Set(
|
|
9217
|
+
manifest.entry.imports.concat(
|
|
9218
|
+
getModuleLinkHrefs(matches, manifest, {
|
|
9219
|
+
includeHydrateFallback: true
|
|
9220
|
+
})
|
|
9221
|
+
)
|
|
8974
9222
|
)
|
|
8975
|
-
|
|
9223
|
+
];
|
|
8976
9224
|
let sri = typeof manifest.sri === "object" ? manifest.sri : {};
|
|
8977
9225
|
warnOnce(
|
|
8978
9226
|
!isRSCRouterContext,
|
|
@@ -8998,6 +9246,7 @@ import(${JSON.stringify(manifest.entry.module)});`;
|
|
|
8998
9246
|
href: manifest.url,
|
|
8999
9247
|
crossOrigin: scriptProps.crossOrigin,
|
|
9000
9248
|
integrity: sri[manifest.url],
|
|
9249
|
+
nonce: scriptProps.nonce,
|
|
9001
9250
|
suppressHydrationWarning: true
|
|
9002
9251
|
}
|
|
9003
9252
|
) : null, /* @__PURE__ */ React7.createElement(
|
|
@@ -9007,6 +9256,7 @@ import(${JSON.stringify(manifest.entry.module)});`;
|
|
|
9007
9256
|
href: manifest.entry.module,
|
|
9008
9257
|
crossOrigin: scriptProps.crossOrigin,
|
|
9009
9258
|
integrity: sri[manifest.entry.module],
|
|
9259
|
+
nonce: scriptProps.nonce,
|
|
9010
9260
|
suppressHydrationWarning: true
|
|
9011
9261
|
}
|
|
9012
9262
|
), preloads.map((path) => /* @__PURE__ */ React7.createElement(
|
|
@@ -9017,13 +9267,11 @@ import(${JSON.stringify(manifest.entry.module)});`;
|
|
|
9017
9267
|
href: path,
|
|
9018
9268
|
crossOrigin: scriptProps.crossOrigin,
|
|
9019
9269
|
integrity: sri[path],
|
|
9270
|
+
nonce: scriptProps.nonce,
|
|
9020
9271
|
suppressHydrationWarning: true
|
|
9021
9272
|
}
|
|
9022
9273
|
)), initialScripts);
|
|
9023
9274
|
}
|
|
9024
|
-
function dedupe(array) {
|
|
9025
|
-
return [...new Set(array)];
|
|
9026
|
-
}
|
|
9027
9275
|
function mergeRefs(...refs) {
|
|
9028
9276
|
return (value) => {
|
|
9029
9277
|
refs.forEach((ref) => {
|
|
@@ -9121,7 +9369,7 @@ function BoundaryShell({
|
|
|
9121
9369
|
children
|
|
9122
9370
|
}) {
|
|
9123
9371
|
let { routeModules } = useFrameworkContext();
|
|
9124
|
-
if (_optionalChain([routeModules, 'access',
|
|
9372
|
+
if (_optionalChain([routeModules, 'access', _132 => _132.root, 'optionalAccess', _133 => _133.Layout]) && !isOutsideRemixApp) {
|
|
9125
9373
|
return children;
|
|
9126
9374
|
}
|
|
9127
9375
|
return /* @__PURE__ */ React8.createElement("html", { lang: "en" }, /* @__PURE__ */ React8.createElement("head", null, /* @__PURE__ */ React8.createElement("meta", { charSet: "utf-8" }), /* @__PURE__ */ React8.createElement(
|
|
@@ -9201,20 +9449,20 @@ var hydrationRouteProperties = [
|
|
|
9201
9449
|
];
|
|
9202
9450
|
function createMemoryRouter(routes, opts) {
|
|
9203
9451
|
return createRouter({
|
|
9204
|
-
basename: _optionalChain([opts, 'optionalAccess',
|
|
9205
|
-
getContext: _optionalChain([opts, 'optionalAccess',
|
|
9206
|
-
future: _optionalChain([opts, 'optionalAccess',
|
|
9452
|
+
basename: _optionalChain([opts, 'optionalAccess', _134 => _134.basename]),
|
|
9453
|
+
getContext: _optionalChain([opts, 'optionalAccess', _135 => _135.getContext]),
|
|
9454
|
+
future: _optionalChain([opts, 'optionalAccess', _136 => _136.future]),
|
|
9207
9455
|
history: createMemoryHistory({
|
|
9208
|
-
initialEntries: _optionalChain([opts, 'optionalAccess',
|
|
9209
|
-
initialIndex: _optionalChain([opts, 'optionalAccess',
|
|
9456
|
+
initialEntries: _optionalChain([opts, 'optionalAccess', _137 => _137.initialEntries]),
|
|
9457
|
+
initialIndex: _optionalChain([opts, 'optionalAccess', _138 => _138.initialIndex])
|
|
9210
9458
|
}),
|
|
9211
|
-
hydrationData: _optionalChain([opts, 'optionalAccess',
|
|
9459
|
+
hydrationData: _optionalChain([opts, 'optionalAccess', _139 => _139.hydrationData]),
|
|
9212
9460
|
routes,
|
|
9213
9461
|
hydrationRouteProperties,
|
|
9214
9462
|
mapRouteProperties,
|
|
9215
|
-
dataStrategy: _optionalChain([opts, 'optionalAccess',
|
|
9216
|
-
patchRoutesOnNavigation: _optionalChain([opts, 'optionalAccess',
|
|
9217
|
-
|
|
9463
|
+
dataStrategy: _optionalChain([opts, 'optionalAccess', _140 => _140.dataStrategy]),
|
|
9464
|
+
patchRoutesOnNavigation: _optionalChain([opts, 'optionalAccess', _141 => _141.patchRoutesOnNavigation]),
|
|
9465
|
+
instrumentations: _optionalChain([opts, 'optionalAccess', _142 => _142.instrumentations])
|
|
9218
9466
|
}).initialize();
|
|
9219
9467
|
}
|
|
9220
9468
|
var Deferred2 = class {
|
|
@@ -9240,10 +9488,10 @@ function RouterProvider({
|
|
|
9240
9488
|
router,
|
|
9241
9489
|
flushSync: reactDomFlushSyncImpl,
|
|
9242
9490
|
onError,
|
|
9243
|
-
|
|
9491
|
+
useTransitions
|
|
9244
9492
|
}) {
|
|
9245
9493
|
let unstable_rsc = useIsRSCRouterContext();
|
|
9246
|
-
|
|
9494
|
+
useTransitions = unstable_rsc || useTransitions;
|
|
9247
9495
|
let [_state, setStateImpl] = React9.useState(router.state);
|
|
9248
9496
|
let [state, setOptimisticState] = useOptimisticSafe(_state);
|
|
9249
9497
|
let [pendingState, setPendingState] = React9.useState();
|
|
@@ -9260,8 +9508,8 @@ function RouterProvider({
|
|
|
9260
9508
|
Object.values(newErrors).forEach(
|
|
9261
9509
|
(error) => onError(error, {
|
|
9262
9510
|
location: newState.location,
|
|
9263
|
-
params: _nullishCoalesce(_optionalChain([newState, 'access',
|
|
9264
|
-
|
|
9511
|
+
params: _nullishCoalesce(_optionalChain([newState, 'access', _143 => _143.matches, 'access', _144 => _144[0], 'optionalAccess', _145 => _145.params]), () => ( {})),
|
|
9512
|
+
pattern: getRoutePattern(newState.matches)
|
|
9265
9513
|
})
|
|
9266
9514
|
);
|
|
9267
9515
|
}
|
|
@@ -9283,11 +9531,11 @@ function RouterProvider({
|
|
|
9283
9531
|
if (!viewTransitionOpts || !isViewTransitionAvailable) {
|
|
9284
9532
|
if (reactDomFlushSyncImpl && flushSync) {
|
|
9285
9533
|
reactDomFlushSyncImpl(() => setStateImpl(newState));
|
|
9286
|
-
} else if (
|
|
9534
|
+
} else if (useTransitions === false) {
|
|
9287
9535
|
setStateImpl(newState);
|
|
9288
9536
|
} else {
|
|
9289
9537
|
React9.startTransition(() => {
|
|
9290
|
-
if (
|
|
9538
|
+
if (useTransitions === true) {
|
|
9291
9539
|
setOptimisticState((s) => getOptimisticRouterState(s, newState));
|
|
9292
9540
|
}
|
|
9293
9541
|
setStateImpl(newState);
|
|
@@ -9298,7 +9546,7 @@ function RouterProvider({
|
|
|
9298
9546
|
if (reactDomFlushSyncImpl && flushSync) {
|
|
9299
9547
|
reactDomFlushSyncImpl(() => {
|
|
9300
9548
|
if (transition) {
|
|
9301
|
-
_optionalChain([renderDfd, 'optionalAccess',
|
|
9549
|
+
_optionalChain([renderDfd, 'optionalAccess', _146 => _146.resolve, 'call', _147 => _147()]);
|
|
9302
9550
|
transition.skipTransition();
|
|
9303
9551
|
}
|
|
9304
9552
|
setVtContext({
|
|
@@ -9323,7 +9571,7 @@ function RouterProvider({
|
|
|
9323
9571
|
return;
|
|
9324
9572
|
}
|
|
9325
9573
|
if (transition) {
|
|
9326
|
-
_optionalChain([renderDfd, 'optionalAccess',
|
|
9574
|
+
_optionalChain([renderDfd, 'optionalAccess', _148 => _148.resolve, 'call', _149 => _149()]);
|
|
9327
9575
|
transition.skipTransition();
|
|
9328
9576
|
setInterruption({
|
|
9329
9577
|
state: newState,
|
|
@@ -9345,22 +9593,12 @@ function RouterProvider({
|
|
|
9345
9593
|
reactDomFlushSyncImpl,
|
|
9346
9594
|
transition,
|
|
9347
9595
|
renderDfd,
|
|
9348
|
-
|
|
9596
|
+
useTransitions,
|
|
9349
9597
|
setOptimisticState,
|
|
9350
9598
|
onError
|
|
9351
9599
|
]
|
|
9352
9600
|
);
|
|
9353
9601
|
React9.useLayoutEffect(() => router.subscribe(setState), [router, setState]);
|
|
9354
|
-
let initialized = state.initialized;
|
|
9355
|
-
React9.useLayoutEffect(() => {
|
|
9356
|
-
if (!initialized && router.state.initialized) {
|
|
9357
|
-
setState(router.state, {
|
|
9358
|
-
deletedFetchers: [],
|
|
9359
|
-
flushSync: false,
|
|
9360
|
-
newErrors: null
|
|
9361
|
-
});
|
|
9362
|
-
}
|
|
9363
|
-
}, [initialized, setState, router.state]);
|
|
9364
9602
|
React9.useEffect(() => {
|
|
9365
9603
|
if (vtContext.isTransitioning && !vtContext.flushSync) {
|
|
9366
9604
|
setRenderDfd(new Deferred2());
|
|
@@ -9371,11 +9609,11 @@ function RouterProvider({
|
|
|
9371
9609
|
let newState = pendingState;
|
|
9372
9610
|
let renderPromise = renderDfd.promise;
|
|
9373
9611
|
let transition2 = router.window.document.startViewTransition(async () => {
|
|
9374
|
-
if (
|
|
9612
|
+
if (useTransitions === false) {
|
|
9375
9613
|
setStateImpl(newState);
|
|
9376
9614
|
} else {
|
|
9377
9615
|
React9.startTransition(() => {
|
|
9378
|
-
if (
|
|
9616
|
+
if (useTransitions === true) {
|
|
9379
9617
|
setOptimisticState((s) => getOptimisticRouterState(s, newState));
|
|
9380
9618
|
}
|
|
9381
9619
|
setStateImpl(newState);
|
|
@@ -9395,7 +9633,7 @@ function RouterProvider({
|
|
|
9395
9633
|
pendingState,
|
|
9396
9634
|
renderDfd,
|
|
9397
9635
|
router.window,
|
|
9398
|
-
|
|
9636
|
+
useTransitions,
|
|
9399
9637
|
setOptimisticState
|
|
9400
9638
|
]);
|
|
9401
9639
|
React9.useEffect(() => {
|
|
@@ -9422,12 +9660,12 @@ function RouterProvider({
|
|
|
9422
9660
|
go: (n) => router.navigate(n),
|
|
9423
9661
|
push: (to, state2, opts) => router.navigate(to, {
|
|
9424
9662
|
state: state2,
|
|
9425
|
-
preventScrollReset: _optionalChain([opts, 'optionalAccess',
|
|
9663
|
+
preventScrollReset: _optionalChain([opts, 'optionalAccess', _150 => _150.preventScrollReset])
|
|
9426
9664
|
}),
|
|
9427
9665
|
replace: (to, state2, opts) => router.navigate(to, {
|
|
9428
9666
|
replace: true,
|
|
9429
9667
|
state: state2,
|
|
9430
|
-
preventScrollReset: _optionalChain([opts, 'optionalAccess',
|
|
9668
|
+
preventScrollReset: _optionalChain([opts, 'optionalAccess', _151 => _151.preventScrollReset])
|
|
9431
9669
|
})
|
|
9432
9670
|
};
|
|
9433
9671
|
}, [router]);
|
|
@@ -9449,12 +9687,13 @@ function RouterProvider({
|
|
|
9449
9687
|
location: state.location,
|
|
9450
9688
|
navigationType: state.historyAction,
|
|
9451
9689
|
navigator,
|
|
9452
|
-
|
|
9690
|
+
useTransitions
|
|
9453
9691
|
},
|
|
9454
9692
|
/* @__PURE__ */ React9.createElement(
|
|
9455
9693
|
MemoizedDataRoutes,
|
|
9456
9694
|
{
|
|
9457
9695
|
routes: router.routes,
|
|
9696
|
+
manifest: router.manifest,
|
|
9458
9697
|
future: router.future,
|
|
9459
9698
|
state,
|
|
9460
9699
|
isStatic: false,
|
|
@@ -9477,22 +9716,29 @@ function getOptimisticRouterState(currentState, newState) {
|
|
|
9477
9716
|
fetchers: newState.fetchers
|
|
9478
9717
|
};
|
|
9479
9718
|
}
|
|
9480
|
-
var MemoizedDataRoutes = React9.memo(
|
|
9481
|
-
function
|
|
9719
|
+
var MemoizedDataRoutes = React9.memo(DataRoutes2);
|
|
9720
|
+
function DataRoutes2({
|
|
9482
9721
|
routes,
|
|
9722
|
+
manifest,
|
|
9483
9723
|
future,
|
|
9484
9724
|
state,
|
|
9485
9725
|
isStatic,
|
|
9486
9726
|
onError
|
|
9487
9727
|
}) {
|
|
9488
|
-
return useRoutesImpl(routes, void 0, {
|
|
9728
|
+
return useRoutesImpl(routes, void 0, {
|
|
9729
|
+
manifest,
|
|
9730
|
+
state,
|
|
9731
|
+
isStatic,
|
|
9732
|
+
onError,
|
|
9733
|
+
future
|
|
9734
|
+
});
|
|
9489
9735
|
}
|
|
9490
9736
|
function MemoryRouter({
|
|
9491
9737
|
basename,
|
|
9492
9738
|
children,
|
|
9493
9739
|
initialEntries,
|
|
9494
9740
|
initialIndex,
|
|
9495
|
-
|
|
9741
|
+
useTransitions
|
|
9496
9742
|
}) {
|
|
9497
9743
|
let historyRef = React9.useRef();
|
|
9498
9744
|
if (historyRef.current == null) {
|
|
@@ -9509,13 +9755,13 @@ function MemoryRouter({
|
|
|
9509
9755
|
});
|
|
9510
9756
|
let setState = React9.useCallback(
|
|
9511
9757
|
(newState) => {
|
|
9512
|
-
if (
|
|
9758
|
+
if (useTransitions === false) {
|
|
9513
9759
|
setStateImpl(newState);
|
|
9514
9760
|
} else {
|
|
9515
9761
|
React9.startTransition(() => setStateImpl(newState));
|
|
9516
9762
|
}
|
|
9517
9763
|
},
|
|
9518
|
-
[
|
|
9764
|
+
[useTransitions]
|
|
9519
9765
|
);
|
|
9520
9766
|
React9.useLayoutEffect(() => history.listen(setState), [history, setState]);
|
|
9521
9767
|
return /* @__PURE__ */ React9.createElement(
|
|
@@ -9526,7 +9772,7 @@ function MemoryRouter({
|
|
|
9526
9772
|
location: state.location,
|
|
9527
9773
|
navigationType: state.action,
|
|
9528
9774
|
navigator: history,
|
|
9529
|
-
|
|
9775
|
+
useTransitions
|
|
9530
9776
|
}
|
|
9531
9777
|
);
|
|
9532
9778
|
}
|
|
@@ -9578,7 +9824,7 @@ function Router({
|
|
|
9578
9824
|
navigationType = "POP" /* Pop */,
|
|
9579
9825
|
navigator,
|
|
9580
9826
|
static: staticProp = false,
|
|
9581
|
-
|
|
9827
|
+
useTransitions
|
|
9582
9828
|
}) {
|
|
9583
9829
|
invariant(
|
|
9584
9830
|
!useInRouterContext(),
|
|
@@ -9590,10 +9836,10 @@ function Router({
|
|
|
9590
9836
|
basename,
|
|
9591
9837
|
navigator,
|
|
9592
9838
|
static: staticProp,
|
|
9593
|
-
|
|
9839
|
+
useTransitions,
|
|
9594
9840
|
future: {}
|
|
9595
9841
|
}),
|
|
9596
|
-
[basename, navigator, staticProp,
|
|
9842
|
+
[basename, navigator, staticProp, useTransitions]
|
|
9597
9843
|
);
|
|
9598
9844
|
if (typeof locationProp === "string") {
|
|
9599
9845
|
locationProp = parsePath(locationProp);
|
|
@@ -9604,7 +9850,7 @@ function Router({
|
|
|
9604
9850
|
hash = "",
|
|
9605
9851
|
state = null,
|
|
9606
9852
|
key = "default",
|
|
9607
|
-
|
|
9853
|
+
mask
|
|
9608
9854
|
} = locationProp;
|
|
9609
9855
|
let locationContext = React9.useMemo(() => {
|
|
9610
9856
|
let trailingPathname = stripBasename(pathname, basename);
|
|
@@ -9618,20 +9864,11 @@ function Router({
|
|
|
9618
9864
|
hash,
|
|
9619
9865
|
state,
|
|
9620
9866
|
key,
|
|
9621
|
-
|
|
9867
|
+
mask
|
|
9622
9868
|
},
|
|
9623
9869
|
navigationType
|
|
9624
9870
|
};
|
|
9625
|
-
}, [
|
|
9626
|
-
basename,
|
|
9627
|
-
pathname,
|
|
9628
|
-
search,
|
|
9629
|
-
hash,
|
|
9630
|
-
state,
|
|
9631
|
-
key,
|
|
9632
|
-
navigationType,
|
|
9633
|
-
unstable_mask
|
|
9634
|
-
]);
|
|
9871
|
+
}, [basename, pathname, search, hash, state, key, navigationType, mask]);
|
|
9635
9872
|
warning(
|
|
9636
9873
|
locationContext != null,
|
|
9637
9874
|
`<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.`
|
|
@@ -9659,8 +9896,8 @@ function Await({
|
|
|
9659
9896
|
if (dataRouterContext && dataRouterContext.onError && dataRouterStateContext) {
|
|
9660
9897
|
dataRouterContext.onError(error, {
|
|
9661
9898
|
location: dataRouterStateContext.location,
|
|
9662
|
-
params: _optionalChain([dataRouterStateContext, 'access',
|
|
9663
|
-
|
|
9899
|
+
params: _optionalChain([dataRouterStateContext, 'access', _152 => _152.matches, 'access', _153 => _153[0], 'optionalAccess', _154 => _154.params]) || {},
|
|
9900
|
+
pattern: getRoutePattern(dataRouterStateContext.matches),
|
|
9664
9901
|
errorInfo
|
|
9665
9902
|
});
|
|
9666
9903
|
}
|
|
@@ -9721,7 +9958,7 @@ var AwaitErrorBoundary = class extends React9.Component {
|
|
|
9721
9958
|
promise = resolve.then(
|
|
9722
9959
|
(data2) => Object.defineProperty(resolve, "_data", { get: () => data2 }),
|
|
9723
9960
|
(error) => {
|
|
9724
|
-
_optionalChain([this, 'access',
|
|
9961
|
+
_optionalChain([this, 'access', _155 => _155.props, 'access', _156 => _156.onError, 'optionalCall', _157 => _157(error)]);
|
|
9725
9962
|
Object.defineProperty(resolve, "_error", { get: () => error });
|
|
9726
9963
|
}
|
|
9727
9964
|
);
|
|
@@ -9986,4 +10223,7 @@ function withErrorBoundaryProps(ErrorBoundary) {
|
|
|
9986
10223
|
|
|
9987
10224
|
|
|
9988
10225
|
|
|
9989
|
-
|
|
10226
|
+
|
|
10227
|
+
|
|
10228
|
+
|
|
10229
|
+
exports.Action = Action; exports.createMemoryHistory = createMemoryHistory; exports.createBrowserHistory = createBrowserHistory; exports.createHashHistory = createHashHistory; exports.invariant = invariant; exports.warning = warning; exports.createPath = createPath; exports.parsePath = parsePath; exports.createContext = createContext; exports.RouterContextProvider = RouterContextProvider; exports.convertRoutesToDataRoutes = convertRoutesToDataRoutes; exports.matchRoutes = matchRoutes; exports.matchRoutesImpl = matchRoutesImpl; exports.generatePath = generatePath; exports.matchPath = matchPath; exports.stripBasename = stripBasename; exports.resolvePath = resolvePath; exports.resolveTo = resolveTo; exports.joinPaths = joinPaths; exports.data = data; exports.redirect = redirect; exports.redirectDocument = redirectDocument; exports.replace = replace; exports.ErrorResponseImpl = ErrorResponseImpl; exports.isRouteErrorResponse = isRouteErrorResponse; exports.parseToInfo = parseToInfo; exports.escapeHtml = escapeHtml; exports.encode = encode; exports.instrumentHandler = instrumentHandler; exports.IDLE_NAVIGATION = IDLE_NAVIGATION; exports.IDLE_FETCHER = IDLE_FETCHER; exports.IDLE_BLOCKER = IDLE_BLOCKER; exports.createRouter = createRouter; exports.createStaticHandler = createStaticHandler; exports.getStaticContextFromError = getStaticContextFromError; exports.invalidProtocols = invalidProtocols; exports.isDataWithResponseInit = isDataWithResponseInit; exports.isResponse = isResponse; exports.isRedirectStatusCode = isRedirectStatusCode; exports.isRedirectResponse = isRedirectResponse; exports.isMutationMethod = isMutationMethod; exports.createRequestInit = createRequestInit; exports.SingleFetchRedirectSymbol = SingleFetchRedirectSymbol; exports.SINGLE_FETCH_REDIRECT_STATUS = SINGLE_FETCH_REDIRECT_STATUS; exports.NO_BODY_STATUS_CODES = NO_BODY_STATUS_CODES; exports.StreamTransfer = StreamTransfer; exports.getTurboStreamSingleFetchDataStrategy = getTurboStreamSingleFetchDataStrategy; exports.getSingleFetchDataStrategyImpl = getSingleFetchDataStrategyImpl; exports.stripIndexParam = stripIndexParam; exports.singleFetchUrl = singleFetchUrl; exports.decodeViaTurboStream = decodeViaTurboStream; exports.DataRouterContext = DataRouterContext; exports.DataRouterStateContext = DataRouterStateContext; exports.RSCRouterContext = RSCRouterContext; exports.ViewTransitionContext = ViewTransitionContext; exports.FetchersContext = FetchersContext; exports.AwaitContextProvider = AwaitContextProvider; exports.NavigationContext = NavigationContext; exports.LocationContext = LocationContext; exports.RouteContext = RouteContext; exports.ENABLE_DEV_WARNINGS = ENABLE_DEV_WARNINGS; exports.warnOnce = warnOnce; exports.decodeRedirectErrorDigest = decodeRedirectErrorDigest; exports.decodeRouteErrorResponseDigest = decodeRouteErrorResponseDigest; exports.useHref = useHref; exports.useInRouterContext = useInRouterContext; exports.useLocation = useLocation; exports.useNavigationType = useNavigationType; exports.useMatch = useMatch; exports.useNavigate = useNavigate; exports.useOutletContext = useOutletContext; exports.useOutlet = useOutlet; exports.useParams = useParams; exports.useResolvedPath = useResolvedPath; exports.useRoutes = useRoutes; exports.useRouteId = useRouteId; exports.useNavigation = useNavigation; exports.useRevalidator = useRevalidator; exports.useMatches = useMatches; exports.useLoaderData = useLoaderData; exports.useRouteLoaderData = useRouteLoaderData; exports.useActionData = useActionData; exports.useRouteError = useRouteError; exports.useAsyncValue = useAsyncValue; exports.useAsyncError = useAsyncError; exports.useBlocker = useBlocker; exports.useRoute = useRoute; exports.useRouterState = useRouterState; exports.RemixErrorBoundary = RemixErrorBoundary; exports.createServerRoutes = createServerRoutes; exports.createClientRoutesWithHMRRevalidationOptOut = createClientRoutesWithHMRRevalidationOptOut; exports.noActionDefinedError = noActionDefinedError; exports.createClientRoutes = createClientRoutes; exports.shouldHydrateRouteLoader = shouldHydrateRouteLoader; exports.URL_LIMIT = URL_LIMIT; exports.getPatchRoutesOnNavigationFunction = getPatchRoutesOnNavigationFunction; exports.useFogOFWarDiscovery = useFogOFWarDiscovery; exports.getManifestPath = getManifestPath; exports.FrameworkContext = FrameworkContext; exports.usePrefetchBehavior = usePrefetchBehavior; exports.CRITICAL_CSS_DATA_ATTRIBUTE = CRITICAL_CSS_DATA_ATTRIBUTE; exports.Links = Links; exports.PrefetchPageLinks = PrefetchPageLinks; exports.Meta = Meta; exports.setIsHydrated = setIsHydrated; exports.Scripts = Scripts; exports.mergeRefs = mergeRefs; exports.mapRouteProperties = mapRouteProperties; exports.hydrationRouteProperties = hydrationRouteProperties; exports.createMemoryRouter = createMemoryRouter; exports.RouterProvider = RouterProvider; exports.DataRoutes = DataRoutes2; exports.MemoryRouter = MemoryRouter; exports.Navigate = Navigate; exports.Outlet = Outlet; exports.Route = Route; exports.Router = Router; exports.Routes = Routes; exports.Await = Await; exports.createRoutesFromChildren = createRoutesFromChildren; exports.createRoutesFromElements = createRoutesFromElements; exports.renderMatches = renderMatches; exports.WithComponentProps = WithComponentProps; exports.withComponentProps = withComponentProps; exports.WithHydrateFallbackProps = WithHydrateFallbackProps; exports.withHydrateFallbackProps = withHydrateFallbackProps; exports.WithErrorBoundaryProps = WithErrorBoundaryProps; exports.withErrorBoundaryProps = withErrorBoundaryProps;
|