| 1 |
|
| 2 | import { PatchRoutesOnNavigationFunction, RouteObject } from "../../router/utils.js";
|
| 3 | import { Router } from "../../router/router.js";
|
| 4 | import { ClientOnErrorFunction } from "../../components.js";
|
| 5 | import { RouteModules } from "./routeModules.js";
|
| 6 | import { RouterFetch } from "./single-fetch.js";
|
| 7 | import { WindowReactRouterContext } from "../global.js";
|
| 8 | import { AssetsManifest } from "./entry.js";
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 | type ManifestMismatchEvent = {
|
| 13 | source: "eager" | "navigation" | "fetcher" | "imperative";
|
| 14 | version: string;
|
| 15 | reloadUrl: string | null;
|
| 16 | loadAllRoutes(): Promise<void>;
|
| 17 | stopPropagation(): void;
|
| 18 | defaultBehavior(): Promise<void>;
|
| 19 | };
|
| 20 |
|
| 21 | type DiscoveryResult = {
|
| 22 | type: "success";
|
| 23 | } | {
|
| 24 | type: "version-mismatch";
|
| 25 | } | {
|
| 26 | type: "aborted";
|
| 27 | };
|
| 28 |
|
| 29 | type RouteDiscoveryOptions = {
|
| 30 | onManifestMismatch?: (event: ManifestMismatchEvent) => void | Promise<void>;
|
| 31 | };
|
| 32 | type Registration = {
|
| 33 | current: RouteDiscoveryOptions;
|
| 34 | };
|
| 35 | type DiscoveryState = "partial" | "loading" | "complete";
|
| 36 | type RouteDiscoverySsrInfo = {
|
| 37 | manifest: AssetsManifest;
|
| 38 | routeModules: RouteModules;
|
| 39 | router: Router | undefined;
|
| 40 | context: Pick<WindowReactRouterContext, "ssr" | "routeDiscovery" | "isSpaMode" | "basename" | "unstable_apiServerOrigin" | "unstable_apiOnly">;
|
| 41 | };
|
| 42 | declare class RouteDiscoveryRuntime {
|
| 43 | private ssrInfo;
|
| 44 | readonly enabled: boolean;
|
| 45 | readonly discoveredPaths: Set<string>;
|
| 46 | readonly nextPaths: Set<string>;
|
| 47 | state: DiscoveryState;
|
| 48 | ready: boolean;
|
| 49 | private registrations;
|
| 50 | private listeners;
|
| 51 | private fullLoadErrorListeners;
|
| 52 | private fullLoad?;
|
| 53 | private loadedManifest?;
|
| 54 | private mismatch?;
|
| 55 | private fetchImplementation;
|
| 56 | private loadManifest;
|
| 57 | onError?: ClientOnErrorFunction;
|
| 58 | constructor(ssrInfo: RouteDiscoverySsrInfo, {
|
| 59 | fetch: fetchImplementation,
|
| 60 | loadManifest
|
| 61 | }?: {
|
| 62 | fetch?: RouterFetch;
|
| 63 | loadManifest?: () => Promise<AssetsManifest>;
|
| 64 | });
|
| 65 | private get router();
|
| 66 | private loadManifestAsset;
|
| 67 | subscribe: (listener: () => void) => () => void;
|
| 68 | private update;
|
| 69 | markReady: () => void;
|
| 70 | register(registration: Registration): () => void;
|
| 71 | private isComplete;
|
| 72 | loadAllRoutes: () => Promise<void>;
|
| 73 | reportError(error: unknown): void;
|
| 74 | private dispatchMismatch;
|
| 75 | private requestUrl;
|
| 76 | discoverRoutes: (paths: string[], options?: {
|
| 77 | signal?: AbortSignal;
|
| 78 | }) => Promise<DiscoveryResult>;
|
| 79 | discover(paths: string[], source: ManifestMismatchEvent["source"], reloadUrl: string | null, signal?: AbortSignal, patch?: (routeId: string | null, children: RouteObject[], unstable_allowElementMutations?: boolean) => void): Promise<DiscoveryResult>;
|
| 80 | }
|
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | |
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 | |
| 97 | |
| 98 | |
| 99 | |
| 100 | |
| 101 | |
| 102 | |
| 103 | |
| 104 | |
| 105 | |
| 106 | |
| 107 | |
| 108 |
|
| 109 | declare function useRouteDiscovery(options?: RouteDiscoveryOptions): {
|
| 110 | version: string;
|
| 111 | state: DiscoveryState;
|
| 112 | loadAllRoutes: () => Promise<void>;
|
| 113 | discoverRoutes: (paths: string[], options?: {
|
| 114 | signal?: AbortSignal;
|
| 115 | }) => Promise<DiscoveryResult>;
|
| 116 | };
|
| 117 | declare function getCustomPatchRoutesOnNavigationFunction(getRouter: () => Router, runtime: RouteDiscoveryRuntime): PatchRoutesOnNavigationFunction | undefined;
|
| 118 | declare function useCustomRouteDiscovery(runtime: RouteDiscoveryRuntime, onError?: ClientOnErrorFunction): "partial" | "loading" | "complete";
|
| 119 |
|
| 120 | export { DiscoveryResult, DiscoveryState, ManifestMismatchEvent, RouteDiscoveryOptions, RouteDiscoveryRuntime, getCustomPatchRoutesOnNavigationFunction, useCustomRouteDiscovery, useRouteDiscovery }; |
| \ | No newline at end of file |