react-router 8.5.0 → 8.5.2

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 (214) hide show
  1. package/CHANGELOG.md +70 -1
  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 +75 -415
  5. package/dist/development/index-react-server.js +106 -20
  6. package/dist/development/index.js +1 -1
  7. package/dist/development/lib/actions.js +1 -1
  8. package/dist/development/lib/await.js +58 -0
  9. package/dist/development/lib/components.d.ts +65 -25
  10. package/dist/development/lib/components.js +69 -15
  11. package/dist/development/lib/context.d.ts +2 -2
  12. package/dist/development/lib/context.js +1 -1
  13. package/dist/development/lib/dom/dom.js +13 -4
  14. package/dist/development/lib/dom/lib.d.ts +2 -2
  15. package/dist/development/lib/dom/lib.js +11 -4
  16. package/dist/development/lib/dom/server.js +1 -1
  17. package/dist/development/lib/dom/ssr/components.js +1 -1
  18. package/dist/development/lib/dom/ssr/data.js +1 -1
  19. package/dist/development/lib/dom/ssr/errorBoundaries.js +1 -1
  20. package/dist/development/lib/dom/ssr/fallback.js +1 -1
  21. package/dist/development/lib/dom/ssr/fog-of-war.js +12 -3
  22. package/dist/development/lib/dom/ssr/hydration.d.ts +1 -0
  23. package/dist/development/lib/dom/ssr/hydration.js +1 -1
  24. package/dist/development/lib/dom/ssr/invariant.js +1 -1
  25. package/dist/development/lib/dom/ssr/links.js +1 -1
  26. package/dist/development/lib/dom/ssr/markup.js +1 -1
  27. package/dist/development/lib/dom/ssr/route-discovery.d.ts +2 -2
  28. package/dist/development/lib/dom/ssr/route-discovery.js +3 -3
  29. package/dist/development/lib/dom/ssr/routeModules.js +1 -1
  30. package/dist/development/lib/dom/ssr/routes-test-stub.js +1 -1
  31. package/dist/development/lib/dom/ssr/routes.js +1 -1
  32. package/dist/development/lib/dom/ssr/server.js +1 -1
  33. package/dist/development/lib/dom/ssr/single-fetch.d.ts +1 -1
  34. package/dist/development/lib/dom/ssr/single-fetch.js +7 -7
  35. package/dist/development/lib/dom-export/dom-router-provider.js +1 -1
  36. package/dist/development/lib/dom-export/hydrated-router.d.ts +1 -1
  37. package/dist/development/lib/dom-export/hydrated-router.js +5 -3
  38. package/dist/development/lib/errors.js +1 -1
  39. package/dist/development/lib/hooks.d.ts +0 -3
  40. package/dist/development/lib/hooks.js +13 -9
  41. package/dist/development/lib/href.js +4 -4
  42. package/dist/development/lib/router/history.js +1 -1
  43. package/dist/development/lib/router/instrumentation.js +1 -1
  44. package/dist/development/lib/router/matcher-route-pattern.js +1 -1
  45. package/dist/development/lib/router/matcher-route-pattern.preload.js +1 -1
  46. package/dist/development/lib/router/matcher.js +6 -1
  47. package/dist/development/lib/router/navigation.js +17 -2
  48. package/dist/development/lib/router/router.d.ts +2 -0
  49. package/dist/development/lib/router/router.js +62 -29
  50. package/dist/development/lib/router/url.js +1 -1
  51. package/dist/development/lib/router/utils.d.ts +13 -5
  52. package/dist/development/lib/router/utils.js +17 -8
  53. package/dist/development/lib/rsc/browser.js +28 -5
  54. package/dist/development/lib/rsc/errorBoundaries.js +1 -1
  55. package/dist/development/lib/rsc/html-stream/browser.js +1 -1
  56. package/dist/development/lib/rsc/html-stream/server.js +1 -1
  57. package/dist/development/lib/rsc/route-modules.js +1 -1
  58. package/dist/development/lib/rsc/server.rsc.d.ts +2 -0
  59. package/dist/development/lib/rsc/server.ssr.js +1 -1
  60. package/dist/development/lib/server-runtime/cookies.js +1 -1
  61. package/dist/development/lib/server-runtime/crypto.js +1 -1
  62. package/dist/development/lib/server-runtime/data.js +1 -1
  63. package/dist/development/lib/server-runtime/dev.js +1 -1
  64. package/dist/development/lib/server-runtime/entry.js +1 -1
  65. package/dist/development/lib/server-runtime/errors.js +1 -1
  66. package/dist/development/lib/server-runtime/headers.js +1 -1
  67. package/dist/development/lib/server-runtime/invariant.js +1 -1
  68. package/dist/development/lib/server-runtime/mode.js +1 -1
  69. package/dist/development/lib/server-runtime/routeMatching.js +1 -1
  70. package/dist/development/lib/server-runtime/routes.js +1 -1
  71. package/dist/development/lib/server-runtime/server.js +21 -10
  72. package/dist/development/lib/server-runtime/serverHandoff.js +1 -1
  73. package/dist/development/lib/server-runtime/sessions/cookieStorage.js +1 -1
  74. package/dist/development/lib/server-runtime/sessions/memoryStorage.js +1 -1
  75. package/dist/development/lib/server-runtime/sessions.js +2 -2
  76. package/dist/development/lib/server-runtime/single-fetch.js +1 -1
  77. package/dist/development/lib/server-runtime/urls.js +1 -1
  78. package/dist/development/lib/server-runtime/warnings.js +1 -1
  79. package/dist/development/lib/types/internal.js +1 -1
  80. package/dist/development/lib/types/route-module-annotations.d.ts +1 -1
  81. package/dist/development/route-pattern.js +1 -1
  82. package/dist/development/vendor/turbo-stream-v2/flatten.js +1 -1
  83. package/dist/development/vendor/turbo-stream-v2/turbo-stream.js +75 -66
  84. package/dist/development/vendor/turbo-stream-v2/unflatten.js +23 -3
  85. package/dist/development/vendor/turbo-stream-v2/utils.js +1 -1
  86. package/dist/production/dom-export.js +1 -1
  87. package/dist/production/index-react-server-client.js +1 -1
  88. package/dist/production/index-react-server.d.ts +75 -415
  89. package/dist/production/index-react-server.js +106 -20
  90. package/dist/production/index.js +1 -1
  91. package/dist/production/lib/actions.js +1 -1
  92. package/dist/production/lib/await.js +58 -0
  93. package/dist/production/lib/components.d.ts +65 -25
  94. package/dist/production/lib/components.js +69 -15
  95. package/dist/production/lib/context.d.ts +2 -2
  96. package/dist/production/lib/context.js +1 -1
  97. package/dist/production/lib/dom/dom.js +13 -4
  98. package/dist/production/lib/dom/lib.d.ts +2 -2
  99. package/dist/production/lib/dom/lib.js +11 -4
  100. package/dist/production/lib/dom/server.js +1 -1
  101. package/dist/production/lib/dom/ssr/components.js +1 -1
  102. package/dist/production/lib/dom/ssr/data.js +1 -1
  103. package/dist/production/lib/dom/ssr/errorBoundaries.js +1 -1
  104. package/dist/production/lib/dom/ssr/fallback.js +1 -1
  105. package/dist/production/lib/dom/ssr/fog-of-war.js +12 -3
  106. package/dist/production/lib/dom/ssr/hydration.d.ts +1 -0
  107. package/dist/production/lib/dom/ssr/hydration.js +1 -1
  108. package/dist/production/lib/dom/ssr/invariant.js +1 -1
  109. package/dist/production/lib/dom/ssr/links.js +1 -1
  110. package/dist/production/lib/dom/ssr/markup.js +1 -1
  111. package/dist/production/lib/dom/ssr/route-discovery.d.ts +2 -2
  112. package/dist/production/lib/dom/ssr/route-discovery.js +3 -3
  113. package/dist/production/lib/dom/ssr/routeModules.js +1 -1
  114. package/dist/production/lib/dom/ssr/routes-test-stub.js +1 -1
  115. package/dist/production/lib/dom/ssr/routes.js +1 -1
  116. package/dist/production/lib/dom/ssr/server.js +1 -1
  117. package/dist/production/lib/dom/ssr/single-fetch.d.ts +1 -1
  118. package/dist/production/lib/dom/ssr/single-fetch.js +7 -7
  119. package/dist/production/lib/dom-export/dom-router-provider.js +1 -1
  120. package/dist/production/lib/dom-export/hydrated-router.d.ts +1 -1
  121. package/dist/production/lib/dom-export/hydrated-router.js +5 -3
  122. package/dist/production/lib/errors.js +1 -1
  123. package/dist/production/lib/hooks.d.ts +0 -3
  124. package/dist/production/lib/hooks.js +13 -9
  125. package/dist/production/lib/href.js +4 -4
  126. package/dist/production/lib/router/history.js +1 -1
  127. package/dist/production/lib/router/instrumentation.js +1 -1
  128. package/dist/production/lib/router/matcher-route-pattern.js +1 -1
  129. package/dist/production/lib/router/matcher-route-pattern.preload.js +1 -1
  130. package/dist/production/lib/router/matcher.js +6 -1
  131. package/dist/production/lib/router/navigation.js +17 -2
  132. package/dist/production/lib/router/router.d.ts +2 -0
  133. package/dist/production/lib/router/router.js +62 -29
  134. package/dist/production/lib/router/url.js +1 -1
  135. package/dist/production/lib/router/utils.d.ts +13 -5
  136. package/dist/production/lib/router/utils.js +17 -8
  137. package/dist/production/lib/rsc/browser.js +28 -5
  138. package/dist/production/lib/rsc/errorBoundaries.js +1 -1
  139. package/dist/production/lib/rsc/html-stream/browser.js +1 -1
  140. package/dist/production/lib/rsc/html-stream/server.js +1 -1
  141. package/dist/production/lib/rsc/route-modules.js +1 -1
  142. package/dist/production/lib/rsc/server.rsc.d.ts +2 -0
  143. package/dist/production/lib/rsc/server.ssr.js +1 -1
  144. package/dist/production/lib/server-runtime/cookies.js +1 -1
  145. package/dist/production/lib/server-runtime/crypto.js +1 -1
  146. package/dist/production/lib/server-runtime/data.js +1 -1
  147. package/dist/production/lib/server-runtime/dev.js +1 -1
  148. package/dist/production/lib/server-runtime/entry.js +1 -1
  149. package/dist/production/lib/server-runtime/errors.js +1 -1
  150. package/dist/production/lib/server-runtime/headers.js +1 -1
  151. package/dist/production/lib/server-runtime/invariant.js +1 -1
  152. package/dist/production/lib/server-runtime/mode.js +1 -1
  153. package/dist/production/lib/server-runtime/routeMatching.js +1 -1
  154. package/dist/production/lib/server-runtime/routes.js +1 -1
  155. package/dist/production/lib/server-runtime/server.js +21 -10
  156. package/dist/production/lib/server-runtime/serverHandoff.js +1 -1
  157. package/dist/production/lib/server-runtime/sessions/cookieStorage.js +1 -1
  158. package/dist/production/lib/server-runtime/sessions/memoryStorage.js +1 -1
  159. package/dist/production/lib/server-runtime/sessions.js +2 -2
  160. package/dist/production/lib/server-runtime/single-fetch.js +1 -1
  161. package/dist/production/lib/server-runtime/urls.js +1 -1
  162. package/dist/production/lib/server-runtime/warnings.js +1 -1
  163. package/dist/production/lib/types/internal.js +1 -1
  164. package/dist/production/lib/types/route-module-annotations.d.ts +1 -1
  165. package/dist/production/route-pattern.js +1 -1
  166. package/dist/production/vendor/turbo-stream-v2/flatten.js +1 -1
  167. package/dist/production/vendor/turbo-stream-v2/turbo-stream.js +75 -66
  168. package/dist/production/vendor/turbo-stream-v2/unflatten.js +23 -3
  169. package/dist/production/vendor/turbo-stream-v2/utils.js +1 -1
  170. package/docs/explanation/backend-for-frontend.md +0 -3
  171. package/docs/explanation/code-splitting.md +0 -3
  172. package/docs/explanation/concurrency.md +0 -3
  173. package/docs/explanation/hot-module-replacement.md +0 -3
  174. package/docs/explanation/lazy-route-discovery.md +0 -3
  175. package/docs/explanation/progressive-enhancement.md +0 -3
  176. package/docs/explanation/race-conditions.md +0 -3
  177. package/docs/explanation/react-transitions.md +0 -3
  178. package/docs/explanation/sessions-and-cookies.md +1 -1
  179. package/docs/explanation/state-management.md +0 -3
  180. package/docs/explanation/styling.md +0 -3
  181. package/docs/explanation/type-safety.md +0 -3
  182. package/docs/how-to/accessibility.md +0 -6
  183. package/docs/how-to/client-data.md +0 -3
  184. package/docs/how-to/data-strategy.md +0 -3
  185. package/docs/how-to/error-boundary.md +0 -3
  186. package/docs/how-to/error-reporting.md +0 -3
  187. package/docs/how-to/fetchers.md +0 -3
  188. package/docs/how-to/file-route-conventions.md +0 -3
  189. package/docs/how-to/file-uploads.md +0 -3
  190. package/docs/how-to/form-validation.md +0 -3
  191. package/docs/how-to/headers.md +0 -3
  192. package/docs/how-to/instrumentation.md +0 -3
  193. package/docs/how-to/middleware.md +6 -3
  194. package/docs/how-to/navigation-blocking.md +0 -3
  195. package/docs/how-to/optimize-revalidation.md +0 -3
  196. package/docs/how-to/pre-rendering.md +0 -3
  197. package/docs/how-to/presets.md +0 -3
  198. package/docs/how-to/react-server-components.md +0 -3
  199. package/docs/how-to/resource-routes.md +0 -3
  200. package/docs/how-to/route-discovery.md +4 -2
  201. package/docs/how-to/route-module-type-safety.md +0 -3
  202. package/docs/how-to/security.md +0 -3
  203. package/docs/how-to/server-bundles.md +0 -3
  204. package/docs/how-to/spa.md +0 -3
  205. package/docs/how-to/status.md +0 -3
  206. package/docs/how-to/suspense.md +22 -6
  207. package/docs/how-to/using-handle.md +0 -3
  208. package/docs/how-to/view-transitions.md +0 -3
  209. package/docs/start/framework/data-loading.md +9 -0
  210. package/docs/upgrading/future.md +0 -12
  211. package/docs/upgrading/v7.md +14 -33
  212. package/package.json +1 -1
  213. package/dist/development/lib/dom/global.d.ts +0 -35
  214. package/dist/production/lib/dom/global.d.ts +0 -35
@@ -32,8 +32,8 @@ type FetchersContextObject = {
32
32
  fetcherData: Map<string, any>;
33
33
  };
34
34
  declare const FetchersContext: React$1.Context<FetchersContextObject | null>;
35
- declare const AwaitContext: React$1.Context<TrackedPromise | null>;
36
- declare const AwaitContextProvider: (props: React$1.ComponentProps<typeof AwaitContext.Provider>) => React$1.FunctionComponentElement<React$1.ProviderProps<TrackedPromise | null>>;
35
+ declare const AwaitContext: React$1.Context<TrackedPromise | PromiseSettledResult<unknown> | null>;
36
+ declare const AwaitContextProvider: (props: React$1.ComponentProps<typeof AwaitContext.Provider>) => React$1.FunctionComponentElement<React$1.ProviderProps<TrackedPromise | PromiseSettledResult<unknown> | null>>;
37
37
  interface NavigateOptions {
38
38
  /** Replace the current entry in the history stack instead of pushing a new one */
39
39
  replace?: boolean;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.0
2
+ * react-router v8.5.2
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.0
2
+ * react-router v8.5.2
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 { warning } from "../router/history.js";
11
+ import { createPath, parsePath, warning } from "../router/history.js";
12
12
  import { stripBasename } from "../router/utils.js";
13
13
  const defaultEncType = "application/x-www-form-urlencoded";
14
14
  function isHtmlElement(object) {
@@ -92,6 +92,15 @@ function getFormEncType(encType) {
92
92
  }
93
93
  return encType;
94
94
  }
95
+ function stripBasenameFromAction(action, basename) {
96
+ if (basename === "/") return action;
97
+ let path = parsePath(action);
98
+ let pathname = stripBasename(path.pathname || "", basename);
99
+ return pathname == null ? null : createPath({
100
+ ...path,
101
+ pathname
102
+ });
103
+ }
95
104
  function getFormSubmissionInfo(target, basename) {
96
105
  let method;
97
106
  let action;
@@ -100,7 +109,7 @@ function getFormSubmissionInfo(target, basename) {
100
109
  let body;
101
110
  if (isFormElement(target)) {
102
111
  let attr = target.getAttribute("action");
103
- action = attr ? stripBasename(attr, basename) : null;
112
+ action = attr ? stripBasenameFromAction(attr, basename) : null;
104
113
  method = target.getAttribute("method") || "get";
105
114
  encType = getFormEncType(target.getAttribute("enctype")) || defaultEncType;
106
115
  formData = new FormData(target);
@@ -108,7 +117,7 @@ function getFormSubmissionInfo(target, basename) {
108
117
  let form = target.form;
109
118
  if (form == null) throw new Error(`Cannot submit a <button> or <input type="submit"> without a <form>`);
110
119
  let attr = target.getAttribute("formaction") || form.getAttribute("action");
111
- action = attr ? stripBasename(attr, basename) : null;
120
+ action = attr ? stripBasenameFromAction(attr, basename) : null;
112
121
  method = target.getAttribute("formmethod") || form.getAttribute("method") || "get";
113
122
  encType = getFormEncType(target.getAttribute("formenctype")) || getFormEncType(form.getAttribute("enctype")) || defaultEncType;
114
123
  formData = new FormData(form, target);
@@ -69,7 +69,7 @@ interface DOMRouterOpts {
69
69
  *
70
70
  * You will almost always include a complete set of `loaderData` to hydrate a
71
71
  * server-rendered app. But in advanced use-cases (such as Framework Mode's
72
- * [`clientLoader`](../../start/framework/route-module#clientLoader)), you may
72
+ * [`clientLoader`](../../start/framework/route-module#clientloader)), you may
73
73
  * want to include `loaderData` for only some routes that were loaded/rendered
74
74
  * on the server. This allows you to hydrate _some_ of the routes (such as the
75
75
  * app layout/shell) while showing a `HydrateFallback` component and running
@@ -208,7 +208,7 @@ interface DOMRouterOpts {
208
208
  * To combat this, we introduced [`route.lazy`](../../start/data/route-object#lazy)
209
209
  * in [v6.9.0](https://github.com/remix-run/react-router/blob/main/CHANGELOG.md#v690)
210
210
  * which lets you lazily load the route _implementation_ ([`loader`](../../start/data/route-object#loader),
211
- * [`Component`](../../start/data/route-object#Component), etc.) while still
211
+ * [`Component`](../../start/data/route-object#component), etc.) while still
212
212
  * providing the route _definition_ aspects up front (`path`, `index`, etc.).
213
213
  * This is a good middle ground. React Router still knows about your route
214
214
  * definitions (the lightweight part) up front and can perform synchronous
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.0
2
+ * react-router v8.5.2
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -10,6 +10,7 @@
10
10
  */
11
11
  import { ABSOLUTE_URL_REGEX } from "../router/url.js";
12
12
  import { createBrowserHistory, createHashHistory, createPath, invariant, warning } from "../router/history.js";
13
+ import { validateDocumentNavigationTarget } from "../router/navigation.js";
13
14
  import { ErrorResponseImpl, SUPPORTED_ERROR_TYPES, defaultMapRouteProperties, joinPaths, matchPath, parseToInfo, resolveTo, stripBasename } from "../router/utils.js";
14
15
  import { IDLE_FETCHER, createRouter } from "../router/router.js";
15
16
  import { DataRouterNavigationContext, NavigationContext, RouteContext, ViewTransitionContext } from "../context.js";
@@ -314,10 +315,12 @@ const Link = React$1.forwardRef(function LinkWithRef({ onClick, discover = "rend
314
315
  if (!event.defaultPrevented) internalOnClick(event);
315
316
  }
316
317
  let isSpaLink = !(parsed.isExternal || reloadDocument);
318
+ let renderedHref = (isSpaLink ? maskedHref : void 0) || parsed.absoluteURL || href;
319
+ validateDocumentNavigationTarget(renderedHref);
317
320
  let link = /* @__PURE__ */ React$1.createElement("a", {
318
321
  ...rest,
319
322
  ...prefetchHandlers,
320
- href: (isSpaLink ? maskedHref : void 0) || parsed.absoluteURL || href,
323
+ href: renderedHref,
321
324
  onClick: isSpaLink ? handleClick : onClick,
322
325
  ref: mergeRefs(forwardedRef, prefetchRef),
323
326
  target,
@@ -562,7 +565,9 @@ function ScrollRestoration({ getKey, storageKey, ...props }) {
562
565
  if (typeof storedY === "number") window.scrollTo(0, storedY);
563
566
  } catch (error) {
564
567
  console.error(error);
565
- sessionStorage.removeItem(storageKey);
568
+ try {
569
+ sessionStorage.removeItem(storageKey);
570
+ } catch {}
566
571
  }
567
572
  }).toString();
568
573
  if (props.nonce == null && remixContext?.nonce) props.nonce = remixContext.nonce;
@@ -872,7 +877,9 @@ function useFormAction(action, { relative } = {}) {
872
877
  }
873
878
  if ((!action || action === ".") && match.route.index) path.search = path.search ? path.search.replace(/^\?/, "?index&") : "?index";
874
879
  if (basename !== "/") path.pathname = path.pathname === "/" ? basename : joinPaths([basename, path.pathname]);
875
- return createPath(path);
880
+ let formAction = createPath(path);
881
+ validateDocumentNavigationTarget(formAction);
882
+ return formAction;
876
883
  }
877
884
  /**
878
885
  * Useful for creating complex, dynamic user interfaces that require multiple,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.0
2
+ * react-router v8.5.2
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.0
2
+ * react-router v8.5.2
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.0
2
+ * react-router v8.5.2
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.0
2
+ * react-router v8.5.2
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.0
2
+ * react-router v8.5.2
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.0
2
+ * react-router v8.5.2
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -29,6 +29,12 @@ function getPathsWithAncestors(paths) {
29
29
  function isFogOfWarEnabled(routeDiscovery, ssr) {
30
30
  return routeDiscovery.mode === "lazy" && ssr;
31
31
  }
32
+ const MANIFEST_MATCH_COST_LIMIT = 5e4;
33
+ const MANIFEST_MATCH_COST_SEGMENT_THRESHOLD = 10;
34
+ function shouldUseInitialRouteDiscovery(pathname, matchCost = 0) {
35
+ let segmentCount = pathname.split("/").length - 1;
36
+ return Math.max(segmentCount - 1, 0) * pathname.length + 1 > 7680 || segmentCount > MANIFEST_MATCH_COST_SEGMENT_THRESHOLD && segmentCount * matchCost > MANIFEST_MATCH_COST_LIMIT;
37
+ }
32
38
  function getPartialManifest({ sri, ...manifest }, router) {
33
39
  let routeIds = new Set(router.state.matches.map((m) => m.route.id));
34
40
  let segments = router.state.location.pathname.split("/").filter(Boolean);
@@ -108,6 +114,9 @@ function useFogOFWarDiscovery(router, manifest, routeModules, ssr, routeDiscover
108
114
  isApiOnly
109
115
  ]);
110
116
  }
117
+ function getManifestPathsParam(paths) {
118
+ return paths.slice().sort().map((path) => path.replace(/,/g, "%2C")).join(",");
119
+ }
111
120
  function getManifestPath(_manifestPath, basename) {
112
121
  let manifestPath = _manifestPath || "/__manifest";
113
122
  return basename == null ? manifestPath : joinPaths([basename, manifestPath]);
@@ -160,7 +169,7 @@ async function handleClientVersionMismatch(needsReload, version, errorReloadPath
160
169
  async function fetchAndApplyManifestPatches(paths, errorReloadPath, manifest, routeModules, ssr, isSpaMode, basename, manifestPath, patchRoutes, signal, fetchImplementation = (request) => fetch(request), serverOrigin, isApiOnly = false) {
161
170
  paths = getPathsWithAncestors(paths);
162
171
  const searchParams = new URLSearchParams();
163
- searchParams.set("paths", paths.sort().join(","));
172
+ searchParams.set("paths", getManifestPathsParam(paths));
164
173
  searchParams.set("version", manifest.version);
165
174
  let url = new URL(getManifestPath(manifestPath, basename), serverOrigin ?? window.location.origin);
166
175
  url.search = searchParams.toString();
@@ -207,4 +216,4 @@ function debounce(callback, wait) {
207
216
  };
208
217
  }
209
218
  //#endregion
210
- export { URL_LIMIT, getManifestPath, getPartialManifest, getPatchRoutesOnNavigationFunction, getPathsWithAncestors, handleClientVersionMismatch, isFogOfWarEnabled, useFogOFWarDiscovery };
219
+ export { URL_LIMIT, getManifestPath, getManifestPathsParam, getPartialManifest, getPatchRoutesOnNavigationFunction, getPathsWithAncestors, handleClientVersionMismatch, isFogOfWarEnabled, shouldUseInitialRouteDiscovery, useFogOFWarDiscovery };
@@ -22,6 +22,7 @@ declare function getHydrationData({
22
22
  routes: DataRouteObject[];
23
23
  getRouteInfo: (routeId: string) => {
24
24
  clientLoader: ClientLoaderFunction | undefined;
25
+ clientMiddleware?: DataRouteObject["middleware"];
25
26
  hasLoader: boolean;
26
27
  hasHydrateFallback: boolean;
27
28
  };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.0
2
+ * react-router v8.5.2
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.0
2
+ * react-router v8.5.2
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.0
2
+ * react-router v8.5.2
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.0
2
+ * react-router v8.5.2
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -4,7 +4,7 @@ import { Router } from "../../router/router.js";
4
4
  import { ClientOnErrorFunction } from "../../components.js";
5
5
  import { RouteModules } from "./routeModules.js";
6
6
  import { RouterFetch } from "./single-fetch.js";
7
- import { WindowReactRouterContext } from "../global.js";
7
+ import { ServerHandoff } from "../../server-runtime/serverHandoff.js";
8
8
  import { AssetsManifest } from "./entry.js";
9
9
 
10
10
  //#region lib/dom/ssr/route-discovery.d.ts
@@ -37,7 +37,7 @@ type RouteDiscoverySsrInfo = {
37
37
  manifest: AssetsManifest;
38
38
  routeModules: RouteModules;
39
39
  router: Router | undefined;
40
- context: Pick<WindowReactRouterContext, "ssr" | "routeDiscovery" | "isSpaMode" | "basename" | "unstable_apiServerOrigin" | "unstable_apiOnly">;
40
+ context: Pick<ServerHandoff, "ssr" | "routeDiscovery" | "isSpaMode" | "basename" | "unstable_apiServerOrigin" | "unstable_apiOnly">;
41
41
  };
42
42
  declare class RouteDiscoveryRuntime {
43
43
  private ssrInfo;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.0
2
+ * react-router v8.5.2
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -11,7 +11,7 @@
11
11
  import { createPath, invariant } from "../../router/history.js";
12
12
  import { DiscoveryCancelledError, getRoutePattern, prependBasename } from "../../router/utils.js";
13
13
  import { createClientRoutes } from "./routes.js";
14
- import { getManifestPath, getPathsWithAncestors, handleClientVersionMismatch, isFogOfWarEnabled } from "./fog-of-war.js";
14
+ import { getManifestPath, getManifestPathsParam, getPathsWithAncestors, handleClientVersionMismatch, isFogOfWarEnabled } from "./fog-of-war.js";
15
15
  import { useFrameworkContext } from "./components.js";
16
16
  import * as React$1 from "react";
17
17
  //#region lib/dom/ssr/route-discovery.ts
@@ -158,7 +158,7 @@ var RouteDiscoveryRuntime = class {
158
158
  requestUrl(paths) {
159
159
  let { manifest, context } = this.ssrInfo;
160
160
  let params = new URLSearchParams();
161
- params.set("paths", paths.slice().sort().join(","));
161
+ params.set("paths", getManifestPathsParam(paths));
162
162
  params.set("version", manifest.version);
163
163
  let url = new URL(getManifestPath(context.routeDiscovery.manifestPath, context.basename), context.unstable_apiServerOrigin ?? window.location.origin);
164
164
  url.search = params.toString();
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.0
2
+ * react-router v8.5.2
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.0
2
+ * react-router v8.5.2
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.0
2
+ * react-router v8.5.2
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.0
2
+ * react-router v8.5.2
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -31,7 +31,7 @@ type RouterFetchContext = {
31
31
  navigationType: null;
32
32
  };
33
33
  type RouterFetch = (request: Request, context: RouterFetchContext) => Promise<Response>;
34
- declare function getTurboStreamSingleFetchDataStrategy(getRouter: () => Router, manifest: AssetsManifest, routeModules: RouteModules, ssr: boolean, fetchImplementation?: RouterFetch, isApiOnly?: boolean, serverOrigin?: string): DataStrategyFunction;
34
+ declare function getTurboStreamSingleFetchDataStrategy(getRouter: () => Router, manifest: AssetsManifest, routeModules: RouteModules, ssr: boolean, fetchImplementation?: RouterFetch, isApiOnly?: boolean, serverOrigin?: string, isSpaMode?: boolean): DataStrategyFunction;
35
35
  declare function decodeViaTurboStream(body: ReadableStream<Uint8Array>, global: Window | typeof globalThis): Promise<{
36
36
  done: Promise<void>;
37
37
  value: unknown;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.0
2
+ * react-router v8.5.2
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -56,7 +56,7 @@ function StreamTransfer({ context, identifier, reader, textDecoder, nonce }) {
56
56
  nonce
57
57
  })));
58
58
  }
59
- function getTurboStreamSingleFetchDataStrategy(getRouter, manifest, routeModules, ssr, fetchImplementation = (request) => fetch(request), isApiOnly = false, serverOrigin) {
59
+ function getTurboStreamSingleFetchDataStrategy(getRouter, manifest, routeModules, ssr, fetchImplementation = (request) => fetch(request), isApiOnly = false, serverOrigin, isSpaMode = false) {
60
60
  let dataStrategy = getSingleFetchDataStrategyImpl(getRouter, (match) => {
61
61
  let manifestRoute = manifest.routes[match.route.id];
62
62
  invariant(manifestRoute, "Route not found in manifest");
@@ -64,10 +64,10 @@ function getTurboStreamSingleFetchDataStrategy(getRouter, manifest, routeModules
64
64
  hasLoader: manifestRoute.hasLoader,
65
65
  hasClientLoader: manifestRoute.hasClientLoader
66
66
  };
67
- }, fetchAndDecodeViaTurboStream(fetchImplementation, serverOrigin), ssr, void 0, isApiOnly);
67
+ }, fetchAndDecodeViaTurboStream(fetchImplementation, serverOrigin), ssr, void 0, isApiOnly, isSpaMode);
68
68
  return async (args) => args.runClientMiddleware(dataStrategy);
69
69
  }
70
- function getSingleFetchDataStrategyImpl(getRouter, getRouteInfo, fetchAndDecode, ssr, shouldAllowOptOut = () => true, isApiOnly = false) {
70
+ function getSingleFetchDataStrategyImpl(getRouter, getRouteInfo, fetchAndDecode, ssr, shouldAllowOptOut = () => true, isApiOnly = false, isSpaMode = false) {
71
71
  return async (args) => {
72
72
  let { request, matches, fetcherKey } = args;
73
73
  let router = getRouter();
@@ -78,7 +78,7 @@ function getSingleFetchDataStrategyImpl(getRouter, getRouteInfo, fetchAndDecode,
78
78
  });
79
79
  if (!ssr && !foundRevalidatingServerLoader) return nonSsrStrategy(args, getRouteInfo, fetchAndDecode);
80
80
  if (fetcherKey) return singleFetchLoaderFetcherStrategy(args, fetchAndDecode);
81
- return singleFetchLoaderNavigationStrategy(args, router, getRouteInfo, fetchAndDecode, ssr, shouldAllowOptOut, isApiOnly);
81
+ return singleFetchLoaderNavigationStrategy(args, router, getRouteInfo, fetchAndDecode, ssr, shouldAllowOptOut, isApiOnly, isSpaMode);
82
82
  };
83
83
  }
84
84
  async function singleFetchActionStrategy(args, fetchAndDecode) {
@@ -113,7 +113,7 @@ async function nonSsrStrategy(args, getRouteInfo, fetchAndDecode) {
113
113
  }));
114
114
  return results;
115
115
  }
116
- async function singleFetchLoaderNavigationStrategy(args, router, getRouteInfo, fetchAndDecode, ssr, shouldAllowOptOut = () => true, isApiOnly = false) {
116
+ async function singleFetchLoaderNavigationStrategy(args, router, getRouteInfo, fetchAndDecode, ssr, shouldAllowOptOut = () => true, isApiOnly = false, isSpaMode = false) {
117
117
  let routesParams = /* @__PURE__ */ new Set();
118
118
  let foundOptOutRoute = false;
119
119
  let routeDfds = args.matches.map(() => createDeferred());
@@ -162,7 +162,7 @@ async function singleFetchLoaderNavigationStrategy(args, router, getRouteInfo, f
162
162
  }
163
163
  })));
164
164
  await Promise.all(routeDfds.map((d) => d.promise));
165
- if ((!router.state.initialized && router.state.navigation.state === "idle" && !isApiOnly || routesParams.size === 0) && !window.__reactRouterHdrActive) singleFetchDfd.resolve({ routes: {} });
165
+ if ((!router.state.initialized && router.state.navigation.state === "idle" && !isApiOnly && !isSpaMode || routesParams.size === 0) && !window.__reactRouterHdrActive) singleFetchDfd.resolve({ routes: {} });
166
166
  else {
167
167
  let targetRoutes = ssr && foundOptOutRoute && routesParams.size > 0 ? [...routesParams.keys()] : void 0;
168
168
  try {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.0
2
+ * react-router v8.5.2
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -15,7 +15,7 @@ interface HydratedRouterProps {
15
15
  * Context factory function to be passed through to {@link createBrowserRouter}.
16
16
  * This function will be called to create a fresh `context` instance on each
17
17
  * navigation/fetch and made available to
18
- * [`clientAction`](../../start/framework/route-module#clientAction)/[`clientLoader`](../../start/framework/route-module#clientLoader)
18
+ * [`clientAction`](../../start/framework/route-module#clientaction)/[`clientLoader`](../../start/framework/route-module#clientloader)
19
19
  * functions.
20
20
  */
21
21
  getContext?: RouterInit["getContext"];
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.0
2
+ * react-router v8.5.2
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -89,7 +89,7 @@ function createHydratedRouter({ getContext, instrumentations, fetch: fetchImplem
89
89
  mapRouteProperties: UNSAFE_defaultMapRouteProperties,
90
90
  hydrationRouteProperties: UNSAFE_hydrationRouteProperties,
91
91
  instrumentations,
92
- dataStrategy: UNSAFE_getTurboStreamSingleFetchDataStrategy(() => router, ssrInfo.manifest, ssrInfo.routeModules, ssr, fetchImplementation, ssrInfo.context.unstable_apiOnly === true, ssrInfo.context.unstable_apiServerOrigin),
92
+ dataStrategy: UNSAFE_getTurboStreamSingleFetchDataStrategy(() => router, ssrInfo.manifest, ssrInfo.routeModules, ssr, fetchImplementation, ssrInfo.context.unstable_apiOnly === true, ssrInfo.context.unstable_apiServerOrigin, ssrInfo.context.isSpaMode),
93
93
  patchRoutesOnNavigation: discoveryRuntime ? UNSAFE_getCustomPatchRoutesOnNavigationFunction(() => router, discoveryRuntime) : UNSAFE_getPatchRoutesOnNavigationFunction(() => router, ssrInfo.manifest, ssrInfo.routeModules, ssr, ssrInfo.context.routeDiscovery, ssrInfo.context.isSpaMode, ssrInfo.context.basename, fetchImplementation, ssrInfo.context.unstable_apiServerOrigin, isApiOnly)
94
94
  });
95
95
  ssrInfo.router = router;
@@ -126,7 +126,9 @@ function HydratedRouter(props) {
126
126
  }
127
127
  let [criticalCss, setCriticalCss] = React$1.useState(process.env.NODE_ENV === "development" ? ssrInfo?.context.criticalCss : void 0);
128
128
  React$1.useEffect(() => {
129
- if (process.env.NODE_ENV === "development") setCriticalCss(void 0);
129
+ if (process.env.NODE_ENV === "development") React$1.startTransition(() => {
130
+ setCriticalCss(void 0);
131
+ });
130
132
  }, []);
131
133
  React$1.useEffect(() => {
132
134
  if (process.env.NODE_ENV === "development" && criticalCss === void 0) document.querySelectorAll(`[${CRITICAL_CSS_DATA_ATTRIBUTE}]`).forEach((element) => element.remove());
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.0
2
+ * react-router v8.5.2
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -192,9 +192,6 @@ interface NavigateFunction {
192
192
  *
193
193
  * [MODES: framework, data]
194
194
  *
195
- * <br/>
196
- * <br/>
197
- *
198
195
  * To prevent {@link ScrollRestoration | `<ScrollRestoration>`} from resetting
199
196
  * the scroll position, use the `preventScrollReset` option.
200
197
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.0
2
+ * react-router v8.5.2
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -9,8 +9,8 @@
9
9
  * @license MIT
10
10
  */
11
11
  import { createPath, invariant, parsePath, warning } from "./router/history.js";
12
- import { convertRouteMatchToUiMatch, decodePath, getResolveToMatches, getRoutePattern, isBrowser, isRouteErrorResponse, joinPaths, matchPath, matchRoutes, parseToInfo, resolveTo, stripBasename } from "./router/utils.js";
13
12
  import { getNavigatorCurrentUrl, validateNavigationTarget } from "./router/navigation.js";
13
+ import { convertRouteMatchToUiMatch, decodePath, getResolveToMatches, getRoutePattern, isBrowser, isRouteErrorResponse, joinPaths, matchPath, matchRoutes, parseToInfo, resolveTo, stripBasename } from "./router/utils.js";
14
14
  import { IDLE_BLOCKER, hasInvalidProtocol } from "./router/router.js";
15
15
  import { AwaitContext, DataRouterContext, DataRouterDataContext, DataRouterNavigationContext, DataRouterStateContext, FetchersContext, IsDataRouteContext, LocationContext, NavigationContext, RSCRouterContext, RouteContext, RouteErrorContext, RouteIdContext } from "./context.js";
16
16
  import { decodeRedirectErrorDigest, decodeRouteErrorResponseDigest } from "./errors.js";
@@ -212,9 +212,6 @@ const navigateEffectWarning = "You should call navigate() in a React.useEffect()
212
212
  *
213
213
  * [MODES: framework, data]
214
214
  *
215
- * <br/>
216
- * <br/>
217
- *
218
215
  * To prevent {@link ScrollRestoration | `<ScrollRestoration>`} from resetting
219
216
  * the scroll position, use the `preventScrollReset` option.
220
217
  *
@@ -1110,7 +1107,8 @@ function useRouteError() {
1110
1107
  * @returns The resolved value from the nearest {@link Await} component
1111
1108
  */
1112
1109
  function useAsyncValue() {
1113
- return React$1.useContext(AwaitContext)?._data;
1110
+ let value = React$1.useContext(AwaitContext);
1111
+ return value && "status" in value && !("_tracked" in value) ? value.status === "fulfilled" ? value.value : void 0 : value?._data;
1114
1112
  }
1115
1113
  /**
1116
1114
  * Returns the rejection value from the closest {@link Await | `<Await>`}.
@@ -1138,7 +1136,8 @@ function useAsyncValue() {
1138
1136
  * @returns The error that was thrown in the nearest {@link Await} component
1139
1137
  */
1140
1138
  function useAsyncError() {
1141
- return React$1.useContext(AwaitContext)?._error;
1139
+ let value = React$1.useContext(AwaitContext);
1140
+ return value && "status" in value && !("_tracked" in value) ? value.status === "rejected" ? value.reason : void 0 : value?._error;
1142
1141
  }
1143
1142
  let blockerId = 0;
1144
1143
  /**
@@ -1270,13 +1269,18 @@ function useBlocker(shouldBlock) {
1270
1269
  historyAction
1271
1270
  });
1272
1271
  }, [basename, shouldBlock]);
1272
+ let activeBlockerKey = React$1.useRef("");
1273
1273
  React$1.useEffect(() => {
1274
1274
  let key = String(++blockerId);
1275
+ activeBlockerKey.current = key;
1275
1276
  setBlockerKey(key);
1276
- return () => router.deleteBlocker(key);
1277
+ return () => {
1278
+ activeBlockerKey.current = "";
1279
+ router.deleteBlocker(key);
1280
+ };
1277
1281
  }, [router]);
1278
1282
  React$1.useEffect(() => {
1279
- if (blockerKey !== "") router.getBlocker(blockerKey, blockerFunction);
1283
+ if (blockerKey !== "" && blockerKey === activeBlockerKey.current) router.getBlocker(blockerKey, blockerFunction);
1280
1284
  }, [
1281
1285
  router,
1282
1286
  blockerKey,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.0
2
+ * react-router v8.5.2
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -44,14 +44,14 @@ function href(path, ...args) {
44
44
  let result = trimTrailingSplat(path).replace(/\/:([\w-]+)(\?)?/g, (_, param, questionMark) => {
45
45
  const isRequired = questionMark === void 0;
46
46
  const value = params?.[param];
47
- if (isRequired && value === void 0) throw new Error(`Path '${path}' requires param '${param}' but it was not provided`);
47
+ if (isRequired && value == null) throw new Error(`Path '${path}' requires param '${param}' but it was not provided`);
48
48
  return value == null ? "" : "/" + encodePathParam(stringify(value));
49
49
  });
50
50
  if (path.endsWith("*")) {
51
51
  const value = params?.["*"];
52
- if (value !== void 0) result += "/" + stringify(value).split("/").map(encodePathParam).join("/");
52
+ if (value != null) result += "/" + stringify(value).split("/").map(encodePathParam).join("/");
53
53
  }
54
- return result || "/";
54
+ return result.replace(/^\/{2,}/, "/") || "/";
55
55
  }
56
56
  /**
57
57
  * Removes a trailing splat and any number of slashes from the end of the path.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.0
2
+ * react-router v8.5.2
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.0
2
+ * react-router v8.5.2
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.0
2
+ * react-router v8.5.2
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.0
2
+ * react-router v8.5.2
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.5.0
2
+ * react-router v8.5.2
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -14,12 +14,17 @@ var V6RegExMatcher = class {
14
14
  #routes = [];
15
15
  #branches = [];
16
16
  #basename;
17
+ #matchCost = 0;
17
18
  constructor(basename) {
18
19
  this.#basename = basename;
19
20
  }
20
21
  update(routes) {
21
22
  this.#routes = routes;
22
23
  this.#branches = flattenAndRankRoutes(routes);
24
+ this.#matchCost = this.#branches.reduce((total, branch) => total + branch.routesMeta.length, 0);
25
+ }
26
+ get matchCost() {
27
+ return this.#matchCost;
23
28
  }
24
29
  match(locationArg, allowPartial = false) {
25
30
  return matchRoutesImpl(this.#routes, locationArg, this.#basename, allowPartial, this.#branches);