react-router 0.0.0-experimental-e2130f538 → 0.0.0-experimental-73e447577
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 +0 -35
- package/dist/development/{chunk-KLLSQY3I.mjs → chunk-NKIXC2FA.mjs} +131 -116
- package/dist/development/{chunk-KNNCBCIS.mjs → chunk-PF7FO4KS.mjs} +310 -135
- package/dist/{production/chunk-D5G4H67X.js → development/chunk-SOMUQ5BV.js} +154 -265
- package/dist/development/{chunk-VU2GHDHY.js → chunk-WQE2SM7S.js} +349 -63
- 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 +183 -14
- package/dist/development/index-react-server.mjs +183 -14
- package/dist/development/index.d.mts +10 -10
- package/dist/development/index.d.ts +10 -8
- package/dist/development/index.js +223 -208
- package/dist/development/index.mjs +3 -3
- package/dist/development/instrumentation-XYmrzhe3.d.ts +1138 -0
- package/dist/development/lib/types/internal.d.mts +2 -2
- package/dist/development/lib/types/internal.d.ts +2 -1
- package/dist/development/lib/types/internal.js +1 -1
- package/dist/development/lib/types/internal.mjs +1 -1
- 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/{development/chunk-LMUBLF7X.js → production/chunk-TA3WUUL6.js} +154 -265
- package/dist/production/{chunk-KBACS3E4.mjs → chunk-TUGDEB6V.mjs} +131 -116
- package/dist/production/{chunk-4OVLJFUE.js → chunk-VRFRIIGI.js} +349 -63
- package/dist/production/{chunk-PXZXGDXW.mjs → chunk-YUNRQEIK.mjs} +310 -135
- 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 +183 -14
- package/dist/production/index-react-server.mjs +183 -14
- package/dist/production/index.d.mts +10 -10
- package/dist/production/index.d.ts +10 -8
- package/dist/production/index.js +223 -208
- package/dist/production/index.mjs +3 -3
- package/dist/production/instrumentation-XYmrzhe3.d.ts +1138 -0
- package/dist/production/lib/types/internal.d.mts +2 -2
- package/dist/production/lib/types/internal.d.ts +2 -1
- package/dist/production/lib/types/internal.js +1 -1
- package/dist/production/lib/types/internal.mjs +1 -1
- 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-73e447577
|
|
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,
|
|
@@ -4148,12 +4429,10 @@ function getDataStrategyMatch(mapRouteProperties2, manifest, request, match, laz
|
|
|
4148
4429
|
return shouldRevalidateLoader(match, unstable_shouldRevalidateArgs);
|
|
4149
4430
|
},
|
|
4150
4431
|
resolve(handlerOverride) {
|
|
4151
|
-
|
|
4152
|
-
let callHandler = isUsingNewApi || shouldLoad || handlerOverride && !isMutationMethod(request.method) && (lazy || loader);
|
|
4153
|
-
let isMiddlewareOnlyRoute = middleware && middleware.length > 0 && !loader && !lazy;
|
|
4154
|
-
if (callHandler && !isMiddlewareOnlyRoute) {
|
|
4432
|
+
if (isUsingNewApi || shouldLoad || handlerOverride && !isMutationMethod(request.method) && (match.route.lazy || match.route.loader)) {
|
|
4155
4433
|
return callLoaderOrAction({
|
|
4156
4434
|
request,
|
|
4435
|
+
pattern,
|
|
4157
4436
|
match,
|
|
4158
4437
|
lazyHandlerPromise: _lazyPromises?.handler,
|
|
4159
4438
|
lazyRoutePromise: _lazyPromises?.route,
|
|
@@ -4187,6 +4466,7 @@ function getTargetedDataStrategyMatches(mapRouteProperties2, manifest, request,
|
|
|
4187
4466
|
mapRouteProperties2,
|
|
4188
4467
|
manifest,
|
|
4189
4468
|
request,
|
|
4469
|
+
getRoutePattern(matches.map((m) => m.route.path)),
|
|
4190
4470
|
match,
|
|
4191
4471
|
lazyRoutePropertiesToSkip,
|
|
4192
4472
|
scopedContext,
|
|
@@ -4201,6 +4481,7 @@ async function callDataStrategyImpl(dataStrategyImpl, request, matches, fetcherK
|
|
|
4201
4481
|
}
|
|
4202
4482
|
let dataStrategyArgs = {
|
|
4203
4483
|
request,
|
|
4484
|
+
pattern: getRoutePattern(matches.map((m) => m.route.path)),
|
|
4204
4485
|
params: matches[0].params,
|
|
4205
4486
|
context: scopedContext,
|
|
4206
4487
|
matches
|
|
@@ -4241,6 +4522,7 @@ async function callDataStrategyImpl(dataStrategyImpl, request, matches, fetcherK
|
|
|
4241
4522
|
}
|
|
4242
4523
|
async function callLoaderOrAction({
|
|
4243
4524
|
request,
|
|
4525
|
+
pattern,
|
|
4244
4526
|
match,
|
|
4245
4527
|
lazyHandlerPromise,
|
|
4246
4528
|
lazyRoutePromise,
|
|
@@ -4267,6 +4549,7 @@ async function callLoaderOrAction({
|
|
|
4267
4549
|
return handler(
|
|
4268
4550
|
{
|
|
4269
4551
|
request,
|
|
4552
|
+
pattern,
|
|
4270
4553
|
params: match.params,
|
|
4271
4554
|
context: scopedContext
|
|
4272
4555
|
},
|
|
@@ -5634,7 +5917,8 @@ function createMemoryRouter(routes, opts) {
|
|
|
5634
5917
|
hydrationRouteProperties,
|
|
5635
5918
|
mapRouteProperties,
|
|
5636
5919
|
dataStrategy: opts?.dataStrategy,
|
|
5637
|
-
patchRoutesOnNavigation: opts?.patchRoutesOnNavigation
|
|
5920
|
+
patchRoutesOnNavigation: opts?.patchRoutesOnNavigation,
|
|
5921
|
+
unstable_instrumentations: opts?.unstable_instrumentations
|
|
5638
5922
|
}).initialize();
|
|
5639
5923
|
}
|
|
5640
5924
|
var Deferred = class {
|
|
@@ -5656,119 +5940,6 @@ var Deferred = class {
|
|
|
5656
5940
|
});
|
|
5657
5941
|
}
|
|
5658
5942
|
};
|
|
5659
|
-
function shallowDiff(a, b) {
|
|
5660
|
-
if (a === b) {
|
|
5661
|
-
return false;
|
|
5662
|
-
}
|
|
5663
|
-
let aKeys = Object.keys(a);
|
|
5664
|
-
let bKeys = Object.keys(b);
|
|
5665
|
-
if (aKeys.length !== bKeys.length) {
|
|
5666
|
-
return true;
|
|
5667
|
-
}
|
|
5668
|
-
for (let key of aKeys) {
|
|
5669
|
-
if (a[key] !== b[key]) {
|
|
5670
|
-
return true;
|
|
5671
|
-
}
|
|
5672
|
-
}
|
|
5673
|
-
return false;
|
|
5674
|
-
}
|
|
5675
|
-
function UNSTABLE_TransitionEnabledRouterProvider({
|
|
5676
|
-
router,
|
|
5677
|
-
flushSync: reactDomFlushSyncImpl,
|
|
5678
|
-
unstable_onError
|
|
5679
|
-
}) {
|
|
5680
|
-
let fetcherData = React3.useRef(/* @__PURE__ */ new Map());
|
|
5681
|
-
let [revalidating, startRevalidation] = React3.useTransition();
|
|
5682
|
-
let [state, setState] = React3.useState(router.state);
|
|
5683
|
-
router.__setPendingRerender = (promise) => startRevalidation(
|
|
5684
|
-
// @ts-expect-error - need react 19 types for this to be async
|
|
5685
|
-
async () => {
|
|
5686
|
-
const rerender = await promise;
|
|
5687
|
-
startRevalidation(() => {
|
|
5688
|
-
rerender();
|
|
5689
|
-
});
|
|
5690
|
-
}
|
|
5691
|
-
);
|
|
5692
|
-
let navigator = React3.useMemo(() => {
|
|
5693
|
-
return {
|
|
5694
|
-
createHref: router.createHref,
|
|
5695
|
-
encodeLocation: router.encodeLocation,
|
|
5696
|
-
go: (n) => router.navigate(n),
|
|
5697
|
-
push: (to, state2, opts) => router.navigate(to, {
|
|
5698
|
-
state: state2,
|
|
5699
|
-
preventScrollReset: opts?.preventScrollReset
|
|
5700
|
-
}),
|
|
5701
|
-
replace: (to, state2, opts) => router.navigate(to, {
|
|
5702
|
-
replace: true,
|
|
5703
|
-
state: state2,
|
|
5704
|
-
preventScrollReset: opts?.preventScrollReset
|
|
5705
|
-
})
|
|
5706
|
-
};
|
|
5707
|
-
}, [router]);
|
|
5708
|
-
let basename = router.basename || "/";
|
|
5709
|
-
let dataRouterContext = React3.useMemo(
|
|
5710
|
-
() => ({
|
|
5711
|
-
router,
|
|
5712
|
-
navigator,
|
|
5713
|
-
static: false,
|
|
5714
|
-
basename,
|
|
5715
|
-
unstable_onError
|
|
5716
|
-
}),
|
|
5717
|
-
[router, navigator, basename, unstable_onError]
|
|
5718
|
-
);
|
|
5719
|
-
React3.useLayoutEffect(() => {
|
|
5720
|
-
return router.subscribe(
|
|
5721
|
-
(newState, { deletedFetchers, flushSync, viewTransitionOpts }) => {
|
|
5722
|
-
newState.fetchers.forEach((fetcher, key) => {
|
|
5723
|
-
if (fetcher.data !== void 0) {
|
|
5724
|
-
fetcherData.current.set(key, fetcher.data);
|
|
5725
|
-
}
|
|
5726
|
-
});
|
|
5727
|
-
deletedFetchers.forEach((key) => fetcherData.current.delete(key));
|
|
5728
|
-
const diff = shallowDiff(state, newState);
|
|
5729
|
-
if (!diff) return;
|
|
5730
|
-
if (flushSync) {
|
|
5731
|
-
if (reactDomFlushSyncImpl) {
|
|
5732
|
-
reactDomFlushSyncImpl(() => setState(newState));
|
|
5733
|
-
} else {
|
|
5734
|
-
setState(newState);
|
|
5735
|
-
}
|
|
5736
|
-
} else {
|
|
5737
|
-
React3.startTransition(() => {
|
|
5738
|
-
setState(newState);
|
|
5739
|
-
});
|
|
5740
|
-
}
|
|
5741
|
-
}
|
|
5742
|
-
);
|
|
5743
|
-
}, [router, reactDomFlushSyncImpl, state]);
|
|
5744
|
-
return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(DataRouterContext.Provider, { value: dataRouterContext }, /* @__PURE__ */ React3.createElement(
|
|
5745
|
-
DataRouterStateContext.Provider,
|
|
5746
|
-
{
|
|
5747
|
-
value: {
|
|
5748
|
-
...state,
|
|
5749
|
-
revalidation: revalidating ? "loading" : state.revalidation
|
|
5750
|
-
}
|
|
5751
|
-
},
|
|
5752
|
-
/* @__PURE__ */ React3.createElement(FetchersContext.Provider, { value: fetcherData.current }, /* @__PURE__ */ React3.createElement(
|
|
5753
|
-
Router,
|
|
5754
|
-
{
|
|
5755
|
-
basename,
|
|
5756
|
-
location: state.location,
|
|
5757
|
-
navigationType: state.historyAction,
|
|
5758
|
-
navigator
|
|
5759
|
-
},
|
|
5760
|
-
/* @__PURE__ */ React3.createElement(
|
|
5761
|
-
MemoizedDataRoutes,
|
|
5762
|
-
{
|
|
5763
|
-
routes: router.routes,
|
|
5764
|
-
future: router.future,
|
|
5765
|
-
state,
|
|
5766
|
-
unstable_onError
|
|
5767
|
-
}
|
|
5768
|
-
)
|
|
5769
|
-
))
|
|
5770
|
-
)), null);
|
|
5771
|
-
}
|
|
5772
5943
|
function RouterProvider({
|
|
5773
5944
|
router,
|
|
5774
5945
|
flushSync: reactDomFlushSyncImpl,
|
|
@@ -7471,8 +7642,8 @@ async function fetchAndDecodeViaTurboStream(args, basename, targetRoutes) {
|
|
|
7471
7642
|
}
|
|
7472
7643
|
}
|
|
7473
7644
|
let res = await fetch(url, await createRequestInit(request));
|
|
7474
|
-
if (res.status
|
|
7475
|
-
throw new ErrorResponseImpl(
|
|
7645
|
+
if (res.status === 404 && !res.headers.has("X-Remix-Response")) {
|
|
7646
|
+
throw new ErrorResponseImpl(404, "Not Found", true);
|
|
7476
7647
|
}
|
|
7477
7648
|
if (res.status === 204 && res.headers.has("X-Remix-Redirect")) {
|
|
7478
7649
|
return {
|
|
@@ -8049,7 +8220,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
8049
8220
|
let hasInitialError = initialState && initialState.errors && route.id in initialState.errors;
|
|
8050
8221
|
let initialError = hasInitialError ? initialState?.errors?.[route.id] : void 0;
|
|
8051
8222
|
let isHydrationRequest = needsRevalidation == null && (routeModule.clientLoader?.hydrate === true || !route.hasLoader);
|
|
8052
|
-
dataRoute.loader = async ({ request, params, context }, singleFetch) => {
|
|
8223
|
+
dataRoute.loader = async ({ request, params, context, pattern }, singleFetch) => {
|
|
8053
8224
|
try {
|
|
8054
8225
|
let result = await prefetchStylesAndCallHandler(async () => {
|
|
8055
8226
|
invariant2(
|
|
@@ -8063,6 +8234,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
8063
8234
|
request,
|
|
8064
8235
|
params,
|
|
8065
8236
|
context,
|
|
8237
|
+
pattern,
|
|
8066
8238
|
async serverLoader() {
|
|
8067
8239
|
preventInvalidServerHandlerCall("loader", route);
|
|
8068
8240
|
if (isHydrationRequest) {
|
|
@@ -8088,7 +8260,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
8088
8260
|
route.hasLoader,
|
|
8089
8261
|
isSpaMode
|
|
8090
8262
|
);
|
|
8091
|
-
dataRoute.action = ({ request, params, context }, singleFetch) => {
|
|
8263
|
+
dataRoute.action = ({ request, params, context, pattern }, singleFetch) => {
|
|
8092
8264
|
return prefetchStylesAndCallHandler(async () => {
|
|
8093
8265
|
invariant2(
|
|
8094
8266
|
routeModule,
|
|
@@ -8104,6 +8276,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
8104
8276
|
request,
|
|
8105
8277
|
params,
|
|
8106
8278
|
context,
|
|
8279
|
+
pattern,
|
|
8107
8280
|
async serverAction() {
|
|
8108
8281
|
preventInvalidServerHandlerCall("action", route);
|
|
8109
8282
|
return fetchServerAction(singleFetch);
|
|
@@ -9113,7 +9286,7 @@ var isBrowser = typeof window !== "undefined" && typeof window.document !== "und
|
|
|
9113
9286
|
try {
|
|
9114
9287
|
if (isBrowser) {
|
|
9115
9288
|
window.__reactRouterVersion = // @ts-expect-error
|
|
9116
|
-
"0.0.0-experimental-
|
|
9289
|
+
"0.0.0-experimental-73e447577";
|
|
9117
9290
|
}
|
|
9118
9291
|
} catch (e) {
|
|
9119
9292
|
}
|
|
@@ -9129,7 +9302,8 @@ function createBrowserRouter(routes, opts) {
|
|
|
9129
9302
|
hydrationRouteProperties,
|
|
9130
9303
|
dataStrategy: opts?.dataStrategy,
|
|
9131
9304
|
patchRoutesOnNavigation: opts?.patchRoutesOnNavigation,
|
|
9132
|
-
window: opts?.window
|
|
9305
|
+
window: opts?.window,
|
|
9306
|
+
unstable_instrumentations: opts?.unstable_instrumentations
|
|
9133
9307
|
}).initialize();
|
|
9134
9308
|
}
|
|
9135
9309
|
function createHashRouter(routes, opts) {
|
|
@@ -9144,7 +9318,8 @@ function createHashRouter(routes, opts) {
|
|
|
9144
9318
|
hydrationRouteProperties,
|
|
9145
9319
|
dataStrategy: opts?.dataStrategy,
|
|
9146
9320
|
patchRoutesOnNavigation: opts?.patchRoutesOnNavigation,
|
|
9147
|
-
window: opts?.window
|
|
9321
|
+
window: opts?.window,
|
|
9322
|
+
unstable_instrumentations: opts?.unstable_instrumentations
|
|
9148
9323
|
}).initialize();
|
|
9149
9324
|
}
|
|
9150
9325
|
function parseHydrationData() {
|
|
@@ -10229,6 +10404,7 @@ export {
|
|
|
10229
10404
|
replace,
|
|
10230
10405
|
ErrorResponseImpl,
|
|
10231
10406
|
isRouteErrorResponse,
|
|
10407
|
+
instrumentHandler,
|
|
10232
10408
|
IDLE_NAVIGATION,
|
|
10233
10409
|
IDLE_FETCHER,
|
|
10234
10410
|
IDLE_BLOCKER,
|
|
@@ -10275,7 +10451,6 @@ export {
|
|
|
10275
10451
|
mapRouteProperties,
|
|
10276
10452
|
hydrationRouteProperties,
|
|
10277
10453
|
createMemoryRouter,
|
|
10278
|
-
UNSTABLE_TransitionEnabledRouterProvider,
|
|
10279
10454
|
RouterProvider,
|
|
10280
10455
|
MemoryRouter,
|
|
10281
10456
|
Navigate,
|