react-router 0.0.0-experimental-73e447577 → 0.0.0-experimental-e613d4238
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 +35 -0
- package/dist/development/{chunk-NKIXC2FA.mjs → chunk-2YVPYFDJ.mjs} +120 -131
- package/dist/development/{chunk-PF7FO4KS.mjs → chunk-5P3HEZQU.mjs} +145 -310
- package/dist/development/{chunk-SOMUQ5BV.js → chunk-XXC4LMW2.js} +265 -154
- package/dist/development/{chunk-WQE2SM7S.js → chunk-YJ6T7YSE.js} +72 -348
- package/dist/development/{router-2BoB34m1.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-BDG19ZQl.d.mts → development/index-react-server-client-2EDmGlsZ.d.mts} +77 -140
- package/dist/development/{index-react-server-client-BDG19ZQl.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 +12 -182
- package/dist/development/index-react-server.mjs +12 -182
- package/dist/development/index.d.mts +18 -13
- package/dist/development/index.d.ts +16 -13
- package/dist/development/index.js +214 -223
- 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-CtCOLGtG.d.mts → route-data-CDwqkzPE.d.mts} +147 -157
- package/dist/{production/routeModules-Bu1JamQV.d.ts → development/routeModules-BmVo7q9e.d.ts} +1046 -73
- package/dist/production/{chunk-TUGDEB6V.mjs → chunk-5MHETEIL.mjs} +120 -131
- package/dist/production/{chunk-TA3WUUL6.js → chunk-E4G6PZCJ.js} +265 -154
- package/dist/production/{chunk-VRFRIIGI.js → chunk-QBUHFRYZ.js} +72 -348
- package/dist/production/{chunk-YUNRQEIK.mjs → chunk-VNGQS422.mjs} +145 -310
- package/dist/production/{router-2BoB34m1.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-83aVZHgI.d.ts → production/index-react-server-client-2EDmGlsZ.d.mts} +77 -140
- package/dist/production/{index-react-server-client-83aVZHgI.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 +12 -182
- package/dist/production/index-react-server.mjs +12 -182
- package/dist/production/index.d.mts +18 -13
- package/dist/production/index.d.ts +16 -13
- package/dist/production/index.js +214 -223
- 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-CtCOLGtG.d.mts → route-data-CDwqkzPE.d.mts} +147 -157
- package/dist/{development/routeModules-Bu1JamQV.d.ts → production/routeModules-BmVo7q9e.d.ts} +1046 -73
- package/package.json +1 -1
- package/dist/development/instrumentation-XYmrzhe3.d.ts +0 -1138
- package/dist/production/instrumentation-XYmrzhe3.d.ts +0 -1138
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v0.0.0-experimental-
|
|
2
|
+
* react-router v0.0.0-experimental-e613d4238
|
|
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, 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
|
-
}
|
|
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
|
-
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
|
-
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,
|
|
@@ -3838,7 +3564,6 @@ function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest,
|
|
|
3838
3564
|
mapRouteProperties2,
|
|
3839
3565
|
manifest,
|
|
3840
3566
|
request,
|
|
3841
|
-
getRoutePattern(matches.map((m) => m.route.path)),
|
|
3842
3567
|
match,
|
|
3843
3568
|
lazyRoutePropertiesToSkip,
|
|
3844
3569
|
scopedContext,
|
|
@@ -3859,7 +3584,6 @@ function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest,
|
|
|
3859
3584
|
mapRouteProperties2,
|
|
3860
3585
|
manifest,
|
|
3861
3586
|
request,
|
|
3862
|
-
getRoutePattern(matches.map((m) => m.route.path)),
|
|
3863
3587
|
match,
|
|
3864
3588
|
lazyRoutePropertiesToSkip,
|
|
3865
3589
|
scopedContext,
|
|
@@ -4318,12 +4042,7 @@ async function runMiddlewarePipeline(args, handler, processResult, isResult, err
|
|
|
4318
4042
|
(m) => m.route.middleware ? m.route.middleware.map((fn) => [m.route.id, fn]) : []
|
|
4319
4043
|
);
|
|
4320
4044
|
let result = await callRouteMiddleware(
|
|
4321
|
-
{
|
|
4322
|
-
request,
|
|
4323
|
-
params,
|
|
4324
|
-
context,
|
|
4325
|
-
pattern: getRoutePattern(matches.map((m) => m.route.path))
|
|
4326
|
-
},
|
|
4045
|
+
{ request, params, context },
|
|
4327
4046
|
tuples,
|
|
4328
4047
|
handler,
|
|
4329
4048
|
processResult,
|
|
@@ -4401,7 +4120,7 @@ function getDataStrategyMatchLazyPromises(mapRouteProperties2, manifest, request
|
|
|
4401
4120
|
handler: lazyRoutePromises.lazyHandlerPromise
|
|
4402
4121
|
};
|
|
4403
4122
|
}
|
|
4404
|
-
function getDataStrategyMatch(mapRouteProperties2, manifest, request,
|
|
4123
|
+
function getDataStrategyMatch(mapRouteProperties2, manifest, request, match, lazyRoutePropertiesToSkip, scopedContext, shouldLoad, unstable_shouldRevalidateArgs = null) {
|
|
4405
4124
|
let isUsingNewApi = false;
|
|
4406
4125
|
let _lazyPromises = getDataStrategyMatchLazyPromises(
|
|
4407
4126
|
mapRouteProperties2,
|
|
@@ -4429,10 +4148,12 @@ function getDataStrategyMatch(mapRouteProperties2, manifest, request, pattern, m
|
|
|
4429
4148
|
return shouldRevalidateLoader(match, unstable_shouldRevalidateArgs);
|
|
4430
4149
|
},
|
|
4431
4150
|
resolve(handlerOverride) {
|
|
4432
|
-
|
|
4151
|
+
let { lazy, loader, middleware } = match.route;
|
|
4152
|
+
let callHandler = isUsingNewApi || shouldLoad || handlerOverride && !isMutationMethod(request.method) && (lazy || loader);
|
|
4153
|
+
let isMiddlewareOnlyRoute = middleware && middleware.length > 0 && !loader && !lazy;
|
|
4154
|
+
if (callHandler && !isMiddlewareOnlyRoute) {
|
|
4433
4155
|
return callLoaderOrAction({
|
|
4434
4156
|
request,
|
|
4435
|
-
pattern,
|
|
4436
4157
|
match,
|
|
4437
4158
|
lazyHandlerPromise: _lazyPromises?.handler,
|
|
4438
4159
|
lazyRoutePromise: _lazyPromises?.route,
|
|
@@ -4466,7 +4187,6 @@ function getTargetedDataStrategyMatches(mapRouteProperties2, manifest, request,
|
|
|
4466
4187
|
mapRouteProperties2,
|
|
4467
4188
|
manifest,
|
|
4468
4189
|
request,
|
|
4469
|
-
getRoutePattern(matches.map((m) => m.route.path)),
|
|
4470
4190
|
match,
|
|
4471
4191
|
lazyRoutePropertiesToSkip,
|
|
4472
4192
|
scopedContext,
|
|
@@ -4481,7 +4201,6 @@ async function callDataStrategyImpl(dataStrategyImpl, request, matches, fetcherK
|
|
|
4481
4201
|
}
|
|
4482
4202
|
let dataStrategyArgs = {
|
|
4483
4203
|
request,
|
|
4484
|
-
pattern: getRoutePattern(matches.map((m) => m.route.path)),
|
|
4485
4204
|
params: matches[0].params,
|
|
4486
4205
|
context: scopedContext,
|
|
4487
4206
|
matches
|
|
@@ -4522,7 +4241,6 @@ async function callDataStrategyImpl(dataStrategyImpl, request, matches, fetcherK
|
|
|
4522
4241
|
}
|
|
4523
4242
|
async function callLoaderOrAction({
|
|
4524
4243
|
request,
|
|
4525
|
-
pattern,
|
|
4526
4244
|
match,
|
|
4527
4245
|
lazyHandlerPromise,
|
|
4528
4246
|
lazyRoutePromise,
|
|
@@ -4549,7 +4267,6 @@ async function callLoaderOrAction({
|
|
|
4549
4267
|
return handler(
|
|
4550
4268
|
{
|
|
4551
4269
|
request,
|
|
4552
|
-
pattern,
|
|
4553
4270
|
params: match.params,
|
|
4554
4271
|
context: scopedContext
|
|
4555
4272
|
},
|
|
@@ -5835,6 +5552,15 @@ function warningOnce(key, cond, message) {
|
|
|
5835
5552
|
warning(false, message);
|
|
5836
5553
|
}
|
|
5837
5554
|
}
|
|
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
|
+
}
|
|
5838
5564
|
|
|
5839
5565
|
// lib/components.tsx
|
|
5840
5566
|
import * as React3 from "react";
|
|
@@ -5917,8 +5643,7 @@ function createMemoryRouter(routes, opts) {
|
|
|
5917
5643
|
hydrationRouteProperties,
|
|
5918
5644
|
mapRouteProperties,
|
|
5919
5645
|
dataStrategy: opts?.dataStrategy,
|
|
5920
|
-
patchRoutesOnNavigation: opts?.patchRoutesOnNavigation
|
|
5921
|
-
unstable_instrumentations: opts?.unstable_instrumentations
|
|
5646
|
+
patchRoutesOnNavigation: opts?.patchRoutesOnNavigation
|
|
5922
5647
|
}).initialize();
|
|
5923
5648
|
}
|
|
5924
5649
|
var Deferred = class {
|
|
@@ -5940,6 +5665,119 @@ var Deferred = class {
|
|
|
5940
5665
|
});
|
|
5941
5666
|
}
|
|
5942
5667
|
};
|
|
5668
|
+
function shallowDiff(a, b) {
|
|
5669
|
+
if (a === b) {
|
|
5670
|
+
return false;
|
|
5671
|
+
}
|
|
5672
|
+
let aKeys = Object.keys(a);
|
|
5673
|
+
let bKeys = Object.keys(b);
|
|
5674
|
+
if (aKeys.length !== bKeys.length) {
|
|
5675
|
+
return true;
|
|
5676
|
+
}
|
|
5677
|
+
for (let key of aKeys) {
|
|
5678
|
+
if (a[key] !== b[key]) {
|
|
5679
|
+
return true;
|
|
5680
|
+
}
|
|
5681
|
+
}
|
|
5682
|
+
return false;
|
|
5683
|
+
}
|
|
5684
|
+
function UNSTABLE_TransitionEnabledRouterProvider({
|
|
5685
|
+
router,
|
|
5686
|
+
flushSync: reactDomFlushSyncImpl,
|
|
5687
|
+
unstable_onError
|
|
5688
|
+
}) {
|
|
5689
|
+
let fetcherData = React3.useRef(/* @__PURE__ */ new Map());
|
|
5690
|
+
let [revalidating, startRevalidation] = React3.useTransition();
|
|
5691
|
+
let [state, setState] = React3.useState(router.state);
|
|
5692
|
+
router.__setPendingRerender = (promise) => startRevalidation(
|
|
5693
|
+
// @ts-expect-error - need react 19 types for this to be async
|
|
5694
|
+
async () => {
|
|
5695
|
+
const rerender = await promise;
|
|
5696
|
+
startRevalidation(() => {
|
|
5697
|
+
rerender();
|
|
5698
|
+
});
|
|
5699
|
+
}
|
|
5700
|
+
);
|
|
5701
|
+
let navigator = React3.useMemo(() => {
|
|
5702
|
+
return {
|
|
5703
|
+
createHref: router.createHref,
|
|
5704
|
+
encodeLocation: router.encodeLocation,
|
|
5705
|
+
go: (n) => router.navigate(n),
|
|
5706
|
+
push: (to, state2, opts) => router.navigate(to, {
|
|
5707
|
+
state: state2,
|
|
5708
|
+
preventScrollReset: opts?.preventScrollReset
|
|
5709
|
+
}),
|
|
5710
|
+
replace: (to, state2, opts) => router.navigate(to, {
|
|
5711
|
+
replace: true,
|
|
5712
|
+
state: state2,
|
|
5713
|
+
preventScrollReset: opts?.preventScrollReset
|
|
5714
|
+
})
|
|
5715
|
+
};
|
|
5716
|
+
}, [router]);
|
|
5717
|
+
let basename = router.basename || "/";
|
|
5718
|
+
let dataRouterContext = React3.useMemo(
|
|
5719
|
+
() => ({
|
|
5720
|
+
router,
|
|
5721
|
+
navigator,
|
|
5722
|
+
static: false,
|
|
5723
|
+
basename,
|
|
5724
|
+
unstable_onError
|
|
5725
|
+
}),
|
|
5726
|
+
[router, navigator, basename, unstable_onError]
|
|
5727
|
+
);
|
|
5728
|
+
React3.useLayoutEffect(() => {
|
|
5729
|
+
return router.subscribe(
|
|
5730
|
+
(newState, { deletedFetchers, flushSync, viewTransitionOpts }) => {
|
|
5731
|
+
newState.fetchers.forEach((fetcher, key) => {
|
|
5732
|
+
if (fetcher.data !== void 0) {
|
|
5733
|
+
fetcherData.current.set(key, fetcher.data);
|
|
5734
|
+
}
|
|
5735
|
+
});
|
|
5736
|
+
deletedFetchers.forEach((key) => fetcherData.current.delete(key));
|
|
5737
|
+
const diff = shallowDiff(state, newState);
|
|
5738
|
+
if (!diff) return;
|
|
5739
|
+
if (flushSync) {
|
|
5740
|
+
if (reactDomFlushSyncImpl) {
|
|
5741
|
+
reactDomFlushSyncImpl(() => setState(newState));
|
|
5742
|
+
} else {
|
|
5743
|
+
setState(newState);
|
|
5744
|
+
}
|
|
5745
|
+
} else {
|
|
5746
|
+
React3.startTransition(() => {
|
|
5747
|
+
setState(newState);
|
|
5748
|
+
});
|
|
5749
|
+
}
|
|
5750
|
+
}
|
|
5751
|
+
);
|
|
5752
|
+
}, [router, reactDomFlushSyncImpl, state]);
|
|
5753
|
+
return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(DataRouterContext.Provider, { value: dataRouterContext }, /* @__PURE__ */ React3.createElement(
|
|
5754
|
+
DataRouterStateContext.Provider,
|
|
5755
|
+
{
|
|
5756
|
+
value: {
|
|
5757
|
+
...state,
|
|
5758
|
+
revalidation: revalidating ? "loading" : state.revalidation
|
|
5759
|
+
}
|
|
5760
|
+
},
|
|
5761
|
+
/* @__PURE__ */ React3.createElement(FetchersContext.Provider, { value: fetcherData.current }, /* @__PURE__ */ React3.createElement(
|
|
5762
|
+
Router,
|
|
5763
|
+
{
|
|
5764
|
+
basename,
|
|
5765
|
+
location: state.location,
|
|
5766
|
+
navigationType: state.historyAction,
|
|
5767
|
+
navigator
|
|
5768
|
+
},
|
|
5769
|
+
/* @__PURE__ */ React3.createElement(
|
|
5770
|
+
MemoizedDataRoutes,
|
|
5771
|
+
{
|
|
5772
|
+
routes: router.routes,
|
|
5773
|
+
future: router.future,
|
|
5774
|
+
state,
|
|
5775
|
+
unstable_onError
|
|
5776
|
+
}
|
|
5777
|
+
)
|
|
5778
|
+
))
|
|
5779
|
+
)), null);
|
|
5780
|
+
}
|
|
5943
5781
|
function RouterProvider({
|
|
5944
5782
|
router,
|
|
5945
5783
|
flushSync: reactDomFlushSyncImpl,
|
|
@@ -7642,8 +7480,8 @@ async function fetchAndDecodeViaTurboStream(args, basename, targetRoutes) {
|
|
|
7642
7480
|
}
|
|
7643
7481
|
}
|
|
7644
7482
|
let res = await fetch(url, await createRequestInit(request));
|
|
7645
|
-
if (res.status
|
|
7646
|
-
throw new ErrorResponseImpl(
|
|
7483
|
+
if (res.status >= 400 && !res.headers.has("X-Remix-Response")) {
|
|
7484
|
+
throw new ErrorResponseImpl(res.status, res.statusText, await res.text());
|
|
7647
7485
|
}
|
|
7648
7486
|
if (res.status === 204 && res.headers.has("X-Remix-Redirect")) {
|
|
7649
7487
|
return {
|
|
@@ -8220,7 +8058,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
8220
8058
|
let hasInitialError = initialState && initialState.errors && route.id in initialState.errors;
|
|
8221
8059
|
let initialError = hasInitialError ? initialState?.errors?.[route.id] : void 0;
|
|
8222
8060
|
let isHydrationRequest = needsRevalidation == null && (routeModule.clientLoader?.hydrate === true || !route.hasLoader);
|
|
8223
|
-
dataRoute.loader = async ({ request, params, context
|
|
8061
|
+
dataRoute.loader = async ({ request, params, context }, singleFetch) => {
|
|
8224
8062
|
try {
|
|
8225
8063
|
let result = await prefetchStylesAndCallHandler(async () => {
|
|
8226
8064
|
invariant2(
|
|
@@ -8234,7 +8072,6 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
8234
8072
|
request,
|
|
8235
8073
|
params,
|
|
8236
8074
|
context,
|
|
8237
|
-
pattern,
|
|
8238
8075
|
async serverLoader() {
|
|
8239
8076
|
preventInvalidServerHandlerCall("loader", route);
|
|
8240
8077
|
if (isHydrationRequest) {
|
|
@@ -8260,7 +8097,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
8260
8097
|
route.hasLoader,
|
|
8261
8098
|
isSpaMode
|
|
8262
8099
|
);
|
|
8263
|
-
dataRoute.action = ({ request, params, context
|
|
8100
|
+
dataRoute.action = ({ request, params, context }, singleFetch) => {
|
|
8264
8101
|
return prefetchStylesAndCallHandler(async () => {
|
|
8265
8102
|
invariant2(
|
|
8266
8103
|
routeModule,
|
|
@@ -8276,7 +8113,6 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
|
|
|
8276
8113
|
request,
|
|
8277
8114
|
params,
|
|
8278
8115
|
context,
|
|
8279
|
-
pattern,
|
|
8280
8116
|
async serverAction() {
|
|
8281
8117
|
preventInvalidServerHandlerCall("action", route);
|
|
8282
8118
|
return fetchServerAction(singleFetch);
|
|
@@ -9286,7 +9122,7 @@ var isBrowser = typeof window !== "undefined" && typeof window.document !== "und
|
|
|
9286
9122
|
try {
|
|
9287
9123
|
if (isBrowser) {
|
|
9288
9124
|
window.__reactRouterVersion = // @ts-expect-error
|
|
9289
|
-
"0.0.0-experimental-
|
|
9125
|
+
"0.0.0-experimental-e613d4238";
|
|
9290
9126
|
}
|
|
9291
9127
|
} catch (e) {
|
|
9292
9128
|
}
|
|
@@ -9302,8 +9138,7 @@ function createBrowserRouter(routes, opts) {
|
|
|
9302
9138
|
hydrationRouteProperties,
|
|
9303
9139
|
dataStrategy: opts?.dataStrategy,
|
|
9304
9140
|
patchRoutesOnNavigation: opts?.patchRoutesOnNavigation,
|
|
9305
|
-
window: opts?.window
|
|
9306
|
-
unstable_instrumentations: opts?.unstable_instrumentations
|
|
9141
|
+
window: opts?.window
|
|
9307
9142
|
}).initialize();
|
|
9308
9143
|
}
|
|
9309
9144
|
function createHashRouter(routes, opts) {
|
|
@@ -9318,8 +9153,7 @@ function createHashRouter(routes, opts) {
|
|
|
9318
9153
|
hydrationRouteProperties,
|
|
9319
9154
|
dataStrategy: opts?.dataStrategy,
|
|
9320
9155
|
patchRoutesOnNavigation: opts?.patchRoutesOnNavigation,
|
|
9321
|
-
window: opts?.window
|
|
9322
|
-
unstable_instrumentations: opts?.unstable_instrumentations
|
|
9156
|
+
window: opts?.window
|
|
9323
9157
|
}).initialize();
|
|
9324
9158
|
}
|
|
9325
9159
|
function parseHydrationData() {
|
|
@@ -10404,7 +10238,6 @@ export {
|
|
|
10404
10238
|
replace,
|
|
10405
10239
|
ErrorResponseImpl,
|
|
10406
10240
|
isRouteErrorResponse,
|
|
10407
|
-
instrumentHandler,
|
|
10408
10241
|
IDLE_NAVIGATION,
|
|
10409
10242
|
IDLE_FETCHER,
|
|
10410
10243
|
IDLE_BLOCKER,
|
|
@@ -10447,10 +10280,12 @@ export {
|
|
|
10447
10280
|
useAsyncValue,
|
|
10448
10281
|
useAsyncError,
|
|
10449
10282
|
useBlocker,
|
|
10283
|
+
useRoute,
|
|
10450
10284
|
warnOnce,
|
|
10451
10285
|
mapRouteProperties,
|
|
10452
10286
|
hydrationRouteProperties,
|
|
10453
10287
|
createMemoryRouter,
|
|
10288
|
+
UNSTABLE_TransitionEnabledRouterProvider,
|
|
10454
10289
|
RouterProvider,
|
|
10455
10290
|
MemoryRouter,
|
|
10456
10291
|
Navigate,
|