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 |
|
1204 | replace?: boolean;
|
1205 |
|
1206 | state?: any;
|
1207 |
|
1208 | preventScrollReset?: boolean;
|
1209 |
|
1210 | relative?: RelativeRoutingType;
|
1211 |
|
1212 | flushSync?: boolean;
|
1213 |
|
1214 | viewTransition?: boolean;
|
1215 | }
|
1216 |
|
1217 |
|
1218 |
|
1219 |
|
1220 |
|
1221 |
|
1222 |
|
1223 |
|
1224 |
|
1225 | interface Navigator {
|
1226 | createHref: History["createHref"];
|
1227 | encodeLocation?: History["encodeLocation"];
|
1228 | go: History["go"];
|
1229 | push(to: To, state?: any, opts?: NavigateOptions): void;
|
1230 | replace(to: To, state?: any, opts?: NavigateOptions): void;
|
1231 | }
|
1232 | interface NavigationContextObject {
|
1233 | basename: string;
|
1234 | navigator: Navigator;
|
1235 | static: boolean;
|
1236 | future: {};
|
1237 | }
|
1238 | declare const NavigationContext: React.Context<NavigationContextObject>;
|
1239 | interface LocationContextObject {
|
1240 | location: Location;
|
1241 | navigationType: Action;
|
1242 | }
|
1243 | declare const LocationContext: React.Context<LocationContextObject>;
|
1244 | interface RouteContextObject {
|
1245 | outlet: React.ReactElement | null;
|
1246 | matches: RouteMatch[];
|
1247 | isDataRoute: boolean;
|
1248 | }
|
1249 | declare const RouteContext: React.Context<RouteContextObject>;
|
1250 |
|
1251 | type Primitive = null | undefined | string | number | boolean | symbol | bigint;
|
1252 | type LiteralUnion<LiteralType, BaseType extends Primitive> = LiteralType | (BaseType & Record<never, never>);
|
1253 | interface HtmlLinkProps {
|
1254 | |
1255 |
|
1256 |
|
1257 | href?: string;
|
1258 | |
1259 |
|
1260 |
|
1261 | crossOrigin?: "anonymous" | "use-credentials";
|
1262 | |
1263 |
|
1264 |
|
1265 | rel: LiteralUnion<"alternate" | "dns-prefetch" | "icon" | "manifest" | "modulepreload" | "next" | "pingback" | "preconnect" | "prefetch" | "preload" | "prerender" | "search" | "stylesheet", string>;
|
1266 | |
1267 |
|
1268 |
|
1269 | media?: string;
|
1270 | |
1271 |
|
1272 |
|
1273 | integrity?: string;
|
1274 | |
1275 |
|
1276 |
|
1277 | hrefLang?: string;
|
1278 | |
1279 |
|
1280 |
|
1281 | type?: string;
|
1282 | |
1283 |
|
1284 |
|
1285 | referrerPolicy?: "" | "no-referrer" | "no-referrer-when-downgrade" | "same-origin" | "origin" | "strict-origin" | "origin-when-cross-origin" | "strict-origin-when-cross-origin" | "unsafe-url";
|
1286 | |
1287 |
|
1288 |
|
1289 | sizes?: string;
|
1290 | |
1291 |
|
1292 |
|
1293 | as?: LiteralUnion<"audio" | "audioworklet" | "document" | "embed" | "fetch" | "font" | "frame" | "iframe" | "image" | "manifest" | "object" | "paintworklet" | "report" | "script" | "serviceworker" | "sharedworker" | "style" | "track" | "video" | "worker" | "xslt", string>;
|
1294 | |
1295 |
|
1296 |
|
1297 | color?: string;
|
1298 | |
1299 |
|
1300 |
|
1301 | disabled?: boolean;
|
1302 | |
1303 |
|
1304 |
|
1305 | title?: string;
|
1306 | |
1307 |
|
1308 |
|
1309 |
|
1310 | imageSrcSet?: string;
|
1311 | |
1312 |
|
1313 |
|
1314 | imageSizes?: string;
|
1315 | }
|
1316 | interface HtmlLinkPreloadImage extends HtmlLinkProps {
|
1317 | |
1318 |
|
1319 |
|
1320 | rel: "preload";
|
1321 | |
1322 |
|
1323 |
|
1324 | as: "image";
|
1325 | |
1326 |
|
1327 |
|
1328 | href?: string;
|
1329 | |
1330 |
|
1331 |
|
1332 |
|
1333 | imageSrcSet: string;
|
1334 | |
1335 |
|
1336 |
|
1337 | imageSizes?: string;
|
1338 | }
|
1339 |
|
1340 |
|
1341 |
|
1342 |
|
1343 |
|
1344 | type HtmlLinkDescriptor = (HtmlLinkProps & Pick<Required<HtmlLinkProps>, "href">) | (HtmlLinkPreloadImage & Pick<Required<HtmlLinkPreloadImage>, "imageSizes">) | (HtmlLinkPreloadImage & Pick<Required<HtmlLinkPreloadImage>, "href"> & {
|
1345 | imageSizes?: never;
|
1346 | });
|
1347 | interface PageLinkDescriptor extends Omit<HtmlLinkDescriptor, "href" | "rel" | "type" | "sizes" | "imageSrcSet" | "imageSizes" | "as" | "color" | "title"> {
|
1348 | |
1349 |
|
1350 |
|
1351 | page: string;
|
1352 | }
|
1353 | type LinkDescriptor = HtmlLinkDescriptor | PageLinkDescriptor;
|
1354 |
|
1355 | interface RouteModules {
|
1356 | [routeId: string]: RouteModule | undefined;
|
1357 | }
|
1358 |
|
1359 |
|
1360 |
|
1361 | interface RouteModule {
|
1362 | clientAction?: ClientActionFunction;
|
1363 | clientLoader?: ClientLoaderFunction;
|
1364 | ErrorBoundary?: ErrorBoundaryComponent;
|
1365 | HydrateFallback?: HydrateFallbackComponent;
|
1366 | Layout?: LayoutComponent;
|
1367 | default: RouteComponent;
|
1368 | handle?: RouteHandle;
|
1369 | links?: LinksFunction;
|
1370 | meta?: MetaFunction;
|
1371 | shouldRevalidate?: ShouldRevalidateFunction;
|
1372 | }
|
1373 |
|
1374 |
|
1375 |
|
1376 | interface ServerRouteModule extends RouteModule {
|
1377 | action?: ActionFunction;
|
1378 | headers?: HeadersFunction | {
|
1379 | [name: string]: string;
|
1380 | };
|
1381 | loader?: LoaderFunction;
|
1382 | }
|
1383 |
|
1384 |
|
1385 |
|
1386 | type ClientActionFunction = (args: ClientActionFunctionArgs) => ReturnType<ActionFunction>;
|
1387 |
|
1388 |
|
1389 |
|
1390 | type ClientActionFunctionArgs = ActionFunctionArgs<undefined> & {
|
1391 | serverAction: <T = unknown>() => Promise<SerializeFrom<T>>;
|
1392 | };
|
1393 |
|
1394 |
|
1395 |
|
1396 | type ClientLoaderFunction = ((args: ClientLoaderFunctionArgs) => ReturnType<LoaderFunction>) & {
|
1397 | hydrate?: boolean;
|
1398 | };
|
1399 | /**
|
1400 | * Arguments passed to a route `clientLoader` function
|
1401 | */
|
1402 | type ClientLoaderFunctionArgs = LoaderFunctionArgs<undefined> & {
|
1403 | serverLoader: <T = unknown>() => Promise<SerializeFrom<T>>;
|
1404 | };
|
1405 |
|
1406 |
|
1407 |
|
1408 | type ErrorBoundaryComponent = ComponentType;
|
1409 | type HeadersArgs = {
|
1410 | loaderHeaders: Headers;
|
1411 | parentHeaders: Headers;
|
1412 | actionHeaders: Headers;
|
1413 | errorHeaders: Headers | undefined;
|
1414 | };
|
1415 |
|
1416 |
|
1417 |
|
1418 |
|
1419 | interface HeadersFunction {
|
1420 | (args: HeadersArgs): Headers | HeadersInit;
|
1421 | }
|
1422 |
|
1423 |
|
1424 |
|
1425 |
|
1426 | type HydrateFallbackComponent = ComponentType;
|
1427 |
|
1428 |
|
1429 |
|
1430 |
|
1431 |
|
1432 | type LayoutComponent = ComponentType<{
|
1433 | children: ReactElement<unknown, ErrorBoundaryComponent | HydrateFallbackComponent | RouteComponent>;
|
1434 | }>;
|
1435 |
|
1436 |
|
1437 |
|
1438 |
|
1439 |
|
1440 |
|
1441 | interface LinksFunction {
|
1442 | (): LinkDescriptor[];
|
1443 | }
|
1444 | interface MetaMatch<RouteId extends string = string, Loader extends LoaderFunction | ClientLoaderFunction | unknown = unknown> {
|
1445 | id: RouteId;
|
1446 | pathname: DataRouteMatch["pathname"];
|
1447 | data: Loader extends LoaderFunction | ClientLoaderFunction ? SerializeFrom<Loader> : unknown;
|
1448 | handle?: RouteHandle;
|
1449 | params: DataRouteMatch["params"];
|
1450 | meta: MetaDescriptor[];
|
1451 | error?: unknown;
|
1452 | }
|
1453 | type MetaMatches<MatchLoaders extends Record<string, LoaderFunction | ClientLoaderFunction | unknown> = Record<string, unknown>> = Array<{
|
1454 | [K in keyof MatchLoaders]: MetaMatch<Exclude<K, number | symbol>, MatchLoaders[K]>;
|
1455 | }[keyof MatchLoaders]>;
|
1456 | interface MetaArgs<Loader extends LoaderFunction | ClientLoaderFunction | unknown = unknown, MatchLoaders extends Record<string, LoaderFunction | ClientLoaderFunction | unknown> = Record<string, unknown>> {
|
1457 | data: (Loader extends LoaderFunction | ClientLoaderFunction ? SerializeFrom<Loader> : unknown) | undefined;
|
1458 | params: Params;
|
1459 | location: Location;
|
1460 | matches: MetaMatches<MatchLoaders>;
|
1461 | error?: unknown;
|
1462 | }
|
1463 |
|
1464 |
|
1465 |
|
1466 |
|
1467 |
|
1468 |
|
1469 |
|
1470 |
|
1471 |
|
1472 |
|
1473 |
|
1474 |
|
1475 |
|
1476 |
|
1477 |
|
1478 |
|
1479 |
|
1480 |
|
1481 |
|
1482 |
|
1483 |
|
1484 |
|
1485 |
|
1486 |
|
1487 |
|
1488 |
|
1489 |
|
1490 |
|
1491 |
|
1492 |
|
1493 |
|
1494 |
|
1495 |
|
1496 |
|
1497 |
|
1498 |
|
1499 |
|
1500 |
|
1501 |
|
1502 |
|
1503 |
|
1504 |
|
1505 |
|
1506 |
|
1507 |
|
1508 |
|
1509 |
|
1510 |
|
1511 |
|
1512 |
|
1513 | interface MetaFunction<Loader extends LoaderFunction | ClientLoaderFunction | unknown = unknown, MatchLoaders extends Record<string, LoaderFunction | ClientLoaderFunction | unknown> = Record<string, unknown>> {
|
1514 | (args: MetaArgs<Loader, MatchLoaders>): MetaDescriptor[] | undefined;
|
1515 | }
|
1516 | type MetaDescriptor = {
|
1517 | charSet: "utf-8";
|
1518 | } | {
|
1519 | title: string;
|
1520 | } | {
|
1521 | name: string;
|
1522 | content: string;
|
1523 | } | {
|
1524 | property: string;
|
1525 | content: string;
|
1526 | } | {
|
1527 | httpEquiv: string;
|
1528 | content: string;
|
1529 | } | {
|
1530 | "script:ld+json": LdJsonObject;
|
1531 | } | {
|
1532 | tagName: "meta" | "link";
|
1533 | [name: string]: string;
|
1534 | } | {
|
1535 | [name: string]: unknown;
|
1536 | };
|
1537 | type LdJsonObject = {
|
1538 | [Key in string]: LdJsonValue;
|
1539 | } & {
|
1540 | [Key in string]?: LdJsonValue | undefined;
|
1541 | };
|
1542 | type LdJsonArray = LdJsonValue[] | readonly LdJsonValue[];
|
1543 | type LdJsonPrimitive = string | number | boolean | null;
|
1544 | type LdJsonValue = LdJsonPrimitive | LdJsonObject | LdJsonArray;
|
1545 |
|
1546 |
|
1547 |
|
1548 | type RouteComponent = ComponentType<{}>;
|
1549 |
|
1550 |
|
1551 |
|
1552 |
|
1553 |
|
1554 | type RouteHandle = unknown;
|
1555 |
|
1556 | type Serializable = undefined | null | boolean | string | symbol | number | Array<Serializable> | {
|
1557 | [key: PropertyKey]: Serializable;
|
1558 | } | bigint | Date | URL | RegExp | Error | Map<Serializable, Serializable> | Set<Serializable> | Promise<Serializable>;
|
1559 |
|
1560 | type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends (<T>() => T extends Y ? 1 : 2) ? true : false;
|
1561 | type IsAny<T> = 0 extends 1 & T ? true : false;
|
1562 | type Func = (...args: any[]) => unknown;
|
1563 | type Pretty<T> = {
|
1564 | [K in keyof T]: T[K];
|
1565 | } & {};
|
1566 |
|
1567 | 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> ? {
|
1568 | [K in keyof T]: Serialize<T[K]>;
|
1569 | } : undefined;
|
1570 | type VoidToUndefined<T> = Equal<T, void> extends true ? undefined : T;
|
1571 | type DataFrom<T> = IsAny<T> extends true ? undefined : T extends Func ? VoidToUndefined<Awaited<ReturnType<T>>> : undefined;
|
1572 | type ClientData<T> = T extends Response ? never : T extends DataWithResponseInit<infer U> ? U : T;
|
1573 | type ServerData<T> = T extends Response ? never : T extends DataWithResponseInit<infer U> ? Serialize<U> : Serialize<T>;
|
1574 | type ServerDataFrom<T> = ServerData<DataFrom<T>>;
|
1575 | type ClientDataFrom<T> = ClientData<DataFrom<T>>;
|
1576 | type SerializeFrom<T> = T extends (...args: infer Args) => unknown ? Args extends [ClientLoaderFunctionArgs | ClientActionFunctionArgs] ? ClientDataFrom<T> : ServerDataFrom<T> : T;
|
1577 |
|
1578 | export { type LazyRouteFunction as $, type ActionFunctionArgs as A, type BlockerFunction as B, type CreateStaticHandlerOptions as C, type DataStrategyFunction as D, type RouterSubscriber as E, type FutureConfig as F, type GetScrollPositionFunction as G, type HydrationState as H, type InitialEntry as I, type RouterNavigateOptions as J, type RouterFetchOptions as K, type LoaderFunctionArgs as L, type MetaFunction as M, type NavigateOptions as N, type DataStrategyFunctionArgs as O, type ParamParseKey as P, type DataStrategyMatch as Q, type RouteModules as R, type ServerRouteModule as S, type To as T, type UIMatch as U, type DataStrategyResult as V, DataWithResponseInit as W, type ErrorResponse as X, type FormEncType as Y, type FormMethod as Z, type HTMLFormMethod as _, type Router as a, type PathParam as a0, type RedirectFunction as a1, type ShouldRevalidateFunction as a2, type ShouldRevalidateFunctionArgs as a3, createPath as a4, parsePath as a5, IDLE_NAVIGATION as a6, IDLE_FETCHER as a7, IDLE_BLOCKER as a8, data as a9, invariant as aA, createRouter as aB, ErrorResponseImpl as aC, DataRouterContext as aD, DataRouterStateContext as aE, FetchersContext as aF, LocationContext as aG, NavigationContext as aH, RouteContext as aI, ViewTransitionContext as aJ, type RouteModule as aK, type History as aL, type ServerDataFrom as aM, type ClientDataFrom as aN, type Func as aO, type Equal as aP, type Pretty as aQ, generatePath as aa, isRouteErrorResponse as ab, matchPath as ac, matchRoutes as ad, redirect as ae, redirectDocument as af, replace as ag, resolvePath as ah, type DataRouteMatch as ai, type DataRouteObject as aj, type Navigator as ak, type PatchRoutesOnNavigationFunction as al, type PatchRoutesOnNavigationFunctionArgs as am, type RouteMatch as an, type ClientActionFunction as ao, type ClientActionFunctionArgs as ap, type ClientLoaderFunction as aq, type ClientLoaderFunctionArgs as ar, type HeadersArgs as as, type HeadersFunction as at, type MetaArgs as au, type MetaDescriptor as av, type PageLinkDescriptor as aw, type HtmlLinkDescriptor as ax, type LinkDescriptor as ay, createBrowserHistory as az, type RouteManifest as b, type RelativeRoutingType as c, type Location as d, Action as e, type Path as f, type PathPattern as g, type PathMatch as h, type Params as i, type RouteObject as j, type Navigation as k, type RevalidationState as l, type SerializeFrom as m, type Blocker as n, type StaticHandlerContext as o, type StaticHandler as p, type IndexRouteObject as q, type LoaderFunction as r, type ActionFunction as s, type LinksFunction as t, type NonIndexRouteObject as u, type RouterState as v, type GetScrollRestorationKeyFunction as w, type Fetcher as x, type NavigationStates as y, type RouterInit as z };
|