react-router 0.0.0-experimental-df0f1dfda → 0.0.0-experimental-fde52e515

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 +20 -0
  2. package/dist/development/{chunk-O5WSUTKP.mjs → chunk-AEO7EMQS.mjs} +77 -39
  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 +66 -36
  6. package/dist/development/dom-export.mjs +10 -4
  7. package/dist/development/{fog-of-war-L5G-Cw9x.d.ts → fog-of-war-D8U3moAU.d.mts} +4 -3
  8. package/dist/{production/fog-of-war-D3ny56dR.d.mts → development/fog-of-war-DjxZtxiP.d.ts} +4 -3
  9. package/dist/development/index.d.mts +9 -4
  10. package/dist/development/index.d.ts +9 -4
  11. package/dist/development/index.js +77 -39
  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-F7U65DMX.mjs → chunk-D2IJPDLL.mjs} +77 -39
  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 +66 -36
  23. package/dist/production/dom-export.mjs +10 -4
  24. package/dist/production/{fog-of-war-L5G-Cw9x.d.ts → fog-of-war-D8U3moAU.d.mts} +4 -3
  25. package/dist/{development/fog-of-war-D3ny56dR.d.mts → production/fog-of-war-DjxZtxiP.d.ts} +4 -3
  26. package/dist/production/index.d.mts +9 -4
  27. package/dist/production/index.d.ts +9 -4
  28. package/dist/production/index.js +77 -39
  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
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # `react-router`
2
2
 
3
+ ## 7.1.5
4
+
5
+ ### Patch Changes
6
+
7
+ - Fix regression introduced in `7.1.4` via [#12800](https://github.com/remix-run/react-router/pull/12800) that caused issues navigating to hash routes inside splat routes for applications using Lazy Route Discovery (`patchRoutesOnNavigation`) ([#12927](https://github.com/remix-run/react-router/pull/12927))
8
+
9
+ ## 7.1.4
10
+
11
+ ### Patch Changes
12
+
13
+ - Internal reorg to clean up some duplicated route module types ([#12799](https://github.com/remix-run/react-router/pull/12799))
14
+ - Properly handle status codes that cannot have a body in single fetch responses (204, etc.) ([#12760](https://github.com/remix-run/react-router/pull/12760))
15
+ - Stop erroring on resource routes that return raw strings/objects and instead serialize them as `text/plain` or `application/json` responses ([#12848](https://github.com/remix-run/react-router/pull/12848))
16
+ - This only applies when accessed as a resource route without the `.data` extension
17
+ - When accessed from a Single Fetch `.data` request, they will still be encoded via `turbo-stream`
18
+ - Optimize Lazy Route Discovery path discovery to favor a single `querySelectorAll` call at the `body` level instead of many calls at the sub-tree level ([#12731](https://github.com/remix-run/react-router/pull/12731))
19
+ - Properly bubble headers as `errorHeaders` when throwing a `data()` result ([#12846](https://github.com/remix-run/react-router/pull/12846))
20
+ - Avoid duplication of `Set-Cookie` headers could be duplicated if also returned from `headers`
21
+ - Optimize route matching by skipping redundant `matchRoutes` calls when possible ([#12800](https://github.com/remix-run/react-router/pull/12800))
22
+
3
23
  ## 7.1.3
4
24
 
5
25
  _No changes_
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v0.0.0-experimental-df0f1dfda
2
+ * react-router v0.0.0-experimental-fde52e515
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1320,6 +1320,10 @@ function createRouter(init) {
1320
1320
  state.matches
1321
1321
  ) : matchRoutes(routesToUse, location, basename);
1322
1322
  let flushSync = (opts && opts.flushSync) === true;
1323
+ if (matches && state.initialized && !isRevalidationRequired && isHashChangeOnly(state.location, location) && !(opts && opts.submission && isMutationMethod(opts.submission.formMethod))) {
1324
+ completeNavigation(location, { matches }, { flushSync });
1325
+ return;
1326
+ }
1323
1327
  let fogOfWar = checkFogOfWar(matches, routesToUse, location.pathname);
1324
1328
  if (fogOfWar.active && fogOfWar.matches) {
1325
1329
  matches = fogOfWar.matches;
@@ -1341,10 +1345,6 @@ function createRouter(init) {
1341
1345
  );
1342
1346
  return;
1343
1347
  }
1344
- if (state.initialized && !isRevalidationRequired && isHashChangeOnly(state.location, location) && !(opts && opts.submission && isMutationMethod(opts.submission.formMethod))) {
1345
- completeNavigation(location, { matches }, { flushSync });
1346
- return;
1347
- }
1348
1348
  pendingNavigationController = new AbortController();
1349
1349
  let request = createClientSideRequest(
1350
1350
  init.history,
@@ -2459,6 +2459,7 @@ function createRouter(init) {
2459
2459
  let localManifest = manifest;
2460
2460
  try {
2461
2461
  await patchRoutesOnNavigationImpl({
2462
+ signal,
2462
2463
  path: pathname,
2463
2464
  matches: partialMatches,
2464
2465
  patch: (routeId, children) => {
@@ -4216,7 +4217,7 @@ function useRoutesImpl(routes, locationArg, dataRouterState, future) {
4216
4217
  // router loaded. We can help them understand how to avoid that.
4217
4218
  `useRoutes() may be used only in the context of a <Router> component.`
4218
4219
  );
4219
- let { navigator: navigator2 } = React2.useContext(NavigationContext);
4220
+ let { navigator: navigator2, static: isStatic } = React2.useContext(NavigationContext);
4220
4221
  let { matches: parentMatches } = React2.useContext(RouteContext);
4221
4222
  let routeMatch = parentMatches[parentMatches.length - 1];
4222
4223
  let parentParams = routeMatch ? routeMatch.params : {};
@@ -4252,7 +4253,7 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
4252
4253
  let segments = pathname.replace(/^\//, "").split("/");
4253
4254
  remainingPathname = "/" + segments.slice(parentSegments.length).join("/");
4254
4255
  }
4255
- let matches = dataRouterState && dataRouterState.matches && dataRouterState.matches.length > 0 ? dataRouterState.matches : matchRoutes(routes, { pathname: remainingPathname });
4256
+ let matches = !isStatic && dataRouterState && dataRouterState.matches && dataRouterState.matches.length > 0 ? dataRouterState.matches : matchRoutes(routes, { pathname: remainingPathname });
4256
4257
  if (ENABLE_DEV_WARNINGS) {
4257
4258
  warning(
4258
4259
  parentRoute || matches != null,
@@ -5362,11 +5363,20 @@ function getKeyedLinksForMatches(matches, routeModules, manifest) {
5362
5363
  let preloads = getModuleLinkHrefs(matches, manifest);
5363
5364
  return dedupeLinkDescriptors(descriptors, preloads);
5364
5365
  }
5366
+ function getRouteCssDescriptors(route) {
5367
+ if (!route.css) return [];
5368
+ return route.css.map((href) => ({ rel: "stylesheet", href }));
5369
+ }
5370
+ async function prefetchRouteCss(route) {
5371
+ if (!route.css) return;
5372
+ let descriptors = getRouteCssDescriptors(route);
5373
+ await Promise.all(descriptors.map(prefetchStyleLink));
5374
+ }
5365
5375
  async function prefetchStyleLinks(route, routeModule) {
5366
5376
  if (!route.css && !routeModule.links || !isPreloadSupported()) return;
5367
5377
  let descriptors = [];
5368
5378
  if (route.css) {
5369
- descriptors.push(...route.css.map((href) => ({ rel: "stylesheet", href })));
5379
+ descriptors.push(...getRouteCssDescriptors(route));
5370
5380
  }
5371
5381
  if (routeModule.links) {
5372
5382
  descriptors.push(...routeModule.links());
@@ -5382,13 +5392,15 @@ async function prefetchStyleLinks(route, routeModule) {
5382
5392
  });
5383
5393
  }
5384
5394
  }
5385
- let matchingLinks = styleLinks.filter(
5386
- (link) => (!link.media || window.matchMedia(link.media).matches) && !document.querySelector(`link[rel="stylesheet"][href="${link.href}"]`)
5387
- );
5388
- await Promise.all(matchingLinks.map(prefetchStyleLink));
5395
+ await Promise.all(styleLinks.map(prefetchStyleLink));
5389
5396
  }
5390
5397
  async function prefetchStyleLink(descriptor) {
5391
5398
  return new Promise((resolve) => {
5399
+ if (descriptor.media && !window.matchMedia(descriptor.media).matches || document.querySelector(
5400
+ `link[rel="stylesheet"][href="${descriptor.href}"]`
5401
+ )) {
5402
+ return resolve();
5403
+ }
5392
5404
  let link = document.createElement("link");
5393
5405
  Object.assign(link, descriptor);
5394
5406
  function removeLink() {
@@ -6345,7 +6357,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
6345
6357
  prefetchRouteModuleChunks(route);
6346
6358
  let mod = await modPromise;
6347
6359
  let lazyRoute = { ...mod };
6348
- if (mod.clientLoader && !route.clientLoaderModule) {
6360
+ if (mod.clientLoader) {
6349
6361
  let clientLoader = mod.clientLoader;
6350
6362
  lazyRoute.loader = (args, singleFetch) => clientLoader({
6351
6363
  ...args,
@@ -6355,7 +6367,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
6355
6367
  }
6356
6368
  });
6357
6369
  }
6358
- if (mod.clientAction && !route.clientActionModule) {
6370
+ if (mod.clientAction) {
6359
6371
  let clientAction = mod.clientAction;
6360
6372
  lazyRoute.action = (args, singleFetch) => clientAction({
6361
6373
  ...args,
@@ -6420,8 +6432,13 @@ function wrapShouldRevalidateForHdr(routeId, routeShouldRevalidate, needsRevalid
6420
6432
  };
6421
6433
  }
6422
6434
  async function loadRouteModuleWithBlockingLinks(route, routeModules) {
6423
- let routeModule = await loadRouteModule(route, routeModules);
6424
- await prefetchStyleLinks(route, routeModule);
6435
+ let routeModulePromise = loadRouteModule(route, routeModules);
6436
+ let prefetchRouteCssPromise = prefetchRouteCss(route);
6437
+ let routeModule = await routeModulePromise;
6438
+ await Promise.all([
6439
+ prefetchRouteCssPromise,
6440
+ prefetchStyleLinks(route, routeModule)
6441
+ ]);
6425
6442
  return {
6426
6443
  Component: getRouteModuleComponent(routeModule),
6427
6444
  ErrorBoundary: routeModule.ErrorBoundary,
@@ -6449,8 +6466,8 @@ var nextPaths = /* @__PURE__ */ new Set();
6449
6466
  var discoveredPathsMaxSize = 1e3;
6450
6467
  var discoveredPaths = /* @__PURE__ */ new Set();
6451
6468
  var URL_LIMIT = 7680;
6452
- function isFogOfWarEnabled(isSpaMode) {
6453
- return !isSpaMode;
6469
+ function isFogOfWarEnabled(ssr) {
6470
+ return ssr === true;
6454
6471
  }
6455
6472
  function getPartialManifest(manifest, router) {
6456
6473
  let routeIds = new Set(router.state.matches.map((m) => m.route.id));
@@ -6476,11 +6493,11 @@ function getPartialManifest(manifest, router) {
6476
6493
  routes: initialRoutes
6477
6494
  };
6478
6495
  }
6479
- function getPatchRoutesOnNavigationFunction(manifest, routeModules, isSpaMode, basename) {
6480
- if (!isFogOfWarEnabled(isSpaMode)) {
6496
+ function getPatchRoutesOnNavigationFunction(manifest, routeModules, ssr, isSpaMode, basename) {
6497
+ if (!isFogOfWarEnabled(ssr)) {
6481
6498
  return void 0;
6482
6499
  }
6483
- return async ({ path, patch }) => {
6500
+ return async ({ path, patch, signal }) => {
6484
6501
  if (discoveredPaths.has(path)) {
6485
6502
  return;
6486
6503
  }
@@ -6490,13 +6507,14 @@ function getPatchRoutesOnNavigationFunction(manifest, routeModules, isSpaMode, b
6490
6507
  routeModules,
6491
6508
  isSpaMode,
6492
6509
  basename,
6493
- patch
6510
+ patch,
6511
+ signal
6494
6512
  );
6495
6513
  };
6496
6514
  }
6497
- function useFogOFWarDiscovery(router, manifest, routeModules, isSpaMode) {
6515
+ function useFogOFWarDiscovery(router, manifest, routeModules, ssr, isSpaMode) {
6498
6516
  React8.useEffect(() => {
6499
- if (!isFogOfWarEnabled(isSpaMode) || navigator.connection?.saveData === true) {
6517
+ if (!isFogOfWarEnabled(ssr) || navigator.connection?.saveData === true) {
6500
6518
  return;
6501
6519
  }
6502
6520
  function registerElement(el) {
@@ -6544,9 +6562,9 @@ function useFogOFWarDiscovery(router, manifest, routeModules, isSpaMode) {
6544
6562
  attributeFilter: ["data-discover", "href", "action"]
6545
6563
  });
6546
6564
  return () => observer.disconnect();
6547
- }, [isSpaMode, manifest, routeModules, router]);
6565
+ }, [ssr, isSpaMode, manifest, routeModules, router]);
6548
6566
  }
6549
- async function fetchAndApplyManifestPatches(paths, manifest, routeModules, isSpaMode, basename, patchRoutes) {
6567
+ async function fetchAndApplyManifestPatches(paths, manifest, routeModules, isSpaMode, basename, patchRoutes, signal) {
6550
6568
  let manifestPath = `${basename != null ? basename : "/"}/__manifest`.replace(
6551
6569
  /\/+/g,
6552
6570
  "/"
@@ -6558,13 +6576,19 @@ async function fetchAndApplyManifestPatches(paths, manifest, routeModules, isSpa
6558
6576
  nextPaths.clear();
6559
6577
  return;
6560
6578
  }
6561
- let res = await fetch(url);
6562
- if (!res.ok) {
6563
- throw new Error(`${res.status} ${res.statusText}`);
6564
- } else if (res.status >= 400) {
6565
- throw new Error(await res.text());
6579
+ let serverPatches;
6580
+ try {
6581
+ let res = await fetch(url, { signal });
6582
+ if (!res.ok) {
6583
+ throw new Error(`${res.status} ${res.statusText}`);
6584
+ } else if (res.status >= 400) {
6585
+ throw new Error(await res.text());
6586
+ }
6587
+ serverPatches = await res.json();
6588
+ } catch (e) {
6589
+ if (signal?.aborted) return;
6590
+ throw e;
6566
6591
  }
6567
- let serverPatches = await res.json();
6568
6592
  let knownRoutes = new Set(Object.keys(manifest.routes));
6569
6593
  let patches = Object.values(serverPatches).reduce((acc, route) => {
6570
6594
  if (route && !knownRoutes.has(route.id)) {
@@ -6932,10 +6956,10 @@ function isValidMetaTag(tagName) {
6932
6956
  }
6933
6957
  var isHydrated = false;
6934
6958
  function Scripts(props) {
6935
- let { manifest, serverHandoffString, isSpaMode, renderMeta } = useFrameworkContext();
6959
+ let { manifest, serverHandoffString, isSpaMode, ssr, renderMeta } = useFrameworkContext();
6936
6960
  let { router, static: isStatic, staticContext } = useDataRouterContext2();
6937
6961
  let { matches: routerMatches } = useDataRouterStateContext();
6938
- let enableFogOfWar = isFogOfWarEnabled(isSpaMode);
6962
+ let enableFogOfWar = isFogOfWarEnabled(ssr);
6939
6963
  if (renderMeta) {
6940
6964
  renderMeta.didRenderScripts = true;
6941
6965
  }
@@ -7063,7 +7087,7 @@ function mergeRefs(...refs) {
7063
7087
  var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
7064
7088
  try {
7065
7089
  if (isBrowser) {
7066
- window.__reactRouterVersion = "0.0.0-experimental-df0f1dfda";
7090
+ window.__reactRouterVersion = "0.0.0-experimental-fde52e515";
7067
7091
  }
7068
7092
  } catch (e) {
7069
7093
  }
@@ -8175,6 +8199,7 @@ function ServerRouter({
8175
8199
  criticalCss,
8176
8200
  serverHandoffString,
8177
8201
  future: context.future,
8202
+ ssr: context.ssr,
8178
8203
  isSpaMode: context.isSpaMode,
8179
8204
  serializeError: context.serializeError,
8180
8205
  renderMeta: context.renderMeta
@@ -8221,6 +8246,7 @@ function createRoutesStub(routes, context = {}) {
8221
8246
  version: ""
8222
8247
  },
8223
8248
  routeModules: {},
8249
+ ssr: false,
8224
8250
  isSpaMode: false
8225
8251
  };
8226
8252
  let patched = processRoutes(
@@ -9066,6 +9092,7 @@ var createRequestHandler = (build, mode) => {
9066
9092
  errorHandler = derived.errorHandler;
9067
9093
  }
9068
9094
  let url = new URL(request.url);
9095
+ let normalizedPath = url.pathname.replace(/\.data$/, "").replace(/^\/_root$/, "/").replace(/\/$/, "");
9069
9096
  let params = {};
9070
9097
  let handleError = (error) => {
9071
9098
  if (mode === "development" /* Development */) {
@@ -9077,6 +9104,13 @@ var createRequestHandler = (build, mode) => {
9077
9104
  request
9078
9105
  });
9079
9106
  };
9107
+ if (!_build.ssr && _build.prerender.length > 0 && // Look with/without the trailing slash to be sure
9108
+ !_build.prerender.includes(normalizedPath) && !_build.prerender.includes(normalizedPath + "/")) {
9109
+ return new Response("Not Found", {
9110
+ status: 404,
9111
+ statusText: "Not Found"
9112
+ });
9113
+ }
9080
9114
  let manifestUrl = `${_build.basename ?? "/"}/__manifest`.replace(
9081
9115
  /\/+/g,
9082
9116
  "/"
@@ -9097,7 +9131,7 @@ var createRequestHandler = (build, mode) => {
9097
9131
  let response;
9098
9132
  if (url.pathname.endsWith(".data")) {
9099
9133
  let handlerUrl = new URL(request.url);
9100
- handlerUrl.pathname = handlerUrl.pathname.replace(/\.data$/, "").replace(/^\/_root$/, "/");
9134
+ handlerUrl.pathname = normalizedPath;
9101
9135
  let singleFetchMatches = matchServerRoutes(
9102
9136
  routes,
9103
9137
  handlerUrl.pathname,
@@ -9237,6 +9271,7 @@ async function handleSingleFetchRequest(serverMode, build, staticHandler, reques
9237
9271
  );
9238
9272
  }
9239
9273
  async function handleDocumentRequest(serverMode, build, staticHandler, request, loadContext, handleError, criticalCss) {
9274
+ let isSpaMode = request.headers.has("X-React-Router-SPA-Mode");
9240
9275
  let context;
9241
9276
  try {
9242
9277
  context = await staticHandler.query(request, {
@@ -9275,7 +9310,8 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
9275
9310
  basename: build.basename,
9276
9311
  criticalCss,
9277
9312
  future: build.future,
9278
- isSpaMode: build.isSpaMode
9313
+ ssr: build.ssr,
9314
+ isSpaMode
9279
9315
  }),
9280
9316
  serverHandoffStream: encodeViaTurboStream(
9281
9317
  state,
@@ -9285,7 +9321,8 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
9285
9321
  ),
9286
9322
  renderMeta: {},
9287
9323
  future: build.future,
9288
- isSpaMode: build.isSpaMode,
9324
+ ssr: build.ssr,
9325
+ isSpaMode,
9289
9326
  serializeError: (err) => serializeError(err, serverMode)
9290
9327
  };
9291
9328
  let handleDocumentRequestFunction = build.entry.module.default;
@@ -9330,7 +9367,8 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
9330
9367
  serverHandoffString: createServerHandoffString({
9331
9368
  basename: build.basename,
9332
9369
  future: build.future,
9333
- isSpaMode: build.isSpaMode
9370
+ ssr: build.ssr,
9371
+ isSpaMode
9334
9372
  }),
9335
9373
  serverHandoffStream: encodeViaTurboStream(
9336
9374
  state2,
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
- import { R as RouterProviderProps$1 } from './fog-of-war-D3ny56dR.mjs';
3
- import './route-data-Cq_b5feC.mjs';
2
+ import { R as RouterProviderProps$1 } from './fog-of-war-D8U3moAU.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-L5G-Cw9x.js';
3
- import './route-data-Cq_b5feC.js';
2
+ import { R as RouterProviderProps$1 } from './fog-of-war-DjxZtxiP.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 v0.0.0-experimental-df0f1dfda
2
+ * react-router v0.0.0-experimental-fde52e515
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1177,6 +1177,10 @@ function createRouter(init) {
1177
1177
  state.matches
1178
1178
  ) : matchRoutes(routesToUse, location, basename);
1179
1179
  let flushSync2 = (opts && opts.flushSync) === true;
1180
+ if (matches && state.initialized && !isRevalidationRequired && isHashChangeOnly(state.location, location) && !(opts && opts.submission && isMutationMethod(opts.submission.formMethod))) {
1181
+ completeNavigation(location, { matches }, { flushSync: flushSync2 });
1182
+ return;
1183
+ }
1180
1184
  let fogOfWar = checkFogOfWar(matches, routesToUse, location.pathname);
1181
1185
  if (fogOfWar.active && fogOfWar.matches) {
1182
1186
  matches = fogOfWar.matches;
@@ -1198,10 +1202,6 @@ function createRouter(init) {
1198
1202
  );
1199
1203
  return;
1200
1204
  }
1201
- if (state.initialized && !isRevalidationRequired && isHashChangeOnly(state.location, location) && !(opts && opts.submission && isMutationMethod(opts.submission.formMethod))) {
1202
- completeNavigation(location, { matches }, { flushSync: flushSync2 });
1203
- return;
1204
- }
1205
1205
  pendingNavigationController = new AbortController();
1206
1206
  let request = createClientSideRequest(
1207
1207
  init.history,
@@ -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) => {
@@ -3560,7 +3561,7 @@ function useRoutesImpl(routes, locationArg, dataRouterState, future) {
3560
3561
  // router loaded. We can help them understand how to avoid that.
3561
3562
  `useRoutes() may be used only in the context of a <Router> component.`
3562
3563
  );
3563
- let { navigator: navigator2 } = React2.useContext(NavigationContext);
3564
+ let { navigator: navigator2, static: isStatic } = React2.useContext(NavigationContext);
3564
3565
  let { matches: parentMatches } = React2.useContext(RouteContext);
3565
3566
  let routeMatch = parentMatches[parentMatches.length - 1];
3566
3567
  let parentParams = routeMatch ? routeMatch.params : {};
@@ -3596,7 +3597,7 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
3596
3597
  let segments = pathname.replace(/^\//, "").split("/");
3597
3598
  remainingPathname = "/" + segments.slice(parentSegments.length).join("/");
3598
3599
  }
3599
- let matches = dataRouterState && dataRouterState.matches && dataRouterState.matches.length > 0 ? dataRouterState.matches : matchRoutes(routes, { pathname: remainingPathname });
3600
+ let matches = !isStatic && dataRouterState && dataRouterState.matches && dataRouterState.matches.length > 0 ? dataRouterState.matches : matchRoutes(routes, { pathname: remainingPathname });
3600
3601
  if (ENABLE_DEV_WARNINGS) {
3601
3602
  warning(
3602
3603
  parentRoute || matches != null,
@@ -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() {
@@ -4994,7 +5006,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
4994
5006
  prefetchRouteModuleChunks(route);
4995
5007
  let mod = await modPromise;
4996
5008
  let lazyRoute = { ...mod };
4997
- if (mod.clientLoader && !route.clientLoaderModule) {
5009
+ if (mod.clientLoader) {
4998
5010
  let clientLoader = mod.clientLoader;
4999
5011
  lazyRoute.loader = (args, singleFetch) => clientLoader({
5000
5012
  ...args,
@@ -5004,7 +5016,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
5004
5016
  }
5005
5017
  });
5006
5018
  }
5007
- if (mod.clientAction && !route.clientActionModule) {
5019
+ if (mod.clientAction) {
5008
5020
  let clientAction = mod.clientAction;
5009
5021
  lazyRoute.action = (args, singleFetch) => clientAction({
5010
5022
  ...args,
@@ -5069,8 +5081,13 @@ function wrapShouldRevalidateForHdr(routeId, routeShouldRevalidate, needsRevalid
5069
5081
  };
5070
5082
  }
5071
5083
  async function loadRouteModuleWithBlockingLinks(route, routeModules) {
5072
- let routeModule = await loadRouteModule(route, routeModules);
5073
- await prefetchStyleLinks(route, routeModule);
5084
+ let routeModulePromise = loadRouteModule(route, routeModules);
5085
+ let prefetchRouteCssPromise = prefetchRouteCss(route);
5086
+ let routeModule = await routeModulePromise;
5087
+ await Promise.all([
5088
+ prefetchRouteCssPromise,
5089
+ prefetchStyleLinks(route, routeModule)
5090
+ ]);
5074
5091
  return {
5075
5092
  Component: getRouteModuleComponent(routeModule),
5076
5093
  ErrorBoundary: routeModule.ErrorBoundary,
@@ -5098,8 +5115,8 @@ var nextPaths = /* @__PURE__ */ new Set();
5098
5115
  var discoveredPathsMaxSize = 1e3;
5099
5116
  var discoveredPaths = /* @__PURE__ */ new Set();
5100
5117
  var URL_LIMIT = 7680;
5101
- function isFogOfWarEnabled(isSpaMode) {
5102
- return !isSpaMode;
5118
+ function isFogOfWarEnabled(ssr) {
5119
+ return ssr === true;
5103
5120
  }
5104
5121
  function getPartialManifest(manifest, router2) {
5105
5122
  let routeIds = new Set(router2.state.matches.map((m) => m.route.id));
@@ -5125,11 +5142,11 @@ function getPartialManifest(manifest, router2) {
5125
5142
  routes: initialRoutes
5126
5143
  };
5127
5144
  }
5128
- function getPatchRoutesOnNavigationFunction(manifest, routeModules, isSpaMode, basename) {
5129
- if (!isFogOfWarEnabled(isSpaMode)) {
5145
+ function getPatchRoutesOnNavigationFunction(manifest, routeModules, ssr, isSpaMode, basename) {
5146
+ if (!isFogOfWarEnabled(ssr)) {
5130
5147
  return void 0;
5131
5148
  }
5132
- return async ({ path, patch }) => {
5149
+ return async ({ path, patch, signal }) => {
5133
5150
  if (discoveredPaths.has(path)) {
5134
5151
  return;
5135
5152
  }
@@ -5139,13 +5156,14 @@ function getPatchRoutesOnNavigationFunction(manifest, routeModules, isSpaMode, b
5139
5156
  routeModules,
5140
5157
  isSpaMode,
5141
5158
  basename,
5142
- patch
5159
+ patch,
5160
+ signal
5143
5161
  );
5144
5162
  };
5145
5163
  }
5146
- function useFogOFWarDiscovery(router2, manifest, routeModules, isSpaMode) {
5164
+ function useFogOFWarDiscovery(router2, manifest, routeModules, ssr, isSpaMode) {
5147
5165
  React8.useEffect(() => {
5148
- if (!isFogOfWarEnabled(isSpaMode) || navigator.connection?.saveData === true) {
5166
+ if (!isFogOfWarEnabled(ssr) || navigator.connection?.saveData === true) {
5149
5167
  return;
5150
5168
  }
5151
5169
  function registerElement(el) {
@@ -5193,9 +5211,9 @@ function useFogOFWarDiscovery(router2, manifest, routeModules, isSpaMode) {
5193
5211
  attributeFilter: ["data-discover", "href", "action"]
5194
5212
  });
5195
5213
  return () => observer.disconnect();
5196
- }, [isSpaMode, manifest, routeModules, router2]);
5214
+ }, [ssr, isSpaMode, manifest, routeModules, router2]);
5197
5215
  }
5198
- async function fetchAndApplyManifestPatches(paths, manifest, routeModules, isSpaMode, basename, patchRoutes) {
5216
+ async function fetchAndApplyManifestPatches(paths, manifest, routeModules, isSpaMode, basename, patchRoutes, signal) {
5199
5217
  let manifestPath = `${basename != null ? basename : "/"}/__manifest`.replace(
5200
5218
  /\/+/g,
5201
5219
  "/"
@@ -5207,13 +5225,19 @@ async function fetchAndApplyManifestPatches(paths, manifest, routeModules, isSpa
5207
5225
  nextPaths.clear();
5208
5226
  return;
5209
5227
  }
5210
- let res = await fetch(url);
5211
- if (!res.ok) {
5212
- throw new Error(`${res.status} ${res.statusText}`);
5213
- } else if (res.status >= 400) {
5214
- throw new Error(await res.text());
5228
+ let serverPatches;
5229
+ try {
5230
+ let res = await fetch(url, { signal });
5231
+ if (!res.ok) {
5232
+ throw new Error(`${res.status} ${res.statusText}`);
5233
+ } else if (res.status >= 400) {
5234
+ throw new Error(await res.text());
5235
+ }
5236
+ serverPatches = await res.json();
5237
+ } catch (e) {
5238
+ if (signal?.aborted) return;
5239
+ throw e;
5215
5240
  }
5216
- let serverPatches = await res.json();
5217
5241
  let knownRoutes = new Set(Object.keys(manifest.routes));
5218
5242
  let patches = Object.values(serverPatches).reduce((acc, route) => {
5219
5243
  if (route && !knownRoutes.has(route.id)) {
@@ -5290,10 +5314,10 @@ function getActiveMatches(matches, errors, isSpaMode) {
5290
5314
  }
5291
5315
  var isHydrated = false;
5292
5316
  function Scripts(props) {
5293
- let { manifest, serverHandoffString, isSpaMode, renderMeta } = useFrameworkContext();
5317
+ let { manifest, serverHandoffString, isSpaMode, ssr, renderMeta } = useFrameworkContext();
5294
5318
  let { router: router2, static: isStatic, staticContext } = useDataRouterContext();
5295
5319
  let { matches: routerMatches } = useDataRouterStateContext();
5296
- let enableFogOfWar = isFogOfWarEnabled(isSpaMode);
5320
+ let enableFogOfWar = isFogOfWarEnabled(ssr);
5297
5321
  if (renderMeta) {
5298
5322
  renderMeta.didRenderScripts = true;
5299
5323
  }
@@ -5496,10 +5520,13 @@ function createHydratedRouter() {
5496
5520
  ssrInfo.context.isSpaMode
5497
5521
  );
5498
5522
  let hydrationData = void 0;
5499
- if (!ssrInfo.context.isSpaMode) {
5523
+ let loaderData = ssrInfo.context.state.loaderData;
5524
+ if (ssrInfo.context.isSpaMode) {
5525
+ hydrationData = { loaderData };
5526
+ } else {
5500
5527
  hydrationData = {
5501
5528
  ...ssrInfo.context.state,
5502
- loaderData: { ...ssrInfo.context.state.loaderData }
5529
+ loaderData: { ...loaderData }
5503
5530
  };
5504
5531
  let initialMatches = matchRoutes(
5505
5532
  routes,
@@ -5540,6 +5567,7 @@ function createHydratedRouter() {
5540
5567
  patchRoutesOnNavigation: getPatchRoutesOnNavigationFunction(
5541
5568
  ssrInfo.manifest,
5542
5569
  ssrInfo.routeModules,
5570
+ ssrInfo.context.ssr,
5543
5571
  ssrInfo.context.isSpaMode,
5544
5572
  ssrInfo.context.basename
5545
5573
  )
@@ -5587,6 +5615,7 @@ function HydratedRouter() {
5587
5615
  router,
5588
5616
  ssrInfo.manifest,
5589
5617
  ssrInfo.routeModules,
5618
+ ssrInfo.context.ssr,
5590
5619
  ssrInfo.context.isSpaMode
5591
5620
  );
5592
5621
  return (
@@ -5600,6 +5629,7 @@ function HydratedRouter() {
5600
5629
  routeModules: ssrInfo.routeModules,
5601
5630
  future: ssrInfo.context.future,
5602
5631
  criticalCss,
5632
+ ssr: ssrInfo.context.ssr,
5603
5633
  isSpaMode: ssrInfo.context.isSpaMode
5604
5634
  }
5605
5635
  },
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v0.0.0-experimental-df0f1dfda
2
+ * react-router v0.0.0-experimental-fde52e515
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-O5WSUTKP.mjs";
28
+ } from "./chunk-AEO7EMQS.mjs";
29
29
 
30
30
  // lib/dom-export/dom-router-provider.tsx
31
31
  import * as React from "react";
@@ -82,10 +82,13 @@ function createHydratedRouter() {
82
82
  ssrInfo.context.isSpaMode
83
83
  );
84
84
  let hydrationData = void 0;
85
- if (!ssrInfo.context.isSpaMode) {
85
+ let loaderData = ssrInfo.context.state.loaderData;
86
+ if (ssrInfo.context.isSpaMode) {
87
+ hydrationData = { loaderData };
88
+ } else {
86
89
  hydrationData = {
87
90
  ...ssrInfo.context.state,
88
- loaderData: { ...ssrInfo.context.state.loaderData }
91
+ loaderData: { ...loaderData }
89
92
  };
90
93
  let initialMatches = matchRoutes(
91
94
  routes,
@@ -126,6 +129,7 @@ function createHydratedRouter() {
126
129
  patchRoutesOnNavigation: getPatchRoutesOnNavigationFunction(
127
130
  ssrInfo.manifest,
128
131
  ssrInfo.routeModules,
132
+ ssrInfo.context.ssr,
129
133
  ssrInfo.context.isSpaMode,
130
134
  ssrInfo.context.basename
131
135
  )
@@ -173,6 +177,7 @@ function HydratedRouter() {
173
177
  router,
174
178
  ssrInfo.manifest,
175
179
  ssrInfo.routeModules,
180
+ ssrInfo.context.ssr,
176
181
  ssrInfo.context.isSpaMode
177
182
  );
178
183
  return (
@@ -186,6 +191,7 @@ function HydratedRouter() {
186
191
  routeModules: ssrInfo.routeModules,
187
192
  future: ssrInfo.context.future,
188
193
  criticalCss,
194
+ ssr: ssrInfo.context.ssr,
189
195
  isSpaMode: ssrInfo.context.isSpaMode
190
196
  }
191
197
  },