react-router 7.9.4 → 7.9.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +37 -0
- package/dist/development/browser-DM83uryY.d.ts +310 -0
- package/dist/development/browser-DfMfSvsC.d.mts +310 -0
- package/dist/development/chunk-FQEOJFGW.js +188 -0
- package/dist/development/chunk-IXESJAGJ.js +1310 -0
- package/dist/development/{chunk-WY5IRSCW.mjs → chunk-JG3XND5A.mjs} +197 -857
- package/dist/development/{chunk-OIYGIGL5.mjs → chunk-UIGDSWPH.mjs} +365 -22
- package/dist/development/{chunk-DI2QHYMJ.js → chunk-VNR6V74N.js} +1226 -122
- package/dist/development/dom-export.d.mts +103 -6
- package/dist/development/dom-export.d.ts +103 -4
- package/dist/development/dom-export.js +708 -20
- package/dist/development/dom-export.mjs +692 -11
- package/dist/{production/index-react-server-client-BIz4AUNd.d.mts → development/index-react-server-client-B0vnxMMk.d.mts} +137 -78
- package/dist/{production/index-react-server-client-BbRcBjrA.d.ts → development/index-react-server-client-BSxMvS7Z.d.ts} +195 -135
- package/dist/development/index-react-server-client.d.mts +2 -3
- package/dist/development/index-react-server-client.d.ts +2 -2
- package/dist/development/index-react-server-client.js +4 -4
- package/dist/development/index-react-server-client.mjs +2 -2
- package/dist/development/index-react-server.d.mts +107 -3
- package/dist/development/index-react-server.d.ts +107 -3
- package/dist/development/index-react-server.js +235 -10
- package/dist/development/index-react-server.mjs +235 -10
- package/dist/development/index.d.mts +14 -320
- package/dist/development/index.d.ts +14 -362
- package/dist/development/index.js +146 -962
- package/dist/development/index.mjs +3 -9
- package/dist/development/{routeModules-D5iJ6JYT.d.ts → instrumentation-iAqbU5Q4.d.ts} +173 -24
- package/dist/development/lib/types/internal.d.mts +2 -3
- 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-CI4bTprK.d.mts → register-_G476ptB.d.mts} +1 -1
- package/dist/{production/register-C34pU-in.d.ts → development/register-c-dooqKE.d.ts} +1 -1
- package/dist/{production/context-DSyS5mLj.d.mts → development/router-DIAPGK5f.d.mts} +1873 -1254
- package/dist/production/browser-DM83uryY.d.ts +310 -0
- package/dist/production/browser-DfMfSvsC.d.mts +310 -0
- package/dist/production/chunk-CWEARR4H.js +188 -0
- package/dist/production/{chunk-4E5LHRQP.js → chunk-EAE7427A.js} +1226 -122
- package/dist/production/chunk-ERPFE3MR.js +1310 -0
- package/dist/production/{chunk-3TADTUL4.mjs → chunk-RZ6LZWMW.mjs} +365 -22
- package/dist/production/{chunk-FR6HSPLK.mjs → chunk-TPBVZP6U.mjs} +197 -857
- package/dist/production/dom-export.d.mts +103 -6
- package/dist/production/dom-export.d.ts +103 -4
- package/dist/production/dom-export.js +708 -20
- package/dist/production/dom-export.mjs +692 -11
- package/dist/{development/index-react-server-client-BbRcBjrA.d.ts → production/index-react-server-client-B0vnxMMk.d.mts} +195 -135
- package/dist/{development/index-react-server-client-BIz4AUNd.d.mts → production/index-react-server-client-BSxMvS7Z.d.ts} +137 -78
- package/dist/production/index-react-server-client.d.mts +2 -3
- package/dist/production/index-react-server-client.d.ts +2 -2
- package/dist/production/index-react-server-client.js +4 -4
- package/dist/production/index-react-server-client.mjs +2 -2
- package/dist/production/index-react-server.d.mts +107 -3
- package/dist/production/index-react-server.d.ts +107 -3
- package/dist/production/index-react-server.js +235 -10
- package/dist/production/index-react-server.mjs +235 -10
- package/dist/production/index.d.mts +14 -320
- package/dist/production/index.d.ts +14 -362
- package/dist/production/index.js +146 -962
- package/dist/production/index.mjs +3 -9
- package/dist/production/{routeModules-D5iJ6JYT.d.ts → instrumentation-iAqbU5Q4.d.ts} +173 -24
- package/dist/production/lib/types/internal.d.mts +2 -3
- 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/production/{register-CI4bTprK.d.mts → register-_G476ptB.d.mts} +1 -1
- package/dist/{development/register-C34pU-in.d.ts → production/register-c-dooqKE.d.ts} +1 -1
- package/dist/{development/context-DSyS5mLj.d.mts → production/router-DIAPGK5f.d.mts} +1873 -1254
- package/package.json +1 -1
- package/dist/development/browser-z32v5KVN.d.mts +0 -46
- package/dist/development/chunk-72XNTZCV.js +0 -2089
- package/dist/development/route-data-DZQOUSqV.d.mts +0 -473
- package/dist/production/browser-z32v5KVN.d.mts +0 -46
- package/dist/production/chunk-WNLQ53P5.js +0 -2089
- package/dist/production/route-data-DZQOUSqV.d.mts +0 -473
|
@@ -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.9.
|
|
2
|
+
* react-router v7.9.5
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -439,7 +439,7 @@ function isUnsupportedLazyRouteFunctionKey(key) {
|
|
|
439
439
|
function isIndexRoute(route) {
|
|
440
440
|
return route.index === true;
|
|
441
441
|
}
|
|
442
|
-
function convertRoutesToDataRoutes(routes,
|
|
442
|
+
function convertRoutesToDataRoutes(routes, mapRouteProperties2, parentPath = [], manifest = {}, allowInPlaceMutations = false) {
|
|
443
443
|
return routes.map((route, index) => {
|
|
444
444
|
let treePath = [...parentPath, String(index)];
|
|
445
445
|
let id = typeof route.id === "string" ? route.id : treePath.join("-");
|
|
@@ -454,23 +454,27 @@ function convertRoutesToDataRoutes(routes, mapRouteProperties, parentPath = [],
|
|
|
454
454
|
if (isIndexRoute(route)) {
|
|
455
455
|
let indexRoute = {
|
|
456
456
|
...route,
|
|
457
|
-
...mapRouteProperties(route),
|
|
458
457
|
id
|
|
459
458
|
};
|
|
460
|
-
manifest[id] =
|
|
459
|
+
manifest[id] = mergeRouteUpdates(
|
|
460
|
+
indexRoute,
|
|
461
|
+
mapRouteProperties2(indexRoute)
|
|
462
|
+
);
|
|
461
463
|
return indexRoute;
|
|
462
464
|
} else {
|
|
463
465
|
let pathOrLayoutRoute = {
|
|
464
466
|
...route,
|
|
465
|
-
...mapRouteProperties(route),
|
|
466
467
|
id,
|
|
467
468
|
children: void 0
|
|
468
469
|
};
|
|
469
|
-
manifest[id] =
|
|
470
|
+
manifest[id] = mergeRouteUpdates(
|
|
471
|
+
pathOrLayoutRoute,
|
|
472
|
+
mapRouteProperties2(pathOrLayoutRoute)
|
|
473
|
+
);
|
|
470
474
|
if (route.children) {
|
|
471
475
|
pathOrLayoutRoute.children = convertRoutesToDataRoutes(
|
|
472
476
|
route.children,
|
|
473
|
-
|
|
477
|
+
mapRouteProperties2,
|
|
474
478
|
treePath,
|
|
475
479
|
manifest,
|
|
476
480
|
allowInPlaceMutations
|
|
@@ -480,6 +484,17 @@ function convertRoutesToDataRoutes(routes, mapRouteProperties, parentPath = [],
|
|
|
480
484
|
}
|
|
481
485
|
});
|
|
482
486
|
}
|
|
487
|
+
function mergeRouteUpdates(route, updates) {
|
|
488
|
+
return Object.assign(route, {
|
|
489
|
+
...updates,
|
|
490
|
+
...typeof updates.lazy === "object" && updates.lazy != null ? {
|
|
491
|
+
lazy: {
|
|
492
|
+
...route.lazy,
|
|
493
|
+
...updates.lazy
|
|
494
|
+
}
|
|
495
|
+
} : {}
|
|
496
|
+
});
|
|
497
|
+
}
|
|
483
498
|
function matchRoutes(routes, locationArg, basename = "/") {
|
|
484
499
|
return matchRoutesImpl(routes, locationArg, basename, false);
|
|
485
500
|
}
|
|
@@ -720,18 +735,18 @@ function matchPath(pattern, pathname) {
|
|
|
720
735
|
let pathnameBase = matchedPathname.replace(/(.)\/+$/, "$1");
|
|
721
736
|
let captureGroups = match.slice(1);
|
|
722
737
|
let params = compiledParams.reduce(
|
|
723
|
-
(
|
|
738
|
+
(memo2, { paramName, isOptional }, index) => {
|
|
724
739
|
if (paramName === "*") {
|
|
725
740
|
let splatValue = captureGroups[index] || "";
|
|
726
741
|
pathnameBase = matchedPathname.slice(0, matchedPathname.length - splatValue.length).replace(/(.)\/+$/, "$1");
|
|
727
742
|
}
|
|
728
743
|
const value = captureGroups[index];
|
|
729
744
|
if (isOptional && !value) {
|
|
730
|
-
|
|
745
|
+
memo2[paramName] = void 0;
|
|
731
746
|
} else {
|
|
732
|
-
|
|
747
|
+
memo2[paramName] = (value || "").replace(/%2F/g, "/");
|
|
733
748
|
}
|
|
734
|
-
return
|
|
749
|
+
return memo2;
|
|
735
750
|
},
|
|
736
751
|
{}
|
|
737
752
|
);
|
|
@@ -935,6 +950,277 @@ var ErrorResponseImpl = class {
|
|
|
935
950
|
function isRouteErrorResponse(error) {
|
|
936
951
|
return error != null && typeof error.status === "number" && typeof error.statusText === "string" && typeof error.internal === "boolean" && "data" in error;
|
|
937
952
|
}
|
|
953
|
+
function getRoutePattern(paths) {
|
|
954
|
+
return paths.filter(Boolean).join("/").replace(/\/\/*/g, "/") || "/";
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
// lib/router/instrumentation.ts
|
|
958
|
+
var UninstrumentedSymbol = Symbol("Uninstrumented");
|
|
959
|
+
function getRouteInstrumentationUpdates(fns, route) {
|
|
960
|
+
let aggregated = {
|
|
961
|
+
lazy: [],
|
|
962
|
+
"lazy.loader": [],
|
|
963
|
+
"lazy.action": [],
|
|
964
|
+
"lazy.middleware": [],
|
|
965
|
+
middleware: [],
|
|
966
|
+
loader: [],
|
|
967
|
+
action: []
|
|
968
|
+
};
|
|
969
|
+
fns.forEach(
|
|
970
|
+
(fn) => fn({
|
|
971
|
+
id: route.id,
|
|
972
|
+
index: route.index,
|
|
973
|
+
path: route.path,
|
|
974
|
+
instrument(i) {
|
|
975
|
+
let keys = Object.keys(aggregated);
|
|
976
|
+
for (let key of keys) {
|
|
977
|
+
if (i[key]) {
|
|
978
|
+
aggregated[key].push(i[key]);
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
})
|
|
983
|
+
);
|
|
984
|
+
let updates = {};
|
|
985
|
+
if (typeof route.lazy === "function" && aggregated.lazy.length > 0) {
|
|
986
|
+
let instrumented = wrapImpl(aggregated.lazy, route.lazy, () => void 0);
|
|
987
|
+
if (instrumented) {
|
|
988
|
+
updates.lazy = instrumented;
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
if (typeof route.lazy === "object") {
|
|
992
|
+
let lazyObject = route.lazy;
|
|
993
|
+
["middleware", "loader", "action"].forEach((key) => {
|
|
994
|
+
let lazyFn = lazyObject[key];
|
|
995
|
+
let instrumentations = aggregated[`lazy.${key}`];
|
|
996
|
+
if (typeof lazyFn === "function" && instrumentations.length > 0) {
|
|
997
|
+
let instrumented = wrapImpl(instrumentations, lazyFn, () => void 0);
|
|
998
|
+
if (instrumented) {
|
|
999
|
+
updates.lazy = Object.assign(updates.lazy || {}, {
|
|
1000
|
+
[key]: instrumented
|
|
1001
|
+
});
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
});
|
|
1005
|
+
}
|
|
1006
|
+
["loader", "action"].forEach((key) => {
|
|
1007
|
+
let handler = route[key];
|
|
1008
|
+
if (typeof handler === "function" && aggregated[key].length > 0) {
|
|
1009
|
+
let original = _nullishCoalesce(handler[UninstrumentedSymbol], () => ( handler));
|
|
1010
|
+
let instrumented = wrapImpl(
|
|
1011
|
+
aggregated[key],
|
|
1012
|
+
original,
|
|
1013
|
+
(...args) => getHandlerInfo(args[0])
|
|
1014
|
+
);
|
|
1015
|
+
if (instrumented) {
|
|
1016
|
+
instrumented[UninstrumentedSymbol] = original;
|
|
1017
|
+
updates[key] = instrumented;
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
});
|
|
1021
|
+
if (route.middleware && route.middleware.length > 0 && aggregated.middleware.length > 0) {
|
|
1022
|
+
updates.middleware = route.middleware.map((middleware) => {
|
|
1023
|
+
let original = _nullishCoalesce(middleware[UninstrumentedSymbol], () => ( middleware));
|
|
1024
|
+
let instrumented = wrapImpl(
|
|
1025
|
+
aggregated.middleware,
|
|
1026
|
+
original,
|
|
1027
|
+
(...args) => getHandlerInfo(args[0])
|
|
1028
|
+
);
|
|
1029
|
+
if (instrumented) {
|
|
1030
|
+
instrumented[UninstrumentedSymbol] = original;
|
|
1031
|
+
return instrumented;
|
|
1032
|
+
}
|
|
1033
|
+
return middleware;
|
|
1034
|
+
});
|
|
1035
|
+
}
|
|
1036
|
+
return updates;
|
|
1037
|
+
}
|
|
1038
|
+
function instrumentClientSideRouter(router, fns) {
|
|
1039
|
+
let aggregated = {
|
|
1040
|
+
navigate: [],
|
|
1041
|
+
fetch: []
|
|
1042
|
+
};
|
|
1043
|
+
fns.forEach(
|
|
1044
|
+
(fn) => fn({
|
|
1045
|
+
instrument(i) {
|
|
1046
|
+
let keys = Object.keys(i);
|
|
1047
|
+
for (let key of keys) {
|
|
1048
|
+
if (i[key]) {
|
|
1049
|
+
aggregated[key].push(i[key]);
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
})
|
|
1054
|
+
);
|
|
1055
|
+
if (aggregated.navigate.length > 0) {
|
|
1056
|
+
let navigate = _nullishCoalesce(router.navigate[UninstrumentedSymbol], () => ( router.navigate));
|
|
1057
|
+
let instrumentedNavigate = wrapImpl(
|
|
1058
|
+
aggregated.navigate,
|
|
1059
|
+
navigate,
|
|
1060
|
+
(...args) => {
|
|
1061
|
+
let [to, opts] = args;
|
|
1062
|
+
return {
|
|
1063
|
+
to: typeof to === "number" || typeof to === "string" ? to : to ? createPath(to) : ".",
|
|
1064
|
+
...getRouterInfo(router, _nullishCoalesce(opts, () => ( {})))
|
|
1065
|
+
};
|
|
1066
|
+
}
|
|
1067
|
+
);
|
|
1068
|
+
if (instrumentedNavigate) {
|
|
1069
|
+
instrumentedNavigate[UninstrumentedSymbol] = navigate;
|
|
1070
|
+
router.navigate = instrumentedNavigate;
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
if (aggregated.fetch.length > 0) {
|
|
1074
|
+
let fetch2 = _nullishCoalesce(router.fetch[UninstrumentedSymbol], () => ( router.fetch));
|
|
1075
|
+
let instrumentedFetch = wrapImpl(aggregated.fetch, fetch2, (...args) => {
|
|
1076
|
+
let [key, , href, opts] = args;
|
|
1077
|
+
return {
|
|
1078
|
+
href: _nullishCoalesce(href, () => ( ".")),
|
|
1079
|
+
fetcherKey: key,
|
|
1080
|
+
...getRouterInfo(router, _nullishCoalesce(opts, () => ( {})))
|
|
1081
|
+
};
|
|
1082
|
+
});
|
|
1083
|
+
if (instrumentedFetch) {
|
|
1084
|
+
instrumentedFetch[UninstrumentedSymbol] = fetch2;
|
|
1085
|
+
router.fetch = instrumentedFetch;
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
return router;
|
|
1089
|
+
}
|
|
1090
|
+
function instrumentHandler(handler, fns) {
|
|
1091
|
+
let aggregated = {
|
|
1092
|
+
request: []
|
|
1093
|
+
};
|
|
1094
|
+
fns.forEach(
|
|
1095
|
+
(fn) => fn({
|
|
1096
|
+
instrument(i) {
|
|
1097
|
+
let keys = Object.keys(i);
|
|
1098
|
+
for (let key of keys) {
|
|
1099
|
+
if (i[key]) {
|
|
1100
|
+
aggregated[key].push(i[key]);
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
})
|
|
1105
|
+
);
|
|
1106
|
+
let instrumentedHandler = handler;
|
|
1107
|
+
if (aggregated.request.length > 0) {
|
|
1108
|
+
instrumentedHandler = wrapImpl(aggregated.request, handler, (...args) => {
|
|
1109
|
+
let [request, context] = args;
|
|
1110
|
+
return {
|
|
1111
|
+
request: getReadonlyRequest(request),
|
|
1112
|
+
context: context != null ? getReadonlyContext(context) : context
|
|
1113
|
+
};
|
|
1114
|
+
});
|
|
1115
|
+
}
|
|
1116
|
+
return instrumentedHandler;
|
|
1117
|
+
}
|
|
1118
|
+
function wrapImpl(impls, handler, getInfo) {
|
|
1119
|
+
if (impls.length === 0) {
|
|
1120
|
+
return null;
|
|
1121
|
+
}
|
|
1122
|
+
return async (...args) => {
|
|
1123
|
+
let result = await recurseRight(
|
|
1124
|
+
impls,
|
|
1125
|
+
getInfo(...args),
|
|
1126
|
+
() => handler(...args),
|
|
1127
|
+
impls.length - 1
|
|
1128
|
+
);
|
|
1129
|
+
if (result.type === "error") {
|
|
1130
|
+
throw result.value;
|
|
1131
|
+
}
|
|
1132
|
+
return result.value;
|
|
1133
|
+
};
|
|
1134
|
+
}
|
|
1135
|
+
async function recurseRight(impls, info, handler, index) {
|
|
1136
|
+
let impl = impls[index];
|
|
1137
|
+
let result;
|
|
1138
|
+
if (!impl) {
|
|
1139
|
+
try {
|
|
1140
|
+
let value = await handler();
|
|
1141
|
+
result = { type: "success", value };
|
|
1142
|
+
} catch (e) {
|
|
1143
|
+
result = { type: "error", value: e };
|
|
1144
|
+
}
|
|
1145
|
+
} else {
|
|
1146
|
+
let handlerPromise = void 0;
|
|
1147
|
+
let callHandler = async () => {
|
|
1148
|
+
if (handlerPromise) {
|
|
1149
|
+
console.error("You cannot call instrumented handlers more than once");
|
|
1150
|
+
} else {
|
|
1151
|
+
handlerPromise = recurseRight(impls, info, handler, index - 1);
|
|
1152
|
+
}
|
|
1153
|
+
result = await handlerPromise;
|
|
1154
|
+
invariant(result, "Expected a result");
|
|
1155
|
+
if (result.type === "error" && result.value instanceof Error) {
|
|
1156
|
+
return { status: "error", error: result.value };
|
|
1157
|
+
}
|
|
1158
|
+
return { status: "success", error: void 0 };
|
|
1159
|
+
};
|
|
1160
|
+
try {
|
|
1161
|
+
await impl(callHandler, info);
|
|
1162
|
+
} catch (e) {
|
|
1163
|
+
console.error("An instrumentation function threw an error:", e);
|
|
1164
|
+
}
|
|
1165
|
+
if (!handlerPromise) {
|
|
1166
|
+
await callHandler();
|
|
1167
|
+
}
|
|
1168
|
+
await handlerPromise;
|
|
1169
|
+
}
|
|
1170
|
+
if (result) {
|
|
1171
|
+
return result;
|
|
1172
|
+
}
|
|
1173
|
+
return {
|
|
1174
|
+
type: "error",
|
|
1175
|
+
value: new Error("No result assigned in instrumentation chain.")
|
|
1176
|
+
};
|
|
1177
|
+
}
|
|
1178
|
+
function getHandlerInfo(args) {
|
|
1179
|
+
let { request, context, params, unstable_pattern } = args;
|
|
1180
|
+
return {
|
|
1181
|
+
request: getReadonlyRequest(request),
|
|
1182
|
+
params: { ...params },
|
|
1183
|
+
unstable_pattern,
|
|
1184
|
+
context: getReadonlyContext(context)
|
|
1185
|
+
};
|
|
1186
|
+
}
|
|
1187
|
+
function getRouterInfo(router, opts) {
|
|
1188
|
+
return {
|
|
1189
|
+
currentUrl: createPath(router.state.location),
|
|
1190
|
+
..."formMethod" in opts ? { formMethod: opts.formMethod } : {},
|
|
1191
|
+
..."formEncType" in opts ? { formEncType: opts.formEncType } : {},
|
|
1192
|
+
..."formData" in opts ? { formData: opts.formData } : {},
|
|
1193
|
+
..."body" in opts ? { body: opts.body } : {}
|
|
1194
|
+
};
|
|
1195
|
+
}
|
|
1196
|
+
function getReadonlyRequest(request) {
|
|
1197
|
+
return {
|
|
1198
|
+
method: request.method,
|
|
1199
|
+
url: request.url,
|
|
1200
|
+
headers: {
|
|
1201
|
+
get: (...args) => request.headers.get(...args)
|
|
1202
|
+
}
|
|
1203
|
+
};
|
|
1204
|
+
}
|
|
1205
|
+
function getReadonlyContext(context) {
|
|
1206
|
+
if (isPlainObject(context)) {
|
|
1207
|
+
let frozen = { ...context };
|
|
1208
|
+
Object.freeze(frozen);
|
|
1209
|
+
return frozen;
|
|
1210
|
+
} else {
|
|
1211
|
+
return {
|
|
1212
|
+
get: (ctx) => context.get(ctx)
|
|
1213
|
+
};
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
var objectProtoNames = Object.getOwnPropertyNames(Object.prototype).sort().join("\0");
|
|
1217
|
+
function isPlainObject(thing) {
|
|
1218
|
+
if (thing === null || typeof thing !== "object") {
|
|
1219
|
+
return false;
|
|
1220
|
+
}
|
|
1221
|
+
const proto = Object.getPrototypeOf(thing);
|
|
1222
|
+
return proto === Object.prototype || proto === null || Object.getOwnPropertyNames(proto).sort().join("\0") === objectProtoNames;
|
|
1223
|
+
}
|
|
938
1224
|
|
|
939
1225
|
// lib/router/router.ts
|
|
940
1226
|
var validMutationMethodsArr = [
|
|
@@ -993,12 +1279,25 @@ function createRouter(init) {
|
|
|
993
1279
|
init.routes.length > 0,
|
|
994
1280
|
"You must provide a non-empty routes array to createRouter"
|
|
995
1281
|
);
|
|
996
|
-
let
|
|
997
|
-
let
|
|
1282
|
+
let hydrationRouteProperties2 = init.hydrationRouteProperties || [];
|
|
1283
|
+
let _mapRouteProperties = init.mapRouteProperties || defaultMapRouteProperties;
|
|
1284
|
+
let mapRouteProperties2 = _mapRouteProperties;
|
|
1285
|
+
if (init.unstable_instrumentations) {
|
|
1286
|
+
let instrumentations = init.unstable_instrumentations;
|
|
1287
|
+
mapRouteProperties2 = (route) => {
|
|
1288
|
+
return {
|
|
1289
|
+
..._mapRouteProperties(route),
|
|
1290
|
+
...getRouteInstrumentationUpdates(
|
|
1291
|
+
instrumentations.map((i) => i.route).filter(Boolean),
|
|
1292
|
+
route
|
|
1293
|
+
)
|
|
1294
|
+
};
|
|
1295
|
+
};
|
|
1296
|
+
}
|
|
998
1297
|
let manifest = {};
|
|
999
1298
|
let dataRoutes = convertRoutesToDataRoutes(
|
|
1000
1299
|
init.routes,
|
|
1001
|
-
|
|
1300
|
+
mapRouteProperties2,
|
|
1002
1301
|
void 0,
|
|
1003
1302
|
manifest
|
|
1004
1303
|
);
|
|
@@ -1610,12 +1909,12 @@ function createRouter(init) {
|
|
|
1610
1909
|
};
|
|
1611
1910
|
} else {
|
|
1612
1911
|
let dsMatches = getTargetedDataStrategyMatches(
|
|
1613
|
-
|
|
1912
|
+
mapRouteProperties2,
|
|
1614
1913
|
manifest,
|
|
1615
1914
|
request,
|
|
1616
1915
|
matches,
|
|
1617
1916
|
actionMatch,
|
|
1618
|
-
initialHydration ? [] :
|
|
1917
|
+
initialHydration ? [] : hydrationRouteProperties2,
|
|
1619
1918
|
scopedContext
|
|
1620
1919
|
);
|
|
1621
1920
|
let results = await callDataStrategy(
|
|
@@ -1736,14 +2035,14 @@ function createRouter(init) {
|
|
|
1736
2035
|
let { dsMatches, revalidatingFetchers } = getMatchesToLoad(
|
|
1737
2036
|
request,
|
|
1738
2037
|
scopedContext,
|
|
1739
|
-
|
|
2038
|
+
mapRouteProperties2,
|
|
1740
2039
|
manifest,
|
|
1741
2040
|
init.history,
|
|
1742
2041
|
state,
|
|
1743
2042
|
matches,
|
|
1744
2043
|
activeSubmission,
|
|
1745
2044
|
location,
|
|
1746
|
-
initialHydration ? [] :
|
|
2045
|
+
initialHydration ? [] : hydrationRouteProperties2,
|
|
1747
2046
|
initialHydration === true,
|
|
1748
2047
|
isRevalidationRequired,
|
|
1749
2048
|
cancelledFetcherLoads,
|
|
@@ -1992,12 +2291,12 @@ function createRouter(init) {
|
|
|
1992
2291
|
fetchControllers.set(key, abortController);
|
|
1993
2292
|
let originatingLoadId = incrementingLoadId;
|
|
1994
2293
|
let fetchMatches = getTargetedDataStrategyMatches(
|
|
1995
|
-
|
|
2294
|
+
mapRouteProperties2,
|
|
1996
2295
|
manifest,
|
|
1997
2296
|
fetchRequest,
|
|
1998
2297
|
requestMatches,
|
|
1999
2298
|
match,
|
|
2000
|
-
|
|
2299
|
+
hydrationRouteProperties2,
|
|
2001
2300
|
scopedContext
|
|
2002
2301
|
);
|
|
2003
2302
|
let actionResults = await callDataStrategy(
|
|
@@ -2054,14 +2353,14 @@ function createRouter(init) {
|
|
|
2054
2353
|
let { dsMatches, revalidatingFetchers } = getMatchesToLoad(
|
|
2055
2354
|
revalidationRequest,
|
|
2056
2355
|
scopedContext,
|
|
2057
|
-
|
|
2356
|
+
mapRouteProperties2,
|
|
2058
2357
|
manifest,
|
|
2059
2358
|
init.history,
|
|
2060
2359
|
state,
|
|
2061
2360
|
matches,
|
|
2062
2361
|
submission,
|
|
2063
2362
|
nextLocation,
|
|
2064
|
-
|
|
2363
|
+
hydrationRouteProperties2,
|
|
2065
2364
|
false,
|
|
2066
2365
|
isRevalidationRequired,
|
|
2067
2366
|
cancelledFetcherLoads,
|
|
@@ -2207,12 +2506,12 @@ function createRouter(init) {
|
|
|
2207
2506
|
fetchControllers.set(key, abortController);
|
|
2208
2507
|
let originatingLoadId = incrementingLoadId;
|
|
2209
2508
|
let dsMatches = getTargetedDataStrategyMatches(
|
|
2210
|
-
|
|
2509
|
+
mapRouteProperties2,
|
|
2211
2510
|
manifest,
|
|
2212
2511
|
fetchRequest,
|
|
2213
2512
|
matches,
|
|
2214
2513
|
match,
|
|
2215
|
-
|
|
2514
|
+
hydrationRouteProperties2,
|
|
2216
2515
|
scopedContext
|
|
2217
2516
|
);
|
|
2218
2517
|
let results = await callDataStrategy(
|
|
@@ -2647,7 +2946,7 @@ function createRouter(init) {
|
|
|
2647
2946
|
children,
|
|
2648
2947
|
routesToUse,
|
|
2649
2948
|
localManifest,
|
|
2650
|
-
|
|
2949
|
+
mapRouteProperties2,
|
|
2651
2950
|
false
|
|
2652
2951
|
);
|
|
2653
2952
|
}
|
|
@@ -2684,7 +2983,7 @@ function createRouter(init) {
|
|
|
2684
2983
|
manifest = {};
|
|
2685
2984
|
inFlightDataRoutes = convertRoutesToDataRoutes(
|
|
2686
2985
|
newRoutes,
|
|
2687
|
-
|
|
2986
|
+
mapRouteProperties2,
|
|
2688
2987
|
void 0,
|
|
2689
2988
|
manifest
|
|
2690
2989
|
);
|
|
@@ -2697,7 +2996,7 @@ function createRouter(init) {
|
|
|
2697
2996
|
children,
|
|
2698
2997
|
routesToUse,
|
|
2699
2998
|
manifest,
|
|
2700
|
-
|
|
2999
|
+
mapRouteProperties2,
|
|
2701
3000
|
unstable_allowElementMutations
|
|
2702
3001
|
);
|
|
2703
3002
|
if (isNonHMR) {
|
|
@@ -2746,6 +3045,12 @@ function createRouter(init) {
|
|
|
2746
3045
|
updateState(newState);
|
|
2747
3046
|
}
|
|
2748
3047
|
};
|
|
3048
|
+
if (init.unstable_instrumentations) {
|
|
3049
|
+
router = instrumentClientSideRouter(
|
|
3050
|
+
router,
|
|
3051
|
+
init.unstable_instrumentations.map((i) => i.router).filter(Boolean)
|
|
3052
|
+
);
|
|
3053
|
+
}
|
|
2749
3054
|
return router;
|
|
2750
3055
|
}
|
|
2751
3056
|
function createStaticHandler(routes, opts) {
|
|
@@ -2755,10 +3060,23 @@ function createStaticHandler(routes, opts) {
|
|
|
2755
3060
|
);
|
|
2756
3061
|
let manifest = {};
|
|
2757
3062
|
let basename = (opts ? opts.basename : null) || "/";
|
|
2758
|
-
let
|
|
3063
|
+
let _mapRouteProperties = _optionalChain([opts, 'optionalAccess', _16 => _16.mapRouteProperties]) || defaultMapRouteProperties;
|
|
3064
|
+
let mapRouteProperties2 = _mapRouteProperties;
|
|
3065
|
+
if (_optionalChain([opts, 'optionalAccess', _17 => _17.unstable_instrumentations])) {
|
|
3066
|
+
let instrumentations = opts.unstable_instrumentations;
|
|
3067
|
+
mapRouteProperties2 = (route) => {
|
|
3068
|
+
return {
|
|
3069
|
+
..._mapRouteProperties(route),
|
|
3070
|
+
...getRouteInstrumentationUpdates(
|
|
3071
|
+
instrumentations.map((i) => i.route).filter(Boolean),
|
|
3072
|
+
route
|
|
3073
|
+
)
|
|
3074
|
+
};
|
|
3075
|
+
};
|
|
3076
|
+
}
|
|
2759
3077
|
let dataRoutes = convertRoutesToDataRoutes(
|
|
2760
3078
|
routes,
|
|
2761
|
-
|
|
3079
|
+
mapRouteProperties2,
|
|
2762
3080
|
void 0,
|
|
2763
3081
|
manifest
|
|
2764
3082
|
);
|
|
@@ -2819,12 +3137,13 @@ function createStaticHandler(routes, opts) {
|
|
|
2819
3137
|
await loadLazyMiddlewareForMatches(
|
|
2820
3138
|
matches,
|
|
2821
3139
|
manifest,
|
|
2822
|
-
|
|
3140
|
+
mapRouteProperties2
|
|
2823
3141
|
);
|
|
2824
3142
|
let renderedStaticContext;
|
|
2825
3143
|
let response = await runServerMiddlewarePipeline(
|
|
2826
3144
|
{
|
|
2827
3145
|
request,
|
|
3146
|
+
unstable_pattern: getRoutePattern(matches.map((m) => m.route.path)),
|
|
2828
3147
|
matches,
|
|
2829
3148
|
params: matches[0].params,
|
|
2830
3149
|
// If we're calling middleware then it must be enabled so we can cast
|
|
@@ -2888,9 +3207,9 @@ function createStaticHandler(routes, opts) {
|
|
|
2888
3207
|
} else {
|
|
2889
3208
|
let boundaryRouteId = skipLoaderErrorBubbling ? routeId : findNearestBoundary(
|
|
2890
3209
|
matches,
|
|
2891
|
-
_optionalChain([matches, 'access',
|
|
3210
|
+
_optionalChain([matches, 'access', _18 => _18.find, 'call', _19 => _19(
|
|
2892
3211
|
(m) => m.route.id === routeId || m.route.loader
|
|
2893
|
-
), 'optionalAccess',
|
|
3212
|
+
), 'optionalAccess', _20 => _20.route, 'access', _21 => _21.id]) || routeId
|
|
2894
3213
|
).route.id;
|
|
2895
3214
|
let staticContext = {
|
|
2896
3215
|
matches,
|
|
@@ -2966,10 +3285,11 @@ function createStaticHandler(routes, opts) {
|
|
|
2966
3285
|
requestContext instanceof RouterContextProvider,
|
|
2967
3286
|
"When using middleware in `staticHandler.queryRoute()`, any provided `requestContext` must be an instance of `RouterContextProvider`"
|
|
2968
3287
|
);
|
|
2969
|
-
await loadLazyMiddlewareForMatches(matches, manifest,
|
|
3288
|
+
await loadLazyMiddlewareForMatches(matches, manifest, mapRouteProperties2);
|
|
2970
3289
|
let response = await runServerMiddlewarePipeline(
|
|
2971
3290
|
{
|
|
2972
3291
|
request,
|
|
3292
|
+
unstable_pattern: getRoutePattern(matches.map((m) => m.route.path)),
|
|
2973
3293
|
matches,
|
|
2974
3294
|
params: matches[0].params,
|
|
2975
3295
|
// If we're calling middleware then it must be enabled so we can cast
|
|
@@ -3101,7 +3421,7 @@ function createStaticHandler(routes, opts) {
|
|
|
3101
3421
|
};
|
|
3102
3422
|
} else {
|
|
3103
3423
|
let dsMatches = getTargetedDataStrategyMatches(
|
|
3104
|
-
|
|
3424
|
+
mapRouteProperties2,
|
|
3105
3425
|
manifest,
|
|
3106
3426
|
request,
|
|
3107
3427
|
matches,
|
|
@@ -3222,17 +3542,17 @@ function createStaticHandler(routes, opts) {
|
|
|
3222
3542
|
}
|
|
3223
3543
|
async function loadRouteData(request, matches, requestContext, dataStrategy, skipLoaderErrorBubbling, routeMatch, filterMatchesToLoad, pendingActionResult) {
|
|
3224
3544
|
let isRouteRequest = routeMatch != null;
|
|
3225
|
-
if (isRouteRequest && !_optionalChain([routeMatch, 'optionalAccess',
|
|
3545
|
+
if (isRouteRequest && !_optionalChain([routeMatch, 'optionalAccess', _22 => _22.route, 'access', _23 => _23.loader]) && !_optionalChain([routeMatch, 'optionalAccess', _24 => _24.route, 'access', _25 => _25.lazy])) {
|
|
3226
3546
|
throw getInternalRouterError(400, {
|
|
3227
3547
|
method: request.method,
|
|
3228
3548
|
pathname: new URL(request.url).pathname,
|
|
3229
|
-
routeId: _optionalChain([routeMatch, 'optionalAccess',
|
|
3549
|
+
routeId: _optionalChain([routeMatch, 'optionalAccess', _26 => _26.route, 'access', _27 => _27.id])
|
|
3230
3550
|
});
|
|
3231
3551
|
}
|
|
3232
3552
|
let dsMatches;
|
|
3233
3553
|
if (routeMatch) {
|
|
3234
3554
|
dsMatches = getTargetedDataStrategyMatches(
|
|
3235
|
-
|
|
3555
|
+
mapRouteProperties2,
|
|
3236
3556
|
manifest,
|
|
3237
3557
|
request,
|
|
3238
3558
|
matches,
|
|
@@ -3245,12 +3565,14 @@ function createStaticHandler(routes, opts) {
|
|
|
3245
3565
|
// Up to but not including the boundary
|
|
3246
3566
|
matches.findIndex((m) => m.route.id === pendingActionResult[0]) - 1
|
|
3247
3567
|
) : void 0;
|
|
3568
|
+
let pattern = getRoutePattern(matches.map((m) => m.route.path));
|
|
3248
3569
|
dsMatches = matches.map((match, index) => {
|
|
3249
3570
|
if (maxIdx != null && index > maxIdx) {
|
|
3250
3571
|
return getDataStrategyMatch(
|
|
3251
|
-
|
|
3572
|
+
mapRouteProperties2,
|
|
3252
3573
|
manifest,
|
|
3253
3574
|
request,
|
|
3575
|
+
pattern,
|
|
3254
3576
|
match,
|
|
3255
3577
|
[],
|
|
3256
3578
|
requestContext,
|
|
@@ -3258,9 +3580,10 @@ function createStaticHandler(routes, opts) {
|
|
|
3258
3580
|
);
|
|
3259
3581
|
}
|
|
3260
3582
|
return getDataStrategyMatch(
|
|
3261
|
-
|
|
3583
|
+
mapRouteProperties2,
|
|
3262
3584
|
manifest,
|
|
3263
3585
|
request,
|
|
3586
|
+
pattern,
|
|
3264
3587
|
match,
|
|
3265
3588
|
[],
|
|
3266
3589
|
requestContext,
|
|
@@ -3518,7 +3841,7 @@ function normalizeNavigateOptions(isFetcher, path, opts) {
|
|
|
3518
3841
|
parsedPath.search = `?${searchParams}`;
|
|
3519
3842
|
return { path: createPath(parsedPath), submission };
|
|
3520
3843
|
}
|
|
3521
|
-
function getMatchesToLoad(request, scopedContext,
|
|
3844
|
+
function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest, history, state, matches, submission, location, lazyRoutePropertiesToSkip, initialHydration, isRevalidationRequired, cancelledFetcherLoads, fetchersQueuedForDeletion, fetchLoadMatches, fetchRedirectIds, routesToUse, basename, hasPatchRoutesOnNavigation, pendingActionResult) {
|
|
3522
3845
|
let actionResult = pendingActionResult ? isErrorResult(pendingActionResult[1]) ? pendingActionResult[1].error : pendingActionResult[1].data : void 0;
|
|
3523
3846
|
let currentUrl = history.createURL(state.location);
|
|
3524
3847
|
let nextUrl = history.createURL(location);
|
|
@@ -3534,13 +3857,14 @@ function getMatchesToLoad(request, scopedContext, mapRouteProperties, manifest,
|
|
|
3534
3857
|
let shouldSkipRevalidation = actionStatus && actionStatus >= 400;
|
|
3535
3858
|
let baseShouldRevalidateArgs = {
|
|
3536
3859
|
currentUrl,
|
|
3537
|
-
currentParams: _optionalChain([state, 'access',
|
|
3860
|
+
currentParams: _optionalChain([state, 'access', _28 => _28.matches, 'access', _29 => _29[0], 'optionalAccess', _30 => _30.params]) || {},
|
|
3538
3861
|
nextUrl,
|
|
3539
3862
|
nextParams: matches[0].params,
|
|
3540
3863
|
...submission,
|
|
3541
3864
|
actionResult,
|
|
3542
3865
|
actionStatus
|
|
3543
3866
|
};
|
|
3867
|
+
let pattern = getRoutePattern(matches.map((m) => m.route.path));
|
|
3544
3868
|
let dsMatches = matches.map((match, index) => {
|
|
3545
3869
|
let { route } = match;
|
|
3546
3870
|
let forceShouldLoad = null;
|
|
@@ -3561,9 +3885,10 @@ function getMatchesToLoad(request, scopedContext, mapRouteProperties, manifest,
|
|
|
3561
3885
|
}
|
|
3562
3886
|
if (forceShouldLoad !== null) {
|
|
3563
3887
|
return getDataStrategyMatch(
|
|
3564
|
-
|
|
3888
|
+
mapRouteProperties2,
|
|
3565
3889
|
manifest,
|
|
3566
3890
|
request,
|
|
3891
|
+
pattern,
|
|
3567
3892
|
match,
|
|
3568
3893
|
lazyRoutePropertiesToSkip,
|
|
3569
3894
|
scopedContext,
|
|
@@ -3581,9 +3906,10 @@ function getMatchesToLoad(request, scopedContext, mapRouteProperties, manifest,
|
|
|
3581
3906
|
};
|
|
3582
3907
|
let shouldLoad = shouldRevalidateLoader(match, shouldRevalidateArgs);
|
|
3583
3908
|
return getDataStrategyMatch(
|
|
3584
|
-
|
|
3909
|
+
mapRouteProperties2,
|
|
3585
3910
|
manifest,
|
|
3586
3911
|
request,
|
|
3912
|
+
pattern,
|
|
3587
3913
|
match,
|
|
3588
3914
|
lazyRoutePropertiesToSkip,
|
|
3589
3915
|
scopedContext,
|
|
@@ -3628,7 +3954,7 @@ function getMatchesToLoad(request, scopedContext, mapRouteProperties, manifest,
|
|
|
3628
3954
|
if (cancelledFetcherLoads.has(key)) {
|
|
3629
3955
|
cancelledFetcherLoads.delete(key);
|
|
3630
3956
|
fetcherDsMatches = getTargetedDataStrategyMatches(
|
|
3631
|
-
|
|
3957
|
+
mapRouteProperties2,
|
|
3632
3958
|
manifest,
|
|
3633
3959
|
fetchRequest,
|
|
3634
3960
|
fetcherMatches,
|
|
@@ -3639,7 +3965,7 @@ function getMatchesToLoad(request, scopedContext, mapRouteProperties, manifest,
|
|
|
3639
3965
|
} else if (isMidInitialLoad) {
|
|
3640
3966
|
if (isRevalidationRequired) {
|
|
3641
3967
|
fetcherDsMatches = getTargetedDataStrategyMatches(
|
|
3642
|
-
|
|
3968
|
+
mapRouteProperties2,
|
|
3643
3969
|
manifest,
|
|
3644
3970
|
fetchRequest,
|
|
3645
3971
|
fetcherMatches,
|
|
@@ -3655,7 +3981,7 @@ function getMatchesToLoad(request, scopedContext, mapRouteProperties, manifest,
|
|
|
3655
3981
|
};
|
|
3656
3982
|
if (shouldRevalidateLoader(fetcherMatch, shouldRevalidateArgs)) {
|
|
3657
3983
|
fetcherDsMatches = getTargetedDataStrategyMatches(
|
|
3658
|
-
|
|
3984
|
+
mapRouteProperties2,
|
|
3659
3985
|
manifest,
|
|
3660
3986
|
fetchRequest,
|
|
3661
3987
|
fetcherMatches,
|
|
@@ -3727,7 +4053,7 @@ function shouldRevalidateLoader(loaderMatch, arg) {
|
|
|
3727
4053
|
}
|
|
3728
4054
|
return arg.defaultShouldRevalidate;
|
|
3729
4055
|
}
|
|
3730
|
-
function patchRoutesImpl(routeId, children, routesToUse, manifest,
|
|
4056
|
+
function patchRoutesImpl(routeId, children, routesToUse, manifest, mapRouteProperties2, allowElementMutations) {
|
|
3731
4057
|
let childrenToPatch;
|
|
3732
4058
|
if (routeId) {
|
|
3733
4059
|
let route = manifest[routeId];
|
|
@@ -3757,8 +4083,8 @@ function patchRoutesImpl(routeId, children, routesToUse, manifest, mapRoutePrope
|
|
|
3757
4083
|
if (uniqueChildren.length > 0) {
|
|
3758
4084
|
let newRoutes = convertRoutesToDataRoutes(
|
|
3759
4085
|
uniqueChildren,
|
|
3760
|
-
|
|
3761
|
-
[routeId || "_", "patch", String(_optionalChain([childrenToPatch, 'optionalAccess',
|
|
4086
|
+
mapRouteProperties2,
|
|
4087
|
+
[routeId || "_", "patch", String(_optionalChain([childrenToPatch, 'optionalAccess', _31 => _31.length]) || "0")],
|
|
3762
4088
|
manifest
|
|
3763
4089
|
);
|
|
3764
4090
|
childrenToPatch.push(...newRoutes);
|
|
@@ -3769,7 +4095,7 @@ function patchRoutesImpl(routeId, children, routesToUse, manifest, mapRoutePrope
|
|
|
3769
4095
|
let existingRouteTyped = existingRoute;
|
|
3770
4096
|
let [newRouteTyped] = convertRoutesToDataRoutes(
|
|
3771
4097
|
[newRoute],
|
|
3772
|
-
|
|
4098
|
+
mapRouteProperties2,
|
|
3773
4099
|
[],
|
|
3774
4100
|
// Doesn't matter for mutated routes since they already have an id
|
|
3775
4101
|
{},
|
|
@@ -3795,7 +4121,7 @@ function isSameRoute(newRoute, existingRoute) {
|
|
|
3795
4121
|
return true;
|
|
3796
4122
|
}
|
|
3797
4123
|
return newRoute.children.every(
|
|
3798
|
-
(aChild, i) => _optionalChain([existingRoute, 'access',
|
|
4124
|
+
(aChild, i) => _optionalChain([existingRoute, 'access', _32 => _32.children, 'optionalAccess', _33 => _33.some, 'call', _34 => _34((bChild) => isSameRoute(aChild, bChild))])
|
|
3799
4125
|
);
|
|
3800
4126
|
}
|
|
3801
4127
|
var lazyRoutePropertyCache = /* @__PURE__ */ new WeakMap();
|
|
@@ -3803,7 +4129,7 @@ var loadLazyRouteProperty = ({
|
|
|
3803
4129
|
key,
|
|
3804
4130
|
route,
|
|
3805
4131
|
manifest,
|
|
3806
|
-
mapRouteProperties
|
|
4132
|
+
mapRouteProperties: mapRouteProperties2
|
|
3807
4133
|
}) => {
|
|
3808
4134
|
let routeToUpdate = manifest[route.id];
|
|
3809
4135
|
invariant(routeToUpdate, "No route found in manifest");
|
|
@@ -3842,7 +4168,7 @@ var loadLazyRouteProperty = ({
|
|
|
3842
4168
|
let value = await lazyFn();
|
|
3843
4169
|
if (value != null) {
|
|
3844
4170
|
Object.assign(routeToUpdate, { [key]: value });
|
|
3845
|
-
Object.assign(routeToUpdate,
|
|
4171
|
+
Object.assign(routeToUpdate, mapRouteProperties2(routeToUpdate));
|
|
3846
4172
|
}
|
|
3847
4173
|
}
|
|
3848
4174
|
if (typeof routeToUpdate.lazy === "object") {
|
|
@@ -3856,7 +4182,7 @@ var loadLazyRouteProperty = ({
|
|
|
3856
4182
|
return propertyPromise;
|
|
3857
4183
|
};
|
|
3858
4184
|
var lazyRouteFunctionCache = /* @__PURE__ */ new WeakMap();
|
|
3859
|
-
function loadLazyRoute(route, type, manifest,
|
|
4185
|
+
function loadLazyRoute(route, type, manifest, mapRouteProperties2, lazyRoutePropertiesToSkip) {
|
|
3860
4186
|
let routeToUpdate = manifest[route.id];
|
|
3861
4187
|
invariant(routeToUpdate, "No route found in manifest");
|
|
3862
4188
|
if (!route.lazy) {
|
|
@@ -3909,7 +4235,7 @@ function loadLazyRoute(route, type, manifest, mapRouteProperties, lazyRoutePrope
|
|
|
3909
4235
|
// To keep things framework agnostic, we use the provided `mapRouteProperties`
|
|
3910
4236
|
// function to set the framework-aware properties (`element`/`hasErrorBoundary`)
|
|
3911
4237
|
// since the logic will differ between frameworks.
|
|
3912
|
-
...
|
|
4238
|
+
...mapRouteProperties2(routeToUpdate),
|
|
3913
4239
|
lazy: void 0
|
|
3914
4240
|
});
|
|
3915
4241
|
})();
|
|
@@ -3932,7 +4258,7 @@ function loadLazyRoute(route, type, manifest, mapRouteProperties, lazyRoutePrope
|
|
|
3932
4258
|
key,
|
|
3933
4259
|
route,
|
|
3934
4260
|
manifest,
|
|
3935
|
-
mapRouteProperties
|
|
4261
|
+
mapRouteProperties: mapRouteProperties2
|
|
3936
4262
|
});
|
|
3937
4263
|
if (promise) {
|
|
3938
4264
|
lazyPropertyPromises.push(promise);
|
|
@@ -3943,9 +4269,9 @@ function loadLazyRoute(route, type, manifest, mapRouteProperties, lazyRoutePrope
|
|
|
3943
4269
|
}
|
|
3944
4270
|
let lazyRoutePromise = lazyPropertyPromises.length > 0 ? Promise.all(lazyPropertyPromises).then(() => {
|
|
3945
4271
|
}) : void 0;
|
|
3946
|
-
_optionalChain([lazyRoutePromise, 'optionalAccess',
|
|
4272
|
+
_optionalChain([lazyRoutePromise, 'optionalAccess', _35 => _35.catch, 'call', _36 => _36(() => {
|
|
3947
4273
|
})]);
|
|
3948
|
-
_optionalChain([lazyHandlerPromise, 'optionalAccess',
|
|
4274
|
+
_optionalChain([lazyHandlerPromise, 'optionalAccess', _37 => _37.catch, 'call', _38 => _38(() => {
|
|
3949
4275
|
})]);
|
|
3950
4276
|
return {
|
|
3951
4277
|
lazyRoutePromise,
|
|
@@ -3955,7 +4281,7 @@ function loadLazyRoute(route, type, manifest, mapRouteProperties, lazyRoutePrope
|
|
|
3955
4281
|
function isNonNullable(value) {
|
|
3956
4282
|
return value !== void 0;
|
|
3957
4283
|
}
|
|
3958
|
-
function loadLazyMiddlewareForMatches(matches, manifest,
|
|
4284
|
+
function loadLazyMiddlewareForMatches(matches, manifest, mapRouteProperties2) {
|
|
3959
4285
|
let promises = matches.map(({ route }) => {
|
|
3960
4286
|
if (typeof route.lazy !== "object" || !route.lazy.middleware) {
|
|
3961
4287
|
return void 0;
|
|
@@ -3964,7 +4290,7 @@ function loadLazyMiddlewareForMatches(matches, manifest, mapRouteProperties) {
|
|
|
3964
4290
|
key: "middleware",
|
|
3965
4291
|
route,
|
|
3966
4292
|
manifest,
|
|
3967
|
-
mapRouteProperties
|
|
4293
|
+
mapRouteProperties: mapRouteProperties2
|
|
3968
4294
|
});
|
|
3969
4295
|
}).filter(isNonNullable);
|
|
3970
4296
|
return promises.length > 0 ? Promise.all(promises) : void 0;
|
|
@@ -4037,12 +4363,17 @@ function runClientMiddlewarePipeline(args, handler) {
|
|
|
4037
4363
|
}
|
|
4038
4364
|
}
|
|
4039
4365
|
async function runMiddlewarePipeline(args, handler, processResult, isResult, errorHandler) {
|
|
4040
|
-
let { matches, request, params, context } = args;
|
|
4366
|
+
let { matches, request, params, context, unstable_pattern } = args;
|
|
4041
4367
|
let tuples = matches.flatMap(
|
|
4042
4368
|
(m) => m.route.middleware ? m.route.middleware.map((fn) => [m.route.id, fn]) : []
|
|
4043
4369
|
);
|
|
4044
4370
|
let result = await callRouteMiddleware(
|
|
4045
|
-
{
|
|
4371
|
+
{
|
|
4372
|
+
request,
|
|
4373
|
+
params,
|
|
4374
|
+
context,
|
|
4375
|
+
unstable_pattern
|
|
4376
|
+
},
|
|
4046
4377
|
tuples,
|
|
4047
4378
|
handler,
|
|
4048
4379
|
processResult,
|
|
@@ -4100,18 +4431,18 @@ async function callRouteMiddleware(args, middlewares, handler, processResult, is
|
|
|
4100
4431
|
return response;
|
|
4101
4432
|
}
|
|
4102
4433
|
}
|
|
4103
|
-
function getDataStrategyMatchLazyPromises(
|
|
4434
|
+
function getDataStrategyMatchLazyPromises(mapRouteProperties2, manifest, request, match, lazyRoutePropertiesToSkip) {
|
|
4104
4435
|
let lazyMiddlewarePromise = loadLazyRouteProperty({
|
|
4105
4436
|
key: "middleware",
|
|
4106
4437
|
route: match.route,
|
|
4107
4438
|
manifest,
|
|
4108
|
-
mapRouteProperties
|
|
4439
|
+
mapRouteProperties: mapRouteProperties2
|
|
4109
4440
|
});
|
|
4110
4441
|
let lazyRoutePromises = loadLazyRoute(
|
|
4111
4442
|
match.route,
|
|
4112
4443
|
isMutationMethod(request.method) ? "action" : "loader",
|
|
4113
4444
|
manifest,
|
|
4114
|
-
|
|
4445
|
+
mapRouteProperties2,
|
|
4115
4446
|
lazyRoutePropertiesToSkip
|
|
4116
4447
|
);
|
|
4117
4448
|
return {
|
|
@@ -4120,10 +4451,10 @@ function getDataStrategyMatchLazyPromises(mapRouteProperties, manifest, request,
|
|
|
4120
4451
|
handler: lazyRoutePromises.lazyHandlerPromise
|
|
4121
4452
|
};
|
|
4122
4453
|
}
|
|
4123
|
-
function getDataStrategyMatch(
|
|
4454
|
+
function getDataStrategyMatch(mapRouteProperties2, manifest, request, unstable_pattern, match, lazyRoutePropertiesToSkip, scopedContext, shouldLoad, unstable_shouldRevalidateArgs = null) {
|
|
4124
4455
|
let isUsingNewApi = false;
|
|
4125
4456
|
let _lazyPromises = getDataStrategyMatchLazyPromises(
|
|
4126
|
-
|
|
4457
|
+
mapRouteProperties2,
|
|
4127
4458
|
manifest,
|
|
4128
4459
|
request,
|
|
4129
4460
|
match,
|
|
@@ -4151,12 +4482,13 @@ function getDataStrategyMatch(mapRouteProperties, manifest, request, match, lazy
|
|
|
4151
4482
|
let { lazy, loader, middleware } = match.route;
|
|
4152
4483
|
let callHandler = isUsingNewApi || shouldLoad || handlerOverride && !isMutationMethod(request.method) && (lazy || loader);
|
|
4153
4484
|
let isMiddlewareOnlyRoute = middleware && middleware.length > 0 && !loader && !lazy;
|
|
4154
|
-
if (callHandler && !isMiddlewareOnlyRoute) {
|
|
4485
|
+
if (callHandler && (isMutationMethod(request.method) || !isMiddlewareOnlyRoute)) {
|
|
4155
4486
|
return callLoaderOrAction({
|
|
4156
4487
|
request,
|
|
4488
|
+
unstable_pattern,
|
|
4157
4489
|
match,
|
|
4158
|
-
lazyHandlerPromise: _optionalChain([_lazyPromises, 'optionalAccess',
|
|
4159
|
-
lazyRoutePromise: _optionalChain([_lazyPromises, 'optionalAccess',
|
|
4490
|
+
lazyHandlerPromise: _optionalChain([_lazyPromises, 'optionalAccess', _39 => _39.handler]),
|
|
4491
|
+
lazyRoutePromise: _optionalChain([_lazyPromises, 'optionalAccess', _40 => _40.route]),
|
|
4160
4492
|
handlerOverride,
|
|
4161
4493
|
scopedContext
|
|
4162
4494
|
});
|
|
@@ -4165,7 +4497,7 @@ function getDataStrategyMatch(mapRouteProperties, manifest, request, match, lazy
|
|
|
4165
4497
|
}
|
|
4166
4498
|
};
|
|
4167
4499
|
}
|
|
4168
|
-
function getTargetedDataStrategyMatches(
|
|
4500
|
+
function getTargetedDataStrategyMatches(mapRouteProperties2, manifest, request, matches, targetMatch, lazyRoutePropertiesToSkip, scopedContext, shouldRevalidateArgs = null) {
|
|
4169
4501
|
return matches.map((match) => {
|
|
4170
4502
|
if (match.route.id !== targetMatch.route.id) {
|
|
4171
4503
|
return {
|
|
@@ -4174,7 +4506,7 @@ function getTargetedDataStrategyMatches(mapRouteProperties, manifest, request, m
|
|
|
4174
4506
|
unstable_shouldRevalidateArgs: shouldRevalidateArgs,
|
|
4175
4507
|
unstable_shouldCallHandler: () => false,
|
|
4176
4508
|
_lazyPromises: getDataStrategyMatchLazyPromises(
|
|
4177
|
-
|
|
4509
|
+
mapRouteProperties2,
|
|
4178
4510
|
manifest,
|
|
4179
4511
|
request,
|
|
4180
4512
|
match,
|
|
@@ -4184,9 +4516,10 @@ function getTargetedDataStrategyMatches(mapRouteProperties, manifest, request, m
|
|
|
4184
4516
|
};
|
|
4185
4517
|
}
|
|
4186
4518
|
return getDataStrategyMatch(
|
|
4187
|
-
|
|
4519
|
+
mapRouteProperties2,
|
|
4188
4520
|
manifest,
|
|
4189
4521
|
request,
|
|
4522
|
+
getRoutePattern(matches.map((m) => m.route.path)),
|
|
4190
4523
|
match,
|
|
4191
4524
|
lazyRoutePropertiesToSkip,
|
|
4192
4525
|
scopedContext,
|
|
@@ -4196,11 +4529,12 @@ function getTargetedDataStrategyMatches(mapRouteProperties, manifest, request, m
|
|
|
4196
4529
|
});
|
|
4197
4530
|
}
|
|
4198
4531
|
async function callDataStrategyImpl(dataStrategyImpl, request, matches, fetcherKey, scopedContext, isStaticHandler) {
|
|
4199
|
-
if (matches.some((m) => _optionalChain([m, 'access',
|
|
4200
|
-
await Promise.all(matches.map((m) => _optionalChain([m, 'access',
|
|
4532
|
+
if (matches.some((m) => _optionalChain([m, 'access', _41 => _41._lazyPromises, 'optionalAccess', _42 => _42.middleware]))) {
|
|
4533
|
+
await Promise.all(matches.map((m) => _optionalChain([m, 'access', _43 => _43._lazyPromises, 'optionalAccess', _44 => _44.middleware])));
|
|
4201
4534
|
}
|
|
4202
4535
|
let dataStrategyArgs = {
|
|
4203
4536
|
request,
|
|
4537
|
+
unstable_pattern: getRoutePattern(matches.map((m) => m.route.path)),
|
|
4204
4538
|
params: matches[0].params,
|
|
4205
4539
|
context: scopedContext,
|
|
4206
4540
|
matches
|
|
@@ -4231,8 +4565,8 @@ async function callDataStrategyImpl(dataStrategyImpl, request, matches, fetcherK
|
|
|
4231
4565
|
try {
|
|
4232
4566
|
await Promise.all(
|
|
4233
4567
|
matches.flatMap((m) => [
|
|
4234
|
-
_optionalChain([m, 'access',
|
|
4235
|
-
_optionalChain([m, 'access',
|
|
4568
|
+
_optionalChain([m, 'access', _45 => _45._lazyPromises, 'optionalAccess', _46 => _46.handler]),
|
|
4569
|
+
_optionalChain([m, 'access', _47 => _47._lazyPromises, 'optionalAccess', _48 => _48.route])
|
|
4236
4570
|
])
|
|
4237
4571
|
);
|
|
4238
4572
|
} catch (e) {
|
|
@@ -4241,6 +4575,7 @@ async function callDataStrategyImpl(dataStrategyImpl, request, matches, fetcherK
|
|
|
4241
4575
|
}
|
|
4242
4576
|
async function callLoaderOrAction({
|
|
4243
4577
|
request,
|
|
4578
|
+
unstable_pattern,
|
|
4244
4579
|
match,
|
|
4245
4580
|
lazyHandlerPromise,
|
|
4246
4581
|
lazyRoutePromise,
|
|
@@ -4267,6 +4602,7 @@ async function callLoaderOrAction({
|
|
|
4267
4602
|
return handler(
|
|
4268
4603
|
{
|
|
4269
4604
|
request,
|
|
4605
|
+
unstable_pattern,
|
|
4270
4606
|
params: match.params,
|
|
4271
4607
|
context: scopedContext
|
|
4272
4608
|
},
|
|
@@ -4375,19 +4711,19 @@ async function convertDataStrategyResultToDataResult(dataStrategyResult) {
|
|
|
4375
4711
|
return {
|
|
4376
4712
|
type: "error" /* error */,
|
|
4377
4713
|
error: result.data,
|
|
4378
|
-
statusCode: _optionalChain([result, 'access',
|
|
4379
|
-
headers: _optionalChain([result, 'access',
|
|
4714
|
+
statusCode: _optionalChain([result, 'access', _49 => _49.init, 'optionalAccess', _50 => _50.status]),
|
|
4715
|
+
headers: _optionalChain([result, 'access', _51 => _51.init, 'optionalAccess', _52 => _52.headers]) ? new Headers(result.init.headers) : void 0
|
|
4380
4716
|
};
|
|
4381
4717
|
}
|
|
4382
4718
|
return {
|
|
4383
4719
|
type: "error" /* error */,
|
|
4384
4720
|
error: new ErrorResponseImpl(
|
|
4385
|
-
_optionalChain([result, 'access',
|
|
4721
|
+
_optionalChain([result, 'access', _53 => _53.init, 'optionalAccess', _54 => _54.status]) || 500,
|
|
4386
4722
|
void 0,
|
|
4387
4723
|
result.data
|
|
4388
4724
|
),
|
|
4389
4725
|
statusCode: isRouteErrorResponse(result) ? result.status : void 0,
|
|
4390
|
-
headers: _optionalChain([result, 'access',
|
|
4726
|
+
headers: _optionalChain([result, 'access', _55 => _55.init, 'optionalAccess', _56 => _56.headers]) ? new Headers(result.init.headers) : void 0
|
|
4391
4727
|
};
|
|
4392
4728
|
}
|
|
4393
4729
|
return {
|
|
@@ -4400,8 +4736,8 @@ async function convertDataStrategyResultToDataResult(dataStrategyResult) {
|
|
|
4400
4736
|
return {
|
|
4401
4737
|
type: "data" /* data */,
|
|
4402
4738
|
data: result.data,
|
|
4403
|
-
statusCode: _optionalChain([result, 'access',
|
|
4404
|
-
headers: _optionalChain([result, 'access',
|
|
4739
|
+
statusCode: _optionalChain([result, 'access', _57 => _57.init, 'optionalAccess', _58 => _58.status]),
|
|
4740
|
+
headers: _optionalChain([result, 'access', _59 => _59.init, 'optionalAccess', _60 => _60.headers]) ? new Headers(result.init.headers) : void 0
|
|
4405
4741
|
};
|
|
4406
4742
|
}
|
|
4407
4743
|
return { type: "data" /* data */, data: result };
|
|
@@ -4550,7 +4886,7 @@ function processLoaderData(state, matches, results, pendingActionResult, revalid
|
|
|
4550
4886
|
let result = fetcherResults[key];
|
|
4551
4887
|
invariant(result, "Did not find corresponding fetcher result");
|
|
4552
4888
|
if (isErrorResult(result)) {
|
|
4553
|
-
let boundaryMatch = findNearestBoundary(state.matches, _optionalChain([match, 'optionalAccess',
|
|
4889
|
+
let boundaryMatch = findNearestBoundary(state.matches, _optionalChain([match, 'optionalAccess', _61 => _61.route, 'access', _62 => _62.id]));
|
|
4554
4890
|
if (!(errors && errors[boundaryMatch.route.id])) {
|
|
4555
4891
|
errors = {
|
|
4556
4892
|
...errors,
|
|
@@ -4684,8 +5020,8 @@ function dataWithResponseInitToResponse(data2) {
|
|
|
4684
5020
|
}
|
|
4685
5021
|
function dataWithResponseInitToErrorResponse(data2) {
|
|
4686
5022
|
return new ErrorResponseImpl(
|
|
4687
|
-
_nullishCoalesce(_optionalChain([data2, 'access',
|
|
4688
|
-
_nullishCoalesce(_optionalChain([data2, 'access',
|
|
5023
|
+
_nullishCoalesce(_optionalChain([data2, 'access', _63 => _63.init, 'optionalAccess', _64 => _64.status]), () => ( 500)),
|
|
5024
|
+
_nullishCoalesce(_optionalChain([data2, 'access', _65 => _65.init, 'optionalAccess', _66 => _66.statusText]), () => ( "Internal Server Error")),
|
|
4689
5025
|
data2.data
|
|
4690
5026
|
);
|
|
4691
5027
|
}
|
|
@@ -4926,7 +5262,7 @@ function createDeferred() {
|
|
|
4926
5262
|
}
|
|
4927
5263
|
|
|
4928
5264
|
// lib/dom/ssr/single-fetch.tsx
|
|
4929
|
-
var _react = require('react'); var React = _interopRequireWildcard(_react); var React2 = _interopRequireWildcard(_react); var React3 = _interopRequireWildcard(_react); var React8 = _interopRequireWildcard(_react); var React7 = _interopRequireWildcard(_react); var React6 = _interopRequireWildcard(_react); var React5 = _interopRequireWildcard(_react); var React4 = _interopRequireWildcard(_react);
|
|
5265
|
+
var _react = require('react'); var React = _interopRequireWildcard(_react); var React2 = _interopRequireWildcard(_react); var React3 = _interopRequireWildcard(_react); var React8 = _interopRequireWildcard(_react); var React7 = _interopRequireWildcard(_react); var React6 = _interopRequireWildcard(_react); var React5 = _interopRequireWildcard(_react); var React4 = _interopRequireWildcard(_react); var React9 = _interopRequireWildcard(_react);
|
|
4930
5266
|
|
|
4931
5267
|
// vendor/turbo-stream-v2/utils.ts
|
|
4932
5268
|
var HOLE = -1;
|
|
@@ -5082,7 +5418,7 @@ function stringify(input, index) {
|
|
|
5082
5418
|
str[index2] += "]";
|
|
5083
5419
|
} else if (Object.getPrototypeOf(input2) === null) {
|
|
5084
5420
|
str[index2] = `["${TYPE_NULL_OBJECT}",{${partsForObj(input2)}}]`;
|
|
5085
|
-
} else if (
|
|
5421
|
+
} else if (isPlainObject2(input2)) {
|
|
5086
5422
|
str[index2] = `{${partsForObj(input2)}}`;
|
|
5087
5423
|
} else {
|
|
5088
5424
|
error = new Error("Cannot encode object with prototype");
|
|
@@ -5136,10 +5472,10 @@ function stringify(input, index) {
|
|
|
5136
5472
|
}
|
|
5137
5473
|
}
|
|
5138
5474
|
}
|
|
5139
|
-
var
|
|
5140
|
-
function
|
|
5475
|
+
var objectProtoNames2 = Object.getOwnPropertyNames(Object.prototype).sort().join("\0");
|
|
5476
|
+
function isPlainObject2(thing) {
|
|
5141
5477
|
const proto = Object.getPrototypeOf(thing);
|
|
5142
|
-
return proto === Object.prototype || proto === null || Object.getOwnPropertyNames(proto).sort().join("\0") ===
|
|
5478
|
+
return proto === Object.prototype || proto === null || Object.getOwnPropertyNames(proto).sort().join("\0") === objectProtoNames2;
|
|
5143
5479
|
}
|
|
5144
5480
|
|
|
5145
5481
|
// vendor/turbo-stream-v2/unflatten.ts
|
|
@@ -5717,7 +6053,7 @@ function getTurboStreamSingleFetchDataStrategy(getRouter, manifest, routeModules
|
|
|
5717
6053
|
return {
|
|
5718
6054
|
hasLoader: manifestRoute.hasLoader,
|
|
5719
6055
|
hasClientLoader: manifestRoute.hasClientLoader,
|
|
5720
|
-
hasShouldRevalidate: Boolean(_optionalChain([routeModule, 'optionalAccess',
|
|
6056
|
+
hasShouldRevalidate: Boolean(_optionalChain([routeModule, 'optionalAccess', _67 => _67.shouldRevalidate]))
|
|
5721
6057
|
};
|
|
5722
6058
|
},
|
|
5723
6059
|
fetchAndDecodeViaTurboStream,
|
|
@@ -5884,7 +6220,7 @@ async function bubbleMiddlewareErrors(singleFetchPromise, matches, routesParams,
|
|
|
5884
6220
|
let routeResult = fetchedData.routes[match.route.id];
|
|
5885
6221
|
if ("error" in routeResult) {
|
|
5886
6222
|
middlewareError = routeResult.error;
|
|
5887
|
-
if (_optionalChain([results, 'access',
|
|
6223
|
+
if (_optionalChain([results, 'access', _68 => _68[match.route.id], 'optionalAccess', _69 => _69.result]) == null) {
|
|
5888
6224
|
results[match.route.id] = {
|
|
5889
6225
|
type: "error",
|
|
5890
6226
|
result: middlewareError
|
|
@@ -5997,7 +6333,7 @@ async function fetchAndDecodeViaTurboStream(args, basename, targetRoutes) {
|
|
|
5997
6333
|
}
|
|
5998
6334
|
} else {
|
|
5999
6335
|
let typed = decoded.value;
|
|
6000
|
-
let routeId = _optionalChain([targetRoutes, 'optionalAccess',
|
|
6336
|
+
let routeId = _optionalChain([targetRoutes, 'optionalAccess', _70 => _70[0]]);
|
|
6001
6337
|
invariant2(routeId, "No routeId found for single fetch call decoding");
|
|
6002
6338
|
if ("redirect" in typed) {
|
|
6003
6339
|
data2 = { redirect: typed };
|
|
@@ -6309,7 +6645,7 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
|
|
|
6309
6645
|
if (locationArg) {
|
|
6310
6646
|
let parsedLocationArg = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
|
|
6311
6647
|
invariant(
|
|
6312
|
-
parentPathnameBase === "/" || _optionalChain([parsedLocationArg, 'access',
|
|
6648
|
+
parentPathnameBase === "/" || _optionalChain([parsedLocationArg, 'access', _71 => _71.pathname, 'optionalAccess', _72 => _72.startsWith, 'call', _73 => _73(parentPathnameBase)]),
|
|
6313
6649
|
`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.`
|
|
6314
6650
|
);
|
|
6315
6651
|
location = parsedLocationArg;
|
|
@@ -6471,10 +6807,10 @@ function _renderMatches(matches, parentMatches = [], dataRouterState = null, uns
|
|
|
6471
6807
|
}
|
|
6472
6808
|
}
|
|
6473
6809
|
let renderedMatches = matches;
|
|
6474
|
-
let errors = _optionalChain([dataRouterState, 'optionalAccess',
|
|
6810
|
+
let errors = _optionalChain([dataRouterState, 'optionalAccess', _74 => _74.errors]);
|
|
6475
6811
|
if (errors != null) {
|
|
6476
6812
|
let errorIndex = renderedMatches.findIndex(
|
|
6477
|
-
(m) => m.route.id && _optionalChain([errors, 'optionalAccess',
|
|
6813
|
+
(m) => m.route.id && _optionalChain([errors, 'optionalAccess', _75 => _75[m.route.id]]) !== void 0
|
|
6478
6814
|
);
|
|
6479
6815
|
invariant(
|
|
6480
6816
|
errorIndex >= 0,
|
|
@@ -6652,15 +6988,15 @@ function useRouteError() {
|
|
|
6652
6988
|
if (error !== void 0) {
|
|
6653
6989
|
return error;
|
|
6654
6990
|
}
|
|
6655
|
-
return _optionalChain([state, 'access',
|
|
6991
|
+
return _optionalChain([state, 'access', _76 => _76.errors, 'optionalAccess', _77 => _77[routeId]]);
|
|
6656
6992
|
}
|
|
6657
6993
|
function useAsyncValue() {
|
|
6658
6994
|
let value = React3.useContext(AwaitContext);
|
|
6659
|
-
return _optionalChain([value, 'optionalAccess',
|
|
6995
|
+
return _optionalChain([value, 'optionalAccess', _78 => _78._data]);
|
|
6660
6996
|
}
|
|
6661
6997
|
function useAsyncError() {
|
|
6662
6998
|
let value = React3.useContext(AwaitContext);
|
|
6663
|
-
return _optionalChain([value, 'optionalAccess',
|
|
6999
|
+
return _optionalChain([value, 'optionalAccess', _79 => _79._error]);
|
|
6664
7000
|
}
|
|
6665
7001
|
var blockerId = 0;
|
|
6666
7002
|
function useBlocker(shouldBlock) {
|
|
@@ -6735,12 +7071,13 @@ function useRoute(...args) {
|
|
|
6735
7071
|
"useRoute" /* UseRoute */
|
|
6736
7072
|
);
|
|
6737
7073
|
const id = _nullishCoalesce(args[0], () => ( currentRouteId));
|
|
6738
|
-
const state = useDataRouterState("
|
|
7074
|
+
const state = useDataRouterState("useRoute" /* UseRoute */);
|
|
6739
7075
|
const route = state.matches.find(({ route: route2 }) => route2.id === id);
|
|
6740
7076
|
if (route === void 0) return void 0;
|
|
6741
7077
|
return {
|
|
7078
|
+
handle: route.route.handle,
|
|
6742
7079
|
loaderData: state.loaderData[id],
|
|
6743
|
-
actionData: _optionalChain([state, 'access',
|
|
7080
|
+
actionData: _optionalChain([state, 'access', _80 => _80.actionData, 'optionalAccess', _81 => _81[id]])
|
|
6744
7081
|
};
|
|
6745
7082
|
}
|
|
6746
7083
|
|
|
@@ -6785,7 +7122,7 @@ function getKeyedLinksForMatches(matches, routeModules, manifest) {
|
|
|
6785
7122
|
let route = manifest.routes[match.route.id];
|
|
6786
7123
|
return [
|
|
6787
7124
|
route && route.css ? route.css.map((href) => ({ rel: "stylesheet", href })) : [],
|
|
6788
|
-
_optionalChain([module, 'optionalAccess',
|
|
7125
|
+
_optionalChain([module, 'optionalAccess', _82 => _82.links, 'optionalCall', _83 => _83()]) || []
|
|
6789
7126
|
];
|
|
6790
7127
|
}).flat(2);
|
|
6791
7128
|
let preloads = getModuleLinkHrefs(matches, manifest);
|
|
@@ -6886,7 +7223,7 @@ function getNewMatchesForLinks(page, nextMatches, currentMatches, manifest, loca
|
|
|
6886
7223
|
// param change, /users/123 -> /users/456
|
|
6887
7224
|
currentMatches[index].pathname !== match.pathname || // splat param changed, which is not present in match.path
|
|
6888
7225
|
// e.g. /files/images/avatar.jpg -> files/finances.xls
|
|
6889
|
-
_optionalChain([currentMatches, 'access',
|
|
7226
|
+
_optionalChain([currentMatches, 'access', _84 => _84[index], 'access', _85 => _85.route, 'access', _86 => _86.path, 'optionalAccess', _87 => _87.endsWith, 'call', _88 => _88("*")]) && currentMatches[index].params["*"] !== match.params["*"]
|
|
6890
7227
|
);
|
|
6891
7228
|
};
|
|
6892
7229
|
if (mode === "assets") {
|
|
@@ -6909,7 +7246,7 @@ function getNewMatchesForLinks(page, nextMatches, currentMatches, manifest, loca
|
|
|
6909
7246
|
location.pathname + location.search + location.hash,
|
|
6910
7247
|
window.origin
|
|
6911
7248
|
),
|
|
6912
|
-
currentParams: _optionalChain([currentMatches, 'access',
|
|
7249
|
+
currentParams: _optionalChain([currentMatches, 'access', _89 => _89[0], 'optionalAccess', _90 => _90.params]) || {},
|
|
6913
7250
|
nextUrl: new URL(page, window.origin),
|
|
6914
7251
|
nextParams: match.params,
|
|
6915
7252
|
defaultShouldRevalidate: true
|
|
@@ -7033,14 +7370,14 @@ function groupRoutesByParentId(manifest) {
|
|
|
7033
7370
|
return routes;
|
|
7034
7371
|
}
|
|
7035
7372
|
function getRouteComponents(route, routeModule, isSpaMode) {
|
|
7036
|
-
let
|
|
7373
|
+
let Component4 = getRouteModuleComponent(routeModule);
|
|
7037
7374
|
let HydrateFallback = routeModule.HydrateFallback && (!isSpaMode || route.id === "root") ? routeModule.HydrateFallback : route.id === "root" ? RemixRootDefaultHydrateFallback : void 0;
|
|
7038
7375
|
let ErrorBoundary = routeModule.ErrorBoundary ? routeModule.ErrorBoundary : route.id === "root" ? () => /* @__PURE__ */ React5.createElement(RemixRootDefaultErrorBoundary, { error: useRouteError() }) : void 0;
|
|
7039
7376
|
if (route.id === "root" && routeModule.Layout) {
|
|
7040
7377
|
return {
|
|
7041
|
-
...
|
|
7042
|
-
element: /* @__PURE__ */ React5.createElement(routeModule.Layout, null, /* @__PURE__ */ React5.createElement(
|
|
7043
|
-
} : { Component:
|
|
7378
|
+
...Component4 ? {
|
|
7379
|
+
element: /* @__PURE__ */ React5.createElement(routeModule.Layout, null, /* @__PURE__ */ React5.createElement(Component4, null))
|
|
7380
|
+
} : { Component: Component4 },
|
|
7044
7381
|
...ErrorBoundary ? {
|
|
7045
7382
|
errorElement: /* @__PURE__ */ React5.createElement(routeModule.Layout, null, /* @__PURE__ */ React5.createElement(ErrorBoundary, null))
|
|
7046
7383
|
} : { ErrorBoundary },
|
|
@@ -7049,7 +7386,7 @@ function getRouteComponents(route, routeModule, isSpaMode) {
|
|
|
7049
7386
|
} : { HydrateFallback }
|
|
7050
7387
|
};
|
|
7051
7388
|
}
|
|
7052
|
-
return { Component:
|
|
7389
|
+
return { Component: Component4, ErrorBoundary, HydrateFallback };
|
|
7053
7390
|
}
|
|
7054
7391
|
function createServerRoutes(manifest, routeModules, future, isSpaMode, parentId = "", routesByParentId = groupRoutesByParentId(manifest), spaModeLazyPromise = Promise.resolve({ Component: () => null })) {
|
|
7055
7392
|
return (routesByParentId[parentId] || []).map((route) => {
|
|
@@ -7181,11 +7518,11 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
7181
7518
|
)
|
|
7182
7519
|
});
|
|
7183
7520
|
let hasInitialData = initialState && initialState.loaderData && route.id in initialState.loaderData;
|
|
7184
|
-
let initialData = hasInitialData ? _optionalChain([initialState, 'optionalAccess',
|
|
7521
|
+
let initialData = hasInitialData ? _optionalChain([initialState, 'optionalAccess', _91 => _91.loaderData, 'optionalAccess', _92 => _92[route.id]]) : void 0;
|
|
7185
7522
|
let hasInitialError = initialState && initialState.errors && route.id in initialState.errors;
|
|
7186
|
-
let initialError = hasInitialError ? _optionalChain([initialState, 'optionalAccess',
|
|
7187
|
-
let isHydrationRequest = needsRevalidation == null && (_optionalChain([routeModule, 'access',
|
|
7188
|
-
dataRoute.loader = async ({ request, params, context }, singleFetch) => {
|
|
7523
|
+
let initialError = hasInitialError ? _optionalChain([initialState, 'optionalAccess', _93 => _93.errors, 'optionalAccess', _94 => _94[route.id]]) : void 0;
|
|
7524
|
+
let isHydrationRequest = needsRevalidation == null && (_optionalChain([routeModule, 'access', _95 => _95.clientLoader, 'optionalAccess', _96 => _96.hydrate]) === true || !route.hasLoader);
|
|
7525
|
+
dataRoute.loader = async ({ request, params, context, unstable_pattern }, singleFetch) => {
|
|
7189
7526
|
try {
|
|
7190
7527
|
let result = await prefetchStylesAndCallHandler(async () => {
|
|
7191
7528
|
invariant2(
|
|
@@ -7199,6 +7536,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
7199
7536
|
request,
|
|
7200
7537
|
params,
|
|
7201
7538
|
context,
|
|
7539
|
+
unstable_pattern,
|
|
7202
7540
|
async serverLoader() {
|
|
7203
7541
|
preventInvalidServerHandlerCall("loader", route);
|
|
7204
7542
|
if (isHydrationRequest) {
|
|
@@ -7224,7 +7562,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
7224
7562
|
route.hasLoader,
|
|
7225
7563
|
isSpaMode
|
|
7226
7564
|
);
|
|
7227
|
-
dataRoute.action = ({ request, params, context }, singleFetch) => {
|
|
7565
|
+
dataRoute.action = ({ request, params, context, unstable_pattern }, singleFetch) => {
|
|
7228
7566
|
return prefetchStylesAndCallHandler(async () => {
|
|
7229
7567
|
invariant2(
|
|
7230
7568
|
routeModule,
|
|
@@ -7240,6 +7578,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
7240
7578
|
request,
|
|
7241
7579
|
params,
|
|
7242
7580
|
context,
|
|
7581
|
+
unstable_pattern,
|
|
7243
7582
|
async serverAction() {
|
|
7244
7583
|
preventInvalidServerHandlerCall("action", route);
|
|
7245
7584
|
return fetchServerAction(singleFetch);
|
|
@@ -7478,7 +7817,7 @@ function getPatchRoutesOnNavigationFunction(manifest, routeModules, ssr, routeDi
|
|
|
7478
7817
|
function useFogOFWarDiscovery(router, manifest, routeModules, ssr, routeDiscovery, isSpaMode) {
|
|
7479
7818
|
React6.useEffect(() => {
|
|
7480
7819
|
if (!isFogOfWarEnabled(routeDiscovery, ssr) || // @ts-expect-error - TS doesn't know about this yet
|
|
7481
|
-
_optionalChain([window, 'access',
|
|
7820
|
+
_optionalChain([window, 'access', _97 => _97.navigator, 'optionalAccess', _98 => _98.connection, 'optionalAccess', _99 => _99.saveData]) === true) {
|
|
7482
7821
|
return;
|
|
7483
7822
|
}
|
|
7484
7823
|
function registerElement(el) {
|
|
@@ -7587,7 +7926,7 @@ async function fetchAndApplyManifestPatches(paths, errorReloadPath, manifest, ro
|
|
|
7587
7926
|
}
|
|
7588
7927
|
serverPatches = await res.json();
|
|
7589
7928
|
} catch (e) {
|
|
7590
|
-
if (_optionalChain([signal, 'optionalAccess',
|
|
7929
|
+
if (_optionalChain([signal, 'optionalAccess', _100 => _100.aborted])) return;
|
|
7591
7930
|
throw e;
|
|
7592
7931
|
}
|
|
7593
7932
|
let knownRoutes = new Set(Object.keys(manifest.routes));
|
|
@@ -7828,7 +8167,7 @@ function PrefetchPageLinksImpl({
|
|
|
7828
8167
|
if (!manifestRoute || !manifestRoute.hasLoader) {
|
|
7829
8168
|
return;
|
|
7830
8169
|
}
|
|
7831
|
-
if (!newMatchesForData.some((m2) => m2.route.id === m.route.id) && m.route.id in loaderData && _optionalChain([routeModules, 'access',
|
|
8170
|
+
if (!newMatchesForData.some((m2) => m2.route.id === m.route.id) && m.route.id in loaderData && _optionalChain([routeModules, 'access', _101 => _101[m.route.id], 'optionalAccess', _102 => _102.shouldRevalidate])) {
|
|
7832
8171
|
foundOptOutRoute = true;
|
|
7833
8172
|
} else if (manifestRoute.hasClientLoader) {
|
|
7834
8173
|
foundOptOutRoute = true;
|
|
@@ -7902,7 +8241,7 @@ function Meta() {
|
|
|
7902
8241
|
error
|
|
7903
8242
|
};
|
|
7904
8243
|
matches[i] = match;
|
|
7905
|
-
if (_optionalChain([routeModule, 'optionalAccess',
|
|
8244
|
+
if (_optionalChain([routeModule, 'optionalAccess', _103 => _103.meta])) {
|
|
7906
8245
|
routeMeta = typeof routeModule.meta === "function" ? routeModule.meta({
|
|
7907
8246
|
data: data2,
|
|
7908
8247
|
loaderData: data2,
|
|
@@ -8001,7 +8340,7 @@ function Scripts(scriptProps) {
|
|
|
8001
8340
|
}
|
|
8002
8341
|
let streamScript = "window.__reactRouterContext.stream = new ReadableStream({start(controller){window.__reactRouterContext.streamController = controller;}}).pipeThrough(new TextEncoderStream());";
|
|
8003
8342
|
let contextScript = staticContext ? `window.__reactRouterContext = ${serverHandoffString};${streamScript}` : " ";
|
|
8004
|
-
let routeModulesScript = !isStatic ? " " : `${_optionalChain([manifest, 'access',
|
|
8343
|
+
let routeModulesScript = !isStatic ? " " : `${_optionalChain([manifest, 'access', _104 => _104.hmr, 'optionalAccess', _105 => _105.runtime]) ? `import ${JSON.stringify(manifest.hmr.runtime)};` : ""}${!enableFogOfWar ? `import ${JSON.stringify(manifest.url)}` : ""};
|
|
8005
8344
|
${matches.map((match, routeIndex) => {
|
|
8006
8345
|
let routeVarName = `route${routeIndex}`;
|
|
8007
8346
|
let manifestEntry = manifest.routes[match.route.id];
|
|
@@ -8231,7 +8570,7 @@ function BoundaryShell({
|
|
|
8231
8570
|
children
|
|
8232
8571
|
}) {
|
|
8233
8572
|
let { routeModules } = useFrameworkContext();
|
|
8234
|
-
if (_optionalChain([routeModules, 'access',
|
|
8573
|
+
if (_optionalChain([routeModules, 'access', _106 => _106.root, 'optionalAccess', _107 => _107.Layout]) && !isOutsideRemixApp) {
|
|
8235
8574
|
return children;
|
|
8236
8575
|
}
|
|
8237
8576
|
return /* @__PURE__ */ React8.createElement("html", { lang: "en" }, /* @__PURE__ */ React8.createElement("head", null, /* @__PURE__ */ React8.createElement("meta", { charSet: "utf-8" }), /* @__PURE__ */ React8.createElement(
|
|
@@ -8243,6 +8582,771 @@ function BoundaryShell({
|
|
|
8243
8582
|
), /* @__PURE__ */ React8.createElement("title", null, title)), /* @__PURE__ */ React8.createElement("body", null, /* @__PURE__ */ React8.createElement("main", { style: { fontFamily: "system-ui, sans-serif", padding: "2rem" } }, children, renderScripts ? /* @__PURE__ */ React8.createElement(Scripts, null) : null)));
|
|
8244
8583
|
}
|
|
8245
8584
|
|
|
8585
|
+
// lib/components.tsx
|
|
8586
|
+
|
|
8587
|
+
function mapRouteProperties(route) {
|
|
8588
|
+
let updates = {
|
|
8589
|
+
// Note: this check also occurs in createRoutesFromChildren so update
|
|
8590
|
+
// there if you change this -- please and thank you!
|
|
8591
|
+
hasErrorBoundary: route.hasErrorBoundary || route.ErrorBoundary != null || route.errorElement != null
|
|
8592
|
+
};
|
|
8593
|
+
if (route.Component) {
|
|
8594
|
+
if (ENABLE_DEV_WARNINGS) {
|
|
8595
|
+
if (route.element) {
|
|
8596
|
+
warning(
|
|
8597
|
+
false,
|
|
8598
|
+
"You should not include both `Component` and `element` on your route - `Component` will be used."
|
|
8599
|
+
);
|
|
8600
|
+
}
|
|
8601
|
+
}
|
|
8602
|
+
Object.assign(updates, {
|
|
8603
|
+
element: React9.createElement(route.Component),
|
|
8604
|
+
Component: void 0
|
|
8605
|
+
});
|
|
8606
|
+
}
|
|
8607
|
+
if (route.HydrateFallback) {
|
|
8608
|
+
if (ENABLE_DEV_WARNINGS) {
|
|
8609
|
+
if (route.hydrateFallbackElement) {
|
|
8610
|
+
warning(
|
|
8611
|
+
false,
|
|
8612
|
+
"You should not include both `HydrateFallback` and `hydrateFallbackElement` on your route - `HydrateFallback` will be used."
|
|
8613
|
+
);
|
|
8614
|
+
}
|
|
8615
|
+
}
|
|
8616
|
+
Object.assign(updates, {
|
|
8617
|
+
hydrateFallbackElement: React9.createElement(route.HydrateFallback),
|
|
8618
|
+
HydrateFallback: void 0
|
|
8619
|
+
});
|
|
8620
|
+
}
|
|
8621
|
+
if (route.ErrorBoundary) {
|
|
8622
|
+
if (ENABLE_DEV_WARNINGS) {
|
|
8623
|
+
if (route.errorElement) {
|
|
8624
|
+
warning(
|
|
8625
|
+
false,
|
|
8626
|
+
"You should not include both `ErrorBoundary` and `errorElement` on your route - `ErrorBoundary` will be used."
|
|
8627
|
+
);
|
|
8628
|
+
}
|
|
8629
|
+
}
|
|
8630
|
+
Object.assign(updates, {
|
|
8631
|
+
errorElement: React9.createElement(route.ErrorBoundary),
|
|
8632
|
+
ErrorBoundary: void 0
|
|
8633
|
+
});
|
|
8634
|
+
}
|
|
8635
|
+
return updates;
|
|
8636
|
+
}
|
|
8637
|
+
var hydrationRouteProperties = [
|
|
8638
|
+
"HydrateFallback",
|
|
8639
|
+
"hydrateFallbackElement"
|
|
8640
|
+
];
|
|
8641
|
+
function createMemoryRouter(routes, opts) {
|
|
8642
|
+
return createRouter({
|
|
8643
|
+
basename: _optionalChain([opts, 'optionalAccess', _108 => _108.basename]),
|
|
8644
|
+
getContext: _optionalChain([opts, 'optionalAccess', _109 => _109.getContext]),
|
|
8645
|
+
future: _optionalChain([opts, 'optionalAccess', _110 => _110.future]),
|
|
8646
|
+
history: createMemoryHistory({
|
|
8647
|
+
initialEntries: _optionalChain([opts, 'optionalAccess', _111 => _111.initialEntries]),
|
|
8648
|
+
initialIndex: _optionalChain([opts, 'optionalAccess', _112 => _112.initialIndex])
|
|
8649
|
+
}),
|
|
8650
|
+
hydrationData: _optionalChain([opts, 'optionalAccess', _113 => _113.hydrationData]),
|
|
8651
|
+
routes,
|
|
8652
|
+
hydrationRouteProperties,
|
|
8653
|
+
mapRouteProperties,
|
|
8654
|
+
dataStrategy: _optionalChain([opts, 'optionalAccess', _114 => _114.dataStrategy]),
|
|
8655
|
+
patchRoutesOnNavigation: _optionalChain([opts, 'optionalAccess', _115 => _115.patchRoutesOnNavigation]),
|
|
8656
|
+
unstable_instrumentations: _optionalChain([opts, 'optionalAccess', _116 => _116.unstable_instrumentations])
|
|
8657
|
+
}).initialize();
|
|
8658
|
+
}
|
|
8659
|
+
var Deferred2 = class {
|
|
8660
|
+
constructor() {
|
|
8661
|
+
this.status = "pending";
|
|
8662
|
+
this.promise = new Promise((resolve, reject) => {
|
|
8663
|
+
this.resolve = (value) => {
|
|
8664
|
+
if (this.status === "pending") {
|
|
8665
|
+
this.status = "resolved";
|
|
8666
|
+
resolve(value);
|
|
8667
|
+
}
|
|
8668
|
+
};
|
|
8669
|
+
this.reject = (reason) => {
|
|
8670
|
+
if (this.status === "pending") {
|
|
8671
|
+
this.status = "rejected";
|
|
8672
|
+
reject(reason);
|
|
8673
|
+
}
|
|
8674
|
+
};
|
|
8675
|
+
});
|
|
8676
|
+
}
|
|
8677
|
+
};
|
|
8678
|
+
function shallowDiff(a, b) {
|
|
8679
|
+
if (a === b) {
|
|
8680
|
+
return false;
|
|
8681
|
+
}
|
|
8682
|
+
let aKeys = Object.keys(a);
|
|
8683
|
+
let bKeys = Object.keys(b);
|
|
8684
|
+
if (aKeys.length !== bKeys.length) {
|
|
8685
|
+
return true;
|
|
8686
|
+
}
|
|
8687
|
+
for (let key of aKeys) {
|
|
8688
|
+
if (a[key] !== b[key]) {
|
|
8689
|
+
return true;
|
|
8690
|
+
}
|
|
8691
|
+
}
|
|
8692
|
+
return false;
|
|
8693
|
+
}
|
|
8694
|
+
function UNSTABLE_TransitionEnabledRouterProvider({
|
|
8695
|
+
router,
|
|
8696
|
+
flushSync: reactDomFlushSyncImpl,
|
|
8697
|
+
unstable_onError
|
|
8698
|
+
}) {
|
|
8699
|
+
let fetcherData = React9.useRef(/* @__PURE__ */ new Map());
|
|
8700
|
+
let [revalidating, startRevalidation] = React9.useTransition();
|
|
8701
|
+
let [state, setState] = React9.useState(router.state);
|
|
8702
|
+
router.__setPendingRerender = (promise) => startRevalidation(
|
|
8703
|
+
// @ts-expect-error - need react 19 types for this to be async
|
|
8704
|
+
async () => {
|
|
8705
|
+
const rerender = await promise;
|
|
8706
|
+
startRevalidation(() => {
|
|
8707
|
+
rerender();
|
|
8708
|
+
});
|
|
8709
|
+
}
|
|
8710
|
+
);
|
|
8711
|
+
let navigator = React9.useMemo(() => {
|
|
8712
|
+
return {
|
|
8713
|
+
createHref: router.createHref,
|
|
8714
|
+
encodeLocation: router.encodeLocation,
|
|
8715
|
+
go: (n) => router.navigate(n),
|
|
8716
|
+
push: (to, state2, opts) => router.navigate(to, {
|
|
8717
|
+
state: state2,
|
|
8718
|
+
preventScrollReset: _optionalChain([opts, 'optionalAccess', _117 => _117.preventScrollReset])
|
|
8719
|
+
}),
|
|
8720
|
+
replace: (to, state2, opts) => router.navigate(to, {
|
|
8721
|
+
replace: true,
|
|
8722
|
+
state: state2,
|
|
8723
|
+
preventScrollReset: _optionalChain([opts, 'optionalAccess', _118 => _118.preventScrollReset])
|
|
8724
|
+
})
|
|
8725
|
+
};
|
|
8726
|
+
}, [router]);
|
|
8727
|
+
let basename = router.basename || "/";
|
|
8728
|
+
let dataRouterContext = React9.useMemo(
|
|
8729
|
+
() => ({
|
|
8730
|
+
router,
|
|
8731
|
+
navigator,
|
|
8732
|
+
static: false,
|
|
8733
|
+
basename,
|
|
8734
|
+
unstable_onError
|
|
8735
|
+
}),
|
|
8736
|
+
[router, navigator, basename, unstable_onError]
|
|
8737
|
+
);
|
|
8738
|
+
React9.useLayoutEffect(() => {
|
|
8739
|
+
return router.subscribe(
|
|
8740
|
+
(newState, { deletedFetchers, flushSync, viewTransitionOpts }) => {
|
|
8741
|
+
newState.fetchers.forEach((fetcher, key) => {
|
|
8742
|
+
if (fetcher.data !== void 0) {
|
|
8743
|
+
fetcherData.current.set(key, fetcher.data);
|
|
8744
|
+
}
|
|
8745
|
+
});
|
|
8746
|
+
deletedFetchers.forEach((key) => fetcherData.current.delete(key));
|
|
8747
|
+
const diff = shallowDiff(state, newState);
|
|
8748
|
+
if (!diff) return;
|
|
8749
|
+
if (flushSync) {
|
|
8750
|
+
if (reactDomFlushSyncImpl) {
|
|
8751
|
+
reactDomFlushSyncImpl(() => setState(newState));
|
|
8752
|
+
} else {
|
|
8753
|
+
setState(newState);
|
|
8754
|
+
}
|
|
8755
|
+
} else {
|
|
8756
|
+
React9.startTransition(() => {
|
|
8757
|
+
setState(newState);
|
|
8758
|
+
});
|
|
8759
|
+
}
|
|
8760
|
+
}
|
|
8761
|
+
);
|
|
8762
|
+
}, [router, reactDomFlushSyncImpl, state]);
|
|
8763
|
+
return /* @__PURE__ */ React9.createElement(React9.Fragment, null, /* @__PURE__ */ React9.createElement(DataRouterContext.Provider, { value: dataRouterContext }, /* @__PURE__ */ React9.createElement(
|
|
8764
|
+
DataRouterStateContext.Provider,
|
|
8765
|
+
{
|
|
8766
|
+
value: {
|
|
8767
|
+
...state,
|
|
8768
|
+
revalidation: revalidating ? "loading" : state.revalidation
|
|
8769
|
+
}
|
|
8770
|
+
},
|
|
8771
|
+
/* @__PURE__ */ React9.createElement(FetchersContext.Provider, { value: fetcherData.current }, /* @__PURE__ */ React9.createElement(
|
|
8772
|
+
Router,
|
|
8773
|
+
{
|
|
8774
|
+
basename,
|
|
8775
|
+
location: state.location,
|
|
8776
|
+
navigationType: state.historyAction,
|
|
8777
|
+
navigator
|
|
8778
|
+
},
|
|
8779
|
+
/* @__PURE__ */ React9.createElement(
|
|
8780
|
+
MemoizedDataRoutes,
|
|
8781
|
+
{
|
|
8782
|
+
routes: router.routes,
|
|
8783
|
+
future: router.future,
|
|
8784
|
+
state,
|
|
8785
|
+
unstable_onError
|
|
8786
|
+
}
|
|
8787
|
+
)
|
|
8788
|
+
))
|
|
8789
|
+
)), null);
|
|
8790
|
+
}
|
|
8791
|
+
function RouterProvider({
|
|
8792
|
+
router,
|
|
8793
|
+
flushSync: reactDomFlushSyncImpl,
|
|
8794
|
+
unstable_onError
|
|
8795
|
+
}) {
|
|
8796
|
+
let [state, setStateImpl] = React9.useState(router.state);
|
|
8797
|
+
let [pendingState, setPendingState] = React9.useState();
|
|
8798
|
+
let [vtContext, setVtContext] = React9.useState({
|
|
8799
|
+
isTransitioning: false
|
|
8800
|
+
});
|
|
8801
|
+
let [renderDfd, setRenderDfd] = React9.useState();
|
|
8802
|
+
let [transition, setTransition] = React9.useState();
|
|
8803
|
+
let [interruption, setInterruption] = React9.useState();
|
|
8804
|
+
let fetcherData = React9.useRef(/* @__PURE__ */ new Map());
|
|
8805
|
+
let logErrorsAndSetState = React9.useCallback(
|
|
8806
|
+
(newState) => {
|
|
8807
|
+
setStateImpl((prevState) => {
|
|
8808
|
+
if (newState.errors && unstable_onError) {
|
|
8809
|
+
Object.entries(newState.errors).forEach(([routeId, error]) => {
|
|
8810
|
+
if (_optionalChain([prevState, 'access', _119 => _119.errors, 'optionalAccess', _120 => _120[routeId]]) !== error) {
|
|
8811
|
+
unstable_onError(error);
|
|
8812
|
+
}
|
|
8813
|
+
});
|
|
8814
|
+
}
|
|
8815
|
+
return newState;
|
|
8816
|
+
});
|
|
8817
|
+
},
|
|
8818
|
+
[unstable_onError]
|
|
8819
|
+
);
|
|
8820
|
+
let setState = React9.useCallback(
|
|
8821
|
+
(newState, { deletedFetchers, flushSync, viewTransitionOpts }) => {
|
|
8822
|
+
newState.fetchers.forEach((fetcher, key) => {
|
|
8823
|
+
if (fetcher.data !== void 0) {
|
|
8824
|
+
fetcherData.current.set(key, fetcher.data);
|
|
8825
|
+
}
|
|
8826
|
+
});
|
|
8827
|
+
deletedFetchers.forEach((key) => fetcherData.current.delete(key));
|
|
8828
|
+
warnOnce(
|
|
8829
|
+
flushSync === false || reactDomFlushSyncImpl != null,
|
|
8830
|
+
'You provided the `flushSync` option to a router update, but you are not using the `<RouterProvider>` from `react-router/dom` so `ReactDOM.flushSync()` is unavailable. Please update your app to `import { RouterProvider } from "react-router/dom"` and ensure you have `react-dom` installed as a dependency to use the `flushSync` option.'
|
|
8831
|
+
);
|
|
8832
|
+
let isViewTransitionAvailable = router.window != null && router.window.document != null && typeof router.window.document.startViewTransition === "function";
|
|
8833
|
+
warnOnce(
|
|
8834
|
+
viewTransitionOpts == null || isViewTransitionAvailable,
|
|
8835
|
+
"You provided the `viewTransition` option to a router update, but you do not appear to be running in a DOM environment as `window.startViewTransition` is not available."
|
|
8836
|
+
);
|
|
8837
|
+
if (!viewTransitionOpts || !isViewTransitionAvailable) {
|
|
8838
|
+
if (reactDomFlushSyncImpl && flushSync) {
|
|
8839
|
+
reactDomFlushSyncImpl(() => logErrorsAndSetState(newState));
|
|
8840
|
+
} else {
|
|
8841
|
+
React9.startTransition(() => logErrorsAndSetState(newState));
|
|
8842
|
+
}
|
|
8843
|
+
return;
|
|
8844
|
+
}
|
|
8845
|
+
if (reactDomFlushSyncImpl && flushSync) {
|
|
8846
|
+
reactDomFlushSyncImpl(() => {
|
|
8847
|
+
if (transition) {
|
|
8848
|
+
renderDfd && renderDfd.resolve();
|
|
8849
|
+
transition.skipTransition();
|
|
8850
|
+
}
|
|
8851
|
+
setVtContext({
|
|
8852
|
+
isTransitioning: true,
|
|
8853
|
+
flushSync: true,
|
|
8854
|
+
currentLocation: viewTransitionOpts.currentLocation,
|
|
8855
|
+
nextLocation: viewTransitionOpts.nextLocation
|
|
8856
|
+
});
|
|
8857
|
+
});
|
|
8858
|
+
let t = router.window.document.startViewTransition(() => {
|
|
8859
|
+
reactDomFlushSyncImpl(() => logErrorsAndSetState(newState));
|
|
8860
|
+
});
|
|
8861
|
+
t.finished.finally(() => {
|
|
8862
|
+
reactDomFlushSyncImpl(() => {
|
|
8863
|
+
setRenderDfd(void 0);
|
|
8864
|
+
setTransition(void 0);
|
|
8865
|
+
setPendingState(void 0);
|
|
8866
|
+
setVtContext({ isTransitioning: false });
|
|
8867
|
+
});
|
|
8868
|
+
});
|
|
8869
|
+
reactDomFlushSyncImpl(() => setTransition(t));
|
|
8870
|
+
return;
|
|
8871
|
+
}
|
|
8872
|
+
if (transition) {
|
|
8873
|
+
renderDfd && renderDfd.resolve();
|
|
8874
|
+
transition.skipTransition();
|
|
8875
|
+
setInterruption({
|
|
8876
|
+
state: newState,
|
|
8877
|
+
currentLocation: viewTransitionOpts.currentLocation,
|
|
8878
|
+
nextLocation: viewTransitionOpts.nextLocation
|
|
8879
|
+
});
|
|
8880
|
+
} else {
|
|
8881
|
+
setPendingState(newState);
|
|
8882
|
+
setVtContext({
|
|
8883
|
+
isTransitioning: true,
|
|
8884
|
+
flushSync: false,
|
|
8885
|
+
currentLocation: viewTransitionOpts.currentLocation,
|
|
8886
|
+
nextLocation: viewTransitionOpts.nextLocation
|
|
8887
|
+
});
|
|
8888
|
+
}
|
|
8889
|
+
},
|
|
8890
|
+
[
|
|
8891
|
+
router.window,
|
|
8892
|
+
reactDomFlushSyncImpl,
|
|
8893
|
+
transition,
|
|
8894
|
+
renderDfd,
|
|
8895
|
+
logErrorsAndSetState
|
|
8896
|
+
]
|
|
8897
|
+
);
|
|
8898
|
+
React9.useLayoutEffect(() => router.subscribe(setState), [router, setState]);
|
|
8899
|
+
React9.useEffect(() => {
|
|
8900
|
+
if (vtContext.isTransitioning && !vtContext.flushSync) {
|
|
8901
|
+
setRenderDfd(new Deferred2());
|
|
8902
|
+
}
|
|
8903
|
+
}, [vtContext]);
|
|
8904
|
+
React9.useEffect(() => {
|
|
8905
|
+
if (renderDfd && pendingState && router.window) {
|
|
8906
|
+
let newState = pendingState;
|
|
8907
|
+
let renderPromise = renderDfd.promise;
|
|
8908
|
+
let transition2 = router.window.document.startViewTransition(async () => {
|
|
8909
|
+
React9.startTransition(() => logErrorsAndSetState(newState));
|
|
8910
|
+
await renderPromise;
|
|
8911
|
+
});
|
|
8912
|
+
transition2.finished.finally(() => {
|
|
8913
|
+
setRenderDfd(void 0);
|
|
8914
|
+
setTransition(void 0);
|
|
8915
|
+
setPendingState(void 0);
|
|
8916
|
+
setVtContext({ isTransitioning: false });
|
|
8917
|
+
});
|
|
8918
|
+
setTransition(transition2);
|
|
8919
|
+
}
|
|
8920
|
+
}, [pendingState, renderDfd, router.window, logErrorsAndSetState]);
|
|
8921
|
+
React9.useEffect(() => {
|
|
8922
|
+
if (renderDfd && pendingState && state.location.key === pendingState.location.key) {
|
|
8923
|
+
renderDfd.resolve();
|
|
8924
|
+
}
|
|
8925
|
+
}, [renderDfd, transition, state.location, pendingState]);
|
|
8926
|
+
React9.useEffect(() => {
|
|
8927
|
+
if (!vtContext.isTransitioning && interruption) {
|
|
8928
|
+
setPendingState(interruption.state);
|
|
8929
|
+
setVtContext({
|
|
8930
|
+
isTransitioning: true,
|
|
8931
|
+
flushSync: false,
|
|
8932
|
+
currentLocation: interruption.currentLocation,
|
|
8933
|
+
nextLocation: interruption.nextLocation
|
|
8934
|
+
});
|
|
8935
|
+
setInterruption(void 0);
|
|
8936
|
+
}
|
|
8937
|
+
}, [vtContext.isTransitioning, interruption]);
|
|
8938
|
+
let navigator = React9.useMemo(() => {
|
|
8939
|
+
return {
|
|
8940
|
+
createHref: router.createHref,
|
|
8941
|
+
encodeLocation: router.encodeLocation,
|
|
8942
|
+
go: (n) => router.navigate(n),
|
|
8943
|
+
push: (to, state2, opts) => router.navigate(to, {
|
|
8944
|
+
state: state2,
|
|
8945
|
+
preventScrollReset: _optionalChain([opts, 'optionalAccess', _121 => _121.preventScrollReset])
|
|
8946
|
+
}),
|
|
8947
|
+
replace: (to, state2, opts) => router.navigate(to, {
|
|
8948
|
+
replace: true,
|
|
8949
|
+
state: state2,
|
|
8950
|
+
preventScrollReset: _optionalChain([opts, 'optionalAccess', _122 => _122.preventScrollReset])
|
|
8951
|
+
})
|
|
8952
|
+
};
|
|
8953
|
+
}, [router]);
|
|
8954
|
+
let basename = router.basename || "/";
|
|
8955
|
+
let dataRouterContext = React9.useMemo(
|
|
8956
|
+
() => ({
|
|
8957
|
+
router,
|
|
8958
|
+
navigator,
|
|
8959
|
+
static: false,
|
|
8960
|
+
basename,
|
|
8961
|
+
unstable_onError
|
|
8962
|
+
}),
|
|
8963
|
+
[router, navigator, basename, unstable_onError]
|
|
8964
|
+
);
|
|
8965
|
+
return /* @__PURE__ */ React9.createElement(React9.Fragment, null, /* @__PURE__ */ React9.createElement(DataRouterContext.Provider, { value: dataRouterContext }, /* @__PURE__ */ React9.createElement(DataRouterStateContext.Provider, { value: state }, /* @__PURE__ */ React9.createElement(FetchersContext.Provider, { value: fetcherData.current }, /* @__PURE__ */ React9.createElement(ViewTransitionContext.Provider, { value: vtContext }, /* @__PURE__ */ React9.createElement(
|
|
8966
|
+
Router,
|
|
8967
|
+
{
|
|
8968
|
+
basename,
|
|
8969
|
+
location: state.location,
|
|
8970
|
+
navigationType: state.historyAction,
|
|
8971
|
+
navigator
|
|
8972
|
+
},
|
|
8973
|
+
/* @__PURE__ */ React9.createElement(
|
|
8974
|
+
MemoizedDataRoutes,
|
|
8975
|
+
{
|
|
8976
|
+
routes: router.routes,
|
|
8977
|
+
future: router.future,
|
|
8978
|
+
state,
|
|
8979
|
+
unstable_onError
|
|
8980
|
+
}
|
|
8981
|
+
)
|
|
8982
|
+
))))), null);
|
|
8983
|
+
}
|
|
8984
|
+
var MemoizedDataRoutes = React9.memo(DataRoutes);
|
|
8985
|
+
function DataRoutes({
|
|
8986
|
+
routes,
|
|
8987
|
+
future,
|
|
8988
|
+
state,
|
|
8989
|
+
unstable_onError
|
|
8990
|
+
}) {
|
|
8991
|
+
return useRoutesImpl(routes, void 0, state, unstable_onError, future);
|
|
8992
|
+
}
|
|
8993
|
+
function MemoryRouter({
|
|
8994
|
+
basename,
|
|
8995
|
+
children,
|
|
8996
|
+
initialEntries,
|
|
8997
|
+
initialIndex
|
|
8998
|
+
}) {
|
|
8999
|
+
let historyRef = React9.useRef();
|
|
9000
|
+
if (historyRef.current == null) {
|
|
9001
|
+
historyRef.current = createMemoryHistory({
|
|
9002
|
+
initialEntries,
|
|
9003
|
+
initialIndex,
|
|
9004
|
+
v5Compat: true
|
|
9005
|
+
});
|
|
9006
|
+
}
|
|
9007
|
+
let history = historyRef.current;
|
|
9008
|
+
let [state, setStateImpl] = React9.useState({
|
|
9009
|
+
action: history.action,
|
|
9010
|
+
location: history.location
|
|
9011
|
+
});
|
|
9012
|
+
let setState = React9.useCallback(
|
|
9013
|
+
(newState) => {
|
|
9014
|
+
React9.startTransition(() => setStateImpl(newState));
|
|
9015
|
+
},
|
|
9016
|
+
[setStateImpl]
|
|
9017
|
+
);
|
|
9018
|
+
React9.useLayoutEffect(() => history.listen(setState), [history, setState]);
|
|
9019
|
+
return /* @__PURE__ */ React9.createElement(
|
|
9020
|
+
Router,
|
|
9021
|
+
{
|
|
9022
|
+
basename,
|
|
9023
|
+
children,
|
|
9024
|
+
location: state.location,
|
|
9025
|
+
navigationType: state.action,
|
|
9026
|
+
navigator: history
|
|
9027
|
+
}
|
|
9028
|
+
);
|
|
9029
|
+
}
|
|
9030
|
+
function Navigate({
|
|
9031
|
+
to,
|
|
9032
|
+
replace: replace2,
|
|
9033
|
+
state,
|
|
9034
|
+
relative
|
|
9035
|
+
}) {
|
|
9036
|
+
invariant(
|
|
9037
|
+
useInRouterContext(),
|
|
9038
|
+
// TODO: This error is probably because they somehow have 2 versions of
|
|
9039
|
+
// the router loaded. We can help them understand how to avoid that.
|
|
9040
|
+
`<Navigate> may be used only in the context of a <Router> component.`
|
|
9041
|
+
);
|
|
9042
|
+
let { static: isStatic } = React9.useContext(NavigationContext);
|
|
9043
|
+
warning(
|
|
9044
|
+
!isStatic,
|
|
9045
|
+
`<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.`
|
|
9046
|
+
);
|
|
9047
|
+
let { matches } = React9.useContext(RouteContext);
|
|
9048
|
+
let { pathname: locationPathname } = useLocation();
|
|
9049
|
+
let navigate = useNavigate();
|
|
9050
|
+
let path = resolveTo(
|
|
9051
|
+
to,
|
|
9052
|
+
getResolveToMatches(matches),
|
|
9053
|
+
locationPathname,
|
|
9054
|
+
relative === "path"
|
|
9055
|
+
);
|
|
9056
|
+
let jsonPath = JSON.stringify(path);
|
|
9057
|
+
React9.useEffect(() => {
|
|
9058
|
+
navigate(JSON.parse(jsonPath), { replace: replace2, state, relative });
|
|
9059
|
+
}, [navigate, jsonPath, relative, replace2, state]);
|
|
9060
|
+
return null;
|
|
9061
|
+
}
|
|
9062
|
+
function Outlet(props) {
|
|
9063
|
+
return useOutlet(props.context);
|
|
9064
|
+
}
|
|
9065
|
+
function Route(props) {
|
|
9066
|
+
invariant(
|
|
9067
|
+
false,
|
|
9068
|
+
`A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.`
|
|
9069
|
+
);
|
|
9070
|
+
}
|
|
9071
|
+
function Router({
|
|
9072
|
+
basename: basenameProp = "/",
|
|
9073
|
+
children = null,
|
|
9074
|
+
location: locationProp,
|
|
9075
|
+
navigationType = "POP" /* Pop */,
|
|
9076
|
+
navigator,
|
|
9077
|
+
static: staticProp = false
|
|
9078
|
+
}) {
|
|
9079
|
+
invariant(
|
|
9080
|
+
!useInRouterContext(),
|
|
9081
|
+
`You cannot render a <Router> inside another <Router>. You should never have more than one in your app.`
|
|
9082
|
+
);
|
|
9083
|
+
let basename = basenameProp.replace(/^\/*/, "/");
|
|
9084
|
+
let navigationContext = React9.useMemo(
|
|
9085
|
+
() => ({
|
|
9086
|
+
basename,
|
|
9087
|
+
navigator,
|
|
9088
|
+
static: staticProp,
|
|
9089
|
+
future: {}
|
|
9090
|
+
}),
|
|
9091
|
+
[basename, navigator, staticProp]
|
|
9092
|
+
);
|
|
9093
|
+
if (typeof locationProp === "string") {
|
|
9094
|
+
locationProp = parsePath(locationProp);
|
|
9095
|
+
}
|
|
9096
|
+
let {
|
|
9097
|
+
pathname = "/",
|
|
9098
|
+
search = "",
|
|
9099
|
+
hash = "",
|
|
9100
|
+
state = null,
|
|
9101
|
+
key = "default"
|
|
9102
|
+
} = locationProp;
|
|
9103
|
+
let locationContext = React9.useMemo(() => {
|
|
9104
|
+
let trailingPathname = stripBasename(pathname, basename);
|
|
9105
|
+
if (trailingPathname == null) {
|
|
9106
|
+
return null;
|
|
9107
|
+
}
|
|
9108
|
+
return {
|
|
9109
|
+
location: {
|
|
9110
|
+
pathname: trailingPathname,
|
|
9111
|
+
search,
|
|
9112
|
+
hash,
|
|
9113
|
+
state,
|
|
9114
|
+
key
|
|
9115
|
+
},
|
|
9116
|
+
navigationType
|
|
9117
|
+
};
|
|
9118
|
+
}, [basename, pathname, search, hash, state, key, navigationType]);
|
|
9119
|
+
warning(
|
|
9120
|
+
locationContext != null,
|
|
9121
|
+
`<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.`
|
|
9122
|
+
);
|
|
9123
|
+
if (locationContext == null) {
|
|
9124
|
+
return null;
|
|
9125
|
+
}
|
|
9126
|
+
return /* @__PURE__ */ React9.createElement(NavigationContext.Provider, { value: navigationContext }, /* @__PURE__ */ React9.createElement(LocationContext.Provider, { children, value: locationContext }));
|
|
9127
|
+
}
|
|
9128
|
+
function Routes({
|
|
9129
|
+
children,
|
|
9130
|
+
location
|
|
9131
|
+
}) {
|
|
9132
|
+
return useRoutes(createRoutesFromChildren(children), location);
|
|
9133
|
+
}
|
|
9134
|
+
function Await({
|
|
9135
|
+
children,
|
|
9136
|
+
errorElement,
|
|
9137
|
+
resolve
|
|
9138
|
+
}) {
|
|
9139
|
+
let dataRouterContext = React9.useContext(DataRouterContext);
|
|
9140
|
+
return /* @__PURE__ */ React9.createElement(
|
|
9141
|
+
AwaitErrorBoundary,
|
|
9142
|
+
{
|
|
9143
|
+
resolve,
|
|
9144
|
+
errorElement,
|
|
9145
|
+
unstable_onError: _optionalChain([dataRouterContext, 'optionalAccess', _123 => _123.unstable_onError])
|
|
9146
|
+
},
|
|
9147
|
+
/* @__PURE__ */ React9.createElement(ResolveAwait, null, children)
|
|
9148
|
+
);
|
|
9149
|
+
}
|
|
9150
|
+
var AwaitErrorBoundary = class extends React9.Component {
|
|
9151
|
+
constructor(props) {
|
|
9152
|
+
super(props);
|
|
9153
|
+
this.state = { error: null };
|
|
9154
|
+
}
|
|
9155
|
+
static getDerivedStateFromError(error) {
|
|
9156
|
+
return { error };
|
|
9157
|
+
}
|
|
9158
|
+
componentDidCatch(error, errorInfo) {
|
|
9159
|
+
if (this.props.unstable_onError) {
|
|
9160
|
+
this.props.unstable_onError(error, errorInfo);
|
|
9161
|
+
} else {
|
|
9162
|
+
console.error(
|
|
9163
|
+
"<Await> caught the following error during render",
|
|
9164
|
+
error,
|
|
9165
|
+
errorInfo
|
|
9166
|
+
);
|
|
9167
|
+
}
|
|
9168
|
+
}
|
|
9169
|
+
render() {
|
|
9170
|
+
let { children, errorElement, resolve } = this.props;
|
|
9171
|
+
let promise = null;
|
|
9172
|
+
let status = 0 /* pending */;
|
|
9173
|
+
if (!(resolve instanceof Promise)) {
|
|
9174
|
+
status = 1 /* success */;
|
|
9175
|
+
promise = Promise.resolve();
|
|
9176
|
+
Object.defineProperty(promise, "_tracked", { get: () => true });
|
|
9177
|
+
Object.defineProperty(promise, "_data", { get: () => resolve });
|
|
9178
|
+
} else if (this.state.error) {
|
|
9179
|
+
status = 2 /* error */;
|
|
9180
|
+
let renderError = this.state.error;
|
|
9181
|
+
promise = Promise.reject().catch(() => {
|
|
9182
|
+
});
|
|
9183
|
+
Object.defineProperty(promise, "_tracked", { get: () => true });
|
|
9184
|
+
Object.defineProperty(promise, "_error", { get: () => renderError });
|
|
9185
|
+
} else if (resolve._tracked) {
|
|
9186
|
+
promise = resolve;
|
|
9187
|
+
status = "_error" in promise ? 2 /* error */ : "_data" in promise ? 1 /* success */ : 0 /* pending */;
|
|
9188
|
+
} else {
|
|
9189
|
+
status = 0 /* pending */;
|
|
9190
|
+
Object.defineProperty(resolve, "_tracked", { get: () => true });
|
|
9191
|
+
promise = resolve.then(
|
|
9192
|
+
(data2) => Object.defineProperty(resolve, "_data", { get: () => data2 }),
|
|
9193
|
+
(error) => {
|
|
9194
|
+
_optionalChain([this, 'access', _124 => _124.props, 'access', _125 => _125.unstable_onError, 'optionalCall', _126 => _126(error)]);
|
|
9195
|
+
Object.defineProperty(resolve, "_error", { get: () => error });
|
|
9196
|
+
}
|
|
9197
|
+
);
|
|
9198
|
+
}
|
|
9199
|
+
if (status === 2 /* error */ && !errorElement) {
|
|
9200
|
+
throw promise._error;
|
|
9201
|
+
}
|
|
9202
|
+
if (status === 2 /* error */) {
|
|
9203
|
+
return /* @__PURE__ */ React9.createElement(AwaitContext.Provider, { value: promise, children: errorElement });
|
|
9204
|
+
}
|
|
9205
|
+
if (status === 1 /* success */) {
|
|
9206
|
+
return /* @__PURE__ */ React9.createElement(AwaitContext.Provider, { value: promise, children });
|
|
9207
|
+
}
|
|
9208
|
+
throw promise;
|
|
9209
|
+
}
|
|
9210
|
+
};
|
|
9211
|
+
function ResolveAwait({
|
|
9212
|
+
children
|
|
9213
|
+
}) {
|
|
9214
|
+
let data2 = useAsyncValue();
|
|
9215
|
+
let toRender = typeof children === "function" ? children(data2) : children;
|
|
9216
|
+
return /* @__PURE__ */ React9.createElement(React9.Fragment, null, toRender);
|
|
9217
|
+
}
|
|
9218
|
+
function createRoutesFromChildren(children, parentPath = []) {
|
|
9219
|
+
let routes = [];
|
|
9220
|
+
React9.Children.forEach(children, (element, index) => {
|
|
9221
|
+
if (!React9.isValidElement(element)) {
|
|
9222
|
+
return;
|
|
9223
|
+
}
|
|
9224
|
+
let treePath = [...parentPath, index];
|
|
9225
|
+
if (element.type === React9.Fragment) {
|
|
9226
|
+
routes.push.apply(
|
|
9227
|
+
routes,
|
|
9228
|
+
createRoutesFromChildren(element.props.children, treePath)
|
|
9229
|
+
);
|
|
9230
|
+
return;
|
|
9231
|
+
}
|
|
9232
|
+
invariant(
|
|
9233
|
+
element.type === Route,
|
|
9234
|
+
`[${typeof element.type === "string" ? element.type : element.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`
|
|
9235
|
+
);
|
|
9236
|
+
invariant(
|
|
9237
|
+
!element.props.index || !element.props.children,
|
|
9238
|
+
"An index route cannot have child routes."
|
|
9239
|
+
);
|
|
9240
|
+
let route = {
|
|
9241
|
+
id: element.props.id || treePath.join("-"),
|
|
9242
|
+
caseSensitive: element.props.caseSensitive,
|
|
9243
|
+
element: element.props.element,
|
|
9244
|
+
Component: element.props.Component,
|
|
9245
|
+
index: element.props.index,
|
|
9246
|
+
path: element.props.path,
|
|
9247
|
+
middleware: element.props.middleware,
|
|
9248
|
+
loader: element.props.loader,
|
|
9249
|
+
action: element.props.action,
|
|
9250
|
+
hydrateFallbackElement: element.props.hydrateFallbackElement,
|
|
9251
|
+
HydrateFallback: element.props.HydrateFallback,
|
|
9252
|
+
errorElement: element.props.errorElement,
|
|
9253
|
+
ErrorBoundary: element.props.ErrorBoundary,
|
|
9254
|
+
hasErrorBoundary: element.props.hasErrorBoundary === true || element.props.ErrorBoundary != null || element.props.errorElement != null,
|
|
9255
|
+
shouldRevalidate: element.props.shouldRevalidate,
|
|
9256
|
+
handle: element.props.handle,
|
|
9257
|
+
lazy: element.props.lazy
|
|
9258
|
+
};
|
|
9259
|
+
if (element.props.children) {
|
|
9260
|
+
route.children = createRoutesFromChildren(
|
|
9261
|
+
element.props.children,
|
|
9262
|
+
treePath
|
|
9263
|
+
);
|
|
9264
|
+
}
|
|
9265
|
+
routes.push(route);
|
|
9266
|
+
});
|
|
9267
|
+
return routes;
|
|
9268
|
+
}
|
|
9269
|
+
var createRoutesFromElements = createRoutesFromChildren;
|
|
9270
|
+
function renderMatches(matches) {
|
|
9271
|
+
return _renderMatches(matches);
|
|
9272
|
+
}
|
|
9273
|
+
function useRouteComponentProps() {
|
|
9274
|
+
return {
|
|
9275
|
+
params: useParams(),
|
|
9276
|
+
loaderData: useLoaderData(),
|
|
9277
|
+
actionData: useActionData(),
|
|
9278
|
+
matches: useMatches()
|
|
9279
|
+
};
|
|
9280
|
+
}
|
|
9281
|
+
function WithComponentProps({
|
|
9282
|
+
children
|
|
9283
|
+
}) {
|
|
9284
|
+
const props = useRouteComponentProps();
|
|
9285
|
+
return React9.cloneElement(children, props);
|
|
9286
|
+
}
|
|
9287
|
+
function withComponentProps(Component4) {
|
|
9288
|
+
return function WithComponentProps2() {
|
|
9289
|
+
const props = useRouteComponentProps();
|
|
9290
|
+
return React9.createElement(Component4, props);
|
|
9291
|
+
};
|
|
9292
|
+
}
|
|
9293
|
+
function useHydrateFallbackProps() {
|
|
9294
|
+
return {
|
|
9295
|
+
params: useParams(),
|
|
9296
|
+
loaderData: useLoaderData(),
|
|
9297
|
+
actionData: useActionData()
|
|
9298
|
+
};
|
|
9299
|
+
}
|
|
9300
|
+
function WithHydrateFallbackProps({
|
|
9301
|
+
children
|
|
9302
|
+
}) {
|
|
9303
|
+
const props = useHydrateFallbackProps();
|
|
9304
|
+
return React9.cloneElement(children, props);
|
|
9305
|
+
}
|
|
9306
|
+
function withHydrateFallbackProps(HydrateFallback) {
|
|
9307
|
+
return function WithHydrateFallbackProps2() {
|
|
9308
|
+
const props = useHydrateFallbackProps();
|
|
9309
|
+
return React9.createElement(HydrateFallback, props);
|
|
9310
|
+
};
|
|
9311
|
+
}
|
|
9312
|
+
function useErrorBoundaryProps() {
|
|
9313
|
+
return {
|
|
9314
|
+
params: useParams(),
|
|
9315
|
+
loaderData: useLoaderData(),
|
|
9316
|
+
actionData: useActionData(),
|
|
9317
|
+
error: useRouteError()
|
|
9318
|
+
};
|
|
9319
|
+
}
|
|
9320
|
+
function WithErrorBoundaryProps({
|
|
9321
|
+
children
|
|
9322
|
+
}) {
|
|
9323
|
+
const props = useErrorBoundaryProps();
|
|
9324
|
+
return React9.cloneElement(children, props);
|
|
9325
|
+
}
|
|
9326
|
+
function withErrorBoundaryProps(ErrorBoundary) {
|
|
9327
|
+
return function WithErrorBoundaryProps2() {
|
|
9328
|
+
const props = useErrorBoundaryProps();
|
|
9329
|
+
return React9.createElement(ErrorBoundary, props);
|
|
9330
|
+
};
|
|
9331
|
+
}
|
|
9332
|
+
|
|
9333
|
+
|
|
9334
|
+
|
|
9335
|
+
|
|
9336
|
+
|
|
9337
|
+
|
|
9338
|
+
|
|
9339
|
+
|
|
9340
|
+
|
|
9341
|
+
|
|
9342
|
+
|
|
9343
|
+
|
|
9344
|
+
|
|
9345
|
+
|
|
9346
|
+
|
|
9347
|
+
|
|
9348
|
+
|
|
9349
|
+
|
|
8246
9350
|
|
|
8247
9351
|
|
|
8248
9352
|
|
|
@@ -8347,4 +9451,4 @@ function BoundaryShell({
|
|
|
8347
9451
|
|
|
8348
9452
|
|
|
8349
9453
|
|
|
8350
|
-
exports.Action = Action; exports.
|
|
9454
|
+
exports.Action = Action; 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.generatePath = generatePath; exports.matchPath = matchPath; exports.stripBasename = stripBasename; exports.resolvePath = resolvePath; exports.joinPaths = joinPaths; exports.data = data; exports.redirect = redirect; exports.redirectDocument = redirectDocument; exports.replace = replace; exports.ErrorResponseImpl = ErrorResponseImpl; exports.isRouteErrorResponse = isRouteErrorResponse; 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.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.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.useRoutesImpl = useRoutesImpl; 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.RemixErrorBoundary = RemixErrorBoundary; exports.createServerRoutes = createServerRoutes; exports.createClientRoutesWithHMRRevalidationOptOut = createClientRoutesWithHMRRevalidationOptOut; exports.noActionDefinedError = noActionDefinedError; exports.createClientRoutes = createClientRoutes; exports.shouldHydrateRouteLoader = shouldHydrateRouteLoader; 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.UNSTABLE_TransitionEnabledRouterProvider = UNSTABLE_TransitionEnabledRouterProvider; exports.RouterProvider = RouterProvider; 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;
|