react-router 0.0.0-experimental-e0b6ce9 → 0.0.0-experimental-de3b900
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +105 -0
- package/dist/development/browser-B4aBBnx8.d.ts +310 -0
- package/dist/development/browser-CN2w9Cbu.d.mts +310 -0
- package/dist/development/{chunk-4FI4BC6Y.mjs → chunk-5VDQAMOM.mjs} +181 -873
- package/dist/development/chunk-JEIV2ESS.js +1308 -0
- package/dist/development/{chunk-INO4IHBF.js → chunk-K3XLKYJI.js} +892 -409
- package/dist/development/{chunk-F6CT5MEB.mjs → chunk-OVO62ONG.mjs} +31 -314
- package/dist/development/chunk-UPBUMW2M.js +188 -0
- package/dist/development/dom-export.d.mts +51 -61
- package/dist/development/dom-export.d.ts +51 -60
- package/dist/development/dom-export.js +705 -23
- package/dist/development/dom-export.mjs +689 -14
- package/dist/{production/index-react-server-client-CYIi6gi0.d.mts → development/index-react-server-client-BOJoTiaG.d.ts} +76 -140
- package/dist/development/{index-react-server-client-CYIi6gi0.d.mts → index-react-server-client-CuQLmpku.d.mts} +76 -140
- package/dist/development/index-react-server-client.d.mts +2 -3
- package/dist/development/index-react-server-client.d.ts +2 -3
- package/dist/development/index-react-server-client.js +4 -4
- package/dist/development/index-react-server-client.mjs +2 -2
- package/dist/development/index-react-server.d.mts +1 -90
- package/dist/development/index-react-server.d.ts +1 -90
- package/dist/development/index-react-server.js +9 -188
- package/dist/development/index-react-server.mjs +9 -188
- package/dist/development/index.d.mts +21 -320
- package/dist/development/index.d.ts +21 -364
- package/dist/development/index.js +131 -977
- package/dist/development/index.mjs +5 -9
- package/dist/development/lib/types/internal.d.mts +2 -3
- package/dist/development/lib/types/internal.d.ts +2 -3
- package/dist/development/lib/types/internal.js +1 -1
- package/dist/development/lib/types/internal.mjs +1 -1
- package/dist/{production/register-DiOIlEq5.d.mts → development/register-BblEgJPm.d.mts} +7 -1
- package/dist/development/{register-DiOIlEq5.d.ts → register-D18raRVf.d.ts} +7 -1
- package/dist/development/{router-DWv6Clt-.d.mts → route-data-nQS6GSUI.d.mts} +1265 -932
- package/dist/development/{routeModules-DqotkItD.d.ts → routeModules-9wlxglVk.d.ts} +1047 -74
- package/dist/production/browser-B4aBBnx8.d.ts +310 -0
- package/dist/production/browser-CN2w9Cbu.d.mts +310 -0
- package/dist/production/{chunk-K7VXYOZD.js → chunk-63YB5VLY.js} +892 -409
- package/dist/production/chunk-IE722GR6.js +188 -0
- package/dist/production/{chunk-LKSLGWXX.mjs → chunk-U25H5FTL.mjs} +31 -314
- package/dist/production/chunk-VX4OHTGR.js +1308 -0
- package/dist/production/{chunk-52MYED7O.mjs → chunk-XOCFS75J.mjs} +181 -873
- package/dist/production/dom-export.d.mts +51 -61
- package/dist/production/dom-export.d.ts +51 -60
- package/dist/production/dom-export.js +705 -23
- package/dist/production/dom-export.mjs +689 -14
- package/dist/production/{index-react-server-client-ChBGplLn.d.ts → index-react-server-client-BOJoTiaG.d.ts} +76 -140
- package/dist/{development/index-react-server-client-ChBGplLn.d.ts → production/index-react-server-client-CuQLmpku.d.mts} +76 -140
- package/dist/production/index-react-server-client.d.mts +2 -3
- package/dist/production/index-react-server-client.d.ts +2 -3
- package/dist/production/index-react-server-client.js +4 -4
- package/dist/production/index-react-server-client.mjs +2 -2
- package/dist/production/index-react-server.d.mts +1 -90
- package/dist/production/index-react-server.d.ts +1 -90
- package/dist/production/index-react-server.js +9 -188
- package/dist/production/index-react-server.mjs +9 -188
- package/dist/production/index.d.mts +21 -320
- package/dist/production/index.d.ts +21 -364
- package/dist/production/index.js +131 -977
- package/dist/production/index.mjs +5 -9
- package/dist/production/lib/types/internal.d.mts +2 -3
- package/dist/production/lib/types/internal.d.ts +2 -3
- package/dist/production/lib/types/internal.js +1 -1
- package/dist/production/lib/types/internal.mjs +1 -1
- package/dist/{development/register-DiOIlEq5.d.mts → production/register-BblEgJPm.d.mts} +7 -1
- package/dist/production/{register-DiOIlEq5.d.ts → register-D18raRVf.d.ts} +7 -1
- package/dist/production/{router-DWv6Clt-.d.mts → route-data-nQS6GSUI.d.mts} +1265 -932
- package/dist/production/{routeModules-DqotkItD.d.ts → routeModules-9wlxglVk.d.ts} +1047 -74
- package/package.json +1 -1
- package/dist/development/browser-z32v5KVN.d.mts +0 -46
- package/dist/development/chunk-ITZFCV4J.js +0 -2092
- package/dist/development/instrumentation-BGrNA7uj.d.ts +0 -1122
- package/dist/development/routeModules-Cy4Xsfoi.d.mts +0 -483
- package/dist/production/browser-z32v5KVN.d.mts +0 -46
- package/dist/production/chunk-DASXXYNZ.js +0 -2092
- package/dist/production/instrumentation-BGrNA7uj.d.ts +0 -1122
- package/dist/production/routeModules-Cy4Xsfoi.d.mts +0 -483
|
@@ -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 v0.0.0-experimental-
|
|
2
|
+
* react-router v0.0.0-experimental-de3b900
|
|
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,27 +454,23 @@ function convertRoutesToDataRoutes(routes, mapRouteProperties, parentPath = [],
|
|
|
454
454
|
if (isIndexRoute(route)) {
|
|
455
455
|
let indexRoute = {
|
|
456
456
|
...route,
|
|
457
|
+
...mapRouteProperties2(route),
|
|
457
458
|
id
|
|
458
459
|
};
|
|
459
|
-
manifest[id] =
|
|
460
|
-
indexRoute,
|
|
461
|
-
mapRouteProperties(indexRoute)
|
|
462
|
-
);
|
|
460
|
+
manifest[id] = indexRoute;
|
|
463
461
|
return indexRoute;
|
|
464
462
|
} else {
|
|
465
463
|
let pathOrLayoutRoute = {
|
|
466
464
|
...route,
|
|
465
|
+
...mapRouteProperties2(route),
|
|
467
466
|
id,
|
|
468
467
|
children: void 0
|
|
469
468
|
};
|
|
470
|
-
manifest[id] =
|
|
471
|
-
pathOrLayoutRoute,
|
|
472
|
-
mapRouteProperties(pathOrLayoutRoute)
|
|
473
|
-
);
|
|
469
|
+
manifest[id] = pathOrLayoutRoute;
|
|
474
470
|
if (route.children) {
|
|
475
471
|
pathOrLayoutRoute.children = convertRoutesToDataRoutes(
|
|
476
472
|
route.children,
|
|
477
|
-
|
|
473
|
+
mapRouteProperties2,
|
|
478
474
|
treePath,
|
|
479
475
|
manifest,
|
|
480
476
|
allowInPlaceMutations
|
|
@@ -484,17 +480,6 @@ function convertRoutesToDataRoutes(routes, mapRouteProperties, parentPath = [],
|
|
|
484
480
|
}
|
|
485
481
|
});
|
|
486
482
|
}
|
|
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
|
-
}
|
|
498
483
|
function matchRoutes(routes, locationArg, basename = "/") {
|
|
499
484
|
return matchRoutesImpl(routes, locationArg, basename, false);
|
|
500
485
|
}
|
|
@@ -735,18 +720,18 @@ function matchPath(pattern, pathname) {
|
|
|
735
720
|
let pathnameBase = matchedPathname.replace(/(.)\/+$/, "$1");
|
|
736
721
|
let captureGroups = match.slice(1);
|
|
737
722
|
let params = compiledParams.reduce(
|
|
738
|
-
(
|
|
723
|
+
(memo2, { paramName, isOptional }, index) => {
|
|
739
724
|
if (paramName === "*") {
|
|
740
725
|
let splatValue = captureGroups[index] || "";
|
|
741
726
|
pathnameBase = matchedPathname.slice(0, matchedPathname.length - splatValue.length).replace(/(.)\/+$/, "$1");
|
|
742
727
|
}
|
|
743
728
|
const value = captureGroups[index];
|
|
744
729
|
if (isOptional && !value) {
|
|
745
|
-
|
|
730
|
+
memo2[paramName] = void 0;
|
|
746
731
|
} else {
|
|
747
|
-
|
|
732
|
+
memo2[paramName] = (value || "").replace(/%2F/g, "/");
|
|
748
733
|
}
|
|
749
|
-
return
|
|
734
|
+
return memo2;
|
|
750
735
|
},
|
|
751
736
|
{}
|
|
752
737
|
);
|
|
@@ -950,233 +935,6 @@ var ErrorResponseImpl = class {
|
|
|
950
935
|
function isRouteErrorResponse(error) {
|
|
951
936
|
return error != null && typeof error.status === "number" && typeof error.statusText === "string" && typeof error.internal === "boolean" && "data" in error;
|
|
952
937
|
}
|
|
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
|
-
// TODO: Handle non-middleware flows
|
|
1113
|
-
// @ts-expect-error
|
|
1114
|
-
context: getReadonlyContext(context)
|
|
1115
|
-
};
|
|
1116
|
-
});
|
|
1117
|
-
}
|
|
1118
|
-
return instrumentedHandler;
|
|
1119
|
-
}
|
|
1120
|
-
function wrapImpl(impls, handler, getInfo) {
|
|
1121
|
-
if (impls.length === 0) {
|
|
1122
|
-
return null;
|
|
1123
|
-
}
|
|
1124
|
-
return async (...args) => {
|
|
1125
|
-
let value;
|
|
1126
|
-
let info = getInfo(...args);
|
|
1127
|
-
await recurseRight(
|
|
1128
|
-
impls,
|
|
1129
|
-
info,
|
|
1130
|
-
async () => {
|
|
1131
|
-
value = await handler(...args);
|
|
1132
|
-
},
|
|
1133
|
-
impls.length - 1
|
|
1134
|
-
);
|
|
1135
|
-
return value;
|
|
1136
|
-
};
|
|
1137
|
-
}
|
|
1138
|
-
async function recurseRight(impls, info, handler, index) {
|
|
1139
|
-
let impl = impls[index];
|
|
1140
|
-
if (!impl) {
|
|
1141
|
-
await handler();
|
|
1142
|
-
} else {
|
|
1143
|
-
await impl(async () => {
|
|
1144
|
-
await recurseRight(impls, info, handler, index - 1);
|
|
1145
|
-
}, info);
|
|
1146
|
-
}
|
|
1147
|
-
}
|
|
1148
|
-
function getHandlerInfo(args) {
|
|
1149
|
-
let { request, context, params, unstable_pattern } = args;
|
|
1150
|
-
return {
|
|
1151
|
-
request: getReadonlyRequest(request),
|
|
1152
|
-
params: { ...params },
|
|
1153
|
-
unstable_pattern,
|
|
1154
|
-
context: getReadonlyContext(context)
|
|
1155
|
-
};
|
|
1156
|
-
}
|
|
1157
|
-
function getRouterInfo(router, opts) {
|
|
1158
|
-
return {
|
|
1159
|
-
currentUrl: createPath(router.state.location),
|
|
1160
|
-
..."formMethod" in opts ? { formMethod: opts.formMethod } : {},
|
|
1161
|
-
..."formEncType" in opts ? { formEncType: opts.formEncType } : {},
|
|
1162
|
-
..."formData" in opts ? { formData: opts.formData } : {},
|
|
1163
|
-
..."body" in opts ? { body: opts.body } : {}
|
|
1164
|
-
};
|
|
1165
|
-
}
|
|
1166
|
-
function getReadonlyRequest(request) {
|
|
1167
|
-
return {
|
|
1168
|
-
method: request.method,
|
|
1169
|
-
url: request.url,
|
|
1170
|
-
headers: {
|
|
1171
|
-
get: (...args) => request.headers.get(...args)
|
|
1172
|
-
}
|
|
1173
|
-
};
|
|
1174
|
-
}
|
|
1175
|
-
function getReadonlyContext(context) {
|
|
1176
|
-
return {
|
|
1177
|
-
get: (ctx) => context.get(ctx)
|
|
1178
|
-
};
|
|
1179
|
-
}
|
|
1180
938
|
|
|
1181
939
|
// lib/router/router.ts
|
|
1182
940
|
var validMutationMethodsArr = [
|
|
@@ -1235,25 +993,12 @@ function createRouter(init) {
|
|
|
1235
993
|
init.routes.length > 0,
|
|
1236
994
|
"You must provide a non-empty routes array to createRouter"
|
|
1237
995
|
);
|
|
1238
|
-
let
|
|
1239
|
-
let
|
|
1240
|
-
let mapRouteProperties = _mapRouteProperties;
|
|
1241
|
-
if (init.unstable_instrumentations) {
|
|
1242
|
-
let instrumentations = init.unstable_instrumentations;
|
|
1243
|
-
mapRouteProperties = (route) => {
|
|
1244
|
-
return {
|
|
1245
|
-
..._mapRouteProperties(route),
|
|
1246
|
-
...getRouteInstrumentationUpdates(
|
|
1247
|
-
instrumentations.map((i) => i.route).filter(Boolean),
|
|
1248
|
-
route
|
|
1249
|
-
)
|
|
1250
|
-
};
|
|
1251
|
-
};
|
|
1252
|
-
}
|
|
996
|
+
let hydrationRouteProperties2 = init.hydrationRouteProperties || [];
|
|
997
|
+
let mapRouteProperties2 = init.mapRouteProperties || defaultMapRouteProperties;
|
|
1253
998
|
let manifest = {};
|
|
1254
999
|
let dataRoutes = convertRoutesToDataRoutes(
|
|
1255
1000
|
init.routes,
|
|
1256
|
-
|
|
1001
|
+
mapRouteProperties2,
|
|
1257
1002
|
void 0,
|
|
1258
1003
|
manifest
|
|
1259
1004
|
);
|
|
@@ -1865,12 +1610,12 @@ function createRouter(init) {
|
|
|
1865
1610
|
};
|
|
1866
1611
|
} else {
|
|
1867
1612
|
let dsMatches = getTargetedDataStrategyMatches(
|
|
1868
|
-
|
|
1613
|
+
mapRouteProperties2,
|
|
1869
1614
|
manifest,
|
|
1870
1615
|
request,
|
|
1871
1616
|
matches,
|
|
1872
1617
|
actionMatch,
|
|
1873
|
-
initialHydration ? [] :
|
|
1618
|
+
initialHydration ? [] : hydrationRouteProperties2,
|
|
1874
1619
|
scopedContext
|
|
1875
1620
|
);
|
|
1876
1621
|
let results = await callDataStrategy(
|
|
@@ -1991,14 +1736,14 @@ function createRouter(init) {
|
|
|
1991
1736
|
let { dsMatches, revalidatingFetchers } = getMatchesToLoad(
|
|
1992
1737
|
request,
|
|
1993
1738
|
scopedContext,
|
|
1994
|
-
|
|
1739
|
+
mapRouteProperties2,
|
|
1995
1740
|
manifest,
|
|
1996
1741
|
init.history,
|
|
1997
1742
|
state,
|
|
1998
1743
|
matches,
|
|
1999
1744
|
activeSubmission,
|
|
2000
1745
|
location,
|
|
2001
|
-
initialHydration ? [] :
|
|
1746
|
+
initialHydration ? [] : hydrationRouteProperties2,
|
|
2002
1747
|
initialHydration === true,
|
|
2003
1748
|
isRevalidationRequired,
|
|
2004
1749
|
cancelledFetcherLoads,
|
|
@@ -2247,12 +1992,12 @@ function createRouter(init) {
|
|
|
2247
1992
|
fetchControllers.set(key, abortController);
|
|
2248
1993
|
let originatingLoadId = incrementingLoadId;
|
|
2249
1994
|
let fetchMatches = getTargetedDataStrategyMatches(
|
|
2250
|
-
|
|
1995
|
+
mapRouteProperties2,
|
|
2251
1996
|
manifest,
|
|
2252
1997
|
fetchRequest,
|
|
2253
1998
|
requestMatches,
|
|
2254
1999
|
match,
|
|
2255
|
-
|
|
2000
|
+
hydrationRouteProperties2,
|
|
2256
2001
|
scopedContext
|
|
2257
2002
|
);
|
|
2258
2003
|
let actionResults = await callDataStrategy(
|
|
@@ -2309,14 +2054,14 @@ function createRouter(init) {
|
|
|
2309
2054
|
let { dsMatches, revalidatingFetchers } = getMatchesToLoad(
|
|
2310
2055
|
revalidationRequest,
|
|
2311
2056
|
scopedContext,
|
|
2312
|
-
|
|
2057
|
+
mapRouteProperties2,
|
|
2313
2058
|
manifest,
|
|
2314
2059
|
init.history,
|
|
2315
2060
|
state,
|
|
2316
2061
|
matches,
|
|
2317
2062
|
submission,
|
|
2318
2063
|
nextLocation,
|
|
2319
|
-
|
|
2064
|
+
hydrationRouteProperties2,
|
|
2320
2065
|
false,
|
|
2321
2066
|
isRevalidationRequired,
|
|
2322
2067
|
cancelledFetcherLoads,
|
|
@@ -2462,12 +2207,12 @@ function createRouter(init) {
|
|
|
2462
2207
|
fetchControllers.set(key, abortController);
|
|
2463
2208
|
let originatingLoadId = incrementingLoadId;
|
|
2464
2209
|
let dsMatches = getTargetedDataStrategyMatches(
|
|
2465
|
-
|
|
2210
|
+
mapRouteProperties2,
|
|
2466
2211
|
manifest,
|
|
2467
2212
|
fetchRequest,
|
|
2468
2213
|
matches,
|
|
2469
2214
|
match,
|
|
2470
|
-
|
|
2215
|
+
hydrationRouteProperties2,
|
|
2471
2216
|
scopedContext
|
|
2472
2217
|
);
|
|
2473
2218
|
let results = await callDataStrategy(
|
|
@@ -2902,7 +2647,7 @@ function createRouter(init) {
|
|
|
2902
2647
|
children,
|
|
2903
2648
|
routesToUse,
|
|
2904
2649
|
localManifest,
|
|
2905
|
-
|
|
2650
|
+
mapRouteProperties2,
|
|
2906
2651
|
false
|
|
2907
2652
|
);
|
|
2908
2653
|
}
|
|
@@ -2939,7 +2684,7 @@ function createRouter(init) {
|
|
|
2939
2684
|
manifest = {};
|
|
2940
2685
|
inFlightDataRoutes = convertRoutesToDataRoutes(
|
|
2941
2686
|
newRoutes,
|
|
2942
|
-
|
|
2687
|
+
mapRouteProperties2,
|
|
2943
2688
|
void 0,
|
|
2944
2689
|
manifest
|
|
2945
2690
|
);
|
|
@@ -2952,7 +2697,7 @@ function createRouter(init) {
|
|
|
2952
2697
|
children,
|
|
2953
2698
|
routesToUse,
|
|
2954
2699
|
manifest,
|
|
2955
|
-
|
|
2700
|
+
mapRouteProperties2,
|
|
2956
2701
|
unstable_allowElementMutations
|
|
2957
2702
|
);
|
|
2958
2703
|
if (isNonHMR) {
|
|
@@ -3001,12 +2746,6 @@ function createRouter(init) {
|
|
|
3001
2746
|
updateState(newState);
|
|
3002
2747
|
}
|
|
3003
2748
|
};
|
|
3004
|
-
if (init.unstable_instrumentations) {
|
|
3005
|
-
router = instrumentClientSideRouter(
|
|
3006
|
-
router,
|
|
3007
|
-
init.unstable_instrumentations.map((i) => i.router).filter(Boolean)
|
|
3008
|
-
);
|
|
3009
|
-
}
|
|
3010
2749
|
return router;
|
|
3011
2750
|
}
|
|
3012
2751
|
function createStaticHandler(routes, opts) {
|
|
@@ -3016,23 +2755,10 @@ function createStaticHandler(routes, opts) {
|
|
|
3016
2755
|
);
|
|
3017
2756
|
let manifest = {};
|
|
3018
2757
|
let basename = (opts ? opts.basename : null) || "/";
|
|
3019
|
-
let
|
|
3020
|
-
let mapRouteProperties = _mapRouteProperties;
|
|
3021
|
-
if (_optionalChain([opts, 'optionalAccess', _17 => _17.unstable_instrumentations])) {
|
|
3022
|
-
let instrumentations = opts.unstable_instrumentations;
|
|
3023
|
-
mapRouteProperties = (route) => {
|
|
3024
|
-
return {
|
|
3025
|
-
..._mapRouteProperties(route),
|
|
3026
|
-
...getRouteInstrumentationUpdates(
|
|
3027
|
-
instrumentations.map((i) => i.route).filter(Boolean),
|
|
3028
|
-
route
|
|
3029
|
-
)
|
|
3030
|
-
};
|
|
3031
|
-
};
|
|
3032
|
-
}
|
|
2758
|
+
let mapRouteProperties2 = _optionalChain([opts, 'optionalAccess', _16 => _16.mapRouteProperties]) || defaultMapRouteProperties;
|
|
3033
2759
|
let dataRoutes = convertRoutesToDataRoutes(
|
|
3034
2760
|
routes,
|
|
3035
|
-
|
|
2761
|
+
mapRouteProperties2,
|
|
3036
2762
|
void 0,
|
|
3037
2763
|
manifest
|
|
3038
2764
|
);
|
|
@@ -3093,13 +2819,12 @@ function createStaticHandler(routes, opts) {
|
|
|
3093
2819
|
await loadLazyMiddlewareForMatches(
|
|
3094
2820
|
matches,
|
|
3095
2821
|
manifest,
|
|
3096
|
-
|
|
2822
|
+
mapRouteProperties2
|
|
3097
2823
|
);
|
|
3098
2824
|
let renderedStaticContext;
|
|
3099
2825
|
let response = await runServerMiddlewarePipeline(
|
|
3100
2826
|
{
|
|
3101
2827
|
request,
|
|
3102
|
-
unstable_pattern: getRoutePattern(matches.map((m) => m.route.path)),
|
|
3103
2828
|
matches,
|
|
3104
2829
|
params: matches[0].params,
|
|
3105
2830
|
// If we're calling middleware then it must be enabled so we can cast
|
|
@@ -3163,9 +2888,9 @@ function createStaticHandler(routes, opts) {
|
|
|
3163
2888
|
} else {
|
|
3164
2889
|
let boundaryRouteId = skipLoaderErrorBubbling ? routeId : findNearestBoundary(
|
|
3165
2890
|
matches,
|
|
3166
|
-
_optionalChain([matches, 'access',
|
|
2891
|
+
_optionalChain([matches, 'access', _17 => _17.find, 'call', _18 => _18(
|
|
3167
2892
|
(m) => m.route.id === routeId || m.route.loader
|
|
3168
|
-
), 'optionalAccess',
|
|
2893
|
+
), 'optionalAccess', _19 => _19.route, 'access', _20 => _20.id]) || routeId
|
|
3169
2894
|
).route.id;
|
|
3170
2895
|
let staticContext = {
|
|
3171
2896
|
matches,
|
|
@@ -3241,11 +2966,10 @@ function createStaticHandler(routes, opts) {
|
|
|
3241
2966
|
requestContext instanceof RouterContextProvider,
|
|
3242
2967
|
"When using middleware in `staticHandler.queryRoute()`, any provided `requestContext` must be an instance of `RouterContextProvider`"
|
|
3243
2968
|
);
|
|
3244
|
-
await loadLazyMiddlewareForMatches(matches, manifest,
|
|
2969
|
+
await loadLazyMiddlewareForMatches(matches, manifest, mapRouteProperties2);
|
|
3245
2970
|
let response = await runServerMiddlewarePipeline(
|
|
3246
2971
|
{
|
|
3247
2972
|
request,
|
|
3248
|
-
unstable_pattern: getRoutePattern(matches.map((m) => m.route.path)),
|
|
3249
2973
|
matches,
|
|
3250
2974
|
params: matches[0].params,
|
|
3251
2975
|
// If we're calling middleware then it must be enabled so we can cast
|
|
@@ -3377,7 +3101,7 @@ function createStaticHandler(routes, opts) {
|
|
|
3377
3101
|
};
|
|
3378
3102
|
} else {
|
|
3379
3103
|
let dsMatches = getTargetedDataStrategyMatches(
|
|
3380
|
-
|
|
3104
|
+
mapRouteProperties2,
|
|
3381
3105
|
manifest,
|
|
3382
3106
|
request,
|
|
3383
3107
|
matches,
|
|
@@ -3498,17 +3222,17 @@ function createStaticHandler(routes, opts) {
|
|
|
3498
3222
|
}
|
|
3499
3223
|
async function loadRouteData(request, matches, requestContext, dataStrategy, skipLoaderErrorBubbling, routeMatch, filterMatchesToLoad, pendingActionResult) {
|
|
3500
3224
|
let isRouteRequest = routeMatch != null;
|
|
3501
|
-
if (isRouteRequest && !_optionalChain([routeMatch, 'optionalAccess',
|
|
3225
|
+
if (isRouteRequest && !_optionalChain([routeMatch, 'optionalAccess', _21 => _21.route, 'access', _22 => _22.loader]) && !_optionalChain([routeMatch, 'optionalAccess', _23 => _23.route, 'access', _24 => _24.lazy])) {
|
|
3502
3226
|
throw getInternalRouterError(400, {
|
|
3503
3227
|
method: request.method,
|
|
3504
3228
|
pathname: new URL(request.url).pathname,
|
|
3505
|
-
routeId: _optionalChain([routeMatch, 'optionalAccess',
|
|
3229
|
+
routeId: _optionalChain([routeMatch, 'optionalAccess', _25 => _25.route, 'access', _26 => _26.id])
|
|
3506
3230
|
});
|
|
3507
3231
|
}
|
|
3508
3232
|
let dsMatches;
|
|
3509
3233
|
if (routeMatch) {
|
|
3510
3234
|
dsMatches = getTargetedDataStrategyMatches(
|
|
3511
|
-
|
|
3235
|
+
mapRouteProperties2,
|
|
3512
3236
|
manifest,
|
|
3513
3237
|
request,
|
|
3514
3238
|
matches,
|
|
@@ -3521,14 +3245,12 @@ function createStaticHandler(routes, opts) {
|
|
|
3521
3245
|
// Up to but not including the boundary
|
|
3522
3246
|
matches.findIndex((m) => m.route.id === pendingActionResult[0]) - 1
|
|
3523
3247
|
) : void 0;
|
|
3524
|
-
let pattern = getRoutePattern(matches.map((m) => m.route.path));
|
|
3525
3248
|
dsMatches = matches.map((match, index) => {
|
|
3526
3249
|
if (maxIdx != null && index > maxIdx) {
|
|
3527
3250
|
return getDataStrategyMatch(
|
|
3528
|
-
|
|
3251
|
+
mapRouteProperties2,
|
|
3529
3252
|
manifest,
|
|
3530
3253
|
request,
|
|
3531
|
-
pattern,
|
|
3532
3254
|
match,
|
|
3533
3255
|
[],
|
|
3534
3256
|
requestContext,
|
|
@@ -3536,10 +3258,9 @@ function createStaticHandler(routes, opts) {
|
|
|
3536
3258
|
);
|
|
3537
3259
|
}
|
|
3538
3260
|
return getDataStrategyMatch(
|
|
3539
|
-
|
|
3261
|
+
mapRouteProperties2,
|
|
3540
3262
|
manifest,
|
|
3541
3263
|
request,
|
|
3542
|
-
pattern,
|
|
3543
3264
|
match,
|
|
3544
3265
|
[],
|
|
3545
3266
|
requestContext,
|
|
@@ -3797,7 +3518,7 @@ function normalizeNavigateOptions(isFetcher, path, opts) {
|
|
|
3797
3518
|
parsedPath.search = `?${searchParams}`;
|
|
3798
3519
|
return { path: createPath(parsedPath), submission };
|
|
3799
3520
|
}
|
|
3800
|
-
function getMatchesToLoad(request, scopedContext,
|
|
3521
|
+
function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest, history, state, matches, submission, location, lazyRoutePropertiesToSkip, initialHydration, isRevalidationRequired, cancelledFetcherLoads, fetchersQueuedForDeletion, fetchLoadMatches, fetchRedirectIds, routesToUse, basename, hasPatchRoutesOnNavigation, pendingActionResult) {
|
|
3801
3522
|
let actionResult = pendingActionResult ? isErrorResult(pendingActionResult[1]) ? pendingActionResult[1].error : pendingActionResult[1].data : void 0;
|
|
3802
3523
|
let currentUrl = history.createURL(state.location);
|
|
3803
3524
|
let nextUrl = history.createURL(location);
|
|
@@ -3813,14 +3534,13 @@ function getMatchesToLoad(request, scopedContext, mapRouteProperties, manifest,
|
|
|
3813
3534
|
let shouldSkipRevalidation = actionStatus && actionStatus >= 400;
|
|
3814
3535
|
let baseShouldRevalidateArgs = {
|
|
3815
3536
|
currentUrl,
|
|
3816
|
-
currentParams: _optionalChain([state, 'access',
|
|
3537
|
+
currentParams: _optionalChain([state, 'access', _27 => _27.matches, 'access', _28 => _28[0], 'optionalAccess', _29 => _29.params]) || {},
|
|
3817
3538
|
nextUrl,
|
|
3818
3539
|
nextParams: matches[0].params,
|
|
3819
3540
|
...submission,
|
|
3820
3541
|
actionResult,
|
|
3821
3542
|
actionStatus
|
|
3822
3543
|
};
|
|
3823
|
-
let pattern = getRoutePattern(matches.map((m) => m.route.path));
|
|
3824
3544
|
let dsMatches = matches.map((match, index) => {
|
|
3825
3545
|
let { route } = match;
|
|
3826
3546
|
let forceShouldLoad = null;
|
|
@@ -3841,10 +3561,9 @@ function getMatchesToLoad(request, scopedContext, mapRouteProperties, manifest,
|
|
|
3841
3561
|
}
|
|
3842
3562
|
if (forceShouldLoad !== null) {
|
|
3843
3563
|
return getDataStrategyMatch(
|
|
3844
|
-
|
|
3564
|
+
mapRouteProperties2,
|
|
3845
3565
|
manifest,
|
|
3846
3566
|
request,
|
|
3847
|
-
pattern,
|
|
3848
3567
|
match,
|
|
3849
3568
|
lazyRoutePropertiesToSkip,
|
|
3850
3569
|
scopedContext,
|
|
@@ -3862,10 +3581,9 @@ function getMatchesToLoad(request, scopedContext, mapRouteProperties, manifest,
|
|
|
3862
3581
|
};
|
|
3863
3582
|
let shouldLoad = shouldRevalidateLoader(match, shouldRevalidateArgs);
|
|
3864
3583
|
return getDataStrategyMatch(
|
|
3865
|
-
|
|
3584
|
+
mapRouteProperties2,
|
|
3866
3585
|
manifest,
|
|
3867
3586
|
request,
|
|
3868
|
-
pattern,
|
|
3869
3587
|
match,
|
|
3870
3588
|
lazyRoutePropertiesToSkip,
|
|
3871
3589
|
scopedContext,
|
|
@@ -3910,7 +3628,7 @@ function getMatchesToLoad(request, scopedContext, mapRouteProperties, manifest,
|
|
|
3910
3628
|
if (cancelledFetcherLoads.has(key)) {
|
|
3911
3629
|
cancelledFetcherLoads.delete(key);
|
|
3912
3630
|
fetcherDsMatches = getTargetedDataStrategyMatches(
|
|
3913
|
-
|
|
3631
|
+
mapRouteProperties2,
|
|
3914
3632
|
manifest,
|
|
3915
3633
|
fetchRequest,
|
|
3916
3634
|
fetcherMatches,
|
|
@@ -3921,7 +3639,7 @@ function getMatchesToLoad(request, scopedContext, mapRouteProperties, manifest,
|
|
|
3921
3639
|
} else if (isMidInitialLoad) {
|
|
3922
3640
|
if (isRevalidationRequired) {
|
|
3923
3641
|
fetcherDsMatches = getTargetedDataStrategyMatches(
|
|
3924
|
-
|
|
3642
|
+
mapRouteProperties2,
|
|
3925
3643
|
manifest,
|
|
3926
3644
|
fetchRequest,
|
|
3927
3645
|
fetcherMatches,
|
|
@@ -3937,7 +3655,7 @@ function getMatchesToLoad(request, scopedContext, mapRouteProperties, manifest,
|
|
|
3937
3655
|
};
|
|
3938
3656
|
if (shouldRevalidateLoader(fetcherMatch, shouldRevalidateArgs)) {
|
|
3939
3657
|
fetcherDsMatches = getTargetedDataStrategyMatches(
|
|
3940
|
-
|
|
3658
|
+
mapRouteProperties2,
|
|
3941
3659
|
manifest,
|
|
3942
3660
|
fetchRequest,
|
|
3943
3661
|
fetcherMatches,
|
|
@@ -4009,7 +3727,7 @@ function shouldRevalidateLoader(loaderMatch, arg) {
|
|
|
4009
3727
|
}
|
|
4010
3728
|
return arg.defaultShouldRevalidate;
|
|
4011
3729
|
}
|
|
4012
|
-
function patchRoutesImpl(routeId, children, routesToUse, manifest,
|
|
3730
|
+
function patchRoutesImpl(routeId, children, routesToUse, manifest, mapRouteProperties2, allowElementMutations) {
|
|
4013
3731
|
let childrenToPatch;
|
|
4014
3732
|
if (routeId) {
|
|
4015
3733
|
let route = manifest[routeId];
|
|
@@ -4039,8 +3757,8 @@ function patchRoutesImpl(routeId, children, routesToUse, manifest, mapRoutePrope
|
|
|
4039
3757
|
if (uniqueChildren.length > 0) {
|
|
4040
3758
|
let newRoutes = convertRoutesToDataRoutes(
|
|
4041
3759
|
uniqueChildren,
|
|
4042
|
-
|
|
4043
|
-
[routeId || "_", "patch", String(_optionalChain([childrenToPatch, 'optionalAccess',
|
|
3760
|
+
mapRouteProperties2,
|
|
3761
|
+
[routeId || "_", "patch", String(_optionalChain([childrenToPatch, 'optionalAccess', _30 => _30.length]) || "0")],
|
|
4044
3762
|
manifest
|
|
4045
3763
|
);
|
|
4046
3764
|
childrenToPatch.push(...newRoutes);
|
|
@@ -4051,7 +3769,7 @@ function patchRoutesImpl(routeId, children, routesToUse, manifest, mapRoutePrope
|
|
|
4051
3769
|
let existingRouteTyped = existingRoute;
|
|
4052
3770
|
let [newRouteTyped] = convertRoutesToDataRoutes(
|
|
4053
3771
|
[newRoute],
|
|
4054
|
-
|
|
3772
|
+
mapRouteProperties2,
|
|
4055
3773
|
[],
|
|
4056
3774
|
// Doesn't matter for mutated routes since they already have an id
|
|
4057
3775
|
{},
|
|
@@ -4077,7 +3795,7 @@ function isSameRoute(newRoute, existingRoute) {
|
|
|
4077
3795
|
return true;
|
|
4078
3796
|
}
|
|
4079
3797
|
return newRoute.children.every(
|
|
4080
|
-
(aChild, i) => _optionalChain([existingRoute, 'access',
|
|
3798
|
+
(aChild, i) => _optionalChain([existingRoute, 'access', _31 => _31.children, 'optionalAccess', _32 => _32.some, 'call', _33 => _33((bChild) => isSameRoute(aChild, bChild))])
|
|
4081
3799
|
);
|
|
4082
3800
|
}
|
|
4083
3801
|
var lazyRoutePropertyCache = /* @__PURE__ */ new WeakMap();
|
|
@@ -4085,7 +3803,7 @@ var loadLazyRouteProperty = ({
|
|
|
4085
3803
|
key,
|
|
4086
3804
|
route,
|
|
4087
3805
|
manifest,
|
|
4088
|
-
mapRouteProperties
|
|
3806
|
+
mapRouteProperties: mapRouteProperties2
|
|
4089
3807
|
}) => {
|
|
4090
3808
|
let routeToUpdate = manifest[route.id];
|
|
4091
3809
|
invariant(routeToUpdate, "No route found in manifest");
|
|
@@ -4124,7 +3842,7 @@ var loadLazyRouteProperty = ({
|
|
|
4124
3842
|
let value = await lazyFn();
|
|
4125
3843
|
if (value != null) {
|
|
4126
3844
|
Object.assign(routeToUpdate, { [key]: value });
|
|
4127
|
-
Object.assign(routeToUpdate,
|
|
3845
|
+
Object.assign(routeToUpdate, mapRouteProperties2(routeToUpdate));
|
|
4128
3846
|
}
|
|
4129
3847
|
}
|
|
4130
3848
|
if (typeof routeToUpdate.lazy === "object") {
|
|
@@ -4138,7 +3856,7 @@ var loadLazyRouteProperty = ({
|
|
|
4138
3856
|
return propertyPromise;
|
|
4139
3857
|
};
|
|
4140
3858
|
var lazyRouteFunctionCache = /* @__PURE__ */ new WeakMap();
|
|
4141
|
-
function loadLazyRoute(route, type, manifest,
|
|
3859
|
+
function loadLazyRoute(route, type, manifest, mapRouteProperties2, lazyRoutePropertiesToSkip) {
|
|
4142
3860
|
let routeToUpdate = manifest[route.id];
|
|
4143
3861
|
invariant(routeToUpdate, "No route found in manifest");
|
|
4144
3862
|
if (!route.lazy) {
|
|
@@ -4191,7 +3909,7 @@ function loadLazyRoute(route, type, manifest, mapRouteProperties, lazyRoutePrope
|
|
|
4191
3909
|
// To keep things framework agnostic, we use the provided `mapRouteProperties`
|
|
4192
3910
|
// function to set the framework-aware properties (`element`/`hasErrorBoundary`)
|
|
4193
3911
|
// since the logic will differ between frameworks.
|
|
4194
|
-
...
|
|
3912
|
+
...mapRouteProperties2(routeToUpdate),
|
|
4195
3913
|
lazy: void 0
|
|
4196
3914
|
});
|
|
4197
3915
|
})();
|
|
@@ -4214,7 +3932,7 @@ function loadLazyRoute(route, type, manifest, mapRouteProperties, lazyRoutePrope
|
|
|
4214
3932
|
key,
|
|
4215
3933
|
route,
|
|
4216
3934
|
manifest,
|
|
4217
|
-
mapRouteProperties
|
|
3935
|
+
mapRouteProperties: mapRouteProperties2
|
|
4218
3936
|
});
|
|
4219
3937
|
if (promise) {
|
|
4220
3938
|
lazyPropertyPromises.push(promise);
|
|
@@ -4225,9 +3943,9 @@ function loadLazyRoute(route, type, manifest, mapRouteProperties, lazyRoutePrope
|
|
|
4225
3943
|
}
|
|
4226
3944
|
let lazyRoutePromise = lazyPropertyPromises.length > 0 ? Promise.all(lazyPropertyPromises).then(() => {
|
|
4227
3945
|
}) : void 0;
|
|
4228
|
-
_optionalChain([lazyRoutePromise, 'optionalAccess',
|
|
3946
|
+
_optionalChain([lazyRoutePromise, 'optionalAccess', _34 => _34.catch, 'call', _35 => _35(() => {
|
|
4229
3947
|
})]);
|
|
4230
|
-
_optionalChain([lazyHandlerPromise, 'optionalAccess',
|
|
3948
|
+
_optionalChain([lazyHandlerPromise, 'optionalAccess', _36 => _36.catch, 'call', _37 => _37(() => {
|
|
4231
3949
|
})]);
|
|
4232
3950
|
return {
|
|
4233
3951
|
lazyRoutePromise,
|
|
@@ -4237,7 +3955,7 @@ function loadLazyRoute(route, type, manifest, mapRouteProperties, lazyRoutePrope
|
|
|
4237
3955
|
function isNonNullable(value) {
|
|
4238
3956
|
return value !== void 0;
|
|
4239
3957
|
}
|
|
4240
|
-
function loadLazyMiddlewareForMatches(matches, manifest,
|
|
3958
|
+
function loadLazyMiddlewareForMatches(matches, manifest, mapRouteProperties2) {
|
|
4241
3959
|
let promises = matches.map(({ route }) => {
|
|
4242
3960
|
if (typeof route.lazy !== "object" || !route.lazy.middleware) {
|
|
4243
3961
|
return void 0;
|
|
@@ -4246,7 +3964,7 @@ function loadLazyMiddlewareForMatches(matches, manifest, mapRouteProperties) {
|
|
|
4246
3964
|
key: "middleware",
|
|
4247
3965
|
route,
|
|
4248
3966
|
manifest,
|
|
4249
|
-
mapRouteProperties
|
|
3967
|
+
mapRouteProperties: mapRouteProperties2
|
|
4250
3968
|
});
|
|
4251
3969
|
}).filter(isNonNullable);
|
|
4252
3970
|
return promises.length > 0 ? Promise.all(promises) : void 0;
|
|
@@ -4319,17 +4037,12 @@ function runClientMiddlewarePipeline(args, handler) {
|
|
|
4319
4037
|
}
|
|
4320
4038
|
}
|
|
4321
4039
|
async function runMiddlewarePipeline(args, handler, processResult, isResult, errorHandler) {
|
|
4322
|
-
let { matches, request, params, context
|
|
4040
|
+
let { matches, request, params, context } = args;
|
|
4323
4041
|
let tuples = matches.flatMap(
|
|
4324
4042
|
(m) => m.route.middleware ? m.route.middleware.map((fn) => [m.route.id, fn]) : []
|
|
4325
4043
|
);
|
|
4326
4044
|
let result = await callRouteMiddleware(
|
|
4327
|
-
{
|
|
4328
|
-
request,
|
|
4329
|
-
params,
|
|
4330
|
-
context,
|
|
4331
|
-
unstable_pattern
|
|
4332
|
-
},
|
|
4045
|
+
{ request, params, context },
|
|
4333
4046
|
tuples,
|
|
4334
4047
|
handler,
|
|
4335
4048
|
processResult,
|
|
@@ -4387,18 +4100,18 @@ async function callRouteMiddleware(args, middlewares, handler, processResult, is
|
|
|
4387
4100
|
return response;
|
|
4388
4101
|
}
|
|
4389
4102
|
}
|
|
4390
|
-
function getDataStrategyMatchLazyPromises(
|
|
4103
|
+
function getDataStrategyMatchLazyPromises(mapRouteProperties2, manifest, request, match, lazyRoutePropertiesToSkip) {
|
|
4391
4104
|
let lazyMiddlewarePromise = loadLazyRouteProperty({
|
|
4392
4105
|
key: "middleware",
|
|
4393
4106
|
route: match.route,
|
|
4394
4107
|
manifest,
|
|
4395
|
-
mapRouteProperties
|
|
4108
|
+
mapRouteProperties: mapRouteProperties2
|
|
4396
4109
|
});
|
|
4397
4110
|
let lazyRoutePromises = loadLazyRoute(
|
|
4398
4111
|
match.route,
|
|
4399
4112
|
isMutationMethod(request.method) ? "action" : "loader",
|
|
4400
4113
|
manifest,
|
|
4401
|
-
|
|
4114
|
+
mapRouteProperties2,
|
|
4402
4115
|
lazyRoutePropertiesToSkip
|
|
4403
4116
|
);
|
|
4404
4117
|
return {
|
|
@@ -4407,10 +4120,10 @@ function getDataStrategyMatchLazyPromises(mapRouteProperties, manifest, request,
|
|
|
4407
4120
|
handler: lazyRoutePromises.lazyHandlerPromise
|
|
4408
4121
|
};
|
|
4409
4122
|
}
|
|
4410
|
-
function getDataStrategyMatch(
|
|
4123
|
+
function getDataStrategyMatch(mapRouteProperties2, manifest, request, match, lazyRoutePropertiesToSkip, scopedContext, shouldLoad, unstable_shouldRevalidateArgs = null) {
|
|
4411
4124
|
let isUsingNewApi = false;
|
|
4412
4125
|
let _lazyPromises = getDataStrategyMatchLazyPromises(
|
|
4413
|
-
|
|
4126
|
+
mapRouteProperties2,
|
|
4414
4127
|
manifest,
|
|
4415
4128
|
request,
|
|
4416
4129
|
match,
|
|
@@ -4441,10 +4154,9 @@ function getDataStrategyMatch(mapRouteProperties, manifest, request, unstable_pa
|
|
|
4441
4154
|
if (callHandler && !isMiddlewareOnlyRoute) {
|
|
4442
4155
|
return callLoaderOrAction({
|
|
4443
4156
|
request,
|
|
4444
|
-
unstable_pattern,
|
|
4445
4157
|
match,
|
|
4446
|
-
lazyHandlerPromise: _optionalChain([_lazyPromises, 'optionalAccess',
|
|
4447
|
-
lazyRoutePromise: _optionalChain([_lazyPromises, 'optionalAccess',
|
|
4158
|
+
lazyHandlerPromise: _optionalChain([_lazyPromises, 'optionalAccess', _38 => _38.handler]),
|
|
4159
|
+
lazyRoutePromise: _optionalChain([_lazyPromises, 'optionalAccess', _39 => _39.route]),
|
|
4448
4160
|
handlerOverride,
|
|
4449
4161
|
scopedContext
|
|
4450
4162
|
});
|
|
@@ -4453,7 +4165,7 @@ function getDataStrategyMatch(mapRouteProperties, manifest, request, unstable_pa
|
|
|
4453
4165
|
}
|
|
4454
4166
|
};
|
|
4455
4167
|
}
|
|
4456
|
-
function getTargetedDataStrategyMatches(
|
|
4168
|
+
function getTargetedDataStrategyMatches(mapRouteProperties2, manifest, request, matches, targetMatch, lazyRoutePropertiesToSkip, scopedContext, shouldRevalidateArgs = null) {
|
|
4457
4169
|
return matches.map((match) => {
|
|
4458
4170
|
if (match.route.id !== targetMatch.route.id) {
|
|
4459
4171
|
return {
|
|
@@ -4462,7 +4174,7 @@ function getTargetedDataStrategyMatches(mapRouteProperties, manifest, request, m
|
|
|
4462
4174
|
unstable_shouldRevalidateArgs: shouldRevalidateArgs,
|
|
4463
4175
|
unstable_shouldCallHandler: () => false,
|
|
4464
4176
|
_lazyPromises: getDataStrategyMatchLazyPromises(
|
|
4465
|
-
|
|
4177
|
+
mapRouteProperties2,
|
|
4466
4178
|
manifest,
|
|
4467
4179
|
request,
|
|
4468
4180
|
match,
|
|
@@ -4472,10 +4184,9 @@ function getTargetedDataStrategyMatches(mapRouteProperties, manifest, request, m
|
|
|
4472
4184
|
};
|
|
4473
4185
|
}
|
|
4474
4186
|
return getDataStrategyMatch(
|
|
4475
|
-
|
|
4187
|
+
mapRouteProperties2,
|
|
4476
4188
|
manifest,
|
|
4477
4189
|
request,
|
|
4478
|
-
getRoutePattern(matches.map((m) => m.route.path)),
|
|
4479
4190
|
match,
|
|
4480
4191
|
lazyRoutePropertiesToSkip,
|
|
4481
4192
|
scopedContext,
|
|
@@ -4485,12 +4196,11 @@ function getTargetedDataStrategyMatches(mapRouteProperties, manifest, request, m
|
|
|
4485
4196
|
});
|
|
4486
4197
|
}
|
|
4487
4198
|
async function callDataStrategyImpl(dataStrategyImpl, request, matches, fetcherKey, scopedContext, isStaticHandler) {
|
|
4488
|
-
if (matches.some((m) => _optionalChain([m, 'access',
|
|
4489
|
-
await Promise.all(matches.map((m) => _optionalChain([m, 'access',
|
|
4199
|
+
if (matches.some((m) => _optionalChain([m, 'access', _40 => _40._lazyPromises, 'optionalAccess', _41 => _41.middleware]))) {
|
|
4200
|
+
await Promise.all(matches.map((m) => _optionalChain([m, 'access', _42 => _42._lazyPromises, 'optionalAccess', _43 => _43.middleware])));
|
|
4490
4201
|
}
|
|
4491
4202
|
let dataStrategyArgs = {
|
|
4492
4203
|
request,
|
|
4493
|
-
unstable_pattern: getRoutePattern(matches.map((m) => m.route.path)),
|
|
4494
4204
|
params: matches[0].params,
|
|
4495
4205
|
context: scopedContext,
|
|
4496
4206
|
matches
|
|
@@ -4521,8 +4231,8 @@ async function callDataStrategyImpl(dataStrategyImpl, request, matches, fetcherK
|
|
|
4521
4231
|
try {
|
|
4522
4232
|
await Promise.all(
|
|
4523
4233
|
matches.flatMap((m) => [
|
|
4524
|
-
_optionalChain([m, 'access',
|
|
4525
|
-
_optionalChain([m, 'access',
|
|
4234
|
+
_optionalChain([m, 'access', _44 => _44._lazyPromises, 'optionalAccess', _45 => _45.handler]),
|
|
4235
|
+
_optionalChain([m, 'access', _46 => _46._lazyPromises, 'optionalAccess', _47 => _47.route])
|
|
4526
4236
|
])
|
|
4527
4237
|
);
|
|
4528
4238
|
} catch (e) {
|
|
@@ -4531,7 +4241,6 @@ async function callDataStrategyImpl(dataStrategyImpl, request, matches, fetcherK
|
|
|
4531
4241
|
}
|
|
4532
4242
|
async function callLoaderOrAction({
|
|
4533
4243
|
request,
|
|
4534
|
-
unstable_pattern,
|
|
4535
4244
|
match,
|
|
4536
4245
|
lazyHandlerPromise,
|
|
4537
4246
|
lazyRoutePromise,
|
|
@@ -4558,7 +4267,6 @@ async function callLoaderOrAction({
|
|
|
4558
4267
|
return handler(
|
|
4559
4268
|
{
|
|
4560
4269
|
request,
|
|
4561
|
-
unstable_pattern,
|
|
4562
4270
|
params: match.params,
|
|
4563
4271
|
context: scopedContext
|
|
4564
4272
|
},
|
|
@@ -4667,19 +4375,19 @@ async function convertDataStrategyResultToDataResult(dataStrategyResult) {
|
|
|
4667
4375
|
return {
|
|
4668
4376
|
type: "error" /* error */,
|
|
4669
4377
|
error: result.data,
|
|
4670
|
-
statusCode: _optionalChain([result, 'access',
|
|
4671
|
-
headers: _optionalChain([result, 'access',
|
|
4378
|
+
statusCode: _optionalChain([result, 'access', _48 => _48.init, 'optionalAccess', _49 => _49.status]),
|
|
4379
|
+
headers: _optionalChain([result, 'access', _50 => _50.init, 'optionalAccess', _51 => _51.headers]) ? new Headers(result.init.headers) : void 0
|
|
4672
4380
|
};
|
|
4673
4381
|
}
|
|
4674
4382
|
return {
|
|
4675
4383
|
type: "error" /* error */,
|
|
4676
4384
|
error: new ErrorResponseImpl(
|
|
4677
|
-
_optionalChain([result, 'access',
|
|
4385
|
+
_optionalChain([result, 'access', _52 => _52.init, 'optionalAccess', _53 => _53.status]) || 500,
|
|
4678
4386
|
void 0,
|
|
4679
4387
|
result.data
|
|
4680
4388
|
),
|
|
4681
4389
|
statusCode: isRouteErrorResponse(result) ? result.status : void 0,
|
|
4682
|
-
headers: _optionalChain([result, 'access',
|
|
4390
|
+
headers: _optionalChain([result, 'access', _54 => _54.init, 'optionalAccess', _55 => _55.headers]) ? new Headers(result.init.headers) : void 0
|
|
4683
4391
|
};
|
|
4684
4392
|
}
|
|
4685
4393
|
return {
|
|
@@ -4692,8 +4400,8 @@ async function convertDataStrategyResultToDataResult(dataStrategyResult) {
|
|
|
4692
4400
|
return {
|
|
4693
4401
|
type: "data" /* data */,
|
|
4694
4402
|
data: result.data,
|
|
4695
|
-
statusCode: _optionalChain([result, 'access',
|
|
4696
|
-
headers: _optionalChain([result, 'access',
|
|
4403
|
+
statusCode: _optionalChain([result, 'access', _56 => _56.init, 'optionalAccess', _57 => _57.status]),
|
|
4404
|
+
headers: _optionalChain([result, 'access', _58 => _58.init, 'optionalAccess', _59 => _59.headers]) ? new Headers(result.init.headers) : void 0
|
|
4697
4405
|
};
|
|
4698
4406
|
}
|
|
4699
4407
|
return { type: "data" /* data */, data: result };
|
|
@@ -4842,7 +4550,7 @@ function processLoaderData(state, matches, results, pendingActionResult, revalid
|
|
|
4842
4550
|
let result = fetcherResults[key];
|
|
4843
4551
|
invariant(result, "Did not find corresponding fetcher result");
|
|
4844
4552
|
if (isErrorResult(result)) {
|
|
4845
|
-
let boundaryMatch = findNearestBoundary(state.matches, _optionalChain([match, 'optionalAccess',
|
|
4553
|
+
let boundaryMatch = findNearestBoundary(state.matches, _optionalChain([match, 'optionalAccess', _60 => _60.route, 'access', _61 => _61.id]));
|
|
4846
4554
|
if (!(errors && errors[boundaryMatch.route.id])) {
|
|
4847
4555
|
errors = {
|
|
4848
4556
|
...errors,
|
|
@@ -4976,8 +4684,8 @@ function dataWithResponseInitToResponse(data2) {
|
|
|
4976
4684
|
}
|
|
4977
4685
|
function dataWithResponseInitToErrorResponse(data2) {
|
|
4978
4686
|
return new ErrorResponseImpl(
|
|
4979
|
-
_nullishCoalesce(_optionalChain([data2, 'access',
|
|
4980
|
-
_nullishCoalesce(_optionalChain([data2, 'access',
|
|
4687
|
+
_nullishCoalesce(_optionalChain([data2, 'access', _62 => _62.init, 'optionalAccess', _63 => _63.status]), () => ( 500)),
|
|
4688
|
+
_nullishCoalesce(_optionalChain([data2, 'access', _64 => _64.init, 'optionalAccess', _65 => _65.statusText]), () => ( "Internal Server Error")),
|
|
4981
4689
|
data2.data
|
|
4982
4690
|
);
|
|
4983
4691
|
}
|
|
@@ -5218,7 +4926,7 @@ function createDeferred() {
|
|
|
5218
4926
|
}
|
|
5219
4927
|
|
|
5220
4928
|
// lib/dom/ssr/single-fetch.tsx
|
|
5221
|
-
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);
|
|
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); var React9 = _interopRequireWildcard(_react);
|
|
5222
4930
|
|
|
5223
4931
|
// vendor/turbo-stream-v2/utils.ts
|
|
5224
4932
|
var HOLE = -1;
|
|
@@ -6009,7 +5717,7 @@ function getTurboStreamSingleFetchDataStrategy(getRouter, manifest, routeModules
|
|
|
6009
5717
|
return {
|
|
6010
5718
|
hasLoader: manifestRoute.hasLoader,
|
|
6011
5719
|
hasClientLoader: manifestRoute.hasClientLoader,
|
|
6012
|
-
hasShouldRevalidate: Boolean(_optionalChain([routeModule, 'optionalAccess',
|
|
5720
|
+
hasShouldRevalidate: Boolean(_optionalChain([routeModule, 'optionalAccess', _66 => _66.shouldRevalidate]))
|
|
6013
5721
|
};
|
|
6014
5722
|
},
|
|
6015
5723
|
fetchAndDecodeViaTurboStream,
|
|
@@ -6176,7 +5884,7 @@ async function bubbleMiddlewareErrors(singleFetchPromise, matches, routesParams,
|
|
|
6176
5884
|
let routeResult = fetchedData.routes[match.route.id];
|
|
6177
5885
|
if ("error" in routeResult) {
|
|
6178
5886
|
middlewareError = routeResult.error;
|
|
6179
|
-
if (_optionalChain([results, 'access',
|
|
5887
|
+
if (_optionalChain([results, 'access', _67 => _67[match.route.id], 'optionalAccess', _68 => _68.result]) == null) {
|
|
6180
5888
|
results[match.route.id] = {
|
|
6181
5889
|
type: "error",
|
|
6182
5890
|
result: middlewareError
|
|
@@ -6289,7 +5997,7 @@ async function fetchAndDecodeViaTurboStream(args, basename, targetRoutes) {
|
|
|
6289
5997
|
}
|
|
6290
5998
|
} else {
|
|
6291
5999
|
let typed = decoded.value;
|
|
6292
|
-
let routeId = _optionalChain([targetRoutes, 'optionalAccess',
|
|
6000
|
+
let routeId = _optionalChain([targetRoutes, 'optionalAccess', _69 => _69[0]]);
|
|
6293
6001
|
invariant2(routeId, "No routeId found for single fetch call decoding");
|
|
6294
6002
|
if ("redirect" in typed) {
|
|
6295
6003
|
data2 = { redirect: typed };
|
|
@@ -6601,7 +6309,7 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
|
|
|
6601
6309
|
if (locationArg) {
|
|
6602
6310
|
let parsedLocationArg = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
|
|
6603
6311
|
invariant(
|
|
6604
|
-
parentPathnameBase === "/" || _optionalChain([parsedLocationArg, 'access',
|
|
6312
|
+
parentPathnameBase === "/" || _optionalChain([parsedLocationArg, 'access', _70 => _70.pathname, 'optionalAccess', _71 => _71.startsWith, 'call', _72 => _72(parentPathnameBase)]),
|
|
6605
6313
|
`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.`
|
|
6606
6314
|
);
|
|
6607
6315
|
location = parsedLocationArg;
|
|
@@ -6763,10 +6471,10 @@ function _renderMatches(matches, parentMatches = [], dataRouterState = null, uns
|
|
|
6763
6471
|
}
|
|
6764
6472
|
}
|
|
6765
6473
|
let renderedMatches = matches;
|
|
6766
|
-
let errors = _optionalChain([dataRouterState, 'optionalAccess',
|
|
6474
|
+
let errors = _optionalChain([dataRouterState, 'optionalAccess', _73 => _73.errors]);
|
|
6767
6475
|
if (errors != null) {
|
|
6768
6476
|
let errorIndex = renderedMatches.findIndex(
|
|
6769
|
-
(m) => m.route.id && _optionalChain([errors, 'optionalAccess',
|
|
6477
|
+
(m) => m.route.id && _optionalChain([errors, 'optionalAccess', _74 => _74[m.route.id]]) !== void 0
|
|
6770
6478
|
);
|
|
6771
6479
|
invariant(
|
|
6772
6480
|
errorIndex >= 0,
|
|
@@ -6944,15 +6652,15 @@ function useRouteError() {
|
|
|
6944
6652
|
if (error !== void 0) {
|
|
6945
6653
|
return error;
|
|
6946
6654
|
}
|
|
6947
|
-
return _optionalChain([state, 'access',
|
|
6655
|
+
return _optionalChain([state, 'access', _75 => _75.errors, 'optionalAccess', _76 => _76[routeId]]);
|
|
6948
6656
|
}
|
|
6949
6657
|
function useAsyncValue() {
|
|
6950
6658
|
let value = React3.useContext(AwaitContext);
|
|
6951
|
-
return _optionalChain([value, 'optionalAccess',
|
|
6659
|
+
return _optionalChain([value, 'optionalAccess', _77 => _77._data]);
|
|
6952
6660
|
}
|
|
6953
6661
|
function useAsyncError() {
|
|
6954
6662
|
let value = React3.useContext(AwaitContext);
|
|
6955
|
-
return _optionalChain([value, 'optionalAccess',
|
|
6663
|
+
return _optionalChain([value, 'optionalAccess', _78 => _78._error]);
|
|
6956
6664
|
}
|
|
6957
6665
|
var blockerId = 0;
|
|
6958
6666
|
function useBlocker(shouldBlock) {
|
|
@@ -7022,6 +6730,20 @@ function warningOnce(key, cond, message) {
|
|
|
7022
6730
|
warning(false, message);
|
|
7023
6731
|
}
|
|
7024
6732
|
}
|
|
6733
|
+
function useRoute(...args) {
|
|
6734
|
+
const currentRouteId = useCurrentRouteId(
|
|
6735
|
+
"useRoute" /* UseRoute */
|
|
6736
|
+
);
|
|
6737
|
+
const id = _nullishCoalesce(args[0], () => ( currentRouteId));
|
|
6738
|
+
const state = useDataRouterState("useRoute" /* UseRoute */);
|
|
6739
|
+
const route = state.matches.find(({ route: route2 }) => route2.id === id);
|
|
6740
|
+
if (route === void 0) return void 0;
|
|
6741
|
+
return {
|
|
6742
|
+
handle: route.route.handle,
|
|
6743
|
+
loaderData: state.loaderData[id],
|
|
6744
|
+
actionData: _optionalChain([state, 'access', _79 => _79.actionData, 'optionalAccess', _80 => _80[id]])
|
|
6745
|
+
};
|
|
6746
|
+
}
|
|
7025
6747
|
|
|
7026
6748
|
// lib/dom/ssr/errorBoundaries.tsx
|
|
7027
6749
|
|
|
@@ -7064,7 +6786,7 @@ function getKeyedLinksForMatches(matches, routeModules, manifest) {
|
|
|
7064
6786
|
let route = manifest.routes[match.route.id];
|
|
7065
6787
|
return [
|
|
7066
6788
|
route && route.css ? route.css.map((href) => ({ rel: "stylesheet", href })) : [],
|
|
7067
|
-
_optionalChain([module, 'optionalAccess',
|
|
6789
|
+
_optionalChain([module, 'optionalAccess', _81 => _81.links, 'optionalCall', _82 => _82()]) || []
|
|
7068
6790
|
];
|
|
7069
6791
|
}).flat(2);
|
|
7070
6792
|
let preloads = getModuleLinkHrefs(matches, manifest);
|
|
@@ -7165,7 +6887,7 @@ function getNewMatchesForLinks(page, nextMatches, currentMatches, manifest, loca
|
|
|
7165
6887
|
// param change, /users/123 -> /users/456
|
|
7166
6888
|
currentMatches[index].pathname !== match.pathname || // splat param changed, which is not present in match.path
|
|
7167
6889
|
// e.g. /files/images/avatar.jpg -> files/finances.xls
|
|
7168
|
-
_optionalChain([currentMatches, 'access',
|
|
6890
|
+
_optionalChain([currentMatches, 'access', _83 => _83[index], 'access', _84 => _84.route, 'access', _85 => _85.path, 'optionalAccess', _86 => _86.endsWith, 'call', _87 => _87("*")]) && currentMatches[index].params["*"] !== match.params["*"]
|
|
7169
6891
|
);
|
|
7170
6892
|
};
|
|
7171
6893
|
if (mode === "assets") {
|
|
@@ -7188,7 +6910,7 @@ function getNewMatchesForLinks(page, nextMatches, currentMatches, manifest, loca
|
|
|
7188
6910
|
location.pathname + location.search + location.hash,
|
|
7189
6911
|
window.origin
|
|
7190
6912
|
),
|
|
7191
|
-
currentParams: _optionalChain([currentMatches, 'access',
|
|
6913
|
+
currentParams: _optionalChain([currentMatches, 'access', _88 => _88[0], 'optionalAccess', _89 => _89.params]) || {},
|
|
7192
6914
|
nextUrl: new URL(page, window.origin),
|
|
7193
6915
|
nextParams: match.params,
|
|
7194
6916
|
defaultShouldRevalidate: true
|
|
@@ -7312,14 +7034,14 @@ function groupRoutesByParentId(manifest) {
|
|
|
7312
7034
|
return routes;
|
|
7313
7035
|
}
|
|
7314
7036
|
function getRouteComponents(route, routeModule, isSpaMode) {
|
|
7315
|
-
let
|
|
7037
|
+
let Component4 = getRouteModuleComponent(routeModule);
|
|
7316
7038
|
let HydrateFallback = routeModule.HydrateFallback && (!isSpaMode || route.id === "root") ? routeModule.HydrateFallback : route.id === "root" ? RemixRootDefaultHydrateFallback : void 0;
|
|
7317
7039
|
let ErrorBoundary = routeModule.ErrorBoundary ? routeModule.ErrorBoundary : route.id === "root" ? () => /* @__PURE__ */ React5.createElement(RemixRootDefaultErrorBoundary, { error: useRouteError() }) : void 0;
|
|
7318
7040
|
if (route.id === "root" && routeModule.Layout) {
|
|
7319
7041
|
return {
|
|
7320
|
-
...
|
|
7321
|
-
element: /* @__PURE__ */ React5.createElement(routeModule.Layout, null, /* @__PURE__ */ React5.createElement(
|
|
7322
|
-
} : { Component:
|
|
7042
|
+
...Component4 ? {
|
|
7043
|
+
element: /* @__PURE__ */ React5.createElement(routeModule.Layout, null, /* @__PURE__ */ React5.createElement(Component4, null))
|
|
7044
|
+
} : { Component: Component4 },
|
|
7323
7045
|
...ErrorBoundary ? {
|
|
7324
7046
|
errorElement: /* @__PURE__ */ React5.createElement(routeModule.Layout, null, /* @__PURE__ */ React5.createElement(ErrorBoundary, null))
|
|
7325
7047
|
} : { ErrorBoundary },
|
|
@@ -7328,7 +7050,7 @@ function getRouteComponents(route, routeModule, isSpaMode) {
|
|
|
7328
7050
|
} : { HydrateFallback }
|
|
7329
7051
|
};
|
|
7330
7052
|
}
|
|
7331
|
-
return { Component:
|
|
7053
|
+
return { Component: Component4, ErrorBoundary, HydrateFallback };
|
|
7332
7054
|
}
|
|
7333
7055
|
function createServerRoutes(manifest, routeModules, future, isSpaMode, parentId = "", routesByParentId = groupRoutesByParentId(manifest), spaModeLazyPromise = Promise.resolve({ Component: () => null })) {
|
|
7334
7056
|
return (routesByParentId[parentId] || []).map((route) => {
|
|
@@ -7460,11 +7182,11 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
7460
7182
|
)
|
|
7461
7183
|
});
|
|
7462
7184
|
let hasInitialData = initialState && initialState.loaderData && route.id in initialState.loaderData;
|
|
7463
|
-
let initialData = hasInitialData ? _optionalChain([initialState, 'optionalAccess',
|
|
7185
|
+
let initialData = hasInitialData ? _optionalChain([initialState, 'optionalAccess', _90 => _90.loaderData, 'optionalAccess', _91 => _91[route.id]]) : void 0;
|
|
7464
7186
|
let hasInitialError = initialState && initialState.errors && route.id in initialState.errors;
|
|
7465
|
-
let initialError = hasInitialError ? _optionalChain([initialState, 'optionalAccess',
|
|
7466
|
-
let isHydrationRequest = needsRevalidation == null && (_optionalChain([routeModule, 'access',
|
|
7467
|
-
dataRoute.loader = async ({ request, params, context
|
|
7187
|
+
let initialError = hasInitialError ? _optionalChain([initialState, 'optionalAccess', _92 => _92.errors, 'optionalAccess', _93 => _93[route.id]]) : void 0;
|
|
7188
|
+
let isHydrationRequest = needsRevalidation == null && (_optionalChain([routeModule, 'access', _94 => _94.clientLoader, 'optionalAccess', _95 => _95.hydrate]) === true || !route.hasLoader);
|
|
7189
|
+
dataRoute.loader = async ({ request, params, context }, singleFetch) => {
|
|
7468
7190
|
try {
|
|
7469
7191
|
let result = await prefetchStylesAndCallHandler(async () => {
|
|
7470
7192
|
invariant2(
|
|
@@ -7478,7 +7200,6 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
7478
7200
|
request,
|
|
7479
7201
|
params,
|
|
7480
7202
|
context,
|
|
7481
|
-
unstable_pattern,
|
|
7482
7203
|
async serverLoader() {
|
|
7483
7204
|
preventInvalidServerHandlerCall("loader", route);
|
|
7484
7205
|
if (isHydrationRequest) {
|
|
@@ -7504,7 +7225,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
7504
7225
|
route.hasLoader,
|
|
7505
7226
|
isSpaMode
|
|
7506
7227
|
);
|
|
7507
|
-
dataRoute.action = ({ request, params, context
|
|
7228
|
+
dataRoute.action = ({ request, params, context }, singleFetch) => {
|
|
7508
7229
|
return prefetchStylesAndCallHandler(async () => {
|
|
7509
7230
|
invariant2(
|
|
7510
7231
|
routeModule,
|
|
@@ -7520,7 +7241,6 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
7520
7241
|
request,
|
|
7521
7242
|
params,
|
|
7522
7243
|
context,
|
|
7523
|
-
unstable_pattern,
|
|
7524
7244
|
async serverAction() {
|
|
7525
7245
|
preventInvalidServerHandlerCall("action", route);
|
|
7526
7246
|
return fetchServerAction(singleFetch);
|
|
@@ -7759,7 +7479,7 @@ function getPatchRoutesOnNavigationFunction(manifest, routeModules, ssr, routeDi
|
|
|
7759
7479
|
function useFogOFWarDiscovery(router, manifest, routeModules, ssr, routeDiscovery, isSpaMode) {
|
|
7760
7480
|
React6.useEffect(() => {
|
|
7761
7481
|
if (!isFogOfWarEnabled(routeDiscovery, ssr) || // @ts-expect-error - TS doesn't know about this yet
|
|
7762
|
-
_optionalChain([window, 'access',
|
|
7482
|
+
_optionalChain([window, 'access', _96 => _96.navigator, 'optionalAccess', _97 => _97.connection, 'optionalAccess', _98 => _98.saveData]) === true) {
|
|
7763
7483
|
return;
|
|
7764
7484
|
}
|
|
7765
7485
|
function registerElement(el) {
|
|
@@ -7868,7 +7588,7 @@ async function fetchAndApplyManifestPatches(paths, errorReloadPath, manifest, ro
|
|
|
7868
7588
|
}
|
|
7869
7589
|
serverPatches = await res.json();
|
|
7870
7590
|
} catch (e) {
|
|
7871
|
-
if (_optionalChain([signal, 'optionalAccess',
|
|
7591
|
+
if (_optionalChain([signal, 'optionalAccess', _99 => _99.aborted])) return;
|
|
7872
7592
|
throw e;
|
|
7873
7593
|
}
|
|
7874
7594
|
let knownRoutes = new Set(Object.keys(manifest.routes));
|
|
@@ -8109,7 +7829,7 @@ function PrefetchPageLinksImpl({
|
|
|
8109
7829
|
if (!manifestRoute || !manifestRoute.hasLoader) {
|
|
8110
7830
|
return;
|
|
8111
7831
|
}
|
|
8112
|
-
if (!newMatchesForData.some((m2) => m2.route.id === m.route.id) && m.route.id in loaderData && _optionalChain([routeModules, 'access',
|
|
7832
|
+
if (!newMatchesForData.some((m2) => m2.route.id === m.route.id) && m.route.id in loaderData && _optionalChain([routeModules, 'access', _100 => _100[m.route.id], 'optionalAccess', _101 => _101.shouldRevalidate])) {
|
|
8113
7833
|
foundOptOutRoute = true;
|
|
8114
7834
|
} else if (manifestRoute.hasClientLoader) {
|
|
8115
7835
|
foundOptOutRoute = true;
|
|
@@ -8183,7 +7903,7 @@ function Meta() {
|
|
|
8183
7903
|
error
|
|
8184
7904
|
};
|
|
8185
7905
|
matches[i] = match;
|
|
8186
|
-
if (_optionalChain([routeModule, 'optionalAccess',
|
|
7906
|
+
if (_optionalChain([routeModule, 'optionalAccess', _102 => _102.meta])) {
|
|
8187
7907
|
routeMeta = typeof routeModule.meta === "function" ? routeModule.meta({
|
|
8188
7908
|
data: data2,
|
|
8189
7909
|
loaderData: data2,
|
|
@@ -8282,7 +8002,7 @@ function Scripts(scriptProps) {
|
|
|
8282
8002
|
}
|
|
8283
8003
|
let streamScript = "window.__reactRouterContext.stream = new ReadableStream({start(controller){window.__reactRouterContext.streamController = controller;}}).pipeThrough(new TextEncoderStream());";
|
|
8284
8004
|
let contextScript = staticContext ? `window.__reactRouterContext = ${serverHandoffString};${streamScript}` : " ";
|
|
8285
|
-
let routeModulesScript = !isStatic ? " " : `${_optionalChain([manifest, 'access',
|
|
8005
|
+
let routeModulesScript = !isStatic ? " " : `${_optionalChain([manifest, 'access', _103 => _103.hmr, 'optionalAccess', _104 => _104.runtime]) ? `import ${JSON.stringify(manifest.hmr.runtime)};` : ""}${!enableFogOfWar ? `import ${JSON.stringify(manifest.url)}` : ""};
|
|
8286
8006
|
${matches.map((match, routeIndex) => {
|
|
8287
8007
|
let routeVarName = `route${routeIndex}`;
|
|
8288
8008
|
let manifestEntry = manifest.routes[match.route.id];
|
|
@@ -8512,7 +8232,7 @@ function BoundaryShell({
|
|
|
8512
8232
|
children
|
|
8513
8233
|
}) {
|
|
8514
8234
|
let { routeModules } = useFrameworkContext();
|
|
8515
|
-
if (_optionalChain([routeModules, 'access',
|
|
8235
|
+
if (_optionalChain([routeModules, 'access', _105 => _105.root, 'optionalAccess', _106 => _106.Layout]) && !isOutsideRemixApp) {
|
|
8516
8236
|
return children;
|
|
8517
8237
|
}
|
|
8518
8238
|
return /* @__PURE__ */ React8.createElement("html", { lang: "en" }, /* @__PURE__ */ React8.createElement("head", null, /* @__PURE__ */ React8.createElement("meta", { charSet: "utf-8" }), /* @__PURE__ */ React8.createElement(
|
|
@@ -8524,6 +8244,769 @@ function BoundaryShell({
|
|
|
8524
8244
|
), /* @__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)));
|
|
8525
8245
|
}
|
|
8526
8246
|
|
|
8247
|
+
// lib/components.tsx
|
|
8248
|
+
|
|
8249
|
+
function mapRouteProperties(route) {
|
|
8250
|
+
let updates = {
|
|
8251
|
+
// Note: this check also occurs in createRoutesFromChildren so update
|
|
8252
|
+
// there if you change this -- please and thank you!
|
|
8253
|
+
hasErrorBoundary: route.hasErrorBoundary || route.ErrorBoundary != null || route.errorElement != null
|
|
8254
|
+
};
|
|
8255
|
+
if (route.Component) {
|
|
8256
|
+
if (ENABLE_DEV_WARNINGS) {
|
|
8257
|
+
if (route.element) {
|
|
8258
|
+
warning(
|
|
8259
|
+
false,
|
|
8260
|
+
"You should not include both `Component` and `element` on your route - `Component` will be used."
|
|
8261
|
+
);
|
|
8262
|
+
}
|
|
8263
|
+
}
|
|
8264
|
+
Object.assign(updates, {
|
|
8265
|
+
element: React9.createElement(route.Component),
|
|
8266
|
+
Component: void 0
|
|
8267
|
+
});
|
|
8268
|
+
}
|
|
8269
|
+
if (route.HydrateFallback) {
|
|
8270
|
+
if (ENABLE_DEV_WARNINGS) {
|
|
8271
|
+
if (route.hydrateFallbackElement) {
|
|
8272
|
+
warning(
|
|
8273
|
+
false,
|
|
8274
|
+
"You should not include both `HydrateFallback` and `hydrateFallbackElement` on your route - `HydrateFallback` will be used."
|
|
8275
|
+
);
|
|
8276
|
+
}
|
|
8277
|
+
}
|
|
8278
|
+
Object.assign(updates, {
|
|
8279
|
+
hydrateFallbackElement: React9.createElement(route.HydrateFallback),
|
|
8280
|
+
HydrateFallback: void 0
|
|
8281
|
+
});
|
|
8282
|
+
}
|
|
8283
|
+
if (route.ErrorBoundary) {
|
|
8284
|
+
if (ENABLE_DEV_WARNINGS) {
|
|
8285
|
+
if (route.errorElement) {
|
|
8286
|
+
warning(
|
|
8287
|
+
false,
|
|
8288
|
+
"You should not include both `ErrorBoundary` and `errorElement` on your route - `ErrorBoundary` will be used."
|
|
8289
|
+
);
|
|
8290
|
+
}
|
|
8291
|
+
}
|
|
8292
|
+
Object.assign(updates, {
|
|
8293
|
+
errorElement: React9.createElement(route.ErrorBoundary),
|
|
8294
|
+
ErrorBoundary: void 0
|
|
8295
|
+
});
|
|
8296
|
+
}
|
|
8297
|
+
return updates;
|
|
8298
|
+
}
|
|
8299
|
+
var hydrationRouteProperties = [
|
|
8300
|
+
"HydrateFallback",
|
|
8301
|
+
"hydrateFallbackElement"
|
|
8302
|
+
];
|
|
8303
|
+
function createMemoryRouter(routes, opts) {
|
|
8304
|
+
return createRouter({
|
|
8305
|
+
basename: _optionalChain([opts, 'optionalAccess', _107 => _107.basename]),
|
|
8306
|
+
getContext: _optionalChain([opts, 'optionalAccess', _108 => _108.getContext]),
|
|
8307
|
+
future: _optionalChain([opts, 'optionalAccess', _109 => _109.future]),
|
|
8308
|
+
history: createMemoryHistory({
|
|
8309
|
+
initialEntries: _optionalChain([opts, 'optionalAccess', _110 => _110.initialEntries]),
|
|
8310
|
+
initialIndex: _optionalChain([opts, 'optionalAccess', _111 => _111.initialIndex])
|
|
8311
|
+
}),
|
|
8312
|
+
hydrationData: _optionalChain([opts, 'optionalAccess', _112 => _112.hydrationData]),
|
|
8313
|
+
routes,
|
|
8314
|
+
hydrationRouteProperties,
|
|
8315
|
+
mapRouteProperties,
|
|
8316
|
+
dataStrategy: _optionalChain([opts, 'optionalAccess', _113 => _113.dataStrategy]),
|
|
8317
|
+
patchRoutesOnNavigation: _optionalChain([opts, 'optionalAccess', _114 => _114.patchRoutesOnNavigation])
|
|
8318
|
+
}).initialize();
|
|
8319
|
+
}
|
|
8320
|
+
var Deferred2 = class {
|
|
8321
|
+
constructor() {
|
|
8322
|
+
this.status = "pending";
|
|
8323
|
+
this.promise = new Promise((resolve, reject) => {
|
|
8324
|
+
this.resolve = (value) => {
|
|
8325
|
+
if (this.status === "pending") {
|
|
8326
|
+
this.status = "resolved";
|
|
8327
|
+
resolve(value);
|
|
8328
|
+
}
|
|
8329
|
+
};
|
|
8330
|
+
this.reject = (reason) => {
|
|
8331
|
+
if (this.status === "pending") {
|
|
8332
|
+
this.status = "rejected";
|
|
8333
|
+
reject(reason);
|
|
8334
|
+
}
|
|
8335
|
+
};
|
|
8336
|
+
});
|
|
8337
|
+
}
|
|
8338
|
+
};
|
|
8339
|
+
function shallowDiff(a, b) {
|
|
8340
|
+
if (a === b) {
|
|
8341
|
+
return false;
|
|
8342
|
+
}
|
|
8343
|
+
let aKeys = Object.keys(a);
|
|
8344
|
+
let bKeys = Object.keys(b);
|
|
8345
|
+
if (aKeys.length !== bKeys.length) {
|
|
8346
|
+
return true;
|
|
8347
|
+
}
|
|
8348
|
+
for (let key of aKeys) {
|
|
8349
|
+
if (a[key] !== b[key]) {
|
|
8350
|
+
return true;
|
|
8351
|
+
}
|
|
8352
|
+
}
|
|
8353
|
+
return false;
|
|
8354
|
+
}
|
|
8355
|
+
function UNSTABLE_TransitionEnabledRouterProvider({
|
|
8356
|
+
router,
|
|
8357
|
+
flushSync: reactDomFlushSyncImpl,
|
|
8358
|
+
unstable_onError
|
|
8359
|
+
}) {
|
|
8360
|
+
let fetcherData = React9.useRef(/* @__PURE__ */ new Map());
|
|
8361
|
+
let [revalidating, startRevalidation] = React9.useTransition();
|
|
8362
|
+
let [state, setState] = React9.useState(router.state);
|
|
8363
|
+
router.__setPendingRerender = (promise) => startRevalidation(
|
|
8364
|
+
// @ts-expect-error - need react 19 types for this to be async
|
|
8365
|
+
async () => {
|
|
8366
|
+
const rerender = await promise;
|
|
8367
|
+
startRevalidation(() => {
|
|
8368
|
+
rerender();
|
|
8369
|
+
});
|
|
8370
|
+
}
|
|
8371
|
+
);
|
|
8372
|
+
let navigator = React9.useMemo(() => {
|
|
8373
|
+
return {
|
|
8374
|
+
createHref: router.createHref,
|
|
8375
|
+
encodeLocation: router.encodeLocation,
|
|
8376
|
+
go: (n) => router.navigate(n),
|
|
8377
|
+
push: (to, state2, opts) => router.navigate(to, {
|
|
8378
|
+
state: state2,
|
|
8379
|
+
preventScrollReset: _optionalChain([opts, 'optionalAccess', _115 => _115.preventScrollReset])
|
|
8380
|
+
}),
|
|
8381
|
+
replace: (to, state2, opts) => router.navigate(to, {
|
|
8382
|
+
replace: true,
|
|
8383
|
+
state: state2,
|
|
8384
|
+
preventScrollReset: _optionalChain([opts, 'optionalAccess', _116 => _116.preventScrollReset])
|
|
8385
|
+
})
|
|
8386
|
+
};
|
|
8387
|
+
}, [router]);
|
|
8388
|
+
let basename = router.basename || "/";
|
|
8389
|
+
let dataRouterContext = React9.useMemo(
|
|
8390
|
+
() => ({
|
|
8391
|
+
router,
|
|
8392
|
+
navigator,
|
|
8393
|
+
static: false,
|
|
8394
|
+
basename,
|
|
8395
|
+
unstable_onError
|
|
8396
|
+
}),
|
|
8397
|
+
[router, navigator, basename, unstable_onError]
|
|
8398
|
+
);
|
|
8399
|
+
React9.useLayoutEffect(() => {
|
|
8400
|
+
return router.subscribe(
|
|
8401
|
+
(newState, { deletedFetchers, flushSync, viewTransitionOpts }) => {
|
|
8402
|
+
newState.fetchers.forEach((fetcher, key) => {
|
|
8403
|
+
if (fetcher.data !== void 0) {
|
|
8404
|
+
fetcherData.current.set(key, fetcher.data);
|
|
8405
|
+
}
|
|
8406
|
+
});
|
|
8407
|
+
deletedFetchers.forEach((key) => fetcherData.current.delete(key));
|
|
8408
|
+
const diff = shallowDiff(state, newState);
|
|
8409
|
+
if (!diff) return;
|
|
8410
|
+
if (flushSync) {
|
|
8411
|
+
if (reactDomFlushSyncImpl) {
|
|
8412
|
+
reactDomFlushSyncImpl(() => setState(newState));
|
|
8413
|
+
} else {
|
|
8414
|
+
setState(newState);
|
|
8415
|
+
}
|
|
8416
|
+
} else {
|
|
8417
|
+
React9.startTransition(() => {
|
|
8418
|
+
setState(newState);
|
|
8419
|
+
});
|
|
8420
|
+
}
|
|
8421
|
+
}
|
|
8422
|
+
);
|
|
8423
|
+
}, [router, reactDomFlushSyncImpl, state]);
|
|
8424
|
+
return /* @__PURE__ */ React9.createElement(React9.Fragment, null, /* @__PURE__ */ React9.createElement(DataRouterContext.Provider, { value: dataRouterContext }, /* @__PURE__ */ React9.createElement(
|
|
8425
|
+
DataRouterStateContext.Provider,
|
|
8426
|
+
{
|
|
8427
|
+
value: {
|
|
8428
|
+
...state,
|
|
8429
|
+
revalidation: revalidating ? "loading" : state.revalidation
|
|
8430
|
+
}
|
|
8431
|
+
},
|
|
8432
|
+
/* @__PURE__ */ React9.createElement(FetchersContext.Provider, { value: fetcherData.current }, /* @__PURE__ */ React9.createElement(
|
|
8433
|
+
Router,
|
|
8434
|
+
{
|
|
8435
|
+
basename,
|
|
8436
|
+
location: state.location,
|
|
8437
|
+
navigationType: state.historyAction,
|
|
8438
|
+
navigator
|
|
8439
|
+
},
|
|
8440
|
+
/* @__PURE__ */ React9.createElement(
|
|
8441
|
+
MemoizedDataRoutes,
|
|
8442
|
+
{
|
|
8443
|
+
routes: router.routes,
|
|
8444
|
+
future: router.future,
|
|
8445
|
+
state,
|
|
8446
|
+
unstable_onError
|
|
8447
|
+
}
|
|
8448
|
+
)
|
|
8449
|
+
))
|
|
8450
|
+
)), null);
|
|
8451
|
+
}
|
|
8452
|
+
function RouterProvider({
|
|
8453
|
+
router,
|
|
8454
|
+
flushSync: reactDomFlushSyncImpl,
|
|
8455
|
+
unstable_onError
|
|
8456
|
+
}) {
|
|
8457
|
+
let [state, setStateImpl] = React9.useState(router.state);
|
|
8458
|
+
let [pendingState, setPendingState] = React9.useState();
|
|
8459
|
+
let [vtContext, setVtContext] = React9.useState({
|
|
8460
|
+
isTransitioning: false
|
|
8461
|
+
});
|
|
8462
|
+
let [renderDfd, setRenderDfd] = React9.useState();
|
|
8463
|
+
let [transition, setTransition] = React9.useState();
|
|
8464
|
+
let [interruption, setInterruption] = React9.useState();
|
|
8465
|
+
let fetcherData = React9.useRef(/* @__PURE__ */ new Map());
|
|
8466
|
+
let logErrorsAndSetState = React9.useCallback(
|
|
8467
|
+
(newState) => {
|
|
8468
|
+
setStateImpl((prevState) => {
|
|
8469
|
+
if (newState.errors && unstable_onError) {
|
|
8470
|
+
Object.entries(newState.errors).forEach(([routeId, error]) => {
|
|
8471
|
+
if (_optionalChain([prevState, 'access', _117 => _117.errors, 'optionalAccess', _118 => _118[routeId]]) !== error) {
|
|
8472
|
+
unstable_onError(error);
|
|
8473
|
+
}
|
|
8474
|
+
});
|
|
8475
|
+
}
|
|
8476
|
+
return newState;
|
|
8477
|
+
});
|
|
8478
|
+
},
|
|
8479
|
+
[unstable_onError]
|
|
8480
|
+
);
|
|
8481
|
+
let setState = React9.useCallback(
|
|
8482
|
+
(newState, { deletedFetchers, flushSync, viewTransitionOpts }) => {
|
|
8483
|
+
newState.fetchers.forEach((fetcher, key) => {
|
|
8484
|
+
if (fetcher.data !== void 0) {
|
|
8485
|
+
fetcherData.current.set(key, fetcher.data);
|
|
8486
|
+
}
|
|
8487
|
+
});
|
|
8488
|
+
deletedFetchers.forEach((key) => fetcherData.current.delete(key));
|
|
8489
|
+
warnOnce(
|
|
8490
|
+
flushSync === false || reactDomFlushSyncImpl != null,
|
|
8491
|
+
'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.'
|
|
8492
|
+
);
|
|
8493
|
+
let isViewTransitionAvailable = router.window != null && router.window.document != null && typeof router.window.document.startViewTransition === "function";
|
|
8494
|
+
warnOnce(
|
|
8495
|
+
viewTransitionOpts == null || isViewTransitionAvailable,
|
|
8496
|
+
"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."
|
|
8497
|
+
);
|
|
8498
|
+
if (!viewTransitionOpts || !isViewTransitionAvailable) {
|
|
8499
|
+
if (reactDomFlushSyncImpl && flushSync) {
|
|
8500
|
+
reactDomFlushSyncImpl(() => logErrorsAndSetState(newState));
|
|
8501
|
+
} else {
|
|
8502
|
+
React9.startTransition(() => logErrorsAndSetState(newState));
|
|
8503
|
+
}
|
|
8504
|
+
return;
|
|
8505
|
+
}
|
|
8506
|
+
if (reactDomFlushSyncImpl && flushSync) {
|
|
8507
|
+
reactDomFlushSyncImpl(() => {
|
|
8508
|
+
if (transition) {
|
|
8509
|
+
renderDfd && renderDfd.resolve();
|
|
8510
|
+
transition.skipTransition();
|
|
8511
|
+
}
|
|
8512
|
+
setVtContext({
|
|
8513
|
+
isTransitioning: true,
|
|
8514
|
+
flushSync: true,
|
|
8515
|
+
currentLocation: viewTransitionOpts.currentLocation,
|
|
8516
|
+
nextLocation: viewTransitionOpts.nextLocation
|
|
8517
|
+
});
|
|
8518
|
+
});
|
|
8519
|
+
let t = router.window.document.startViewTransition(() => {
|
|
8520
|
+
reactDomFlushSyncImpl(() => logErrorsAndSetState(newState));
|
|
8521
|
+
});
|
|
8522
|
+
t.finished.finally(() => {
|
|
8523
|
+
reactDomFlushSyncImpl(() => {
|
|
8524
|
+
setRenderDfd(void 0);
|
|
8525
|
+
setTransition(void 0);
|
|
8526
|
+
setPendingState(void 0);
|
|
8527
|
+
setVtContext({ isTransitioning: false });
|
|
8528
|
+
});
|
|
8529
|
+
});
|
|
8530
|
+
reactDomFlushSyncImpl(() => setTransition(t));
|
|
8531
|
+
return;
|
|
8532
|
+
}
|
|
8533
|
+
if (transition) {
|
|
8534
|
+
renderDfd && renderDfd.resolve();
|
|
8535
|
+
transition.skipTransition();
|
|
8536
|
+
setInterruption({
|
|
8537
|
+
state: newState,
|
|
8538
|
+
currentLocation: viewTransitionOpts.currentLocation,
|
|
8539
|
+
nextLocation: viewTransitionOpts.nextLocation
|
|
8540
|
+
});
|
|
8541
|
+
} else {
|
|
8542
|
+
setPendingState(newState);
|
|
8543
|
+
setVtContext({
|
|
8544
|
+
isTransitioning: true,
|
|
8545
|
+
flushSync: false,
|
|
8546
|
+
currentLocation: viewTransitionOpts.currentLocation,
|
|
8547
|
+
nextLocation: viewTransitionOpts.nextLocation
|
|
8548
|
+
});
|
|
8549
|
+
}
|
|
8550
|
+
},
|
|
8551
|
+
[
|
|
8552
|
+
router.window,
|
|
8553
|
+
reactDomFlushSyncImpl,
|
|
8554
|
+
transition,
|
|
8555
|
+
renderDfd,
|
|
8556
|
+
logErrorsAndSetState
|
|
8557
|
+
]
|
|
8558
|
+
);
|
|
8559
|
+
React9.useLayoutEffect(() => router.subscribe(setState), [router, setState]);
|
|
8560
|
+
React9.useEffect(() => {
|
|
8561
|
+
if (vtContext.isTransitioning && !vtContext.flushSync) {
|
|
8562
|
+
setRenderDfd(new Deferred2());
|
|
8563
|
+
}
|
|
8564
|
+
}, [vtContext]);
|
|
8565
|
+
React9.useEffect(() => {
|
|
8566
|
+
if (renderDfd && pendingState && router.window) {
|
|
8567
|
+
let newState = pendingState;
|
|
8568
|
+
let renderPromise = renderDfd.promise;
|
|
8569
|
+
let transition2 = router.window.document.startViewTransition(async () => {
|
|
8570
|
+
React9.startTransition(() => logErrorsAndSetState(newState));
|
|
8571
|
+
await renderPromise;
|
|
8572
|
+
});
|
|
8573
|
+
transition2.finished.finally(() => {
|
|
8574
|
+
setRenderDfd(void 0);
|
|
8575
|
+
setTransition(void 0);
|
|
8576
|
+
setPendingState(void 0);
|
|
8577
|
+
setVtContext({ isTransitioning: false });
|
|
8578
|
+
});
|
|
8579
|
+
setTransition(transition2);
|
|
8580
|
+
}
|
|
8581
|
+
}, [pendingState, renderDfd, router.window, logErrorsAndSetState]);
|
|
8582
|
+
React9.useEffect(() => {
|
|
8583
|
+
if (renderDfd && pendingState && state.location.key === pendingState.location.key) {
|
|
8584
|
+
renderDfd.resolve();
|
|
8585
|
+
}
|
|
8586
|
+
}, [renderDfd, transition, state.location, pendingState]);
|
|
8587
|
+
React9.useEffect(() => {
|
|
8588
|
+
if (!vtContext.isTransitioning && interruption) {
|
|
8589
|
+
setPendingState(interruption.state);
|
|
8590
|
+
setVtContext({
|
|
8591
|
+
isTransitioning: true,
|
|
8592
|
+
flushSync: false,
|
|
8593
|
+
currentLocation: interruption.currentLocation,
|
|
8594
|
+
nextLocation: interruption.nextLocation
|
|
8595
|
+
});
|
|
8596
|
+
setInterruption(void 0);
|
|
8597
|
+
}
|
|
8598
|
+
}, [vtContext.isTransitioning, interruption]);
|
|
8599
|
+
let navigator = React9.useMemo(() => {
|
|
8600
|
+
return {
|
|
8601
|
+
createHref: router.createHref,
|
|
8602
|
+
encodeLocation: router.encodeLocation,
|
|
8603
|
+
go: (n) => router.navigate(n),
|
|
8604
|
+
push: (to, state2, opts) => router.navigate(to, {
|
|
8605
|
+
state: state2,
|
|
8606
|
+
preventScrollReset: _optionalChain([opts, 'optionalAccess', _119 => _119.preventScrollReset])
|
|
8607
|
+
}),
|
|
8608
|
+
replace: (to, state2, opts) => router.navigate(to, {
|
|
8609
|
+
replace: true,
|
|
8610
|
+
state: state2,
|
|
8611
|
+
preventScrollReset: _optionalChain([opts, 'optionalAccess', _120 => _120.preventScrollReset])
|
|
8612
|
+
})
|
|
8613
|
+
};
|
|
8614
|
+
}, [router]);
|
|
8615
|
+
let basename = router.basename || "/";
|
|
8616
|
+
let dataRouterContext = React9.useMemo(
|
|
8617
|
+
() => ({
|
|
8618
|
+
router,
|
|
8619
|
+
navigator,
|
|
8620
|
+
static: false,
|
|
8621
|
+
basename,
|
|
8622
|
+
unstable_onError
|
|
8623
|
+
}),
|
|
8624
|
+
[router, navigator, basename, unstable_onError]
|
|
8625
|
+
);
|
|
8626
|
+
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(
|
|
8627
|
+
Router,
|
|
8628
|
+
{
|
|
8629
|
+
basename,
|
|
8630
|
+
location: state.location,
|
|
8631
|
+
navigationType: state.historyAction,
|
|
8632
|
+
navigator
|
|
8633
|
+
},
|
|
8634
|
+
/* @__PURE__ */ React9.createElement(
|
|
8635
|
+
MemoizedDataRoutes,
|
|
8636
|
+
{
|
|
8637
|
+
routes: router.routes,
|
|
8638
|
+
future: router.future,
|
|
8639
|
+
state,
|
|
8640
|
+
unstable_onError
|
|
8641
|
+
}
|
|
8642
|
+
)
|
|
8643
|
+
))))), null);
|
|
8644
|
+
}
|
|
8645
|
+
var MemoizedDataRoutes = React9.memo(DataRoutes);
|
|
8646
|
+
function DataRoutes({
|
|
8647
|
+
routes,
|
|
8648
|
+
future,
|
|
8649
|
+
state,
|
|
8650
|
+
unstable_onError
|
|
8651
|
+
}) {
|
|
8652
|
+
return useRoutesImpl(routes, void 0, state, unstable_onError, future);
|
|
8653
|
+
}
|
|
8654
|
+
function MemoryRouter({
|
|
8655
|
+
basename,
|
|
8656
|
+
children,
|
|
8657
|
+
initialEntries,
|
|
8658
|
+
initialIndex
|
|
8659
|
+
}) {
|
|
8660
|
+
let historyRef = React9.useRef();
|
|
8661
|
+
if (historyRef.current == null) {
|
|
8662
|
+
historyRef.current = createMemoryHistory({
|
|
8663
|
+
initialEntries,
|
|
8664
|
+
initialIndex,
|
|
8665
|
+
v5Compat: true
|
|
8666
|
+
});
|
|
8667
|
+
}
|
|
8668
|
+
let history = historyRef.current;
|
|
8669
|
+
let [state, setStateImpl] = React9.useState({
|
|
8670
|
+
action: history.action,
|
|
8671
|
+
location: history.location
|
|
8672
|
+
});
|
|
8673
|
+
let setState = React9.useCallback(
|
|
8674
|
+
(newState) => {
|
|
8675
|
+
React9.startTransition(() => setStateImpl(newState));
|
|
8676
|
+
},
|
|
8677
|
+
[setStateImpl]
|
|
8678
|
+
);
|
|
8679
|
+
React9.useLayoutEffect(() => history.listen(setState), [history, setState]);
|
|
8680
|
+
return /* @__PURE__ */ React9.createElement(
|
|
8681
|
+
Router,
|
|
8682
|
+
{
|
|
8683
|
+
basename,
|
|
8684
|
+
children,
|
|
8685
|
+
location: state.location,
|
|
8686
|
+
navigationType: state.action,
|
|
8687
|
+
navigator: history
|
|
8688
|
+
}
|
|
8689
|
+
);
|
|
8690
|
+
}
|
|
8691
|
+
function Navigate({
|
|
8692
|
+
to,
|
|
8693
|
+
replace: replace2,
|
|
8694
|
+
state,
|
|
8695
|
+
relative
|
|
8696
|
+
}) {
|
|
8697
|
+
invariant(
|
|
8698
|
+
useInRouterContext(),
|
|
8699
|
+
// TODO: This error is probably because they somehow have 2 versions of
|
|
8700
|
+
// the router loaded. We can help them understand how to avoid that.
|
|
8701
|
+
`<Navigate> may be used only in the context of a <Router> component.`
|
|
8702
|
+
);
|
|
8703
|
+
let { static: isStatic } = React9.useContext(NavigationContext);
|
|
8704
|
+
warning(
|
|
8705
|
+
!isStatic,
|
|
8706
|
+
`<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.`
|
|
8707
|
+
);
|
|
8708
|
+
let { matches } = React9.useContext(RouteContext);
|
|
8709
|
+
let { pathname: locationPathname } = useLocation();
|
|
8710
|
+
let navigate = useNavigate();
|
|
8711
|
+
let path = resolveTo(
|
|
8712
|
+
to,
|
|
8713
|
+
getResolveToMatches(matches),
|
|
8714
|
+
locationPathname,
|
|
8715
|
+
relative === "path"
|
|
8716
|
+
);
|
|
8717
|
+
let jsonPath = JSON.stringify(path);
|
|
8718
|
+
React9.useEffect(() => {
|
|
8719
|
+
navigate(JSON.parse(jsonPath), { replace: replace2, state, relative });
|
|
8720
|
+
}, [navigate, jsonPath, relative, replace2, state]);
|
|
8721
|
+
return null;
|
|
8722
|
+
}
|
|
8723
|
+
function Outlet(props) {
|
|
8724
|
+
return useOutlet(props.context);
|
|
8725
|
+
}
|
|
8726
|
+
function Route(props) {
|
|
8727
|
+
invariant(
|
|
8728
|
+
false,
|
|
8729
|
+
`A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.`
|
|
8730
|
+
);
|
|
8731
|
+
}
|
|
8732
|
+
function Router({
|
|
8733
|
+
basename: basenameProp = "/",
|
|
8734
|
+
children = null,
|
|
8735
|
+
location: locationProp,
|
|
8736
|
+
navigationType = "POP" /* Pop */,
|
|
8737
|
+
navigator,
|
|
8738
|
+
static: staticProp = false
|
|
8739
|
+
}) {
|
|
8740
|
+
invariant(
|
|
8741
|
+
!useInRouterContext(),
|
|
8742
|
+
`You cannot render a <Router> inside another <Router>. You should never have more than one in your app.`
|
|
8743
|
+
);
|
|
8744
|
+
let basename = basenameProp.replace(/^\/*/, "/");
|
|
8745
|
+
let navigationContext = React9.useMemo(
|
|
8746
|
+
() => ({
|
|
8747
|
+
basename,
|
|
8748
|
+
navigator,
|
|
8749
|
+
static: staticProp,
|
|
8750
|
+
future: {}
|
|
8751
|
+
}),
|
|
8752
|
+
[basename, navigator, staticProp]
|
|
8753
|
+
);
|
|
8754
|
+
if (typeof locationProp === "string") {
|
|
8755
|
+
locationProp = parsePath(locationProp);
|
|
8756
|
+
}
|
|
8757
|
+
let {
|
|
8758
|
+
pathname = "/",
|
|
8759
|
+
search = "",
|
|
8760
|
+
hash = "",
|
|
8761
|
+
state = null,
|
|
8762
|
+
key = "default"
|
|
8763
|
+
} = locationProp;
|
|
8764
|
+
let locationContext = React9.useMemo(() => {
|
|
8765
|
+
let trailingPathname = stripBasename(pathname, basename);
|
|
8766
|
+
if (trailingPathname == null) {
|
|
8767
|
+
return null;
|
|
8768
|
+
}
|
|
8769
|
+
return {
|
|
8770
|
+
location: {
|
|
8771
|
+
pathname: trailingPathname,
|
|
8772
|
+
search,
|
|
8773
|
+
hash,
|
|
8774
|
+
state,
|
|
8775
|
+
key
|
|
8776
|
+
},
|
|
8777
|
+
navigationType
|
|
8778
|
+
};
|
|
8779
|
+
}, [basename, pathname, search, hash, state, key, navigationType]);
|
|
8780
|
+
warning(
|
|
8781
|
+
locationContext != null,
|
|
8782
|
+
`<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.`
|
|
8783
|
+
);
|
|
8784
|
+
if (locationContext == null) {
|
|
8785
|
+
return null;
|
|
8786
|
+
}
|
|
8787
|
+
return /* @__PURE__ */ React9.createElement(NavigationContext.Provider, { value: navigationContext }, /* @__PURE__ */ React9.createElement(LocationContext.Provider, { children, value: locationContext }));
|
|
8788
|
+
}
|
|
8789
|
+
function Routes({
|
|
8790
|
+
children,
|
|
8791
|
+
location
|
|
8792
|
+
}) {
|
|
8793
|
+
return useRoutes(createRoutesFromChildren(children), location);
|
|
8794
|
+
}
|
|
8795
|
+
function Await({
|
|
8796
|
+
children,
|
|
8797
|
+
errorElement,
|
|
8798
|
+
resolve
|
|
8799
|
+
}) {
|
|
8800
|
+
let dataRouterContext = React9.useContext(DataRouterContext);
|
|
8801
|
+
return /* @__PURE__ */ React9.createElement(
|
|
8802
|
+
AwaitErrorBoundary,
|
|
8803
|
+
{
|
|
8804
|
+
resolve,
|
|
8805
|
+
errorElement,
|
|
8806
|
+
unstable_onError: _optionalChain([dataRouterContext, 'optionalAccess', _121 => _121.unstable_onError])
|
|
8807
|
+
},
|
|
8808
|
+
/* @__PURE__ */ React9.createElement(ResolveAwait, null, children)
|
|
8809
|
+
);
|
|
8810
|
+
}
|
|
8811
|
+
var AwaitErrorBoundary = class extends React9.Component {
|
|
8812
|
+
constructor(props) {
|
|
8813
|
+
super(props);
|
|
8814
|
+
this.state = { error: null };
|
|
8815
|
+
}
|
|
8816
|
+
static getDerivedStateFromError(error) {
|
|
8817
|
+
return { error };
|
|
8818
|
+
}
|
|
8819
|
+
componentDidCatch(error, errorInfo) {
|
|
8820
|
+
if (this.props.unstable_onError) {
|
|
8821
|
+
this.props.unstable_onError(error, errorInfo);
|
|
8822
|
+
} else {
|
|
8823
|
+
console.error(
|
|
8824
|
+
"<Await> caught the following error during render",
|
|
8825
|
+
error,
|
|
8826
|
+
errorInfo
|
|
8827
|
+
);
|
|
8828
|
+
}
|
|
8829
|
+
}
|
|
8830
|
+
render() {
|
|
8831
|
+
let { children, errorElement, resolve } = this.props;
|
|
8832
|
+
let promise = null;
|
|
8833
|
+
let status = 0 /* pending */;
|
|
8834
|
+
if (!(resolve instanceof Promise)) {
|
|
8835
|
+
status = 1 /* success */;
|
|
8836
|
+
promise = Promise.resolve();
|
|
8837
|
+
Object.defineProperty(promise, "_tracked", { get: () => true });
|
|
8838
|
+
Object.defineProperty(promise, "_data", { get: () => resolve });
|
|
8839
|
+
} else if (this.state.error) {
|
|
8840
|
+
status = 2 /* error */;
|
|
8841
|
+
let renderError = this.state.error;
|
|
8842
|
+
promise = Promise.reject().catch(() => {
|
|
8843
|
+
});
|
|
8844
|
+
Object.defineProperty(promise, "_tracked", { get: () => true });
|
|
8845
|
+
Object.defineProperty(promise, "_error", { get: () => renderError });
|
|
8846
|
+
} else if (resolve._tracked) {
|
|
8847
|
+
promise = resolve;
|
|
8848
|
+
status = "_error" in promise ? 2 /* error */ : "_data" in promise ? 1 /* success */ : 0 /* pending */;
|
|
8849
|
+
} else {
|
|
8850
|
+
status = 0 /* pending */;
|
|
8851
|
+
Object.defineProperty(resolve, "_tracked", { get: () => true });
|
|
8852
|
+
promise = resolve.then(
|
|
8853
|
+
(data2) => Object.defineProperty(resolve, "_data", { get: () => data2 }),
|
|
8854
|
+
(error) => {
|
|
8855
|
+
_optionalChain([this, 'access', _122 => _122.props, 'access', _123 => _123.unstable_onError, 'optionalCall', _124 => _124(error)]);
|
|
8856
|
+
Object.defineProperty(resolve, "_error", { get: () => error });
|
|
8857
|
+
}
|
|
8858
|
+
);
|
|
8859
|
+
}
|
|
8860
|
+
if (status === 2 /* error */ && !errorElement) {
|
|
8861
|
+
throw promise._error;
|
|
8862
|
+
}
|
|
8863
|
+
if (status === 2 /* error */) {
|
|
8864
|
+
return /* @__PURE__ */ React9.createElement(AwaitContext.Provider, { value: promise, children: errorElement });
|
|
8865
|
+
}
|
|
8866
|
+
if (status === 1 /* success */) {
|
|
8867
|
+
return /* @__PURE__ */ React9.createElement(AwaitContext.Provider, { value: promise, children });
|
|
8868
|
+
}
|
|
8869
|
+
throw promise;
|
|
8870
|
+
}
|
|
8871
|
+
};
|
|
8872
|
+
function ResolveAwait({
|
|
8873
|
+
children
|
|
8874
|
+
}) {
|
|
8875
|
+
let data2 = useAsyncValue();
|
|
8876
|
+
let toRender = typeof children === "function" ? children(data2) : children;
|
|
8877
|
+
return /* @__PURE__ */ React9.createElement(React9.Fragment, null, toRender);
|
|
8878
|
+
}
|
|
8879
|
+
function createRoutesFromChildren(children, parentPath = []) {
|
|
8880
|
+
let routes = [];
|
|
8881
|
+
React9.Children.forEach(children, (element, index) => {
|
|
8882
|
+
if (!React9.isValidElement(element)) {
|
|
8883
|
+
return;
|
|
8884
|
+
}
|
|
8885
|
+
let treePath = [...parentPath, index];
|
|
8886
|
+
if (element.type === React9.Fragment) {
|
|
8887
|
+
routes.push.apply(
|
|
8888
|
+
routes,
|
|
8889
|
+
createRoutesFromChildren(element.props.children, treePath)
|
|
8890
|
+
);
|
|
8891
|
+
return;
|
|
8892
|
+
}
|
|
8893
|
+
invariant(
|
|
8894
|
+
element.type === Route,
|
|
8895
|
+
`[${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>`
|
|
8896
|
+
);
|
|
8897
|
+
invariant(
|
|
8898
|
+
!element.props.index || !element.props.children,
|
|
8899
|
+
"An index route cannot have child routes."
|
|
8900
|
+
);
|
|
8901
|
+
let route = {
|
|
8902
|
+
id: element.props.id || treePath.join("-"),
|
|
8903
|
+
caseSensitive: element.props.caseSensitive,
|
|
8904
|
+
element: element.props.element,
|
|
8905
|
+
Component: element.props.Component,
|
|
8906
|
+
index: element.props.index,
|
|
8907
|
+
path: element.props.path,
|
|
8908
|
+
middleware: element.props.middleware,
|
|
8909
|
+
loader: element.props.loader,
|
|
8910
|
+
action: element.props.action,
|
|
8911
|
+
hydrateFallbackElement: element.props.hydrateFallbackElement,
|
|
8912
|
+
HydrateFallback: element.props.HydrateFallback,
|
|
8913
|
+
errorElement: element.props.errorElement,
|
|
8914
|
+
ErrorBoundary: element.props.ErrorBoundary,
|
|
8915
|
+
hasErrorBoundary: element.props.hasErrorBoundary === true || element.props.ErrorBoundary != null || element.props.errorElement != null,
|
|
8916
|
+
shouldRevalidate: element.props.shouldRevalidate,
|
|
8917
|
+
handle: element.props.handle,
|
|
8918
|
+
lazy: element.props.lazy
|
|
8919
|
+
};
|
|
8920
|
+
if (element.props.children) {
|
|
8921
|
+
route.children = createRoutesFromChildren(
|
|
8922
|
+
element.props.children,
|
|
8923
|
+
treePath
|
|
8924
|
+
);
|
|
8925
|
+
}
|
|
8926
|
+
routes.push(route);
|
|
8927
|
+
});
|
|
8928
|
+
return routes;
|
|
8929
|
+
}
|
|
8930
|
+
var createRoutesFromElements = createRoutesFromChildren;
|
|
8931
|
+
function renderMatches(matches) {
|
|
8932
|
+
return _renderMatches(matches);
|
|
8933
|
+
}
|
|
8934
|
+
function useRouteComponentProps() {
|
|
8935
|
+
return {
|
|
8936
|
+
params: useParams(),
|
|
8937
|
+
loaderData: useLoaderData(),
|
|
8938
|
+
actionData: useActionData(),
|
|
8939
|
+
matches: useMatches()
|
|
8940
|
+
};
|
|
8941
|
+
}
|
|
8942
|
+
function WithComponentProps({
|
|
8943
|
+
children
|
|
8944
|
+
}) {
|
|
8945
|
+
const props = useRouteComponentProps();
|
|
8946
|
+
return React9.cloneElement(children, props);
|
|
8947
|
+
}
|
|
8948
|
+
function withComponentProps(Component4) {
|
|
8949
|
+
return function WithComponentProps2() {
|
|
8950
|
+
const props = useRouteComponentProps();
|
|
8951
|
+
return React9.createElement(Component4, props);
|
|
8952
|
+
};
|
|
8953
|
+
}
|
|
8954
|
+
function useHydrateFallbackProps() {
|
|
8955
|
+
return {
|
|
8956
|
+
params: useParams(),
|
|
8957
|
+
loaderData: useLoaderData(),
|
|
8958
|
+
actionData: useActionData()
|
|
8959
|
+
};
|
|
8960
|
+
}
|
|
8961
|
+
function WithHydrateFallbackProps({
|
|
8962
|
+
children
|
|
8963
|
+
}) {
|
|
8964
|
+
const props = useHydrateFallbackProps();
|
|
8965
|
+
return React9.cloneElement(children, props);
|
|
8966
|
+
}
|
|
8967
|
+
function withHydrateFallbackProps(HydrateFallback) {
|
|
8968
|
+
return function WithHydrateFallbackProps2() {
|
|
8969
|
+
const props = useHydrateFallbackProps();
|
|
8970
|
+
return React9.createElement(HydrateFallback, props);
|
|
8971
|
+
};
|
|
8972
|
+
}
|
|
8973
|
+
function useErrorBoundaryProps() {
|
|
8974
|
+
return {
|
|
8975
|
+
params: useParams(),
|
|
8976
|
+
loaderData: useLoaderData(),
|
|
8977
|
+
actionData: useActionData(),
|
|
8978
|
+
error: useRouteError()
|
|
8979
|
+
};
|
|
8980
|
+
}
|
|
8981
|
+
function WithErrorBoundaryProps({
|
|
8982
|
+
children
|
|
8983
|
+
}) {
|
|
8984
|
+
const props = useErrorBoundaryProps();
|
|
8985
|
+
return React9.cloneElement(children, props);
|
|
8986
|
+
}
|
|
8987
|
+
function withErrorBoundaryProps(ErrorBoundary) {
|
|
8988
|
+
return function WithErrorBoundaryProps2() {
|
|
8989
|
+
const props = useErrorBoundaryProps();
|
|
8990
|
+
return React9.createElement(ErrorBoundary, props);
|
|
8991
|
+
};
|
|
8992
|
+
}
|
|
8993
|
+
|
|
8994
|
+
|
|
8995
|
+
|
|
8996
|
+
|
|
8997
|
+
|
|
8998
|
+
|
|
8999
|
+
|
|
9000
|
+
|
|
9001
|
+
|
|
9002
|
+
|
|
9003
|
+
|
|
9004
|
+
|
|
9005
|
+
|
|
9006
|
+
|
|
9007
|
+
|
|
9008
|
+
|
|
9009
|
+
|
|
8527
9010
|
|
|
8528
9011
|
|
|
8529
9012
|
|
|
@@ -8628,4 +9111,4 @@ function BoundaryShell({
|
|
|
8628
9111
|
|
|
8629
9112
|
|
|
8630
9113
|
|
|
8631
|
-
exports.Action = Action; exports.
|
|
9114
|
+
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.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;
|