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
|
/**
|
|
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
|
*
|
|
@@ -454,23 +454,19 @@ function convertRoutesToDataRoutes(routes, mapRouteProperties2, 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
|
-
mapRouteProperties2(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
|
-
mapRouteProperties2(pathOrLayoutRoute)
|
|
473
|
-
);
|
|
469
|
+
manifest[id] = pathOrLayoutRoute;
|
|
474
470
|
if (route.children) {
|
|
475
471
|
pathOrLayoutRoute.children = convertRoutesToDataRoutes(
|
|
476
472
|
route.children,
|
|
@@ -484,17 +480,6 @@ function convertRoutesToDataRoutes(routes, mapRouteProperties2, 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
|
}
|
|
@@ -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 = 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 = 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 = 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, 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 = router.fetch[UninstrumentedSymbol] ?? router.fetch;
|
|
1075
|
-
let instrumentedFetch = wrapImpl(aggregated.fetch, fetch2, (...args) => {
|
|
1076
|
-
let [key, , href, opts] = args;
|
|
1077
|
-
return {
|
|
1078
|
-
href: href ?? ".",
|
|
1079
|
-
fetcherKey: key,
|
|
1080
|
-
...getRouterInfo(router, 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 = [
|
|
@@ -1236,20 +994,7 @@ function createRouter(init) {
|
|
|
1236
994
|
"You must provide a non-empty routes array to createRouter"
|
|
1237
995
|
);
|
|
1238
996
|
let hydrationRouteProperties2 = init.hydrationRouteProperties || [];
|
|
1239
|
-
let
|
|
1240
|
-
let mapRouteProperties2 = _mapRouteProperties;
|
|
1241
|
-
if (init.unstable_instrumentations) {
|
|
1242
|
-
let instrumentations = init.unstable_instrumentations;
|
|
1243
|
-
mapRouteProperties2 = (route) => {
|
|
1244
|
-
return {
|
|
1245
|
-
..._mapRouteProperties(route),
|
|
1246
|
-
...getRouteInstrumentationUpdates(
|
|
1247
|
-
instrumentations.map((i) => i.route).filter(Boolean),
|
|
1248
|
-
route
|
|
1249
|
-
)
|
|
1250
|
-
};
|
|
1251
|
-
};
|
|
1252
|
-
}
|
|
997
|
+
let mapRouteProperties2 = init.mapRouteProperties || defaultMapRouteProperties;
|
|
1253
998
|
let manifest = {};
|
|
1254
999
|
let dataRoutes = convertRoutesToDataRoutes(
|
|
1255
1000
|
init.routes,
|
|
@@ -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,20 +2755,7 @@ function createStaticHandler(routes, opts) {
|
|
|
3016
2755
|
);
|
|
3017
2756
|
let manifest = {};
|
|
3018
2757
|
let basename = (opts ? opts.basename : null) || "/";
|
|
3019
|
-
let
|
|
3020
|
-
let mapRouteProperties2 = _mapRouteProperties;
|
|
3021
|
-
if (opts?.unstable_instrumentations) {
|
|
3022
|
-
let instrumentations = opts.unstable_instrumentations;
|
|
3023
|
-
mapRouteProperties2 = (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 = opts?.mapRouteProperties || defaultMapRouteProperties;
|
|
3033
2759
|
let dataRoutes = convertRoutesToDataRoutes(
|
|
3034
2760
|
routes,
|
|
3035
2761
|
mapRouteProperties2,
|
|
@@ -3099,7 +2825,6 @@ function createStaticHandler(routes, opts) {
|
|
|
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
|
|
@@ -3245,7 +2970,6 @@ function createStaticHandler(routes, opts) {
|
|
|
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
|
|
@@ -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,
|
|
@@ -3539,7 +3261,6 @@ function createStaticHandler(routes, opts) {
|
|
|
3539
3261
|
mapRouteProperties2,
|
|
3540
3262
|
manifest,
|
|
3541
3263
|
request,
|
|
3542
|
-
pattern,
|
|
3543
3264
|
match,
|
|
3544
3265
|
[],
|
|
3545
3266
|
requestContext,
|
|
@@ -3820,7 +3541,6 @@ function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest,
|
|
|
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;
|
|
@@ -3844,7 +3564,6 @@ function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest,
|
|
|
3844
3564
|
mapRouteProperties2,
|
|
3845
3565
|
manifest,
|
|
3846
3566
|
request,
|
|
3847
|
-
pattern,
|
|
3848
3567
|
match,
|
|
3849
3568
|
lazyRoutePropertiesToSkip,
|
|
3850
3569
|
scopedContext,
|
|
@@ -3865,7 +3584,6 @@ function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest,
|
|
|
3865
3584
|
mapRouteProperties2,
|
|
3866
3585
|
manifest,
|
|
3867
3586
|
request,
|
|
3868
|
-
pattern,
|
|
3869
3587
|
match,
|
|
3870
3588
|
lazyRoutePropertiesToSkip,
|
|
3871
3589
|
scopedContext,
|
|
@@ -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,
|
|
@@ -4407,7 +4120,7 @@ function getDataStrategyMatchLazyPromises(mapRouteProperties2, manifest, request
|
|
|
4407
4120
|
handler: lazyRoutePromises.lazyHandlerPromise
|
|
4408
4121
|
};
|
|
4409
4122
|
}
|
|
4410
|
-
function getDataStrategyMatch(mapRouteProperties2, manifest, request,
|
|
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,
|
|
@@ -4441,7 +4154,6 @@ function getDataStrategyMatch(mapRouteProperties2, manifest, request, unstable_p
|
|
|
4441
4154
|
if (callHandler && !isMiddlewareOnlyRoute) {
|
|
4442
4155
|
return callLoaderOrAction({
|
|
4443
4156
|
request,
|
|
4444
|
-
unstable_pattern,
|
|
4445
4157
|
match,
|
|
4446
4158
|
lazyHandlerPromise: _lazyPromises?.handler,
|
|
4447
4159
|
lazyRoutePromise: _lazyPromises?.route,
|
|
@@ -4475,7 +4187,6 @@ function getTargetedDataStrategyMatches(mapRouteProperties2, manifest, request,
|
|
|
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,
|
|
@@ -4490,7 +4201,6 @@ async function callDataStrategyImpl(dataStrategyImpl, request, matches, fetcherK
|
|
|
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
|
|
@@ -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
|
},
|
|
@@ -5844,6 +5552,20 @@ function warningOnce(key, cond, message) {
|
|
|
5844
5552
|
warning(false, message);
|
|
5845
5553
|
}
|
|
5846
5554
|
}
|
|
5555
|
+
function useRoute(...args) {
|
|
5556
|
+
const currentRouteId = useCurrentRouteId(
|
|
5557
|
+
"useRoute" /* UseRoute */
|
|
5558
|
+
);
|
|
5559
|
+
const id = args[0] ?? currentRouteId;
|
|
5560
|
+
const state = useDataRouterState("useRoute" /* UseRoute */);
|
|
5561
|
+
const route = state.matches.find(({ route: route2 }) => route2.id === id);
|
|
5562
|
+
if (route === void 0) return void 0;
|
|
5563
|
+
return {
|
|
5564
|
+
handle: route.route.handle,
|
|
5565
|
+
loaderData: state.loaderData[id],
|
|
5566
|
+
actionData: state.actionData?.[id]
|
|
5567
|
+
};
|
|
5568
|
+
}
|
|
5847
5569
|
|
|
5848
5570
|
// lib/components.tsx
|
|
5849
5571
|
import * as React3 from "react";
|
|
@@ -5926,8 +5648,7 @@ function createMemoryRouter(routes, opts) {
|
|
|
5926
5648
|
hydrationRouteProperties,
|
|
5927
5649
|
mapRouteProperties,
|
|
5928
5650
|
dataStrategy: opts?.dataStrategy,
|
|
5929
|
-
patchRoutesOnNavigation: opts?.patchRoutesOnNavigation
|
|
5930
|
-
unstable_instrumentations: opts?.unstable_instrumentations
|
|
5651
|
+
patchRoutesOnNavigation: opts?.patchRoutesOnNavigation
|
|
5931
5652
|
}).initialize();
|
|
5932
5653
|
}
|
|
5933
5654
|
var Deferred = class {
|
|
@@ -8342,7 +8063,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
8342
8063
|
let hasInitialError = initialState && initialState.errors && route.id in initialState.errors;
|
|
8343
8064
|
let initialError = hasInitialError ? initialState?.errors?.[route.id] : void 0;
|
|
8344
8065
|
let isHydrationRequest = needsRevalidation == null && (routeModule.clientLoader?.hydrate === true || !route.hasLoader);
|
|
8345
|
-
dataRoute.loader = async ({ request, params, context
|
|
8066
|
+
dataRoute.loader = async ({ request, params, context }, singleFetch) => {
|
|
8346
8067
|
try {
|
|
8347
8068
|
let result = await prefetchStylesAndCallHandler(async () => {
|
|
8348
8069
|
invariant2(
|
|
@@ -8356,7 +8077,6 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
8356
8077
|
request,
|
|
8357
8078
|
params,
|
|
8358
8079
|
context,
|
|
8359
|
-
unstable_pattern,
|
|
8360
8080
|
async serverLoader() {
|
|
8361
8081
|
preventInvalidServerHandlerCall("loader", route);
|
|
8362
8082
|
if (isHydrationRequest) {
|
|
@@ -8382,7 +8102,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
8382
8102
|
route.hasLoader,
|
|
8383
8103
|
isSpaMode
|
|
8384
8104
|
);
|
|
8385
|
-
dataRoute.action = ({ request, params, context
|
|
8105
|
+
dataRoute.action = ({ request, params, context }, singleFetch) => {
|
|
8386
8106
|
return prefetchStylesAndCallHandler(async () => {
|
|
8387
8107
|
invariant2(
|
|
8388
8108
|
routeModule,
|
|
@@ -8398,7 +8118,6 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
8398
8118
|
request,
|
|
8399
8119
|
params,
|
|
8400
8120
|
context,
|
|
8401
|
-
unstable_pattern,
|
|
8402
8121
|
async serverAction() {
|
|
8403
8122
|
preventInvalidServerHandlerCall("action", route);
|
|
8404
8123
|
return fetchServerAction(singleFetch);
|
|
@@ -9408,7 +9127,7 @@ var isBrowser = typeof window !== "undefined" && typeof window.document !== "und
|
|
|
9408
9127
|
try {
|
|
9409
9128
|
if (isBrowser) {
|
|
9410
9129
|
window.__reactRouterVersion = // @ts-expect-error
|
|
9411
|
-
"0.0.0-experimental-
|
|
9130
|
+
"0.0.0-experimental-de3b900";
|
|
9412
9131
|
}
|
|
9413
9132
|
} catch (e) {
|
|
9414
9133
|
}
|
|
@@ -9424,8 +9143,7 @@ function createBrowserRouter(routes, opts) {
|
|
|
9424
9143
|
hydrationRouteProperties,
|
|
9425
9144
|
dataStrategy: opts?.dataStrategy,
|
|
9426
9145
|
patchRoutesOnNavigation: opts?.patchRoutesOnNavigation,
|
|
9427
|
-
window: opts?.window
|
|
9428
|
-
unstable_instrumentations: opts?.unstable_instrumentations
|
|
9146
|
+
window: opts?.window
|
|
9429
9147
|
}).initialize();
|
|
9430
9148
|
}
|
|
9431
9149
|
function createHashRouter(routes, opts) {
|
|
@@ -9440,8 +9158,7 @@ function createHashRouter(routes, opts) {
|
|
|
9440
9158
|
hydrationRouteProperties,
|
|
9441
9159
|
dataStrategy: opts?.dataStrategy,
|
|
9442
9160
|
patchRoutesOnNavigation: opts?.patchRoutesOnNavigation,
|
|
9443
|
-
window: opts?.window
|
|
9444
|
-
unstable_instrumentations: opts?.unstable_instrumentations
|
|
9161
|
+
window: opts?.window
|
|
9445
9162
|
}).initialize();
|
|
9446
9163
|
}
|
|
9447
9164
|
function parseHydrationData() {
|
|
@@ -10526,7 +10243,6 @@ export {
|
|
|
10526
10243
|
replace,
|
|
10527
10244
|
ErrorResponseImpl,
|
|
10528
10245
|
isRouteErrorResponse,
|
|
10529
|
-
instrumentHandler,
|
|
10530
10246
|
IDLE_NAVIGATION,
|
|
10531
10247
|
IDLE_FETCHER,
|
|
10532
10248
|
IDLE_BLOCKER,
|
|
@@ -10569,6 +10285,7 @@ export {
|
|
|
10569
10285
|
useAsyncValue,
|
|
10570
10286
|
useAsyncError,
|
|
10571
10287
|
useBlocker,
|
|
10288
|
+
useRoute,
|
|
10572
10289
|
warnOnce,
|
|
10573
10290
|
mapRouteProperties,
|
|
10574
10291
|
hydrationRouteProperties,
|