react-router 8.3.0 → 8.4.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 (176) hide show
  1. package/CHANGELOG.md +46 -2
  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 +50 -48
  5. package/dist/development/index-react-server.js +96 -43
  6. package/dist/development/index.d.ts +2 -2
  7. package/dist/development/index.js +3 -3
  8. package/dist/development/lib/actions.js +10 -5
  9. package/dist/development/lib/components.js +50 -10
  10. package/dist/development/lib/context.d.ts +14 -5
  11. package/dist/development/lib/context.js +11 -3
  12. package/dist/development/lib/dom/dom.js +2 -2
  13. package/dist/development/lib/dom/lib.js +33 -36
  14. package/dist/development/lib/dom/server.d.ts +6 -1
  15. package/dist/development/lib/dom/server.js +40 -14
  16. package/dist/development/lib/dom/ssr/components.js +16 -24
  17. package/dist/development/lib/dom/ssr/data.js +1 -1
  18. package/dist/development/lib/dom/ssr/entry.d.ts +4 -0
  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 +34 -12
  22. package/dist/development/lib/dom/ssr/hydration.d.ts +3 -1
  23. package/dist/development/lib/dom/ssr/hydration.js +6 -4
  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 +5 -2
  27. package/dist/development/lib/dom/ssr/routeModules.js +1 -1
  28. package/dist/development/lib/dom/ssr/routes-test-stub.js +1 -1
  29. package/dist/development/lib/dom/ssr/routes.js +1 -1
  30. package/dist/development/lib/dom/ssr/server.js +2 -2
  31. package/dist/development/lib/dom/ssr/single-fetch.js +13 -22
  32. package/dist/development/lib/dom-export/dom-router-provider.js +1 -1
  33. package/dist/development/lib/dom-export/hydrated-router.js +2 -1
  34. package/dist/development/lib/errors.js +1 -1
  35. package/dist/development/lib/hooks.js +54 -46
  36. package/dist/development/lib/href.js +1 -1
  37. package/dist/development/lib/router/history.js +2 -2
  38. package/dist/development/lib/router/instrumentation.js +1 -1
  39. package/dist/development/lib/router/matcher-route-pattern.d.ts +2 -0
  40. package/dist/development/lib/router/matcher-route-pattern.js +216 -0
  41. package/dist/development/lib/router/matcher-route-pattern.preload.d.ts +20 -0
  42. package/dist/development/lib/router/matcher-route-pattern.preload.js +36 -0
  43. package/dist/development/lib/router/matcher.d.ts +2 -0
  44. package/dist/development/lib/router/matcher.js +29 -0
  45. package/dist/development/lib/router/navigation.js +45 -0
  46. package/dist/development/lib/router/router.d.ts +21 -7
  47. package/dist/development/lib/router/router.js +111 -82
  48. package/dist/development/lib/router/url.js +1 -1
  49. package/dist/development/lib/router/utils.d.ts +6 -1
  50. package/dist/development/lib/router/utils.js +15 -9
  51. package/dist/development/lib/rsc/browser.js +5 -1
  52. package/dist/development/lib/rsc/errorBoundaries.js +1 -1
  53. package/dist/development/lib/rsc/html-stream/browser.js +1 -1
  54. package/dist/development/lib/rsc/html-stream/server.js +3 -5
  55. package/dist/development/lib/rsc/route-modules.js +1 -1
  56. package/dist/development/lib/rsc/server.rsc.d.ts +7 -0
  57. package/dist/development/lib/rsc/server.ssr.js +26 -22
  58. package/dist/development/lib/server-runtime/cookies.js +2 -2
  59. package/dist/development/lib/server-runtime/crypto.js +2 -2
  60. package/dist/development/lib/server-runtime/data.js +1 -1
  61. package/dist/development/lib/server-runtime/dev.js +2 -2
  62. package/dist/development/lib/server-runtime/entry.js +1 -1
  63. package/dist/development/lib/server-runtime/errors.js +1 -1
  64. package/dist/development/lib/server-runtime/headers.js +1 -1
  65. package/dist/development/lib/server-runtime/invariant.js +1 -1
  66. package/dist/development/lib/server-runtime/mode.js +1 -1
  67. package/dist/development/lib/server-runtime/routeMatching.js +3 -4
  68. package/dist/development/lib/server-runtime/routes.js +1 -1
  69. package/dist/development/lib/server-runtime/server.js +8 -7
  70. package/dist/development/lib/server-runtime/serverHandoff.js +1 -1
  71. package/dist/development/lib/server-runtime/sessions/cookieStorage.js +1 -1
  72. package/dist/development/lib/server-runtime/sessions/memoryStorage.js +1 -1
  73. package/dist/development/lib/server-runtime/sessions.js +1 -1
  74. package/dist/development/lib/server-runtime/single-fetch.js +2 -2
  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/route-pattern.d.ts +3 -0
  79. package/dist/development/route-pattern.js +12 -0
  80. package/dist/development/vendor/turbo-stream-v2/flatten.js +1 -1
  81. package/dist/development/vendor/turbo-stream-v2/turbo-stream.js +4 -4
  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 +50 -48
  87. package/dist/production/index-react-server.js +96 -43
  88. package/dist/production/index.d.ts +2 -2
  89. package/dist/production/index.js +3 -3
  90. package/dist/production/lib/actions.js +10 -5
  91. package/dist/production/lib/components.js +50 -10
  92. package/dist/production/lib/context.d.ts +14 -5
  93. package/dist/production/lib/context.js +11 -3
  94. package/dist/production/lib/dom/dom.js +2 -2
  95. package/dist/production/lib/dom/lib.js +33 -36
  96. package/dist/production/lib/dom/server.d.ts +6 -1
  97. package/dist/production/lib/dom/server.js +40 -14
  98. package/dist/production/lib/dom/ssr/components.js +16 -24
  99. package/dist/production/lib/dom/ssr/data.js +1 -1
  100. package/dist/production/lib/dom/ssr/entry.d.ts +4 -0
  101. package/dist/production/lib/dom/ssr/errorBoundaries.js +1 -1
  102. package/dist/production/lib/dom/ssr/fallback.js +1 -1
  103. package/dist/production/lib/dom/ssr/fog-of-war.js +34 -12
  104. package/dist/production/lib/dom/ssr/hydration.d.ts +3 -1
  105. package/dist/production/lib/dom/ssr/hydration.js +6 -4
  106. package/dist/production/lib/dom/ssr/invariant.js +1 -1
  107. package/dist/production/lib/dom/ssr/links.js +1 -1
  108. package/dist/production/lib/dom/ssr/markup.js +5 -2
  109. package/dist/production/lib/dom/ssr/routeModules.js +1 -1
  110. package/dist/production/lib/dom/ssr/routes-test-stub.js +1 -1
  111. package/dist/production/lib/dom/ssr/routes.js +1 -1
  112. package/dist/production/lib/dom/ssr/server.js +2 -2
  113. package/dist/production/lib/dom/ssr/single-fetch.js +13 -22
  114. package/dist/production/lib/dom-export/dom-router-provider.js +1 -1
  115. package/dist/production/lib/dom-export/hydrated-router.js +2 -1
  116. package/dist/production/lib/errors.js +1 -1
  117. package/dist/production/lib/hooks.js +54 -46
  118. package/dist/production/lib/href.js +1 -1
  119. package/dist/production/lib/router/history.js +2 -2
  120. package/dist/production/lib/router/instrumentation.js +1 -1
  121. package/dist/production/lib/router/matcher-route-pattern.d.ts +2 -0
  122. package/dist/production/lib/router/matcher-route-pattern.js +216 -0
  123. package/dist/production/lib/router/matcher-route-pattern.preload.d.ts +20 -0
  124. package/dist/production/lib/router/matcher-route-pattern.preload.js +36 -0
  125. package/dist/production/lib/router/matcher.d.ts +2 -0
  126. package/dist/production/lib/router/matcher.js +29 -0
  127. package/dist/production/lib/router/navigation.js +45 -0
  128. package/dist/production/lib/router/router.d.ts +21 -7
  129. package/dist/production/lib/router/router.js +111 -82
  130. package/dist/production/lib/router/url.js +1 -1
  131. package/dist/production/lib/router/utils.d.ts +6 -1
  132. package/dist/production/lib/router/utils.js +15 -9
  133. package/dist/production/lib/rsc/browser.js +5 -1
  134. package/dist/production/lib/rsc/errorBoundaries.js +1 -1
  135. package/dist/production/lib/rsc/html-stream/browser.js +1 -1
  136. package/dist/production/lib/rsc/html-stream/server.js +3 -5
  137. package/dist/production/lib/rsc/route-modules.js +1 -1
  138. package/dist/production/lib/rsc/server.rsc.d.ts +7 -0
  139. package/dist/production/lib/rsc/server.ssr.js +26 -22
  140. package/dist/production/lib/server-runtime/cookies.js +2 -2
  141. package/dist/production/lib/server-runtime/crypto.js +2 -2
  142. package/dist/production/lib/server-runtime/data.js +1 -1
  143. package/dist/production/lib/server-runtime/dev.js +2 -2
  144. package/dist/production/lib/server-runtime/entry.js +1 -1
  145. package/dist/production/lib/server-runtime/errors.js +1 -1
  146. package/dist/production/lib/server-runtime/headers.js +1 -1
  147. package/dist/production/lib/server-runtime/invariant.js +1 -1
  148. package/dist/production/lib/server-runtime/mode.js +1 -1
  149. package/dist/production/lib/server-runtime/routeMatching.js +3 -4
  150. package/dist/production/lib/server-runtime/routes.js +1 -1
  151. package/dist/production/lib/server-runtime/server.js +8 -7
  152. package/dist/production/lib/server-runtime/serverHandoff.js +1 -1
  153. package/dist/production/lib/server-runtime/sessions/cookieStorage.js +1 -1
  154. package/dist/production/lib/server-runtime/sessions/memoryStorage.js +1 -1
  155. package/dist/production/lib/server-runtime/sessions.js +1 -1
  156. package/dist/production/lib/server-runtime/single-fetch.js +2 -2
  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/route-pattern.d.ts +3 -0
  161. package/dist/production/route-pattern.js +12 -0
  162. package/dist/production/vendor/turbo-stream-v2/flatten.js +1 -1
  163. package/dist/production/vendor/turbo-stream-v2/turbo-stream.js +4 -4
  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/how-to/fetchers.md +6 -1
  167. package/docs/how-to/middleware.md +3 -1
  168. package/docs/how-to/optimize-revalidation.md +178 -5
  169. package/docs/how-to/react-server-components.md +26 -3
  170. package/docs/how-to/resource-routes.md +3 -0
  171. package/docs/start/data/actions.md +2 -1
  172. package/docs/start/data/route-object.md +21 -6
  173. package/docs/start/framework/actions.md +4 -2
  174. package/docs/start/framework/route-module.md +32 -5
  175. package/docs/upgrading/future.md +68 -0
  176. package/package.json +11 -1
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.3.0
2
+ * react-router v8.4.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -24,7 +24,7 @@ function warning(cond, message) {
24
24
  if (typeof console !== "undefined") console.warn(message);
25
25
  try {
26
26
  throw new Error(message);
27
- } catch (e) {}
27
+ } catch {}
28
28
  }
29
29
  }
30
30
  function createKey$1() {
@@ -207,7 +207,8 @@ const unsupportedLazyRouteObjectKeys = new Set([
207
207
  "path",
208
208
  "id",
209
209
  "index",
210
- "children"
210
+ "children",
211
+ "unstable_validateParams"
211
212
  ]);
212
213
  function isUnsupportedLazyRouteObjectKey(key) {
213
214
  return unsupportedLazyRouteObjectKeys.has(key);
@@ -219,7 +220,8 @@ const unsupportedLazyRouteFunctionKeys = new Set([
219
220
  "id",
220
221
  "index",
221
222
  "middleware",
222
- "children"
223
+ "children",
224
+ "unstable_validateParams"
223
225
  ]);
224
226
  function isUnsupportedLazyRouteFunctionKey(key) {
225
227
  return unsupportedLazyRouteFunctionKeys.has(key);
@@ -515,13 +517,13 @@ function matchPathImpl(pattern, pathname, matcher, compiledParams) {
515
517
  let match = pathname.match(matcher);
516
518
  if (!match) return null;
517
519
  let matchedPathname = match[0];
518
- let pathnameBase = matchedPathname.replace(/(.)\/+$/, "$1");
520
+ let pathnameBase = removeTrailingSlash(matchedPathname, 1);
519
521
  let captureGroups = match.slice(1);
520
522
  return {
521
523
  params: compiledParams.reduce((memo, { paramName, isOptional }, index) => {
522
524
  if (paramName === "*") {
523
525
  let splatValue = captureGroups[index] || "";
524
- pathnameBase = matchedPathname.slice(0, matchedPathname.length - splatValue.length).replace(/(.)\/+$/, "$1");
526
+ pathnameBase = removeTrailingSlash(matchedPathname.slice(0, matchedPathname.length - splatValue.length), 1);
525
527
  }
526
528
  const value = captureGroups[index];
527
529
  if (isOptional && !value) memo[paramName] = void 0;
@@ -590,7 +592,7 @@ function resolvePath(to, fromPathname = "/") {
590
592
  let pathname;
591
593
  if (toPathname) {
592
594
  toPathname = removeDoubleSlashes(toPathname);
593
- if (toPathname.startsWith("/")) pathname = resolvePathname(toPathname.substring(1), "/");
595
+ if (toPathname.startsWith("/") || toPathname.startsWith("\\")) pathname = resolvePathname(toPathname.substring(1), "/");
594
596
  else pathname = resolvePathname(toPathname, fromPathname);
595
597
  } else pathname = fromPathname;
596
598
  return {
@@ -651,7 +653,11 @@ function resolveTo(toArg, routePathnames, locationPathname, isPathRelative = fal
651
653
  }
652
654
  const removeDoubleSlashes = (path) => path.replace(/[\\/]{2,}/g, "/");
653
655
  const joinPaths = (paths) => removeDoubleSlashes(paths.join("/"));
654
- const removeTrailingSlash = (path) => path.replace(/\/+$/, "");
656
+ function removeTrailingSlash(path, minLength = 0) {
657
+ let end = path.length;
658
+ while (end > minLength && path.charCodeAt(end - 1) === 47) end--;
659
+ return end === path.length ? path : path.slice(0, end);
660
+ }
655
661
  const normalizePathname = (pathname) => removeTrailingSlash(pathname).replace(/^\/*/, "/");
656
662
  const normalizeSearch = (search) => !search || search === "?" ? "" : search.startsWith("?") ? search : "?" + search;
657
663
  const normalizeHash = (hash) => !hash || hash === "#" ? "" : hash.startsWith("#") ? hash : "#" + hash;
@@ -1036,6 +1042,23 @@ function getReadonlyContext(context) {
1036
1042
  return { get: (ctx) => context.get(ctx) };
1037
1043
  }
1038
1044
  //#endregion
1045
+ //#region lib/router/matcher.ts
1046
+ var V6RegExMatcher = class {
1047
+ #routes = [];
1048
+ #branches = [];
1049
+ #basename;
1050
+ constructor(basename) {
1051
+ this.#basename = basename;
1052
+ }
1053
+ update(routes) {
1054
+ this.#routes = routes;
1055
+ this.#branches = flattenAndRankRoutes(routes);
1056
+ }
1057
+ match(locationArg, allowPartial = false) {
1058
+ return matchRoutesImpl(this.#routes, locationArg, this.#basename, allowPartial, this.#branches);
1059
+ }
1060
+ };
1061
+ //#endregion
1039
1062
  //#region lib/router/router.ts
1040
1063
  const validMutationMethodsArr = [
1041
1064
  "POST",
@@ -1054,6 +1077,14 @@ const redirectStatusCodes = new Set([
1054
1077
  308
1055
1078
  ]);
1056
1079
  const ResetLoaderDataSymbol = Symbol("ResetLoaderData");
1080
+ function createDataRouteMatcher(future, basename) {
1081
+ if (future.unstable_routePatternMatching) {
1082
+ let RoutePatternMatcher = void 0;
1083
+ invariant$1(RoutePatternMatcher, "You must call unstable_preloadRoutePattern() from \"react-router/route-pattern\" before enabling future.unstable_routePatternMatching.");
1084
+ return new RoutePatternMatcher(basename);
1085
+ }
1086
+ return new V6RegExMatcher(basename);
1087
+ }
1057
1088
  /**
1058
1089
  * Create a static handler to perform server-side data loading
1059
1090
  *
@@ -1090,7 +1121,7 @@ function createStaticHandler(routes, opts) {
1090
1121
  let basename = (opts ? opts.basename : null) || "/";
1091
1122
  let _mapRouteProperties = opts?.mapRouteProperties;
1092
1123
  let mapRouteProperties = _mapRouteProperties ? _mapRouteProperties : () => ({});
1093
- ({ ...opts?.future });
1124
+ let dataRouteMatcher = createDataRouteMatcher({ ...opts?.future }, basename);
1094
1125
  if (opts?.instrumentations) {
1095
1126
  let instrumentations = opts.instrumentations;
1096
1127
  mapRouteProperties = (route) => {
@@ -1101,7 +1132,8 @@ function createStaticHandler(routes, opts) {
1101
1132
  };
1102
1133
  }
1103
1134
  let dataRoutes = convertRoutesToDataRoutes(routes, mapRouteProperties, void 0, manifest);
1104
- let routeBranches = flattenAndRankRoutes(dataRoutes);
1135
+ dataRouteMatcher.update(dataRoutes);
1136
+ let match = (locationArg) => dataRouteMatcher.match(locationArg);
1105
1137
  /**
1106
1138
  * The query() method is intended for document requests, in which we want to
1107
1139
  * call an optional action and potentially multiple loaders for all nested
@@ -1132,7 +1164,7 @@ function createStaticHandler(routes, opts) {
1132
1164
  let normalizePathImpl = normalizePath || defaultNormalizePath;
1133
1165
  let method = request.method;
1134
1166
  let location = createLocation("", normalizePathImpl(request), null, "default");
1135
- let matches = matchRoutesImpl(dataRoutes, location, basename, false, routeBranches);
1167
+ let matches = dataRouteMatcher.match(location);
1136
1168
  requestContext = requestContext != null ? requestContext : new RouterContextProvider();
1137
1169
  if (!isValidMethod(method) && method !== "HEAD") {
1138
1170
  let error = getInternalRouterError(405, { method });
@@ -1146,7 +1178,8 @@ function createStaticHandler(routes, opts) {
1146
1178
  errors: { [route.id]: error },
1147
1179
  statusCode: error.status,
1148
1180
  loaderHeaders: {},
1149
- actionHeaders: {}
1181
+ actionHeaders: {},
1182
+ _match: match
1150
1183
  };
1151
1184
  return generateMiddlewareResponse ? generateMiddlewareResponse(() => Promise.resolve(staticContext)) : staticContext;
1152
1185
  } else if (!matches) {
@@ -1161,7 +1194,8 @@ function createStaticHandler(routes, opts) {
1161
1194
  errors: { [route.id]: error },
1162
1195
  statusCode: error.status,
1163
1196
  loaderHeaders: {},
1164
- actionHeaders: {}
1197
+ actionHeaders: {},
1198
+ _match: match
1165
1199
  };
1166
1200
  return generateMiddlewareResponse ? generateMiddlewareResponse(() => Promise.resolve(staticContext)) : staticContext;
1167
1201
  }
@@ -1184,7 +1218,8 @@ function createStaticHandler(routes, opts) {
1184
1218
  renderedStaticContext = {
1185
1219
  location,
1186
1220
  basename,
1187
- ...result
1221
+ ...result,
1222
+ _match: match
1188
1223
  };
1189
1224
  return renderedStaticContext;
1190
1225
  });
@@ -1210,7 +1245,8 @@ function createStaticHandler(routes, opts) {
1210
1245
  errors: { [skipLoaderErrorBubbling ? routeId : findNearestBoundary(matches, matches.find((m) => m.route.id === routeId || m.route.loader)?.route.id || routeId).route.id]: error },
1211
1246
  statusCode: isRouteErrorResponse(error) ? error.status : 500,
1212
1247
  actionHeaders: {},
1213
- loaderHeaders: {}
1248
+ loaderHeaders: {},
1249
+ _match: match
1214
1250
  };
1215
1251
  return generateMiddlewareResponse(() => Promise.resolve(staticContext));
1216
1252
  }
@@ -1227,7 +1263,8 @@ function createStaticHandler(routes, opts) {
1227
1263
  return {
1228
1264
  location,
1229
1265
  basename,
1230
- ...result
1266
+ ...result,
1267
+ _match: match
1231
1268
  };
1232
1269
  }
1233
1270
  /**
@@ -1260,7 +1297,7 @@ function createStaticHandler(routes, opts) {
1260
1297
  let normalizePathImpl = normalizePath || defaultNormalizePath;
1261
1298
  let method = request.method;
1262
1299
  let location = createLocation("", normalizePathImpl(request), null, "default");
1263
- let matches = matchRoutesImpl(dataRoutes, location, basename, false, routeBranches);
1300
+ let matches = dataRouteMatcher.match(location);
1264
1301
  requestContext = requestContext != null ? requestContext : new RouterContextProvider();
1265
1302
  if (!isValidMethod(method) && method !== "HEAD" && method !== "OPTIONS") throw getInternalRouterError(405, { method });
1266
1303
  else if (!matches) throw getInternalRouterError(404, { pathname: location.pathname });
@@ -1441,7 +1478,7 @@ function createStaticHandler(routes, opts) {
1441
1478
  }
1442
1479
  return {
1443
1480
  dataRoutes,
1444
- _internalRouteBranches: routeBranches,
1481
+ match,
1445
1482
  query,
1446
1483
  queryRoute
1447
1484
  };
@@ -1816,7 +1853,7 @@ async function callDataStrategyImpl(dataStrategyImpl, request, path, matches, fe
1816
1853
  });
1817
1854
  try {
1818
1855
  await Promise.all(matches.flatMap((m) => [m._lazyPromises?.handler, m._lazyPromises?.route]));
1819
- } catch (e) {}
1856
+ } catch {}
1820
1857
  return results;
1821
1858
  }
1822
1859
  async function callLoaderOrAction({ request, path, pattern, match, lazyHandlerPromise, lazyRoutePromise, handlerOverride, scopedContext }) {
@@ -2217,14 +2254,19 @@ function getPathsWithAncestors(paths) {
2217
2254
  function throwIfPotentialCSRFAttack(request, allowedActionOrigins) {
2218
2255
  let originHeader = request.headers.get("origin");
2219
2256
  let originDomain = null;
2257
+ let originUrl = null;
2220
2258
  try {
2221
- originDomain = typeof originHeader === "string" && originHeader !== "null" ? new URL(originHeader).host : originHeader;
2259
+ if (typeof originHeader === "string" && originHeader !== "null") {
2260
+ originUrl = new URL(originHeader);
2261
+ originDomain = originUrl.host;
2262
+ } else originDomain = originHeader;
2222
2263
  } catch {
2223
2264
  throw new Error(`\`origin\` header is not a valid URL. Aborting the action.`);
2224
2265
  }
2225
- let host = new URL(request.url).host;
2226
- if (originDomain && originDomain !== host) {
2227
- if (!isAllowedOrigin(originDomain, allowedActionOrigins)) throw new Error("The `request.url` host does not match `origin` header from a forwarded action request. Aborting the action.");
2266
+ let requestUrl = new URL(request.url);
2267
+ let originMatchesRequest = originUrl ? originUrl.origin === requestUrl.origin : originDomain === requestUrl.host;
2268
+ if (originDomain && !originMatchesRequest) {
2269
+ if (!isAllowedOrigin(originDomain, allowedActionOrigins)) throw new Error("The `request.url` origin does not match `origin` header from a forwarded action request. Aborting the action.");
2228
2270
  }
2229
2271
  }
2230
2272
  function matchWildcardDomain(domain, pattern) {
@@ -2328,6 +2370,13 @@ const Await = (async ({ children, resolve, errorElement }) => {
2328
2370
  * encoding an {@link unstable_RSCPayload} for consumption by an [RSC](https://react.dev/reference/rsc/server-components)
2329
2371
  * enabled client router.
2330
2372
  *
2373
+ * Treat every React Server Function as a public endpoint. Server Functions are
2374
+ * not inherently associated with a route. Any route middleware that runs is
2375
+ * selected from the URL used to call a Server Function, but the client controls
2376
+ * both the Server Function identifier and the URL. Perform all access control
2377
+ * checks within each Server Function, or use a route action for
2378
+ * middleware-driven access control.
2379
+ *
2331
2380
  * @example
2332
2381
  * import {
2333
2382
  * createTemporaryReferenceSet,
@@ -2415,11 +2464,12 @@ async function matchRSCServerRequest({ allowedActionOrigins, createTemporaryRefe
2415
2464
  const requestUrl = new URL(request.url);
2416
2465
  if (isManifestRequest(requestUrl)) return await generateManifestResponse(routes, basename, request, generateResponse, temporaryReferences, routeDiscovery, clientVersion);
2417
2466
  let isDataRequest = isReactServerRequest(requestUrl);
2418
- let matches = matchRoutes(routes, url.pathname, basename);
2467
+ let staticHandler = createStaticHandler(routes, { basename });
2468
+ let matches = staticHandler.match(url.pathname);
2419
2469
  if (matches) await Promise.all(matches.map((m) => explodeLazyRoute(m.route)));
2420
2470
  const leafMatch = matches?.[matches.length - 1];
2421
- if (!isDataRequest && leafMatch && !leafMatch.route.Component && !leafMatch.route.ErrorBoundary) return generateResourceResponse(routerRequest, routes, basename, leafMatch.route.id, requestContext, onError);
2422
- let response = await generateRenderResponse(routerRequest, routes, basename, isDataRequest, decodeReply, requestContext, loadServerAction, decodeAction, decodeFormState, onError, generateResponse, temporaryReferences, allowedActionOrigins, routeDiscovery, clientVersion);
2471
+ if (!isDataRequest && leafMatch && !leafMatch.route.Component && !leafMatch.route.ErrorBoundary) return generateResourceResponse(routerRequest, staticHandler, leafMatch.route.id, requestContext, onError);
2472
+ let response = await generateRenderResponse(routerRequest, staticHandler, basename, isDataRequest, decodeReply, requestContext, loadServerAction, decodeAction, decodeFormState, onError, generateResponse, temporaryReferences, allowedActionOrigins, routeDiscovery, clientVersion);
2423
2473
  response.headers.set("X-Remix-Response", "yes");
2424
2474
  return response;
2425
2475
  }
@@ -2452,9 +2502,10 @@ async function generateManifestResponse(routes, basename, request, generateRespo
2452
2502
  }
2453
2503
  let pathParam = url.searchParams.get("paths");
2454
2504
  let pathnames = pathParam ? pathParam.split(",").filter(Boolean) : [url.pathname.replace(/\.manifest$/, "")];
2505
+ let staticHandler = routes.length > 0 ? createStaticHandler(routes, { basename }) : void 0;
2455
2506
  let routeIds = /* @__PURE__ */ new Set();
2456
- let matchedRoutes = pathnames.flatMap((pathname) => {
2457
- let pathnameMatches = matchRoutes(routes, pathname, basename);
2507
+ let matchedRoutes = staticHandler ? pathnames.flatMap((pathname) => {
2508
+ let pathnameMatches = staticHandler.match(pathname);
2458
2509
  return pathnameMatches?.map((m, i) => ({
2459
2510
  ...m.route,
2460
2511
  parentId: pathnameMatches[i - 1]?.route.id
@@ -2465,10 +2516,10 @@ async function generateManifestResponse(routes, basename, request, generateRespo
2465
2516
  return true;
2466
2517
  }
2467
2518
  return false;
2468
- });
2519
+ }) : [];
2469
2520
  let payload = {
2470
2521
  type: "manifest",
2471
- patches: Promise.all([...matchedRoutes.map((route) => getManifestRoute(route)), getAdditionalRoutePatches(pathnames, routes, basename, Array.from(routeIds))]).then((r) => r.flat(1))
2522
+ patches: Promise.all([...matchedRoutes.map((route) => getManifestRoute(route)), staticHandler ? getAdditionalRoutePatches(pathnames, staticHandler, Array.from(routeIds)) : Promise.resolve([])]).then((r) => r.flat(1))
2472
2523
  };
2473
2524
  return generateResponse({
2474
2525
  statusCode: 200,
@@ -2538,9 +2589,9 @@ async function processServerAction(request, basename, decodeReply, loadServerAct
2538
2589
  }
2539
2590
  }
2540
2591
  }
2541
- async function generateResourceResponse(request, routes, basename, routeId, requestContext, onError) {
2592
+ async function generateResourceResponse(request, staticHandler, routeId, requestContext, onError) {
2542
2593
  try {
2543
- return await createStaticHandler(routes, { basename }).queryRoute(request, {
2594
+ return await staticHandler.queryRoute(request, {
2544
2595
  routeId,
2545
2596
  requestContext,
2546
2597
  async generateMiddlewareResponse(queryRoute) {
@@ -2581,12 +2632,11 @@ async function generateResourceResponse(request, routes, basename, routeId, requ
2581
2632
  });
2582
2633
  }
2583
2634
  }
2584
- async function generateRenderResponse(request, routes, basename, isDataRequest, decodeReply, requestContext, loadServerAction, decodeAction, decodeFormState, onError, generateResponse, temporaryReferences, allowedActionOrigins, routeDiscovery, clientVersion) {
2635
+ async function generateRenderResponse(request, staticHandler, basename, isDataRequest, decodeReply, requestContext, loadServerAction, decodeAction, decodeFormState, onError, generateResponse, temporaryReferences, allowedActionOrigins, routeDiscovery, clientVersion) {
2585
2636
  let statusCode = 200;
2586
2637
  let url = new URL(request.url);
2587
2638
  let isSubmission = isMutationMethod(request.method);
2588
2639
  let routeIdsToLoad = !isSubmission && url.searchParams.has("_routes") ? url.searchParams.get("_routes").split(",") : null;
2589
- const staticHandler = createStaticHandler(routes, { basename });
2590
2640
  let actionResult;
2591
2641
  const ctx = {
2592
2642
  request,
@@ -2634,7 +2684,7 @@ async function generateRenderResponse(request, routes, basename, isDataRequest,
2634
2684
  staticContext.errors[staticContext.matches[0].route.id] = potentialCSRFAttackError;
2635
2685
  staticContext.statusCode = 400;
2636
2686
  }
2637
- return generateStaticContextResponse(routes, basename, generateResponse, statusCode, routeIdsToLoad, isDataRequest, isSubmission, actionResult, formState, staticContext, temporaryReferences, skipRevalidation, ctx.redirect?.headers, routeDiscovery, clientVersion);
2687
+ return generateStaticContextResponse(staticHandler, basename, generateResponse, statusCode, routeIdsToLoad, isDataRequest, isSubmission, actionResult, formState, staticContext, temporaryReferences, skipRevalidation, ctx.redirect?.headers, routeDiscovery, clientVersion);
2638
2688
  }
2639
2689
  }));
2640
2690
  if (isRedirectResponse(result)) return generateRedirectResponse(result, actionResult, basename, isDataRequest, generateResponse, temporaryReferences, ctx.redirect?.headers);
@@ -2668,7 +2718,7 @@ function generateRedirectResponse(response, actionResult, basename, isDataReques
2668
2718
  onError: defaultOnError
2669
2719
  });
2670
2720
  }
2671
- async function generateStaticContextResponse(routes, basename, generateResponse, statusCode, routeIdsToLoad, isDataRequest, isSubmission, actionResult, formState, staticContext, temporaryReferences, skipRevalidation, sideEffectRedirectHeaders, routeDiscovery, clientVersion) {
2721
+ async function generateStaticContextResponse(staticHandler, basename, generateResponse, statusCode, routeIdsToLoad, isDataRequest, isSubmission, actionResult, formState, staticContext, temporaryReferences, skipRevalidation, sideEffectRedirectHeaders, routeDiscovery, clientVersion) {
2672
2722
  statusCode = staticContext.statusCode ?? statusCode;
2673
2723
  if (staticContext.errors) staticContext.errors = Object.fromEntries(Object.entries(staticContext.errors).map(([key, error]) => [key, isRouteErrorResponse(error) ? Object.fromEntries(Object.entries(error)) : error]));
2674
2724
  staticContext.matches.forEach((m) => {
@@ -2689,7 +2739,7 @@ async function generateStaticContextResponse(routes, basename, generateResponse,
2689
2739
  location: staticContext.location,
2690
2740
  formState
2691
2741
  };
2692
- const renderPayloadPromise = () => getRenderPayload(baseRenderPayload, routes, basename, routeIdsToLoad, isDataRequest, staticContext, routeDiscovery);
2742
+ const renderPayloadPromise = () => getRenderPayload(baseRenderPayload, staticHandler, basename, routeIdsToLoad, isDataRequest, staticContext, routeDiscovery);
2693
2743
  let payload;
2694
2744
  if (actionResult) payload = {
2695
2745
  type: "action",
@@ -2711,7 +2761,8 @@ async function generateStaticContextResponse(routes, basename, generateResponse,
2711
2761
  onError: defaultOnError
2712
2762
  });
2713
2763
  }
2714
- async function getRenderPayload(baseRenderPayload, routes, basename, routeIdsToLoad, isDataRequest, staticContext, routeDiscovery) {
2764
+ async function getRenderPayload(baseRenderPayload, staticHandler, basename, routeIdsToLoad, isDataRequest, staticContext, routeDiscovery) {
2765
+ let routes = staticHandler.dataRoutes;
2715
2766
  let deepestRenderedRouteIdx = staticContext.matches.length - 1;
2716
2767
  let parentIds = {};
2717
2768
  staticContext.matches.forEach((m, i) => {
@@ -2729,7 +2780,9 @@ async function getRenderPayload(baseRenderPayload, routes, basename, routeIdsToL
2729
2780
  parentId
2730
2781
  });
2731
2782
  }));
2732
- let patches = routeDiscovery?.mode === "initial" && !isDataRequest ? getAllRoutePatches(routes, basename).then((patches) => patches.filter((patch) => !staticContext.matches.some((m) => m.route.id === patch.id))) : getAdditionalRoutePatches(getPathsWithAncestors([staticContext.location.pathname]), routes, basename, staticContext.matches.map((m) => m.route.id));
2783
+ let patches;
2784
+ if (routeDiscovery?.mode === "initial" && !isDataRequest) patches = getAllRoutePatches(routes, basename).then((patches) => patches.filter((patch) => !staticContext.matches.some((m) => m.route.id === patch.id)));
2785
+ else patches = getAdditionalRoutePatches(getPathsWithAncestors([staticContext.location.pathname]), staticHandler, staticContext.matches.map((m) => m.route.id));
2733
2786
  return {
2734
2787
  ...baseRenderPayload,
2735
2788
  matches: await matchesPromise,
@@ -2833,13 +2886,13 @@ async function getAllRoutePatches(routes, basename) {
2833
2886
  for (let route of routes) await traverse(route, void 0);
2834
2887
  return patches.filter((p) => !!p.parentId);
2835
2888
  }
2836
- async function getAdditionalRoutePatches(pathnames, routes, basename, matchedRouteIds) {
2889
+ async function getAdditionalRoutePatches(pathnames, staticHandler, matchedRouteIds) {
2837
2890
  let patchRouteMatches = /* @__PURE__ */ new Map();
2838
2891
  let matchedPaths = /* @__PURE__ */ new Set();
2839
2892
  for (const pathname of pathnames) {
2840
2893
  if (matchedPaths.has(pathname)) continue;
2841
2894
  matchedPaths.add(pathname);
2842
- let matches = matchRoutes(routes, pathname, basename) || [];
2895
+ let matches = staticHandler.match(pathname) || [];
2843
2896
  matches.forEach((m, i) => {
2844
2897
  if (patchRouteMatches.get(m.route.id)) return;
2845
2898
  patchRouteMatches.set(m.route.id, {
@@ -2948,7 +3001,7 @@ const unsign = async (cookie, secret) => {
2948
3001
  try {
2949
3002
  let signature = byteStringToUint8Array(atob(hash));
2950
3003
  return await crypto.subtle.verify("HMAC", key, signature, data) ? value : false;
2951
- } catch (e) {
3004
+ } catch {
2952
3005
  return false;
2953
3006
  }
2954
3007
  };
@@ -3046,7 +3099,7 @@ function encodeData(value) {
3046
3099
  function decodeData(value) {
3047
3100
  try {
3048
3101
  return JSON.parse(decodeURIComponent(myEscape(atob(value))));
3049
- } catch (e) {
3102
+ } catch {
3050
3103
  return {};
3051
3104
  }
3052
3105
  }
@@ -4,7 +4,7 @@ import { ActionFunction, ActionFunctionArgs, BaseRouteObject, DataRouteMatch, Da
4
4
  import { Blocker, BlockerFunction, Fetcher, GetScrollPositionFunction, GetScrollRestorationKeyFunction, HydrationState, IDLE_BLOCKER, IDLE_FETCHER, IDLE_NAVIGATION, Navigation, NavigationStates, RelativeRoutingType, RevalidationState, Router, RouterFetchOptions, RouterInit, RouterNavigateOptions, RouterState, RouterSubscriber, StaticHandler, StaticHandlerContext, createRouter, createStaticHandler } from "./lib/router/router.js";
5
5
  import { HtmlLinkDescriptor, LinkDescriptor, PageLinkDescriptor } from "./lib/router/links.js";
6
6
  import { Await, AwaitProps, ClientOnErrorFunction, IndexRouteProps, LayoutRouteProps, MemoryRouter, MemoryRouterOpts, MemoryRouterProps, Navigate, NavigateProps, Outlet, OutletProps, PathRouteProps, Route, RouteProps, Router as Router$1, RouterProps, RouterProvider, RouterProviderProps, Routes, RoutesProps, WithComponentProps, WithErrorBoundaryProps, WithHydrateFallbackProps, createMemoryRouter, createRoutesFromChildren, createRoutesFromElements, hydrationRouteProperties, renderMatches, withComponentProps, withErrorBoundaryProps, withHydrateFallbackProps } from "./lib/components.js";
7
- import { AwaitContextProvider, DataRouterContext, DataRouterStateContext, FetchersContext, LocationContext, NavigateOptions, NavigationContext, Navigator, RouteContext, ViewTransitionContext } from "./lib/context.js";
7
+ import { AwaitContextProvider, DataRouterContext, DataRouterDataContext, DataRouterNavigationContext, DataRouterStateContext, FetchersContext, LocationContext, NavigateOptions, NavigationContext, Navigator, RouteContext, ViewTransitionContext } from "./lib/context.js";
8
8
  import { Register } from "./lib/types/register.js";
9
9
  import { NavigateFunction, unstable_RouterState, unstable_RouterStateActiveVariant, unstable_RouterStatePendingVariant, useActionData, useAsyncError, useAsyncValue, useBlocker, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRoute, useRouteError, useRouteLoaderData, useRouterState, useRoutes } from "./lib/hooks.js";
10
10
  import { FetcherSubmitOptions, ParamKeyValuePair, SubmitOptions, SubmitTarget, URLSearchParamsInit, createSearchParams } from "./lib/dom/dom.js";
@@ -41,4 +41,4 @@ import { ClientInstrumentation, InstrumentRequestHandlerFunction, InstrumentRout
41
41
  declare const unstable_getRequest: typeof getRequest;
42
42
  declare const unstable_matchRSCServerRequest: typeof matchRSCServerRequest;
43
43
  //#endregion
44
- export { type ActionFunction, type ActionFunctionArgs, Await, type AwaitProps, type BaseRouteObject, type Blocker, type BlockerFunction, BrowserRouter, type BrowserRouterProps, type ClientActionFunction, type ClientActionFunctionArgs, type ClientInstrumentation, type ClientLoaderFunction, type ClientLoaderFunctionArgs, type ClientOnErrorFunction, type Cookie, type CookieOptions, type CookieParseOptions, type CookieSerializeOptions, type CookieSignatureOptions, type CreateRequestHandlerFunction, type DOMRouterOpts, type DataRouteMatch, type DataRouteObject, type Router as DataRouter, type DataStrategyFunction, type DataStrategyFunctionArgs, type DataStrategyMatch, type DataStrategyResult, type DiscoverBehavior, type EntryContext, type ErrorResponse, type Fetcher, type FetcherFormProps, type FetcherSubmitFunction, type FetcherSubmitOptions, type FetcherWithComponents, type FlashSessionData, Form, type FormEncType, type FormMethod, type FormProps, type Future, type GetScrollPositionFunction, type GetScrollRestorationKeyFunction, type HTMLFormMethod, type HandleDataRequestFunction, type HandleDocumentRequestFunction, type HandleErrorFunction, HashRouter, type HashRouterProps, type HeadersArgs, type HeadersFunction, type HistoryRouterProps, type HtmlLinkDescriptor, type HydrationState, IDLE_BLOCKER, IDLE_FETCHER, IDLE_NAVIGATION, type IndexRouteObject, type IndexRouteProps, type InitialEntry, type InstrumentRequestHandlerFunction, type InstrumentRouteFunction, type InstrumentRouterFunction, type InstrumentationClientRouterResult, type InstrumentationHandlerResult, type InstrumentationServerHandlerResult, type IsCookieFunction, type IsSessionFunction, type LayoutRouteProps, type LazyRouteFunction, Link, type LinkDescriptor, type LinkProps, Links, type LinksFunction, type LinksProps, type LoaderFunction, type LoaderFunctionArgs, type Location, MemoryRouter, type MemoryRouterOpts, type MemoryRouterProps, Meta, type MetaArgs, type MetaDescriptor, type MetaFunction, type MiddlewareFunction, NavLink, type NavLinkProps, type NavLinkRenderProps, Navigate, type NavigateFunction, type NavigateOptions, type NavigateProps, type Navigation, type NavigationStates, Action as NavigationType, type Navigator, type NonIndexRouteObject, Outlet, type OutletProps, type PageLinkDescriptor, type ParamKeyValuePair, type ParamParseKey, type Params, type PatchRoutesOnNavigationFunction, type PatchRoutesOnNavigationFunctionArgs, type Path, type PathMatch, type PathParam, type PathPattern, type PathRouteProps, type PrefetchBehavior, PrefetchPageLinks, type RedirectFunction, type Register, type RelativeRoutingType, type RequestHandler, type RevalidationState, Route, type RouteMatch, type RouteObject, type RouteProps, Router$1 as Router, type RouterContext, RouterContextProvider, type RouterFetchOptions, type RouterInit, type RouterNavigateOptions, type RouterProps, RouterProvider, type RouterProviderProps, type RouterState, type RouterSubscriber, Routes, type RoutesProps, type RoutesTestStubProps, Scripts, type ScriptsProps, ScrollRestoration, type ScrollRestorationProps, type ServerBuild, type ServerEntryModule, type ServerInstrumentation, ServerRouter, type ServerRouterProps, type Session, type SessionData, type SessionIdStorageStrategy, type SessionStorage, type SetURLSearchParams, type ShouldRevalidateFunction, type ShouldRevalidateFunctionArgs, type StaticHandler, type StaticHandlerContext, StaticRouter, type StaticRouterProps, StaticRouterProvider, type StaticRouterProviderProps, type SubmitFunction, type SubmitOptions, type SubmitTarget, type To, type UIMatch, type AssetsManifest as UNSAFE_AssetsManifest, AwaitContextProvider as UNSAFE_AwaitContextProvider, DataRouterContext as UNSAFE_DataRouterContext, DataRouterStateContext as UNSAFE_DataRouterStateContext, type DataWithResponseInit as UNSAFE_DataWithResponseInit, ErrorResponseImpl as UNSAFE_ErrorResponseImpl, FetchersContext as UNSAFE_FetchersContext, FrameworkContext as UNSAFE_FrameworkContext, LocationContext as UNSAFE_LocationContext, NavigationContext as UNSAFE_NavigationContext, RSCDefaultRootErrorBoundary as UNSAFE_RSCDefaultRootErrorBoundary, RemixErrorBoundary as UNSAFE_RemixErrorBoundary, RouteContext as UNSAFE_RouteContext, type RouteModules as UNSAFE_RouteModules, ServerMode as UNSAFE_ServerMode, SingleFetchRedirectSymbol as UNSAFE_SingleFetchRedirectSymbol, ViewTransitionContext as UNSAFE_ViewTransitionContext, WithComponentProps as UNSAFE_WithComponentProps, WithErrorBoundaryProps as UNSAFE_WithErrorBoundaryProps, WithHydrateFallbackProps as UNSAFE_WithHydrateFallbackProps, createBrowserHistory as UNSAFE_createBrowserHistory, createClientRoutes as UNSAFE_createClientRoutes, createClientRoutesWithHMRRevalidationOptOut as UNSAFE_createClientRoutesWithHMRRevalidationOptOut, createHashHistory as UNSAFE_createHashHistory, createMemoryHistory as UNSAFE_createMemoryHistory, createRouter as UNSAFE_createRouter, decodeViaTurboStream as UNSAFE_decodeViaTurboStream, defaultMapRouteProperties as UNSAFE_defaultMapRouteProperties, getHydrationData as UNSAFE_getHydrationData, getPatchRoutesOnNavigationFunction as UNSAFE_getPatchRoutesOnNavigationFunction, getTurboStreamSingleFetchDataStrategy as UNSAFE_getTurboStreamSingleFetchDataStrategy, hydrationRouteProperties as UNSAFE_hydrationRouteProperties, invariant as UNSAFE_invariant, shouldHydrateRouteLoader as UNSAFE_shouldHydrateRouteLoader, useFogOFWarDiscovery as UNSAFE_useFogOFWarDiscovery, useScrollRestoration as UNSAFE_useScrollRestoration, withComponentProps as UNSAFE_withComponentProps, withErrorBoundaryProps as UNSAFE_withErrorBoundaryProps, withHydrateFallbackProps as UNSAFE_withHydrateFallbackProps, type URLSearchParamsInit, createBrowserRouter, createContext, createCookie, createCookieSessionStorage, createHashRouter, createMemoryRouter, createMemorySessionStorage, createPath, createRequestHandler, createRoutesFromChildren, createRoutesFromElements, createRoutesStub, createSearchParams, createSession, createSessionStorage, createStaticHandler, createStaticRouter, data, generatePath, href, isCookie, isRouteErrorResponse, isSession, matchPath, matchRoutes, parsePath, redirect, redirectDocument, renderMatches, replace, resolvePath, type BrowserCreateFromReadableStreamFunction as unstable_BrowserCreateFromReadableStreamFunction, type DecodeActionFunction as unstable_DecodeActionFunction, type DecodeFormStateFunction as unstable_DecodeFormStateFunction, type DecodeReplyFunction as unstable_DecodeReplyFunction, type EncodeReplyFunction as unstable_EncodeReplyFunction, HistoryRouter as unstable_HistoryRouter, type LoadServerActionFunction as unstable_LoadServerActionFunction, type RSCHydratedRouterProps as unstable_RSCHydratedRouterProps, type RSCManifestPayload as unstable_RSCManifestPayload, type RSCMatch as unstable_RSCMatch, type RSCPayload as unstable_RSCPayload, type RSCRenderPayload as unstable_RSCRenderPayload, type RSCRouteConfig as unstable_RSCRouteConfig, type RSCRouteConfigEntry as unstable_RSCRouteConfigEntry, type RSCRouteManifest as unstable_RSCRouteManifest, type RSCRouteMatch as unstable_RSCRouteMatch, RSCStaticRouter as unstable_RSCStaticRouter, type RSCStaticRouterProps as unstable_RSCStaticRouterProps, type unstable_RouterState, type unstable_RouterStateActiveVariant, type unstable_RouterStatePendingVariant, type SSRCreateFromReadableStreamFunction as unstable_SSRCreateFromReadableStreamFunction, type unstable_SerializesTo, unstable_getRequest, unstable_matchRSCServerRequest, routeRSCServerRequest as unstable_routeRSCServerRequest, setDevServerHooks as unstable_setDevServerHooks, usePrompt as unstable_usePrompt, useRoute as unstable_useRoute, useRouterState as unstable_useRouterState, useActionData, useAsyncError, useAsyncValue, useBeforeUnload, useBlocker, useFetcher, useFetchers, useFormAction, useHref, useInRouterContext, useLinkClickHandler, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes, useSearchParams, useSubmit, useViewTransitionState };
44
+ export { type ActionFunction, type ActionFunctionArgs, Await, type AwaitProps, type BaseRouteObject, type Blocker, type BlockerFunction, BrowserRouter, type BrowserRouterProps, type ClientActionFunction, type ClientActionFunctionArgs, type ClientInstrumentation, type ClientLoaderFunction, type ClientLoaderFunctionArgs, type ClientOnErrorFunction, type Cookie, type CookieOptions, type CookieParseOptions, type CookieSerializeOptions, type CookieSignatureOptions, type CreateRequestHandlerFunction, type DOMRouterOpts, type DataRouteMatch, type DataRouteObject, type Router as DataRouter, type DataStrategyFunction, type DataStrategyFunctionArgs, type DataStrategyMatch, type DataStrategyResult, type DiscoverBehavior, type EntryContext, type ErrorResponse, type Fetcher, type FetcherFormProps, type FetcherSubmitFunction, type FetcherSubmitOptions, type FetcherWithComponents, type FlashSessionData, Form, type FormEncType, type FormMethod, type FormProps, type Future, type GetScrollPositionFunction, type GetScrollRestorationKeyFunction, type HTMLFormMethod, type HandleDataRequestFunction, type HandleDocumentRequestFunction, type HandleErrorFunction, HashRouter, type HashRouterProps, type HeadersArgs, type HeadersFunction, type HistoryRouterProps, type HtmlLinkDescriptor, type HydrationState, IDLE_BLOCKER, IDLE_FETCHER, IDLE_NAVIGATION, type IndexRouteObject, type IndexRouteProps, type InitialEntry, type InstrumentRequestHandlerFunction, type InstrumentRouteFunction, type InstrumentRouterFunction, type InstrumentationClientRouterResult, type InstrumentationHandlerResult, type InstrumentationServerHandlerResult, type IsCookieFunction, type IsSessionFunction, type LayoutRouteProps, type LazyRouteFunction, Link, type LinkDescriptor, type LinkProps, Links, type LinksFunction, type LinksProps, type LoaderFunction, type LoaderFunctionArgs, type Location, MemoryRouter, type MemoryRouterOpts, type MemoryRouterProps, Meta, type MetaArgs, type MetaDescriptor, type MetaFunction, type MiddlewareFunction, NavLink, type NavLinkProps, type NavLinkRenderProps, Navigate, type NavigateFunction, type NavigateOptions, type NavigateProps, type Navigation, type NavigationStates, Action as NavigationType, type Navigator, type NonIndexRouteObject, Outlet, type OutletProps, type PageLinkDescriptor, type ParamKeyValuePair, type ParamParseKey, type Params, type PatchRoutesOnNavigationFunction, type PatchRoutesOnNavigationFunctionArgs, type Path, type PathMatch, type PathParam, type PathPattern, type PathRouteProps, type PrefetchBehavior, PrefetchPageLinks, type RedirectFunction, type Register, type RelativeRoutingType, type RequestHandler, type RevalidationState, Route, type RouteMatch, type RouteObject, type RouteProps, Router$1 as Router, type RouterContext, RouterContextProvider, type RouterFetchOptions, type RouterInit, type RouterNavigateOptions, type RouterProps, RouterProvider, type RouterProviderProps, type RouterState, type RouterSubscriber, Routes, type RoutesProps, type RoutesTestStubProps, Scripts, type ScriptsProps, ScrollRestoration, type ScrollRestorationProps, type ServerBuild, type ServerEntryModule, type ServerInstrumentation, ServerRouter, type ServerRouterProps, type Session, type SessionData, type SessionIdStorageStrategy, type SessionStorage, type SetURLSearchParams, type ShouldRevalidateFunction, type ShouldRevalidateFunctionArgs, type StaticHandler, type StaticHandlerContext, StaticRouter, type StaticRouterProps, StaticRouterProvider, type StaticRouterProviderProps, type SubmitFunction, type SubmitOptions, type SubmitTarget, type To, type UIMatch, type AssetsManifest as UNSAFE_AssetsManifest, AwaitContextProvider as UNSAFE_AwaitContextProvider, DataRouterContext as UNSAFE_DataRouterContext, DataRouterDataContext as UNSAFE_DataRouterDataContext, DataRouterNavigationContext as UNSAFE_DataRouterNavigationContext, DataRouterStateContext as UNSAFE_DataRouterStateContext, type DataWithResponseInit as UNSAFE_DataWithResponseInit, ErrorResponseImpl as UNSAFE_ErrorResponseImpl, FetchersContext as UNSAFE_FetchersContext, FrameworkContext as UNSAFE_FrameworkContext, LocationContext as UNSAFE_LocationContext, NavigationContext as UNSAFE_NavigationContext, RSCDefaultRootErrorBoundary as UNSAFE_RSCDefaultRootErrorBoundary, RemixErrorBoundary as UNSAFE_RemixErrorBoundary, RouteContext as UNSAFE_RouteContext, type RouteModules as UNSAFE_RouteModules, ServerMode as UNSAFE_ServerMode, SingleFetchRedirectSymbol as UNSAFE_SingleFetchRedirectSymbol, ViewTransitionContext as UNSAFE_ViewTransitionContext, WithComponentProps as UNSAFE_WithComponentProps, WithErrorBoundaryProps as UNSAFE_WithErrorBoundaryProps, WithHydrateFallbackProps as UNSAFE_WithHydrateFallbackProps, createBrowserHistory as UNSAFE_createBrowserHistory, createClientRoutes as UNSAFE_createClientRoutes, createClientRoutesWithHMRRevalidationOptOut as UNSAFE_createClientRoutesWithHMRRevalidationOptOut, createHashHistory as UNSAFE_createHashHistory, createMemoryHistory as UNSAFE_createMemoryHistory, createRouter as UNSAFE_createRouter, decodeViaTurboStream as UNSAFE_decodeViaTurboStream, defaultMapRouteProperties as UNSAFE_defaultMapRouteProperties, getHydrationData as UNSAFE_getHydrationData, getPatchRoutesOnNavigationFunction as UNSAFE_getPatchRoutesOnNavigationFunction, getTurboStreamSingleFetchDataStrategy as UNSAFE_getTurboStreamSingleFetchDataStrategy, hydrationRouteProperties as UNSAFE_hydrationRouteProperties, invariant as UNSAFE_invariant, shouldHydrateRouteLoader as UNSAFE_shouldHydrateRouteLoader, useFogOFWarDiscovery as UNSAFE_useFogOFWarDiscovery, useScrollRestoration as UNSAFE_useScrollRestoration, withComponentProps as UNSAFE_withComponentProps, withErrorBoundaryProps as UNSAFE_withErrorBoundaryProps, withHydrateFallbackProps as UNSAFE_withHydrateFallbackProps, type URLSearchParamsInit, createBrowserRouter, createContext, createCookie, createCookieSessionStorage, createHashRouter, createMemoryRouter, createMemorySessionStorage, createPath, createRequestHandler, createRoutesFromChildren, createRoutesFromElements, createRoutesStub, createSearchParams, createSession, createSessionStorage, createStaticHandler, createStaticRouter, data, generatePath, href, isCookie, isRouteErrorResponse, isSession, matchPath, matchRoutes, parsePath, redirect, redirectDocument, renderMatches, replace, resolvePath, type BrowserCreateFromReadableStreamFunction as unstable_BrowserCreateFromReadableStreamFunction, type DecodeActionFunction as unstable_DecodeActionFunction, type DecodeFormStateFunction as unstable_DecodeFormStateFunction, type DecodeReplyFunction as unstable_DecodeReplyFunction, type EncodeReplyFunction as unstable_EncodeReplyFunction, HistoryRouter as unstable_HistoryRouter, type LoadServerActionFunction as unstable_LoadServerActionFunction, type RSCHydratedRouterProps as unstable_RSCHydratedRouterProps, type RSCManifestPayload as unstable_RSCManifestPayload, type RSCMatch as unstable_RSCMatch, type RSCPayload as unstable_RSCPayload, type RSCRenderPayload as unstable_RSCRenderPayload, type RSCRouteConfig as unstable_RSCRouteConfig, type RSCRouteConfigEntry as unstable_RSCRouteConfigEntry, type RSCRouteManifest as unstable_RSCRouteManifest, type RSCRouteMatch as unstable_RSCRouteMatch, RSCStaticRouter as unstable_RSCStaticRouter, type RSCStaticRouterProps as unstable_RSCStaticRouterProps, type unstable_RouterState, type unstable_RouterStateActiveVariant, type unstable_RouterStatePendingVariant, type SSRCreateFromReadableStreamFunction as unstable_SSRCreateFromReadableStreamFunction, type unstable_SerializesTo, unstable_getRequest, unstable_matchRSCServerRequest, routeRSCServerRequest as unstable_routeRSCServerRequest, setDevServerHooks as unstable_setDevServerHooks, usePrompt as unstable_usePrompt, useRoute as unstable_useRoute, useRouterState as unstable_useRouterState, useActionData, useAsyncError, useAsyncValue, useBeforeUnload, useBlocker, useFetcher, useFetchers, useFormAction, useHref, useInRouterContext, useLinkClickHandler, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes, useSearchParams, useSubmit, useViewTransitionState };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.3.0
2
+ * react-router v8.4.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -12,7 +12,7 @@
12
12
  import { Action, createBrowserHistory, createHashHistory, createMemoryHistory, createPath, invariant, parsePath } from "./lib/router/history.js";
13
13
  import { ErrorResponseImpl, RouterContextProvider, createContext, data, defaultMapRouteProperties, generatePath, isRouteErrorResponse, matchPath, matchRoutes, redirect, redirectDocument, replace, resolvePath } from "./lib/router/utils.js";
14
14
  import { IDLE_BLOCKER, IDLE_FETCHER, IDLE_NAVIGATION, createRouter, createStaticHandler } from "./lib/router/router.js";
15
- import { AwaitContextProvider, DataRouterContext, DataRouterStateContext, FetchersContext, LocationContext, NavigationContext, RouteContext, ViewTransitionContext } from "./lib/context.js";
15
+ import { AwaitContextProvider, DataRouterContext, DataRouterDataContext, DataRouterNavigationContext, DataRouterStateContext, FetchersContext, LocationContext, NavigationContext, RouteContext, ViewTransitionContext } from "./lib/context.js";
16
16
  import { useActionData, useAsyncError, useAsyncValue, useBlocker, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRoute, useRouteError, useRouteLoaderData, useRouterState, useRoutes } from "./lib/hooks.js";
17
17
  import { Await, MemoryRouter, Navigate, Outlet, Route, Router, RouterProvider, Routes, WithComponentProps, WithErrorBoundaryProps, WithHydrateFallbackProps, createMemoryRouter, createRoutesFromChildren, createRoutesFromElements, hydrationRouteProperties, renderMatches, withComponentProps, withErrorBoundaryProps, withHydrateFallbackProps } from "./lib/components.js";
18
18
  import { createSearchParams } from "./lib/dom/dom.js";
@@ -42,4 +42,4 @@ import { getHydrationData } from "./lib/dom/ssr/hydration.js";
42
42
  * @mergeModuleWith react-router
43
43
  */
44
44
  //#endregion
45
- export { Await, BrowserRouter, Form, HashRouter, IDLE_BLOCKER, IDLE_FETCHER, IDLE_NAVIGATION, Link, Links, MemoryRouter, Meta, NavLink, Navigate, Action as NavigationType, Outlet, PrefetchPageLinks, Route, Router, RouterContextProvider, RouterProvider, Routes, Scripts, ScrollRestoration, ServerRouter, StaticRouter, StaticRouterProvider, AwaitContextProvider as UNSAFE_AwaitContextProvider, DataRouterContext as UNSAFE_DataRouterContext, DataRouterStateContext as UNSAFE_DataRouterStateContext, ErrorResponseImpl as UNSAFE_ErrorResponseImpl, FetchersContext as UNSAFE_FetchersContext, FrameworkContext as UNSAFE_FrameworkContext, LocationContext as UNSAFE_LocationContext, NavigationContext as UNSAFE_NavigationContext, RSCDefaultRootErrorBoundary as UNSAFE_RSCDefaultRootErrorBoundary, RemixErrorBoundary as UNSAFE_RemixErrorBoundary, RouteContext as UNSAFE_RouteContext, ServerMode as UNSAFE_ServerMode, SingleFetchRedirectSymbol as UNSAFE_SingleFetchRedirectSymbol, ViewTransitionContext as UNSAFE_ViewTransitionContext, WithComponentProps as UNSAFE_WithComponentProps, WithErrorBoundaryProps as UNSAFE_WithErrorBoundaryProps, WithHydrateFallbackProps as UNSAFE_WithHydrateFallbackProps, createBrowserHistory as UNSAFE_createBrowserHistory, createClientRoutes as UNSAFE_createClientRoutes, createClientRoutesWithHMRRevalidationOptOut as UNSAFE_createClientRoutesWithHMRRevalidationOptOut, createHashHistory as UNSAFE_createHashHistory, createMemoryHistory as UNSAFE_createMemoryHistory, createRouter as UNSAFE_createRouter, decodeViaTurboStream as UNSAFE_decodeViaTurboStream, defaultMapRouteProperties as UNSAFE_defaultMapRouteProperties, getHydrationData as UNSAFE_getHydrationData, getPatchRoutesOnNavigationFunction as UNSAFE_getPatchRoutesOnNavigationFunction, getTurboStreamSingleFetchDataStrategy as UNSAFE_getTurboStreamSingleFetchDataStrategy, hydrationRouteProperties as UNSAFE_hydrationRouteProperties, invariant as UNSAFE_invariant, shouldHydrateRouteLoader as UNSAFE_shouldHydrateRouteLoader, useFogOFWarDiscovery as UNSAFE_useFogOFWarDiscovery, useScrollRestoration as UNSAFE_useScrollRestoration, withComponentProps as UNSAFE_withComponentProps, withErrorBoundaryProps as UNSAFE_withErrorBoundaryProps, withHydrateFallbackProps as UNSAFE_withHydrateFallbackProps, createBrowserRouter, createContext, createCookie, createCookieSessionStorage, createHashRouter, createMemoryRouter, createMemorySessionStorage, createPath, createRequestHandler, createRoutesFromChildren, createRoutesFromElements, createRoutesStub, createSearchParams, createSession, createSessionStorage, createStaticHandler, createStaticRouter, data, generatePath, href, isCookie, isRouteErrorResponse, isSession, matchPath, matchRoutes, parsePath, redirect, redirectDocument, renderMatches, replace, resolvePath, HistoryRouter as unstable_HistoryRouter, RSCStaticRouter as unstable_RSCStaticRouter, routeRSCServerRequest as unstable_routeRSCServerRequest, setDevServerHooks as unstable_setDevServerHooks, usePrompt as unstable_usePrompt, useRoute as unstable_useRoute, useRouterState as unstable_useRouterState, useActionData, useAsyncError, useAsyncValue, useBeforeUnload, useBlocker, useFetcher, useFetchers, useFormAction, useHref, useInRouterContext, useLinkClickHandler, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes, useSearchParams, useSubmit, useViewTransitionState };
45
+ export { Await, BrowserRouter, Form, HashRouter, IDLE_BLOCKER, IDLE_FETCHER, IDLE_NAVIGATION, Link, Links, MemoryRouter, Meta, NavLink, Navigate, Action as NavigationType, Outlet, PrefetchPageLinks, Route, Router, RouterContextProvider, RouterProvider, Routes, Scripts, ScrollRestoration, ServerRouter, StaticRouter, StaticRouterProvider, AwaitContextProvider as UNSAFE_AwaitContextProvider, DataRouterContext as UNSAFE_DataRouterContext, DataRouterDataContext as UNSAFE_DataRouterDataContext, DataRouterNavigationContext as UNSAFE_DataRouterNavigationContext, DataRouterStateContext as UNSAFE_DataRouterStateContext, ErrorResponseImpl as UNSAFE_ErrorResponseImpl, FetchersContext as UNSAFE_FetchersContext, FrameworkContext as UNSAFE_FrameworkContext, LocationContext as UNSAFE_LocationContext, NavigationContext as UNSAFE_NavigationContext, RSCDefaultRootErrorBoundary as UNSAFE_RSCDefaultRootErrorBoundary, RemixErrorBoundary as UNSAFE_RemixErrorBoundary, RouteContext as UNSAFE_RouteContext, ServerMode as UNSAFE_ServerMode, SingleFetchRedirectSymbol as UNSAFE_SingleFetchRedirectSymbol, ViewTransitionContext as UNSAFE_ViewTransitionContext, WithComponentProps as UNSAFE_WithComponentProps, WithErrorBoundaryProps as UNSAFE_WithErrorBoundaryProps, WithHydrateFallbackProps as UNSAFE_WithHydrateFallbackProps, createBrowserHistory as UNSAFE_createBrowserHistory, createClientRoutes as UNSAFE_createClientRoutes, createClientRoutesWithHMRRevalidationOptOut as UNSAFE_createClientRoutesWithHMRRevalidationOptOut, createHashHistory as UNSAFE_createHashHistory, createMemoryHistory as UNSAFE_createMemoryHistory, createRouter as UNSAFE_createRouter, decodeViaTurboStream as UNSAFE_decodeViaTurboStream, defaultMapRouteProperties as UNSAFE_defaultMapRouteProperties, getHydrationData as UNSAFE_getHydrationData, getPatchRoutesOnNavigationFunction as UNSAFE_getPatchRoutesOnNavigationFunction, getTurboStreamSingleFetchDataStrategy as UNSAFE_getTurboStreamSingleFetchDataStrategy, hydrationRouteProperties as UNSAFE_hydrationRouteProperties, invariant as UNSAFE_invariant, shouldHydrateRouteLoader as UNSAFE_shouldHydrateRouteLoader, useFogOFWarDiscovery as UNSAFE_useFogOFWarDiscovery, useScrollRestoration as UNSAFE_useScrollRestoration, withComponentProps as UNSAFE_withComponentProps, withErrorBoundaryProps as UNSAFE_withErrorBoundaryProps, withHydrateFallbackProps as UNSAFE_withHydrateFallbackProps, createBrowserRouter, createContext, createCookie, createCookieSessionStorage, createHashRouter, createMemoryRouter, createMemorySessionStorage, createPath, createRequestHandler, createRoutesFromChildren, createRoutesFromElements, createRoutesStub, createSearchParams, createSession, createSessionStorage, createStaticHandler, createStaticRouter, data, generatePath, href, isCookie, isRouteErrorResponse, isSession, matchPath, matchRoutes, parsePath, redirect, redirectDocument, renderMatches, replace, resolvePath, HistoryRouter as unstable_HistoryRouter, RSCStaticRouter as unstable_RSCStaticRouter, routeRSCServerRequest as unstable_routeRSCServerRequest, setDevServerHooks as unstable_setDevServerHooks, usePrompt as unstable_usePrompt, useRoute as unstable_useRoute, useRouterState as unstable_useRouterState, useActionData, useAsyncError, useAsyncValue, useBeforeUnload, useBlocker, useFetcher, useFetchers, useFormAction, useHref, useInRouterContext, useLinkClickHandler, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes, useSearchParams, useSubmit, useViewTransitionState };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.3.0
2
+ * react-router v8.4.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -12,14 +12,19 @@
12
12
  function throwIfPotentialCSRFAttack(request, allowedActionOrigins) {
13
13
  let originHeader = request.headers.get("origin");
14
14
  let originDomain = null;
15
+ let originUrl = null;
15
16
  try {
16
- originDomain = typeof originHeader === "string" && originHeader !== "null" ? new URL(originHeader).host : originHeader;
17
+ if (typeof originHeader === "string" && originHeader !== "null") {
18
+ originUrl = new URL(originHeader);
19
+ originDomain = originUrl.host;
20
+ } else originDomain = originHeader;
17
21
  } catch {
18
22
  throw new Error(`\`origin\` header is not a valid URL. Aborting the action.`);
19
23
  }
20
- let host = new URL(request.url).host;
21
- if (originDomain && originDomain !== host) {
22
- if (!isAllowedOrigin(originDomain, allowedActionOrigins)) throw new Error("The `request.url` host does not match `origin` header from a forwarded action request. Aborting the action.");
24
+ let requestUrl = new URL(request.url);
25
+ let originMatchesRequest = originUrl ? originUrl.origin === requestUrl.origin : originDomain === requestUrl.host;
26
+ if (originDomain && !originMatchesRequest) {
27
+ if (!isAllowedOrigin(originDomain, allowedActionOrigins)) throw new Error("The `request.url` origin does not match `origin` header from a forwarded action request. Aborting the action.");
23
28
  }
24
29
  }
25
30
  function matchWildcardDomain(domain, pattern) {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v8.3.0
2
+ * react-router v8.4.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -8,10 +8,11 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
- import { createMemoryHistory, invariant, parsePath, warning } from "./router/history.js";
11
+ import { createMemoryHistory, createPath, invariant, parsePath, warning } from "./router/history.js";
12
12
  import { defaultMapRouteProperties, getResolveToMatches, getRoutePattern, resolveTo, stripBasename } from "./router/utils.js";
13
+ import { getNavigatorCurrentUrl, validateNavigationTarget } from "./router/navigation.js";
13
14
  import { createRouter } from "./router/router.js";
14
- import { AwaitContext, DataRouterContext, DataRouterStateContext, FetchersContext, LocationContext, NavigationContext, RouteContext, ViewTransitionContext, useIsRSCRouterContext } from "./context.js";
15
+ import { AwaitContext, DataRouterContext, DataRouterDataContext, DataRouterNavigationContext, DataRouterStateContext, FetchersContext, LocationContext, NavigationContext, RouteContext, ViewTransitionContext, useIsRSCRouterContext } from "./context.js";
15
16
  import { _renderMatches, useActionData, useAsyncValue, useInRouterContext, useLoaderData, useLocation, useMatches, useNavigate, useOutlet, useParams, useRouteError, useRoutes, useRoutesImpl } from "./hooks.js";
16
17
  import { warnOnce } from "./server-runtime/warnings.js";
17
18
  import * as React$1 from "react";
@@ -256,6 +257,7 @@ function RouterProvider({ router, flushSync: reactDomFlushSyncImpl, onError, use
256
257
  let navigator = React$1.useMemo(() => {
257
258
  return {
258
259
  createHref: router.createHref,
260
+ createURL: router.createURL,
259
261
  encodeLocation: router.encodeLocation,
260
262
  go: (n) => router.navigate(n),
261
263
  push: (to, state, opts) => router.navigate(to, {
@@ -282,7 +284,43 @@ function RouterProvider({ router, flushSync: reactDomFlushSyncImpl, onError, use
282
284
  basename,
283
285
  onError
284
286
  ]);
285
- return /* @__PURE__ */ React$1.createElement(React$1.Fragment, null, /* @__PURE__ */ React$1.createElement(DataRouterContext.Provider, { value: dataRouterContext }, /* @__PURE__ */ React$1.createElement(DataRouterStateContext.Provider, { value: state }, /* @__PURE__ */ React$1.createElement(FetchersContext.Provider, { value: fetcherData.current }, /* @__PURE__ */ React$1.createElement(ViewTransitionContext.Provider, { value: vtContext }, /* @__PURE__ */ React$1.createElement(Router, {
287
+ let dataRouterState = React$1.useMemo(() => ({
288
+ historyAction: state.historyAction,
289
+ location: state.location,
290
+ matches: state.matches,
291
+ initialized: state.initialized,
292
+ renderFallback: state.renderFallback,
293
+ restoreScrollPosition: state.restoreScrollPosition,
294
+ preventScrollReset: state.preventScrollReset,
295
+ blockers: state.blockers
296
+ }), [
297
+ state.historyAction,
298
+ state.location,
299
+ state.matches,
300
+ state.initialized,
301
+ state.renderFallback,
302
+ state.restoreScrollPosition,
303
+ state.preventScrollReset,
304
+ state.blockers
305
+ ]);
306
+ let dataRouterNavigation = React$1.useMemo(() => ({
307
+ navigation: state.navigation,
308
+ revalidation: state.revalidation
309
+ }), [state.navigation, state.revalidation]);
310
+ let dataRouterData = React$1.useMemo(() => ({
311
+ loaderData: state.loaderData,
312
+ actionData: state.actionData,
313
+ errors: state.errors
314
+ }), [
315
+ state.loaderData,
316
+ state.actionData,
317
+ state.errors
318
+ ]);
319
+ let fetchersContext = React$1.useMemo(() => ({
320
+ fetchers: state.fetchers,
321
+ fetcherData: fetcherData.current
322
+ }), [state.fetchers]);
323
+ return /* @__PURE__ */ React$1.createElement(React$1.Fragment, null, /* @__PURE__ */ React$1.createElement(DataRouterContext.Provider, { value: dataRouterContext }, /* @__PURE__ */ React$1.createElement(DataRouterStateContext.Provider, { value: dataRouterState }, /* @__PURE__ */ React$1.createElement(DataRouterNavigationContext.Provider, { value: dataRouterNavigation }, /* @__PURE__ */ React$1.createElement(DataRouterDataContext.Provider, { value: dataRouterData }, /* @__PURE__ */ React$1.createElement(FetchersContext.Provider, { value: fetchersContext }, /* @__PURE__ */ React$1.createElement(ViewTransitionContext.Provider, { value: vtContext }, /* @__PURE__ */ React$1.createElement(Router, {
286
324
  basename,
287
325
  location: state.location,
288
326
  navigationType: state.historyAction,
@@ -291,11 +329,10 @@ function RouterProvider({ router, flushSync: reactDomFlushSyncImpl, onError, use
291
329
  }, /* @__PURE__ */ React$1.createElement(MemoizedDataRoutes, {
292
330
  routes: router.routes,
293
331
  manifest: router.manifest,
294
- future: router.future,
295
332
  state,
296
333
  isStatic: false,
297
334
  onError
298
- })))))), null);
335
+ })))))))), null);
299
336
  }
300
337
  function getOptimisticRouterState(currentState, newState) {
301
338
  return {
@@ -307,13 +344,15 @@ function getOptimisticRouterState(currentState, newState) {
307
344
  };
308
345
  }
309
346
  const MemoizedDataRoutes = React$1.memo(DataRoutes);
310
- function DataRoutes({ routes, manifest, future, state, isStatic, onError }) {
347
+ function DataRoutes({ routes, manifest, state, isStatic, onError }) {
348
+ let dataRouterContext = React$1.useContext(DataRouterContext);
349
+ invariant(dataRouterContext, "You must render this element inside a <DataRouterContext.Provider> element");
311
350
  return useRoutesImpl(routes, void 0, {
351
+ router: dataRouterContext.router,
312
352
  manifest,
313
353
  state,
314
354
  isStatic,
315
- onError,
316
- future
355
+ onError
317
356
  });
318
357
  }
319
358
  /**
@@ -379,12 +418,13 @@ function MemoryRouter({ basename, children, initialEntries, initialIndex, useTra
379
418
  */
380
419
  function Navigate({ to, replace, state, relative }) {
381
420
  invariant(useInRouterContext(), `<Navigate> may be used only in the context of a <Router> component.`);
382
- let { static: isStatic } = React$1.useContext(NavigationContext);
421
+ let { static: isStatic, navigator } = React$1.useContext(NavigationContext);
383
422
  warning(!isStatic, "<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");
384
423
  let { matches } = React$1.useContext(RouteContext);
385
424
  let { pathname: locationPathname } = useLocation();
386
425
  let navigate = useNavigate();
387
426
  let path = resolveTo(to, getResolveToMatches(matches), locationPathname, relative === "path");
427
+ validateNavigationTarget(typeof to === "string" ? to : createPath(to), navigator.createHref(path), getNavigatorCurrentUrl(navigator), "reject");
388
428
  let jsonPath = JSON.stringify(path);
389
429
  React$1.useEffect(() => {
390
430
  navigate(JSON.parse(jsonPath), {