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