| 1 | import * as React from 'react';
|
| 2 | import { ComponentType, ReactElement } from 'react';
|
| 3 |
|
| 4 | |
| 5 | |
| 6 |
|
| 7 | declare enum Action {
|
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 |
|
| 15 | Pop = "POP",
|
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 |
|
| 21 | Push = "PUSH",
|
| 22 | |
| 23 | |
| 24 | |
| 25 |
|
| 26 | Replace = "REPLACE"
|
| 27 | }
|
| 28 | |
| 29 | |
| 30 |
|
| 31 | interface Path {
|
| 32 | |
| 33 | |
| 34 |
|
| 35 | pathname: string;
|
| 36 | |
| 37 | |
| 38 |
|
| 39 | search: string;
|
| 40 | |
| 41 | |
| 42 |
|
| 43 | hash: string;
|
| 44 | }
|
| 45 | |
| 46 | |
| 47 | |
| 48 |
|
| 49 | interface Location<State = any> extends Path {
|
| 50 | |
| 51 | |
| 52 |
|
| 53 | state: State;
|
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 |
|
| 60 | key: string;
|
| 61 | }
|
| 62 | |
| 63 | |
| 64 |
|
| 65 | interface Update {
|
| 66 | |
| 67 | |
| 68 |
|
| 69 | action: Action;
|
| 70 | |
| 71 | |
| 72 |
|
| 73 | location: Location;
|
| 74 | |
| 75 | |
| 76 |
|
| 77 | delta: number | null;
|
| 78 | }
|
| 79 | |
| 80 | |
| 81 |
|
| 82 | interface Listener {
|
| 83 | (update: Update): void;
|
| 84 | }
|
| 85 | |
| 86 | |
| 87 | |
| 88 |
|
| 89 | type To = string | Partial<Path>;
|
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 | |
| 97 |
|
| 98 | interface History {
|
| 99 | |
| 100 | |
| 101 | |
| 102 |
|
| 103 | readonly action: Action;
|
| 104 | |
| 105 | |
| 106 |
|
| 107 | readonly location: Location;
|
| 108 | |
| 109 | |
| 110 | |
| 111 | |
| 112 | |
| 113 |
|
| 114 | createHref(to: To): string;
|
| 115 | |
| 116 | |
| 117 | |
| 118 | |
| 119 |
|
| 120 | createURL(to: To): URL;
|
| 121 | |
| 122 | |
| 123 | |
| 124 | |
| 125 | |
| 126 | |
| 127 |
|
| 128 | encodeLocation(to: To): Path;
|
| 129 | |
| 130 | |
| 131 | |
| 132 | |
| 133 | |
| 134 | |
| 135 | |
| 136 |
|
| 137 | push(to: To, state?: any): void;
|
| 138 | |
| 139 | |
| 140 | |
| 141 | |
| 142 | |
| 143 | |
| 144 |
|
| 145 | replace(to: To, state?: any): void;
|
| 146 | |
| 147 | |
| 148 | |
| 149 | |
| 150 | |
| 151 |
|
| 152 | go(delta: number): void;
|
| 153 | |
| 154 | |
| 155 | |
| 156 | |
| 157 | |
| 158 | |
| 159 |
|
| 160 | listen(listener: Listener): () => void;
|
| 161 | }
|
| 162 | |
| 163 | |
| 164 | |
| 165 |
|
| 166 | type InitialEntry = string | Partial<Location>;
|
| 167 | |
| 168 | |
| 169 | |
| 170 | |
| 171 | |
| 172 | |
| 173 |
|
| 174 | interface BrowserHistory extends UrlHistory {
|
| 175 | }
|
| 176 | type BrowserHistoryOptions = UrlHistoryOptions;
|
| 177 | |
| 178 | |
| 179 | |
| 180 | |
| 181 | |
| 182 | |
| 183 |
|
| 184 | declare function createBrowserHistory(options?: BrowserHistoryOptions): BrowserHistory;
|
| 185 | |
| 186 | |
| 187 |
|
| 188 | declare function invariant(value: boolean, message?: string): asserts value;
|
| 189 | declare function invariant<T>(value: T | null | undefined, message?: string): asserts value is T;
|
| 190 | |
| 191 | |
| 192 | |
| 193 | |
| 194 |
|
| 195 | declare function createPath({ pathname, search, hash, }: Partial<Path>): string;
|
| 196 | |
| 197 | |
| 198 | |
| 199 | |
| 200 |
|
| 201 | declare function parsePath(path: string): Partial<Path>;
|
| 202 | interface UrlHistory extends History {
|
| 203 | }
|
| 204 | type UrlHistoryOptions = {
|
| 205 | window?: Window;
|
| 206 | v5Compat?: boolean;
|
| 207 | };
|
| 208 |
|
| 209 | type MaybePromise<T> = T | Promise<T>;
|
| 210 | |
| 211 | |
| 212 |
|
| 213 | interface RouteData {
|
| 214 | [routeId: string]: any;
|
| 215 | }
|
| 216 | type LowerCaseFormMethod = "get" | "post" | "put" | "patch" | "delete";
|
| 217 | type UpperCaseFormMethod = Uppercase<LowerCaseFormMethod>;
|
| 218 | |
| 219 | |
| 220 | |
| 221 |
|
| 222 | type HTMLFormMethod = LowerCaseFormMethod | UpperCaseFormMethod;
|
| 223 | |
| 224 | |
| 225 | |
| 226 |
|
| 227 | type FormMethod = UpperCaseFormMethod;
|
| 228 | type FormEncType = "application/x-www-form-urlencoded" | "multipart/form-data" | "application/json" | "text/plain";
|
| 229 | type JsonObject = {
|
| 230 | [Key in string]: JsonValue;
|
| 231 | } & {
|
| 232 | [Key in string]?: JsonValue | undefined;
|
| 233 | };
|
| 234 | type JsonArray = JsonValue[] | readonly JsonValue[];
|
| 235 | type JsonPrimitive = string | number | boolean | null;
|
| 236 | type JsonValue = JsonPrimitive | JsonObject | JsonArray;
|
| 237 | |
| 238 | |
| 239 | |
| 240 | |
| 241 |
|
| 242 | type Submission = {
|
| 243 | formMethod: FormMethod;
|
| 244 | formAction: string;
|
| 245 | formEncType: FormEncType;
|
| 246 | formData: FormData;
|
| 247 | json: undefined;
|
| 248 | text: undefined;
|
| 249 | } | {
|
| 250 | formMethod: FormMethod;
|
| 251 | formAction: string;
|
| 252 | formEncType: FormEncType;
|
| 253 | formData: undefined;
|
| 254 | json: JsonValue;
|
| 255 | text: undefined;
|
| 256 | } | {
|
| 257 | formMethod: FormMethod;
|
| 258 | formAction: string;
|
| 259 | formEncType: FormEncType;
|
| 260 | formData: undefined;
|
| 261 | json: undefined;
|
| 262 | text: string;
|
| 263 | };
|
| 264 | interface unstable_RouterContext<T = unknown> {
|
| 265 | defaultValue?: T;
|
| 266 | }
|
| 267 | |
| 268 | |
| 269 | |
| 270 | |
| 271 | |
| 272 | |
| 273 | |
| 274 | |
| 275 | |
| 276 |
|
| 277 | declare function unstable_createContext<T>(defaultValue?: T): unstable_RouterContext<T>;
|
| 278 | |
| 279 | |
| 280 | |
| 281 |
|
| 282 | type unstable_InitialContext = Map<unstable_RouterContext, unknown>;
|
| 283 | |
| 284 | |
| 285 |
|
| 286 | declare class unstable_RouterContextProvider {
|
| 287 | #private;
|
| 288 | constructor(init?: unstable_InitialContext);
|
| 289 | get<T>(context: unstable_RouterContext<T>): T;
|
| 290 | set<C extends unstable_RouterContext>(context: C, value: C extends unstable_RouterContext<infer T> ? T : never): void;
|
| 291 | }
|
| 292 | |
| 293 | |
| 294 | |
| 295 | |
| 296 |
|
| 297 | interface DataFunctionArgs<Context> {
|
| 298 |
|
| 299 | request: Request;
|
| 300 | |
| 301 | |
| 302 | |
| 303 | |
| 304 | |
| 305 | |
| 306 | |
| 307 | |
| 308 | |
| 309 | |
| 310 | |
| 311 | |
| 312 | |
| 313 |
|
| 314 | params: Params;
|
| 315 | |
| 316 | |
| 317 | |
| 318 | |
| 319 |
|
| 320 | context: Context;
|
| 321 | }
|
| 322 | |
| 323 | |
| 324 | |
| 325 |
|
| 326 | interface unstable_MiddlewareNextFunction<Result = unknown> {
|
| 327 | (): MaybePromise<Result>;
|
| 328 | }
|
| 329 | |
| 330 | |
| 331 | |
| 332 | |
| 333 | |
| 334 |
|
| 335 | type unstable_MiddlewareFunction<Result = unknown> = (args: DataFunctionArgs<unstable_RouterContextProvider>, next: unstable_MiddlewareNextFunction<Result>) => MaybePromise<Result | undefined>;
|
| 336 | |
| 337 | |
| 338 |
|
| 339 | interface LoaderFunctionArgs<Context = any> extends DataFunctionArgs<Context> {
|
| 340 | }
|
| 341 | |
| 342 | |
| 343 |
|
| 344 | interface ActionFunctionArgs<Context = any> extends DataFunctionArgs<Context> {
|
| 345 | }
|
| 346 | |
| 347 | |
| 348 |
|
| 349 | type DataFunctionValue = unknown;
|
| 350 | type DataFunctionReturnValue = MaybePromise<DataFunctionValue>;
|
| 351 | |
| 352 | |
| 353 |
|
| 354 | type LoaderFunction<Context = any> = {
|
| 355 | (args: LoaderFunctionArgs<Context>, handlerCtx?: unknown): DataFunctionReturnValue;
|
| 356 | } & {
|
| 357 | hydrate?: boolean;
|
| 358 | };
|
| 359 | |
| 360 | |
| 361 |
|
| 362 | interface ActionFunction<Context = any> {
|
| 363 | (args: ActionFunctionArgs<Context>, handlerCtx?: unknown): DataFunctionReturnValue;
|
| 364 | }
|
| 365 | |
| 366 | |
| 367 |
|
| 368 | interface ShouldRevalidateFunctionArgs {
|
| 369 |
|
| 370 | currentUrl: URL;
|
| 371 |
|
| 372 | currentParams: AgnosticDataRouteMatch["params"];
|
| 373 |
|
| 374 | nextUrl: URL;
|
| 375 |
|
| 376 | nextParams: AgnosticDataRouteMatch["params"];
|
| 377 |
|
| 378 | formMethod?: Submission["formMethod"];
|
| 379 |
|
| 380 | formAction?: Submission["formAction"];
|
| 381 |
|
| 382 | formEncType?: Submission["formEncType"];
|
| 383 |
|
| 384 | text?: Submission["text"];
|
| 385 |
|
| 386 | formData?: Submission["formData"];
|
| 387 |
|
| 388 | json?: Submission["json"];
|
| 389 |
|
| 390 | actionStatus?: number;
|
| 391 | |
| 392 | |
| 393 | |
| 394 | |
| 395 | |
| 396 | |
| 397 | |
| 398 | |
| 399 | |
| 400 | |
| 401 | |
| 402 | |
| 403 | |
| 404 | |
| 405 | |
| 406 | |
| 407 | |
| 408 |
|
| 409 | actionResult?: any;
|
| 410 | |
| 411 | |
| 412 | |
| 413 | |
| 414 | |
| 415 | |
| 416 | |
| 417 | |
| 418 |
|
| 419 | defaultShouldRevalidate: boolean;
|
| 420 | }
|
| 421 | |
| 422 | |
| 423 | |
| 424 | |
| 425 | |
| 426 | |
| 427 |
|
| 428 | interface ShouldRevalidateFunction {
|
| 429 | (args: ShouldRevalidateFunctionArgs): boolean;
|
| 430 | }
|
| 431 | interface DataStrategyMatch extends AgnosticRouteMatch<string, AgnosticDataRouteObject> {
|
| 432 | shouldLoad: boolean;
|
| 433 | resolve: (handlerOverride?: (handler: (ctx?: unknown) => DataFunctionReturnValue) => DataFunctionReturnValue) => Promise<DataStrategyResult>;
|
| 434 | }
|
| 435 | interface DataStrategyFunctionArgs<Context = any> extends DataFunctionArgs<Context> {
|
| 436 | matches: DataStrategyMatch[];
|
| 437 | fetcherKey: string | null;
|
| 438 | }
|
| 439 | |
| 440 | |
| 441 |
|
| 442 | interface DataStrategyResult {
|
| 443 | type: "data" | "error";
|
| 444 | result: unknown;
|
| 445 | }
|
| 446 | interface DataStrategyFunction<Context = any> {
|
| 447 | (args: DataStrategyFunctionArgs<Context>): Promise<Record<string, DataStrategyResult>>;
|
| 448 | }
|
| 449 | type AgnosticPatchRoutesOnNavigationFunctionArgs<O extends AgnosticRouteObject = AgnosticRouteObject, M extends AgnosticRouteMatch = AgnosticRouteMatch> = {
|
| 450 | signal: AbortSignal;
|
| 451 | path: string;
|
| 452 | matches: M[];
|
| 453 | fetcherKey: string | undefined;
|
| 454 | patch: (routeId: string | null, children: O[]) => void;
|
| 455 | };
|
| 456 | type AgnosticPatchRoutesOnNavigationFunction<O extends AgnosticRouteObject = AgnosticRouteObject, M extends AgnosticRouteMatch = AgnosticRouteMatch> = (opts: AgnosticPatchRoutesOnNavigationFunctionArgs<O, M>) => MaybePromise<void>;
|
| 457 | |
| 458 | |
| 459 | |
| 460 |
|
| 461 | interface MapRoutePropertiesFunction {
|
| 462 | (route: AgnosticRouteObject): {
|
| 463 | hasErrorBoundary: boolean;
|
| 464 | } & Record<string, any>;
|
| 465 | }
|
| 466 | |
| 467 | |
| 468 | |
| 469 | |
| 470 |
|
| 471 | type ImmutableRouteKey = "lazy" | "caseSensitive" | "path" | "id" | "index" | "children";
|
| 472 | type RequireOne<T, Key = keyof T> = Exclude<{
|
| 473 | [K in keyof T]: K extends Key ? Omit<T, K> & Required<Pick<T, K>> : never;
|
| 474 | }[keyof T], undefined>;
|
| 475 | |
| 476 | |
| 477 | |
| 478 |
|
| 479 | interface LazyRouteFunction<R extends AgnosticRouteObject> {
|
| 480 | (): Promise<RequireOne<Omit<R, ImmutableRouteKey>>>;
|
| 481 | }
|
| 482 | |
| 483 | |
| 484 |
|
| 485 | type AgnosticBaseRouteObject = {
|
| 486 | caseSensitive?: boolean;
|
| 487 | path?: string;
|
| 488 | id?: string;
|
| 489 | unstable_middleware?: unstable_MiddlewareFunction[];
|
| 490 | loader?: LoaderFunction | boolean;
|
| 491 | action?: ActionFunction | boolean;
|
| 492 | hasErrorBoundary?: boolean;
|
| 493 | shouldRevalidate?: ShouldRevalidateFunction;
|
| 494 | handle?: any;
|
| 495 | lazy?: LazyRouteFunction<AgnosticBaseRouteObject>;
|
| 496 | };
|
| 497 | |
| 498 | |
| 499 |
|
| 500 | type AgnosticIndexRouteObject = AgnosticBaseRouteObject & {
|
| 501 | children?: undefined;
|
| 502 | index: true;
|
| 503 | };
|
| 504 | |
| 505 | |
| 506 |
|
| 507 | type AgnosticNonIndexRouteObject = AgnosticBaseRouteObject & {
|
| 508 | children?: AgnosticRouteObject[];
|
| 509 | index?: false;
|
| 510 | };
|
| 511 | |
| 512 | |
| 513 | |
| 514 |
|
| 515 | type AgnosticRouteObject = AgnosticIndexRouteObject | AgnosticNonIndexRouteObject;
|
| 516 | type AgnosticDataIndexRouteObject = AgnosticIndexRouteObject & {
|
| 517 | id: string;
|
| 518 | };
|
| 519 | type AgnosticDataNonIndexRouteObject = AgnosticNonIndexRouteObject & {
|
| 520 | children?: AgnosticDataRouteObject[];
|
| 521 | id: string;
|
| 522 | };
|
| 523 | |
| 524 | |
| 525 |
|
| 526 | type AgnosticDataRouteObject = AgnosticDataIndexRouteObject | AgnosticDataNonIndexRouteObject;
|
| 527 | type RouteManifest<R = AgnosticDataRouteObject> = Record<string, R | undefined>;
|
| 528 | type Regex_az = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z";
|
| 529 | type Regez_AZ = "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z";
|
| 530 | type Regex_09 = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9";
|
| 531 | type Regex_w = Regex_az | Regez_AZ | Regex_09 | "_";
|
| 532 | type ParamChar = Regex_w | "-";
|
| 533 | type RegexMatchPlus<CharPattern extends string, T extends string> = T extends `${infer First}${infer Rest}` ? First extends CharPattern ? RegexMatchPlus<CharPattern, Rest> extends never ? First : `${First}${RegexMatchPlus<CharPattern, Rest>}` : never : never;
|
| 534 | type _PathParam<Path extends string> = Path extends `${infer L}/${infer R}` ? _PathParam<L> | _PathParam<R> : Path extends `:${infer Param}` ? Param extends `${infer Optional}?${string}` ? RegexMatchPlus<ParamChar, Optional> : RegexMatchPlus<ParamChar, Param> : never;
|
| 535 | type PathParam<Path extends string> = Path extends "*" | "/*" ? "*" : Path extends `${infer Rest}/*` ? "*" | _PathParam<Rest> : _PathParam<Path>;
|
| 536 | type ParamParseKey<Segment extends string> = [
|
| 537 | PathParam<Segment>
|
| 538 | ] extends [never] ? string : PathParam<Segment>;
|
| 539 | |
| 540 | |
| 541 |
|
| 542 | type Params<Key extends string = string> = {
|
| 543 | readonly [key in Key]: string | undefined;
|
| 544 | };
|
| 545 | |
| 546 | |
| 547 |
|
| 548 | interface AgnosticRouteMatch<ParamKey extends string = string, RouteObjectType extends AgnosticRouteObject = AgnosticRouteObject> {
|
| 549 | |
| 550 | |
| 551 |
|
| 552 | params: Params<ParamKey>;
|
| 553 | |
| 554 | |
| 555 |
|
| 556 | pathname: string;
|
| 557 | |
| 558 | |
| 559 |
|
| 560 | pathnameBase: string;
|
| 561 | |
| 562 | |
| 563 |
|
| 564 | route: RouteObjectType;
|
| 565 | }
|
| 566 | interface AgnosticDataRouteMatch extends AgnosticRouteMatch<string, AgnosticDataRouteObject> {
|
| 567 | }
|
| 568 | |
| 569 | |
| 570 | |
| 571 | |
| 572 |
|
| 573 | declare function matchRoutes<RouteObjectType extends AgnosticRouteObject = AgnosticRouteObject>(routes: RouteObjectType[], locationArg: Partial<Location> | string, basename?: string): AgnosticRouteMatch<string, RouteObjectType>[] | null;
|
| 574 | interface UIMatch<Data = unknown, Handle = unknown> {
|
| 575 | id: string;
|
| 576 | pathname: string;
|
| 577 | |
| 578 | |
| 579 |
|
| 580 | params: AgnosticRouteMatch["params"];
|
| 581 |
|
| 582 | data: Data;
|
| 583 |
|
| 584 | handle: Handle;
|
| 585 | }
|
| 586 | |
| 587 | |
| 588 | |
| 589 | |
| 590 |
|
| 591 | declare function generatePath<Path extends string>(originalPath: Path, params?: {
|
| 592 | [key in PathParam<Path>]: string | null;
|
| 593 | }): string;
|
| 594 | |
| 595 | |
| 596 |
|
| 597 | interface PathPattern<Path extends string = string> {
|
| 598 | |
| 599 | |
| 600 | |
| 601 | |
| 602 |
|
| 603 | path: Path;
|
| 604 | |
| 605 | |
| 606 | |
| 607 |
|
| 608 | caseSensitive?: boolean;
|
| 609 | |
| 610 | |
| 611 |
|
| 612 | end?: boolean;
|
| 613 | }
|
| 614 | |
| 615 | |
| 616 |
|
| 617 | interface PathMatch<ParamKey extends string = string> {
|
| 618 | |
| 619 | |
| 620 |
|
| 621 | params: Params<ParamKey>;
|
| 622 | |
| 623 | |
| 624 |
|
| 625 | pathname: string;
|
| 626 | |
| 627 | |
| 628 |
|
| 629 | pathnameBase: string;
|
| 630 | |
| 631 | |
| 632 |
|
| 633 | pattern: PathPattern;
|
| 634 | }
|
| 635 | |
| 636 | |
| 637 | |
| 638 | |
| 639 | |
| 640 |
|
| 641 | declare function matchPath<ParamKey extends ParamParseKey<Path>, Path extends string>(pattern: PathPattern<Path> | Path, pathname: string): PathMatch<ParamKey> | null;
|
| 642 | |
| 643 | |
| 644 | |
| 645 | |
| 646 |
|
| 647 | declare function resolvePath(to: To, fromPathname?: string): Path;
|
| 648 | declare class DataWithResponseInit<D> {
|
| 649 | type: string;
|
| 650 | data: D;
|
| 651 | init: ResponseInit | null;
|
| 652 | constructor(data: D, init?: ResponseInit);
|
| 653 | }
|
| 654 | |
| 655 | |
| 656 | |
| 657 | |
| 658 | |
| 659 |
|
| 660 | declare function data<D>(data: D, init?: number | ResponseInit): DataWithResponseInit<D>;
|
| 661 | type RedirectFunction = (url: string, init?: number | ResponseInit) => Response;
|
| 662 | |
| 663 | |
| 664 | |
| 665 | |
| 666 | |
| 667 |
|
| 668 | declare const redirect: RedirectFunction;
|
| 669 | |
| 670 | |
| 671 | |
| 672 | |
| 673 | |
| 674 | |
| 675 |
|
| 676 | declare const redirectDocument: RedirectFunction;
|
| 677 | |
| 678 | |
| 679 | |
| 680 | |
| 681 | |
| 682 | |
| 683 | |
| 684 |
|
| 685 | declare const replace: RedirectFunction;
|
| 686 | type ErrorResponse = {
|
| 687 | status: number;
|
| 688 | statusText: string;
|
| 689 | data: any;
|
| 690 | };
|
| 691 | |
| 692 | |
| 693 | |
| 694 | |
| 695 | |
| 696 | |
| 697 | |
| 698 |
|
| 699 | declare class ErrorResponseImpl implements ErrorResponse {
|
| 700 | status: number;
|
| 701 | statusText: string;
|
| 702 | data: any;
|
| 703 | private error?;
|
| 704 | private internal;
|
| 705 | constructor(status: number, statusText: string | undefined, data: any, internal?: boolean);
|
| 706 | }
|
| 707 | |
| 708 | |
| 709 | |
| 710 | |
| 711 | |
| 712 |
|
| 713 | declare function isRouteErrorResponse(error: any): error is ErrorResponse;
|
| 714 |
|
| 715 | |
| 716 | |
| 717 |
|
| 718 | interface Router {
|
| 719 | |
| 720 | |
| 721 | |
| 722 | |
| 723 | |
| 724 |
|
| 725 | get basename(): RouterInit["basename"];
|
| 726 | |
| 727 | |
| 728 | |
| 729 | |
| 730 | |
| 731 |
|
| 732 | get future(): FutureConfig;
|
| 733 | |
| 734 | |
| 735 | |
| 736 | |
| 737 | |
| 738 |
|
| 739 | get state(): RouterState;
|
| 740 | |
| 741 | |
| 742 | |
| 743 | |
| 744 | |
| 745 |
|
| 746 | get routes(): AgnosticDataRouteObject[];
|
| 747 | |
| 748 | |
| 749 | |
| 750 | |
| 751 | |
| 752 |
|
| 753 | get window(): RouterInit["window"];
|
| 754 | |
| 755 | |
| 756 | |
| 757 | |
| 758 | |
| 759 | |
| 760 | |
| 761 |
|
| 762 | initialize(): Router;
|
| 763 | |
| 764 | |
| 765 | |
| 766 | |
| 767 | |
| 768 | |
| 769 | |
| 770 |
|
| 771 | subscribe(fn: RouterSubscriber): () => void;
|
| 772 | |
| 773 | |
| 774 | |
| 775 | |
| 776 | |
| 777 | |
| 778 | |
| 779 | |
| 780 | |
| 781 | |
| 782 |
|
| 783 | enableScrollRestoration(savedScrollPositions: Record<string, number>, getScrollPosition: GetScrollPositionFunction, getKey?: GetScrollRestorationKeyFunction): () => void;
|
| 784 | |
| 785 | |
| 786 | |
| 787 | |
| 788 | |
| 789 | |
| 790 |
|
| 791 | navigate(to: number): Promise<void>;
|
| 792 | |
| 793 | |
| 794 | |
| 795 | |
| 796 |
|
| 797 | navigate(to: To | null, opts?: RouterNavigateOptions): Promise<void>;
|
| 798 | |
| 799 | |
| 800 | |
| 801 | |
| 802 | |
| 803 | |
| 804 | |
| 805 | |
| 806 | |
| 807 | |
| 808 |
|
| 809 | fetch(key: string, routeId: string, href: string | null, opts?: RouterFetchOptions): Promise<void>;
|
| 810 | |
| 811 | |
| 812 | |
| 813 | |
| 814 | |
| 815 |
|
| 816 | revalidate(): Promise<void>;
|
| 817 | |
| 818 | |
| 819 | |
| 820 | |
| 821 | |
| 822 | |
| 823 |
|
| 824 | createHref(location: Location | URL): string;
|
| 825 | |
| 826 | |
| 827 | |
| 828 | |
| 829 | |
| 830 | |
| 831 | |
| 832 |
|
| 833 | encodeLocation(to: To): Path;
|
| 834 | |
| 835 | |
| 836 | |
| 837 | |
| 838 | |
| 839 | |
| 840 |
|
| 841 | getFetcher<TData = any>(key: string): Fetcher<TData>;
|
| 842 | |
| 843 | |
| 844 | |
| 845 | |
| 846 | |
| 847 | |
| 848 |
|
| 849 | deleteFetcher(key: string): void;
|
| 850 | |
| 851 | |
| 852 | |
| 853 | |
| 854 | |
| 855 |
|
| 856 | dispose(): void;
|
| 857 | |
| 858 | |
| 859 | |
| 860 | |
| 861 | |
| 862 | |
| 863 | |
| 864 |
|
| 865 | getBlocker(key: string, fn: BlockerFunction): Blocker;
|
| 866 | |
| 867 | |
| 868 | |
| 869 | |
| 870 | |
| 871 | |
| 872 |
|
| 873 | deleteBlocker(key: string): void;
|
| 874 | |
| 875 | |
| 876 | |
| 877 | |
| 878 | |
| 879 | |
| 880 | |
| 881 | |
| 882 |
|
| 883 | patchRoutes(routeId: string | null, children: AgnosticRouteObject[]): void;
|
| 884 | |
| 885 | |
| 886 | |
| 887 | |
| 888 | |
| 889 | |
| 890 |
|
| 891 | _internalSetRoutes(routes: AgnosticRouteObject[]): void;
|
| 892 | |
| 893 | |
| 894 | |
| 895 | |
| 896 | |
| 897 |
|
| 898 | _internalFetchControllers: Map<string, AbortController>;
|
| 899 | }
|
| 900 | |
| 901 | |
| 902 | |
| 903 |
|
| 904 | interface RouterState {
|
| 905 | |
| 906 | |
| 907 |
|
| 908 | historyAction: Action;
|
| 909 | |
| 910 | |
| 911 |
|
| 912 | location: Location;
|
| 913 | |
| 914 | |
| 915 |
|
| 916 | matches: AgnosticDataRouteMatch[];
|
| 917 | |
| 918 | |
| 919 |
|
| 920 | initialized: boolean;
|
| 921 | |
| 922 | |
| 923 | |
| 924 | |
| 925 | |
| 926 |
|
| 927 | restoreScrollPosition: number | false | null;
|
| 928 | |
| 929 | |
| 930 | |
| 931 |
|
| 932 | preventScrollReset: boolean;
|
| 933 | |
| 934 | |
| 935 |
|
| 936 | navigation: Navigation;
|
| 937 | |
| 938 | |
| 939 |
|
| 940 | revalidation: RevalidationState;
|
| 941 | |
| 942 | |
| 943 |
|
| 944 | loaderData: RouteData;
|
| 945 | |
| 946 | |
| 947 |
|
| 948 | actionData: RouteData | null;
|
| 949 | |
| 950 | |
| 951 |
|
| 952 | errors: RouteData | null;
|
| 953 | |
| 954 | |
| 955 |
|
| 956 | fetchers: Map<string, Fetcher>;
|
| 957 | |
| 958 | |
| 959 |
|
| 960 | blockers: Map<string, Blocker>;
|
| 961 | }
|
| 962 | |
| 963 | |
| 964 |
|
| 965 | type HydrationState = Partial<Pick<RouterState, "loaderData" | "actionData" | "errors">>;
|
| 966 | |
| 967 | |
| 968 |
|
| 969 | interface FutureConfig {
|
| 970 | unstable_middleware: boolean;
|
| 971 | }
|
| 972 | |
| 973 | |
| 974 |
|
| 975 | interface RouterInit {
|
| 976 | routes: AgnosticRouteObject[];
|
| 977 | history: History;
|
| 978 | basename?: string;
|
| 979 | unstable_getContext?: () => MaybePromise<unstable_InitialContext>;
|
| 980 | mapRouteProperties?: MapRoutePropertiesFunction;
|
| 981 | future?: Partial<FutureConfig>;
|
| 982 | hydrationData?: HydrationState;
|
| 983 | window?: Window;
|
| 984 | dataStrategy?: DataStrategyFunction;
|
| 985 | patchRoutesOnNavigation?: AgnosticPatchRoutesOnNavigationFunction;
|
| 986 | }
|
| 987 | |
| 988 | |
| 989 |
|
| 990 | interface StaticHandlerContext {
|
| 991 | basename: Router["basename"];
|
| 992 | location: RouterState["location"];
|
| 993 | matches: RouterState["matches"];
|
| 994 | loaderData: RouterState["loaderData"];
|
| 995 | actionData: RouterState["actionData"];
|
| 996 | errors: RouterState["errors"];
|
| 997 | statusCode: number;
|
| 998 | loaderHeaders: Record<string, Headers>;
|
| 999 | actionHeaders: Record<string, Headers>;
|
| 1000 | _deepestRenderedBoundaryId?: string | null;
|
| 1001 | }
|
| 1002 | |
| 1003 | |
| 1004 |
|
| 1005 | interface StaticHandler {
|
| 1006 | dataRoutes: AgnosticDataRouteObject[];
|
| 1007 | query(request: Request, opts?: {
|
| 1008 | requestContext?: unknown;
|
| 1009 | filterMatchesToLoad?: (match: AgnosticDataRouteMatch) => boolean;
|
| 1010 | skipLoaderErrorBubbling?: boolean;
|
| 1011 | skipRevalidation?: boolean;
|
| 1012 | dataStrategy?: DataStrategyFunction<unknown>;
|
| 1013 | unstable_respond?: (staticContext: StaticHandlerContext) => MaybePromise<Response>;
|
| 1014 | }): Promise<StaticHandlerContext | Response>;
|
| 1015 | queryRoute(request: Request, opts?: {
|
| 1016 | routeId?: string;
|
| 1017 | requestContext?: unknown;
|
| 1018 | dataStrategy?: DataStrategyFunction<unknown>;
|
| 1019 | unstable_respond?: (res: Response) => MaybePromise<Response>;
|
| 1020 | }): Promise<any>;
|
| 1021 | }
|
| 1022 | type ViewTransitionOpts = {
|
| 1023 | currentLocation: Location;
|
| 1024 | nextLocation: Location;
|
| 1025 | };
|
| 1026 | |
| 1027 | |
| 1028 |
|
| 1029 | interface RouterSubscriber {
|
| 1030 | (state: RouterState, opts: {
|
| 1031 | deletedFetchers: string[];
|
| 1032 | viewTransitionOpts?: ViewTransitionOpts;
|
| 1033 | flushSync: boolean;
|
| 1034 | }): void;
|
| 1035 | }
|
| 1036 | |
| 1037 | |
| 1038 | |
| 1039 |
|
| 1040 | interface GetScrollRestorationKeyFunction {
|
| 1041 | (location: Location, matches: UIMatch[]): string | null;
|
| 1042 | }
|
| 1043 | |
| 1044 | |
| 1045 |
|
| 1046 | interface GetScrollPositionFunction {
|
| 1047 | (): number;
|
| 1048 | }
|
| 1049 | |
| 1050 | |
| 1051 | |
| 1052 |
|
| 1053 | type RelativeRoutingType = "route" | "path";
|
| 1054 | type BaseNavigateOrFetchOptions = {
|
| 1055 | preventScrollReset?: boolean;
|
| 1056 | relative?: RelativeRoutingType;
|
| 1057 | flushSync?: boolean;
|
| 1058 | };
|
| 1059 | type BaseNavigateOptions = BaseNavigateOrFetchOptions & {
|
| 1060 | replace?: boolean;
|
| 1061 | state?: any;
|
| 1062 | fromRouteId?: string;
|
| 1063 | viewTransition?: boolean;
|
| 1064 | };
|
| 1065 | type BaseSubmissionOptions = {
|
| 1066 | formMethod?: HTMLFormMethod;
|
| 1067 | formEncType?: FormEncType;
|
| 1068 | } & ({
|
| 1069 | formData: FormData;
|
| 1070 | body?: undefined;
|
| 1071 | } | {
|
| 1072 | formData?: undefined;
|
| 1073 | body: any;
|
| 1074 | });
|
| 1075 | |
| 1076 | |
| 1077 |
|
| 1078 | type LinkNavigateOptions = BaseNavigateOptions;
|
| 1079 | |
| 1080 | |
| 1081 |
|
| 1082 | type SubmissionNavigateOptions = BaseNavigateOptions & BaseSubmissionOptions;
|
| 1083 | |
| 1084 | |
| 1085 |
|
| 1086 | type RouterNavigateOptions = LinkNavigateOptions | SubmissionNavigateOptions;
|
| 1087 | |
| 1088 | |
| 1089 |
|
| 1090 | type LoadFetchOptions = BaseNavigateOrFetchOptions;
|
| 1091 | |
| 1092 | |
| 1093 |
|
| 1094 | type SubmitFetchOptions = BaseNavigateOrFetchOptions & BaseSubmissionOptions;
|
| 1095 | |
| 1096 | |
| 1097 |
|
| 1098 | type RouterFetchOptions = LoadFetchOptions | SubmitFetchOptions;
|
| 1099 | |
| 1100 | |
| 1101 |
|
| 1102 | type NavigationStates = {
|
| 1103 | Idle: {
|
| 1104 | state: "idle";
|
| 1105 | location: undefined;
|
| 1106 | formMethod: undefined;
|
| 1107 | formAction: undefined;
|
| 1108 | formEncType: undefined;
|
| 1109 | formData: undefined;
|
| 1110 | json: undefined;
|
| 1111 | text: undefined;
|
| 1112 | };
|
| 1113 | Loading: {
|
| 1114 | state: "loading";
|
| 1115 | location: Location;
|
| 1116 | formMethod: Submission["formMethod"] | undefined;
|
| 1117 | formAction: Submission["formAction"] | undefined;
|
| 1118 | formEncType: Submission["formEncType"] | undefined;
|
| 1119 | formData: Submission["formData"] | undefined;
|
| 1120 | json: Submission["json"] | undefined;
|
| 1121 | text: Submission["text"] | undefined;
|
| 1122 | };
|
| 1123 | Submitting: {
|
| 1124 | state: "submitting";
|
| 1125 | location: Location;
|
| 1126 | formMethod: Submission["formMethod"];
|
| 1127 | formAction: Submission["formAction"];
|
| 1128 | formEncType: Submission["formEncType"];
|
| 1129 | formData: Submission["formData"];
|
| 1130 | json: Submission["json"];
|
| 1131 | text: Submission["text"];
|
| 1132 | };
|
| 1133 | };
|
| 1134 | type Navigation = NavigationStates[keyof NavigationStates];
|
| 1135 | type RevalidationState = "idle" | "loading";
|
| 1136 | |
| 1137 | |
| 1138 |
|
| 1139 | type FetcherStates<TData = any> = {
|
| 1140 | |
| 1141 | |
| 1142 | |
| 1143 | |
| 1144 | |
| 1145 | |
| 1146 |
|
| 1147 | Idle: {
|
| 1148 | state: "idle";
|
| 1149 | formMethod: undefined;
|
| 1150 | formAction: undefined;
|
| 1151 | formEncType: undefined;
|
| 1152 | text: undefined;
|
| 1153 | formData: undefined;
|
| 1154 | json: undefined;
|
| 1155 | |
| 1156 | |
| 1157 |
|
| 1158 | data: TData | undefined;
|
| 1159 | };
|
| 1160 | |
| 1161 | |
| 1162 | |
| 1163 | |
| 1164 | |
| 1165 | |
| 1166 | |
| 1167 | |
| 1168 | |
| 1169 | |
| 1170 | |
| 1171 |
|
| 1172 | Loading: {
|
| 1173 | state: "loading";
|
| 1174 | formMethod: Submission["formMethod"] | undefined;
|
| 1175 | formAction: Submission["formAction"] | undefined;
|
| 1176 | formEncType: Submission["formEncType"] | undefined;
|
| 1177 | text: Submission["text"] | undefined;
|
| 1178 | formData: Submission["formData"] | undefined;
|
| 1179 | json: Submission["json"] | undefined;
|
| 1180 | data: TData | undefined;
|
| 1181 | };
|
| 1182 | |
| 1183 | |
| 1184 | |
| 1185 | |
| 1186 | |
| 1187 | |
| 1188 | |
| 1189 | |
| 1190 | |
| 1191 | |
| 1192 | |
| 1193 | |
| 1194 | |
| 1195 | |
| 1196 | |
| 1197 | |
| 1198 | |
| 1199 |
|
| 1200 | Submitting: {
|
| 1201 | state: "submitting";
|
| 1202 | formMethod: Submission["formMethod"];
|
| 1203 | formAction: Submission["formAction"];
|
| 1204 | formEncType: Submission["formEncType"];
|
| 1205 | text: Submission["text"];
|
| 1206 | formData: Submission["formData"];
|
| 1207 | json: Submission["json"];
|
| 1208 | data: TData | undefined;
|
| 1209 | };
|
| 1210 | };
|
| 1211 | type Fetcher<TData = any> = FetcherStates<TData>[keyof FetcherStates<TData>];
|
| 1212 | interface BlockerBlocked {
|
| 1213 | state: "blocked";
|
| 1214 | reset(): void;
|
| 1215 | proceed(): void;
|
| 1216 | location: Location;
|
| 1217 | }
|
| 1218 | interface BlockerUnblocked {
|
| 1219 | state: "unblocked";
|
| 1220 | reset: undefined;
|
| 1221 | proceed: undefined;
|
| 1222 | location: undefined;
|
| 1223 | }
|
| 1224 | interface BlockerProceeding {
|
| 1225 | state: "proceeding";
|
| 1226 | reset: undefined;
|
| 1227 | proceed: undefined;
|
| 1228 | location: Location;
|
| 1229 | }
|
| 1230 | type Blocker = BlockerUnblocked | BlockerBlocked | BlockerProceeding;
|
| 1231 | type BlockerFunction = (args: {
|
| 1232 | currentLocation: Location;
|
| 1233 | nextLocation: Location;
|
| 1234 | historyAction: Action;
|
| 1235 | }) => boolean;
|
| 1236 | declare const IDLE_NAVIGATION: NavigationStates["Idle"];
|
| 1237 | declare const IDLE_FETCHER: FetcherStates["Idle"];
|
| 1238 | declare const IDLE_BLOCKER: BlockerUnblocked;
|
| 1239 | |
| 1240 | |
| 1241 |
|
| 1242 | declare function createRouter(init: RouterInit): Router;
|
| 1243 | interface CreateStaticHandlerOptions {
|
| 1244 | basename?: string;
|
| 1245 | mapRouteProperties?: MapRoutePropertiesFunction;
|
| 1246 | future?: {};
|
| 1247 | }
|
| 1248 |
|
| 1249 | interface IndexRouteObject {
|
| 1250 | caseSensitive?: AgnosticIndexRouteObject["caseSensitive"];
|
| 1251 | path?: AgnosticIndexRouteObject["path"];
|
| 1252 | id?: AgnosticIndexRouteObject["id"];
|
| 1253 | unstable_middleware?: AgnosticIndexRouteObject["unstable_middleware"];
|
| 1254 | loader?: AgnosticIndexRouteObject["loader"];
|
| 1255 | action?: AgnosticIndexRouteObject["action"];
|
| 1256 | hasErrorBoundary?: AgnosticIndexRouteObject["hasErrorBoundary"];
|
| 1257 | shouldRevalidate?: AgnosticIndexRouteObject["shouldRevalidate"];
|
| 1258 | handle?: AgnosticIndexRouteObject["handle"];
|
| 1259 | index: true;
|
| 1260 | children?: undefined;
|
| 1261 | element?: React.ReactNode | null;
|
| 1262 | hydrateFallbackElement?: React.ReactNode | null;
|
| 1263 | errorElement?: React.ReactNode | null;
|
| 1264 | Component?: React.ComponentType | null;
|
| 1265 | HydrateFallback?: React.ComponentType | null;
|
| 1266 | ErrorBoundary?: React.ComponentType | null;
|
| 1267 | lazy?: LazyRouteFunction<RouteObject>;
|
| 1268 | }
|
| 1269 | interface NonIndexRouteObject {
|
| 1270 | caseSensitive?: AgnosticNonIndexRouteObject["caseSensitive"];
|
| 1271 | path?: AgnosticNonIndexRouteObject["path"];
|
| 1272 | id?: AgnosticNonIndexRouteObject["id"];
|
| 1273 | unstable_middleware?: AgnosticNonIndexRouteObject["unstable_middleware"];
|
| 1274 | loader?: AgnosticNonIndexRouteObject["loader"];
|
| 1275 | action?: AgnosticNonIndexRouteObject["action"];
|
| 1276 | hasErrorBoundary?: AgnosticNonIndexRouteObject["hasErrorBoundary"];
|
| 1277 | shouldRevalidate?: AgnosticNonIndexRouteObject["shouldRevalidate"];
|
| 1278 | handle?: AgnosticNonIndexRouteObject["handle"];
|
| 1279 | index?: false;
|
| 1280 | children?: RouteObject[];
|
| 1281 | element?: React.ReactNode | null;
|
| 1282 | hydrateFallbackElement?: React.ReactNode | null;
|
| 1283 | errorElement?: React.ReactNode | null;
|
| 1284 | Component?: React.ComponentType | null;
|
| 1285 | HydrateFallback?: React.ComponentType | null;
|
| 1286 | ErrorBoundary?: React.ComponentType | null;
|
| 1287 | lazy?: LazyRouteFunction<RouteObject>;
|
| 1288 | }
|
| 1289 | type RouteObject = IndexRouteObject | NonIndexRouteObject;
|
| 1290 | type DataRouteObject = RouteObject & {
|
| 1291 | children?: DataRouteObject[];
|
| 1292 | id: string;
|
| 1293 | };
|
| 1294 | interface RouteMatch<ParamKey extends string = string, RouteObjectType extends RouteObject = RouteObject> extends AgnosticRouteMatch<ParamKey, RouteObjectType> {
|
| 1295 | }
|
| 1296 | interface DataRouteMatch extends RouteMatch<string, DataRouteObject> {
|
| 1297 | }
|
| 1298 | type PatchRoutesOnNavigationFunctionArgs = AgnosticPatchRoutesOnNavigationFunctionArgs<RouteObject, RouteMatch>;
|
| 1299 | type PatchRoutesOnNavigationFunction = AgnosticPatchRoutesOnNavigationFunction<RouteObject, RouteMatch>;
|
| 1300 | interface DataRouterContextObject extends Omit<NavigationContextObject, "future"> {
|
| 1301 | router: Router;
|
| 1302 | staticContext?: StaticHandlerContext;
|
| 1303 | }
|
| 1304 | declare const DataRouterContext: React.Context<DataRouterContextObject | null>;
|
| 1305 | declare const DataRouterStateContext: React.Context<RouterState | null>;
|
| 1306 | type ViewTransitionContextObject = {
|
| 1307 | isTransitioning: false;
|
| 1308 | } | {
|
| 1309 | isTransitioning: true;
|
| 1310 | flushSync: boolean;
|
| 1311 | currentLocation: Location;
|
| 1312 | nextLocation: Location;
|
| 1313 | };
|
| 1314 | declare const ViewTransitionContext: React.Context<ViewTransitionContextObject>;
|
| 1315 | type FetchersContextObject = Map<string, any>;
|
| 1316 | declare const FetchersContext: React.Context<FetchersContextObject>;
|
| 1317 | interface NavigateOptions {
|
| 1318 |
|
| 1319 | replace?: boolean;
|
| 1320 |
|
| 1321 | state?: any;
|
| 1322 |
|
| 1323 | preventScrollReset?: boolean;
|
| 1324 |
|
| 1325 | relative?: RelativeRoutingType;
|
| 1326 |
|
| 1327 | flushSync?: boolean;
|
| 1328 |
|
| 1329 | viewTransition?: boolean;
|
| 1330 | }
|
| 1331 | |
| 1332 | |
| 1333 | |
| 1334 | |
| 1335 | |
| 1336 | |
| 1337 | |
| 1338 | |
| 1339 |
|
| 1340 | interface Navigator {
|
| 1341 | createHref: History["createHref"];
|
| 1342 | encodeLocation?: History["encodeLocation"];
|
| 1343 | go: History["go"];
|
| 1344 | push(to: To, state?: any, opts?: NavigateOptions): void;
|
| 1345 | replace(to: To, state?: any, opts?: NavigateOptions): void;
|
| 1346 | }
|
| 1347 | interface NavigationContextObject {
|
| 1348 | basename: string;
|
| 1349 | navigator: Navigator;
|
| 1350 | static: boolean;
|
| 1351 | future: {};
|
| 1352 | }
|
| 1353 | declare const NavigationContext: React.Context<NavigationContextObject>;
|
| 1354 | interface LocationContextObject {
|
| 1355 | location: Location;
|
| 1356 | navigationType: Action;
|
| 1357 | }
|
| 1358 | declare const LocationContext: React.Context<LocationContextObject>;
|
| 1359 | interface RouteContextObject {
|
| 1360 | outlet: React.ReactElement | null;
|
| 1361 | matches: RouteMatch[];
|
| 1362 | isDataRoute: boolean;
|
| 1363 | }
|
| 1364 | declare const RouteContext: React.Context<RouteContextObject>;
|
| 1365 |
|
| 1366 | type Primitive = null | undefined | string | number | boolean | symbol | bigint;
|
| 1367 | type LiteralUnion<LiteralType, BaseType extends Primitive> = LiteralType | (BaseType & Record<never, never>);
|
| 1368 | interface HtmlLinkProps {
|
| 1369 | |
| 1370 | |
| 1371 |
|
| 1372 | href?: string;
|
| 1373 | |
| 1374 | |
| 1375 |
|
| 1376 | crossOrigin?: "anonymous" | "use-credentials";
|
| 1377 | |
| 1378 | |
| 1379 |
|
| 1380 | rel: LiteralUnion<"alternate" | "dns-prefetch" | "icon" | "manifest" | "modulepreload" | "next" | "pingback" | "preconnect" | "prefetch" | "preload" | "prerender" | "search" | "stylesheet", string>;
|
| 1381 | |
| 1382 | |
| 1383 |
|
| 1384 | media?: string;
|
| 1385 | |
| 1386 | |
| 1387 |
|
| 1388 | integrity?: string;
|
| 1389 | |
| 1390 | |
| 1391 |
|
| 1392 | hrefLang?: string;
|
| 1393 | |
| 1394 | |
| 1395 |
|
| 1396 | type?: string;
|
| 1397 | |
| 1398 | |
| 1399 |
|
| 1400 | referrerPolicy?: "" | "no-referrer" | "no-referrer-when-downgrade" | "same-origin" | "origin" | "strict-origin" | "origin-when-cross-origin" | "strict-origin-when-cross-origin" | "unsafe-url";
|
| 1401 | |
| 1402 | |
| 1403 |
|
| 1404 | sizes?: string;
|
| 1405 | |
| 1406 | |
| 1407 |
|
| 1408 | as?: LiteralUnion<"audio" | "audioworklet" | "document" | "embed" | "fetch" | "font" | "frame" | "iframe" | "image" | "manifest" | "object" | "paintworklet" | "report" | "script" | "serviceworker" | "sharedworker" | "style" | "track" | "video" | "worker" | "xslt", string>;
|
| 1409 | |
| 1410 | |
| 1411 |
|
| 1412 | color?: string;
|
| 1413 | |
| 1414 | |
| 1415 |
|
| 1416 | disabled?: boolean;
|
| 1417 | |
| 1418 | |
| 1419 |
|
| 1420 | title?: string;
|
| 1421 | |
| 1422 | |
| 1423 | |
| 1424 |
|
| 1425 | imageSrcSet?: string;
|
| 1426 | |
| 1427 | |
| 1428 |
|
| 1429 | imageSizes?: string;
|
| 1430 | }
|
| 1431 | interface HtmlLinkPreloadImage extends HtmlLinkProps {
|
| 1432 | |
| 1433 | |
| 1434 |
|
| 1435 | rel: "preload";
|
| 1436 | |
| 1437 | |
| 1438 |
|
| 1439 | as: "image";
|
| 1440 | |
| 1441 | |
| 1442 |
|
| 1443 | href?: string;
|
| 1444 | |
| 1445 | |
| 1446 | |
| 1447 |
|
| 1448 | imageSrcSet: string;
|
| 1449 | |
| 1450 | |
| 1451 |
|
| 1452 | imageSizes?: string;
|
| 1453 | }
|
| 1454 | |
| 1455 | |
| 1456 | |
| 1457 | |
| 1458 |
|
| 1459 | type HtmlLinkDescriptor = (HtmlLinkProps & Pick<Required<HtmlLinkProps>, "href">) | (HtmlLinkPreloadImage & Pick<Required<HtmlLinkPreloadImage>, "imageSizes">) | (HtmlLinkPreloadImage & Pick<Required<HtmlLinkPreloadImage>, "href"> & {
|
| 1460 | imageSizes?: never;
|
| 1461 | });
|
| 1462 | interface PageLinkDescriptor extends Omit<HtmlLinkDescriptor, "href" | "rel" | "type" | "sizes" | "imageSrcSet" | "imageSizes" | "as" | "color" | "title"> {
|
| 1463 | |
| 1464 | |
| 1465 |
|
| 1466 | page: string;
|
| 1467 | }
|
| 1468 | type LinkDescriptor = HtmlLinkDescriptor | PageLinkDescriptor;
|
| 1469 |
|
| 1470 | interface RouteModules {
|
| 1471 | [routeId: string]: RouteModule | undefined;
|
| 1472 | }
|
| 1473 | |
| 1474 | |
| 1475 |
|
| 1476 | interface RouteModule {
|
| 1477 | clientAction?: ClientActionFunction;
|
| 1478 | clientLoader?: ClientLoaderFunction;
|
| 1479 | unstable_clientMiddleware?: unstable_MiddlewareFunction<undefined>[];
|
| 1480 | ErrorBoundary?: ErrorBoundaryComponent;
|
| 1481 | HydrateFallback?: HydrateFallbackComponent;
|
| 1482 | Layout?: LayoutComponent;
|
| 1483 | default: RouteComponent;
|
| 1484 | handle?: RouteHandle;
|
| 1485 | links?: LinksFunction;
|
| 1486 | meta?: MetaFunction;
|
| 1487 | shouldRevalidate?: ShouldRevalidateFunction;
|
| 1488 | }
|
| 1489 | |
| 1490 | |
| 1491 |
|
| 1492 | interface ServerRouteModule extends RouteModule {
|
| 1493 | action?: ActionFunction;
|
| 1494 | headers?: HeadersFunction | {
|
| 1495 | [name: string]: string;
|
| 1496 | };
|
| 1497 | loader?: LoaderFunction;
|
| 1498 | unstable_middleware?: unstable_MiddlewareFunction<Response>[];
|
| 1499 | }
|
| 1500 | |
| 1501 | |
| 1502 |
|
| 1503 | type ClientActionFunction = (args: ClientActionFunctionArgs) => ReturnType<ActionFunction>;
|
| 1504 | |
| 1505 | |
| 1506 |
|
| 1507 | type ClientActionFunctionArgs = ActionFunctionArgs & {
|
| 1508 | serverAction: <T = unknown>() => Promise<SerializeFrom<T>>;
|
| 1509 | };
|
| 1510 | |
| 1511 | |
| 1512 |
|
| 1513 | type ClientLoaderFunction = ((args: ClientLoaderFunctionArgs) => ReturnType<LoaderFunction>) & {
|
| 1514 | hydrate?: boolean;
|
| 1515 | };
|
| 1516 | /**
|
| 1517 | * Arguments passed to a route `clientLoader` function
|
| 1518 | */
|
| 1519 | type ClientLoaderFunctionArgs = LoaderFunctionArgs & {
|
| 1520 | serverLoader: <T = unknown>() => Promise<SerializeFrom<T>>;
|
| 1521 | };
|
| 1522 | |
| 1523 | |
| 1524 |
|
| 1525 | type ErrorBoundaryComponent = ComponentType;
|
| 1526 | type HeadersArgs = {
|
| 1527 | loaderHeaders: Headers;
|
| 1528 | parentHeaders: Headers;
|
| 1529 | actionHeaders: Headers;
|
| 1530 | errorHeaders: Headers | undefined;
|
| 1531 | };
|
| 1532 | |
| 1533 | |
| 1534 | |
| 1535 |
|
| 1536 | interface HeadersFunction {
|
| 1537 | (args: HeadersArgs): Headers | HeadersInit;
|
| 1538 | }
|
| 1539 | |
| 1540 | |
| 1541 | |
| 1542 |
|
| 1543 | type HydrateFallbackComponent = ComponentType;
|
| 1544 | |
| 1545 | |
| 1546 | |
| 1547 | |
| 1548 |
|
| 1549 | type LayoutComponent = ComponentType<{
|
| 1550 | children: ReactElement<unknown, ErrorBoundaryComponent | HydrateFallbackComponent | RouteComponent>;
|
| 1551 | }>;
|
| 1552 | |
| 1553 | |
| 1554 | |
| 1555 | |
| 1556 | |
| 1557 |
|
| 1558 | interface LinksFunction {
|
| 1559 | (): LinkDescriptor[];
|
| 1560 | }
|
| 1561 | interface MetaMatch<RouteId extends string = string, Loader extends LoaderFunction | ClientLoaderFunction | unknown = unknown> {
|
| 1562 | id: RouteId;
|
| 1563 | pathname: DataRouteMatch["pathname"];
|
| 1564 | data: Loader extends LoaderFunction | ClientLoaderFunction ? SerializeFrom<Loader> : unknown;
|
| 1565 | handle?: RouteHandle;
|
| 1566 | params: DataRouteMatch["params"];
|
| 1567 | meta: MetaDescriptor[];
|
| 1568 | error?: unknown;
|
| 1569 | }
|
| 1570 | type MetaMatches<MatchLoaders extends Record<string, LoaderFunction | ClientLoaderFunction | unknown> = Record<string, unknown>> = Array<{
|
| 1571 | [K in keyof MatchLoaders]: MetaMatch<Exclude<K, number | symbol>, MatchLoaders[K]>;
|
| 1572 | }[keyof MatchLoaders]>;
|
| 1573 | interface MetaArgs<Loader extends LoaderFunction | ClientLoaderFunction | unknown = unknown, MatchLoaders extends Record<string, LoaderFunction | ClientLoaderFunction | unknown> = Record<string, unknown>> {
|
| 1574 | data: (Loader extends LoaderFunction | ClientLoaderFunction ? SerializeFrom<Loader> : unknown) | undefined;
|
| 1575 | params: Params;
|
| 1576 | location: Location;
|
| 1577 | matches: MetaMatches<MatchLoaders>;
|
| 1578 | error?: unknown;
|
| 1579 | }
|
| 1580 | |
| 1581 | |
| 1582 | |
| 1583 | |
| 1584 | |
| 1585 | |
| 1586 | |
| 1587 | |
| 1588 | |
| 1589 | |
| 1590 | |
| 1591 | |
| 1592 | |
| 1593 | |
| 1594 | |
| 1595 | |
| 1596 | |
| 1597 | |
| 1598 | |
| 1599 | |
| 1600 | |
| 1601 | |
| 1602 | |
| 1603 | |
| 1604 | |
| 1605 | |
| 1606 | |
| 1607 | |
| 1608 | |
| 1609 | |
| 1610 | |
| 1611 | |
| 1612 | |
| 1613 | |
| 1614 | |
| 1615 | |
| 1616 | |
| 1617 | |
| 1618 | |
| 1619 | |
| 1620 | |
| 1621 | |
| 1622 | |
| 1623 | |
| 1624 | |
| 1625 | |
| 1626 | |
| 1627 | |
| 1628 | |
| 1629 |
|
| 1630 | interface MetaFunction<Loader extends LoaderFunction | ClientLoaderFunction | unknown = unknown, MatchLoaders extends Record<string, LoaderFunction | ClientLoaderFunction | unknown> = Record<string, unknown>> {
|
| 1631 | (args: MetaArgs<Loader, MatchLoaders>): MetaDescriptor[] | undefined;
|
| 1632 | }
|
| 1633 | type MetaDescriptor = {
|
| 1634 | charSet: "utf-8";
|
| 1635 | } | {
|
| 1636 | title: string;
|
| 1637 | } | {
|
| 1638 | name: string;
|
| 1639 | content: string;
|
| 1640 | } | {
|
| 1641 | property: string;
|
| 1642 | content: string;
|
| 1643 | } | {
|
| 1644 | httpEquiv: string;
|
| 1645 | content: string;
|
| 1646 | } | {
|
| 1647 | "script:ld+json": LdJsonObject;
|
| 1648 | } | {
|
| 1649 | tagName: "meta" | "link";
|
| 1650 | [name: string]: string;
|
| 1651 | } | {
|
| 1652 | [name: string]: unknown;
|
| 1653 | };
|
| 1654 | type LdJsonObject = {
|
| 1655 | [Key in string]: LdJsonValue;
|
| 1656 | } & {
|
| 1657 | [Key in string]?: LdJsonValue | undefined;
|
| 1658 | };
|
| 1659 | type LdJsonArray = LdJsonValue[] | readonly LdJsonValue[];
|
| 1660 | type LdJsonPrimitive = string | number | boolean | null;
|
| 1661 | type LdJsonValue = LdJsonPrimitive | LdJsonObject | LdJsonArray;
|
| 1662 | |
| 1663 | |
| 1664 |
|
| 1665 | type RouteComponent = ComponentType<{}>;
|
| 1666 | |
| 1667 | |
| 1668 | |
| 1669 | |
| 1670 |
|
| 1671 | type RouteHandle = unknown;
|
| 1672 |
|
| 1673 | type Serializable = undefined | null | boolean | string | symbol | number | Array<Serializable> | {
|
| 1674 | [key: PropertyKey]: Serializable;
|
| 1675 | } | bigint | Date | URL | RegExp | Error | Map<Serializable, Serializable> | Set<Serializable> | Promise<Serializable>;
|
| 1676 |
|
| 1677 | |
| 1678 | |
| 1679 | |
| 1680 | |
| 1681 | |
| 1682 |
|
| 1683 | type unstable_SerializesTo<T> = {
|
| 1684 | unstable__ReactRouter_SerializesTo: [T];
|
| 1685 | };
|
| 1686 |
|
| 1687 | type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends (<T>() => T extends Y ? 1 : 2) ? true : false;
|
| 1688 | type IsAny<T> = 0 extends 1 & T ? true : false;
|
| 1689 | type Func = (...args: any[]) => unknown;
|
| 1690 | type Pretty<T> = {
|
| 1691 | [K in keyof T]: T[K];
|
| 1692 | } & {};
|
| 1693 |
|
| 1694 | type Serialize<T> = T extends unstable_SerializesTo<infer To> ? To : T extends Serializable ? T : T extends (...args: any[]) => unknown ? undefined : T extends Promise<infer U> ? Promise<Serialize<U>> : T extends Map<infer K, infer V> ? Map<Serialize<K>, Serialize<V>> : T extends Set<infer U> ? Set<Serialize<U>> : T extends [] ? [] : T extends readonly [infer F, ...infer R] ? [Serialize<F>, ...Serialize<R>] : T extends Array<infer U> ? Array<Serialize<U>> : T extends readonly unknown[] ? readonly Serialize<T[number]>[] : T extends Record<any, any> ? {
|
| 1695 | [K in keyof T]: Serialize<T[K]>;
|
| 1696 | } : undefined;
|
| 1697 | type VoidToUndefined<T> = Equal<T, void> extends true ? undefined : T;
|
| 1698 | type DataFrom<T> = IsAny<T> extends true ? undefined : T extends Func ? VoidToUndefined<Awaited<ReturnType<T>>> : undefined;
|
| 1699 | type ClientData<T> = T extends Response ? never : T extends DataWithResponseInit<infer U> ? U : T;
|
| 1700 | type ServerData<T> = T extends Response ? never : T extends DataWithResponseInit<infer U> ? Serialize<U> : Serialize<T>;
|
| 1701 | type ServerDataFrom<T> = ServerData<DataFrom<T>>;
|
| 1702 | type ClientDataFrom<T> = ClientData<DataFrom<T>>;
|
| 1703 | type SerializeFrom<T> = T extends (...args: infer Args) => unknown ? Args extends [ClientLoaderFunctionArgs | ClientActionFunctionArgs] ? ClientDataFrom<T> : ServerDataFrom<T> : T;
|
| 1704 |
|
| 1705 | export { type FormEncType as $, type ActionFunctionArgs as A, type BlockerFunction as B, type CreateStaticHandlerOptions as C, type DataStrategyFunction as D, type Equal as E, type FutureConfig as F, type GetScrollPositionFunction as G, type HydrationState as H, type InitialEntry as I, type Fetcher as J, type NavigationStates as K, type LoaderFunctionArgs as L, type MetaFunction as M, type NavigateOptions as N, type RouterSubscriber as O, type ParamParseKey as P, type RouterNavigateOptions as Q, type RouterInit as R, type ServerRouteModule as S, type To as T, type UIMatch as U, type RouterFetchOptions as V, type DataStrategyFunctionArgs as W, type DataStrategyMatch as X, type DataStrategyResult as Y, DataWithResponseInit as Z, type ErrorResponse as _, type RouteModules as a, type FormMethod as a0, type HTMLFormMethod as a1, type LazyRouteFunction as a2, type unstable_MiddlewareFunction as a3, type PathParam as a4, type RedirectFunction as a5, type unstable_RouterContext as a6, type ShouldRevalidateFunction as a7, type ShouldRevalidateFunctionArgs as a8, unstable_createContext as a9, type MetaArgs as aA, type MetaDescriptor as aB, type PageLinkDescriptor as aC, type HtmlLinkDescriptor as aD, type LinkDescriptor as aE, type unstable_SerializesTo as aF, createBrowserHistory as aG, invariant as aH, createRouter as aI, ErrorResponseImpl as aJ, DataRouterContext as aK, DataRouterStateContext as aL, FetchersContext as aM, LocationContext as aN, NavigationContext as aO, RouteContext as aP, ViewTransitionContext as aQ, type RouteModule as aR, type History as aS, type ServerDataFrom as aT, type ClientDataFrom as aU, type Func as aV, type unstable_MiddlewareNextFunction as aW, type Pretty as aX, createPath as aa, parsePath as ab, IDLE_NAVIGATION as ac, IDLE_FETCHER as ad, IDLE_BLOCKER as ae, data as af, generatePath as ag, isRouteErrorResponse as ah, matchPath as ai, matchRoutes as aj, redirect as ak, redirectDocument as al, replace as am, resolvePath as an, type DataRouteMatch as ao, type DataRouteObject as ap, type Navigator as aq, type PatchRoutesOnNavigationFunction as ar, type PatchRoutesOnNavigationFunctionArgs as as, type RouteMatch as at, type ClientActionFunction as au, type ClientActionFunctionArgs as av, type ClientLoaderFunction as aw, type ClientLoaderFunctionArgs as ax, type HeadersArgs as ay, type HeadersFunction as az, type Router as b, type RouteManifest as c, type RelativeRoutingType as d, type Location as e, Action as f, type Path as g, type PathPattern as h, type PathMatch as i, type Params as j, type RouteObject as k, type Navigation as l, type RevalidationState as m, type SerializeFrom as n, type Blocker as o, type StaticHandlerContext as p, type StaticHandler as q, type unstable_InitialContext as r, type IndexRouteObject as s, type LoaderFunction as t, unstable_RouterContextProvider as u, type ActionFunction as v, type LinksFunction as w, type NonIndexRouteObject as x, type RouterState as y, type GetScrollRestorationKeyFunction as z };
|