-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.d.ts
811 lines (685 loc) · 32.2 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
/// <reference path="./modules.d.ts" />
import { Component } from '@qwik.dev/core';
import { Cookie } from '@qwik.dev/router/middleware/request-handler';
import { CookieOptions } from '@qwik.dev/router/middleware/request-handler';
import { CookieValue } from '@qwik.dev/router/middleware/request-handler';
import { DeferReturn } from '@qwik.dev/router/middleware/request-handler';
import type { EnvGetter } from '@qwik.dev/router/middleware/request-handler';
import { JSXNode } from '@qwik.dev/core';
import { JSXOutput } from '@qwik.dev/core';
import { QRL } from '@qwik.dev/core';
import { QRLEventHandlerMulti } from '@qwik.dev/core';
import { QwikIntrinsicElements } from '@qwik.dev/core';
import { QwikJSX } from '@qwik.dev/core';
import type { ReadonlySignal } from '@qwik.dev/core';
import { RequestEvent } from '@qwik.dev/router/middleware/request-handler';
import { RequestEventAction } from '@qwik.dev/router/middleware/request-handler';
import { RequestEventBase } from '@qwik.dev/router/middleware/request-handler';
import { RequestEventCommon } from '@qwik.dev/router/middleware/request-handler';
import { RequestEventLoader } from '@qwik.dev/router/middleware/request-handler';
import { RequestHandler } from '@qwik.dev/router/middleware/request-handler';
import type { ResolveSyncValue } from '@qwik.dev/router/middleware/request-handler';
import type * as v from 'valibot';
import type { ValueOrPromise } from '@qwik.dev/core';
import { z } from 'zod';
import type * as z_2 from 'zod';
/** @public */
export declare type Action<RETURN, INPUT = Record<string, unknown>, OPTIONAL extends boolean = true> = {
/**
* Returns the `ActionStore` containing the current action state and methods to invoke it from a
* component$(). Like all `use-` functions and methods, it can only be invoked within a
* `component$()`.
*/
(): ActionStore<RETURN, INPUT, OPTIONAL>;
};
/** @public */
export declare type ActionConstructor = {
<OBJ extends Record<string, any> | void | null, VALIDATOR extends TypedDataValidator, REST extends [DataValidator, ...DataValidator[]]>(actionQrl: (data: GetValidatorOutputType<VALIDATOR>, event: RequestEventAction) => ValueOrPromise<OBJ>, options: {
readonly id?: string;
readonly validation: [VALIDATOR, ...REST];
}): Action<StrictUnion<OBJ | FailReturn<ValidatorErrorType<GetValidatorInputType<VALIDATOR>>> | FailReturn<FailOfRest<REST>>>, GetValidatorInputType<VALIDATOR>, false>;
<OBJ extends Record<string, any> | void | null, VALIDATOR extends TypedDataValidator>(actionQrl: (data: GetValidatorOutputType<VALIDATOR>, event: RequestEventAction) => ValueOrPromise<OBJ>, options: {
readonly id?: string;
readonly validation: [VALIDATOR];
}): Action<StrictUnion<OBJ | FailReturn<ValidatorErrorType<GetValidatorInputType<VALIDATOR>>>>, GetValidatorInputType<VALIDATOR>, false>;
<OBJ extends Record<string, any> | void | null, REST extends [DataValidator, ...DataValidator[]]>(actionQrl: (data: JSONObject, event: RequestEventAction) => ValueOrPromise<OBJ>, options: {
readonly id?: string;
readonly validation: REST;
}): Action<StrictUnion<OBJ | FailReturn<FailOfRest<REST>>>>;
<OBJ extends Record<string, any> | void | null, VALIDATOR extends TypedDataValidator, REST extends [DataValidator, ...DataValidator[]]>(actionQrl: (data: GetValidatorOutputType<VALIDATOR>, event: RequestEventAction) => ValueOrPromise<OBJ>, options: VALIDATOR, ...rest: REST): Action<StrictUnion<OBJ | FailReturn<ValidatorErrorType<GetValidatorInputType<VALIDATOR>>> | FailReturn<FailOfRest<REST>>>, GetValidatorInputType<VALIDATOR>, false>;
<OBJ extends Record<string, any> | void | null, VALIDATOR extends TypedDataValidator>(actionQrl: (data: GetValidatorOutputType<VALIDATOR>, event: RequestEventAction) => ValueOrPromise<OBJ>, options: VALIDATOR): Action<StrictUnion<OBJ | FailReturn<ValidatorErrorType<GetValidatorInputType<VALIDATOR>>>>, GetValidatorInputType<VALIDATOR>, false>;
<OBJ extends Record<string, any> | void | null, REST extends [DataValidator, ...DataValidator[]]>(actionQrl: (form: JSONObject, event: RequestEventAction) => ValueOrPromise<OBJ>, ...rest: REST): Action<StrictUnion<OBJ | FailReturn<FailOfRest<REST>>>>;
<OBJ>(actionQrl: (form: JSONObject, event: RequestEventAction) => ValueOrPromise<OBJ>, options?: {
readonly id?: string;
}): Action<StrictUnion<OBJ>>;
};
/** @public */
declare type ActionConstructorQRL = {
<OBJ extends Record<string, any> | void | null, VALIDATOR extends TypedDataValidator, REST extends [DataValidator, ...DataValidator[]]>(actionQrl: QRL<(data: GetValidatorOutputType<VALIDATOR>, event: RequestEventAction) => ValueOrPromise<OBJ>>, options: {
readonly id?: string;
readonly validation: [VALIDATOR, ...REST];
}): Action<StrictUnion<OBJ | FailReturn<ValidatorErrorType<GetValidatorInputType<VALIDATOR>>> | FailReturn<FailOfRest<REST>>>, GetValidatorInputType<VALIDATOR>, false>;
<OBJ extends Record<string, any> | void | null, VALIDATOR extends TypedDataValidator>(actionQrl: QRL<(data: GetValidatorOutputType<VALIDATOR>, event: RequestEventAction) => ValueOrPromise<OBJ>>, options: {
readonly id?: string;
readonly validation: [VALIDATOR];
}): Action<StrictUnion<OBJ | FailReturn<ValidatorErrorType<GetValidatorInputType<VALIDATOR>>>>, GetValidatorInputType<VALIDATOR>, false>;
<OBJ extends Record<string, any> | void | null, REST extends [DataValidator, ...DataValidator[]]>(actionQrl: QRL<(data: JSONObject, event: RequestEventAction) => ValueOrPromise<OBJ>>, options: {
readonly id?: string;
readonly validation: REST;
}): Action<StrictUnion<OBJ | FailReturn<FailOfRest<REST>>>>;
<OBJ extends Record<string, any> | void | null, VALIDATOR extends TypedDataValidator, REST extends [DataValidator, ...DataValidator[]]>(actionQrl: QRL<(data: GetValidatorOutputType<VALIDATOR>, event: RequestEventAction) => ValueOrPromise<OBJ>>, options: VALIDATOR, ...rest: REST): Action<StrictUnion<OBJ | FailReturn<ValidatorErrorType<GetValidatorInputType<VALIDATOR>>> | FailReturn<FailOfRest<REST>>>, GetValidatorInputType<VALIDATOR>, false>;
<OBJ extends Record<string, any> | void | null, VALIDATOR extends TypedDataValidator>(actionQrl: QRL<(data: GetValidatorOutputType<VALIDATOR>, event: RequestEventAction) => ValueOrPromise<OBJ>>, options: VALIDATOR): Action<StrictUnion<OBJ | FailReturn<ValidatorErrorType<GetValidatorInputType<VALIDATOR>>>>, GetValidatorInputType<VALIDATOR>, false>;
<OBJ extends Record<string, any> | void | null, REST extends [DataValidator, ...DataValidator[]]>(actionQrl: QRL<(form: JSONObject, event: RequestEventAction) => ValueOrPromise<OBJ>>, ...rest: REST): Action<StrictUnion<OBJ | FailReturn<FailOfRest<REST>>>>;
<OBJ>(actionQrl: QRL<(form: JSONObject, event: RequestEventAction) => ValueOrPromise<OBJ>>, options?: {
readonly id?: string;
}): Action<StrictUnion<OBJ>>;
};
/** @public */
export declare type ActionReturn<RETURN> = {
readonly status?: number;
readonly value: RETURN;
};
/** @public */
export declare type ActionStore<RETURN, INPUT, OPTIONAL extends boolean = true> = {
/**
* It's the "action" path that a native `<form>` should have in order to call the action.
*
* ```tsx
* <form action={action.actionPath} />
* ```
*
* Most of the time this property should not be used directly, instead use the `Form` component:
*
* ```tsx
* import {action$, Form} from '@qwik.dev/router';
*
* export const useAddUser = action$(() => { ... });
*
* export default component$(() => {
* const action = useAddUser();
* return (
* <Form action={action}/>
* );
* });
* ```
*/
readonly actionPath: string;
/**
* Reactive property that becomes `true` only in the browser, when a form is submitted and
* switched back to false when the action finish, ie, it describes if the action is actively
* running.
*
* This property is specially useful to disable the submit button while the action is processing,
* to prevent multiple submissions, and to inform visually to the user that the action is actively
* running.
*
* It will be always `false` in the server, and only becomes `true` briefly while the action is
* running.
*/
readonly isRunning: boolean;
/**
* Returned HTTP status code of the action after its last execution.
*
* It's `undefined` before the action is first called.
*/
readonly status?: number;
/**
* When calling an action through a `<form>`, this property contains the previously submitted
* `FormData`.
*
* This is useful to keep the filled form data even after a full page reload.
*
* It's `undefined` before the action is first called.
*/
readonly formData: FormData | undefined;
/**
* Returned successful data of the action. This reactive property will contain the data returned
* inside the `action$` function.
*
* It's `undefined` before the action is first called.
*/
readonly value: RETURN | undefined;
/**
* Method to execute the action programmatically from the browser. Ie, instead of using a
* `<form>`, a 'click' handle can call the `run()` method of the action in order to execute the
* action in the server.
*/
readonly submit: QRL<OPTIONAL extends true ? (form?: INPUT | FormData | SubmitEvent) => Promise<ActionReturn<RETURN>> : (form: INPUT | FormData | SubmitEvent) => Promise<ActionReturn<RETURN>>>;
/** Is action.submit was submitted */
readonly submitted: boolean;
};
declare type AnchorAttributes = QwikIntrinsicElements['a'];
/** @public */
export declare interface ContentHeading {
readonly text: string;
readonly id: string;
readonly level: number;
}
/** @public */
export declare interface ContentMenu {
readonly text: string;
readonly href?: string;
readonly items?: ContentMenu[];
}
declare type ContentModule = PageModule | LayoutModule;
declare type ContentModuleHead = DocumentHead | ResolvedDocumentHead;
declare type ContentModuleLoader = () => Promise<ContentModule>;
/** @public */
declare interface ContentState {
readonly headings: ContentHeading[] | undefined;
readonly menu: ContentMenu | undefined;
}
export { Cookie }
export { CookieOptions }
export { CookieValue }
/** @public */
export declare type DataValidator<T extends Record<string, any> = {}> = {
validate(ev: RequestEvent, data: unknown): Promise<ValidatorReturn<T>>;
};
export { DeferReturn }
/** @public */
export declare type DocumentHead = DocumentHeadValue | ((props: DocumentHeadProps) => DocumentHeadValue);
/** @public */
export declare interface DocumentHeadProps extends RouteLocation {
readonly head: ResolvedDocumentHead;
readonly withLocale: <T>(fn: () => T) => T;
readonly resolveValue: ResolveSyncValue;
}
/** @public */
export declare interface DocumentHeadValue<FrontMatter extends Record<string, any> = Record<string, unknown>> {
/** Sets `document.title`. */
readonly title?: string;
/**
* Used to manually set meta tags in the head. Additionally, the `data` property could be used to
* set arbitrary data which the `<head>` component could later use to generate `<meta>` tags.
*/
readonly meta?: readonly DocumentMeta[];
/** Used to manually append `<link>` elements to the `<head>`. */
readonly links?: readonly DocumentLink[];
/** Used to manually append `<style>` elements to the `<head>`. */
readonly styles?: readonly DocumentStyle[];
/** Used to manually append `<script>` elements to the `<head>`. */
readonly scripts?: readonly DocumentScript[];
/**
* Arbitrary object containing custom data. When the document head is created from markdown files,
* the frontmatter attributes that are not recognized as a well-known meta names (such as title,
* description, author, etc...), are stored in this property.
*/
readonly frontmatter?: Readonly<FrontMatter>;
}
/** @public */
export declare interface DocumentLink {
as?: string;
crossorigin?: string;
disabled?: boolean;
href?: string;
hreflang?: string;
id?: string;
imagesizes?: string;
imagesrcset?: string;
integrity?: string;
media?: string;
prefetch?: string;
referrerpolicy?: string;
rel?: string;
sizes?: string;
title?: string;
type?: string;
key?: string;
}
/** @public */
export declare interface DocumentMeta {
readonly content?: string;
readonly httpEquiv?: string;
readonly name?: string;
readonly property?: string;
readonly key?: string;
readonly itemprop?: string;
readonly media?: string;
}
/** @alpha */
export declare interface DocumentScript {
readonly script?: string;
readonly props?: Readonly<QwikIntrinsicElements['script']>;
readonly key?: string;
}
/** @public */
export declare interface DocumentStyle {
readonly style: string;
readonly props?: Readonly<QwikIntrinsicElements['style']>;
readonly key?: string;
}
declare type EndpointModuleLoader = () => Promise<RouteModule>;
declare type Failed = {
failed: true;
};
/** @public */
export declare type FailOfRest<REST extends readonly DataValidator[]> = REST extends readonly DataValidator<infer ERROR>[] ? ERROR : never;
/** @public */
export declare type FailReturn<T> = T & Failed;
/** @public */
export declare const Form: <O, I>({ action, spaReset, reloadDocument, onSubmit$, ...rest }: FormProps<O, I>, key: string | null) => JSXOutput;
/** @public */
export declare interface FormProps<O, I> extends Omit<QwikJSX.IntrinsicElements['form'], 'action' | 'method'> {
/** Reference to the action returned by `action()`. */
action?: ActionStore<O, I, true | false>;
/**
* When `true` the form submission will cause a full page reload, even if SPA mode is enabled and
* JS is available.
*/
reloadDocument?: boolean;
/**
* When `true` all the form inputs will be reset in SPA mode, just like happens in a full page
* form submission.
*
* Defaults to `false`
*/
spaReset?: boolean;
/** Event handler executed right when the form is submitted. */
onSubmit$?: QRLEventHandlerMulti<SubmitEvent, HTMLFormElement> | undefined;
/** Event handler executed right after the action is executed successfully and returns some data. */
onSubmitCompleted$?: QRLEventHandlerMulti<CustomEvent<FormSubmitSuccessDetail<O>>, HTMLFormElement> | undefined;
key?: string | number | null;
}
/** @public */
export declare interface FormSubmitSuccessDetail<T> {
status: number;
value: T;
}
/** @public */
export declare type GetValidatorInputType<VALIDATOR extends TypedDataValidator> = VALIDATOR extends ValibotDataValidator<infer TYPE> ? v.InferInput<TYPE> : VALIDATOR extends ZodDataValidator<infer TYPE> ? z_2.input<TYPE> : never;
/** @public */
export declare type GetValidatorOutputType<VALIDATOR extends TypedDataValidator> = VALIDATOR extends ValibotDataValidator<infer TYPE> ? v.InferOutput<TYPE> : VALIDATOR extends ZodDataValidator<infer TYPE> ? z_2.output<TYPE> : never;
/** @public */
export declare type GetValidatorType<VALIDATOR extends TypedDataValidator> = GetValidatorOutputType<VALIDATOR>;
/** @public */
export declare const globalAction$: ActionConstructor;
/** @public */
export declare const globalActionQrl: ActionConstructorQRL;
declare type IsAny<Type> = 0 extends 1 & Type ? true : false;
/** @public */
export declare type JSONObject = {
[x: string]: JSONValue;
};
/** @public */
export declare type JSONValue = string | number | boolean | {
[x: string]: JSONValue;
} | Array<JSONValue>;
declare interface LayoutModule extends RouteModule {
readonly default: unknown;
readonly head?: ContentModuleHead;
}
/** @public */
export declare const Link: Component<LinkProps>;
/** @public */
export declare interface LinkProps extends AnchorAttributes {
/**
* **Defaults to _true_.**
*
* Whether Qwik should prefetch and cache the target page of this **`Link`**, this includes
* invoking any **`routeLoader$`**, **`onGet`**, etc.
*
* This **improves UX performance** for client-side (**SPA**) navigations.
*
* Prefetching occurs when a the Link enters the viewport in production (**`on:qvisibile`**), or
* with **`mouseover`/`focus`** during dev.
*
* Prefetching will not occur if the user has the **data saver** setting enabled.
*
* Setting this value to **`"js"`** will prefetch only javascript bundles required to render this
* page on the client, **`false`** will disable prefetching altogether.
*/
prefetch?: boolean | 'js';
reload?: boolean;
replaceState?: boolean;
scroll?: boolean;
}
/** @public */
declare type Loader_2<RETURN> = {
/**
* Returns the `Signal` containing the data returned by the `loader$` function. Like all `use-`
* functions and methods, it can only be invoked within a `component$()`.
*/
(): LoaderSignal<RETURN>;
};
export { Loader_2 as Loader }
/** @public */
declare type LoaderConstructor = {
<OBJ>(loaderFn: (event: RequestEventLoader) => ValueOrPromise<OBJ>, options?: LoaderOptions): Loader_2<[Extract<OBJ, Failed>] extends [never] ? OBJ : StrictUnion<OBJ>>;
<OBJ extends Record<string, any> | void | null, REST extends readonly DataValidator[]>(loaderFn: (event: RequestEventLoader) => ValueOrPromise<OBJ>, ...rest: REST): Loader_2<StrictUnion<OBJ | FailReturn<FailOfRest<REST>>>>;
};
/** @public */
declare type LoaderConstructorQRL = {
<OBJ>(loaderQrl: QRL<(event: RequestEventLoader) => ValueOrPromise<OBJ>>, options?: LoaderOptions): Loader_2<[Extract<OBJ, Failed>] extends [never] ? OBJ : StrictUnion<OBJ>>;
<OBJ extends Record<string, any> | void | null, REST extends readonly DataValidator[]>(loaderQrl: QRL<(event: RequestEventLoader) => ValueOrPromise<OBJ>>, ...rest: REST): Loader_2<StrictUnion<OBJ | FailReturn<FailOfRest<REST>>>>;
};
/** @public */
declare type LoaderOptions = {
id?: string;
};
/** @public */
export declare type LoaderSignal<TYPE> = TYPE extends () => ValueOrPromise<infer VALIDATOR> ? ReadonlySignal<ValueOrPromise<VALIDATOR>> : ReadonlySignal<TYPE>;
/** @public */
export declare type MenuData = [pathname: string, menuLoader: MenuModuleLoader];
declare interface MenuModule {
readonly default: ContentMenu;
}
declare type MenuModuleLoader = () => Promise<MenuModule>;
declare type ModuleLoader = ContentModuleLoader | EndpointModuleLoader;
/** @public */
export declare type NavigationType = 'initial' | 'form' | 'link' | 'popstate';
/**
* Creates a new object from `obj` by omitting a set of `keys`.
*
* @alpha
* @experimental
*/
export declare function omitProps<T, KEYS extends keyof T>(obj: T, keys: KEYS[]): Omit<T, KEYS>;
/** @public */
export declare interface PageModule extends RouteModule {
readonly default: unknown;
readonly head?: ContentModuleHead;
readonly headings?: ContentHeading[];
readonly onStaticGenerate?: StaticGenerateHandler;
}
/** @public */
export declare type PathParams = Record<string, string>;
declare type Prettify<T> = {} & {
[K in keyof T]: T[K];
};
/**
* @param url - The URL that the user is trying to navigate to, or a number to indicate the user is
* trying to navigate back/forward in the application history. If it is missing, the event is sent
* by the browser and the user is trying to reload or navigate away from the page. In this case,
* the function should decide the answer synchronously.
* @returns `true` to prevent navigation, `false` to allow navigation, or a Promise that resolves to
* `true` or `false`. For browser events, returning `true` or a Promise may show a confirmation
* dialog, at the browser's discretion. If the user confirms, the navigation will still be
* allowed.
* @public
*/
export declare type PreventNavigateCallback = (url?: number | URL) => ValueOrPromise<boolean>;
/**
* @deprecated Use `QWIK_ROUTER_SCROLLER` instead (will be removed in V3)
* @public
*/
export declare const QWIK_CITY_SCROLLER = "_qCityScroller";
/** @public */
export declare const QWIK_ROUTER_SCROLLER = "_qRouterScroller";
/**
* @deprecated Use `QwikRouterMockProps` instead. will be removed in V3
* @public
*/
export declare type QwikCityMockProps = QwikRouterMockProps;
/**
* @deprecated Use `QwikRouterMockProvider` instead. Will be removed in V3
* @public
*/
export declare const QwikCityMockProvider: Component<QwikRouterMockProps>;
/**
* @deprecated Use `QwikRouterConfig` instead. Will be removed in V3.
* @public
*/
export declare type QwikCityPlan = QwikRouterConfig;
/**
* @deprecated Use `QwikRouterProps` instead. will be removed in V3
* @public
*/
export declare type QwikCityProps = QwikRouterProps;
/**
* @deprecated Use `QwikRouterProvider` instead. will be removed in V3
* @public
*/
export declare const QwikCityProvider: Component<QwikRouterProps>;
/** @public */
export declare interface QwikRouterConfig {
readonly routes: RouteData[];
readonly serverPlugins?: RouteModule[];
readonly basePathname?: string;
readonly menus?: MenuData[];
readonly trailingSlash?: boolean;
readonly cacheModules?: boolean;
}
/** @public */
export declare interface QwikRouterMockProps {
url?: string;
params?: Record<string, string>;
goto?: RouteNavigate;
}
/** @public */
export declare const QwikRouterMockProvider: Component<QwikRouterMockProps>;
/** @public */
export declare interface QwikRouterProps {
/**
* Enable the ViewTransition API
*
* Default: `true`
*
* @see https://github.com/WICG/view-transitions/blob/main/explainer.md
* @see https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API
* @see https://caniuse.com/mdn-api_viewtransition
*/
viewTransition?: boolean;
}
/** @public */
export declare const QwikRouterProvider: Component<QwikRouterProps>;
export { RequestEvent }
export { RequestEventAction }
export { RequestEventBase }
export { RequestEventCommon }
export { RequestEventLoader }
export { RequestHandler }
/** @public */
export declare type ResolvedDocumentHead<FrontMatter extends Record<string, any> = Record<string, unknown>> = Required<DocumentHeadValue<FrontMatter>>;
/** @public */
export declare const routeAction$: ActionConstructor;
/** @public */
export declare const routeActionQrl: ActionConstructorQRL;
/** @public */
export declare type RouteData = [routeName: string, loaders: ModuleLoader[]] | [
routeName: string,
loaders: ModuleLoader[],
originalPathname: string,
routeBundleNames: string[]
];
/** @public */
export declare const routeLoader$: LoaderConstructor;
/** @public */
export declare const routeLoaderQrl: LoaderConstructorQRL;
/** @public */
export declare interface RouteLocation {
readonly params: Readonly<Record<string, string>>;
readonly url: URL;
readonly isNavigating: boolean;
readonly prevUrl: URL | undefined;
}
declare interface RouteModule<BODY = unknown> {
onDelete?: RequestHandler<BODY> | RequestHandler<BODY>[];
onGet?: RequestHandler<BODY> | RequestHandler<BODY>[];
onHead?: RequestHandler<BODY> | RequestHandler<BODY>[];
onOptions?: RequestHandler<BODY> | RequestHandler<BODY>[];
onPatch?: RequestHandler<BODY> | RequestHandler<BODY>[];
onPost?: RequestHandler<BODY> | RequestHandler<BODY>[];
onPut?: RequestHandler<BODY> | RequestHandler<BODY>[];
onRequest?: RequestHandler<BODY> | RequestHandler<BODY>[];
}
/** @public */
export declare type RouteNavigate = QRL<(path?: string | number | URL, options?: {
type?: Exclude<NavigationType, 'initial'>;
forceReload?: boolean;
replaceState?: boolean;
scroll?: boolean;
} | boolean) => Promise<void>>;
/** @public */
export declare const RouterOutlet: Component<unknown>;
/** @public */
export declare const server$: <T extends ServerFunction>(qrl: T, options?: ServerConfig | undefined) => ServerQRL<T>;
/** @public */
declare interface ServerConfig {
origin?: string;
method?: 'get' | 'post';
headers?: Record<string, string>;
fetchOptions?: any;
}
/** @public */
export declare type ServerFunction = {
(this: RequestEventBase, ...args: any[]): any;
options?: ServerConfig;
};
/**
* You can pass an AbortSignal as the first argument of a `server$` function and it will use it to
* abort the fetch when fired.
*
* @public
*/
export declare type ServerQRL<T extends ServerFunction> = QRL<((abort: AbortSignal, ...args: Parameters<T>) => ReturnType<T>) | ((...args: Parameters<T>) => ReturnType<T>)>;
/** @public */
export declare const serverQrl: <T extends ServerFunction>(qrl: QRL<T>, options?: ServerConfig) => ServerQRL<T>;
/** @public */
export declare const ServiceWorkerRegister: (props: {
nonce?: string;
}) => JSXNode<"script">;
/** @public */
export declare interface StaticGenerate {
params?: PathParams[];
}
/** @public */
export declare type StaticGenerateHandler = ({ env, }: {
env: EnvGetter;
}) => Promise<StaticGenerate> | StaticGenerate;
/** @public */
export declare type StrictUnion<T> = Prettify<StrictUnionHelper<T, T>>;
declare type StrictUnionHelper<T, TAll> = T extends any ? T & Partial<Record<Exclude<UnionKeys<TAll>, keyof T>, never>> : never;
/** @public */
export declare type TypedDataValidator = ValibotDataValidator | ZodDataValidator;
declare type UnionKeys<T> = T extends T ? keyof T : never;
/**
* @alpha
* @experimental
*/
export declare const untypedAppUrl: (route: string, params?: Record<string, string>, paramsPrefix?: string) => string;
/** @public */
export declare const useContent: () => ContentState;
/**
* Returns the document head for the current page. The generic type describes the front matter.
*
* @public
*/
export declare const useDocumentHead: <FrontMatter extends Record<string, unknown> = Record<string, any>>() => Required<ResolvedDocumentHead<FrontMatter>>;
/** @public */
export declare const useLocation: () => RouteLocation;
/** @public */
export declare const useNavigate: () => RouteNavigate;
/**
* Prevent navigation attempts. This hook registers a callback that will be called before SPA or
* browser navigation.
*
* Return `true` to prevent navigation.
*
* #### SPA Navigation
*
* For Single-Page-App (SPA) navigation (via `<Link />`, `const nav = useNavigate()`, and browser
* backwards/forwards inside SPA history), the callback will be provided with the target, either a
* URL or a number. It will only be a number if `nav(number)` was called to navigate forwards or
* backwards in SPA history.
*
* If you return a Promise, the navigation will be blocked until the promise resolves.
*
* This can be used to show a nice dialog to the user, and wait for the user to confirm, or to
* record the url, prevent the navigation, and navigate there later via `nav(url)`.
*
* #### Browser Navigation
*
* However, when the user navigates away by clicking on a regular `<a />`, reloading, or moving
* backwards/forwards outside SPA history, this callback will not be awaited. This is because the
* browser does not provide a way to asynchronously prevent these navigations.
*
* In this case, returning returning `true` will tell the browser to show a confirmation dialog,
* which cannot be customized. You are also not able to show your own `window.confirm()` dialog
* during the callback, the browser won't allow it. If you return a Promise, it will be considered
* as `true`.
*
* When the callback is called from the browser, no url will be provided. Use this to know whether
* you can show a dialog or just return `true` to prevent the navigation.
*
* @public
*/
export declare const usePreventNavigate$: (qrl: PreventNavigateCallback) => void;
/** @internal Implementation of usePreventNavigate$ */
export declare const usePreventNavigateQrl: (fn: QRL<PreventNavigateCallback>) => void;
/** @alpha */
export declare const valibot$: ValibotConstructor;
/** @alpha */
declare type ValibotConstructor = {
<T extends v.GenericSchema | v.GenericSchemaAsync>(schema: T): ValibotDataValidator<T>;
<T extends v.GenericSchema | v.GenericSchemaAsync>(schema: (ev: RequestEvent) => T): ValibotDataValidator<T>;
};
/** @alpha */
declare type ValibotConstructorQRL = {
<T extends v.GenericSchema | v.GenericSchemaAsync>(schema: QRL<T>): ValibotDataValidator<T>;
<T extends v.GenericSchema | v.GenericSchemaAsync>(schema: QRL<(ev: RequestEvent) => T>): ValibotDataValidator<T>;
};
/** @alpha */
declare type ValibotDataValidator<T extends v.GenericSchema | v.GenericSchemaAsync = v.GenericSchema | v.GenericSchemaAsync> = {
readonly __brand: 'valibot';
validate(ev: RequestEvent, data: unknown): Promise<ValidatorReturn<ValidatorErrorType<v.InferInput<T>>>>;
};
/** @alpha */
export declare const valibotQrl: ValibotConstructorQRL;
/** @public */
export declare const validator$: ValidatorConstructor;
declare type ValidatorConstructor = {
<T extends ValidatorReturn>(validator: (ev: RequestEvent, data: unknown) => ValueOrPromise<T>): T extends ValidatorReturnFail<infer ERROR> ? DataValidator<ERROR> : DataValidator<never>;
};
declare type ValidatorConstructorQRL = {
<T extends ValidatorReturn>(validator: QRL<(ev: RequestEvent, data: unknown) => ValueOrPromise<T>>): T extends ValidatorReturnFail<infer ERROR> ? DataValidator<ERROR> : DataValidator<never>;
};
/** @public */
export declare type ValidatorErrorKeyDotNotation<T, Prefix extends string = ''> = IsAny<T> extends true ? never : T extends object ? {
[K in keyof T & string]: IsAny<T[K]> extends true ? never : T[K] extends (infer U)[] ? IsAny<U> extends true ? never : U extends object ? `${Prefix}${K}[]` | ValidatorErrorKeyDotNotation<U, `${Prefix}${K}[].`> : `${Prefix}${K}[]` : T[K] extends object ? ValidatorErrorKeyDotNotation<T[K], `${Prefix}${K}.`> : `${Prefix}${K}`;
}[keyof T & string] : never;
/** @public */
export declare type ValidatorErrorType<T, U = string> = {
formErrors: U[];
fieldErrors: Partial<{
[K in ValidatorErrorKeyDotNotation<T>]: K extends `${infer _Prefix}[]${infer _Suffix}` ? U[] : U;
}>;
};
/** @public */
export declare const validatorQrl: ValidatorConstructorQRL;
/** @public */
export declare type ValidatorReturn<T extends Record<string, any> = {}> = ValidatorReturnSuccess | ValidatorReturnFail<T>;
declare type ValidatorReturnFail<T extends Record<string, any> = {}> = {
readonly success: false;
readonly error: T;
readonly status?: number;
};
declare type ValidatorReturnSuccess = {
readonly success: true;
readonly data?: unknown;
};
export { z }
/** @public */
export declare const zod$: ZodConstructor;
/** @public */
export declare type ZodConstructor = {
<T extends z_2.ZodRawShape>(schema: T): ZodDataValidator<z_2.ZodObject<T>>;
<T extends z_2.ZodRawShape>(schema: (zod: typeof z_2.z, ev: RequestEvent) => T): ZodDataValidator<z_2.ZodObject<T>>;
<T extends z_2.Schema>(schema: T): ZodDataValidator<T>;
<T extends z_2.Schema>(schema: (zod: typeof z_2.z, ev: RequestEvent) => T): ZodDataValidator<T>;
};
/** @public */
declare type ZodConstructorQRL = {
<T extends z_2.ZodRawShape>(schema: QRL<T>): ZodDataValidator<z_2.ZodObject<T>>;
<T extends z_2.ZodRawShape>(schema: QRL<(zod: typeof z_2.z, ev: RequestEvent) => T>): ZodDataValidator<z_2.ZodObject<T>>;
<T extends z_2.Schema>(schema: QRL<T>): ZodDataValidator<T>;
<T extends z_2.Schema>(schema: QRL<(zod: typeof z_2.z, ev: RequestEvent) => T>): ZodDataValidator<T>;
};
/** @public */
declare type ZodDataValidator<T extends z_2.ZodType = z_2.ZodType> = {
readonly __brand: 'zod';
validate(ev: RequestEvent, data: unknown): Promise<ValidatorReturn<ValidatorErrorType<z_2.input<T>>>>;
};
/** @public */
export declare const zodQrl: ZodConstructorQRL;
export { }