react-router 0.0.0-experimental-c19b79d → 0.0.0-experimental-e0b6ce9
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/dist/development/{chunk-AGOH44BE.mjs → chunk-4FI4BC6Y.mjs} +67 -51
- package/dist/development/{chunk-IMKEG5CI.mjs → chunk-F6CT5MEB.mjs} +314 -30
- package/dist/development/{chunk-LUB73E44.js → chunk-INO4IHBF.js} +352 -71
- package/dist/development/{chunk-2G2U5HGB.js → chunk-ITZFCV4J.js} +164 -161
- package/dist/development/dom-export.d.mts +59 -4
- package/dist/development/dom-export.d.ts +59 -3
- package/dist/development/dom-export.js +8 -5
- package/dist/development/dom-export.mjs +8 -5
- package/dist/development/{index-react-server-client-DKvU8YRr.d.ts → index-react-server-client-CYIi6gi0.d.mts} +198 -134
- package/dist/{production/index-react-server-client-DKvU8YRr.d.ts → development/index-react-server-client-ChBGplLn.d.ts} +198 -134
- package/dist/development/index-react-server-client.d.mts +3 -3
- package/dist/development/index-react-server-client.d.ts +3 -2
- package/dist/development/index-react-server-client.js +4 -4
- package/dist/development/index-react-server-client.mjs +2 -2
- package/dist/development/index-react-server.d.mts +90 -1
- package/dist/development/index-react-server.d.ts +90 -1
- package/dist/development/index-react-server.js +188 -9
- package/dist/development/index-react-server.mjs +188 -9
- package/dist/development/index.d.mts +13 -20
- package/dist/development/index.d.ts +13 -18
- package/dist/development/index.js +161 -147
- package/dist/development/index.mjs +3 -5
- package/dist/development/instrumentation-BGrNA7uj.d.ts +1122 -0
- package/dist/development/lib/types/internal.d.mts +3 -3
- package/dist/development/lib/types/internal.d.ts +3 -2
- package/dist/development/lib/types/internal.js +1 -1
- package/dist/development/lib/types/internal.mjs +1 -1
- package/dist/development/{register-BrVEYTED.d.mts → register-DiOIlEq5.d.mts} +1 -7
- package/dist/{production/register-BrVEYTED.d.mts → development/register-DiOIlEq5.d.ts} +1 -7
- package/dist/development/{route-data-CDwqkzPE.d.mts → routeModules-Cy4Xsfoi.d.mts} +157 -147
- package/dist/{production/routeModules-BmVo7q9e.d.ts → development/routeModules-DqotkItD.d.ts} +73 -1046
- package/dist/{production/context-BqL5Eckq.d.mts → development/router-DWv6Clt-.d.mts} +1390 -1253
- package/dist/production/{chunk-AODJW4D3.mjs → chunk-52MYED7O.mjs} +67 -51
- package/dist/production/{chunk-FGRCWJDI.js → chunk-DASXXYNZ.js} +164 -161
- package/dist/production/{chunk-2L5AG5Y5.js → chunk-K7VXYOZD.js} +352 -71
- package/dist/production/{chunk-UOQCOPF6.mjs → chunk-LKSLGWXX.mjs} +314 -30
- package/dist/production/dom-export.d.mts +59 -4
- package/dist/production/dom-export.d.ts +59 -3
- package/dist/production/dom-export.js +8 -5
- package/dist/production/dom-export.mjs +8 -5
- package/dist/production/{index-react-server-client-2EDmGlsZ.d.mts → index-react-server-client-CYIi6gi0.d.mts} +140 -77
- package/dist/{development/index-react-server-client-2EDmGlsZ.d.mts → production/index-react-server-client-ChBGplLn.d.ts} +140 -77
- package/dist/production/index-react-server-client.d.mts +3 -3
- package/dist/production/index-react-server-client.d.ts +3 -2
- package/dist/production/index-react-server-client.js +4 -4
- package/dist/production/index-react-server-client.mjs +2 -2
- package/dist/production/index-react-server.d.mts +90 -1
- package/dist/production/index-react-server.d.ts +90 -1
- package/dist/production/index-react-server.js +188 -9
- package/dist/production/index-react-server.mjs +188 -9
- package/dist/production/index.d.mts +13 -20
- package/dist/production/index.d.ts +13 -18
- package/dist/production/index.js +161 -147
- package/dist/production/index.mjs +3 -5
- package/dist/production/instrumentation-BGrNA7uj.d.ts +1122 -0
- package/dist/production/lib/types/internal.d.mts +3 -3
- package/dist/production/lib/types/internal.d.ts +3 -2
- package/dist/production/lib/types/internal.js +1 -1
- package/dist/production/lib/types/internal.mjs +1 -1
- package/dist/{development/register-D8NQoPsO.d.ts → production/register-DiOIlEq5.d.mts} +1 -7
- package/dist/production/{register-D8NQoPsO.d.ts → register-DiOIlEq5.d.ts} +1 -7
- package/dist/production/{route-data-CDwqkzPE.d.mts → routeModules-Cy4Xsfoi.d.mts} +157 -147
- package/dist/{development/routeModules-BmVo7q9e.d.ts → production/routeModules-DqotkItD.d.ts} +73 -1046
- package/dist/{development/context-BqL5Eckq.d.mts → production/router-DWv6Clt-.d.mts} +1390 -1253
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v0.0.0-experimental-
|
|
2
|
+
* react-router v0.0.0-experimental-e0b6ce9
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -454,19 +454,23 @@ function convertRoutesToDataRoutes(routes, mapRouteProperties2, parentPath = [],
|
|
|
454
454
|
if (isIndexRoute(route)) {
|
|
455
455
|
let indexRoute = {
|
|
456
456
|
...route,
|
|
457
|
-
...mapRouteProperties2(route),
|
|
458
457
|
id
|
|
459
458
|
};
|
|
460
|
-
manifest[id] =
|
|
459
|
+
manifest[id] = mergeRouteUpdates(
|
|
460
|
+
indexRoute,
|
|
461
|
+
mapRouteProperties2(indexRoute)
|
|
462
|
+
);
|
|
461
463
|
return indexRoute;
|
|
462
464
|
} else {
|
|
463
465
|
let pathOrLayoutRoute = {
|
|
464
466
|
...route,
|
|
465
|
-
...mapRouteProperties2(route),
|
|
466
467
|
id,
|
|
467
468
|
children: void 0
|
|
468
469
|
};
|
|
469
|
-
manifest[id] =
|
|
470
|
+
manifest[id] = mergeRouteUpdates(
|
|
471
|
+
pathOrLayoutRoute,
|
|
472
|
+
mapRouteProperties2(pathOrLayoutRoute)
|
|
473
|
+
);
|
|
470
474
|
if (route.children) {
|
|
471
475
|
pathOrLayoutRoute.children = convertRoutesToDataRoutes(
|
|
472
476
|
route.children,
|
|
@@ -480,6 +484,17 @@ function convertRoutesToDataRoutes(routes, mapRouteProperties2, parentPath = [],
|
|
|
480
484
|
}
|
|
481
485
|
});
|
|
482
486
|
}
|
|
487
|
+
function mergeRouteUpdates(route, updates) {
|
|
488
|
+
return Object.assign(route, {
|
|
489
|
+
...updates,
|
|
490
|
+
...typeof updates.lazy === "object" && updates.lazy != null ? {
|
|
491
|
+
lazy: {
|
|
492
|
+
...route.lazy,
|
|
493
|
+
...updates.lazy
|
|
494
|
+
}
|
|
495
|
+
} : {}
|
|
496
|
+
});
|
|
497
|
+
}
|
|
483
498
|
function matchRoutes(routes, locationArg, basename = "/") {
|
|
484
499
|
return matchRoutesImpl(routes, locationArg, basename, false);
|
|
485
500
|
}
|
|
@@ -935,6 +950,233 @@ var ErrorResponseImpl = class {
|
|
|
935
950
|
function isRouteErrorResponse(error) {
|
|
936
951
|
return error != null && typeof error.status === "number" && typeof error.statusText === "string" && typeof error.internal === "boolean" && "data" in error;
|
|
937
952
|
}
|
|
953
|
+
function getRoutePattern(paths) {
|
|
954
|
+
return paths.filter(Boolean).join("/").replace(/\/\/*/g, "/");
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
// lib/router/instrumentation.ts
|
|
958
|
+
var UninstrumentedSymbol = Symbol("Uninstrumented");
|
|
959
|
+
function getRouteInstrumentationUpdates(fns, route) {
|
|
960
|
+
let aggregated = {
|
|
961
|
+
lazy: [],
|
|
962
|
+
"lazy.loader": [],
|
|
963
|
+
"lazy.action": [],
|
|
964
|
+
"lazy.middleware": [],
|
|
965
|
+
middleware: [],
|
|
966
|
+
loader: [],
|
|
967
|
+
action: []
|
|
968
|
+
};
|
|
969
|
+
fns.forEach(
|
|
970
|
+
(fn) => fn({
|
|
971
|
+
id: route.id,
|
|
972
|
+
index: route.index,
|
|
973
|
+
path: route.path,
|
|
974
|
+
instrument(i) {
|
|
975
|
+
let keys = Object.keys(aggregated);
|
|
976
|
+
for (let key of keys) {
|
|
977
|
+
if (i[key]) {
|
|
978
|
+
aggregated[key].push(i[key]);
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
})
|
|
983
|
+
);
|
|
984
|
+
let updates = {};
|
|
985
|
+
if (typeof route.lazy === "function" && aggregated.lazy.length > 0) {
|
|
986
|
+
let instrumented = wrapImpl(aggregated.lazy, route.lazy, () => void 0);
|
|
987
|
+
if (instrumented) {
|
|
988
|
+
updates.lazy = instrumented;
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
if (typeof route.lazy === "object") {
|
|
992
|
+
let lazyObject = route.lazy;
|
|
993
|
+
["middleware", "loader", "action"].forEach((key) => {
|
|
994
|
+
let lazyFn = lazyObject[key];
|
|
995
|
+
let instrumentations = aggregated[`lazy.${key}`];
|
|
996
|
+
if (typeof lazyFn === "function" && instrumentations.length > 0) {
|
|
997
|
+
let instrumented = wrapImpl(instrumentations, lazyFn, () => void 0);
|
|
998
|
+
if (instrumented) {
|
|
999
|
+
updates.lazy = Object.assign(updates.lazy || {}, {
|
|
1000
|
+
[key]: instrumented
|
|
1001
|
+
});
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
});
|
|
1005
|
+
}
|
|
1006
|
+
["loader", "action"].forEach((key) => {
|
|
1007
|
+
let handler = route[key];
|
|
1008
|
+
if (typeof handler === "function" && aggregated[key].length > 0) {
|
|
1009
|
+
let original = 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
|
+
}
|
|
938
1180
|
|
|
939
1181
|
// lib/router/router.ts
|
|
940
1182
|
var validMutationMethodsArr = [
|
|
@@ -994,7 +1236,20 @@ function createRouter(init) {
|
|
|
994
1236
|
"You must provide a non-empty routes array to createRouter"
|
|
995
1237
|
);
|
|
996
1238
|
let hydrationRouteProperties2 = init.hydrationRouteProperties || [];
|
|
997
|
-
let
|
|
1239
|
+
let _mapRouteProperties = init.mapRouteProperties || defaultMapRouteProperties;
|
|
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
|
+
}
|
|
998
1253
|
let manifest = {};
|
|
999
1254
|
let dataRoutes = convertRoutesToDataRoutes(
|
|
1000
1255
|
init.routes,
|
|
@@ -2746,6 +3001,12 @@ function createRouter(init) {
|
|
|
2746
3001
|
updateState(newState);
|
|
2747
3002
|
}
|
|
2748
3003
|
};
|
|
3004
|
+
if (init.unstable_instrumentations) {
|
|
3005
|
+
router = instrumentClientSideRouter(
|
|
3006
|
+
router,
|
|
3007
|
+
init.unstable_instrumentations.map((i) => i.router).filter(Boolean)
|
|
3008
|
+
);
|
|
3009
|
+
}
|
|
2749
3010
|
return router;
|
|
2750
3011
|
}
|
|
2751
3012
|
function createStaticHandler(routes, opts) {
|
|
@@ -2755,7 +3016,20 @@ function createStaticHandler(routes, opts) {
|
|
|
2755
3016
|
);
|
|
2756
3017
|
let manifest = {};
|
|
2757
3018
|
let basename = (opts ? opts.basename : null) || "/";
|
|
2758
|
-
let
|
|
3019
|
+
let _mapRouteProperties = opts?.mapRouteProperties || defaultMapRouteProperties;
|
|
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
|
+
}
|
|
2759
3033
|
let dataRoutes = convertRoutesToDataRoutes(
|
|
2760
3034
|
routes,
|
|
2761
3035
|
mapRouteProperties2,
|
|
@@ -2825,6 +3099,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2825
3099
|
let response = await runServerMiddlewarePipeline(
|
|
2826
3100
|
{
|
|
2827
3101
|
request,
|
|
3102
|
+
unstable_pattern: getRoutePattern(matches.map((m) => m.route.path)),
|
|
2828
3103
|
matches,
|
|
2829
3104
|
params: matches[0].params,
|
|
2830
3105
|
// If we're calling middleware then it must be enabled so we can cast
|
|
@@ -2970,6 +3245,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2970
3245
|
let response = await runServerMiddlewarePipeline(
|
|
2971
3246
|
{
|
|
2972
3247
|
request,
|
|
3248
|
+
unstable_pattern: getRoutePattern(matches.map((m) => m.route.path)),
|
|
2973
3249
|
matches,
|
|
2974
3250
|
params: matches[0].params,
|
|
2975
3251
|
// If we're calling middleware then it must be enabled so we can cast
|
|
@@ -3245,12 +3521,14 @@ function createStaticHandler(routes, opts) {
|
|
|
3245
3521
|
// Up to but not including the boundary
|
|
3246
3522
|
matches.findIndex((m) => m.route.id === pendingActionResult[0]) - 1
|
|
3247
3523
|
) : void 0;
|
|
3524
|
+
let pattern = getRoutePattern(matches.map((m) => m.route.path));
|
|
3248
3525
|
dsMatches = matches.map((match, index) => {
|
|
3249
3526
|
if (maxIdx != null && index > maxIdx) {
|
|
3250
3527
|
return getDataStrategyMatch(
|
|
3251
3528
|
mapRouteProperties2,
|
|
3252
3529
|
manifest,
|
|
3253
3530
|
request,
|
|
3531
|
+
pattern,
|
|
3254
3532
|
match,
|
|
3255
3533
|
[],
|
|
3256
3534
|
requestContext,
|
|
@@ -3261,6 +3539,7 @@ function createStaticHandler(routes, opts) {
|
|
|
3261
3539
|
mapRouteProperties2,
|
|
3262
3540
|
manifest,
|
|
3263
3541
|
request,
|
|
3542
|
+
pattern,
|
|
3264
3543
|
match,
|
|
3265
3544
|
[],
|
|
3266
3545
|
requestContext,
|
|
@@ -3541,6 +3820,7 @@ function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest,
|
|
|
3541
3820
|
actionResult,
|
|
3542
3821
|
actionStatus
|
|
3543
3822
|
};
|
|
3823
|
+
let pattern = getRoutePattern(matches.map((m) => m.route.path));
|
|
3544
3824
|
let dsMatches = matches.map((match, index) => {
|
|
3545
3825
|
let { route } = match;
|
|
3546
3826
|
let forceShouldLoad = null;
|
|
@@ -3564,6 +3844,7 @@ function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest,
|
|
|
3564
3844
|
mapRouteProperties2,
|
|
3565
3845
|
manifest,
|
|
3566
3846
|
request,
|
|
3847
|
+
pattern,
|
|
3567
3848
|
match,
|
|
3568
3849
|
lazyRoutePropertiesToSkip,
|
|
3569
3850
|
scopedContext,
|
|
@@ -3584,6 +3865,7 @@ function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest,
|
|
|
3584
3865
|
mapRouteProperties2,
|
|
3585
3866
|
manifest,
|
|
3586
3867
|
request,
|
|
3868
|
+
pattern,
|
|
3587
3869
|
match,
|
|
3588
3870
|
lazyRoutePropertiesToSkip,
|
|
3589
3871
|
scopedContext,
|
|
@@ -4037,12 +4319,17 @@ function runClientMiddlewarePipeline(args, handler) {
|
|
|
4037
4319
|
}
|
|
4038
4320
|
}
|
|
4039
4321
|
async function runMiddlewarePipeline(args, handler, processResult, isResult, errorHandler) {
|
|
4040
|
-
let { matches, request, params, context } = args;
|
|
4322
|
+
let { matches, request, params, context, unstable_pattern } = args;
|
|
4041
4323
|
let tuples = matches.flatMap(
|
|
4042
4324
|
(m) => m.route.middleware ? m.route.middleware.map((fn) => [m.route.id, fn]) : []
|
|
4043
4325
|
);
|
|
4044
4326
|
let result = await callRouteMiddleware(
|
|
4045
|
-
{
|
|
4327
|
+
{
|
|
4328
|
+
request,
|
|
4329
|
+
params,
|
|
4330
|
+
context,
|
|
4331
|
+
unstable_pattern
|
|
4332
|
+
},
|
|
4046
4333
|
tuples,
|
|
4047
4334
|
handler,
|
|
4048
4335
|
processResult,
|
|
@@ -4120,7 +4407,7 @@ function getDataStrategyMatchLazyPromises(mapRouteProperties2, manifest, request
|
|
|
4120
4407
|
handler: lazyRoutePromises.lazyHandlerPromise
|
|
4121
4408
|
};
|
|
4122
4409
|
}
|
|
4123
|
-
function getDataStrategyMatch(mapRouteProperties2, manifest, request, match, lazyRoutePropertiesToSkip, scopedContext, shouldLoad, unstable_shouldRevalidateArgs = null) {
|
|
4410
|
+
function getDataStrategyMatch(mapRouteProperties2, manifest, request, unstable_pattern, match, lazyRoutePropertiesToSkip, scopedContext, shouldLoad, unstable_shouldRevalidateArgs = null) {
|
|
4124
4411
|
let isUsingNewApi = false;
|
|
4125
4412
|
let _lazyPromises = getDataStrategyMatchLazyPromises(
|
|
4126
4413
|
mapRouteProperties2,
|
|
@@ -4154,6 +4441,7 @@ function getDataStrategyMatch(mapRouteProperties2, manifest, request, match, laz
|
|
|
4154
4441
|
if (callHandler && !isMiddlewareOnlyRoute) {
|
|
4155
4442
|
return callLoaderOrAction({
|
|
4156
4443
|
request,
|
|
4444
|
+
unstable_pattern,
|
|
4157
4445
|
match,
|
|
4158
4446
|
lazyHandlerPromise: _lazyPromises?.handler,
|
|
4159
4447
|
lazyRoutePromise: _lazyPromises?.route,
|
|
@@ -4187,6 +4475,7 @@ function getTargetedDataStrategyMatches(mapRouteProperties2, manifest, request,
|
|
|
4187
4475
|
mapRouteProperties2,
|
|
4188
4476
|
manifest,
|
|
4189
4477
|
request,
|
|
4478
|
+
getRoutePattern(matches.map((m) => m.route.path)),
|
|
4190
4479
|
match,
|
|
4191
4480
|
lazyRoutePropertiesToSkip,
|
|
4192
4481
|
scopedContext,
|
|
@@ -4201,6 +4490,7 @@ async function callDataStrategyImpl(dataStrategyImpl, request, matches, fetcherK
|
|
|
4201
4490
|
}
|
|
4202
4491
|
let dataStrategyArgs = {
|
|
4203
4492
|
request,
|
|
4493
|
+
unstable_pattern: getRoutePattern(matches.map((m) => m.route.path)),
|
|
4204
4494
|
params: matches[0].params,
|
|
4205
4495
|
context: scopedContext,
|
|
4206
4496
|
matches
|
|
@@ -4241,6 +4531,7 @@ async function callDataStrategyImpl(dataStrategyImpl, request, matches, fetcherK
|
|
|
4241
4531
|
}
|
|
4242
4532
|
async function callLoaderOrAction({
|
|
4243
4533
|
request,
|
|
4534
|
+
unstable_pattern,
|
|
4244
4535
|
match,
|
|
4245
4536
|
lazyHandlerPromise,
|
|
4246
4537
|
lazyRoutePromise,
|
|
@@ -4267,6 +4558,7 @@ async function callLoaderOrAction({
|
|
|
4267
4558
|
return handler(
|
|
4268
4559
|
{
|
|
4269
4560
|
request,
|
|
4561
|
+
unstable_pattern,
|
|
4270
4562
|
params: match.params,
|
|
4271
4563
|
context: scopedContext
|
|
4272
4564
|
},
|
|
@@ -5552,19 +5844,6 @@ function warningOnce(key, cond, message) {
|
|
|
5552
5844
|
warning(false, message);
|
|
5553
5845
|
}
|
|
5554
5846
|
}
|
|
5555
|
-
function useRoute(...args) {
|
|
5556
|
-
const currentRouteId = useCurrentRouteId(
|
|
5557
|
-
"useRoute" /* UseRoute */
|
|
5558
|
-
);
|
|
5559
|
-
const id = args[0] ?? currentRouteId;
|
|
5560
|
-
const state = useDataRouterState("useRouteLoaderData" /* UseRouteLoaderData */);
|
|
5561
|
-
const route = state.matches.find(({ route: route2 }) => route2.id === id);
|
|
5562
|
-
if (route === void 0) return void 0;
|
|
5563
|
-
return {
|
|
5564
|
-
loaderData: state.loaderData[id],
|
|
5565
|
-
actionData: state.actionData?.[id]
|
|
5566
|
-
};
|
|
5567
|
-
}
|
|
5568
5847
|
|
|
5569
5848
|
// lib/components.tsx
|
|
5570
5849
|
import * as React3 from "react";
|
|
@@ -5647,7 +5926,8 @@ function createMemoryRouter(routes, opts) {
|
|
|
5647
5926
|
hydrationRouteProperties,
|
|
5648
5927
|
mapRouteProperties,
|
|
5649
5928
|
dataStrategy: opts?.dataStrategy,
|
|
5650
|
-
patchRoutesOnNavigation: opts?.patchRoutesOnNavigation
|
|
5929
|
+
patchRoutesOnNavigation: opts?.patchRoutesOnNavigation,
|
|
5930
|
+
unstable_instrumentations: opts?.unstable_instrumentations
|
|
5651
5931
|
}).initialize();
|
|
5652
5932
|
}
|
|
5653
5933
|
var Deferred = class {
|
|
@@ -8062,7 +8342,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
8062
8342
|
let hasInitialError = initialState && initialState.errors && route.id in initialState.errors;
|
|
8063
8343
|
let initialError = hasInitialError ? initialState?.errors?.[route.id] : void 0;
|
|
8064
8344
|
let isHydrationRequest = needsRevalidation == null && (routeModule.clientLoader?.hydrate === true || !route.hasLoader);
|
|
8065
|
-
dataRoute.loader = async ({ request, params, context }, singleFetch) => {
|
|
8345
|
+
dataRoute.loader = async ({ request, params, context, unstable_pattern }, singleFetch) => {
|
|
8066
8346
|
try {
|
|
8067
8347
|
let result = await prefetchStylesAndCallHandler(async () => {
|
|
8068
8348
|
invariant2(
|
|
@@ -8076,6 +8356,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
8076
8356
|
request,
|
|
8077
8357
|
params,
|
|
8078
8358
|
context,
|
|
8359
|
+
unstable_pattern,
|
|
8079
8360
|
async serverLoader() {
|
|
8080
8361
|
preventInvalidServerHandlerCall("loader", route);
|
|
8081
8362
|
if (isHydrationRequest) {
|
|
@@ -8101,7 +8382,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
8101
8382
|
route.hasLoader,
|
|
8102
8383
|
isSpaMode
|
|
8103
8384
|
);
|
|
8104
|
-
dataRoute.action = ({ request, params, context }, singleFetch) => {
|
|
8385
|
+
dataRoute.action = ({ request, params, context, unstable_pattern }, singleFetch) => {
|
|
8105
8386
|
return prefetchStylesAndCallHandler(async () => {
|
|
8106
8387
|
invariant2(
|
|
8107
8388
|
routeModule,
|
|
@@ -8117,6 +8398,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
8117
8398
|
request,
|
|
8118
8399
|
params,
|
|
8119
8400
|
context,
|
|
8401
|
+
unstable_pattern,
|
|
8120
8402
|
async serverAction() {
|
|
8121
8403
|
preventInvalidServerHandlerCall("action", route);
|
|
8122
8404
|
return fetchServerAction(singleFetch);
|
|
@@ -9126,7 +9408,7 @@ var isBrowser = typeof window !== "undefined" && typeof window.document !== "und
|
|
|
9126
9408
|
try {
|
|
9127
9409
|
if (isBrowser) {
|
|
9128
9410
|
window.__reactRouterVersion = // @ts-expect-error
|
|
9129
|
-
"0.0.0-experimental-
|
|
9411
|
+
"0.0.0-experimental-e0b6ce9";
|
|
9130
9412
|
}
|
|
9131
9413
|
} catch (e) {
|
|
9132
9414
|
}
|
|
@@ -9142,7 +9424,8 @@ function createBrowserRouter(routes, opts) {
|
|
|
9142
9424
|
hydrationRouteProperties,
|
|
9143
9425
|
dataStrategy: opts?.dataStrategy,
|
|
9144
9426
|
patchRoutesOnNavigation: opts?.patchRoutesOnNavigation,
|
|
9145
|
-
window: opts?.window
|
|
9427
|
+
window: opts?.window,
|
|
9428
|
+
unstable_instrumentations: opts?.unstable_instrumentations
|
|
9146
9429
|
}).initialize();
|
|
9147
9430
|
}
|
|
9148
9431
|
function createHashRouter(routes, opts) {
|
|
@@ -9157,7 +9440,8 @@ function createHashRouter(routes, opts) {
|
|
|
9157
9440
|
hydrationRouteProperties,
|
|
9158
9441
|
dataStrategy: opts?.dataStrategy,
|
|
9159
9442
|
patchRoutesOnNavigation: opts?.patchRoutesOnNavigation,
|
|
9160
|
-
window: opts?.window
|
|
9443
|
+
window: opts?.window,
|
|
9444
|
+
unstable_instrumentations: opts?.unstable_instrumentations
|
|
9161
9445
|
}).initialize();
|
|
9162
9446
|
}
|
|
9163
9447
|
function parseHydrationData() {
|
|
@@ -10242,6 +10526,7 @@ export {
|
|
|
10242
10526
|
replace,
|
|
10243
10527
|
ErrorResponseImpl,
|
|
10244
10528
|
isRouteErrorResponse,
|
|
10529
|
+
instrumentHandler,
|
|
10245
10530
|
IDLE_NAVIGATION,
|
|
10246
10531
|
IDLE_FETCHER,
|
|
10247
10532
|
IDLE_BLOCKER,
|
|
@@ -10284,7 +10569,6 @@ export {
|
|
|
10284
10569
|
useAsyncValue,
|
|
10285
10570
|
useAsyncError,
|
|
10286
10571
|
useBlocker,
|
|
10287
|
-
useRoute,
|
|
10288
10572
|
warnOnce,
|
|
10289
10573
|
mapRouteProperties,
|
|
10290
10574
|
hydrationRouteProperties,
|