react-router 0.0.0-experimental-c7dd3d3a → 0.0.0-experimental-e53172d16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/README.md +1 -10
- package/dist/index.d.ts +37 -16
- package/dist/index.js +9809 -1087
- package/dist/index.js.map +1 -1
- package/dist/lib/components.d.ts +13 -2
- package/dist/lib/context.d.ts +2 -2
- package/dist/lib/dom/dom.d.ts +104 -0
- package/dist/lib/dom/global.d.ts +36 -0
- package/dist/lib/dom/lib.d.ts +304 -0
- package/dist/lib/dom/server.d.ts +32 -0
- package/dist/lib/dom/ssr/browser.d.ts +3 -0
- package/dist/lib/dom/ssr/components.d.ts +61 -0
- package/dist/lib/dom/ssr/create-remix-stub.d.ts +56 -0
- package/dist/lib/dom/ssr/data.d.ts +16 -0
- package/dist/lib/dom/ssr/errorBoundaries.d.ts +33 -0
- package/dist/lib/dom/ssr/errors.d.ts +2 -0
- package/dist/lib/dom/ssr/fallback.d.ts +2 -0
- package/dist/lib/dom/ssr/invariant.d.ts +2 -0
- package/dist/lib/dom/ssr/links.d.ts +127 -0
- package/dist/lib/dom/ssr/markup.d.ts +5 -0
- package/dist/lib/dom/ssr/routeModules.d.ts +141 -0
- package/dist/lib/dom/ssr/routes.d.ts +32 -0
- package/dist/lib/dom/ssr/server.d.ts +13 -0
- package/dist/lib/dom/ssr/single-fetch.d.ts +36 -0
- package/dist/lib/hooks.d.ts +3 -3
- package/dist/lib/router/history.d.ts +250 -0
- package/dist/lib/router/index.d.ts +9 -0
- package/dist/lib/router/router.d.ts +512 -0
- package/dist/lib/router/utils.d.ts +520 -0
- package/dist/main.js +1 -1
- package/dist/react-router.development.js +10495 -1126
- package/dist/react-router.development.js.map +1 -1
- package/dist/react-router.production.min.js +2 -2
- package/dist/react-router.production.min.js.map +1 -1
- package/dist/umd/react-router.development.js +10876 -1287
- package/dist/umd/react-router.development.js.map +1 -1
- package/dist/umd/react-router.production.min.js +2 -2
- package/dist/umd/react-router.production.min.js.map +1 -1
- package/package.json +12 -5
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { Location } from "../../router/history";
|
|
3
|
+
type RemixErrorBoundaryProps = React.PropsWithChildren<{
|
|
4
|
+
location: Location;
|
|
5
|
+
error?: Error;
|
|
6
|
+
}>;
|
|
7
|
+
type RemixErrorBoundaryState = {
|
|
8
|
+
error: null | Error;
|
|
9
|
+
location: Location;
|
|
10
|
+
};
|
|
11
|
+
export declare class RemixErrorBoundary extends React.Component<RemixErrorBoundaryProps, RemixErrorBoundaryState> {
|
|
12
|
+
constructor(props: RemixErrorBoundaryProps);
|
|
13
|
+
static getDerivedStateFromError(error: Error): {
|
|
14
|
+
error: Error;
|
|
15
|
+
};
|
|
16
|
+
static getDerivedStateFromProps(props: RemixErrorBoundaryProps, state: RemixErrorBoundaryState): {
|
|
17
|
+
error: Error | null;
|
|
18
|
+
location: Location<any>;
|
|
19
|
+
};
|
|
20
|
+
render(): string | number | boolean | Iterable<React.ReactNode> | React.JSX.Element | null | undefined;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* When app's don't provide a root level ErrorBoundary, we default to this.
|
|
24
|
+
*/
|
|
25
|
+
export declare function RemixRootDefaultErrorBoundary({ error }: {
|
|
26
|
+
error: unknown;
|
|
27
|
+
}): React.JSX.Element;
|
|
28
|
+
export declare function BoundaryShell({ title, renderScripts, children, }: {
|
|
29
|
+
title: string;
|
|
30
|
+
renderScripts?: boolean;
|
|
31
|
+
children: React.ReactNode | React.ReactNode[];
|
|
32
|
+
}): string | number | boolean | Iterable<React.ReactNode> | React.JSX.Element | null | undefined;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import type { AgnosticDataRouteMatch, Location } from "../../router";
|
|
2
|
+
import type { AssetsManifest } from "./entry";
|
|
3
|
+
import type { RouteModules, RouteModule } from "./routeModules";
|
|
4
|
+
import type { EntryRoute } from "./routes";
|
|
5
|
+
type Primitive = null | undefined | string | number | boolean | symbol | bigint;
|
|
6
|
+
type LiteralUnion<LiteralType, BaseType extends Primitive> = LiteralType | (BaseType & Record<never, never>);
|
|
7
|
+
interface HtmlLinkProps {
|
|
8
|
+
/**
|
|
9
|
+
* Address of the hyperlink
|
|
10
|
+
*/
|
|
11
|
+
href?: string;
|
|
12
|
+
/**
|
|
13
|
+
* How the element handles crossorigin requests
|
|
14
|
+
*/
|
|
15
|
+
crossOrigin?: "anonymous" | "use-credentials";
|
|
16
|
+
/**
|
|
17
|
+
* Relationship between the document containing the hyperlink and the destination resource
|
|
18
|
+
*/
|
|
19
|
+
rel: LiteralUnion<"alternate" | "dns-prefetch" | "icon" | "manifest" | "modulepreload" | "next" | "pingback" | "preconnect" | "prefetch" | "preload" | "prerender" | "search" | "stylesheet", string>;
|
|
20
|
+
/**
|
|
21
|
+
* Applicable media: "screen", "print", "(max-width: 764px)"
|
|
22
|
+
*/
|
|
23
|
+
media?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Integrity metadata used in Subresource Integrity checks
|
|
26
|
+
*/
|
|
27
|
+
integrity?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Language of the linked resource
|
|
30
|
+
*/
|
|
31
|
+
hrefLang?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Hint for the type of the referenced resource
|
|
34
|
+
*/
|
|
35
|
+
type?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Referrer policy for fetches initiated by the element
|
|
38
|
+
*/
|
|
39
|
+
referrerPolicy?: "" | "no-referrer" | "no-referrer-when-downgrade" | "same-origin" | "origin" | "strict-origin" | "origin-when-cross-origin" | "strict-origin-when-cross-origin" | "unsafe-url";
|
|
40
|
+
/**
|
|
41
|
+
* Sizes of the icons (for rel="icon")
|
|
42
|
+
*/
|
|
43
|
+
sizes?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Potential destination for a preload request (for rel="preload" and rel="modulepreload")
|
|
46
|
+
*/
|
|
47
|
+
as?: LiteralUnion<"audio" | "audioworklet" | "document" | "embed" | "fetch" | "font" | "frame" | "iframe" | "image" | "manifest" | "object" | "paintworklet" | "report" | "script" | "serviceworker" | "sharedworker" | "style" | "track" | "video" | "worker" | "xslt", string>;
|
|
48
|
+
/**
|
|
49
|
+
* Color to use when customizing a site's icon (for rel="mask-icon")
|
|
50
|
+
*/
|
|
51
|
+
color?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Whether the link is disabled
|
|
54
|
+
*/
|
|
55
|
+
disabled?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* The title attribute has special semantics on this element: Title of the link; CSS style sheet set name.
|
|
58
|
+
*/
|
|
59
|
+
title?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Images to use in different situations, e.g., high-resolution displays,
|
|
62
|
+
* small monitors, etc. (for rel="preload")
|
|
63
|
+
*/
|
|
64
|
+
imageSrcSet?: string;
|
|
65
|
+
/**
|
|
66
|
+
* Image sizes for different page layouts (for rel="preload")
|
|
67
|
+
*/
|
|
68
|
+
imageSizes?: string;
|
|
69
|
+
}
|
|
70
|
+
interface HtmlLinkPreloadImage extends HtmlLinkProps {
|
|
71
|
+
/**
|
|
72
|
+
* Relationship between the document containing the hyperlink and the destination resource
|
|
73
|
+
*/
|
|
74
|
+
rel: "preload";
|
|
75
|
+
/**
|
|
76
|
+
* Potential destination for a preload request (for rel="preload" and rel="modulepreload")
|
|
77
|
+
*/
|
|
78
|
+
as: "image";
|
|
79
|
+
/**
|
|
80
|
+
* Address of the hyperlink
|
|
81
|
+
*/
|
|
82
|
+
href?: string;
|
|
83
|
+
/**
|
|
84
|
+
* Images to use in different situations, e.g., high-resolution displays,
|
|
85
|
+
* small monitors, etc. (for rel="preload")
|
|
86
|
+
*/
|
|
87
|
+
imageSrcSet: string;
|
|
88
|
+
/**
|
|
89
|
+
* Image sizes for different page layouts (for rel="preload")
|
|
90
|
+
*/
|
|
91
|
+
imageSizes?: string;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Represents a `<link>` element.
|
|
95
|
+
*
|
|
96
|
+
* WHATWG Specification: https://html.spec.whatwg.org/multipage/semantics.html#the-link-element
|
|
97
|
+
*/
|
|
98
|
+
export type HtmlLinkDescriptor = (HtmlLinkProps & Pick<Required<HtmlLinkProps>, "href">) | (HtmlLinkPreloadImage & Pick<Required<HtmlLinkPreloadImage>, "imageSizes">) | (HtmlLinkPreloadImage & Pick<Required<HtmlLinkPreloadImage>, "href"> & {
|
|
99
|
+
imageSizes?: never;
|
|
100
|
+
});
|
|
101
|
+
export interface PrefetchPageDescriptor extends Omit<HtmlLinkDescriptor, "href" | "rel" | "type" | "sizes" | "imageSrcSet" | "imageSizes" | "as" | "color" | "title"> {
|
|
102
|
+
/**
|
|
103
|
+
* The absolute path of the page to prefetch.
|
|
104
|
+
*/
|
|
105
|
+
page: string;
|
|
106
|
+
}
|
|
107
|
+
export type LinkDescriptor = HtmlLinkDescriptor | PrefetchPageDescriptor;
|
|
108
|
+
/**
|
|
109
|
+
* Gets all the links for a set of matches. The modules are assumed to have been
|
|
110
|
+
* loaded already.
|
|
111
|
+
*/
|
|
112
|
+
export declare function getKeyedLinksForMatches(matches: AgnosticDataRouteMatch[], routeModules: RouteModules, manifest: AssetsManifest): KeyedLinkDescriptor[];
|
|
113
|
+
export declare function prefetchStyleLinks(route: EntryRoute, routeModule: RouteModule): Promise<void>;
|
|
114
|
+
export declare function isPageLinkDescriptor(object: any): object is PrefetchPageDescriptor;
|
|
115
|
+
export type KeyedHtmlLinkDescriptor = {
|
|
116
|
+
key: string;
|
|
117
|
+
link: HtmlLinkDescriptor;
|
|
118
|
+
};
|
|
119
|
+
export declare function getKeyedPrefetchLinks(matches: AgnosticDataRouteMatch[], manifest: AssetsManifest, routeModules: RouteModules): Promise<KeyedHtmlLinkDescriptor[]>;
|
|
120
|
+
export declare function getNewMatchesForLinks(page: string, nextMatches: AgnosticDataRouteMatch[], currentMatches: AgnosticDataRouteMatch[], manifest: AssetsManifest, location: Location, mode: "data" | "assets"): AgnosticDataRouteMatch[];
|
|
121
|
+
export declare function getDataLinkHrefs(page: string, matches: AgnosticDataRouteMatch[], manifest: AssetsManifest): string[];
|
|
122
|
+
export declare function getModuleLinkHrefs(matches: AgnosticDataRouteMatch[], manifestPatch: AssetsManifest): string[];
|
|
123
|
+
type KeyedLinkDescriptor<Descriptor extends LinkDescriptor = LinkDescriptor> = {
|
|
124
|
+
key: string;
|
|
125
|
+
link: Descriptor;
|
|
126
|
+
};
|
|
127
|
+
export {};
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import type { ComponentType, ReactElement } from "react";
|
|
2
|
+
import type { Location } from "../../router/history";
|
|
3
|
+
import type { ActionFunction as RRActionFunction, ActionFunctionArgs as RRActionFunctionArgs, LoaderFunction as RRLoaderFunction, LoaderFunctionArgs as RRLoaderFunctionArgs, Params, ShouldRevalidateFunction, LoaderFunctionArgs } from "../../router/utils";
|
|
4
|
+
import type { SerializeFrom } from "./components";
|
|
5
|
+
import type { AppData } from "./data";
|
|
6
|
+
import type { LinkDescriptor } from "./links";
|
|
7
|
+
import type { EntryRoute } from "./routes";
|
|
8
|
+
import type { DataRouteMatch } from "../../context";
|
|
9
|
+
export interface RouteModules {
|
|
10
|
+
[routeId: string]: RouteModule | undefined;
|
|
11
|
+
}
|
|
12
|
+
export interface RouteModule {
|
|
13
|
+
clientAction?: ClientActionFunction;
|
|
14
|
+
clientLoader?: ClientLoaderFunction;
|
|
15
|
+
ErrorBoundary?: ErrorBoundaryComponent;
|
|
16
|
+
HydrateFallback?: HydrateFallbackComponent;
|
|
17
|
+
Layout?: LayoutComponent;
|
|
18
|
+
default: RouteComponent;
|
|
19
|
+
handle?: RouteHandle;
|
|
20
|
+
links?: LinksFunction;
|
|
21
|
+
meta?: MetaFunction;
|
|
22
|
+
shouldRevalidate?: ShouldRevalidateFunction;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* A function that handles data mutations for a route on the client
|
|
26
|
+
*/
|
|
27
|
+
export type ClientActionFunction = (args: ClientActionFunctionArgs) => ReturnType<RRActionFunction>;
|
|
28
|
+
/**
|
|
29
|
+
* Arguments passed to a route `clientAction` function
|
|
30
|
+
*/
|
|
31
|
+
export type ClientActionFunctionArgs = RRActionFunctionArgs<undefined> & {
|
|
32
|
+
serverAction: <T = AppData>() => Promise<SerializeFrom<T>>;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* A function that loads data for a route on the client
|
|
36
|
+
*/
|
|
37
|
+
export type ClientLoaderFunction = ((args: ClientLoaderFunctionArgs) => ReturnType<RRLoaderFunction>) & {
|
|
38
|
+
hydrate?: boolean;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Arguments passed to a route `clientLoader` function
|
|
42
|
+
*/
|
|
43
|
+
export type ClientLoaderFunctionArgs = RRLoaderFunctionArgs<undefined> & {
|
|
44
|
+
serverLoader: <T = AppData>() => Promise<SerializeFrom<T>>;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* ErrorBoundary to display for this route
|
|
48
|
+
*/
|
|
49
|
+
export type ErrorBoundaryComponent = ComponentType;
|
|
50
|
+
/**
|
|
51
|
+
* `<Route HydrateFallback>` component to render on initial loads
|
|
52
|
+
* when client loaders are present
|
|
53
|
+
*/
|
|
54
|
+
export type HydrateFallbackComponent = ComponentType;
|
|
55
|
+
/**
|
|
56
|
+
* Optional, root-only `<Route Layout>` component to wrap the root content in.
|
|
57
|
+
* Useful for defining the <html>/<head>/<body> document shell shared by the
|
|
58
|
+
* Component, HydrateFallback, and ErrorBoundary
|
|
59
|
+
*/
|
|
60
|
+
export type LayoutComponent = ComponentType<{
|
|
61
|
+
children: ReactElement<unknown, ErrorBoundaryComponent | HydrateFallbackComponent | RouteComponent>;
|
|
62
|
+
}>;
|
|
63
|
+
/**
|
|
64
|
+
* A function that defines `<link>` tags to be inserted into the `<head>` of
|
|
65
|
+
* the document on route transitions.
|
|
66
|
+
*
|
|
67
|
+
* @see https://remix.run/route/meta
|
|
68
|
+
*/
|
|
69
|
+
export interface LinksFunction {
|
|
70
|
+
(): LinkDescriptor[];
|
|
71
|
+
}
|
|
72
|
+
type LoaderFunction = (args: LoaderFunctionArgs & {
|
|
73
|
+
context: unknown;
|
|
74
|
+
response?: {
|
|
75
|
+
status: number | undefined;
|
|
76
|
+
headers: Headers;
|
|
77
|
+
};
|
|
78
|
+
}) => ReturnType<RRLoaderFunction>;
|
|
79
|
+
export interface MetaMatch<RouteId extends string = string, Loader extends LoaderFunction | unknown = unknown> {
|
|
80
|
+
id: RouteId;
|
|
81
|
+
pathname: DataRouteMatch["pathname"];
|
|
82
|
+
data: Loader extends LoaderFunction ? SerializeFrom<Loader> : unknown;
|
|
83
|
+
handle?: RouteHandle;
|
|
84
|
+
params: DataRouteMatch["params"];
|
|
85
|
+
meta: MetaDescriptor[];
|
|
86
|
+
error?: unknown;
|
|
87
|
+
}
|
|
88
|
+
export type MetaMatches<MatchLoaders extends Record<string, LoaderFunction | unknown> = Record<string, unknown>> = Array<{
|
|
89
|
+
[K in keyof MatchLoaders]: MetaMatch<Exclude<K, number | symbol>, MatchLoaders[K]>;
|
|
90
|
+
}[keyof MatchLoaders]>;
|
|
91
|
+
export interface MetaArgs<Loader extends LoaderFunction | unknown = unknown, MatchLoaders extends Record<string, LoaderFunction | unknown> = Record<string, unknown>> {
|
|
92
|
+
data: (Loader extends LoaderFunction ? SerializeFrom<Loader> : AppData) | undefined;
|
|
93
|
+
params: Params;
|
|
94
|
+
location: Location;
|
|
95
|
+
matches: MetaMatches<MatchLoaders>;
|
|
96
|
+
error?: unknown;
|
|
97
|
+
}
|
|
98
|
+
export interface MetaFunction<Loader extends LoaderFunction | unknown = unknown, MatchLoaders extends Record<string, LoaderFunction | unknown> = Record<string, unknown>> {
|
|
99
|
+
(args: MetaArgs<Loader, MatchLoaders>): MetaDescriptor[] | undefined;
|
|
100
|
+
}
|
|
101
|
+
export type MetaDescriptor = {
|
|
102
|
+
charSet: "utf-8";
|
|
103
|
+
} | {
|
|
104
|
+
title: string;
|
|
105
|
+
} | {
|
|
106
|
+
name: string;
|
|
107
|
+
content: string;
|
|
108
|
+
} | {
|
|
109
|
+
property: string;
|
|
110
|
+
content: string;
|
|
111
|
+
} | {
|
|
112
|
+
httpEquiv: string;
|
|
113
|
+
content: string;
|
|
114
|
+
} | {
|
|
115
|
+
"script:ld+json": LdJsonObject;
|
|
116
|
+
} | {
|
|
117
|
+
tagName: "meta" | "link";
|
|
118
|
+
[name: string]: string;
|
|
119
|
+
} | {
|
|
120
|
+
[name: string]: unknown;
|
|
121
|
+
};
|
|
122
|
+
type LdJsonObject = {
|
|
123
|
+
[Key in string]: LdJsonValue;
|
|
124
|
+
} & {
|
|
125
|
+
[Key in string]?: LdJsonValue | undefined;
|
|
126
|
+
};
|
|
127
|
+
type LdJsonArray = LdJsonValue[] | readonly LdJsonValue[];
|
|
128
|
+
type LdJsonPrimitive = string | number | boolean | null;
|
|
129
|
+
type LdJsonValue = LdJsonPrimitive | LdJsonObject | LdJsonArray;
|
|
130
|
+
/**
|
|
131
|
+
* A React component that is rendered for a route.
|
|
132
|
+
*/
|
|
133
|
+
export type RouteComponent = ComponentType<{}>;
|
|
134
|
+
/**
|
|
135
|
+
* An arbitrary object that is associated with a route.
|
|
136
|
+
*
|
|
137
|
+
* @see https://remix.run/route/handle
|
|
138
|
+
*/
|
|
139
|
+
export type RouteHandle = unknown;
|
|
140
|
+
export declare function loadRouteModule(route: EntryRoute, routeModulesCache: RouteModules): Promise<RouteModule>;
|
|
141
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { HydrationState } from "../../router";
|
|
2
|
+
import type { RouteModule, RouteModules } from "./routeModules";
|
|
3
|
+
import type { FutureConfig } from "./entry";
|
|
4
|
+
import type { DataRouteObject } from "../../context";
|
|
5
|
+
export interface RouteManifest<Route> {
|
|
6
|
+
[routeId: string]: Route;
|
|
7
|
+
}
|
|
8
|
+
interface Route {
|
|
9
|
+
index?: boolean;
|
|
10
|
+
caseSensitive?: boolean;
|
|
11
|
+
id: string;
|
|
12
|
+
parentId?: string;
|
|
13
|
+
path?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface EntryRoute extends Route {
|
|
16
|
+
hasAction: boolean;
|
|
17
|
+
hasLoader: boolean;
|
|
18
|
+
hasClientAction: boolean;
|
|
19
|
+
hasClientLoader: boolean;
|
|
20
|
+
hasErrorBoundary: boolean;
|
|
21
|
+
imports?: string[];
|
|
22
|
+
css?: string[];
|
|
23
|
+
module: string;
|
|
24
|
+
parentId?: string;
|
|
25
|
+
}
|
|
26
|
+
export declare function createServerRoutes(manifest: RouteManifest<EntryRoute>, routeModules: RouteModules, future: FutureConfig, isSpaMode: boolean, parentId?: string, routesByParentId?: Record<string, Omit<EntryRoute, "children">[]>, spaModeLazyPromise?: Promise<{
|
|
27
|
+
Component: () => null;
|
|
28
|
+
}>): DataRouteObject[];
|
|
29
|
+
export declare function createClientRoutesWithHMRRevalidationOptOut(needsRevalidation: Set<string>, manifest: RouteManifest<EntryRoute>, routeModulesCache: RouteModules, initialState: HydrationState, future: FutureConfig, isSpaMode: boolean): DataRouteObject[];
|
|
30
|
+
export declare function createClientRoutes(manifest: RouteManifest<EntryRoute>, routeModulesCache: RouteModules, initialState: HydrationState, future: FutureConfig, isSpaMode: boolean, parentId?: string, routesByParentId?: Record<string, Omit<EntryRoute, "children">[]>, needsRevalidation?: Set<string>): DataRouteObject[];
|
|
31
|
+
export declare function shouldHydrateRouteLoader(route: EntryRoute, routeModule: RouteModule, isSpaMode: boolean): boolean;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ReactElement } from "react";
|
|
2
|
+
import type { EntryContext } from "./entry";
|
|
3
|
+
export interface RemixServerProps {
|
|
4
|
+
context: EntryContext;
|
|
5
|
+
url: string | URL;
|
|
6
|
+
abortDelay?: number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The entry point for a Remix app when it is rendered on the server (in
|
|
10
|
+
* `app/entry.server.js`). This component is used to generate the HTML in the
|
|
11
|
+
* response from the server.
|
|
12
|
+
*/
|
|
13
|
+
export declare function RemixServer({ context, url, abortDelay, }: RemixServerProps): ReactElement;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { unstable_DataStrategyFunction as DataStrategyFunction } from "../../router";
|
|
3
|
+
import type { AssetsManifest, EntryContext } from "./entry";
|
|
4
|
+
import type { RouteModules } from "./routeModules";
|
|
5
|
+
import type { DataRouteObject } from "../../context";
|
|
6
|
+
export declare const SingleFetchRedirectSymbol: unique symbol;
|
|
7
|
+
export type SingleFetchRedirectResult = {
|
|
8
|
+
redirect: string;
|
|
9
|
+
status: number;
|
|
10
|
+
revalidate: boolean;
|
|
11
|
+
reload: boolean;
|
|
12
|
+
};
|
|
13
|
+
export type SingleFetchResult = {
|
|
14
|
+
data: unknown;
|
|
15
|
+
} | {
|
|
16
|
+
error: unknown;
|
|
17
|
+
} | SingleFetchRedirectResult;
|
|
18
|
+
export type SingleFetchResults = {
|
|
19
|
+
[key: string]: SingleFetchResult;
|
|
20
|
+
[SingleFetchRedirectSymbol]?: SingleFetchRedirectResult;
|
|
21
|
+
};
|
|
22
|
+
interface StreamTransferProps {
|
|
23
|
+
context: EntryContext;
|
|
24
|
+
identifier: number;
|
|
25
|
+
reader: ReadableStreamDefaultReader<Uint8Array>;
|
|
26
|
+
textDecoder: TextDecoder;
|
|
27
|
+
}
|
|
28
|
+
export declare function StreamTransfer({ context, identifier, reader, textDecoder, }: StreamTransferProps): React.JSX.Element | null;
|
|
29
|
+
export declare function getSingleFetchDataStrategy(manifest: AssetsManifest, routeModules: RouteModules): DataStrategyFunction;
|
|
30
|
+
export declare function addRevalidationParam(manifest: AssetsManifest, routeModules: RouteModules, matchedRoutes: DataRouteObject[], loadRoutes: DataRouteObject[], url: URL): URL;
|
|
31
|
+
export declare function singleFetchUrl(reqUrl: URL | string): URL;
|
|
32
|
+
export declare function decodeViaTurboStream(body: ReadableStream<Uint8Array>, global: Window | typeof globalThis): Promise<{
|
|
33
|
+
done: Promise<undefined>;
|
|
34
|
+
value: unknown;
|
|
35
|
+
}>;
|
|
36
|
+
export {};
|
package/dist/lib/hooks.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import type { Blocker, BlockerFunction, Location, ParamParseKey, Params, Path, PathMatch, PathPattern, RelativeRoutingType, Router as RemixRouter, RevalidationState, To, UIMatch } from "
|
|
3
|
-
import { Action as NavigationType } from "
|
|
2
|
+
import type { Blocker, BlockerFunction, Location, ParamParseKey, Params, Path, PathMatch, PathPattern, RelativeRoutingType, Router as RemixRouter, RevalidationState, To, UIMatch } from "./router";
|
|
3
|
+
import { Action as NavigationType } from "./router";
|
|
4
4
|
import type { NavigateOptions, RouteContextObject, RouteMatch, RouteObject } from "./context";
|
|
5
5
|
/**
|
|
6
6
|
* Returns the full href for the given "to" value. This is useful for building
|
|
@@ -131,7 +131,7 @@ export declare function useRouteId(): string;
|
|
|
131
131
|
* Returns the current navigation, defaulting to an "idle" navigation when
|
|
132
132
|
* no navigation is in progress
|
|
133
133
|
*/
|
|
134
|
-
export declare function useNavigation(): import("
|
|
134
|
+
export declare function useNavigation(): import("./router").Navigation;
|
|
135
135
|
/**
|
|
136
136
|
* Returns a revalidate function for manually triggering revalidation, as well
|
|
137
137
|
* as the current state of any manual revalidations
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Actions represent the type of change to a location value.
|
|
3
|
+
*/
|
|
4
|
+
export declare enum Action {
|
|
5
|
+
/**
|
|
6
|
+
* A POP indicates a change to an arbitrary index in the history stack, such
|
|
7
|
+
* as a back or forward navigation. It does not describe the direction of the
|
|
8
|
+
* navigation, only that the current index changed.
|
|
9
|
+
*
|
|
10
|
+
* Note: This is the default action for newly created history objects.
|
|
11
|
+
*/
|
|
12
|
+
Pop = "POP",
|
|
13
|
+
/**
|
|
14
|
+
* A PUSH indicates a new entry being added to the history stack, such as when
|
|
15
|
+
* a link is clicked and a new page loads. When this happens, all subsequent
|
|
16
|
+
* entries in the stack are lost.
|
|
17
|
+
*/
|
|
18
|
+
Push = "PUSH",
|
|
19
|
+
/**
|
|
20
|
+
* A REPLACE indicates the entry at the current index in the history stack
|
|
21
|
+
* being replaced by a new one.
|
|
22
|
+
*/
|
|
23
|
+
Replace = "REPLACE"
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The pathname, search, and hash values of a URL.
|
|
27
|
+
*/
|
|
28
|
+
export interface Path {
|
|
29
|
+
/**
|
|
30
|
+
* A URL pathname, beginning with a /.
|
|
31
|
+
*/
|
|
32
|
+
pathname: string;
|
|
33
|
+
/**
|
|
34
|
+
* A URL search string, beginning with a ?.
|
|
35
|
+
*/
|
|
36
|
+
search: string;
|
|
37
|
+
/**
|
|
38
|
+
* A URL fragment identifier, beginning with a #.
|
|
39
|
+
*/
|
|
40
|
+
hash: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* An entry in a history stack. A location contains information about the
|
|
44
|
+
* URL path, as well as possibly some arbitrary state and a key.
|
|
45
|
+
*/
|
|
46
|
+
export interface Location<State = any> extends Path {
|
|
47
|
+
/**
|
|
48
|
+
* A value of arbitrary data associated with this location.
|
|
49
|
+
*/
|
|
50
|
+
state: State;
|
|
51
|
+
/**
|
|
52
|
+
* A unique string associated with this location. May be used to safely store
|
|
53
|
+
* and retrieve data in some other storage API, like `localStorage`.
|
|
54
|
+
*
|
|
55
|
+
* Note: This value is always "default" on the initial location.
|
|
56
|
+
*/
|
|
57
|
+
key: string;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* A change to the current location.
|
|
61
|
+
*/
|
|
62
|
+
export interface Update {
|
|
63
|
+
/**
|
|
64
|
+
* The action that triggered the change.
|
|
65
|
+
*/
|
|
66
|
+
action: Action;
|
|
67
|
+
/**
|
|
68
|
+
* The new location.
|
|
69
|
+
*/
|
|
70
|
+
location: Location;
|
|
71
|
+
/**
|
|
72
|
+
* The delta between this location and the former location in the history stack
|
|
73
|
+
*/
|
|
74
|
+
delta: number | null;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* A function that receives notifications about location changes.
|
|
78
|
+
*/
|
|
79
|
+
export interface Listener {
|
|
80
|
+
(update: Update): void;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Describes a location that is the destination of some navigation, either via
|
|
84
|
+
* `history.push` or `history.replace`. This may be either a URL or the pieces
|
|
85
|
+
* of a URL path.
|
|
86
|
+
*/
|
|
87
|
+
export type To = string | Partial<Path>;
|
|
88
|
+
/**
|
|
89
|
+
* A history is an interface to the navigation stack. The history serves as the
|
|
90
|
+
* source of truth for the current location, as well as provides a set of
|
|
91
|
+
* methods that may be used to change it.
|
|
92
|
+
*
|
|
93
|
+
* It is similar to the DOM's `window.history` object, but with a smaller, more
|
|
94
|
+
* focused API.
|
|
95
|
+
*/
|
|
96
|
+
export interface History {
|
|
97
|
+
/**
|
|
98
|
+
* The last action that modified the current location. This will always be
|
|
99
|
+
* Action.Pop when a history instance is first created. This value is mutable.
|
|
100
|
+
*/
|
|
101
|
+
readonly action: Action;
|
|
102
|
+
/**
|
|
103
|
+
* The current location. This value is mutable.
|
|
104
|
+
*/
|
|
105
|
+
readonly location: Location;
|
|
106
|
+
/**
|
|
107
|
+
* Returns a valid href for the given `to` value that may be used as
|
|
108
|
+
* the value of an <a href> attribute.
|
|
109
|
+
*
|
|
110
|
+
* @param to - The destination URL
|
|
111
|
+
*/
|
|
112
|
+
createHref(to: To): string;
|
|
113
|
+
/**
|
|
114
|
+
* Returns a URL for the given `to` value
|
|
115
|
+
*
|
|
116
|
+
* @param to - The destination URL
|
|
117
|
+
*/
|
|
118
|
+
createURL(to: To): URL;
|
|
119
|
+
/**
|
|
120
|
+
* Encode a location the same way window.history would do (no-op for memory
|
|
121
|
+
* history) so we ensure our PUSH/REPLACE navigations for data routers
|
|
122
|
+
* behave the same as POP
|
|
123
|
+
*
|
|
124
|
+
* @param to Unencoded path
|
|
125
|
+
*/
|
|
126
|
+
encodeLocation(to: To): Path;
|
|
127
|
+
/**
|
|
128
|
+
* Pushes a new location onto the history stack, increasing its length by one.
|
|
129
|
+
* If there were any entries in the stack after the current one, they are
|
|
130
|
+
* lost.
|
|
131
|
+
*
|
|
132
|
+
* @param to - The new URL
|
|
133
|
+
* @param state - Data to associate with the new location
|
|
134
|
+
*/
|
|
135
|
+
push(to: To, state?: any): void;
|
|
136
|
+
/**
|
|
137
|
+
* Replaces the current location in the history stack with a new one. The
|
|
138
|
+
* location that was replaced will no longer be available.
|
|
139
|
+
*
|
|
140
|
+
* @param to - The new URL
|
|
141
|
+
* @param state - Data to associate with the new location
|
|
142
|
+
*/
|
|
143
|
+
replace(to: To, state?: any): void;
|
|
144
|
+
/**
|
|
145
|
+
* Navigates `n` entries backward/forward in the history stack relative to the
|
|
146
|
+
* current index. For example, a "back" navigation would use go(-1).
|
|
147
|
+
*
|
|
148
|
+
* @param delta - The delta in the stack index
|
|
149
|
+
*/
|
|
150
|
+
go(delta: number): void;
|
|
151
|
+
/**
|
|
152
|
+
* Sets up a listener that will be called whenever the current location
|
|
153
|
+
* changes.
|
|
154
|
+
*
|
|
155
|
+
* @param listener - A function that will be called when the location changes
|
|
156
|
+
* @returns unlisten - A function that may be used to stop listening
|
|
157
|
+
*/
|
|
158
|
+
listen(listener: Listener): () => void;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* A user-supplied object that describes a location. Used when providing
|
|
162
|
+
* entries to `createMemoryHistory` via its `initialEntries` option.
|
|
163
|
+
*/
|
|
164
|
+
export type InitialEntry = string | Partial<Location>;
|
|
165
|
+
export type MemoryHistoryOptions = {
|
|
166
|
+
initialEntries?: InitialEntry[];
|
|
167
|
+
initialIndex?: number;
|
|
168
|
+
v5Compat?: boolean;
|
|
169
|
+
};
|
|
170
|
+
/**
|
|
171
|
+
* A memory history stores locations in memory. This is useful in stateful
|
|
172
|
+
* environments where there is no web browser, such as node tests or React
|
|
173
|
+
* Native.
|
|
174
|
+
*/
|
|
175
|
+
export interface MemoryHistory extends History {
|
|
176
|
+
/**
|
|
177
|
+
* The current index in the history stack.
|
|
178
|
+
*/
|
|
179
|
+
readonly index: number;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Memory history stores the current location in memory. It is designed for use
|
|
183
|
+
* in stateful non-browser environments like tests and React Native.
|
|
184
|
+
*/
|
|
185
|
+
export declare function createMemoryHistory(options?: MemoryHistoryOptions): MemoryHistory;
|
|
186
|
+
/**
|
|
187
|
+
* A browser history stores the current location in regular URLs in a web
|
|
188
|
+
* browser environment. This is the standard for most web apps and provides the
|
|
189
|
+
* cleanest URLs the browser's address bar.
|
|
190
|
+
*
|
|
191
|
+
* @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#browserhistory
|
|
192
|
+
*/
|
|
193
|
+
export interface BrowserHistory extends UrlHistory {
|
|
194
|
+
}
|
|
195
|
+
export type BrowserHistoryOptions = UrlHistoryOptions;
|
|
196
|
+
/**
|
|
197
|
+
* Browser history stores the location in regular URLs. This is the standard for
|
|
198
|
+
* most web apps, but it requires some configuration on the server to ensure you
|
|
199
|
+
* serve the same app at multiple URLs.
|
|
200
|
+
*
|
|
201
|
+
* @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#createbrowserhistory
|
|
202
|
+
*/
|
|
203
|
+
export declare function createBrowserHistory(options?: BrowserHistoryOptions): BrowserHistory;
|
|
204
|
+
/**
|
|
205
|
+
* A hash history stores the current location in the fragment identifier portion
|
|
206
|
+
* of the URL in a web browser environment.
|
|
207
|
+
*
|
|
208
|
+
* This is ideal for apps that do not control the server for some reason
|
|
209
|
+
* (because the fragment identifier is never sent to the server), including some
|
|
210
|
+
* shared hosting environments that do not provide fine-grained controls over
|
|
211
|
+
* which pages are served at which URLs.
|
|
212
|
+
*
|
|
213
|
+
* @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#hashhistory
|
|
214
|
+
*/
|
|
215
|
+
export interface HashHistory extends UrlHistory {
|
|
216
|
+
}
|
|
217
|
+
export type HashHistoryOptions = UrlHistoryOptions;
|
|
218
|
+
/**
|
|
219
|
+
* Hash history stores the location in window.location.hash. This makes it ideal
|
|
220
|
+
* for situations where you don't want to send the location to the server for
|
|
221
|
+
* some reason, either because you do cannot configure it or the URL space is
|
|
222
|
+
* reserved for something else.
|
|
223
|
+
*
|
|
224
|
+
* @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#createhashhistory
|
|
225
|
+
*/
|
|
226
|
+
export declare function createHashHistory(options?: HashHistoryOptions): HashHistory;
|
|
227
|
+
/**
|
|
228
|
+
* @private
|
|
229
|
+
*/
|
|
230
|
+
export declare function invariant(value: boolean, message?: string): asserts value;
|
|
231
|
+
export declare function invariant<T>(value: T | null | undefined, message?: string): asserts value is T;
|
|
232
|
+
export declare function warning(cond: any, message: string): void;
|
|
233
|
+
/**
|
|
234
|
+
* Creates a Location object with a unique key from the given Path
|
|
235
|
+
*/
|
|
236
|
+
export declare function createLocation(current: string | Location, to: To, state?: any, key?: string): Readonly<Location>;
|
|
237
|
+
/**
|
|
238
|
+
* Creates a string URL path from the given pathname, search, and hash components.
|
|
239
|
+
*/
|
|
240
|
+
export declare function createPath({ pathname, search, hash, }: Partial<Path>): string;
|
|
241
|
+
/**
|
|
242
|
+
* Parses a string URL path into its separate pathname, search, and hash components.
|
|
243
|
+
*/
|
|
244
|
+
export declare function parsePath(path: string): Partial<Path>;
|
|
245
|
+
export interface UrlHistory extends History {
|
|
246
|
+
}
|
|
247
|
+
export type UrlHistoryOptions = {
|
|
248
|
+
window?: Window;
|
|
249
|
+
v5Compat?: boolean;
|
|
250
|
+
};
|