react-router 0.0.0-experimental-e6fb6e074 → 0.0.0-experimental-5bbc45fb6
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.
- package/CHANGELOG.md +753 -18
- package/README.md +5 -14
- package/dist/development/chunk-EKICUOCX.mjs +11486 -0
- package/dist/development/dom-export.d.mts +23 -0
- package/dist/development/dom-export.d.ts +22 -0
- package/dist/development/dom-export.js +246 -0
- package/dist/development/dom-export.mjs +225 -0
- package/dist/development/index.d.mts +795 -0
- package/dist/development/index.d.ts +2524 -0
- package/dist/development/index.js +11636 -0
- package/dist/development/index.mjs +246 -0
- package/dist/development/lib/types/internal.d.mts +275 -0
- package/dist/development/lib/types/internal.d.ts +274 -0
- package/dist/development/lib/types/internal.js +28 -0
- package/dist/development/lib/types/internal.mjs +10 -0
- package/dist/development/lib-DOOHL1pK.d.mts +1736 -0
- package/dist/development/register-DEZBC9Yl.d.ts +1767 -0
- package/dist/development/register-e9PGCFx1.d.mts +10 -0
- package/dist/development/route-data-BwJdBC92.d.mts +1758 -0
- package/dist/production/chunk-5UK3OH7I.mjs +11486 -0
- package/dist/production/dom-export.d.mts +23 -0
- package/dist/production/dom-export.d.ts +22 -0
- package/dist/production/dom-export.js +246 -0
- package/dist/production/dom-export.mjs +225 -0
- package/dist/production/index.d.mts +795 -0
- package/dist/production/index.d.ts +2524 -0
- package/dist/production/index.js +11636 -0
- package/dist/production/index.mjs +246 -0
- package/dist/production/lib/types/internal.d.mts +275 -0
- package/dist/production/lib/types/internal.d.ts +274 -0
- package/dist/production/lib/types/internal.js +28 -0
- package/dist/production/lib/types/internal.mjs +10 -0
- package/dist/production/lib-DOOHL1pK.d.mts +1736 -0
- package/dist/production/register-DEZBC9Yl.d.ts +1767 -0
- package/dist/production/register-e9PGCFx1.d.mts +10 -0
- package/dist/production/route-data-BwJdBC92.d.mts +1758 -0
- package/package.json +82 -9
- package/dist/index.d.ts +0 -30
- package/dist/index.js +0 -1501
- package/dist/index.js.map +0 -1
- package/dist/lib/components.d.ts +0 -157
- package/dist/lib/context.d.ts +0 -102
- package/dist/lib/deprecations.d.ts +0 -4
- package/dist/lib/hooks.d.ts +0 -181
- package/dist/main.js +0 -19
- package/dist/react-router.development.js +0 -1397
- package/dist/react-router.development.js.map +0 -1
- package/dist/react-router.production.min.js +0 -12
- package/dist/react-router.production.min.js.map +0 -1
- package/dist/umd/react-router.development.js +0 -1624
- package/dist/umd/react-router.development.js.map +0 -1
- package/dist/umd/react-router.production.min.js +0 -12
- package/dist/umd/react-router.production.min.js.map +0 -1
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import { aW as Normalize, a0 as Register, aX as ServerDataFrom, aY as ClientDataFrom, aZ as Func, aI as LinkDescriptor, $ as Equal, e as Location, aG as MetaDescriptor, a_ as unstable_MiddlewareNextFunction, u as unstable_RouterContextProvider, M as MiddlewareEnabled, i as AppLoadContext, a$ as Pretty } from '../../register-DEZBC9Yl.js';
|
|
2
|
+
import 'react';
|
|
3
|
+
|
|
4
|
+
type AnyRoutes = Record<string, {
|
|
5
|
+
parentId?: string;
|
|
6
|
+
path?: string;
|
|
7
|
+
index?: boolean;
|
|
8
|
+
file: string;
|
|
9
|
+
params: Record<string, string | undefined>;
|
|
10
|
+
}>;
|
|
11
|
+
type RoutesPre = Register extends {
|
|
12
|
+
routesPre: infer RegisteredRoutes extends AnyRoutes;
|
|
13
|
+
} ? RegisteredRoutes : AnyRoutes;
|
|
14
|
+
type RouteId = keyof RoutesPre;
|
|
15
|
+
type GetParents<Id extends RouteId> = RoutesPre[Id] extends {
|
|
16
|
+
parentId: infer P extends RouteId;
|
|
17
|
+
} ? [
|
|
18
|
+
...GetParents<P>,
|
|
19
|
+
P
|
|
20
|
+
] : [
|
|
21
|
+
];
|
|
22
|
+
type _GetChildren<Id extends RouteId> = {
|
|
23
|
+
[K in RouteId]: RoutesPre[K] extends {
|
|
24
|
+
parentId: Id;
|
|
25
|
+
} ? RoutesPre[K] extends {
|
|
26
|
+
index: true;
|
|
27
|
+
} ? [K] : RoutesPre[K] extends {
|
|
28
|
+
path: undefined;
|
|
29
|
+
} ? [K, ...GetChildren<K>] : [
|
|
30
|
+
K
|
|
31
|
+
] | [K, ...GetChildren<K>] : [
|
|
32
|
+
];
|
|
33
|
+
}[RouteId];
|
|
34
|
+
type GetChildren<Id extends RouteId> = _GetChildren<Id> extends [] ? [] : Exclude<_GetChildren<Id>, []>;
|
|
35
|
+
type GetBranch<Id extends RouteId> = [
|
|
36
|
+
...GetParents<Id>,
|
|
37
|
+
Id,
|
|
38
|
+
..._GetChildren<Id>
|
|
39
|
+
];
|
|
40
|
+
type Branches = {
|
|
41
|
+
[Id in RouteId]: GetBranch<Id>;
|
|
42
|
+
};
|
|
43
|
+
type PartialParams = {
|
|
44
|
+
[Id in RouteId]: RoutesPre[Id]["params"];
|
|
45
|
+
};
|
|
46
|
+
type BranchParams<Branch extends Array<RouteId>> = Branch extends [
|
|
47
|
+
infer Id extends RouteId,
|
|
48
|
+
...infer Ids extends Array<RouteId>
|
|
49
|
+
] ? PartialParams[Id] & BranchParams<Ids> : {};
|
|
50
|
+
type Params = {
|
|
51
|
+
[Id in RouteId]: Normalize<BranchParams<Branches[Id]>>;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
type IsDefined<T> = Equal<T, undefined> extends true ? false : true;
|
|
55
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
56
|
+
type RouteModule = {
|
|
57
|
+
meta?: Func;
|
|
58
|
+
links?: Func;
|
|
59
|
+
headers?: Func;
|
|
60
|
+
loader?: Func;
|
|
61
|
+
clientLoader?: Func;
|
|
62
|
+
action?: Func;
|
|
63
|
+
clientAction?: Func;
|
|
64
|
+
HydrateFallback?: Func;
|
|
65
|
+
default?: Func;
|
|
66
|
+
ErrorBoundary?: Func;
|
|
67
|
+
[key: string]: unknown;
|
|
68
|
+
};
|
|
69
|
+
type Props = {
|
|
70
|
+
params: unknown;
|
|
71
|
+
loaderData: unknown;
|
|
72
|
+
actionData: unknown;
|
|
73
|
+
};
|
|
74
|
+
type RouteInfo = Props & {
|
|
75
|
+
parents: Props[];
|
|
76
|
+
module: RouteModule;
|
|
77
|
+
};
|
|
78
|
+
type MetaMatch<T extends Props> = Pretty<Pick<T, "params"> & {
|
|
79
|
+
pathname: string;
|
|
80
|
+
meta: MetaDescriptor[];
|
|
81
|
+
data: T["loaderData"];
|
|
82
|
+
handle?: unknown;
|
|
83
|
+
error?: unknown;
|
|
84
|
+
}>;
|
|
85
|
+
type MetaMatches<T extends Props[]> = T extends [infer F extends Props, ...infer R extends Props[]] ? [MetaMatch<F>, ...MetaMatches<R>] : Array<MetaMatch<RouteInfo> | undefined>;
|
|
86
|
+
type CreateMetaArgs<T extends RouteInfo> = {
|
|
87
|
+
/** This is the current router `Location` object. This is useful for generating tags for routes at specific paths or query parameters. */
|
|
88
|
+
location: Location;
|
|
89
|
+
/** {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route. */
|
|
90
|
+
params: T["params"];
|
|
91
|
+
/** The return value for this route's server loader function */
|
|
92
|
+
data: T["loaderData"];
|
|
93
|
+
/** Thrown errors that trigger error boundaries will be passed to the meta function. This is useful for generating metadata for error pages. */
|
|
94
|
+
error?: unknown;
|
|
95
|
+
/** An array of the current {@link https://api.reactrouter.com/v7/interfaces/react_router.UIMatch.html route matches}, including parent route matches. */
|
|
96
|
+
matches: MetaMatches<[...T["parents"], T]>;
|
|
97
|
+
};
|
|
98
|
+
type MetaDescriptors = MetaDescriptor[];
|
|
99
|
+
type HeadersArgs = {
|
|
100
|
+
loaderHeaders: Headers;
|
|
101
|
+
parentHeaders: Headers;
|
|
102
|
+
actionHeaders: Headers;
|
|
103
|
+
errorHeaders: Headers | undefined;
|
|
104
|
+
};
|
|
105
|
+
type IsHydrate<ClientLoader> = ClientLoader extends {
|
|
106
|
+
hydrate: true;
|
|
107
|
+
} ? true : ClientLoader extends {
|
|
108
|
+
hydrate: false;
|
|
109
|
+
} ? false : false;
|
|
110
|
+
type CreateLoaderData<T extends RouteModule> = _CreateLoaderData<ServerDataFrom<T["loader"]>, ClientDataFrom<T["clientLoader"]>, IsHydrate<T["clientLoader"]>, T extends {
|
|
111
|
+
HydrateFallback: Func;
|
|
112
|
+
} ? true : false>;
|
|
113
|
+
type _CreateLoaderData<ServerLoaderData, ClientLoaderData, ClientLoaderHydrate extends boolean, HasHydrateFallback> = [
|
|
114
|
+
HasHydrateFallback,
|
|
115
|
+
ClientLoaderHydrate
|
|
116
|
+
] extends [true, true] ? IsDefined<ClientLoaderData> extends true ? ClientLoaderData : undefined : [
|
|
117
|
+
IsDefined<ClientLoaderData>,
|
|
118
|
+
IsDefined<ServerLoaderData>
|
|
119
|
+
] extends [true, true] ? ServerLoaderData | ClientLoaderData : IsDefined<ClientLoaderData> extends true ? ClientLoaderData : IsDefined<ServerLoaderData> extends true ? ServerLoaderData : undefined;
|
|
120
|
+
type CreateActionData<T extends RouteModule> = _CreateActionData<ServerDataFrom<T["action"]>, ClientDataFrom<T["clientAction"]>>;
|
|
121
|
+
type _CreateActionData<ServerActionData, ClientActionData> = Awaited<[
|
|
122
|
+
IsDefined<ServerActionData>,
|
|
123
|
+
IsDefined<ClientActionData>
|
|
124
|
+
] extends [true, true] ? ServerActionData | ClientActionData : IsDefined<ClientActionData> extends true ? ClientActionData : IsDefined<ServerActionData> extends true ? ServerActionData : undefined>;
|
|
125
|
+
type ClientDataFunctionArgs<T extends RouteInfo> = {
|
|
126
|
+
/**
|
|
127
|
+
* 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.
|
|
128
|
+
*
|
|
129
|
+
* @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.
|
|
130
|
+
**/
|
|
131
|
+
request: Request;
|
|
132
|
+
/**
|
|
133
|
+
* {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
|
|
134
|
+
* @example
|
|
135
|
+
* // app/routes.ts
|
|
136
|
+
* route("teams/:teamId", "./team.tsx"),
|
|
137
|
+
*
|
|
138
|
+
* // app/team.tsx
|
|
139
|
+
* export function clientLoader({
|
|
140
|
+
* params,
|
|
141
|
+
* }: Route.ClientLoaderArgs) {
|
|
142
|
+
* params.teamId;
|
|
143
|
+
* // ^ string
|
|
144
|
+
* }
|
|
145
|
+
**/
|
|
146
|
+
params: T["params"];
|
|
147
|
+
/**
|
|
148
|
+
* When `future.unstable_middleware` is not enabled, this is undefined.
|
|
149
|
+
*
|
|
150
|
+
* When `future.unstable_middleware` is enabled, this is an instance of
|
|
151
|
+
* `unstable_RouterContextProvider` and can be used to access context values
|
|
152
|
+
* from your route middlewares. You may pass in initial context values in your
|
|
153
|
+
* `<HydratedRouter unstable_getContext>` prop
|
|
154
|
+
*/
|
|
155
|
+
context: unstable_RouterContextProvider;
|
|
156
|
+
};
|
|
157
|
+
type ServerDataFunctionArgs<T extends RouteInfo> = {
|
|
158
|
+
/** 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. */
|
|
159
|
+
request: Request;
|
|
160
|
+
/**
|
|
161
|
+
* {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
|
|
162
|
+
* @example
|
|
163
|
+
* // app/routes.ts
|
|
164
|
+
* route("teams/:teamId", "./team.tsx"),
|
|
165
|
+
*
|
|
166
|
+
* // app/team.tsx
|
|
167
|
+
* export function loader({
|
|
168
|
+
* params,
|
|
169
|
+
* }: Route.LoaderArgs) {
|
|
170
|
+
* params.teamId;
|
|
171
|
+
* // ^ string
|
|
172
|
+
* }
|
|
173
|
+
**/
|
|
174
|
+
params: T["params"];
|
|
175
|
+
/**
|
|
176
|
+
* Without `future.unstable_middleware` enabled, this is the context passed in
|
|
177
|
+
* to your server adapter's `getLoadContext` function. It's a way to bridge the
|
|
178
|
+
* gap between the adapter's request/response API with your React Router app.
|
|
179
|
+
* It is only applicable if you are using a custom server adapter.
|
|
180
|
+
*
|
|
181
|
+
* With `future.unstable_middleware` enabled, this is an instance of
|
|
182
|
+
* `unstable_RouterContextProvider` and can be used for type-safe access to
|
|
183
|
+
* context value set in your route middlewares. If you are using a custom
|
|
184
|
+
* server adapter, you may provide an initial set of context values from your
|
|
185
|
+
* `getLoadContext` function.
|
|
186
|
+
*/
|
|
187
|
+
context: MiddlewareEnabled extends true ? unstable_RouterContextProvider : AppLoadContext;
|
|
188
|
+
};
|
|
189
|
+
type CreateServerMiddlewareFunction<T extends RouteInfo> = (args: ServerDataFunctionArgs<T>, next: unstable_MiddlewareNextFunction<Response>) => MaybePromise<Response | void>;
|
|
190
|
+
type CreateClientMiddlewareFunction<T extends RouteInfo> = (args: ClientDataFunctionArgs<T>, next: unstable_MiddlewareNextFunction<undefined>) => MaybePromise<void>;
|
|
191
|
+
type CreateServerLoaderArgs<T extends RouteInfo> = ServerDataFunctionArgs<T>;
|
|
192
|
+
type CreateClientLoaderArgs<T extends RouteInfo> = ClientDataFunctionArgs<T> & {
|
|
193
|
+
/** This is an asynchronous function to get the data from the server loader for this route. On client-side navigations, this will make a {@link https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API fetch} call to the React Router server loader. If you opt-into running your clientLoader on hydration, then this function will return the data that was already loaded on the server (via Promise.resolve). */
|
|
194
|
+
serverLoader: () => Promise<ServerDataFrom<T["module"]["loader"]>>;
|
|
195
|
+
};
|
|
196
|
+
type CreateServerActionArgs<T extends RouteInfo> = ServerDataFunctionArgs<T>;
|
|
197
|
+
type CreateClientActionArgs<T extends RouteInfo> = ClientDataFunctionArgs<T> & {
|
|
198
|
+
/** This is an asynchronous function that makes the {@link https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API fetch} call to the React Router server action for this route. */
|
|
199
|
+
serverAction: () => Promise<ServerDataFrom<T["module"]["action"]>>;
|
|
200
|
+
};
|
|
201
|
+
type CreateHydrateFallbackProps<T extends RouteInfo> = {
|
|
202
|
+
params: T["params"];
|
|
203
|
+
loaderData?: T["loaderData"];
|
|
204
|
+
actionData?: T["actionData"];
|
|
205
|
+
};
|
|
206
|
+
type Match<T extends Props> = Pretty<Pick<T, "params"> & {
|
|
207
|
+
pathname: string;
|
|
208
|
+
data: T["loaderData"];
|
|
209
|
+
handle: unknown;
|
|
210
|
+
}>;
|
|
211
|
+
type Matches<T extends Props[]> = T extends [infer F extends Props, ...infer R extends Props[]] ? [Match<F>, ...Matches<R>] : Array<Match<Props> | undefined>;
|
|
212
|
+
type CreateComponentProps<T extends RouteInfo> = {
|
|
213
|
+
/**
|
|
214
|
+
* {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
|
|
215
|
+
* @example
|
|
216
|
+
* // app/routes.ts
|
|
217
|
+
* route("teams/:teamId", "./team.tsx"),
|
|
218
|
+
*
|
|
219
|
+
* // app/team.tsx
|
|
220
|
+
* export default function Component({
|
|
221
|
+
* params,
|
|
222
|
+
* }: Route.ComponentProps) {
|
|
223
|
+
* params.teamId;
|
|
224
|
+
* // ^ string
|
|
225
|
+
* }
|
|
226
|
+
**/
|
|
227
|
+
params: T["params"];
|
|
228
|
+
/** The data returned from the `loader` or `clientLoader` */
|
|
229
|
+
loaderData: T["loaderData"];
|
|
230
|
+
/** The data returned from the `action` or `clientAction` following an action submission. */
|
|
231
|
+
actionData?: T["actionData"];
|
|
232
|
+
/** An array of the current {@link https://api.reactrouter.com/v7/interfaces/react_router.UIMatch.html route matches}, including parent route matches. */
|
|
233
|
+
matches: Matches<[...T["parents"], T]>;
|
|
234
|
+
};
|
|
235
|
+
type CreateErrorBoundaryProps<T extends RouteInfo> = {
|
|
236
|
+
/**
|
|
237
|
+
* {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
|
|
238
|
+
* @example
|
|
239
|
+
* // app/routes.ts
|
|
240
|
+
* route("teams/:teamId", "./team.tsx"),
|
|
241
|
+
*
|
|
242
|
+
* // app/team.tsx
|
|
243
|
+
* export function ErrorBoundary({
|
|
244
|
+
* params,
|
|
245
|
+
* }: Route.ErrorBoundaryProps) {
|
|
246
|
+
* params.teamId;
|
|
247
|
+
* // ^ string
|
|
248
|
+
* }
|
|
249
|
+
**/
|
|
250
|
+
params: T["params"];
|
|
251
|
+
error: unknown;
|
|
252
|
+
loaderData?: T["loaderData"];
|
|
253
|
+
actionData?: T["actionData"];
|
|
254
|
+
};
|
|
255
|
+
type RouteModuleAnnotations<Info extends RouteInfo> = {
|
|
256
|
+
LinkDescriptors: LinkDescriptor[];
|
|
257
|
+
LinksFunction: () => LinkDescriptor[];
|
|
258
|
+
MetaArgs: CreateMetaArgs<Info>;
|
|
259
|
+
MetaDescriptors: MetaDescriptors;
|
|
260
|
+
MetaFunction: (args: CreateMetaArgs<Info>) => MetaDescriptors;
|
|
261
|
+
HeadersArgs: HeadersArgs;
|
|
262
|
+
HeadersFunction: (args: HeadersArgs) => Headers | HeadersInit;
|
|
263
|
+
unstable_MiddlewareFunction: CreateServerMiddlewareFunction<Info>;
|
|
264
|
+
unstable_ClientMiddlewareFunction: CreateClientMiddlewareFunction<Info>;
|
|
265
|
+
LoaderArgs: CreateServerLoaderArgs<Info>;
|
|
266
|
+
ClientLoaderArgs: CreateClientLoaderArgs<Info>;
|
|
267
|
+
ActionArgs: CreateServerActionArgs<Info>;
|
|
268
|
+
ClientActionArgs: CreateClientActionArgs<Info>;
|
|
269
|
+
HydrateFallbackProps: CreateHydrateFallbackProps<Info>;
|
|
270
|
+
ComponentProps: CreateComponentProps<Info>;
|
|
271
|
+
ErrorBoundaryProps: CreateErrorBoundaryProps<Info>;
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
export type { CreateActionData, CreateLoaderData, Params, RouteModuleAnnotations };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* react-router v0.0.0-experimental-5bbc45fb6
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Remix Software Inc.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @license MIT
|
|
10
|
+
*/
|
|
11
|
+
"use strict";
|
|
12
|
+
var __defProp = Object.defineProperty;
|
|
13
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
14
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
15
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
+
var __copyProps = (to, from, except, desc) => {
|
|
17
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
+
for (let key of __getOwnPropNames(from))
|
|
19
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
20
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
|
|
26
|
+
// lib/types/internal.ts
|
|
27
|
+
var internal_exports = {};
|
|
28
|
+
module.exports = __toCommonJS(internal_exports);
|