Push V1 app
This commit is contained in:
+318
@@ -0,0 +1,318 @@
|
||||
import * as React from 'react';
|
||||
import { R as RouterInit } from './instrumentation-Dkmpzd13.js';
|
||||
import { L as Location, C as ClientActionFunction, a as ClientLoaderFunction, b as LinksFunction, M as MetaFunction, S as ShouldRevalidateFunction, P as Params, c as RouterContextProvider, A as ActionFunction, H as HeadersFunction, d as LoaderFunction } from './data-CjO11-hU.js';
|
||||
|
||||
declare function getRequest(): Request;
|
||||
type RSCRouteConfigEntryBase = {
|
||||
action?: ActionFunction;
|
||||
clientAction?: ClientActionFunction;
|
||||
clientLoader?: ClientLoaderFunction;
|
||||
ErrorBoundary?: React.ComponentType<any>;
|
||||
handle?: any;
|
||||
headers?: HeadersFunction;
|
||||
HydrateFallback?: React.ComponentType<any>;
|
||||
Layout?: React.ComponentType<any>;
|
||||
links?: LinksFunction;
|
||||
loader?: LoaderFunction;
|
||||
meta?: MetaFunction;
|
||||
shouldRevalidate?: ShouldRevalidateFunction;
|
||||
};
|
||||
type RSCRouteConfigEntry = RSCRouteConfigEntryBase & {
|
||||
id: string;
|
||||
path?: string;
|
||||
Component?: React.ComponentType<any>;
|
||||
lazy?: () => Promise<RSCRouteConfigEntryBase & ({
|
||||
default?: React.ComponentType<any>;
|
||||
Component?: never;
|
||||
} | {
|
||||
default?: never;
|
||||
Component?: React.ComponentType<any>;
|
||||
})>;
|
||||
} & ({
|
||||
index: true;
|
||||
} | {
|
||||
children?: RSCRouteConfigEntry[];
|
||||
});
|
||||
type RSCRouteConfig = Array<RSCRouteConfigEntry>;
|
||||
type RSCRouteManifest = {
|
||||
clientAction?: ClientActionFunction;
|
||||
clientLoader?: ClientLoaderFunction;
|
||||
element?: React.ReactElement | false;
|
||||
errorElement?: React.ReactElement;
|
||||
handle?: any;
|
||||
hasAction: boolean;
|
||||
hasComponent: boolean;
|
||||
hasErrorBoundary: boolean;
|
||||
hasLoader: boolean;
|
||||
hydrateFallbackElement?: React.ReactElement;
|
||||
id: string;
|
||||
index?: boolean;
|
||||
links?: LinksFunction;
|
||||
meta?: MetaFunction;
|
||||
parentId?: string;
|
||||
path?: string;
|
||||
shouldRevalidate?: ShouldRevalidateFunction;
|
||||
};
|
||||
type RSCRouteMatch = RSCRouteManifest & {
|
||||
params: Params;
|
||||
pathname: string;
|
||||
pathnameBase: string;
|
||||
};
|
||||
type RSCRenderPayload = {
|
||||
type: "render";
|
||||
actionData: Record<string, any> | null;
|
||||
basename: string | undefined;
|
||||
errors: Record<string, any> | null;
|
||||
loaderData: Record<string, any>;
|
||||
location: Location;
|
||||
routeDiscovery: RouteDiscovery;
|
||||
matches: RSCRouteMatch[];
|
||||
patches?: Promise<RSCRouteManifest[]>;
|
||||
nonce?: string;
|
||||
formState?: unknown;
|
||||
};
|
||||
type RSCManifestPayload = {
|
||||
type: "manifest";
|
||||
patches: Promise<RSCRouteManifest[]>;
|
||||
};
|
||||
type RSCActionPayload = {
|
||||
type: "action";
|
||||
actionResult: Promise<unknown>;
|
||||
rerender?: Promise<RSCRenderPayload | RSCRedirectPayload>;
|
||||
};
|
||||
type RSCRedirectPayload = {
|
||||
type: "redirect";
|
||||
status: number;
|
||||
location: string;
|
||||
replace: boolean;
|
||||
reload: boolean;
|
||||
actionResult?: Promise<unknown>;
|
||||
};
|
||||
type RSCPayload = RSCRenderPayload | RSCManifestPayload | RSCActionPayload | RSCRedirectPayload;
|
||||
type RSCMatch = {
|
||||
statusCode: number;
|
||||
headers: Headers;
|
||||
payload: RSCPayload;
|
||||
};
|
||||
type DecodeActionFunction = (formData: FormData) => Promise<() => Promise<unknown>>;
|
||||
type DecodeFormStateFunction = (result: unknown, formData: FormData) => unknown;
|
||||
type DecodeReplyFunction = (reply: FormData | string, options: {
|
||||
temporaryReferences: unknown;
|
||||
}) => Promise<unknown[]>;
|
||||
type LoadServerActionFunction = (id: string) => Promise<Function>;
|
||||
type RouteDiscovery = {
|
||||
mode: "lazy";
|
||||
manifestPath?: string | undefined;
|
||||
} | {
|
||||
mode: "initial";
|
||||
};
|
||||
/**
|
||||
* Matches the given routes to a [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
|
||||
* and returns an [RSC](https://react.dev/reference/rsc/server-components)
|
||||
* [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
|
||||
* encoding an {@link unstable_RSCPayload} for consumption by an [RSC](https://react.dev/reference/rsc/server-components)
|
||||
* enabled client router.
|
||||
*
|
||||
* @example
|
||||
* import {
|
||||
* createTemporaryReferenceSet,
|
||||
* decodeAction,
|
||||
* decodeReply,
|
||||
* loadServerAction,
|
||||
* renderToReadableStream,
|
||||
* } from "@vitejs/plugin-rsc/rsc";
|
||||
* import { unstable_matchRSCServerRequest as matchRSCServerRequest } from "react-router";
|
||||
*
|
||||
* matchRSCServerRequest({
|
||||
* createTemporaryReferenceSet,
|
||||
* decodeAction,
|
||||
* decodeFormState,
|
||||
* decodeReply,
|
||||
* loadServerAction,
|
||||
* request,
|
||||
* routes: routes(),
|
||||
* generateResponse(match) {
|
||||
* return new Response(
|
||||
* renderToReadableStream(match.payload),
|
||||
* {
|
||||
* status: match.statusCode,
|
||||
* headers: match.headers,
|
||||
* }
|
||||
* );
|
||||
* },
|
||||
* });
|
||||
*
|
||||
* @name unstable_matchRSCServerRequest
|
||||
* @public
|
||||
* @category RSC
|
||||
* @mode data
|
||||
* @param opts Options
|
||||
* @param opts.allowedActionOrigins Origin patterns that are allowed to execute actions.
|
||||
* @param opts.basename The basename to use when matching the request.
|
||||
* @param opts.createTemporaryReferenceSet A function that returns a temporary
|
||||
* reference set for the request, used to track temporary references in the [RSC](https://react.dev/reference/rsc/server-components)
|
||||
* stream.
|
||||
* @param opts.decodeAction Your `react-server-dom-xyz/server`'s `decodeAction`
|
||||
* function, responsible for loading a server action.
|
||||
* @param opts.decodeFormState A function responsible for decoding form state for
|
||||
* progressively enhanceable forms with React's [`useActionState`](https://react.dev/reference/react/useActionState)
|
||||
* using your `react-server-dom-xyz/server`'s `decodeFormState`.
|
||||
* @param opts.decodeReply Your `react-server-dom-xyz/server`'s `decodeReply`
|
||||
* function, used to decode the server function's arguments and bind them to the
|
||||
* implementation for invocation by the router.
|
||||
* @param opts.generateResponse A function responsible for using your
|
||||
* `renderToReadableStream` to generate a [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
|
||||
* encoding the {@link unstable_RSCPayload}.
|
||||
* @param opts.loadServerAction Your `react-server-dom-xyz/server`'s
|
||||
* `loadServerAction` function, used to load a server action by ID.
|
||||
* @param opts.onError An optional error handler that will be called with any
|
||||
* errors that occur during the request processing.
|
||||
* @param opts.request The [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
|
||||
* to match against.
|
||||
* @param opts.requestContext An instance of {@link RouterContextProvider}
|
||||
* that should be created per request, to be passed to [`action`](../../start/data/route-object#action)s,
|
||||
* [`loader`](../../start/data/route-object#loader)s and [middleware](../../how-to/middleware).
|
||||
* @param opts.routeDiscovery The route discovery configuration, used to determine how the router should discover new routes during navigations.
|
||||
* @param opts.routes Your {@link unstable_RSCRouteConfigEntry | route definitions}.
|
||||
* @returns A [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
|
||||
* that contains the [RSC](https://react.dev/reference/rsc/server-components)
|
||||
* data for hydration.
|
||||
*/
|
||||
declare function matchRSCServerRequest({ allowedActionOrigins, createTemporaryReferenceSet, basename, decodeReply, requestContext, routeDiscovery, loadServerAction, decodeAction, decodeFormState, onError, request, routes, generateResponse, }: {
|
||||
allowedActionOrigins?: string[];
|
||||
createTemporaryReferenceSet: () => unknown;
|
||||
basename?: string;
|
||||
decodeReply?: DecodeReplyFunction;
|
||||
decodeAction?: DecodeActionFunction;
|
||||
decodeFormState?: DecodeFormStateFunction;
|
||||
requestContext?: RouterContextProvider;
|
||||
loadServerAction?: LoadServerActionFunction;
|
||||
onError?: (error: unknown) => void;
|
||||
request: Request;
|
||||
routes: RSCRouteConfigEntry[];
|
||||
routeDiscovery?: RouteDiscovery;
|
||||
generateResponse: (match: RSCMatch, { onError, temporaryReferences, }: {
|
||||
onError(error: unknown): string | undefined;
|
||||
temporaryReferences: unknown;
|
||||
}) => Response;
|
||||
}): Promise<Response>;
|
||||
|
||||
type BrowserCreateFromReadableStreamFunction = (body: ReadableStream<Uint8Array>, { temporaryReferences, }: {
|
||||
temporaryReferences: unknown;
|
||||
}) => Promise<unknown>;
|
||||
type EncodeReplyFunction = (args: unknown[], options: {
|
||||
temporaryReferences: unknown;
|
||||
}) => Promise<BodyInit>;
|
||||
/**
|
||||
* Create a React `callServer` implementation for React Router.
|
||||
*
|
||||
* @example
|
||||
* import {
|
||||
* createFromReadableStream,
|
||||
* createTemporaryReferenceSet,
|
||||
* encodeReply,
|
||||
* setServerCallback,
|
||||
* } from "@vitejs/plugin-rsc/browser";
|
||||
* import { unstable_createCallServer as createCallServer } from "react-router";
|
||||
*
|
||||
* setServerCallback(
|
||||
* createCallServer({
|
||||
* createFromReadableStream,
|
||||
* createTemporaryReferenceSet,
|
||||
* encodeReply,
|
||||
* })
|
||||
* );
|
||||
*
|
||||
* @name unstable_createCallServer
|
||||
* @public
|
||||
* @category RSC
|
||||
* @mode data
|
||||
* @param opts Options
|
||||
* @param opts.createFromReadableStream Your `react-server-dom-xyz/client`'s
|
||||
* `createFromReadableStream`. Used to decode payloads from the server.
|
||||
* @param opts.createTemporaryReferenceSet A function that creates a temporary
|
||||
* reference set for the [RSC](https://react.dev/reference/rsc/server-components)
|
||||
* payload.
|
||||
* @param opts.encodeReply Your `react-server-dom-xyz/client`'s `encodeReply`.
|
||||
* Used when sending payloads to the server.
|
||||
* @param opts.fetch Optional [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)
|
||||
* implementation. Defaults to global [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/fetch).
|
||||
* @returns A function that can be used to call server actions.
|
||||
*/
|
||||
declare function createCallServer({ createFromReadableStream, createTemporaryReferenceSet, encodeReply, fetch: fetchImplementation, }: {
|
||||
createFromReadableStream: BrowserCreateFromReadableStreamFunction;
|
||||
createTemporaryReferenceSet: () => unknown;
|
||||
encodeReply: EncodeReplyFunction;
|
||||
fetch?: (request: Request) => Promise<Response>;
|
||||
}): (id: string, args: unknown[]) => Promise<unknown>;
|
||||
/**
|
||||
* Props for the {@link unstable_RSCHydratedRouter} component.
|
||||
*
|
||||
* @name unstable_RSCHydratedRouterProps
|
||||
* @category Types
|
||||
*/
|
||||
interface RSCHydratedRouterProps {
|
||||
/**
|
||||
* Your `react-server-dom-xyz/client`'s `createFromReadableStream` function,
|
||||
* used to decode payloads from the server.
|
||||
*/
|
||||
createFromReadableStream: BrowserCreateFromReadableStreamFunction;
|
||||
/**
|
||||
* Optional fetch implementation. Defaults to global [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/fetch).
|
||||
*/
|
||||
fetch?: (request: Request) => Promise<Response>;
|
||||
/**
|
||||
* The decoded {@link unstable_RSCPayload} to hydrate.
|
||||
*/
|
||||
payload: RSCPayload;
|
||||
/**
|
||||
* A function that returns an {@link RouterContextProvider} instance
|
||||
* which is provided as the `context` argument to client [`action`](../../start/data/route-object#action)s,
|
||||
* [`loader`](../../start/data/route-object#loader)s and [middleware](../../how-to/middleware).
|
||||
* This function is called to generate a fresh `context` instance on each
|
||||
* navigation or fetcher call.
|
||||
*/
|
||||
getContext?: RouterInit["getContext"];
|
||||
}
|
||||
/**
|
||||
* Hydrates a server rendered {@link unstable_RSCPayload} in the browser.
|
||||
*
|
||||
* @example
|
||||
* import { startTransition, StrictMode } from "react";
|
||||
* import { hydrateRoot } from "react-dom/client";
|
||||
* import {
|
||||
* unstable_getRSCStream as getRSCStream,
|
||||
* unstable_RSCHydratedRouter as RSCHydratedRouter,
|
||||
* } from "react-router";
|
||||
* import type { unstable_RSCPayload as RSCPayload } from "react-router";
|
||||
*
|
||||
* createFromReadableStream(getRSCStream()).then((payload) =>
|
||||
* startTransition(async () => {
|
||||
* hydrateRoot(
|
||||
* document,
|
||||
* <StrictMode>
|
||||
* <RSCHydratedRouter
|
||||
* createFromReadableStream={createFromReadableStream}
|
||||
* payload={payload}
|
||||
* />
|
||||
* </StrictMode>,
|
||||
* { formState: await getFormState(payload) },
|
||||
* );
|
||||
* }),
|
||||
* );
|
||||
*
|
||||
* @name unstable_RSCHydratedRouter
|
||||
* @public
|
||||
* @category RSC
|
||||
* @mode data
|
||||
* @param props Props
|
||||
* @param {unstable_RSCHydratedRouterProps.createFromReadableStream} props.createFromReadableStream n/a
|
||||
* @param {unstable_RSCHydratedRouterProps.fetch} props.fetch n/a
|
||||
* @param {unstable_RSCHydratedRouterProps.getContext} props.getContext n/a
|
||||
* @param {unstable_RSCHydratedRouterProps.payload} props.payload n/a
|
||||
* @returns A hydrated {@link DataRouter} that can be used to navigate and
|
||||
* render routes.
|
||||
*/
|
||||
declare function RSCHydratedRouter({ createFromReadableStream, fetch: fetchImplementation, payload, getContext, }: RSCHydratedRouterProps): React.JSX.Element;
|
||||
|
||||
export { type BrowserCreateFromReadableStreamFunction as B, type DecodeActionFunction as D, type EncodeReplyFunction as E, type LoadServerActionFunction as L, RSCHydratedRouter as R, type DecodeFormStateFunction as a, type DecodeReplyFunction as b, createCallServer as c, type RSCManifestPayload as d, type RSCPayload as e, type RSCRenderPayload as f, getRequest as g, type RSCHydratedRouterProps as h, type RSCMatch as i, type RSCRouteManifest as j, type RSCRouteMatch as k, type RSCRouteConfigEntry as l, matchRSCServerRequest as m, type RSCRouteConfig as n };
|
||||
+318
@@ -0,0 +1,318 @@
|
||||
import * as React from 'react';
|
||||
import { R as RouterInit } from './context-CeD5LmaF.mjs';
|
||||
import { L as Location, C as ClientActionFunction, a as ClientLoaderFunction, b as LinksFunction, M as MetaFunction, S as ShouldRevalidateFunction, P as Params, c as RouterContextProvider, A as ActionFunction, H as HeadersFunction, d as LoaderFunction } from './data-DEjBmEfD.mjs';
|
||||
|
||||
declare function getRequest(): Request;
|
||||
type RSCRouteConfigEntryBase = {
|
||||
action?: ActionFunction;
|
||||
clientAction?: ClientActionFunction;
|
||||
clientLoader?: ClientLoaderFunction;
|
||||
ErrorBoundary?: React.ComponentType<any>;
|
||||
handle?: any;
|
||||
headers?: HeadersFunction;
|
||||
HydrateFallback?: React.ComponentType<any>;
|
||||
Layout?: React.ComponentType<any>;
|
||||
links?: LinksFunction;
|
||||
loader?: LoaderFunction;
|
||||
meta?: MetaFunction;
|
||||
shouldRevalidate?: ShouldRevalidateFunction;
|
||||
};
|
||||
type RSCRouteConfigEntry = RSCRouteConfigEntryBase & {
|
||||
id: string;
|
||||
path?: string;
|
||||
Component?: React.ComponentType<any>;
|
||||
lazy?: () => Promise<RSCRouteConfigEntryBase & ({
|
||||
default?: React.ComponentType<any>;
|
||||
Component?: never;
|
||||
} | {
|
||||
default?: never;
|
||||
Component?: React.ComponentType<any>;
|
||||
})>;
|
||||
} & ({
|
||||
index: true;
|
||||
} | {
|
||||
children?: RSCRouteConfigEntry[];
|
||||
});
|
||||
type RSCRouteConfig = Array<RSCRouteConfigEntry>;
|
||||
type RSCRouteManifest = {
|
||||
clientAction?: ClientActionFunction;
|
||||
clientLoader?: ClientLoaderFunction;
|
||||
element?: React.ReactElement | false;
|
||||
errorElement?: React.ReactElement;
|
||||
handle?: any;
|
||||
hasAction: boolean;
|
||||
hasComponent: boolean;
|
||||
hasErrorBoundary: boolean;
|
||||
hasLoader: boolean;
|
||||
hydrateFallbackElement?: React.ReactElement;
|
||||
id: string;
|
||||
index?: boolean;
|
||||
links?: LinksFunction;
|
||||
meta?: MetaFunction;
|
||||
parentId?: string;
|
||||
path?: string;
|
||||
shouldRevalidate?: ShouldRevalidateFunction;
|
||||
};
|
||||
type RSCRouteMatch = RSCRouteManifest & {
|
||||
params: Params;
|
||||
pathname: string;
|
||||
pathnameBase: string;
|
||||
};
|
||||
type RSCRenderPayload = {
|
||||
type: "render";
|
||||
actionData: Record<string, any> | null;
|
||||
basename: string | undefined;
|
||||
errors: Record<string, any> | null;
|
||||
loaderData: Record<string, any>;
|
||||
location: Location;
|
||||
routeDiscovery: RouteDiscovery;
|
||||
matches: RSCRouteMatch[];
|
||||
patches?: Promise<RSCRouteManifest[]>;
|
||||
nonce?: string;
|
||||
formState?: unknown;
|
||||
};
|
||||
type RSCManifestPayload = {
|
||||
type: "manifest";
|
||||
patches: Promise<RSCRouteManifest[]>;
|
||||
};
|
||||
type RSCActionPayload = {
|
||||
type: "action";
|
||||
actionResult: Promise<unknown>;
|
||||
rerender?: Promise<RSCRenderPayload | RSCRedirectPayload>;
|
||||
};
|
||||
type RSCRedirectPayload = {
|
||||
type: "redirect";
|
||||
status: number;
|
||||
location: string;
|
||||
replace: boolean;
|
||||
reload: boolean;
|
||||
actionResult?: Promise<unknown>;
|
||||
};
|
||||
type RSCPayload = RSCRenderPayload | RSCManifestPayload | RSCActionPayload | RSCRedirectPayload;
|
||||
type RSCMatch = {
|
||||
statusCode: number;
|
||||
headers: Headers;
|
||||
payload: RSCPayload;
|
||||
};
|
||||
type DecodeActionFunction = (formData: FormData) => Promise<() => Promise<unknown>>;
|
||||
type DecodeFormStateFunction = (result: unknown, formData: FormData) => unknown;
|
||||
type DecodeReplyFunction = (reply: FormData | string, options: {
|
||||
temporaryReferences: unknown;
|
||||
}) => Promise<unknown[]>;
|
||||
type LoadServerActionFunction = (id: string) => Promise<Function>;
|
||||
type RouteDiscovery = {
|
||||
mode: "lazy";
|
||||
manifestPath?: string | undefined;
|
||||
} | {
|
||||
mode: "initial";
|
||||
};
|
||||
/**
|
||||
* Matches the given routes to a [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
|
||||
* and returns an [RSC](https://react.dev/reference/rsc/server-components)
|
||||
* [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
|
||||
* encoding an {@link unstable_RSCPayload} for consumption by an [RSC](https://react.dev/reference/rsc/server-components)
|
||||
* enabled client router.
|
||||
*
|
||||
* @example
|
||||
* import {
|
||||
* createTemporaryReferenceSet,
|
||||
* decodeAction,
|
||||
* decodeReply,
|
||||
* loadServerAction,
|
||||
* renderToReadableStream,
|
||||
* } from "@vitejs/plugin-rsc/rsc";
|
||||
* import { unstable_matchRSCServerRequest as matchRSCServerRequest } from "react-router";
|
||||
*
|
||||
* matchRSCServerRequest({
|
||||
* createTemporaryReferenceSet,
|
||||
* decodeAction,
|
||||
* decodeFormState,
|
||||
* decodeReply,
|
||||
* loadServerAction,
|
||||
* request,
|
||||
* routes: routes(),
|
||||
* generateResponse(match) {
|
||||
* return new Response(
|
||||
* renderToReadableStream(match.payload),
|
||||
* {
|
||||
* status: match.statusCode,
|
||||
* headers: match.headers,
|
||||
* }
|
||||
* );
|
||||
* },
|
||||
* });
|
||||
*
|
||||
* @name unstable_matchRSCServerRequest
|
||||
* @public
|
||||
* @category RSC
|
||||
* @mode data
|
||||
* @param opts Options
|
||||
* @param opts.allowedActionOrigins Origin patterns that are allowed to execute actions.
|
||||
* @param opts.basename The basename to use when matching the request.
|
||||
* @param opts.createTemporaryReferenceSet A function that returns a temporary
|
||||
* reference set for the request, used to track temporary references in the [RSC](https://react.dev/reference/rsc/server-components)
|
||||
* stream.
|
||||
* @param opts.decodeAction Your `react-server-dom-xyz/server`'s `decodeAction`
|
||||
* function, responsible for loading a server action.
|
||||
* @param opts.decodeFormState A function responsible for decoding form state for
|
||||
* progressively enhanceable forms with React's [`useActionState`](https://react.dev/reference/react/useActionState)
|
||||
* using your `react-server-dom-xyz/server`'s `decodeFormState`.
|
||||
* @param opts.decodeReply Your `react-server-dom-xyz/server`'s `decodeReply`
|
||||
* function, used to decode the server function's arguments and bind them to the
|
||||
* implementation for invocation by the router.
|
||||
* @param opts.generateResponse A function responsible for using your
|
||||
* `renderToReadableStream` to generate a [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
|
||||
* encoding the {@link unstable_RSCPayload}.
|
||||
* @param opts.loadServerAction Your `react-server-dom-xyz/server`'s
|
||||
* `loadServerAction` function, used to load a server action by ID.
|
||||
* @param opts.onError An optional error handler that will be called with any
|
||||
* errors that occur during the request processing.
|
||||
* @param opts.request The [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
|
||||
* to match against.
|
||||
* @param opts.requestContext An instance of {@link RouterContextProvider}
|
||||
* that should be created per request, to be passed to [`action`](../../start/data/route-object#action)s,
|
||||
* [`loader`](../../start/data/route-object#loader)s and [middleware](../../how-to/middleware).
|
||||
* @param opts.routeDiscovery The route discovery configuration, used to determine how the router should discover new routes during navigations.
|
||||
* @param opts.routes Your {@link unstable_RSCRouteConfigEntry | route definitions}.
|
||||
* @returns A [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
|
||||
* that contains the [RSC](https://react.dev/reference/rsc/server-components)
|
||||
* data for hydration.
|
||||
*/
|
||||
declare function matchRSCServerRequest({ allowedActionOrigins, createTemporaryReferenceSet, basename, decodeReply, requestContext, routeDiscovery, loadServerAction, decodeAction, decodeFormState, onError, request, routes, generateResponse, }: {
|
||||
allowedActionOrigins?: string[];
|
||||
createTemporaryReferenceSet: () => unknown;
|
||||
basename?: string;
|
||||
decodeReply?: DecodeReplyFunction;
|
||||
decodeAction?: DecodeActionFunction;
|
||||
decodeFormState?: DecodeFormStateFunction;
|
||||
requestContext?: RouterContextProvider;
|
||||
loadServerAction?: LoadServerActionFunction;
|
||||
onError?: (error: unknown) => void;
|
||||
request: Request;
|
||||
routes: RSCRouteConfigEntry[];
|
||||
routeDiscovery?: RouteDiscovery;
|
||||
generateResponse: (match: RSCMatch, { onError, temporaryReferences, }: {
|
||||
onError(error: unknown): string | undefined;
|
||||
temporaryReferences: unknown;
|
||||
}) => Response;
|
||||
}): Promise<Response>;
|
||||
|
||||
type BrowserCreateFromReadableStreamFunction = (body: ReadableStream<Uint8Array>, { temporaryReferences, }: {
|
||||
temporaryReferences: unknown;
|
||||
}) => Promise<unknown>;
|
||||
type EncodeReplyFunction = (args: unknown[], options: {
|
||||
temporaryReferences: unknown;
|
||||
}) => Promise<BodyInit>;
|
||||
/**
|
||||
* Create a React `callServer` implementation for React Router.
|
||||
*
|
||||
* @example
|
||||
* import {
|
||||
* createFromReadableStream,
|
||||
* createTemporaryReferenceSet,
|
||||
* encodeReply,
|
||||
* setServerCallback,
|
||||
* } from "@vitejs/plugin-rsc/browser";
|
||||
* import { unstable_createCallServer as createCallServer } from "react-router";
|
||||
*
|
||||
* setServerCallback(
|
||||
* createCallServer({
|
||||
* createFromReadableStream,
|
||||
* createTemporaryReferenceSet,
|
||||
* encodeReply,
|
||||
* })
|
||||
* );
|
||||
*
|
||||
* @name unstable_createCallServer
|
||||
* @public
|
||||
* @category RSC
|
||||
* @mode data
|
||||
* @param opts Options
|
||||
* @param opts.createFromReadableStream Your `react-server-dom-xyz/client`'s
|
||||
* `createFromReadableStream`. Used to decode payloads from the server.
|
||||
* @param opts.createTemporaryReferenceSet A function that creates a temporary
|
||||
* reference set for the [RSC](https://react.dev/reference/rsc/server-components)
|
||||
* payload.
|
||||
* @param opts.encodeReply Your `react-server-dom-xyz/client`'s `encodeReply`.
|
||||
* Used when sending payloads to the server.
|
||||
* @param opts.fetch Optional [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)
|
||||
* implementation. Defaults to global [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/fetch).
|
||||
* @returns A function that can be used to call server actions.
|
||||
*/
|
||||
declare function createCallServer({ createFromReadableStream, createTemporaryReferenceSet, encodeReply, fetch: fetchImplementation, }: {
|
||||
createFromReadableStream: BrowserCreateFromReadableStreamFunction;
|
||||
createTemporaryReferenceSet: () => unknown;
|
||||
encodeReply: EncodeReplyFunction;
|
||||
fetch?: (request: Request) => Promise<Response>;
|
||||
}): (id: string, args: unknown[]) => Promise<unknown>;
|
||||
/**
|
||||
* Props for the {@link unstable_RSCHydratedRouter} component.
|
||||
*
|
||||
* @name unstable_RSCHydratedRouterProps
|
||||
* @category Types
|
||||
*/
|
||||
interface RSCHydratedRouterProps {
|
||||
/**
|
||||
* Your `react-server-dom-xyz/client`'s `createFromReadableStream` function,
|
||||
* used to decode payloads from the server.
|
||||
*/
|
||||
createFromReadableStream: BrowserCreateFromReadableStreamFunction;
|
||||
/**
|
||||
* Optional fetch implementation. Defaults to global [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/fetch).
|
||||
*/
|
||||
fetch?: (request: Request) => Promise<Response>;
|
||||
/**
|
||||
* The decoded {@link unstable_RSCPayload} to hydrate.
|
||||
*/
|
||||
payload: RSCPayload;
|
||||
/**
|
||||
* A function that returns an {@link RouterContextProvider} instance
|
||||
* which is provided as the `context` argument to client [`action`](../../start/data/route-object#action)s,
|
||||
* [`loader`](../../start/data/route-object#loader)s and [middleware](../../how-to/middleware).
|
||||
* This function is called to generate a fresh `context` instance on each
|
||||
* navigation or fetcher call.
|
||||
*/
|
||||
getContext?: RouterInit["getContext"];
|
||||
}
|
||||
/**
|
||||
* Hydrates a server rendered {@link unstable_RSCPayload} in the browser.
|
||||
*
|
||||
* @example
|
||||
* import { startTransition, StrictMode } from "react";
|
||||
* import { hydrateRoot } from "react-dom/client";
|
||||
* import {
|
||||
* unstable_getRSCStream as getRSCStream,
|
||||
* unstable_RSCHydratedRouter as RSCHydratedRouter,
|
||||
* } from "react-router";
|
||||
* import type { unstable_RSCPayload as RSCPayload } from "react-router";
|
||||
*
|
||||
* createFromReadableStream(getRSCStream()).then((payload) =>
|
||||
* startTransition(async () => {
|
||||
* hydrateRoot(
|
||||
* document,
|
||||
* <StrictMode>
|
||||
* <RSCHydratedRouter
|
||||
* createFromReadableStream={createFromReadableStream}
|
||||
* payload={payload}
|
||||
* />
|
||||
* </StrictMode>,
|
||||
* { formState: await getFormState(payload) },
|
||||
* );
|
||||
* }),
|
||||
* );
|
||||
*
|
||||
* @name unstable_RSCHydratedRouter
|
||||
* @public
|
||||
* @category RSC
|
||||
* @mode data
|
||||
* @param props Props
|
||||
* @param {unstable_RSCHydratedRouterProps.createFromReadableStream} props.createFromReadableStream n/a
|
||||
* @param {unstable_RSCHydratedRouterProps.fetch} props.fetch n/a
|
||||
* @param {unstable_RSCHydratedRouterProps.getContext} props.getContext n/a
|
||||
* @param {unstable_RSCHydratedRouterProps.payload} props.payload n/a
|
||||
* @returns A hydrated {@link DataRouter} that can be used to navigate and
|
||||
* render routes.
|
||||
*/
|
||||
declare function RSCHydratedRouter({ createFromReadableStream, fetch: fetchImplementation, payload, getContext, }: RSCHydratedRouterProps): React.JSX.Element;
|
||||
|
||||
export { type BrowserCreateFromReadableStreamFunction as B, type DecodeActionFunction as D, type EncodeReplyFunction as E, type LoadServerActionFunction as L, RSCHydratedRouter as R, type DecodeFormStateFunction as a, type DecodeReplyFunction as b, createCallServer as c, type RSCManifestPayload as d, type RSCPayload as e, type RSCRenderPayload as f, getRequest as g, type RSCHydratedRouterProps as h, type RSCMatch as i, type RSCRouteManifest as j, type RSCRouteMatch as k, type RSCRouteConfigEntry as l, matchRSCServerRequest as m, type RSCRouteConfig as n };
|
||||
+11606
File diff suppressed because it is too large
Load Diff
+2517
File diff suppressed because it is too large
Load Diff
+10307
File diff suppressed because one or more lines are too long
+188
@@ -0,0 +1,188 @@
|
||||
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }/**
|
||||
* react-router v7.18.0
|
||||
*
|
||||
* Copyright (c) Remix Software Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE.md file in the root directory of this source tree.
|
||||
*
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var _chunkU7ORXROYjs = require('./chunk-U7ORXROY.js');
|
||||
|
||||
// lib/dom/ssr/hydration.tsx
|
||||
function getHydrationData({
|
||||
state,
|
||||
routes,
|
||||
getRouteInfo,
|
||||
location,
|
||||
basename,
|
||||
isSpaMode
|
||||
}) {
|
||||
let hydrationData = {
|
||||
...state,
|
||||
loaderData: { ...state.loaderData }
|
||||
};
|
||||
let initialMatches = _chunkU7ORXROYjs.matchRoutes.call(void 0, routes, location, basename);
|
||||
if (initialMatches) {
|
||||
for (let match of initialMatches) {
|
||||
let routeId = match.route.id;
|
||||
let routeInfo = getRouteInfo(routeId);
|
||||
if (_chunkU7ORXROYjs.shouldHydrateRouteLoader.call(void 0,
|
||||
routeId,
|
||||
routeInfo.clientLoader,
|
||||
routeInfo.hasLoader,
|
||||
isSpaMode
|
||||
) && (routeInfo.hasHydrateFallback || !routeInfo.hasLoader)) {
|
||||
delete hydrationData.loaderData[routeId];
|
||||
} else if (!routeInfo.hasLoader) {
|
||||
hydrationData.loaderData[routeId] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return hydrationData;
|
||||
}
|
||||
|
||||
// lib/rsc/errorBoundaries.tsx
|
||||
var _react = require('react'); var _react2 = _interopRequireDefault(_react);
|
||||
var RSCRouterGlobalErrorBoundary = class extends _react2.default.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = { error: null, location: props.location };
|
||||
}
|
||||
static getDerivedStateFromError(error) {
|
||||
return { error };
|
||||
}
|
||||
static getDerivedStateFromProps(props, state) {
|
||||
if (state.location !== props.location) {
|
||||
return { error: null, location: props.location };
|
||||
}
|
||||
return { error: state.error, location: state.location };
|
||||
}
|
||||
render() {
|
||||
if (this.state.error) {
|
||||
return /* @__PURE__ */ _react2.default.createElement(
|
||||
RSCDefaultRootErrorBoundaryImpl,
|
||||
{
|
||||
error: this.state.error,
|
||||
renderAppShell: true
|
||||
}
|
||||
);
|
||||
} else {
|
||||
return this.props.children;
|
||||
}
|
||||
}
|
||||
};
|
||||
function ErrorWrapper({
|
||||
renderAppShell,
|
||||
title,
|
||||
children
|
||||
}) {
|
||||
if (!renderAppShell) {
|
||||
return children;
|
||||
}
|
||||
return /* @__PURE__ */ _react2.default.createElement("html", { lang: "en" }, /* @__PURE__ */ _react2.default.createElement("head", null, /* @__PURE__ */ _react2.default.createElement("meta", { charSet: "utf-8" }), /* @__PURE__ */ _react2.default.createElement(
|
||||
"meta",
|
||||
{
|
||||
name: "viewport",
|
||||
content: "width=device-width,initial-scale=1,viewport-fit=cover"
|
||||
}
|
||||
), /* @__PURE__ */ _react2.default.createElement("title", null, title)), /* @__PURE__ */ _react2.default.createElement("body", null, /* @__PURE__ */ _react2.default.createElement("main", { style: { fontFamily: "system-ui, sans-serif", padding: "2rem" } }, children)));
|
||||
}
|
||||
function RSCDefaultRootErrorBoundaryImpl({
|
||||
error,
|
||||
renderAppShell
|
||||
}) {
|
||||
console.error(error);
|
||||
let heyDeveloper = /* @__PURE__ */ _react2.default.createElement(
|
||||
"script",
|
||||
{
|
||||
dangerouslySetInnerHTML: {
|
||||
__html: `
|
||||
console.log(
|
||||
"\u{1F4BF} Hey developer \u{1F44B}. You can provide a way better UX than this when your app throws errors. Check out https://reactrouter.com/how-to/error-boundary for more information."
|
||||
);
|
||||
`
|
||||
}
|
||||
}
|
||||
);
|
||||
if (_chunkU7ORXROYjs.isRouteErrorResponse.call(void 0, error)) {
|
||||
return /* @__PURE__ */ _react2.default.createElement(
|
||||
ErrorWrapper,
|
||||
{
|
||||
renderAppShell,
|
||||
title: "Unhandled Thrown Response!"
|
||||
},
|
||||
/* @__PURE__ */ _react2.default.createElement("h1", { style: { fontSize: "24px" } }, error.status, " ", error.statusText),
|
||||
_chunkU7ORXROYjs.ENABLE_DEV_WARNINGS ? heyDeveloper : null
|
||||
);
|
||||
}
|
||||
let errorInstance;
|
||||
if (error instanceof Error) {
|
||||
errorInstance = error;
|
||||
} else {
|
||||
let errorString = error == null ? "Unknown Error" : typeof error === "object" && "toString" in error ? error.toString() : JSON.stringify(error);
|
||||
errorInstance = new Error(errorString);
|
||||
}
|
||||
return /* @__PURE__ */ _react2.default.createElement(ErrorWrapper, { renderAppShell, title: "Application Error!" }, /* @__PURE__ */ _react2.default.createElement("h1", { style: { fontSize: "24px" } }, "Application Error"), /* @__PURE__ */ _react2.default.createElement(
|
||||
"pre",
|
||||
{
|
||||
style: {
|
||||
padding: "2rem",
|
||||
background: "hsla(10, 50%, 50%, 0.1)",
|
||||
color: "red",
|
||||
overflow: "auto"
|
||||
}
|
||||
},
|
||||
errorInstance.stack
|
||||
), heyDeveloper);
|
||||
}
|
||||
function RSCDefaultRootErrorBoundary({
|
||||
hasRootLayout
|
||||
}) {
|
||||
let error = _chunkU7ORXROYjs.useRouteError.call(void 0, );
|
||||
if (hasRootLayout === void 0) {
|
||||
throw new Error("Missing 'hasRootLayout' prop");
|
||||
}
|
||||
return /* @__PURE__ */ _react2.default.createElement(
|
||||
RSCDefaultRootErrorBoundaryImpl,
|
||||
{
|
||||
renderAppShell: !hasRootLayout,
|
||||
error
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// lib/rsc/route-modules.ts
|
||||
function createRSCRouteModules(payload) {
|
||||
const routeModules = {};
|
||||
for (const match of payload.matches) {
|
||||
populateRSCRouteModules(routeModules, match);
|
||||
}
|
||||
return routeModules;
|
||||
}
|
||||
function populateRSCRouteModules(routeModules, matches) {
|
||||
matches = Array.isArray(matches) ? matches : [matches];
|
||||
for (const match of matches) {
|
||||
routeModules[match.id] = {
|
||||
links: match.links,
|
||||
meta: match.meta,
|
||||
default: noopComponent
|
||||
};
|
||||
}
|
||||
}
|
||||
var noopComponent = () => null;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
exports.getHydrationData = getHydrationData; exports.RSCRouterGlobalErrorBoundary = RSCRouterGlobalErrorBoundary; exports.RSCDefaultRootErrorBoundary = RSCDefaultRootErrorBoundary; exports.createRSCRouteModules = createRSCRouteModules; exports.populateRSCRouteModules = populateRSCRouteModules;
|
||||
+1366
File diff suppressed because it is too large
Load Diff
+1779
File diff suppressed because it is too large
Load Diff
+1740
File diff suppressed because it is too large
Load Diff
+1740
File diff suppressed because it is too large
Load Diff
+172
@@ -0,0 +1,172 @@
|
||||
import * as React from 'react';
|
||||
import { a as RouterProviderProps$1, R as RouterInit, C as ClientInstrumentation, b as ClientOnErrorFunction } from './context-CeD5LmaF.mjs';
|
||||
export { D as unstable_DecodeActionFunction, a as unstable_DecodeFormStateFunction, b as unstable_DecodeReplyFunction, R as unstable_RSCHydratedRouter, d as unstable_RSCManifestPayload, e as unstable_RSCPayload, f as unstable_RSCRenderPayload, c as unstable_createCallServer } from './browser-DBmQ1yAR.mjs';
|
||||
import './data-DEjBmEfD.mjs';
|
||||
|
||||
type RouterProviderProps = Omit<RouterProviderProps$1, "flushSync">;
|
||||
declare function RouterProvider(props: RouterProviderProps): React.JSX.Element;
|
||||
|
||||
/**
|
||||
* Props for the {@link dom.HydratedRouter} component.
|
||||
*
|
||||
* @category Types
|
||||
*/
|
||||
interface HydratedRouterProps {
|
||||
/**
|
||||
* Context factory function to be passed through to {@link createBrowserRouter}.
|
||||
* This function will be called to create a fresh `context` instance on each
|
||||
* navigation/fetch and made available to
|
||||
* [`clientAction`](../../start/framework/route-module#clientAction)/[`clientLoader`](../../start/framework/route-module#clientLoader)
|
||||
* functions.
|
||||
*/
|
||||
getContext?: RouterInit["getContext"];
|
||||
/**
|
||||
* Array of instrumentation objects allowing you to instrument the router and
|
||||
* individual routes prior to router initialization (and on any subsequently
|
||||
* added routes via `route.lazy` or `patchRoutesOnNavigation`). This is
|
||||
* mostly useful for observability such as wrapping navigations, fetches,
|
||||
* as well as route loaders/actions/middlewares with logging and/or performance
|
||||
* tracing. See the [docs](../../how-to/instrumentation) for more information.
|
||||
*
|
||||
* ```tsx
|
||||
* const logging = {
|
||||
* router({ instrument }) {
|
||||
* instrument({
|
||||
* navigate: (impl, { to }) => logExecution(`navigate ${to}`, impl),
|
||||
* fetch: (impl, { to }) => logExecution(`fetch ${to}`, impl)
|
||||
* });
|
||||
* },
|
||||
* route({ instrument, id }) {
|
||||
* instrument({
|
||||
* middleware: (impl, { request }) => logExecution(
|
||||
* `middleware ${request.url} (route ${id})`,
|
||||
* impl
|
||||
* ),
|
||||
* loader: (impl, { request }) => logExecution(
|
||||
* `loader ${request.url} (route ${id})`,
|
||||
* impl
|
||||
* ),
|
||||
* action: (impl, { request }) => logExecution(
|
||||
* `action ${request.url} (route ${id})`,
|
||||
* impl
|
||||
* ),
|
||||
* })
|
||||
* }
|
||||
* };
|
||||
*
|
||||
* async function logExecution(label: string, impl: () => Promise<void>) {
|
||||
* let start = performance.now();
|
||||
* console.log(`start ${label}`);
|
||||
* await impl();
|
||||
* let duration = Math.round(performance.now() - start);
|
||||
* console.log(`end ${label} (${duration}ms)`);
|
||||
* }
|
||||
*
|
||||
* startTransition(() => {
|
||||
* hydrateRoot(
|
||||
* document,
|
||||
* <HydratedRouter instrumentations={[logging]} />
|
||||
* );
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
instrumentations?: ClientInstrumentation[];
|
||||
/**
|
||||
* An error handler function that will be called for any middleware, loader, action,
|
||||
* or render errors that are encountered in your application. This is useful for
|
||||
* logging or reporting errors instead of in the {@link ErrorBoundary} because it's not
|
||||
* subject to re-rendering and will only run one time per error.
|
||||
*
|
||||
* The `errorInfo` parameter is passed along from
|
||||
* [`componentDidCatch`](https://react.dev/reference/react/Component#componentdidcatch)
|
||||
* and is only present for render errors.
|
||||
*
|
||||
* ```tsx
|
||||
* <HydratedRouter onError={(error, info) => {
|
||||
* let { location, params, pattern, errorInfo } = info;
|
||||
* console.error(error, location, errorInfo);
|
||||
* reportToErrorService(error, location, errorInfo);
|
||||
* }} />
|
||||
* ```
|
||||
*/
|
||||
onError?: ClientOnErrorFunction;
|
||||
/**
|
||||
* Control whether router state updates are internally wrapped in
|
||||
* [`React.startTransition`](https://react.dev/reference/react/startTransition).
|
||||
*
|
||||
* - When left `undefined`, all state updates are wrapped in
|
||||
* `React.startTransition`
|
||||
* - This can lead to buggy behaviors if you are wrapping your own
|
||||
* navigations/fetchers in `startTransition`.
|
||||
* - When set to `true`, {@link Link} and {@link Form} navigations will be wrapped
|
||||
* in `React.startTransition` and router state changes will be wrapped in
|
||||
* `React.startTransition` and also sent through
|
||||
* [`useOptimistic`](https://react.dev/reference/react/useOptimistic) to
|
||||
* surface mid-navigation router state changes to the UI.
|
||||
* - When set to `false`, the router will not leverage `React.startTransition` or
|
||||
* `React.useOptimistic` on any navigations or state changes.
|
||||
*
|
||||
* For more information, please see the [docs](../../explanation/react-transitions).
|
||||
*/
|
||||
useTransitions?: boolean;
|
||||
}
|
||||
/**
|
||||
* Framework-mode router component to be used to hydrate a router from a
|
||||
* {@link ServerRouter}. See [`entry.client.tsx`](../framework-conventions/entry.client.tsx).
|
||||
*
|
||||
* @public
|
||||
* @category Framework Routers
|
||||
* @mode framework
|
||||
* @param props Props
|
||||
* @param {dom.HydratedRouterProps.getContext} props.getContext n/a
|
||||
* @param {dom.HydratedRouterProps.onError} props.onError n/a
|
||||
* @returns A React element that represents the hydrated application.
|
||||
*/
|
||||
declare function HydratedRouter(props: HydratedRouterProps): React.JSX.Element;
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
__FLIGHT_DATA: any[];
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Get the prerendered [RSC](https://react.dev/reference/rsc/server-components)
|
||||
* stream for hydration. Usually passed directly to your
|
||||
* `react-server-dom-xyz/client`'s `createFromReadableStream`.
|
||||
*
|
||||
* @example
|
||||
* import { startTransition, StrictMode } from "react";
|
||||
* import { hydrateRoot } from "react-dom/client";
|
||||
* import {
|
||||
* unstable_getRSCStream as getRSCStream,
|
||||
* unstable_RSCHydratedRouter as RSCHydratedRouter,
|
||||
* } from "react-router";
|
||||
* import type { unstable_RSCPayload as RSCPayload } from "react-router";
|
||||
*
|
||||
* createFromReadableStream(getRSCStream()).then(
|
||||
* (payload: RSCServerPayload) => {
|
||||
* startTransition(async () => {
|
||||
* hydrateRoot(
|
||||
* document,
|
||||
* <StrictMode>
|
||||
* <RSCHydratedRouter {...props} />
|
||||
* </StrictMode>,
|
||||
* {
|
||||
* // Options
|
||||
* }
|
||||
* );
|
||||
* });
|
||||
* }
|
||||
* );
|
||||
*
|
||||
* @name unstable_getRSCStream
|
||||
* @public
|
||||
* @category RSC
|
||||
* @mode data
|
||||
* @returns A [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream)
|
||||
* that contains the [RSC](https://react.dev/reference/rsc/server-components)
|
||||
* data for hydration.
|
||||
*/
|
||||
declare function getRSCStream(): ReadableStream;
|
||||
|
||||
export { HydratedRouter, type HydratedRouterProps, RouterProvider, type RouterProviderProps, getRSCStream as unstable_getRSCStream };
|
||||
+173
@@ -0,0 +1,173 @@
|
||||
import * as React from 'react';
|
||||
import { RouterProviderProps as RouterProviderProps$1, RouterInit, ClientOnErrorFunction } from 'react-router';
|
||||
import { C as ClientInstrumentation } from './instrumentation-Dkmpzd13.js';
|
||||
export { D as unstable_DecodeActionFunction, a as unstable_DecodeFormStateFunction, b as unstable_DecodeReplyFunction, R as unstable_RSCHydratedRouter, d as unstable_RSCManifestPayload, e as unstable_RSCPayload, f as unstable_RSCRenderPayload, c as unstable_createCallServer } from './browser-B2PdsXXH.js';
|
||||
import './data-CjO11-hU.js';
|
||||
|
||||
type RouterProviderProps = Omit<RouterProviderProps$1, "flushSync">;
|
||||
declare function RouterProvider(props: RouterProviderProps): React.JSX.Element;
|
||||
|
||||
/**
|
||||
* Props for the {@link dom.HydratedRouter} component.
|
||||
*
|
||||
* @category Types
|
||||
*/
|
||||
interface HydratedRouterProps {
|
||||
/**
|
||||
* Context factory function to be passed through to {@link createBrowserRouter}.
|
||||
* This function will be called to create a fresh `context` instance on each
|
||||
* navigation/fetch and made available to
|
||||
* [`clientAction`](../../start/framework/route-module#clientAction)/[`clientLoader`](../../start/framework/route-module#clientLoader)
|
||||
* functions.
|
||||
*/
|
||||
getContext?: RouterInit["getContext"];
|
||||
/**
|
||||
* Array of instrumentation objects allowing you to instrument the router and
|
||||
* individual routes prior to router initialization (and on any subsequently
|
||||
* added routes via `route.lazy` or `patchRoutesOnNavigation`). This is
|
||||
* mostly useful for observability such as wrapping navigations, fetches,
|
||||
* as well as route loaders/actions/middlewares with logging and/or performance
|
||||
* tracing. See the [docs](../../how-to/instrumentation) for more information.
|
||||
*
|
||||
* ```tsx
|
||||
* const logging = {
|
||||
* router({ instrument }) {
|
||||
* instrument({
|
||||
* navigate: (impl, { to }) => logExecution(`navigate ${to}`, impl),
|
||||
* fetch: (impl, { to }) => logExecution(`fetch ${to}`, impl)
|
||||
* });
|
||||
* },
|
||||
* route({ instrument, id }) {
|
||||
* instrument({
|
||||
* middleware: (impl, { request }) => logExecution(
|
||||
* `middleware ${request.url} (route ${id})`,
|
||||
* impl
|
||||
* ),
|
||||
* loader: (impl, { request }) => logExecution(
|
||||
* `loader ${request.url} (route ${id})`,
|
||||
* impl
|
||||
* ),
|
||||
* action: (impl, { request }) => logExecution(
|
||||
* `action ${request.url} (route ${id})`,
|
||||
* impl
|
||||
* ),
|
||||
* })
|
||||
* }
|
||||
* };
|
||||
*
|
||||
* async function logExecution(label: string, impl: () => Promise<void>) {
|
||||
* let start = performance.now();
|
||||
* console.log(`start ${label}`);
|
||||
* await impl();
|
||||
* let duration = Math.round(performance.now() - start);
|
||||
* console.log(`end ${label} (${duration}ms)`);
|
||||
* }
|
||||
*
|
||||
* startTransition(() => {
|
||||
* hydrateRoot(
|
||||
* document,
|
||||
* <HydratedRouter instrumentations={[logging]} />
|
||||
* );
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
instrumentations?: ClientInstrumentation[];
|
||||
/**
|
||||
* An error handler function that will be called for any middleware, loader, action,
|
||||
* or render errors that are encountered in your application. This is useful for
|
||||
* logging or reporting errors instead of in the {@link ErrorBoundary} because it's not
|
||||
* subject to re-rendering and will only run one time per error.
|
||||
*
|
||||
* The `errorInfo` parameter is passed along from
|
||||
* [`componentDidCatch`](https://react.dev/reference/react/Component#componentdidcatch)
|
||||
* and is only present for render errors.
|
||||
*
|
||||
* ```tsx
|
||||
* <HydratedRouter onError={(error, info) => {
|
||||
* let { location, params, pattern, errorInfo } = info;
|
||||
* console.error(error, location, errorInfo);
|
||||
* reportToErrorService(error, location, errorInfo);
|
||||
* }} />
|
||||
* ```
|
||||
*/
|
||||
onError?: ClientOnErrorFunction;
|
||||
/**
|
||||
* Control whether router state updates are internally wrapped in
|
||||
* [`React.startTransition`](https://react.dev/reference/react/startTransition).
|
||||
*
|
||||
* - When left `undefined`, all state updates are wrapped in
|
||||
* `React.startTransition`
|
||||
* - This can lead to buggy behaviors if you are wrapping your own
|
||||
* navigations/fetchers in `startTransition`.
|
||||
* - When set to `true`, {@link Link} and {@link Form} navigations will be wrapped
|
||||
* in `React.startTransition` and router state changes will be wrapped in
|
||||
* `React.startTransition` and also sent through
|
||||
* [`useOptimistic`](https://react.dev/reference/react/useOptimistic) to
|
||||
* surface mid-navigation router state changes to the UI.
|
||||
* - When set to `false`, the router will not leverage `React.startTransition` or
|
||||
* `React.useOptimistic` on any navigations or state changes.
|
||||
*
|
||||
* For more information, please see the [docs](../../explanation/react-transitions).
|
||||
*/
|
||||
useTransitions?: boolean;
|
||||
}
|
||||
/**
|
||||
* Framework-mode router component to be used to hydrate a router from a
|
||||
* {@link ServerRouter}. See [`entry.client.tsx`](../framework-conventions/entry.client.tsx).
|
||||
*
|
||||
* @public
|
||||
* @category Framework Routers
|
||||
* @mode framework
|
||||
* @param props Props
|
||||
* @param {dom.HydratedRouterProps.getContext} props.getContext n/a
|
||||
* @param {dom.HydratedRouterProps.onError} props.onError n/a
|
||||
* @returns A React element that represents the hydrated application.
|
||||
*/
|
||||
declare function HydratedRouter(props: HydratedRouterProps): React.JSX.Element;
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
__FLIGHT_DATA: any[];
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Get the prerendered [RSC](https://react.dev/reference/rsc/server-components)
|
||||
* stream for hydration. Usually passed directly to your
|
||||
* `react-server-dom-xyz/client`'s `createFromReadableStream`.
|
||||
*
|
||||
* @example
|
||||
* import { startTransition, StrictMode } from "react";
|
||||
* import { hydrateRoot } from "react-dom/client";
|
||||
* import {
|
||||
* unstable_getRSCStream as getRSCStream,
|
||||
* unstable_RSCHydratedRouter as RSCHydratedRouter,
|
||||
* } from "react-router";
|
||||
* import type { unstable_RSCPayload as RSCPayload } from "react-router";
|
||||
*
|
||||
* createFromReadableStream(getRSCStream()).then(
|
||||
* (payload: RSCServerPayload) => {
|
||||
* startTransition(async () => {
|
||||
* hydrateRoot(
|
||||
* document,
|
||||
* <StrictMode>
|
||||
* <RSCHydratedRouter {...props} />
|
||||
* </StrictMode>,
|
||||
* {
|
||||
* // Options
|
||||
* }
|
||||
* );
|
||||
* });
|
||||
* }
|
||||
* );
|
||||
*
|
||||
* @name unstable_getRSCStream
|
||||
* @public
|
||||
* @category RSC
|
||||
* @mode data
|
||||
* @returns A [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream)
|
||||
* that contains the [RSC](https://react.dev/reference/rsc/server-components)
|
||||
* data for hydration.
|
||||
*/
|
||||
declare function getRSCStream(): ReadableStream;
|
||||
|
||||
export { HydratedRouter, type HydratedRouterProps, RouterProvider, type RouterProviderProps, getRSCStream as unstable_getRSCStream };
|
||||
+1018
File diff suppressed because it is too large
Load Diff
+1010
File diff suppressed because it is too large
Load Diff
Generated
Vendored
+3677
File diff suppressed because it is too large
Load Diff
Generated
Vendored
+2614
File diff suppressed because it is too large
Load Diff
Generated
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
export { Q as MemoryRouter, T as Navigate, U as Outlet, V as Route, W as Router, X as RouterProvider, Y as Routes, A as UNSAFE_AwaitContextProvider, ab as UNSAFE_WithComponentProps, af as UNSAFE_WithErrorBoundaryProps, ad as UNSAFE_WithHydrateFallbackProps } from './context-CeD5LmaF.mjs';
|
||||
export { l as BrowserRouter, q as Form, m as HashRouter, n as Link, X as Links, W as Meta, p as NavLink, r as ScrollRestoration, T as StaticRouter, V as StaticRouterProvider, o as unstable_HistoryRouter } from './index-react-server-client-CACgcj2J.mjs';
|
||||
import './data-DEjBmEfD.mjs';
|
||||
import 'react';
|
||||
Generated
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
export { W as BrowserRouter, $ as Form, X as HashRouter, Y as Link, an as Links, j as MemoryRouter, am as Meta, _ as NavLink, k as Navigate, l as Outlet, m as Route, n as Router, o as RouterProvider, p as Routes, a0 as ScrollRestoration, ak as StaticRouter, al as StaticRouterProvider, b as UNSAFE_AwaitContextProvider, aH as UNSAFE_WithComponentProps, aL as UNSAFE_WithErrorBoundaryProps, aJ as UNSAFE_WithHydrateFallbackProps, Z as unstable_HistoryRouter } from './index-react-server-client-3ykjivgQ.js';
|
||||
import './instrumentation-Dkmpzd13.js';
|
||||
import './data-CjO11-hU.js';
|
||||
import 'react';
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
"use strict";Object.defineProperty(exports, "__esModule", {value: true});/**
|
||||
* react-router v7.18.0
|
||||
*
|
||||
* Copyright (c) Remix Software Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE.md file in the root directory of this source tree.
|
||||
*
|
||||
* @license MIT
|
||||
*/
|
||||
"use client";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var _chunkYL5M26XIjs = require('./chunk-YL5M26XI.js');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var _chunkU7ORXROYjs = require('./chunk-U7ORXROY.js');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
exports.BrowserRouter = _chunkYL5M26XIjs.BrowserRouter; exports.Form = _chunkYL5M26XIjs.Form; exports.HashRouter = _chunkYL5M26XIjs.HashRouter; exports.Link = _chunkYL5M26XIjs.Link; exports.Links = _chunkU7ORXROYjs.Links; exports.MemoryRouter = _chunkU7ORXROYjs.MemoryRouter; exports.Meta = _chunkU7ORXROYjs.Meta; exports.NavLink = _chunkYL5M26XIjs.NavLink; exports.Navigate = _chunkU7ORXROYjs.Navigate; exports.Outlet = _chunkU7ORXROYjs.Outlet; exports.Route = _chunkU7ORXROYjs.Route; exports.Router = _chunkU7ORXROYjs.Router; exports.RouterProvider = _chunkU7ORXROYjs.RouterProvider; exports.Routes = _chunkU7ORXROYjs.Routes; exports.ScrollRestoration = _chunkYL5M26XIjs.ScrollRestoration; exports.StaticRouter = _chunkYL5M26XIjs.StaticRouter; exports.StaticRouterProvider = _chunkYL5M26XIjs.StaticRouterProvider; exports.UNSAFE_AwaitContextProvider = _chunkU7ORXROYjs.AwaitContextProvider; exports.UNSAFE_WithComponentProps = _chunkU7ORXROYjs.WithComponentProps; exports.UNSAFE_WithErrorBoundaryProps = _chunkU7ORXROYjs.WithErrorBoundaryProps; exports.UNSAFE_WithHydrateFallbackProps = _chunkU7ORXROYjs.WithHydrateFallbackProps; exports.unstable_HistoryRouter = _chunkYL5M26XIjs.HistoryRouter;
|
||||
Generated
Vendored
+59
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* react-router v7.18.0
|
||||
*
|
||||
* Copyright (c) Remix Software Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE.md file in the root directory of this source tree.
|
||||
*
|
||||
* @license MIT
|
||||
*/
|
||||
"use client";
|
||||
import {
|
||||
AwaitContextProvider,
|
||||
BrowserRouter,
|
||||
Form,
|
||||
HashRouter,
|
||||
HistoryRouter,
|
||||
Link,
|
||||
Links,
|
||||
MemoryRouter,
|
||||
Meta,
|
||||
NavLink,
|
||||
Navigate,
|
||||
Outlet,
|
||||
Route,
|
||||
Router,
|
||||
RouterProvider,
|
||||
Routes,
|
||||
ScrollRestoration,
|
||||
StaticRouter,
|
||||
StaticRouterProvider,
|
||||
WithComponentProps,
|
||||
WithErrorBoundaryProps,
|
||||
WithHydrateFallbackProps
|
||||
} from "./chunk-4ZMWKKQ3.mjs";
|
||||
export {
|
||||
BrowserRouter,
|
||||
Form,
|
||||
HashRouter,
|
||||
Link,
|
||||
Links,
|
||||
MemoryRouter,
|
||||
Meta,
|
||||
NavLink,
|
||||
Navigate,
|
||||
Outlet,
|
||||
Route,
|
||||
Router,
|
||||
RouterProvider,
|
||||
Routes,
|
||||
ScrollRestoration,
|
||||
StaticRouter,
|
||||
StaticRouterProvider,
|
||||
AwaitContextProvider as UNSAFE_AwaitContextProvider,
|
||||
WithComponentProps as UNSAFE_WithComponentProps,
|
||||
WithErrorBoundaryProps as UNSAFE_WithErrorBoundaryProps,
|
||||
WithHydrateFallbackProps as UNSAFE_WithHydrateFallbackProps,
|
||||
HistoryRouter as unstable_HistoryRouter
|
||||
};
|
||||
+2711
File diff suppressed because it is too large
Load Diff
+2711
File diff suppressed because it is too large
Load Diff
+3915
File diff suppressed because it is too large
Load Diff
+3803
File diff suppressed because it is too large
Load Diff
+1479
File diff suppressed because it is too large
Load Diff
+1479
File diff suppressed because it is too large
Load Diff
+2562
File diff suppressed because one or more lines are too long
+275
@@ -0,0 +1,275 @@
|
||||
/**
|
||||
* react-router v7.18.0
|
||||
*
|
||||
* Copyright (c) Remix Software Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE.md file in the root directory of this source tree.
|
||||
*
|
||||
* @license MIT
|
||||
*/
|
||||
"use client";
|
||||
import {
|
||||
RSCDefaultRootErrorBoundary,
|
||||
RSCStaticRouter,
|
||||
ServerMode,
|
||||
ServerRouter,
|
||||
createCookie,
|
||||
createCookieSessionStorage,
|
||||
createMemorySessionStorage,
|
||||
createRequestHandler,
|
||||
createRoutesStub,
|
||||
createSession,
|
||||
createSessionStorage,
|
||||
getHydrationData,
|
||||
href,
|
||||
isCookie,
|
||||
isSession,
|
||||
routeRSCServerRequest,
|
||||
setDevServerHooks
|
||||
} from "./chunk-E4MTK73K.mjs";
|
||||
import {
|
||||
Action,
|
||||
Await,
|
||||
AwaitContextProvider,
|
||||
BrowserRouter,
|
||||
DataRouterContext,
|
||||
DataRouterStateContext,
|
||||
ErrorResponseImpl,
|
||||
FetchersContext,
|
||||
Form,
|
||||
FrameworkContext,
|
||||
HashRouter,
|
||||
HistoryRouter,
|
||||
IDLE_BLOCKER,
|
||||
IDLE_FETCHER,
|
||||
IDLE_NAVIGATION,
|
||||
Link,
|
||||
Links,
|
||||
LocationContext,
|
||||
MemoryRouter,
|
||||
Meta,
|
||||
NavLink,
|
||||
Navigate,
|
||||
NavigationContext,
|
||||
Outlet,
|
||||
PrefetchPageLinks,
|
||||
RemixErrorBoundary,
|
||||
Route,
|
||||
RouteContext,
|
||||
Router,
|
||||
RouterContextProvider,
|
||||
RouterProvider,
|
||||
Routes,
|
||||
Scripts,
|
||||
ScrollRestoration,
|
||||
SingleFetchRedirectSymbol,
|
||||
StaticRouter,
|
||||
StaticRouterProvider,
|
||||
ViewTransitionContext,
|
||||
WithComponentProps,
|
||||
WithErrorBoundaryProps,
|
||||
WithHydrateFallbackProps,
|
||||
createBrowserHistory,
|
||||
createBrowserRouter,
|
||||
createClientRoutes,
|
||||
createClientRoutesWithHMRRevalidationOptOut,
|
||||
createContext,
|
||||
createHashHistory,
|
||||
createHashRouter,
|
||||
createMemoryHistory,
|
||||
createMemoryRouter,
|
||||
createPath,
|
||||
createRouter,
|
||||
createRoutesFromChildren,
|
||||
createRoutesFromElements,
|
||||
createSearchParams,
|
||||
createStaticHandler2 as createStaticHandler,
|
||||
createStaticRouter,
|
||||
data,
|
||||
decodeViaTurboStream,
|
||||
generatePath,
|
||||
getPatchRoutesOnNavigationFunction,
|
||||
getTurboStreamSingleFetchDataStrategy,
|
||||
hydrationRouteProperties,
|
||||
invariant,
|
||||
isRouteErrorResponse,
|
||||
mapRouteProperties,
|
||||
matchPath,
|
||||
matchRoutes,
|
||||
parsePath,
|
||||
redirect,
|
||||
redirectDocument,
|
||||
renderMatches,
|
||||
replace,
|
||||
resolvePath,
|
||||
shouldHydrateRouteLoader,
|
||||
useActionData,
|
||||
useAsyncError,
|
||||
useAsyncValue,
|
||||
useBeforeUnload,
|
||||
useBlocker,
|
||||
useFetcher,
|
||||
useFetchers,
|
||||
useFogOFWarDiscovery,
|
||||
useFormAction,
|
||||
useHref,
|
||||
useInRouterContext,
|
||||
useLinkClickHandler,
|
||||
useLoaderData,
|
||||
useLocation,
|
||||
useMatch,
|
||||
useMatches,
|
||||
useNavigate,
|
||||
useNavigation,
|
||||
useNavigationType,
|
||||
useOutlet,
|
||||
useOutletContext,
|
||||
useParams,
|
||||
usePrompt,
|
||||
useResolvedPath,
|
||||
useRevalidator,
|
||||
useRoute,
|
||||
useRouteError,
|
||||
useRouteLoaderData,
|
||||
useRouterState,
|
||||
useRoutes,
|
||||
useScrollRestoration,
|
||||
useSearchParams,
|
||||
useSubmit,
|
||||
useViewTransitionState,
|
||||
withComponentProps,
|
||||
withErrorBoundaryProps,
|
||||
withHydrateFallbackProps
|
||||
} from "./chunk-4ZMWKKQ3.mjs";
|
||||
export {
|
||||
Await,
|
||||
BrowserRouter,
|
||||
Form,
|
||||
HashRouter,
|
||||
IDLE_BLOCKER,
|
||||
IDLE_FETCHER,
|
||||
IDLE_NAVIGATION,
|
||||
Link,
|
||||
Links,
|
||||
MemoryRouter,
|
||||
Meta,
|
||||
NavLink,
|
||||
Navigate,
|
||||
Action as NavigationType,
|
||||
Outlet,
|
||||
PrefetchPageLinks,
|
||||
Route,
|
||||
Router,
|
||||
RouterContextProvider,
|
||||
RouterProvider,
|
||||
Routes,
|
||||
Scripts,
|
||||
ScrollRestoration,
|
||||
ServerRouter,
|
||||
StaticRouter,
|
||||
StaticRouterProvider,
|
||||
AwaitContextProvider as UNSAFE_AwaitContextProvider,
|
||||
DataRouterContext as UNSAFE_DataRouterContext,
|
||||
DataRouterStateContext as UNSAFE_DataRouterStateContext,
|
||||
ErrorResponseImpl as UNSAFE_ErrorResponseImpl,
|
||||
FetchersContext as UNSAFE_FetchersContext,
|
||||
FrameworkContext as UNSAFE_FrameworkContext,
|
||||
LocationContext as UNSAFE_LocationContext,
|
||||
NavigationContext as UNSAFE_NavigationContext,
|
||||
RSCDefaultRootErrorBoundary as UNSAFE_RSCDefaultRootErrorBoundary,
|
||||
RemixErrorBoundary as UNSAFE_RemixErrorBoundary,
|
||||
RouteContext as UNSAFE_RouteContext,
|
||||
ServerMode as UNSAFE_ServerMode,
|
||||
SingleFetchRedirectSymbol as UNSAFE_SingleFetchRedirectSymbol,
|
||||
ViewTransitionContext as UNSAFE_ViewTransitionContext,
|
||||
WithComponentProps as UNSAFE_WithComponentProps,
|
||||
WithErrorBoundaryProps as UNSAFE_WithErrorBoundaryProps,
|
||||
WithHydrateFallbackProps as UNSAFE_WithHydrateFallbackProps,
|
||||
createBrowserHistory as UNSAFE_createBrowserHistory,
|
||||
createClientRoutes as UNSAFE_createClientRoutes,
|
||||
createClientRoutesWithHMRRevalidationOptOut as UNSAFE_createClientRoutesWithHMRRevalidationOptOut,
|
||||
createHashHistory as UNSAFE_createHashHistory,
|
||||
createMemoryHistory as UNSAFE_createMemoryHistory,
|
||||
createRouter as UNSAFE_createRouter,
|
||||
decodeViaTurboStream as UNSAFE_decodeViaTurboStream,
|
||||
getHydrationData as UNSAFE_getHydrationData,
|
||||
getPatchRoutesOnNavigationFunction as UNSAFE_getPatchRoutesOnNavigationFunction,
|
||||
getTurboStreamSingleFetchDataStrategy as UNSAFE_getTurboStreamSingleFetchDataStrategy,
|
||||
hydrationRouteProperties as UNSAFE_hydrationRouteProperties,
|
||||
invariant as UNSAFE_invariant,
|
||||
mapRouteProperties as UNSAFE_mapRouteProperties,
|
||||
shouldHydrateRouteLoader as UNSAFE_shouldHydrateRouteLoader,
|
||||
useFogOFWarDiscovery as UNSAFE_useFogOFWarDiscovery,
|
||||
useScrollRestoration as UNSAFE_useScrollRestoration,
|
||||
withComponentProps as UNSAFE_withComponentProps,
|
||||
withErrorBoundaryProps as UNSAFE_withErrorBoundaryProps,
|
||||
withHydrateFallbackProps as UNSAFE_withHydrateFallbackProps,
|
||||
createBrowserRouter,
|
||||
createContext,
|
||||
createCookie,
|
||||
createCookieSessionStorage,
|
||||
createHashRouter,
|
||||
createMemoryRouter,
|
||||
createMemorySessionStorage,
|
||||
createPath,
|
||||
createRequestHandler,
|
||||
createRoutesFromChildren,
|
||||
createRoutesFromElements,
|
||||
createRoutesStub,
|
||||
createSearchParams,
|
||||
createSession,
|
||||
createSessionStorage,
|
||||
createStaticHandler,
|
||||
createStaticRouter,
|
||||
data,
|
||||
generatePath,
|
||||
href,
|
||||
isCookie,
|
||||
isRouteErrorResponse,
|
||||
isSession,
|
||||
matchPath,
|
||||
matchRoutes,
|
||||
parsePath,
|
||||
redirect,
|
||||
redirectDocument,
|
||||
renderMatches,
|
||||
replace,
|
||||
resolvePath,
|
||||
HistoryRouter as unstable_HistoryRouter,
|
||||
RSCStaticRouter as unstable_RSCStaticRouter,
|
||||
routeRSCServerRequest as unstable_routeRSCServerRequest,
|
||||
setDevServerHooks as unstable_setDevServerHooks,
|
||||
usePrompt as unstable_usePrompt,
|
||||
useRoute as unstable_useRoute,
|
||||
useRouterState as unstable_useRouterState,
|
||||
useActionData,
|
||||
useAsyncError,
|
||||
useAsyncValue,
|
||||
useBeforeUnload,
|
||||
useBlocker,
|
||||
useFetcher,
|
||||
useFetchers,
|
||||
useFormAction,
|
||||
useHref,
|
||||
useInRouterContext,
|
||||
useLinkClickHandler,
|
||||
useLoaderData,
|
||||
useLocation,
|
||||
useMatch,
|
||||
useMatches,
|
||||
useNavigate,
|
||||
useNavigation,
|
||||
useNavigationType,
|
||||
useOutlet,
|
||||
useOutletContext,
|
||||
useParams,
|
||||
useResolvedPath,
|
||||
useRevalidator,
|
||||
useRouteError,
|
||||
useRouteLoaderData,
|
||||
useRoutes,
|
||||
useSearchParams,
|
||||
useSubmit,
|
||||
useViewTransitionState
|
||||
};
|
||||
Generated
Vendored
+715
@@ -0,0 +1,715 @@
|
||||
import { e as RouteObject, f as History, g as MaybePromise, c as RouterContextProvider, h as MapRoutePropertiesFunction, i as Action, L as Location, D as DataRouteMatch, j as Submission, k as RouteData, l as DataStrategyFunction, m as PatchRoutesOnNavigationFunction, n as DataRouteObject, o as RouteBranch, p as RouteManifest, U as UIMatch, T as To, q as HTMLFormMethod, F as FormEncType, r as Path, s as LoaderFunctionArgs, t as MiddlewareEnabled, u as AppLoadContext } from './data-CjO11-hU.js';
|
||||
|
||||
/**
|
||||
* A Router instance manages all navigation and data loading/mutations
|
||||
*/
|
||||
interface Router {
|
||||
/**
|
||||
* @private
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Return the basename for the router
|
||||
*/
|
||||
get basename(): RouterInit["basename"];
|
||||
/**
|
||||
* @private
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Return the future config for the router
|
||||
*/
|
||||
get future(): FutureConfig;
|
||||
/**
|
||||
* @private
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Return the current state of the router
|
||||
*/
|
||||
get state(): RouterState;
|
||||
/**
|
||||
* @private
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Return the routes for this router instance
|
||||
*/
|
||||
get routes(): DataRouteObject[];
|
||||
/**
|
||||
* @private
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Return the route branches for this router instance
|
||||
*/
|
||||
get branches(): RouteBranch<DataRouteObject>[] | undefined;
|
||||
/**
|
||||
* @private
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Return the manifest for this router instance
|
||||
*/
|
||||
get manifest(): RouteManifest;
|
||||
/**
|
||||
* @private
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Return the window associated with the router
|
||||
*/
|
||||
get window(): RouterInit["window"];
|
||||
/**
|
||||
* @private
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Initialize the router, including adding history listeners and kicking off
|
||||
* initial data fetches. Returns a function to cleanup listeners and abort
|
||||
* any in-progress loads
|
||||
*/
|
||||
initialize(): Router;
|
||||
/**
|
||||
* @private
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Subscribe to router.state updates
|
||||
*
|
||||
* @param fn function to call with the new state
|
||||
*/
|
||||
subscribe(fn: RouterSubscriber): () => void;
|
||||
/**
|
||||
* @private
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Enable scroll restoration behavior in the router
|
||||
*
|
||||
* @param savedScrollPositions Object that will manage positions, in case
|
||||
* it's being restored from sessionStorage
|
||||
* @param getScrollPosition Function to get the active Y scroll position
|
||||
* @param getKey Function to get the key to use for restoration
|
||||
*/
|
||||
enableScrollRestoration(savedScrollPositions: Record<string, number>, getScrollPosition: GetScrollPositionFunction, getKey?: GetScrollRestorationKeyFunction): () => void;
|
||||
/**
|
||||
* @private
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Navigate forward/backward in the history stack
|
||||
* @param to Delta to move in the history stack
|
||||
*/
|
||||
navigate(to: number): Promise<void>;
|
||||
/**
|
||||
* Navigate to the given path
|
||||
* @param to Path to navigate to
|
||||
* @param opts Navigation options (method, submission, etc.)
|
||||
*/
|
||||
navigate(to: To | null, opts?: RouterNavigateOptions): Promise<void>;
|
||||
/**
|
||||
* @private
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Trigger a fetcher load/submission
|
||||
*
|
||||
* @param key Fetcher key
|
||||
* @param routeId Route that owns the fetcher
|
||||
* @param href href to fetch
|
||||
* @param opts Fetcher options, (method, submission, etc.)
|
||||
*/
|
||||
fetch(key: string, routeId: string, href: string | null, opts?: RouterFetchOptions): Promise<void>;
|
||||
/**
|
||||
* @private
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Trigger a revalidation of all current route loaders and fetcher loads
|
||||
*/
|
||||
revalidate(): Promise<void>;
|
||||
/**
|
||||
* @private
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Utility function to create an href for the given location
|
||||
* @param location
|
||||
*/
|
||||
createHref(location: Location | URL): string;
|
||||
/**
|
||||
* @private
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Utility function to URL encode a destination path according to the internal
|
||||
* history implementation
|
||||
* @param to
|
||||
*/
|
||||
encodeLocation(to: To): Path;
|
||||
/**
|
||||
* @private
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Get/create a fetcher for the given key
|
||||
* @param key
|
||||
*/
|
||||
getFetcher<TData = any>(key: string): Fetcher<TData>;
|
||||
/**
|
||||
* @internal
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Reset the fetcher for a given key
|
||||
* @param key
|
||||
*/
|
||||
resetFetcher(key: string, opts?: {
|
||||
reason?: unknown;
|
||||
}): void;
|
||||
/**
|
||||
* @private
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Delete the fetcher for a given key
|
||||
* @param key
|
||||
*/
|
||||
deleteFetcher(key: string): void;
|
||||
/**
|
||||
* @private
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Cleanup listeners and abort any in-progress loads
|
||||
*/
|
||||
dispose(): void;
|
||||
/**
|
||||
* @private
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Get a navigation blocker
|
||||
* @param key The identifier for the blocker
|
||||
* @param fn The blocker function implementation
|
||||
*/
|
||||
getBlocker(key: string, fn: BlockerFunction): Blocker;
|
||||
/**
|
||||
* @private
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Delete a navigation blocker
|
||||
* @param key The identifier for the blocker
|
||||
*/
|
||||
deleteBlocker(key: string): void;
|
||||
/**
|
||||
* @private
|
||||
* PRIVATE DO NOT USE
|
||||
*
|
||||
* Patch additional children routes into an existing parent route
|
||||
* @param routeId The parent route id or a callback function accepting `patch`
|
||||
* to perform batch patching
|
||||
* @param children The additional children routes
|
||||
* @param unstable_allowElementMutations Allow mutation or route elements on
|
||||
* existing routes. Intended for RSC-usage
|
||||
* only.
|
||||
*/
|
||||
patchRoutes(routeId: string | null, children: RouteObject[], unstable_allowElementMutations?: boolean): void;
|
||||
/**
|
||||
* @private
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* HMR needs to pass in-flight route updates to React Router
|
||||
* TODO: Replace this with granular route update APIs (addRoute, updateRoute, deleteRoute)
|
||||
*/
|
||||
_internalSetRoutes(routes: RouteObject[]): void;
|
||||
/**
|
||||
* @private
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Cause subscribers to re-render. This is used to force a re-render.
|
||||
*/
|
||||
_internalSetStateDoNotUseOrYouWillBreakYourApp(state: Partial<RouterState>): void;
|
||||
/**
|
||||
* @private
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Internal fetch AbortControllers accessed by unit tests
|
||||
*/
|
||||
_internalFetchControllers: Map<string, AbortController>;
|
||||
}
|
||||
/**
|
||||
* State maintained internally by the router. During a navigation, all states
|
||||
* reflect the "old" location unless otherwise noted.
|
||||
*/
|
||||
interface RouterState {
|
||||
/**
|
||||
* The action of the most recent navigation
|
||||
*/
|
||||
historyAction: Action;
|
||||
/**
|
||||
* The current location reflected by the router
|
||||
*/
|
||||
location: Location;
|
||||
/**
|
||||
* The current set of route matches
|
||||
*/
|
||||
matches: DataRouteMatch[];
|
||||
/**
|
||||
* Tracks whether we've completed our initial data load
|
||||
*/
|
||||
initialized: boolean;
|
||||
/**
|
||||
* Tracks whether we should be rendering a HydrateFallback during hydration
|
||||
*/
|
||||
renderFallback: boolean;
|
||||
/**
|
||||
* Current scroll position we should start at for a new view
|
||||
* - number -> scroll position to restore to
|
||||
* - false -> do not restore scroll at all (used during submissions/revalidations)
|
||||
* - null -> don't have a saved position, scroll to hash or top of page
|
||||
*/
|
||||
restoreScrollPosition: number | false | null;
|
||||
/**
|
||||
* Indicate whether this navigation should skip resetting the scroll position
|
||||
* if we are unable to restore the scroll position
|
||||
*/
|
||||
preventScrollReset: boolean;
|
||||
/**
|
||||
* Tracks the state of the current navigation
|
||||
*/
|
||||
navigation: Navigation;
|
||||
/**
|
||||
* Tracks any in-progress revalidations
|
||||
*/
|
||||
revalidation: RevalidationState;
|
||||
/**
|
||||
* Data from the loaders for the current matches
|
||||
*/
|
||||
loaderData: RouteData;
|
||||
/**
|
||||
* Data from the action for the current matches
|
||||
*/
|
||||
actionData: RouteData | null;
|
||||
/**
|
||||
* Errors caught from loaders for the current matches
|
||||
*/
|
||||
errors: RouteData | null;
|
||||
/**
|
||||
* Map of current fetchers
|
||||
*/
|
||||
fetchers: Map<string, Fetcher>;
|
||||
/**
|
||||
* Map of current blockers
|
||||
*/
|
||||
blockers: Map<string, Blocker>;
|
||||
}
|
||||
/**
|
||||
* Data that can be passed into hydrate a Router from SSR
|
||||
*/
|
||||
type HydrationState = Partial<Pick<RouterState, "loaderData" | "actionData" | "errors">>;
|
||||
/**
|
||||
* Future flags to toggle new feature behavior
|
||||
*/
|
||||
interface FutureConfig {
|
||||
}
|
||||
/**
|
||||
* Initialization options for createRouter
|
||||
*/
|
||||
interface RouterInit {
|
||||
routes: RouteObject[];
|
||||
history: History;
|
||||
basename?: string;
|
||||
getContext?: () => MaybePromise<RouterContextProvider>;
|
||||
instrumentations?: ClientInstrumentation[];
|
||||
mapRouteProperties?: MapRoutePropertiesFunction;
|
||||
future?: Partial<FutureConfig>;
|
||||
hydrationRouteProperties?: string[];
|
||||
hydrationData?: HydrationState;
|
||||
window?: Window;
|
||||
dataStrategy?: DataStrategyFunction;
|
||||
patchRoutesOnNavigation?: PatchRoutesOnNavigationFunction;
|
||||
}
|
||||
/**
|
||||
* State returned from a server-side query() call
|
||||
*/
|
||||
interface StaticHandlerContext {
|
||||
basename: Router["basename"];
|
||||
location: RouterState["location"];
|
||||
matches: RouterState["matches"];
|
||||
loaderData: RouterState["loaderData"];
|
||||
actionData: RouterState["actionData"];
|
||||
errors: RouterState["errors"];
|
||||
statusCode: number;
|
||||
loaderHeaders: Record<string, Headers>;
|
||||
actionHeaders: Record<string, Headers>;
|
||||
_deepestRenderedBoundaryId?: string | null;
|
||||
}
|
||||
/**
|
||||
* A StaticHandler instance manages a singular SSR navigation/fetch event
|
||||
*/
|
||||
interface StaticHandler {
|
||||
/**
|
||||
* The set of data routes managed by this handler
|
||||
*/
|
||||
dataRoutes: DataRouteObject[];
|
||||
/**
|
||||
* @private
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* The route branches derived from the data routes, used for internal route
|
||||
* matching in Framework Mode
|
||||
*/
|
||||
_internalRouteBranches: RouteBranch<DataRouteObject>[];
|
||||
/**
|
||||
* Perform a query for a given request - executing all matched route
|
||||
* loaders/actions. Used for document requests.
|
||||
*
|
||||
* @param request The request to query
|
||||
* @param opts Optional query options
|
||||
* @param opts.dataStrategy Alternate dataStrategy implementation
|
||||
* @param opts.filterMatchesToLoad Predicate function to filter which matches should be loaded
|
||||
* @param opts.generateMiddlewareResponse To enable middleware, provide a function
|
||||
* to generate a response to bubble back up the middleware chain
|
||||
* @param opts.requestContext Context object to pass to loaders/actions
|
||||
* @param opts.skipLoaderErrorBubbling Skip loader error bubbling
|
||||
* @param opts.skipRevalidation Skip revalidation after action submission
|
||||
* @param opts.normalizePath Normalize the request path
|
||||
*/
|
||||
query(request: Request, opts?: {
|
||||
requestContext?: unknown;
|
||||
filterMatchesToLoad?: (match: DataRouteMatch) => boolean;
|
||||
skipLoaderErrorBubbling?: boolean;
|
||||
skipRevalidation?: boolean;
|
||||
dataStrategy?: DataStrategyFunction<unknown>;
|
||||
generateMiddlewareResponse?: (query: (r: Request, args?: {
|
||||
filterMatchesToLoad?: (match: DataRouteMatch) => boolean;
|
||||
}) => Promise<StaticHandlerContext | Response>) => MaybePromise<Response>;
|
||||
normalizePath?: (request: Request) => Path;
|
||||
}): Promise<StaticHandlerContext | Response>;
|
||||
/**
|
||||
* Perform a query for a specific route. Used for resource requests.
|
||||
*
|
||||
* @param request The request to query
|
||||
* @param opts Optional queryRoute options
|
||||
* @param opts.dataStrategy Alternate dataStrategy implementation
|
||||
* @param opts.generateMiddlewareResponse To enable middleware, provide a function
|
||||
* to generate a response to bubble back up the middleware chain
|
||||
* @param opts.requestContext Context object to pass to loaders/actions
|
||||
* @param opts.routeId The ID of the route to query
|
||||
* @param opts.normalizePath Normalize the request path
|
||||
|
||||
*/
|
||||
queryRoute(request: Request, opts?: {
|
||||
routeId?: string;
|
||||
requestContext?: unknown;
|
||||
dataStrategy?: DataStrategyFunction<unknown>;
|
||||
generateMiddlewareResponse?: (queryRoute: (r: Request) => Promise<Response>) => MaybePromise<Response>;
|
||||
normalizePath?: (request: Request) => Path;
|
||||
}): Promise<any>;
|
||||
}
|
||||
type ViewTransitionOpts = {
|
||||
currentLocation: Location;
|
||||
nextLocation: Location;
|
||||
};
|
||||
/**
|
||||
* Subscriber function signature for changes to router state
|
||||
*/
|
||||
interface RouterSubscriber {
|
||||
(state: RouterState, opts: {
|
||||
deletedFetchers: string[];
|
||||
newErrors: RouteData | null;
|
||||
viewTransitionOpts?: ViewTransitionOpts;
|
||||
flushSync: boolean;
|
||||
}): void;
|
||||
}
|
||||
/**
|
||||
* Function signature for determining the key to be used in scroll restoration
|
||||
* for a given location
|
||||
*/
|
||||
interface GetScrollRestorationKeyFunction {
|
||||
(location: Location, matches: UIMatch[]): string | null;
|
||||
}
|
||||
/**
|
||||
* Function signature for determining the current scroll position
|
||||
*/
|
||||
interface GetScrollPositionFunction {
|
||||
(): number;
|
||||
}
|
||||
/**
|
||||
* - "route": relative to the route hierarchy so `..` means remove all segments
|
||||
* of the current route even if it has many. For example, a `route("posts/:id")`
|
||||
* would have both `:id` and `posts` removed from the url.
|
||||
* - "path": relative to the pathname so `..` means remove one segment of the
|
||||
* pathname. For example, a `route("posts/:id")` would have only `:id` removed
|
||||
* from the url.
|
||||
*/
|
||||
type RelativeRoutingType = "route" | "path";
|
||||
type BaseNavigateOrFetchOptions = {
|
||||
preventScrollReset?: boolean;
|
||||
relative?: RelativeRoutingType;
|
||||
flushSync?: boolean;
|
||||
defaultShouldRevalidate?: boolean;
|
||||
};
|
||||
type BaseNavigateOptions = BaseNavigateOrFetchOptions & {
|
||||
replace?: boolean;
|
||||
state?: any;
|
||||
fromRouteId?: string;
|
||||
viewTransition?: boolean;
|
||||
mask?: To;
|
||||
};
|
||||
type BaseSubmissionOptions = {
|
||||
formMethod?: HTMLFormMethod;
|
||||
formEncType?: FormEncType;
|
||||
} & ({
|
||||
formData: FormData;
|
||||
body?: undefined;
|
||||
} | {
|
||||
formData?: undefined;
|
||||
body: any;
|
||||
});
|
||||
/**
|
||||
* Options for a navigate() call for a normal (non-submission) navigation
|
||||
*/
|
||||
type LinkNavigateOptions = BaseNavigateOptions;
|
||||
/**
|
||||
* Options for a navigate() call for a submission navigation
|
||||
*/
|
||||
type SubmissionNavigateOptions = BaseNavigateOptions & BaseSubmissionOptions;
|
||||
/**
|
||||
* Options to pass to navigate() for a navigation
|
||||
*/
|
||||
type RouterNavigateOptions = LinkNavigateOptions | SubmissionNavigateOptions;
|
||||
/**
|
||||
* Options for a fetch() load
|
||||
*/
|
||||
type LoadFetchOptions = BaseNavigateOrFetchOptions;
|
||||
/**
|
||||
* Options for a fetch() submission
|
||||
*/
|
||||
type SubmitFetchOptions = BaseNavigateOrFetchOptions & BaseSubmissionOptions;
|
||||
/**
|
||||
* Options to pass to fetch()
|
||||
*/
|
||||
type RouterFetchOptions = LoadFetchOptions | SubmitFetchOptions;
|
||||
/**
|
||||
* Potential states for state.navigation
|
||||
*/
|
||||
type NavigationStates = {
|
||||
Idle: {
|
||||
state: "idle";
|
||||
location: undefined;
|
||||
matches: undefined;
|
||||
historyAction: undefined;
|
||||
formMethod: undefined;
|
||||
formAction: undefined;
|
||||
formEncType: undefined;
|
||||
formData: undefined;
|
||||
json: undefined;
|
||||
text: undefined;
|
||||
};
|
||||
Loading: {
|
||||
state: "loading";
|
||||
location: Location;
|
||||
matches: DataRouteMatch[];
|
||||
historyAction: Action;
|
||||
formMethod: Submission["formMethod"] | undefined;
|
||||
formAction: Submission["formAction"] | undefined;
|
||||
formEncType: Submission["formEncType"] | undefined;
|
||||
formData: Submission["formData"] | undefined;
|
||||
json: Submission["json"] | undefined;
|
||||
text: Submission["text"] | undefined;
|
||||
};
|
||||
Submitting: {
|
||||
state: "submitting";
|
||||
location: Location;
|
||||
matches: DataRouteMatch[];
|
||||
historyAction: Action;
|
||||
formMethod: Submission["formMethod"];
|
||||
formAction: Submission["formAction"];
|
||||
formEncType: Submission["formEncType"];
|
||||
formData: Submission["formData"];
|
||||
json: Submission["json"];
|
||||
text: Submission["text"];
|
||||
};
|
||||
};
|
||||
type Navigation = NavigationStates[keyof NavigationStates];
|
||||
type RevalidationState = "idle" | "loading";
|
||||
/**
|
||||
* Potential states for fetchers
|
||||
*/
|
||||
type FetcherStates<TData = any> = {
|
||||
/**
|
||||
* The fetcher is not calling a loader or action
|
||||
*
|
||||
* ```tsx
|
||||
* fetcher.state === "idle"
|
||||
* ```
|
||||
*/
|
||||
Idle: {
|
||||
state: "idle";
|
||||
formMethod: undefined;
|
||||
formAction: undefined;
|
||||
formEncType: undefined;
|
||||
text: undefined;
|
||||
formData: undefined;
|
||||
json: undefined;
|
||||
/**
|
||||
* If the fetcher has never been called, this will be undefined.
|
||||
*/
|
||||
data: TData | undefined;
|
||||
};
|
||||
/**
|
||||
* The fetcher is loading data from a {@link LoaderFunction | loader} from a
|
||||
* call to {@link FetcherWithComponents.load | `fetcher.load`}.
|
||||
*
|
||||
* ```tsx
|
||||
* // somewhere
|
||||
* <button onClick={() => fetcher.load("/some/route") }>Load</button>
|
||||
*
|
||||
* // the state will update
|
||||
* fetcher.state === "loading"
|
||||
* ```
|
||||
*/
|
||||
Loading: {
|
||||
state: "loading";
|
||||
formMethod: Submission["formMethod"] | undefined;
|
||||
formAction: Submission["formAction"] | undefined;
|
||||
formEncType: Submission["formEncType"] | undefined;
|
||||
text: Submission["text"] | undefined;
|
||||
formData: Submission["formData"] | undefined;
|
||||
json: Submission["json"] | undefined;
|
||||
data: TData | undefined;
|
||||
};
|
||||
/**
|
||||
The fetcher is submitting to a {@link LoaderFunction} (GET) or {@link ActionFunction} (POST) from a {@link FetcherWithComponents.Form | `fetcher.Form`} or {@link FetcherWithComponents.submit | `fetcher.submit`}.
|
||||
|
||||
```tsx
|
||||
// somewhere
|
||||
<input
|
||||
onChange={e => {
|
||||
fetcher.submit(event.currentTarget.form, { method: "post" });
|
||||
}}
|
||||
/>
|
||||
|
||||
// the state will update
|
||||
fetcher.state === "submitting"
|
||||
|
||||
// and formData will be available
|
||||
fetcher.formData
|
||||
```
|
||||
*/
|
||||
Submitting: {
|
||||
state: "submitting";
|
||||
formMethod: Submission["formMethod"];
|
||||
formAction: Submission["formAction"];
|
||||
formEncType: Submission["formEncType"];
|
||||
text: Submission["text"];
|
||||
formData: Submission["formData"];
|
||||
json: Submission["json"];
|
||||
data: TData | undefined;
|
||||
};
|
||||
};
|
||||
type Fetcher<TData = any> = FetcherStates<TData>[keyof FetcherStates<TData>];
|
||||
interface BlockerBlocked {
|
||||
state: "blocked";
|
||||
reset: () => void;
|
||||
proceed: () => void;
|
||||
location: Location;
|
||||
}
|
||||
interface BlockerUnblocked {
|
||||
state: "unblocked";
|
||||
reset: undefined;
|
||||
proceed: undefined;
|
||||
location: undefined;
|
||||
}
|
||||
interface BlockerProceeding {
|
||||
state: "proceeding";
|
||||
reset: undefined;
|
||||
proceed: undefined;
|
||||
location: Location;
|
||||
}
|
||||
type Blocker = BlockerUnblocked | BlockerBlocked | BlockerProceeding;
|
||||
type BlockerFunction = (args: {
|
||||
currentLocation: Location;
|
||||
nextLocation: Location;
|
||||
historyAction: Action;
|
||||
}) => boolean;
|
||||
declare const IDLE_NAVIGATION: NavigationStates["Idle"];
|
||||
declare const IDLE_FETCHER: FetcherStates["Idle"];
|
||||
declare const IDLE_BLOCKER: BlockerUnblocked;
|
||||
/**
|
||||
* Create a router and listen to history POP navigations
|
||||
*/
|
||||
declare function createRouter(init: RouterInit): Router;
|
||||
interface CreateStaticHandlerOptions {
|
||||
basename?: string;
|
||||
mapRouteProperties?: MapRoutePropertiesFunction;
|
||||
instrumentations?: Pick<ServerInstrumentation, "route">[];
|
||||
future?: Partial<FutureConfig>;
|
||||
}
|
||||
|
||||
type ServerInstrumentation = {
|
||||
handler?: InstrumentRequestHandlerFunction;
|
||||
route?: InstrumentRouteFunction;
|
||||
};
|
||||
type ClientInstrumentation = {
|
||||
router?: InstrumentRouterFunction;
|
||||
route?: InstrumentRouteFunction;
|
||||
};
|
||||
type InstrumentRequestHandlerFunction = (handler: InstrumentableRequestHandler) => void;
|
||||
type InstrumentRouterFunction = (router: InstrumentableRouter) => void;
|
||||
type InstrumentRouteFunction = (route: InstrumentableRoute) => void;
|
||||
type InstrumentationHandlerResult = {
|
||||
status: "success";
|
||||
error: undefined;
|
||||
} | {
|
||||
status: "error";
|
||||
error: Error;
|
||||
};
|
||||
type InstrumentFunction<T> = (handler: () => Promise<InstrumentationHandlerResult>, info: T) => Promise<void>;
|
||||
type ReadonlyRequest = {
|
||||
method: string;
|
||||
url: string;
|
||||
headers: Pick<Headers, "get">;
|
||||
};
|
||||
type ReadonlyContext = MiddlewareEnabled extends true ? Pick<RouterContextProvider, "get"> : Readonly<AppLoadContext>;
|
||||
type InstrumentableRoute = {
|
||||
id: string;
|
||||
index: boolean | undefined;
|
||||
path: string | undefined;
|
||||
instrument(instrumentations: RouteInstrumentations): void;
|
||||
};
|
||||
type RouteInstrumentations = {
|
||||
lazy?: InstrumentFunction<RouteLazyInstrumentationInfo>;
|
||||
"lazy.loader"?: InstrumentFunction<RouteLazyInstrumentationInfo>;
|
||||
"lazy.action"?: InstrumentFunction<RouteLazyInstrumentationInfo>;
|
||||
"lazy.middleware"?: InstrumentFunction<RouteLazyInstrumentationInfo>;
|
||||
middleware?: InstrumentFunction<RouteHandlerInstrumentationInfo>;
|
||||
loader?: InstrumentFunction<RouteHandlerInstrumentationInfo>;
|
||||
action?: InstrumentFunction<RouteHandlerInstrumentationInfo>;
|
||||
};
|
||||
type RouteLazyInstrumentationInfo = undefined;
|
||||
type RouteHandlerInstrumentationInfo = Readonly<{
|
||||
request: ReadonlyRequest;
|
||||
params: LoaderFunctionArgs["params"];
|
||||
pattern: string;
|
||||
context: ReadonlyContext;
|
||||
}>;
|
||||
type InstrumentableRouter = {
|
||||
instrument(instrumentations: RouterInstrumentations): void;
|
||||
};
|
||||
type RouterInstrumentations = {
|
||||
navigate?: InstrumentFunction<RouterNavigationInstrumentationInfo>;
|
||||
fetch?: InstrumentFunction<RouterFetchInstrumentationInfo>;
|
||||
};
|
||||
type RouterNavigationInstrumentationInfo = Readonly<{
|
||||
to: string | number;
|
||||
currentUrl: string;
|
||||
formMethod?: HTMLFormMethod;
|
||||
formEncType?: FormEncType;
|
||||
formData?: FormData;
|
||||
body?: any;
|
||||
}>;
|
||||
type RouterFetchInstrumentationInfo = Readonly<{
|
||||
href: string;
|
||||
currentUrl: string;
|
||||
fetcherKey: string;
|
||||
formMethod?: HTMLFormMethod;
|
||||
formEncType?: FormEncType;
|
||||
formData?: FormData;
|
||||
body?: any;
|
||||
}>;
|
||||
type InstrumentableRequestHandler = {
|
||||
instrument(instrumentations: RequestHandlerInstrumentations): void;
|
||||
};
|
||||
type RequestHandlerInstrumentations = {
|
||||
request?: InstrumentFunction<RequestHandlerInstrumentationInfo>;
|
||||
};
|
||||
type RequestHandlerInstrumentationInfo = Readonly<{
|
||||
request: ReadonlyRequest;
|
||||
context: ReadonlyContext | undefined;
|
||||
}>;
|
||||
|
||||
export { type BlockerFunction as B, type ClientInstrumentation as C, type Fetcher as F, type GetScrollPositionFunction as G, type HydrationState as H, type InstrumentRequestHandlerFunction as I, type NavigationStates as N, type RouterInit as R, type StaticHandler as S, type Router as a, type Blocker as b, type RelativeRoutingType as c, type GetScrollRestorationKeyFunction as d, type StaticHandlerContext as e, type Navigation as f, type RouterState as g, type RouterSubscriber as h, type RouterNavigateOptions as i, type RouterFetchOptions as j, type RevalidationState as k, type ServerInstrumentation as l, type InstrumentRouterFunction as m, type InstrumentRouteFunction as n, type InstrumentationHandlerResult as o, IDLE_NAVIGATION as p, IDLE_FETCHER as q, IDLE_BLOCKER as r, createRouter as s, type FutureConfig as t, type CreateStaticHandlerOptions as u };
|
||||
+184
@@ -0,0 +1,184 @@
|
||||
import { R as RouteModule, e as LinkDescriptor, L as Location, F as Func, f as Pretty, g as MetaDescriptor, G as GetLoaderData, h as ServerDataFunctionArgs, i as MiddlewareNextFunction, j as ClientDataFunctionArgs, D as DataStrategyResult, k as ServerDataFrom, N as Normalize, l as GetActionData } from '../../data-DEjBmEfD.mjs';
|
||||
import { R as RouteFiles, P as Pages } from '../../register-CmkRspdl.mjs';
|
||||
import 'react';
|
||||
|
||||
type MaybePromise<T> = T | Promise<T>;
|
||||
type Props = {
|
||||
params: unknown;
|
||||
loaderData: unknown;
|
||||
actionData: unknown;
|
||||
};
|
||||
type RouteInfo = Props & {
|
||||
module: RouteModule;
|
||||
matches: Array<MatchInfo>;
|
||||
};
|
||||
type MatchInfo = {
|
||||
id: string;
|
||||
module: RouteModule;
|
||||
};
|
||||
type MetaMatch<T extends MatchInfo> = Pretty<{
|
||||
id: T["id"];
|
||||
params: Record<string, string | undefined>;
|
||||
pathname: string;
|
||||
meta: MetaDescriptor[];
|
||||
/** @deprecated Use `MetaMatch.loaderData` instead */
|
||||
data: GetLoaderData<T["module"]>;
|
||||
loaderData: GetLoaderData<T["module"]>;
|
||||
handle?: unknown;
|
||||
error?: unknown;
|
||||
}>;
|
||||
type MetaMatches<T extends Array<MatchInfo>> = T extends [infer F extends MatchInfo, ...infer R extends Array<MatchInfo>] ? [MetaMatch<F>, ...MetaMatches<R>] : Array<MetaMatch<MatchInfo> | undefined>;
|
||||
type HasErrorBoundary<T extends RouteInfo> = T["module"] extends {
|
||||
ErrorBoundary: Func;
|
||||
} ? true : false;
|
||||
type CreateMetaArgs<T extends RouteInfo> = {
|
||||
/** This is the current router `Location` object. This is useful for generating tags for routes at specific paths or query parameters. */
|
||||
location: Location;
|
||||
/** {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route. */
|
||||
params: T["params"];
|
||||
/**
|
||||
* The return value for this route's server loader function
|
||||
*
|
||||
* @deprecated Use `Route.MetaArgs.loaderData` instead
|
||||
*/
|
||||
data: T["loaderData"] | (HasErrorBoundary<T> extends true ? undefined : never);
|
||||
/** The return value for this route's server loader function */
|
||||
loaderData: T["loaderData"] | (HasErrorBoundary<T> extends true ? undefined : never);
|
||||
/** Thrown errors that trigger error boundaries will be passed to the meta function. This is useful for generating metadata for error pages. */
|
||||
error?: unknown;
|
||||
/** An array of the current {@link https://api.reactrouter.com/v7/interfaces/react-router.UIMatch.html route matches}, including parent route matches. */
|
||||
matches: MetaMatches<T["matches"]>;
|
||||
};
|
||||
type MetaDescriptors = MetaDescriptor[];
|
||||
type HeadersArgs = {
|
||||
loaderHeaders: Headers;
|
||||
parentHeaders: Headers;
|
||||
actionHeaders: Headers;
|
||||
errorHeaders: Headers | undefined;
|
||||
};
|
||||
type CreateServerMiddlewareFunction<T extends RouteInfo> = (args: ServerDataFunctionArgs<T["params"]>, next: MiddlewareNextFunction<Response>) => MaybePromise<Response | void>;
|
||||
type CreateClientMiddlewareFunction<T extends RouteInfo> = (args: ClientDataFunctionArgs<T["params"]>, next: MiddlewareNextFunction<Record<string, DataStrategyResult>>) => MaybePromise<Record<string, DataStrategyResult> | void>;
|
||||
type CreateServerLoaderArgs<T extends RouteInfo> = ServerDataFunctionArgs<T["params"]>;
|
||||
type CreateClientLoaderArgs<T extends RouteInfo> = ClientDataFunctionArgs<T["params"]> & {
|
||||
/** 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). */
|
||||
serverLoader: () => Promise<ServerDataFrom<T["module"]["loader"]>>;
|
||||
};
|
||||
type CreateServerActionArgs<T extends RouteInfo> = ServerDataFunctionArgs<T["params"]>;
|
||||
type CreateClientActionArgs<T extends RouteInfo> = ClientDataFunctionArgs<T["params"]> & {
|
||||
/** 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. */
|
||||
serverAction: () => Promise<ServerDataFrom<T["module"]["action"]>>;
|
||||
};
|
||||
type CreateHydrateFallbackProps<T extends RouteInfo, RSCEnabled extends boolean> = {
|
||||
params: T["params"];
|
||||
} & (RSCEnabled extends true ? {
|
||||
/** The data returned from the `loader` */
|
||||
loaderData?: ServerDataFrom<T["module"]["loader"]>;
|
||||
/** The data returned from the `action` following an action submission. */
|
||||
actionData?: ServerDataFrom<T["module"]["action"]>;
|
||||
} : {
|
||||
/** The data returned from the `loader` or `clientLoader` */
|
||||
loaderData?: T["loaderData"];
|
||||
/** The data returned from the `action` or `clientAction` following an action submission. */
|
||||
actionData?: T["actionData"];
|
||||
});
|
||||
type Match<T extends MatchInfo> = Pretty<{
|
||||
id: T["id"];
|
||||
params: Record<string, string | undefined>;
|
||||
pathname: string;
|
||||
/** @deprecated Use `Match.loaderData` instead */
|
||||
data: GetLoaderData<T["module"]>;
|
||||
loaderData: GetLoaderData<T["module"]>;
|
||||
handle: unknown;
|
||||
}>;
|
||||
type Matches<T extends Array<MatchInfo>> = T extends [infer F extends MatchInfo, ...infer R extends Array<MatchInfo>] ? [Match<F>, ...Matches<R>] : Array<Match<MatchInfo> | undefined>;
|
||||
type CreateComponentProps<T extends RouteInfo, RSCEnabled extends boolean> = {
|
||||
/**
|
||||
* {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
|
||||
* @example
|
||||
* // app/routes.ts
|
||||
* route("teams/:teamId", "./team.tsx"),
|
||||
*
|
||||
* // app/team.tsx
|
||||
* export default function Component({
|
||||
* params,
|
||||
* }: Route.ComponentProps) {
|
||||
* params.teamId;
|
||||
* // ^ string
|
||||
* }
|
||||
**/
|
||||
params: T["params"];
|
||||
/** An array of the current {@link https://api.reactrouter.com/v7/interfaces/react-router.UIMatch.html route matches}, including parent route matches. */
|
||||
matches: Matches<T["matches"]>;
|
||||
} & (RSCEnabled extends true ? {
|
||||
/** The data returned from the `loader` */
|
||||
loaderData: ServerDataFrom<T["module"]["loader"]>;
|
||||
/** The data returned from the `action` following an action submission. */
|
||||
actionData?: ServerDataFrom<T["module"]["action"]>;
|
||||
} : {
|
||||
/** The data returned from the `loader` or `clientLoader` */
|
||||
loaderData: T["loaderData"];
|
||||
/** The data returned from the `action` or `clientAction` following an action submission. */
|
||||
actionData?: T["actionData"];
|
||||
});
|
||||
type CreateErrorBoundaryProps<T extends RouteInfo, RSCEnabled extends boolean> = {
|
||||
/**
|
||||
* {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
|
||||
* @example
|
||||
* // app/routes.ts
|
||||
* route("teams/:teamId", "./team.tsx"),
|
||||
*
|
||||
* // app/team.tsx
|
||||
* export function ErrorBoundary({
|
||||
* params,
|
||||
* }: Route.ErrorBoundaryProps) {
|
||||
* params.teamId;
|
||||
* // ^ string
|
||||
* }
|
||||
**/
|
||||
params: T["params"];
|
||||
error: unknown;
|
||||
} & (RSCEnabled extends true ? {
|
||||
/** The data returned from the `loader` */
|
||||
loaderData?: ServerDataFrom<T["module"]["loader"]>;
|
||||
/** The data returned from the `action` following an action submission. */
|
||||
actionData?: ServerDataFrom<T["module"]["action"]>;
|
||||
} : {
|
||||
/** The data returned from the `loader` or `clientLoader` */
|
||||
loaderData?: T["loaderData"];
|
||||
/** The data returned from the `action` or `clientAction` following an action submission. */
|
||||
actionData?: T["actionData"];
|
||||
});
|
||||
type GetAnnotations<Info extends RouteInfo> = {
|
||||
LinkDescriptors: LinkDescriptor[];
|
||||
LinksFunction: () => LinkDescriptor[];
|
||||
MetaArgs: CreateMetaArgs<Info>;
|
||||
MetaDescriptors: MetaDescriptors;
|
||||
MetaFunction: (args: CreateMetaArgs<Info>) => MetaDescriptors;
|
||||
HeadersArgs: HeadersArgs;
|
||||
HeadersFunction: (args: HeadersArgs) => Headers | HeadersInit;
|
||||
MiddlewareFunction: CreateServerMiddlewareFunction<Info>;
|
||||
ClientMiddlewareFunction: CreateClientMiddlewareFunction<Info>;
|
||||
LoaderArgs: CreateServerLoaderArgs<Info>;
|
||||
ClientLoaderArgs: CreateClientLoaderArgs<Info>;
|
||||
ActionArgs: CreateServerActionArgs<Info>;
|
||||
ClientActionArgs: CreateClientActionArgs<Info>;
|
||||
HydrateFallbackProps: CreateHydrateFallbackProps<Info, false>;
|
||||
ServerHydrateFallbackProps: CreateHydrateFallbackProps<Info, true>;
|
||||
ComponentProps: CreateComponentProps<Info, false>;
|
||||
ServerComponentProps: CreateComponentProps<Info, true>;
|
||||
ErrorBoundaryProps: CreateErrorBoundaryProps<Info, false>;
|
||||
ServerErrorBoundaryProps: CreateErrorBoundaryProps<Info, true>;
|
||||
};
|
||||
|
||||
type Params<RouteFile extends keyof RouteFiles> = Normalize<Pages[RouteFiles[RouteFile]["page"]]["params"]>;
|
||||
|
||||
type GetInfo<T extends {
|
||||
file: keyof RouteFiles;
|
||||
module: RouteModule;
|
||||
}> = {
|
||||
params: Params<T["file"]>;
|
||||
loaderData: GetLoaderData<T["module"]>;
|
||||
actionData: GetActionData<T["module"]>;
|
||||
};
|
||||
|
||||
export type { GetAnnotations, GetInfo };
|
||||
+184
@@ -0,0 +1,184 @@
|
||||
import { R as RouteModule, v as LinkDescriptor, L as Location, w as Func, x as Pretty, y as MetaDescriptor, G as GetLoaderData, z as ServerDataFunctionArgs, B as MiddlewareNextFunction, E as ClientDataFunctionArgs, I as DataStrategyResult, J as ServerDataFrom, N as Normalize, K as GetActionData } from '../../data-CjO11-hU.js';
|
||||
import { R as RouteFiles, P as Pages } from '../../register-roq_0qYo.js';
|
||||
import 'react';
|
||||
|
||||
type MaybePromise<T> = T | Promise<T>;
|
||||
type Props = {
|
||||
params: unknown;
|
||||
loaderData: unknown;
|
||||
actionData: unknown;
|
||||
};
|
||||
type RouteInfo = Props & {
|
||||
module: RouteModule;
|
||||
matches: Array<MatchInfo>;
|
||||
};
|
||||
type MatchInfo = {
|
||||
id: string;
|
||||
module: RouteModule;
|
||||
};
|
||||
type MetaMatch<T extends MatchInfo> = Pretty<{
|
||||
id: T["id"];
|
||||
params: Record<string, string | undefined>;
|
||||
pathname: string;
|
||||
meta: MetaDescriptor[];
|
||||
/** @deprecated Use `MetaMatch.loaderData` instead */
|
||||
data: GetLoaderData<T["module"]>;
|
||||
loaderData: GetLoaderData<T["module"]>;
|
||||
handle?: unknown;
|
||||
error?: unknown;
|
||||
}>;
|
||||
type MetaMatches<T extends Array<MatchInfo>> = T extends [infer F extends MatchInfo, ...infer R extends Array<MatchInfo>] ? [MetaMatch<F>, ...MetaMatches<R>] : Array<MetaMatch<MatchInfo> | undefined>;
|
||||
type HasErrorBoundary<T extends RouteInfo> = T["module"] extends {
|
||||
ErrorBoundary: Func;
|
||||
} ? true : false;
|
||||
type CreateMetaArgs<T extends RouteInfo> = {
|
||||
/** This is the current router `Location` object. This is useful for generating tags for routes at specific paths or query parameters. */
|
||||
location: Location;
|
||||
/** {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route. */
|
||||
params: T["params"];
|
||||
/**
|
||||
* The return value for this route's server loader function
|
||||
*
|
||||
* @deprecated Use `Route.MetaArgs.loaderData` instead
|
||||
*/
|
||||
data: T["loaderData"] | (HasErrorBoundary<T> extends true ? undefined : never);
|
||||
/** The return value for this route's server loader function */
|
||||
loaderData: T["loaderData"] | (HasErrorBoundary<T> extends true ? undefined : never);
|
||||
/** Thrown errors that trigger error boundaries will be passed to the meta function. This is useful for generating metadata for error pages. */
|
||||
error?: unknown;
|
||||
/** An array of the current {@link https://api.reactrouter.com/v7/interfaces/react-router.UIMatch.html route matches}, including parent route matches. */
|
||||
matches: MetaMatches<T["matches"]>;
|
||||
};
|
||||
type MetaDescriptors = MetaDescriptor[];
|
||||
type HeadersArgs = {
|
||||
loaderHeaders: Headers;
|
||||
parentHeaders: Headers;
|
||||
actionHeaders: Headers;
|
||||
errorHeaders: Headers | undefined;
|
||||
};
|
||||
type CreateServerMiddlewareFunction<T extends RouteInfo> = (args: ServerDataFunctionArgs<T["params"]>, next: MiddlewareNextFunction<Response>) => MaybePromise<Response | void>;
|
||||
type CreateClientMiddlewareFunction<T extends RouteInfo> = (args: ClientDataFunctionArgs<T["params"]>, next: MiddlewareNextFunction<Record<string, DataStrategyResult>>) => MaybePromise<Record<string, DataStrategyResult> | void>;
|
||||
type CreateServerLoaderArgs<T extends RouteInfo> = ServerDataFunctionArgs<T["params"]>;
|
||||
type CreateClientLoaderArgs<T extends RouteInfo> = ClientDataFunctionArgs<T["params"]> & {
|
||||
/** 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). */
|
||||
serverLoader: () => Promise<ServerDataFrom<T["module"]["loader"]>>;
|
||||
};
|
||||
type CreateServerActionArgs<T extends RouteInfo> = ServerDataFunctionArgs<T["params"]>;
|
||||
type CreateClientActionArgs<T extends RouteInfo> = ClientDataFunctionArgs<T["params"]> & {
|
||||
/** 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. */
|
||||
serverAction: () => Promise<ServerDataFrom<T["module"]["action"]>>;
|
||||
};
|
||||
type CreateHydrateFallbackProps<T extends RouteInfo, RSCEnabled extends boolean> = {
|
||||
params: T["params"];
|
||||
} & (RSCEnabled extends true ? {
|
||||
/** The data returned from the `loader` */
|
||||
loaderData?: ServerDataFrom<T["module"]["loader"]>;
|
||||
/** The data returned from the `action` following an action submission. */
|
||||
actionData?: ServerDataFrom<T["module"]["action"]>;
|
||||
} : {
|
||||
/** The data returned from the `loader` or `clientLoader` */
|
||||
loaderData?: T["loaderData"];
|
||||
/** The data returned from the `action` or `clientAction` following an action submission. */
|
||||
actionData?: T["actionData"];
|
||||
});
|
||||
type Match<T extends MatchInfo> = Pretty<{
|
||||
id: T["id"];
|
||||
params: Record<string, string | undefined>;
|
||||
pathname: string;
|
||||
/** @deprecated Use `Match.loaderData` instead */
|
||||
data: GetLoaderData<T["module"]>;
|
||||
loaderData: GetLoaderData<T["module"]>;
|
||||
handle: unknown;
|
||||
}>;
|
||||
type Matches<T extends Array<MatchInfo>> = T extends [infer F extends MatchInfo, ...infer R extends Array<MatchInfo>] ? [Match<F>, ...Matches<R>] : Array<Match<MatchInfo> | undefined>;
|
||||
type CreateComponentProps<T extends RouteInfo, RSCEnabled extends boolean> = {
|
||||
/**
|
||||
* {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
|
||||
* @example
|
||||
* // app/routes.ts
|
||||
* route("teams/:teamId", "./team.tsx"),
|
||||
*
|
||||
* // app/team.tsx
|
||||
* export default function Component({
|
||||
* params,
|
||||
* }: Route.ComponentProps) {
|
||||
* params.teamId;
|
||||
* // ^ string
|
||||
* }
|
||||
**/
|
||||
params: T["params"];
|
||||
/** An array of the current {@link https://api.reactrouter.com/v7/interfaces/react-router.UIMatch.html route matches}, including parent route matches. */
|
||||
matches: Matches<T["matches"]>;
|
||||
} & (RSCEnabled extends true ? {
|
||||
/** The data returned from the `loader` */
|
||||
loaderData: ServerDataFrom<T["module"]["loader"]>;
|
||||
/** The data returned from the `action` following an action submission. */
|
||||
actionData?: ServerDataFrom<T["module"]["action"]>;
|
||||
} : {
|
||||
/** The data returned from the `loader` or `clientLoader` */
|
||||
loaderData: T["loaderData"];
|
||||
/** The data returned from the `action` or `clientAction` following an action submission. */
|
||||
actionData?: T["actionData"];
|
||||
});
|
||||
type CreateErrorBoundaryProps<T extends RouteInfo, RSCEnabled extends boolean> = {
|
||||
/**
|
||||
* {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
|
||||
* @example
|
||||
* // app/routes.ts
|
||||
* route("teams/:teamId", "./team.tsx"),
|
||||
*
|
||||
* // app/team.tsx
|
||||
* export function ErrorBoundary({
|
||||
* params,
|
||||
* }: Route.ErrorBoundaryProps) {
|
||||
* params.teamId;
|
||||
* // ^ string
|
||||
* }
|
||||
**/
|
||||
params: T["params"];
|
||||
error: unknown;
|
||||
} & (RSCEnabled extends true ? {
|
||||
/** The data returned from the `loader` */
|
||||
loaderData?: ServerDataFrom<T["module"]["loader"]>;
|
||||
/** The data returned from the `action` following an action submission. */
|
||||
actionData?: ServerDataFrom<T["module"]["action"]>;
|
||||
} : {
|
||||
/** The data returned from the `loader` or `clientLoader` */
|
||||
loaderData?: T["loaderData"];
|
||||
/** The data returned from the `action` or `clientAction` following an action submission. */
|
||||
actionData?: T["actionData"];
|
||||
});
|
||||
type GetAnnotations<Info extends RouteInfo> = {
|
||||
LinkDescriptors: LinkDescriptor[];
|
||||
LinksFunction: () => LinkDescriptor[];
|
||||
MetaArgs: CreateMetaArgs<Info>;
|
||||
MetaDescriptors: MetaDescriptors;
|
||||
MetaFunction: (args: CreateMetaArgs<Info>) => MetaDescriptors;
|
||||
HeadersArgs: HeadersArgs;
|
||||
HeadersFunction: (args: HeadersArgs) => Headers | HeadersInit;
|
||||
MiddlewareFunction: CreateServerMiddlewareFunction<Info>;
|
||||
ClientMiddlewareFunction: CreateClientMiddlewareFunction<Info>;
|
||||
LoaderArgs: CreateServerLoaderArgs<Info>;
|
||||
ClientLoaderArgs: CreateClientLoaderArgs<Info>;
|
||||
ActionArgs: CreateServerActionArgs<Info>;
|
||||
ClientActionArgs: CreateClientActionArgs<Info>;
|
||||
HydrateFallbackProps: CreateHydrateFallbackProps<Info, false>;
|
||||
ServerHydrateFallbackProps: CreateHydrateFallbackProps<Info, true>;
|
||||
ComponentProps: CreateComponentProps<Info, false>;
|
||||
ServerComponentProps: CreateComponentProps<Info, true>;
|
||||
ErrorBoundaryProps: CreateErrorBoundaryProps<Info, false>;
|
||||
ServerErrorBoundaryProps: CreateErrorBoundaryProps<Info, true>;
|
||||
};
|
||||
|
||||
type Params<RouteFile extends keyof RouteFiles> = Normalize<Pages[RouteFiles[RouteFile]["page"]]["params"]>;
|
||||
|
||||
type GetInfo<T extends {
|
||||
file: keyof RouteFiles;
|
||||
module: RouteModule;
|
||||
}> = {
|
||||
params: Params<T["file"]>;
|
||||
loaderData: GetLoaderData<T["module"]>;
|
||||
actionData: GetActionData<T["module"]>;
|
||||
};
|
||||
|
||||
export type { GetAnnotations, GetInfo };
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
"use strict";/**
|
||||
* react-router v7.18.0
|
||||
*
|
||||
* Copyright (c) Remix Software Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE.md file in the root directory of this source tree.
|
||||
*
|
||||
* @license MIT
|
||||
*/
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* react-router v7.18.0
|
||||
*
|
||||
* Copyright (c) Remix Software Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE.md file in the root directory of this source tree.
|
||||
*
|
||||
* @license MIT
|
||||
*/
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
import { R as RouteModule } from './data-DEjBmEfD.mjs';
|
||||
|
||||
/**
|
||||
* Apps can use this interface to "register" app-wide types for React Router via interface declaration merging and module augmentation.
|
||||
* React Router should handle this for you via type generation.
|
||||
*
|
||||
* For more on declaration merging and module augmentation, see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation .
|
||||
*/
|
||||
interface Register {
|
||||
}
|
||||
type AnyParams = Record<string, string | undefined>;
|
||||
type AnyPages = Record<string, {
|
||||
params: AnyParams;
|
||||
}>;
|
||||
type Pages = Register extends {
|
||||
pages: infer Registered extends AnyPages;
|
||||
} ? Registered : AnyPages;
|
||||
type AnyRouteFiles = Record<string, {
|
||||
id: string;
|
||||
page: string;
|
||||
}>;
|
||||
type RouteFiles = Register extends {
|
||||
routeFiles: infer Registered extends AnyRouteFiles;
|
||||
} ? Registered : AnyRouteFiles;
|
||||
type AnyRouteModules = Record<string, RouteModule>;
|
||||
type RouteModules = Register extends {
|
||||
routeModules: infer Registered extends AnyRouteModules;
|
||||
} ? Registered : AnyRouteModules;
|
||||
|
||||
export type { Pages as P, RouteFiles as R, RouteModules as a, Register as b };
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
import { R as RouteModule } from './data-CjO11-hU.js';
|
||||
|
||||
/**
|
||||
* Apps can use this interface to "register" app-wide types for React Router via interface declaration merging and module augmentation.
|
||||
* React Router should handle this for you via type generation.
|
||||
*
|
||||
* For more on declaration merging and module augmentation, see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation .
|
||||
*/
|
||||
interface Register {
|
||||
}
|
||||
type AnyParams = Record<string, string | undefined>;
|
||||
type AnyPages = Record<string, {
|
||||
params: AnyParams;
|
||||
}>;
|
||||
type Pages = Register extends {
|
||||
pages: infer Registered extends AnyPages;
|
||||
} ? Registered : AnyPages;
|
||||
type AnyRouteFiles = Record<string, {
|
||||
id: string;
|
||||
page: string;
|
||||
}>;
|
||||
type RouteFiles = Register extends {
|
||||
routeFiles: infer Registered extends AnyRouteFiles;
|
||||
} ? Registered : AnyRouteFiles;
|
||||
type AnyRouteModules = Record<string, RouteModule>;
|
||||
type RouteModules = Register extends {
|
||||
routeModules: infer Registered extends AnyRouteModules;
|
||||
} ? Registered : AnyRouteModules;
|
||||
|
||||
export type { Pages as P, RouteFiles as R, RouteModules as a, Register as b };
|
||||
Reference in New Issue
Block a user