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