react-router 8.5.1 → 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 (167) hide show
  1. package/CHANGELOG.md +79 -3
  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 +46 -39
  5. package/dist/development/index-react-server.js +104 -41
  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.d.ts +42 -38
  10. package/dist/development/lib/components.js +34 -36
  11. package/dist/development/lib/context.js +3 -2
  12. package/dist/development/lib/dom/dom.js +16 -5
  13. package/dist/development/lib/dom/lib.d.ts +2 -2
  14. package/dist/development/lib/dom/lib.js +22 -8
  15. package/dist/development/lib/dom/server.js +5 -3
  16. package/dist/development/lib/dom/ssr/components.js +4 -1
  17. package/dist/development/lib/dom/ssr/data.js +1 -1
  18. package/dist/development/lib/dom/ssr/errorBoundaries.js +2 -1
  19. package/dist/development/lib/dom/ssr/fallback.js +2 -1
  20. package/dist/development/lib/dom/ssr/fog-of-war.js +1 -1
  21. package/dist/development/lib/dom/ssr/hydration.d.ts +1 -0
  22. package/dist/development/lib/dom/ssr/hydration.js +1 -1
  23. package/dist/development/lib/dom/ssr/invariant.js +1 -1
  24. package/dist/development/lib/dom/ssr/links.js +1 -1
  25. package/dist/development/lib/dom/ssr/markup.js +1 -1
  26. package/dist/development/lib/dom/ssr/route-discovery.js +1 -1
  27. package/dist/development/lib/dom/ssr/routeModules.js +1 -1
  28. package/dist/development/lib/dom/ssr/routes-test-stub.js +3 -1
  29. package/dist/development/lib/dom/ssr/routes.js +2 -1
  30. package/dist/development/lib/dom/ssr/server.js +1 -1
  31. package/dist/development/lib/dom/ssr/single-fetch.js +1 -1
  32. package/dist/development/lib/dom-export/dom-router-provider.js +1 -1
  33. package/dist/development/lib/dom-export/hydrated-router.d.ts +1 -1
  34. package/dist/development/lib/dom-export/hydrated-router.js +4 -2
  35. package/dist/development/lib/errors.js +1 -1
  36. package/dist/development/lib/hooks.d.ts +30 -0
  37. package/dist/development/lib/hooks.js +46 -7
  38. package/dist/development/lib/href.js +4 -4
  39. package/dist/development/lib/router/history.js +10 -4
  40. package/dist/development/lib/router/instrumentation.js +1 -1
  41. package/dist/development/lib/router/matcher-route-pattern.js +1 -1
  42. package/dist/development/lib/router/matcher-route-pattern.preload.js +1 -1
  43. package/dist/development/lib/router/matcher.js +1 -1
  44. package/dist/development/lib/router/navigation.js +17 -2
  45. package/dist/development/lib/router/router.js +26 -9
  46. package/dist/development/lib/router/url.js +1 -1
  47. package/dist/development/lib/router/utils.d.ts +8 -5
  48. package/dist/development/lib/router/utils.js +24 -9
  49. package/dist/development/lib/rsc/browser.js +27 -4
  50. package/dist/development/lib/rsc/errorBoundaries.js +3 -2
  51. package/dist/development/lib/rsc/html-stream/browser.js +1 -1
  52. package/dist/development/lib/rsc/html-stream/server.js +1 -1
  53. package/dist/development/lib/rsc/route-modules.js +1 -1
  54. package/dist/development/lib/rsc/server.rsc.d.ts +4 -1
  55. package/dist/development/lib/rsc/server.ssr.d.ts +1 -0
  56. package/dist/development/lib/rsc/server.ssr.js +5 -4
  57. package/dist/development/lib/server-runtime/cookies.js +1 -1
  58. package/dist/development/lib/server-runtime/crypto.js +1 -1
  59. package/dist/development/lib/server-runtime/data.js +1 -1
  60. package/dist/development/lib/server-runtime/dev.js +1 -1
  61. package/dist/development/lib/server-runtime/entry.js +1 -1
  62. package/dist/development/lib/server-runtime/errors.js +1 -1
  63. package/dist/development/lib/server-runtime/headers.js +1 -1
  64. package/dist/development/lib/server-runtime/invariant.js +1 -1
  65. package/dist/development/lib/server-runtime/mode.js +1 -1
  66. package/dist/development/lib/server-runtime/routeMatching.js +1 -1
  67. package/dist/development/lib/server-runtime/routes.js +1 -1
  68. package/dist/development/lib/server-runtime/server.js +9 -6
  69. package/dist/development/lib/server-runtime/serverHandoff.js +1 -1
  70. package/dist/development/lib/server-runtime/sessions/cookieStorage.js +3 -2
  71. package/dist/development/lib/server-runtime/sessions/memoryStorage.js +1 -1
  72. package/dist/development/lib/server-runtime/sessions.d.ts +1 -1
  73. package/dist/development/lib/server-runtime/sessions.js +5 -3
  74. package/dist/development/lib/server-runtime/single-fetch.js +1 -1
  75. package/dist/development/lib/server-runtime/urls.js +1 -1
  76. package/dist/development/lib/server-runtime/warnings.js +1 -1
  77. package/dist/development/lib/types/internal.js +1 -1
  78. package/dist/development/lib/types/route-module-annotations.d.ts +16 -9
  79. package/dist/development/route-pattern.js +1 -1
  80. package/dist/development/vendor/turbo-stream-v2/flatten.js +1 -1
  81. package/dist/development/vendor/turbo-stream-v2/turbo-stream.js +83 -73
  82. package/dist/development/vendor/turbo-stream-v2/unflatten.js +1 -1
  83. package/dist/development/vendor/turbo-stream-v2/utils.js +1 -1
  84. package/dist/production/dom-export.js +1 -1
  85. package/dist/production/index-react-server-client.js +1 -1
  86. package/dist/production/index-react-server.d.ts +46 -39
  87. package/dist/production/index-react-server.js +104 -41
  88. package/dist/production/index.js +1 -1
  89. package/dist/production/lib/actions.js +1 -1
  90. package/dist/production/lib/await.js +1 -1
  91. package/dist/production/lib/components.d.ts +42 -38
  92. package/dist/production/lib/components.js +34 -36
  93. package/dist/production/lib/context.js +3 -2
  94. package/dist/production/lib/dom/dom.js +16 -5
  95. package/dist/production/lib/dom/lib.d.ts +2 -2
  96. package/dist/production/lib/dom/lib.js +22 -8
  97. package/dist/production/lib/dom/server.js +5 -3
  98. package/dist/production/lib/dom/ssr/components.js +4 -1
  99. package/dist/production/lib/dom/ssr/data.js +1 -1
  100. package/dist/production/lib/dom/ssr/errorBoundaries.js +2 -1
  101. package/dist/production/lib/dom/ssr/fallback.js +1 -1
  102. package/dist/production/lib/dom/ssr/fog-of-war.js +1 -1
  103. package/dist/production/lib/dom/ssr/hydration.d.ts +1 -0
  104. package/dist/production/lib/dom/ssr/hydration.js +1 -1
  105. package/dist/production/lib/dom/ssr/invariant.js +1 -1
  106. package/dist/production/lib/dom/ssr/links.js +1 -1
  107. package/dist/production/lib/dom/ssr/markup.js +1 -1
  108. package/dist/production/lib/dom/ssr/route-discovery.js +1 -1
  109. package/dist/production/lib/dom/ssr/routeModules.js +1 -1
  110. package/dist/production/lib/dom/ssr/routes-test-stub.js +3 -1
  111. package/dist/production/lib/dom/ssr/routes.js +2 -1
  112. package/dist/production/lib/dom/ssr/server.js +1 -1
  113. package/dist/production/lib/dom/ssr/single-fetch.js +1 -1
  114. package/dist/production/lib/dom-export/dom-router-provider.js +1 -1
  115. package/dist/production/lib/dom-export/hydrated-router.d.ts +1 -1
  116. package/dist/production/lib/dom-export/hydrated-router.js +4 -2
  117. package/dist/production/lib/errors.js +1 -1
  118. package/dist/production/lib/hooks.d.ts +30 -0
  119. package/dist/production/lib/hooks.js +45 -6
  120. package/dist/production/lib/href.js +4 -4
  121. package/dist/production/lib/router/history.js +10 -4
  122. package/dist/production/lib/router/instrumentation.js +1 -1
  123. package/dist/production/lib/router/matcher-route-pattern.js +1 -1
  124. package/dist/production/lib/router/matcher-route-pattern.preload.js +1 -1
  125. package/dist/production/lib/router/matcher.js +1 -1
  126. package/dist/production/lib/router/navigation.js +17 -2
  127. package/dist/production/lib/router/router.js +26 -9
  128. package/dist/production/lib/router/url.js +1 -1
  129. package/dist/production/lib/router/utils.d.ts +8 -5
  130. package/dist/production/lib/router/utils.js +24 -9
  131. package/dist/production/lib/rsc/browser.js +27 -4
  132. package/dist/production/lib/rsc/errorBoundaries.js +3 -2
  133. package/dist/production/lib/rsc/html-stream/browser.js +1 -1
  134. package/dist/production/lib/rsc/html-stream/server.js +1 -1
  135. package/dist/production/lib/rsc/route-modules.js +1 -1
  136. package/dist/production/lib/rsc/server.rsc.d.ts +4 -1
  137. package/dist/production/lib/rsc/server.ssr.d.ts +1 -0
  138. package/dist/production/lib/rsc/server.ssr.js +5 -4
  139. package/dist/production/lib/server-runtime/cookies.js +1 -1
  140. package/dist/production/lib/server-runtime/crypto.js +1 -1
  141. package/dist/production/lib/server-runtime/data.js +1 -1
  142. package/dist/production/lib/server-runtime/dev.js +1 -1
  143. package/dist/production/lib/server-runtime/entry.js +1 -1
  144. package/dist/production/lib/server-runtime/errors.js +1 -1
  145. package/dist/production/lib/server-runtime/headers.js +1 -1
  146. package/dist/production/lib/server-runtime/invariant.js +1 -1
  147. package/dist/production/lib/server-runtime/mode.js +1 -1
  148. package/dist/production/lib/server-runtime/routeMatching.js +1 -1
  149. package/dist/production/lib/server-runtime/routes.js +1 -1
  150. package/dist/production/lib/server-runtime/server.js +9 -6
  151. package/dist/production/lib/server-runtime/serverHandoff.js +1 -1
  152. package/dist/production/lib/server-runtime/sessions/cookieStorage.js +3 -2
  153. package/dist/production/lib/server-runtime/sessions/memoryStorage.js +1 -1
  154. package/dist/production/lib/server-runtime/sessions.d.ts +1 -1
  155. package/dist/production/lib/server-runtime/sessions.js +5 -3
  156. package/dist/production/lib/server-runtime/single-fetch.js +1 -1
  157. package/dist/production/lib/server-runtime/urls.js +1 -1
  158. package/dist/production/lib/server-runtime/warnings.js +1 -1
  159. package/dist/production/lib/types/internal.js +1 -1
  160. package/dist/production/lib/types/route-module-annotations.d.ts +16 -9
  161. package/dist/production/route-pattern.js +1 -1
  162. package/dist/production/vendor/turbo-stream-v2/flatten.js +1 -1
  163. package/dist/production/vendor/turbo-stream-v2/turbo-stream.js +83 -73
  164. package/dist/production/vendor/turbo-stream-v2/unflatten.js +1 -1
  165. package/dist/production/vendor/turbo-stream-v2/utils.js +1 -1
  166. package/docs/upgrading/v7.md +11 -0
  167. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,10 +1,85 @@
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
+
53
+ ## v8.5.2
54
+
55
+ ### Patch Changes
56
+
57
+ - Keep navigation metadata consistent after a submission action throws an error ([#15621](https://github.com/remix-run/react-router/pull/15621))
58
+ - Use the committed history action for loader `dataStrategy` navigation types and loading navigation history actions
59
+ - Cancel the discarded response body for `HEAD` requests, so a resource route streaming a file no longer leaks its file descriptor ([#15634](https://github.com/remix-run/react-router/pull/15634))
60
+ - Keep observing nested deferred promise rejections after cancelling a data response so they cannot crash the server
61
+ - Preserve streamed `<Suspense>` boundaries during hydration in development ([#15382](https://github.com/remix-run/react-router/pull/15382))
62
+ - Wrap the critical CSS reset in `React.startTransition` to prevent React 19 from silently discarding the server HTML and rendering the boundary on the client
63
+ - Fix submissions to root form actions containing search parameters or a hash when a `basename` is configured ([#15725](https://github.com/remix-run/react-router/pull/15725))
64
+ - Fix `href()` to throw for `null` required parameters and omit `null` splat parameters without a trailing slash, matching the behavior for `undefined` and the defined types ([#15754](https://github.com/remix-run/react-router/pull/15754))
65
+ - Fix generated `MetaArgs.matches` types to stop at the current route instead of appending an unknown, possibly undefined tail ([#15697](https://github.com/remix-run/react-router/pull/15697))
66
+ - Improve path generation and URL validation across `href()`, `generatePath()`, links, forms, fetchers, and redirects ([#15785](https://github.com/remix-run/react-router/pull/15785))
67
+ - Stop `redirect()`, `redirectDocument()` and `replace()` from setting `status: 302` on the `ResponseInit` passed to them ([#15753](https://github.com/remix-run/react-router/pull/15753))
68
+ - Later responses created from the same init object no longer get status 302, and a frozen init no longer throws
69
+ - Clear an `<Await>` render error when it receives a new `resolve` value, so the error element no longer stays on screen after navigating to a route whose data renders fine ([#15695](https://github.com/remix-run/react-router/pull/15695))
70
+ - Run `clientMiddleware` during RSC client navigations and preserve it when route components update via HMR ([#15763](https://github.com/remix-run/react-router/pull/15763))
71
+ - Handle `HEAD` resource responses consistently in RSC Framework and RSC Data modes ([#15783](https://github.com/remix-run/react-router/pull/15783))
72
+ - Fix initial rendering of RSC routes with a `clientLoader` and no `HydrateFallback` ([#15763](https://github.com/remix-run/react-router/pull/15763))
73
+ - Fix `<ScrollRestoration>` throwing an uncaught error before hydration when `sessionStorage` is unavailable ([#15566](https://github.com/remix-run/react-router/pull/15566))
74
+ - The inline restore script already logged the storage error, but its cleanup call accessed `sessionStorage` again and threw (e.g. Chrome with "Block all cookies", sandboxed cross-origin iframes)
75
+ - The error is still logged with `console.error`; only the second, uncaught throw is removed
76
+ - Fix `useBlocker` leaving behind a stale blocker that keeps blocking navigation after its component is hidden and shown again with `<Activity>`, or after the router is recreated ([#15710](https://github.com/remix-run/react-router/pull/15710))
77
+
3
78
  ## v8.5.1
4
79
 
5
80
  ### Patch Changes
6
81
 
7
- - Fix `URIError: URI malformed` when an API-only (`ssr: "unstable_api-only"`) server or an `ssr: false` dev server receives a URL path with a malformed percent-encoding ([#15649](https://github.com/remix-run/react-router/pull/15649))
82
+ - Fix `URIError: URI malformed` when an `ssr: false` dev server receives a URL path with a malformed percent-encoding ([#15649](https://github.com/remix-run/react-router/pull/15649))
8
83
  - Bound server route manifest processing for paths with expensive route expansion ([#15703](https://github.com/remix-run/react-router/pull/15703))
9
84
  - Fall back to initial route discovery during server rendering and RSC document/data requests
10
85
  - Account for the number and depth of candidate branches when using regex matching
@@ -25,7 +100,6 @@
25
100
  - Return fetchers to `idle` when a revalidation completes a pending navigation started by another fetcher's redirect
26
101
  - Avoid adding an incompatible `document.startViewTransition()` overload to the global `Document` type ([#15680](https://github.com/remix-run/react-router/pull/15680))
27
102
  - Allow transition results to be assigned to the DOM `ViewTransition` type
28
- - Fix duplicate headers when throwing a redirect from an RSC server function ([#15667](https://github.com/remix-run/react-router/pull/15667))
29
103
  - Skip `deleteData` in `destroySession` when the session has no ID ([#15639](https://github.com/remix-run/react-router/pull/15639))
30
104
  - Avoid failures when destroying a session without a cookie on storage that rejects an empty key
31
105
  - Surface the host's 404 response when a SPA fallback route has no prerendered data ([#15646](https://github.com/remix-run/react-router/pull/15646))
@@ -35,13 +109,15 @@
35
109
 
36
110
  ### Unstable Changes
37
111
 
38
- ⚠️ _[Unstable features](https://reactrouter.com/community/api-development-strategy#unstable-flags) are not recommended for production use_
112
+ ⚠️ _[Unstable features](https://reactrouter.com/community/api-development-strategy#unstable-flags) are not recommended for production use_
39
113
 
40
114
  - Add an opt-in `<Await unstable_promise={promise}>` implementation based on React's `use()` API ([#15678](https://github.com/remix-run/react-router/pull/15678))
41
115
  - Use `React.use` instead of React Router's internal promise tracking
42
116
  - Accept promise-like values and retain `errorElement`, `useAsyncValue`, and `useAsyncError` support
43
117
  - Handle only promise rejections with `errorElement` when using `unstable_promise`, allowing child render errors to bubble to the nearest React error boundary
44
118
  - Track streamed promises during decoding so settled server content stays visible during hydration updates with either Await API or direct `React.use()`
119
+ - Fix `URIError: URI malformed` when an API-only (`ssr: "unstable_api-only"`) server receives a URL path with a malformed percent-encoding ([#15649](https://github.com/remix-run/react-router/pull/15649))
120
+ - Fix duplicate headers when throwing a redirect from an RSC server function ([#15667](https://github.com/remix-run/react-router/pull/15667))
45
121
 
46
122
  ## v8.5.0
47
123
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.1
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.1
2
+ * react-router v8.5.3
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -679,7 +679,7 @@ type BaseRouteObject = {
679
679
  action?: ActionFunction | boolean;
680
680
  /**
681
681
  * The route shouldRevalidate function.
682
- * See [`shouldRevalidate`](../../start/data/route-object#shouldRevalidate).
682
+ * See [`shouldRevalidate`](../../start/data/route-object#shouldrevalidate).
683
683
  */
684
684
  shouldRevalidate?: ShouldRevalidateFunction;
685
685
  /**
@@ -1014,7 +1014,25 @@ interface AwaitResolveRenderFunction<Resolve = any> {
1014
1014
  * @category Types
1015
1015
  */
1016
1016
  interface AwaitProps<Resolve> {
1017
- /** Use either `resolve` or `unstable_promise`, never both. */
1017
+ /**
1018
+ * <docs-warning>This prop is currently unstable and may change in minor or patch
1019
+ * releases.</docs-warning>
1020
+ *
1021
+ * A promise (or value) to read using React's `use()` API in client components.
1022
+ * Unlike `resolve` in client components, this accepts promise-like values
1023
+ * without modifying the source promise.
1024
+ *
1025
+ * `errorElement` handles promise rejections. Errors thrown while rendering
1026
+ * children bubble to the nearest React error boundary.
1027
+ *
1028
+ * ```tsx
1029
+ * <Await unstable_promise={reviewsPromise} errorElement={<ReviewsError />}>
1030
+ * {(reviews) => <Reviews items={reviews} />}
1031
+ * </Await>
1032
+ * ```
1033
+ *
1034
+ * Pass exactly one of `unstable_promise` or `resolve`.
1035
+ */
1018
1036
  unstable_promise?: never;
1019
1037
  /**
1020
1038
  * When using a function, the resolved value is provided as the parameter.
@@ -1041,14 +1059,17 @@ interface AwaitProps<Resolve> {
1041
1059
  */
1042
1060
  children: React.ReactNode | AwaitResolveRenderFunction<Resolve>;
1043
1061
  /**
1044
- * The error element renders instead of the `children` when the [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
1062
+ * The error element renders instead of the `children` when the
1063
+ * [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
1045
1064
  * rejects.
1046
1065
  *
1066
+ * When using `resolve`, errors thrown while rendering `children` are
1067
+ * also caught and rendered here. With `unstable_promise`, only promise
1068
+ * rejections are handled; errors thrown while rendering `children` bubble to
1069
+ * the nearest React error boundary.
1070
+ *
1047
1071
  * ```tsx
1048
- * <Await
1049
- * errorElement={<div>Oops</div>}
1050
- * resolve={reviewsPromise}
1051
- * >
1072
+ * <Await resolve={reviewsPromise} errorElement={<div>Oops</div>}>
1052
1073
  * <Reviews />
1053
1074
  * </Await>
1054
1075
  * ```
@@ -1057,10 +1078,7 @@ interface AwaitProps<Resolve> {
1057
1078
  * child component
1058
1079
  *
1059
1080
  * ```tsx
1060
- * <Await
1061
- * errorElement={<ReviewsError />}
1062
- * resolve={reviewsPromise}
1063
- * >
1081
+ * <Await resolve={reviewsPromise} errorElement={<ReviewsError />}>
1064
1082
  * <Reviews />
1065
1083
  * </Await>
1066
1084
  *
@@ -1140,22 +1158,16 @@ interface AwaitPromiseProps<Resolve> extends Omit<AwaitProps<Resolve>, "resolve"
1140
1158
  /**
1141
1159
  * Used to render promise values with automatic error handling.
1142
1160
  *
1143
- * **Note:** `<Await>` expects to be rendered inside a [`<React.Suspense>`](https://react.dev/reference/react/Suspense)
1161
+ * Passing the promise through `resolve` uses React Router-specific promise tracking, while passing
1162
+ * it through `unstable_promise` uses React's built-in [`use()`](https://react.dev/reference/react/use)
1163
+ * API.
1144
1164
  *
1145
- * Pass `unstable_promise` instead of `resolve` to opt into React's
1146
- * [`use()`](https://react.dev/reference/react/use) implementation. With
1147
- * `unstable_promise`, `errorElement` handles promise rejections, while errors
1148
- * thrown by children bubble to the nearest React error boundary.
1149
- *
1150
- * In React Server Components, `resolve` already has this error-handling behavior:
1151
- * `errorElement` handles only input rejections, while child render errors
1152
- * propagate to the surrounding error boundary. Both props accept promise-like
1153
- * values without modifying the source promise. Both props treat a falsy
1154
- * `errorElement` as absent and propagate the rejection. Pass an empty fragment
1155
- * to handle a rejection without rendering any content.
1165
+ * **Note:** `<Await>` expects to be rendered inside a [`<React.Suspense>`](https://react.dev/reference/react/Suspense)
1156
1166
  *
1157
- * <docs-warning>The `unstable_promise` prop is experimental and may change in
1158
- * minor or patch releases.</docs-warning>
1167
+ * <docs-warning>The `unstable_promise` prop is currently unstable and may change in minor or patch
1168
+ * releases. We plan to stabilize `<Await promise>` and deprecate `<Await resolve>` during v8, and then
1169
+ * drop `<Await resolve>` in v9. Please see below for minor `errorElement` behavioral differences
1170
+ * between the two approaches.</docs-warning>
1159
1171
  *
1160
1172
  * @example
1161
1173
  * import { Await, useLoaderData } from "react-router";
@@ -1175,15 +1187,9 @@ interface AwaitPromiseProps<Resolve> extends Omit<AwaitProps<Resolve>, "resolve"
1175
1187
  * <h1>{book.title}</h1>
1176
1188
  * <p>{book.description}</p>
1177
1189
  * <React.Suspense fallback={<ReviewsSkeleton />}>
1178
- * <Await
1179
- * resolve={reviews}
1180
- * errorElement={
1181
- * <div>Could not load reviews 😬</div>
1182
- * }
1183
- * children={(resolvedReviews) => (
1184
- * <Reviews items={resolvedReviews} />
1185
- * )}
1186
- * />
1190
+ * <Await resolve={reviews} errorElement={<BookError />}>
1191
+ * {(resolvedReviews) => <Reviews items={resolvedReviews} />}
1192
+ * </Await>
1187
1193
  * </React.Suspense>
1188
1194
  * </div>
1189
1195
  * );
@@ -1197,9 +1203,7 @@ interface AwaitPromiseProps<Resolve> extends Omit<AwaitProps<Resolve>, "resolve"
1197
1203
  * @param {AwaitProps.children} props.children n/a
1198
1204
  * @param {AwaitProps.errorElement} props.errorElement n/a
1199
1205
  * @param {AwaitProps.resolve} props.resolve n/a
1200
- * @param props.unstable_promise A promise (or value) to read using React's `use()`
1201
- * API in client components. Accepts promise-like values without modifying the
1202
- * source promise. Pass exactly one of `unstable_promise` or `resolve`.
1206
+ * @param {AwaitProps.unstable_promise} props.unstable_promise n/a
1203
1207
  * @returns React element for the rendered awaited value
1204
1208
  */
1205
1209
  declare function Await$1<Resolve>(props: AwaitProps<Resolve> | AwaitPromiseProps<Resolve>): React.JSX.Element;
@@ -2330,6 +2334,7 @@ type RSCRouteConfigEntryBase = {
2330
2334
  action?: ActionFunction;
2331
2335
  clientAction?: ClientActionFunction;
2332
2336
  clientLoader?: ClientLoaderFunction;
2337
+ clientMiddleware?: MiddlewareFunction<any>[];
2333
2338
  ErrorBoundary?: React.ComponentType<any>;
2334
2339
  handle?: any;
2335
2340
  headers?: HeadersFunction;
@@ -2361,6 +2366,7 @@ type RSCRouteConfig = Array<RSCRouteConfigEntry>;
2361
2366
  type RSCRouteManifest = {
2362
2367
  clientAction?: ClientActionFunction;
2363
2368
  clientLoader?: ClientLoaderFunction;
2369
+ clientMiddleware?: MiddlewareFunction<any>[];
2364
2370
  element?: React.ReactElement | false;
2365
2371
  errorElement?: React.ReactElement;
2366
2372
  handle?: any;
@@ -2498,7 +2504,8 @@ type RouteDiscovery = {
2498
2504
  * @param opts.clientVersion A version derived from the client build output used
2499
2505
  * to detect stale clients during lazy route discovery.
2500
2506
  * @param opts.onError An optional error handler that will be called with any
2501
- * 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.
2502
2509
  * @param opts.request The [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
2503
2510
  * to match against.
2504
2511
  * @param opts.requestContext An instance of {@link RouterContextProvider}
@@ -2731,7 +2738,7 @@ interface Session<Data = SessionData, FlashData = Data> {
2731
2738
  /**
2732
2739
  * Removes a value from the session.
2733
2740
  */
2734
- unset(name: keyof Data & string): void;
2741
+ unset(name: (keyof Data | keyof FlashData) & string): void;
2735
2742
  }
2736
2743
  type FlashSessionData<Data, FlashData> = Partial<Data & { [Key in keyof FlashData as FlashDataKey<Key & string>]: FlashData[Key] }>;
2737
2744
  type FlashDataKey<Key extends string> = `__flash_${Key}__`;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.1
2
+ * react-router v8.5.3
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -83,6 +83,46 @@ function parsePath(path) {
83
83
  return parsedPath;
84
84
  }
85
85
  //#endregion
86
+ //#region lib/router/navigation.ts
87
+ const DEFAULT_NAVIGATION_URL = new URL("http://localhost");
88
+ function isSameOrigin(a, b) {
89
+ return a.origin === b.origin && (a.origin !== "null" || a.protocol === b.protocol && a.host === b.host);
90
+ }
91
+ function isExplicitUrl(destination, target) {
92
+ if (destination.startsWith("//")) return true;
93
+ let protocol = target.protocol.toLowerCase();
94
+ if (!destination.toLowerCase().startsWith(protocol)) return false;
95
+ return target.host === "" || destination.slice(protocol.length).startsWith("//");
96
+ }
97
+ function validateDocumentNavigationTarget(destination) {
98
+ let normalized = destination.replace(/[\t\n\r]/g, "");
99
+ let start = 0;
100
+ while (normalized.charCodeAt(start) <= 32) start++;
101
+ normalized = normalized.slice(start);
102
+ if (!ABSOLUTE_URL_REGEX.test(normalized)) return;
103
+ let target;
104
+ try {
105
+ target = new URL(destination, DEFAULT_NAVIGATION_URL);
106
+ } catch {
107
+ return;
108
+ }
109
+ if (!isExplicitUrl(destination, target)) throw new Error("External navigation is not allowed");
110
+ }
111
+ function validateNavigationTarget(original, resolved, currentUrl, externalPolicy) {
112
+ let originalUrl = null;
113
+ try {
114
+ originalUrl = original == null ? null : new URL(original, currentUrl);
115
+ } catch {}
116
+ let resolvedUrl = new URL(resolved, currentUrl);
117
+ let originalIsExternal = originalUrl != null && !isSameOrigin(originalUrl, currentUrl);
118
+ let resolvedIsExternal = !isSameOrigin(resolvedUrl, currentUrl);
119
+ if (externalPolicy === "reject") {
120
+ if (originalIsExternal || resolvedIsExternal) throw new Error("External navigation is not allowed");
121
+ } else if (resolvedIsExternal) {
122
+ if (originalUrl == null || !isExplicitUrl(original, originalUrl) || !isSameOrigin(originalUrl, resolvedUrl)) throw new Error("External navigation is not allowed");
123
+ }
124
+ }
125
+ //#endregion
86
126
  //#region lib/router/utils.ts
87
127
  /**
88
128
  * Creates a type-safe {@link RouterContext} object that can be used to
@@ -490,10 +530,13 @@ const PATH_PARAM_OVERESCAPED = {
490
530
  function encodePathParam(value) {
491
531
  return encodeURIComponent(value).replace(/%(?:24|26|2B|2C|3A|3B|3D|40)/g, (match) => PATH_PARAM_OVERESCAPED[match]);
492
532
  }
533
+ const MAX_OPTIONAL_PATH_SEGMENTS = 12;
493
534
  /**
494
535
  * Performs pattern matching on a URL pathname and returns information about
495
536
  * the match.
496
537
  *
538
+ * Throws if the pattern contains more than 12 optional (`?`) markers.
539
+ *
497
540
  * @public
498
541
  * @category Utils
499
542
  * @param pattern The pattern to match against the URL pathname. This can be a
@@ -510,7 +553,10 @@ function matchPath(pattern, pathname) {
510
553
  caseSensitive: false,
511
554
  end: true
512
555
  };
513
- 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);
514
560
  return matchPathImpl(pattern, pathname, matcher, compiledParams);
515
561
  }
516
562
  function matchPathImpl(pattern, pathname, matcher, compiledParams) {
@@ -730,11 +776,15 @@ function data(data, init) {
730
776
  * header.
731
777
  */
732
778
  const redirect$1 = (url, init = 302) => {
779
+ validateDocumentNavigationTarget(url);
733
780
  let responseInit = init;
734
781
  if (typeof responseInit === "number") responseInit = { status: responseInit };
735
- else if (typeof responseInit.status === "undefined") responseInit.status = 302;
736
782
  let headers = new Headers(responseInit.headers);
737
783
  headers.set("Location", url);
784
+ if (typeof responseInit.status === "undefined") responseInit = {
785
+ ...responseInit,
786
+ status: 302
787
+ };
738
788
  return new Response(null, {
739
789
  ...responseInit,
740
790
  headers
@@ -2018,6 +2068,7 @@ async function convertDataStrategyResultToDataResult(dataStrategyResult) {
2018
2068
  function normalizeRelativeRoutingRedirectResponse(response, request, routeId, matches, basename) {
2019
2069
  let location = response.headers.get("Location");
2020
2070
  invariant$1(location, "Redirects returned/thrown from loaders/actions must have a Location header");
2071
+ validateNavigationTarget(location, location, new URL(request.url), "allow-explicit");
2021
2072
  if (!isAbsoluteUrl(location)) {
2022
2073
  let trimmedMatches = matches.slice(0, matches.findIndex((m) => m.route.id === routeId) + 1);
2023
2074
  location = normalizeTo(new URL(request.url), trimmedMatches, basename, location);
@@ -2459,7 +2510,8 @@ const Await = (async (props) => {
2459
2510
  * @param opts.clientVersion A version derived from the client build output used
2460
2511
  * to detect stale clients during lazy route discovery.
2461
2512
  * @param opts.onError An optional error handler that will be called with any
2462
- * 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.
2463
2515
  * @param opts.request The [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
2464
2516
  * to match against.
2465
2517
  * @param opts.requestContext An instance of {@link RouterContextProvider}
@@ -2478,6 +2530,9 @@ async function matchRSCServerRequest({ allowedActionOrigins, createTemporaryRefe
2478
2530
  return response;
2479
2531
  };
2480
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
+ };
2481
2536
  basename = basename || "/";
2482
2537
  let normalizedPath = url.pathname;
2483
2538
  if (url.pathname.endsWith("/_.rsc")) normalizedPath = url.pathname.replace(/_\.rsc$/, "");
@@ -2500,9 +2555,20 @@ async function matchRSCServerRequest({ allowedActionOrigins, createTemporaryRefe
2500
2555
  let matches = staticHandler.match(url.pathname);
2501
2556
  if (matches) await Promise.all(matches.map((m) => explodeLazyRoute(m.route)));
2502
2557
  const leafMatch = matches?.[matches.length - 1];
2503
- if (!isDataRequest && leafMatch && !leafMatch.route.Component && !leafMatch.route.ErrorBoundary) return generateResourceResponse(routerRequest, staticHandler, leafMatch.route.id, requestContext, onError);
2558
+ if (!isDataRequest && leafMatch && !leafMatch.route.Component && !leafMatch.route.ErrorBoundary) return normalizeResourceResponse(request, await generateResourceResponse(routerRequest, staticHandler, leafMatch.route.id, requestContext, onError));
2504
2559
  let response = await generateRenderResponse(routerRequest, staticHandler, basename, isDataRequest, decodeReply, requestContext, loadServerAction, decodeAction, decodeFormState, onError, generateResponse, temporaryReferences, allowedActionOrigins, routeDiscovery, clientVersion);
2505
2560
  response.headers.set("X-Remix-Response", "yes");
2561
+ return normalizeResourceResponse(request, response);
2562
+ }
2563
+ function normalizeResourceResponse(request, response) {
2564
+ if (request.method === "HEAD" && response.headers.get("React-Router-Resource") === "true") {
2565
+ response.body?.cancel().catch(() => {});
2566
+ return new Response(null, {
2567
+ status: response.status,
2568
+ statusText: response.statusText,
2569
+ headers: response.headers
2570
+ });
2571
+ }
2506
2572
  return response;
2507
2573
  }
2508
2574
  async function generateManifestResponse(routes, basename, request, generateResponse, temporaryReferences, routeDiscovery, clientVersion) {
@@ -2665,11 +2731,18 @@ function tagResourceResponse(response) {
2665
2731
  });
2666
2732
  }
2667
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
+ }
2668
2740
  let statusCode = 200;
2669
2741
  let url = new URL(request.url);
2670
2742
  let isSubmission = isMutationMethod(request.method);
2671
2743
  let routeIdsToLoad = !isSubmission && url.searchParams.has("_routes") ? url.searchParams.get("_routes").split(",") : null;
2672
2744
  let actionResult;
2745
+ let handledSubmission = false;
2673
2746
  const ctx = {
2674
2747
  request,
2675
2748
  runningAction: false
@@ -2683,39 +2756,24 @@ async function generateRenderResponse(request, staticHandler, basename, isDataRe
2683
2756
  async generateMiddlewareResponse(query) {
2684
2757
  let formState;
2685
2758
  let skipRevalidation = false;
2686
- let potentialCSRFAttackError;
2687
- if (isMutationMethod(request.method)) {
2688
- try {
2689
- throwIfPotentialCSRFAttack(request, allowedActionOrigins);
2690
- } catch (error) {
2691
- onError?.(error);
2692
- potentialCSRFAttackError = error;
2693
- request = new Request(request.url, {
2694
- method: "GET",
2695
- headers: request.headers,
2696
- signal: request.signal
2697
- });
2698
- }
2699
- if (!potentialCSRFAttackError) {
2700
- ctx.runningAction = true;
2701
- let result = await processServerAction(request, basename, decodeReply, loadServerAction, decodeAction, decodeFormState, onError, temporaryReferences).finally(() => {
2702
- ctx.runningAction = false;
2703
- });
2704
- if (isResponse(result)) return generateRedirectResponse(result, actionResult, basename, isDataRequest, generateResponse, temporaryReferences, result === ctx.redirect ? void 0 : ctx.redirect?.headers);
2705
- skipRevalidation = result?.skipRevalidation ?? false;
2706
- actionResult = result?.actionResult;
2707
- formState = result?.formState;
2708
- request = result?.revalidationRequest ?? request;
2709
- if (ctx.redirect) return generateRedirectResponse(ctx.redirect, actionResult, basename, isDataRequest, generateResponse, temporaryReferences, void 0);
2710
- }
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);
2711
2771
  }
2712
2772
  let staticContext = await query(request, skipRevalidation ? { filterMatchesToLoad: () => false } : void 0);
2713
2773
  if (isResponse(staticContext)) return generateRedirectResponse(staticContext, actionResult, basename, isDataRequest, generateResponse, temporaryReferences, ctx.redirect?.headers);
2714
- if (potentialCSRFAttackError) {
2715
- staticContext.errors ??= {};
2716
- staticContext.errors[staticContext.matches[0].route.id] = potentialCSRFAttackError;
2717
- staticContext.statusCode = 400;
2718
- }
2774
+ if (staticContext.errors) Object.values(staticContext.errors).forEach((error) => {
2775
+ if (!isRouteErrorResponse(error) || error.error) onError?.(error);
2776
+ });
2719
2777
  return generateStaticContextResponse(staticHandler, basename, generateResponse, statusCode, routeIdsToLoad, isDataRequest, isSubmission, actionResult, formState, staticContext, temporaryReferences, skipRevalidation, ctx.redirect?.headers, routeDiscovery, clientVersion);
2720
2778
  }
2721
2779
  }));
@@ -2860,6 +2918,7 @@ async function getRSCRouteMatch({ staticContext, match, isBelowErrorBoundary, ro
2860
2918
  return {
2861
2919
  clientAction: route.clientAction,
2862
2920
  clientLoader: route.clientLoader,
2921
+ clientMiddleware: route.clientMiddleware,
2863
2922
  element,
2864
2923
  errorElement,
2865
2924
  handle: route.handle,
@@ -2887,6 +2946,7 @@ async function getManifestRoute(route) {
2887
2946
  return {
2888
2947
  clientAction: route.clientAction,
2889
2948
  clientLoader: route.clientLoader,
2949
+ clientMiddleware: route.clientMiddleware,
2890
2950
  handle: route.handle,
2891
2951
  hasAction: !!route.action,
2892
2952
  hasComponent: !!route.Component,
@@ -2996,14 +3056,14 @@ function href(path, ...args) {
2996
3056
  let result = trimTrailingSplat(path).replace(/\/:([\w-]+)(\?)?/g, (_, param, questionMark) => {
2997
3057
  const isRequired = questionMark === void 0;
2998
3058
  const value = params?.[param];
2999
- if (isRequired && value === void 0) throw new Error(`Path '${path}' requires param '${param}' but it was not provided`);
3059
+ if (isRequired && value == null) throw new Error(`Path '${path}' requires param '${param}' but it was not provided`);
3000
3060
  return value == null ? "" : "/" + encodePathParam(stringify(value));
3001
3061
  });
3002
3062
  if (path.endsWith("*")) {
3003
3063
  const value = params?.["*"];
3004
- if (value !== void 0) result += "/" + stringify(value).split("/").map(encodePathParam).join("/");
3064
+ if (value != null) result += "/" + stringify(value).split("/").map(encodePathParam).join("/");
3005
3065
  }
3006
- return result || "/";
3066
+ return result.replace(/^\/{2,}/, "/") || "/";
3007
3067
  }
3008
3068
  /**
3009
3069
  * Removes a trailing splat and any number of slashes from the end of the path.
@@ -3235,6 +3295,7 @@ const createSession = (initialData = {}, id = "") => {
3235
3295
  },
3236
3296
  unset(name) {
3237
3297
  map.delete(name);
3298
+ map.delete(flash(name));
3238
3299
  }
3239
3300
  };
3240
3301
  };
@@ -3268,8 +3329,9 @@ function createSessionStorage({ cookie: cookieArg, createData, readData, updateD
3268
3329
  warnOnceAboutSigningSessionCookie(cookie);
3269
3330
  return {
3270
3331
  async getSession(cookieHeader, options) {
3271
- let id = cookieHeader && await cookie.parse(cookieHeader, options);
3272
- 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);
3273
3335
  },
3274
3336
  async commitSession(session, options) {
3275
3337
  let { id, data } = session;
@@ -3315,7 +3377,8 @@ function createCookieSessionStorage({ cookie: cookieArg } = {}) {
3315
3377
  warnOnceAboutSigningSessionCookie(cookie);
3316
3378
  return {
3317
3379
  async getSession(cookieHeader, options) {
3318
- 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 : {});
3319
3382
  },
3320
3383
  async commitSession(session, options) {
3321
3384
  let serializedCookie = await cookie.serialize(session.data, options);
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.1
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.1
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.1
2
+ * react-router v8.5.3
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *