react-router 7.10.0-pre.0 → 7.10.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 (64) hide show
  1. package/CHANGELOG.md +9 -2
  2. package/dist/development/{browser-eL-tAN4R.d.ts → browser-BpxEZgZC.d.ts} +1 -1
  3. package/dist/development/{browser-BHySFrZ2.d.mts → browser-C5z6FZmz.d.mts} +1 -1
  4. package/dist/development/{chunk-Z4R76DXJ.js → chunk-26EFLBGX.js} +7 -7
  5. package/dist/development/{chunk-M4WLV5HP.js → chunk-54KWOGSJ.js} +1 -1
  6. package/dist/{production/chunk-5DTJHKF7.js → development/chunk-AWUYHSQU.js} +94 -94
  7. package/dist/development/{chunk-4BTFPFZR.mjs → chunk-FGUA77HG.mjs} +2 -2
  8. package/dist/development/{chunk-CECIHG5K.mjs → chunk-INCZGKXY.mjs} +2 -2
  9. package/dist/development/dom-export.d.mts +10 -10
  10. package/dist/development/dom-export.d.ts +10 -10
  11. package/dist/development/dom-export.js +27 -27
  12. package/dist/development/dom-export.mjs +3 -3
  13. package/dist/{production/index-react-server-client-CNrKUHDv.d.ts → development/index-react-server-client-CCjKYJTH.d.ts} +17 -174
  14. package/dist/development/{index-react-server-client-DYtvZPLT.d.mts → index-react-server-client-CipGfVBI.d.mts} +17 -174
  15. package/dist/development/index-react-server-client.d.mts +2 -2
  16. package/dist/development/index-react-server-client.d.ts +2 -2
  17. package/dist/development/index-react-server-client.js +4 -4
  18. package/dist/development/index-react-server-client.mjs +2 -2
  19. package/dist/development/index-react-server.js +1 -1
  20. package/dist/development/index-react-server.mjs +1 -1
  21. package/dist/development/index.d.mts +8 -8
  22. package/dist/development/index.d.ts +8 -8
  23. package/dist/development/index.js +76 -76
  24. package/dist/development/index.mjs +3 -3
  25. package/dist/{production/instrumentation-Dwf-sTWa.d.ts → development/instrumentation-BB0wRuqz.d.ts} +27 -3
  26. package/dist/development/lib/types/internal.d.mts +2 -2
  27. package/dist/development/lib/types/internal.d.ts +2 -2
  28. package/dist/development/lib/types/internal.js +1 -1
  29. package/dist/development/lib/types/internal.mjs +1 -1
  30. package/dist/development/{register-C97Jz2jB.d.mts → register-C1RwVJAt.d.mts} +1 -1
  31. package/dist/development/{register-BnQsYkwj.d.ts → register-ODDAAYlf.d.ts} +1 -1
  32. package/dist/development/{router-Dgz_Mh9m.d.mts → router-CwNp5l9u.d.mts} +27 -3
  33. package/dist/production/{browser-eL-tAN4R.d.ts → browser-BpxEZgZC.d.ts} +1 -1
  34. package/dist/production/{browser-BHySFrZ2.d.mts → browser-C5z6FZmz.d.mts} +1 -1
  35. package/dist/production/{chunk-SGCRBGEM.js → chunk-EKXDIDQN.js} +7 -7
  36. package/dist/{development/chunk-2VILFZWG.js → production/chunk-J25F7BL4.js} +94 -94
  37. package/dist/production/{chunk-QKAGOFED.mjs → chunk-MFC2CGJA.mjs} +2 -2
  38. package/dist/production/{chunk-KJ5676BZ.mjs → chunk-RNH4J7KQ.mjs} +2 -2
  39. package/dist/production/{chunk-55FFLVQP.js → chunk-SKXBY33F.js} +1 -1
  40. package/dist/production/dom-export.d.mts +10 -10
  41. package/dist/production/dom-export.d.ts +10 -10
  42. package/dist/production/dom-export.js +27 -27
  43. package/dist/production/dom-export.mjs +3 -3
  44. package/dist/{development/index-react-server-client-CNrKUHDv.d.ts → production/index-react-server-client-CCjKYJTH.d.ts} +17 -174
  45. package/dist/production/{index-react-server-client-DYtvZPLT.d.mts → index-react-server-client-CipGfVBI.d.mts} +17 -174
  46. package/dist/production/index-react-server-client.d.mts +2 -2
  47. package/dist/production/index-react-server-client.d.ts +2 -2
  48. package/dist/production/index-react-server-client.js +4 -4
  49. package/dist/production/index-react-server-client.mjs +2 -2
  50. package/dist/production/index-react-server.js +1 -1
  51. package/dist/production/index-react-server.mjs +1 -1
  52. package/dist/production/index.d.mts +8 -8
  53. package/dist/production/index.d.ts +8 -8
  54. package/dist/production/index.js +76 -76
  55. package/dist/production/index.mjs +3 -3
  56. package/dist/{development/instrumentation-Dwf-sTWa.d.ts → production/instrumentation-BB0wRuqz.d.ts} +27 -3
  57. package/dist/production/lib/types/internal.d.mts +2 -2
  58. package/dist/production/lib/types/internal.d.ts +2 -2
  59. package/dist/production/lib/types/internal.js +1 -1
  60. package/dist/production/lib/types/internal.mjs +1 -1
  61. package/dist/production/{register-C97Jz2jB.d.mts → register-C1RwVJAt.d.mts} +1 -1
  62. package/dist/production/{register-BnQsYkwj.d.ts → register-ODDAAYlf.d.ts} +1 -1
  63. package/dist/production/{router-Dgz_Mh9m.d.mts → router-CwNp5l9u.d.mts} +27 -3
  64. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { RouterProviderProps as RouterProviderProps$1, RouterInit, unstable_ClientOnErrorFunction } from 'react-router';
3
- import { u as unstable_ClientInstrumentation } from './instrumentation-Dwf-sTWa.js';
4
- export { D as unstable_DecodeActionFunction, a as unstable_DecodeFormStateFunction, b as unstable_DecodeReplyFunction, R as unstable_RSCHydratedRouter, d as unstable_RSCManifestPayload, e as unstable_RSCPayload, f as unstable_RSCRenderPayload, c as unstable_createCallServer } from './browser-eL-tAN4R.js';
3
+ import { u as unstable_ClientInstrumentation } from './instrumentation-BB0wRuqz.js';
4
+ export { D as unstable_DecodeActionFunction, a as unstable_DecodeFormStateFunction, b as unstable_DecodeReplyFunction, R as unstable_RSCHydratedRouter, d as unstable_RSCManifestPayload, e as unstable_RSCPayload, f as unstable_RSCRenderPayload, c as unstable_createCallServer } from './browser-BpxEZgZC.js';
5
5
 
6
6
  type RouterProviderProps = Omit<RouterProviderProps$1, "flushSync">;
7
7
  declare function RouterProvider(props: Omit<RouterProviderProps, "flushSync">): React.JSX.Element;
@@ -26,16 +26,9 @@ interface HydratedRouterProps {
26
26
  * added routes via `route.lazy` or `patchRoutesOnNavigation`). This is
27
27
  * mostly useful for observability such as wrapping navigations, fetches,
28
28
  * as well as route loaders/actions/middlewares with logging and/or performance
29
- * tracing.
29
+ * tracing. See the [docs](../../how-to/instrumentation) for more information.
30
30
  *
31
31
  * ```tsx
32
- * startTransition(() => {
33
- * hydrateRoot(
34
- * document,
35
- * <HydratedRouter unstable_instrumentations={[logging]} />
36
- * );
37
- * });
38
- *
39
32
  * const logging = {
40
33
  * router({ instrument }) {
41
34
  * instrument({
@@ -68,6 +61,13 @@ interface HydratedRouterProps {
68
61
  * let duration = Math.round(performance.now() - start);
69
62
  * console.log(`end ${label} (${duration}ms)`);
70
63
  * }
64
+ *
65
+ * startTransition(() => {
66
+ * hydrateRoot(
67
+ * document,
68
+ * <HydratedRouter unstable_instrumentations={[logging]} />
69
+ * );
70
+ * });
71
71
  * ```
72
72
  */
73
73
  unstable_instrumentations?: unstable_ClientInstrumentation[];
@@ -1,5 +1,5 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }/**
2
- * react-router v7.10.0-pre.0
2
+ * react-router v7.10.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -13,7 +13,7 @@
13
13
 
14
14
 
15
15
 
16
- var _chunkSGCRBGEMjs = require('./chunk-SGCRBGEM.js');
16
+ var _chunkEKXDIDQNjs = require('./chunk-EKXDIDQN.js');
17
17
 
18
18
 
19
19
 
@@ -32,7 +32,7 @@ var _chunkSGCRBGEMjs = require('./chunk-SGCRBGEM.js');
32
32
 
33
33
 
34
34
 
35
- var _chunk55FFLVQPjs = require('./chunk-55FFLVQP.js');
35
+ var _chunkSKXBY33Fjs = require('./chunk-SKXBY33F.js');
36
36
 
37
37
  // lib/dom-export/dom-router-provider.tsx
38
38
  var _react = require('react'); var React = _interopRequireWildcard(_react); var React2 = _interopRequireWildcard(_react); var React3 = _interopRequireWildcard(_react);
@@ -204,7 +204,7 @@ function HydratedRouter(props) {
204
204
  }, []);
205
205
  React2.useEffect(() => {
206
206
  if (process.env.NODE_ENV === "development" && criticalCss === void 0) {
207
- document.querySelectorAll(`[${_chunk55FFLVQPjs.CRITICAL_CSS_DATA_ATTRIBUTE}]`).forEach((element) => element.remove());
207
+ document.querySelectorAll(`[${_chunkSKXBY33Fjs.CRITICAL_CSS_DATA_ATTRIBUTE}]`).forEach((element) => element.remove());
208
208
  }
209
209
  }, [criticalCss]);
210
210
  let [location2, setLocation] = React2.useState(router.state.location);
@@ -376,10 +376,10 @@ function createRouterFromPayload({
376
376
  };
377
377
  if (payload.type !== "render") throw new Error("Invalid payload type");
378
378
  globalVar.__reactRouterRouteModules = _nullishCoalesce(globalVar.__reactRouterRouteModules, () => ( {}));
379
- _chunkSGCRBGEMjs.populateRSCRouteModules.call(void 0, globalVar.__reactRouterRouteModules, payload.matches);
379
+ _chunkEKXDIDQNjs.populateRSCRouteModules.call(void 0, globalVar.__reactRouterRouteModules, payload.matches);
380
380
  let patches = /* @__PURE__ */ new Map();
381
381
  _optionalChain([payload, 'access', _22 => _22.patches, 'optionalAccess', _23 => _23.forEach, 'call', _24 => _24((patch) => {
382
- _chunk55FFLVQPjs.invariant.call(void 0, patch.parentId, "Invalid patch parentId");
382
+ _chunkSKXBY33Fjs.invariant.call(void 0, patch.parentId, "Invalid patch parentId");
383
383
  if (!patches.has(patch.parentId)) {
384
384
  patches.set(patch.parentId, []);
385
385
  }
@@ -401,12 +401,12 @@ function createRouterFromPayload({
401
401
  }
402
402
  return [route];
403
403
  }, []);
404
- globalVar.__reactRouterDataRouter = _chunk55FFLVQPjs.createRouter.call(void 0, {
404
+ globalVar.__reactRouterDataRouter = _chunkSKXBY33Fjs.createRouter.call(void 0, {
405
405
  routes,
406
406
  getContext,
407
407
  basename: payload.basename,
408
- history: _chunk55FFLVQPjs.createBrowserHistory.call(void 0, ),
409
- hydrationData: _chunkSGCRBGEMjs.getHydrationData.call(void 0, {
408
+ history: _chunkSKXBY33Fjs.createBrowserHistory.call(void 0, ),
409
+ hydrationData: _chunkEKXDIDQNjs.getHydrationData.call(void 0, {
410
410
  state: {
411
411
  loaderData: payload.loaderData,
412
412
  actionData: payload.actionData,
@@ -415,7 +415,7 @@ function createRouterFromPayload({
415
415
  routes,
416
416
  getRouteInfo: (routeId) => {
417
417
  let match = payload.matches.find((m) => m.id === routeId);
418
- _chunk55FFLVQPjs.invariant.call(void 0, match, "Route not found in payload");
418
+ _chunkSKXBY33Fjs.invariant.call(void 0, match, "Route not found in payload");
419
419
  return {
420
420
  clientLoader: match.clientLoader,
421
421
  hasLoader: match.hasLoader,
@@ -513,9 +513,9 @@ function createRouterFromPayload({
513
513
  routeModules: globalVar.__reactRouterRouteModules
514
514
  };
515
515
  }
516
- var renderedRoutesContext = _chunk55FFLVQPjs.createContext.call(void 0, );
516
+ var renderedRoutesContext = _chunkSKXBY33Fjs.createContext.call(void 0, );
517
517
  function getRSCSingleFetchDataStrategy(getRouter, ssr, basename, createFromReadableStream, fetchImplementation) {
518
- let dataStrategy = _chunk55FFLVQPjs.getSingleFetchDataStrategyImpl.call(void 0,
518
+ let dataStrategy = _chunkSKXBY33Fjs.getSingleFetchDataStrategyImpl.call(void 0,
519
519
  getRouter,
520
520
  (match) => {
521
521
  let M = match;
@@ -571,20 +571,20 @@ function getRSCSingleFetchDataStrategy(getRouter, ssr, basename, createFromReada
571
571
  function getFetchAndDecodeViaRSC(createFromReadableStream, fetchImplementation) {
572
572
  return async (args, basename, targetRoutes) => {
573
573
  let { request, context } = args;
574
- let url = _chunk55FFLVQPjs.singleFetchUrl.call(void 0, request.url, basename, "rsc");
574
+ let url = _chunkSKXBY33Fjs.singleFetchUrl.call(void 0, request.url, basename, "rsc");
575
575
  if (request.method === "GET") {
576
- url = _chunk55FFLVQPjs.stripIndexParam.call(void 0, url);
576
+ url = _chunkSKXBY33Fjs.stripIndexParam.call(void 0, url);
577
577
  if (targetRoutes) {
578
578
  url.searchParams.set("_routes", targetRoutes.join(","));
579
579
  }
580
580
  }
581
581
  let res = await fetchImplementation(
582
- new Request(url, await _chunk55FFLVQPjs.createRequestInit.call(void 0, request))
582
+ new Request(url, await _chunkSKXBY33Fjs.createRequestInit.call(void 0, request))
583
583
  );
584
584
  if (res.status >= 400 && !res.headers.has("X-Remix-Response")) {
585
- throw new (0, _chunk55FFLVQPjs.ErrorResponseImpl)(res.status, res.statusText, await res.text());
585
+ throw new (0, _chunkSKXBY33Fjs.ErrorResponseImpl)(res.status, res.statusText, await res.text());
586
586
  }
587
- _chunk55FFLVQPjs.invariant.call(void 0, res.body, "No response body to decode");
587
+ _chunkSKXBY33Fjs.invariant.call(void 0, res.body, "No response body to decode");
588
588
  try {
589
589
  const payload = await createFromReadableStream(res.body, {
590
590
  temporaryReferences: void 0
@@ -608,7 +608,7 @@ function getFetchAndDecodeViaRSC(createFromReadableStream, fetchImplementation)
608
608
  }
609
609
  context.get(renderedRoutesContext).push(...payload.matches);
610
610
  let results = { routes: {} };
611
- const dataKey = _chunk55FFLVQPjs.isMutationMethod.call(void 0, request.method) ? "actionData" : "loaderData";
611
+ const dataKey = _chunkSKXBY33Fjs.isMutationMethod.call(void 0, request.method) ? "actionData" : "loaderData";
612
612
  for (let [routeId, data] of Object.entries(payload[dataKey] || {})) {
613
613
  results.routes[routeId] = { data };
614
614
  }
@@ -641,7 +641,7 @@ function RSCHydratedRouter({
641
641
  [createFromReadableStream, payload, fetchImplementation, getContext]
642
642
  );
643
643
  React3.useEffect(() => {
644
- _chunk55FFLVQPjs.setIsHydrated.call(void 0, );
644
+ _chunkSKXBY33Fjs.setIsHydrated.call(void 0, );
645
645
  }, []);
646
646
  React3.useLayoutEffect(() => {
647
647
  const globalVar = window;
@@ -743,8 +743,8 @@ function RSCHydratedRouter({
743
743
  routeDiscovery: { mode: "lazy", manifestPath: "/__manifest" },
744
744
  routeModules
745
745
  };
746
- return /* @__PURE__ */ React3.createElement(_chunk55FFLVQPjs.RSCRouterContext.Provider, { value: true }, /* @__PURE__ */ React3.createElement(_chunkSGCRBGEMjs.RSCRouterGlobalErrorBoundary, { location: state.location }, /* @__PURE__ */ React3.createElement(_chunk55FFLVQPjs.FrameworkContext.Provider, { value: frameworkContext }, /* @__PURE__ */ React3.createElement(
747
- _chunk55FFLVQPjs.RouterProvider,
746
+ return /* @__PURE__ */ React3.createElement(_chunkSKXBY33Fjs.RSCRouterContext.Provider, { value: true }, /* @__PURE__ */ React3.createElement(_chunkEKXDIDQNjs.RSCRouterGlobalErrorBoundary, { location: state.location }, /* @__PURE__ */ React3.createElement(_chunkSKXBY33Fjs.FrameworkContext.Provider, { value: frameworkContext }, /* @__PURE__ */ React3.createElement(
747
+ _chunkSKXBY33Fjs.RouterProvider,
748
748
  {
749
749
  router: transitionEnabledRouter,
750
750
  flushSync: ReactDOM2.flushSync,
@@ -761,8 +761,8 @@ function createRouteFromServerManifest(match, payload) {
761
761
  // the server loader flow regardless of whether the client loader calls
762
762
  // `serverLoader` or not, otherwise we'll have nothing to render.
763
763
  match.hasComponent && !match.element;
764
- _chunk55FFLVQPjs.invariant.call(void 0, window.__reactRouterRouteModules);
765
- _chunkSGCRBGEMjs.populateRSCRouteModules.call(void 0, window.__reactRouterRouteModules, match);
764
+ _chunkSKXBY33Fjs.invariant.call(void 0, window.__reactRouterRouteModules);
765
+ _chunkEKXDIDQNjs.populateRSCRouteModules.call(void 0, window.__reactRouterRouteModules, match);
766
766
  let dataRoute = {
767
767
  id: match.id,
768
768
  element: match.element,
@@ -812,7 +812,7 @@ function createRouteFromServerManifest(match, payload) {
812
812
  return await callSingleFetch(singleFetch);
813
813
  }
814
814
  }) : match.hasAction ? (_, singleFetch) => callSingleFetch(singleFetch) : () => {
815
- throw _chunk55FFLVQPjs.noActionDefinedError.call(void 0, "action", match.id);
815
+ throw _chunkSKXBY33Fjs.noActionDefinedError.call(void 0, "action", match.id);
816
816
  },
817
817
  path: match.path,
818
818
  shouldRevalidate: match.shouldRevalidate,
@@ -825,7 +825,7 @@ function createRouteFromServerManifest(match, payload) {
825
825
  hasShouldRevalidate: match.shouldRevalidate != null
826
826
  };
827
827
  if (typeof dataRoute.loader === "function") {
828
- dataRoute.loader.hydrate = _chunk55FFLVQPjs.shouldHydrateRouteLoader.call(void 0,
828
+ dataRoute.loader.hydrate = _chunkSKXBY33Fjs.shouldHydrateRouteLoader.call(void 0,
829
829
  match.id,
830
830
  match.clientLoader,
831
831
  match.hasLoader,
@@ -835,7 +835,7 @@ function createRouteFromServerManifest(match, payload) {
835
835
  return dataRoute;
836
836
  }
837
837
  function callSingleFetch(singleFetch) {
838
- _chunk55FFLVQPjs.invariant.call(void 0, typeof singleFetch === "function", "Invalid singleFetch parameter");
838
+ _chunkSKXBY33Fjs.invariant.call(void 0, typeof singleFetch === "function", "Invalid singleFetch parameter");
839
839
  return singleFetch();
840
840
  }
841
841
  function preventInvalidServerHandlerCall(type, routeId, hasHandler) {
@@ -843,7 +843,7 @@ function preventInvalidServerHandlerCall(type, routeId, hasHandler) {
843
843
  let fn = type === "action" ? "serverAction()" : "serverLoader()";
844
844
  let msg = `You are trying to call ${fn} on a route that does not have a server ${type} (routeId: "${routeId}")`;
845
845
  console.error(msg);
846
- throw new (0, _chunk55FFLVQPjs.ErrorResponseImpl)(400, "Bad Request", new Error(msg), true);
846
+ throw new (0, _chunkSKXBY33Fjs.ErrorResponseImpl)(400, "Bad Request", new Error(msg), true);
847
847
  }
848
848
  }
849
849
  var nextPaths = /* @__PURE__ */ new Set();
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.10.0-pre.0
2
+ * react-router v7.10.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -14,7 +14,7 @@ import {
14
14
  deserializeErrors,
15
15
  getHydrationData,
16
16
  populateRSCRouteModules
17
- } from "./chunk-QKAGOFED.mjs";
17
+ } from "./chunk-MFC2CGJA.mjs";
18
18
  import {
19
19
  CRITICAL_CSS_DATA_ATTRIBUTE,
20
20
  ErrorResponseImpl,
@@ -42,7 +42,7 @@ import {
42
42
  singleFetchUrl,
43
43
  stripIndexParam,
44
44
  useFogOFWarDiscovery
45
- } from "./chunk-KJ5676BZ.mjs";
45
+ } from "./chunk-RNH4J7KQ.mjs";
46
46
 
47
47
  // lib/dom-export/dom-router-provider.tsx
48
48
  import * as React from "react";
@@ -1,4 +1,4 @@
1
- import { bE as RouteManifest, o as RouteModules, Q as HydrationState, a1 as DataRouteObject, a as ClientLoaderFunction, a5 as StaticHandlerContext, bF as ServerRouteModule, q as MiddlewareEnabled, c as RouterContextProvider, r as AppLoadContext, al as LoaderFunctionArgs, ac as ActionFunctionArgs, au as unstable_ServerInstrumentation, aj as HTMLFormMethod, ah as FormEncType, w as RelativeRoutingType, bh as PageLinkDescriptor, T as To, bG as History, a4 as GetScrollRestorationKeyFunction, e as RouterInit, bH as FutureConfig$1, u as unstable_ClientInstrumentation, p as DataStrategyFunction, a0 as PatchRoutesOnNavigationFunction, s as NavigateOptions, a6 as Fetcher, K as RouteObject, n as Router, v as SerializeFrom, B as BlockerFunction, L as Location, bI as CreateStaticHandlerOptions$1, a2 as StaticHandler } from './instrumentation-Dwf-sTWa.js';
1
+ import { bE as RouteManifest, o as RouteModules, Q as HydrationState, a1 as DataRouteObject, a as ClientLoaderFunction, a5 as StaticHandlerContext, bF as ServerRouteModule, q as MiddlewareEnabled, c as RouterContextProvider, r as AppLoadContext, al as LoaderFunctionArgs, ac as ActionFunctionArgs, au as unstable_ServerInstrumentation, aj as HTMLFormMethod, ah as FormEncType, w as RelativeRoutingType, bh as PageLinkDescriptor, T as To, bG as History, a4 as GetScrollRestorationKeyFunction, e as RouterInit, bH as FutureConfig$1, u as unstable_ClientInstrumentation, p as DataStrategyFunction, a0 as PatchRoutesOnNavigationFunction, s as NavigateOptions, a6 as Fetcher, K as RouteObject, n as Router, v as SerializeFrom, B as BlockerFunction, L as Location, bI as CreateStaticHandlerOptions$1, a2 as StaticHandler } from './instrumentation-BB0wRuqz.js';
2
2
  import * as React from 'react';
3
3
 
4
4
  interface Route {
@@ -536,7 +536,7 @@ interface DOMRouterOpts {
536
536
  * added routes via `route.lazy` or `patchRoutesOnNavigation`). This is
537
537
  * mostly useful for observability such as wrapping navigations, fetches,
538
538
  * as well as route loaders/actions/middlewares with logging and/or performance
539
- * tracing.
539
+ * tracing. See the [docs](../../how-to/instrumentation) for more information.
540
540
  *
541
541
  * ```tsx
542
542
  * let router = createBrowserRouter(routes, {
@@ -580,189 +580,32 @@ interface DOMRouterOpts {
580
580
  */
581
581
  unstable_instrumentations?: unstable_ClientInstrumentation[];
582
582
  /**
583
- * Override the default data strategy of running loaders in parallel.
584
- * See {@link DataStrategyFunction}.
585
- *
586
- * <docs-warning>This is a low-level API intended for advanced use-cases. This
587
- * overrides React Router's internal handling of
588
- * [`action`](../../start/data/route-object#action)/[`loader`](../../start/data/route-object#loader)
589
- * execution, and if done incorrectly will break your app code. Please use
590
- * with caution and perform the appropriate testing.</docs-warning>
591
- *
592
- * By default, React Router is opinionated about how your data is loaded/submitted -
593
- * and most notably, executes all of your [`loader`](../../start/data/route-object#loader)s
594
- * in parallel for optimal data fetching. While we think this is the right
595
- * behavior for most use-cases, we realize that there is no "one size fits all"
596
- * solution when it comes to data fetching for the wide landscape of
597
- * application requirements.
598
- *
599
- * The `dataStrategy` option gives you full control over how your [`action`](../../start/data/route-object#action)s
600
- * and [`loader`](../../start/data/route-object#loader)s are executed and lays
601
- * the foundation to build in more advanced APIs such as middleware, context,
602
- * and caching layers. Over time, we expect that we'll leverage this API
603
- * internally to bring more first class APIs to React Router, but until then
604
- * (and beyond), this is your way to add more advanced functionality for your
605
- * application's data needs.
606
- *
607
- * The `dataStrategy` function should return a key/value-object of
608
- * `routeId` -> {@link DataStrategyResult} and should include entries for any
609
- * routes where a handler was executed. A `DataStrategyResult` indicates if
610
- * the handler was successful or not based on the `DataStrategyResult.type`
611
- * field. If the returned `DataStrategyResult.result` is a [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response),
612
- * React Router will unwrap it for you (via [`res.json`](https://developer.mozilla.org/en-US/docs/Web/API/Response/json)
613
- * or [`res.text`](https://developer.mozilla.org/en-US/docs/Web/API/Response/text)).
614
- * If you need to do custom decoding of a [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
615
- * but want to preserve the status code, you can use the `data` utility to
616
- * return your decoded data along with a `ResponseInit`.
617
- *
618
- * <details>
619
- * <summary><b>Example <code>dataStrategy</code> Use Cases</b></summary>
620
- *
621
- * **Adding logging**
622
- *
623
- * In the simplest case, let's look at hooking into this API to add some logging
624
- * for when our route [`action`](../../start/data/route-object#action)s/[`loader`](../../start/data/route-object#loader)s
625
- * execute:
583
+ * Override the default data strategy of running loaders in parallel -
584
+ * see the [docs](../../how-to/data-strategy) for more information.
626
585
  *
627
586
  * ```tsx
628
587
  * let router = createBrowserRouter(routes, {
629
- * async dataStrategy({ matches, request }) {
630
- * const matchesToLoad = matches.filter((m) => m.shouldLoad);
631
- * const results: Record<string, DataStrategyResult> = {};
632
- * await Promise.all(
633
- * matchesToLoad.map(async (match) => {
634
- * console.log(`Processing ${match.route.id}`);
635
- * results[match.route.id] = await match.resolve();;
636
- * })
588
+ * async dataStrategy({
589
+ * matches,
590
+ * request,
591
+ * runClientMiddleware,
592
+ * }) {
593
+ * const matchesToLoad = matches.filter((m) =>
594
+ * m.shouldCallHandler(),
637
595
  * );
638
- * return results;
639
- * },
640
- * });
641
- * ```
642
- *
643
- * **Middleware**
644
- *
645
- * Let's define a middleware on each route via [`handle`](../../start/data/route-object#handle)
646
- * and call middleware sequentially first, then call all
647
- * [`loader`](../../start/data/route-object#loader)s in parallel - providing
648
- * any data made available via the middleware:
649
- *
650
- * ```ts
651
- * const routes = [
652
- * {
653
- * id: "parent",
654
- * path: "/parent",
655
- * loader({ request }, context) {
656
- * // ...
657
- * },
658
- * handle: {
659
- * async middleware({ request }, context) {
660
- * context.parent = "PARENT MIDDLEWARE";
661
- * },
662
- * },
663
- * children: [
664
- * {
665
- * id: "child",
666
- * path: "child",
667
- * loader({ request }, context) {
668
- * // ...
669
- * },
670
- * handle: {
671
- * async middleware({ request }, context) {
672
- * context.child = "CHILD MIDDLEWARE";
673
- * },
674
- * },
675
- * },
676
- * ],
677
- * },
678
- * ];
679
596
  *
680
- * let router = createBrowserRouter(routes, {
681
- * async dataStrategy({ matches, params, request }) {
682
- * // Run middleware sequentially and let them add data to `context`
683
- * let context = {};
684
- * for (const match of matches) {
685
- * if (match.route.handle?.middleware) {
686
- * await match.route.handle.middleware(
687
- * { request, params },
688
- * context
689
- * );
690
- * }
691
- * }
692
- *
693
- * // Run loaders in parallel with the `context` value
694
- * let matchesToLoad = matches.filter((m) => m.shouldLoad);
695
- * let results = await Promise.all(
696
- * matchesToLoad.map((match, i) =>
697
- * match.resolve((handler) => {
698
- * // Whatever you pass to `handler` will be passed as the 2nd parameter
699
- * // to your loader/action
700
- * return handler(context);
701
- * })
702
- * )
703
- * );
704
- * return results.reduce(
705
- * (acc, result, i) =>
706
- * Object.assign(acc, {
707
- * [matchesToLoad[i].route.id]: result,
597
+ * const results: Record<string, DataStrategyResult> = {};
598
+ * await runClientMiddleware(() =>
599
+ * Promise.all(
600
+ * matchesToLoad.map(async (match) => {
601
+ * results[match.route.id] = await match.resolve();
708
602
  * }),
709
- * {}
603
+ * ),
710
604
  * );
711
- * },
712
- * });
713
- * ```
714
- *
715
- * **Custom Handler**
716
- *
717
- * It's also possible you don't even want to define a [`loader`](../../start/data/route-object#loader)
718
- * implementation at the route level. Maybe you want to just determine the
719
- * routes and issue a single GraphQL request for all of your data? You can do
720
- * that by setting your `route.loader=true` so it qualifies as "having a
721
- * loader", and then store GQL fragments on `route.handle`:
722
- *
723
- * ```ts
724
- * const routes = [
725
- * {
726
- * id: "parent",
727
- * path: "/parent",
728
- * loader: true,
729
- * handle: {
730
- * gql: gql`
731
- * fragment Parent on Whatever {
732
- * parentField
733
- * }
734
- * `,
735
- * },
736
- * children: [
737
- * {
738
- * id: "child",
739
- * path: "child",
740
- * loader: true,
741
- * handle: {
742
- * gql: gql`
743
- * fragment Child on Whatever {
744
- * childField
745
- * }
746
- * `,
747
- * },
748
- * },
749
- * ],
750
- * },
751
- * ];
752
- *
753
- * let router = createBrowserRouter(routes, {
754
- * async dataStrategy({ matches, params, request }) {
755
- * // Compose route fragments into a single GQL payload
756
- * let gql = getFragmentsFromRouteHandles(matches);
757
- * let data = await fetchGql(gql);
758
- * // Parse results back out into individual route level `DataStrategyResult`'s
759
- * // keyed by `routeId`
760
- * let results = parseResultsFromGql(data);
761
605
  * return results;
762
606
  * },
763
607
  * });
764
608
  * ```
765
- *</details>
766
609
  */
767
610
  dataStrategy?: DataStrategyFunction;
768
611
  /**