react-router 7.1.5 → 7.2.0-pre.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 (36) hide show
  1. package/CHANGELOG.md +21 -1
  2. package/dist/development/{chunk-IR6S3I6Y.mjs → chunk-HLU4BUUT.mjs} +244 -78
  3. package/dist/development/dom-export.d.mts +2 -2
  4. package/dist/development/dom-export.d.ts +2 -2
  5. package/dist/development/dom-export.js +222 -58
  6. package/dist/development/dom-export.mjs +12 -4
  7. package/dist/{production/fog-of-war-CCAcUMgB.d.ts → development/fog-of-war-Ax4Jg2xL.d.ts} +9 -5
  8. package/dist/development/{fog-of-war-D6dP9JIt.d.mts → fog-of-war-Cyo_TZuh.d.mts} +9 -5
  9. package/dist/development/index.d.mts +10 -5
  10. package/dist/development/index.d.ts +10 -5
  11. package/dist/development/index.js +244 -78
  12. package/dist/development/index.mjs +2 -2
  13. package/dist/development/lib/types/route-module.d.mts +3 -1
  14. package/dist/development/lib/types/route-module.d.ts +3 -1
  15. package/dist/development/lib/types/route-module.js +1 -1
  16. package/dist/development/lib/types/route-module.mjs +1 -1
  17. package/dist/development/{route-data-Cq_b5feC.d.ts → route-data-DQbTMaUY.d.mts} +1 -0
  18. package/dist/{production/route-data-Cq_b5feC.d.mts → development/route-data-DQbTMaUY.d.ts} +1 -0
  19. package/dist/production/{chunk-JRAGQQ3X.mjs → chunk-IA3JXIZE.mjs} +244 -78
  20. package/dist/production/dom-export.d.mts +2 -2
  21. package/dist/production/dom-export.d.ts +2 -2
  22. package/dist/production/dom-export.js +222 -58
  23. package/dist/production/dom-export.mjs +12 -4
  24. package/dist/{development/fog-of-war-CCAcUMgB.d.ts → production/fog-of-war-Ax4Jg2xL.d.ts} +9 -5
  25. package/dist/production/{fog-of-war-D6dP9JIt.d.mts → fog-of-war-Cyo_TZuh.d.mts} +9 -5
  26. package/dist/production/index.d.mts +10 -5
  27. package/dist/production/index.d.ts +10 -5
  28. package/dist/production/index.js +244 -78
  29. package/dist/production/index.mjs +2 -2
  30. package/dist/production/lib/types/route-module.d.mts +3 -1
  31. package/dist/production/lib/types/route-module.d.ts +3 -1
  32. package/dist/production/lib/types/route-module.js +1 -1
  33. package/dist/production/lib/types/route-module.mjs +1 -1
  34. package/dist/production/{route-data-Cq_b5feC.d.ts → route-data-DQbTMaUY.d.mts} +1 -0
  35. package/dist/{development/route-data-Cq_b5feC.d.mts → production/route-data-DQbTMaUY.d.ts} +1 -0
  36. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
- import { R as RouterProviderProps$1 } from './fog-of-war-D6dP9JIt.mjs';
3
- import './route-data-Cq_b5feC.mjs';
2
+ import { R as RouterProviderProps$1 } from './fog-of-war-Cyo_TZuh.mjs';
3
+ import './route-data-DQbTMaUY.mjs';
4
4
 
5
5
  type RouterProviderProps = Omit<RouterProviderProps$1, "flushSync">;
6
6
  declare function RouterProvider(props: Omit<RouterProviderProps, "flushSync">): React.JSX.Element;
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
- import { R as RouterProviderProps$1 } from './fog-of-war-CCAcUMgB.js';
3
- import './route-data-Cq_b5feC.js';
2
+ import { R as RouterProviderProps$1 } from './fog-of-war-Ax4Jg2xL.js';
3
+ import './route-data-DQbTMaUY.js';
4
4
 
5
5
  type RouterProviderProps = Omit<RouterProviderProps$1, "flushSync">;
6
6
  declare function RouterProvider(props: Omit<RouterProviderProps, "flushSync">): React.JSX.Element;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.1.5
2
+ * react-router v7.2.0-pre.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -2316,6 +2316,7 @@ function createRouter(init) {
2316
2316
  let localManifest = manifest;
2317
2317
  try {
2318
2318
  await patchRoutesOnNavigationImpl({
2319
+ signal,
2319
2320
  path: pathname,
2320
2321
  matches: partialMatches,
2321
2322
  patch: (routeId, children) => {
@@ -4225,11 +4226,20 @@ async function loadRouteModule(route, routeModulesCache) {
4225
4226
  }
4226
4227
 
4227
4228
  // lib/dom/ssr/links.ts
4229
+ function getRouteCssDescriptors(route) {
4230
+ if (!route.css) return [];
4231
+ return route.css.map((href) => ({ rel: "stylesheet", href }));
4232
+ }
4233
+ async function prefetchRouteCss(route) {
4234
+ if (!route.css) return;
4235
+ let descriptors = getRouteCssDescriptors(route);
4236
+ await Promise.all(descriptors.map(prefetchStyleLink));
4237
+ }
4228
4238
  async function prefetchStyleLinks(route, routeModule) {
4229
4239
  if (!route.css && !routeModule.links || !isPreloadSupported()) return;
4230
4240
  let descriptors = [];
4231
4241
  if (route.css) {
4232
- descriptors.push(...route.css.map((href) => ({ rel: "stylesheet", href })));
4242
+ descriptors.push(...getRouteCssDescriptors(route));
4233
4243
  }
4234
4244
  if (routeModule.links) {
4235
4245
  descriptors.push(...routeModule.links());
@@ -4245,13 +4255,15 @@ async function prefetchStyleLinks(route, routeModule) {
4245
4255
  });
4246
4256
  }
4247
4257
  }
4248
- let matchingLinks = styleLinks.filter(
4249
- (link) => (!link.media || window.matchMedia(link.media).matches) && !document.querySelector(`link[rel="stylesheet"][href="${link.href}"]`)
4250
- );
4251
- await Promise.all(matchingLinks.map(prefetchStyleLink));
4258
+ await Promise.all(styleLinks.map(prefetchStyleLink));
4252
4259
  }
4253
4260
  async function prefetchStyleLink(descriptor) {
4254
4261
  return new Promise((resolve) => {
4262
+ if (descriptor.media && !window.matchMedia(descriptor.media).matches || document.querySelector(
4263
+ `link[rel="stylesheet"][href="${descriptor.href}"]`
4264
+ )) {
4265
+ return resolve();
4266
+ }
4255
4267
  let link = document.createElement("link");
4256
4268
  Object.assign(link, descriptor);
4257
4269
  function removeLink() {
@@ -4273,6 +4285,31 @@ async function prefetchStyleLink(descriptor) {
4273
4285
  function isPageLinkDescriptor(object) {
4274
4286
  return object != null && typeof object.page === "string";
4275
4287
  }
4288
+ function getModuleLinkHrefs(matches, manifest, { includeHydrateFallback } = {}) {
4289
+ return dedupeHrefs(
4290
+ matches.map((match) => {
4291
+ let route = manifest.routes[match.route.id];
4292
+ if (!route) return [];
4293
+ let hrefs = [route.module];
4294
+ if (route.clientActionModule) {
4295
+ hrefs = hrefs.concat(route.clientActionModule);
4296
+ }
4297
+ if (route.clientLoaderModule) {
4298
+ hrefs = hrefs.concat(route.clientLoaderModule);
4299
+ }
4300
+ if (includeHydrateFallback && route.hydrateFallbackModule) {
4301
+ hrefs = hrefs.concat(route.hydrateFallbackModule);
4302
+ }
4303
+ if (route.imports) {
4304
+ hrefs = hrefs.concat(route.imports);
4305
+ }
4306
+ return hrefs;
4307
+ }).flat(1)
4308
+ );
4309
+ }
4310
+ function dedupeHrefs(hrefs) {
4311
+ return [...new Set(hrefs)];
4312
+ }
4276
4313
  var _isPreloadSupported;
4277
4314
  function isPreloadSupported() {
4278
4315
  if (_isPreloadSupported !== void 0) {
@@ -4316,17 +4353,31 @@ async function createRequestInit(request) {
4316
4353
 
4317
4354
  // lib/dom/ssr/single-fetch.tsx
4318
4355
  var SingleFetchRedirectSymbol = Symbol("SingleFetchRedirect");
4319
- function getSingleFetchDataStrategy(manifest, routeModules, getRouter) {
4356
+ function getSingleFetchDataStrategy(manifest, routeModules, ssr, getRouter) {
4320
4357
  return async ({ request, matches, fetcherKey }) => {
4321
4358
  if (request.method !== "GET") {
4322
4359
  return singleFetchActionStrategy(request, matches);
4323
4360
  }
4361
+ if (!ssr) {
4362
+ let foundLoaderBelowRoot = matches.some(
4363
+ (m) => m.route.id !== "root" && manifest.routes[m.route.id]?.hasLoader
4364
+ );
4365
+ if (!foundLoaderBelowRoot) {
4366
+ let matchesToLoad = matches.filter((m) => m.shouldLoad);
4367
+ let results = await Promise.all(matchesToLoad.map((m) => m.resolve()));
4368
+ return results.reduce(
4369
+ (acc, result, i) => Object.assign(acc, { [matchesToLoad[i].route.id]: result }),
4370
+ {}
4371
+ );
4372
+ }
4373
+ }
4324
4374
  if (fetcherKey) {
4325
4375
  return singleFetchLoaderFetcherStrategy(request, matches);
4326
4376
  }
4327
4377
  return singleFetchLoaderNavigationStrategy(
4328
4378
  manifest,
4329
4379
  routeModules,
4380
+ ssr,
4330
4381
  getRouter(),
4331
4382
  request,
4332
4383
  matches
@@ -4360,7 +4411,7 @@ async function singleFetchActionStrategy(request, matches) {
4360
4411
  }
4361
4412
  };
4362
4413
  }
4363
- async function singleFetchLoaderNavigationStrategy(manifest, routeModules, router2, request, matches) {
4414
+ async function singleFetchLoaderNavigationStrategy(manifest, routeModules, ssr, router2, request, matches) {
4364
4415
  let routesParams = /* @__PURE__ */ new Set();
4365
4416
  let foundOptOutRoute = false;
4366
4417
  let routeDfds = matches.map(() => createDeferred2());
@@ -4426,7 +4477,7 @@ async function singleFetchLoaderNavigationStrategy(manifest, routeModules, route
4426
4477
  singleFetchDfd.resolve({});
4427
4478
  } else {
4428
4479
  try {
4429
- if (foundOptOutRoute && routesParams.size > 0) {
4480
+ if (ssr && foundOptOutRoute && routesParams.size > 0) {
4430
4481
  url.searchParams.set(
4431
4482
  "_routes",
4432
4483
  matches.filter((m) => routesParams.has(m.route.id)).map((m) => m.route.id).join(",")
@@ -4754,11 +4805,12 @@ function getRouteComponents(route, routeModule, isSpaMode) {
4754
4805
  }
4755
4806
  return { Component: Component4, ErrorBoundary, HydrateFallback };
4756
4807
  }
4757
- function createClientRoutesWithHMRRevalidationOptOut(needsRevalidation, manifest, routeModulesCache, initialState, future, isSpaMode) {
4808
+ function createClientRoutesWithHMRRevalidationOptOut(needsRevalidation, manifest, routeModulesCache, initialState, ssr, isSpaMode) {
4758
4809
  return createClientRoutes(
4759
4810
  manifest,
4760
4811
  routeModulesCache,
4761
4812
  initialState,
4813
+ ssr,
4762
4814
  isSpaMode,
4763
4815
  "",
4764
4816
  groupRoutesByParentId(manifest),
@@ -4767,14 +4819,14 @@ function createClientRoutesWithHMRRevalidationOptOut(needsRevalidation, manifest
4767
4819
  }
4768
4820
  function preventInvalidServerHandlerCall(type, route, isSpaMode) {
4769
4821
  if (isSpaMode) {
4770
- let fn2 = type === "action" ? "serverAction()" : "serverLoader()";
4771
- let msg2 = `You cannot call ${fn2} in SPA Mode (routeId: "${route.id}")`;
4772
- console.error(msg2);
4773
- throw new ErrorResponseImpl(400, "Bad Request", new Error(msg2), true);
4822
+ let fn = type === "action" ? "serverAction()" : "serverLoader()";
4823
+ let msg = `You cannot call ${fn} in SPA Mode (routeId: "${route.id}")`;
4824
+ console.error(msg);
4825
+ throw new ErrorResponseImpl(400, "Bad Request", new Error(msg), true);
4774
4826
  }
4775
- let fn = type === "action" ? "serverAction()" : "serverLoader()";
4776
- let msg = `You are trying to call ${fn} on a route that does not have a server ${type} (routeId: "${route.id}")`;
4777
4827
  if (type === "loader" && !route.hasLoader || type === "action" && !route.hasAction) {
4828
+ let fn = type === "action" ? "serverAction()" : "serverLoader()";
4829
+ let msg = `You are trying to call ${fn} on a route that does not have a server ${type} (routeId: "${route.id}")`;
4778
4830
  console.error(msg);
4779
4831
  throw new ErrorResponseImpl(400, "Bad Request", new Error(msg), true);
4780
4832
  }
@@ -4785,7 +4837,7 @@ function noActionDefinedError(type, routeId) {
4785
4837
  console.error(msg);
4786
4838
  throw new ErrorResponseImpl(405, "Method Not Allowed", new Error(msg), true);
4787
4839
  }
4788
- function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode, parentId = "", routesByParentId = groupRoutesByParentId(manifest), needsRevalidation) {
4840
+ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSpaMode, parentId = "", routesByParentId = groupRoutesByParentId(manifest), needsRevalidation) {
4789
4841
  return (routesByParentId[parentId] || []).map((route) => {
4790
4842
  let routeModule = routeModulesCache[route.id];
4791
4843
  function fetchServerHandler(singleFetch) {
@@ -4805,6 +4857,21 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
4805
4857
  }
4806
4858
  return fetchServerHandler(singleFetch);
4807
4859
  }
4860
+ function prefetchModule(modulePath) {
4861
+ import(
4862
+ /* @vite-ignore */
4863
+ /* webpackIgnore: true */
4864
+ modulePath
4865
+ );
4866
+ }
4867
+ function prefetchRouteModuleChunks(route2) {
4868
+ if (route2.clientActionModule) {
4869
+ prefetchModule(route2.clientActionModule);
4870
+ }
4871
+ if (route2.clientLoaderModule) {
4872
+ prefetchModule(route2.clientLoaderModule);
4873
+ }
4874
+ }
4808
4875
  async function prefetchStylesAndCallHandler(handler) {
4809
4876
  let cachedModule = routeModulesCache[route.id];
4810
4877
  let linkPrefetchPromise = cachedModule ? prefetchStyleLinks(route, cachedModule) : Promise.resolve();
@@ -4826,7 +4893,8 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
4826
4893
  handle: routeModule.handle,
4827
4894
  shouldRevalidate: getShouldRevalidateFunction(
4828
4895
  routeModule,
4829
- route.id,
4896
+ route,
4897
+ ssr,
4830
4898
  needsRevalidation
4831
4899
  )
4832
4900
  });
@@ -4843,7 +4911,6 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
4843
4911
  "No `routeModule` available for critical-route loader"
4844
4912
  );
4845
4913
  if (!routeModule.clientLoader) {
4846
- if (isSpaMode) return null;
4847
4914
  return fetchServerLoader(singleFetch);
4848
4915
  }
4849
4916
  return routeModule.clientLoader({
@@ -4898,9 +4965,24 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
4898
4965
  } else {
4899
4966
  if (!route.hasClientLoader) {
4900
4967
  dataRoute.loader = ({ request }, singleFetch) => prefetchStylesAndCallHandler(() => {
4901
- if (isSpaMode) return Promise.resolve(null);
4902
4968
  return fetchServerLoader(singleFetch);
4903
4969
  });
4970
+ } else if (route.clientLoaderModule) {
4971
+ dataRoute.loader = async (args, singleFetch) => {
4972
+ invariant2(route.clientLoaderModule);
4973
+ let { clientLoader } = await import(
4974
+ /* @vite-ignore */
4975
+ /* webpackIgnore: true */
4976
+ route.clientLoaderModule
4977
+ );
4978
+ return clientLoader({
4979
+ ...args,
4980
+ async serverLoader() {
4981
+ preventInvalidServerHandlerCall("loader", route, isSpaMode);
4982
+ return fetchServerLoader(singleFetch);
4983
+ }
4984
+ });
4985
+ };
4904
4986
  }
4905
4987
  if (!route.hasClientAction) {
4906
4988
  dataRoute.action = ({ request }, singleFetch) => prefetchStylesAndCallHandler(() => {
@@ -4909,12 +4991,34 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
4909
4991
  }
4910
4992
  return fetchServerAction(singleFetch);
4911
4993
  });
4994
+ } else if (route.clientActionModule) {
4995
+ dataRoute.action = async (args, singleFetch) => {
4996
+ invariant2(route.clientActionModule);
4997
+ prefetchRouteModuleChunks(route);
4998
+ let { clientAction } = await import(
4999
+ /* @vite-ignore */
5000
+ /* webpackIgnore: true */
5001
+ route.clientActionModule
5002
+ );
5003
+ return clientAction({
5004
+ ...args,
5005
+ async serverAction() {
5006
+ preventInvalidServerHandlerCall("action", route, isSpaMode);
5007
+ return fetchServerAction(singleFetch);
5008
+ }
5009
+ });
5010
+ };
4912
5011
  }
4913
5012
  dataRoute.lazy = async () => {
4914
- let mod = await loadRouteModuleWithBlockingLinks(
5013
+ if (route.clientLoaderModule || route.clientActionModule) {
5014
+ await new Promise((resolve) => setTimeout(resolve, 0));
5015
+ }
5016
+ let modPromise = loadRouteModuleWithBlockingLinks(
4915
5017
  route,
4916
5018
  routeModulesCache
4917
5019
  );
5020
+ prefetchRouteModuleChunks(route);
5021
+ let mod = await modPromise;
4918
5022
  let lazyRoute = { ...mod };
4919
5023
  if (mod.clientLoader) {
4920
5024
  let clientLoader = mod.clientLoader;
@@ -4942,7 +5046,8 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
4942
5046
  hasErrorBoundary: lazyRoute.hasErrorBoundary,
4943
5047
  shouldRevalidate: getShouldRevalidateFunction(
4944
5048
  lazyRoute,
4945
- route.id,
5049
+ route,
5050
+ ssr,
4946
5051
  needsRevalidation
4947
5052
  ),
4948
5053
  handle: lazyRoute.handle,
@@ -4957,6 +5062,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
4957
5062
  manifest,
4958
5063
  routeModulesCache,
4959
5064
  initialState,
5065
+ ssr,
4960
5066
  isSpaMode,
4961
5067
  route.id,
4962
5068
  routesByParentId,
@@ -4966,15 +5072,18 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
4966
5072
  return dataRoute;
4967
5073
  });
4968
5074
  }
4969
- function getShouldRevalidateFunction(route, routeId, needsRevalidation) {
5075
+ function getShouldRevalidateFunction(route, manifestRoute, ssr, needsRevalidation) {
4970
5076
  if (needsRevalidation) {
4971
5077
  return wrapShouldRevalidateForHdr(
4972
- routeId,
5078
+ manifestRoute.id,
4973
5079
  route.shouldRevalidate,
4974
5080
  needsRevalidation
4975
5081
  );
4976
5082
  }
4977
- if (route.shouldRevalidate) {
5083
+ if (!ssr && manifestRoute.id === "root" && manifestRoute.hasLoader && !manifestRoute.hasClientLoader) {
5084
+ return () => false;
5085
+ }
5086
+ if (ssr && route.shouldRevalidate) {
4978
5087
  let fn = route.shouldRevalidate;
4979
5088
  return (opts) => fn({ ...opts, defaultShouldRevalidate: true });
4980
5089
  }
@@ -4991,8 +5100,13 @@ function wrapShouldRevalidateForHdr(routeId, routeShouldRevalidate, needsRevalid
4991
5100
  };
4992
5101
  }
4993
5102
  async function loadRouteModuleWithBlockingLinks(route, routeModules) {
4994
- let routeModule = await loadRouteModule(route, routeModules);
4995
- await prefetchStyleLinks(route, routeModule);
5103
+ let routeModulePromise = loadRouteModule(route, routeModules);
5104
+ let prefetchRouteCssPromise = prefetchRouteCss(route);
5105
+ let routeModule = await routeModulePromise;
5106
+ await Promise.all([
5107
+ prefetchRouteCssPromise,
5108
+ prefetchStyleLinks(route, routeModule)
5109
+ ]);
4996
5110
  return {
4997
5111
  Component: getRouteModuleComponent(routeModule),
4998
5112
  ErrorBoundary: routeModule.ErrorBoundary,
@@ -5020,8 +5134,8 @@ var nextPaths = /* @__PURE__ */ new Set();
5020
5134
  var discoveredPathsMaxSize = 1e3;
5021
5135
  var discoveredPaths = /* @__PURE__ */ new Set();
5022
5136
  var URL_LIMIT = 7680;
5023
- function isFogOfWarEnabled(isSpaMode) {
5024
- return !isSpaMode;
5137
+ function isFogOfWarEnabled(ssr) {
5138
+ return ssr === true;
5025
5139
  }
5026
5140
  function getPartialManifest(manifest, router2) {
5027
5141
  let routeIds = new Set(router2.state.matches.map((m) => m.route.id));
@@ -5047,11 +5161,11 @@ function getPartialManifest(manifest, router2) {
5047
5161
  routes: initialRoutes
5048
5162
  };
5049
5163
  }
5050
- function getPatchRoutesOnNavigationFunction(manifest, routeModules, isSpaMode, basename) {
5051
- if (!isFogOfWarEnabled(isSpaMode)) {
5164
+ function getPatchRoutesOnNavigationFunction(manifest, routeModules, ssr, isSpaMode, basename) {
5165
+ if (!isFogOfWarEnabled(ssr)) {
5052
5166
  return void 0;
5053
5167
  }
5054
- return async ({ path, patch }) => {
5168
+ return async ({ path, patch, signal }) => {
5055
5169
  if (discoveredPaths.has(path)) {
5056
5170
  return;
5057
5171
  }
@@ -5059,15 +5173,17 @@ function getPatchRoutesOnNavigationFunction(manifest, routeModules, isSpaMode, b
5059
5173
  [path],
5060
5174
  manifest,
5061
5175
  routeModules,
5176
+ ssr,
5062
5177
  isSpaMode,
5063
5178
  basename,
5064
- patch
5179
+ patch,
5180
+ signal
5065
5181
  );
5066
5182
  };
5067
5183
  }
5068
- function useFogOFWarDiscovery(router2, manifest, routeModules, isSpaMode) {
5184
+ function useFogOFWarDiscovery(router2, manifest, routeModules, ssr, isSpaMode) {
5069
5185
  React8.useEffect(() => {
5070
- if (!isFogOfWarEnabled(isSpaMode) || navigator.connection?.saveData === true) {
5186
+ if (!isFogOfWarEnabled(ssr) || navigator.connection?.saveData === true) {
5071
5187
  return;
5072
5188
  }
5073
5189
  function registerElement(el) {
@@ -5097,6 +5213,7 @@ function useFogOFWarDiscovery(router2, manifest, routeModules, isSpaMode) {
5097
5213
  lazyPaths,
5098
5214
  manifest,
5099
5215
  routeModules,
5216
+ ssr,
5100
5217
  isSpaMode,
5101
5218
  router2.basename,
5102
5219
  router2.patchRoutes
@@ -5115,9 +5232,9 @@ function useFogOFWarDiscovery(router2, manifest, routeModules, isSpaMode) {
5115
5232
  attributeFilter: ["data-discover", "href", "action"]
5116
5233
  });
5117
5234
  return () => observer.disconnect();
5118
- }, [isSpaMode, manifest, routeModules, router2]);
5235
+ }, [ssr, isSpaMode, manifest, routeModules, router2]);
5119
5236
  }
5120
- async function fetchAndApplyManifestPatches(paths, manifest, routeModules, isSpaMode, basename, patchRoutes) {
5237
+ async function fetchAndApplyManifestPatches(paths, manifest, routeModules, ssr, isSpaMode, basename, patchRoutes, signal) {
5121
5238
  let manifestPath = `${basename != null ? basename : "/"}/__manifest`.replace(
5122
5239
  /\/+/g,
5123
5240
  "/"
@@ -5129,13 +5246,19 @@ async function fetchAndApplyManifestPatches(paths, manifest, routeModules, isSpa
5129
5246
  nextPaths.clear();
5130
5247
  return;
5131
5248
  }
5132
- let res = await fetch(url);
5133
- if (!res.ok) {
5134
- throw new Error(`${res.status} ${res.statusText}`);
5135
- } else if (res.status >= 400) {
5136
- throw new Error(await res.text());
5249
+ let serverPatches;
5250
+ try {
5251
+ let res = await fetch(url, { signal });
5252
+ if (!res.ok) {
5253
+ throw new Error(`${res.status} ${res.statusText}`);
5254
+ } else if (res.status >= 400) {
5255
+ throw new Error(await res.text());
5256
+ }
5257
+ serverPatches = await res.json();
5258
+ } catch (e) {
5259
+ if (signal?.aborted) return;
5260
+ throw e;
5137
5261
  }
5138
- let serverPatches = await res.json();
5139
5262
  let knownRoutes = new Set(Object.keys(manifest.routes));
5140
5263
  let patches = Object.values(serverPatches).reduce((acc, route) => {
5141
5264
  if (route && !knownRoutes.has(route.id)) {
@@ -5154,7 +5277,7 @@ async function fetchAndApplyManifestPatches(paths, manifest, routeModules, isSpa
5154
5277
  parentIds.forEach(
5155
5278
  (parentId) => patchRoutes(
5156
5279
  parentId || null,
5157
- createClientRoutes(patches, routeModules, null, isSpaMode, parentId)
5280
+ createClientRoutes(patches, routeModules, null, ssr, isSpaMode, parentId)
5158
5281
  )
5159
5282
  );
5160
5283
  }
@@ -5212,10 +5335,10 @@ function getActiveMatches(matches, errors, isSpaMode) {
5212
5335
  }
5213
5336
  var isHydrated = false;
5214
5337
  function Scripts(props) {
5215
- let { manifest, serverHandoffString, isSpaMode, renderMeta } = useFrameworkContext();
5338
+ let { manifest, serverHandoffString, isSpaMode, ssr, renderMeta } = useFrameworkContext();
5216
5339
  let { router: router2, static: isStatic, staticContext } = useDataRouterContext();
5217
5340
  let { matches: routerMatches } = useDataRouterStateContext();
5218
- let enableFogOfWar = isFogOfWarEnabled(isSpaMode);
5341
+ let enableFogOfWar = isFogOfWarEnabled(ssr);
5219
5342
  if (renderMeta) {
5220
5343
  renderMeta.didRenderScripts = true;
5221
5344
  }
@@ -5227,11 +5350,44 @@ function Scripts(props) {
5227
5350
  let streamScript = "window.__reactRouterContext.stream = new ReadableStream({start(controller){window.__reactRouterContext.streamController = controller;}}).pipeThrough(new TextEncoderStream());";
5228
5351
  let contextScript = staticContext ? `window.__reactRouterContext = ${serverHandoffString};${streamScript}` : " ";
5229
5352
  let routeModulesScript = !isStatic ? " " : `${manifest.hmr?.runtime ? `import ${JSON.stringify(manifest.hmr.runtime)};` : ""}${!enableFogOfWar ? `import ${JSON.stringify(manifest.url)}` : ""};
5230
- ${matches.map(
5231
- (match, index) => `import * as route${index} from ${JSON.stringify(
5232
- manifest.routes[match.route.id].module
5233
- )};`
5234
- ).join("\n")}
5353
+ ${matches.map((match, routeIndex) => {
5354
+ let routeVarName = `route${routeIndex}`;
5355
+ let manifestEntry = manifest.routes[match.route.id];
5356
+ invariant2(manifestEntry, `Route ${match.route.id} not found in manifest`);
5357
+ let {
5358
+ clientActionModule,
5359
+ clientLoaderModule,
5360
+ hydrateFallbackModule,
5361
+ module: module2
5362
+ } = manifestEntry;
5363
+ let chunks = [
5364
+ ...clientActionModule ? [
5365
+ {
5366
+ module: clientActionModule,
5367
+ varName: `${routeVarName}_clientAction`
5368
+ }
5369
+ ] : [],
5370
+ ...clientLoaderModule ? [
5371
+ {
5372
+ module: clientLoaderModule,
5373
+ varName: `${routeVarName}_clientLoader`
5374
+ }
5375
+ ] : [],
5376
+ ...hydrateFallbackModule ? [
5377
+ {
5378
+ module: hydrateFallbackModule,
5379
+ varName: `${routeVarName}_HydrateFallback`
5380
+ }
5381
+ ] : [],
5382
+ { module: module2, varName: `${routeVarName}_main` }
5383
+ ];
5384
+ if (chunks.length === 1) {
5385
+ return `import * as ${routeVarName} from ${JSON.stringify(module2)};`;
5386
+ }
5387
+ let chunkImportsSnippet = chunks.map((chunk) => `import * as ${chunk.varName} from "${chunk.module}";`).join("\n");
5388
+ let mergedChunksSnippet = `const ${routeVarName} = {${chunks.map((chunk) => `...${chunk.varName}`).join(",")}};`;
5389
+ return [chunkImportsSnippet, mergedChunksSnippet].join("\n");
5390
+ }).join("\n")}
5235
5391
  ${enableFogOfWar ? (
5236
5392
  // Inline a minimal manifest with the SSR matches
5237
5393
  `window.__reactRouterManifest = ${JSON.stringify(
@@ -5262,11 +5418,11 @@ import(${JSON.stringify(manifest.entry.module)});`;
5262
5418
  }
5263
5419
  ));
5264
5420
  }, []);
5265
- let routePreloads = matches.map((match) => {
5266
- let route = manifest.routes[match.route.id];
5267
- return route ? (route.imports || []).concat([route.module]) : [];
5268
- }).flat(1);
5269
- let preloads = isHydrated ? [] : manifest.entry.imports.concat(routePreloads);
5421
+ let preloads = isHydrated ? [] : manifest.entry.imports.concat(
5422
+ getModuleLinkHrefs(matches, manifest, {
5423
+ includeHydrateFallback: true
5424
+ })
5425
+ );
5270
5426
  return isHydrated ? null : /* @__PURE__ */ React9.createElement(React9.Fragment, null, !enableFogOfWar ? /* @__PURE__ */ React9.createElement(
5271
5427
  "link",
5272
5428
  {
@@ -5382,13 +5538,17 @@ function createHydratedRouter() {
5382
5538
  ssrInfo.manifest.routes,
5383
5539
  ssrInfo.routeModules,
5384
5540
  ssrInfo.context.state,
5541
+ ssrInfo.context.ssr,
5385
5542
  ssrInfo.context.isSpaMode
5386
5543
  );
5387
5544
  let hydrationData = void 0;
5388
- if (!ssrInfo.context.isSpaMode) {
5545
+ let loaderData = ssrInfo.context.state.loaderData;
5546
+ if (ssrInfo.context.isSpaMode) {
5547
+ hydrationData = { loaderData };
5548
+ } else {
5389
5549
  hydrationData = {
5390
5550
  ...ssrInfo.context.state,
5391
- loaderData: { ...ssrInfo.context.state.loaderData }
5551
+ loaderData: { ...loaderData }
5392
5552
  };
5393
5553
  let initialMatches = matchRoutes(
5394
5554
  routes,
@@ -5424,11 +5584,13 @@ function createHydratedRouter() {
5424
5584
  dataStrategy: getSingleFetchDataStrategy(
5425
5585
  ssrInfo.manifest,
5426
5586
  ssrInfo.routeModules,
5587
+ ssrInfo.context.ssr,
5427
5588
  () => router2
5428
5589
  ),
5429
5590
  patchRoutesOnNavigation: getPatchRoutesOnNavigationFunction(
5430
5591
  ssrInfo.manifest,
5431
5592
  ssrInfo.routeModules,
5593
+ ssrInfo.context.ssr,
5432
5594
  ssrInfo.context.isSpaMode,
5433
5595
  ssrInfo.context.basename
5434
5596
  )
@@ -5476,6 +5638,7 @@ function HydratedRouter() {
5476
5638
  router,
5477
5639
  ssrInfo.manifest,
5478
5640
  ssrInfo.routeModules,
5641
+ ssrInfo.context.ssr,
5479
5642
  ssrInfo.context.isSpaMode
5480
5643
  );
5481
5644
  return (
@@ -5489,6 +5652,7 @@ function HydratedRouter() {
5489
5652
  routeModules: ssrInfo.routeModules,
5490
5653
  future: ssrInfo.context.future,
5491
5654
  criticalCss,
5655
+ ssr: ssrInfo.context.ssr,
5492
5656
  isSpaMode: ssrInfo.context.isSpaMode
5493
5657
  }
5494
5658
  },
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.1.5
2
+ * react-router v7.2.0-pre.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -25,7 +25,7 @@ import {
25
25
  matchRoutes,
26
26
  shouldHydrateRouteLoader,
27
27
  useFogOFWarDiscovery
28
- } from "./chunk-IR6S3I6Y.mjs";
28
+ } from "./chunk-HLU4BUUT.mjs";
29
29
 
30
30
  // lib/dom-export/dom-router-provider.tsx
31
31
  import * as React from "react";
@@ -79,13 +79,17 @@ function createHydratedRouter() {
79
79
  ssrInfo.manifest.routes,
80
80
  ssrInfo.routeModules,
81
81
  ssrInfo.context.state,
82
+ ssrInfo.context.ssr,
82
83
  ssrInfo.context.isSpaMode
83
84
  );
84
85
  let hydrationData = void 0;
85
- if (!ssrInfo.context.isSpaMode) {
86
+ let loaderData = ssrInfo.context.state.loaderData;
87
+ if (ssrInfo.context.isSpaMode) {
88
+ hydrationData = { loaderData };
89
+ } else {
86
90
  hydrationData = {
87
91
  ...ssrInfo.context.state,
88
- loaderData: { ...ssrInfo.context.state.loaderData }
92
+ loaderData: { ...loaderData }
89
93
  };
90
94
  let initialMatches = matchRoutes(
91
95
  routes,
@@ -121,11 +125,13 @@ function createHydratedRouter() {
121
125
  dataStrategy: getSingleFetchDataStrategy(
122
126
  ssrInfo.manifest,
123
127
  ssrInfo.routeModules,
128
+ ssrInfo.context.ssr,
124
129
  () => router2
125
130
  ),
126
131
  patchRoutesOnNavigation: getPatchRoutesOnNavigationFunction(
127
132
  ssrInfo.manifest,
128
133
  ssrInfo.routeModules,
134
+ ssrInfo.context.ssr,
129
135
  ssrInfo.context.isSpaMode,
130
136
  ssrInfo.context.basename
131
137
  )
@@ -173,6 +179,7 @@ function HydratedRouter() {
173
179
  router,
174
180
  ssrInfo.manifest,
175
181
  ssrInfo.routeModules,
182
+ ssrInfo.context.ssr,
176
183
  ssrInfo.context.isSpaMode
177
184
  );
178
185
  return (
@@ -186,6 +193,7 @@ function HydratedRouter() {
186
193
  routeModules: ssrInfo.routeModules,
187
194
  future: ssrInfo.context.future,
188
195
  criticalCss,
196
+ ssr: ssrInfo.context.ssr,
189
197
  isSpaMode: ssrInfo.context.isSpaMode
190
198
  }
191
199
  },