react-router 8.5.2 → 8.5.3

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 (158) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/dist/development/dom-export.js +1 -1
  3. package/dist/development/index-react-server-client.js +1 -1
  4. package/dist/development/index-react-server.d.ts +3 -2
  5. package/dist/development/index-react-server.js +41 -36
  6. package/dist/development/index.js +1 -1
  7. package/dist/development/lib/actions.js +1 -1
  8. package/dist/development/lib/await.js +1 -1
  9. package/dist/development/lib/components.js +10 -8
  10. package/dist/development/lib/context.js +3 -2
  11. package/dist/development/lib/dom/dom.js +4 -2
  12. package/dist/development/lib/dom/lib.js +12 -5
  13. package/dist/development/lib/dom/server.js +5 -3
  14. package/dist/development/lib/dom/ssr/components.js +4 -1
  15. package/dist/development/lib/dom/ssr/data.js +1 -1
  16. package/dist/development/lib/dom/ssr/errorBoundaries.js +2 -1
  17. package/dist/development/lib/dom/ssr/fallback.js +2 -1
  18. package/dist/development/lib/dom/ssr/fog-of-war.js +1 -1
  19. package/dist/development/lib/dom/ssr/hydration.js +1 -1
  20. package/dist/development/lib/dom/ssr/invariant.js +1 -1
  21. package/dist/development/lib/dom/ssr/links.js +1 -1
  22. package/dist/development/lib/dom/ssr/markup.js +1 -1
  23. package/dist/development/lib/dom/ssr/route-discovery.js +1 -1
  24. package/dist/development/lib/dom/ssr/routeModules.js +1 -1
  25. package/dist/development/lib/dom/ssr/routes-test-stub.js +3 -1
  26. package/dist/development/lib/dom/ssr/routes.js +2 -1
  27. package/dist/development/lib/dom/ssr/server.js +1 -1
  28. package/dist/development/lib/dom/ssr/single-fetch.js +1 -1
  29. package/dist/development/lib/dom-export/dom-router-provider.js +1 -1
  30. package/dist/development/lib/dom-export/hydrated-router.js +1 -1
  31. package/dist/development/lib/errors.js +1 -1
  32. package/dist/development/lib/hooks.d.ts +30 -0
  33. package/dist/development/lib/hooks.js +39 -5
  34. package/dist/development/lib/href.js +1 -1
  35. package/dist/development/lib/router/history.js +10 -4
  36. package/dist/development/lib/router/instrumentation.js +1 -1
  37. package/dist/development/lib/router/matcher-route-pattern.js +1 -1
  38. package/dist/development/lib/router/matcher-route-pattern.preload.js +1 -1
  39. package/dist/development/lib/router/matcher.js +1 -1
  40. package/dist/development/lib/router/navigation.js +1 -1
  41. package/dist/development/lib/router/router.js +22 -8
  42. package/dist/development/lib/router/url.js +1 -1
  43. package/dist/development/lib/router/utils.d.ts +2 -0
  44. package/dist/development/lib/router/utils.js +8 -2
  45. package/dist/development/lib/rsc/browser.js +2 -2
  46. package/dist/development/lib/rsc/errorBoundaries.js +3 -2
  47. package/dist/development/lib/rsc/html-stream/browser.js +1 -1
  48. package/dist/development/lib/rsc/html-stream/server.js +1 -1
  49. package/dist/development/lib/rsc/route-modules.js +1 -1
  50. package/dist/development/lib/rsc/server.rsc.d.ts +2 -1
  51. package/dist/development/lib/rsc/server.ssr.d.ts +1 -0
  52. package/dist/development/lib/rsc/server.ssr.js +5 -4
  53. package/dist/development/lib/server-runtime/cookies.js +1 -1
  54. package/dist/development/lib/server-runtime/crypto.js +1 -1
  55. package/dist/development/lib/server-runtime/data.js +1 -1
  56. package/dist/development/lib/server-runtime/dev.js +1 -1
  57. package/dist/development/lib/server-runtime/entry.js +1 -1
  58. package/dist/development/lib/server-runtime/errors.js +1 -1
  59. package/dist/development/lib/server-runtime/headers.js +1 -1
  60. package/dist/development/lib/server-runtime/invariant.js +1 -1
  61. package/dist/development/lib/server-runtime/mode.js +1 -1
  62. package/dist/development/lib/server-runtime/routeMatching.js +1 -1
  63. package/dist/development/lib/server-runtime/routes.js +1 -1
  64. package/dist/development/lib/server-runtime/server.js +1 -1
  65. package/dist/development/lib/server-runtime/serverHandoff.js +1 -1
  66. package/dist/development/lib/server-runtime/sessions/cookieStorage.js +3 -2
  67. package/dist/development/lib/server-runtime/sessions/memoryStorage.js +1 -1
  68. package/dist/development/lib/server-runtime/sessions.d.ts +1 -1
  69. package/dist/development/lib/server-runtime/sessions.js +5 -3
  70. package/dist/development/lib/server-runtime/single-fetch.js +1 -1
  71. package/dist/development/lib/server-runtime/urls.js +1 -1
  72. package/dist/development/lib/server-runtime/warnings.js +1 -1
  73. package/dist/development/lib/types/internal.js +1 -1
  74. package/dist/development/lib/types/route-module-annotations.d.ts +16 -9
  75. package/dist/development/route-pattern.js +1 -1
  76. package/dist/development/vendor/turbo-stream-v2/flatten.js +1 -1
  77. package/dist/development/vendor/turbo-stream-v2/turbo-stream.js +9 -8
  78. package/dist/development/vendor/turbo-stream-v2/unflatten.js +1 -1
  79. package/dist/development/vendor/turbo-stream-v2/utils.js +1 -1
  80. package/dist/production/dom-export.js +1 -1
  81. package/dist/production/index-react-server-client.js +1 -1
  82. package/dist/production/index-react-server.d.ts +3 -2
  83. package/dist/production/index-react-server.js +41 -36
  84. package/dist/production/index.js +1 -1
  85. package/dist/production/lib/actions.js +1 -1
  86. package/dist/production/lib/await.js +1 -1
  87. package/dist/production/lib/components.js +10 -8
  88. package/dist/production/lib/context.js +3 -2
  89. package/dist/production/lib/dom/dom.js +4 -2
  90. package/dist/production/lib/dom/lib.js +12 -5
  91. package/dist/production/lib/dom/server.js +5 -3
  92. package/dist/production/lib/dom/ssr/components.js +4 -1
  93. package/dist/production/lib/dom/ssr/data.js +1 -1
  94. package/dist/production/lib/dom/ssr/errorBoundaries.js +2 -1
  95. package/dist/production/lib/dom/ssr/fallback.js +1 -1
  96. package/dist/production/lib/dom/ssr/fog-of-war.js +1 -1
  97. package/dist/production/lib/dom/ssr/hydration.js +1 -1
  98. package/dist/production/lib/dom/ssr/invariant.js +1 -1
  99. package/dist/production/lib/dom/ssr/links.js +1 -1
  100. package/dist/production/lib/dom/ssr/markup.js +1 -1
  101. package/dist/production/lib/dom/ssr/route-discovery.js +1 -1
  102. package/dist/production/lib/dom/ssr/routeModules.js +1 -1
  103. package/dist/production/lib/dom/ssr/routes-test-stub.js +3 -1
  104. package/dist/production/lib/dom/ssr/routes.js +2 -1
  105. package/dist/production/lib/dom/ssr/server.js +1 -1
  106. package/dist/production/lib/dom/ssr/single-fetch.js +1 -1
  107. package/dist/production/lib/dom-export/dom-router-provider.js +1 -1
  108. package/dist/production/lib/dom-export/hydrated-router.js +1 -1
  109. package/dist/production/lib/errors.js +1 -1
  110. package/dist/production/lib/hooks.d.ts +30 -0
  111. package/dist/production/lib/hooks.js +38 -4
  112. package/dist/production/lib/href.js +1 -1
  113. package/dist/production/lib/router/history.js +10 -4
  114. package/dist/production/lib/router/instrumentation.js +1 -1
  115. package/dist/production/lib/router/matcher-route-pattern.js +1 -1
  116. package/dist/production/lib/router/matcher-route-pattern.preload.js +1 -1
  117. package/dist/production/lib/router/matcher.js +1 -1
  118. package/dist/production/lib/router/navigation.js +1 -1
  119. package/dist/production/lib/router/router.js +22 -8
  120. package/dist/production/lib/router/url.js +1 -1
  121. package/dist/production/lib/router/utils.d.ts +2 -0
  122. package/dist/production/lib/router/utils.js +8 -2
  123. package/dist/production/lib/rsc/browser.js +2 -2
  124. package/dist/production/lib/rsc/errorBoundaries.js +3 -2
  125. package/dist/production/lib/rsc/html-stream/browser.js +1 -1
  126. package/dist/production/lib/rsc/html-stream/server.js +1 -1
  127. package/dist/production/lib/rsc/route-modules.js +1 -1
  128. package/dist/production/lib/rsc/server.rsc.d.ts +2 -1
  129. package/dist/production/lib/rsc/server.ssr.d.ts +1 -0
  130. package/dist/production/lib/rsc/server.ssr.js +5 -4
  131. package/dist/production/lib/server-runtime/cookies.js +1 -1
  132. package/dist/production/lib/server-runtime/crypto.js +1 -1
  133. package/dist/production/lib/server-runtime/data.js +1 -1
  134. package/dist/production/lib/server-runtime/dev.js +1 -1
  135. package/dist/production/lib/server-runtime/entry.js +1 -1
  136. package/dist/production/lib/server-runtime/errors.js +1 -1
  137. package/dist/production/lib/server-runtime/headers.js +1 -1
  138. package/dist/production/lib/server-runtime/invariant.js +1 -1
  139. package/dist/production/lib/server-runtime/mode.js +1 -1
  140. package/dist/production/lib/server-runtime/routeMatching.js +1 -1
  141. package/dist/production/lib/server-runtime/routes.js +1 -1
  142. package/dist/production/lib/server-runtime/server.js +1 -1
  143. package/dist/production/lib/server-runtime/serverHandoff.js +1 -1
  144. package/dist/production/lib/server-runtime/sessions/cookieStorage.js +3 -2
  145. package/dist/production/lib/server-runtime/sessions/memoryStorage.js +1 -1
  146. package/dist/production/lib/server-runtime/sessions.d.ts +1 -1
  147. package/dist/production/lib/server-runtime/sessions.js +5 -3
  148. package/dist/production/lib/server-runtime/single-fetch.js +1 -1
  149. package/dist/production/lib/server-runtime/urls.js +1 -1
  150. package/dist/production/lib/server-runtime/warnings.js +1 -1
  151. package/dist/production/lib/types/internal.js +1 -1
  152. package/dist/production/lib/types/route-module-annotations.d.ts +16 -9
  153. package/dist/production/route-pattern.js +1 -1
  154. package/dist/production/vendor/turbo-stream-v2/flatten.js +1 -1
  155. package/dist/production/vendor/turbo-stream-v2/turbo-stream.js +9 -8
  156. package/dist/production/vendor/turbo-stream-v2/unflatten.js +1 -1
  157. package/dist/production/vendor/turbo-stream-v2/utils.js +1 -1
  158. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,55 @@
1
1
  # `react-router`
2
2
 
3
+ ## v8.5.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Forward all `NavigateOptions` from `<RouterProvider>`'s `navigator.push()` and `navigator.replace()` to `router.navigate()` ([#15781](https://github.com/remix-run/react-router/pull/15781))
8
+ - Options such as `mask`, `defaultShouldRevalidate`, `flushSync`, and `viewTransition` now reach the router from `<Link>`, `useNavigate()`, and `useSearchParams()` inside descendant `<Routes>` in Data and Framework modes
9
+ - Prevent fetcher action revalidation from completing a navigation with stale route matches while lazy route discovery is pending ([#15731](https://github.com/remix-run/react-router/pull/15731))
10
+ - Fix a circular type error when arrow function route components access `matches` from `Route.ComponentProps` ([#15163](https://github.com/remix-run/react-router/pull/15163))
11
+ - Use the current route's `loaderData` type directly so TypeScript can resolve `matches` without evaluating the component's own props again
12
+ - Fix `useBlocker` blocking a second time when the destination route updates search params in a mount effect ([#15538](https://github.com/remix-run/react-router/pull/15538))
13
+ - Read `encType` and `formEncType` case-insensitively in `<Form>` and `useSubmit` ([#15776](https://github.com/remix-run/react-router/pull/15776))
14
+ - Submit `Multipart/Form-Data` as `multipart/form-data`
15
+ - Restore the router location of a masked hash history entry on back and forward navigation ([#15771](https://github.com/remix-run/react-router/pull/15771))
16
+ - Prevent `<HydratedRouter>` from re-rendering the previous route during navigation ([#15823](https://github.com/remix-run/react-router/pull/15823))
17
+ - Avoid a loop with `<Navigate state={...} replace>` that could exceed Safari's limit on `history.replaceState()` calls
18
+ - Keep the current route's `actionData` while a submission to another route is loading ([#15716](https://github.com/remix-run/react-router/pull/15716))
19
+ - Reject excessively large optional route path combinations in `matchPath`. Each pattern may contain up to 12 optional (`?`) markers. ([#15827](https://github.com/remix-run/react-router/pull/15827))
20
+ - Let the browser handle clicks on links with a `download` attribute ([#15815](https://github.com/remix-run/react-router/pull/15815))
21
+ - Apply this behavior to `<Link download>` and custom links built with `useLinkClickHandler`
22
+ - Suppress nonce hydration warnings when using `<ServerRouter nonce>` ([#15721](https://github.com/remix-run/react-router/pull/15721))
23
+ - Cover critical CSS and HTML link descriptors rendered by `<Links>`
24
+ - Cover developer scripts rendered by the default root error boundary and hydrate fallback
25
+ - Fix blocked back/forward navigations in a memory router landing on the wrong history entry when the requested delta goes past the first or last entry ([#15779](https://github.com/remix-run/react-router/pull/15779))
26
+ - Preserve `caseSensitive` on client routes in Framework Mode and `createRoutesStub()` ([#15808](https://github.com/remix-run/react-router/pull/15808))
27
+ - Forward `route.caseSensitive` in `createClientRoutes()` so client hydration, client-side navigation, lazy route discovery, and HMR match `createServerRoutes()` and `createStaticHandlerDataRoutes()`
28
+ - Forward `route.caseSensitive` in `createRoutesStub()`
29
+ - Preserve loader data for the current routes when a background fetcher finishes during a navigation ([#15806](https://github.com/remix-run/react-router/pull/15806))
30
+ - Keep layout content visible when the navigation reuses that data
31
+ - Discard invalid persisted scroll positions so new positions can be saved when the page is hidden ([#15794](https://github.com/remix-run/react-router/pull/15794))
32
+ - Fix `session.unset()` to remove both regular and flashed values for the given key ([#15811](https://github.com/remix-run/react-router/pull/15811))
33
+ - Accept flash-only keys in typed sessions
34
+ - Keep `NavLink` inactive in the prerendered Framework SPA fallback and set its active state from the browser URL after hydration ([#15818](https://github.com/remix-run/react-router/pull/15818))
35
+ - Handle leading double slashes in static router `encodeLocation()` ([#15805](https://github.com/remix-run/react-router/pull/15805))
36
+ - Prevent `TypeError: Invalid URL` during SSR in `<ServerRouter>`, `<StaticRouterProvider>`, and `<StaticRouter>`, including when rendering query-only or hash-only `<NavLink>` destinations on double-slash request URLs
37
+ - Fix unhandled single-fetch stream completion rejections while preserving errors for callers awaiting completion or deferred values ([#15765](https://github.com/remix-run/react-router/pull/15765))
38
+ - Treat session cookies with an invalid payload shape as empty sessions ([#15809](https://github.com/remix-run/react-router/pull/15809))
39
+ - Pass only nonempty string session IDs to storage adapters
40
+ - Accept only non-array objects as data for cookie-backed sessions
41
+
42
+ ### Unstable Changes
43
+
44
+ ⚠️ _[Unstable features](https://reactrouter.com/community/api-development-strategy#unstable-flags) are not recommended for production use_
45
+
46
+ - Report RSC loader, action, and middleware errors through `unstable_matchRSCServerRequest`'s `onError` handler ([#15598](https://github.com/remix-run/react-router/pull/15598))
47
+ - Log request errors with `console.error` by default unless the request was aborted
48
+ - Report middleware errors that occur after a form action consumes the request body
49
+ - Avoid duplicate logging when rendering the default error boundary during SSR in RSC Data and RSC Framework modes
50
+ - Avoid false 404s in RSC Framework and RSC Data modes when navigating while eager route discovery is still streaming route definitions ([#15801](https://github.com/remix-run/react-router/pull/15801))
51
+ - Improve handling of invalid requests in RSC Framework and RSC Data modes ([#15828](https://github.com/remix-run/react-router/pull/15828))
52
+
3
53
  ## v8.5.2
4
54
 
5
55
  ### Patch Changes
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.2
2
+ * react-router v8.5.3
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.2
2
+ * react-router v8.5.3
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -2504,7 +2504,8 @@ type RouteDiscovery = {
2504
2504
  * @param opts.clientVersion A version derived from the client build output used
2505
2505
  * to detect stale clients during lazy route discovery.
2506
2506
  * @param opts.onError An optional error handler that will be called with any
2507
- * errors that occur during the request processing.
2507
+ * errors that occur during the request processing. Defaults to logging errors
2508
+ * with `console.error` unless the request was aborted.
2508
2509
  * @param opts.request The [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
2509
2510
  * to match against.
2510
2511
  * @param opts.requestContext An instance of {@link RouterContextProvider}
@@ -2737,7 +2738,7 @@ interface Session<Data = SessionData, FlashData = Data> {
2737
2738
  /**
2738
2739
  * Removes a value from the session.
2739
2740
  */
2740
- unset(name: keyof Data & string): void;
2741
+ unset(name: (keyof Data | keyof FlashData) & string): void;
2741
2742
  }
2742
2743
  type FlashSessionData<Data, FlashData> = Partial<Data & { [Key in keyof FlashData as FlashDataKey<Key & string>]: FlashData[Key] }>;
2743
2744
  type FlashDataKey<Key extends string> = `__flash_${Key}__`;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.2
2
+ * react-router v8.5.3
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -530,10 +530,13 @@ const PATH_PARAM_OVERESCAPED = {
530
530
  function encodePathParam(value) {
531
531
  return encodeURIComponent(value).replace(/%(?:24|26|2B|2C|3A|3B|3D|40)/g, (match) => PATH_PARAM_OVERESCAPED[match]);
532
532
  }
533
+ const MAX_OPTIONAL_PATH_SEGMENTS = 12;
533
534
  /**
534
535
  * Performs pattern matching on a URL pathname and returns information about
535
536
  * the match.
536
537
  *
538
+ * Throws if the pattern contains more than 12 optional (`?`) markers.
539
+ *
537
540
  * @public
538
541
  * @category Utils
539
542
  * @param pattern The pattern to match against the URL pathname. This can be a
@@ -550,7 +553,10 @@ function matchPath(pattern, pathname) {
550
553
  caseSensitive: false,
551
554
  end: true
552
555
  };
553
- let [matcher, compiledParams] = compilePath(pattern.path, pattern.caseSensitive, pattern.end);
556
+ let { path } = pattern;
557
+ let optionalSegments = 0;
558
+ for (let index = path.indexOf("?"); index !== -1; index = path.indexOf("?", index + 1)) if (++optionalSegments > MAX_OPTIONAL_PATH_SEGMENTS) throw new Error(`Path pattern ${JSON.stringify(path)} exceeds the limit of ${MAX_OPTIONAL_PATH_SEGMENTS} optional segments.`);
559
+ let [matcher, compiledParams] = compilePath(path, pattern.caseSensitive, pattern.end);
554
560
  return matchPathImpl(pattern, pathname, matcher, compiledParams);
555
561
  }
556
562
  function matchPathImpl(pattern, pathname, matcher, compiledParams) {
@@ -2504,7 +2510,8 @@ const Await = (async (props) => {
2504
2510
  * @param opts.clientVersion A version derived from the client build output used
2505
2511
  * to detect stale clients during lazy route discovery.
2506
2512
  * @param opts.onError An optional error handler that will be called with any
2507
- * errors that occur during the request processing.
2513
+ * errors that occur during the request processing. Defaults to logging errors
2514
+ * with `console.error` unless the request was aborted.
2508
2515
  * @param opts.request The [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
2509
2516
  * to match against.
2510
2517
  * @param opts.requestContext An instance of {@link RouterContextProvider}
@@ -2523,6 +2530,9 @@ async function matchRSCServerRequest({ allowedActionOrigins, createTemporaryRefe
2523
2530
  return response;
2524
2531
  };
2525
2532
  let url = new URL(request.url);
2533
+ onError ??= (error) => {
2534
+ if (!request.signal.aborted) console.error(isRouteErrorResponse(error) && error.error ? error.error : error);
2535
+ };
2526
2536
  basename = basename || "/";
2527
2537
  let normalizedPath = url.pathname;
2528
2538
  if (url.pathname.endsWith("/_.rsc")) normalizedPath = url.pathname.replace(/_\.rsc$/, "");
@@ -2721,11 +2731,18 @@ function tagResourceResponse(response) {
2721
2731
  });
2722
2732
  }
2723
2733
  async function generateRenderResponse(request, staticHandler, basename, isDataRequest, decodeReply, requestContext, loadServerAction, decodeAction, decodeFormState, onError, generateResponse, temporaryReferences, allowedActionOrigins, routeDiscovery, clientVersion) {
2734
+ if (isMutationMethod(request.method)) try {
2735
+ throwIfPotentialCSRFAttack(request, allowedActionOrigins);
2736
+ } catch (error) {
2737
+ onError?.(error);
2738
+ return tagResourceResponse(new Response("Bad Request", { status: 400 }));
2739
+ }
2724
2740
  let statusCode = 200;
2725
2741
  let url = new URL(request.url);
2726
2742
  let isSubmission = isMutationMethod(request.method);
2727
2743
  let routeIdsToLoad = !isSubmission && url.searchParams.has("_routes") ? url.searchParams.get("_routes").split(",") : null;
2728
2744
  let actionResult;
2745
+ let handledSubmission = false;
2729
2746
  const ctx = {
2730
2747
  request,
2731
2748
  runningAction: false
@@ -2739,39 +2756,24 @@ async function generateRenderResponse(request, staticHandler, basename, isDataRe
2739
2756
  async generateMiddlewareResponse(query) {
2740
2757
  let formState;
2741
2758
  let skipRevalidation = false;
2742
- let potentialCSRFAttackError;
2743
- if (isMutationMethod(request.method)) {
2744
- try {
2745
- throwIfPotentialCSRFAttack(request, allowedActionOrigins);
2746
- } catch (error) {
2747
- onError?.(error);
2748
- potentialCSRFAttackError = error;
2749
- request = new Request(request.url, {
2750
- method: "GET",
2751
- headers: request.headers,
2752
- signal: request.signal
2753
- });
2754
- }
2755
- if (!potentialCSRFAttackError) {
2756
- ctx.runningAction = true;
2757
- let result = await processServerAction(request, basename, decodeReply, loadServerAction, decodeAction, decodeFormState, onError, temporaryReferences).finally(() => {
2758
- ctx.runningAction = false;
2759
- });
2760
- if (isResponse(result)) return generateRedirectResponse(result, actionResult, basename, isDataRequest, generateResponse, temporaryReferences, result === ctx.redirect ? void 0 : ctx.redirect?.headers);
2761
- skipRevalidation = result?.skipRevalidation ?? false;
2762
- actionResult = result?.actionResult;
2763
- formState = result?.formState;
2764
- request = result?.revalidationRequest ?? request;
2765
- if (ctx.redirect) return generateRedirectResponse(ctx.redirect, actionResult, basename, isDataRequest, generateResponse, temporaryReferences, void 0);
2766
- }
2759
+ if (isSubmission && !handledSubmission) {
2760
+ handledSubmission = true;
2761
+ ctx.runningAction = true;
2762
+ let result = await processServerAction(request, basename, decodeReply, loadServerAction, decodeAction, decodeFormState, onError, temporaryReferences).finally(() => {
2763
+ ctx.runningAction = false;
2764
+ });
2765
+ if (isResponse(result)) return generateRedirectResponse(result, actionResult, basename, isDataRequest, generateResponse, temporaryReferences, result === ctx.redirect ? void 0 : ctx.redirect?.headers);
2766
+ skipRevalidation = result?.skipRevalidation ?? false;
2767
+ actionResult = result?.actionResult;
2768
+ formState = result?.formState;
2769
+ request = result?.revalidationRequest ?? request;
2770
+ if (ctx.redirect) return generateRedirectResponse(ctx.redirect, actionResult, basename, isDataRequest, generateResponse, temporaryReferences, void 0);
2767
2771
  }
2768
2772
  let staticContext = await query(request, skipRevalidation ? { filterMatchesToLoad: () => false } : void 0);
2769
2773
  if (isResponse(staticContext)) return generateRedirectResponse(staticContext, actionResult, basename, isDataRequest, generateResponse, temporaryReferences, ctx.redirect?.headers);
2770
- if (potentialCSRFAttackError) {
2771
- staticContext.errors ??= {};
2772
- staticContext.errors[staticContext.matches[0].route.id] = potentialCSRFAttackError;
2773
- staticContext.statusCode = 400;
2774
- }
2774
+ if (staticContext.errors) Object.values(staticContext.errors).forEach((error) => {
2775
+ if (!isRouteErrorResponse(error) || error.error) onError?.(error);
2776
+ });
2775
2777
  return generateStaticContextResponse(staticHandler, basename, generateResponse, statusCode, routeIdsToLoad, isDataRequest, isSubmission, actionResult, formState, staticContext, temporaryReferences, skipRevalidation, ctx.redirect?.headers, routeDiscovery, clientVersion);
2776
2778
  }
2777
2779
  }));
@@ -3293,6 +3295,7 @@ const createSession = (initialData = {}, id = "") => {
3293
3295
  },
3294
3296
  unset(name) {
3295
3297
  map.delete(name);
3298
+ map.delete(flash(name));
3296
3299
  }
3297
3300
  };
3298
3301
  };
@@ -3326,8 +3329,9 @@ function createSessionStorage({ cookie: cookieArg, createData, readData, updateD
3326
3329
  warnOnceAboutSigningSessionCookie(cookie);
3327
3330
  return {
3328
3331
  async getSession(cookieHeader, options) {
3329
- let id = cookieHeader && await cookie.parse(cookieHeader, options);
3330
- return createSession(id && await readData(id) || {}, id || "");
3332
+ let parsedId = cookieHeader && await cookie.parse(cookieHeader, options);
3333
+ let id = typeof parsedId === "string" && parsedId ? parsedId : "";
3334
+ return createSession((id ? await readData(id) : null) || {}, id);
3331
3335
  },
3332
3336
  async commitSession(session, options) {
3333
3337
  let { id, data } = session;
@@ -3373,7 +3377,8 @@ function createCookieSessionStorage({ cookie: cookieArg } = {}) {
3373
3377
  warnOnceAboutSigningSessionCookie(cookie);
3374
3378
  return {
3375
3379
  async getSession(cookieHeader, options) {
3376
- return createSession(cookieHeader && await cookie.parse(cookieHeader, options) || {});
3380
+ let data = cookieHeader && await cookie.parse(cookieHeader, options);
3381
+ return createSession(typeof data === "object" && data !== null && !Array.isArray(data) ? data : {});
3377
3382
  },
3378
3383
  async commitSession(session, options) {
3379
3384
  let serializedCookie = await cookie.serialize(session.data, options);
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.2
2
+ * react-router v8.5.3
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.2
2
+ * react-router v8.5.3
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.2
2
+ * react-router v8.5.3
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.2
2
+ * react-router v8.5.3
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -284,13 +284,14 @@ function RouterProvider({ router, flushSync: reactDomFlushSyncImpl, onError, use
284
284
  encodeLocation: router.encodeLocation,
285
285
  go: (n) => router.navigate(n),
286
286
  push: (to, state, opts) => router.navigate(to, {
287
- state,
288
- preventScrollReset: opts?.preventScrollReset
287
+ ...opts,
288
+ replace: opts?.replace === false ? false : void 0,
289
+ state: state !== void 0 ? state : opts?.state
289
290
  }),
290
291
  replace: (to, state, opts) => router.navigate(to, {
292
+ ...opts,
291
293
  replace: true,
292
- state,
293
- preventScrollReset: opts?.preventScrollReset
294
+ state: state !== void 0 ? state : opts?.state
294
295
  })
295
296
  };
296
297
  }, [router]);
@@ -343,6 +344,7 @@ function RouterProvider({ router, flushSync: reactDomFlushSyncImpl, onError, use
343
344
  fetchers: state.fetchers,
344
345
  fetcherData: fetcherData.current
345
346
  }), [state.fetchers]);
347
+ let discoveryRuntime = React$1.useContext(FrameworkContext)?.routeDiscoveryRuntime;
346
348
  return /* @__PURE__ */ React$1.createElement(React$1.Fragment, null, /* @__PURE__ */ React$1.createElement(DataRouterContext.Provider, { value: dataRouterContext }, /* @__PURE__ */ React$1.createElement(DataRouterStateContext.Provider, { value: dataRouterState }, /* @__PURE__ */ React$1.createElement(DataRouterNavigationContext.Provider, { value: dataRouterNavigation }, /* @__PURE__ */ React$1.createElement(DataRouterDataContext.Provider, { value: dataRouterData }, /* @__PURE__ */ React$1.createElement(FetchersContext.Provider, { value: fetchersContext }, /* @__PURE__ */ React$1.createElement(ViewTransitionContext.Provider, { value: vtContext }, /* @__PURE__ */ React$1.createElement(Router, {
347
349
  basename,
348
350
  location: state.location,
@@ -354,7 +356,8 @@ function RouterProvider({ router, flushSync: reactDomFlushSyncImpl, onError, use
354
356
  manifest: router.manifest,
355
357
  state,
356
358
  isStatic: false,
357
- onError
359
+ onError,
360
+ discoveryRuntime
358
361
  })))))))), null);
359
362
  }
360
363
  function getOptimisticRouterState(currentState, newState) {
@@ -367,10 +370,9 @@ function getOptimisticRouterState(currentState, newState) {
367
370
  };
368
371
  }
369
372
  const MemoizedDataRoutes = React$1.memo(DataRoutes);
370
- function DataRoutes({ routes, manifest, state, isStatic, onError }) {
373
+ function DataRoutes({ routes, manifest, state, isStatic, onError, discoveryRuntime }) {
371
374
  let dataRouterContext = React$1.useContext(DataRouterContext);
372
375
  invariant(dataRouterContext, "You must render this element inside a <DataRouterContext.Provider> element");
373
- let discoveryRuntime = React$1.useContext(FrameworkContext)?.routeDiscoveryRuntime;
374
376
  React$1.useEffect(() => {
375
377
  if (state.initialized) discoveryRuntime?.markReady();
376
378
  }, [state.initialized, discoveryRuntime]);
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.2
2
+ * react-router v8.5.3
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -19,6 +19,7 @@ DataRouterDataContext.displayName = "DataRouterData";
19
19
  const DataRouterNavigationContext = React$1.createContext(null);
20
20
  DataRouterNavigationContext.displayName = "DataRouterNavigation";
21
21
  const RSCRouterContext = React$1.createContext(false);
22
+ const RSCErrorAlreadyReportedContext = React$1.createContext(false);
22
23
  function useIsRSCRouterContext() {
23
24
  return React$1.useContext(RSCRouterContext);
24
25
  }
@@ -46,4 +47,4 @@ RouteIdContext.displayName = "RouteId";
46
47
  const RouteErrorContext = React$1.createContext(null);
47
48
  RouteErrorContext.displayName = "RouteError";
48
49
  //#endregion
49
- export { AwaitContext, AwaitContextProvider, DataRouterContext, DataRouterDataContext, DataRouterNavigationContext, DataRouterStateContext, FetchersContext, IsDataRouteContext, LocationContext, NavigationContext, RSCRouterContext, RouteContext, RouteErrorContext, RouteIdContext, ViewTransitionContext, useIsRSCRouterContext };
50
+ export { AwaitContext, AwaitContextProvider, DataRouterContext, DataRouterDataContext, DataRouterNavigationContext, DataRouterStateContext, FetchersContext, IsDataRouteContext, LocationContext, NavigationContext, RSCErrorAlreadyReportedContext, RSCRouterContext, RouteContext, RouteErrorContext, RouteIdContext, ViewTransitionContext, useIsRSCRouterContext };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.2
2
+ * react-router v8.5.3
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -27,7 +27,8 @@ function isModifiedEvent(event) {
27
27
  return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
28
28
  }
29
29
  function shouldProcessLinkClick(event, target) {
30
- return event.button === 0 && (!target || target === "_self") && !isModifiedEvent(event);
30
+ let element = event.currentTarget;
31
+ return event.button === 0 && (!target || target === "_self") && !isModifiedEvent(event) && !((element?.localName === "a" || element?.localName === "area") && element.hasAttribute("href") && element.hasAttribute("download"));
31
32
  }
32
33
  /**
33
34
  * Creates a URLSearchParams object using the given initializer.
@@ -86,6 +87,7 @@ const supportedFormEncTypes = new Set([
86
87
  "text/plain"
87
88
  ]);
88
89
  function getFormEncType(encType) {
90
+ encType = encType?.toLowerCase() ?? null;
89
91
  if (encType != null && !supportedFormEncTypes.has(encType)) {
90
92
  warning(false, `"${encType}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${defaultEncType}"`);
91
93
  return null;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.2
2
+ * react-router v8.5.3
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -329,6 +329,8 @@ const Link = React$1.forwardRef(function LinkWithRef({ onClick, discover = "rend
329
329
  return shouldPrefetch && !isAbsolute ? /* @__PURE__ */ React$1.createElement(React$1.Fragment, null, link, /* @__PURE__ */ React$1.createElement(PrefetchPageLinks, { page: href })) : link;
330
330
  });
331
331
  Link.displayName = "Link";
332
+ const subscribeToNothing = () => () => {};
333
+ const getClientSpaFallback = () => false;
332
334
  /**
333
335
  * Wraps {@link Link | `<Link>`} with additional props for styling active and
334
336
  * pending states.
@@ -377,7 +379,9 @@ const NavLink = React$1.forwardRef(function NavLinkWithRef({ "aria-current": ari
377
379
  let location = useLocation();
378
380
  let routerNavigation = React$1.useContext(DataRouterNavigationContext);
379
381
  let { navigator, basename } = React$1.useContext(NavigationContext);
380
- let isTransitioning = routerNavigation != null && useViewTransitionState(path) && viewTransition === true;
382
+ let isSpaMode = React$1.useContext(FrameworkContext)?.isSpaMode === true;
383
+ let isSpaFallback = React$1.useSyncExternalStore(subscribeToNothing, getClientSpaFallback, () => isSpaMode);
384
+ let isTransitioning = routerNavigation != null && useViewTransitionState(path) && viewTransition === true && !isSpaFallback;
381
385
  let toPathname = navigator.encodeLocation ? navigator.encodeLocation(path).pathname : path.pathname;
382
386
  let locationPathname = location.pathname;
383
387
  let nextLocationPathname = routerNavigation?.navigation.location ? routerNavigation.navigation.location.pathname : null;
@@ -388,8 +392,8 @@ const NavLink = React$1.forwardRef(function NavLinkWithRef({ "aria-current": ari
388
392
  }
389
393
  if (nextLocationPathname && basename) nextLocationPathname = stripBasename(nextLocationPathname, basename) || nextLocationPathname;
390
394
  const endSlashPosition = toPathname !== "/" && toPathname.endsWith("/") ? toPathname.length - 1 : toPathname.length;
391
- let isActive = locationPathname === toPathname || !end && locationPathname.startsWith(toPathname) && locationPathname.charAt(endSlashPosition) === "/";
392
- let isPending = nextLocationPathname != null && (nextLocationPathname === toPathname || !end && nextLocationPathname.startsWith(toPathname) && nextLocationPathname.charAt(endSlashPosition) === "/");
395
+ let isActive = !isSpaFallback && (locationPathname === toPathname || !end && locationPathname.startsWith(toPathname) && locationPathname.charAt(endSlashPosition) === "/");
396
+ let isPending = !isSpaFallback && nextLocationPathname != null && (nextLocationPathname === toPathname || !end && nextLocationPathname.startsWith(toPathname) && nextLocationPathname.charAt(endSlashPosition) === "/");
393
397
  let renderProps = {
394
398
  isActive,
395
399
  isPending,
@@ -1108,7 +1112,10 @@ function useScrollRestoration({ getKey, storageKey } = {}) {
1108
1112
  React$1.useLayoutEffect(() => {
1109
1113
  try {
1110
1114
  let sessionPositions = sessionStorage.getItem(storageKey || SCROLL_RESTORATION_STORAGE_KEY);
1111
- if (sessionPositions) savedScrollPositions = JSON.parse(sessionPositions);
1115
+ if (sessionPositions) {
1116
+ let parsedPositions = JSON.parse(sessionPositions);
1117
+ savedScrollPositions = parsedPositions && typeof parsedPositions === "object" && !Array.isArray(parsedPositions) ? parsedPositions : {};
1118
+ }
1112
1119
  } catch {}
1113
1120
  }, [storageKey]);
1114
1121
  React$1.useLayoutEffect(() => {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.2
2
+ * react-router v8.5.3
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
- import { ABSOLUTE_URL_REGEX } from "../router/url.js";
11
+ import { PROTOCOL_RELATIVE_URL_REGEX } from "../router/url.js";
12
12
  import { createPath, invariant, parsePath, warning } from "../router/history.js";
13
13
  import { convertRoutesToDataRoutes, isRouteErrorResponse } from "../router/utils.js";
14
14
  import { IDLE_BLOCKER, IDLE_FETCHER, IDLE_NAVIGATION } from "../router/router.js";
@@ -314,9 +314,11 @@ function createHref(to) {
314
314
  return typeof to === "string" ? to : createPath(to);
315
315
  }
316
316
  function encodeLocation(to) {
317
+ let base = "http://localhost";
317
318
  let href = typeof to === "string" ? to : createPath(to);
318
319
  href = href.replace(/ $/, "%20");
319
- let encoded = ABSOLUTE_URL_REGEX.test(href) ? new URL(href) : new URL(href, "http://localhost");
320
+ if (PROTOCOL_RELATIVE_URL_REGEX.test(href)) href = base + href;
321
+ let encoded = new URL(href, base);
320
322
  return {
321
323
  pathname: encoded.pathname,
322
324
  search: encoded.search,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.2
2
+ * react-router v8.5.3
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -143,12 +143,14 @@ function Links({ nonce, crossOrigin }) {
143
143
  return /* @__PURE__ */ React$1.createElement(React$1.Fragment, null, typeof criticalCss === "string" ? /* @__PURE__ */ React$1.createElement("style", {
144
144
  [CRITICAL_CSS_DATA_ATTRIBUTE]: "",
145
145
  nonce,
146
+ suppressHydrationWarning: true,
146
147
  dangerouslySetInnerHTML: { __html: criticalCss }
147
148
  }) : null, typeof criticalCss === "object" ? /* @__PURE__ */ React$1.createElement("link", {
148
149
  [CRITICAL_CSS_DATA_ATTRIBUTE]: "",
149
150
  rel: "stylesheet",
150
151
  href: criticalCss.href,
151
152
  nonce,
153
+ suppressHydrationWarning: true,
152
154
  crossOrigin
153
155
  }) : null, keyedLinks.map(({ key, link }) => isPageLinkDescriptor(link) ? /* @__PURE__ */ React$1.createElement(PrefetchPageLinks, {
154
156
  key,
@@ -158,6 +160,7 @@ function Links({ nonce, crossOrigin }) {
158
160
  }) : /* @__PURE__ */ React$1.createElement("link", {
159
161
  key,
160
162
  nonce,
163
+ suppressHydrationWarning: true,
161
164
  ...link,
162
165
  crossOrigin: link.crossOrigin ?? crossOrigin
163
166
  })));
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.2
2
+ * react-router v8.5.3
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.2
2
+ * react-router v8.5.3
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -49,6 +49,7 @@ function RemixRootDefaultErrorBoundary({ error, isOutsideRemixApp }) {
49
49
  console.error(error);
50
50
  let heyDeveloper = /* @__PURE__ */ React$1.createElement("script", {
51
51
  nonce,
52
+ suppressHydrationWarning: true,
52
53
  dangerouslySetInnerHTML: { __html: `
53
54
  console.log(
54
55
  "💿 Hey developer 👋. You can provide a way better UX than this when your app throws errors. Check out https://reactrouter.com/how-to/error-boundary for more information."
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.2
2
+ * react-router v8.5.3
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -19,6 +19,7 @@ function RemixRootDefaultHydrateFallback() {
19
19
  renderScripts: true
20
20
  }, /* @__PURE__ */ React$1.createElement("script", {
21
21
  nonce,
22
+ suppressHydrationWarning: true,
22
23
  dangerouslySetInnerHTML: { __html: `
23
24
  console.log(
24
25
  "💿 Hey developer 👋. You can provide a way better UX than this " +
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.2
2
+ * react-router v8.5.3
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.2
2
+ * react-router v8.5.3
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.2
2
+ * react-router v8.5.3
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.2
2
+ * react-router v8.5.3
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.2
2
+ * react-router v8.5.3
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.2
2
+ * react-router v8.5.3
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.2
2
+ * react-router v8.5.3
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.2
2
+ * react-router v8.5.3
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -69,6 +69,7 @@ function processRoutes(routes, context, manifest, routeModules, parentId) {
69
69
  id: route.id,
70
70
  path: route.path,
71
71
  index: route.index,
72
+ caseSensitive: route.caseSensitive,
72
73
  Component: route.Component ? withComponentProps(route.Component) : void 0,
73
74
  HydrateFallback: route.HydrateFallback ? withHydrateFallbackProps(route.HydrateFallback) : void 0,
74
75
  ErrorBoundary: route.ErrorBoundary ? withErrorBoundaryProps(route.ErrorBoundary) : void 0,
@@ -91,6 +92,7 @@ function processRoutes(routes, context, manifest, routeModules, parentId) {
91
92
  id: route.id,
92
93
  path: route.path,
93
94
  index: route.index,
95
+ caseSensitive: route.caseSensitive,
94
96
  parentId,
95
97
  hasAction: route.action != null,
96
98
  hasLoader: route.loader != null,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.2
2
+ * react-router v8.5.3
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -114,6 +114,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
114
114
  }
115
115
  }
116
116
  let dataRoute = {
117
+ caseSensitive: route.caseSensitive,
117
118
  id: route.id,
118
119
  index: route.index,
119
120
  path: route.path
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.2
2
+ * react-router v8.5.3
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.2
2
+ * react-router v8.5.3
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.2
2
+ * react-router v8.5.3
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *