react-router 7.16.0 → 7.18.0

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 (157) hide show
  1. package/CHANGELOG.md +21 -1
  2. package/dist/development/{browser-D3uq9sI1.d.ts → browser-B2PdsXXH.d.ts} +2 -2
  3. package/dist/development/{browser-nIQ4Nsyi.d.mts → browser-DBmQ1yAR.d.mts} +2 -2
  4. package/dist/development/{chunk-QUQL4437.mjs → chunk-4ZMWKKQ3.mjs} +115 -38
  5. package/dist/development/{chunk-S54KXAEJ.mjs → chunk-E4MTK73K.mjs} +45 -113
  6. package/dist/development/{chunk-SRID2YZ2.js → chunk-U7ORXROY.js} +113 -35
  7. package/dist/development/{chunk-XEJDWL2B.js → chunk-WW7PN6QI.js} +7 -7
  8. package/dist/{production/chunk-SKEDDLRM.js → development/chunk-YL5M26XI.js} +111 -108
  9. package/dist/development/{context-m8rizgnE.d.mts → context-CeD5LmaF.d.mts} +13 -5
  10. package/dist/{production/data-D4xhSy90.d.ts → development/data-CjO11-hU.d.ts} +9 -1
  11. package/dist/{production/data-U8FS-wNn.d.mts → development/data-DEjBmEfD.d.mts} +9 -1
  12. package/dist/development/dom-export.d.mts +4 -4
  13. package/dist/development/dom-export.d.ts +4 -4
  14. package/dist/development/dom-export.js +46 -44
  15. package/dist/development/dom-export.mjs +23 -21
  16. package/dist/{production/index-react-server-client-BLiUx67a.d.ts → development/index-react-server-client-3ykjivgQ.d.ts} +30 -8
  17. package/dist/development/{index-react-server-client-CdKROblb.d.mts → index-react-server-client-CACgcj2J.d.mts} +19 -5
  18. package/dist/development/index-react-server-client.d.mts +3 -3
  19. package/dist/development/index-react-server-client.d.ts +3 -3
  20. package/dist/development/index-react-server-client.js +4 -4
  21. package/dist/development/index-react-server-client.mjs +2 -2
  22. package/dist/development/index-react-server.d.mts +9 -1
  23. package/dist/development/index-react-server.d.ts +9 -1
  24. package/dist/development/index-react-server.js +144 -121
  25. package/dist/development/index-react-server.mjs +143 -120
  26. package/dist/development/index.d.mts +15 -14
  27. package/dist/development/index.d.ts +15 -14
  28. package/dist/development/index.js +137 -205
  29. package/dist/development/index.mjs +3 -5
  30. package/dist/{production/instrumentation-1q4YhLGP.d.ts → development/instrumentation-Dkmpzd13.d.ts} +2 -2
  31. package/dist/development/lib/types/internal.d.mts +2 -2
  32. package/dist/development/lib/types/internal.d.ts +2 -2
  33. package/dist/development/lib/types/internal.js +1 -1
  34. package/dist/development/lib/types/internal.mjs +1 -1
  35. package/dist/development/{register-CqK96Zfk.d.mts → register-CmkRspdl.d.mts} +1 -1
  36. package/dist/development/{register-CNAx3TXj.d.ts → register-roq_0qYo.d.ts} +1 -1
  37. package/dist/production/{browser-D3uq9sI1.d.ts → browser-B2PdsXXH.d.ts} +2 -2
  38. package/dist/production/{browser-nIQ4Nsyi.d.mts → browser-DBmQ1yAR.d.mts} +2 -2
  39. package/dist/production/{chunk-EAQNHM3N.js → chunk-3Z6WS2WZ.js} +7 -7
  40. package/dist/{development/chunk-IBI7OMNB.js → production/chunk-BIP66BKV.js} +111 -108
  41. package/dist/production/{chunk-NALGHHKE.mjs → chunk-EGOTSXNH.mjs} +45 -113
  42. package/dist/production/{chunk-Y7DNFQZP.js → chunk-IUPBOWYO.js} +113 -35
  43. package/dist/production/{chunk-Q65P7S7Y.mjs → chunk-M7NGGUU6.mjs} +115 -38
  44. package/dist/production/{context-m8rizgnE.d.mts → context-CeD5LmaF.d.mts} +13 -5
  45. package/dist/{development/data-D4xhSy90.d.ts → production/data-CjO11-hU.d.ts} +9 -1
  46. package/dist/{development/data-U8FS-wNn.d.mts → production/data-DEjBmEfD.d.mts} +9 -1
  47. package/dist/production/dom-export.d.mts +4 -4
  48. package/dist/production/dom-export.d.ts +4 -4
  49. package/dist/production/dom-export.js +46 -44
  50. package/dist/production/dom-export.mjs +23 -21
  51. package/dist/{development/index-react-server-client-BLiUx67a.d.ts → production/index-react-server-client-3ykjivgQ.d.ts} +30 -8
  52. package/dist/production/{index-react-server-client-CdKROblb.d.mts → index-react-server-client-CACgcj2J.d.mts} +19 -5
  53. package/dist/production/index-react-server-client.d.mts +3 -3
  54. package/dist/production/index-react-server-client.d.ts +3 -3
  55. package/dist/production/index-react-server-client.js +4 -4
  56. package/dist/production/index-react-server-client.mjs +2 -2
  57. package/dist/production/index-react-server.d.mts +9 -1
  58. package/dist/production/index-react-server.d.ts +9 -1
  59. package/dist/production/index-react-server.js +144 -121
  60. package/dist/production/index-react-server.mjs +143 -120
  61. package/dist/production/index.d.mts +15 -14
  62. package/dist/production/index.d.ts +15 -14
  63. package/dist/production/index.js +137 -205
  64. package/dist/production/index.mjs +3 -5
  65. package/dist/{development/instrumentation-1q4YhLGP.d.ts → production/instrumentation-Dkmpzd13.d.ts} +2 -2
  66. package/dist/production/lib/types/internal.d.mts +2 -2
  67. package/dist/production/lib/types/internal.d.ts +2 -2
  68. package/dist/production/lib/types/internal.js +1 -1
  69. package/dist/production/lib/types/internal.mjs +1 -1
  70. package/dist/production/{register-CqK96Zfk.d.mts → register-CmkRspdl.d.mts} +1 -1
  71. package/dist/production/{register-CNAx3TXj.d.ts → register-roq_0qYo.d.ts} +1 -1
  72. package/docs/explanation/backend-for-frontend.md +50 -0
  73. package/docs/explanation/code-splitting.md +61 -0
  74. package/docs/explanation/concurrency.md +135 -0
  75. package/docs/explanation/form-vs-fetcher.md +292 -0
  76. package/docs/explanation/hot-module-replacement.md +137 -0
  77. package/docs/explanation/hydration.md +14 -0
  78. package/docs/explanation/index-query-param.md +86 -0
  79. package/docs/explanation/index.md +4 -0
  80. package/docs/explanation/lazy-route-discovery.md +78 -0
  81. package/docs/explanation/location.md +6 -0
  82. package/docs/explanation/progressive-enhancement.md +150 -0
  83. package/docs/explanation/race-conditions.md +88 -0
  84. package/docs/explanation/react-transitions.md +160 -0
  85. package/docs/explanation/route-matching.md +7 -0
  86. package/docs/explanation/server-client-execution.md +4 -0
  87. package/docs/explanation/sessions-and-cookies.md +465 -0
  88. package/docs/explanation/special-files.md +16 -0
  89. package/docs/explanation/state-management.md +524 -0
  90. package/docs/explanation/styling.md +87 -0
  91. package/docs/explanation/type-safety.md +82 -0
  92. package/docs/how-to/accessibility.md +44 -0
  93. package/docs/how-to/client-data.md +199 -0
  94. package/docs/how-to/data-strategy.md +317 -0
  95. package/docs/how-to/error-boundary.md +231 -0
  96. package/docs/how-to/error-reporting.md +142 -0
  97. package/docs/how-to/fetchers.md +307 -0
  98. package/docs/how-to/file-route-conventions.md +410 -0
  99. package/docs/how-to/file-uploads.md +217 -0
  100. package/docs/how-to/form-validation.md +120 -0
  101. package/docs/how-to/headers.md +165 -0
  102. package/docs/how-to/index.md +4 -0
  103. package/docs/how-to/instrumentation.md +556 -0
  104. package/docs/how-to/meta.md +40 -0
  105. package/docs/how-to/middleware.md +763 -0
  106. package/docs/how-to/navigation-blocking.md +233 -0
  107. package/docs/how-to/optimize-revalidation.md +12 -0
  108. package/docs/how-to/pre-rendering.md +225 -0
  109. package/docs/how-to/presets.md +103 -0
  110. package/docs/how-to/react-server-components.md +899 -0
  111. package/docs/how-to/resource-routes.md +126 -0
  112. package/docs/how-to/route-module-type-safety.md +100 -0
  113. package/docs/how-to/search-params.md +4 -0
  114. package/docs/how-to/security.md +32 -0
  115. package/docs/how-to/server-bundles.md +66 -0
  116. package/docs/how-to/spa.md +120 -0
  117. package/docs/how-to/status.md +63 -0
  118. package/docs/how-to/suspense.md +132 -0
  119. package/docs/how-to/using-handle.md +117 -0
  120. package/docs/how-to/view-transitions.md +237 -0
  121. package/docs/how-to/webhook.md +50 -0
  122. package/docs/index.md +39 -0
  123. package/docs/start/data/actions.md +138 -0
  124. package/docs/start/data/custom.md +198 -0
  125. package/docs/start/data/data-loading.md +44 -0
  126. package/docs/start/data/index.md +4 -0
  127. package/docs/start/data/installation.md +56 -0
  128. package/docs/start/data/navigating.md +12 -0
  129. package/docs/start/data/pending-ui.md +12 -0
  130. package/docs/start/data/route-object.md +268 -0
  131. package/docs/start/data/routing.md +281 -0
  132. package/docs/start/data/testing.md +8 -0
  133. package/docs/start/declarative/index.md +4 -0
  134. package/docs/start/declarative/installation.md +43 -0
  135. package/docs/start/declarative/navigating.md +133 -0
  136. package/docs/start/declarative/routing.md +237 -0
  137. package/docs/start/declarative/url-values.md +65 -0
  138. package/docs/start/framework/actions.md +174 -0
  139. package/docs/start/framework/data-loading.md +201 -0
  140. package/docs/start/framework/deploying.md +100 -0
  141. package/docs/start/framework/index.md +4 -0
  142. package/docs/start/framework/installation.md +41 -0
  143. package/docs/start/framework/navigating.md +182 -0
  144. package/docs/start/framework/pending-ui.md +142 -0
  145. package/docs/start/framework/rendering.md +59 -0
  146. package/docs/start/framework/route-module.md +527 -0
  147. package/docs/start/framework/routing.md +362 -0
  148. package/docs/start/framework/testing.md +133 -0
  149. package/docs/start/index.md +4 -0
  150. package/docs/start/modes.md +201 -0
  151. package/docs/upgrading/component-routes.md +363 -0
  152. package/docs/upgrading/future.md +280 -0
  153. package/docs/upgrading/index.md +4 -0
  154. package/docs/upgrading/remix.md +403 -0
  155. package/docs/upgrading/router-provider.md +442 -0
  156. package/docs/upgrading/v6.md +382 -0
  157. package/package.json +2 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # `react-router`
2
2
 
3
+ ## v7.18.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Fix server handler prerender responses when using `ssr: false` and `future.v8_trailingSlashAwareDataRequests: true`. Avoids false positive "SPA Mode" detection when serving prerendered paths ([#15173](https://github.com/remix-run/react-router/pull/15173))
8
+ - Use the `ServerRouter` nonce for nonce-aware SSR components when they don't provide their own value so strict CSP pages can load them. ([#15170](https://github.com/remix-run/react-router/pull/15170))
9
+ - Use `turbo-stream` to serialize and deserialize Framework Mode hydration errors ([#15175](https://github.com/remix-run/react-router/pull/15175))
10
+ - Precompute route branch matchers to avoid recompiling route path regexes during matching ([#15186](https://github.com/remix-run/react-router/pull/15186))
11
+ - Use the constructed request URL host when validating action request origins. ([#15185](https://github.com/remix-run/react-router/pull/15185))
12
+ - Remove the un-documented custom error serialization logic from Data Mode SSR built-in hydration flows ([#15175](https://github.com/remix-run/react-router/pull/15175))
13
+ - Validate protocols in RSC render redirects ([#15177](https://github.com/remix-run/react-router/pull/15177))
14
+ - Consolidate url normalization logic and better handle mixed slashes ([#15176](https://github.com/remix-run/react-router/pull/15176))
15
+
16
+ ## v7.17.0
17
+
18
+ ### Minor Changes
19
+
20
+ - Ship a subset of the official documentation inside the `react-router` package ([#15121](https://github.com/remix-run/react-router/pull/15121))
21
+ - Markdown docs are now available in `node_modules/react-router/docs`, letting AI coding agents and the React Router agent skills read official docs locally
22
+ - Excludes auto-generated API docs (`api/`), `community/` content, and tutorials (`tutorials/`)
23
+
3
24
  ## v7.16.0
4
25
 
5
26
  ### Minor Changes
@@ -11,7 +32,6 @@
11
32
  - Disable manifest path when lazy route dicovery is disabled ([#15068](https://github.com/remix-run/react-router/pull/15068))
12
33
 
13
34
  - Fix browser URL creation to use the configured history window instead of the global window. ([#15066](https://github.com/remix-run/react-router/pull/15066))
14
-
15
35
  - Pass the history/router window through to `createBrowserURLImpl` so custom window contexts keep the correct URL origin.
16
36
 
17
37
  - Fix `useNavigation()` return type to preserve discriminated union across navigation states ([#15095](https://github.com/remix-run/react-router/pull/15095))
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
- import { R as RouterInit } from './instrumentation-1q4YhLGP.js';
3
- import { L as Location, C as ClientActionFunction, a as ClientLoaderFunction, b as LinksFunction, M as MetaFunction, S as ShouldRevalidateFunction, P as Params, c as RouterContextProvider, A as ActionFunction, H as HeadersFunction, d as LoaderFunction } from './data-D4xhSy90.js';
2
+ import { R as RouterInit } from './instrumentation-Dkmpzd13.js';
3
+ import { L as Location, C as ClientActionFunction, a as ClientLoaderFunction, b as LinksFunction, M as MetaFunction, S as ShouldRevalidateFunction, P as Params, c as RouterContextProvider, A as ActionFunction, H as HeadersFunction, d as LoaderFunction } from './data-CjO11-hU.js';
4
4
 
5
5
  declare function getRequest(): Request;
6
6
  type RSCRouteConfigEntryBase = {
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
- import { R as RouterInit } from './context-m8rizgnE.mjs';
3
- import { L as Location, C as ClientActionFunction, a as ClientLoaderFunction, b as LinksFunction, M as MetaFunction, S as ShouldRevalidateFunction, P as Params, c as RouterContextProvider, A as ActionFunction, H as HeadersFunction, d as LoaderFunction } from './data-U8FS-wNn.mjs';
2
+ import { R as RouterInit } from './context-CeD5LmaF.mjs';
3
+ import { L as Location, C as ClientActionFunction, a as ClientLoaderFunction, b as LinksFunction, M as MetaFunction, S as ShouldRevalidateFunction, P as Params, c as RouterContextProvider, A as ActionFunction, H as HeadersFunction, d as LoaderFunction } from './data-DEjBmEfD.mjs';
4
4
 
5
5
  declare function getRequest(): Request;
6
6
  type RSCRouteConfigEntryBase = {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.16.0
2
+ * react-router v7.18.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -16,6 +16,13 @@ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read fr
16
16
  var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
17
17
  var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
18
18
 
19
+ // lib/router/url.ts
20
+ var ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i;
21
+ var PROTOCOL_RELATIVE_URL_REGEX = /^[\\/]{2}/;
22
+ function normalizeProtocolRelativeUrl(url, protocol) {
23
+ return protocol + url.replace(/\\/g, "/");
24
+ }
25
+
19
26
  // lib/router/history.ts
20
27
  var Action = /* @__PURE__ */ ((Action2) => {
21
28
  Action2["Pop"] = "POP";
@@ -373,7 +380,7 @@ function createBrowserURLImpl(windowImpl, to, isAbsolute = false) {
373
380
  invariant(base, "No window.location.(origin|href) available to create URL");
374
381
  let href = typeof to === "string" ? to : createPath(to);
375
382
  href = href.replace(/ $/, "%20");
376
- if (!isAbsolute && href.startsWith("//")) {
383
+ if (!isAbsolute && PROTOCOL_RELATIVE_URL_REGEX.test(href)) {
377
384
  href = base + href;
378
385
  }
379
386
  return new URL(href, base);
@@ -591,7 +598,18 @@ function flattenRoutes(routes, branches = [], parentsMeta = [], parentPath = "",
591
598
  branches.push({
592
599
  path,
593
600
  score: computeScore(path, route.index),
594
- routesMeta
601
+ routesMeta: routesMeta.map((meta2, i) => {
602
+ let [matcher, params] = compilePath(
603
+ meta2.relativePath,
604
+ meta2.caseSensitive,
605
+ i === routesMeta.length - 1
606
+ );
607
+ return {
608
+ ...meta2,
609
+ matcher,
610
+ compiledParams: params
611
+ };
612
+ })
595
613
  });
596
614
  };
597
615
  routes.forEach((route, index) => {
@@ -680,9 +698,19 @@ function matchRouteBranch(branch, pathname, allowPartial = false) {
680
698
  let meta = routesMeta[i];
681
699
  let end = i === routesMeta.length - 1;
682
700
  let remainingPathname = matchedPathname === "/" ? pathname : pathname.slice(matchedPathname.length) || "/";
683
- let match = matchPath(
684
- { path: meta.relativePath, caseSensitive: meta.caseSensitive, end },
685
- remainingPathname
701
+ let pattern = {
702
+ path: meta.relativePath,
703
+ caseSensitive: meta.caseSensitive,
704
+ end
705
+ };
706
+ let match = (
707
+ // Use precomputed matcher if it exists
708
+ meta.matcher && meta.compiledParams ? matchPathImpl(
709
+ pattern,
710
+ remainingPathname,
711
+ meta.matcher,
712
+ meta.compiledParams
713
+ ) : matchPath(pattern, remainingPathname)
686
714
  );
687
715
  let route = meta.route;
688
716
  if (!match && end && allowPartial && !routesMeta[routesMeta.length - 1].route.index) {
@@ -750,6 +778,9 @@ function matchPath(pattern, pathname) {
750
778
  pattern.caseSensitive,
751
779
  pattern.end
752
780
  );
781
+ return matchPathImpl(pattern, pathname, matcher, compiledParams);
782
+ }
783
+ function matchPathImpl(pattern, pathname, matcher, compiledParams) {
753
784
  let match = pathname.match(matcher);
754
785
  if (!match) return null;
755
786
  let matchedPathname = match[0];
@@ -839,7 +870,6 @@ function prependBasename({
839
870
  }) {
840
871
  return pathname === "/" ? basename : joinPaths([basename, pathname]);
841
872
  }
842
- var ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
843
873
  var isAbsoluteUrl = (url) => ABSOLUTE_URL_REGEX.test(url);
844
874
  function resolvePath(to, fromPathname = "/") {
845
875
  let {
@@ -936,7 +966,7 @@ function resolveTo(toArg, routePathnames, locationPathname, isPathRelative = fal
936
966
  }
937
967
  return path;
938
968
  }
939
- var removeDoubleSlashes = (path) => path.replace(/\/\/+/g, "/");
969
+ var removeDoubleSlashes = (path) => path.replace(/[\\/]{2,}/g, "/");
940
970
  var joinPaths = (paths) => removeDoubleSlashes(paths.join("/"));
941
971
  var removeTrailingSlash = (path) => path.replace(/\/+$/, "");
942
972
  var normalizePathname = (pathname) => removeTrailingSlash(pathname).replace(/^\/*/, "/");
@@ -976,6 +1006,14 @@ var replace = (url, init) => {
976
1006
  response.headers.set("X-Remix-Replace", "true");
977
1007
  return response;
978
1008
  };
1009
+ var SUPPORTED_ERROR_TYPES = [
1010
+ "EvalError",
1011
+ "RangeError",
1012
+ "ReferenceError",
1013
+ "SyntaxError",
1014
+ "TypeError",
1015
+ "URIError"
1016
+ ];
979
1017
  var ErrorResponseImpl = class {
980
1018
  constructor(status, statusText, data2, internal = false) {
981
1019
  this.status = status;
@@ -1011,7 +1049,7 @@ function parseToInfo(_to, basename) {
1011
1049
  if (isBrowser) {
1012
1050
  try {
1013
1051
  let currentUrl = new URL(window.location.href);
1014
- let targetUrl = to.startsWith("//") ? new URL(currentUrl.protocol + to) : new URL(to);
1052
+ let targetUrl = PROTOCOL_RELATIVE_URL_REGEX.test(to) ? new URL(normalizeProtocolRelativeUrl(to, currentUrl.protocol)) : new URL(to);
1015
1053
  let path = stripBasename(targetUrl.pathname, basename);
1016
1054
  if (targetUrl.origin === currentUrl.origin && path != null) {
1017
1055
  to = path + targetUrl.search + targetUrl.hash;
@@ -5203,11 +5241,20 @@ var invalidProtocols = [
5203
5241
  // eslint-disable-next-line no-script-url
5204
5242
  "javascript:"
5205
5243
  ];
5244
+ function hasInvalidProtocol(location) {
5245
+ try {
5246
+ return invalidProtocols.includes(new URL(location).protocol);
5247
+ } catch {
5248
+ return false;
5249
+ }
5250
+ }
5206
5251
  function normalizeRedirectLocation(location, currentUrl, basename, historyInstance) {
5207
5252
  if (isAbsoluteUrl(location)) {
5208
5253
  let normalizedLocation = location;
5209
- let url = normalizedLocation.startsWith("//") ? new URL(currentUrl.protocol + normalizedLocation) : new URL(normalizedLocation);
5210
- if (invalidProtocols.includes(url.protocol)) {
5254
+ let url = PROTOCOL_RELATIVE_URL_REGEX.test(normalizedLocation) ? new URL(
5255
+ normalizeProtocolRelativeUrl(normalizedLocation, currentUrl.protocol)
5256
+ ) : new URL(normalizedLocation);
5257
+ if (hasInvalidProtocol(url.toString())) {
5211
5258
  throw new Error("Invalid redirect location");
5212
5259
  }
5213
5260
  let isSameBasename = stripBasename(url.pathname, basename) != null;
@@ -5217,7 +5264,7 @@ function normalizeRedirectLocation(location, currentUrl, basename, historyInstan
5217
5264
  }
5218
5265
  try {
5219
5266
  let url = historyInstance.createURL(location);
5220
- if (invalidProtocols.includes(url.protocol)) {
5267
+ if (hasInvalidProtocol(url.toString())) {
5221
5268
  throw new Error("Invalid redirect location");
5222
5269
  }
5223
5270
  } catch (e) {
@@ -6146,9 +6193,13 @@ function RSCErrorHandler({
6146
6193
  let existingRedirect = errorRedirectHandledMap.get(error);
6147
6194
  if (existingRedirect) throw existingRedirect;
6148
6195
  let parsed = parseToInfo(redirect2.location, basename);
6196
+ let target = parsed.absoluteURL || parsed.to;
6197
+ if (hasInvalidProtocol(target)) {
6198
+ throw new Error("Invalid redirect location");
6199
+ }
6149
6200
  if (isBrowser && !errorRedirectHandledMap.get(error)) {
6150
6201
  if (parsed.isExternal || redirect2.reloadDocument) {
6151
- window.location.href = parsed.absoluteURL || parsed.to;
6202
+ window.location.href = target;
6152
6203
  } else {
6153
6204
  const redirectPromise = Promise.resolve().then(
6154
6205
  () => window.__reactRouterDataRouter.navigate(parsed.to, {
@@ -6159,13 +6210,7 @@ function RSCErrorHandler({
6159
6210
  throw redirectPromise;
6160
6211
  }
6161
6212
  }
6162
- return /* @__PURE__ */ React2.createElement(
6163
- "meta",
6164
- {
6165
- httpEquiv: "refresh",
6166
- content: `0;url=${parsed.absoluteURL || parsed.to}`
6167
- }
6168
- );
6213
+ return /* @__PURE__ */ React2.createElement("meta", { httpEquiv: "refresh", content: `0;url=${target}` });
6169
6214
  }
6170
6215
  }
6171
6216
  return children;
@@ -7417,14 +7462,6 @@ var TYPE_SET = "S";
7417
7462
  var TYPE_SYMBOL = "Y";
7418
7463
  var TYPE_URL = "U";
7419
7464
  var TYPE_PREVIOUS_RESOLVED = "Z";
7420
- var SUPPORTED_ERROR_TYPES = [
7421
- "EvalError",
7422
- "RangeError",
7423
- "ReferenceError",
7424
- "SyntaxError",
7425
- "TypeError",
7426
- "URIError"
7427
- ];
7428
7465
  var Deferred2 = class {
7429
7466
  constructor() {
7430
7467
  this.promise = new Promise((resolve, reject) => {
@@ -8901,9 +8938,11 @@ import * as React6 from "react";
8901
8938
  // lib/dom/ssr/fallback.tsx
8902
8939
  import * as React5 from "react";
8903
8940
  function RemixRootDefaultHydrateFallback() {
8941
+ let { nonce } = useFrameworkContext();
8904
8942
  return /* @__PURE__ */ React5.createElement(BoundaryShell, { title: "Loading...", renderScripts: true }, ENABLE_DEV_WARNINGS ? /* @__PURE__ */ React5.createElement(
8905
8943
  "script",
8906
8944
  {
8945
+ nonce,
8907
8946
  dangerouslySetInnerHTML: {
8908
8947
  __html: `
8909
8948
  console.log(
@@ -9323,6 +9362,21 @@ var nextPaths = /* @__PURE__ */ new Set();
9323
9362
  var discoveredPathsMaxSize = 1e3;
9324
9363
  var discoveredPaths = /* @__PURE__ */ new Set();
9325
9364
  var URL_LIMIT = 7680;
9365
+ function getPathsWithAncestors(paths) {
9366
+ let result = /* @__PURE__ */ new Set();
9367
+ paths.forEach((path) => {
9368
+ if (!path.startsWith("/")) {
9369
+ path = `/${path}`;
9370
+ }
9371
+ for (let i = 1; i < path.length; i++) {
9372
+ if (path[i] === "/") {
9373
+ result.add(path.slice(0, i));
9374
+ }
9375
+ }
9376
+ result.add(path);
9377
+ });
9378
+ return Array.from(result);
9379
+ }
9326
9380
  function isFogOfWarEnabled(routeDiscovery, ssr) {
9327
9381
  return routeDiscovery.mode === "lazy" && ssr === true;
9328
9382
  }
@@ -9444,6 +9498,7 @@ function getManifestPath(_manifestPath, basename) {
9444
9498
  }
9445
9499
  var MANIFEST_VERSION_STORAGE_KEY = "react-router-manifest-version";
9446
9500
  async function fetchAndApplyManifestPatches(paths, errorReloadPath, manifest, routeModules, ssr, isSpaMode, basename, manifestPath, patchRoutes, signal) {
9501
+ paths = getPathsWithAncestors(paths);
9447
9502
  const searchParams = new URLSearchParams();
9448
9503
  searchParams.set("paths", paths.sort().join(","));
9449
9504
  searchParams.set("version", manifest.version);
@@ -9636,13 +9691,22 @@ function getActiveMatches(matches, errors, isSpaMode) {
9636
9691
  }
9637
9692
  var CRITICAL_CSS_DATA_ATTRIBUTE = "data-react-router-critical-css";
9638
9693
  function Links({ nonce, crossOrigin }) {
9639
- let { isSpaMode, manifest, routeModules, criticalCss } = useFrameworkContext();
9694
+ let {
9695
+ isSpaMode,
9696
+ manifest,
9697
+ routeModules,
9698
+ criticalCss,
9699
+ nonce: contextNonce
9700
+ } = useFrameworkContext();
9640
9701
  let { errors, matches: routerMatches } = useDataRouterStateContext();
9641
9702
  let matches = getActiveMatches(routerMatches, errors, isSpaMode);
9642
9703
  let keyedLinks = React8.useMemo(
9643
9704
  () => getKeyedLinksForMatches(matches, routeModules, manifest),
9644
9705
  [matches, routeModules, manifest]
9645
9706
  );
9707
+ if (nonce == null && contextNonce) {
9708
+ nonce = contextNonce;
9709
+ }
9646
9710
  return /* @__PURE__ */ React8.createElement(React8.Fragment, null, typeof criticalCss === "string" ? /* @__PURE__ */ React8.createElement(
9647
9711
  "style",
9648
9712
  {
@@ -9681,6 +9745,7 @@ function Links({ nonce, crossOrigin }) {
9681
9745
  }
9682
9746
  function PrefetchPageLinks({ page, ...linkProps }) {
9683
9747
  let rsc = useIsRSCRouterContext();
9748
+ let { nonce: contextNonce } = useFrameworkContext();
9684
9749
  let { router } = useDataRouterContext2();
9685
9750
  let matches = React8.useMemo(
9686
9751
  () => matchRoutes(router.routes, page, router.basename),
@@ -9689,6 +9754,9 @@ function PrefetchPageLinks({ page, ...linkProps }) {
9689
9754
  if (!matches) {
9690
9755
  return null;
9691
9756
  }
9757
+ if (linkProps.nonce == null && contextNonce) {
9758
+ linkProps = { ...linkProps, nonce: contextNonce };
9759
+ }
9692
9760
  if (rsc) {
9693
9761
  return /* @__PURE__ */ React8.createElement(RSCPrefetchPageLinksImpl, { page, matches, ...linkProps });
9694
9762
  }
@@ -9962,12 +10030,16 @@ function Scripts(scriptProps) {
9962
10030
  isSpaMode,
9963
10031
  renderMeta,
9964
10032
  routeDiscovery,
9965
- ssr
10033
+ ssr,
10034
+ nonce: contextNonce
9966
10035
  } = useFrameworkContext();
9967
10036
  let { router, static: isStatic, staticContext } = useDataRouterContext2();
9968
10037
  let { matches: routerMatches } = useDataRouterStateContext();
9969
10038
  let isRSCRouterContext = useIsRSCRouterContext();
9970
10039
  let enableFogOfWar = isFogOfWarEnabled(routeDiscovery, ssr);
10040
+ if (scriptProps.nonce == null && contextNonce) {
10041
+ scriptProps = { ...scriptProps, nonce: contextNonce };
10042
+ }
9971
10043
  if (renderMeta) {
9972
10044
  renderMeta.didRenderScripts = true;
9973
10045
  }
@@ -10163,10 +10235,12 @@ function RemixRootDefaultErrorBoundary({
10163
10235
  error,
10164
10236
  isOutsideRemixApp
10165
10237
  }) {
10238
+ let { nonce } = useFrameworkContext();
10166
10239
  console.error(error);
10167
10240
  let heyDeveloper = /* @__PURE__ */ React9.createElement(
10168
10241
  "script",
10169
10242
  {
10243
+ nonce,
10170
10244
  dangerouslySetInnerHTML: {
10171
10245
  __html: `
10172
10246
  console.log(
@@ -10233,7 +10307,7 @@ var isBrowser2 = typeof window !== "undefined" && typeof window.document !== "un
10233
10307
  try {
10234
10308
  if (isBrowser2) {
10235
10309
  window.__reactRouterVersion = // @ts-expect-error
10236
- "7.16.0";
10310
+ "7.18.0";
10237
10311
  }
10238
10312
  } catch (e) {
10239
10313
  }
@@ -10292,7 +10366,7 @@ function deserializeErrors(errors) {
10292
10366
  val.internal === true
10293
10367
  );
10294
10368
  } else if (val && val.__type === "Error") {
10295
- if (val.__subType) {
10369
+ if (typeof val.__subType === "string" && SUPPORTED_ERROR_TYPES.includes(val.__subType)) {
10296
10370
  let ErrorConstructor = window[val.__subType];
10297
10371
  if (typeof ErrorConstructor === "function") {
10298
10372
  try {
@@ -10424,7 +10498,6 @@ function HistoryRouter({
10424
10498
  );
10425
10499
  }
10426
10500
  HistoryRouter.displayName = "unstable_HistoryRouter";
10427
- var ABSOLUTE_URL_REGEX2 = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
10428
10501
  var Link = React10.forwardRef(
10429
10502
  function LinkWithRef({
10430
10503
  onClick,
@@ -10443,7 +10516,7 @@ var Link = React10.forwardRef(
10443
10516
  ...rest
10444
10517
  }, forwardedRef) {
10445
10518
  let { basename, navigator, useTransitions } = React10.useContext(NavigationContext);
10446
- let isAbsolute = typeof to === "string" && ABSOLUTE_URL_REGEX2.test(to);
10519
+ let isAbsolute = typeof to === "string" && ABSOLUTE_URL_REGEX.test(to);
10447
10520
  let parsed = parseToInfo(to, basename);
10448
10521
  to = parsed.to;
10449
10522
  let href = useHref(to, { relative });
@@ -10590,7 +10663,7 @@ var Form = React10.forwardRef(
10590
10663
  let submit = useSubmit();
10591
10664
  let formAction = useFormAction(action, { relative });
10592
10665
  let formMethod = method.toLowerCase() === "get" ? "get" : "post";
10593
- let isAbsolute = typeof action === "string" && ABSOLUTE_URL_REGEX2.test(action);
10666
+ let isAbsolute = typeof action === "string" && ABSOLUTE_URL_REGEX.test(action);
10594
10667
  let submitHandler = (event) => {
10595
10668
  onSubmit && onSubmit(event);
10596
10669
  if (event.defaultPrevented) return;
@@ -10672,6 +10745,9 @@ function ScrollRestoration({
10672
10745
  sessionStorage.removeItem(storageKey2);
10673
10746
  }
10674
10747
  }).toString();
10748
+ if (props.nonce == null && remixContext?.nonce) {
10749
+ props.nonce = remixContext.nonce;
10750
+ }
10675
10751
  return /* @__PURE__ */ React10.createElement(
10676
10752
  "script",
10677
10753
  {
@@ -11372,16 +11448,16 @@ function createHref(to) {
11372
11448
  function encodeLocation(to) {
11373
11449
  let href = typeof to === "string" ? to : createPath(to);
11374
11450
  href = href.replace(/ $/, "%20");
11375
- let encoded = ABSOLUTE_URL_REGEX3.test(href) ? new URL(href) : new URL(href, "http://localhost");
11451
+ let encoded = ABSOLUTE_URL_REGEX.test(href) ? new URL(href) : new URL(href, "http://localhost");
11376
11452
  return {
11377
11453
  pathname: encoded.pathname,
11378
11454
  search: encoded.search,
11379
11455
  hash: encoded.hash
11380
11456
  };
11381
11457
  }
11382
- var ABSOLUTE_URL_REGEX3 = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
11383
11458
 
11384
11459
  export {
11460
+ PROTOCOL_RELATIVE_URL_REGEX,
11385
11461
  Action,
11386
11462
  createMemoryHistory,
11387
11463
  createBrowserHistory,
@@ -11411,7 +11487,7 @@ export {
11411
11487
  createRouter,
11412
11488
  createStaticHandler,
11413
11489
  getStaticContextFromError,
11414
- invalidProtocols,
11490
+ hasInvalidProtocol,
11415
11491
  isDataWithResponseInit,
11416
11492
  isResponse,
11417
11493
  isRedirectStatusCode,
@@ -11493,6 +11569,7 @@ export {
11493
11569
  createClientRoutes,
11494
11570
  shouldHydrateRouteLoader,
11495
11571
  URL_LIMIT,
11572
+ getPathsWithAncestors,
11496
11573
  getPatchRoutesOnNavigationFunction,
11497
11574
  useFogOFWarDiscovery,
11498
11575
  getManifestPath,