react-router 0.0.0-experimental-e613d4238 → 0.0.0-experimental-4e44d47
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-YJ6T7YSE.js → chunk-7B7CUJYE.js} +345 -66
- package/dist/development/{chunk-XXC4LMW2.js → chunk-MTLWRICG.js} +164 -161
- package/dist/development/{chunk-2YVPYFDJ.mjs → chunk-PSQFTIPQ.mjs} +67 -51
- package/dist/development/{chunk-5P3HEZQU.mjs → chunk-XVVWTPHF.mjs} +307 -25
- 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-83aVZHgI.d.ts} +198 -134
- package/dist/{production/index-react-server-client-2EDmGlsZ.d.mts → development/index-react-server-client-BDG19ZQl.d.mts} +140 -77
- 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 +106 -1
- package/dist/development/index-react-server.d.ts +106 -1
- package/dist/development/index-react-server.js +181 -8
- package/dist/development/index-react-server.mjs +181 -8
- package/dist/development/index.d.mts +13 -18
- package/dist/development/index.d.ts +13 -16
- package/dist/development/index.js +161 -147
- package/dist/development/index.mjs +3 -5
- package/dist/development/instrumentation-XYmrzhe3.d.ts +1138 -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/{routeModules-BmVo7q9e.d.ts → routeModules-Bu1JamQV.d.ts} +73 -1046
- package/dist/development/{route-data-CDwqkzPE.d.mts → routeModules-CtCOLGtG.d.mts} +157 -147
- package/dist/development/{context-BqL5Eckq.d.mts → router-2BoB34m1.d.mts} +1403 -1250
- package/dist/production/{chunk-VNGQS422.mjs → chunk-GSSVRQ6M.mjs} +307 -25
- package/dist/production/{chunk-5MHETEIL.mjs → chunk-IZVJSKMU.mjs} +67 -51
- package/dist/production/{chunk-QBUHFRYZ.js → chunk-OXRQQZPR.js} +345 -66
- package/dist/production/{chunk-E4G6PZCJ.js → chunk-UNIYMJFU.js} +164 -161
- 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/{development/index-react-server-client-2EDmGlsZ.d.mts → production/index-react-server-client-83aVZHgI.d.ts} +140 -77
- package/dist/production/{index-react-server-client-DKvU8YRr.d.ts → index-react-server-client-BDG19ZQl.d.mts} +198 -134
- 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 +106 -1
- package/dist/production/index-react-server.d.ts +106 -1
- package/dist/production/index-react-server.js +181 -8
- package/dist/production/index-react-server.mjs +181 -8
- package/dist/production/index.d.mts +13 -18
- package/dist/production/index.d.ts +13 -16
- package/dist/production/index.js +161 -147
- package/dist/production/index.mjs +3 -5
- package/dist/production/instrumentation-XYmrzhe3.d.ts +1138 -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/{routeModules-BmVo7q9e.d.ts → routeModules-Bu1JamQV.d.ts} +73 -1046
- package/dist/production/{route-data-CDwqkzPE.d.mts → routeModules-CtCOLGtG.d.mts} +157 -147
- package/dist/production/{context-BqL5Eckq.d.mts → router-2BoB34m1.d.mts} +1403 -1250
- 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-4e44d47
|
|
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,229 @@ 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 getInstrumentedImplementation(impls, handler, getInfo = () => void 0) {
|
|
960
|
+
if (impls.length === 0) {
|
|
961
|
+
return null;
|
|
962
|
+
}
|
|
963
|
+
return async (...args) => {
|
|
964
|
+
let value;
|
|
965
|
+
let info = getInfo(...args);
|
|
966
|
+
await recurseRight(
|
|
967
|
+
impls,
|
|
968
|
+
info,
|
|
969
|
+
async () => {
|
|
970
|
+
value = await handler(...args);
|
|
971
|
+
},
|
|
972
|
+
impls.length - 1
|
|
973
|
+
);
|
|
974
|
+
return value;
|
|
975
|
+
};
|
|
976
|
+
}
|
|
977
|
+
async function recurseRight(impls, info, handler, index) {
|
|
978
|
+
let impl = impls[index];
|
|
979
|
+
if (!impl) {
|
|
980
|
+
await handler();
|
|
981
|
+
} else {
|
|
982
|
+
await impl(async () => {
|
|
983
|
+
await recurseRight(impls, info, handler, index - 1);
|
|
984
|
+
}, info);
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
function getInstrumentationInfo(args) {
|
|
988
|
+
let { request, context, params, pattern } = args;
|
|
989
|
+
return {
|
|
990
|
+
// pseudo "Request" with the info they may want to read from
|
|
991
|
+
request: {
|
|
992
|
+
method: request.method,
|
|
993
|
+
url: request.url,
|
|
994
|
+
// Maybe make this a proxy that only supports `get`?
|
|
995
|
+
headers: {
|
|
996
|
+
get: (...args2) => request.headers.get(...args2)
|
|
997
|
+
}
|
|
998
|
+
},
|
|
999
|
+
params: { ...params },
|
|
1000
|
+
pattern,
|
|
1001
|
+
context: {
|
|
1002
|
+
get: (...args2) => context.get(...args2)
|
|
1003
|
+
}
|
|
1004
|
+
};
|
|
1005
|
+
}
|
|
1006
|
+
function getInstrumentationsByType(instrumentations, key) {
|
|
1007
|
+
let value = [];
|
|
1008
|
+
for (let i in instrumentations) {
|
|
1009
|
+
let instrumentation = instrumentations[i];
|
|
1010
|
+
if (key in instrumentation && instrumentation[key] != null) {
|
|
1011
|
+
value.push(instrumentation[key]);
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
return value;
|
|
1015
|
+
}
|
|
1016
|
+
function getInstrumentationUpdates(fns, route) {
|
|
1017
|
+
let instrumentations = [];
|
|
1018
|
+
fns.forEach(
|
|
1019
|
+
(fn) => fn({
|
|
1020
|
+
id: route.id,
|
|
1021
|
+
index: route.index,
|
|
1022
|
+
path: route.path,
|
|
1023
|
+
instrument(i) {
|
|
1024
|
+
instrumentations.push(i);
|
|
1025
|
+
}
|
|
1026
|
+
})
|
|
1027
|
+
);
|
|
1028
|
+
let updates = {};
|
|
1029
|
+
if (instrumentations.length > 0) {
|
|
1030
|
+
["lazy", "loader", "action"].forEach((key) => {
|
|
1031
|
+
let func = route[key];
|
|
1032
|
+
if (typeof func === "function") {
|
|
1033
|
+
let original = func[UninstrumentedSymbol] ?? func;
|
|
1034
|
+
let instrumented = getInstrumentedImplementation(
|
|
1035
|
+
getInstrumentationsByType(instrumentations, key),
|
|
1036
|
+
original,
|
|
1037
|
+
key === "lazy" ? () => void 0 : (...args) => getInstrumentationInfo(
|
|
1038
|
+
args[0]
|
|
1039
|
+
)
|
|
1040
|
+
);
|
|
1041
|
+
if (instrumented) {
|
|
1042
|
+
instrumented[UninstrumentedSymbol] = original;
|
|
1043
|
+
updates[key] = instrumented;
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
});
|
|
1047
|
+
if (route.middleware && route.middleware.length > 0) {
|
|
1048
|
+
updates.middleware = route.middleware.map((middleware) => {
|
|
1049
|
+
let original = middleware[UninstrumentedSymbol] ?? middleware;
|
|
1050
|
+
let instrumented = getInstrumentedImplementation(
|
|
1051
|
+
getInstrumentationsByType(instrumentations, "middleware"),
|
|
1052
|
+
original,
|
|
1053
|
+
(...args) => getInstrumentationInfo(
|
|
1054
|
+
args[0]
|
|
1055
|
+
)
|
|
1056
|
+
);
|
|
1057
|
+
if (instrumented) {
|
|
1058
|
+
instrumented[UninstrumentedSymbol] = original;
|
|
1059
|
+
return instrumented;
|
|
1060
|
+
}
|
|
1061
|
+
return middleware;
|
|
1062
|
+
});
|
|
1063
|
+
}
|
|
1064
|
+
if (typeof route.lazy === "object") {
|
|
1065
|
+
let lazyObject = route.lazy;
|
|
1066
|
+
["middleware", "loader", "action"].forEach((key) => {
|
|
1067
|
+
let func = lazyObject[key];
|
|
1068
|
+
if (typeof func === "function") {
|
|
1069
|
+
let instrumented = getInstrumentedImplementation(
|
|
1070
|
+
getInstrumentationsByType(instrumentations, `lazy.${key}`),
|
|
1071
|
+
func
|
|
1072
|
+
);
|
|
1073
|
+
if (instrumented) {
|
|
1074
|
+
updates.lazy = Object.assign(updates.lazy || {}, {
|
|
1075
|
+
[key]: instrumented
|
|
1076
|
+
});
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
});
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
return updates;
|
|
1083
|
+
}
|
|
1084
|
+
function instrumentClientSideRouter(router, fns) {
|
|
1085
|
+
let instrumentations = [];
|
|
1086
|
+
fns.forEach(
|
|
1087
|
+
(fn) => fn({
|
|
1088
|
+
instrument(i) {
|
|
1089
|
+
instrumentations.push(i);
|
|
1090
|
+
}
|
|
1091
|
+
})
|
|
1092
|
+
);
|
|
1093
|
+
if (instrumentations.length > 0) {
|
|
1094
|
+
let navigate = router.navigate[UninstrumentedSymbol] ?? router.navigate;
|
|
1095
|
+
let instrumentedNavigate = getInstrumentedImplementation(
|
|
1096
|
+
getInstrumentationsByType(instrumentations, "navigate"),
|
|
1097
|
+
navigate,
|
|
1098
|
+
(...args) => {
|
|
1099
|
+
let [to, opts] = args;
|
|
1100
|
+
opts = opts ?? {};
|
|
1101
|
+
let info = {
|
|
1102
|
+
to: typeof to === "number" || typeof to === "string" ? to : to ? createPath(to) : ".",
|
|
1103
|
+
currentUrl: createPath(router.state.location),
|
|
1104
|
+
..."formMethod" in opts ? { formMethod: opts.formMethod } : {},
|
|
1105
|
+
..."formEncType" in opts ? { formEncType: opts.formEncType } : {},
|
|
1106
|
+
..."formData" in opts ? { formData: opts.formData } : {},
|
|
1107
|
+
..."body" in opts ? { body: opts.body } : {}
|
|
1108
|
+
};
|
|
1109
|
+
return info;
|
|
1110
|
+
}
|
|
1111
|
+
);
|
|
1112
|
+
if (instrumentedNavigate) {
|
|
1113
|
+
instrumentedNavigate[UninstrumentedSymbol] = navigate;
|
|
1114
|
+
router.navigate = instrumentedNavigate;
|
|
1115
|
+
}
|
|
1116
|
+
let fetch2 = router.fetch[UninstrumentedSymbol] ?? router.fetch;
|
|
1117
|
+
let instrumentedFetch = getInstrumentedImplementation(
|
|
1118
|
+
getInstrumentationsByType(instrumentations, "fetch"),
|
|
1119
|
+
fetch2,
|
|
1120
|
+
(...args) => {
|
|
1121
|
+
let [key, , href, opts] = args;
|
|
1122
|
+
opts = opts ?? {};
|
|
1123
|
+
let info = {
|
|
1124
|
+
href: href ?? ".",
|
|
1125
|
+
currentUrl: createPath(router.state.location),
|
|
1126
|
+
fetcherKey: key,
|
|
1127
|
+
..."formMethod" in opts ? { formMethod: opts.formMethod } : {},
|
|
1128
|
+
..."formEncType" in opts ? { formEncType: opts.formEncType } : {},
|
|
1129
|
+
..."formData" in opts ? { formData: opts.formData } : {},
|
|
1130
|
+
..."body" in opts ? { body: opts.body } : {}
|
|
1131
|
+
};
|
|
1132
|
+
return info;
|
|
1133
|
+
}
|
|
1134
|
+
);
|
|
1135
|
+
if (instrumentedFetch) {
|
|
1136
|
+
instrumentedFetch[UninstrumentedSymbol] = fetch2;
|
|
1137
|
+
router.fetch = instrumentedFetch;
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
return router;
|
|
1141
|
+
}
|
|
1142
|
+
function instrumentHandler(handler, fns) {
|
|
1143
|
+
let instrumentations = [];
|
|
1144
|
+
fns.forEach(
|
|
1145
|
+
(fn) => fn({
|
|
1146
|
+
instrument(i) {
|
|
1147
|
+
instrumentations.push(i);
|
|
1148
|
+
}
|
|
1149
|
+
})
|
|
1150
|
+
);
|
|
1151
|
+
if (instrumentations.length === 0) {
|
|
1152
|
+
return handler;
|
|
1153
|
+
}
|
|
1154
|
+
let instrumentedHandler = getInstrumentedImplementation(
|
|
1155
|
+
getInstrumentationsByType(instrumentations, "request"),
|
|
1156
|
+
handler,
|
|
1157
|
+
(...args) => {
|
|
1158
|
+
let [request, context] = args;
|
|
1159
|
+
let info = {
|
|
1160
|
+
request: {
|
|
1161
|
+
method: request.method,
|
|
1162
|
+
url: request.url,
|
|
1163
|
+
headers: {
|
|
1164
|
+
get: (...args2) => request.headers.get(...args2)
|
|
1165
|
+
}
|
|
1166
|
+
},
|
|
1167
|
+
context: {
|
|
1168
|
+
get: (ctx) => context ? context.get(ctx) : void 0
|
|
1169
|
+
}
|
|
1170
|
+
};
|
|
1171
|
+
return info;
|
|
1172
|
+
}
|
|
1173
|
+
);
|
|
1174
|
+
return instrumentedHandler ?? handler;
|
|
1175
|
+
}
|
|
938
1176
|
|
|
939
1177
|
// lib/router/router.ts
|
|
940
1178
|
var validMutationMethodsArr = [
|
|
@@ -994,7 +1232,20 @@ function createRouter(init) {
|
|
|
994
1232
|
"You must provide a non-empty routes array to createRouter"
|
|
995
1233
|
);
|
|
996
1234
|
let hydrationRouteProperties2 = init.hydrationRouteProperties || [];
|
|
997
|
-
let
|
|
1235
|
+
let _mapRouteProperties = init.mapRouteProperties || defaultMapRouteProperties;
|
|
1236
|
+
let mapRouteProperties2 = _mapRouteProperties;
|
|
1237
|
+
if (init.unstable_instrumentations) {
|
|
1238
|
+
let instrumentations = init.unstable_instrumentations;
|
|
1239
|
+
mapRouteProperties2 = (route) => {
|
|
1240
|
+
return {
|
|
1241
|
+
..._mapRouteProperties(route),
|
|
1242
|
+
...getInstrumentationUpdates(
|
|
1243
|
+
instrumentations.map((i) => i.route).filter(Boolean),
|
|
1244
|
+
route
|
|
1245
|
+
)
|
|
1246
|
+
};
|
|
1247
|
+
};
|
|
1248
|
+
}
|
|
998
1249
|
let manifest = {};
|
|
999
1250
|
let dataRoutes = convertRoutesToDataRoutes(
|
|
1000
1251
|
init.routes,
|
|
@@ -2746,6 +2997,12 @@ function createRouter(init) {
|
|
|
2746
2997
|
updateState(newState);
|
|
2747
2998
|
}
|
|
2748
2999
|
};
|
|
3000
|
+
if (init.unstable_instrumentations) {
|
|
3001
|
+
router = instrumentClientSideRouter(
|
|
3002
|
+
router,
|
|
3003
|
+
init.unstable_instrumentations.map((i) => i.router).filter(Boolean)
|
|
3004
|
+
);
|
|
3005
|
+
}
|
|
2749
3006
|
return router;
|
|
2750
3007
|
}
|
|
2751
3008
|
function createStaticHandler(routes, opts) {
|
|
@@ -2755,7 +3012,20 @@ function createStaticHandler(routes, opts) {
|
|
|
2755
3012
|
);
|
|
2756
3013
|
let manifest = {};
|
|
2757
3014
|
let basename = (opts ? opts.basename : null) || "/";
|
|
2758
|
-
let
|
|
3015
|
+
let _mapRouteProperties = opts?.mapRouteProperties || defaultMapRouteProperties;
|
|
3016
|
+
let mapRouteProperties2 = _mapRouteProperties;
|
|
3017
|
+
if (opts?.unstable_instrumentations) {
|
|
3018
|
+
let instrumentations = opts.unstable_instrumentations;
|
|
3019
|
+
mapRouteProperties2 = (route) => {
|
|
3020
|
+
return {
|
|
3021
|
+
..._mapRouteProperties(route),
|
|
3022
|
+
...getInstrumentationUpdates(
|
|
3023
|
+
instrumentations.map((i) => i.route).filter(Boolean),
|
|
3024
|
+
route
|
|
3025
|
+
)
|
|
3026
|
+
};
|
|
3027
|
+
};
|
|
3028
|
+
}
|
|
2759
3029
|
let dataRoutes = convertRoutesToDataRoutes(
|
|
2760
3030
|
routes,
|
|
2761
3031
|
mapRouteProperties2,
|
|
@@ -2825,6 +3095,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2825
3095
|
let response = await runServerMiddlewarePipeline(
|
|
2826
3096
|
{
|
|
2827
3097
|
request,
|
|
3098
|
+
pattern: getRoutePattern(matches.map((m) => m.route.path)),
|
|
2828
3099
|
matches,
|
|
2829
3100
|
params: matches[0].params,
|
|
2830
3101
|
// If we're calling middleware then it must be enabled so we can cast
|
|
@@ -2970,6 +3241,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2970
3241
|
let response = await runServerMiddlewarePipeline(
|
|
2971
3242
|
{
|
|
2972
3243
|
request,
|
|
3244
|
+
pattern: getRoutePattern(matches.map((m) => m.route.path)),
|
|
2973
3245
|
matches,
|
|
2974
3246
|
params: matches[0].params,
|
|
2975
3247
|
// If we're calling middleware then it must be enabled so we can cast
|
|
@@ -3251,6 +3523,7 @@ function createStaticHandler(routes, opts) {
|
|
|
3251
3523
|
mapRouteProperties2,
|
|
3252
3524
|
manifest,
|
|
3253
3525
|
request,
|
|
3526
|
+
getRoutePattern(matches.map((m) => m.route.path)),
|
|
3254
3527
|
match,
|
|
3255
3528
|
[],
|
|
3256
3529
|
requestContext,
|
|
@@ -3261,6 +3534,7 @@ function createStaticHandler(routes, opts) {
|
|
|
3261
3534
|
mapRouteProperties2,
|
|
3262
3535
|
manifest,
|
|
3263
3536
|
request,
|
|
3537
|
+
getRoutePattern(matches.map((m) => m.route.path)),
|
|
3264
3538
|
match,
|
|
3265
3539
|
[],
|
|
3266
3540
|
requestContext,
|
|
@@ -3564,6 +3838,7 @@ function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest,
|
|
|
3564
3838
|
mapRouteProperties2,
|
|
3565
3839
|
manifest,
|
|
3566
3840
|
request,
|
|
3841
|
+
getRoutePattern(matches.map((m) => m.route.path)),
|
|
3567
3842
|
match,
|
|
3568
3843
|
lazyRoutePropertiesToSkip,
|
|
3569
3844
|
scopedContext,
|
|
@@ -3584,6 +3859,7 @@ function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest,
|
|
|
3584
3859
|
mapRouteProperties2,
|
|
3585
3860
|
manifest,
|
|
3586
3861
|
request,
|
|
3862
|
+
getRoutePattern(matches.map((m) => m.route.path)),
|
|
3587
3863
|
match,
|
|
3588
3864
|
lazyRoutePropertiesToSkip,
|
|
3589
3865
|
scopedContext,
|
|
@@ -4042,7 +4318,12 @@ async function runMiddlewarePipeline(args, handler, processResult, isResult, err
|
|
|
4042
4318
|
(m) => m.route.middleware ? m.route.middleware.map((fn) => [m.route.id, fn]) : []
|
|
4043
4319
|
);
|
|
4044
4320
|
let result = await callRouteMiddleware(
|
|
4045
|
-
{
|
|
4321
|
+
{
|
|
4322
|
+
request,
|
|
4323
|
+
params,
|
|
4324
|
+
context,
|
|
4325
|
+
pattern: getRoutePattern(matches.map((m) => m.route.path))
|
|
4326
|
+
},
|
|
4046
4327
|
tuples,
|
|
4047
4328
|
handler,
|
|
4048
4329
|
processResult,
|
|
@@ -4120,7 +4401,7 @@ function getDataStrategyMatchLazyPromises(mapRouteProperties2, manifest, request
|
|
|
4120
4401
|
handler: lazyRoutePromises.lazyHandlerPromise
|
|
4121
4402
|
};
|
|
4122
4403
|
}
|
|
4123
|
-
function getDataStrategyMatch(mapRouteProperties2, manifest, request, match, lazyRoutePropertiesToSkip, scopedContext, shouldLoad, unstable_shouldRevalidateArgs = null) {
|
|
4404
|
+
function getDataStrategyMatch(mapRouteProperties2, manifest, request, pattern, match, lazyRoutePropertiesToSkip, scopedContext, shouldLoad, unstable_shouldRevalidateArgs = null) {
|
|
4124
4405
|
let isUsingNewApi = false;
|
|
4125
4406
|
let _lazyPromises = getDataStrategyMatchLazyPromises(
|
|
4126
4407
|
mapRouteProperties2,
|
|
@@ -4154,6 +4435,7 @@ function getDataStrategyMatch(mapRouteProperties2, manifest, request, match, laz
|
|
|
4154
4435
|
if (callHandler && !isMiddlewareOnlyRoute) {
|
|
4155
4436
|
return callLoaderOrAction({
|
|
4156
4437
|
request,
|
|
4438
|
+
pattern,
|
|
4157
4439
|
match,
|
|
4158
4440
|
lazyHandlerPromise: _lazyPromises?.handler,
|
|
4159
4441
|
lazyRoutePromise: _lazyPromises?.route,
|
|
@@ -4187,6 +4469,7 @@ function getTargetedDataStrategyMatches(mapRouteProperties2, manifest, request,
|
|
|
4187
4469
|
mapRouteProperties2,
|
|
4188
4470
|
manifest,
|
|
4189
4471
|
request,
|
|
4472
|
+
getRoutePattern(matches.map((m) => m.route.path)),
|
|
4190
4473
|
match,
|
|
4191
4474
|
lazyRoutePropertiesToSkip,
|
|
4192
4475
|
scopedContext,
|
|
@@ -4201,6 +4484,7 @@ async function callDataStrategyImpl(dataStrategyImpl, request, matches, fetcherK
|
|
|
4201
4484
|
}
|
|
4202
4485
|
let dataStrategyArgs = {
|
|
4203
4486
|
request,
|
|
4487
|
+
pattern: getRoutePattern(matches.map((m) => m.route.path)),
|
|
4204
4488
|
params: matches[0].params,
|
|
4205
4489
|
context: scopedContext,
|
|
4206
4490
|
matches
|
|
@@ -4241,6 +4525,7 @@ async function callDataStrategyImpl(dataStrategyImpl, request, matches, fetcherK
|
|
|
4241
4525
|
}
|
|
4242
4526
|
async function callLoaderOrAction({
|
|
4243
4527
|
request,
|
|
4528
|
+
pattern,
|
|
4244
4529
|
match,
|
|
4245
4530
|
lazyHandlerPromise,
|
|
4246
4531
|
lazyRoutePromise,
|
|
@@ -4267,6 +4552,7 @@ async function callLoaderOrAction({
|
|
|
4267
4552
|
return handler(
|
|
4268
4553
|
{
|
|
4269
4554
|
request,
|
|
4555
|
+
pattern,
|
|
4270
4556
|
params: match.params,
|
|
4271
4557
|
context: scopedContext
|
|
4272
4558
|
},
|
|
@@ -5552,15 +5838,6 @@ function warningOnce(key, cond, message) {
|
|
|
5552
5838
|
warning(false, message);
|
|
5553
5839
|
}
|
|
5554
5840
|
}
|
|
5555
|
-
function useRoute(routeId) {
|
|
5556
|
-
const state = useDataRouterState("useRouteLoaderData" /* UseRouteLoaderData */);
|
|
5557
|
-
const route = state.matches.find(({ route: route2 }) => route2.id === routeId);
|
|
5558
|
-
if (route === void 0) return void 0;
|
|
5559
|
-
return {
|
|
5560
|
-
loaderData: state.loaderData[routeId],
|
|
5561
|
-
actionData: state.actionData?.[routeId]
|
|
5562
|
-
};
|
|
5563
|
-
}
|
|
5564
5841
|
|
|
5565
5842
|
// lib/components.tsx
|
|
5566
5843
|
import * as React3 from "react";
|
|
@@ -5643,7 +5920,8 @@ function createMemoryRouter(routes, opts) {
|
|
|
5643
5920
|
hydrationRouteProperties,
|
|
5644
5921
|
mapRouteProperties,
|
|
5645
5922
|
dataStrategy: opts?.dataStrategy,
|
|
5646
|
-
patchRoutesOnNavigation: opts?.patchRoutesOnNavigation
|
|
5923
|
+
patchRoutesOnNavigation: opts?.patchRoutesOnNavigation,
|
|
5924
|
+
unstable_instrumentations: opts?.unstable_instrumentations
|
|
5647
5925
|
}).initialize();
|
|
5648
5926
|
}
|
|
5649
5927
|
var Deferred = class {
|
|
@@ -8058,7 +8336,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
8058
8336
|
let hasInitialError = initialState && initialState.errors && route.id in initialState.errors;
|
|
8059
8337
|
let initialError = hasInitialError ? initialState?.errors?.[route.id] : void 0;
|
|
8060
8338
|
let isHydrationRequest = needsRevalidation == null && (routeModule.clientLoader?.hydrate === true || !route.hasLoader);
|
|
8061
|
-
dataRoute.loader = async ({ request, params, context }, singleFetch) => {
|
|
8339
|
+
dataRoute.loader = async ({ request, params, context, pattern }, singleFetch) => {
|
|
8062
8340
|
try {
|
|
8063
8341
|
let result = await prefetchStylesAndCallHandler(async () => {
|
|
8064
8342
|
invariant2(
|
|
@@ -8072,6 +8350,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
8072
8350
|
request,
|
|
8073
8351
|
params,
|
|
8074
8352
|
context,
|
|
8353
|
+
pattern,
|
|
8075
8354
|
async serverLoader() {
|
|
8076
8355
|
preventInvalidServerHandlerCall("loader", route);
|
|
8077
8356
|
if (isHydrationRequest) {
|
|
@@ -8097,7 +8376,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
8097
8376
|
route.hasLoader,
|
|
8098
8377
|
isSpaMode
|
|
8099
8378
|
);
|
|
8100
|
-
dataRoute.action = ({ request, params, context }, singleFetch) => {
|
|
8379
|
+
dataRoute.action = ({ request, params, context, pattern }, singleFetch) => {
|
|
8101
8380
|
return prefetchStylesAndCallHandler(async () => {
|
|
8102
8381
|
invariant2(
|
|
8103
8382
|
routeModule,
|
|
@@ -8113,6 +8392,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
8113
8392
|
request,
|
|
8114
8393
|
params,
|
|
8115
8394
|
context,
|
|
8395
|
+
pattern,
|
|
8116
8396
|
async serverAction() {
|
|
8117
8397
|
preventInvalidServerHandlerCall("action", route);
|
|
8118
8398
|
return fetchServerAction(singleFetch);
|
|
@@ -9122,7 +9402,7 @@ var isBrowser = typeof window !== "undefined" && typeof window.document !== "und
|
|
|
9122
9402
|
try {
|
|
9123
9403
|
if (isBrowser) {
|
|
9124
9404
|
window.__reactRouterVersion = // @ts-expect-error
|
|
9125
|
-
"0.0.0-experimental-
|
|
9405
|
+
"0.0.0-experimental-4e44d47";
|
|
9126
9406
|
}
|
|
9127
9407
|
} catch (e) {
|
|
9128
9408
|
}
|
|
@@ -9138,7 +9418,8 @@ function createBrowserRouter(routes, opts) {
|
|
|
9138
9418
|
hydrationRouteProperties,
|
|
9139
9419
|
dataStrategy: opts?.dataStrategy,
|
|
9140
9420
|
patchRoutesOnNavigation: opts?.patchRoutesOnNavigation,
|
|
9141
|
-
window: opts?.window
|
|
9421
|
+
window: opts?.window,
|
|
9422
|
+
unstable_instrumentations: opts?.unstable_instrumentations
|
|
9142
9423
|
}).initialize();
|
|
9143
9424
|
}
|
|
9144
9425
|
function createHashRouter(routes, opts) {
|
|
@@ -9153,7 +9434,8 @@ function createHashRouter(routes, opts) {
|
|
|
9153
9434
|
hydrationRouteProperties,
|
|
9154
9435
|
dataStrategy: opts?.dataStrategy,
|
|
9155
9436
|
patchRoutesOnNavigation: opts?.patchRoutesOnNavigation,
|
|
9156
|
-
window: opts?.window
|
|
9437
|
+
window: opts?.window,
|
|
9438
|
+
unstable_instrumentations: opts?.unstable_instrumentations
|
|
9157
9439
|
}).initialize();
|
|
9158
9440
|
}
|
|
9159
9441
|
function parseHydrationData() {
|
|
@@ -10238,6 +10520,7 @@ export {
|
|
|
10238
10520
|
replace,
|
|
10239
10521
|
ErrorResponseImpl,
|
|
10240
10522
|
isRouteErrorResponse,
|
|
10523
|
+
instrumentHandler,
|
|
10241
10524
|
IDLE_NAVIGATION,
|
|
10242
10525
|
IDLE_FETCHER,
|
|
10243
10526
|
IDLE_BLOCKER,
|
|
@@ -10280,7 +10563,6 @@ export {
|
|
|
10280
10563
|
useAsyncValue,
|
|
10281
10564
|
useAsyncError,
|
|
10282
10565
|
useBlocker,
|
|
10283
|
-
useRoute,
|
|
10284
10566
|
warnOnce,
|
|
10285
10567
|
mapRouteProperties,
|
|
10286
10568
|
hydrationRouteProperties,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { R as RouterProviderProps$1, a as RouterInit, u as unstable_ClientOnErrorFunction } from './
|
|
2
|
+
import { R as RouterProviderProps$1, a as RouterInit, u as unstable_ClientInstrumentation, b as unstable_ClientOnErrorFunction } from './router-2BoB34m1.mjs';
|
|
3
3
|
import './browser-z32v5KVN.mjs';
|
|
4
4
|
|
|
5
5
|
type RouterProviderProps = Omit<RouterProviderProps$1, "flushSync">;
|
|
@@ -12,12 +12,67 @@ declare function RouterProvider(props: Omit<RouterProviderProps, "flushSync">):
|
|
|
12
12
|
*/
|
|
13
13
|
interface HydratedRouterProps {
|
|
14
14
|
/**
|
|
15
|
-
* Context
|
|
16
|
-
*
|
|
15
|
+
* Context factory function to be passed through to {@link createBrowserRouter}.
|
|
16
|
+
* This function will be called to create a fresh `context` instance on each
|
|
17
|
+
* navigation/fetch and made available to
|
|
17
18
|
* [`clientAction`](../../start/framework/route-module#clientAction)/[`clientLoader`](../../start/framework/route-module#clientLoader)
|
|
18
|
-
* functions
|
|
19
|
+
* functions.
|
|
19
20
|
*/
|
|
20
21
|
getContext?: RouterInit["getContext"];
|
|
22
|
+
/**
|
|
23
|
+
* Array of instrumentation objects allowing you to instrument the router and
|
|
24
|
+
* individual routes prior to router initialization (and on any subsequently
|
|
25
|
+
* added routes via `route.lazy` or `patchRoutesOnNavigation`). This is
|
|
26
|
+
* mostly useful for observability such as wrapping navigations, fetches,
|
|
27
|
+
* as well as route loaders/actions/middlewares with logging and/or performance
|
|
28
|
+
* tracing.
|
|
29
|
+
*
|
|
30
|
+
* ```tsx
|
|
31
|
+
* startTransition(() => {
|
|
32
|
+
* hydrateRoot(
|
|
33
|
+
* document,
|
|
34
|
+
* <HydratedRouter unstable_instrumentations={[logging]} />
|
|
35
|
+
* );
|
|
36
|
+
* });
|
|
37
|
+
*
|
|
38
|
+
* const logging = {
|
|
39
|
+
* router({ instrument }) {
|
|
40
|
+
* instrument({
|
|
41
|
+
* navigate: (impl, { to }) => logExecution(`navigate ${to}`, impl),
|
|
42
|
+
* fetch: (impl, { to }) => logExecution(`fetch ${to}`, impl)
|
|
43
|
+
* });
|
|
44
|
+
* },
|
|
45
|
+
* route({ instrument, id }) {
|
|
46
|
+
* instrument({
|
|
47
|
+
* middleware: (impl, { request }) => logExecution(
|
|
48
|
+
* `middleware ${request.url} (route ${id})`,
|
|
49
|
+
* impl
|
|
50
|
+
* ),
|
|
51
|
+
* loader: (impl, { request }) => logExecution(
|
|
52
|
+
* `loader ${request.url} (route ${id})`,
|
|
53
|
+
* impl
|
|
54
|
+
* ),
|
|
55
|
+
* action: (impl, { request }) => logExecution(
|
|
56
|
+
* `action ${request.url} (route ${id})`,
|
|
57
|
+
* impl
|
|
58
|
+
* ),
|
|
59
|
+
* })
|
|
60
|
+
* }
|
|
61
|
+
* };
|
|
62
|
+
*
|
|
63
|
+
* async function logExecution(label: string, impl: () => Promise<void>) {
|
|
64
|
+
* let start = performance.now();
|
|
65
|
+
* console.log(`start ${label}`);
|
|
66
|
+
* try {
|
|
67
|
+
* await impl();
|
|
68
|
+
* } finally {
|
|
69
|
+
* let end = performance.now();
|
|
70
|
+
* console.log(`end ${label} (${Math.round(end - start)}ms)`);
|
|
71
|
+
* }
|
|
72
|
+
* }
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
unstable_instrumentations?: unstable_ClientInstrumentation[];
|
|
21
76
|
/**
|
|
22
77
|
* An error handler function that will be called for any loader/action/render
|
|
23
78
|
* errors that are encountered in your application. This is useful for
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { RouterProviderProps as RouterProviderProps$1, RouterInit, unstable_ClientOnErrorFunction } from 'react-router';
|
|
3
|
+
import { u as unstable_ClientInstrumentation } from './instrumentation-XYmrzhe3.js';
|
|
3
4
|
|
|
4
5
|
type RouterProviderProps = Omit<RouterProviderProps$1, "flushSync">;
|
|
5
6
|
declare function RouterProvider(props: Omit<RouterProviderProps, "flushSync">): React.JSX.Element;
|
|
@@ -11,12 +12,67 @@ declare function RouterProvider(props: Omit<RouterProviderProps, "flushSync">):
|
|
|
11
12
|
*/
|
|
12
13
|
interface HydratedRouterProps {
|
|
13
14
|
/**
|
|
14
|
-
* Context
|
|
15
|
-
*
|
|
15
|
+
* Context factory function to be passed through to {@link createBrowserRouter}.
|
|
16
|
+
* This function will be called to create a fresh `context` instance on each
|
|
17
|
+
* navigation/fetch and made available to
|
|
16
18
|
* [`clientAction`](../../start/framework/route-module#clientAction)/[`clientLoader`](../../start/framework/route-module#clientLoader)
|
|
17
|
-
* functions
|
|
19
|
+
* functions.
|
|
18
20
|
*/
|
|
19
21
|
getContext?: RouterInit["getContext"];
|
|
22
|
+
/**
|
|
23
|
+
* Array of instrumentation objects allowing you to instrument the router and
|
|
24
|
+
* individual routes prior to router initialization (and on any subsequently
|
|
25
|
+
* added routes via `route.lazy` or `patchRoutesOnNavigation`). This is
|
|
26
|
+
* mostly useful for observability such as wrapping navigations, fetches,
|
|
27
|
+
* as well as route loaders/actions/middlewares with logging and/or performance
|
|
28
|
+
* tracing.
|
|
29
|
+
*
|
|
30
|
+
* ```tsx
|
|
31
|
+
* startTransition(() => {
|
|
32
|
+
* hydrateRoot(
|
|
33
|
+
* document,
|
|
34
|
+
* <HydratedRouter unstable_instrumentations={[logging]} />
|
|
35
|
+
* );
|
|
36
|
+
* });
|
|
37
|
+
*
|
|
38
|
+
* const logging = {
|
|
39
|
+
* router({ instrument }) {
|
|
40
|
+
* instrument({
|
|
41
|
+
* navigate: (impl, { to }) => logExecution(`navigate ${to}`, impl),
|
|
42
|
+
* fetch: (impl, { to }) => logExecution(`fetch ${to}`, impl)
|
|
43
|
+
* });
|
|
44
|
+
* },
|
|
45
|
+
* route({ instrument, id }) {
|
|
46
|
+
* instrument({
|
|
47
|
+
* middleware: (impl, { request }) => logExecution(
|
|
48
|
+
* `middleware ${request.url} (route ${id})`,
|
|
49
|
+
* impl
|
|
50
|
+
* ),
|
|
51
|
+
* loader: (impl, { request }) => logExecution(
|
|
52
|
+
* `loader ${request.url} (route ${id})`,
|
|
53
|
+
* impl
|
|
54
|
+
* ),
|
|
55
|
+
* action: (impl, { request }) => logExecution(
|
|
56
|
+
* `action ${request.url} (route ${id})`,
|
|
57
|
+
* impl
|
|
58
|
+
* ),
|
|
59
|
+
* })
|
|
60
|
+
* }
|
|
61
|
+
* };
|
|
62
|
+
*
|
|
63
|
+
* async function logExecution(label: string, impl: () => Promise<void>) {
|
|
64
|
+
* let start = performance.now();
|
|
65
|
+
* console.log(`start ${label}`);
|
|
66
|
+
* try {
|
|
67
|
+
* await impl();
|
|
68
|
+
* } finally {
|
|
69
|
+
* let end = performance.now();
|
|
70
|
+
* console.log(`end ${label} (${Math.round(end - start)}ms)`);
|
|
71
|
+
* }
|
|
72
|
+
* }
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
unstable_instrumentations?: unstable_ClientInstrumentation[];
|
|
20
76
|
/**
|
|
21
77
|
* An error handler function that will be called for any loader/action/render
|
|
22
78
|
* errors that are encountered in your application. This is useful for
|