forked from remix-run/react-router
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
349 lines (319 loc) · 8.89 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
// Expose old @remix-run/router API y2
export type { InitialEntry, Location, Path, To } from "./lib/router/history";
export type {
HydrationState,
StaticHandler,
GetScrollPositionFunction,
GetScrollRestorationKeyFunction,
StaticHandlerContext,
Fetcher,
Navigation,
NavigationStates,
RelativeRoutingType,
Blocker,
BlockerFunction,
Router as DataRouter,
RouterState,
RouterInit,
RouterSubscriber,
RouterNavigateOptions,
RouterFetchOptions,
RevalidationState,
} from "./lib/router/router";
export type {
ActionFunction,
ActionFunctionArgs,
DataStrategyFunction,
DataStrategyFunctionArgs,
DataStrategyMatch,
DataStrategyResult,
DataWithResponseInit as UNSAFE_DataWithResponseInit,
ErrorResponse,
FormEncType,
FormMethod,
HTMLFormMethod,
LazyRouteFunction,
LoaderFunction,
LoaderFunctionArgs,
ParamParseKey,
Params,
PathMatch,
PathParam,
PathPattern,
RedirectFunction,
ShouldRevalidateFunction,
ShouldRevalidateFunctionArgs,
UIMatch,
} from "./lib/router/utils";
export {
Action as NavigationType,
createPath,
parsePath,
} from "./lib/router/history";
export {
IDLE_NAVIGATION,
IDLE_FETCHER,
IDLE_BLOCKER,
} from "./lib/router/router";
export {
data,
generatePath,
isRouteErrorResponse,
matchPath,
matchRoutes,
redirect,
redirectDocument,
replace,
resolvePath,
} from "./lib/router/utils";
// Expose react-router public API
export type {
DataRouteMatch,
DataRouteObject,
IndexRouteObject,
NavigateOptions,
Navigator,
NonIndexRouteObject,
PatchRoutesOnNavigationFunction,
PatchRoutesOnNavigationFunctionArgs,
RouteMatch,
RouteObject,
} from "./lib/context";
export type {
AwaitProps,
IndexRouteProps,
LayoutRouteProps,
MemoryRouterProps,
NavigateProps,
OutletProps,
PathRouteProps,
RouteProps,
RouterProps,
RouterProviderProps,
RoutesProps,
} from "./lib/components";
export type { NavigateFunction } from "./lib/hooks";
export {
Await,
MemoryRouter,
Navigate,
Outlet,
Route,
Router,
RouterProvider,
Routes,
createMemoryRouter,
createRoutesFromChildren,
createRoutesFromElements,
renderMatches,
} from "./lib/components";
export {
useBlocker,
useActionData,
useAsyncError,
useAsyncValue,
useHref,
useInRouterContext,
useLoaderData,
useLocation,
useMatch,
useMatches,
useNavigate,
useNavigation,
useNavigationType,
useOutlet,
useOutletContext,
useParams,
useResolvedPath,
useRevalidator,
useRouteError,
useRouteLoaderData,
useRoutes,
} from "./lib/hooks";
// Expose old RR DOM API
export type {
BrowserRouterProps,
HashRouterProps,
HistoryRouterProps,
LinkProps,
NavLinkProps,
NavLinkRenderProps,
FetcherFormProps,
FormProps,
ScrollRestorationProps,
SetURLSearchParams,
SubmitFunction,
FetcherSubmitFunction,
FetcherWithComponents,
} from "./lib/dom/lib";
export {
createBrowserRouter,
createHashRouter,
BrowserRouter,
HashRouter,
Link,
HistoryRouter as unstable_HistoryRouter,
NavLink,
Form,
ScrollRestoration,
useLinkClickHandler,
useSearchParams,
useSubmit,
useFormAction,
useFetcher,
useFetchers,
useBeforeUnload,
usePrompt as unstable_usePrompt,
useViewTransitionState,
} from "./lib/dom/lib";
export type {
FetcherSubmitOptions,
ParamKeyValuePair,
SubmitOptions,
URLSearchParamsInit,
SubmitTarget,
} from "./lib/dom/dom";
export { createSearchParams } from "./lib/dom/dom";
export type {
StaticRouterProps,
StaticRouterProviderProps,
} from "./lib/dom/server";
export {
createStaticHandler,
createStaticRouter,
StaticRouter,
StaticRouterProvider,
} from "./lib/dom/server";
export {
Meta,
Links,
Scripts,
PrefetchPageLinks,
} from "./lib/dom/ssr/components";
export type { ScriptsProps } from "./lib/dom/ssr/components";
export type { EntryContext } from "./lib/dom/ssr/entry";
export type {
ClientActionFunction,
ClientActionFunctionArgs,
ClientLoaderFunction,
ClientLoaderFunctionArgs,
MetaArgs,
MetaDescriptor,
MetaFunction,
LinksFunction,
} from "./lib/dom/ssr/routeModules";
export type { ServerRouterProps } from "./lib/dom/ssr/server";
export { ServerRouter } from "./lib/dom/ssr/server";
export type { RoutesTestStubProps } from "./lib/dom/ssr/routes-test-stub";
export { createRoutesStub } from "./lib/dom/ssr/routes-test-stub";
// Expose old @remix-run/server-runtime API, minus duplicate APIs
export { createCookie, isCookie } from "./lib/server-runtime/cookies";
export { createRequestHandler } from "./lib/server-runtime/server";
export {
createSession,
createSessionStorage,
isSession,
} from "./lib/server-runtime/sessions";
export { createCookieSessionStorage } from "./lib/server-runtime/sessions/cookieStorage";
export { createMemorySessionStorage } from "./lib/server-runtime/sessions/memoryStorage";
export { setDevServerHooks as unstable_setDevServerHooks } from "./lib/server-runtime/dev";
export type { IsCookieFunction } from "./lib/server-runtime/cookies";
export type { CreateRequestHandlerFunction } from "./lib/server-runtime/server";
export type { IsSessionFunction } from "./lib/server-runtime/sessions";
export type {
HandleDataRequestFunction,
HandleDocumentRequestFunction,
HandleErrorFunction,
ServerBuild,
ServerEntryModule,
} from "./lib/server-runtime/build";
export type {
Cookie,
CookieOptions,
CookieParseOptions,
CookieSerializeOptions,
CookieSignatureOptions,
} from "./lib/server-runtime/cookies";
export type { AppLoadContext } from "./lib/server-runtime/data";
export type {
PageLinkDescriptor,
HtmlLinkDescriptor,
LinkDescriptor,
} from "./lib/router/links";
export type {
HeadersArgs,
HeadersFunction,
} from "./lib/server-runtime/routeModules";
export type { RequestHandler } from "./lib/server-runtime/server";
export type {
Session,
SessionData,
SessionIdStorageStrategy,
SessionStorage,
FlashSessionData,
} from "./lib/server-runtime/sessions";
///////////////////////////////////////////////////////////////////////////////
// DANGER! PLEASE READ ME!
// We provide these exports as an escape hatch in the event that you need any
// routing data that we don't provide an explicit API for. With that said, we
// want to cover your use case if we can, so if you feel the need to use these
// we want to hear from you. Let us know what you're building and we'll do our
// best to make sure we can support you!
//
// We consider these exports an implementation detail and do not guarantee
// against any breaking changes, regardless of the semver release. Use with
// extreme caution and only if you understand the consequences. Godspeed.
///////////////////////////////////////////////////////////////////////////////
/** @internal */
export {
createBrowserHistory as UNSAFE_createBrowserHistory,
invariant as UNSAFE_invariant,
} from "./lib/router/history";
/** @internal */
export { createRouter as UNSAFE_createRouter } from "./lib/router/router";
/** @internal */
export { ErrorResponseImpl as UNSAFE_ErrorResponseImpl } from "./lib/router/utils";
/** @internal */
export {
DataRouterContext as UNSAFE_DataRouterContext,
DataRouterStateContext as UNSAFE_DataRouterStateContext,
FetchersContext as UNSAFE_FetchersContext,
LocationContext as UNSAFE_LocationContext,
NavigationContext as UNSAFE_NavigationContext,
RouteContext as UNSAFE_RouteContext,
ViewTransitionContext as UNSAFE_ViewTransitionContext,
} from "./lib/context";
/** @internal */
export { mapRouteProperties as UNSAFE_mapRouteProperties } from "./lib/components";
/** @internal */
export { FrameworkContext as UNSAFE_FrameworkContext } from "./lib/dom/ssr/components";
/** @internal */
export type { AssetsManifest as UNSAFE_AssetsManifest } from "./lib/dom/ssr/entry";
/** @internal */
export { deserializeErrors as UNSAFE_deserializeErrors } from "./lib/dom/ssr/errors";
/** @internal */
export { RemixErrorBoundary as UNSAFE_RemixErrorBoundary } from "./lib/dom/ssr/errorBoundaries";
/** @internal */
export {
getPatchRoutesOnNavigationFunction as UNSAFE_getPatchRoutesOnNavigationFunction,
useFogOFWarDiscovery as UNSAFE_useFogOFWarDiscovery,
} from "./lib/dom/ssr/fog-of-war";
/** @internal */
export type { RouteModules as UNSAFE_RouteModules } from "./lib/dom/ssr/routeModules";
/** @internal */
export {
createClientRoutes as UNSAFE_createClientRoutes,
createClientRoutesWithHMRRevalidationOptOut as UNSAFE_createClientRoutesWithHMRRevalidationOptOut,
shouldHydrateRouteLoader as UNSAFE_shouldHydrateRouteLoader,
} from "./lib/dom/ssr/routes";
/** @internal */
export { getSingleFetchDataStrategy as UNSAFE_getSingleFetchDataStrategy } from "./lib/dom/ssr/single-fetch";
/** @internal */
export {
decodeViaTurboStream as UNSAFE_decodeViaTurboStream,
SingleFetchRedirectSymbol as UNSAFE_SingleFetchRedirectSymbol,
} from "./lib/dom/ssr/single-fetch";
/** @internal */
export { ServerMode as UNSAFE_ServerMode } from "./lib/server-runtime/mode";
/** @internal */
export { useScrollRestoration as UNSAFE_useScrollRestoration } from "./lib/dom/lib";