react-router 0.0.0-experimental-a65d6f5 → 0.0.0-experimental-c19b79d
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-ZLVXSGFL.js → chunk-2G2U5HGB.js} +161 -164
- package/dist/development/{chunk-CWSJ6RYI.mjs → chunk-AGOH44BE.mjs} +51 -67
- package/dist/development/{chunk-47MIYFLC.mjs → chunk-IMKEG5CI.mjs} +29 -309
- package/dist/development/{chunk-QOFB7XZ5.js → chunk-LUB73E44.js} +70 -347
- package/dist/development/{router-DQIRhYoj.d.mts → context-BqL5Eckq.d.mts} +1288 -1441
- package/dist/development/dom-export.d.mts +4 -59
- package/dist/development/dom-export.d.ts +3 -59
- package/dist/development/dom-export.js +5 -8
- package/dist/development/dom-export.mjs +5 -8
- package/dist/{production/index-react-server-client-lf74v6ET.d.mts → development/index-react-server-client-2EDmGlsZ.d.mts} +77 -140
- package/dist/development/{index-react-server-client-lf74v6ET.d.mts → index-react-server-client-DKvU8YRr.d.ts} +134 -198
- package/dist/development/index-react-server-client.d.mts +3 -3
- package/dist/development/index-react-server-client.d.ts +2 -3
- package/dist/development/index-react-server-client.js +4 -4
- package/dist/development/index-react-server-client.mjs +2 -2
- package/dist/development/index-react-server.d.mts +1 -106
- package/dist/development/index-react-server.d.ts +1 -106
- package/dist/development/index-react-server.js +8 -181
- package/dist/development/index-react-server.mjs +8 -181
- package/dist/development/index.d.mts +20 -13
- package/dist/development/index.d.ts +18 -13
- package/dist/development/index.js +147 -161
- package/dist/development/index.mjs +5 -3
- package/dist/development/lib/types/internal.d.mts +3 -3
- package/dist/development/lib/types/internal.d.ts +2 -3
- package/dist/development/lib/types/internal.js +1 -1
- package/dist/development/lib/types/internal.mjs +1 -1
- package/dist/development/{register-DiOIlEq5.d.mts → register-BrVEYTED.d.mts} +7 -1
- package/dist/{production/register-DiOIlEq5.d.mts → development/register-D8NQoPsO.d.ts} +7 -1
- package/dist/development/{routeModules--SgCTStn.d.mts → route-data-CDwqkzPE.d.mts} +147 -157
- package/dist/{production/routeModules-rxNxBmdR.d.ts → development/routeModules-BmVo7q9e.d.ts} +1046 -73
- package/dist/production/{chunk-ZOHTOBOT.js → chunk-2L5AG5Y5.js} +70 -347
- package/dist/production/{chunk-UAAA7FTX.mjs → chunk-AODJW4D3.mjs} +51 -67
- package/dist/production/{chunk-4SPSFXAZ.js → chunk-FGRCWJDI.js} +161 -164
- package/dist/production/{chunk-MMAHTIVZ.mjs → chunk-UOQCOPF6.mjs} +29 -309
- package/dist/production/{router-DQIRhYoj.d.mts → context-BqL5Eckq.d.mts} +1288 -1441
- package/dist/production/dom-export.d.mts +4 -59
- package/dist/production/dom-export.d.ts +3 -59
- package/dist/production/dom-export.js +5 -8
- package/dist/production/dom-export.mjs +5 -8
- package/dist/{development/index-react-server-client-Iw2PMej2.d.ts → production/index-react-server-client-2EDmGlsZ.d.mts} +77 -140
- package/dist/production/{index-react-server-client-Iw2PMej2.d.ts → index-react-server-client-DKvU8YRr.d.ts} +134 -198
- package/dist/production/index-react-server-client.d.mts +3 -3
- package/dist/production/index-react-server-client.d.ts +2 -3
- package/dist/production/index-react-server-client.js +4 -4
- package/dist/production/index-react-server-client.mjs +2 -2
- package/dist/production/index-react-server.d.mts +1 -106
- package/dist/production/index-react-server.d.ts +1 -106
- package/dist/production/index-react-server.js +8 -181
- package/dist/production/index-react-server.mjs +8 -181
- package/dist/production/index.d.mts +20 -13
- package/dist/production/index.d.ts +18 -13
- package/dist/production/index.js +147 -161
- package/dist/production/index.mjs +5 -3
- package/dist/production/lib/types/internal.d.mts +3 -3
- package/dist/production/lib/types/internal.d.ts +2 -3
- package/dist/production/lib/types/internal.js +1 -1
- package/dist/production/lib/types/internal.mjs +1 -1
- package/dist/{development/register-DiOIlEq5.d.ts → production/register-BrVEYTED.d.mts} +7 -1
- package/dist/production/{register-DiOIlEq5.d.ts → register-D8NQoPsO.d.ts} +7 -1
- package/dist/production/{routeModules--SgCTStn.d.mts → route-data-CDwqkzPE.d.mts} +147 -157
- package/dist/{development/routeModules-rxNxBmdR.d.ts → production/routeModules-BmVo7q9e.d.ts} +1046 -73
- package/package.json +1 -1
- package/dist/development/instrumentation-BWRz1MRU.d.ts +0 -1138
- package/dist/production/instrumentation-BWRz1MRU.d.ts +0 -1138
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v0.0.0-experimental-
|
|
2
|
+
* react-router v0.0.0-experimental-c19b79d
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -454,23 +454,19 @@ function convertRoutesToDataRoutes(routes, mapRouteProperties2, parentPath = [],
|
|
|
454
454
|
if (isIndexRoute(route)) {
|
|
455
455
|
let indexRoute = {
|
|
456
456
|
...route,
|
|
457
|
+
...mapRouteProperties2(route),
|
|
457
458
|
id
|
|
458
459
|
};
|
|
459
|
-
manifest[id] =
|
|
460
|
-
indexRoute,
|
|
461
|
-
mapRouteProperties2(indexRoute)
|
|
462
|
-
);
|
|
460
|
+
manifest[id] = indexRoute;
|
|
463
461
|
return indexRoute;
|
|
464
462
|
} else {
|
|
465
463
|
let pathOrLayoutRoute = {
|
|
466
464
|
...route,
|
|
465
|
+
...mapRouteProperties2(route),
|
|
467
466
|
id,
|
|
468
467
|
children: void 0
|
|
469
468
|
};
|
|
470
|
-
manifest[id] =
|
|
471
|
-
pathOrLayoutRoute,
|
|
472
|
-
mapRouteProperties2(pathOrLayoutRoute)
|
|
473
|
-
);
|
|
469
|
+
manifest[id] = pathOrLayoutRoute;
|
|
474
470
|
if (route.children) {
|
|
475
471
|
pathOrLayoutRoute.children = convertRoutesToDataRoutes(
|
|
476
472
|
route.children,
|
|
@@ -484,17 +480,6 @@ function convertRoutesToDataRoutes(routes, mapRouteProperties2, parentPath = [],
|
|
|
484
480
|
}
|
|
485
481
|
});
|
|
486
482
|
}
|
|
487
|
-
function mergeRouteUpdates(route, updates) {
|
|
488
|
-
return Object.assign(route, {
|
|
489
|
-
...updates,
|
|
490
|
-
...typeof updates.lazy === "object" && updates.lazy != null ? {
|
|
491
|
-
lazy: {
|
|
492
|
-
...route.lazy,
|
|
493
|
-
...updates.lazy
|
|
494
|
-
}
|
|
495
|
-
} : {}
|
|
496
|
-
});
|
|
497
|
-
}
|
|
498
483
|
function matchRoutes(routes, locationArg, basename = "/") {
|
|
499
484
|
return matchRoutesImpl(routes, locationArg, basename, false);
|
|
500
485
|
}
|
|
@@ -950,229 +935,6 @@ var ErrorResponseImpl = class {
|
|
|
950
935
|
function isRouteErrorResponse(error) {
|
|
951
936
|
return error != null && typeof error.status === "number" && typeof error.statusText === "string" && typeof error.internal === "boolean" && "data" in error;
|
|
952
937
|
}
|
|
953
|
-
function getRoutePattern(paths) {
|
|
954
|
-
return paths.filter(Boolean).join("/").replace(/\/\/*/g, "/");
|
|
955
|
-
}
|
|
956
|
-
|
|
957
|
-
// lib/router/instrumentation.ts
|
|
958
|
-
var UninstrumentedSymbol = Symbol("Uninstrumented");
|
|
959
|
-
function 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, unstable_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
|
-
unstable_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
|
-
}
|
|
1176
938
|
|
|
1177
939
|
// lib/router/router.ts
|
|
1178
940
|
var validMutationMethodsArr = [
|
|
@@ -1232,20 +994,7 @@ function createRouter(init) {
|
|
|
1232
994
|
"You must provide a non-empty routes array to createRouter"
|
|
1233
995
|
);
|
|
1234
996
|
let hydrationRouteProperties2 = init.hydrationRouteProperties || [];
|
|
1235
|
-
let
|
|
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
|
-
}
|
|
997
|
+
let mapRouteProperties2 = init.mapRouteProperties || defaultMapRouteProperties;
|
|
1249
998
|
let manifest = {};
|
|
1250
999
|
let dataRoutes = convertRoutesToDataRoutes(
|
|
1251
1000
|
init.routes,
|
|
@@ -2997,12 +2746,6 @@ function createRouter(init) {
|
|
|
2997
2746
|
updateState(newState);
|
|
2998
2747
|
}
|
|
2999
2748
|
};
|
|
3000
|
-
if (init.unstable_instrumentations) {
|
|
3001
|
-
router = instrumentClientSideRouter(
|
|
3002
|
-
router,
|
|
3003
|
-
init.unstable_instrumentations.map((i) => i.router).filter(Boolean)
|
|
3004
|
-
);
|
|
3005
|
-
}
|
|
3006
2749
|
return router;
|
|
3007
2750
|
}
|
|
3008
2751
|
function createStaticHandler(routes, opts) {
|
|
@@ -3012,20 +2755,7 @@ function createStaticHandler(routes, opts) {
|
|
|
3012
2755
|
);
|
|
3013
2756
|
let manifest = {};
|
|
3014
2757
|
let basename = (opts ? opts.basename : null) || "/";
|
|
3015
|
-
let
|
|
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
|
-
}
|
|
2758
|
+
let mapRouteProperties2 = opts?.mapRouteProperties || defaultMapRouteProperties;
|
|
3029
2759
|
let dataRoutes = convertRoutesToDataRoutes(
|
|
3030
2760
|
routes,
|
|
3031
2761
|
mapRouteProperties2,
|
|
@@ -3095,7 +2825,6 @@ function createStaticHandler(routes, opts) {
|
|
|
3095
2825
|
let response = await runServerMiddlewarePipeline(
|
|
3096
2826
|
{
|
|
3097
2827
|
request,
|
|
3098
|
-
unstable_pattern: getRoutePattern(matches.map((m) => m.route.path)),
|
|
3099
2828
|
matches,
|
|
3100
2829
|
params: matches[0].params,
|
|
3101
2830
|
// If we're calling middleware then it must be enabled so we can cast
|
|
@@ -3241,7 +2970,6 @@ function createStaticHandler(routes, opts) {
|
|
|
3241
2970
|
let response = await runServerMiddlewarePipeline(
|
|
3242
2971
|
{
|
|
3243
2972
|
request,
|
|
3244
|
-
unstable_pattern: getRoutePattern(matches.map((m) => m.route.path)),
|
|
3245
2973
|
matches,
|
|
3246
2974
|
params: matches[0].params,
|
|
3247
2975
|
// If we're calling middleware then it must be enabled so we can cast
|
|
@@ -3523,7 +3251,6 @@ function createStaticHandler(routes, opts) {
|
|
|
3523
3251
|
mapRouteProperties2,
|
|
3524
3252
|
manifest,
|
|
3525
3253
|
request,
|
|
3526
|
-
getRoutePattern(matches.map((m) => m.route.path)),
|
|
3527
3254
|
match,
|
|
3528
3255
|
[],
|
|
3529
3256
|
requestContext,
|
|
@@ -3534,7 +3261,6 @@ function createStaticHandler(routes, opts) {
|
|
|
3534
3261
|
mapRouteProperties2,
|
|
3535
3262
|
manifest,
|
|
3536
3263
|
request,
|
|
3537
|
-
getRoutePattern(matches.map((m) => m.route.path)),
|
|
3538
3264
|
match,
|
|
3539
3265
|
[],
|
|
3540
3266
|
requestContext,
|
|
@@ -3815,8 +3541,6 @@ function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest,
|
|
|
3815
3541
|
actionResult,
|
|
3816
3542
|
actionStatus
|
|
3817
3543
|
};
|
|
3818
|
-
let pattern = getRoutePattern(matches.map((m) => m.route.path));
|
|
3819
|
-
console.log(pattern, matches);
|
|
3820
3544
|
let dsMatches = matches.map((match, index) => {
|
|
3821
3545
|
let { route } = match;
|
|
3822
3546
|
let forceShouldLoad = null;
|
|
@@ -3840,7 +3564,6 @@ function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest,
|
|
|
3840
3564
|
mapRouteProperties2,
|
|
3841
3565
|
manifest,
|
|
3842
3566
|
request,
|
|
3843
|
-
pattern,
|
|
3844
3567
|
match,
|
|
3845
3568
|
lazyRoutePropertiesToSkip,
|
|
3846
3569
|
scopedContext,
|
|
@@ -3861,7 +3584,6 @@ function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest,
|
|
|
3861
3584
|
mapRouteProperties2,
|
|
3862
3585
|
manifest,
|
|
3863
3586
|
request,
|
|
3864
|
-
pattern,
|
|
3865
3587
|
match,
|
|
3866
3588
|
lazyRoutePropertiesToSkip,
|
|
3867
3589
|
scopedContext,
|
|
@@ -4320,12 +4042,7 @@ async function runMiddlewarePipeline(args, handler, processResult, isResult, err
|
|
|
4320
4042
|
(m) => m.route.middleware ? m.route.middleware.map((fn) => [m.route.id, fn]) : []
|
|
4321
4043
|
);
|
|
4322
4044
|
let result = await callRouteMiddleware(
|
|
4323
|
-
{
|
|
4324
|
-
request,
|
|
4325
|
-
params,
|
|
4326
|
-
context,
|
|
4327
|
-
unstable_pattern: getRoutePattern(matches.map((m) => m.route.path))
|
|
4328
|
-
},
|
|
4045
|
+
{ request, params, context },
|
|
4329
4046
|
tuples,
|
|
4330
4047
|
handler,
|
|
4331
4048
|
processResult,
|
|
@@ -4403,7 +4120,7 @@ function getDataStrategyMatchLazyPromises(mapRouteProperties2, manifest, request
|
|
|
4403
4120
|
handler: lazyRoutePromises.lazyHandlerPromise
|
|
4404
4121
|
};
|
|
4405
4122
|
}
|
|
4406
|
-
function getDataStrategyMatch(mapRouteProperties2, manifest, request,
|
|
4123
|
+
function getDataStrategyMatch(mapRouteProperties2, manifest, request, match, lazyRoutePropertiesToSkip, scopedContext, shouldLoad, unstable_shouldRevalidateArgs = null) {
|
|
4407
4124
|
let isUsingNewApi = false;
|
|
4408
4125
|
let _lazyPromises = getDataStrategyMatchLazyPromises(
|
|
4409
4126
|
mapRouteProperties2,
|
|
@@ -4437,7 +4154,6 @@ function getDataStrategyMatch(mapRouteProperties2, manifest, request, unstable_p
|
|
|
4437
4154
|
if (callHandler && !isMiddlewareOnlyRoute) {
|
|
4438
4155
|
return callLoaderOrAction({
|
|
4439
4156
|
request,
|
|
4440
|
-
unstable_pattern,
|
|
4441
4157
|
match,
|
|
4442
4158
|
lazyHandlerPromise: _lazyPromises?.handler,
|
|
4443
4159
|
lazyRoutePromise: _lazyPromises?.route,
|
|
@@ -4471,7 +4187,6 @@ function getTargetedDataStrategyMatches(mapRouteProperties2, manifest, request,
|
|
|
4471
4187
|
mapRouteProperties2,
|
|
4472
4188
|
manifest,
|
|
4473
4189
|
request,
|
|
4474
|
-
getRoutePattern(matches.map((m) => m.route.path)),
|
|
4475
4190
|
match,
|
|
4476
4191
|
lazyRoutePropertiesToSkip,
|
|
4477
4192
|
scopedContext,
|
|
@@ -4486,7 +4201,6 @@ async function callDataStrategyImpl(dataStrategyImpl, request, matches, fetcherK
|
|
|
4486
4201
|
}
|
|
4487
4202
|
let dataStrategyArgs = {
|
|
4488
4203
|
request,
|
|
4489
|
-
unstable_pattern: getRoutePattern(matches.map((m) => m.route.path)),
|
|
4490
4204
|
params: matches[0].params,
|
|
4491
4205
|
context: scopedContext,
|
|
4492
4206
|
matches
|
|
@@ -4527,7 +4241,6 @@ async function callDataStrategyImpl(dataStrategyImpl, request, matches, fetcherK
|
|
|
4527
4241
|
}
|
|
4528
4242
|
async function callLoaderOrAction({
|
|
4529
4243
|
request,
|
|
4530
|
-
unstable_pattern,
|
|
4531
4244
|
match,
|
|
4532
4245
|
lazyHandlerPromise,
|
|
4533
4246
|
lazyRoutePromise,
|
|
@@ -4554,7 +4267,6 @@ async function callLoaderOrAction({
|
|
|
4554
4267
|
return handler(
|
|
4555
4268
|
{
|
|
4556
4269
|
request,
|
|
4557
|
-
unstable_pattern,
|
|
4558
4270
|
params: match.params,
|
|
4559
4271
|
context: scopedContext
|
|
4560
4272
|
},
|
|
@@ -5840,6 +5552,19 @@ function warningOnce(key, cond, message) {
|
|
|
5840
5552
|
warning(false, message);
|
|
5841
5553
|
}
|
|
5842
5554
|
}
|
|
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
|
+
}
|
|
5843
5568
|
|
|
5844
5569
|
// lib/components.tsx
|
|
5845
5570
|
import * as React3 from "react";
|
|
@@ -5922,8 +5647,7 @@ function createMemoryRouter(routes, opts) {
|
|
|
5922
5647
|
hydrationRouteProperties,
|
|
5923
5648
|
mapRouteProperties,
|
|
5924
5649
|
dataStrategy: opts?.dataStrategy,
|
|
5925
|
-
patchRoutesOnNavigation: opts?.patchRoutesOnNavigation
|
|
5926
|
-
unstable_instrumentations: opts?.unstable_instrumentations
|
|
5650
|
+
patchRoutesOnNavigation: opts?.patchRoutesOnNavigation
|
|
5927
5651
|
}).initialize();
|
|
5928
5652
|
}
|
|
5929
5653
|
var Deferred = class {
|
|
@@ -8338,7 +8062,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
8338
8062
|
let hasInitialError = initialState && initialState.errors && route.id in initialState.errors;
|
|
8339
8063
|
let initialError = hasInitialError ? initialState?.errors?.[route.id] : void 0;
|
|
8340
8064
|
let isHydrationRequest = needsRevalidation == null && (routeModule.clientLoader?.hydrate === true || !route.hasLoader);
|
|
8341
|
-
dataRoute.loader = async ({ request, params, context
|
|
8065
|
+
dataRoute.loader = async ({ request, params, context }, singleFetch) => {
|
|
8342
8066
|
try {
|
|
8343
8067
|
let result = await prefetchStylesAndCallHandler(async () => {
|
|
8344
8068
|
invariant2(
|
|
@@ -8352,7 +8076,6 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
8352
8076
|
request,
|
|
8353
8077
|
params,
|
|
8354
8078
|
context,
|
|
8355
|
-
unstable_pattern,
|
|
8356
8079
|
async serverLoader() {
|
|
8357
8080
|
preventInvalidServerHandlerCall("loader", route);
|
|
8358
8081
|
if (isHydrationRequest) {
|
|
@@ -8378,7 +8101,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
8378
8101
|
route.hasLoader,
|
|
8379
8102
|
isSpaMode
|
|
8380
8103
|
);
|
|
8381
|
-
dataRoute.action = ({ request, params, context
|
|
8104
|
+
dataRoute.action = ({ request, params, context }, singleFetch) => {
|
|
8382
8105
|
return prefetchStylesAndCallHandler(async () => {
|
|
8383
8106
|
invariant2(
|
|
8384
8107
|
routeModule,
|
|
@@ -8394,7 +8117,6 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
8394
8117
|
request,
|
|
8395
8118
|
params,
|
|
8396
8119
|
context,
|
|
8397
|
-
unstable_pattern,
|
|
8398
8120
|
async serverAction() {
|
|
8399
8121
|
preventInvalidServerHandlerCall("action", route);
|
|
8400
8122
|
return fetchServerAction(singleFetch);
|
|
@@ -9404,7 +9126,7 @@ var isBrowser = typeof window !== "undefined" && typeof window.document !== "und
|
|
|
9404
9126
|
try {
|
|
9405
9127
|
if (isBrowser) {
|
|
9406
9128
|
window.__reactRouterVersion = // @ts-expect-error
|
|
9407
|
-
"0.0.0-experimental-
|
|
9129
|
+
"0.0.0-experimental-c19b79d";
|
|
9408
9130
|
}
|
|
9409
9131
|
} catch (e) {
|
|
9410
9132
|
}
|
|
@@ -9420,8 +9142,7 @@ function createBrowserRouter(routes, opts) {
|
|
|
9420
9142
|
hydrationRouteProperties,
|
|
9421
9143
|
dataStrategy: opts?.dataStrategy,
|
|
9422
9144
|
patchRoutesOnNavigation: opts?.patchRoutesOnNavigation,
|
|
9423
|
-
window: opts?.window
|
|
9424
|
-
unstable_instrumentations: opts?.unstable_instrumentations
|
|
9145
|
+
window: opts?.window
|
|
9425
9146
|
}).initialize();
|
|
9426
9147
|
}
|
|
9427
9148
|
function createHashRouter(routes, opts) {
|
|
@@ -9436,8 +9157,7 @@ function createHashRouter(routes, opts) {
|
|
|
9436
9157
|
hydrationRouteProperties,
|
|
9437
9158
|
dataStrategy: opts?.dataStrategy,
|
|
9438
9159
|
patchRoutesOnNavigation: opts?.patchRoutesOnNavigation,
|
|
9439
|
-
window: opts?.window
|
|
9440
|
-
unstable_instrumentations: opts?.unstable_instrumentations
|
|
9160
|
+
window: opts?.window
|
|
9441
9161
|
}).initialize();
|
|
9442
9162
|
}
|
|
9443
9163
|
function parseHydrationData() {
|
|
@@ -10522,7 +10242,6 @@ export {
|
|
|
10522
10242
|
replace,
|
|
10523
10243
|
ErrorResponseImpl,
|
|
10524
10244
|
isRouteErrorResponse,
|
|
10525
|
-
instrumentHandler,
|
|
10526
10245
|
IDLE_NAVIGATION,
|
|
10527
10246
|
IDLE_FETCHER,
|
|
10528
10247
|
IDLE_BLOCKER,
|
|
@@ -10565,6 +10284,7 @@ export {
|
|
|
10565
10284
|
useAsyncValue,
|
|
10566
10285
|
useAsyncError,
|
|
10567
10286
|
useBlocker,
|
|
10287
|
+
useRoute,
|
|
10568
10288
|
warnOnce,
|
|
10569
10289
|
mapRouteProperties,
|
|
10570
10290
|
hydrationRouteProperties,
|