react-router 7.8.2 → 7.9.0-pre.1

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 (60) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/development/{chunk-5UALIXAM.mjs → chunk-AVXIT45F.mjs} +94 -70
  3. package/dist/development/{chunk-PVWAREVJ.mjs → chunk-QZH3B547.mjs} +47 -50
  4. package/dist/development/{chunk-ZO66TDGB.js → chunk-RGB6BZUL.js} +41 -44
  5. package/dist/development/{chunk-CSDGKXLR.js → chunk-XYB2GISA.js} +135 -135
  6. package/dist/{production/context-jKip1TFB.d.mts → development/context-BH6Jwdoy.d.mts} +39 -32
  7. package/dist/development/dom-export.d.mts +3 -3
  8. package/dist/development/dom-export.d.ts +2 -2
  9. package/dist/development/dom-export.js +14 -14
  10. package/dist/development/dom-export.mjs +14 -14
  11. package/dist/development/{index-react-server-client-DRhjXpk2.d.mts → index-react-server-client-1cWMpKk4.d.mts} +13 -13
  12. package/dist/{production/index-react-server-client-BKpa2trA.d.ts → development/index-react-server-client-CMC2eQAY.d.ts} +12 -12
  13. package/dist/development/index-react-server-client.d.mts +3 -3
  14. package/dist/development/index-react-server-client.d.ts +2 -2
  15. package/dist/development/index-react-server-client.js +4 -4
  16. package/dist/development/index-react-server-client.mjs +4 -4
  17. package/dist/development/index-react-server.d.mts +229 -37
  18. package/dist/development/index-react-server.d.ts +229 -37
  19. package/dist/development/index-react-server.js +89 -39
  20. package/dist/development/index-react-server.mjs +88 -36
  21. package/dist/development/index.d.mts +31 -24
  22. package/dist/development/index.d.ts +29 -22
  23. package/dist/development/index.js +184 -158
  24. package/dist/development/index.mjs +9 -7
  25. package/dist/development/lib/types/internal.d.mts +6 -6
  26. package/dist/development/lib/types/internal.d.ts +5 -5
  27. package/dist/development/lib/types/internal.js +1 -1
  28. package/dist/development/lib/types/internal.mjs +1 -1
  29. package/dist/development/{route-data-DAVP2QQ0.d.mts → route-data-BQkq8Erj.d.mts} +12 -12
  30. package/dist/development/{routeModules-rOzWJJ9x.d.ts → routeModules-DSKAn01V.d.ts} +175 -168
  31. package/dist/production/{chunk-Z56HUDN5.js → chunk-A6EU7LHU.js} +41 -44
  32. package/dist/production/{chunk-REDRD2MB.mjs → chunk-BQLQLXP4.mjs} +47 -50
  33. package/dist/production/{chunk-JNT5PWCQ.js → chunk-IR3XRH6J.js} +135 -135
  34. package/dist/production/{chunk-KWHRV2I7.mjs → chunk-WMHWIEJV.mjs} +94 -70
  35. package/dist/{development/context-jKip1TFB.d.mts → production/context-BH6Jwdoy.d.mts} +39 -32
  36. package/dist/production/dom-export.d.mts +3 -3
  37. package/dist/production/dom-export.d.ts +2 -2
  38. package/dist/production/dom-export.js +14 -14
  39. package/dist/production/dom-export.mjs +14 -14
  40. package/dist/production/{index-react-server-client-DRhjXpk2.d.mts → index-react-server-client-1cWMpKk4.d.mts} +13 -13
  41. package/dist/{development/index-react-server-client-BKpa2trA.d.ts → production/index-react-server-client-CMC2eQAY.d.ts} +12 -12
  42. package/dist/production/index-react-server-client.d.mts +3 -3
  43. package/dist/production/index-react-server-client.d.ts +2 -2
  44. package/dist/production/index-react-server-client.js +4 -4
  45. package/dist/production/index-react-server-client.mjs +4 -4
  46. package/dist/production/index-react-server.d.mts +229 -37
  47. package/dist/production/index-react-server.d.ts +229 -37
  48. package/dist/production/index-react-server.js +89 -39
  49. package/dist/production/index-react-server.mjs +88 -36
  50. package/dist/production/index.d.mts +31 -24
  51. package/dist/production/index.d.ts +29 -22
  52. package/dist/production/index.js +184 -158
  53. package/dist/production/index.mjs +9 -7
  54. package/dist/production/lib/types/internal.d.mts +6 -6
  55. package/dist/production/lib/types/internal.d.ts +5 -5
  56. package/dist/production/lib/types/internal.js +1 -1
  57. package/dist/production/lib/types/internal.mjs +1 -1
  58. package/dist/production/{route-data-DAVP2QQ0.d.mts → route-data-BQkq8Erj.d.mts} +12 -12
  59. package/dist/production/{routeModules-rOzWJJ9x.d.ts → routeModules-DSKAn01V.d.ts} +175 -168
  60. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.8.2
2
+ * react-router v7.9.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -16,6 +16,7 @@ import {
16
16
  Outlet,
17
17
  RSCRouterContext,
18
18
  RemixErrorBoundary,
19
+ RouterContextProvider,
19
20
  RouterProvider,
20
21
  SINGLE_FETCH_REDIRECT_STATUS,
21
22
  SingleFetchRedirectSymbol,
@@ -23,6 +24,7 @@ import {
23
24
  StreamTransfer,
24
25
  convertRoutesToDataRoutes,
25
26
  createBrowserHistory,
27
+ createContext,
26
28
  createMemoryRouter,
27
29
  createRequestInit,
28
30
  createRouter,
@@ -31,6 +33,7 @@ import {
31
33
  createStaticRouter,
32
34
  decodeViaTurboStream,
33
35
  encode,
36
+ escapeHtml,
34
37
  getManifestPath,
35
38
  getSingleFetchDataStrategyImpl,
36
39
  getStaticContextFromError,
@@ -51,14 +54,12 @@ import {
51
54
  singleFetchUrl,
52
55
  stripBasename,
53
56
  stripIndexParam,
54
- unstable_RouterContextProvider,
55
- unstable_createContext,
56
57
  useRouteError,
57
58
  warnOnce,
58
59
  withComponentProps,
59
60
  withErrorBoundaryProps,
60
61
  withHydrateFallbackProps
61
- } from "./chunk-REDRD2MB.mjs";
62
+ } from "./chunk-BQLQLXP4.mjs";
62
63
 
63
64
  // lib/dom/ssr/server.tsx
64
65
  import * as React from "react";
@@ -145,7 +146,7 @@ function createRoutesStub(routes, _context) {
145
146
  frameworkContextRef.current = {
146
147
  future: {
147
148
  unstable_subResourceIntegrity: future?.unstable_subResourceIntegrity === true,
148
- unstable_middleware: future?.unstable_middleware === true
149
+ v8_middleware: future?.v8_middleware === true
149
150
  },
150
151
  manifest: {
151
152
  routes: {},
@@ -162,7 +163,7 @@ function createRoutesStub(routes, _context) {
162
163
  // @ts-expect-error `StubRouteObject` is stricter about `loader`/`action`
163
164
  // types compared to `AgnosticRouteObject`
164
165
  convertRoutesToDataRoutes(routes, (r) => r),
165
- _context !== void 0 ? _context : future?.unstable_middleware ? new unstable_RouterContextProvider() : {},
166
+ _context !== void 0 ? _context : future?.v8_middleware ? new RouterContextProvider() : {},
166
167
  frameworkContextRef.current.manifest,
167
168
  frameworkContextRef.current.routeModules
168
169
  );
@@ -612,7 +613,7 @@ function createStaticHandlerDataRoutes(manifest, future, parentId = "", routesBy
612
613
  hasErrorBoundary: route.id === "root" || route.module.ErrorBoundary != null,
613
614
  id: route.id,
614
615
  path: route.path,
615
- unstable_middleware: route.module.unstable_middleware,
616
+ middleware: route.module.middleware,
616
617
  // Need to use RR's version in the param typed here to permit the optional
617
618
  // context even though we know it'll always be provided in remix
618
619
  loader: route.module.loader ? async (args) => {
@@ -677,19 +678,6 @@ function createStaticHandlerDataRoutes(manifest, future, parentId = "", routesBy
677
678
  });
678
679
  }
679
680
 
680
- // lib/server-runtime/markup.ts
681
- var ESCAPE_LOOKUP = {
682
- "&": "\\u0026",
683
- ">": "\\u003e",
684
- "<": "\\u003c",
685
- "\u2028": "\\u2028",
686
- "\u2029": "\\u2029"
687
- };
688
- var ESCAPE_REGEX = /[&><\u2028\u2029]/g;
689
- function escapeHtml(html) {
690
- return html.replace(ESCAPE_REGEX, (match) => ESCAPE_LOOKUP[match]);
691
- }
692
-
693
681
  // lib/server-runtime/serverHandoff.ts
694
682
  function createServerHandoffString(serverHandoff) {
695
683
  return escapeHtml(JSON.stringify(serverHandoff));
@@ -785,7 +773,7 @@ async function singleFetchAction(build, serverMode, staticHandler, request, hand
785
773
  requestContext: loadContext,
786
774
  skipLoaderErrorBubbling: true,
787
775
  skipRevalidation: true,
788
- unstable_generateMiddlewareResponse: build.future.unstable_middleware ? async (query) => {
776
+ generateMiddlewareResponse: build.future.v8_middleware ? async (query) => {
789
777
  try {
790
778
  let innerResult = await query(handlerRequest);
791
779
  return handleQueryResult(innerResult);
@@ -849,7 +837,7 @@ async function singleFetchLoaders(build, serverMode, staticHandler, request, han
849
837
  requestContext: loadContext,
850
838
  filterMatchesToLoad: (m) => !loadRouteIds || loadRouteIds.has(m.route.id),
851
839
  skipLoaderErrorBubbling: true,
852
- unstable_generateMiddlewareResponse: build.future.unstable_middleware ? async (query) => {
840
+ generateMiddlewareResponse: build.future.v8_middleware ? async (query) => {
853
841
  try {
854
842
  let innerResult = await query(handlerRequest);
855
843
  return handleQueryResult(innerResult);
@@ -1066,15 +1054,15 @@ var createRequestHandler = (build, mode) => {
1066
1054
  request
1067
1055
  });
1068
1056
  };
1069
- if (_build.future.unstable_middleware) {
1070
- if (initialContext && !(initialContext instanceof unstable_RouterContextProvider)) {
1057
+ if (_build.future.v8_middleware) {
1058
+ if (initialContext && !(initialContext instanceof RouterContextProvider)) {
1071
1059
  let error = new Error(
1072
- "Invalid `context` value provided to `handleRequest`. When middleware is enabled you must return an instance of `unstable_RouterContextProvider` from your `getLoadContext` function."
1060
+ "Invalid `context` value provided to `handleRequest`. When middleware is enabled you must return an instance of `RouterContextProvider` from your `getLoadContext` function."
1073
1061
  );
1074
1062
  handleError(error);
1075
1063
  return returnLastResortErrorResponse(error, serverMode);
1076
1064
  }
1077
- loadContext = initialContext || new unstable_RouterContextProvider();
1065
+ loadContext = initialContext || new RouterContextProvider();
1078
1066
  } else {
1079
1067
  loadContext = initialContext || {};
1080
1068
  }
@@ -1302,7 +1290,7 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
1302
1290
  try {
1303
1291
  let result = await staticHandler.query(request, {
1304
1292
  requestContext: loadContext,
1305
- unstable_generateMiddlewareResponse: build.future.unstable_middleware ? async (query) => {
1293
+ generateMiddlewareResponse: build.future.v8_middleware ? async (query) => {
1306
1294
  try {
1307
1295
  let innerResult = await query(request);
1308
1296
  if (!isResponse(innerResult)) {
@@ -1438,7 +1426,7 @@ async function handleResourceRequest(serverMode, build, staticHandler, routeId,
1438
1426
  let result = await staticHandler.queryRoute(request, {
1439
1427
  routeId,
1440
1428
  requestContext: loadContext,
1441
- unstable_generateMiddlewareResponse: build.future.unstable_middleware ? async (queryRoute) => {
1429
+ generateMiddlewareResponse: build.future.v8_middleware ? async (queryRoute) => {
1442
1430
  try {
1443
1431
  let innerResult = await queryRoute(request);
1444
1432
  return handleQueryRouteResult(innerResult);
@@ -1658,22 +1646,27 @@ function createMemorySessionStorage({ cookie } = {}) {
1658
1646
  // lib/href.ts
1659
1647
  function href(path, ...args) {
1660
1648
  let params = args[0];
1661
- return path.split("/").map((segment) => {
1662
- if (segment === "*") {
1663
- return params ? params["*"] : void 0;
1664
- }
1665
- const match = segment.match(/^:([\w-]+)(\?)?/);
1666
- if (!match) return segment;
1667
- const param = match[1];
1668
- const value = params ? params[param] : void 0;
1669
- const isRequired = match[2] === void 0;
1670
- if (isRequired && value === void 0) {
1671
- throw Error(
1672
- `Path '${path}' requires param '${param}' but it was not provided`
1673
- );
1649
+ let result = path.replace(/\/*\*?$/, "").replace(
1650
+ /\/:([\w-]+)(\?)?/g,
1651
+ // same regex as in .\router\utils.ts: compilePath().
1652
+ (_, param, questionMark) => {
1653
+ const isRequired = questionMark === void 0;
1654
+ const value = params ? params[param] : void 0;
1655
+ if (isRequired && value === void 0) {
1656
+ throw new Error(
1657
+ `Path '${path}' requires param '${param}' but it was not provided`
1658
+ );
1659
+ }
1660
+ return value === void 0 ? "" : "/" + value;
1674
1661
  }
1675
- return value;
1676
- }).filter((segment) => segment !== void 0).join("/");
1662
+ );
1663
+ if (path.endsWith("*")) {
1664
+ const value = params ? params["*"] : void 0;
1665
+ if (value !== void 0) {
1666
+ result += "/" + value;
1667
+ }
1668
+ }
1669
+ return result || "/";
1677
1670
  }
1678
1671
 
1679
1672
  // lib/rsc/browser.tsx
@@ -1681,7 +1674,14 @@ import * as React4 from "react";
1681
1674
  import * as ReactDOM from "react-dom";
1682
1675
 
1683
1676
  // lib/dom/ssr/hydration.tsx
1684
- function getHydrationData(state, routes, getRouteInfo, location2, basename, isSpaMode) {
1677
+ function getHydrationData({
1678
+ state,
1679
+ routes,
1680
+ getRouteInfo,
1681
+ location: location2,
1682
+ basename,
1683
+ isSpaMode
1684
+ }) {
1685
1685
  let hydrationData = {
1686
1686
  ...state,
1687
1687
  loaderData: { ...state.loaderData }
@@ -1933,7 +1933,7 @@ function createCallServer({
1933
1933
  function createRouterFromPayload({
1934
1934
  fetchImplementation,
1935
1935
  createFromReadableStream,
1936
- unstable_getContext,
1936
+ getContext,
1937
1937
  payload
1938
1938
  }) {
1939
1939
  const globalVar = window;
@@ -1971,17 +1971,17 @@ function createRouterFromPayload({
1971
1971
  }, []);
1972
1972
  globalVar.__reactRouterDataRouter = createRouter({
1973
1973
  routes,
1974
- unstable_getContext,
1974
+ getContext,
1975
1975
  basename: payload.basename,
1976
1976
  history: createBrowserHistory(),
1977
- hydrationData: getHydrationData(
1978
- {
1977
+ hydrationData: getHydrationData({
1978
+ state: {
1979
1979
  loaderData: payload.loaderData,
1980
1980
  actionData: payload.actionData,
1981
1981
  errors: payload.errors
1982
1982
  },
1983
1983
  routes,
1984
- (routeId) => {
1984
+ getRouteInfo: (routeId) => {
1985
1985
  let match = payload.matches.find((m) => m.id === routeId);
1986
1986
  invariant(match, "Route not found in payload");
1987
1987
  return {
@@ -1990,10 +1990,10 @@ function createRouterFromPayload({
1990
1990
  hasHydrateFallback: match.hydrateFallbackElement != null
1991
1991
  };
1992
1992
  },
1993
- payload.location,
1994
- void 0,
1995
- false
1996
- ),
1993
+ location: payload.location,
1994
+ basename: payload.basename,
1995
+ isSpaMode: false
1996
+ }),
1997
1997
  async patchRoutesOnNavigation({ path, signal }) {
1998
1998
  if (discoveredPaths.has(path)) {
1999
1999
  return;
@@ -2081,7 +2081,7 @@ function createRouterFromPayload({
2081
2081
  routeModules: globalVar.__reactRouterRouteModules
2082
2082
  };
2083
2083
  }
2084
- var renderedRoutesContext = unstable_createContext();
2084
+ var renderedRoutesContext = createContext();
2085
2085
  function getRSCSingleFetchDataStrategy(getRouter, ssr, basename, createFromReadableStream, fetchImplementation) {
2086
2086
  let dataStrategy = getSingleFetchDataStrategyImpl(
2087
2087
  getRouter,
@@ -2108,7 +2108,7 @@ function getRSCSingleFetchDataStrategy(getRouter, ssr, basename, createFromReada
2108
2108
  return M.route.hasComponent && !M.route.element;
2109
2109
  }
2110
2110
  );
2111
- return async (args) => args.unstable_runClientMiddleware(async () => {
2111
+ return async (args) => args.runClientMiddleware(async () => {
2112
2112
  let context = args.context;
2113
2113
  context.set(renderedRoutesContext, []);
2114
2114
  let results = await dataStrategy(args);
@@ -2194,22 +2194,17 @@ function RSCHydratedRouter({
2194
2194
  fetch: fetchImplementation = fetch,
2195
2195
  payload,
2196
2196
  routeDiscovery = "eager",
2197
- unstable_getContext
2197
+ getContext
2198
2198
  }) {
2199
2199
  if (payload.type !== "render") throw new Error("Invalid payload type");
2200
2200
  let { router, routeModules } = React4.useMemo(
2201
2201
  () => createRouterFromPayload({
2202
2202
  payload,
2203
2203
  fetchImplementation,
2204
- unstable_getContext,
2204
+ getContext,
2205
2205
  createFromReadableStream
2206
2206
  }),
2207
- [
2208
- createFromReadableStream,
2209
- payload,
2210
- fetchImplementation,
2211
- unstable_getContext
2212
- ]
2207
+ [createFromReadableStream, payload, fetchImplementation, getContext]
2213
2208
  );
2214
2209
  React4.useEffect(() => {
2215
2210
  setIsHydrated();
@@ -2281,7 +2276,7 @@ function RSCHydratedRouter({
2281
2276
  future: {
2282
2277
  // These flags have no runtime impact so can always be false. If we add
2283
2278
  // flags that drive runtime behavior they'll need to be proxied through.
2284
- unstable_middleware: false,
2279
+ v8_middleware: false,
2285
2280
  unstable_subResourceIntegrity: false
2286
2281
  },
2287
2282
  isSpaMode: false,
@@ -2574,19 +2569,48 @@ async function routeRSCServerRequest({
2574
2569
  if (!serverResponse.body) {
2575
2570
  throw new Error("Missing body in server response");
2576
2571
  }
2572
+ const detectRedirectResponse = serverResponse.clone();
2577
2573
  let serverResponseB = null;
2578
2574
  if (hydrate) {
2579
2575
  serverResponseB = serverResponse.clone();
2580
2576
  }
2581
2577
  const body = serverResponse.body;
2582
- let payloadPromise;
2578
+ let buffer;
2579
+ let streamControllers = [];
2580
+ const createStream = () => {
2581
+ if (!buffer) {
2582
+ buffer = [];
2583
+ return body.pipeThrough(
2584
+ new TransformStream({
2585
+ transform(chunk, controller) {
2586
+ buffer.push(chunk);
2587
+ controller.enqueue(chunk);
2588
+ streamControllers.forEach((c) => c.enqueue(chunk));
2589
+ },
2590
+ flush() {
2591
+ streamControllers.forEach((c) => c.close());
2592
+ streamControllers = [];
2593
+ }
2594
+ })
2595
+ );
2596
+ }
2597
+ return new ReadableStream({
2598
+ start(controller) {
2599
+ buffer.forEach((chunk) => controller.enqueue(chunk));
2600
+ streamControllers.push(controller);
2601
+ }
2602
+ });
2603
+ };
2583
2604
  const getPayload = async () => {
2584
- if (payloadPromise) return payloadPromise;
2585
- payloadPromise = createFromReadableStream(body);
2586
- return payloadPromise;
2605
+ return createFromReadableStream(createStream());
2587
2606
  };
2588
2607
  try {
2589
- const payload = await getPayload();
2608
+ if (!detectRedirectResponse.body) {
2609
+ throw new Error("Failed to clone server response");
2610
+ }
2611
+ const payload = await createFromReadableStream(
2612
+ detectRedirectResponse.body
2613
+ );
2590
2614
  if (serverResponse.status === SINGLE_FETCH_REDIRECT_STATUS && payload.type === "redirect") {
2591
2615
  const headers2 = new Headers(serverResponse.headers);
2592
2616
  headers2.delete("Content-Encoding");
@@ -2697,7 +2721,7 @@ function RSCStaticRouter({ getPayload }) {
2697
2721
  future: {
2698
2722
  // These flags have no runtime impact so can always be false. If we add
2699
2723
  // flags that drive runtime behavior they'll need to be proxied through.
2700
- unstable_middleware: false,
2724
+ v8_middleware: false,
2701
2725
  unstable_subResourceIntegrity: false
2702
2726
  },
2703
2727
  isSpaMode: false,
@@ -212,7 +212,7 @@ type UrlHistoryOptions = {
212
212
  interface Future {
213
213
  }
214
214
  type MiddlewareEnabled = Future extends {
215
- unstable_middleware: infer T extends boolean;
215
+ middleware: infer T extends boolean;
216
216
  } ? T : false;
217
217
 
218
218
  type MaybePromise<T> = T | Promise<T>;
@@ -272,14 +272,14 @@ type Submission = {
272
272
  };
273
273
  /**
274
274
  * A context instance used as the key for the `get`/`set` methods of a
275
- * {@link unstable_RouterContextProvider}. Accepts an optional default
275
+ * {@link RouterContextProvider}. Accepts an optional default
276
276
  * value to be returned if no value has been set.
277
277
  */
278
- interface unstable_RouterContext<T = unknown> {
278
+ interface RouterContext<T = unknown> {
279
279
  defaultValue?: T;
280
280
  }
281
281
  /**
282
- * Creates a type-safe {@link unstable_RouterContext} object that can be used to
282
+ * Creates a type-safe {@link RouterContext} object that can be used to
283
283
  * store and retrieve arbitrary values in [`action`](../../start/framework/route-module#action)s,
284
284
  * [`loader`](../../start/framework/route-module#loader)s, and [middleware](../../how-to/middleware).
285
285
  * Similar to React's [`createContext`](https://react.dev/reference/react/createContext),
@@ -290,11 +290,11 @@ interface unstable_RouterContext<T = unknown> {
290
290
  * when no value has been set will throw an error.
291
291
  *
292
292
  * ```tsx filename=app/context.ts
293
- * import { unstable_createContext } from "react-router";
293
+ * import { createContext } from "react-router";
294
294
  *
295
295
  * // Create a context for user data
296
296
  * export const userContext =
297
- * unstable_createContext<User | null>(null);
297
+ * createContext<User | null>(null);
298
298
  * ```
299
299
  *
300
300
  * ```tsx filename=app/middleware/auth.ts
@@ -332,23 +332,23 @@ interface unstable_RouterContext<T = unknown> {
332
332
  * @mode data
333
333
  * @param defaultValue An optional default value for the context. This value
334
334
  * will be returned if no value has been set for this context.
335
- * @returns A {@link unstable_RouterContext} object that can be used with
335
+ * @returns A {@link RouterContext} object that can be used with
336
336
  * `context.get()` and `context.set()` in [`action`](../../start/framework/route-module#action)s,
337
337
  * [`loader`](../../start/framework/route-module#loader)s, and [middleware](../../how-to/middleware).
338
338
  */
339
- declare function unstable_createContext<T>(defaultValue?: T): unstable_RouterContext<T>;
339
+ declare function createContext<T>(defaultValue?: T): RouterContext<T>;
340
340
  /**
341
341
  * Provides methods for writing/reading values in application context in a
342
342
  * type-safe way. Primarily for usage with [middleware](../../how-to/middleware).
343
343
  *
344
344
  * @example
345
345
  * import {
346
- * unstable_createContext,
347
- * unstable_RouterContextProvider
346
+ * createContext,
347
+ * RouterContextProvider
348
348
  * } from "react-router";
349
349
  *
350
- * const userContext = unstable_createContext<User | null>(null);
351
- * const contextProvider = new unstable_RouterContextProvider();
350
+ * const userContext = createContext<User | null>(null);
351
+ * const contextProvider = new RouterContextProvider();
352
352
  * contextProvider.set(userContext, getUser());
353
353
  * // ^ Type-safe
354
354
  * const user = contextProvider.get(userContext);
@@ -359,13 +359,13 @@ declare function unstable_createContext<T>(defaultValue?: T): unstable_RouterCon
359
359
  * @mode framework
360
360
  * @mode data
361
361
  */
362
- declare class unstable_RouterContextProvider {
362
+ declare class RouterContextProvider {
363
363
  #private;
364
364
  /**
365
- * Create a new `unstable_RouterContextProvider` instance
365
+ * Create a new `RouterContextProvider` instance
366
366
  * @param init An optional initial context map to populate the provider with
367
367
  */
368
- constructor(init?: Map<unstable_RouterContext, unknown>);
368
+ constructor(init?: Map<RouterContext, unknown>);
369
369
  /**
370
370
  * Access a value from the context. If no value has been set for the context,
371
371
  * it will return the context's `defaultValue` if provided, or throw an error
@@ -374,7 +374,7 @@ declare class unstable_RouterContextProvider {
374
374
  * @returns The value for the context, or the context's `defaultValue` if no
375
375
  * value was set
376
376
  */
377
- get<T>(context: unstable_RouterContext<T>): T;
377
+ get<T>(context: RouterContext<T>): T;
378
378
  /**
379
379
  * Set a value for the context. If the context already has a value set, this
380
380
  * will overwrite it.
@@ -383,9 +383,9 @@ declare class unstable_RouterContextProvider {
383
383
  * @param value The value to set for the context
384
384
  * @returns {void}
385
385
  */
386
- set<C extends unstable_RouterContext>(context: C, value: C extends unstable_RouterContext<infer T> ? T : never): void;
386
+ set<C extends RouterContext>(context: C, value: C extends RouterContext<infer T> ? T : never): void;
387
387
  }
388
- type DefaultContext = MiddlewareEnabled extends true ? Readonly<unstable_RouterContextProvider> : any;
388
+ type DefaultContext = MiddlewareEnabled extends true ? Readonly<RouterContextProvider> : any;
389
389
  /**
390
390
  * @private
391
391
  * Arguments passed to route loader/action functions. Same for now but we keep
@@ -420,7 +420,7 @@ interface DataFunctionArgs<Context> {
420
420
  * Route middleware `next` function to call downstream handlers and then complete
421
421
  * middlewares from the bottom-up
422
422
  */
423
- interface unstable_MiddlewareNextFunction<Result = unknown> {
423
+ interface MiddlewareNextFunction<Result = unknown> {
424
424
  (): Promise<Result>;
425
425
  }
426
426
  /**
@@ -429,7 +429,7 @@ interface unstable_MiddlewareNextFunction<Result = unknown> {
429
429
  * a `next` function as the second parameter which will call downstream handlers
430
430
  * and then complete middlewares from the bottom-up
431
431
  */
432
- type unstable_MiddlewareFunction<Result = unknown> = (args: DataFunctionArgs<Readonly<unstable_RouterContextProvider>>, next: unstable_MiddlewareNextFunction<Result>) => MaybePromise<Result | void>;
432
+ type MiddlewareFunction<Result = unknown> = (args: DataFunctionArgs<Readonly<RouterContextProvider>>, next: MiddlewareNextFunction<Result>) => MaybePromise<Result | void>;
433
433
  /**
434
434
  * Arguments passed to loader functions
435
435
  */
@@ -584,7 +584,7 @@ interface DataStrategyFunctionArgs<Context = DefaultContext> extends DataFunctio
584
584
  * Matches for this route extended with Data strategy APIs
585
585
  */
586
586
  matches: DataStrategyMatch[];
587
- unstable_runClientMiddleware: (cb: DataStrategyFunction<Context>) => Promise<Record<string, DataStrategyResult>>;
587
+ runClientMiddleware: (cb: DataStrategyFunction<Context>) => Promise<Record<string, DataStrategyResult>>;
588
588
  /**
589
589
  * The key of the fetcher we are calling `dataStrategy` for, otherwise `null`
590
590
  * for navigational executions
@@ -629,7 +629,7 @@ type UnsupportedLazyRouteObjectKey = "lazy" | "caseSensitive" | "path" | "id" |
629
629
  * onto the route. Either they're meaningful to the router, or they'll get
630
630
  * ignored.
631
631
  */
632
- type UnsupportedLazyRouteFunctionKey = UnsupportedLazyRouteObjectKey | "unstable_middleware";
632
+ type UnsupportedLazyRouteFunctionKey = UnsupportedLazyRouteObjectKey | "middleware";
633
633
  /**
634
634
  * lazy object to load route properties, which can add non-matching
635
635
  * related properties to a route
@@ -652,7 +652,7 @@ type AgnosticBaseRouteObject = {
652
652
  caseSensitive?: boolean;
653
653
  path?: string;
654
654
  id?: string;
655
- unstable_middleware?: unstable_MiddlewareFunction[];
655
+ middleware?: MiddlewareFunction[];
656
656
  loader?: LoaderFunction | boolean;
657
657
  action?: ActionFunction | boolean;
658
658
  hasErrorBoundary?: boolean;
@@ -902,6 +902,11 @@ declare class DataWithResponseInit<D> {
902
902
  * response init.
903
903
  */
904
904
  declare function data<D>(data: D, init?: number | ResponseInit): DataWithResponseInit<D>;
905
+ interface TrackedPromise extends Promise<any> {
906
+ _tracked?: boolean;
907
+ _data?: any;
908
+ _error?: any;
909
+ }
905
910
  type RedirectFunction = (url: string, init?: number | ResponseInit) => Response;
906
911
  /**
907
912
  * A redirect [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response).
@@ -1307,7 +1312,7 @@ interface RouterInit {
1307
1312
  routes: AgnosticRouteObject[];
1308
1313
  history: History;
1309
1314
  basename?: string;
1310
- unstable_getContext?: () => MaybePromise<unstable_RouterContextProvider>;
1315
+ getContext?: () => MaybePromise<RouterContextProvider>;
1311
1316
  mapRouteProperties?: MapRoutePropertiesFunction;
1312
1317
  future?: Partial<FutureConfig>;
1313
1318
  hydrationRouteProperties?: string[];
@@ -1342,7 +1347,7 @@ interface StaticHandler {
1342
1347
  skipLoaderErrorBubbling?: boolean;
1343
1348
  skipRevalidation?: boolean;
1344
1349
  dataStrategy?: DataStrategyFunction<unknown>;
1345
- unstable_generateMiddlewareResponse?: (query: (r: Request, args?: {
1350
+ generateMiddlewareResponse?: (query: (r: Request, args?: {
1346
1351
  filterMatchesToLoad?: (match: AgnosticDataRouteMatch) => boolean;
1347
1352
  }) => Promise<StaticHandlerContext | Response>) => MaybePromise<Response>;
1348
1353
  }): Promise<StaticHandlerContext | Response>;
@@ -1350,7 +1355,7 @@ interface StaticHandler {
1350
1355
  routeId?: string;
1351
1356
  requestContext?: unknown;
1352
1357
  dataStrategy?: DataStrategyFunction<unknown>;
1353
- unstable_generateMiddlewareResponse?: (queryRoute: (r: Request) => Promise<Response>) => MaybePromise<Response>;
1358
+ generateMiddlewareResponse?: (queryRoute: (r: Request) => Promise<Response>) => MaybePromise<Response>;
1354
1359
  }): Promise<any>;
1355
1360
  }
1356
1361
  type ViewTransitionOpts = {
@@ -1597,13 +1602,13 @@ interface MemoryRouterOpts {
1597
1602
  */
1598
1603
  basename?: string;
1599
1604
  /**
1600
- * A function that returns an {@link unstable_RouterContextProvider} instance
1605
+ * A function that returns an {@link RouterContextProvider} instance
1601
1606
  * which is provided as the `context` argument to client [`action`](../../start/data/route-object#action)s,
1602
1607
  * [`loader`](../../start/data/route-object#loader)s and [middleware](../../how-to/middleware).
1603
1608
  * This function is called to generate a fresh `context` instance on each
1604
1609
  * navigation or fetcher call.
1605
1610
  */
1606
- unstable_getContext?: RouterInit["unstable_getContext"];
1611
+ getContext?: RouterInit["getContext"];
1607
1612
  /**
1608
1613
  * Future flags to enable for the router.
1609
1614
  */
@@ -1644,7 +1649,7 @@ interface MemoryRouterOpts {
1644
1649
  * @param {MemoryRouterOpts.basename} opts.basename n/a
1645
1650
  * @param {MemoryRouterOpts.dataStrategy} opts.dataStrategy n/a
1646
1651
  * @param {MemoryRouterOpts.future} opts.future n/a
1647
- * @param {MemoryRouterOpts.unstable_getContext} opts.unstable_getContext n/a
1652
+ * @param {MemoryRouterOpts.getContext} opts.getContext n/a
1648
1653
  * @param {MemoryRouterOpts.hydrationData} opts.hydrationData n/a
1649
1654
  * @param {MemoryRouterOpts.initialEntries} opts.initialEntries n/a
1650
1655
  * @param {MemoryRouterOpts.initialIndex} opts.initialIndex n/a
@@ -2424,7 +2429,7 @@ interface IndexRouteObject {
2424
2429
  caseSensitive?: AgnosticIndexRouteObject["caseSensitive"];
2425
2430
  path?: AgnosticIndexRouteObject["path"];
2426
2431
  id?: AgnosticIndexRouteObject["id"];
2427
- unstable_middleware?: AgnosticIndexRouteObject["unstable_middleware"];
2432
+ middleware?: AgnosticIndexRouteObject["middleware"];
2428
2433
  loader?: AgnosticIndexRouteObject["loader"];
2429
2434
  action?: AgnosticIndexRouteObject["action"];
2430
2435
  hasErrorBoundary?: AgnosticIndexRouteObject["hasErrorBoundary"];
@@ -2444,7 +2449,7 @@ interface NonIndexRouteObject {
2444
2449
  caseSensitive?: AgnosticNonIndexRouteObject["caseSensitive"];
2445
2450
  path?: AgnosticNonIndexRouteObject["path"];
2446
2451
  id?: AgnosticNonIndexRouteObject["id"];
2447
- unstable_middleware?: AgnosticNonIndexRouteObject["unstable_middleware"];
2452
+ middleware?: AgnosticNonIndexRouteObject["middleware"];
2448
2453
  loader?: AgnosticNonIndexRouteObject["loader"];
2449
2454
  action?: AgnosticNonIndexRouteObject["action"];
2450
2455
  hasErrorBoundary?: AgnosticNonIndexRouteObject["hasErrorBoundary"];
@@ -2489,6 +2494,8 @@ type ViewTransitionContextObject = {
2489
2494
  declare const ViewTransitionContext: React.Context<ViewTransitionContextObject>;
2490
2495
  type FetchersContextObject = Map<string, any>;
2491
2496
  declare const FetchersContext: React.Context<FetchersContextObject>;
2497
+ declare const AwaitContext: React.Context<TrackedPromise | null>;
2498
+ declare const AwaitContextProvider: (props: React.ComponentProps<typeof AwaitContext.Provider>) => React.FunctionComponentElement<React.ProviderProps<TrackedPromise | null>>;
2492
2499
  interface NavigateOptions {
2493
2500
  /** Replace the current entry in the history stack instead of pushing a new one */
2494
2501
  replace?: boolean;
@@ -2538,4 +2545,4 @@ interface RouteContextObject {
2538
2545
  }
2539
2546
  declare const RouteContext: React.Context<RouteContextObject>;
2540
2547
 
2541
- export { type DataStrategyMatch as $, type ActionFunctionArgs as A, type BlockerFunction as B, type PatchRoutesOnNavigationFunction as C, type DataStrategyResult as D, type ErrorBoundaryType as E, type DataRouteObject as F, type StaticHandler as G, type HydrationState as H, type InitialEntry as I, type GetScrollPositionFunction as J, type GetScrollRestorationKeyFunction as K, type Location as L, type MiddlewareEnabled as M, type NavigateOptions as N, type StaticHandlerContext as O, type Params as P, type Fetcher as Q, type RouterProviderProps as R, type ShouldRevalidateFunction as S, type To as T, type UIMatch as U, type NavigationStates as V, type RouterSubscriber as W, type RouterNavigateOptions as X, type RouterFetchOptions as Y, type RevalidationState as Z, type DataStrategyFunctionArgs as _, type RouterInit as a, mapRouteProperties as a$, type ErrorResponse as a0, type FormEncType as a1, type FormMethod as a2, type HTMLFormMethod as a3, type LazyRouteFunction as a4, type PathParam as a5, type RedirectFunction as a6, type unstable_RouterContext as a7, type ShouldRevalidateFunctionArgs as a8, unstable_createContext as a9, type RouterProps as aA, type RoutesProps as aB, Await as aC, MemoryRouter as aD, Navigate as aE, Outlet as aF, Route as aG, Router as aH, RouterProvider as aI, Routes as aJ, createMemoryRouter as aK, createRoutesFromChildren as aL, createRoutesFromElements as aM, renderMatches as aN, type Future as aO, createBrowserHistory as aP, invariant as aQ, createRouter as aR, ErrorResponseImpl as aS, DataRouterContext as aT, DataRouterStateContext as aU, FetchersContext as aV, LocationContext as aW, NavigationContext as aX, RouteContext as aY, ViewTransitionContext as aZ, hydrationRouteProperties as a_, createPath as aa, parsePath as ab, IDLE_NAVIGATION as ac, IDLE_FETCHER as ad, IDLE_BLOCKER as ae, data as af, generatePath as ag, isRouteErrorResponse as ah, matchPath as ai, matchRoutes as aj, redirect as ak, redirectDocument as al, replace as am, resolvePath as an, type Navigator as ao, type PatchRoutesOnNavigationFunctionArgs as ap, type RouteMatch as aq, type AwaitProps as ar, type IndexRouteProps as as, type LayoutRouteProps as at, type MemoryRouterOpts as au, type MemoryRouterProps as av, type NavigateProps as aw, type OutletProps as ax, type PathRouteProps as ay, type RouteProps as az, type unstable_MiddlewareNextFunction as b, WithComponentProps as b0, withComponentProps as b1, WithHydrateFallbackProps as b2, withHydrateFallbackProps as b3, WithErrorBoundaryProps as b4, withErrorBoundaryProps as b5, type RouteManifest as b6, type History as b7, type FutureConfig as b8, type CreateStaticHandlerOptions as b9, type LoaderFunctionArgs as c, type ActionFunction as d, type LoaderFunction as e, type DataRouteMatch as f, type unstable_MiddlewareFunction as g, unstable_RouterContextProvider as h, DataWithResponseInit as i, type Router$1 as j, type DataStrategyFunction as k, type Blocker as l, type RelativeRoutingType as m, type ParamParseKey as n, type Path as o, type PathPattern as p, type PathMatch as q, type Navigation as r, Action as s, type RouteObject as t, type unstable_ClientOnErrorFunction as u, type IndexRouteObject as v, type RouteComponentType as w, type HydrateFallbackType as x, type NonIndexRouteObject as y, type RouterState as z };
2548
+ export { type DataStrategyMatch as $, type ActionFunctionArgs as A, type BlockerFunction as B, type PatchRoutesOnNavigationFunction as C, type DataStrategyResult as D, type ErrorBoundaryType as E, type DataRouteObject as F, type StaticHandler as G, type HydrationState as H, type InitialEntry as I, type GetScrollPositionFunction as J, type GetScrollRestorationKeyFunction as K, type Location as L, type MiddlewareNextFunction as M, type NavigateOptions as N, type StaticHandlerContext as O, type Params as P, type Fetcher as Q, type RouterProviderProps as R, type ShouldRevalidateFunction as S, type To as T, type UIMatch as U, type NavigationStates as V, type RouterSubscriber as W, type RouterNavigateOptions as X, type RouterFetchOptions as Y, type RevalidationState as Z, type DataStrategyFunctionArgs as _, type RouterInit as a, hydrationRouteProperties as a$, type ErrorResponse as a0, type FormEncType as a1, type FormMethod as a2, type HTMLFormMethod as a3, type LazyRouteFunction as a4, type PathParam as a5, type RedirectFunction as a6, type RouterContext as a7, type ShouldRevalidateFunctionArgs as a8, createContext as a9, type RouteProps as aA, type RouterProps as aB, type RoutesProps as aC, Await as aD, MemoryRouter as aE, Navigate as aF, Outlet as aG, Route as aH, Router as aI, RouterProvider as aJ, Routes as aK, createMemoryRouter as aL, createRoutesFromChildren as aM, createRoutesFromElements as aN, renderMatches as aO, type Future as aP, createBrowserHistory as aQ, invariant as aR, createRouter as aS, ErrorResponseImpl as aT, DataRouterContext as aU, DataRouterStateContext as aV, FetchersContext as aW, LocationContext as aX, NavigationContext as aY, RouteContext as aZ, ViewTransitionContext as a_, createPath as aa, parsePath as ab, IDLE_NAVIGATION as ac, IDLE_FETCHER as ad, IDLE_BLOCKER as ae, data as af, generatePath as ag, isRouteErrorResponse as ah, matchPath as ai, matchRoutes as aj, redirect as ak, redirectDocument as al, replace as am, resolvePath as an, type Navigator as ao, type PatchRoutesOnNavigationFunctionArgs as ap, type RouteMatch as aq, AwaitContextProvider as ar, type AwaitProps as as, type IndexRouteProps as at, type LayoutRouteProps as au, type MemoryRouterOpts as av, type MemoryRouterProps as aw, type NavigateProps as ax, type OutletProps as ay, type PathRouteProps as az, type LoaderFunctionArgs as b, mapRouteProperties as b0, WithComponentProps as b1, withComponentProps as b2, WithHydrateFallbackProps as b3, withHydrateFallbackProps as b4, WithErrorBoundaryProps as b5, withErrorBoundaryProps as b6, type RouteManifest as b7, type History as b8, type FutureConfig as b9, type CreateStaticHandlerOptions as ba, type ActionFunction as c, type LoaderFunction as d, type DataRouteMatch as e, type MiddlewareFunction as f, RouterContextProvider as g, DataWithResponseInit as h, type MiddlewareEnabled as i, type Router$1 as j, type DataStrategyFunction as k, type Blocker as l, type RelativeRoutingType as m, type ParamParseKey as n, type Path as o, type PathPattern as p, type PathMatch as q, type Navigation as r, Action as s, type RouteObject as t, type unstable_ClientOnErrorFunction as u, type IndexRouteObject as v, type RouteComponentType as w, type HydrateFallbackType as x, type NonIndexRouteObject as y, type RouterState as z };
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { R as RouterProviderProps$1, a as RouterInit, u as unstable_ClientOnErrorFunction } from './context-jKip1TFB.mjs';
2
+ import { R as RouterProviderProps$1, a as RouterInit, u as unstable_ClientOnErrorFunction } from './context-BH6Jwdoy.mjs';
3
3
  import './browser-z32v5KVN.mjs';
4
4
 
5
5
  type RouterProviderProps = Omit<RouterProviderProps$1, "flushSync">;
@@ -17,7 +17,7 @@ interface HydratedRouterProps {
17
17
  * [`clientAction`](../../start/framework/route-module#clientAction)/[`clientLoader`](../../start/framework/route-module#clientLoader)
18
18
  * functions
19
19
  */
20
- unstable_getContext?: RouterInit["unstable_getContext"];
20
+ getContext?: RouterInit["getContext"];
21
21
  /**
22
22
  * An error handler function that will be called for any loader/action/render
23
23
  * errors that are encountered in your application. This is useful for
@@ -45,7 +45,7 @@ interface HydratedRouterProps {
45
45
  * @category Framework Routers
46
46
  * @mode framework
47
47
  * @param props Props
48
- * @param {dom.HydratedRouterProps.unstable_getContext} props.unstable_getContext n/a
48
+ * @param {dom.HydratedRouterProps.getContext} props.getContext n/a
49
49
  * @param {dom.HydratedRouterProps.unstable_onError} props.unstable_onError n/a
50
50
  * @returns A React element that represents the hydrated application.
51
51
  */
@@ -16,7 +16,7 @@ interface HydratedRouterProps {
16
16
  * [`clientAction`](../../start/framework/route-module#clientAction)/[`clientLoader`](../../start/framework/route-module#clientLoader)
17
17
  * functions
18
18
  */
19
- unstable_getContext?: RouterInit["unstable_getContext"];
19
+ getContext?: RouterInit["getContext"];
20
20
  /**
21
21
  * An error handler function that will be called for any loader/action/render
22
22
  * errors that are encountered in your application. This is useful for
@@ -44,7 +44,7 @@ interface HydratedRouterProps {
44
44
  * @category Framework Routers
45
45
  * @mode framework
46
46
  * @param props Props
47
- * @param {dom.HydratedRouterProps.unstable_getContext} props.unstable_getContext n/a
47
+ * @param {dom.HydratedRouterProps.getContext} props.getContext n/a
48
48
  * @param {dom.HydratedRouterProps.unstable_onError} props.unstable_onError n/a
49
49
  * @returns A React element that represents the hydrated application.
50
50
  */