react-router 7.9.4 → 7.9.6

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 (74) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/dist/development/browser-BbBXFHbO.d.ts +310 -0
  3. package/dist/development/browser-C07r42Tt.d.mts +310 -0
  4. package/dist/development/{chunk-OIYGIGL5.mjs → chunk-4WY6JWTD.mjs} +458 -43
  5. package/dist/development/{chunk-DI2QHYMJ.js → chunk-AMVS5XVJ.js} +1314 -138
  6. package/dist/development/{chunk-WY5IRSCW.mjs → chunk-G3INQAYP.mjs} +197 -857
  7. package/dist/development/chunk-O4JVZSOY.js +1310 -0
  8. package/dist/development/chunk-PZWDWJAY.js +188 -0
  9. package/dist/development/dom-export.d.mts +103 -6
  10. package/dist/development/dom-export.d.ts +103 -4
  11. package/dist/development/dom-export.js +708 -20
  12. package/dist/development/dom-export.mjs +692 -11
  13. package/dist/{production/index-react-server-client-BbRcBjrA.d.ts → development/index-react-server-client-Da3kmxNd.d.ts} +195 -135
  14. package/dist/{production/index-react-server-client-BIz4AUNd.d.mts → development/index-react-server-client-rcoGPJhU.d.mts} +137 -78
  15. package/dist/development/index-react-server-client.d.mts +2 -3
  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.d.mts +107 -3
  20. package/dist/development/index-react-server.d.ts +107 -3
  21. package/dist/development/index-react-server.js +259 -13
  22. package/dist/development/index-react-server.mjs +259 -13
  23. package/dist/development/index.d.mts +14 -320
  24. package/dist/development/index.d.ts +14 -362
  25. package/dist/development/index.js +146 -962
  26. package/dist/development/index.mjs +3 -9
  27. package/dist/development/{routeModules-D5iJ6JYT.d.ts → instrumentation-Unc20tLk.d.ts} +178 -25
  28. package/dist/development/lib/types/internal.d.mts +2 -3
  29. package/dist/development/lib/types/internal.d.ts +2 -2
  30. package/dist/development/lib/types/internal.js +1 -1
  31. package/dist/development/lib/types/internal.mjs +1 -1
  32. package/dist/{production/register-C34pU-in.d.ts → development/register-BpU9rFBJ.d.ts} +1 -1
  33. package/dist/development/{register-CI4bTprK.d.mts → register-QkB3HGjm.d.mts} +1 -1
  34. package/dist/{production/context-DSyS5mLj.d.mts → development/router-CAvh_Drx.d.mts} +1877 -1254
  35. package/dist/production/browser-BbBXFHbO.d.ts +310 -0
  36. package/dist/production/browser-C07r42Tt.d.mts +310 -0
  37. package/dist/production/{chunk-4E5LHRQP.js → chunk-EAIF67OW.js} +1314 -138
  38. package/dist/production/{chunk-FR6HSPLK.mjs → chunk-FDUMZGKM.mjs} +197 -857
  39. package/dist/production/{chunk-3TADTUL4.mjs → chunk-FUSXQSWG.mjs} +458 -43
  40. package/dist/production/chunk-G5A35OQU.js +188 -0
  41. package/dist/production/chunk-QN64DHI4.js +1310 -0
  42. package/dist/production/dom-export.d.mts +103 -6
  43. package/dist/production/dom-export.d.ts +103 -4
  44. package/dist/production/dom-export.js +708 -20
  45. package/dist/production/dom-export.mjs +692 -11
  46. package/dist/{development/index-react-server-client-BIz4AUNd.d.mts → production/index-react-server-client-Da3kmxNd.d.ts} +137 -78
  47. package/dist/{development/index-react-server-client-BbRcBjrA.d.ts → production/index-react-server-client-rcoGPJhU.d.mts} +195 -135
  48. package/dist/production/index-react-server-client.d.mts +2 -3
  49. package/dist/production/index-react-server-client.d.ts +2 -2
  50. package/dist/production/index-react-server-client.js +4 -4
  51. package/dist/production/index-react-server-client.mjs +2 -2
  52. package/dist/production/index-react-server.d.mts +107 -3
  53. package/dist/production/index-react-server.d.ts +107 -3
  54. package/dist/production/index-react-server.js +259 -13
  55. package/dist/production/index-react-server.mjs +259 -13
  56. package/dist/production/index.d.mts +14 -320
  57. package/dist/production/index.d.ts +14 -362
  58. package/dist/production/index.js +146 -962
  59. package/dist/production/index.mjs +3 -9
  60. package/dist/production/{routeModules-D5iJ6JYT.d.ts → instrumentation-Unc20tLk.d.ts} +178 -25
  61. package/dist/production/lib/types/internal.d.mts +2 -3
  62. package/dist/production/lib/types/internal.d.ts +2 -2
  63. package/dist/production/lib/types/internal.js +1 -1
  64. package/dist/production/lib/types/internal.mjs +1 -1
  65. package/dist/{development/register-C34pU-in.d.ts → production/register-BpU9rFBJ.d.ts} +1 -1
  66. package/dist/production/{register-CI4bTprK.d.mts → register-QkB3HGjm.d.mts} +1 -1
  67. package/dist/{development/context-DSyS5mLj.d.mts → production/router-CAvh_Drx.d.mts} +1877 -1254
  68. package/package.json +1 -1
  69. package/dist/development/browser-z32v5KVN.d.mts +0 -46
  70. package/dist/development/chunk-72XNTZCV.js +0 -2089
  71. package/dist/development/route-data-DZQOUSqV.d.mts +0 -473
  72. package/dist/production/browser-z32v5KVN.d.mts +0 -46
  73. package/dist/production/chunk-WNLQ53P5.js +0 -2089
  74. package/dist/production/route-data-DZQOUSqV.d.mts +0 -473
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
- import { R as RouterProviderProps$1, a as RouterInit, u as unstable_ClientOnErrorFunction } from './context-DSyS5mLj.mjs';
3
- import './browser-z32v5KVN.mjs';
2
+ import { f as RouterProviderProps$1, e as RouterInit, u as unstable_ClientInstrumentation, g as unstable_ClientOnErrorFunction } from './router-CAvh_Drx.mjs';
3
+ 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-C07r42Tt.mjs';
4
4
 
5
5
  type RouterProviderProps = Omit<RouterProviderProps$1, "flushSync">;
6
6
  declare function RouterProvider(props: Omit<RouterProviderProps, "flushSync">): React.JSX.Element;
@@ -12,12 +12,64 @@ declare function RouterProvider(props: Omit<RouterProviderProps, "flushSync">):
12
12
  */
13
13
  interface HydratedRouterProps {
14
14
  /**
15
- * Context object to be passed through to {@link createBrowserRouter} and made
16
- * available to
15
+ * Context factory function to be passed through to {@link createBrowserRouter}.
16
+ * This function will be called to create a fresh `context` instance on each
17
+ * navigation/fetch and made available to
17
18
  * [`clientAction`](../../start/framework/route-module#clientAction)/[`clientLoader`](../../start/framework/route-module#clientLoader)
18
- * functions
19
+ * functions.
19
20
  */
20
21
  getContext?: RouterInit["getContext"];
22
+ /**
23
+ * Array of instrumentation objects allowing you to instrument the router and
24
+ * individual routes prior to router initialization (and on any subsequently
25
+ * added routes via `route.lazy` or `patchRoutesOnNavigation`). This is
26
+ * mostly useful for observability such as wrapping navigations, fetches,
27
+ * as well as route loaders/actions/middlewares with logging and/or performance
28
+ * tracing.
29
+ *
30
+ * ```tsx
31
+ * startTransition(() => {
32
+ * hydrateRoot(
33
+ * document,
34
+ * <HydratedRouter unstable_instrumentations={[logging]} />
35
+ * );
36
+ * });
37
+ *
38
+ * const logging = {
39
+ * router({ instrument }) {
40
+ * instrument({
41
+ * navigate: (impl, { to }) => logExecution(`navigate ${to}`, impl),
42
+ * fetch: (impl, { to }) => logExecution(`fetch ${to}`, impl)
43
+ * });
44
+ * },
45
+ * route({ instrument, id }) {
46
+ * instrument({
47
+ * middleware: (impl, { request }) => logExecution(
48
+ * `middleware ${request.url} (route ${id})`,
49
+ * impl
50
+ * ),
51
+ * loader: (impl, { request }) => logExecution(
52
+ * `loader ${request.url} (route ${id})`,
53
+ * impl
54
+ * ),
55
+ * action: (impl, { request }) => logExecution(
56
+ * `action ${request.url} (route ${id})`,
57
+ * impl
58
+ * ),
59
+ * })
60
+ * }
61
+ * };
62
+ *
63
+ * async function logExecution(label: string, impl: () => Promise<void>) {
64
+ * let start = performance.now();
65
+ * console.log(`start ${label}`);
66
+ * await impl();
67
+ * let duration = Math.round(performance.now() - start);
68
+ * console.log(`end ${label} (${duration}ms)`);
69
+ * }
70
+ * ```
71
+ */
72
+ unstable_instrumentations?: unstable_ClientInstrumentation[];
21
73
  /**
22
74
  * An error handler function that will be called for any loader/action/render
23
75
  * errors that are encountered in your application. This is useful for
@@ -51,4 +103,49 @@ interface HydratedRouterProps {
51
103
  */
52
104
  declare function HydratedRouter(props: HydratedRouterProps): React.JSX.Element;
53
105
 
54
- export { HydratedRouter, type HydratedRouterProps, RouterProvider, type RouterProviderProps };
106
+ declare global {
107
+ interface Window {
108
+ __FLIGHT_DATA: any[];
109
+ }
110
+ }
111
+ /**
112
+ * Get the prerendered [RSC](https://react.dev/reference/rsc/server-components)
113
+ * stream for hydration. Usually passed directly to your
114
+ * `react-server-dom-xyz/client`'s `createFromReadableStream`.
115
+ *
116
+ * @example
117
+ * import { startTransition, StrictMode } from "react";
118
+ * import { hydrateRoot } from "react-dom/client";
119
+ * import {
120
+ * unstable_getRSCStream as getRSCStream,
121
+ * unstable_RSCHydratedRouter as RSCHydratedRouter,
122
+ * } from "react-router";
123
+ * import type { unstable_RSCPayload as RSCPayload } from "react-router";
124
+ *
125
+ * createFromReadableStream(getRSCStream()).then(
126
+ * (payload: RSCServerPayload) => {
127
+ * startTransition(async () => {
128
+ * hydrateRoot(
129
+ * document,
130
+ * <StrictMode>
131
+ * <RSCHydratedRouter {...props} />
132
+ * </StrictMode>,
133
+ * {
134
+ * // Options
135
+ * }
136
+ * );
137
+ * });
138
+ * }
139
+ * );
140
+ *
141
+ * @name unstable_getRSCStream
142
+ * @public
143
+ * @category RSC
144
+ * @mode data
145
+ * @returns A [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream)
146
+ * that contains the [RSC](https://react.dev/reference/rsc/server-components)
147
+ * data for hydration.
148
+ */
149
+ declare function getRSCStream(): ReadableStream;
150
+
151
+ export { HydratedRouter, type HydratedRouterProps, RouterProvider, type RouterProviderProps, getRSCStream as unstable_getRSCStream };
@@ -1,5 +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-Unc20tLk.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-BbBXFHbO.js';
3
5
 
4
6
  type RouterProviderProps = Omit<RouterProviderProps$1, "flushSync">;
5
7
  declare function RouterProvider(props: Omit<RouterProviderProps, "flushSync">): React.JSX.Element;
@@ -11,12 +13,64 @@ declare function RouterProvider(props: Omit<RouterProviderProps, "flushSync">):
11
13
  */
12
14
  interface HydratedRouterProps {
13
15
  /**
14
- * Context object to be passed through to {@link createBrowserRouter} and made
15
- * available to
16
+ * Context factory function to be passed through to {@link createBrowserRouter}.
17
+ * This function will be called to create a fresh `context` instance on each
18
+ * navigation/fetch and made available to
16
19
  * [`clientAction`](../../start/framework/route-module#clientAction)/[`clientLoader`](../../start/framework/route-module#clientLoader)
17
- * functions
20
+ * functions.
18
21
  */
19
22
  getContext?: RouterInit["getContext"];
23
+ /**
24
+ * Array of instrumentation objects allowing you to instrument the router and
25
+ * individual routes prior to router initialization (and on any subsequently
26
+ * added routes via `route.lazy` or `patchRoutesOnNavigation`). This is
27
+ * mostly useful for observability such as wrapping navigations, fetches,
28
+ * as well as route loaders/actions/middlewares with logging and/or performance
29
+ * tracing.
30
+ *
31
+ * ```tsx
32
+ * startTransition(() => {
33
+ * hydrateRoot(
34
+ * document,
35
+ * <HydratedRouter unstable_instrumentations={[logging]} />
36
+ * );
37
+ * });
38
+ *
39
+ * const logging = {
40
+ * router({ instrument }) {
41
+ * instrument({
42
+ * navigate: (impl, { to }) => logExecution(`navigate ${to}`, impl),
43
+ * fetch: (impl, { to }) => logExecution(`fetch ${to}`, impl)
44
+ * });
45
+ * },
46
+ * route({ instrument, id }) {
47
+ * instrument({
48
+ * middleware: (impl, { request }) => logExecution(
49
+ * `middleware ${request.url} (route ${id})`,
50
+ * impl
51
+ * ),
52
+ * loader: (impl, { request }) => logExecution(
53
+ * `loader ${request.url} (route ${id})`,
54
+ * impl
55
+ * ),
56
+ * action: (impl, { request }) => logExecution(
57
+ * `action ${request.url} (route ${id})`,
58
+ * impl
59
+ * ),
60
+ * })
61
+ * }
62
+ * };
63
+ *
64
+ * async function logExecution(label: string, impl: () => Promise<void>) {
65
+ * let start = performance.now();
66
+ * console.log(`start ${label}`);
67
+ * await impl();
68
+ * let duration = Math.round(performance.now() - start);
69
+ * console.log(`end ${label} (${duration}ms)`);
70
+ * }
71
+ * ```
72
+ */
73
+ unstable_instrumentations?: unstable_ClientInstrumentation[];
20
74
  /**
21
75
  * An error handler function that will be called for any loader/action/render
22
76
  * errors that are encountered in your application. This is useful for
@@ -50,4 +104,49 @@ interface HydratedRouterProps {
50
104
  */
51
105
  declare function HydratedRouter(props: HydratedRouterProps): React.JSX.Element;
52
106
 
53
- export { HydratedRouter, type HydratedRouterProps, RouterProvider, type RouterProviderProps };
107
+ declare global {
108
+ interface Window {
109
+ __FLIGHT_DATA: any[];
110
+ }
111
+ }
112
+ /**
113
+ * Get the prerendered [RSC](https://react.dev/reference/rsc/server-components)
114
+ * stream for hydration. Usually passed directly to your
115
+ * `react-server-dom-xyz/client`'s `createFromReadableStream`.
116
+ *
117
+ * @example
118
+ * import { startTransition, StrictMode } from "react";
119
+ * import { hydrateRoot } from "react-dom/client";
120
+ * import {
121
+ * unstable_getRSCStream as getRSCStream,
122
+ * unstable_RSCHydratedRouter as RSCHydratedRouter,
123
+ * } from "react-router";
124
+ * import type { unstable_RSCPayload as RSCPayload } from "react-router";
125
+ *
126
+ * createFromReadableStream(getRSCStream()).then(
127
+ * (payload: RSCServerPayload) => {
128
+ * startTransition(async () => {
129
+ * hydrateRoot(
130
+ * document,
131
+ * <StrictMode>
132
+ * <RSCHydratedRouter {...props} />
133
+ * </StrictMode>,
134
+ * {
135
+ * // Options
136
+ * }
137
+ * );
138
+ * });
139
+ * }
140
+ * );
141
+ *
142
+ * @name unstable_getRSCStream
143
+ * @public
144
+ * @category RSC
145
+ * @mode data
146
+ * @returns A [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream)
147
+ * that contains the [RSC](https://react.dev/reference/rsc/server-components)
148
+ * data for hydration.
149
+ */
150
+ declare function getRSCStream(): ReadableStream;
151
+
152
+ export { HydratedRouter, type HydratedRouterProps, RouterProvider, type RouterProviderProps, getRSCStream as unstable_getRSCStream };