react-router 7.9.4 → 7.9.6
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 +70 -0
- package/dist/development/browser-BbBXFHbO.d.ts +310 -0
- package/dist/development/browser-C07r42Tt.d.mts +310 -0
- package/dist/development/{chunk-OIYGIGL5.mjs → chunk-4WY6JWTD.mjs} +458 -43
- package/dist/development/{chunk-DI2QHYMJ.js → chunk-AMVS5XVJ.js} +1314 -138
- package/dist/development/{chunk-WY5IRSCW.mjs → chunk-G3INQAYP.mjs} +197 -857
- package/dist/development/chunk-O4JVZSOY.js +1310 -0
- package/dist/development/chunk-PZWDWJAY.js +188 -0
- package/dist/development/dom-export.d.mts +103 -6
- package/dist/development/dom-export.d.ts +103 -4
- package/dist/development/dom-export.js +708 -20
- package/dist/development/dom-export.mjs +692 -11
- package/dist/{production/index-react-server-client-BbRcBjrA.d.ts → development/index-react-server-client-Da3kmxNd.d.ts} +195 -135
- package/dist/{production/index-react-server-client-BIz4AUNd.d.mts → development/index-react-server-client-rcoGPJhU.d.mts} +137 -78
- package/dist/development/index-react-server-client.d.mts +2 -3
- package/dist/development/index-react-server-client.d.ts +2 -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 +107 -3
- package/dist/development/index-react-server.d.ts +107 -3
- package/dist/development/index-react-server.js +259 -13
- package/dist/development/index-react-server.mjs +259 -13
- package/dist/development/index.d.mts +14 -320
- package/dist/development/index.d.ts +14 -362
- package/dist/development/index.js +146 -962
- package/dist/development/index.mjs +3 -9
- package/dist/development/{routeModules-D5iJ6JYT.d.ts → instrumentation-Unc20tLk.d.ts} +178 -25
- package/dist/development/lib/types/internal.d.mts +2 -3
- package/dist/development/lib/types/internal.d.ts +2 -2
- package/dist/development/lib/types/internal.js +1 -1
- package/dist/development/lib/types/internal.mjs +1 -1
- package/dist/{production/register-C34pU-in.d.ts → development/register-BpU9rFBJ.d.ts} +1 -1
- package/dist/development/{register-CI4bTprK.d.mts → register-QkB3HGjm.d.mts} +1 -1
- package/dist/{production/context-DSyS5mLj.d.mts → development/router-CAvh_Drx.d.mts} +1877 -1254
- package/dist/production/browser-BbBXFHbO.d.ts +310 -0
- package/dist/production/browser-C07r42Tt.d.mts +310 -0
- package/dist/production/{chunk-4E5LHRQP.js → chunk-EAIF67OW.js} +1314 -138
- package/dist/production/{chunk-FR6HSPLK.mjs → chunk-FDUMZGKM.mjs} +197 -857
- package/dist/production/{chunk-3TADTUL4.mjs → chunk-FUSXQSWG.mjs} +458 -43
- package/dist/production/chunk-G5A35OQU.js +188 -0
- package/dist/production/chunk-QN64DHI4.js +1310 -0
- package/dist/production/dom-export.d.mts +103 -6
- package/dist/production/dom-export.d.ts +103 -4
- package/dist/production/dom-export.js +708 -20
- package/dist/production/dom-export.mjs +692 -11
- package/dist/{development/index-react-server-client-BIz4AUNd.d.mts → production/index-react-server-client-Da3kmxNd.d.ts} +137 -78
- package/dist/{development/index-react-server-client-BbRcBjrA.d.ts → production/index-react-server-client-rcoGPJhU.d.mts} +195 -135
- package/dist/production/index-react-server-client.d.mts +2 -3
- package/dist/production/index-react-server-client.d.ts +2 -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 +107 -3
- package/dist/production/index-react-server.d.ts +107 -3
- package/dist/production/index-react-server.js +259 -13
- package/dist/production/index-react-server.mjs +259 -13
- package/dist/production/index.d.mts +14 -320
- package/dist/production/index.d.ts +14 -362
- package/dist/production/index.js +146 -962
- package/dist/production/index.mjs +3 -9
- package/dist/production/{routeModules-D5iJ6JYT.d.ts → instrumentation-Unc20tLk.d.ts} +178 -25
- package/dist/production/lib/types/internal.d.mts +2 -3
- package/dist/production/lib/types/internal.d.ts +2 -2
- package/dist/production/lib/types/internal.js +1 -1
- package/dist/production/lib/types/internal.mjs +1 -1
- package/dist/{development/register-C34pU-in.d.ts → production/register-BpU9rFBJ.d.ts} +1 -1
- package/dist/production/{register-CI4bTprK.d.mts → register-QkB3HGjm.d.mts} +1 -1
- package/dist/{development/context-DSyS5mLj.d.mts → production/router-CAvh_Drx.d.mts} +1877 -1254
- package/package.json +1 -1
- package/dist/development/browser-z32v5KVN.d.mts +0 -46
- package/dist/development/chunk-72XNTZCV.js +0 -2089
- package/dist/development/route-data-DZQOUSqV.d.mts +0 -473
- package/dist/production/browser-z32v5KVN.d.mts +0 -46
- package/dist/production/chunk-WNLQ53P5.js +0 -2089
- package/dist/production/route-data-DZQOUSqV.d.mts +0 -473
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v7.9.
|
|
2
|
+
* react-router v7.9.6
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -22,13 +22,8 @@ import {
|
|
|
22
22
|
SingleFetchRedirectSymbol,
|
|
23
23
|
StaticRouterProvider,
|
|
24
24
|
StreamTransfer,
|
|
25
|
-
UNSTABLE_TransitionEnabledRouterProvider,
|
|
26
25
|
convertRoutesToDataRoutes,
|
|
27
|
-
createBrowserHistory,
|
|
28
|
-
createContext,
|
|
29
26
|
createMemoryRouter,
|
|
30
|
-
createRequestInit,
|
|
31
|
-
createRouter,
|
|
32
27
|
createServerRoutes,
|
|
33
28
|
createStaticHandler,
|
|
34
29
|
createStaticRouter,
|
|
@@ -36,31 +31,25 @@ import {
|
|
|
36
31
|
encode,
|
|
37
32
|
escapeHtml,
|
|
38
33
|
getManifestPath,
|
|
39
|
-
getSingleFetchDataStrategyImpl,
|
|
40
34
|
getStaticContextFromError,
|
|
41
|
-
|
|
35
|
+
instrumentHandler,
|
|
42
36
|
isDataWithResponseInit,
|
|
43
|
-
isMutationMethod,
|
|
44
37
|
isRedirectResponse,
|
|
45
38
|
isRedirectStatusCode,
|
|
46
39
|
isResponse,
|
|
47
40
|
isRouteErrorResponse,
|
|
48
41
|
matchRoutes,
|
|
49
|
-
noActionDefinedError,
|
|
50
42
|
redirect,
|
|
51
43
|
redirectDocument,
|
|
52
44
|
replace,
|
|
53
|
-
setIsHydrated,
|
|
54
45
|
shouldHydrateRouteLoader,
|
|
55
|
-
singleFetchUrl,
|
|
56
46
|
stripBasename,
|
|
57
|
-
stripIndexParam,
|
|
58
47
|
useRouteError,
|
|
59
48
|
warnOnce,
|
|
60
49
|
withComponentProps,
|
|
61
50
|
withErrorBoundaryProps,
|
|
62
51
|
withHydrateFallbackProps
|
|
63
|
-
} from "./chunk-
|
|
52
|
+
} from "./chunk-FUSXQSWG.mjs";
|
|
64
53
|
|
|
65
54
|
// lib/dom/ssr/server.tsx
|
|
66
55
|
import * as React from "react";
|
|
@@ -515,16 +504,17 @@ function matchServerRoutes(routes, pathname, basename) {
|
|
|
515
504
|
// lib/server-runtime/data.ts
|
|
516
505
|
async function callRouteHandler(handler, args) {
|
|
517
506
|
let result = await handler({
|
|
518
|
-
request: stripRoutesParam(
|
|
507
|
+
request: stripRoutesParam(stripIndexParam(args.request)),
|
|
519
508
|
params: args.params,
|
|
520
|
-
context: args.context
|
|
509
|
+
context: args.context,
|
|
510
|
+
unstable_pattern: args.unstable_pattern
|
|
521
511
|
});
|
|
522
512
|
if (isDataWithResponseInit(result) && result.init && result.init.status && isRedirectStatusCode(result.init.status)) {
|
|
523
513
|
throw new Response(null, result.init);
|
|
524
514
|
}
|
|
525
515
|
return result;
|
|
526
516
|
}
|
|
527
|
-
function
|
|
517
|
+
function stripIndexParam(request) {
|
|
528
518
|
let url = new URL(request.url);
|
|
529
519
|
let indexValues = url.searchParams.getAll("index");
|
|
530
520
|
url.searchParams.delete("index");
|
|
@@ -564,7 +554,7 @@ function stripRoutesParam(request) {
|
|
|
564
554
|
}
|
|
565
555
|
|
|
566
556
|
// lib/server-runtime/invariant.ts
|
|
567
|
-
function
|
|
557
|
+
function invariant(value, message) {
|
|
568
558
|
if (value === false || value === null || typeof value === "undefined") {
|
|
569
559
|
console.error(
|
|
570
560
|
"The following error is a bug in React Router; please open an issue! https://github.com/remix-run/react-router/issues/new/choose"
|
|
@@ -630,7 +620,7 @@ function createStaticHandlerDataRoutes(manifest, future, parentId = "", routesBy
|
|
|
630
620
|
);
|
|
631
621
|
if (preRenderedData != null) {
|
|
632
622
|
let encoded = preRenderedData ? decodeURI(preRenderedData) : preRenderedData;
|
|
633
|
-
|
|
623
|
+
invariant(encoded, "Missing prerendered data for route");
|
|
634
624
|
let uint8array = new TextEncoder().encode(encoded);
|
|
635
625
|
let stream = new ReadableStream({
|
|
636
626
|
start(controller) {
|
|
@@ -651,12 +641,12 @@ function createStaticHandlerDataRoutes(manifest, future, parentId = "", routesBy
|
|
|
651
641
|
throw redirect(result.redirect, init);
|
|
652
642
|
}
|
|
653
643
|
} else {
|
|
654
|
-
|
|
644
|
+
invariant(
|
|
655
645
|
data2 && route.id in data2,
|
|
656
646
|
"Unable to decode prerendered data"
|
|
657
647
|
);
|
|
658
648
|
let result = data2[route.id];
|
|
659
|
-
|
|
649
|
+
invariant(
|
|
660
650
|
"data" in result,
|
|
661
651
|
"Unable to process prerendered data"
|
|
662
652
|
);
|
|
@@ -695,7 +685,7 @@ import { splitCookiesString } from "set-cookie-parser";
|
|
|
695
685
|
function getDocumentHeaders(context, build) {
|
|
696
686
|
return getDocumentHeadersImpl(context, (m) => {
|
|
697
687
|
let route = build.routes[m.route.id];
|
|
698
|
-
|
|
688
|
+
invariant(route, `Route with id "${m.route.id}" not found in build`);
|
|
699
689
|
return route.module.headers;
|
|
700
690
|
});
|
|
701
691
|
}
|
|
@@ -1010,7 +1000,8 @@ function derive(build, mode) {
|
|
|
1010
1000
|
let dataRoutes = createStaticHandlerDataRoutes(build.routes, build.future);
|
|
1011
1001
|
let serverMode = isServerMode(mode) ? mode : "production" /* Production */;
|
|
1012
1002
|
let staticHandler = createStaticHandler(dataRoutes, {
|
|
1013
|
-
basename: build.basename
|
|
1003
|
+
basename: build.basename,
|
|
1004
|
+
unstable_instrumentations: build.entry.module.unstable_instrumentations
|
|
1014
1005
|
});
|
|
1015
1006
|
let errorHandler = build.entry.module.handleError || ((error, { request }) => {
|
|
1016
1007
|
if (serverMode !== "test" /* Test */ && !request.signal.aborted) {
|
|
@@ -1020,35 +1011,7 @@ function derive(build, mode) {
|
|
|
1020
1011
|
);
|
|
1021
1012
|
}
|
|
1022
1013
|
});
|
|
1023
|
-
|
|
1024
|
-
routes,
|
|
1025
|
-
dataRoutes,
|
|
1026
|
-
serverMode,
|
|
1027
|
-
staticHandler,
|
|
1028
|
-
errorHandler
|
|
1029
|
-
};
|
|
1030
|
-
}
|
|
1031
|
-
var createRequestHandler = (build, mode) => {
|
|
1032
|
-
let _build;
|
|
1033
|
-
let routes;
|
|
1034
|
-
let serverMode;
|
|
1035
|
-
let staticHandler;
|
|
1036
|
-
let errorHandler;
|
|
1037
|
-
return async function requestHandler(request, initialContext) {
|
|
1038
|
-
_build = typeof build === "function" ? await build() : build;
|
|
1039
|
-
if (typeof build === "function") {
|
|
1040
|
-
let derived = derive(_build, mode);
|
|
1041
|
-
routes = derived.routes;
|
|
1042
|
-
serverMode = derived.serverMode;
|
|
1043
|
-
staticHandler = derived.staticHandler;
|
|
1044
|
-
errorHandler = derived.errorHandler;
|
|
1045
|
-
} else if (!routes || !serverMode || !staticHandler || !errorHandler) {
|
|
1046
|
-
let derived = derive(_build, mode);
|
|
1047
|
-
routes = derived.routes;
|
|
1048
|
-
serverMode = derived.serverMode;
|
|
1049
|
-
staticHandler = derived.staticHandler;
|
|
1050
|
-
errorHandler = derived.errorHandler;
|
|
1051
|
-
}
|
|
1014
|
+
let requestHandler = async (request, initialContext) => {
|
|
1052
1015
|
let params = {};
|
|
1053
1016
|
let loadContext;
|
|
1054
1017
|
let handleError = (error) => {
|
|
@@ -1061,7 +1024,7 @@ var createRequestHandler = (build, mode) => {
|
|
|
1061
1024
|
request
|
|
1062
1025
|
});
|
|
1063
1026
|
};
|
|
1064
|
-
if (
|
|
1027
|
+
if (build.future.v8_middleware) {
|
|
1065
1028
|
if (initialContext && !(initialContext instanceof RouterContextProvider)) {
|
|
1066
1029
|
let error = new Error(
|
|
1067
1030
|
"Invalid `context` value provided to `handleRequest`. When middleware is enabled you must return an instance of `RouterContextProvider` from your `getLoadContext` function."
|
|
@@ -1074,7 +1037,7 @@ var createRequestHandler = (build, mode) => {
|
|
|
1074
1037
|
loadContext = initialContext || {};
|
|
1075
1038
|
}
|
|
1076
1039
|
let url = new URL(request.url);
|
|
1077
|
-
let normalizedBasename =
|
|
1040
|
+
let normalizedBasename = build.basename || "/";
|
|
1078
1041
|
let normalizedPath = url.pathname;
|
|
1079
1042
|
if (stripBasename(normalizedPath, normalizedBasename) === "/_root.data") {
|
|
1080
1043
|
normalizedPath = normalizedBasename;
|
|
@@ -1085,7 +1048,7 @@ var createRequestHandler = (build, mode) => {
|
|
|
1085
1048
|
normalizedPath = normalizedPath.slice(0, -1);
|
|
1086
1049
|
}
|
|
1087
1050
|
let isSpaMode = getBuildTimeHeader(request, "X-React-Router-SPA-Mode") === "yes";
|
|
1088
|
-
if (!
|
|
1051
|
+
if (!build.ssr) {
|
|
1089
1052
|
let decodedPath = decodeURI(normalizedPath);
|
|
1090
1053
|
if (normalizedBasename !== "/") {
|
|
1091
1054
|
let strippedPath = stripBasename(decodedPath, normalizedBasename);
|
|
@@ -1109,9 +1072,9 @@ var createRequestHandler = (build, mode) => {
|
|
|
1109
1072
|
}
|
|
1110
1073
|
decodedPath = strippedPath;
|
|
1111
1074
|
}
|
|
1112
|
-
if (
|
|
1075
|
+
if (build.prerender.length === 0) {
|
|
1113
1076
|
isSpaMode = true;
|
|
1114
|
-
} else if (!
|
|
1077
|
+
} else if (!build.prerender.includes(decodedPath) && !build.prerender.includes(decodedPath + "/")) {
|
|
1115
1078
|
if (url.pathname.endsWith(".data")) {
|
|
1116
1079
|
errorHandler(
|
|
1117
1080
|
new ErrorResponseImpl(
|
|
@@ -1135,19 +1098,19 @@ var createRequestHandler = (build, mode) => {
|
|
|
1135
1098
|
}
|
|
1136
1099
|
}
|
|
1137
1100
|
let manifestUrl = getManifestPath(
|
|
1138
|
-
|
|
1101
|
+
build.routeDiscovery.manifestPath,
|
|
1139
1102
|
normalizedBasename
|
|
1140
1103
|
);
|
|
1141
1104
|
if (url.pathname === manifestUrl) {
|
|
1142
1105
|
try {
|
|
1143
|
-
let res = await handleManifestRequest(
|
|
1106
|
+
let res = await handleManifestRequest(build, routes, url);
|
|
1144
1107
|
return res;
|
|
1145
1108
|
} catch (e) {
|
|
1146
1109
|
handleError(e);
|
|
1147
1110
|
return new Response("Unknown Server Error", { status: 500 });
|
|
1148
1111
|
}
|
|
1149
1112
|
}
|
|
1150
|
-
let matches = matchServerRoutes(routes, normalizedPath,
|
|
1113
|
+
let matches = matchServerRoutes(routes, normalizedPath, build.basename);
|
|
1151
1114
|
if (matches && matches.length > 0) {
|
|
1152
1115
|
Object.assign(params, matches[0].params);
|
|
1153
1116
|
}
|
|
@@ -1158,11 +1121,11 @@ var createRequestHandler = (build, mode) => {
|
|
|
1158
1121
|
let singleFetchMatches = matchServerRoutes(
|
|
1159
1122
|
routes,
|
|
1160
1123
|
handlerUrl.pathname,
|
|
1161
|
-
|
|
1124
|
+
build.basename
|
|
1162
1125
|
);
|
|
1163
1126
|
response = await handleSingleFetchRequest(
|
|
1164
1127
|
serverMode,
|
|
1165
|
-
|
|
1128
|
+
build,
|
|
1166
1129
|
staticHandler,
|
|
1167
1130
|
request,
|
|
1168
1131
|
handlerUrl,
|
|
@@ -1173,12 +1136,12 @@ var createRequestHandler = (build, mode) => {
|
|
|
1173
1136
|
response = generateSingleFetchRedirectResponse(
|
|
1174
1137
|
response,
|
|
1175
1138
|
request,
|
|
1176
|
-
|
|
1139
|
+
build,
|
|
1177
1140
|
serverMode
|
|
1178
1141
|
);
|
|
1179
1142
|
}
|
|
1180
|
-
if (
|
|
1181
|
-
response = await
|
|
1143
|
+
if (build.entry.module.handleDataRequest) {
|
|
1144
|
+
response = await build.entry.module.handleDataRequest(response, {
|
|
1182
1145
|
context: loadContext,
|
|
1183
1146
|
params: singleFetchMatches ? singleFetchMatches[0].params : {},
|
|
1184
1147
|
request
|
|
@@ -1187,7 +1150,7 @@ var createRequestHandler = (build, mode) => {
|
|
|
1187
1150
|
response = generateSingleFetchRedirectResponse(
|
|
1188
1151
|
response,
|
|
1189
1152
|
request,
|
|
1190
|
-
|
|
1153
|
+
build,
|
|
1191
1154
|
serverMode
|
|
1192
1155
|
);
|
|
1193
1156
|
}
|
|
@@ -1195,7 +1158,7 @@ var createRequestHandler = (build, mode) => {
|
|
|
1195
1158
|
} else if (!isSpaMode && matches && matches[matches.length - 1].route.module.default == null && matches[matches.length - 1].route.module.ErrorBoundary == null) {
|
|
1196
1159
|
response = await handleResourceRequest(
|
|
1197
1160
|
serverMode,
|
|
1198
|
-
|
|
1161
|
+
build,
|
|
1199
1162
|
staticHandler,
|
|
1200
1163
|
matches.slice(-1)[0].route.id,
|
|
1201
1164
|
request,
|
|
@@ -1205,14 +1168,14 @@ var createRequestHandler = (build, mode) => {
|
|
|
1205
1168
|
} else {
|
|
1206
1169
|
let { pathname } = url;
|
|
1207
1170
|
let criticalCss = void 0;
|
|
1208
|
-
if (
|
|
1209
|
-
criticalCss = await
|
|
1171
|
+
if (build.unstable_getCriticalCss) {
|
|
1172
|
+
criticalCss = await build.unstable_getCriticalCss({ pathname });
|
|
1210
1173
|
} else if (mode === "development" /* Development */ && getDevServerHooks()?.getCriticalCss) {
|
|
1211
1174
|
criticalCss = await getDevServerHooks()?.getCriticalCss?.(pathname);
|
|
1212
1175
|
}
|
|
1213
1176
|
response = await handleDocumentRequest(
|
|
1214
1177
|
serverMode,
|
|
1215
|
-
|
|
1178
|
+
build,
|
|
1216
1179
|
staticHandler,
|
|
1217
1180
|
request,
|
|
1218
1181
|
loadContext,
|
|
@@ -1230,6 +1193,47 @@ var createRequestHandler = (build, mode) => {
|
|
|
1230
1193
|
}
|
|
1231
1194
|
return response;
|
|
1232
1195
|
};
|
|
1196
|
+
if (build.entry.module.unstable_instrumentations) {
|
|
1197
|
+
requestHandler = instrumentHandler(
|
|
1198
|
+
requestHandler,
|
|
1199
|
+
build.entry.module.unstable_instrumentations.map((i) => i.handler).filter(Boolean)
|
|
1200
|
+
);
|
|
1201
|
+
}
|
|
1202
|
+
return {
|
|
1203
|
+
routes,
|
|
1204
|
+
dataRoutes,
|
|
1205
|
+
serverMode,
|
|
1206
|
+
staticHandler,
|
|
1207
|
+
errorHandler,
|
|
1208
|
+
requestHandler
|
|
1209
|
+
};
|
|
1210
|
+
}
|
|
1211
|
+
var createRequestHandler = (build, mode) => {
|
|
1212
|
+
let _build;
|
|
1213
|
+
let routes;
|
|
1214
|
+
let serverMode;
|
|
1215
|
+
let staticHandler;
|
|
1216
|
+
let errorHandler;
|
|
1217
|
+
let _requestHandler;
|
|
1218
|
+
return async function requestHandler(request, initialContext) {
|
|
1219
|
+
_build = typeof build === "function" ? await build() : build;
|
|
1220
|
+
if (typeof build === "function") {
|
|
1221
|
+
let derived = derive(_build, mode);
|
|
1222
|
+
routes = derived.routes;
|
|
1223
|
+
serverMode = derived.serverMode;
|
|
1224
|
+
staticHandler = derived.staticHandler;
|
|
1225
|
+
errorHandler = derived.errorHandler;
|
|
1226
|
+
_requestHandler = derived.requestHandler;
|
|
1227
|
+
} else if (!routes || !serverMode || !staticHandler || !errorHandler || !_requestHandler) {
|
|
1228
|
+
let derived = derive(_build, mode);
|
|
1229
|
+
routes = derived.routes;
|
|
1230
|
+
serverMode = derived.serverMode;
|
|
1231
|
+
staticHandler = derived.staticHandler;
|
|
1232
|
+
errorHandler = derived.errorHandler;
|
|
1233
|
+
_requestHandler = derived.requestHandler;
|
|
1234
|
+
}
|
|
1235
|
+
return _requestHandler(request, initialContext);
|
|
1236
|
+
};
|
|
1233
1237
|
};
|
|
1234
1238
|
async function handleManifestRequest(build, routes, url) {
|
|
1235
1239
|
if (build.assets.version !== url.searchParams.get("version")) {
|
|
@@ -1674,41 +1678,95 @@ function href(path, ...args) {
|
|
|
1674
1678
|
return result || "/";
|
|
1675
1679
|
}
|
|
1676
1680
|
|
|
1677
|
-
// lib/rsc/
|
|
1681
|
+
// lib/rsc/server.ssr.tsx
|
|
1678
1682
|
import * as React4 from "react";
|
|
1679
|
-
import * as ReactDOM from "react-dom";
|
|
1680
1683
|
|
|
1681
|
-
// lib/
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
let
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
let routeInfo = getRouteInfo(routeId);
|
|
1699
|
-
if (shouldHydrateRouteLoader(
|
|
1700
|
-
routeId,
|
|
1701
|
-
routeInfo.clientLoader,
|
|
1702
|
-
routeInfo.hasLoader,
|
|
1703
|
-
isSpaMode
|
|
1704
|
-
) && (routeInfo.hasHydrateFallback || !routeInfo.hasLoader)) {
|
|
1705
|
-
delete hydrationData.loaderData[routeId];
|
|
1706
|
-
} else if (!routeInfo.hasLoader) {
|
|
1707
|
-
hydrationData.loaderData[routeId] = null;
|
|
1684
|
+
// lib/rsc/html-stream/server.ts
|
|
1685
|
+
var encoder2 = new TextEncoder();
|
|
1686
|
+
var trailer = "</body></html>";
|
|
1687
|
+
function injectRSCPayload(rscStream) {
|
|
1688
|
+
let decoder = new TextDecoder();
|
|
1689
|
+
let resolveFlightDataPromise;
|
|
1690
|
+
let flightDataPromise = new Promise(
|
|
1691
|
+
(resolve) => resolveFlightDataPromise = resolve
|
|
1692
|
+
);
|
|
1693
|
+
let startedRSC = false;
|
|
1694
|
+
let buffered = [];
|
|
1695
|
+
let timeout = null;
|
|
1696
|
+
function flushBufferedChunks(controller) {
|
|
1697
|
+
for (let chunk of buffered) {
|
|
1698
|
+
let buf = decoder.decode(chunk, { stream: true });
|
|
1699
|
+
if (buf.endsWith(trailer)) {
|
|
1700
|
+
buf = buf.slice(0, -trailer.length);
|
|
1708
1701
|
}
|
|
1702
|
+
controller.enqueue(encoder2.encode(buf));
|
|
1709
1703
|
}
|
|
1704
|
+
buffered.length = 0;
|
|
1705
|
+
timeout = null;
|
|
1706
|
+
}
|
|
1707
|
+
return new TransformStream({
|
|
1708
|
+
transform(chunk, controller) {
|
|
1709
|
+
buffered.push(chunk);
|
|
1710
|
+
if (timeout) {
|
|
1711
|
+
return;
|
|
1712
|
+
}
|
|
1713
|
+
timeout = setTimeout(async () => {
|
|
1714
|
+
flushBufferedChunks(controller);
|
|
1715
|
+
if (!startedRSC) {
|
|
1716
|
+
startedRSC = true;
|
|
1717
|
+
writeRSCStream(rscStream, controller).catch((err) => controller.error(err)).then(resolveFlightDataPromise);
|
|
1718
|
+
}
|
|
1719
|
+
}, 0);
|
|
1720
|
+
},
|
|
1721
|
+
async flush(controller) {
|
|
1722
|
+
await flightDataPromise;
|
|
1723
|
+
if (timeout) {
|
|
1724
|
+
clearTimeout(timeout);
|
|
1725
|
+
flushBufferedChunks(controller);
|
|
1726
|
+
}
|
|
1727
|
+
controller.enqueue(encoder2.encode("</body></html>"));
|
|
1728
|
+
}
|
|
1729
|
+
});
|
|
1730
|
+
}
|
|
1731
|
+
async function writeRSCStream(rscStream, controller) {
|
|
1732
|
+
let decoder = new TextDecoder("utf-8", { fatal: true });
|
|
1733
|
+
const reader = rscStream.getReader();
|
|
1734
|
+
try {
|
|
1735
|
+
let read;
|
|
1736
|
+
while ((read = await reader.read()) && !read.done) {
|
|
1737
|
+
const chunk = read.value;
|
|
1738
|
+
try {
|
|
1739
|
+
writeChunk(
|
|
1740
|
+
JSON.stringify(decoder.decode(chunk, { stream: true })),
|
|
1741
|
+
controller
|
|
1742
|
+
);
|
|
1743
|
+
} catch (err) {
|
|
1744
|
+
let base64 = JSON.stringify(btoa(String.fromCodePoint(...chunk)));
|
|
1745
|
+
writeChunk(
|
|
1746
|
+
`Uint8Array.from(atob(${base64}), m => m.codePointAt(0))`,
|
|
1747
|
+
controller
|
|
1748
|
+
);
|
|
1749
|
+
}
|
|
1750
|
+
}
|
|
1751
|
+
} finally {
|
|
1752
|
+
reader.releaseLock();
|
|
1753
|
+
}
|
|
1754
|
+
let remaining = decoder.decode();
|
|
1755
|
+
if (remaining.length) {
|
|
1756
|
+
writeChunk(JSON.stringify(remaining), controller);
|
|
1710
1757
|
}
|
|
1711
|
-
|
|
1758
|
+
}
|
|
1759
|
+
function writeChunk(chunk, controller) {
|
|
1760
|
+
controller.enqueue(
|
|
1761
|
+
encoder2.encode(
|
|
1762
|
+
`<script>${escapeScript(
|
|
1763
|
+
`(self.__FLIGHT_DATA||=[]).push(${chunk})`
|
|
1764
|
+
)}</script>`
|
|
1765
|
+
)
|
|
1766
|
+
);
|
|
1767
|
+
}
|
|
1768
|
+
function escapeScript(script) {
|
|
1769
|
+
return script.replace(/<!--/g, "<\\!--").replace(/<\/(script)/gi, "</\\$1");
|
|
1712
1770
|
}
|
|
1713
1771
|
|
|
1714
1772
|
// lib/rsc/errorBoundaries.tsx
|
|
@@ -1841,724 +1899,9 @@ function populateRSCRouteModules(routeModules, matches) {
|
|
|
1841
1899
|
}
|
|
1842
1900
|
var noopComponent = () => null;
|
|
1843
1901
|
|
|
1844
|
-
// lib/rsc/browser.tsx
|
|
1845
|
-
function createCallServer({
|
|
1846
|
-
createFromReadableStream,
|
|
1847
|
-
createTemporaryReferenceSet,
|
|
1848
|
-
encodeReply,
|
|
1849
|
-
fetch: fetchImplementation = fetch
|
|
1850
|
-
}) {
|
|
1851
|
-
const globalVar = window;
|
|
1852
|
-
let landedActionId = 0;
|
|
1853
|
-
return async (id, args) => {
|
|
1854
|
-
let actionId = globalVar.__routerActionID = (globalVar.__routerActionID ?? (globalVar.__routerActionID = 0)) + 1;
|
|
1855
|
-
const temporaryReferences = createTemporaryReferenceSet();
|
|
1856
|
-
const payloadPromise = fetchImplementation(
|
|
1857
|
-
new Request(location.href, {
|
|
1858
|
-
body: await encodeReply(args, { temporaryReferences }),
|
|
1859
|
-
method: "POST",
|
|
1860
|
-
headers: {
|
|
1861
|
-
Accept: "text/x-component",
|
|
1862
|
-
"rsc-action-id": id
|
|
1863
|
-
}
|
|
1864
|
-
})
|
|
1865
|
-
).then((response) => {
|
|
1866
|
-
if (!response.body) {
|
|
1867
|
-
throw new Error("No response body");
|
|
1868
|
-
}
|
|
1869
|
-
return createFromReadableStream(response.body, {
|
|
1870
|
-
temporaryReferences
|
|
1871
|
-
});
|
|
1872
|
-
});
|
|
1873
|
-
globalVar.__reactRouterDataRouter.__setPendingRerender(
|
|
1874
|
-
Promise.resolve(payloadPromise).then(async (payload) => {
|
|
1875
|
-
if (payload.type === "redirect") {
|
|
1876
|
-
if (payload.reload || isExternalLocation(payload.location)) {
|
|
1877
|
-
window.location.href = payload.location;
|
|
1878
|
-
return () => {
|
|
1879
|
-
};
|
|
1880
|
-
}
|
|
1881
|
-
return () => {
|
|
1882
|
-
globalVar.__reactRouterDataRouter.navigate(payload.location, {
|
|
1883
|
-
replace: payload.replace
|
|
1884
|
-
});
|
|
1885
|
-
};
|
|
1886
|
-
}
|
|
1887
|
-
if (payload.type !== "action") {
|
|
1888
|
-
throw new Error("Unexpected payload type");
|
|
1889
|
-
}
|
|
1890
|
-
const rerender = await payload.rerender;
|
|
1891
|
-
if (rerender && landedActionId < actionId && globalVar.__routerActionID <= actionId) {
|
|
1892
|
-
if (rerender.type === "redirect") {
|
|
1893
|
-
if (rerender.reload || isExternalLocation(rerender.location)) {
|
|
1894
|
-
window.location.href = rerender.location;
|
|
1895
|
-
return;
|
|
1896
|
-
}
|
|
1897
|
-
return () => {
|
|
1898
|
-
globalVar.__reactRouterDataRouter.navigate(rerender.location, {
|
|
1899
|
-
replace: rerender.replace
|
|
1900
|
-
});
|
|
1901
|
-
};
|
|
1902
|
-
}
|
|
1903
|
-
return () => {
|
|
1904
|
-
let lastMatch;
|
|
1905
|
-
for (const match of rerender.matches) {
|
|
1906
|
-
globalVar.__reactRouterDataRouter.patchRoutes(
|
|
1907
|
-
lastMatch?.id ?? null,
|
|
1908
|
-
[createRouteFromServerManifest(match)],
|
|
1909
|
-
true
|
|
1910
|
-
);
|
|
1911
|
-
lastMatch = match;
|
|
1912
|
-
}
|
|
1913
|
-
window.__reactRouterDataRouter._internalSetStateDoNotUseOrYouWillBreakYourApp(
|
|
1914
|
-
{
|
|
1915
|
-
loaderData: Object.assign(
|
|
1916
|
-
{},
|
|
1917
|
-
globalVar.__reactRouterDataRouter.state.loaderData,
|
|
1918
|
-
rerender.loaderData
|
|
1919
|
-
),
|
|
1920
|
-
errors: rerender.errors ? Object.assign(
|
|
1921
|
-
{},
|
|
1922
|
-
globalVar.__reactRouterDataRouter.state.errors,
|
|
1923
|
-
rerender.errors
|
|
1924
|
-
) : null
|
|
1925
|
-
}
|
|
1926
|
-
);
|
|
1927
|
-
};
|
|
1928
|
-
}
|
|
1929
|
-
return () => {
|
|
1930
|
-
};
|
|
1931
|
-
}).catch(() => {
|
|
1932
|
-
})
|
|
1933
|
-
);
|
|
1934
|
-
return payloadPromise.then((payload) => {
|
|
1935
|
-
if (payload.type !== "action" && payload.type !== "redirect") {
|
|
1936
|
-
throw new Error("Unexpected payload type");
|
|
1937
|
-
}
|
|
1938
|
-
return payload.actionResult;
|
|
1939
|
-
});
|
|
1940
|
-
};
|
|
1941
|
-
}
|
|
1942
|
-
function createRouterFromPayload({
|
|
1943
|
-
fetchImplementation,
|
|
1944
|
-
createFromReadableStream,
|
|
1945
|
-
getContext,
|
|
1946
|
-
payload
|
|
1947
|
-
}) {
|
|
1948
|
-
const globalVar = window;
|
|
1949
|
-
if (globalVar.__reactRouterDataRouter && globalVar.__reactRouterRouteModules)
|
|
1950
|
-
return {
|
|
1951
|
-
router: globalVar.__reactRouterDataRouter,
|
|
1952
|
-
routeModules: globalVar.__reactRouterRouteModules
|
|
1953
|
-
};
|
|
1954
|
-
if (payload.type !== "render") throw new Error("Invalid payload type");
|
|
1955
|
-
globalVar.__reactRouterRouteModules = globalVar.__reactRouterRouteModules ?? {};
|
|
1956
|
-
populateRSCRouteModules(globalVar.__reactRouterRouteModules, payload.matches);
|
|
1957
|
-
let patches = /* @__PURE__ */ new Map();
|
|
1958
|
-
payload.patches?.forEach((patch) => {
|
|
1959
|
-
invariant(patch.parentId, "Invalid patch parentId");
|
|
1960
|
-
if (!patches.has(patch.parentId)) {
|
|
1961
|
-
patches.set(patch.parentId, []);
|
|
1962
|
-
}
|
|
1963
|
-
patches.get(patch.parentId)?.push(patch);
|
|
1964
|
-
});
|
|
1965
|
-
let routes = payload.matches.reduceRight((previous, match) => {
|
|
1966
|
-
const route = createRouteFromServerManifest(
|
|
1967
|
-
match,
|
|
1968
|
-
payload
|
|
1969
|
-
);
|
|
1970
|
-
if (previous.length > 0) {
|
|
1971
|
-
route.children = previous;
|
|
1972
|
-
let childrenToPatch = patches.get(match.id);
|
|
1973
|
-
if (childrenToPatch) {
|
|
1974
|
-
route.children.push(
|
|
1975
|
-
...childrenToPatch.map((r) => createRouteFromServerManifest(r))
|
|
1976
|
-
);
|
|
1977
|
-
}
|
|
1978
|
-
}
|
|
1979
|
-
return [route];
|
|
1980
|
-
}, []);
|
|
1981
|
-
globalVar.__reactRouterDataRouter = createRouter({
|
|
1982
|
-
routes,
|
|
1983
|
-
getContext,
|
|
1984
|
-
basename: payload.basename,
|
|
1985
|
-
history: createBrowserHistory(),
|
|
1986
|
-
hydrationData: getHydrationData({
|
|
1987
|
-
state: {
|
|
1988
|
-
loaderData: payload.loaderData,
|
|
1989
|
-
actionData: payload.actionData,
|
|
1990
|
-
errors: payload.errors
|
|
1991
|
-
},
|
|
1992
|
-
routes,
|
|
1993
|
-
getRouteInfo: (routeId) => {
|
|
1994
|
-
let match = payload.matches.find((m) => m.id === routeId);
|
|
1995
|
-
invariant(match, "Route not found in payload");
|
|
1996
|
-
return {
|
|
1997
|
-
clientLoader: match.clientLoader,
|
|
1998
|
-
hasLoader: match.hasLoader,
|
|
1999
|
-
hasHydrateFallback: match.hydrateFallbackElement != null
|
|
2000
|
-
};
|
|
2001
|
-
},
|
|
2002
|
-
location: payload.location,
|
|
2003
|
-
basename: payload.basename,
|
|
2004
|
-
isSpaMode: false
|
|
2005
|
-
}),
|
|
2006
|
-
async patchRoutesOnNavigation({ path, signal }) {
|
|
2007
|
-
if (discoveredPaths.has(path)) {
|
|
2008
|
-
return;
|
|
2009
|
-
}
|
|
2010
|
-
await fetchAndApplyManifestPatches(
|
|
2011
|
-
[path],
|
|
2012
|
-
createFromReadableStream,
|
|
2013
|
-
fetchImplementation,
|
|
2014
|
-
signal
|
|
2015
|
-
);
|
|
2016
|
-
},
|
|
2017
|
-
// FIXME: Pass `build.ssr` into this function
|
|
2018
|
-
dataStrategy: getRSCSingleFetchDataStrategy(
|
|
2019
|
-
() => globalVar.__reactRouterDataRouter,
|
|
2020
|
-
true,
|
|
2021
|
-
payload.basename,
|
|
2022
|
-
createFromReadableStream,
|
|
2023
|
-
fetchImplementation
|
|
2024
|
-
)
|
|
2025
|
-
});
|
|
2026
|
-
if (globalVar.__reactRouterDataRouter.state.initialized) {
|
|
2027
|
-
globalVar.__routerInitialized = true;
|
|
2028
|
-
globalVar.__reactRouterDataRouter.initialize();
|
|
2029
|
-
} else {
|
|
2030
|
-
globalVar.__routerInitialized = false;
|
|
2031
|
-
}
|
|
2032
|
-
let lastLoaderData = void 0;
|
|
2033
|
-
globalVar.__reactRouterDataRouter.subscribe(({ loaderData, actionData }) => {
|
|
2034
|
-
if (lastLoaderData !== loaderData) {
|
|
2035
|
-
globalVar.__routerActionID = (globalVar.__routerActionID ?? (globalVar.__routerActionID = 0)) + 1;
|
|
2036
|
-
}
|
|
2037
|
-
});
|
|
2038
|
-
globalVar.__reactRouterDataRouter._updateRoutesForHMR = (routeUpdateByRouteId) => {
|
|
2039
|
-
const oldRoutes = window.__reactRouterDataRouter.routes;
|
|
2040
|
-
const newRoutes = [];
|
|
2041
|
-
function walkRoutes(routes2, parentId) {
|
|
2042
|
-
return routes2.map((route) => {
|
|
2043
|
-
const routeUpdate = routeUpdateByRouteId.get(route.id);
|
|
2044
|
-
if (routeUpdate) {
|
|
2045
|
-
const {
|
|
2046
|
-
routeModule,
|
|
2047
|
-
hasAction,
|
|
2048
|
-
hasComponent,
|
|
2049
|
-
hasErrorBoundary,
|
|
2050
|
-
hasLoader
|
|
2051
|
-
} = routeUpdate;
|
|
2052
|
-
const newRoute = createRouteFromServerManifest({
|
|
2053
|
-
clientAction: routeModule.clientAction,
|
|
2054
|
-
clientLoader: routeModule.clientLoader,
|
|
2055
|
-
element: route.element,
|
|
2056
|
-
errorElement: route.errorElement,
|
|
2057
|
-
handle: route.handle,
|
|
2058
|
-
hasAction,
|
|
2059
|
-
hasComponent,
|
|
2060
|
-
hasErrorBoundary,
|
|
2061
|
-
hasLoader,
|
|
2062
|
-
hydrateFallbackElement: route.hydrateFallbackElement,
|
|
2063
|
-
id: route.id,
|
|
2064
|
-
index: route.index,
|
|
2065
|
-
links: routeModule.links,
|
|
2066
|
-
meta: routeModule.meta,
|
|
2067
|
-
parentId,
|
|
2068
|
-
path: route.path,
|
|
2069
|
-
shouldRevalidate: routeModule.shouldRevalidate
|
|
2070
|
-
});
|
|
2071
|
-
if (route.children) {
|
|
2072
|
-
newRoute.children = walkRoutes(route.children, route.id);
|
|
2073
|
-
}
|
|
2074
|
-
return newRoute;
|
|
2075
|
-
}
|
|
2076
|
-
const updatedRoute = { ...route };
|
|
2077
|
-
if (route.children) {
|
|
2078
|
-
updatedRoute.children = walkRoutes(route.children, route.id);
|
|
2079
|
-
}
|
|
2080
|
-
return updatedRoute;
|
|
2081
|
-
});
|
|
2082
|
-
}
|
|
2083
|
-
newRoutes.push(
|
|
2084
|
-
...walkRoutes(oldRoutes, void 0)
|
|
2085
|
-
);
|
|
2086
|
-
window.__reactRouterDataRouter._internalSetRoutes(newRoutes);
|
|
2087
|
-
};
|
|
2088
|
-
return {
|
|
2089
|
-
router: globalVar.__reactRouterDataRouter,
|
|
2090
|
-
routeModules: globalVar.__reactRouterRouteModules
|
|
2091
|
-
};
|
|
2092
|
-
}
|
|
2093
|
-
var renderedRoutesContext = createContext();
|
|
2094
|
-
function getRSCSingleFetchDataStrategy(getRouter, ssr, basename, createFromReadableStream, fetchImplementation) {
|
|
2095
|
-
let dataStrategy = getSingleFetchDataStrategyImpl(
|
|
2096
|
-
getRouter,
|
|
2097
|
-
(match) => {
|
|
2098
|
-
let M = match;
|
|
2099
|
-
return {
|
|
2100
|
-
hasLoader: M.route.hasLoader,
|
|
2101
|
-
hasClientLoader: M.route.hasClientLoader,
|
|
2102
|
-
hasComponent: M.route.hasComponent,
|
|
2103
|
-
hasAction: M.route.hasAction,
|
|
2104
|
-
hasClientAction: M.route.hasClientAction,
|
|
2105
|
-
hasShouldRevalidate: M.route.hasShouldRevalidate
|
|
2106
|
-
};
|
|
2107
|
-
},
|
|
2108
|
-
// pass map into fetchAndDecode so it can add payloads
|
|
2109
|
-
getFetchAndDecodeViaRSC(createFromReadableStream, fetchImplementation),
|
|
2110
|
-
ssr,
|
|
2111
|
-
basename,
|
|
2112
|
-
// If the route has a component but we don't have an element, we need to hit
|
|
2113
|
-
// the server loader flow regardless of whether the client loader calls
|
|
2114
|
-
// `serverLoader` or not, otherwise we'll have nothing to render.
|
|
2115
|
-
(match) => {
|
|
2116
|
-
let M = match;
|
|
2117
|
-
return M.route.hasComponent && !M.route.element;
|
|
2118
|
-
}
|
|
2119
|
-
);
|
|
2120
|
-
return async (args) => args.runClientMiddleware(async () => {
|
|
2121
|
-
let context = args.context;
|
|
2122
|
-
context.set(renderedRoutesContext, []);
|
|
2123
|
-
let results = await dataStrategy(args);
|
|
2124
|
-
const renderedRoutesById = /* @__PURE__ */ new Map();
|
|
2125
|
-
for (const route of context.get(renderedRoutesContext)) {
|
|
2126
|
-
if (!renderedRoutesById.has(route.id)) {
|
|
2127
|
-
renderedRoutesById.set(route.id, []);
|
|
2128
|
-
}
|
|
2129
|
-
renderedRoutesById.get(route.id).push(route);
|
|
2130
|
-
}
|
|
2131
|
-
for (const match of args.matches) {
|
|
2132
|
-
const renderedRoutes = renderedRoutesById.get(match.route.id);
|
|
2133
|
-
if (renderedRoutes) {
|
|
2134
|
-
for (const rendered of renderedRoutes) {
|
|
2135
|
-
window.__reactRouterDataRouter.patchRoutes(
|
|
2136
|
-
rendered.parentId ?? null,
|
|
2137
|
-
[createRouteFromServerManifest(rendered)],
|
|
2138
|
-
true
|
|
2139
|
-
);
|
|
2140
|
-
}
|
|
2141
|
-
}
|
|
2142
|
-
}
|
|
2143
|
-
return results;
|
|
2144
|
-
});
|
|
2145
|
-
}
|
|
2146
|
-
function getFetchAndDecodeViaRSC(createFromReadableStream, fetchImplementation) {
|
|
2147
|
-
return async (args, basename, targetRoutes) => {
|
|
2148
|
-
let { request, context } = args;
|
|
2149
|
-
let url = singleFetchUrl(request.url, basename, "rsc");
|
|
2150
|
-
if (request.method === "GET") {
|
|
2151
|
-
url = stripIndexParam(url);
|
|
2152
|
-
if (targetRoutes) {
|
|
2153
|
-
url.searchParams.set("_routes", targetRoutes.join(","));
|
|
2154
|
-
}
|
|
2155
|
-
}
|
|
2156
|
-
let res = await fetchImplementation(
|
|
2157
|
-
new Request(url, await createRequestInit(request))
|
|
2158
|
-
);
|
|
2159
|
-
if (res.status >= 400 && !res.headers.has("X-Remix-Response")) {
|
|
2160
|
-
throw new ErrorResponseImpl(res.status, res.statusText, await res.text());
|
|
2161
|
-
}
|
|
2162
|
-
invariant(res.body, "No response body to decode");
|
|
2163
|
-
try {
|
|
2164
|
-
const payload = await createFromReadableStream(res.body, {
|
|
2165
|
-
temporaryReferences: void 0
|
|
2166
|
-
});
|
|
2167
|
-
if (payload.type === "redirect") {
|
|
2168
|
-
return {
|
|
2169
|
-
status: res.status,
|
|
2170
|
-
data: {
|
|
2171
|
-
redirect: {
|
|
2172
|
-
redirect: payload.location,
|
|
2173
|
-
reload: payload.reload,
|
|
2174
|
-
replace: payload.replace,
|
|
2175
|
-
revalidate: false,
|
|
2176
|
-
status: payload.status
|
|
2177
|
-
}
|
|
2178
|
-
}
|
|
2179
|
-
};
|
|
2180
|
-
}
|
|
2181
|
-
if (payload.type !== "render") {
|
|
2182
|
-
throw new Error("Unexpected payload type");
|
|
2183
|
-
}
|
|
2184
|
-
context.get(renderedRoutesContext).push(...payload.matches);
|
|
2185
|
-
let results = { routes: {} };
|
|
2186
|
-
const dataKey = isMutationMethod(request.method) ? "actionData" : "loaderData";
|
|
2187
|
-
for (let [routeId, data2] of Object.entries(payload[dataKey] || {})) {
|
|
2188
|
-
results.routes[routeId] = { data: data2 };
|
|
2189
|
-
}
|
|
2190
|
-
if (payload.errors) {
|
|
2191
|
-
for (let [routeId, error] of Object.entries(payload.errors)) {
|
|
2192
|
-
results.routes[routeId] = { error };
|
|
2193
|
-
}
|
|
2194
|
-
}
|
|
2195
|
-
return { status: res.status, data: results };
|
|
2196
|
-
} catch (e) {
|
|
2197
|
-
throw new Error("Unable to decode RSC response");
|
|
2198
|
-
}
|
|
2199
|
-
};
|
|
2200
|
-
}
|
|
2201
|
-
function RSCHydratedRouter({
|
|
2202
|
-
createFromReadableStream,
|
|
2203
|
-
fetch: fetchImplementation = fetch,
|
|
2204
|
-
payload,
|
|
2205
|
-
routeDiscovery = "eager",
|
|
2206
|
-
getContext
|
|
2207
|
-
}) {
|
|
2208
|
-
if (payload.type !== "render") throw new Error("Invalid payload type");
|
|
2209
|
-
let { router, routeModules } = React4.useMemo(
|
|
2210
|
-
() => createRouterFromPayload({
|
|
2211
|
-
payload,
|
|
2212
|
-
fetchImplementation,
|
|
2213
|
-
getContext,
|
|
2214
|
-
createFromReadableStream
|
|
2215
|
-
}),
|
|
2216
|
-
[createFromReadableStream, payload, fetchImplementation, getContext]
|
|
2217
|
-
);
|
|
2218
|
-
React4.useEffect(() => {
|
|
2219
|
-
setIsHydrated();
|
|
2220
|
-
}, []);
|
|
2221
|
-
React4.useLayoutEffect(() => {
|
|
2222
|
-
const globalVar = window;
|
|
2223
|
-
if (!globalVar.__routerInitialized) {
|
|
2224
|
-
globalVar.__routerInitialized = true;
|
|
2225
|
-
globalVar.__reactRouterDataRouter.initialize();
|
|
2226
|
-
}
|
|
2227
|
-
}, []);
|
|
2228
|
-
let [location2, setLocation] = React4.useState(router.state.location);
|
|
2229
|
-
React4.useLayoutEffect(
|
|
2230
|
-
() => router.subscribe((newState) => {
|
|
2231
|
-
if (newState.location !== location2) {
|
|
2232
|
-
setLocation(newState.location);
|
|
2233
|
-
}
|
|
2234
|
-
}),
|
|
2235
|
-
[router, location2]
|
|
2236
|
-
);
|
|
2237
|
-
React4.useEffect(() => {
|
|
2238
|
-
if (routeDiscovery === "lazy" || // @ts-expect-error - TS doesn't know about this yet
|
|
2239
|
-
window.navigator?.connection?.saveData === true) {
|
|
2240
|
-
return;
|
|
2241
|
-
}
|
|
2242
|
-
function registerElement(el) {
|
|
2243
|
-
let path = el.tagName === "FORM" ? el.getAttribute("action") : el.getAttribute("href");
|
|
2244
|
-
if (!path) {
|
|
2245
|
-
return;
|
|
2246
|
-
}
|
|
2247
|
-
let pathname = el.tagName === "A" ? el.pathname : new URL(path, window.location.origin).pathname;
|
|
2248
|
-
if (!discoveredPaths.has(pathname)) {
|
|
2249
|
-
nextPaths.add(pathname);
|
|
2250
|
-
}
|
|
2251
|
-
}
|
|
2252
|
-
async function fetchPatches() {
|
|
2253
|
-
document.querySelectorAll("a[data-discover], form[data-discover]").forEach(registerElement);
|
|
2254
|
-
let paths = Array.from(nextPaths.keys()).filter((path) => {
|
|
2255
|
-
if (discoveredPaths.has(path)) {
|
|
2256
|
-
nextPaths.delete(path);
|
|
2257
|
-
return false;
|
|
2258
|
-
}
|
|
2259
|
-
return true;
|
|
2260
|
-
});
|
|
2261
|
-
if (paths.length === 0) {
|
|
2262
|
-
return;
|
|
2263
|
-
}
|
|
2264
|
-
try {
|
|
2265
|
-
await fetchAndApplyManifestPatches(
|
|
2266
|
-
paths,
|
|
2267
|
-
createFromReadableStream,
|
|
2268
|
-
fetchImplementation
|
|
2269
|
-
);
|
|
2270
|
-
} catch (e) {
|
|
2271
|
-
console.error("Failed to fetch manifest patches", e);
|
|
2272
|
-
}
|
|
2273
|
-
}
|
|
2274
|
-
let debouncedFetchPatches = debounce(fetchPatches, 100);
|
|
2275
|
-
fetchPatches();
|
|
2276
|
-
let observer = new MutationObserver(() => debouncedFetchPatches());
|
|
2277
|
-
observer.observe(document.documentElement, {
|
|
2278
|
-
subtree: true,
|
|
2279
|
-
childList: true,
|
|
2280
|
-
attributes: true,
|
|
2281
|
-
attributeFilter: ["data-discover", "href", "action"]
|
|
2282
|
-
});
|
|
2283
|
-
}, [routeDiscovery, createFromReadableStream, fetchImplementation]);
|
|
2284
|
-
const frameworkContext = {
|
|
2285
|
-
future: {
|
|
2286
|
-
// These flags have no runtime impact so can always be false. If we add
|
|
2287
|
-
// flags that drive runtime behavior they'll need to be proxied through.
|
|
2288
|
-
v8_middleware: false,
|
|
2289
|
-
unstable_subResourceIntegrity: false
|
|
2290
|
-
},
|
|
2291
|
-
isSpaMode: false,
|
|
2292
|
-
ssr: true,
|
|
2293
|
-
criticalCss: "",
|
|
2294
|
-
manifest: {
|
|
2295
|
-
routes: {},
|
|
2296
|
-
version: "1",
|
|
2297
|
-
url: "",
|
|
2298
|
-
entry: {
|
|
2299
|
-
module: "",
|
|
2300
|
-
imports: []
|
|
2301
|
-
}
|
|
2302
|
-
},
|
|
2303
|
-
routeDiscovery: { mode: "lazy", manifestPath: "/__manifest" },
|
|
2304
|
-
routeModules
|
|
2305
|
-
};
|
|
2306
|
-
return /* @__PURE__ */ React4.createElement(RSCRouterContext.Provider, { value: true }, /* @__PURE__ */ React4.createElement(RSCRouterGlobalErrorBoundary, { location: location2 }, /* @__PURE__ */ React4.createElement(FrameworkContext.Provider, { value: frameworkContext }, /* @__PURE__ */ React4.createElement(UNSTABLE_TransitionEnabledRouterProvider, { router, flushSync: ReactDOM.flushSync }))));
|
|
2307
|
-
}
|
|
2308
|
-
function createRouteFromServerManifest(match, payload) {
|
|
2309
|
-
let hasInitialData = payload && match.id in payload.loaderData;
|
|
2310
|
-
let initialData = payload?.loaderData[match.id];
|
|
2311
|
-
let hasInitialError = payload?.errors && match.id in payload.errors;
|
|
2312
|
-
let initialError = payload?.errors?.[match.id];
|
|
2313
|
-
let isHydrationRequest = match.clientLoader?.hydrate === true || !match.hasLoader || // If the route has a component but we don't have an element, we need to hit
|
|
2314
|
-
// the server loader flow regardless of whether the client loader calls
|
|
2315
|
-
// `serverLoader` or not, otherwise we'll have nothing to render.
|
|
2316
|
-
match.hasComponent && !match.element;
|
|
2317
|
-
invariant(window.__reactRouterRouteModules);
|
|
2318
|
-
populateRSCRouteModules(window.__reactRouterRouteModules, match);
|
|
2319
|
-
let dataRoute = {
|
|
2320
|
-
id: match.id,
|
|
2321
|
-
element: match.element,
|
|
2322
|
-
errorElement: match.errorElement,
|
|
2323
|
-
handle: match.handle,
|
|
2324
|
-
hasErrorBoundary: match.hasErrorBoundary,
|
|
2325
|
-
hydrateFallbackElement: match.hydrateFallbackElement,
|
|
2326
|
-
index: match.index,
|
|
2327
|
-
loader: match.clientLoader ? async (args, singleFetch) => {
|
|
2328
|
-
try {
|
|
2329
|
-
let result = await match.clientLoader({
|
|
2330
|
-
...args,
|
|
2331
|
-
serverLoader: () => {
|
|
2332
|
-
preventInvalidServerHandlerCall(
|
|
2333
|
-
"loader",
|
|
2334
|
-
match.id,
|
|
2335
|
-
match.hasLoader
|
|
2336
|
-
);
|
|
2337
|
-
if (isHydrationRequest) {
|
|
2338
|
-
if (hasInitialData) {
|
|
2339
|
-
return initialData;
|
|
2340
|
-
}
|
|
2341
|
-
if (hasInitialError) {
|
|
2342
|
-
throw initialError;
|
|
2343
|
-
}
|
|
2344
|
-
}
|
|
2345
|
-
return callSingleFetch(singleFetch);
|
|
2346
|
-
}
|
|
2347
|
-
});
|
|
2348
|
-
return result;
|
|
2349
|
-
} finally {
|
|
2350
|
-
isHydrationRequest = false;
|
|
2351
|
-
}
|
|
2352
|
-
} : (
|
|
2353
|
-
// We always make the call in this RSC world since even if we don't
|
|
2354
|
-
// have a `loader` we may need to get the `element` implementation
|
|
2355
|
-
(_, singleFetch) => callSingleFetch(singleFetch)
|
|
2356
|
-
),
|
|
2357
|
-
action: match.clientAction ? (args, singleFetch) => match.clientAction({
|
|
2358
|
-
...args,
|
|
2359
|
-
serverAction: async () => {
|
|
2360
|
-
preventInvalidServerHandlerCall(
|
|
2361
|
-
"action",
|
|
2362
|
-
match.id,
|
|
2363
|
-
match.hasLoader
|
|
2364
|
-
);
|
|
2365
|
-
return await callSingleFetch(singleFetch);
|
|
2366
|
-
}
|
|
2367
|
-
}) : match.hasAction ? (_, singleFetch) => callSingleFetch(singleFetch) : () => {
|
|
2368
|
-
throw noActionDefinedError("action", match.id);
|
|
2369
|
-
},
|
|
2370
|
-
path: match.path,
|
|
2371
|
-
shouldRevalidate: match.shouldRevalidate,
|
|
2372
|
-
// We always have a "loader" in this RSC world since even if we don't
|
|
2373
|
-
// have a `loader` we may need to get the `element` implementation
|
|
2374
|
-
hasLoader: true,
|
|
2375
|
-
hasClientLoader: match.clientLoader != null,
|
|
2376
|
-
hasAction: match.hasAction,
|
|
2377
|
-
hasClientAction: match.clientAction != null,
|
|
2378
|
-
hasShouldRevalidate: match.shouldRevalidate != null
|
|
2379
|
-
};
|
|
2380
|
-
if (typeof dataRoute.loader === "function") {
|
|
2381
|
-
dataRoute.loader.hydrate = shouldHydrateRouteLoader(
|
|
2382
|
-
match.id,
|
|
2383
|
-
match.clientLoader,
|
|
2384
|
-
match.hasLoader,
|
|
2385
|
-
false
|
|
2386
|
-
);
|
|
2387
|
-
}
|
|
2388
|
-
return dataRoute;
|
|
2389
|
-
}
|
|
2390
|
-
function callSingleFetch(singleFetch) {
|
|
2391
|
-
invariant(typeof singleFetch === "function", "Invalid singleFetch parameter");
|
|
2392
|
-
return singleFetch();
|
|
2393
|
-
}
|
|
2394
|
-
function preventInvalidServerHandlerCall(type, routeId, hasHandler) {
|
|
2395
|
-
if (!hasHandler) {
|
|
2396
|
-
let fn = type === "action" ? "serverAction()" : "serverLoader()";
|
|
2397
|
-
let msg = `You are trying to call ${fn} on a route that does not have a server ${type} (routeId: "${routeId}")`;
|
|
2398
|
-
console.error(msg);
|
|
2399
|
-
throw new ErrorResponseImpl(400, "Bad Request", new Error(msg), true);
|
|
2400
|
-
}
|
|
2401
|
-
}
|
|
2402
|
-
var nextPaths = /* @__PURE__ */ new Set();
|
|
2403
|
-
var discoveredPathsMaxSize = 1e3;
|
|
2404
|
-
var discoveredPaths = /* @__PURE__ */ new Set();
|
|
2405
|
-
var URL_LIMIT = 7680;
|
|
2406
|
-
function getManifestUrl(paths) {
|
|
2407
|
-
if (paths.length === 0) {
|
|
2408
|
-
return null;
|
|
2409
|
-
}
|
|
2410
|
-
if (paths.length === 1) {
|
|
2411
|
-
return new URL(`${paths[0]}.manifest`, window.location.origin);
|
|
2412
|
-
}
|
|
2413
|
-
const globalVar = window;
|
|
2414
|
-
let basename = (globalVar.__reactRouterDataRouter.basename ?? "").replace(
|
|
2415
|
-
/^\/|\/$/g,
|
|
2416
|
-
""
|
|
2417
|
-
);
|
|
2418
|
-
let url = new URL(`${basename}/.manifest`, window.location.origin);
|
|
2419
|
-
url.searchParams.set("paths", paths.sort().join(","));
|
|
2420
|
-
return url;
|
|
2421
|
-
}
|
|
2422
|
-
async function fetchAndApplyManifestPatches(paths, createFromReadableStream, fetchImplementation, signal) {
|
|
2423
|
-
let url = getManifestUrl(paths);
|
|
2424
|
-
if (url == null) {
|
|
2425
|
-
return;
|
|
2426
|
-
}
|
|
2427
|
-
if (url.toString().length > URL_LIMIT) {
|
|
2428
|
-
nextPaths.clear();
|
|
2429
|
-
return;
|
|
2430
|
-
}
|
|
2431
|
-
let response = await fetchImplementation(new Request(url, { signal }));
|
|
2432
|
-
if (!response.body || response.status < 200 || response.status >= 300) {
|
|
2433
|
-
throw new Error("Unable to fetch new route matches from the server");
|
|
2434
|
-
}
|
|
2435
|
-
let payload = await createFromReadableStream(response.body, {
|
|
2436
|
-
temporaryReferences: void 0
|
|
2437
|
-
});
|
|
2438
|
-
if (payload.type !== "manifest") {
|
|
2439
|
-
throw new Error("Failed to patch routes");
|
|
2440
|
-
}
|
|
2441
|
-
paths.forEach((p) => addToFifoQueue(p, discoveredPaths));
|
|
2442
|
-
payload.patches.forEach((p) => {
|
|
2443
|
-
window.__reactRouterDataRouter.patchRoutes(
|
|
2444
|
-
p.parentId ?? null,
|
|
2445
|
-
[createRouteFromServerManifest(p)]
|
|
2446
|
-
);
|
|
2447
|
-
});
|
|
2448
|
-
}
|
|
2449
|
-
function addToFifoQueue(path, queue) {
|
|
2450
|
-
if (queue.size >= discoveredPathsMaxSize) {
|
|
2451
|
-
let first = queue.values().next().value;
|
|
2452
|
-
queue.delete(first);
|
|
2453
|
-
}
|
|
2454
|
-
queue.add(path);
|
|
2455
|
-
}
|
|
2456
|
-
function debounce(callback, wait) {
|
|
2457
|
-
let timeoutId;
|
|
2458
|
-
return (...args) => {
|
|
2459
|
-
window.clearTimeout(timeoutId);
|
|
2460
|
-
timeoutId = window.setTimeout(() => callback(...args), wait);
|
|
2461
|
-
};
|
|
2462
|
-
}
|
|
2463
|
-
function isExternalLocation(location2) {
|
|
2464
|
-
const newLocation = new URL(location2, window.location.href);
|
|
2465
|
-
return newLocation.origin !== window.location.origin;
|
|
2466
|
-
}
|
|
2467
|
-
|
|
2468
|
-
// lib/rsc/server.ssr.tsx
|
|
2469
|
-
import * as React5 from "react";
|
|
2470
|
-
|
|
2471
|
-
// lib/rsc/html-stream/server.ts
|
|
2472
|
-
var encoder2 = new TextEncoder();
|
|
2473
|
-
var trailer = "</body></html>";
|
|
2474
|
-
function injectRSCPayload(rscStream) {
|
|
2475
|
-
let decoder = new TextDecoder();
|
|
2476
|
-
let resolveFlightDataPromise;
|
|
2477
|
-
let flightDataPromise = new Promise(
|
|
2478
|
-
(resolve) => resolveFlightDataPromise = resolve
|
|
2479
|
-
);
|
|
2480
|
-
let startedRSC = false;
|
|
2481
|
-
let buffered = [];
|
|
2482
|
-
let timeout = null;
|
|
2483
|
-
function flushBufferedChunks(controller) {
|
|
2484
|
-
for (let chunk of buffered) {
|
|
2485
|
-
let buf = decoder.decode(chunk, { stream: true });
|
|
2486
|
-
if (buf.endsWith(trailer)) {
|
|
2487
|
-
buf = buf.slice(0, -trailer.length);
|
|
2488
|
-
}
|
|
2489
|
-
controller.enqueue(encoder2.encode(buf));
|
|
2490
|
-
}
|
|
2491
|
-
buffered.length = 0;
|
|
2492
|
-
timeout = null;
|
|
2493
|
-
}
|
|
2494
|
-
return new TransformStream({
|
|
2495
|
-
transform(chunk, controller) {
|
|
2496
|
-
buffered.push(chunk);
|
|
2497
|
-
if (timeout) {
|
|
2498
|
-
return;
|
|
2499
|
-
}
|
|
2500
|
-
timeout = setTimeout(async () => {
|
|
2501
|
-
flushBufferedChunks(controller);
|
|
2502
|
-
if (!startedRSC) {
|
|
2503
|
-
startedRSC = true;
|
|
2504
|
-
writeRSCStream(rscStream, controller).catch((err) => controller.error(err)).then(resolveFlightDataPromise);
|
|
2505
|
-
}
|
|
2506
|
-
}, 0);
|
|
2507
|
-
},
|
|
2508
|
-
async flush(controller) {
|
|
2509
|
-
await flightDataPromise;
|
|
2510
|
-
if (timeout) {
|
|
2511
|
-
clearTimeout(timeout);
|
|
2512
|
-
flushBufferedChunks(controller);
|
|
2513
|
-
}
|
|
2514
|
-
controller.enqueue(encoder2.encode("</body></html>"));
|
|
2515
|
-
}
|
|
2516
|
-
});
|
|
2517
|
-
}
|
|
2518
|
-
async function writeRSCStream(rscStream, controller) {
|
|
2519
|
-
let decoder = new TextDecoder("utf-8", { fatal: true });
|
|
2520
|
-
const reader = rscStream.getReader();
|
|
2521
|
-
try {
|
|
2522
|
-
let read;
|
|
2523
|
-
while ((read = await reader.read()) && !read.done) {
|
|
2524
|
-
const chunk = read.value;
|
|
2525
|
-
try {
|
|
2526
|
-
writeChunk(
|
|
2527
|
-
JSON.stringify(decoder.decode(chunk, { stream: true })),
|
|
2528
|
-
controller
|
|
2529
|
-
);
|
|
2530
|
-
} catch (err) {
|
|
2531
|
-
let base64 = JSON.stringify(btoa(String.fromCodePoint(...chunk)));
|
|
2532
|
-
writeChunk(
|
|
2533
|
-
`Uint8Array.from(atob(${base64}), m => m.codePointAt(0))`,
|
|
2534
|
-
controller
|
|
2535
|
-
);
|
|
2536
|
-
}
|
|
2537
|
-
}
|
|
2538
|
-
} finally {
|
|
2539
|
-
reader.releaseLock();
|
|
2540
|
-
}
|
|
2541
|
-
let remaining = decoder.decode();
|
|
2542
|
-
if (remaining.length) {
|
|
2543
|
-
writeChunk(JSON.stringify(remaining), controller);
|
|
2544
|
-
}
|
|
2545
|
-
}
|
|
2546
|
-
function writeChunk(chunk, controller) {
|
|
2547
|
-
controller.enqueue(
|
|
2548
|
-
encoder2.encode(
|
|
2549
|
-
`<script>${escapeScript(
|
|
2550
|
-
`(self.__FLIGHT_DATA||=[]).push(${chunk})`
|
|
2551
|
-
)}</script>`
|
|
2552
|
-
)
|
|
2553
|
-
);
|
|
2554
|
-
}
|
|
2555
|
-
function escapeScript(script) {
|
|
2556
|
-
return script.replace(/<!--/g, "<\\!--").replace(/<\/(script)/gi, "</\\$1");
|
|
2557
|
-
}
|
|
2558
|
-
|
|
2559
1902
|
// lib/rsc/server.ssr.tsx
|
|
2560
1903
|
var REACT_USE = "use";
|
|
2561
|
-
var useImpl =
|
|
1904
|
+
var useImpl = React4[REACT_USE];
|
|
2562
1905
|
function useSafe(promise) {
|
|
2563
1906
|
if (useImpl) {
|
|
2564
1907
|
return useImpl(promise);
|
|
@@ -2829,7 +2172,7 @@ function RSCStaticRouter({ getPayload }) {
|
|
|
2829
2172
|
routeDiscovery: { mode: "lazy", manifestPath: "/__manifest" },
|
|
2830
2173
|
routeModules: createRSCRouteModules(payload)
|
|
2831
2174
|
};
|
|
2832
|
-
return /* @__PURE__ */
|
|
2175
|
+
return /* @__PURE__ */ React4.createElement(RSCRouterContext.Provider, { value: true }, /* @__PURE__ */ React4.createElement(RSCRouterGlobalErrorBoundary, { location: payload.location }, /* @__PURE__ */ React4.createElement(FrameworkContext.Provider, { value: frameworkContext }, /* @__PURE__ */ React4.createElement(
|
|
2833
2176
|
StaticRouterProvider,
|
|
2834
2177
|
{
|
|
2835
2178
|
context,
|
|
@@ -2846,41 +2189,6 @@ function isManifestRequest(url) {
|
|
|
2846
2189
|
return url.pathname.endsWith(".manifest");
|
|
2847
2190
|
}
|
|
2848
2191
|
|
|
2849
|
-
// lib/rsc/html-stream/browser.ts
|
|
2850
|
-
function getRSCStream() {
|
|
2851
|
-
let encoder3 = new TextEncoder();
|
|
2852
|
-
let streamController = null;
|
|
2853
|
-
let rscStream = new ReadableStream({
|
|
2854
|
-
start(controller) {
|
|
2855
|
-
if (typeof window === "undefined") {
|
|
2856
|
-
return;
|
|
2857
|
-
}
|
|
2858
|
-
let handleChunk = (chunk) => {
|
|
2859
|
-
if (typeof chunk === "string") {
|
|
2860
|
-
controller.enqueue(encoder3.encode(chunk));
|
|
2861
|
-
} else {
|
|
2862
|
-
controller.enqueue(chunk);
|
|
2863
|
-
}
|
|
2864
|
-
};
|
|
2865
|
-
window.__FLIGHT_DATA || (window.__FLIGHT_DATA = []);
|
|
2866
|
-
window.__FLIGHT_DATA.forEach(handleChunk);
|
|
2867
|
-
window.__FLIGHT_DATA.push = (chunk) => {
|
|
2868
|
-
handleChunk(chunk);
|
|
2869
|
-
return 0;
|
|
2870
|
-
};
|
|
2871
|
-
streamController = controller;
|
|
2872
|
-
}
|
|
2873
|
-
});
|
|
2874
|
-
if (typeof document !== "undefined" && document.readyState === "loading") {
|
|
2875
|
-
document.addEventListener("DOMContentLoaded", () => {
|
|
2876
|
-
streamController?.close();
|
|
2877
|
-
});
|
|
2878
|
-
} else {
|
|
2879
|
-
streamController?.close();
|
|
2880
|
-
}
|
|
2881
|
-
return rscStream;
|
|
2882
|
-
}
|
|
2883
|
-
|
|
2884
2192
|
// lib/dom/ssr/errors.ts
|
|
2885
2193
|
function deserializeErrors(errors) {
|
|
2886
2194
|
if (!errors) return null;
|
|
@@ -2918,6 +2226,39 @@ function deserializeErrors(errors) {
|
|
|
2918
2226
|
return serialized;
|
|
2919
2227
|
}
|
|
2920
2228
|
|
|
2229
|
+
// lib/dom/ssr/hydration.tsx
|
|
2230
|
+
function getHydrationData({
|
|
2231
|
+
state,
|
|
2232
|
+
routes,
|
|
2233
|
+
getRouteInfo,
|
|
2234
|
+
location,
|
|
2235
|
+
basename,
|
|
2236
|
+
isSpaMode
|
|
2237
|
+
}) {
|
|
2238
|
+
let hydrationData = {
|
|
2239
|
+
...state,
|
|
2240
|
+
loaderData: { ...state.loaderData }
|
|
2241
|
+
};
|
|
2242
|
+
let initialMatches = matchRoutes(routes, location, basename);
|
|
2243
|
+
if (initialMatches) {
|
|
2244
|
+
for (let match of initialMatches) {
|
|
2245
|
+
let routeId = match.route.id;
|
|
2246
|
+
let routeInfo = getRouteInfo(routeId);
|
|
2247
|
+
if (shouldHydrateRouteLoader(
|
|
2248
|
+
routeId,
|
|
2249
|
+
routeInfo.clientLoader,
|
|
2250
|
+
routeInfo.hasLoader,
|
|
2251
|
+
isSpaMode
|
|
2252
|
+
) && (routeInfo.hasHydrateFallback || !routeInfo.hasLoader)) {
|
|
2253
|
+
delete hydrationData.loaderData[routeId];
|
|
2254
|
+
} else if (!routeInfo.hasLoader) {
|
|
2255
|
+
hydrationData.loaderData[routeId] = null;
|
|
2256
|
+
}
|
|
2257
|
+
}
|
|
2258
|
+
}
|
|
2259
|
+
return hydrationData;
|
|
2260
|
+
}
|
|
2261
|
+
|
|
2921
2262
|
export {
|
|
2922
2263
|
ServerRouter,
|
|
2923
2264
|
createRoutesStub,
|
|
@@ -2932,12 +2273,11 @@ export {
|
|
|
2932
2273
|
createCookieSessionStorage,
|
|
2933
2274
|
createMemorySessionStorage,
|
|
2934
2275
|
href,
|
|
2935
|
-
|
|
2276
|
+
RSCRouterGlobalErrorBoundary,
|
|
2936
2277
|
RSCDefaultRootErrorBoundary,
|
|
2937
|
-
|
|
2938
|
-
RSCHydratedRouter,
|
|
2278
|
+
populateRSCRouteModules,
|
|
2939
2279
|
routeRSCServerRequest,
|
|
2940
2280
|
RSCStaticRouter,
|
|
2941
|
-
|
|
2942
|
-
|
|
2281
|
+
deserializeErrors,
|
|
2282
|
+
getHydrationData
|
|
2943
2283
|
};
|