react-router 0.0.0-experimental-759a11a62 → 0.0.0-experimental-df0f1dfda

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 (48) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/development/{chunk-5WLC4F5Z.mjs → chunk-O5WSUTKP.mjs} +187 -107
  3. package/dist/development/data-CQbyyGzl.d.mts +11 -0
  4. package/dist/development/data-CQbyyGzl.d.ts +11 -0
  5. package/dist/development/dom-export.d.mts +3 -3
  6. package/dist/development/dom-export.d.ts +3 -3
  7. package/dist/development/dom-export.js +166 -56
  8. package/dist/development/dom-export.mjs +2 -2
  9. package/dist/development/{fog-of-war-DFo9BKir.d.ts → fog-of-war-D3ny56dR.d.mts} +78 -75
  10. package/dist/{production/fog-of-war-BCniP0AZ.d.mts → development/fog-of-war-L5G-Cw9x.d.ts} +78 -75
  11. package/dist/development/index.d.mts +10 -45
  12. package/dist/development/index.d.ts +10 -45
  13. package/dist/development/index.js +187 -108
  14. package/dist/development/index.mjs +2 -4
  15. package/dist/development/lib/types/route-module.d.mts +108 -1
  16. package/dist/development/lib/types/route-module.d.ts +108 -1
  17. package/dist/development/lib/types/route-module.js +1 -1
  18. package/dist/development/lib/types/route-module.mjs +1 -1
  19. package/dist/development/{router-BYH9f2xg.d.mts → route-data-Cq_b5feC.d.mts} +804 -1073
  20. package/dist/{production/router-BYH9f2xg.d.mts → development/route-data-Cq_b5feC.d.ts} +804 -1073
  21. package/dist/production/{chunk-QJ3CF3ZA.mjs → chunk-F7U65DMX.mjs} +187 -107
  22. package/dist/production/data-CQbyyGzl.d.mts +11 -0
  23. package/dist/production/data-CQbyyGzl.d.ts +11 -0
  24. package/dist/production/dom-export.d.mts +3 -3
  25. package/dist/production/dom-export.d.ts +3 -3
  26. package/dist/production/dom-export.js +166 -56
  27. package/dist/production/dom-export.mjs +2 -2
  28. package/dist/production/{fog-of-war-DFo9BKir.d.ts → fog-of-war-D3ny56dR.d.mts} +78 -75
  29. package/dist/{development/fog-of-war-BCniP0AZ.d.mts → production/fog-of-war-L5G-Cw9x.d.ts} +78 -75
  30. package/dist/production/index.d.mts +10 -45
  31. package/dist/production/index.d.ts +10 -45
  32. package/dist/production/index.js +187 -108
  33. package/dist/production/index.mjs +2 -4
  34. package/dist/production/lib/types/route-module.d.mts +108 -1
  35. package/dist/production/lib/types/route-module.d.ts +108 -1
  36. package/dist/production/lib/types/route-module.js +1 -1
  37. package/dist/production/lib/types/route-module.mjs +1 -1
  38. package/dist/production/{router-BYH9f2xg.d.ts → route-data-Cq_b5feC.d.mts} +804 -1073
  39. package/dist/{development/router-BYH9f2xg.d.ts → production/route-data-Cq_b5feC.d.ts} +804 -1073
  40. package/package.json +1 -9
  41. package/dist/development/lib/types/index.d.mts +0 -2
  42. package/dist/development/lib/types/index.d.ts +0 -2
  43. package/dist/development/lib/types/index.js +0 -28
  44. package/dist/development/lib/types/index.mjs +0 -10
  45. package/dist/production/lib/types/index.d.mts +0 -2
  46. package/dist/production/lib/types/index.d.ts +0 -2
  47. package/dist/production/lib/types/index.js +0 -28
  48. package/dist/production/lib/types/index.mjs +0 -10
package/CHANGELOG.md CHANGED
@@ -1,7 +1,28 @@
1
1
  # `react-router`
2
2
 
3
+ ## 7.1.3
4
+
5
+ _No changes_
6
+
7
+ ## 7.1.2
8
+
9
+ ### Patch Changes
10
+
11
+ - Fix issue with fetcher data cleanup in the data layer on fetcher unmount ([#12681](https://github.com/remix-run/react-router/pull/12681))
12
+ - Do not rely on `symbol` for filtering out `redirect` responses from loader data ([#12694](https://github.com/remix-run/react-router/pull/12694))
13
+
14
+ Previously, some projects were getting type checking errors like:
15
+
16
+ ```ts
17
+ error TS4058: Return type of exported function has or is using name 'redirectSymbol' from external module "node_modules/..." but cannot be named.
18
+ ```
19
+
20
+ Now that `symbol`s are not used for the `redirect` response type, these errors should no longer be present.
21
+
3
22
  ## 7.1.1
4
23
 
24
+ _No changes_
25
+
5
26
  ## 7.1.0
6
27
 
7
28
  ### Patch Changes
@@ -23,6 +44,8 @@
23
44
 
24
45
  ## 7.0.1
25
46
 
47
+ _No changes_
48
+
26
49
  ## 7.0.0
27
50
 
28
51
  ### Major Changes
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v0.0.0-experimental-759a11a62
2
+ * react-router v0.0.0-experimental-df0f1dfda
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -154,13 +154,13 @@ function createHashHistory(options = {}) {
154
154
  }
155
155
  function createHashHref(window2, to) {
156
156
  let base = window2.document.querySelector("base");
157
- let href2 = "";
157
+ let href = "";
158
158
  if (base && base.getAttribute("href")) {
159
159
  let url = window2.location.href;
160
160
  let hashIndex = url.indexOf("#");
161
- href2 = hashIndex === -1 ? url : url.slice(0, hashIndex);
161
+ href = hashIndex === -1 ? url : url.slice(0, hashIndex);
162
162
  }
163
- return href2 + "#" + (typeof to === "string" ? to : createPath(to));
163
+ return href + "#" + (typeof to === "string" ? to : createPath(to));
164
164
  }
165
165
  function validateHashLocation(location, to) {
166
166
  warning(
@@ -302,13 +302,13 @@ function getUrlBasedHistory(getLocation, createHref2, validateLocation, options
302
302
  }
303
303
  function createURL(to) {
304
304
  let base = window2.location.origin !== "null" ? window2.location.origin : window2.location.href;
305
- let href2 = typeof to === "string" ? to : createPath(to);
306
- href2 = href2.replace(/ $/, "%20");
305
+ let href = typeof to === "string" ? to : createPath(to);
306
+ href = href.replace(/ $/, "%20");
307
307
  invariant(
308
308
  base,
309
- `No window.location.(origin|href) available to create URL for href: ${href2}`
309
+ `No window.location.(origin|href) available to create URL for href: ${href}`
310
310
  );
311
- return new URL(href2, base);
311
+ return new URL(href, base);
312
312
  }
313
313
  let history = {
314
314
  get action() {
@@ -684,7 +684,7 @@ function decodePath(value) {
684
684
  } catch (error) {
685
685
  warning(
686
686
  false,
687
- `The URL path "${value}" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent encoding (${error}).`
687
+ `The URL path "${value}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${error}).`
688
688
  );
689
689
  return value;
690
690
  }
@@ -840,15 +840,6 @@ var ErrorResponseImpl = class {
840
840
  function isRouteErrorResponse(error) {
841
841
  return error != null && typeof error.status === "number" && typeof error.statusText === "string" && typeof error.internal === "boolean" && "data" in error;
842
842
  }
843
- function href(path, ...args) {
844
- let params = args[0];
845
- return path.split("/").map((segment) => {
846
- const match = segment.match(/^:([\w-]+)(\?)?/);
847
- if (!match) return segment;
848
- const param = match[1];
849
- return params[param];
850
- }).join("/");
851
- }
852
843
 
853
844
  // lib/router/router.ts
854
845
  var validMutationMethodsArr = [
@@ -928,6 +919,7 @@ function createRouter(init) {
928
919
  let getScrollPosition = null;
929
920
  let initialScrollRestored = init.hydrationData != null;
930
921
  let initialMatches = matchRoutes(dataRoutes, init.history.location, basename);
922
+ let initialMatchesIsFOW = false;
931
923
  let initialErrors = null;
932
924
  if (initialMatches == null && !patchRoutesOnNavigationImpl) {
933
925
  let error = getInternalRouterError(404, {
@@ -957,6 +949,7 @@ function createRouter(init) {
957
949
  init.history.location.pathname
958
950
  );
959
951
  if (fogOfWar.active && fogOfWar.matches) {
952
+ initialMatchesIsFOW = true;
960
953
  initialMatches = fogOfWar.matches;
961
954
  }
962
955
  } else if (initialMatches.some((m) => m.route.lazy)) {
@@ -1322,7 +1315,10 @@ function createRouter(init) {
1322
1315
  pendingViewTransitionEnabled = (opts && opts.enableViewTransition) === true;
1323
1316
  let routesToUse = inFlightDataRoutes || dataRoutes;
1324
1317
  let loadingNavigation = opts && opts.overrideNavigation;
1325
- let matches = matchRoutes(routesToUse, location, basename);
1318
+ let matches = opts?.initialHydration && state.matches && state.matches.length > 0 && !initialMatchesIsFOW ? (
1319
+ // `matchRoutes()` has already been called if we're in here via `router.initialize()`
1320
+ state.matches
1321
+ ) : matchRoutes(routesToUse, location, basename);
1326
1322
  let flushSync = (opts && opts.flushSync) === true;
1327
1323
  let fogOfWar = checkFogOfWar(matches, routesToUse, location.pathname);
1328
1324
  if (fogOfWar.active && fogOfWar.matches) {
@@ -1714,7 +1710,7 @@ function createRouter(init) {
1714
1710
  });
1715
1711
  return new Map(state.fetchers);
1716
1712
  }
1717
- async function fetch2(key, routeId, href2, opts) {
1713
+ async function fetch2(key, routeId, href, opts) {
1718
1714
  abortFetcher(key);
1719
1715
  let flushSync = (opts && opts.flushSync) === true;
1720
1716
  let routesToUse = inFlightDataRoutes || dataRoutes;
@@ -1722,7 +1718,7 @@ function createRouter(init) {
1722
1718
  state.location,
1723
1719
  state.matches,
1724
1720
  basename,
1725
- href2,
1721
+ href,
1726
1722
  routeId,
1727
1723
  opts?.relative
1728
1724
  );
@@ -3506,14 +3502,20 @@ async function convertDataStrategyResultToDataResult(dataStrategyResult) {
3506
3502
  return {
3507
3503
  type: "error" /* error */,
3508
3504
  error: result.data,
3509
- statusCode: result.init?.status
3505
+ statusCode: result.init?.status,
3506
+ headers: result.init?.headers ? new Headers(result.init.headers) : void 0
3510
3507
  };
3511
3508
  }
3512
- result = new ErrorResponseImpl(
3513
- result.init?.status || 500,
3514
- void 0,
3515
- result.data
3516
- );
3509
+ return {
3510
+ type: "error" /* error */,
3511
+ error: new ErrorResponseImpl(
3512
+ result.init?.status || 500,
3513
+ void 0,
3514
+ result.data
3515
+ ),
3516
+ statusCode: isRouteErrorResponse(result) ? result.status : void 0,
3517
+ headers: result.init?.headers ? new Headers(result.init.headers) : void 0
3518
+ };
3517
3519
  }
3518
3520
  return {
3519
3521
  type: "error" /* error */,
@@ -4250,7 +4252,7 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
4250
4252
  let segments = pathname.replace(/^\//, "").split("/");
4251
4253
  remainingPathname = "/" + segments.slice(parentSegments.length).join("/");
4252
4254
  }
4253
- let matches = matchRoutes(routes, { pathname: remainingPathname });
4255
+ let matches = dataRouterState && dataRouterState.matches && dataRouterState.matches.length > 0 ? dataRouterState.matches : matchRoutes(routes, { pathname: remainingPathname });
4254
4256
  if (ENABLE_DEV_WARNINGS) {
4255
4257
  warning(
4256
4258
  parentRoute || matches != null,
@@ -5353,18 +5355,18 @@ function getKeyedLinksForMatches(matches, routeModules, manifest) {
5353
5355
  let module = routeModules[match.route.id];
5354
5356
  let route = manifest.routes[match.route.id];
5355
5357
  return [
5356
- route && route.css ? route.css.map((href2) => ({ rel: "stylesheet", href: href2 })) : [],
5358
+ route && route.css ? route.css.map((href) => ({ rel: "stylesheet", href })) : [],
5357
5359
  module?.links?.() || []
5358
5360
  ];
5359
5361
  }).flat(2);
5360
- let preloads = getCurrentPageModulePreloadHrefs(matches, manifest);
5362
+ let preloads = getModuleLinkHrefs(matches, manifest);
5361
5363
  return dedupeLinkDescriptors(descriptors, preloads);
5362
5364
  }
5363
5365
  async function prefetchStyleLinks(route, routeModule) {
5364
5366
  if (!route.css && !routeModule.links || !isPreloadSupported()) return;
5365
5367
  let descriptors = [];
5366
5368
  if (route.css) {
5367
- descriptors.push(...route.css.map((href2) => ({ rel: "stylesheet", href: href2 })));
5369
+ descriptors.push(...route.css.map((href) => ({ rel: "stylesheet", href })));
5368
5370
  }
5369
5371
  if (routeModule.links) {
5370
5372
  descriptors.push(...routeModule.links());
@@ -5481,25 +5483,21 @@ function getNewMatchesForLinks(page, nextMatches, currentMatches, manifest, loca
5481
5483
  }
5482
5484
  return [];
5483
5485
  }
5484
- function getModuleLinkHrefs(matches, manifestPatch) {
5485
- return dedupeHrefs(
5486
- matches.map((match) => {
5487
- let route = manifestPatch.routes[match.route.id];
5488
- if (!route) return [];
5489
- let hrefs = [route.module];
5490
- if (route.imports) {
5491
- hrefs = hrefs.concat(route.imports);
5492
- }
5493
- return hrefs;
5494
- }).flat(1)
5495
- );
5496
- }
5497
- function getCurrentPageModulePreloadHrefs(matches, manifest) {
5486
+ function getModuleLinkHrefs(matches, manifest, { includeHydrateFallback } = {}) {
5498
5487
  return dedupeHrefs(
5499
5488
  matches.map((match) => {
5500
5489
  let route = manifest.routes[match.route.id];
5501
5490
  if (!route) return [];
5502
5491
  let hrefs = [route.module];
5492
+ if (route.clientActionModule) {
5493
+ hrefs = hrefs.concat(route.clientActionModule);
5494
+ }
5495
+ if (route.clientLoaderModule) {
5496
+ hrefs = hrefs.concat(route.clientLoaderModule);
5497
+ }
5498
+ if (includeHydrateFallback && route.hydrateFallbackModule) {
5499
+ hrefs = hrefs.concat(route.hydrateFallbackModule);
5500
+ }
5503
5501
  if (route.imports) {
5504
5502
  hrefs = hrefs.concat(route.imports);
5505
5503
  }
@@ -5830,6 +5828,14 @@ async function fetchAndDecode(url, init) {
5830
5828
  if (res.status === 404 && !res.headers.has("X-Remix-Response")) {
5831
5829
  throw new ErrorResponseImpl(404, "Not Found", true);
5832
5830
  }
5831
+ const NO_BODY_STATUS_CODES2 = /* @__PURE__ */ new Set([100, 101, 204, 205]);
5832
+ if (NO_BODY_STATUS_CODES2.has(res.status)) {
5833
+ if (!init.method || init.method === "GET") {
5834
+ return { status: res.status, data: {} };
5835
+ } else {
5836
+ return { status: res.status, data: { data: void 0 } };
5837
+ }
5838
+ }
5833
5839
  invariant2(res.body, "No response body to decode");
5834
5840
  try {
5835
5841
  let decoded = await decodeViaTurboStream(res.body, window);
@@ -6175,6 +6181,21 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
6175
6181
  }
6176
6182
  return fetchServerHandler(singleFetch);
6177
6183
  }
6184
+ function prefetchModule(modulePath) {
6185
+ import(
6186
+ /* @vite-ignore */
6187
+ /* webpackIgnore: true */
6188
+ modulePath
6189
+ );
6190
+ }
6191
+ function prefetchRouteModuleChunks(route2) {
6192
+ if (route2.clientActionModule) {
6193
+ prefetchModule(route2.clientActionModule);
6194
+ }
6195
+ if (route2.clientLoaderModule) {
6196
+ prefetchModule(route2.clientLoaderModule);
6197
+ }
6198
+ }
6178
6199
  async function prefetchStylesAndCallHandler(handler) {
6179
6200
  let cachedModule = routeModulesCache[route.id];
6180
6201
  let linkPrefetchPromise = cachedModule ? prefetchStyleLinks(route, cachedModule) : Promise.resolve();
@@ -6271,6 +6292,22 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
6271
6292
  if (isSpaMode) return Promise.resolve(null);
6272
6293
  return fetchServerLoader(singleFetch);
6273
6294
  });
6295
+ } else if (route.clientLoaderModule) {
6296
+ dataRoute.loader = async (args, singleFetch) => {
6297
+ invariant2(route.clientLoaderModule);
6298
+ let { clientLoader } = await import(
6299
+ /* @vite-ignore */
6300
+ /* webpackIgnore: true */
6301
+ route.clientLoaderModule
6302
+ );
6303
+ return clientLoader({
6304
+ ...args,
6305
+ async serverLoader() {
6306
+ preventInvalidServerHandlerCall("loader", route, isSpaMode);
6307
+ return fetchServerLoader(singleFetch);
6308
+ }
6309
+ });
6310
+ };
6274
6311
  }
6275
6312
  if (!route.hasClientAction) {
6276
6313
  dataRoute.action = ({ request }, singleFetch) => prefetchStylesAndCallHandler(() => {
@@ -6279,14 +6316,36 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
6279
6316
  }
6280
6317
  return fetchServerAction(singleFetch);
6281
6318
  });
6319
+ } else if (route.clientActionModule) {
6320
+ dataRoute.action = async (args, singleFetch) => {
6321
+ invariant2(route.clientActionModule);
6322
+ prefetchRouteModuleChunks(route);
6323
+ let { clientAction } = await import(
6324
+ /* @vite-ignore */
6325
+ /* webpackIgnore: true */
6326
+ route.clientActionModule
6327
+ );
6328
+ return clientAction({
6329
+ ...args,
6330
+ async serverAction() {
6331
+ preventInvalidServerHandlerCall("action", route, isSpaMode);
6332
+ return fetchServerAction(singleFetch);
6333
+ }
6334
+ });
6335
+ };
6282
6336
  }
6283
6337
  dataRoute.lazy = async () => {
6284
- let mod = await loadRouteModuleWithBlockingLinks(
6338
+ if (route.clientLoaderModule || route.clientActionModule) {
6339
+ await new Promise((resolve) => setTimeout(resolve, 0));
6340
+ }
6341
+ let modPromise = loadRouteModuleWithBlockingLinks(
6285
6342
  route,
6286
6343
  routeModulesCache
6287
6344
  );
6345
+ prefetchRouteModuleChunks(route);
6346
+ let mod = await modPromise;
6288
6347
  let lazyRoute = { ...mod };
6289
- if (mod.clientLoader) {
6348
+ if (mod.clientLoader && !route.clientLoaderModule) {
6290
6349
  let clientLoader = mod.clientLoader;
6291
6350
  lazyRoute.loader = (args, singleFetch) => clientLoader({
6292
6351
  ...args,
@@ -6296,7 +6355,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
6296
6355
  }
6297
6356
  });
6298
6357
  }
6299
- if (mod.clientAction) {
6358
+ if (mod.clientAction && !route.clientActionModule) {
6300
6359
  let clientAction = mod.clientAction;
6301
6360
  lazyRoute.action = (args, singleFetch) => clientAction({
6302
6361
  ...args,
@@ -6445,12 +6504,13 @@ function useFogOFWarDiscovery(router, manifest, routeModules, isSpaMode) {
6445
6504
  if (!path) {
6446
6505
  return;
6447
6506
  }
6448
- let url = new URL(path, window.location.origin);
6449
- if (!discoveredPaths.has(url.pathname)) {
6450
- nextPaths.add(url.pathname);
6507
+ let pathname = el.tagName === "A" ? el.pathname : new URL(path, window.location.origin).pathname;
6508
+ if (!discoveredPaths.has(pathname)) {
6509
+ nextPaths.add(pathname);
6451
6510
  }
6452
6511
  }
6453
6512
  async function fetchPatches() {
6513
+ document.querySelectorAll("a[data-discover], form[data-discover]").forEach(registerElement);
6454
6514
  let lazyPaths = Array.from(nextPaths.keys()).filter((path) => {
6455
6515
  if (discoveredPaths.has(path)) {
6456
6516
  nextPaths.delete(path);
@@ -6474,30 +6534,9 @@ function useFogOFWarDiscovery(router, manifest, routeModules, isSpaMode) {
6474
6534
  console.error("Failed to fetch manifest patches", e);
6475
6535
  }
6476
6536
  }
6477
- document.body.querySelectorAll("a[data-discover], form[data-discover]").forEach((el) => registerElement(el));
6478
- fetchPatches();
6479
6537
  let debouncedFetchPatches = debounce(fetchPatches, 100);
6480
- function isElement(node) {
6481
- return node.nodeType === Node.ELEMENT_NODE;
6482
- }
6483
- let observer = new MutationObserver((records) => {
6484
- let elements = /* @__PURE__ */ new Set();
6485
- records.forEach((r) => {
6486
- [r.target, ...r.addedNodes].forEach((node) => {
6487
- if (!isElement(node)) return;
6488
- if (node.tagName === "A" && node.getAttribute("data-discover")) {
6489
- elements.add(node);
6490
- } else if (node.tagName === "FORM" && node.getAttribute("data-discover")) {
6491
- elements.add(node);
6492
- }
6493
- if (node.tagName !== "A") {
6494
- node.querySelectorAll("a[data-discover], form[data-discover]").forEach((el) => elements.add(el));
6495
- }
6496
- });
6497
- });
6498
- elements.forEach((el) => registerElement(el));
6499
- debouncedFetchPatches();
6500
- });
6538
+ fetchPatches();
6539
+ let observer = new MutationObserver(() => debouncedFetchPatches());
6501
6540
  observer.observe(document.documentElement, {
6502
6541
  subtree: true,
6503
6542
  childList: true,
@@ -6784,7 +6823,7 @@ function PrefetchPageLinksImpl({
6784
6823
  [newMatchesForAssets, manifest]
6785
6824
  );
6786
6825
  let keyedPrefetchLinks = useKeyedPrefetchLinks(newMatchesForAssets);
6787
- return /* @__PURE__ */ React9.createElement(React9.Fragment, null, dataHrefs.map((href2) => /* @__PURE__ */ React9.createElement("link", { key: href2, rel: "prefetch", as: "fetch", href: href2, ...linkProps })), moduleHrefs.map((href2) => /* @__PURE__ */ React9.createElement("link", { key: href2, rel: "modulepreload", href: href2, ...linkProps })), keyedPrefetchLinks.map(({ key, link }) => (
6826
+ return /* @__PURE__ */ React9.createElement(React9.Fragment, null, dataHrefs.map((href) => /* @__PURE__ */ React9.createElement("link", { key: href, rel: "prefetch", as: "fetch", href, ...linkProps })), moduleHrefs.map((href) => /* @__PURE__ */ React9.createElement("link", { key: href, rel: "modulepreload", href, ...linkProps })), keyedPrefetchLinks.map(({ key, link }) => (
6788
6827
  // these don't spread `linkProps` because they are full link descriptors
6789
6828
  // already with their own props
6790
6829
  /* @__PURE__ */ React9.createElement("link", { key, ...link })
@@ -6908,11 +6947,44 @@ function Scripts(props) {
6908
6947
  let streamScript = "window.__reactRouterContext.stream = new ReadableStream({start(controller){window.__reactRouterContext.streamController = controller;}}).pipeThrough(new TextEncoderStream());";
6909
6948
  let contextScript = staticContext ? `window.__reactRouterContext = ${serverHandoffString};${streamScript}` : " ";
6910
6949
  let routeModulesScript = !isStatic ? " " : `${manifest.hmr?.runtime ? `import ${JSON.stringify(manifest.hmr.runtime)};` : ""}${!enableFogOfWar ? `import ${JSON.stringify(manifest.url)}` : ""};
6911
- ${matches.map(
6912
- (match, index) => `import * as route${index} from ${JSON.stringify(
6913
- manifest.routes[match.route.id].module
6914
- )};`
6915
- ).join("\n")}
6950
+ ${matches.map((match, routeIndex) => {
6951
+ let routeVarName = `route${routeIndex}`;
6952
+ let manifestEntry = manifest.routes[match.route.id];
6953
+ invariant2(manifestEntry, `Route ${match.route.id} not found in manifest`);
6954
+ let {
6955
+ clientActionModule,
6956
+ clientLoaderModule,
6957
+ hydrateFallbackModule,
6958
+ module
6959
+ } = manifestEntry;
6960
+ let chunks = [
6961
+ ...clientActionModule ? [
6962
+ {
6963
+ module: clientActionModule,
6964
+ varName: `${routeVarName}_clientAction`
6965
+ }
6966
+ ] : [],
6967
+ ...clientLoaderModule ? [
6968
+ {
6969
+ module: clientLoaderModule,
6970
+ varName: `${routeVarName}_clientLoader`
6971
+ }
6972
+ ] : [],
6973
+ ...hydrateFallbackModule ? [
6974
+ {
6975
+ module: hydrateFallbackModule,
6976
+ varName: `${routeVarName}_HydrateFallback`
6977
+ }
6978
+ ] : [],
6979
+ { module, varName: `${routeVarName}_main` }
6980
+ ];
6981
+ if (chunks.length === 1) {
6982
+ return `import * as ${routeVarName} from ${JSON.stringify(module)};`;
6983
+ }
6984
+ let chunkImportsSnippet = chunks.map((chunk) => `import * as ${chunk.varName} from "${chunk.module}";`).join("\n");
6985
+ let mergedChunksSnippet = `const ${routeVarName} = {${chunks.map((chunk) => `...${chunk.varName}`).join(",")}};`;
6986
+ return [chunkImportsSnippet, mergedChunksSnippet].join("\n");
6987
+ }).join("\n")}
6916
6988
  ${enableFogOfWar ? (
6917
6989
  // Inline a minimal manifest with the SSR matches
6918
6990
  `window.__reactRouterManifest = ${JSON.stringify(
@@ -6943,11 +7015,11 @@ import(${JSON.stringify(manifest.entry.module)});`;
6943
7015
  }
6944
7016
  ));
6945
7017
  }, []);
6946
- let routePreloads = matches.map((match) => {
6947
- let route = manifest.routes[match.route.id];
6948
- return route ? (route.imports || []).concat([route.module]) : [];
6949
- }).flat(1);
6950
- let preloads = isHydrated ? [] : manifest.entry.imports.concat(routePreloads);
7018
+ let preloads = isHydrated ? [] : manifest.entry.imports.concat(
7019
+ getModuleLinkHrefs(matches, manifest, {
7020
+ includeHydrateFallback: true
7021
+ })
7022
+ );
6951
7023
  return isHydrated ? null : /* @__PURE__ */ React9.createElement(React9.Fragment, null, !enableFogOfWar ? /* @__PURE__ */ React9.createElement(
6952
7024
  "link",
6953
7025
  {
@@ -6991,7 +7063,7 @@ function mergeRefs(...refs) {
6991
7063
  var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
6992
7064
  try {
6993
7065
  if (isBrowser) {
6994
- window.__reactRouterVersion = "0.0.0-experimental-759a11a62";
7066
+ window.__reactRouterVersion = "0.0.0-experimental-df0f1dfda";
6995
7067
  }
6996
7068
  } catch (e) {
6997
7069
  }
@@ -7194,7 +7266,7 @@ var Link = React10.forwardRef(
7194
7266
  }
7195
7267
  }
7196
7268
  }
7197
- let href2 = useHref(to, { relative });
7269
+ let href = useHref(to, { relative });
7198
7270
  let [shouldPrefetch, prefetchRef, prefetchHandlers] = usePrefetchBehavior(
7199
7271
  prefetch,
7200
7272
  rest
@@ -7220,7 +7292,7 @@ var Link = React10.forwardRef(
7220
7292
  {
7221
7293
  ...rest,
7222
7294
  ...prefetchHandlers,
7223
- href: absoluteHref || href2,
7295
+ href: absoluteHref || href,
7224
7296
  onClick: isExternal || reloadDocument ? onClick : handleClick,
7225
7297
  ref: mergeRefs(forwardedRef, prefetchRef),
7226
7298
  target,
@@ -7228,7 +7300,7 @@ var Link = React10.forwardRef(
7228
7300
  }
7229
7301
  )
7230
7302
  );
7231
- return shouldPrefetch && !isAbsolute ? /* @__PURE__ */ React10.createElement(React10.Fragment, null, link, /* @__PURE__ */ React10.createElement(PrefetchPageLinks, { page: href2 })) : link;
7303
+ return shouldPrefetch && !isAbsolute ? /* @__PURE__ */ React10.createElement(React10.Fragment, null, link, /* @__PURE__ */ React10.createElement(PrefetchPageLinks, { page: href })) : link;
7232
7304
  }
7233
7305
  );
7234
7306
  Link.displayName = "Link";
@@ -7584,9 +7656,9 @@ function useFetcher({
7584
7656
  return () => router.deleteFetcher(fetcherKey);
7585
7657
  }, [router, fetcherKey]);
7586
7658
  let load = React10.useCallback(
7587
- async (href2, opts) => {
7659
+ async (href, opts) => {
7588
7660
  invariant(routeId, "No routeId available for fetcher.load()");
7589
- await router.fetch(fetcherKey, routeId, href2, opts);
7661
+ await router.fetch(fetcherKey, routeId, href, opts);
7590
7662
  },
7591
7663
  [fetcherKey, routeId, router]
7592
7664
  );
@@ -8043,9 +8115,9 @@ function createHref(to) {
8043
8115
  return typeof to === "string" ? to : createPath(to);
8044
8116
  }
8045
8117
  function encodeLocation(to) {
8046
- let href2 = typeof to === "string" ? to : createPath(to);
8047
- href2 = href2.replace(/ $/, "%20");
8048
- let encoded = ABSOLUTE_URL_REGEX3.test(href2) ? new URL(href2) : new URL(href2, "http://localhost");
8118
+ let href = typeof to === "string" ? to : createPath(to);
8119
+ href = href.replace(/ $/, "%20");
8120
+ let encoded = ABSOLUTE_URL_REGEX3.test(href) ? new URL(href) : new URL(href, "http://localhost");
8049
8121
  return {
8050
8122
  pathname: encoded.pathname,
8051
8123
  search: encoded.search,
@@ -8200,8 +8272,11 @@ function processRoutes(routes, context, manifest, routeModules, parentId) {
8200
8272
  hasClientAction: false,
8201
8273
  hasClientLoader: false,
8202
8274
  hasErrorBoundary: route.ErrorBoundary != null,
8203
- module: "build/stub-path-to-module.js"
8204
- // any need for this?
8275
+ // any need for these?
8276
+ module: "build/stub-path-to-module.js",
8277
+ clientActionModule: void 0,
8278
+ clientLoaderModule: void 0,
8279
+ hydrateFallbackModule: void 0
8205
8280
  };
8206
8281
  manifest.routes[newRoute.id] = entryRoute;
8207
8282
  routeModules[route.id] = {
@@ -8711,8 +8786,11 @@ function prependCookies(parentHeaders, childHeaders) {
8711
8786
  let parentSetCookieString = parentHeaders.get("Set-Cookie");
8712
8787
  if (parentSetCookieString) {
8713
8788
  let cookies = splitCookiesString(parentSetCookieString);
8789
+ let childCookies = new Set(childHeaders.getSetCookie());
8714
8790
  cookies.forEach((cookie) => {
8715
- childHeaders.append("Set-Cookie", cookie);
8791
+ if (!childCookies.has(cookie)) {
8792
+ childHeaders.append("Set-Cookie", cookie);
8793
+ }
8716
8794
  });
8717
8795
  }
8718
8796
  }
@@ -8942,6 +9020,7 @@ function encodeViaTurboStream(data2, requestSignal, streamTimeout, serverMode) {
8942
9020
  }
8943
9021
 
8944
9022
  // lib/server-runtime/server.ts
9023
+ var NO_BODY_STATUS_CODES = /* @__PURE__ */ new Set([100, 101, 204, 205, 304]);
8945
9024
  function derive(build, mode) {
8946
9025
  let routes = createRoutes(build.routes);
8947
9026
  let dataRoutes = createStaticHandlerDataRoutes(build.routes, build.future);
@@ -9140,8 +9219,8 @@ async function handleSingleFetchRequest(serverMode, build, staticHandler, reques
9140
9219
  );
9141
9220
  let resultHeaders = new Headers(headers);
9142
9221
  resultHeaders.set("X-Remix-Response", "yes");
9143
- if (status === 304) {
9144
- return new Response(null, { status: 304, headers: resultHeaders });
9222
+ if (NO_BODY_STATUS_CODES.has(status)) {
9223
+ return new Response(null, { status, headers: resultHeaders });
9145
9224
  }
9146
9225
  resultHeaders.set("Content-Type", "text/x-script");
9147
9226
  return new Response(
@@ -9171,8 +9250,8 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
9171
9250
  return context;
9172
9251
  }
9173
9252
  let headers = getDocumentHeaders(build, context);
9174
- if (context.statusCode === 304) {
9175
- return new Response(null, { status: 304, headers });
9253
+ if (NO_BODY_STATUS_CODES.has(context.statusCode)) {
9254
+ return new Response(null, { status: context.statusCode, headers });
9176
9255
  }
9177
9256
  if (context.errors) {
9178
9257
  Object.values(context.errors).forEach((err) => {
@@ -9281,11 +9360,13 @@ async function handleResourceRequest(serverMode, staticHandler, routeId, request
9281
9360
  routeId,
9282
9361
  requestContext: loadContext
9283
9362
  });
9284
- invariant3(
9285
- isResponse(response),
9286
- "Expected a Response to be returned from resource route handler"
9287
- );
9288
- return response;
9363
+ if (isResponse(response)) {
9364
+ return response;
9365
+ }
9366
+ if (typeof response === "string") {
9367
+ return new Response(response);
9368
+ }
9369
+ return Response.json(response);
9289
9370
  } catch (error) {
9290
9371
  if (isResponse(error)) {
9291
9372
  error.headers.set("X-Remix-Catch", "yes");
@@ -9529,7 +9610,6 @@ export {
9529
9610
  replace,
9530
9611
  ErrorResponseImpl,
9531
9612
  isRouteErrorResponse,
9532
- href,
9533
9613
  IDLE_NAVIGATION,
9534
9614
  IDLE_FETCHER,
9535
9615
  IDLE_BLOCKER,
@@ -0,0 +1,11 @@
1
+ /**
2
+ * An object of unknown type for route loaders and actions provided by the
3
+ * server's `getLoadContext()` function. This is defined as an empty interface
4
+ * specifically so apps can leverage declaration merging to augment this type
5
+ * globally: https://www.typescriptlang.org/docs/handbook/declaration-merging.html
6
+ */
7
+ interface AppLoadContext {
8
+ [key: string]: unknown;
9
+ }
10
+
11
+ export type { AppLoadContext as A };
@@ -0,0 +1,11 @@
1
+ /**
2
+ * An object of unknown type for route loaders and actions provided by the
3
+ * server's `getLoadContext()` function. This is defined as an empty interface
4
+ * specifically so apps can leverage declaration merging to augment this type
5
+ * globally: https://www.typescriptlang.org/docs/handbook/declaration-merging.html
6
+ */
7
+ interface AppLoadContext {
8
+ [key: string]: unknown;
9
+ }
10
+
11
+ export type { AppLoadContext as A };
@@ -1,12 +1,12 @@
1
1
  import * as React from 'react';
2
- import { R as RouterProviderProps$1 } from './fog-of-war-BCniP0AZ.mjs';
3
- import './router-BYH9f2xg.mjs';
2
+ import { R as RouterProviderProps$1 } from './fog-of-war-D3ny56dR.mjs';
3
+ import './route-data-Cq_b5feC.mjs';
4
4
 
5
5
  type RouterProviderProps = Omit<RouterProviderProps$1, "flushSync">;
6
6
  declare function RouterProvider(props: Omit<RouterProviderProps, "flushSync">): React.JSX.Element;
7
7
 
8
8
  /**
9
- * @category Router Components
9
+ * @category Component Routers
10
10
  */
11
11
  declare function HydratedRouter(): React.JSX.Element;
12
12
 
@@ -1,12 +1,12 @@
1
1
  import * as React from 'react';
2
- import { R as RouterProviderProps$1 } from './fog-of-war-DFo9BKir.js';
3
- import './router-BYH9f2xg.js';
2
+ import { R as RouterProviderProps$1 } from './fog-of-war-L5G-Cw9x.js';
3
+ import './route-data-Cq_b5feC.js';
4
4
 
5
5
  type RouterProviderProps = Omit<RouterProviderProps$1, "flushSync">;
6
6
  declare function RouterProvider(props: Omit<RouterProviderProps, "flushSync">): React.JSX.Element;
7
7
 
8
8
  /**
9
- * @category Router Components
9
+ * @category Component Routers
10
10
  */
11
11
  declare function HydratedRouter(): React.JSX.Element;
12
12