react-router 6.27.0 → 7.0.0-pre.1

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.
Files changed (84) hide show
  1. package/CHANGELOG.md +309 -11
  2. package/README.md +1 -14
  3. package/dist/dom-export.d.ts +3 -0
  4. package/dist/dom-export.mjs +205 -0
  5. package/dist/dom-export.mjs.map +1 -0
  6. package/dist/index.d.ts +74 -29
  7. package/dist/index.mjs +11543 -0
  8. package/dist/index.mjs.map +1 -0
  9. package/dist/lib/components.d.ts +250 -35
  10. package/dist/lib/context.d.ts +18 -5
  11. package/dist/lib/dom/dom.d.ts +123 -0
  12. package/dist/lib/dom/global.d.ts +40 -0
  13. package/dist/lib/dom/lib.d.ts +940 -0
  14. package/dist/lib/dom/server.d.ts +41 -0
  15. package/dist/lib/dom/ssr/components.d.ts +123 -0
  16. package/dist/lib/dom/ssr/data.d.ts +7 -0
  17. package/dist/lib/dom/ssr/entry.d.ts +47 -0
  18. package/dist/lib/dom/ssr/errorBoundaries.d.ts +36 -0
  19. package/dist/lib/dom/ssr/errors.d.ts +2 -0
  20. package/dist/lib/dom/ssr/fallback.d.ts +2 -0
  21. package/dist/lib/dom/ssr/fog-of-war.d.ts +28 -0
  22. package/dist/lib/dom/ssr/invariant.d.ts +2 -0
  23. package/dist/lib/dom/ssr/links.d.ts +25 -0
  24. package/dist/lib/dom/ssr/markup.d.ts +5 -0
  25. package/dist/lib/dom/ssr/routeModules.d.ts +141 -0
  26. package/dist/lib/dom/ssr/routes-test-stub.d.ts +59 -0
  27. package/dist/lib/dom/ssr/routes.d.ts +32 -0
  28. package/dist/lib/dom/ssr/server.d.ts +16 -0
  29. package/dist/lib/dom/ssr/single-fetch.d.ts +37 -0
  30. package/dist/lib/dom-export/dom-router-provider.d.ts +5 -0
  31. package/dist/lib/dom-export/hydrated-router.d.ts +5 -0
  32. package/dist/lib/dom-export.d.ts +3 -0
  33. package/dist/lib/hooks.d.ts +286 -57
  34. package/dist/lib/router/history.d.ts +253 -0
  35. package/dist/lib/router/links.d.ts +104 -0
  36. package/dist/lib/router/router.d.ts +540 -0
  37. package/dist/lib/router/utils.d.ts +505 -0
  38. package/dist/lib/server-runtime/build.d.ts +38 -0
  39. package/dist/lib/server-runtime/cookies.d.ts +62 -0
  40. package/dist/lib/server-runtime/crypto.d.ts +2 -0
  41. package/dist/lib/server-runtime/data.d.ts +15 -0
  42. package/dist/lib/server-runtime/dev.d.ts +8 -0
  43. package/dist/lib/server-runtime/entry.d.ts +3 -0
  44. package/dist/lib/server-runtime/errors.d.ts +51 -0
  45. package/dist/lib/server-runtime/headers.d.ts +3 -0
  46. package/dist/lib/server-runtime/invariant.d.ts +2 -0
  47. package/dist/lib/server-runtime/jsonify.d.ts +33 -0
  48. package/dist/lib/server-runtime/markup.d.ts +1 -0
  49. package/dist/lib/server-runtime/mode.d.ts +9 -0
  50. package/dist/lib/server-runtime/responses.d.ts +37 -0
  51. package/dist/lib/server-runtime/routeMatching.d.ts +8 -0
  52. package/dist/lib/server-runtime/routeModules.d.ts +212 -0
  53. package/dist/lib/server-runtime/routes.d.ts +31 -0
  54. package/dist/lib/server-runtime/server.d.ts +5 -0
  55. package/dist/lib/server-runtime/serverHandoff.d.ts +11 -0
  56. package/dist/lib/server-runtime/sessions/cookieStorage.d.ts +19 -0
  57. package/dist/lib/server-runtime/sessions/memoryStorage.d.ts +17 -0
  58. package/dist/lib/server-runtime/sessions.d.ts +140 -0
  59. package/dist/lib/server-runtime/single-fetch.d.ts +30 -0
  60. package/dist/lib/server-runtime/typecheck.d.ts +4 -0
  61. package/dist/lib/server-runtime/warnings.d.ts +1 -0
  62. package/dist/lib/types.d.ts +76 -0
  63. package/dist/lib/types.mjs +10 -0
  64. package/dist/main-dom-export.js +19 -0
  65. package/dist/main.js +1 -1
  66. package/dist/react-router-dom.development.js +199 -0
  67. package/dist/react-router-dom.development.js.map +1 -0
  68. package/dist/react-router-dom.production.min.js +12 -0
  69. package/dist/react-router-dom.production.min.js.map +1 -0
  70. package/dist/react-router.development.js +12281 -1141
  71. package/dist/react-router.development.js.map +1 -1
  72. package/dist/react-router.production.min.js +2 -2
  73. package/dist/react-router.production.min.js.map +1 -1
  74. package/dist/umd/react-router-dom.development.js +241 -0
  75. package/dist/umd/react-router-dom.development.js.map +1 -0
  76. package/dist/umd/react-router-dom.production.min.js +12 -0
  77. package/dist/umd/react-router-dom.production.min.js.map +1 -0
  78. package/dist/umd/react-router.development.js +12467 -1238
  79. package/dist/umd/react-router.development.js.map +1 -1
  80. package/dist/umd/react-router.production.min.js +2 -2
  81. package/dist/umd/react-router.production.min.js.map +1 -1
  82. package/package.json +35 -6
  83. package/dist/index.js +0 -1467
  84. package/dist/index.js.map +0 -1
@@ -0,0 +1,41 @@
1
+ import * as React from "react";
2
+ import type { Location } from "../router/history";
3
+ import type { FutureConfig, Router as DataRouter, CreateStaticHandlerOptions as RouterCreateStaticHandlerOptions, StaticHandlerContext } from "../router/router";
4
+ import type { RouteObject } from "../context";
5
+ export interface StaticRouterProps {
6
+ basename?: string;
7
+ children?: React.ReactNode;
8
+ location: Partial<Location> | string;
9
+ }
10
+ /**
11
+ * A `<Router>` that may not navigate to any other location. This is useful
12
+ * on the server where there is no stateful UI.
13
+ *
14
+ * @category Router Components
15
+ */
16
+ export declare function StaticRouter({ basename, children, location: locationProp, }: StaticRouterProps): React.JSX.Element;
17
+ export interface StaticRouterProviderProps {
18
+ context: StaticHandlerContext;
19
+ router: DataRouter;
20
+ hydrate?: boolean;
21
+ nonce?: string;
22
+ }
23
+ /**
24
+ * A Data Router that may not navigate to any other location. This is useful
25
+ * on the server where there is no stateful UI.
26
+ *
27
+ * @category Router Components
28
+ */
29
+ export declare function StaticRouterProvider({ context, router, hydrate, nonce, }: StaticRouterProviderProps): React.JSX.Element;
30
+ type CreateStaticHandlerOptions = Omit<RouterCreateStaticHandlerOptions, "mapRouteProperties">;
31
+ /**
32
+ * @category Utils
33
+ */
34
+ export declare function createStaticHandler(routes: RouteObject[], opts?: CreateStaticHandlerOptions): import("../router/router").StaticHandler;
35
+ /**
36
+ * @category Routers
37
+ */
38
+ export declare function createStaticRouter(routes: RouteObject[], context: StaticHandlerContext, opts?: {
39
+ future?: Partial<FutureConfig>;
40
+ }): DataRouter;
41
+ export {};
@@ -0,0 +1,123 @@
1
+ import type { FocusEventHandler, MouseEventHandler, TouchEventHandler } from "react";
2
+ import * as React from "react";
3
+ import type { FrameworkContextObject } from "./entry";
4
+ import type { PageLinkDescriptor } from "../../router/links";
5
+ export type SerializeFrom<D> = D extends () => {} ? Awaited<ReturnType<D>> : D;
6
+ export declare const FrameworkContext: React.Context<FrameworkContextObject | undefined>;
7
+ export declare function useFrameworkContext(): FrameworkContextObject;
8
+ /**
9
+ * Defines the discovery behavior of the link:
10
+ *
11
+ * - "render" - default, discover the route when the link renders
12
+ * - "none" - don't eagerly discover, only discover if the link is clicked
13
+ */
14
+ export type DiscoverBehavior = "render" | "none";
15
+ /**
16
+ * Defines the prefetching behavior of the link:
17
+ *
18
+ * - "none": Never fetched
19
+ * - "intent": Fetched when the user focuses or hovers the link
20
+ * - "render": Fetched when the link is rendered
21
+ * - "viewport": Fetched when the link is in the viewport
22
+ */
23
+ export type PrefetchBehavior = "intent" | "render" | "none" | "viewport";
24
+ interface PrefetchHandlers {
25
+ onFocus?: FocusEventHandler;
26
+ onBlur?: FocusEventHandler;
27
+ onMouseEnter?: MouseEventHandler;
28
+ onMouseLeave?: MouseEventHandler;
29
+ onTouchStart?: TouchEventHandler;
30
+ }
31
+ export declare function usePrefetchBehavior<T extends HTMLAnchorElement>(prefetch: PrefetchBehavior, theirElementProps: PrefetchHandlers): [boolean, React.RefObject<T>, PrefetchHandlers];
32
+ export declare function composeEventHandlers<EventType extends React.SyntheticEvent | Event>(theirHandler: ((event: EventType) => any) | undefined, ourHandler: (event: EventType) => any): (event: EventType) => any;
33
+ /**
34
+ Renders all of the `<link>` tags created by route module {@link LinksFunction} export. You should render it inside the `<head>` of your document.
35
+
36
+ ```tsx
37
+ import { Links } from "react-router";
38
+
39
+ export default function Root() {
40
+ return (
41
+ <html>
42
+ <head>
43
+ <Links />
44
+ </head>
45
+ <body></body>
46
+ </html>
47
+ );
48
+ }
49
+ ```
50
+
51
+ @category Components
52
+ */
53
+ export declare function Links(): React.JSX.Element;
54
+ /**
55
+ Renders `<link rel=prefetch|modulepreload>` tags for modules and data of another page to enable an instant navigation to that page. {@link LinkProps.prefetch | `<Link prefetch>`} uses this internally, but you can render it to prefetch a page for any other reason.
56
+
57
+ ```tsx
58
+ import { PrefetchPageLinks } from "react-router"
59
+
60
+ <PrefetchPageLinks page="/absolute/path" />
61
+ ```
62
+
63
+ For example, you may render one of this as the user types into a search field to prefetch search results before they click through to their selection.
64
+
65
+ @category Components
66
+ */
67
+ export declare function PrefetchPageLinks({ page, ...dataLinkProps }: PageLinkDescriptor): React.JSX.Element | null;
68
+ /**
69
+ Renders all the `<meta>` tags created by route module {@link MetaFunction} exports. You should render it inside the `<head>` of your HTML.
70
+
71
+ ```tsx
72
+ import { Meta } from "react-router";
73
+
74
+ export default function Root() {
75
+ return (
76
+ <html>
77
+ <head>
78
+ <Meta />
79
+ </head>
80
+ </html>
81
+ );
82
+ }
83
+ ```
84
+
85
+ @category Components
86
+ */
87
+ export declare function Meta(): React.JSX.Element;
88
+ /**
89
+ A couple common attributes:
90
+
91
+ - `<Scripts crossOrigin>` for hosting your static assets on a different server than your app.
92
+ - `<Scripts nonce>` to support a [content security policy for scripts](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src) with [nonce-sources](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/Sources#sources) for your `<script>` tags.
93
+
94
+ You cannot pass through attributes such as `async`, `defer`, `src`, `type`, `noModule` because they are managed by React Router internally.
95
+
96
+ @category Types
97
+ */
98
+ export type ScriptsProps = Omit<React.HTMLProps<HTMLScriptElement>, "children" | "async" | "defer" | "src" | "type" | "noModule" | "dangerouslySetInnerHTML" | "suppressHydrationWarning">;
99
+ /**
100
+ Renders the client runtime of your app. It should be rendered inside the `<body>` of the document.
101
+
102
+ ```tsx
103
+ import { Scripts } from "react-router";
104
+
105
+ export default function Root() {
106
+ return (
107
+ <html>
108
+ <head />
109
+ <body>
110
+ <Scripts />
111
+ </body>
112
+ </html>
113
+ );
114
+ }
115
+ ```
116
+
117
+ If server rendering, you can omit `<Scripts/>` and the app will work as a traditional web app without JavaScript, relying solely on HTML and browser behaviors.
118
+
119
+ @category Components
120
+ */
121
+ export declare function Scripts(props: ScriptsProps): React.JSX.Element | null;
122
+ export declare function mergeRefs<T = any>(...refs: Array<React.MutableRefObject<T> | React.LegacyRef<T>>): React.RefCallback<T>;
123
+ export {};
@@ -0,0 +1,7 @@
1
+ import "../global";
2
+ /**
3
+ * Data for a route that was returned from a `loader()`.
4
+ */
5
+ export type AppData = unknown;
6
+ export declare function isResponse(value: any): value is Response;
7
+ export declare function createRequestInit(request: Request): Promise<RequestInit>;
@@ -0,0 +1,47 @@
1
+ import type { StaticHandlerContext } from "../../router/router";
2
+ import type { RouteManifest, EntryRoute } from "./routes";
3
+ import type { RouteModules } from "./routeModules";
4
+ type SerializedError = {
5
+ message: string;
6
+ stack?: string;
7
+ };
8
+ export interface FrameworkContextObject {
9
+ manifest: AssetsManifest;
10
+ routeModules: RouteModules;
11
+ criticalCss?: string;
12
+ serverHandoffString?: string;
13
+ future: FutureConfig;
14
+ isSpaMode: boolean;
15
+ abortDelay?: number;
16
+ serializeError?(error: Error): SerializedError;
17
+ renderMeta?: {
18
+ didRenderScripts?: boolean;
19
+ streamCache?: Record<number, Promise<void> & {
20
+ result?: {
21
+ done: boolean;
22
+ value: string;
23
+ };
24
+ error?: unknown;
25
+ }>;
26
+ };
27
+ }
28
+ export interface EntryContext extends FrameworkContextObject {
29
+ staticHandlerContext: StaticHandlerContext;
30
+ serverHandoffStream?: ReadableStream<Uint8Array>;
31
+ }
32
+ export interface FutureConfig {
33
+ }
34
+ export interface AssetsManifest {
35
+ entry: {
36
+ imports: string[];
37
+ module: string;
38
+ };
39
+ routes: RouteManifest<EntryRoute>;
40
+ url: string;
41
+ version: string;
42
+ hmr?: {
43
+ timestamp?: number;
44
+ runtime: string;
45
+ };
46
+ }
47
+ export {};
@@ -0,0 +1,36 @@
1
+ import * as React from "react";
2
+ import type { Location } from "../../router/history";
3
+ type RemixErrorBoundaryProps = React.PropsWithChildren<{
4
+ location: Location;
5
+ isOutsideRemixApp?: boolean;
6
+ error?: Error;
7
+ }>;
8
+ type RemixErrorBoundaryState = {
9
+ error: null | Error;
10
+ location: Location;
11
+ };
12
+ export declare class RemixErrorBoundary extends React.Component<RemixErrorBoundaryProps, RemixErrorBoundaryState> {
13
+ constructor(props: RemixErrorBoundaryProps);
14
+ static getDerivedStateFromError(error: Error): {
15
+ error: Error;
16
+ };
17
+ static getDerivedStateFromProps(props: RemixErrorBoundaryProps, state: RemixErrorBoundaryState): {
18
+ error: Error | null;
19
+ location: Location<any>;
20
+ };
21
+ render(): string | number | boolean | Iterable<React.ReactNode> | React.JSX.Element | null | undefined;
22
+ }
23
+ /**
24
+ * When app's don't provide a root level ErrorBoundary, we default to this.
25
+ */
26
+ export declare function RemixRootDefaultErrorBoundary({ error, isOutsideRemixApp, }: {
27
+ error: unknown;
28
+ isOutsideRemixApp?: boolean;
29
+ }): React.JSX.Element;
30
+ export declare function BoundaryShell({ title, renderScripts, isOutsideRemixApp, children, }: {
31
+ title: string;
32
+ renderScripts?: boolean;
33
+ isOutsideRemixApp?: boolean;
34
+ children: React.ReactNode | React.ReactNode[];
35
+ }): string | number | boolean | Iterable<React.ReactNode> | React.JSX.Element | null | undefined;
36
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { RouterState } from "../../router/router";
2
+ export declare function deserializeErrors(errors: RouterState["errors"]): RouterState["errors"];
@@ -0,0 +1,2 @@
1
+ import * as React from "react";
2
+ export declare function RemixRootDefaultHydrateFallback(): React.JSX.Element;
@@ -0,0 +1,28 @@
1
+ import type { PatchRoutesOnNavigationFunction } from "../../context";
2
+ import type { Router as DataRouter } from "../../router/router";
3
+ import type { AssetsManifest } from "./entry";
4
+ import type { RouteModules } from "./routeModules";
5
+ declare global {
6
+ interface Navigator {
7
+ connection?: {
8
+ saveData: boolean;
9
+ };
10
+ }
11
+ }
12
+ export declare function isFogOfWarEnabled(isSpaMode: boolean): boolean;
13
+ export declare function getPartialManifest(manifest: AssetsManifest, router: DataRouter): {
14
+ routes: {};
15
+ entry: {
16
+ imports: string[];
17
+ module: string;
18
+ };
19
+ url: string;
20
+ version: string;
21
+ hmr?: {
22
+ timestamp?: number | undefined;
23
+ runtime: string;
24
+ } | undefined;
25
+ };
26
+ export declare function getPatchRoutesOnNavigationFunction(manifest: AssetsManifest, routeModules: RouteModules, isSpaMode: boolean, basename: string | undefined): PatchRoutesOnNavigationFunction | undefined;
27
+ export declare function useFogOFWarDiscovery(router: DataRouter, manifest: AssetsManifest, routeModules: RouteModules, isSpaMode: boolean): void;
28
+ export declare function fetchAndApplyManifestPatches(paths: string[], manifest: AssetsManifest, routeModules: RouteModules, isSpaMode: boolean, basename: string | undefined, patchRoutes: DataRouter["patchRoutes"]): Promise<void>;
@@ -0,0 +1,2 @@
1
+ export default function invariant(value: boolean, message?: string): asserts value;
2
+ export default function invariant<T>(value: T | null | undefined, message?: string): asserts value is T;
@@ -0,0 +1,25 @@
1
+ import type { Location } from "../../router/history";
2
+ import type { AgnosticDataRouteMatch } from "../../router/utils";
3
+ import type { AssetsManifest } from "./entry";
4
+ import type { RouteModules, RouteModule } from "./routeModules";
5
+ import type { EntryRoute } from "./routes";
6
+ import type { HtmlLinkDescriptor, LinkDescriptor, PageLinkDescriptor } from "../../router/links";
7
+ /**
8
+ * Gets all the links for a set of matches. The modules are assumed to have been
9
+ * loaded already.
10
+ */
11
+ export declare function getKeyedLinksForMatches(matches: AgnosticDataRouteMatch[], routeModules: RouteModules, manifest: AssetsManifest): KeyedLinkDescriptor[];
12
+ export declare function prefetchStyleLinks(route: EntryRoute, routeModule: RouteModule): Promise<void>;
13
+ export declare function isPageLinkDescriptor(object: any): object is PageLinkDescriptor;
14
+ export type KeyedHtmlLinkDescriptor = {
15
+ key: string;
16
+ link: HtmlLinkDescriptor;
17
+ };
18
+ export declare function getKeyedPrefetchLinks(matches: AgnosticDataRouteMatch[], manifest: AssetsManifest, routeModules: RouteModules): Promise<KeyedHtmlLinkDescriptor[]>;
19
+ export declare function getNewMatchesForLinks(page: string, nextMatches: AgnosticDataRouteMatch[], currentMatches: AgnosticDataRouteMatch[], manifest: AssetsManifest, location: Location, mode: "data" | "assets"): AgnosticDataRouteMatch[];
20
+ export declare function getModuleLinkHrefs(matches: AgnosticDataRouteMatch[], manifestPatch: AssetsManifest): string[];
21
+ type KeyedLinkDescriptor<Descriptor extends LinkDescriptor = LinkDescriptor> = {
22
+ key: string;
23
+ link: Descriptor;
24
+ };
25
+ export {};
@@ -0,0 +1,5 @@
1
+ export declare function escapeHtml(html: string): string;
2
+ export interface SafeHtml {
3
+ __html: string;
4
+ }
5
+ export declare function createHtml(html: string): SafeHtml;
@@ -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 { EntryRoute } from "./routes";
7
+ import type { DataRouteMatch } from "../../context";
8
+ import type { LinkDescriptor } from "../../router/links";
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,59 @@
1
+ import * as React from "react";
2
+ import type { ActionFunction, LoaderFunction } from "../../router/utils";
3
+ import type { IndexRouteObject, NonIndexRouteObject } from "../../context";
4
+ import type { LinksFunction, MetaFunction } from "./routeModules";
5
+ import type { InitialEntry } from "../../router/history";
6
+ import type { HydrationState } from "../../router/router";
7
+ import type { FutureConfig } from "./entry";
8
+ interface StubIndexRouteObject extends Omit<IndexRouteObject, "loader" | "action" | "element" | "errorElement" | "children"> {
9
+ loader?: LoaderFunction;
10
+ action?: ActionFunction;
11
+ children?: StubRouteObject[];
12
+ meta?: MetaFunction;
13
+ links?: LinksFunction;
14
+ }
15
+ interface StubNonIndexRouteObject extends Omit<NonIndexRouteObject, "loader" | "action" | "element" | "errorElement" | "children"> {
16
+ loader?: LoaderFunction;
17
+ action?: ActionFunction;
18
+ children?: StubRouteObject[];
19
+ meta?: MetaFunction;
20
+ links?: LinksFunction;
21
+ }
22
+ type StubRouteObject = StubIndexRouteObject | StubNonIndexRouteObject;
23
+ interface AppLoadContext {
24
+ [key: string]: unknown;
25
+ }
26
+ export interface RoutesTestStubProps {
27
+ /**
28
+ * The initial entries in the history stack. This allows you to start a test with
29
+ * multiple locations already in the history stack (for testing a back navigation, etc.)
30
+ * The test will default to the last entry in initialEntries if no initialIndex is provided.
31
+ * e.g. initialEntries={["/home", "/about", "/contact"]}
32
+ */
33
+ initialEntries?: InitialEntry[];
34
+ /**
35
+ * The initial index in the history stack to render. This allows you to start a test at a specific entry.
36
+ * It defaults to the last entry in initialEntries.
37
+ * e.g.
38
+ * initialEntries: ["/", "/events/123"]
39
+ * initialIndex: 1 // start at "/events/123"
40
+ */
41
+ initialIndex?: number;
42
+ /**
43
+ * Used to set the route's initial loader and action data.
44
+ * e.g. hydrationData={{
45
+ * loaderData: { "/contact": { locale: "en-US" } },
46
+ * actionData: { "/login": { errors: { email: "invalid email" } }}
47
+ * }}
48
+ */
49
+ hydrationData?: HydrationState;
50
+ /**
51
+ * Future flags mimicking the settings in remix.config.js
52
+ */
53
+ future?: Partial<FutureConfig>;
54
+ }
55
+ /**
56
+ * @category Utils
57
+ */
58
+ export declare function createRoutesStub(routes: StubRouteObject[], context?: AppLoadContext): ({ initialEntries, initialIndex, hydrationData, future, }: RoutesTestStubProps) => React.JSX.Element;
59
+ export {};
@@ -0,0 +1,32 @@
1
+ import type { HydrationState } from "../../router/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 | null, 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,16 @@
1
+ import type { ReactElement } from "react";
2
+ import type { EntryContext } from "./entry";
3
+ export interface ServerRouterProps {
4
+ context: EntryContext;
5
+ url: string | URL;
6
+ abortDelay?: number;
7
+ nonce?: string;
8
+ }
9
+ /**
10
+ * The entry point for a Remix app when it is rendered on the server (in
11
+ * `app/entry.server.js`). This component is used to generate the HTML in the
12
+ * response from the server.
13
+ *
14
+ * @category Components
15
+ */
16
+ export declare function ServerRouter({ context, url, abortDelay, nonce, }: ServerRouterProps): ReactElement;
@@ -0,0 +1,37 @@
1
+ import * as React from "react";
2
+ import type { Router as DataRouter } from "../../router/router";
3
+ import type { DataStrategyFunction } from "../../router/utils";
4
+ import type { AssetsManifest, EntryContext } from "./entry";
5
+ import type { RouteModules } from "./routeModules";
6
+ export declare const SingleFetchRedirectSymbol: unique symbol;
7
+ export type SingleFetchRedirectResult = {
8
+ redirect: string;
9
+ status: number;
10
+ revalidate: boolean;
11
+ reload: boolean;
12
+ replace: boolean;
13
+ };
14
+ export type SingleFetchResult = {
15
+ data: unknown;
16
+ } | {
17
+ error: unknown;
18
+ } | SingleFetchRedirectResult;
19
+ export type SingleFetchResults = {
20
+ [key: string]: SingleFetchResult;
21
+ [SingleFetchRedirectSymbol]?: SingleFetchRedirectResult;
22
+ };
23
+ interface StreamTransferProps {
24
+ context: EntryContext;
25
+ identifier: number;
26
+ reader: ReadableStreamDefaultReader<Uint8Array>;
27
+ textDecoder: TextDecoder;
28
+ nonce?: string;
29
+ }
30
+ export declare function StreamTransfer({ context, identifier, reader, textDecoder, nonce, }: StreamTransferProps): React.JSX.Element | null;
31
+ export declare function getSingleFetchDataStrategy(manifest: AssetsManifest, routeModules: RouteModules, getRouter: () => DataRouter): DataStrategyFunction;
32
+ export declare function singleFetchUrl(reqUrl: URL | string): URL;
33
+ export declare function decodeViaTurboStream(body: ReadableStream<Uint8Array>, global: Window | typeof globalThis): Promise<{
34
+ done: Promise<undefined>;
35
+ value: unknown;
36
+ }>;
37
+ export {};
@@ -0,0 +1,5 @@
1
+ import * as React from "react";
2
+ import type { RouterProviderProps as BaseRouterProviderProps } from "react-router";
3
+ export { HydratedRouter } from "./hydrated-router";
4
+ export type RouterProviderProps = Omit<BaseRouterProviderProps, "flushSync">;
5
+ export declare function RouterProvider(props: Omit<RouterProviderProps, "flushSync">): React.JSX.Element;
@@ -0,0 +1,5 @@
1
+ import * as React from "react";
2
+ /**
3
+ * @category Router Components
4
+ */
5
+ export declare function HydratedRouter(): React.JSX.Element;
@@ -0,0 +1,3 @@
1
+ export type { RouterProviderProps } from "./lib/dom-export/dom-router-provider";
2
+ export { RouterProvider } from "./lib/dom-export/dom-router-provider";
3
+ export { HydratedRouter } from "./lib/dom-export/hydrated-router";