react-router 7.15.1 → 7.18.5
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 +73 -2
- package/dist/development/{browser-BOdXz9dK.d.ts → browser-7x6a6gQP.d.ts} +2 -2
- package/dist/development/{browser-3AnU12UI.d.mts → browser-CiGxXXOl.d.mts} +2 -2
- package/dist/development/{chunk-D6LUOGOQ.js → chunk-2ZBLYC7V.js} +265 -57
- package/dist/development/{chunk-4N6VE7H7.mjs → chunk-6KYCQHYJ.mjs} +268 -60
- package/dist/{production/chunk-Y6IFXO7V.js → development/chunk-IFHLIXZW.js} +7 -7
- package/dist/development/{chunk-RJYABSBD.mjs → chunk-JAHXRPFV.mjs} +71 -122
- package/dist/development/{chunk-66UKHEGQ.js → chunk-NDF5KBLP.js} +112 -108
- package/dist/{production/context-ByvtofY2.d.mts → development/context-BlYKn1tE.d.mts} +24 -5
- package/dist/development/{data-BqZ2x964.d.ts → data-CjO11-hU.d.ts} +10 -2
- package/dist/{production/data-BVUf681J.d.mts → development/data-DEjBmEfD.d.mts} +10 -2
- package/dist/development/dom-export.d.mts +4 -4
- package/dist/development/dom-export.d.ts +4 -4
- package/dist/development/dom-export.js +61 -46
- package/dist/development/dom-export.mjs +39 -24
- package/dist/{production/index-react-server-client-BS5F89FR.d.ts → development/index-react-server-client-BaaZU3sM.d.ts} +32 -9
- package/dist/{production/index-react-server-client-DY04-103.d.mts → development/index-react-server-client-KK-TR-t7.d.mts} +20 -6
- 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 +20 -2
- package/dist/development/index-react-server.d.ts +20 -2
- package/dist/development/index-react-server.js +212 -144
- package/dist/development/index-react-server.mjs +211 -143
- package/dist/development/index.d.mts +22 -15
- package/dist/development/index.d.ts +22 -15
- package/dist/development/index.js +160 -211
- package/dist/development/index.mjs +3 -5
- package/dist/{production/instrumentation-cRWWLfsU.d.ts → development/instrumentation-CPkMwccd.d.ts} +12 -2
- 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-Df8okEea.d.mts → register-CmkRspdl.d.mts} +1 -1
- package/dist/development/{register-Bsscfj79.d.ts → register-roq_0qYo.d.ts} +1 -1
- package/dist/production/{browser-BOdXz9dK.d.ts → browser-7x6a6gQP.d.ts} +2 -2
- package/dist/production/{browser-3AnU12UI.d.mts → browser-CiGxXXOl.d.mts} +2 -2
- package/dist/production/{chunk-PNZCCTKT.js → chunk-75HN637G.js} +112 -108
- package/dist/production/{chunk-JAKZPQZC.mjs → chunk-7RTFRKQW.mjs} +268 -60
- package/dist/production/{chunk-HUBUW7R3.js → chunk-HNBICOIU.js} +265 -57
- package/dist/production/{chunk-6S4627ZB.mjs → chunk-IAM5GYT3.mjs} +71 -122
- package/dist/{development/chunk-4YRVXM2U.js → production/chunk-K3NA4NUH.js} +7 -7
- package/dist/{development/context-ByvtofY2.d.mts → production/context-BlYKn1tE.d.mts} +24 -5
- package/dist/production/{data-BqZ2x964.d.ts → data-CjO11-hU.d.ts} +10 -2
- package/dist/{development/data-BVUf681J.d.mts → production/data-DEjBmEfD.d.mts} +10 -2
- package/dist/production/dom-export.d.mts +4 -4
- package/dist/production/dom-export.d.ts +4 -4
- package/dist/production/dom-export.js +61 -46
- package/dist/production/dom-export.mjs +39 -24
- package/dist/{development/index-react-server-client-BS5F89FR.d.ts → production/index-react-server-client-BaaZU3sM.d.ts} +32 -9
- package/dist/{development/index-react-server-client-DY04-103.d.mts → production/index-react-server-client-KK-TR-t7.d.mts} +20 -6
- 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 +20 -2
- package/dist/production/index-react-server.d.ts +20 -2
- package/dist/production/index-react-server.js +212 -144
- package/dist/production/index-react-server.mjs +211 -143
- package/dist/production/index.d.mts +22 -15
- package/dist/production/index.d.ts +22 -15
- package/dist/production/index.js +160 -211
- package/dist/production/index.mjs +3 -5
- package/dist/{development/instrumentation-cRWWLfsU.d.ts → production/instrumentation-CPkMwccd.d.ts} +12 -2
- 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/production/{register-Df8okEea.d.mts → register-CmkRspdl.d.mts} +1 -1
- package/dist/production/{register-Bsscfj79.d.ts → register-roq_0qYo.d.ts} +1 -1
- package/docs/explanation/backend-for-frontend.md +50 -0
- package/docs/explanation/code-splitting.md +61 -0
- package/docs/explanation/concurrency.md +135 -0
- package/docs/explanation/form-vs-fetcher.md +292 -0
- package/docs/explanation/hot-module-replacement.md +137 -0
- package/docs/explanation/hydration.md +14 -0
- package/docs/explanation/index-query-param.md +86 -0
- package/docs/explanation/index.md +4 -0
- package/docs/explanation/lazy-route-discovery.md +78 -0
- package/docs/explanation/location.md +6 -0
- package/docs/explanation/progressive-enhancement.md +150 -0
- package/docs/explanation/race-conditions.md +88 -0
- package/docs/explanation/react-transitions.md +160 -0
- package/docs/explanation/route-matching.md +7 -0
- package/docs/explanation/server-client-execution.md +4 -0
- package/docs/explanation/sessions-and-cookies.md +465 -0
- package/docs/explanation/special-files.md +16 -0
- package/docs/explanation/state-management.md +524 -0
- package/docs/explanation/styling.md +87 -0
- package/docs/explanation/type-safety.md +82 -0
- package/docs/how-to/accessibility.md +44 -0
- package/docs/how-to/client-data.md +199 -0
- package/docs/how-to/data-strategy.md +317 -0
- package/docs/how-to/error-boundary.md +231 -0
- package/docs/how-to/error-reporting.md +142 -0
- package/docs/how-to/fetchers.md +307 -0
- package/docs/how-to/file-route-conventions.md +410 -0
- package/docs/how-to/file-uploads.md +217 -0
- package/docs/how-to/form-validation.md +120 -0
- package/docs/how-to/headers.md +165 -0
- package/docs/how-to/index.md +4 -0
- package/docs/how-to/instrumentation.md +556 -0
- package/docs/how-to/meta.md +40 -0
- package/docs/how-to/middleware.md +763 -0
- package/docs/how-to/navigation-blocking.md +233 -0
- package/docs/how-to/optimize-revalidation.md +12 -0
- package/docs/how-to/pre-rendering.md +225 -0
- package/docs/how-to/presets.md +103 -0
- package/docs/how-to/react-server-components.md +899 -0
- package/docs/how-to/resource-routes.md +126 -0
- package/docs/how-to/route-module-type-safety.md +100 -0
- package/docs/how-to/search-params.md +4 -0
- package/docs/how-to/security.md +32 -0
- package/docs/how-to/server-bundles.md +66 -0
- package/docs/how-to/spa.md +120 -0
- package/docs/how-to/status.md +63 -0
- package/docs/how-to/suspense.md +132 -0
- package/docs/how-to/using-handle.md +117 -0
- package/docs/how-to/view-transitions.md +237 -0
- package/docs/how-to/webhook.md +50 -0
- package/docs/index.md +39 -0
- package/docs/start/data/actions.md +138 -0
- package/docs/start/data/custom.md +198 -0
- package/docs/start/data/data-loading.md +44 -0
- package/docs/start/data/index.md +4 -0
- package/docs/start/data/installation.md +56 -0
- package/docs/start/data/navigating.md +12 -0
- package/docs/start/data/pending-ui.md +12 -0
- package/docs/start/data/route-object.md +268 -0
- package/docs/start/data/routing.md +281 -0
- package/docs/start/data/testing.md +8 -0
- package/docs/start/declarative/index.md +4 -0
- package/docs/start/declarative/installation.md +43 -0
- package/docs/start/declarative/navigating.md +133 -0
- package/docs/start/declarative/routing.md +237 -0
- package/docs/start/declarative/url-values.md +65 -0
- package/docs/start/framework/actions.md +174 -0
- package/docs/start/framework/data-loading.md +201 -0
- package/docs/start/framework/deploying.md +100 -0
- package/docs/start/framework/index.md +4 -0
- package/docs/start/framework/installation.md +41 -0
- package/docs/start/framework/navigating.md +182 -0
- package/docs/start/framework/pending-ui.md +142 -0
- package/docs/start/framework/rendering.md +59 -0
- package/docs/start/framework/route-module.md +527 -0
- package/docs/start/framework/routing.md +362 -0
- package/docs/start/framework/testing.md +133 -0
- package/docs/start/index.md +4 -0
- package/docs/start/modes.md +201 -0
- package/docs/upgrading/component-routes.md +363 -0
- package/docs/upgrading/future.md +490 -0
- package/docs/upgrading/index.md +4 -0
- package/docs/upgrading/remix.md +403 -0
- package/docs/upgrading/router-provider.md +442 -0
- package/docs/upgrading/v6.md +382 -0
- package/package.json +2 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var node_async_hooks = require('node:async_hooks');
|
|
4
|
-
var
|
|
4
|
+
var React3 = require('react');
|
|
5
5
|
var setCookieParser = require('set-cookie-parser');
|
|
6
6
|
var reactServerClient = require('react-router/internal/react-server-client');
|
|
7
7
|
var cookie = require('cookie');
|
|
@@ -24,10 +24,10 @@ function _interopNamespace(e) {
|
|
|
24
24
|
return Object.freeze(n);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
var
|
|
27
|
+
var React3__namespace = /*#__PURE__*/_interopNamespace(React3);
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
|
-
* react-router v7.
|
|
30
|
+
* react-router v7.18.5
|
|
31
31
|
*
|
|
32
32
|
* Copyright (c) Remix Software Inc.
|
|
33
33
|
*
|
|
@@ -43,6 +43,9 @@ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot
|
|
|
43
43
|
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
44
44
|
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
45
45
|
|
|
46
|
+
// lib/router/url.ts
|
|
47
|
+
var ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i;
|
|
48
|
+
|
|
46
49
|
// lib/router/history.ts
|
|
47
50
|
function invariant(value, message) {
|
|
48
51
|
if (value === false || value === null || typeof value === "undefined") {
|
|
@@ -502,7 +505,18 @@ function flattenRoutes(routes, branches = [], parentsMeta = [], parentPath = "",
|
|
|
502
505
|
branches.push({
|
|
503
506
|
path,
|
|
504
507
|
score: computeScore(path, route.index),
|
|
505
|
-
routesMeta
|
|
508
|
+
routesMeta: routesMeta.map((meta2, i) => {
|
|
509
|
+
let [matcher, params] = compilePath(
|
|
510
|
+
meta2.relativePath,
|
|
511
|
+
meta2.caseSensitive,
|
|
512
|
+
i === routesMeta.length - 1
|
|
513
|
+
);
|
|
514
|
+
return {
|
|
515
|
+
...meta2,
|
|
516
|
+
matcher,
|
|
517
|
+
compiledParams: params
|
|
518
|
+
};
|
|
519
|
+
})
|
|
506
520
|
});
|
|
507
521
|
};
|
|
508
522
|
routes.forEach((route, index) => {
|
|
@@ -591,9 +605,19 @@ function matchRouteBranch(branch, pathname, allowPartial = false) {
|
|
|
591
605
|
let meta = routesMeta[i];
|
|
592
606
|
let end = i === routesMeta.length - 1;
|
|
593
607
|
let remainingPathname = matchedPathname === "/" ? pathname : pathname.slice(matchedPathname.length) || "/";
|
|
594
|
-
let
|
|
595
|
-
|
|
596
|
-
|
|
608
|
+
let pattern = {
|
|
609
|
+
path: meta.relativePath,
|
|
610
|
+
caseSensitive: meta.caseSensitive,
|
|
611
|
+
end
|
|
612
|
+
};
|
|
613
|
+
let match = (
|
|
614
|
+
// Use precomputed matcher if it exists
|
|
615
|
+
meta.matcher && meta.compiledParams ? matchPathImpl(
|
|
616
|
+
pattern,
|
|
617
|
+
remainingPathname,
|
|
618
|
+
meta.matcher,
|
|
619
|
+
meta.compiledParams
|
|
620
|
+
) : matchPath(pattern, remainingPathname)
|
|
597
621
|
);
|
|
598
622
|
let route = meta.route;
|
|
599
623
|
if (!match && end && allowPartial && !routesMeta[routesMeta.length - 1].route.index) {
|
|
@@ -634,16 +658,22 @@ function matchPath(pattern, pathname) {
|
|
|
634
658
|
pattern.caseSensitive,
|
|
635
659
|
pattern.end
|
|
636
660
|
);
|
|
661
|
+
return matchPathImpl(pattern, pathname, matcher, compiledParams);
|
|
662
|
+
}
|
|
663
|
+
function matchPathImpl(pattern, pathname, matcher, compiledParams) {
|
|
637
664
|
let match = pathname.match(matcher);
|
|
638
665
|
if (!match) return null;
|
|
639
666
|
let matchedPathname = match[0];
|
|
640
|
-
let pathnameBase = matchedPathname
|
|
667
|
+
let pathnameBase = removeTrailingSlash(matchedPathname, 1);
|
|
641
668
|
let captureGroups = match.slice(1);
|
|
642
669
|
let params = compiledParams.reduce(
|
|
643
670
|
(memo, { paramName, isOptional }, index) => {
|
|
644
671
|
if (paramName === "*") {
|
|
645
672
|
let splatValue = captureGroups[index] || "";
|
|
646
|
-
pathnameBase =
|
|
673
|
+
pathnameBase = removeTrailingSlash(
|
|
674
|
+
matchedPathname.slice(0, matchedPathname.length - splatValue.length),
|
|
675
|
+
1
|
|
676
|
+
);
|
|
647
677
|
}
|
|
648
678
|
const value = captureGroups[index];
|
|
649
679
|
if (isOptional && !value) {
|
|
@@ -722,7 +752,6 @@ function prependBasename({
|
|
|
722
752
|
}) {
|
|
723
753
|
return pathname === "/" ? basename : joinPaths([basename, pathname]);
|
|
724
754
|
}
|
|
725
|
-
var ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
|
|
726
755
|
var isAbsoluteUrl = (url) => ABSOLUTE_URL_REGEX.test(url);
|
|
727
756
|
function resolvePath(to, fromPathname = "/") {
|
|
728
757
|
let {
|
|
@@ -733,7 +762,7 @@ function resolvePath(to, fromPathname = "/") {
|
|
|
733
762
|
let pathname;
|
|
734
763
|
if (toPathname) {
|
|
735
764
|
toPathname = removeDoubleSlashes(toPathname);
|
|
736
|
-
if (toPathname.startsWith("/")) {
|
|
765
|
+
if (toPathname.startsWith("/") || toPathname.startsWith("\\")) {
|
|
737
766
|
pathname = resolvePathname(toPathname.substring(1), "/");
|
|
738
767
|
} else {
|
|
739
768
|
pathname = resolvePathname(toPathname, fromPathname);
|
|
@@ -819,9 +848,15 @@ function resolveTo(toArg, routePathnames, locationPathname, isPathRelative = fal
|
|
|
819
848
|
}
|
|
820
849
|
return path;
|
|
821
850
|
}
|
|
822
|
-
var removeDoubleSlashes = (path) => path.replace(
|
|
851
|
+
var removeDoubleSlashes = (path) => path.replace(/[\\/]{2,}/g, "/");
|
|
823
852
|
var joinPaths = (paths) => removeDoubleSlashes(paths.join("/"));
|
|
824
|
-
|
|
853
|
+
function removeTrailingSlash(path, minLength = 0) {
|
|
854
|
+
let end = path.length;
|
|
855
|
+
while (end > minLength && path.charCodeAt(end - 1) === 47) {
|
|
856
|
+
end--;
|
|
857
|
+
}
|
|
858
|
+
return end === path.length ? path : path.slice(0, end);
|
|
859
|
+
}
|
|
825
860
|
var normalizePathname = (pathname) => removeTrailingSlash(pathname).replace(/^\/*/, "/");
|
|
826
861
|
var normalizeSearch = (search) => !search || search === "?" ? "" : search.startsWith("?") ? search : "?" + search;
|
|
827
862
|
var normalizeHash = (hash) => !hash || hash === "#" ? "" : hash.startsWith("#") ? hash : "#" + hash;
|
|
@@ -931,6 +966,10 @@ function createStaticHandler(routes, opts) {
|
|
|
931
966
|
manifest
|
|
932
967
|
);
|
|
933
968
|
let routeBranches = flattenAndRankRoutes(dataRoutes);
|
|
969
|
+
let matchCost = routeBranches.reduce(
|
|
970
|
+
(total, branch) => total + branch.routesMeta.length,
|
|
971
|
+
0
|
|
972
|
+
);
|
|
934
973
|
async function query(request, {
|
|
935
974
|
requestContext,
|
|
936
975
|
filterMatchesToLoad,
|
|
@@ -1550,6 +1589,7 @@ function createStaticHandler(routes, opts) {
|
|
|
1550
1589
|
}
|
|
1551
1590
|
return {
|
|
1552
1591
|
dataRoutes,
|
|
1592
|
+
_matchCost: matchCost,
|
|
1553
1593
|
_internalRouteBranches: routeBranches,
|
|
1554
1594
|
query,
|
|
1555
1595
|
queryRoute
|
|
@@ -2469,29 +2509,99 @@ function prependCookies(parentHeaders, childHeaders) {
|
|
|
2469
2509
|
}
|
|
2470
2510
|
var SINGLE_FETCH_REDIRECT_STATUS = 202;
|
|
2471
2511
|
|
|
2512
|
+
// lib/server-runtime/warnings.ts
|
|
2513
|
+
var alreadyWarned = {};
|
|
2514
|
+
function warnOnce(condition, message) {
|
|
2515
|
+
if (!condition && !alreadyWarned[message]) {
|
|
2516
|
+
alreadyWarned[message] = true;
|
|
2517
|
+
console.warn(message);
|
|
2518
|
+
}
|
|
2519
|
+
}
|
|
2520
|
+
|
|
2521
|
+
// lib/errors.ts
|
|
2522
|
+
var ERROR_DIGEST_BASE = "REACT_ROUTER_ERROR";
|
|
2523
|
+
var ERROR_DIGEST_REDIRECT = "REDIRECT";
|
|
2524
|
+
var ERROR_DIGEST_ROUTE_ERROR_RESPONSE = "ROUTE_ERROR_RESPONSE";
|
|
2525
|
+
function createRedirectErrorDigest(response) {
|
|
2526
|
+
return `${ERROR_DIGEST_BASE}:${ERROR_DIGEST_REDIRECT}:${JSON.stringify({
|
|
2527
|
+
status: response.status,
|
|
2528
|
+
statusText: response.statusText,
|
|
2529
|
+
location: response.headers.get("Location"),
|
|
2530
|
+
reloadDocument: response.headers.get("X-Remix-Reload-Document") === "true",
|
|
2531
|
+
replace: response.headers.get("X-Remix-Replace") === "true"
|
|
2532
|
+
})}`;
|
|
2533
|
+
}
|
|
2534
|
+
function createRouteErrorResponseDigest(response) {
|
|
2535
|
+
let status = 500;
|
|
2536
|
+
let statusText = "";
|
|
2537
|
+
let data2;
|
|
2538
|
+
if (isDataWithResponseInit(response)) {
|
|
2539
|
+
status = response.init?.status ?? status;
|
|
2540
|
+
statusText = response.init?.statusText ?? statusText;
|
|
2541
|
+
data2 = response.data;
|
|
2542
|
+
} else {
|
|
2543
|
+
status = response.status;
|
|
2544
|
+
statusText = response.statusText;
|
|
2545
|
+
data2 = void 0;
|
|
2546
|
+
}
|
|
2547
|
+
return `${ERROR_DIGEST_BASE}:${ERROR_DIGEST_ROUTE_ERROR_RESPONSE}:${JSON.stringify(
|
|
2548
|
+
{
|
|
2549
|
+
status,
|
|
2550
|
+
statusText,
|
|
2551
|
+
data: data2
|
|
2552
|
+
}
|
|
2553
|
+
)}`;
|
|
2554
|
+
}
|
|
2555
|
+
|
|
2556
|
+
// lib/dom/ssr/fog-of-war.ts
|
|
2557
|
+
var URL_LIMIT = 7680;
|
|
2558
|
+
function getPathsWithAncestors(paths) {
|
|
2559
|
+
let result = /* @__PURE__ */ new Set();
|
|
2560
|
+
paths.forEach((path) => {
|
|
2561
|
+
if (!path.startsWith("/")) {
|
|
2562
|
+
path = `/${path}`;
|
|
2563
|
+
}
|
|
2564
|
+
for (let i = 1; i < path.length; i++) {
|
|
2565
|
+
if (path[i] === "/") {
|
|
2566
|
+
result.add(path.slice(0, i));
|
|
2567
|
+
}
|
|
2568
|
+
}
|
|
2569
|
+
result.add(path);
|
|
2570
|
+
});
|
|
2571
|
+
return Array.from(result);
|
|
2572
|
+
}
|
|
2573
|
+
var MANIFEST_MATCH_COST_LIMIT = 5e4;
|
|
2574
|
+
var MANIFEST_MATCH_COST_SEGMENT_THRESHOLD = 10;
|
|
2575
|
+
function shouldUseInitialRouteDiscovery(pathname, matchCost = 0) {
|
|
2576
|
+
let segmentCount = pathname.split("/").length - 1;
|
|
2577
|
+
let ancestorCount = Math.max(segmentCount - 1, 0);
|
|
2578
|
+
return ancestorCount * pathname.length + 1 > URL_LIMIT || segmentCount > MANIFEST_MATCH_COST_SEGMENT_THRESHOLD && segmentCount * matchCost > MANIFEST_MATCH_COST_LIMIT;
|
|
2579
|
+
}
|
|
2580
|
+
|
|
2472
2581
|
// lib/actions.ts
|
|
2473
|
-
function throwIfPotentialCSRFAttack(
|
|
2474
|
-
let originHeader = headers.get("origin");
|
|
2582
|
+
function throwIfPotentialCSRFAttack(request, allowedActionOrigins) {
|
|
2583
|
+
let originHeader = request.headers.get("origin");
|
|
2475
2584
|
let originDomain = null;
|
|
2585
|
+
let originUrl = null;
|
|
2476
2586
|
try {
|
|
2477
|
-
|
|
2587
|
+
if (typeof originHeader === "string" && originHeader !== "null") {
|
|
2588
|
+
originUrl = new URL(originHeader);
|
|
2589
|
+
originDomain = originUrl.host;
|
|
2590
|
+
} else {
|
|
2591
|
+
originDomain = originHeader;
|
|
2592
|
+
}
|
|
2478
2593
|
} catch {
|
|
2479
2594
|
throw new Error(
|
|
2480
2595
|
`\`origin\` header is not a valid URL. Aborting the action.`
|
|
2481
2596
|
);
|
|
2482
2597
|
}
|
|
2483
|
-
let
|
|
2484
|
-
|
|
2598
|
+
let requestUrl = new URL(request.url);
|
|
2599
|
+
let originMatchesRequest = originUrl ? originUrl.origin === requestUrl.origin : originDomain === requestUrl.host;
|
|
2600
|
+
if (originDomain && !originMatchesRequest) {
|
|
2485
2601
|
if (!isAllowedOrigin(originDomain, allowedActionOrigins)) {
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
);
|
|
2490
|
-
} else {
|
|
2491
|
-
throw new Error(
|
|
2492
|
-
"`x-forwarded-host` or `host` headers are not provided. One of these is needed to compare the `origin` header from a forwarded action request. Aborting the action."
|
|
2493
|
-
);
|
|
2494
|
-
}
|
|
2602
|
+
throw new Error(
|
|
2603
|
+
"The `request.url` origin does not match `origin` header from a forwarded action request. Aborting the action."
|
|
2604
|
+
);
|
|
2495
2605
|
}
|
|
2496
2606
|
}
|
|
2497
2607
|
}
|
|
@@ -2539,53 +2649,6 @@ function isAllowedOrigin(originDomain, allowedActionOrigins = []) {
|
|
|
2539
2649
|
(allowedOrigin) => allowedOrigin && (allowedOrigin === originDomain || matchWildcardDomain(originDomain, allowedOrigin))
|
|
2540
2650
|
);
|
|
2541
2651
|
}
|
|
2542
|
-
function parseHostHeader(headers) {
|
|
2543
|
-
let forwardedHostHeader = headers.get("x-forwarded-host");
|
|
2544
|
-
let forwardedHostValue = forwardedHostHeader?.split(",")[0]?.trim();
|
|
2545
|
-
let hostHeader = headers.get("host");
|
|
2546
|
-
return forwardedHostValue ? {
|
|
2547
|
-
type: "x-forwarded-host",
|
|
2548
|
-
value: forwardedHostValue
|
|
2549
|
-
} : hostHeader ? {
|
|
2550
|
-
type: "host",
|
|
2551
|
-
value: hostHeader
|
|
2552
|
-
} : void 0;
|
|
2553
|
-
}
|
|
2554
|
-
|
|
2555
|
-
// lib/errors.ts
|
|
2556
|
-
var ERROR_DIGEST_BASE = "REACT_ROUTER_ERROR";
|
|
2557
|
-
var ERROR_DIGEST_REDIRECT = "REDIRECT";
|
|
2558
|
-
var ERROR_DIGEST_ROUTE_ERROR_RESPONSE = "ROUTE_ERROR_RESPONSE";
|
|
2559
|
-
function createRedirectErrorDigest(response) {
|
|
2560
|
-
return `${ERROR_DIGEST_BASE}:${ERROR_DIGEST_REDIRECT}:${JSON.stringify({
|
|
2561
|
-
status: response.status,
|
|
2562
|
-
statusText: response.statusText,
|
|
2563
|
-
location: response.headers.get("Location"),
|
|
2564
|
-
reloadDocument: response.headers.get("X-Remix-Reload-Document") === "true",
|
|
2565
|
-
replace: response.headers.get("X-Remix-Replace") === "true"
|
|
2566
|
-
})}`;
|
|
2567
|
-
}
|
|
2568
|
-
function createRouteErrorResponseDigest(response) {
|
|
2569
|
-
let status = 500;
|
|
2570
|
-
let statusText = "";
|
|
2571
|
-
let data2;
|
|
2572
|
-
if (isDataWithResponseInit(response)) {
|
|
2573
|
-
status = response.init?.status ?? status;
|
|
2574
|
-
statusText = response.init?.statusText ?? statusText;
|
|
2575
|
-
data2 = response.data;
|
|
2576
|
-
} else {
|
|
2577
|
-
status = response.status;
|
|
2578
|
-
statusText = response.statusText;
|
|
2579
|
-
data2 = void 0;
|
|
2580
|
-
}
|
|
2581
|
-
return `${ERROR_DIGEST_BASE}:${ERROR_DIGEST_ROUTE_ERROR_RESPONSE}:${JSON.stringify(
|
|
2582
|
-
{
|
|
2583
|
-
status,
|
|
2584
|
-
statusText,
|
|
2585
|
-
data: data2
|
|
2586
|
-
}
|
|
2587
|
-
)}`;
|
|
2588
|
-
}
|
|
2589
2652
|
|
|
2590
2653
|
// lib/server-runtime/urls.ts
|
|
2591
2654
|
function getNormalizedPath(request, basename, future) {
|
|
@@ -2657,7 +2720,7 @@ var replace2 = (...args) => {
|
|
|
2657
2720
|
};
|
|
2658
2721
|
var cachedResolvePromise = (
|
|
2659
2722
|
// @ts-expect-error - on 18 types, requires 19.
|
|
2660
|
-
|
|
2723
|
+
React3__namespace.cache(async (resolve) => {
|
|
2661
2724
|
return Promise.allSettled([resolve]).then((r) => r[0]);
|
|
2662
2725
|
})
|
|
2663
2726
|
);
|
|
@@ -2672,13 +2735,13 @@ var Await = async ({
|
|
|
2672
2735
|
throw resolved.reason;
|
|
2673
2736
|
}
|
|
2674
2737
|
if (resolved.status === "rejected") {
|
|
2675
|
-
return
|
|
2676
|
-
children:
|
|
2738
|
+
return React3__namespace.createElement(reactServerClient.UNSAFE_AwaitContextProvider, {
|
|
2739
|
+
children: React3__namespace.createElement(React3__namespace.Fragment, null, errorElement),
|
|
2677
2740
|
value: { _tracked: true, _error: resolved.reason }
|
|
2678
2741
|
});
|
|
2679
2742
|
}
|
|
2680
2743
|
const toRender = typeof children === "function" ? children(resolved.value) : children;
|
|
2681
|
-
return
|
|
2744
|
+
return React3__namespace.createElement(reactServerClient.UNSAFE_AwaitContextProvider, {
|
|
2682
2745
|
children: toRender,
|
|
2683
2746
|
value: { _tracked: true, _data: resolved.value }
|
|
2684
2747
|
});
|
|
@@ -2767,6 +2830,13 @@ async function matchRSCServerRequest({
|
|
|
2767
2830
|
return response;
|
|
2768
2831
|
}
|
|
2769
2832
|
async function generateManifestResponse(routes, basename, request, generateResponse, temporaryReferences, routeDiscovery) {
|
|
2833
|
+
let url = new URL(request.url);
|
|
2834
|
+
if (url.toString().length > URL_LIMIT) {
|
|
2835
|
+
return new Response(null, {
|
|
2836
|
+
statusText: "Bad Request",
|
|
2837
|
+
status: 400
|
|
2838
|
+
});
|
|
2839
|
+
}
|
|
2770
2840
|
if (routeDiscovery?.mode === "initial") {
|
|
2771
2841
|
let payload2 = {
|
|
2772
2842
|
type: "manifest",
|
|
@@ -2784,7 +2854,6 @@ async function generateManifestResponse(routes, basename, request, generateRespo
|
|
|
2784
2854
|
{ temporaryReferences, onError: defaultOnError }
|
|
2785
2855
|
);
|
|
2786
2856
|
}
|
|
2787
|
-
let url = new URL(request.url);
|
|
2788
2857
|
let pathParam = url.searchParams.get("paths");
|
|
2789
2858
|
let pathnames = pathParam ? pathParam.split(",").filter(Boolean) : [url.pathname.replace(/\.manifest$/, "")];
|
|
2790
2859
|
let routeIds = /* @__PURE__ */ new Set();
|
|
@@ -2987,7 +3056,17 @@ async function generateRenderResponse(request, routes, basename, isDataRequest,
|
|
|
2987
3056
|
let potentialCSRFAttackError;
|
|
2988
3057
|
if (isMutationMethod(request.method)) {
|
|
2989
3058
|
try {
|
|
2990
|
-
throwIfPotentialCSRFAttack(request
|
|
3059
|
+
throwIfPotentialCSRFAttack(request, allowedActionOrigins);
|
|
3060
|
+
} catch (error) {
|
|
3061
|
+
onError?.(error);
|
|
3062
|
+
potentialCSRFAttackError = error;
|
|
3063
|
+
request = new Request(request.url, {
|
|
3064
|
+
method: "GET",
|
|
3065
|
+
headers: request.headers,
|
|
3066
|
+
signal: request.signal
|
|
3067
|
+
});
|
|
3068
|
+
}
|
|
3069
|
+
if (!potentialCSRFAttackError) {
|
|
2991
3070
|
ctx.runningAction = true;
|
|
2992
3071
|
let result2 = await processServerAction(
|
|
2993
3072
|
request,
|
|
@@ -3027,15 +3106,11 @@ async function generateRenderResponse(request, routes, basename, isDataRequest,
|
|
|
3027
3106
|
void 0
|
|
3028
3107
|
);
|
|
3029
3108
|
}
|
|
3030
|
-
} catch (error) {
|
|
3031
|
-
potentialCSRFAttackError = error;
|
|
3032
3109
|
}
|
|
3033
3110
|
}
|
|
3034
3111
|
let staticContext = await query(
|
|
3035
3112
|
request,
|
|
3036
|
-
skipRevalidation
|
|
3037
|
-
filterMatchesToLoad: () => false
|
|
3038
|
-
} : void 0
|
|
3113
|
+
skipRevalidation ? { filterMatchesToLoad: () => false } : void 0
|
|
3039
3114
|
);
|
|
3040
3115
|
if (isResponse(staticContext)) {
|
|
3041
3116
|
return generateRedirectResponse(
|
|
@@ -3067,7 +3142,8 @@ async function generateRenderResponse(request, routes, basename, isDataRequest,
|
|
|
3067
3142
|
temporaryReferences,
|
|
3068
3143
|
skipRevalidation,
|
|
3069
3144
|
ctx.redirect?.headers,
|
|
3070
|
-
routeDiscovery
|
|
3145
|
+
routeDiscovery,
|
|
3146
|
+
staticHandler._matchCost
|
|
3071
3147
|
);
|
|
3072
3148
|
}
|
|
3073
3149
|
})
|
|
@@ -3117,7 +3193,7 @@ function generateRedirectResponse(response, actionResult, basename, isDataReques
|
|
|
3117
3193
|
{ temporaryReferences, onError: defaultOnError }
|
|
3118
3194
|
);
|
|
3119
3195
|
}
|
|
3120
|
-
async function generateStaticContextResponse(routes, basename, generateResponse, statusCode, routeIdsToLoad, isDataRequest, isSubmission, actionResult, formState, staticContext, temporaryReferences, skipRevalidation, sideEffectRedirectHeaders, routeDiscovery) {
|
|
3196
|
+
async function generateStaticContextResponse(routes, basename, generateResponse, statusCode, routeIdsToLoad, isDataRequest, isSubmission, actionResult, formState, staticContext, temporaryReferences, skipRevalidation, sideEffectRedirectHeaders, routeDiscovery, matchCost) {
|
|
3121
3197
|
statusCode = staticContext.statusCode ?? statusCode;
|
|
3122
3198
|
if (staticContext.errors) {
|
|
3123
3199
|
staticContext.errors = Object.fromEntries(
|
|
@@ -3159,7 +3235,8 @@ async function generateStaticContextResponse(routes, basename, generateResponse,
|
|
|
3159
3235
|
routeIdsToLoad,
|
|
3160
3236
|
isDataRequest,
|
|
3161
3237
|
staticContext,
|
|
3162
|
-
routeDiscovery
|
|
3238
|
+
routeDiscovery,
|
|
3239
|
+
matchCost
|
|
3163
3240
|
);
|
|
3164
3241
|
let payload;
|
|
3165
3242
|
if (actionResult) {
|
|
@@ -3186,7 +3263,7 @@ async function generateStaticContextResponse(routes, basename, generateResponse,
|
|
|
3186
3263
|
{ temporaryReferences, onError: defaultOnError }
|
|
3187
3264
|
);
|
|
3188
3265
|
}
|
|
3189
|
-
async function getRenderPayload(baseRenderPayload, routes, basename, routeIdsToLoad, isDataRequest, staticContext, routeDiscovery) {
|
|
3266
|
+
async function getRenderPayload(baseRenderPayload, routes, basename, routeIdsToLoad, isDataRequest, staticContext, routeDiscovery, matchCost) {
|
|
3190
3267
|
let deepestRenderedRouteIdx = staticContext.matches.length - 1;
|
|
3191
3268
|
let parentIds = {};
|
|
3192
3269
|
staticContext.matches.forEach((m, i) => {
|
|
@@ -3210,18 +3287,27 @@ async function getRenderPayload(baseRenderPayload, routes, basename, routeIdsToL
|
|
|
3210
3287
|
});
|
|
3211
3288
|
})
|
|
3212
3289
|
);
|
|
3213
|
-
let
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3290
|
+
let pathname = staticContext.location.pathname;
|
|
3291
|
+
let useInitialRouteDiscovery = routeDiscovery?.mode === "initial" && !isDataRequest || shouldUseInitialRouteDiscovery(pathname, matchCost);
|
|
3292
|
+
let patches;
|
|
3293
|
+
if (useInitialRouteDiscovery) {
|
|
3294
|
+
patches = getAllRoutePatches(routes).then(
|
|
3295
|
+
(patches2) => patches2.filter(
|
|
3296
|
+
(patch) => !staticContext.matches.some((m) => m.route.id === patch.id)
|
|
3297
|
+
)
|
|
3298
|
+
);
|
|
3299
|
+
} else {
|
|
3300
|
+
patches = getAdditionalRoutePatches(
|
|
3301
|
+
// The full pathname is last and its matches are already in the payload.
|
|
3302
|
+
getPathsWithAncestors([pathname]).slice(0, -1),
|
|
3303
|
+
routes,
|
|
3304
|
+
basename,
|
|
3305
|
+
staticContext.matches.map((m) => m.route.id)
|
|
3306
|
+
);
|
|
3307
|
+
}
|
|
3223
3308
|
return {
|
|
3224
3309
|
...baseRenderPayload,
|
|
3310
|
+
routeDiscovery: useInitialRouteDiscovery ? { mode: "initial" } : baseRenderPayload.routeDiscovery,
|
|
3225
3311
|
matches: await matchesPromise,
|
|
3226
3312
|
patches
|
|
3227
3313
|
};
|
|
@@ -3235,7 +3321,7 @@ async function getRSCRouteMatch({
|
|
|
3235
3321
|
}) {
|
|
3236
3322
|
const route = match.route;
|
|
3237
3323
|
await explodeLazyRoute(route);
|
|
3238
|
-
const Layout = route.Layout ||
|
|
3324
|
+
const Layout = route.Layout || React3__namespace.Fragment;
|
|
3239
3325
|
const Component = route.Component;
|
|
3240
3326
|
const ErrorBoundary = route.ErrorBoundary;
|
|
3241
3327
|
const HydrateFallback = route.HydrateFallback;
|
|
@@ -3245,12 +3331,12 @@ async function getRSCRouteMatch({
|
|
|
3245
3331
|
let element = void 0;
|
|
3246
3332
|
let shouldLoadRoute = !routeIdsToLoad || routeIdsToLoad.includes(route.id);
|
|
3247
3333
|
if (Component && shouldLoadRoute) {
|
|
3248
|
-
element = !isBelowErrorBoundary ?
|
|
3334
|
+
element = !isBelowErrorBoundary ? React3__namespace.createElement(
|
|
3249
3335
|
Layout,
|
|
3250
3336
|
null,
|
|
3251
|
-
isClientReference(Component) ?
|
|
3252
|
-
children:
|
|
3253
|
-
}) :
|
|
3337
|
+
isClientReference(Component) ? React3__namespace.createElement(WithComponentProps, {
|
|
3338
|
+
children: React3__namespace.createElement(Component)
|
|
3339
|
+
}) : React3__namespace.createElement(Component, {
|
|
3254
3340
|
loaderData,
|
|
3255
3341
|
actionData,
|
|
3256
3342
|
params,
|
|
@@ -3258,30 +3344,30 @@ async function getRSCRouteMatch({
|
|
|
3258
3344
|
(match2) => convertRouteMatchToUiMatch(match2, staticContext.loaderData)
|
|
3259
3345
|
)
|
|
3260
3346
|
})
|
|
3261
|
-
) :
|
|
3347
|
+
) : React3__namespace.createElement(Outlet);
|
|
3262
3348
|
}
|
|
3263
3349
|
let error = void 0;
|
|
3264
3350
|
if (ErrorBoundary && staticContext.errors) {
|
|
3265
3351
|
error = staticContext.errors[route.id];
|
|
3266
3352
|
}
|
|
3267
|
-
const errorElement = ErrorBoundary ?
|
|
3353
|
+
const errorElement = ErrorBoundary ? React3__namespace.createElement(
|
|
3268
3354
|
Layout,
|
|
3269
3355
|
null,
|
|
3270
|
-
isClientReference(ErrorBoundary) ?
|
|
3271
|
-
children:
|
|
3272
|
-
}) :
|
|
3356
|
+
isClientReference(ErrorBoundary) ? React3__namespace.createElement(WithErrorBoundaryProps, {
|
|
3357
|
+
children: React3__namespace.createElement(ErrorBoundary)
|
|
3358
|
+
}) : React3__namespace.createElement(ErrorBoundary, {
|
|
3273
3359
|
loaderData,
|
|
3274
3360
|
actionData,
|
|
3275
3361
|
params,
|
|
3276
3362
|
error
|
|
3277
3363
|
})
|
|
3278
3364
|
) : void 0;
|
|
3279
|
-
const hydrateFallbackElement = HydrateFallback ?
|
|
3365
|
+
const hydrateFallbackElement = HydrateFallback ? React3__namespace.createElement(
|
|
3280
3366
|
Layout,
|
|
3281
3367
|
null,
|
|
3282
|
-
isClientReference(HydrateFallback) ?
|
|
3283
|
-
children:
|
|
3284
|
-
}) :
|
|
3368
|
+
isClientReference(HydrateFallback) ? React3__namespace.createElement(WithHydrateFallbackProps, {
|
|
3369
|
+
children: React3__namespace.createElement(HydrateFallback)
|
|
3370
|
+
}) : React3__namespace.createElement(HydrateFallback, {
|
|
3285
3371
|
loaderData,
|
|
3286
3372
|
actionData,
|
|
3287
3373
|
params
|
|
@@ -3318,11 +3404,11 @@ async function getRSCRouteMatch({
|
|
|
3318
3404
|
}
|
|
3319
3405
|
async function getManifestRoute(route) {
|
|
3320
3406
|
await explodeLazyRoute(route);
|
|
3321
|
-
const Layout = route.Layout ||
|
|
3322
|
-
const errorElement = route.ErrorBoundary ?
|
|
3407
|
+
const Layout = route.Layout || React3__namespace.Fragment;
|
|
3408
|
+
const errorElement = route.ErrorBoundary ? React3__namespace.createElement(
|
|
3323
3409
|
Layout,
|
|
3324
3410
|
null,
|
|
3325
|
-
|
|
3411
|
+
React3__namespace.createElement(route.ErrorBoundary)
|
|
3326
3412
|
) : void 0;
|
|
3327
3413
|
return {
|
|
3328
3414
|
clientAction: route.clientAction,
|
|
@@ -3380,27 +3466,18 @@ async function getAdditionalRoutePatches(pathnames, routes, basename, matchedRou
|
|
|
3380
3466
|
let patchRouteMatches = /* @__PURE__ */ new Map();
|
|
3381
3467
|
let matchedPaths = /* @__PURE__ */ new Set();
|
|
3382
3468
|
for (const pathname of pathnames) {
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
paths.forEach((path) => {
|
|
3391
|
-
if (matchedPaths.has(path)) {
|
|
3469
|
+
if (matchedPaths.has(pathname)) {
|
|
3470
|
+
continue;
|
|
3471
|
+
}
|
|
3472
|
+
matchedPaths.add(pathname);
|
|
3473
|
+
let matches = matchRoutes(routes, pathname, basename) || [];
|
|
3474
|
+
matches.forEach((m, i) => {
|
|
3475
|
+
if (patchRouteMatches.get(m.route.id)) {
|
|
3392
3476
|
return;
|
|
3393
3477
|
}
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
if (patchRouteMatches.get(m.route.id)) {
|
|
3398
|
-
return;
|
|
3399
|
-
}
|
|
3400
|
-
patchRouteMatches.set(m.route.id, {
|
|
3401
|
-
...m.route,
|
|
3402
|
-
parentId: matches[i - 1]?.route.id
|
|
3403
|
-
});
|
|
3478
|
+
patchRouteMatches.set(m.route.id, {
|
|
3479
|
+
...m.route,
|
|
3480
|
+
parentId: matches[i - 1]?.route.id
|
|
3404
3481
|
});
|
|
3405
3482
|
});
|
|
3406
3483
|
}
|
|
@@ -3512,15 +3589,6 @@ function byteStringToUint8Array(byteString) {
|
|
|
3512
3589
|
return array;
|
|
3513
3590
|
}
|
|
3514
3591
|
|
|
3515
|
-
// lib/server-runtime/warnings.ts
|
|
3516
|
-
var alreadyWarned = {};
|
|
3517
|
-
function warnOnce(condition, message) {
|
|
3518
|
-
if (!condition && !alreadyWarned[message]) {
|
|
3519
|
-
alreadyWarned[message] = true;
|
|
3520
|
-
console.warn(message);
|
|
3521
|
-
}
|
|
3522
|
-
}
|
|
3523
|
-
|
|
3524
3592
|
// lib/server-runtime/cookies.ts
|
|
3525
3593
|
var createCookie = (name, cookieOptions = {}) => {
|
|
3526
3594
|
let { secrets = [], ...options } = {
|