UNPKG

33.6 kBTypeScriptView Raw
1import { R as RouteModules, a as Router, D as DataStrategyFunction, A as ActionFunction, L as LoaderFunction, C as ClientActionFunction, b as ClientLoaderFunction, c as LinksFunction, M as MetaFunction, d as RouteManifest, e as LoaderFunctionArgs, f as ActionFunctionArgs, T as To, g as RelativeRoutingType, h as Location, i as Action, P as ParamParseKey, j as Path, k as PathPattern, l as PathMatch, N as NavigateOptions, m as Params, n as RouteObject, o as Navigation, p as RevalidationState, U as UIMatch, S as SerializeFrom, B as BlockerFunction, q as Blocker, r as StaticHandlerContext, s as StaticHandler, F as FutureConfig$1, t as CreateStaticHandlerOptions$1, I as InitialEntry, H as HydrationState, u as IndexRouteObject, v as NonIndexRouteObject, w as RouterState } from './route-data-DuV3tXo2.js';
2export { ap as ClientActionFunctionArgs, aq as ClientLoaderFunctionArgs, aj as DataRouteMatch, ak as DataRouteObject, Q as DataStrategyFunctionArgs, V as DataStrategyMatch, W as DataStrategyResult, Y as ErrorResponse, y as Fetcher, Z as FormEncType, _ as FormMethod, G as GetScrollPositionFunction, x as GetScrollRestorationKeyFunction, $ as HTMLFormMethod, au as HtmlLinkDescriptor, a9 as IDLE_BLOCKER, a8 as IDLE_FETCHER, a7 as IDLE_NAVIGATION, a0 as LazyRouteFunction, av as LinkDescriptor, ar as MetaArgs, as as MetaDescriptor, z as NavigationStates, al as Navigator, at as PageLinkDescriptor, am as PatchRoutesOnNavigationFunction, an as PatchRoutesOnNavigationFunctionArgs, a1 as PathParam, a2 as RedirectFunction, ao as RouteMatch, O as RouterFetchOptions, E as RouterInit, K as RouterNavigateOptions, J as RouterSubscriber, a3 as ShouldRevalidateFunction, a4 as ShouldRevalidateFunctionArgs, aA as UNSAFE_DataRouterContext, aB as UNSAFE_DataRouterStateContext, X as UNSAFE_DataWithResponseInit, az as UNSAFE_ErrorResponseImpl, aC as UNSAFE_FetchersContext, aD as UNSAFE_LocationContext, aE as UNSAFE_NavigationContext, aF as UNSAFE_RouteContext, aG as UNSAFE_ViewTransitionContext, aw as UNSAFE_createBrowserHistory, ay as UNSAFE_createRouter, ax as UNSAFE_invariant, a5 as createPath, aa as data, ab as generatePath, ac as isRouteErrorResponse, ad as matchPath, ae as matchRoutes, a6 as parsePath, af as redirect, ag as redirectDocument, ah as replace, ai as resolvePath } from './route-data-DuV3tXo2.js';
3import { A as AssetsManifest, a as Route, F as FutureConfig, E as EntryContext } from './fog-of-war-CbNQuoo8.js';
4export { f as Await, b as AwaitProps, G as BrowserRouter, B as BrowserRouterProps, u as FetcherFormProps, y as FetcherSubmitFunction, a3 as FetcherSubmitOptions, z as FetcherWithComponents, U as Form, v as FormProps, J as HashRouter, H as HashRouterProps, p as HistoryRouterProps, I as IndexRouteProps, L as LayoutRouteProps, K as Link, q as LinkProps, aa as Links, g as MemoryRouter, M as MemoryRouterProps, a9 as Meta, T as NavLink, s as NavLinkProps, t as NavLinkRenderProps, h as Navigate, N as NavigateProps, i as Outlet, O as OutletProps, a4 as ParamKeyValuePair, P as PathRouteProps, ac as PrefetchPageLinks, j as Route, c as RouteProps, k as Router, d as RouterProps, l as RouterProvider, R as RouterProviderProps, m as Routes, e as RoutesProps, ab as Scripts, ad as ScriptsProps, V as ScrollRestoration, S as ScrollRestorationProps, w as SetURLSearchParams, x as SubmitFunction, a5 as SubmitOptions, a7 as SubmitTarget, af as UNSAFE_FrameworkContext, ai as UNSAFE_createClientRoutes, aj as UNSAFE_createClientRoutesWithHMRRevalidationOptOut, ag as UNSAFE_getPatchRoutesOnNavigationFunction, ae as UNSAFE_mapRouteProperties, ak as UNSAFE_shouldHydrateRouteLoader, ah as UNSAFE_useFogOFWarDiscovery, al as UNSAFE_useScrollRestoration, a6 as URLSearchParamsInit, C as createBrowserRouter, D as createHashRouter, n as createMemoryRouter, o as createRoutesFromChildren, o as createRoutesFromElements, a8 as createSearchParams, r as renderMatches, Q as unstable_HistoryRouter, a1 as unstable_usePrompt, a0 as useBeforeUnload, _ as useFetcher, $ as useFetchers, Z as useFormAction, W as useLinkClickHandler, X as useSearchParams, Y as useSubmit, a2 as useViewTransitionState } from './fog-of-war-CbNQuoo8.js';
5import * as React from 'react';
6import { ReactElement } from 'react';
7import { ParseOptions, SerializeOptions } from 'cookie';
8export { ParseOptions as CookieParseOptions, SerializeOptions as CookieSerializeOptions } from 'cookie';
9import { A as AppLoadContext$1 } from './data-CQbyyGzl.js';
10
11declare const SingleFetchRedirectSymbol: unique symbol;
12declare function getSingleFetchDataStrategy(manifest: AssetsManifest, routeModules: RouteModules, getRouter: () => Router): DataStrategyFunction;
13declare function decodeViaTurboStream(body: ReadableStream<Uint8Array>, global: Window | typeof globalThis): Promise<{
14 done: Promise<undefined>;
15 value: unknown;
16}>;
17
18/**
19 * The mode to use when running the server.
20 */
21declare enum ServerMode {
22 Development = "development",
23 Production = "production",
24 Test = "test"
25}
26
27type HeadersArgs = {
28 loaderHeaders: Headers;
29 parentHeaders: Headers;
30 actionHeaders: Headers;
31 errorHeaders: Headers | undefined;
32};
33/**
34 * A function that returns HTTP headers to be used for a route. These headers
35 * will be merged with (and take precedence over) headers from parent routes.
36 */
37interface HeadersFunction {
38 (args: HeadersArgs): Headers | HeadersInit;
39}
40/**
41 * An arbitrary object that is associated with a route.
42 */
43type RouteHandle = unknown;
44interface EntryRouteModule {
45 clientAction?: ClientActionFunction;
46 clientLoader?: ClientLoaderFunction;
47 ErrorBoundary?: any;
48 HydrateFallback?: any;
49 Layout?: any;
50 default: any;
51 handle?: RouteHandle;
52 links?: LinksFunction;
53 meta?: MetaFunction;
54}
55interface ServerRouteModule extends EntryRouteModule {
56 action?: ActionFunction;
57 headers?: HeadersFunction | {
58 [name: string]: string;
59 };
60 loader?: LoaderFunction;
61}
62
63type ServerRouteManifest = RouteManifest<Omit<ServerRoute, "children">>;
64interface ServerRoute extends Route {
65 children: ServerRoute[];
66 module: ServerRouteModule;
67}
68
69/**
70 * The output of the compiler for the server build.
71 */
72interface ServerBuild {
73 entry: {
74 module: ServerEntryModule;
75 };
76 routes: ServerRouteManifest;
77 assets: AssetsManifest;
78 basename?: string;
79 publicPath: string;
80 assetsBuildDirectory: string;
81 future: FutureConfig;
82 isSpaMode: boolean;
83}
84interface HandleDocumentRequestFunction {
85 (request: Request, responseStatusCode: number, responseHeaders: Headers, context: EntryContext, loadContext: AppLoadContext$1): Promise<Response> | Response;
86}
87interface HandleDataRequestFunction {
88 (response: Response, args: LoaderFunctionArgs | ActionFunctionArgs): Promise<Response> | Response;
89}
90interface HandleErrorFunction {
91 (error: unknown, args: LoaderFunctionArgs | ActionFunctionArgs): void;
92}
93/**
94 * A module that serves as the entry point for a Remix app during server
95 * rendering.
96 */
97interface ServerEntryModule {
98 default: HandleDocumentRequestFunction;
99 handleDataRequest?: HandleDataRequestFunction;
100 handleError?: HandleErrorFunction;
101 streamTimeout?: number;
102}
103
104/**
105 Resolves a URL against the current location.
106
107 ```tsx
108 import { useHref } from "react-router"
109
110 function SomeComponent() {
111 let href = useHref("some/where");
112 // "/resolved/some/where"
113 }
114 ```
115
116 @category Hooks
117 */
118declare function useHref(to: To, { relative }?: {
119 relative?: RelativeRoutingType;
120}): string;
121/**
122 * Returns true if this component is a descendant of a Router, useful to ensure
123 * a component is used within a Router.
124 *
125 * @category Hooks
126 */
127declare function useInRouterContext(): boolean;
128/**
129 Returns the current {@link Location}. This can be useful if you'd like to perform some side effect whenever it changes.
130
131 ```tsx
132 import * as React from 'react'
133 import { useLocation } from 'react-router'
134
135 function SomeComponent() {
136 let location = useLocation()
137
138 React.useEffect(() => {
139 // Google Analytics
140 ga('send', 'pageview')
141 }, [location]);
142
143 return (
144 // ...
145 );
146 }
147 ```
148
149 @category Hooks
150 */
151declare function useLocation(): Location;
152/**
153 * Returns the current navigation action which describes how the router came to
154 * the current location, either by a pop, push, or replace on the history stack.
155 *
156 * @category Hooks
157 */
158declare function useNavigationType(): Action;
159/**
160 * Returns a PathMatch object if the given pattern matches the current URL.
161 * This is useful for components that need to know "active" state, e.g.
162 * `<NavLink>`.
163 *
164 * @category Hooks
165 */
166declare function useMatch<ParamKey extends ParamParseKey<Path>, Path extends string>(pattern: PathPattern<Path> | Path): PathMatch<ParamKey> | null;
167/**
168 * The interface for the navigate() function returned from useNavigate().
169 */
170interface NavigateFunction {
171 (to: To, options?: NavigateOptions): void | Promise<void>;
172 (delta: number): void | Promise<void>;
173}
174/**
175 Returns a function that lets you navigate programmatically in the browser in response to user interactions or effects.
176
177 ```tsx
178 import { useNavigate } from "react-router";
179
180 function SomeComponent() {
181 let navigate = useNavigate();
182 return (
183 <button
184 onClick={() => {
185 navigate(-1);
186 }}
187 />
188 );
189 }
190 ```
191
192 It's often better to use {@link redirect} in {@link ActionFunction | actions} and {@link LoaderFunction | loaders} than this hook.
193
194 @category Hooks
195 */
196declare function useNavigate(): NavigateFunction;
197/**
198 * Returns the parent route {@link OutletProps.context | `<Outlet context>`}.
199 *
200 * @category Hooks
201 */
202declare function useOutletContext<Context = unknown>(): Context;
203/**
204 * Returns the element for the child route at this level of the route
205 * hierarchy. Used internally by `<Outlet>` to render child routes.
206 *
207 * @category Hooks
208 */
209declare function useOutlet(context?: unknown): React.ReactElement | null;
210/**
211 Returns an object of key/value pairs of the dynamic params from the current URL that were matched by the routes. Child routes inherit all params from their parent routes.
212
213 ```tsx
214 import { useParams } from "react-router"
215
216 function SomeComponent() {
217 let params = useParams()
218 params.postId
219 }
220 ```
221
222 Assuming a route pattern like `/posts/:postId` is matched by `/posts/123` then `params.postId` will be `"123"`.
223
224 @category Hooks
225 */
226declare function useParams<ParamsOrKey extends string | Record<string, string | undefined> = string>(): Readonly<[
227 ParamsOrKey
228] extends [string] ? Params<ParamsOrKey> : Partial<ParamsOrKey>>;
229/**
230 Resolves the pathname of the given `to` value against the current location. Similar to {@link useHref}, but returns a {@link Path} instead of a string.
231
232 ```tsx
233 import { useResolvedPath } from "react-router"
234
235 function SomeComponent() {
236 // if the user is at /dashboard/profile
237 let path = useResolvedPath("../accounts")
238 path.pathname // "/dashboard/accounts"
239 path.search // ""
240 path.hash // ""
241 }
242 ```
243
244 @category Hooks
245 */
246declare function useResolvedPath(to: To, { relative }?: {
247 relative?: RelativeRoutingType;
248}): Path;
249/**
250 Hook version of {@link Routes | `<Routes>`} that uses objects instead of components. These objects have the same properties as the component props.
251
252 The return value of `useRoutes` is either a valid React element you can use to render the route tree, or `null` if nothing matched.
253
254 ```tsx
255 import * as React from "react";
256 import { useRoutes } from "react-router";
257
258 function App() {
259 let element = useRoutes([
260 {
261 path: "/",
262 element: <Dashboard />,
263 children: [
264 {
265 path: "messages",
266 element: <DashboardMessages />,
267 },
268 { path: "tasks", element: <DashboardTasks /> },
269 ],
270 },
271 { path: "team", element: <AboutPage /> },
272 ]);
273
274 return element;
275 }
276 ```
277
278 @category Hooks
279 */
280declare function useRoutes(routes: RouteObject[], locationArg?: Partial<Location> | string): React.ReactElement | null;
281/**
282 Returns the current navigation, defaulting to an "idle" navigation when no navigation is in progress. You can use this to render pending UI (like a global spinner) or read FormData from a form navigation.
283
284 ```tsx
285 import { useNavigation } from "react-router"
286
287 function SomeComponent() {
288 let navigation = useNavigation();
289 navigation.state
290 navigation.formData
291 // etc.
292 }
293 ```
294
295 @category Hooks
296 */
297declare function useNavigation(): Navigation;
298/**
299 Revalidate the data on the page for reasons outside of normal data mutations like window focus or polling on an interval.
300
301 ```tsx
302 import { useRevalidator } from "react-router";
303
304 function WindowFocusRevalidator() {
305 const revalidator = useRevalidator();
306
307 useFakeWindowFocus(() => {
308 revalidator.revalidate();
309 });
310
311 return (
312 <div hidden={revalidator.state === "idle"}>
313 Revalidating...
314 </div>
315 );
316 }
317 ```
318
319 Note that page data is already revalidated automatically after actions. If you find yourself using this for normal CRUD operations on your data in response to user interactions, you're probably not taking advantage of the other APIs like {@link useFetcher}, {@link Form}, {@link useSubmit} that do this automatically.
320
321 @category Hooks
322 */
323declare function useRevalidator(): {
324 revalidate(): Promise<void>;
325 state: RevalidationState;
326};
327/**
328 * Returns the active route matches, useful for accessing loaderData for
329 * parent/child routes or the route "handle" property
330 *
331 * @category Hooks
332 */
333declare function useMatches(): UIMatch[];
334/**
335 Returns the data from the closest route {@link LoaderFunction | loader} or {@link ClientLoaderFunction | client loader}.
336
337 ```tsx
338 import { useLoaderData } from "react-router"
339
340 export async function loader() {
341 return await fakeDb.invoices.findAll();
342 }
343
344 export default function Invoices() {
345 let invoices = useLoaderData<typeof loader>();
346 // ...
347 }
348 ```
349
350 @category Hooks
351 */
352declare function useLoaderData<T = any>(): SerializeFrom<T>;
353/**
354 Returns the loader data for a given route by route ID.
355
356 ```tsx
357 import { useRouteLoaderData } from "react-router";
358
359 function SomeComponent() {
360 const { user } = useRouteLoaderData("root");
361 }
362 ```
363
364 Route IDs are created automatically. They are simply the path of the route file relative to the app folder without the extension.
365
366 | Route Filename | Route ID |
367 | -------------------------- | -------------------- |
368 | `app/root.tsx` | `"root"` |
369 | `app/routes/teams.tsx` | `"routes/teams"` |
370 | `app/whatever/teams.$id.tsx` | `"whatever/teams.$id"` |
371
372 If you created an ID manually, you can use that instead:
373
374 ```tsx
375 route("/", "containers/app.tsx", { id: "app" }})
376 ```
377
378 @category Hooks
379 */
380declare function useRouteLoaderData<T = any>(routeId: string): SerializeFrom<T> | undefined;
381/**
382 Returns the action data from the most recent POST navigation form submission or `undefined` if there hasn't been one.
383
384 ```tsx
385 import { Form, useActionData } from "react-router"
386
387 export async function action({ request }) {
388 const body = await request.formData()
389 const name = body.get("visitorsName")
390 return { message: `Hello, ${name}` }
391 }
392
393 export default function Invoices() {
394 const data = useActionData()
395 return (
396 <Form method="post">
397 <input type="text" name="visitorsName" />
398 {data ? data.message : "Waiting..."}
399 </Form>
400 )
401 }
402 ```
403
404 @category Hooks
405 */
406declare function useActionData<T = any>(): SerializeFrom<T> | undefined;
407/**
408 Accesses the error thrown during an {@link ActionFunction | action}, {@link LoaderFunction | loader}, or component render to be used in a route module Error Boundary.
409
410 ```tsx
411 export function ErrorBoundary() {
412 const error = useRouteError();
413 return <div>{error.message}</div>;
414 }
415 ```
416
417 @category Hooks
418 */
419declare function useRouteError(): unknown;
420/**
421 Returns the resolved promise value from the closest {@link Await | `<Await>`}.
422
423 ```tsx
424 function SomeDescendant() {
425 const value = useAsyncValue();
426 // ...
427 }
428
429 // somewhere in your app
430 <Await resolve={somePromise}>
431 <SomeDescendant />
432 </Await>
433 ```
434
435 @category Hooks
436 */
437declare function useAsyncValue(): unknown;
438/**
439 Returns the rejection value from the closest {@link Await | `<Await>`}.
440
441 ```tsx
442 import { Await, useAsyncError } from "react-router"
443
444 function ErrorElement() {
445 const error = useAsyncError();
446 return (
447 <p>Uh Oh, something went wrong! {error.message}</p>
448 );
449 }
450
451 // somewhere in your app
452 <Await
453 resolve={promiseThatRejects}
454 errorElement={<ErrorElement />}
455 />
456 ```
457
458 @category Hooks
459 */
460declare function useAsyncError(): unknown;
461/**
462 * Allow the application to block navigations within the SPA and present the
463 * user a confirmation dialog to confirm the navigation. Mostly used to avoid
464 * using half-filled form data. This does not handle hard-reloads or
465 * cross-origin navigations.
466 *
467 * @category Hooks
468 */
469declare function useBlocker(shouldBlock: boolean | BlockerFunction): Blocker;
470
471interface StaticRouterProps {
472 basename?: string;
473 children?: React.ReactNode;
474 location: Partial<Location> | string;
475}
476/**
477 * A `<Router>` that may not navigate to any other location. This is useful
478 * on the server where there is no stateful UI.
479 *
480 * @category Router Components
481 */
482declare function StaticRouter({ basename, children, location: locationProp, }: StaticRouterProps): React.JSX.Element;
483interface StaticRouterProviderProps {
484 context: StaticHandlerContext;
485 router: Router;
486 hydrate?: boolean;
487 nonce?: string;
488}
489/**
490 * A Data Router that may not navigate to any other location. This is useful
491 * on the server where there is no stateful UI.
492 *
493 * @category Router Components
494 */
495declare function StaticRouterProvider({ context, router, hydrate, nonce, }: StaticRouterProviderProps): React.JSX.Element;
496type CreateStaticHandlerOptions = Omit<CreateStaticHandlerOptions$1, "mapRouteProperties">;
497/**
498 * @category Utils
499 */
500declare function createStaticHandler(routes: RouteObject[], opts?: CreateStaticHandlerOptions): StaticHandler;
501/**
502 * @category Routers
503 */
504declare function createStaticRouter(routes: RouteObject[], context: StaticHandlerContext, opts?: {
505 future?: Partial<FutureConfig$1>;
506}): Router;
507
508interface ServerRouterProps {
509 context: EntryContext;
510 url: string | URL;
511 abortDelay?: number;
512 nonce?: string;
513}
514/**
515 * The entry point for a Remix app when it is rendered on the server (in
516 * `app/entry.server.js`). This component is used to generate the HTML in the
517 * response from the server.
518 *
519 * @category Components
520 */
521declare function ServerRouter({ context, url, abortDelay, nonce, }: ServerRouterProps): ReactElement;
522
523interface StubIndexRouteObject extends Omit<IndexRouteObject, "loader" | "action" | "element" | "errorElement" | "children"> {
524 loader?: LoaderFunction;
525 action?: ActionFunction;
526 children?: StubRouteObject[];
527 meta?: MetaFunction;
528 links?: LinksFunction;
529}
530interface StubNonIndexRouteObject extends Omit<NonIndexRouteObject, "loader" | "action" | "element" | "errorElement" | "children"> {
531 loader?: LoaderFunction;
532 action?: ActionFunction;
533 children?: StubRouteObject[];
534 meta?: MetaFunction;
535 links?: LinksFunction;
536}
537type StubRouteObject = StubIndexRouteObject | StubNonIndexRouteObject;
538interface AppLoadContext {
539 [key: string]: unknown;
540}
541interface RoutesTestStubProps {
542 /**
543 * The initial entries in the history stack. This allows you to start a test with
544 * multiple locations already in the history stack (for testing a back navigation, etc.)
545 * The test will default to the last entry in initialEntries if no initialIndex is provided.
546 * e.g. initialEntries={["/home", "/about", "/contact"]}
547 */
548 initialEntries?: InitialEntry[];
549 /**
550 * The initial index in the history stack to render. This allows you to start a test at a specific entry.
551 * It defaults to the last entry in initialEntries.
552 * e.g.
553 * initialEntries: ["/", "/events/123"]
554 * initialIndex: 1 // start at "/events/123"
555 */
556 initialIndex?: number;
557 /**
558 * Used to set the route's initial loader and action data.
559 * e.g. hydrationData={{
560 * loaderData: { "/contact": { locale: "en-US" } },
561 * actionData: { "/login": { errors: { email: "invalid email" } }}
562 * }}
563 */
564 hydrationData?: HydrationState;
565 /**
566 * Future flags mimicking the settings in react-router.config.ts
567 */
568 future?: Partial<FutureConfig>;
569}
570/**
571 * @category Utils
572 */
573declare function createRoutesStub(routes: StubRouteObject[], context?: AppLoadContext): ({ initialEntries, initialIndex, hydrationData, future, }: RoutesTestStubProps) => React.JSX.Element;
574
575interface CookieSignatureOptions {
576 /**
577 * An array of secrets that may be used to sign/unsign the value of a cookie.
578 *
579 * The array makes it easy to rotate secrets. New secrets should be added to
580 * the beginning of the array. `cookie.serialize()` will always use the first
581 * value in the array, but `cookie.parse()` may use any of them so that
582 * cookies that were signed with older secrets still work.
583 */
584 secrets?: string[];
585}
586type CookieOptions = ParseOptions & SerializeOptions & CookieSignatureOptions;
587/**
588 * A HTTP cookie.
589 *
590 * A Cookie is a logical container for metadata about a HTTP cookie; its name
591 * and options. But it doesn't contain a value. Instead, it has `parse()` and
592 * `serialize()` methods that allow a single instance to be reused for
593 * parsing/encoding multiple different values.
594 *
595 * @see https://remix.run/utils/cookies#cookie-api
596 */
597interface Cookie {
598 /**
599 * The name of the cookie, used in the `Cookie` and `Set-Cookie` headers.
600 */
601 readonly name: string;
602 /**
603 * True if this cookie uses one or more secrets for verification.
604 */
605 readonly isSigned: boolean;
606 /**
607 * The Date this cookie expires.
608 *
609 * Note: This is calculated at access time using `maxAge` when no `expires`
610 * option is provided to `createCookie()`.
611 */
612 readonly expires?: Date;
613 /**
614 * Parses a raw `Cookie` header and returns the value of this cookie or
615 * `null` if it's not present.
616 */
617 parse(cookieHeader: string | null, options?: ParseOptions): Promise<any>;
618 /**
619 * Serializes the given value to a string and returns the `Set-Cookie`
620 * header.
621 */
622 serialize(value: any, options?: SerializeOptions): Promise<string>;
623}
624/**
625 * Creates a logical container for managing a browser cookie from the server.
626 */
627declare const createCookie: (name: string, cookieOptions?: CookieOptions) => Cookie;
628type IsCookieFunction = (object: any) => object is Cookie;
629/**
630 * Returns true if an object is a Remix cookie container.
631 *
632 * @see https://remix.run/utils/cookies#iscookie
633 */
634declare const isCookie: IsCookieFunction;
635
636type RequestHandler = (request: Request, loadContext?: AppLoadContext$1) => Promise<Response>;
637type CreateRequestHandlerFunction = (build: ServerBuild | (() => ServerBuild | Promise<ServerBuild>), mode?: string) => RequestHandler;
638declare const createRequestHandler: CreateRequestHandlerFunction;
639
640/**
641 * An object of name/value pairs to be used in the session.
642 */
643interface SessionData {
644 [name: string]: any;
645}
646/**
647 * Session persists data across HTTP requests.
648 *
649 * @see https://remix.run/utils/sessions#session-api
650 */
651interface Session<Data = SessionData, FlashData = Data> {
652 /**
653 * A unique identifier for this session.
654 *
655 * Note: This will be the empty string for newly created sessions and
656 * sessions that are not backed by a database (i.e. cookie-based sessions).
657 */
658 readonly id: string;
659 /**
660 * The raw data contained in this session.
661 *
662 * This is useful mostly for SessionStorage internally to access the raw
663 * session data to persist.
664 */
665 readonly data: FlashSessionData<Data, FlashData>;
666 /**
667 * Returns `true` if the session has a value for the given `name`, `false`
668 * otherwise.
669 */
670 has(name: (keyof Data | keyof FlashData) & string): boolean;
671 /**
672 * Returns the value for the given `name` in this session.
673 */
674 get<Key extends (keyof Data | keyof FlashData) & string>(name: Key): (Key extends keyof Data ? Data[Key] : undefined) | (Key extends keyof FlashData ? FlashData[Key] : undefined) | undefined;
675 /**
676 * Sets a value in the session for the given `name`.
677 */
678 set<Key extends keyof Data & string>(name: Key, value: Data[Key]): void;
679 /**
680 * Sets a value in the session that is only valid until the next `get()`.
681 * This can be useful for temporary values, like error messages.
682 */
683 flash<Key extends keyof FlashData & string>(name: Key, value: FlashData[Key]): void;
684 /**
685 * Removes a value from the session.
686 */
687 unset(name: keyof Data & string): void;
688}
689type FlashSessionData<Data, FlashData> = Partial<Data & {
690 [Key in keyof FlashData as FlashDataKey<Key & string>]: FlashData[Key];
691}>;
692type FlashDataKey<Key extends string> = `__flash_${Key}__`;
693type CreateSessionFunction = <Data = SessionData, FlashData = Data>(initialData?: Data, id?: string) => Session<Data, FlashData>;
694/**
695 * Creates a new Session object.
696 *
697 * Note: This function is typically not invoked directly by application code.
698 * Instead, use a `SessionStorage` object's `getSession` method.
699 *
700 * @see https://remix.run/utils/sessions#createsession
701 */
702declare const createSession: CreateSessionFunction;
703type IsSessionFunction = (object: any) => object is Session;
704/**
705 * Returns true if an object is a Remix session.
706 *
707 * @see https://remix.run/utils/sessions#issession
708 */
709declare const isSession: IsSessionFunction;
710/**
711 * SessionStorage stores session data between HTTP requests and knows how to
712 * parse and create cookies.
713 *
714 * A SessionStorage creates Session objects using a `Cookie` header as input.
715 * Then, later it generates the `Set-Cookie` header to be used in the response.
716 */
717interface SessionStorage<Data = SessionData, FlashData = Data> {
718 /**
719 * Parses a Cookie header from a HTTP request and returns the associated
720 * Session. If there is no session associated with the cookie, this will
721 * return a new Session with no data.
722 */
723 getSession: (cookieHeader?: string | null, options?: ParseOptions) => Promise<Session<Data, FlashData>>;
724 /**
725 * Stores all data in the Session and returns the Set-Cookie header to be
726 * used in the HTTP response.
727 */
728 commitSession: (session: Session<Data, FlashData>, options?: SerializeOptions) => Promise<string>;
729 /**
730 * Deletes all data associated with the Session and returns the Set-Cookie
731 * header to be used in the HTTP response.
732 */
733 destroySession: (session: Session<Data, FlashData>, options?: SerializeOptions) => Promise<string>;
734}
735/**
736 * SessionIdStorageStrategy is designed to allow anyone to easily build their
737 * own SessionStorage using `createSessionStorage(strategy)`.
738 *
739 * This strategy describes a common scenario where the session id is stored in
740 * a cookie but the actual session data is stored elsewhere, usually in a
741 * database or on disk. A set of create, read, update, and delete operations
742 * are provided for managing the session data.
743 */
744interface SessionIdStorageStrategy<Data = SessionData, FlashData = Data> {
745 /**
746 * The Cookie used to store the session id, or options used to automatically
747 * create one.
748 */
749 cookie?: Cookie | (CookieOptions & {
750 name?: string;
751 });
752 /**
753 * Creates a new record with the given data and returns the session id.
754 */
755 createData: (data: FlashSessionData<Data, FlashData>, expires?: Date) => Promise<string>;
756 /**
757 * Returns data for a given session id, or `null` if there isn't any.
758 */
759 readData: (id: string) => Promise<FlashSessionData<Data, FlashData> | null>;
760 /**
761 * Updates data for the given session id.
762 */
763 updateData: (id: string, data: FlashSessionData<Data, FlashData>, expires?: Date) => Promise<void>;
764 /**
765 * Deletes data for a given session id from the data store.
766 */
767 deleteData: (id: string) => Promise<void>;
768}
769/**
770 * Creates a SessionStorage object using a SessionIdStorageStrategy.
771 *
772 * Note: This is a low-level API that should only be used if none of the
773 * existing session storage options meet your requirements.
774 */
775declare function createSessionStorage<Data = SessionData, FlashData = Data>({ cookie: cookieArg, createData, readData, updateData, deleteData, }: SessionIdStorageStrategy<Data, FlashData>): SessionStorage<Data, FlashData>;
776
777interface CookieSessionStorageOptions {
778 /**
779 * The Cookie used to store the session data on the client, or options used
780 * to automatically create one.
781 */
782 cookie?: SessionIdStorageStrategy["cookie"];
783}
784/**
785 * Creates and returns a SessionStorage object that stores all session data
786 * directly in the session cookie itself.
787 *
788 * This has the advantage that no database or other backend services are
789 * needed, and can help to simplify some load-balanced scenarios. However, it
790 * also has the limitation that serialized session data may not exceed the
791 * browser's maximum cookie size. Trade-offs!
792 */
793declare function createCookieSessionStorage<Data = SessionData, FlashData = Data>({ cookie: cookieArg }?: CookieSessionStorageOptions): SessionStorage<Data, FlashData>;
794
795interface MemorySessionStorageOptions {
796 /**
797 * The Cookie used to store the session id on the client, or options used
798 * to automatically create one.
799 */
800 cookie?: SessionIdStorageStrategy["cookie"];
801}
802/**
803 * Creates and returns a simple in-memory SessionStorage object, mostly useful
804 * for testing and as a reference implementation.
805 *
806 * Note: This storage does not scale beyond a single process, so it is not
807 * suitable for most production scenarios.
808 */
809declare function createMemorySessionStorage<Data = SessionData, FlashData = Data>({ cookie }?: MemorySessionStorageOptions): SessionStorage<Data, FlashData>;
810
811type DevServerHooks = {
812 getCriticalCss?: (build: ServerBuild, pathname: string) => Promise<string | undefined>;
813 processRequestError?: (error: unknown) => void;
814};
815declare function setDevServerHooks(devServerHooks: DevServerHooks): void;
816
817declare function deserializeErrors(errors: RouterState["errors"]): RouterState["errors"];
818
819type RemixErrorBoundaryProps = React.PropsWithChildren<{
820 location: Location;
821 isOutsideRemixApp?: boolean;
822 error?: Error;
823}>;
824type RemixErrorBoundaryState = {
825 error: null | Error;
826 location: Location;
827};
828declare class RemixErrorBoundary extends React.Component<RemixErrorBoundaryProps, RemixErrorBoundaryState> {
829 constructor(props: RemixErrorBoundaryProps);
830 static getDerivedStateFromError(error: Error): {
831 error: Error;
832 };
833 static getDerivedStateFromProps(props: RemixErrorBoundaryProps, state: RemixErrorBoundaryState): {
834 error: Error | null;
835 location: Location<any>;
836 };
837 render(): string | number | boolean | Iterable<React.ReactNode> | React.JSX.Element | null | undefined;
838}
839
840export { ActionFunction, ActionFunctionArgs, AppLoadContext$1 as AppLoadContext, Blocker, BlockerFunction, ClientActionFunction, ClientLoaderFunction, type Cookie, type CookieOptions, type CookieSignatureOptions, type CreateRequestHandlerFunction, Router as DataRouter, DataStrategyFunction, EntryContext, type FlashSessionData, type HandleDataRequestFunction, type HandleDocumentRequestFunction, type HandleErrorFunction, type HeadersArgs, type HeadersFunction, HydrationState, IndexRouteObject, InitialEntry, type IsCookieFunction, type IsSessionFunction, LinksFunction, LoaderFunction, LoaderFunctionArgs, Location, MetaFunction, type NavigateFunction, NavigateOptions, Navigation, Action as NavigationType, NonIndexRouteObject, ParamParseKey, Params, Path, PathMatch, PathPattern, RelativeRoutingType, type RequestHandler, RevalidationState, RouteObject, RouterState, type RoutesTestStubProps, type ServerBuild, type ServerEntryModule, ServerRouter, type ServerRouterProps, type Session, type SessionData, type SessionIdStorageStrategy, type SessionStorage, StaticHandler, StaticHandlerContext, StaticRouter, type StaticRouterProps, StaticRouterProvider, type StaticRouterProviderProps, To, UIMatch, AssetsManifest as UNSAFE_AssetsManifest, RemixErrorBoundary as UNSAFE_RemixErrorBoundary, RouteModules as UNSAFE_RouteModules, ServerMode as UNSAFE_ServerMode, SingleFetchRedirectSymbol as UNSAFE_SingleFetchRedirectSymbol, decodeViaTurboStream as UNSAFE_decodeViaTurboStream, deserializeErrors as UNSAFE_deserializeErrors, getSingleFetchDataStrategy as UNSAFE_getSingleFetchDataStrategy, createCookie, createCookieSessionStorage, createMemorySessionStorage, createRequestHandler, createRoutesStub, createSession, createSessionStorage, createStaticHandler, createStaticRouter, isCookie, isSession, setDevServerHooks as unstable_setDevServerHooks, useActionData, useAsyncError, useAsyncValue, useBlocker, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes };