react-router 7.17.0 → 7.18.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.
Files changed (80) hide show
  1. package/CHANGELOG.md +19 -1
  2. package/dist/development/{browser-D3uq9sI1.d.ts → browser-B2PdsXXH.d.ts} +2 -2
  3. package/dist/development/{browser-CGcs-0pD.d.mts → browser-DBmQ1yAR.d.mts} +2 -2
  4. package/dist/development/{chunk-PBLBZ3QU.js → chunk-EVX4J2F5.js} +7 -7
  5. package/dist/development/{chunk-PULC7NLK.js → chunk-G5KIBF6U.js} +111 -108
  6. package/dist/{production/chunk-5TQZEVD5.mjs → development/chunk-IJF3QNGC.mjs} +45 -113
  7. package/dist/development/{chunk-6CSD65Y2.mjs → chunk-KS7C4IRE.mjs} +115 -38
  8. package/dist/development/{chunk-KFNXW4AL.js → chunk-SA4DP3SF.js} +113 -35
  9. package/dist/{production/context-CmHpk1Ws.d.mts → development/context-CeD5LmaF.d.mts} +12 -4
  10. package/dist/{production/data-D4xhSy90.d.ts → development/data-CjO11-hU.d.ts} +9 -1
  11. package/dist/development/{data-U8FS-wNn.d.mts → data-DEjBmEfD.d.mts} +9 -1
  12. package/dist/development/dom-export.d.mts +3 -3
  13. package/dist/development/dom-export.d.ts +3 -3
  14. package/dist/development/dom-export.js +46 -44
  15. package/dist/development/dom-export.mjs +23 -21
  16. package/dist/development/{index-react-server-client-CwU9bE5R.d.ts → index-react-server-client-3ykjivgQ.d.ts} +29 -7
  17. package/dist/development/{index-react-server-client-DPrDrCew.d.mts → index-react-server-client-CACgcj2J.d.mts} +19 -5
  18. package/dist/development/index-react-server-client.d.mts +3 -3
  19. package/dist/development/index-react-server-client.d.ts +3 -3
  20. package/dist/development/index-react-server-client.js +4 -4
  21. package/dist/development/index-react-server-client.mjs +2 -2
  22. package/dist/development/index-react-server.d.mts +9 -1
  23. package/dist/development/index-react-server.d.ts +9 -1
  24. package/dist/development/index-react-server.js +144 -121
  25. package/dist/development/index-react-server.mjs +143 -120
  26. package/dist/development/index.d.mts +15 -14
  27. package/dist/development/index.d.ts +15 -14
  28. package/dist/development/index.js +137 -205
  29. package/dist/development/index.mjs +3 -5
  30. package/dist/{production/instrumentation-1q4YhLGP.d.ts → development/instrumentation-Dkmpzd13.d.ts} +2 -2
  31. package/dist/development/lib/types/internal.d.mts +2 -2
  32. package/dist/development/lib/types/internal.d.ts +2 -2
  33. package/dist/development/lib/types/internal.js +1 -1
  34. package/dist/development/lib/types/internal.mjs +1 -1
  35. package/dist/development/{register-CqK96Zfk.d.mts → register-CmkRspdl.d.mts} +1 -1
  36. package/dist/development/{register-CNAx3TXj.d.ts → register-roq_0qYo.d.ts} +1 -1
  37. package/dist/production/{browser-D3uq9sI1.d.ts → browser-B2PdsXXH.d.ts} +2 -2
  38. package/dist/production/{browser-CGcs-0pD.d.mts → browser-DBmQ1yAR.d.mts} +2 -2
  39. package/dist/{development/chunk-ASILSGTR.mjs → production/chunk-3MA7PLKB.mjs} +45 -113
  40. package/dist/production/{chunk-OSYEOCBT.mjs → chunk-3WDNQUW5.mjs} +115 -38
  41. package/dist/production/{chunk-CTIXC7EV.js → chunk-GOIER6ML.js} +7 -7
  42. package/dist/production/{chunk-RTRY3JFT.js → chunk-IEF7VMTA.js} +113 -35
  43. package/dist/production/{chunk-EN242BO4.js → chunk-WICLSFKL.js} +111 -108
  44. package/dist/{development/context-CmHpk1Ws.d.mts → production/context-CeD5LmaF.d.mts} +12 -4
  45. package/dist/{development/data-D4xhSy90.d.ts → production/data-CjO11-hU.d.ts} +9 -1
  46. package/dist/production/{data-U8FS-wNn.d.mts → data-DEjBmEfD.d.mts} +9 -1
  47. package/dist/production/dom-export.d.mts +3 -3
  48. package/dist/production/dom-export.d.ts +3 -3
  49. package/dist/production/dom-export.js +46 -44
  50. package/dist/production/dom-export.mjs +23 -21
  51. package/dist/production/{index-react-server-client-CwU9bE5R.d.ts → index-react-server-client-3ykjivgQ.d.ts} +29 -7
  52. package/dist/production/{index-react-server-client-DPrDrCew.d.mts → index-react-server-client-CACgcj2J.d.mts} +19 -5
  53. package/dist/production/index-react-server-client.d.mts +3 -3
  54. package/dist/production/index-react-server-client.d.ts +3 -3
  55. package/dist/production/index-react-server-client.js +4 -4
  56. package/dist/production/index-react-server-client.mjs +2 -2
  57. package/dist/production/index-react-server.d.mts +9 -1
  58. package/dist/production/index-react-server.d.ts +9 -1
  59. package/dist/production/index-react-server.js +144 -121
  60. package/dist/production/index-react-server.mjs +143 -120
  61. package/dist/production/index.d.mts +15 -14
  62. package/dist/production/index.d.ts +15 -14
  63. package/dist/production/index.js +137 -205
  64. package/dist/production/index.mjs +3 -5
  65. package/dist/{development/instrumentation-1q4YhLGP.d.ts → production/instrumentation-Dkmpzd13.d.ts} +2 -2
  66. package/dist/production/lib/types/internal.d.mts +2 -2
  67. package/dist/production/lib/types/internal.d.ts +2 -2
  68. package/dist/production/lib/types/internal.js +1 -1
  69. package/dist/production/lib/types/internal.mjs +1 -1
  70. package/dist/production/{register-CqK96Zfk.d.mts → register-CmkRspdl.d.mts} +1 -1
  71. package/dist/production/{register-CNAx3TXj.d.ts → register-roq_0qYo.d.ts} +1 -1
  72. package/docs/explanation/type-safety.md +1 -1
  73. package/docs/how-to/headers.md +2 -1
  74. package/docs/how-to/security.md +8 -6
  75. package/docs/how-to/status.md +1 -1
  76. package/docs/start/data/installation.md +4 -0
  77. package/docs/start/framework/deploying.md +4 -0
  78. package/docs/upgrading/future.md +222 -12
  79. package/docs/upgrading/remix.md +2 -2
  80. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
- import { o as ServerInstrumentation, H as HydrationState, i as StaticHandlerContext, f as RelativeRoutingType, h as GetScrollRestorationKeyFunction, R as RouterInit, ah as FutureConfig$1, C as ClientInstrumentation, N as NavigateOptions, F as Fetcher, c as Router, B as BlockerFunction, ai as CreateStaticHandlerOptions$1, S as StaticHandler } from './context-CmHpk1Ws.mjs';
1
+ import { o as ServerInstrumentation, H as HydrationState, h as StaticHandlerContext, f as RelativeRoutingType, g as GetScrollRestorationKeyFunction, R as RouterInit, ah as FutureConfig$1, C as ClientInstrumentation, N as NavigateOptions, F as Fetcher, c as Router, B as BlockerFunction, ai as CreateStaticHandlerOptions$1, S as StaticHandler } from './context-CeD5LmaF.mjs';
2
2
  import * as React from 'react';
3
- import { J as RouteManifest, aF as ServerRouteModule, p as MiddlewareEnabled, c as RouterContextProvider, q as AppLoadContext, o as LoaderFunctionArgs, a3 as ActionFunctionArgs, Z as RouteModules, E as DataRouteObject, a as ClientLoaderFunction, I as RouteBranch, m as HTMLFormMethod, n as FormEncType, aw as PageLinkDescriptor, T as To, s as History, z as DataStrategyFunction, B as PatchRoutesOnNavigationFunction, r as RouteObject, _ as SerializeFrom, L as Location } from './data-U8FS-wNn.mjs';
3
+ import { J as RouteManifest, aF as ServerRouteModule, p as MiddlewareEnabled, c as RouterContextProvider, q as AppLoadContext, o as LoaderFunctionArgs, a3 as ActionFunctionArgs, Z as RouteModules, E as DataRouteObject, a as ClientLoaderFunction, I as RouteBranch, m as HTMLFormMethod, n as FormEncType, aw as PageLinkDescriptor, T as To, s as History, z as DataStrategyFunction, B as PatchRoutesOnNavigationFunction, r as RouteObject, _ as SerializeFrom, L as Location } from './data-DEjBmEfD.mjs';
4
4
 
5
5
  type ServerRouteManifest = RouteManifest<Omit<ServerRoute, "children">>;
6
6
  interface ServerRoute extends Route {
@@ -106,6 +106,7 @@ interface FrameworkContextObject {
106
106
  ssr: boolean;
107
107
  isSpaMode: boolean;
108
108
  routeDiscovery: ServerBuild["routeDiscovery"];
109
+ nonce?: string;
109
110
  serializeError?(error: Error): SerializedError;
110
111
  renderMeta?: {
111
112
  didRenderScripts?: boolean;
@@ -292,7 +293,8 @@ interface LinksProps {
292
293
  /**
293
294
  * A [`nonce`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/nonce)
294
295
  * attribute to render on the [`<link>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link)
295
- * element
296
+ * element. If not provided in Framework Mode, it will default to any
297
+ * {@link ServerRouter | `<ServerRouter nonce>`} prop.
296
298
  */
297
299
  nonce?: string | undefined;
298
300
  /**
@@ -409,7 +411,8 @@ type ScriptsProps = Omit<React.HTMLProps<HTMLScriptElement>, "async" | "children
409
411
  /**
410
412
  * A [`nonce`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/nonce)
411
413
  * attribute to render on the [`<script>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script)
412
- * element
414
+ * element. If not provided in Framework Mode, it will default to any
415
+ * {@link ServerRouter | `<ServerRouter nonce>`} prop.
413
416
  */
414
417
  nonce?: string | undefined;
415
418
  };
@@ -941,6 +944,10 @@ interface DOMRouterOpts {
941
944
  * path via [`history.pushState`](https://developer.mozilla.org/en-US/docs/Web/API/History/pushState)
942
945
  * and [`history.replaceState`](https://developer.mozilla.org/en-US/docs/Web/API/History/replaceState).
943
946
  *
947
+ * Data Routers should not be held in React state. You should create your router
948
+ * once outside of the React tree and pass it to {@link RouterProvider | `<RouterProvider>`}.
949
+ * You can use `patchRoutesOnNavigation` to add additional routes programmatically.
950
+ *
944
951
  * @public
945
952
  * @category Data Routers
946
953
  * @mode data
@@ -961,6 +968,10 @@ declare function createBrowserRouter(routes: RouteObject[], opts?: DOMRouterOpts
961
968
  * Create a new {@link DataRouter| data router} that manages the application
962
969
  * path via the URL [`hash`](https://developer.mozilla.org/en-US/docs/Web/API/URL/hash).
963
970
  *
971
+ * Data Routers should not be held in React state. You should create your router
972
+ * once outside of the React tree and pass it to {@link RouterProvider | `<RouterProvider>`}.
973
+ * You can use `patchRoutesOnNavigation` to add additional routes programmatically.
974
+ *
964
975
  * @public
965
976
  * @category Data Routers
966
977
  * @mode data
@@ -1781,7 +1792,10 @@ type ScrollRestorationProps = ScriptsProps & {
1781
1792
  * }
1782
1793
  * ```
1783
1794
  *
1784
- * This component renders an inline `<script>` to prevent scroll flashing. The `nonce` prop will be passed down to the script tag to allow CSP nonce usage.
1795
+ * This component renders an inline `<script>` to prevent scroll flashing. The
1796
+ * `nonce` prop will be passed down to the script tag to allow CSP nonce usage.
1797
+ * If not provided in Framework Mode, it will default to any
1798
+ * {@link ServerRouter | `<ServerRouter nonce>`} prop.
1785
1799
  *
1786
1800
  * ```tsx
1787
1801
  * <ScrollRestoration nonce={cspNonce} />
@@ -1,4 +1,4 @@
1
- export { Q as MemoryRouter, T as Navigate, U as Outlet, V as Route, W as Router, X as RouterProvider, Y as Routes, A as UNSAFE_AwaitContextProvider, ab as UNSAFE_WithComponentProps, af as UNSAFE_WithErrorBoundaryProps, ad as UNSAFE_WithHydrateFallbackProps } from './context-CmHpk1Ws.mjs';
2
- export { l as BrowserRouter, q as Form, m as HashRouter, n as Link, X as Links, W as Meta, p as NavLink, r as ScrollRestoration, T as StaticRouter, V as StaticRouterProvider, o as unstable_HistoryRouter } from './index-react-server-client-DPrDrCew.mjs';
3
- import './data-U8FS-wNn.mjs';
1
+ export { Q as MemoryRouter, T as Navigate, U as Outlet, V as Route, W as Router, X as RouterProvider, Y as Routes, A as UNSAFE_AwaitContextProvider, ab as UNSAFE_WithComponentProps, af as UNSAFE_WithErrorBoundaryProps, ad as UNSAFE_WithHydrateFallbackProps } from './context-CeD5LmaF.mjs';
2
+ export { l as BrowserRouter, q as Form, m as HashRouter, n as Link, X as Links, W as Meta, p as NavLink, r as ScrollRestoration, T as StaticRouter, V as StaticRouterProvider, o as unstable_HistoryRouter } from './index-react-server-client-CACgcj2J.mjs';
3
+ import './data-DEjBmEfD.mjs';
4
4
  import 'react';
@@ -1,4 +1,4 @@
1
- export { W as BrowserRouter, $ as Form, X as HashRouter, Y as Link, an as Links, j as MemoryRouter, am as Meta, _ as NavLink, k as Navigate, l as Outlet, m as Route, n as Router, o as RouterProvider, p as Routes, a0 as ScrollRestoration, ak as StaticRouter, al as StaticRouterProvider, b as UNSAFE_AwaitContextProvider, aH as UNSAFE_WithComponentProps, aL as UNSAFE_WithErrorBoundaryProps, aJ as UNSAFE_WithHydrateFallbackProps, Z as unstable_HistoryRouter } from './index-react-server-client-CwU9bE5R.js';
2
- import './instrumentation-1q4YhLGP.js';
3
- import './data-D4xhSy90.js';
1
+ export { W as BrowserRouter, $ as Form, X as HashRouter, Y as Link, an as Links, j as MemoryRouter, am as Meta, _ as NavLink, k as Navigate, l as Outlet, m as Route, n as Router, o as RouterProvider, p as Routes, a0 as ScrollRestoration, ak as StaticRouter, al as StaticRouterProvider, b as UNSAFE_AwaitContextProvider, aH as UNSAFE_WithComponentProps, aL as UNSAFE_WithErrorBoundaryProps, aJ as UNSAFE_WithHydrateFallbackProps, Z as unstable_HistoryRouter } from './index-react-server-client-3ykjivgQ.js';
2
+ import './instrumentation-Dkmpzd13.js';
3
+ import './data-CjO11-hU.js';
4
4
  import 'react';
@@ -1,5 +1,5 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});/**
2
- * react-router v7.17.0
2
+ * react-router v7.18.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -19,7 +19,7 @@
19
19
 
20
20
 
21
21
 
22
- var _chunkEN242BO4js = require('./chunk-EN242BO4.js');
22
+ var _chunkWICLSFKLjs = require('./chunk-WICLSFKL.js');
23
23
 
24
24
 
25
25
 
@@ -34,7 +34,7 @@ var _chunkEN242BO4js = require('./chunk-EN242BO4.js');
34
34
 
35
35
 
36
36
 
37
- var _chunkRTRY3JFTjs = require('./chunk-RTRY3JFT.js');
37
+ var _chunkIEF7VMTAjs = require('./chunk-IEF7VMTA.js');
38
38
 
39
39
 
40
40
 
@@ -58,4 +58,4 @@ var _chunkRTRY3JFTjs = require('./chunk-RTRY3JFT.js');
58
58
 
59
59
 
60
60
 
61
- exports.BrowserRouter = _chunkEN242BO4js.BrowserRouter; exports.Form = _chunkEN242BO4js.Form; exports.HashRouter = _chunkEN242BO4js.HashRouter; exports.Link = _chunkEN242BO4js.Link; exports.Links = _chunkRTRY3JFTjs.Links; exports.MemoryRouter = _chunkRTRY3JFTjs.MemoryRouter; exports.Meta = _chunkRTRY3JFTjs.Meta; exports.NavLink = _chunkEN242BO4js.NavLink; exports.Navigate = _chunkRTRY3JFTjs.Navigate; exports.Outlet = _chunkRTRY3JFTjs.Outlet; exports.Route = _chunkRTRY3JFTjs.Route; exports.Router = _chunkRTRY3JFTjs.Router; exports.RouterProvider = _chunkRTRY3JFTjs.RouterProvider; exports.Routes = _chunkRTRY3JFTjs.Routes; exports.ScrollRestoration = _chunkEN242BO4js.ScrollRestoration; exports.StaticRouter = _chunkEN242BO4js.StaticRouter; exports.StaticRouterProvider = _chunkEN242BO4js.StaticRouterProvider; exports.UNSAFE_AwaitContextProvider = _chunkRTRY3JFTjs.AwaitContextProvider; exports.UNSAFE_WithComponentProps = _chunkRTRY3JFTjs.WithComponentProps; exports.UNSAFE_WithErrorBoundaryProps = _chunkRTRY3JFTjs.WithErrorBoundaryProps; exports.UNSAFE_WithHydrateFallbackProps = _chunkRTRY3JFTjs.WithHydrateFallbackProps; exports.unstable_HistoryRouter = _chunkEN242BO4js.HistoryRouter;
61
+ exports.BrowserRouter = _chunkWICLSFKLjs.BrowserRouter; exports.Form = _chunkWICLSFKLjs.Form; exports.HashRouter = _chunkWICLSFKLjs.HashRouter; exports.Link = _chunkWICLSFKLjs.Link; exports.Links = _chunkIEF7VMTAjs.Links; exports.MemoryRouter = _chunkIEF7VMTAjs.MemoryRouter; exports.Meta = _chunkIEF7VMTAjs.Meta; exports.NavLink = _chunkWICLSFKLjs.NavLink; exports.Navigate = _chunkIEF7VMTAjs.Navigate; exports.Outlet = _chunkIEF7VMTAjs.Outlet; exports.Route = _chunkIEF7VMTAjs.Route; exports.Router = _chunkIEF7VMTAjs.Router; exports.RouterProvider = _chunkIEF7VMTAjs.RouterProvider; exports.Routes = _chunkIEF7VMTAjs.Routes; exports.ScrollRestoration = _chunkWICLSFKLjs.ScrollRestoration; exports.StaticRouter = _chunkWICLSFKLjs.StaticRouter; exports.StaticRouterProvider = _chunkWICLSFKLjs.StaticRouterProvider; exports.UNSAFE_AwaitContextProvider = _chunkIEF7VMTAjs.AwaitContextProvider; exports.UNSAFE_WithComponentProps = _chunkIEF7VMTAjs.WithComponentProps; exports.UNSAFE_WithErrorBoundaryProps = _chunkIEF7VMTAjs.WithErrorBoundaryProps; exports.UNSAFE_WithHydrateFallbackProps = _chunkIEF7VMTAjs.WithHydrateFallbackProps; exports.unstable_HistoryRouter = _chunkWICLSFKLjs.HistoryRouter;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.17.0
2
+ * react-router v7.18.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -32,7 +32,7 @@ import {
32
32
  WithComponentProps,
33
33
  WithErrorBoundaryProps,
34
34
  WithHydrateFallbackProps
35
- } from "./chunk-OSYEOCBT.mjs";
35
+ } from "./chunk-3WDNQUW5.mjs";
36
36
  export {
37
37
  BrowserRouter,
38
38
  Form,
@@ -845,6 +845,8 @@ interface RouteMeta<RouteObjectType extends RouteObject = RouteObject> {
845
845
  caseSensitive: boolean;
846
846
  childrenIndex: number;
847
847
  route: RouteObjectType;
848
+ matcher?: RegExp;
849
+ compiledParams?: CompiledPathParam[];
848
850
  }
849
851
  /**
850
852
  * @private
@@ -858,6 +860,10 @@ interface RouteBranch<RouteObjectType extends RouteObject = RouteObject> {
858
860
  score: number;
859
861
  routesMeta: RouteMeta<RouteObjectType>[];
860
862
  }
863
+ type CompiledPathParam = {
864
+ paramName: string;
865
+ isOptional?: boolean;
866
+ };
861
867
  declare class DataWithResponseInit<D> {
862
868
  type: string;
863
869
  data: D;
@@ -1837,7 +1843,9 @@ interface PageLinkDescriptor extends Omit<HtmlLinkDescriptor, "href" | "rel" | "
1837
1843
  /**
1838
1844
  * A [`nonce`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/nonce)
1839
1845
  * attribute to render on the [`<link>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link)
1840
- * element
1846
+ * element. If not provided in Framework Mode, it will default to any
1847
+ * {@link ServerRouter | `<ServerRouter nonce>`} prop.
1848
+
1841
1849
  */
1842
1850
  nonce?: string | undefined;
1843
1851
  /**
@@ -845,6 +845,8 @@ interface RouteMeta<RouteObjectType extends RouteObject = RouteObject> {
845
845
  caseSensitive: boolean;
846
846
  childrenIndex: number;
847
847
  route: RouteObjectType;
848
+ matcher?: RegExp;
849
+ compiledParams?: CompiledPathParam[];
848
850
  }
849
851
  /**
850
852
  * @private
@@ -858,6 +860,10 @@ interface RouteBranch<RouteObjectType extends RouteObject = RouteObject> {
858
860
  score: number;
859
861
  routesMeta: RouteMeta<RouteObjectType>[];
860
862
  }
863
+ type CompiledPathParam = {
864
+ paramName: string;
865
+ isOptional?: boolean;
866
+ };
861
867
  declare class DataWithResponseInit<D> {
862
868
  type: string;
863
869
  data: D;
@@ -1837,7 +1843,9 @@ interface PageLinkDescriptor extends Omit<HtmlLinkDescriptor, "href" | "rel" | "
1837
1843
  /**
1838
1844
  * A [`nonce`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/nonce)
1839
1845
  * attribute to render on the [`<link>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link)
1840
- * element
1846
+ * element. If not provided in Framework Mode, it will default to any
1847
+ * {@link ServerRouter | `<ServerRouter nonce>`} prop.
1848
+
1841
1849
  */
1842
1850
  nonce?: string | undefined;
1843
1851
  /**
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var node_async_hooks = require('node:async_hooks');
4
- var React2 = require('react');
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 React2__namespace = /*#__PURE__*/_interopNamespace(React2);
27
+ var React3__namespace = /*#__PURE__*/_interopNamespace(React3);
28
28
 
29
29
  /**
30
- * react-router v7.17.0
30
+ * react-router v7.18.1
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 match = matchPath(
595
- { path: meta.relativePath, caseSensitive: meta.caseSensitive, end },
596
- remainingPathname
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,6 +658,9 @@ 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];
@@ -722,7 +749,6 @@ function prependBasename({
722
749
  }) {
723
750
  return pathname === "/" ? basename : joinPaths([basename, pathname]);
724
751
  }
725
- var ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
726
752
  var isAbsoluteUrl = (url) => ABSOLUTE_URL_REGEX.test(url);
727
753
  function resolvePath(to, fromPathname = "/") {
728
754
  let {
@@ -819,7 +845,7 @@ function resolveTo(toArg, routePathnames, locationPathname, isPathRelative = fal
819
845
  }
820
846
  return path;
821
847
  }
822
- var removeDoubleSlashes = (path) => path.replace(/\/\/+/g, "/");
848
+ var removeDoubleSlashes = (path) => path.replace(/[\\/]{2,}/g, "/");
823
849
  var joinPaths = (paths) => removeDoubleSlashes(paths.join("/"));
824
850
  var removeTrailingSlash = (path) => path.replace(/\/+$/, "");
825
851
  var normalizePathname = (pathname) => removeTrailingSlash(pathname).replace(/^\/*/, "/");
@@ -2469,9 +2495,71 @@ function prependCookies(parentHeaders, childHeaders) {
2469
2495
  }
2470
2496
  var SINGLE_FETCH_REDIRECT_STATUS = 202;
2471
2497
 
2498
+ // lib/server-runtime/warnings.ts
2499
+ var alreadyWarned = {};
2500
+ function warnOnce(condition, message) {
2501
+ if (!condition && !alreadyWarned[message]) {
2502
+ alreadyWarned[message] = true;
2503
+ console.warn(message);
2504
+ }
2505
+ }
2506
+
2507
+ // lib/errors.ts
2508
+ var ERROR_DIGEST_BASE = "REACT_ROUTER_ERROR";
2509
+ var ERROR_DIGEST_REDIRECT = "REDIRECT";
2510
+ var ERROR_DIGEST_ROUTE_ERROR_RESPONSE = "ROUTE_ERROR_RESPONSE";
2511
+ function createRedirectErrorDigest(response) {
2512
+ return `${ERROR_DIGEST_BASE}:${ERROR_DIGEST_REDIRECT}:${JSON.stringify({
2513
+ status: response.status,
2514
+ statusText: response.statusText,
2515
+ location: response.headers.get("Location"),
2516
+ reloadDocument: response.headers.get("X-Remix-Reload-Document") === "true",
2517
+ replace: response.headers.get("X-Remix-Replace") === "true"
2518
+ })}`;
2519
+ }
2520
+ function createRouteErrorResponseDigest(response) {
2521
+ let status = 500;
2522
+ let statusText = "";
2523
+ let data2;
2524
+ if (isDataWithResponseInit(response)) {
2525
+ status = response.init?.status ?? status;
2526
+ statusText = response.init?.statusText ?? statusText;
2527
+ data2 = response.data;
2528
+ } else {
2529
+ status = response.status;
2530
+ statusText = response.statusText;
2531
+ data2 = void 0;
2532
+ }
2533
+ return `${ERROR_DIGEST_BASE}:${ERROR_DIGEST_ROUTE_ERROR_RESPONSE}:${JSON.stringify(
2534
+ {
2535
+ status,
2536
+ statusText,
2537
+ data: data2
2538
+ }
2539
+ )}`;
2540
+ }
2541
+
2542
+ // lib/dom/ssr/fog-of-war.ts
2543
+ var URL_LIMIT = 7680;
2544
+ function getPathsWithAncestors(paths) {
2545
+ let result = /* @__PURE__ */ new Set();
2546
+ paths.forEach((path) => {
2547
+ if (!path.startsWith("/")) {
2548
+ path = `/${path}`;
2549
+ }
2550
+ for (let i = 1; i < path.length; i++) {
2551
+ if (path[i] === "/") {
2552
+ result.add(path.slice(0, i));
2553
+ }
2554
+ }
2555
+ result.add(path);
2556
+ });
2557
+ return Array.from(result);
2558
+ }
2559
+
2472
2560
  // lib/actions.ts
2473
- function throwIfPotentialCSRFAttack(headers, allowedActionOrigins) {
2474
- let originHeader = headers.get("origin");
2561
+ function throwIfPotentialCSRFAttack(request, allowedActionOrigins) {
2562
+ let originHeader = request.headers.get("origin");
2475
2563
  let originDomain = null;
2476
2564
  try {
2477
2565
  originDomain = typeof originHeader === "string" && originHeader !== "null" ? new URL(originHeader).host : originHeader;
@@ -2480,18 +2568,12 @@ function throwIfPotentialCSRFAttack(headers, allowedActionOrigins) {
2480
2568
  `\`origin\` header is not a valid URL. Aborting the action.`
2481
2569
  );
2482
2570
  }
2483
- let host = parseHostHeader(headers);
2484
- if (originDomain && (!host || originDomain !== host.value)) {
2571
+ let host = new URL(request.url).host;
2572
+ if (originDomain && originDomain !== host) {
2485
2573
  if (!isAllowedOrigin(originDomain, allowedActionOrigins)) {
2486
- if (host) {
2487
- throw new Error(
2488
- `${host.type} header does not match \`origin\` header from a forwarded action request. Aborting the action.`
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
- }
2574
+ throw new Error(
2575
+ "The `request.url` host does not match `origin` header from a forwarded action request. Aborting the action."
2576
+ );
2495
2577
  }
2496
2578
  }
2497
2579
  }
@@ -2539,53 +2621,6 @@ function isAllowedOrigin(originDomain, allowedActionOrigins = []) {
2539
2621
  (allowedOrigin) => allowedOrigin && (allowedOrigin === originDomain || matchWildcardDomain(originDomain, allowedOrigin))
2540
2622
  );
2541
2623
  }
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
2624
 
2590
2625
  // lib/server-runtime/urls.ts
2591
2626
  function getNormalizedPath(request, basename, future) {
@@ -2657,7 +2692,7 @@ var replace2 = (...args) => {
2657
2692
  };
2658
2693
  var cachedResolvePromise = (
2659
2694
  // @ts-expect-error - on 18 types, requires 19.
2660
- React2__namespace.cache(async (resolve) => {
2695
+ React3__namespace.cache(async (resolve) => {
2661
2696
  return Promise.allSettled([resolve]).then((r) => r[0]);
2662
2697
  })
2663
2698
  );
@@ -2672,13 +2707,13 @@ var Await = async ({
2672
2707
  throw resolved.reason;
2673
2708
  }
2674
2709
  if (resolved.status === "rejected") {
2675
- return React2__namespace.createElement(reactServerClient.UNSAFE_AwaitContextProvider, {
2676
- children: React2__namespace.createElement(React2__namespace.Fragment, null, errorElement),
2710
+ return React3__namespace.createElement(reactServerClient.UNSAFE_AwaitContextProvider, {
2711
+ children: React3__namespace.createElement(React3__namespace.Fragment, null, errorElement),
2677
2712
  value: { _tracked: true, _error: resolved.reason }
2678
2713
  });
2679
2714
  }
2680
2715
  const toRender = typeof children === "function" ? children(resolved.value) : children;
2681
- return React2__namespace.createElement(reactServerClient.UNSAFE_AwaitContextProvider, {
2716
+ return React3__namespace.createElement(reactServerClient.UNSAFE_AwaitContextProvider, {
2682
2717
  children: toRender,
2683
2718
  value: { _tracked: true, _data: resolved.value }
2684
2719
  });
@@ -2767,6 +2802,13 @@ async function matchRSCServerRequest({
2767
2802
  return response;
2768
2803
  }
2769
2804
  async function generateManifestResponse(routes, basename, request, generateResponse, temporaryReferences, routeDiscovery) {
2805
+ let url = new URL(request.url);
2806
+ if (url.toString().length > URL_LIMIT) {
2807
+ return new Response(null, {
2808
+ statusText: "Bad Request",
2809
+ status: 400
2810
+ });
2811
+ }
2770
2812
  if (routeDiscovery?.mode === "initial") {
2771
2813
  let payload2 = {
2772
2814
  type: "manifest",
@@ -2784,7 +2826,6 @@ async function generateManifestResponse(routes, basename, request, generateRespo
2784
2826
  { temporaryReferences, onError: defaultOnError }
2785
2827
  );
2786
2828
  }
2787
- let url = new URL(request.url);
2788
2829
  let pathParam = url.searchParams.get("paths");
2789
2830
  let pathnames = pathParam ? pathParam.split(",").filter(Boolean) : [url.pathname.replace(/\.manifest$/, "")];
2790
2831
  let routeIds = /* @__PURE__ */ new Set();
@@ -2987,7 +3028,7 @@ async function generateRenderResponse(request, routes, basename, isDataRequest,
2987
3028
  let potentialCSRFAttackError;
2988
3029
  if (isMutationMethod(request.method)) {
2989
3030
  try {
2990
- throwIfPotentialCSRFAttack(request.headers, allowedActionOrigins);
3031
+ throwIfPotentialCSRFAttack(request, allowedActionOrigins);
2991
3032
  ctx.runningAction = true;
2992
3033
  let result2 = await processServerAction(
2993
3034
  request,
@@ -3215,7 +3256,7 @@ async function getRenderPayload(baseRenderPayload, routes, basename, routeIdsToL
3215
3256
  (patch) => !staticContext.matches.some((m) => m.route.id === patch.id)
3216
3257
  )
3217
3258
  ) : getAdditionalRoutePatches(
3218
- [staticContext.location.pathname],
3259
+ getPathsWithAncestors([staticContext.location.pathname]),
3219
3260
  routes,
3220
3261
  basename,
3221
3262
  staticContext.matches.map((m) => m.route.id)
@@ -3235,7 +3276,7 @@ async function getRSCRouteMatch({
3235
3276
  }) {
3236
3277
  const route = match.route;
3237
3278
  await explodeLazyRoute(route);
3238
- const Layout = route.Layout || React2__namespace.Fragment;
3279
+ const Layout = route.Layout || React3__namespace.Fragment;
3239
3280
  const Component = route.Component;
3240
3281
  const ErrorBoundary = route.ErrorBoundary;
3241
3282
  const HydrateFallback = route.HydrateFallback;
@@ -3245,12 +3286,12 @@ async function getRSCRouteMatch({
3245
3286
  let element = void 0;
3246
3287
  let shouldLoadRoute = !routeIdsToLoad || routeIdsToLoad.includes(route.id);
3247
3288
  if (Component && shouldLoadRoute) {
3248
- element = !isBelowErrorBoundary ? React2__namespace.createElement(
3289
+ element = !isBelowErrorBoundary ? React3__namespace.createElement(
3249
3290
  Layout,
3250
3291
  null,
3251
- isClientReference(Component) ? React2__namespace.createElement(WithComponentProps, {
3252
- children: React2__namespace.createElement(Component)
3253
- }) : React2__namespace.createElement(Component, {
3292
+ isClientReference(Component) ? React3__namespace.createElement(WithComponentProps, {
3293
+ children: React3__namespace.createElement(Component)
3294
+ }) : React3__namespace.createElement(Component, {
3254
3295
  loaderData,
3255
3296
  actionData,
3256
3297
  params,
@@ -3258,30 +3299,30 @@ async function getRSCRouteMatch({
3258
3299
  (match2) => convertRouteMatchToUiMatch(match2, staticContext.loaderData)
3259
3300
  )
3260
3301
  })
3261
- ) : React2__namespace.createElement(Outlet);
3302
+ ) : React3__namespace.createElement(Outlet);
3262
3303
  }
3263
3304
  let error = void 0;
3264
3305
  if (ErrorBoundary && staticContext.errors) {
3265
3306
  error = staticContext.errors[route.id];
3266
3307
  }
3267
- const errorElement = ErrorBoundary ? React2__namespace.createElement(
3308
+ const errorElement = ErrorBoundary ? React3__namespace.createElement(
3268
3309
  Layout,
3269
3310
  null,
3270
- isClientReference(ErrorBoundary) ? React2__namespace.createElement(WithErrorBoundaryProps, {
3271
- children: React2__namespace.createElement(ErrorBoundary)
3272
- }) : React2__namespace.createElement(ErrorBoundary, {
3311
+ isClientReference(ErrorBoundary) ? React3__namespace.createElement(WithErrorBoundaryProps, {
3312
+ children: React3__namespace.createElement(ErrorBoundary)
3313
+ }) : React3__namespace.createElement(ErrorBoundary, {
3273
3314
  loaderData,
3274
3315
  actionData,
3275
3316
  params,
3276
3317
  error
3277
3318
  })
3278
3319
  ) : void 0;
3279
- const hydrateFallbackElement = HydrateFallback ? React2__namespace.createElement(
3320
+ const hydrateFallbackElement = HydrateFallback ? React3__namespace.createElement(
3280
3321
  Layout,
3281
3322
  null,
3282
- isClientReference(HydrateFallback) ? React2__namespace.createElement(WithHydrateFallbackProps, {
3283
- children: React2__namespace.createElement(HydrateFallback)
3284
- }) : React2__namespace.createElement(HydrateFallback, {
3323
+ isClientReference(HydrateFallback) ? React3__namespace.createElement(WithHydrateFallbackProps, {
3324
+ children: React3__namespace.createElement(HydrateFallback)
3325
+ }) : React3__namespace.createElement(HydrateFallback, {
3285
3326
  loaderData,
3286
3327
  actionData,
3287
3328
  params
@@ -3318,11 +3359,11 @@ async function getRSCRouteMatch({
3318
3359
  }
3319
3360
  async function getManifestRoute(route) {
3320
3361
  await explodeLazyRoute(route);
3321
- const Layout = route.Layout || React2__namespace.Fragment;
3322
- const errorElement = route.ErrorBoundary ? React2__namespace.createElement(
3362
+ const Layout = route.Layout || React3__namespace.Fragment;
3363
+ const errorElement = route.ErrorBoundary ? React3__namespace.createElement(
3323
3364
  Layout,
3324
3365
  null,
3325
- React2__namespace.createElement(route.ErrorBoundary)
3366
+ React3__namespace.createElement(route.ErrorBoundary)
3326
3367
  ) : void 0;
3327
3368
  return {
3328
3369
  clientAction: route.clientAction,
@@ -3380,27 +3421,18 @@ async function getAdditionalRoutePatches(pathnames, routes, basename, matchedRou
3380
3421
  let patchRouteMatches = /* @__PURE__ */ new Map();
3381
3422
  let matchedPaths = /* @__PURE__ */ new Set();
3382
3423
  for (const pathname of pathnames) {
3383
- let segments = pathname.split("/").filter(Boolean);
3384
- let paths = ["/"];
3385
- segments.pop();
3386
- while (segments.length > 0) {
3387
- paths.push(`/${segments.join("/")}`);
3388
- segments.pop();
3389
- }
3390
- paths.forEach((path) => {
3391
- if (matchedPaths.has(path)) {
3424
+ if (matchedPaths.has(pathname)) {
3425
+ continue;
3426
+ }
3427
+ matchedPaths.add(pathname);
3428
+ let matches = matchRoutes(routes, pathname, basename) || [];
3429
+ matches.forEach((m, i) => {
3430
+ if (patchRouteMatches.get(m.route.id)) {
3392
3431
  return;
3393
3432
  }
3394
- matchedPaths.add(path);
3395
- let matches = matchRoutes(routes, path, basename) || [];
3396
- matches.forEach((m, i) => {
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
- });
3433
+ patchRouteMatches.set(m.route.id, {
3434
+ ...m.route,
3435
+ parentId: matches[i - 1]?.route.id
3404
3436
  });
3405
3437
  });
3406
3438
  }
@@ -3512,15 +3544,6 @@ function byteStringToUint8Array(byteString) {
3512
3544
  return array;
3513
3545
  }
3514
3546
 
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
3547
  // lib/server-runtime/cookies.ts
3525
3548
  var createCookie = (name, cookieOptions = {}) => {
3526
3549
  let { secrets = [], ...options } = {