react-router 0.0.0-experimental-b588f7e → 0.0.0-experimental-23decd7bc

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 +28 -0
  2. package/dist/development/browser-CmIT056Z.d.mts +154 -0
  3. package/dist/development/chunk-3E3CD4NY.mjs +2669 -0
  4. package/dist/development/{chunk-3HOZPCHX.mjs → chunk-GJVCYY62.mjs} +1445 -3021
  5. package/dist/development/chunk-H2M6MMUH.js +10007 -0
  6. package/dist/development/chunk-I3MHZ4NU.js +21 -0
  7. package/dist/development/components-CwtESh53.d.mts +816 -0
  8. package/dist/development/dom-export.d.mts +4 -2
  9. package/dist/development/dom-export.js +53 -72
  10. package/dist/development/dom-export.mjs +7 -4
  11. package/dist/development/index-react-server-client-CzKQ01cq.d.mts +1360 -0
  12. package/dist/development/{lib-oW7CoPA6.d.mts → index-react-server-client-unV28389.d.ts} +39 -39
  13. package/dist/development/index-react-server-client.d.mts +4 -0
  14. package/dist/development/index-react-server-client.d.ts +3 -0
  15. package/dist/development/index-react-server-client.js +54 -0
  16. package/dist/development/index-react-server-client.mjs +53 -0
  17. package/dist/development/index-react-server.d.mts +1861 -0
  18. package/dist/development/index-react-server.d.ts +1861 -0
  19. package/dist/development/index-react-server.js +3137 -0
  20. package/dist/development/index-react-server.mjs +3025 -0
  21. package/dist/development/index.d.mts +32 -46
  22. package/dist/development/index.d.ts +191 -2223
  23. package/dist/development/index.js +2577 -11464
  24. package/dist/development/index.mjs +33 -22
  25. package/dist/development/lib/types/internal.d.mts +8 -72
  26. package/dist/development/lib/types/internal.d.ts +8 -71
  27. package/dist/development/lib/types/internal.js +2 -20
  28. package/dist/development/lib/types/internal.mjs +1 -1
  29. package/dist/{production/register-DeIo2iHO.d.mts → development/register-DiOIlEq5.d.mts} +1 -1
  30. package/dist/development/{register-DeIo2iHO.d.mts → register-DiOIlEq5.d.ts} +1 -1
  31. package/dist/development/{route-data-ByAYLHuM.d.mts → route-data-Csr8hE3v.d.mts} +80 -3
  32. package/dist/{production/register-DCE0tH5m.d.ts → development/route-data-x_b_BLCv.d.ts} +90 -36
  33. package/dist/production/browser-CmIT056Z.d.mts +154 -0
  34. package/dist/production/chunk-7TUGB72O.js +10007 -0
  35. package/dist/production/chunk-I3MHZ4NU.js +21 -0
  36. package/dist/production/chunk-XNTCWHOK.mjs +2669 -0
  37. package/dist/production/{chunk-UROK22QK.mjs → chunk-YWCG2M57.mjs} +1445 -3021
  38. package/dist/production/components-CwtESh53.d.mts +816 -0
  39. package/dist/production/dom-export.d.mts +4 -2
  40. package/dist/production/dom-export.js +53 -72
  41. package/dist/production/dom-export.mjs +7 -4
  42. package/dist/production/index-react-server-client-CzKQ01cq.d.mts +1360 -0
  43. package/dist/production/{lib-oW7CoPA6.d.mts → index-react-server-client-unV28389.d.ts} +39 -39
  44. package/dist/production/index-react-server-client.d.mts +4 -0
  45. package/dist/production/index-react-server-client.d.ts +3 -0
  46. package/dist/production/index-react-server-client.js +54 -0
  47. package/dist/production/index-react-server-client.mjs +53 -0
  48. package/dist/production/index-react-server.d.mts +1861 -0
  49. package/dist/production/index-react-server.d.ts +1861 -0
  50. package/dist/production/index-react-server.js +3137 -0
  51. package/dist/production/index-react-server.mjs +3025 -0
  52. package/dist/production/index.d.mts +32 -46
  53. package/dist/production/index.d.ts +191 -2223
  54. package/dist/production/index.js +2577 -11464
  55. package/dist/production/index.mjs +33 -22
  56. package/dist/production/lib/types/internal.d.mts +8 -72
  57. package/dist/production/lib/types/internal.d.ts +8 -71
  58. package/dist/production/lib/types/internal.js +2 -20
  59. package/dist/production/lib/types/internal.mjs +1 -1
  60. package/dist/production/register-DiOIlEq5.d.mts +24 -0
  61. package/dist/production/register-DiOIlEq5.d.ts +24 -0
  62. package/dist/{development/register-DCE0tH5m.d.ts → production/route-data-Csr8hE3v.d.mts} +80 -26
  63. package/dist/production/{route-data-ByAYLHuM.d.mts → route-data-x_b_BLCv.d.ts} +90 -13
  64. package/package.json +49 -10
@@ -1,6 +1,16 @@
1
1
  import * as React from 'react';
2
2
  import { ComponentType, ReactElement } from 'react';
3
3
 
4
+ /**
5
+ * An augmentable interface users can modify in their app-code to opt into
6
+ * future-flag-specific types
7
+ */
8
+ interface Future {
9
+ }
10
+ type MiddlewareEnabled = Future extends {
11
+ unstable_middleware: infer T extends boolean;
12
+ } ? T : false;
13
+
4
14
  /**
5
15
  * Actions represent the type of change to a location value.
6
16
  */
@@ -206,16 +216,6 @@ type UrlHistoryOptions = {
206
216
  v5Compat?: boolean;
207
217
  };
208
218
 
209
- /**
210
- * An augmentable interface users can modify in their app-code to opt into
211
- * future-flag-specific types
212
- */
213
- interface Future {
214
- }
215
- type MiddlewareEnabled = Future extends {
216
- unstable_middleware: infer T extends boolean;
217
- } ? T : false;
218
-
219
219
  type MaybePromise<T> = T | Promise<T>;
220
220
  /**
221
221
  * Map of routeId -> data returned from a loader/action/error
@@ -912,8 +912,11 @@ interface Router {
912
912
  * @param routeId The parent route id or a callback function accepting `patch`
913
913
  * to perform batch patching
914
914
  * @param children The additional children routes
915
+ * @param unstable_allowElementMutations Allow mutation or route elements on
916
+ * existing routes. Intended for RSC-usage
917
+ * only.
915
918
  */
916
- patchRoutes(routeId: string | null, children: AgnosticRouteObject[]): void;
919
+ patchRoutes(routeId: string | null, children: AgnosticRouteObject[], unstable_allowElementMutations?: boolean): void;
917
920
  /**
918
921
  * @private
919
922
  * PRIVATE - DO NOT USE
@@ -922,6 +925,13 @@ interface Router {
922
925
  * TODO: Replace this with granular route update APIs (addRoute, updateRoute, deleteRoute)
923
926
  */
924
927
  _internalSetRoutes(routes: AgnosticRouteObject[]): void;
928
+ /**
929
+ * @private
930
+ * PRIVATE - DO NOT USE
931
+ *
932
+ * Cause subscribers to re-render. This is used to force a re-render.
933
+ */
934
+ _internalSetStateDoNotUseOrYouWillBreakYourApp(state: Partial<RouterState>): void;
925
935
  /**
926
936
  * @private
927
937
  * PRIVATE - DO NOT USE
@@ -1045,6 +1055,7 @@ interface StaticHandler {
1045
1055
  skipRevalidation?: boolean;
1046
1056
  dataStrategy?: DataStrategyFunction<unknown>;
1047
1057
  unstable_respond?: (staticContext: StaticHandlerContext) => MaybePromise<Response>;
1058
+ unstable_stream?: (context: unstable_RouterContextProvider, query: (r: Request) => Promise<StaticHandlerContext | Response>) => MaybePromise<Response>;
1048
1059
  }): Promise<StaticHandlerContext | Response>;
1049
1060
  queryRoute(request: Request, opts?: {
1050
1061
  routeId?: string;
@@ -1767,7 +1778,73 @@ type ClientData<T> = T extends Response ? never : T extends DataWithResponseInit
1767
1778
  type ServerData<T> = T extends Response ? never : T extends DataWithResponseInit<infer U> ? Serialize<U> : Serialize<T>;
1768
1779
  type ServerDataFrom<T> = ServerData<DataFrom<T>>;
1769
1780
  type ClientDataFrom<T> = ClientData<DataFrom<T>>;
1770
- type SerializeFrom<T> = T extends (...args: infer Args) => unknown ? Args extends [ClientLoaderFunctionArgs | ClientActionFunctionArgs] ? ClientDataFrom<T> : ServerDataFrom<T> : T;
1781
+ type ClientDataFunctionArgs<Params> = {
1782
+ /**
1783
+ * A {@link https://developer.mozilla.org/en-US/docs/Web/API/Request Fetch Request instance} which you can use to read the URL, the method, the "content-type" header, and the request body from the request.
1784
+ *
1785
+ * @note Because client data functions are called before a network request is made, the Request object does not include the headers which the browser automatically adds. React Router infers the "content-type" header from the enc-type of the form that performed the submission.
1786
+ **/
1787
+ request: Request;
1788
+ /**
1789
+ * {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
1790
+ * @example
1791
+ * // app/routes.ts
1792
+ * route("teams/:teamId", "./team.tsx"),
1793
+ *
1794
+ * // app/team.tsx
1795
+ * export function clientLoader({
1796
+ * params,
1797
+ * }: Route.ClientLoaderArgs) {
1798
+ * params.teamId;
1799
+ * // ^ string
1800
+ * }
1801
+ **/
1802
+ params: Params;
1803
+ /**
1804
+ * When `future.unstable_middleware` is not enabled, this is undefined.
1805
+ *
1806
+ * When `future.unstable_middleware` is enabled, this is an instance of
1807
+ * `unstable_RouterContextProvider` and can be used to access context values
1808
+ * from your route middlewares. You may pass in initial context values in your
1809
+ * `<HydratedRouter unstable_getContext>` prop
1810
+ */
1811
+ context: unstable_RouterContextProvider;
1812
+ };
1813
+ type ServerDataFunctionArgs<Params> = {
1814
+ /** A {@link https://developer.mozilla.org/en-US/docs/Web/API/Request Fetch Request instance} which you can use to read the url, method, headers (such as cookies), and request body from the request. */
1815
+ request: Request;
1816
+ /**
1817
+ * {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
1818
+ * @example
1819
+ * // app/routes.ts
1820
+ * route("teams/:teamId", "./team.tsx"),
1821
+ *
1822
+ * // app/team.tsx
1823
+ * export function loader({
1824
+ * params,
1825
+ * }: Route.LoaderArgs) {
1826
+ * params.teamId;
1827
+ * // ^ string
1828
+ * }
1829
+ **/
1830
+ params: Params;
1831
+ /**
1832
+ * Without `future.unstable_middleware` enabled, this is the context passed in
1833
+ * to your server adapter's `getLoadContext` function. It's a way to bridge the
1834
+ * gap between the adapter's request/response API with your React Router app.
1835
+ * It is only applicable if you are using a custom server adapter.
1836
+ *
1837
+ * With `future.unstable_middleware` enabled, this is an instance of
1838
+ * `unstable_RouterContextProvider` and can be used for type-safe access to
1839
+ * context value set in your route middlewares. If you are using a custom
1840
+ * server adapter, you may provide an initial set of context values from your
1841
+ * `getLoadContext` function.
1842
+ */
1843
+ context: MiddlewareEnabled extends true ? unstable_RouterContextProvider : AppLoadContext;
1844
+ };
1845
+ type SerializeFrom<T> = T extends (...args: infer Args) => unknown ? Args extends [
1846
+ ClientLoaderFunctionArgs | ClientActionFunctionArgs | ClientDataFunctionArgs<unknown>
1847
+ ] ? ClientDataFrom<T> : ServerDataFrom<T> : T;
1771
1848
  type IsDefined<T> = Equal<T, undefined> extends true ? false : true;
1772
1849
  type IsHydrate<ClientLoader> = ClientLoader extends {
1773
1850
  hydrate: true;
@@ -1790,4 +1867,4 @@ type _DataActionData<ServerActionData, ClientActionData> = Awaited<[
1790
1867
  IsDefined<ClientActionData>
1791
1868
  ] extends [true, true] ? ServerActionData | ClientActionData : IsDefined<ClientActionData> extends true ? ClientActionData : IsDefined<ServerActionData> extends true ? ServerActionData : undefined>;
1792
1869
 
1793
- export { type Params as $, type ActionFunction as A, type Blocker as B, type CreateStaticHandlerOptions as C, type DataStrategyFunction as D, type Equal as E, type FutureConfig as F, type GetScrollPositionFunction as G, type HydrationState as H, type InitialEntry as I, type DataStrategyMatch as J, type DataStrategyResult as K, type Location as L, type MetaFunction as M, type NonIndexRouteObject as N, DataWithResponseInit as O, type PatchRoutesOnNavigationFunction as P, type ErrorResponse as Q, type RouterInit as R, type StaticHandlerContext as S, type To as T, type FormEncType as U, type FormMethod as V, type HTMLFormMethod as W, type LazyRouteFunction as X, type LoaderFunctionArgs as Y, type unstable_MiddlewareFunction as Z, type ParamParseKey as _, type Router as a, type GetActionData as a$, type PathMatch as a0, type PathParam as a1, type PathPattern as a2, type RedirectFunction as a3, type unstable_RouterContext as a4, type ShouldRevalidateFunction as a5, type ShouldRevalidateFunctionArgs as a6, type UIMatch as a7, unstable_createContext as a8, unstable_RouterContextProvider as a9, type MetaDescriptor as aA, type PageLinkDescriptor as aB, type HtmlLinkDescriptor as aC, type LinkDescriptor as aD, type Future as aE, type unstable_SerializesTo as aF, createBrowserHistory as aG, invariant as aH, createRouter as aI, ErrorResponseImpl as aJ, DataRouterContext as aK, DataRouterStateContext as aL, FetchersContext as aM, LocationContext as aN, NavigationContext as aO, RouteContext as aP, ViewTransitionContext as aQ, type RouteManifest as aR, type ServerRouteModule as aS, type SerializeFrom as aT, type History as aU, type RouteModule as aV, type unstable_MiddlewareNextFunction as aW, type ServerDataFrom as aX, type Pretty as aY, type GetLoaderData as aZ, type Normalize as a_, Action as aa, createPath as ab, parsePath as ac, IDLE_NAVIGATION as ad, IDLE_FETCHER as ae, IDLE_BLOCKER as af, data as ag, generatePath as ah, isRouteErrorResponse as ai, matchPath as aj, matchRoutes as ak, redirect as al, redirectDocument as am, replace as an, resolvePath as ao, type DataRouteMatch as ap, type NavigateOptions as aq, type Navigator as ar, type PatchRoutesOnNavigationFunctionArgs as as, type RouteMatch as at, type ClientActionFunction as au, type ClientActionFunctionArgs as av, type ClientLoaderFunctionArgs as aw, type HeadersArgs as ax, type HeadersFunction as ay, type MetaArgs as az, type RouteModules as b, type RouteObject as c, type StaticHandler as d, type IndexRouteObject as e, type LoaderFunction as f, type LinksFunction as g, type MiddlewareEnabled as h, type AppLoadContext as i, type RouterState as j, type DataRouteObject as k, type ClientLoaderFunction as l, type Path as m, type GetScrollRestorationKeyFunction as n, type Fetcher as o, type Navigation as p, type NavigationStates as q, type RelativeRoutingType as r, type BlockerFunction as s, type RouterSubscriber as t, type unstable_InitialContext as u, type RouterNavigateOptions as v, type RouterFetchOptions as w, type RevalidationState as x, type ActionFunctionArgs as y, type DataStrategyFunctionArgs as z };
1870
+ export { type DataStrategyFunctionArgs as $, type ActionFunction as A, type StaticHandlerContext as B, type ClientDataFunctionArgs as C, type DataStrategyFunction as D, type Equal as E, type Fetcher as F, type GetLoaderData as G, type HydrationState as H, type InitialEntry as I, type Navigation as J, type NavigationStates as K, type LinkDescriptor as L, type MetaDescriptor as M, type Normalize as N, type RelativeRoutingType as O, type Pretty as P, type Blocker as Q, type RouteModule as R, type ServerDataFunctionArgs as S, type To as T, type BlockerFunction as U, type RouterInit as V, type RouterSubscriber as W, type RouterNavigateOptions as X, type RouterFetchOptions as Y, type RevalidationState as Z, type ActionFunctionArgs as _, type Location as a, type FutureConfig as a$, type DataStrategyMatch as a0, type DataStrategyResult as a1, DataWithResponseInit as a2, type ErrorResponse as a3, type FormEncType as a4, type FormMethod as a5, type HTMLFormMethod as a6, type LazyRouteFunction as a7, type LoaderFunctionArgs as a8, type unstable_MiddlewareFunction as a9, type NavigateOptions as aA, type Navigator as aB, type PatchRoutesOnNavigationFunctionArgs as aC, type RouteMatch as aD, type RouteObject as aE, type ClientActionFunctionArgs as aF, type ClientLoaderFunctionArgs as aG, type HeadersArgs as aH, type MetaArgs as aI, type PageLinkDescriptor as aJ, type HtmlLinkDescriptor as aK, type Future as aL, type unstable_SerializesTo as aM, createBrowserHistory as aN, invariant as aO, createRouter as aP, ErrorResponseImpl as aQ, DataRouterContext as aR, DataRouterStateContext as aS, FetchersContext as aT, LocationContext as aU, NavigationContext as aV, RouteContext as aW, ViewTransitionContext as aX, type RouteManifest as aY, type ServerRouteModule as aZ, type SerializeFrom as a_, type ParamParseKey as aa, type PathMatch as ab, type PathParam as ac, type PathPattern as ad, type RedirectFunction as ae, type unstable_RouterContext as af, type ShouldRevalidateFunctionArgs as ag, type UIMatch as ah, unstable_createContext as ai, unstable_RouterContextProvider as aj, Action as ak, createPath as al, parsePath as am, IDLE_NAVIGATION as an, IDLE_FETCHER as ao, IDLE_BLOCKER as ap, data as aq, generatePath as ar, isRouteErrorResponse as as, matchPath as at, matchRoutes as au, redirect as av, redirectDocument as aw, replace as ax, resolvePath as ay, type DataRouteMatch as az, type ServerDataFrom as b, type History as b0, type CreateStaticHandlerOptions as b1, type GetActionData as c, type Router as d, type RouteModules as e, type IndexRouteObject as f, type LoaderFunction as g, type MetaFunction as h, type LinksFunction as i, type NonIndexRouteObject as j, type unstable_InitialContext as k, type MiddlewareEnabled as l, type AppLoadContext as m, type ClientActionFunction as n, type ClientLoaderFunction as o, type HeadersFunction as p, type ShouldRevalidateFunction as q, type Params as r, type RouterState as s, type PatchRoutesOnNavigationFunction as t, type unstable_MiddlewareNextFunction as u, type DataRouteObject as v, type Path as w, type StaticHandler as x, type GetScrollPositionFunction as y, type GetScrollRestorationKeyFunction as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-router",
3
- "version": "0.0.0-experimental-b588f7e",
3
+ "version": "0.0.0-experimental-23decd7bc",
4
4
  "description": "Declarative routing for React",
5
5
  "keywords": [
6
6
  "react",
@@ -23,11 +23,20 @@
23
23
  "module": "./dist/development/index.mjs",
24
24
  "exports": {
25
25
  ".": {
26
+ "react-server": {
27
+ "module": "./dist/development/index-react-server.mjs",
28
+ "default": "./dist/development/index-react-server.js"
29
+ },
26
30
  "node": {
27
31
  "types": "./dist/development/index.d.ts",
32
+ "module": "./dist/development/index.mjs",
28
33
  "module-sync": "./dist/development/index.mjs",
29
34
  "default": "./dist/development/index.js"
30
35
  },
36
+ "module": {
37
+ "types": "./dist/development/index.d.mts",
38
+ "default": "./dist/development/index.mjs"
39
+ },
31
40
  "import": {
32
41
  "types": "./dist/development/index.d.mts",
33
42
  "default": "./dist/development/index.mjs"
@@ -37,6 +46,26 @@
37
46
  "default": "./dist/development/index.js"
38
47
  }
39
48
  },
49
+ "./dom": {
50
+ "node": {
51
+ "types": "./dist/development/dom-export.d.ts",
52
+ "module": "./dist/development/dom-export.mjs",
53
+ "module-sync": "./dist/development/dom-export.mjs",
54
+ "default": "./dist/development/dom-export.js"
55
+ },
56
+ "module": {
57
+ "types": "./dist/development/dom-export.d.mts",
58
+ "default": "./dist/development/dom-export.mjs"
59
+ },
60
+ "import": {
61
+ "types": "./dist/development/dom-export.d.mts",
62
+ "default": "./dist/development/dom-export.mjs"
63
+ },
64
+ "default": {
65
+ "types": "./dist/development/dom-export.d.ts",
66
+ "default": "./dist/development/dom-export.js"
67
+ }
68
+ },
40
69
  "./internal": {
41
70
  "node": {
42
71
  "types": "./dist/development/lib/types/internal.d.ts"
@@ -48,26 +77,35 @@
48
77
  "types": "./dist/development/lib/types/index.d.ts"
49
78
  }
50
79
  },
51
- "./dom": {
80
+ "./internal/react-server-client": {
81
+ "react-server": {
82
+ "module": "./dist/development/index-react-server-client.mjs",
83
+ "default": "./dist/development/index-react-server-client.js"
84
+ },
52
85
  "node": {
53
- "types": "./dist/development/dom-export.d.ts",
54
- "module-sync": "./dist/development/dom-export.mjs",
55
- "default": "./dist/development/dom-export.js"
86
+ "types": "./dist/development/index.d.ts",
87
+ "module": "./dist/development/index.mjs",
88
+ "module-sync": "./dist/development/index.mjs",
89
+ "default": "./dist/development/index.js"
90
+ },
91
+ "module": {
92
+ "types": "./dist/development/index.d.mts",
93
+ "default": "./dist/development/index.mjs"
56
94
  },
57
95
  "import": {
58
- "types": "./dist/development/dom-export.d.mts",
59
- "default": "./dist/development/dom-export.mjs"
96
+ "types": "./dist/development/index.d.mts",
97
+ "default": "./dist/development/index.mjs"
60
98
  },
61
99
  "default": {
62
- "types": "./dist/development/dom-export.d.ts",
63
- "default": "./dist/development/dom-export.js"
100
+ "types": "./dist/development/index.d.ts",
101
+ "default": "./dist/development/index.js"
64
102
  }
65
103
  },
66
104
  "./package.json": "./package.json"
67
105
  },
68
106
  "wireit": {
69
107
  "build": {
70
- "command": "rimraf dist && tsup",
108
+ "command": "rimraf dist && tsup && tsup --config tsup.config.rsc.ts",
71
109
  "files": [
72
110
  "lib/**",
73
111
  "*.ts",
@@ -112,6 +150,7 @@
112
150
  },
113
151
  "scripts": {
114
152
  "build": "wireit",
153
+ "watch": "tsup --watch & tsup --config tsup.config.rsc.ts --watch",
115
154
  "typecheck": "tsc"
116
155
  }
117
156
  }