react-router 6.26.2-pre.0 → 7.0.0-pre.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +309 -2
- package/README.md +1 -14
- package/dist/dom-export.d.ts +3 -0
- package/dist/dom-export.mjs +205 -0
- package/dist/dom-export.mjs.map +1 -0
- package/dist/index.d.ts +74 -29
- package/dist/index.mjs +11551 -0
- package/dist/index.mjs.map +1 -0
- package/dist/lib/components.d.ts +250 -35
- package/dist/lib/context.d.ts +20 -7
- package/dist/lib/dom/dom.d.ts +123 -0
- package/dist/lib/dom/global.d.ts +40 -0
- package/dist/lib/dom/lib.d.ts +940 -0
- package/dist/lib/dom/server.d.ts +41 -0
- package/dist/lib/dom/ssr/components.d.ts +123 -0
- package/dist/lib/dom/ssr/data.d.ts +7 -0
- package/dist/lib/dom/ssr/entry.d.ts +47 -0
- package/dist/lib/dom/ssr/errorBoundaries.d.ts +36 -0
- package/dist/lib/dom/ssr/errors.d.ts +2 -0
- package/dist/lib/dom/ssr/fallback.d.ts +2 -0
- package/dist/lib/dom/ssr/fog-of-war.d.ts +28 -0
- package/dist/lib/dom/ssr/invariant.d.ts +2 -0
- package/dist/lib/dom/ssr/links.d.ts +25 -0
- package/dist/lib/dom/ssr/markup.d.ts +5 -0
- package/dist/lib/dom/ssr/routeModules.d.ts +141 -0
- package/dist/lib/dom/ssr/routes-test-stub.d.ts +59 -0
- package/dist/lib/dom/ssr/routes.d.ts +32 -0
- package/dist/lib/dom/ssr/server.d.ts +16 -0
- package/dist/lib/dom/ssr/single-fetch.d.ts +37 -0
- package/dist/lib/dom-export/dom-router-provider.d.ts +5 -0
- package/dist/lib/dom-export/hydrated-router.d.ts +5 -0
- package/dist/lib/dom-export.d.ts +3 -0
- package/dist/lib/hooks.d.ts +286 -57
- package/dist/lib/router/history.d.ts +253 -0
- package/dist/lib/router/links.d.ts +104 -0
- package/dist/lib/router/router.d.ts +540 -0
- package/dist/lib/router/utils.d.ts +505 -0
- package/dist/lib/server-runtime/build.d.ts +38 -0
- package/dist/lib/server-runtime/cookies.d.ts +62 -0
- package/dist/lib/server-runtime/crypto.d.ts +2 -0
- package/dist/lib/server-runtime/data.d.ts +15 -0
- package/dist/lib/server-runtime/dev.d.ts +8 -0
- package/dist/lib/server-runtime/entry.d.ts +3 -0
- package/dist/lib/server-runtime/errors.d.ts +51 -0
- package/dist/lib/server-runtime/headers.d.ts +3 -0
- package/dist/lib/server-runtime/invariant.d.ts +2 -0
- package/dist/lib/server-runtime/jsonify.d.ts +33 -0
- package/dist/lib/server-runtime/markup.d.ts +1 -0
- package/dist/lib/server-runtime/mode.d.ts +9 -0
- package/dist/lib/server-runtime/responses.d.ts +37 -0
- package/dist/lib/server-runtime/routeMatching.d.ts +8 -0
- package/dist/lib/server-runtime/routeModules.d.ts +212 -0
- package/dist/lib/server-runtime/routes.d.ts +31 -0
- package/dist/lib/server-runtime/server.d.ts +5 -0
- package/dist/lib/server-runtime/serverHandoff.d.ts +11 -0
- package/dist/lib/server-runtime/sessions/cookieStorage.d.ts +19 -0
- package/dist/lib/server-runtime/sessions/memoryStorage.d.ts +17 -0
- package/dist/lib/server-runtime/sessions.d.ts +140 -0
- package/dist/lib/server-runtime/single-fetch.d.ts +30 -0
- package/dist/lib/server-runtime/typecheck.d.ts +4 -0
- package/dist/lib/server-runtime/warnings.d.ts +1 -0
- package/dist/lib/types.d.ts +71 -0
- package/dist/lib/types.mjs +10 -0
- package/dist/main-dom-export.js +19 -0
- package/dist/main.js +1 -1
- package/dist/react-router-dom.development.js +199 -0
- package/dist/react-router-dom.development.js.map +1 -0
- package/dist/react-router-dom.production.min.js +12 -0
- package/dist/react-router-dom.production.min.js.map +1 -0
- package/dist/react-router.development.js +12271 -1129
- package/dist/react-router.development.js.map +1 -1
- package/dist/react-router.production.min.js +2 -2
- package/dist/react-router.production.min.js.map +1 -1
- package/dist/umd/react-router-dom.development.js +241 -0
- package/dist/umd/react-router-dom.development.js.map +1 -0
- package/dist/umd/react-router-dom.production.min.js +12 -0
- package/dist/umd/react-router-dom.production.min.js.map +1 -0
- package/dist/umd/react-router.development.js +12459 -1224
- package/dist/umd/react-router.development.js.map +1 -1
- package/dist/umd/react-router.production.min.js +2 -2
- package/dist/umd/react-router.production.min.js.map +1 -1
- package/package.json +35 -6
- package/dist/index.js +0 -1467
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Actions represent the type of change to a location value.
|
|
3
|
+
*/
|
|
4
|
+
export declare enum Action {
|
|
5
|
+
/**
|
|
6
|
+
* A POP indicates a change to an arbitrary index in the history stack, such
|
|
7
|
+
* as a back or forward navigation. It does not describe the direction of the
|
|
8
|
+
* navigation, only that the current index changed.
|
|
9
|
+
*
|
|
10
|
+
* Note: This is the default action for newly created history objects.
|
|
11
|
+
*/
|
|
12
|
+
Pop = "POP",
|
|
13
|
+
/**
|
|
14
|
+
* A PUSH indicates a new entry being added to the history stack, such as when
|
|
15
|
+
* a link is clicked and a new page loads. When this happens, all subsequent
|
|
16
|
+
* entries in the stack are lost.
|
|
17
|
+
*/
|
|
18
|
+
Push = "PUSH",
|
|
19
|
+
/**
|
|
20
|
+
* A REPLACE indicates the entry at the current index in the history stack
|
|
21
|
+
* being replaced by a new one.
|
|
22
|
+
*/
|
|
23
|
+
Replace = "REPLACE"
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The pathname, search, and hash values of a URL.
|
|
27
|
+
*/
|
|
28
|
+
export interface Path {
|
|
29
|
+
/**
|
|
30
|
+
* A URL pathname, beginning with a /.
|
|
31
|
+
*/
|
|
32
|
+
pathname: string;
|
|
33
|
+
/**
|
|
34
|
+
* A URL search string, beginning with a ?.
|
|
35
|
+
*/
|
|
36
|
+
search: string;
|
|
37
|
+
/**
|
|
38
|
+
* A URL fragment identifier, beginning with a #.
|
|
39
|
+
*/
|
|
40
|
+
hash: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* An entry in a history stack. A location contains information about the
|
|
44
|
+
* URL path, as well as possibly some arbitrary state and a key.
|
|
45
|
+
*/
|
|
46
|
+
export interface Location<State = any> extends Path {
|
|
47
|
+
/**
|
|
48
|
+
* A value of arbitrary data associated with this location.
|
|
49
|
+
*/
|
|
50
|
+
state: State;
|
|
51
|
+
/**
|
|
52
|
+
* A unique string associated with this location. May be used to safely store
|
|
53
|
+
* and retrieve data in some other storage API, like `localStorage`.
|
|
54
|
+
*
|
|
55
|
+
* Note: This value is always "default" on the initial location.
|
|
56
|
+
*/
|
|
57
|
+
key: string;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* A change to the current location.
|
|
61
|
+
*/
|
|
62
|
+
export interface Update {
|
|
63
|
+
/**
|
|
64
|
+
* The action that triggered the change.
|
|
65
|
+
*/
|
|
66
|
+
action: Action;
|
|
67
|
+
/**
|
|
68
|
+
* The new location.
|
|
69
|
+
*/
|
|
70
|
+
location: Location;
|
|
71
|
+
/**
|
|
72
|
+
* The delta between this location and the former location in the history stack
|
|
73
|
+
*/
|
|
74
|
+
delta: number | null;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* A function that receives notifications about location changes.
|
|
78
|
+
*/
|
|
79
|
+
export interface Listener {
|
|
80
|
+
(update: Update): void;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Describes a location that is the destination of some navigation used in
|
|
84
|
+
* {@link Link}, {@link useNavigate}, etc.
|
|
85
|
+
*/
|
|
86
|
+
export type To = string | Partial<Path>;
|
|
87
|
+
/**
|
|
88
|
+
* A history is an interface to the navigation stack. The history serves as the
|
|
89
|
+
* source of truth for the current location, as well as provides a set of
|
|
90
|
+
* methods that may be used to change it.
|
|
91
|
+
*
|
|
92
|
+
* It is similar to the DOM's `window.history` object, but with a smaller, more
|
|
93
|
+
* focused API.
|
|
94
|
+
*/
|
|
95
|
+
export interface History {
|
|
96
|
+
/**
|
|
97
|
+
* The last action that modified the current location. This will always be
|
|
98
|
+
* Action.Pop when a history instance is first created. This value is mutable.
|
|
99
|
+
*/
|
|
100
|
+
readonly action: Action;
|
|
101
|
+
/**
|
|
102
|
+
* The current location. This value is mutable.
|
|
103
|
+
*/
|
|
104
|
+
readonly location: Location;
|
|
105
|
+
/**
|
|
106
|
+
* Returns a valid href for the given `to` value that may be used as
|
|
107
|
+
* the value of an <a href> attribute.
|
|
108
|
+
*
|
|
109
|
+
* @param to - The destination URL
|
|
110
|
+
*/
|
|
111
|
+
createHref(to: To): string;
|
|
112
|
+
/**
|
|
113
|
+
* Returns a URL for the given `to` value
|
|
114
|
+
*
|
|
115
|
+
* @param to - The destination URL
|
|
116
|
+
*/
|
|
117
|
+
createURL(to: To): URL;
|
|
118
|
+
/**
|
|
119
|
+
* Encode a location the same way window.history would do (no-op for memory
|
|
120
|
+
* history) so we ensure our PUSH/REPLACE navigations for data routers
|
|
121
|
+
* behave the same as POP
|
|
122
|
+
*
|
|
123
|
+
* @param to Unencoded path
|
|
124
|
+
*/
|
|
125
|
+
encodeLocation(to: To): Path;
|
|
126
|
+
/**
|
|
127
|
+
* Pushes a new location onto the history stack, increasing its length by one.
|
|
128
|
+
* If there were any entries in the stack after the current one, they are
|
|
129
|
+
* lost.
|
|
130
|
+
*
|
|
131
|
+
* @param to - The new URL
|
|
132
|
+
* @param state - Data to associate with the new location
|
|
133
|
+
*/
|
|
134
|
+
push(to: To, state?: any): void;
|
|
135
|
+
/**
|
|
136
|
+
* Replaces the current location in the history stack with a new one. The
|
|
137
|
+
* location that was replaced will no longer be available.
|
|
138
|
+
*
|
|
139
|
+
* @param to - The new URL
|
|
140
|
+
* @param state - Data to associate with the new location
|
|
141
|
+
*/
|
|
142
|
+
replace(to: To, state?: any): void;
|
|
143
|
+
/**
|
|
144
|
+
* Navigates `n` entries backward/forward in the history stack relative to the
|
|
145
|
+
* current index. For example, a "back" navigation would use go(-1).
|
|
146
|
+
*
|
|
147
|
+
* @param delta - The delta in the stack index
|
|
148
|
+
*/
|
|
149
|
+
go(delta: number): void;
|
|
150
|
+
/**
|
|
151
|
+
* Sets up a listener that will be called whenever the current location
|
|
152
|
+
* changes.
|
|
153
|
+
*
|
|
154
|
+
* @param listener - A function that will be called when the location changes
|
|
155
|
+
* @returns unlisten - A function that may be used to stop listening
|
|
156
|
+
*/
|
|
157
|
+
listen(listener: Listener): () => void;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* A user-supplied object that describes a location. Used when providing
|
|
161
|
+
* entries to `createMemoryHistory` via its `initialEntries` option.
|
|
162
|
+
*/
|
|
163
|
+
export type InitialEntry = string | Partial<Location>;
|
|
164
|
+
export type MemoryHistoryOptions = {
|
|
165
|
+
initialEntries?: InitialEntry[];
|
|
166
|
+
initialIndex?: number;
|
|
167
|
+
v5Compat?: boolean;
|
|
168
|
+
};
|
|
169
|
+
/**
|
|
170
|
+
* A memory history stores locations in memory. This is useful in stateful
|
|
171
|
+
* environments where there is no web browser, such as node tests or React
|
|
172
|
+
* Native.
|
|
173
|
+
*/
|
|
174
|
+
export interface MemoryHistory extends History {
|
|
175
|
+
/**
|
|
176
|
+
* The current index in the history stack.
|
|
177
|
+
*/
|
|
178
|
+
readonly index: number;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Memory history stores the current location in memory. It is designed for use
|
|
182
|
+
* in stateful non-browser environments like tests and React Native.
|
|
183
|
+
*/
|
|
184
|
+
export declare function createMemoryHistory(options?: MemoryHistoryOptions): MemoryHistory;
|
|
185
|
+
/**
|
|
186
|
+
* A browser history stores the current location in regular URLs in a web
|
|
187
|
+
* browser environment. This is the standard for most web apps and provides the
|
|
188
|
+
* cleanest URLs the browser's address bar.
|
|
189
|
+
*
|
|
190
|
+
* @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#browserhistory
|
|
191
|
+
*/
|
|
192
|
+
export interface BrowserHistory extends UrlHistory {
|
|
193
|
+
}
|
|
194
|
+
export type BrowserHistoryOptions = UrlHistoryOptions;
|
|
195
|
+
/**
|
|
196
|
+
* Browser history stores the location in regular URLs. This is the standard for
|
|
197
|
+
* most web apps, but it requires some configuration on the server to ensure you
|
|
198
|
+
* serve the same app at multiple URLs.
|
|
199
|
+
*
|
|
200
|
+
* @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#createbrowserhistory
|
|
201
|
+
*/
|
|
202
|
+
export declare function createBrowserHistory(options?: BrowserHistoryOptions): BrowserHistory;
|
|
203
|
+
/**
|
|
204
|
+
* A hash history stores the current location in the fragment identifier portion
|
|
205
|
+
* of the URL in a web browser environment.
|
|
206
|
+
*
|
|
207
|
+
* This is ideal for apps that do not control the server for some reason
|
|
208
|
+
* (because the fragment identifier is never sent to the server), including some
|
|
209
|
+
* shared hosting environments that do not provide fine-grained controls over
|
|
210
|
+
* which pages are served at which URLs.
|
|
211
|
+
*
|
|
212
|
+
* @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#hashhistory
|
|
213
|
+
*/
|
|
214
|
+
export interface HashHistory extends UrlHistory {
|
|
215
|
+
}
|
|
216
|
+
export type HashHistoryOptions = UrlHistoryOptions;
|
|
217
|
+
/**
|
|
218
|
+
* Hash history stores the location in window.location.hash. This makes it ideal
|
|
219
|
+
* for situations where you don't want to send the location to the server for
|
|
220
|
+
* some reason, either because you do cannot configure it or the URL space is
|
|
221
|
+
* reserved for something else.
|
|
222
|
+
*
|
|
223
|
+
* @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#createhashhistory
|
|
224
|
+
*/
|
|
225
|
+
export declare function createHashHistory(options?: HashHistoryOptions): HashHistory;
|
|
226
|
+
/**
|
|
227
|
+
* @private
|
|
228
|
+
*/
|
|
229
|
+
export declare function invariant(value: boolean, message?: string): asserts value;
|
|
230
|
+
export declare function invariant<T>(value: T | null | undefined, message?: string): asserts value is T;
|
|
231
|
+
export declare function warning(cond: any, message: string): void;
|
|
232
|
+
/**
|
|
233
|
+
* Creates a Location object with a unique key from the given Path
|
|
234
|
+
*/
|
|
235
|
+
export declare function createLocation(current: string | Location, to: To, state?: any, key?: string): Readonly<Location>;
|
|
236
|
+
/**
|
|
237
|
+
* Creates a string URL path from the given pathname, search, and hash components.
|
|
238
|
+
*
|
|
239
|
+
* @category Utils
|
|
240
|
+
*/
|
|
241
|
+
export declare function createPath({ pathname, search, hash, }: Partial<Path>): string;
|
|
242
|
+
/**
|
|
243
|
+
* Parses a string URL path into its separate pathname, search, and hash components.
|
|
244
|
+
*
|
|
245
|
+
* @category Utils
|
|
246
|
+
*/
|
|
247
|
+
export declare function parsePath(path: string): Partial<Path>;
|
|
248
|
+
export interface UrlHistory extends History {
|
|
249
|
+
}
|
|
250
|
+
export type UrlHistoryOptions = {
|
|
251
|
+
window?: Window;
|
|
252
|
+
v5Compat?: boolean;
|
|
253
|
+
};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
type Primitive = null | undefined | string | number | boolean | symbol | bigint;
|
|
2
|
+
type LiteralUnion<LiteralType, BaseType extends Primitive> = LiteralType | (BaseType & Record<never, never>);
|
|
3
|
+
interface HtmlLinkProps {
|
|
4
|
+
/**
|
|
5
|
+
* Address of the hyperlink
|
|
6
|
+
*/
|
|
7
|
+
href?: string;
|
|
8
|
+
/**
|
|
9
|
+
* How the element handles crossorigin requests
|
|
10
|
+
*/
|
|
11
|
+
crossOrigin?: "anonymous" | "use-credentials";
|
|
12
|
+
/**
|
|
13
|
+
* Relationship between the document containing the hyperlink and the destination resource
|
|
14
|
+
*/
|
|
15
|
+
rel: LiteralUnion<"alternate" | "dns-prefetch" | "icon" | "manifest" | "modulepreload" | "next" | "pingback" | "preconnect" | "prefetch" | "preload" | "prerender" | "search" | "stylesheet", string>;
|
|
16
|
+
/**
|
|
17
|
+
* Applicable media: "screen", "print", "(max-width: 764px)"
|
|
18
|
+
*/
|
|
19
|
+
media?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Integrity metadata used in Subresource Integrity checks
|
|
22
|
+
*/
|
|
23
|
+
integrity?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Language of the linked resource
|
|
26
|
+
*/
|
|
27
|
+
hrefLang?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Hint for the type of the referenced resource
|
|
30
|
+
*/
|
|
31
|
+
type?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Referrer policy for fetches initiated by the element
|
|
34
|
+
*/
|
|
35
|
+
referrerPolicy?: "" | "no-referrer" | "no-referrer-when-downgrade" | "same-origin" | "origin" | "strict-origin" | "origin-when-cross-origin" | "strict-origin-when-cross-origin" | "unsafe-url";
|
|
36
|
+
/**
|
|
37
|
+
* Sizes of the icons (for rel="icon")
|
|
38
|
+
*/
|
|
39
|
+
sizes?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Potential destination for a preload request (for rel="preload" and rel="modulepreload")
|
|
42
|
+
*/
|
|
43
|
+
as?: LiteralUnion<"audio" | "audioworklet" | "document" | "embed" | "fetch" | "font" | "frame" | "iframe" | "image" | "manifest" | "object" | "paintworklet" | "report" | "script" | "serviceworker" | "sharedworker" | "style" | "track" | "video" | "worker" | "xslt", string>;
|
|
44
|
+
/**
|
|
45
|
+
* Color to use when customizing a site's icon (for rel="mask-icon")
|
|
46
|
+
*/
|
|
47
|
+
color?: string;
|
|
48
|
+
/**
|
|
49
|
+
* Whether the link is disabled
|
|
50
|
+
*/
|
|
51
|
+
disabled?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* The title attribute has special semantics on this element: Title of the link; CSS style sheet set name.
|
|
54
|
+
*/
|
|
55
|
+
title?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Images to use in different situations, e.g., high-resolution displays,
|
|
58
|
+
* small monitors, etc. (for rel="preload")
|
|
59
|
+
*/
|
|
60
|
+
imageSrcSet?: string;
|
|
61
|
+
/**
|
|
62
|
+
* Image sizes for different page layouts (for rel="preload")
|
|
63
|
+
*/
|
|
64
|
+
imageSizes?: string;
|
|
65
|
+
}
|
|
66
|
+
interface HtmlLinkPreloadImage extends HtmlLinkProps {
|
|
67
|
+
/**
|
|
68
|
+
* Relationship between the document containing the hyperlink and the destination resource
|
|
69
|
+
*/
|
|
70
|
+
rel: "preload";
|
|
71
|
+
/**
|
|
72
|
+
* Potential destination for a preload request (for rel="preload" and rel="modulepreload")
|
|
73
|
+
*/
|
|
74
|
+
as: "image";
|
|
75
|
+
/**
|
|
76
|
+
* Address of the hyperlink
|
|
77
|
+
*/
|
|
78
|
+
href?: string;
|
|
79
|
+
/**
|
|
80
|
+
* Images to use in different situations, e.g., high-resolution displays,
|
|
81
|
+
* small monitors, etc. (for rel="preload")
|
|
82
|
+
*/
|
|
83
|
+
imageSrcSet: string;
|
|
84
|
+
/**
|
|
85
|
+
* Image sizes for different page layouts (for rel="preload")
|
|
86
|
+
*/
|
|
87
|
+
imageSizes?: string;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Represents a `<link>` element.
|
|
91
|
+
*
|
|
92
|
+
* WHATWG Specification: https://html.spec.whatwg.org/multipage/semantics.html#the-link-element
|
|
93
|
+
*/
|
|
94
|
+
export type HtmlLinkDescriptor = (HtmlLinkProps & Pick<Required<HtmlLinkProps>, "href">) | (HtmlLinkPreloadImage & Pick<Required<HtmlLinkPreloadImage>, "imageSizes">) | (HtmlLinkPreloadImage & Pick<Required<HtmlLinkPreloadImage>, "href"> & {
|
|
95
|
+
imageSizes?: never;
|
|
96
|
+
});
|
|
97
|
+
export interface PageLinkDescriptor extends Omit<HtmlLinkDescriptor, "href" | "rel" | "type" | "sizes" | "imageSrcSet" | "imageSizes" | "as" | "color" | "title"> {
|
|
98
|
+
/**
|
|
99
|
+
* The absolute path of the page to prefetch.
|
|
100
|
+
*/
|
|
101
|
+
page: string;
|
|
102
|
+
}
|
|
103
|
+
export type LinkDescriptor = HtmlLinkDescriptor | PageLinkDescriptor;
|
|
104
|
+
export {};
|