react-router 7.14.2 → 7.15.1
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 +99 -0
- package/dist/development/{browser-I6n6wVSO.d.mts → browser-3AnU12UI.d.mts} +2 -2
- package/dist/{production/browser-I6n6wVSO.d.mts → development/browser-BOdXz9dK.d.ts} +2 -2
- package/dist/development/{chunk-EVOBXE3Y.mjs → chunk-4N6VE7H7.mjs} +567 -317
- package/dist/{production/chunk-PQL4HLVQ.js → development/chunk-4YRVXM2U.js} +7 -7
- package/dist/{production/chunk-UJQ4OJF4.js → development/chunk-66UKHEGQ.js} +153 -143
- package/dist/development/{chunk-ZZNWZ5Q3.js → chunk-D6LUOGOQ.js} +550 -310
- package/dist/development/{chunk-YQSHRJWW.mjs → chunk-RJYABSBD.mjs} +100 -80
- package/dist/{production/context-DGGUoDIu.d.mts → development/context-ByvtofY2.d.mts} +100 -42
- package/dist/development/{routeModules-7rtk67cd.d.ts → data-BVUf681J.d.mts} +64 -46
- package/dist/development/{routeModules-BW4a8k3I.d.mts → data-BqZ2x964.d.ts} +64 -46
- package/dist/development/dom-export.d.mts +8 -8
- package/dist/development/dom-export.d.ts +8 -8
- package/dist/development/dom-export.js +57 -62
- package/dist/development/dom-export.mjs +32 -37
- package/dist/{production/index-react-server-client-BBd0A0TL.d.ts → development/index-react-server-client-BS5F89FR.d.ts} +132 -122
- package/dist/{production/index-react-server-client-BjhKIe3u.d.mts → development/index-react-server-client-DY04-103.d.mts} +111 -101
- package/dist/development/index-react-server-client.d.mts +3 -3
- package/dist/development/index-react-server-client.d.ts +3 -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 +113 -36
- package/dist/development/index-react-server.d.ts +113 -36
- package/dist/development/index-react-server.js +63 -36
- package/dist/development/index-react-server.mjs +63 -36
- package/dist/development/index.d.mts +94 -12
- package/dist/development/index.d.ts +94 -12
- package/dist/development/index.js +193 -171
- package/dist/development/index.mjs +5 -3
- package/dist/{production/instrumentation-g0dG8UL0.d.ts → development/instrumentation-cRWWLfsU.d.ts} +79 -21
- package/dist/development/lib/types/internal.d.mts +2 -2
- 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/development/{register-DcBltf5q.d.ts → register-Bsscfj79.d.ts} +1 -1
- package/dist/{production/register-DcBltf5q.d.ts → development/register-Df8okEea.d.mts} +1 -1
- package/dist/production/{browser-C-UvoYvi.d.ts → browser-3AnU12UI.d.mts} +2 -2
- package/dist/{development/browser-C-UvoYvi.d.ts → production/browser-BOdXz9dK.d.ts} +2 -2
- package/dist/production/{chunk-2WLZNCK5.mjs → chunk-6S4627ZB.mjs} +100 -80
- package/dist/production/{chunk-X5SKXJ4A.js → chunk-HUBUW7R3.js} +550 -310
- package/dist/production/{chunk-LK6U7ULH.mjs → chunk-JAKZPQZC.mjs} +567 -317
- package/dist/{development/chunk-YZKCRDTN.js → production/chunk-PNZCCTKT.js} +153 -143
- package/dist/{development/chunk-PZFPF4X7.js → production/chunk-Y6IFXO7V.js} +7 -7
- package/dist/{development/context-DGGUoDIu.d.mts → production/context-ByvtofY2.d.mts} +100 -42
- package/dist/production/{routeModules-7rtk67cd.d.ts → data-BVUf681J.d.mts} +64 -46
- package/dist/production/{routeModules-BW4a8k3I.d.mts → data-BqZ2x964.d.ts} +64 -46
- package/dist/production/dom-export.d.mts +8 -8
- package/dist/production/dom-export.d.ts +8 -8
- package/dist/production/dom-export.js +57 -62
- package/dist/production/dom-export.mjs +32 -37
- package/dist/{development/index-react-server-client-BBd0A0TL.d.ts → production/index-react-server-client-BS5F89FR.d.ts} +132 -122
- package/dist/{development/index-react-server-client-BjhKIe3u.d.mts → production/index-react-server-client-DY04-103.d.mts} +111 -101
- package/dist/production/index-react-server-client.d.mts +3 -3
- package/dist/production/index-react-server-client.d.ts +3 -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 +113 -36
- package/dist/production/index-react-server.d.ts +113 -36
- package/dist/production/index-react-server.js +63 -36
- package/dist/production/index-react-server.mjs +63 -36
- package/dist/production/index.d.mts +94 -12
- package/dist/production/index.d.ts +94 -12
- package/dist/production/index.js +193 -171
- package/dist/production/index.mjs +5 -3
- package/dist/{development/instrumentation-g0dG8UL0.d.ts → production/instrumentation-cRWWLfsU.d.ts} +79 -21
- package/dist/production/lib/types/internal.d.mts +2 -2
- 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-D9d2sMQ7.d.mts → production/register-Bsscfj79.d.ts} +1 -1
- package/dist/production/{register-D9d2sMQ7.d.mts → register-Df8okEea.d.mts} +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v7.
|
|
2
|
+
* react-router v7.15.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
SingleFetchRedirectSymbol,
|
|
23
23
|
StaticRouterProvider,
|
|
24
24
|
StreamTransfer,
|
|
25
|
+
URL_LIMIT,
|
|
25
26
|
convertRoutesToDataRoutes,
|
|
26
27
|
createMemoryRouter,
|
|
27
28
|
createServerRoutes,
|
|
@@ -36,11 +37,13 @@ import {
|
|
|
36
37
|
getStaticContextFromError,
|
|
37
38
|
instrumentHandler,
|
|
38
39
|
isDataWithResponseInit,
|
|
40
|
+
isMutationMethod,
|
|
39
41
|
isRedirectResponse,
|
|
40
42
|
isRedirectStatusCode,
|
|
41
43
|
isResponse,
|
|
42
44
|
isRouteErrorResponse,
|
|
43
45
|
matchRoutes,
|
|
46
|
+
matchRoutesImpl,
|
|
44
47
|
redirect,
|
|
45
48
|
redirectDocument,
|
|
46
49
|
replace,
|
|
@@ -51,7 +54,7 @@ import {
|
|
|
51
54
|
withComponentProps,
|
|
52
55
|
withErrorBoundaryProps,
|
|
53
56
|
withHydrateFallbackProps
|
|
54
|
-
} from "./chunk-
|
|
57
|
+
} from "./chunk-4N6VE7H7.mjs";
|
|
55
58
|
|
|
56
59
|
// lib/dom/ssr/server.tsx
|
|
57
60
|
import * as React from "react";
|
|
@@ -86,7 +89,9 @@ function ServerRouter({
|
|
|
86
89
|
delete context.staticHandlerContext.loaderData[routeId];
|
|
87
90
|
}
|
|
88
91
|
}
|
|
89
|
-
let router = createStaticRouter(routes, context.staticHandlerContext
|
|
92
|
+
let router = createStaticRouter(routes, context.staticHandlerContext, {
|
|
93
|
+
branches: context.branches
|
|
94
|
+
});
|
|
90
95
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
|
|
91
96
|
FrameworkContext.Provider,
|
|
92
97
|
{
|
|
@@ -137,8 +142,7 @@ function createRoutesStub(routes, _context) {
|
|
|
137
142
|
if (routerRef.current == null) {
|
|
138
143
|
frameworkContextRef.current = {
|
|
139
144
|
future: {
|
|
140
|
-
|
|
141
|
-
unstable_subResourceIntegrity: future?.unstable_subResourceIntegrity === true,
|
|
145
|
+
v8_passThroughRequests: future?.v8_passThroughRequests === true,
|
|
142
146
|
v8_middleware: future?.v8_middleware === true,
|
|
143
147
|
unstable_trailingSlashAwareDataRequests: future?.unstable_trailingSlashAwareDataRequests === true
|
|
144
148
|
},
|
|
@@ -263,7 +267,7 @@ var unsign = async (cookie, secret) => {
|
|
|
263
267
|
let signature = byteStringToUint8Array(atob(hash));
|
|
264
268
|
let valid = await crypto.subtle.verify("HMAC", key, signature, data2);
|
|
265
269
|
return valid ? value : false;
|
|
266
|
-
} catch (
|
|
270
|
+
} catch (e) {
|
|
267
271
|
return false;
|
|
268
272
|
}
|
|
269
273
|
};
|
|
@@ -355,7 +359,7 @@ function encodeData(value) {
|
|
|
355
359
|
function decodeData(value) {
|
|
356
360
|
try {
|
|
357
361
|
return JSON.parse(decodeURIComponent(myEscape(atob(value))));
|
|
358
|
-
} catch (
|
|
362
|
+
} catch (e) {
|
|
359
363
|
return {};
|
|
360
364
|
}
|
|
361
365
|
}
|
|
@@ -490,29 +494,48 @@ function serializeErrors(errors, serverMode) {
|
|
|
490
494
|
return serialized;
|
|
491
495
|
}
|
|
492
496
|
|
|
497
|
+
// lib/server-runtime/invariant.ts
|
|
498
|
+
function invariant(value, message) {
|
|
499
|
+
if (value === false || value === null || typeof value === "undefined") {
|
|
500
|
+
console.error(
|
|
501
|
+
"The following error is a bug in React Router; please open an issue! https://github.com/remix-run/react-router/issues/new/choose"
|
|
502
|
+
);
|
|
503
|
+
throw new Error(message);
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
|
|
493
507
|
// lib/server-runtime/routeMatching.ts
|
|
494
|
-
function matchServerRoutes(
|
|
495
|
-
let matches =
|
|
496
|
-
|
|
508
|
+
function matchServerRoutes(manifest, dataRoutes, branches, pathname, basename) {
|
|
509
|
+
let matches = matchRoutesImpl(
|
|
510
|
+
dataRoutes,
|
|
497
511
|
pathname,
|
|
498
|
-
basename
|
|
512
|
+
basename ?? "/",
|
|
513
|
+
false,
|
|
514
|
+
branches
|
|
499
515
|
);
|
|
500
516
|
if (!matches) return null;
|
|
501
|
-
return matches.map((match) =>
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
517
|
+
return matches.map((match) => {
|
|
518
|
+
let route = manifest[match.route.id];
|
|
519
|
+
invariant(
|
|
520
|
+
route,
|
|
521
|
+
`Route with id "${match.route.id}" not found in manifest.`
|
|
522
|
+
);
|
|
523
|
+
return {
|
|
524
|
+
params: match.params,
|
|
525
|
+
pathname: match.pathname,
|
|
526
|
+
route
|
|
527
|
+
};
|
|
528
|
+
});
|
|
506
529
|
}
|
|
507
530
|
|
|
508
531
|
// lib/server-runtime/data.ts
|
|
509
532
|
async function callRouteHandler(handler, args, future) {
|
|
510
533
|
let result = await handler({
|
|
511
|
-
request: future.
|
|
512
|
-
|
|
534
|
+
request: future.v8_passThroughRequests ? args.request : stripRoutesParam(stripIndexParam(args.request)),
|
|
535
|
+
url: args.url,
|
|
513
536
|
params: args.params,
|
|
514
537
|
context: args.context,
|
|
515
|
-
|
|
538
|
+
pattern: args.pattern
|
|
516
539
|
});
|
|
517
540
|
if (isDataWithResponseInit(result) && result.init && result.init.status && isRedirectStatusCode(result.init.status)) {
|
|
518
541
|
throw new Response(null, result.init);
|
|
@@ -558,16 +581,6 @@ function stripRoutesParam(request) {
|
|
|
558
581
|
return new Request(url.href, init);
|
|
559
582
|
}
|
|
560
583
|
|
|
561
|
-
// lib/server-runtime/invariant.ts
|
|
562
|
-
function invariant(value, message) {
|
|
563
|
-
if (value === false || value === null || typeof value === "undefined") {
|
|
564
|
-
console.error(
|
|
565
|
-
"The following error is a bug in React Router; please open an issue! https://github.com/remix-run/react-router/issues/new/choose"
|
|
566
|
-
);
|
|
567
|
-
throw new Error(message);
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
|
|
571
584
|
// lib/server-runtime/dev.ts
|
|
572
585
|
var globalDevServerHooksKey = "__reactRouterDevServerHooks";
|
|
573
586
|
function setDevServerHooks(devServerHooks) {
|
|
@@ -602,12 +615,6 @@ function groupRoutesByParentId(manifest) {
|
|
|
602
615
|
});
|
|
603
616
|
return routes;
|
|
604
617
|
}
|
|
605
|
-
function createRoutes(manifest, parentId = "", routesByParentId = groupRoutesByParentId(manifest)) {
|
|
606
|
-
return (routesByParentId[parentId] || []).map((route) => ({
|
|
607
|
-
...route,
|
|
608
|
-
children: createRoutes(manifest, route.id, routesByParentId)
|
|
609
|
-
}));
|
|
610
|
-
}
|
|
611
618
|
function createStaticHandlerDataRoutes(manifest, future, parentId = "", routesByParentId = groupRoutesByParentId(manifest)) {
|
|
612
619
|
return (routesByParentId[parentId] || []).map((route) => {
|
|
613
620
|
let commonRoute = {
|
|
@@ -894,7 +901,7 @@ async function singleFetchAction(build, serverMode, staticHandler, request, hand
|
|
|
894
901
|
} catch (e) {
|
|
895
902
|
return handleQueryError(new Error("Bad Request"), 400);
|
|
896
903
|
}
|
|
897
|
-
let handlerRequest = build.future.
|
|
904
|
+
let handlerRequest = build.future.v8_passThroughRequests ? request : new Request(handlerUrl, {
|
|
898
905
|
method: request.method,
|
|
899
906
|
body: request.body,
|
|
900
907
|
headers: request.headers,
|
|
@@ -913,7 +920,7 @@ async function singleFetchAction(build, serverMode, staticHandler, request, hand
|
|
|
913
920
|
return handleQueryError(error);
|
|
914
921
|
}
|
|
915
922
|
} : void 0,
|
|
916
|
-
|
|
923
|
+
normalizePath: (r) => getNormalizedPath(r, build.basename, build.future)
|
|
917
924
|
});
|
|
918
925
|
return handleQueryResult(result);
|
|
919
926
|
} catch (error) {
|
|
@@ -962,7 +969,7 @@ async function singleFetchLoaders(build, serverMode, staticHandler, request, han
|
|
|
962
969
|
let routesParam = new URL(request.url).searchParams.get("_routes");
|
|
963
970
|
let loadRouteIds = routesParam ? new Set(routesParam.split(",")) : null;
|
|
964
971
|
try {
|
|
965
|
-
let handlerRequest = build.future.
|
|
972
|
+
let handlerRequest = build.future.v8_passThroughRequests ? request : new Request(handlerUrl, {
|
|
966
973
|
headers: request.headers,
|
|
967
974
|
signal: request.signal
|
|
968
975
|
});
|
|
@@ -978,7 +985,7 @@ async function singleFetchLoaders(build, serverMode, staticHandler, request, han
|
|
|
978
985
|
return handleQueryError(error);
|
|
979
986
|
}
|
|
980
987
|
} : void 0,
|
|
981
|
-
|
|
988
|
+
normalizePath: (r) => getNormalizedPath(r, build.basename, build.future)
|
|
982
989
|
});
|
|
983
990
|
return handleQueryResult(result);
|
|
984
991
|
} catch (error) {
|
|
@@ -1145,12 +1152,12 @@ function encodeViaTurboStream(data2, requestSignal, streamTimeout, serverMode) {
|
|
|
1145
1152
|
|
|
1146
1153
|
// lib/server-runtime/server.ts
|
|
1147
1154
|
function derive(build, mode) {
|
|
1148
|
-
let routes = createRoutes(build.routes);
|
|
1149
1155
|
let dataRoutes = createStaticHandlerDataRoutes(build.routes, build.future);
|
|
1150
1156
|
let serverMode = isServerMode(mode) ? mode : "production" /* Production */;
|
|
1151
1157
|
let staticHandler = createStaticHandler(dataRoutes, {
|
|
1152
1158
|
basename: build.basename,
|
|
1153
|
-
|
|
1159
|
+
instrumentations: build.entry.module.instrumentations,
|
|
1160
|
+
future: build.future
|
|
1154
1161
|
});
|
|
1155
1162
|
let errorHandler = build.entry.module.handleError || ((error, { request }) => {
|
|
1156
1163
|
if (serverMode !== "test" /* Test */ && !request.signal.aborted) {
|
|
@@ -1247,24 +1254,30 @@ function derive(build, mode) {
|
|
|
1247
1254
|
);
|
|
1248
1255
|
if (requestUrl.pathname === manifestUrl) {
|
|
1249
1256
|
try {
|
|
1250
|
-
let res = await handleManifestRequest(
|
|
1257
|
+
let res = await handleManifestRequest(
|
|
1258
|
+
build,
|
|
1259
|
+
staticHandler.dataRoutes,
|
|
1260
|
+
staticHandler._internalRouteBranches,
|
|
1261
|
+
requestUrl
|
|
1262
|
+
);
|
|
1251
1263
|
return res;
|
|
1252
1264
|
} catch (e) {
|
|
1253
1265
|
handleError(e);
|
|
1254
1266
|
return new Response("Unknown Server Error", { status: 500 });
|
|
1255
1267
|
}
|
|
1256
1268
|
}
|
|
1257
|
-
let matches = matchServerRoutes(
|
|
1269
|
+
let matches = matchServerRoutes(
|
|
1270
|
+
build.routes,
|
|
1271
|
+
staticHandler.dataRoutes,
|
|
1272
|
+
staticHandler._internalRouteBranches,
|
|
1273
|
+
normalizedPathname,
|
|
1274
|
+
build.basename
|
|
1275
|
+
);
|
|
1258
1276
|
if (matches && matches.length > 0) {
|
|
1259
1277
|
Object.assign(params, matches[0].params);
|
|
1260
1278
|
}
|
|
1261
1279
|
let response;
|
|
1262
1280
|
if (requestUrl.pathname.endsWith(".data")) {
|
|
1263
|
-
let singleFetchMatches = matchServerRoutes(
|
|
1264
|
-
routes,
|
|
1265
|
-
normalizedPathname,
|
|
1266
|
-
build.basename
|
|
1267
|
-
);
|
|
1268
1281
|
response = await handleSingleFetchRequest(
|
|
1269
1282
|
serverMode,
|
|
1270
1283
|
build,
|
|
@@ -1285,7 +1298,7 @@ function derive(build, mode) {
|
|
|
1285
1298
|
if (build.entry.module.handleDataRequest) {
|
|
1286
1299
|
response = await build.entry.module.handleDataRequest(response, {
|
|
1287
1300
|
context: loadContext,
|
|
1288
|
-
params:
|
|
1301
|
+
params: matches ? matches[0].params : {},
|
|
1289
1302
|
request
|
|
1290
1303
|
});
|
|
1291
1304
|
if (isRedirectResponse(response)) {
|
|
@@ -1335,15 +1348,13 @@ function derive(build, mode) {
|
|
|
1335
1348
|
}
|
|
1336
1349
|
return response;
|
|
1337
1350
|
};
|
|
1338
|
-
if (build.entry.module.
|
|
1351
|
+
if (build.entry.module.instrumentations) {
|
|
1339
1352
|
requestHandler = instrumentHandler(
|
|
1340
1353
|
requestHandler,
|
|
1341
|
-
build.entry.module.
|
|
1354
|
+
build.entry.module.instrumentations.map((i) => i.handler).filter(Boolean)
|
|
1342
1355
|
);
|
|
1343
1356
|
}
|
|
1344
1357
|
return {
|
|
1345
|
-
routes,
|
|
1346
|
-
dataRoutes,
|
|
1347
1358
|
serverMode,
|
|
1348
1359
|
staticHandler,
|
|
1349
1360
|
errorHandler,
|
|
@@ -1352,7 +1363,6 @@ function derive(build, mode) {
|
|
|
1352
1363
|
}
|
|
1353
1364
|
var createRequestHandler = (build, mode) => {
|
|
1354
1365
|
let _build;
|
|
1355
|
-
let routes;
|
|
1356
1366
|
let serverMode;
|
|
1357
1367
|
let staticHandler;
|
|
1358
1368
|
let errorHandler;
|
|
@@ -1361,14 +1371,12 @@ var createRequestHandler = (build, mode) => {
|
|
|
1361
1371
|
_build = typeof build === "function" ? await build() : build;
|
|
1362
1372
|
if (typeof build === "function") {
|
|
1363
1373
|
let derived = derive(_build, mode);
|
|
1364
|
-
routes = derived.routes;
|
|
1365
1374
|
serverMode = derived.serverMode;
|
|
1366
1375
|
staticHandler = derived.staticHandler;
|
|
1367
1376
|
errorHandler = derived.errorHandler;
|
|
1368
1377
|
_requestHandler = derived.requestHandler;
|
|
1369
|
-
} else if (!
|
|
1378
|
+
} else if (!serverMode || !staticHandler || !errorHandler || !_requestHandler) {
|
|
1370
1379
|
let derived = derive(_build, mode);
|
|
1371
|
-
routes = derived.routes;
|
|
1372
1380
|
serverMode = derived.serverMode;
|
|
1373
1381
|
staticHandler = derived.staticHandler;
|
|
1374
1382
|
errorHandler = derived.errorHandler;
|
|
@@ -1377,7 +1385,7 @@ var createRequestHandler = (build, mode) => {
|
|
|
1377
1385
|
return _requestHandler(request, initialContext);
|
|
1378
1386
|
};
|
|
1379
1387
|
};
|
|
1380
|
-
async function handleManifestRequest(build,
|
|
1388
|
+
async function handleManifestRequest(build, dataRoutes, branches, url) {
|
|
1381
1389
|
if (build.assets.version !== url.searchParams.get("version")) {
|
|
1382
1390
|
return new Response(null, {
|
|
1383
1391
|
status: 204,
|
|
@@ -1386,6 +1394,12 @@ async function handleManifestRequest(build, routes, url) {
|
|
|
1386
1394
|
}
|
|
1387
1395
|
});
|
|
1388
1396
|
}
|
|
1397
|
+
if (url.toString().length > URL_LIMIT) {
|
|
1398
|
+
return new Response(null, {
|
|
1399
|
+
statusText: "Bad Request",
|
|
1400
|
+
status: 400
|
|
1401
|
+
});
|
|
1402
|
+
}
|
|
1389
1403
|
let patches = {};
|
|
1390
1404
|
if (url.searchParams.has("paths")) {
|
|
1391
1405
|
let paths = /* @__PURE__ */ new Set();
|
|
@@ -1402,7 +1416,13 @@ async function handleManifestRequest(build, routes, url) {
|
|
|
1402
1416
|
});
|
|
1403
1417
|
});
|
|
1404
1418
|
for (let path of paths) {
|
|
1405
|
-
let matches = matchServerRoutes(
|
|
1419
|
+
let matches = matchServerRoutes(
|
|
1420
|
+
build.routes,
|
|
1421
|
+
dataRoutes,
|
|
1422
|
+
branches,
|
|
1423
|
+
path,
|
|
1424
|
+
build.basename
|
|
1425
|
+
);
|
|
1406
1426
|
if (matches) {
|
|
1407
1427
|
for (let match of matches) {
|
|
1408
1428
|
let routeId = match.route.id;
|
|
@@ -1424,7 +1444,7 @@ async function handleManifestRequest(build, routes, url) {
|
|
|
1424
1444
|
async function handleSingleFetchRequest(serverMode, build, staticHandler, request, normalizedPath, loadContext, handleError) {
|
|
1425
1445
|
let handlerUrl = new URL(request.url);
|
|
1426
1446
|
handlerUrl.pathname = normalizedPath;
|
|
1427
|
-
let response = request.method
|
|
1447
|
+
let response = isMutationMethod(request.method) ? await singleFetchAction(
|
|
1428
1448
|
build,
|
|
1429
1449
|
serverMode,
|
|
1430
1450
|
staticHandler,
|
|
@@ -1445,7 +1465,7 @@ async function handleSingleFetchRequest(serverMode, build, staticHandler, reques
|
|
|
1445
1465
|
}
|
|
1446
1466
|
async function handleDocumentRequest(serverMode, build, staticHandler, request, loadContext, handleError, isSpaMode, criticalCss) {
|
|
1447
1467
|
try {
|
|
1448
|
-
if (request.method
|
|
1468
|
+
if (isMutationMethod(request.method)) {
|
|
1449
1469
|
try {
|
|
1450
1470
|
throwIfPotentialCSRFAttack(
|
|
1451
1471
|
request.headers,
|
|
@@ -1470,7 +1490,7 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
|
|
|
1470
1490
|
return new Response(null, { status: 500 });
|
|
1471
1491
|
}
|
|
1472
1492
|
} : void 0,
|
|
1473
|
-
|
|
1493
|
+
normalizePath: (r) => getNormalizedPath(r, build.basename, build.future)
|
|
1474
1494
|
});
|
|
1475
1495
|
if (!isResponse(result)) {
|
|
1476
1496
|
result = await renderHtml(result, isSpaMode);
|
|
@@ -1507,6 +1527,7 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
|
|
|
1507
1527
|
};
|
|
1508
1528
|
let entryContext = {
|
|
1509
1529
|
manifest: build.assets,
|
|
1530
|
+
branches: staticHandler._internalRouteBranches,
|
|
1510
1531
|
routeModules: createEntryRouteModules(build.routes),
|
|
1511
1532
|
staticHandlerContext: context,
|
|
1512
1533
|
criticalCss,
|
|
@@ -1603,7 +1624,7 @@ async function handleResourceRequest(serverMode, build, staticHandler, routeId,
|
|
|
1603
1624
|
return handleQueryRouteError(error);
|
|
1604
1625
|
}
|
|
1605
1626
|
} : void 0,
|
|
1606
|
-
|
|
1627
|
+
normalizePath: (r) => getNormalizedPath(r, build.basename, build.future)
|
|
1607
1628
|
});
|
|
1608
1629
|
return handleQueryRouteResult(result);
|
|
1609
1630
|
} catch (error) {
|
|
@@ -1907,7 +1928,7 @@ async function writeRSCStream(rscStream, controller) {
|
|
|
1907
1928
|
JSON.stringify(decoder.decode(chunk, { stream: true })),
|
|
1908
1929
|
controller
|
|
1909
1930
|
);
|
|
1910
|
-
} catch (
|
|
1931
|
+
} catch (e) {
|
|
1911
1932
|
let base64 = JSON.stringify(btoa(String.fromCodePoint(...chunk)));
|
|
1912
1933
|
writeChunk(
|
|
1913
1934
|
`Uint8Array.from(atob(${base64}), m => m.codePointAt(0))`,
|
|
@@ -2233,9 +2254,9 @@ async function routeRSCServerRequest({
|
|
|
2233
2254
|
statusText,
|
|
2234
2255
|
headers
|
|
2235
2256
|
});
|
|
2236
|
-
} catch (
|
|
2237
|
-
if (
|
|
2238
|
-
return
|
|
2257
|
+
} catch (error) {
|
|
2258
|
+
if (error instanceof Response) {
|
|
2259
|
+
return error;
|
|
2239
2260
|
}
|
|
2240
2261
|
if (renderRedirect) {
|
|
2241
2262
|
return new Response(`Redirect: ${renderRedirect.location}`, {
|
|
@@ -2246,8 +2267,8 @@ async function routeRSCServerRequest({
|
|
|
2246
2267
|
});
|
|
2247
2268
|
}
|
|
2248
2269
|
try {
|
|
2249
|
-
|
|
2250
|
-
let [status, statusText] = isRouteErrorResponse(
|
|
2270
|
+
let normalizedError = renderError ?? error;
|
|
2271
|
+
let [status, statusText] = isRouteErrorResponse(normalizedError) ? [normalizedError.status, normalizedError.statusText] : [500, ""];
|
|
2251
2272
|
let retryRedirect;
|
|
2252
2273
|
let reactHeaders = new Headers();
|
|
2253
2274
|
const html = await renderHTML(
|
|
@@ -2259,7 +2280,7 @@ async function routeRSCServerRequest({
|
|
|
2259
2280
|
(payload) => Object.assign(payload, {
|
|
2260
2281
|
status,
|
|
2261
2282
|
errors: deepestRenderedBoundaryId ? {
|
|
2262
|
-
[deepestRenderedBoundaryId]:
|
|
2283
|
+
[deepestRenderedBoundaryId]: normalizedError
|
|
2263
2284
|
} : {}
|
|
2264
2285
|
})
|
|
2265
2286
|
);
|
|
@@ -2282,19 +2303,19 @@ async function routeRSCServerRequest({
|
|
|
2282
2303
|
});
|
|
2283
2304
|
},
|
|
2284
2305
|
{
|
|
2285
|
-
onError(
|
|
2286
|
-
if (typeof
|
|
2287
|
-
retryRedirect = decodeRedirectErrorDigest(
|
|
2306
|
+
onError(error2) {
|
|
2307
|
+
if (typeof error2 === "object" && error2 && "digest" in error2 && typeof error2.digest === "string") {
|
|
2308
|
+
retryRedirect = decodeRedirectErrorDigest(error2.digest);
|
|
2288
2309
|
if (retryRedirect) {
|
|
2289
|
-
return
|
|
2310
|
+
return error2.digest;
|
|
2290
2311
|
}
|
|
2291
2312
|
let routeErrorResponse = decodeRouteErrorResponseDigest(
|
|
2292
|
-
|
|
2313
|
+
error2.digest
|
|
2293
2314
|
);
|
|
2294
2315
|
if (routeErrorResponse) {
|
|
2295
2316
|
status = routeErrorResponse.status;
|
|
2296
2317
|
statusText = routeErrorResponse.statusText;
|
|
2297
|
-
return
|
|
2318
|
+
return error2.digest;
|
|
2298
2319
|
}
|
|
2299
2320
|
}
|
|
2300
2321
|
},
|
|
@@ -2344,9 +2365,9 @@ async function routeRSCServerRequest({
|
|
|
2344
2365
|
statusText,
|
|
2345
2366
|
headers
|
|
2346
2367
|
});
|
|
2347
|
-
} catch {
|
|
2368
|
+
} catch (error2) {
|
|
2348
2369
|
}
|
|
2349
|
-
throw
|
|
2370
|
+
throw error;
|
|
2350
2371
|
}
|
|
2351
2372
|
}
|
|
2352
2373
|
function RSCStaticRouter({ getPayload }) {
|
|
@@ -2430,10 +2451,9 @@ function RSCStaticRouter({ getPayload }) {
|
|
|
2430
2451
|
// These flags have no runtime impact so can always be false. If we add
|
|
2431
2452
|
// flags that drive runtime behavior they'll need to be proxied through.
|
|
2432
2453
|
v8_middleware: false,
|
|
2433
|
-
unstable_subResourceIntegrity: false,
|
|
2434
2454
|
unstable_trailingSlashAwareDataRequests: true,
|
|
2435
2455
|
// always on for RSC
|
|
2436
|
-
|
|
2456
|
+
v8_passThroughRequests: true
|
|
2437
2457
|
// always on for RSC
|
|
2438
2458
|
},
|
|
2439
2459
|
isSpaMode: false,
|