mirror of
https://ghproxy.net/https://github.com/abhijitb/helix.git
synced 2025-08-28 11:36:13 +08:00
Initial commit
This commit is contained in:
commit
153a4e9fd7
345 changed files with 359185 additions and 0 deletions
250
node_modules/@remix-run/router/dist/history.d.ts
generated
vendored
Normal file
250
node_modules/@remix-run/router/dist/history.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,250 @@
|
|||
/**
|
||||
* Actions represent the type of change to a location value.
|
||||
*/
|
||||
export declare enum Action {
|
||||
/**
|
||||
* A POP indicates a change to an arbitrary index in the history stack, such
|
||||
* as a back or forward navigation. It does not describe the direction of the
|
||||
* navigation, only that the current index changed.
|
||||
*
|
||||
* Note: This is the default action for newly created history objects.
|
||||
*/
|
||||
Pop = "POP",
|
||||
/**
|
||||
* A PUSH indicates a new entry being added to the history stack, such as when
|
||||
* a link is clicked and a new page loads. When this happens, all subsequent
|
||||
* entries in the stack are lost.
|
||||
*/
|
||||
Push = "PUSH",
|
||||
/**
|
||||
* A REPLACE indicates the entry at the current index in the history stack
|
||||
* being replaced by a new one.
|
||||
*/
|
||||
Replace = "REPLACE"
|
||||
}
|
||||
/**
|
||||
* The pathname, search, and hash values of a URL.
|
||||
*/
|
||||
export interface Path {
|
||||
/**
|
||||
* A URL pathname, beginning with a /.
|
||||
*/
|
||||
pathname: string;
|
||||
/**
|
||||
* A URL search string, beginning with a ?.
|
||||
*/
|
||||
search: string;
|
||||
/**
|
||||
* A URL fragment identifier, beginning with a #.
|
||||
*/
|
||||
hash: string;
|
||||
}
|
||||
/**
|
||||
* An entry in a history stack. A location contains information about the
|
||||
* URL path, as well as possibly some arbitrary state and a key.
|
||||
*/
|
||||
export interface Location<State = any> extends Path {
|
||||
/**
|
||||
* A value of arbitrary data associated with this location.
|
||||
*/
|
||||
state: State;
|
||||
/**
|
||||
* A unique string associated with this location. May be used to safely store
|
||||
* and retrieve data in some other storage API, like `localStorage`.
|
||||
*
|
||||
* Note: This value is always "default" on the initial location.
|
||||
*/
|
||||
key: string;
|
||||
}
|
||||
/**
|
||||
* A change to the current location.
|
||||
*/
|
||||
export interface Update {
|
||||
/**
|
||||
* The action that triggered the change.
|
||||
*/
|
||||
action: Action;
|
||||
/**
|
||||
* The new location.
|
||||
*/
|
||||
location: Location;
|
||||
/**
|
||||
* The delta between this location and the former location in the history stack
|
||||
*/
|
||||
delta: number | null;
|
||||
}
|
||||
/**
|
||||
* A function that receives notifications about location changes.
|
||||
*/
|
||||
export interface Listener {
|
||||
(update: Update): void;
|
||||
}
|
||||
/**
|
||||
* Describes a location that is the destination of some navigation, either via
|
||||
* `history.push` or `history.replace`. This may be either a URL or the pieces
|
||||
* of a URL path.
|
||||
*/
|
||||
export type To = string | Partial<Path>;
|
||||
/**
|
||||
* A history is an interface to the navigation stack. The history serves as the
|
||||
* source of truth for the current location, as well as provides a set of
|
||||
* methods that may be used to change it.
|
||||
*
|
||||
* It is similar to the DOM's `window.history` object, but with a smaller, more
|
||||
* focused API.
|
||||
*/
|
||||
export interface History {
|
||||
/**
|
||||
* The last action that modified the current location. This will always be
|
||||
* Action.Pop when a history instance is first created. This value is mutable.
|
||||
*/
|
||||
readonly action: Action;
|
||||
/**
|
||||
* The current location. This value is mutable.
|
||||
*/
|
||||
readonly location: Location;
|
||||
/**
|
||||
* Returns a valid href for the given `to` value that may be used as
|
||||
* the value of an <a href> attribute.
|
||||
*
|
||||
* @param to - The destination URL
|
||||
*/
|
||||
createHref(to: To): string;
|
||||
/**
|
||||
* Returns a URL for the given `to` value
|
||||
*
|
||||
* @param to - The destination URL
|
||||
*/
|
||||
createURL(to: To): URL;
|
||||
/**
|
||||
* Encode a location the same way window.history would do (no-op for memory
|
||||
* history) so we ensure our PUSH/REPLACE navigations for data routers
|
||||
* behave the same as POP
|
||||
*
|
||||
* @param to Unencoded path
|
||||
*/
|
||||
encodeLocation(to: To): Path;
|
||||
/**
|
||||
* Pushes a new location onto the history stack, increasing its length by one.
|
||||
* If there were any entries in the stack after the current one, they are
|
||||
* lost.
|
||||
*
|
||||
* @param to - The new URL
|
||||
* @param state - Data to associate with the new location
|
||||
*/
|
||||
push(to: To, state?: any): void;
|
||||
/**
|
||||
* Replaces the current location in the history stack with a new one. The
|
||||
* location that was replaced will no longer be available.
|
||||
*
|
||||
* @param to - The new URL
|
||||
* @param state - Data to associate with the new location
|
||||
*/
|
||||
replace(to: To, state?: any): void;
|
||||
/**
|
||||
* Navigates `n` entries backward/forward in the history stack relative to the
|
||||
* current index. For example, a "back" navigation would use go(-1).
|
||||
*
|
||||
* @param delta - The delta in the stack index
|
||||
*/
|
||||
go(delta: number): void;
|
||||
/**
|
||||
* Sets up a listener that will be called whenever the current location
|
||||
* changes.
|
||||
*
|
||||
* @param listener - A function that will be called when the location changes
|
||||
* @returns unlisten - A function that may be used to stop listening
|
||||
*/
|
||||
listen(listener: Listener): () => void;
|
||||
}
|
||||
/**
|
||||
* A user-supplied object that describes a location. Used when providing
|
||||
* entries to `createMemoryHistory` via its `initialEntries` option.
|
||||
*/
|
||||
export type InitialEntry = string | Partial<Location>;
|
||||
export type MemoryHistoryOptions = {
|
||||
initialEntries?: InitialEntry[];
|
||||
initialIndex?: number;
|
||||
v5Compat?: boolean;
|
||||
};
|
||||
/**
|
||||
* A memory history stores locations in memory. This is useful in stateful
|
||||
* environments where there is no web browser, such as node tests or React
|
||||
* Native.
|
||||
*/
|
||||
export interface MemoryHistory extends History {
|
||||
/**
|
||||
* The current index in the history stack.
|
||||
*/
|
||||
readonly index: number;
|
||||
}
|
||||
/**
|
||||
* Memory history stores the current location in memory. It is designed for use
|
||||
* in stateful non-browser environments like tests and React Native.
|
||||
*/
|
||||
export declare function createMemoryHistory(options?: MemoryHistoryOptions): MemoryHistory;
|
||||
/**
|
||||
* A browser history stores the current location in regular URLs in a web
|
||||
* browser environment. This is the standard for most web apps and provides the
|
||||
* cleanest URLs the browser's address bar.
|
||||
*
|
||||
* @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#browserhistory
|
||||
*/
|
||||
export interface BrowserHistory extends UrlHistory {
|
||||
}
|
||||
export type BrowserHistoryOptions = UrlHistoryOptions;
|
||||
/**
|
||||
* Browser history stores the location in regular URLs. This is the standard for
|
||||
* most web apps, but it requires some configuration on the server to ensure you
|
||||
* serve the same app at multiple URLs.
|
||||
*
|
||||
* @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#createbrowserhistory
|
||||
*/
|
||||
export declare function createBrowserHistory(options?: BrowserHistoryOptions): BrowserHistory;
|
||||
/**
|
||||
* A hash history stores the current location in the fragment identifier portion
|
||||
* of the URL in a web browser environment.
|
||||
*
|
||||
* This is ideal for apps that do not control the server for some reason
|
||||
* (because the fragment identifier is never sent to the server), including some
|
||||
* shared hosting environments that do not provide fine-grained controls over
|
||||
* which pages are served at which URLs.
|
||||
*
|
||||
* @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#hashhistory
|
||||
*/
|
||||
export interface HashHistory extends UrlHistory {
|
||||
}
|
||||
export type HashHistoryOptions = UrlHistoryOptions;
|
||||
/**
|
||||
* Hash history stores the location in window.location.hash. This makes it ideal
|
||||
* for situations where you don't want to send the location to the server for
|
||||
* some reason, either because you do cannot configure it or the URL space is
|
||||
* reserved for something else.
|
||||
*
|
||||
* @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#createhashhistory
|
||||
*/
|
||||
export declare function createHashHistory(options?: HashHistoryOptions): HashHistory;
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
export declare function invariant(value: boolean, message?: string): asserts value;
|
||||
export declare function invariant<T>(value: T | null | undefined, message?: string): asserts value is T;
|
||||
export declare function warning(cond: any, message: string): void;
|
||||
/**
|
||||
* Creates a Location object with a unique key from the given Path
|
||||
*/
|
||||
export declare function createLocation(current: string | Location, to: To, state?: any, key?: string): Readonly<Location>;
|
||||
/**
|
||||
* Creates a string URL path from the given pathname, search, and hash components.
|
||||
*/
|
||||
export declare function createPath({ pathname, search, hash, }: Partial<Path>): string;
|
||||
/**
|
||||
* Parses a string URL path into its separate pathname, search, and hash components.
|
||||
*/
|
||||
export declare function parsePath(path: string): Partial<Path>;
|
||||
export interface UrlHistory extends History {
|
||||
}
|
||||
export type UrlHistoryOptions = {
|
||||
window?: Window;
|
||||
v5Compat?: boolean;
|
||||
};
|
9
node_modules/@remix-run/router/dist/index.d.ts
generated
vendored
Normal file
9
node_modules/@remix-run/router/dist/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
export type { ActionFunction, ActionFunctionArgs, AgnosticDataIndexRouteObject, AgnosticDataNonIndexRouteObject, AgnosticDataRouteMatch, AgnosticDataRouteObject, AgnosticIndexRouteObject, AgnosticNonIndexRouteObject, AgnosticPatchRoutesOnNavigationFunction, AgnosticPatchRoutesOnNavigationFunctionArgs, AgnosticRouteMatch, AgnosticRouteObject, DataStrategyFunction, DataStrategyFunctionArgs, DataStrategyMatch, DataStrategyResult, ErrorResponse, FormEncType, FormMethod, HTMLFormMethod, JsonFunction, LazyRouteFunction, LoaderFunction, LoaderFunctionArgs, ParamParseKey, Params, PathMatch, PathParam, PathPattern, RedirectFunction, ShouldRevalidateFunction, ShouldRevalidateFunctionArgs, TrackedPromise, UIMatch, V7_FormMethod, DataWithResponseInit as UNSAFE_DataWithResponseInit, } from "./utils";
|
||||
export { AbortedDeferredError, data, defer, generatePath, getToPathname, isRouteErrorResponse, joinPaths, json, matchPath, matchRoutes, normalizePathname, redirect, redirectDocument, replace, resolvePath, resolveTo, stripBasename, } from "./utils";
|
||||
export type { BrowserHistory, BrowserHistoryOptions, HashHistory, HashHistoryOptions, History, InitialEntry, Location, MemoryHistory, MemoryHistoryOptions, Path, To, } from "./history";
|
||||
export { Action, createBrowserHistory, createHashHistory, createMemoryHistory, createPath, parsePath, } from "./history";
|
||||
export * from "./router";
|
||||
/** @internal */
|
||||
export type { RouteManifest as UNSAFE_RouteManifest } from "./utils";
|
||||
export { DeferredData as UNSAFE_DeferredData, ErrorResponseImpl as UNSAFE_ErrorResponseImpl, convertRoutesToDataRoutes as UNSAFE_convertRoutesToDataRoutes, convertRouteMatchToUiMatch as UNSAFE_convertRouteMatchToUiMatch, decodePath as UNSAFE_decodePath, getResolveToMatches as UNSAFE_getResolveToMatches, } from "./utils";
|
||||
export { invariant as UNSAFE_invariant, warning as UNSAFE_warning, } from "./history";
|
5607
node_modules/@remix-run/router/dist/router.cjs.js
generated
vendored
Normal file
5607
node_modules/@remix-run/router/dist/router.cjs.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
1
node_modules/@remix-run/router/dist/router.cjs.js.map
generated
vendored
Normal file
1
node_modules/@remix-run/router/dist/router.cjs.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
525
node_modules/@remix-run/router/dist/router.d.ts
generated
vendored
Normal file
525
node_modules/@remix-run/router/dist/router.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,525 @@
|
|||
import type { History, Location, Path, To } from "./history";
|
||||
import { Action as HistoryAction } from "./history";
|
||||
import type { AgnosticDataRouteMatch, AgnosticDataRouteObject, AgnosticRouteObject, DataStrategyFunction, DeferredData, DetectErrorBoundaryFunction, FormEncType, HTMLFormMethod, MapRoutePropertiesFunction, RouteData, Submission, UIMatch, AgnosticPatchRoutesOnNavigationFunction, DataWithResponseInit } from "./utils";
|
||||
/**
|
||||
* A Router instance manages all navigation and data loading/mutations
|
||||
*/
|
||||
export interface Router {
|
||||
/**
|
||||
* @internal
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Return the basename for the router
|
||||
*/
|
||||
get basename(): RouterInit["basename"];
|
||||
/**
|
||||
* @internal
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Return the future config for the router
|
||||
*/
|
||||
get future(): FutureConfig;
|
||||
/**
|
||||
* @internal
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Return the current state of the router
|
||||
*/
|
||||
get state(): RouterState;
|
||||
/**
|
||||
* @internal
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Return the routes for this router instance
|
||||
*/
|
||||
get routes(): AgnosticDataRouteObject[];
|
||||
/**
|
||||
* @internal
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Return the window associated with the router
|
||||
*/
|
||||
get window(): RouterInit["window"];
|
||||
/**
|
||||
* @internal
|
||||
* 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;
|
||||
/**
|
||||
* @internal
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Subscribe to router.state updates
|
||||
*
|
||||
* @param fn function to call with the new state
|
||||
*/
|
||||
subscribe(fn: RouterSubscriber): () => void;
|
||||
/**
|
||||
* @internal
|
||||
* 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;
|
||||
/**
|
||||
* @internal
|
||||
* 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>;
|
||||
/**
|
||||
* @internal
|
||||
* 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): void;
|
||||
/**
|
||||
* @internal
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Trigger a revalidation of all current route loaders and fetcher loads
|
||||
*/
|
||||
revalidate(): void;
|
||||
/**
|
||||
* @internal
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Utility function to create an href for the given location
|
||||
* @param location
|
||||
*/
|
||||
createHref(location: Location | URL): string;
|
||||
/**
|
||||
* @internal
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Utility function to URL encode a destination path according to the internal
|
||||
* history implementation
|
||||
* @param to
|
||||
*/
|
||||
encodeLocation(to: To): Path;
|
||||
/**
|
||||
* @internal
|
||||
* 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
|
||||
*
|
||||
* Delete the fetcher for a given key
|
||||
* @param key
|
||||
*/
|
||||
deleteFetcher(key: string): void;
|
||||
/**
|
||||
* @internal
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Cleanup listeners and abort any in-progress loads
|
||||
*/
|
||||
dispose(): void;
|
||||
/**
|
||||
* @internal
|
||||
* 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;
|
||||
/**
|
||||
* @internal
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Delete a navigation blocker
|
||||
* @param key The identifier for the blocker
|
||||
*/
|
||||
deleteBlocker(key: string): void;
|
||||
/**
|
||||
* @internal
|
||||
* 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
|
||||
*/
|
||||
patchRoutes(routeId: string | null, children: AgnosticRouteObject[]): void;
|
||||
/**
|
||||
* @internal
|
||||
* 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: AgnosticRouteObject[]): void;
|
||||
/**
|
||||
* @internal
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Internal fetch AbortControllers accessed by unit tests
|
||||
*/
|
||||
_internalFetchControllers: Map<string, AbortController>;
|
||||
/**
|
||||
* @internal
|
||||
* PRIVATE - DO NOT USE
|
||||
*
|
||||
* Internal pending DeferredData instances accessed by unit tests
|
||||
*/
|
||||
_internalActiveDeferreds: Map<string, DeferredData>;
|
||||
}
|
||||
/**
|
||||
* State maintained internally by the router. During a navigation, all states
|
||||
* reflect the the "old" location unless otherwise noted.
|
||||
*/
|
||||
export interface RouterState {
|
||||
/**
|
||||
* The action of the most recent navigation
|
||||
*/
|
||||
historyAction: HistoryAction;
|
||||
/**
|
||||
* The current location reflected by the router
|
||||
*/
|
||||
location: Location;
|
||||
/**
|
||||
* The current set of route matches
|
||||
*/
|
||||
matches: AgnosticDataRouteMatch[];
|
||||
/**
|
||||
* Tracks whether we've completed our initial data load
|
||||
*/
|
||||
initialized: 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)
|
||||
* - 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
|
||||
*/
|
||||
export type HydrationState = Partial<Pick<RouterState, "loaderData" | "actionData" | "errors">>;
|
||||
/**
|
||||
* Future flags to toggle new feature behavior
|
||||
*/
|
||||
export interface FutureConfig {
|
||||
v7_fetcherPersist: boolean;
|
||||
v7_normalizeFormMethod: boolean;
|
||||
v7_partialHydration: boolean;
|
||||
v7_prependBasename: boolean;
|
||||
v7_relativeSplatPath: boolean;
|
||||
v7_skipActionErrorRevalidation: boolean;
|
||||
}
|
||||
/**
|
||||
* Initialization options for createRouter
|
||||
*/
|
||||
export interface RouterInit {
|
||||
routes: AgnosticRouteObject[];
|
||||
history: History;
|
||||
basename?: string;
|
||||
/**
|
||||
* @deprecated Use `mapRouteProperties` instead
|
||||
*/
|
||||
detectErrorBoundary?: DetectErrorBoundaryFunction;
|
||||
mapRouteProperties?: MapRoutePropertiesFunction;
|
||||
future?: Partial<FutureConfig>;
|
||||
hydrationData?: HydrationState;
|
||||
window?: Window;
|
||||
dataStrategy?: DataStrategyFunction;
|
||||
patchRoutesOnNavigation?: AgnosticPatchRoutesOnNavigationFunction;
|
||||
}
|
||||
/**
|
||||
* State returned from a server-side query() call
|
||||
*/
|
||||
export 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>;
|
||||
activeDeferreds: Record<string, DeferredData> | null;
|
||||
_deepestRenderedBoundaryId?: string | null;
|
||||
}
|
||||
/**
|
||||
* A StaticHandler instance manages a singular SSR navigation/fetch event
|
||||
*/
|
||||
export interface StaticHandler {
|
||||
dataRoutes: AgnosticDataRouteObject[];
|
||||
query(request: Request, opts?: {
|
||||
requestContext?: unknown;
|
||||
skipLoaderErrorBubbling?: boolean;
|
||||
dataStrategy?: DataStrategyFunction;
|
||||
}): Promise<StaticHandlerContext | Response>;
|
||||
queryRoute(request: Request, opts?: {
|
||||
routeId?: string;
|
||||
requestContext?: unknown;
|
||||
dataStrategy?: DataStrategyFunction;
|
||||
}): Promise<any>;
|
||||
}
|
||||
type ViewTransitionOpts = {
|
||||
currentLocation: Location;
|
||||
nextLocation: Location;
|
||||
};
|
||||
/**
|
||||
* Subscriber function signature for changes to router state
|
||||
*/
|
||||
export interface RouterSubscriber {
|
||||
(state: RouterState, opts: {
|
||||
deletedFetchers: string[];
|
||||
viewTransitionOpts?: ViewTransitionOpts;
|
||||
flushSync: boolean;
|
||||
}): void;
|
||||
}
|
||||
/**
|
||||
* Function signature for determining the key to be used in scroll restoration
|
||||
* for a given location
|
||||
*/
|
||||
export interface GetScrollRestorationKeyFunction {
|
||||
(location: Location, matches: UIMatch[]): string | null;
|
||||
}
|
||||
/**
|
||||
* Function signature for determining the current scroll position
|
||||
*/
|
||||
export interface GetScrollPositionFunction {
|
||||
(): number;
|
||||
}
|
||||
export type RelativeRoutingType = "route" | "path";
|
||||
type BaseNavigateOrFetchOptions = {
|
||||
preventScrollReset?: boolean;
|
||||
relative?: RelativeRoutingType;
|
||||
flushSync?: boolean;
|
||||
};
|
||||
type BaseNavigateOptions = BaseNavigateOrFetchOptions & {
|
||||
replace?: boolean;
|
||||
state?: any;
|
||||
fromRouteId?: string;
|
||||
viewTransition?: boolean;
|
||||
};
|
||||
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
|
||||
*/
|
||||
export 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()
|
||||
*/
|
||||
export type RouterFetchOptions = LoadFetchOptions | SubmitFetchOptions;
|
||||
/**
|
||||
* Potential states for state.navigation
|
||||
*/
|
||||
export type NavigationStates = {
|
||||
Idle: {
|
||||
state: "idle";
|
||||
location: undefined;
|
||||
formMethod: undefined;
|
||||
formAction: undefined;
|
||||
formEncType: undefined;
|
||||
formData: undefined;
|
||||
json: undefined;
|
||||
text: undefined;
|
||||
};
|
||||
Loading: {
|
||||
state: "loading";
|
||||
location: Location;
|
||||
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;
|
||||
formMethod: Submission["formMethod"];
|
||||
formAction: Submission["formAction"];
|
||||
formEncType: Submission["formEncType"];
|
||||
formData: Submission["formData"];
|
||||
json: Submission["json"];
|
||||
text: Submission["text"];
|
||||
};
|
||||
};
|
||||
export type Navigation = NavigationStates[keyof NavigationStates];
|
||||
export type RevalidationState = "idle" | "loading";
|
||||
/**
|
||||
* Potential states for fetchers
|
||||
*/
|
||||
type FetcherStates<TData = any> = {
|
||||
Idle: {
|
||||
state: "idle";
|
||||
formMethod: undefined;
|
||||
formAction: undefined;
|
||||
formEncType: undefined;
|
||||
text: undefined;
|
||||
formData: undefined;
|
||||
json: undefined;
|
||||
data: TData | undefined;
|
||||
};
|
||||
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;
|
||||
};
|
||||
Submitting: {
|
||||
state: "submitting";
|
||||
formMethod: Submission["formMethod"];
|
||||
formAction: Submission["formAction"];
|
||||
formEncType: Submission["formEncType"];
|
||||
text: Submission["text"];
|
||||
formData: Submission["formData"];
|
||||
json: Submission["json"];
|
||||
data: TData | undefined;
|
||||
};
|
||||
};
|
||||
export 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;
|
||||
}
|
||||
export type Blocker = BlockerUnblocked | BlockerBlocked | BlockerProceeding;
|
||||
export type BlockerFunction = (args: {
|
||||
currentLocation: Location;
|
||||
nextLocation: Location;
|
||||
historyAction: HistoryAction;
|
||||
}) => boolean;
|
||||
export declare const IDLE_NAVIGATION: NavigationStates["Idle"];
|
||||
export declare const IDLE_FETCHER: FetcherStates["Idle"];
|
||||
export declare const IDLE_BLOCKER: BlockerUnblocked;
|
||||
/**
|
||||
* Create a router and listen to history POP navigations
|
||||
*/
|
||||
export declare function createRouter(init: RouterInit): Router;
|
||||
export declare const UNSAFE_DEFERRED_SYMBOL: unique symbol;
|
||||
/**
|
||||
* Future flags to toggle new feature behavior
|
||||
*/
|
||||
export interface StaticHandlerFutureConfig {
|
||||
v7_relativeSplatPath: boolean;
|
||||
v7_throwAbortReason: boolean;
|
||||
}
|
||||
export interface CreateStaticHandlerOptions {
|
||||
basename?: string;
|
||||
/**
|
||||
* @deprecated Use `mapRouteProperties` instead
|
||||
*/
|
||||
detectErrorBoundary?: DetectErrorBoundaryFunction;
|
||||
mapRouteProperties?: MapRoutePropertiesFunction;
|
||||
future?: Partial<StaticHandlerFutureConfig>;
|
||||
}
|
||||
export declare function createStaticHandler(routes: AgnosticRouteObject[], opts?: CreateStaticHandlerOptions): StaticHandler;
|
||||
/**
|
||||
* Given an existing StaticHandlerContext and an error thrown at render time,
|
||||
* provide an updated StaticHandlerContext suitable for a second SSR render
|
||||
*/
|
||||
export declare function getStaticContextFromError(routes: AgnosticDataRouteObject[], context: StaticHandlerContext, error: any): StaticHandlerContext;
|
||||
export declare function isDataWithResponseInit(value: any): value is DataWithResponseInit<unknown>;
|
||||
export declare function isDeferredData(value: any): value is DeferredData;
|
||||
export {};
|
5038
node_modules/@remix-run/router/dist/router.js
generated
vendored
Normal file
5038
node_modules/@remix-run/router/dist/router.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
1
node_modules/@remix-run/router/dist/router.js.map
generated
vendored
Normal file
1
node_modules/@remix-run/router/dist/router.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
5613
node_modules/@remix-run/router/dist/router.umd.js
generated
vendored
Normal file
5613
node_modules/@remix-run/router/dist/router.umd.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
1
node_modules/@remix-run/router/dist/router.umd.js.map
generated
vendored
Normal file
1
node_modules/@remix-run/router/dist/router.umd.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
12
node_modules/@remix-run/router/dist/router.umd.min.js
generated
vendored
Normal file
12
node_modules/@remix-run/router/dist/router.umd.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/@remix-run/router/dist/router.umd.min.js.map
generated
vendored
Normal file
1
node_modules/@remix-run/router/dist/router.umd.min.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
555
node_modules/@remix-run/router/dist/utils.d.ts
generated
vendored
Normal file
555
node_modules/@remix-run/router/dist/utils.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,555 @@
|
|||
import type { Location, Path, To } from "./history";
|
||||
/**
|
||||
* Map of routeId -> data returned from a loader/action/error
|
||||
*/
|
||||
export interface RouteData {
|
||||
[routeId: string]: any;
|
||||
}
|
||||
export declare enum ResultType {
|
||||
data = "data",
|
||||
deferred = "deferred",
|
||||
redirect = "redirect",
|
||||
error = "error"
|
||||
}
|
||||
/**
|
||||
* Successful result from a loader or action
|
||||
*/
|
||||
export interface SuccessResult {
|
||||
type: ResultType.data;
|
||||
data: unknown;
|
||||
statusCode?: number;
|
||||
headers?: Headers;
|
||||
}
|
||||
/**
|
||||
* Successful defer() result from a loader or action
|
||||
*/
|
||||
export interface DeferredResult {
|
||||
type: ResultType.deferred;
|
||||
deferredData: DeferredData;
|
||||
statusCode?: number;
|
||||
headers?: Headers;
|
||||
}
|
||||
/**
|
||||
* Redirect result from a loader or action
|
||||
*/
|
||||
export interface RedirectResult {
|
||||
type: ResultType.redirect;
|
||||
response: Response;
|
||||
}
|
||||
/**
|
||||
* Unsuccessful result from a loader or action
|
||||
*/
|
||||
export interface ErrorResult {
|
||||
type: ResultType.error;
|
||||
error: unknown;
|
||||
statusCode?: number;
|
||||
headers?: Headers;
|
||||
}
|
||||
/**
|
||||
* Result from a loader or action - potentially successful or unsuccessful
|
||||
*/
|
||||
export type DataResult = SuccessResult | DeferredResult | RedirectResult | ErrorResult;
|
||||
type LowerCaseFormMethod = "get" | "post" | "put" | "patch" | "delete";
|
||||
type UpperCaseFormMethod = Uppercase<LowerCaseFormMethod>;
|
||||
/**
|
||||
* Users can specify either lowercase or uppercase form methods on `<Form>`,
|
||||
* useSubmit(), `<fetcher.Form>`, etc.
|
||||
*/
|
||||
export type HTMLFormMethod = LowerCaseFormMethod | UpperCaseFormMethod;
|
||||
/**
|
||||
* Active navigation/fetcher form methods are exposed in lowercase on the
|
||||
* RouterState
|
||||
*/
|
||||
export type FormMethod = LowerCaseFormMethod;
|
||||
export type MutationFormMethod = Exclude<FormMethod, "get">;
|
||||
/**
|
||||
* In v7, active navigation/fetcher form methods are exposed in uppercase on the
|
||||
* RouterState. This is to align with the normalization done via fetch().
|
||||
*/
|
||||
export type V7_FormMethod = UpperCaseFormMethod;
|
||||
export type V7_MutationFormMethod = Exclude<V7_FormMethod, "GET">;
|
||||
export type FormEncType = "application/x-www-form-urlencoded" | "multipart/form-data" | "application/json" | "text/plain";
|
||||
type JsonObject = {
|
||||
[Key in string]: JsonValue;
|
||||
} & {
|
||||
[Key in string]?: JsonValue | undefined;
|
||||
};
|
||||
type JsonArray = JsonValue[] | readonly JsonValue[];
|
||||
type JsonPrimitive = string | number | boolean | null;
|
||||
type JsonValue = JsonPrimitive | JsonObject | JsonArray;
|
||||
/**
|
||||
* @private
|
||||
* Internal interface to pass around for action submissions, not intended for
|
||||
* external consumption
|
||||
*/
|
||||
export type Submission = {
|
||||
formMethod: FormMethod | V7_FormMethod;
|
||||
formAction: string;
|
||||
formEncType: FormEncType;
|
||||
formData: FormData;
|
||||
json: undefined;
|
||||
text: undefined;
|
||||
} | {
|
||||
formMethod: FormMethod | V7_FormMethod;
|
||||
formAction: string;
|
||||
formEncType: FormEncType;
|
||||
formData: undefined;
|
||||
json: JsonValue;
|
||||
text: undefined;
|
||||
} | {
|
||||
formMethod: FormMethod | V7_FormMethod;
|
||||
formAction: string;
|
||||
formEncType: FormEncType;
|
||||
formData: undefined;
|
||||
json: undefined;
|
||||
text: string;
|
||||
};
|
||||
/**
|
||||
* @private
|
||||
* Arguments passed to route loader/action functions. Same for now but we keep
|
||||
* this as a private implementation detail in case they diverge in the future.
|
||||
*/
|
||||
interface DataFunctionArgs<Context> {
|
||||
request: Request;
|
||||
params: Params;
|
||||
context?: Context;
|
||||
}
|
||||
/**
|
||||
* Arguments passed to loader functions
|
||||
*/
|
||||
export interface LoaderFunctionArgs<Context = any> extends DataFunctionArgs<Context> {
|
||||
}
|
||||
/**
|
||||
* Arguments passed to action functions
|
||||
*/
|
||||
export interface ActionFunctionArgs<Context = any> extends DataFunctionArgs<Context> {
|
||||
}
|
||||
/**
|
||||
* Loaders and actions can return anything except `undefined` (`null` is a
|
||||
* valid return value if there is no data to return). Responses are preferred
|
||||
* and will ease any future migration to Remix
|
||||
*/
|
||||
type DataFunctionValue = Response | NonNullable<unknown> | null;
|
||||
type DataFunctionReturnValue = Promise<DataFunctionValue> | DataFunctionValue;
|
||||
/**
|
||||
* Route loader function signature
|
||||
*/
|
||||
export type LoaderFunction<Context = any> = {
|
||||
(args: LoaderFunctionArgs<Context>, handlerCtx?: unknown): DataFunctionReturnValue;
|
||||
} & {
|
||||
hydrate?: boolean;
|
||||
};
|
||||
/**
|
||||
* Route action function signature
|
||||
*/
|
||||
export interface ActionFunction<Context = any> {
|
||||
(args: ActionFunctionArgs<Context>, handlerCtx?: unknown): DataFunctionReturnValue;
|
||||
}
|
||||
/**
|
||||
* Arguments passed to shouldRevalidate function
|
||||
*/
|
||||
export interface ShouldRevalidateFunctionArgs {
|
||||
currentUrl: URL;
|
||||
currentParams: AgnosticDataRouteMatch["params"];
|
||||
nextUrl: URL;
|
||||
nextParams: AgnosticDataRouteMatch["params"];
|
||||
formMethod?: Submission["formMethod"];
|
||||
formAction?: Submission["formAction"];
|
||||
formEncType?: Submission["formEncType"];
|
||||
text?: Submission["text"];
|
||||
formData?: Submission["formData"];
|
||||
json?: Submission["json"];
|
||||
actionStatus?: number;
|
||||
actionResult?: any;
|
||||
defaultShouldRevalidate: boolean;
|
||||
}
|
||||
/**
|
||||
* Route shouldRevalidate function signature. This runs after any submission
|
||||
* (navigation or fetcher), so we flatten the navigation/fetcher submission
|
||||
* onto the arguments. It shouldn't matter whether it came from a navigation
|
||||
* or a fetcher, what really matters is the URLs and the formData since loaders
|
||||
* have to re-run based on the data models that were potentially mutated.
|
||||
*/
|
||||
export interface ShouldRevalidateFunction {
|
||||
(args: ShouldRevalidateFunctionArgs): boolean;
|
||||
}
|
||||
/**
|
||||
* Function provided by the framework-aware layers to set `hasErrorBoundary`
|
||||
* from the framework-aware `errorElement` prop
|
||||
*
|
||||
* @deprecated Use `mapRouteProperties` instead
|
||||
*/
|
||||
export interface DetectErrorBoundaryFunction {
|
||||
(route: AgnosticRouteObject): boolean;
|
||||
}
|
||||
export interface DataStrategyMatch extends AgnosticRouteMatch<string, AgnosticDataRouteObject> {
|
||||
shouldLoad: boolean;
|
||||
resolve: (handlerOverride?: (handler: (ctx?: unknown) => DataFunctionReturnValue) => DataFunctionReturnValue) => Promise<DataStrategyResult>;
|
||||
}
|
||||
export interface DataStrategyFunctionArgs<Context = any> extends DataFunctionArgs<Context> {
|
||||
matches: DataStrategyMatch[];
|
||||
fetcherKey: string | null;
|
||||
}
|
||||
/**
|
||||
* Result from a loader or action called via dataStrategy
|
||||
*/
|
||||
export interface DataStrategyResult {
|
||||
type: "data" | "error";
|
||||
result: unknown;
|
||||
}
|
||||
export interface DataStrategyFunction {
|
||||
(args: DataStrategyFunctionArgs): Promise<Record<string, DataStrategyResult>>;
|
||||
}
|
||||
export type AgnosticPatchRoutesOnNavigationFunctionArgs<O extends AgnosticRouteObject = AgnosticRouteObject, M extends AgnosticRouteMatch = AgnosticRouteMatch> = {
|
||||
signal: AbortSignal;
|
||||
path: string;
|
||||
matches: M[];
|
||||
fetcherKey: string | undefined;
|
||||
patch: (routeId: string | null, children: O[]) => void;
|
||||
};
|
||||
export type AgnosticPatchRoutesOnNavigationFunction<O extends AgnosticRouteObject = AgnosticRouteObject, M extends AgnosticRouteMatch = AgnosticRouteMatch> = (opts: AgnosticPatchRoutesOnNavigationFunctionArgs<O, M>) => void | Promise<void>;
|
||||
/**
|
||||
* Function provided by the framework-aware layers to set any framework-specific
|
||||
* properties from framework-agnostic properties
|
||||
*/
|
||||
export interface MapRoutePropertiesFunction {
|
||||
(route: AgnosticRouteObject): {
|
||||
hasErrorBoundary: boolean;
|
||||
} & Record<string, any>;
|
||||
}
|
||||
/**
|
||||
* Keys we cannot change from within a lazy() function. We spread all other keys
|
||||
* onto the route. Either they're meaningful to the router, or they'll get
|
||||
* ignored.
|
||||
*/
|
||||
export type ImmutableRouteKey = "lazy" | "caseSensitive" | "path" | "id" | "index" | "children";
|
||||
export declare const immutableRouteKeys: Set<ImmutableRouteKey>;
|
||||
type RequireOne<T, Key = keyof T> = Exclude<{
|
||||
[K in keyof T]: K extends Key ? Omit<T, K> & Required<Pick<T, K>> : never;
|
||||
}[keyof T], undefined>;
|
||||
/**
|
||||
* lazy() function to load a route definition, which can add non-matching
|
||||
* related properties to a route
|
||||
*/
|
||||
export interface LazyRouteFunction<R extends AgnosticRouteObject> {
|
||||
(): Promise<RequireOne<Omit<R, ImmutableRouteKey>>>;
|
||||
}
|
||||
/**
|
||||
* Base RouteObject with common props shared by all types of routes
|
||||
*/
|
||||
type AgnosticBaseRouteObject = {
|
||||
caseSensitive?: boolean;
|
||||
path?: string;
|
||||
id?: string;
|
||||
loader?: LoaderFunction | boolean;
|
||||
action?: ActionFunction | boolean;
|
||||
hasErrorBoundary?: boolean;
|
||||
shouldRevalidate?: ShouldRevalidateFunction;
|
||||
handle?: any;
|
||||
lazy?: LazyRouteFunction<AgnosticBaseRouteObject>;
|
||||
};
|
||||
/**
|
||||
* Index routes must not have children
|
||||
*/
|
||||
export type AgnosticIndexRouteObject = AgnosticBaseRouteObject & {
|
||||
children?: undefined;
|
||||
index: true;
|
||||
};
|
||||
/**
|
||||
* Non-index routes may have children, but cannot have index
|
||||
*/
|
||||
export type AgnosticNonIndexRouteObject = AgnosticBaseRouteObject & {
|
||||
children?: AgnosticRouteObject[];
|
||||
index?: false;
|
||||
};
|
||||
/**
|
||||
* A route object represents a logical route, with (optionally) its child
|
||||
* routes organized in a tree-like structure.
|
||||
*/
|
||||
export type AgnosticRouteObject = AgnosticIndexRouteObject | AgnosticNonIndexRouteObject;
|
||||
export type AgnosticDataIndexRouteObject = AgnosticIndexRouteObject & {
|
||||
id: string;
|
||||
};
|
||||
export type AgnosticDataNonIndexRouteObject = AgnosticNonIndexRouteObject & {
|
||||
children?: AgnosticDataRouteObject[];
|
||||
id: string;
|
||||
};
|
||||
/**
|
||||
* A data route object, which is just a RouteObject with a required unique ID
|
||||
*/
|
||||
export type AgnosticDataRouteObject = AgnosticDataIndexRouteObject | AgnosticDataNonIndexRouteObject;
|
||||
export type RouteManifest = Record<string, AgnosticDataRouteObject | undefined>;
|
||||
type _PathParam<Path extends string> = Path extends `${infer L}/${infer R}` ? _PathParam<L> | _PathParam<R> : Path extends `:${infer Param}` ? Param extends `${infer Optional}?` ? Optional : Param : never;
|
||||
/**
|
||||
* Examples:
|
||||
* "/a/b/*" -> "*"
|
||||
* ":a" -> "a"
|
||||
* "/a/:b" -> "b"
|
||||
* "/a/blahblahblah:b" -> "b"
|
||||
* "/:a/:b" -> "a" | "b"
|
||||
* "/:a/b/:c/*" -> "a" | "c" | "*"
|
||||
*/
|
||||
export type PathParam<Path extends string> = Path extends "*" | "/*" ? "*" : Path extends `${infer Rest}/*` ? "*" | _PathParam<Rest> : _PathParam<Path>;
|
||||
export type ParamParseKey<Segment extends string> = [
|
||||
PathParam<Segment>
|
||||
] extends [never] ? string : PathParam<Segment>;
|
||||
/**
|
||||
* The parameters that were parsed from the URL path.
|
||||
*/
|
||||
export type Params<Key extends string = string> = {
|
||||
readonly [key in Key]: string | undefined;
|
||||
};
|
||||
/**
|
||||
* A RouteMatch contains info about how a route matched a URL.
|
||||
*/
|
||||
export interface AgnosticRouteMatch<ParamKey extends string = string, RouteObjectType extends AgnosticRouteObject = AgnosticRouteObject> {
|
||||
/**
|
||||
* The names and values of dynamic parameters in the URL.
|
||||
*/
|
||||
params: Params<ParamKey>;
|
||||
/**
|
||||
* The portion of the URL pathname that was matched.
|
||||
*/
|
||||
pathname: string;
|
||||
/**
|
||||
* The portion of the URL pathname that was matched before child routes.
|
||||
*/
|
||||
pathnameBase: string;
|
||||
/**
|
||||
* The route object that was used to match.
|
||||
*/
|
||||
route: RouteObjectType;
|
||||
}
|
||||
export interface AgnosticDataRouteMatch extends AgnosticRouteMatch<string, AgnosticDataRouteObject> {
|
||||
}
|
||||
export declare function convertRoutesToDataRoutes(routes: AgnosticRouteObject[], mapRouteProperties: MapRoutePropertiesFunction, parentPath?: string[], manifest?: RouteManifest): AgnosticDataRouteObject[];
|
||||
/**
|
||||
* Matches the given routes to a location and returns the match data.
|
||||
*
|
||||
* @see https://reactrouter.com/v6/utils/match-routes
|
||||
*/
|
||||
export declare function matchRoutes<RouteObjectType extends AgnosticRouteObject = AgnosticRouteObject>(routes: RouteObjectType[], locationArg: Partial<Location> | string, basename?: string): AgnosticRouteMatch<string, RouteObjectType>[] | null;
|
||||
export declare function matchRoutesImpl<RouteObjectType extends AgnosticRouteObject = AgnosticRouteObject>(routes: RouteObjectType[], locationArg: Partial<Location> | string, basename: string, allowPartial: boolean): AgnosticRouteMatch<string, RouteObjectType>[] | null;
|
||||
export interface UIMatch<Data = unknown, Handle = unknown> {
|
||||
id: string;
|
||||
pathname: string;
|
||||
params: AgnosticRouteMatch["params"];
|
||||
data: Data;
|
||||
handle: Handle;
|
||||
}
|
||||
export declare function convertRouteMatchToUiMatch(match: AgnosticDataRouteMatch, loaderData: RouteData): UIMatch;
|
||||
/**
|
||||
* Returns a path with params interpolated.
|
||||
*
|
||||
* @see https://reactrouter.com/v6/utils/generate-path
|
||||
*/
|
||||
export declare function generatePath<Path extends string>(originalPath: Path, params?: {
|
||||
[key in PathParam<Path>]: string | null;
|
||||
}): string;
|
||||
/**
|
||||
* A PathPattern is used to match on some portion of a URL pathname.
|
||||
*/
|
||||
export interface PathPattern<Path extends string = string> {
|
||||
/**
|
||||
* A string to match against a URL pathname. May contain `:id`-style segments
|
||||
* to indicate placeholders for dynamic parameters. May also end with `/*` to
|
||||
* indicate matching the rest of the URL pathname.
|
||||
*/
|
||||
path: Path;
|
||||
/**
|
||||
* Should be `true` if the static portions of the `path` should be matched in
|
||||
* the same case.
|
||||
*/
|
||||
caseSensitive?: boolean;
|
||||
/**
|
||||
* Should be `true` if this pattern should match the entire URL pathname.
|
||||
*/
|
||||
end?: boolean;
|
||||
}
|
||||
/**
|
||||
* A PathMatch contains info about how a PathPattern matched on a URL pathname.
|
||||
*/
|
||||
export interface PathMatch<ParamKey extends string = string> {
|
||||
/**
|
||||
* The names and values of dynamic parameters in the URL.
|
||||
*/
|
||||
params: Params<ParamKey>;
|
||||
/**
|
||||
* The portion of the URL pathname that was matched.
|
||||
*/
|
||||
pathname: string;
|
||||
/**
|
||||
* The portion of the URL pathname that was matched before child routes.
|
||||
*/
|
||||
pathnameBase: string;
|
||||
/**
|
||||
* The pattern that was used to match.
|
||||
*/
|
||||
pattern: PathPattern;
|
||||
}
|
||||
/**
|
||||
* Performs pattern matching on a URL pathname and returns information about
|
||||
* the match.
|
||||
*
|
||||
* @see https://reactrouter.com/v6/utils/match-path
|
||||
*/
|
||||
export declare function matchPath<ParamKey extends ParamParseKey<Path>, Path extends string>(pattern: PathPattern<Path> | Path, pathname: string): PathMatch<ParamKey> | null;
|
||||
export declare function decodePath(value: string): string;
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
export declare function stripBasename(pathname: string, basename: string): string | null;
|
||||
/**
|
||||
* Returns a resolved path object relative to the given pathname.
|
||||
*
|
||||
* @see https://reactrouter.com/v6/utils/resolve-path
|
||||
*/
|
||||
export declare function resolvePath(to: To, fromPathname?: string): Path;
|
||||
/**
|
||||
* @private
|
||||
*
|
||||
* When processing relative navigation we want to ignore ancestor routes that
|
||||
* do not contribute to the path, such that index/pathless layout routes don't
|
||||
* interfere.
|
||||
*
|
||||
* For example, when moving a route element into an index route and/or a
|
||||
* pathless layout route, relative link behavior contained within should stay
|
||||
* the same. Both of the following examples should link back to the root:
|
||||
*
|
||||
* <Route path="/">
|
||||
* <Route path="accounts" element={<Link to=".."}>
|
||||
* </Route>
|
||||
*
|
||||
* <Route path="/">
|
||||
* <Route path="accounts">
|
||||
* <Route element={<AccountsLayout />}> // <-- Does not contribute
|
||||
* <Route index element={<Link to=".."} /> // <-- Does not contribute
|
||||
* </Route
|
||||
* </Route>
|
||||
* </Route>
|
||||
*/
|
||||
export declare function getPathContributingMatches<T extends AgnosticRouteMatch = AgnosticRouteMatch>(matches: T[]): T[];
|
||||
export declare function getResolveToMatches<T extends AgnosticRouteMatch = AgnosticRouteMatch>(matches: T[], v7_relativeSplatPath: boolean): string[];
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
export declare function resolveTo(toArg: To, routePathnames: string[], locationPathname: string, isPathRelative?: boolean): Path;
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
export declare function getToPathname(to: To): string | undefined;
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
export declare const joinPaths: (paths: string[]) => string;
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
export declare const normalizePathname: (pathname: string) => string;
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
export declare const normalizeSearch: (search: string) => string;
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
export declare const normalizeHash: (hash: string) => string;
|
||||
export type JsonFunction = <Data>(data: Data, init?: number | ResponseInit) => Response;
|
||||
/**
|
||||
* This is a shortcut for creating `application/json` responses. Converts `data`
|
||||
* to JSON and sets the `Content-Type` header.
|
||||
*
|
||||
* @deprecated The `json` method is deprecated in favor of returning raw objects.
|
||||
* This method will be removed in v7.
|
||||
*/
|
||||
export declare const json: JsonFunction;
|
||||
export declare class DataWithResponseInit<D> {
|
||||
type: string;
|
||||
data: D;
|
||||
init: ResponseInit | null;
|
||||
constructor(data: D, init?: ResponseInit);
|
||||
}
|
||||
/**
|
||||
* Create "responses" that contain `status`/`headers` without forcing
|
||||
* serialization into an actual `Response` - used by Remix single fetch
|
||||
*/
|
||||
export declare function data<D>(data: D, init?: number | ResponseInit): DataWithResponseInit<D>;
|
||||
export interface TrackedPromise extends Promise<any> {
|
||||
_tracked?: boolean;
|
||||
_data?: any;
|
||||
_error?: any;
|
||||
}
|
||||
export declare class AbortedDeferredError extends Error {
|
||||
}
|
||||
export declare class DeferredData {
|
||||
private pendingKeysSet;
|
||||
private controller;
|
||||
private abortPromise;
|
||||
private unlistenAbortSignal;
|
||||
private subscribers;
|
||||
data: Record<string, unknown>;
|
||||
init?: ResponseInit;
|
||||
deferredKeys: string[];
|
||||
constructor(data: Record<string, unknown>, responseInit?: ResponseInit);
|
||||
private trackPromise;
|
||||
private onSettle;
|
||||
private emit;
|
||||
subscribe(fn: (aborted: boolean, settledKey?: string) => void): () => boolean;
|
||||
cancel(): void;
|
||||
resolveData(signal: AbortSignal): Promise<boolean>;
|
||||
get done(): boolean;
|
||||
get unwrappedData(): {};
|
||||
get pendingKeys(): string[];
|
||||
}
|
||||
export type DeferFunction = (data: Record<string, unknown>, init?: number | ResponseInit) => DeferredData;
|
||||
/**
|
||||
* @deprecated The `defer` method is deprecated in favor of returning raw
|
||||
* objects. This method will be removed in v7.
|
||||
*/
|
||||
export declare const defer: DeferFunction;
|
||||
export type RedirectFunction = (url: string, init?: number | ResponseInit) => Response;
|
||||
/**
|
||||
* A redirect response. Sets the status code and the `Location` header.
|
||||
* Defaults to "302 Found".
|
||||
*/
|
||||
export declare const redirect: RedirectFunction;
|
||||
/**
|
||||
* A redirect response that will force a document reload to the new location.
|
||||
* Sets the status code and the `Location` header.
|
||||
* Defaults to "302 Found".
|
||||
*/
|
||||
export declare const redirectDocument: RedirectFunction;
|
||||
/**
|
||||
* A redirect response that will perform a `history.replaceState` instead of a
|
||||
* `history.pushState` for client-side navigation redirects.
|
||||
* Sets the status code and the `Location` header.
|
||||
* Defaults to "302 Found".
|
||||
*/
|
||||
export declare const replace: RedirectFunction;
|
||||
export type ErrorResponse = {
|
||||
status: number;
|
||||
statusText: string;
|
||||
data: any;
|
||||
};
|
||||
/**
|
||||
* @private
|
||||
* Utility class we use to hold auto-unwrapped 4xx/5xx Response bodies
|
||||
*
|
||||
* We don't export the class for public use since it's an implementation
|
||||
* detail, but we export the interface above so folks can build their own
|
||||
* abstractions around instances via isRouteErrorResponse()
|
||||
*/
|
||||
export declare class ErrorResponseImpl implements ErrorResponse {
|
||||
status: number;
|
||||
statusText: string;
|
||||
data: any;
|
||||
private error?;
|
||||
private internal;
|
||||
constructor(status: number, statusText: string | undefined, data: any, internal?: boolean);
|
||||
}
|
||||
/**
|
||||
* Check if the given error is an ErrorResponse generated from a 4xx/5xx
|
||||
* Response thrown from an action/loader
|
||||
*/
|
||||
export declare function isRouteErrorResponse(error: any): error is ErrorResponse;
|
||||
export {};
|
Loading…
Add table
Add a link
Reference in a new issue