yvee 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -0
- package/dist/index.d.ts +522 -320
- package/dist/index.js +2 -2
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -477,64 +477,100 @@ type CSSStyle = {
|
|
|
477
477
|
};
|
|
478
478
|
|
|
479
479
|
interface c_events<T extends Elements = HTMLElement> {
|
|
480
|
-
state?: (this: T, e: T) => maybePromise<[
|
|
480
|
+
state?: ((this: T, e: T) => maybePromise<[
|
|
481
481
|
(...args: any[]) => void,
|
|
482
482
|
IStateful<any>[],
|
|
483
483
|
boolean?,
|
|
484
484
|
boolean?
|
|
485
|
-
]
|
|
486
|
-
states?: (this: T, e: T) => maybePromise<[
|
|
485
|
+
]>) | undefined;
|
|
486
|
+
states?: ((this: T, e: T) => maybePromise<[
|
|
487
487
|
(...args: any[]) => void,
|
|
488
488
|
IStateful<any>[],
|
|
489
489
|
boolean?,
|
|
490
490
|
boolean?
|
|
491
|
-
]>[];
|
|
492
|
-
ready?: (this: T, e: T) => maybePromise<void | (() => void)
|
|
493
|
-
resize?: (this: T, e: UIEvent) => void;
|
|
494
|
-
beforeunload?: (this: T, e: BeforeUnloadEvent) => void;
|
|
495
|
-
popstate?: (this: T, e: PopStateEvent) => void;
|
|
496
|
-
DOMContentLoaded?: (this: T, e: Event) => void;
|
|
497
|
-
winscroll?: (this: T, e: Event) => void;
|
|
498
|
-
winload?: (this: T, e: Event) => void;
|
|
499
|
-
winfocus?: (this: T, e: Event) => void;
|
|
500
|
-
winblur?: (this: T, e: Event) => void;
|
|
501
|
-
winkeydown?: (this: T, e: KeyboardEvent) => void;
|
|
502
|
-
winkeypress?: (this: T, e: KeyboardEvent) => void;
|
|
503
|
-
winkeyup?: (this: T, e: KeyboardEvent) => void;
|
|
491
|
+
]>[]) | undefined;
|
|
492
|
+
ready?: ((this: T, e: T) => maybePromise<void | (() => void)>) | undefined;
|
|
493
|
+
resize?: ((this: T, e: UIEvent) => void) | undefined;
|
|
494
|
+
beforeunload?: ((this: T, e: BeforeUnloadEvent) => void) | undefined;
|
|
495
|
+
popstate?: ((this: T, e: PopStateEvent) => void) | undefined;
|
|
496
|
+
DOMContentLoaded?: ((this: T, e: Event) => void) | undefined;
|
|
497
|
+
winscroll?: ((this: T, e: Event) => void) | undefined;
|
|
498
|
+
winload?: ((this: T, e: Event) => void) | undefined;
|
|
499
|
+
winfocus?: ((this: T, e: Event) => void) | undefined;
|
|
500
|
+
winblur?: ((this: T, e: Event) => void) | undefined;
|
|
501
|
+
winkeydown?: ((this: T, e: KeyboardEvent) => void) | undefined;
|
|
502
|
+
winkeypress?: ((this: T, e: KeyboardEvent) => void) | undefined;
|
|
503
|
+
winkeyup?: ((this: T, e: KeyboardEvent) => void) | undefined;
|
|
504
504
|
}
|
|
505
|
+
/**
|
|
506
|
+
* Event handler map accepted by `on`. Every handler is optional and may be
|
|
507
|
+
* explicitly `undefined`; the renderer skips absent handlers.
|
|
508
|
+
*/
|
|
505
509
|
type DOMEvents<T extends Elements = HTMLElement> = {
|
|
506
|
-
[P in keyof GlobalEventHandlersEventMap]?: (this: T, event: GlobalEventHandlersEventMap[P]) => void;
|
|
510
|
+
[P in keyof GlobalEventHandlersEventMap]?: ((this: T, event: GlobalEventHandlersEventMap[P]) => void) | undefined;
|
|
507
511
|
} & c_events<T>;
|
|
508
512
|
|
|
513
|
+
/**
|
|
514
|
+
* Attributes accepted by every Yvee element. Optional attributes are declared
|
|
515
|
+
* as `?: T | undefined` so a conditionally-present value
|
|
516
|
+
* (`disabled={props.disabled}`) type-checks under `exactOptionalPropertyTypes`;
|
|
517
|
+
* an explicitly `undefined` attribute is dropped during render.
|
|
518
|
+
*/
|
|
509
519
|
interface EAttr<T = DVal> {
|
|
510
520
|
[key: string]: any;
|
|
511
521
|
[key: `data-${string}`]: T | any;
|
|
512
|
-
accesskey?: T;
|
|
513
|
-
autocapitalize?: T;
|
|
514
|
-
class?: T | T[];
|
|
515
|
-
on?: DOMEvents<any
|
|
516
|
-
ref?: Ref<any
|
|
517
|
-
contenteditable?: T;
|
|
518
|
-
dir?: T;
|
|
519
|
-
draggable?: T;
|
|
520
|
-
hidden?: T;
|
|
521
|
-
id?: T;
|
|
522
|
-
itemprop?: T;
|
|
523
|
-
lang?: T;
|
|
524
|
-
role?: T;
|
|
525
|
-
slot?: T;
|
|
526
|
-
spellcheck?: T;
|
|
527
|
-
style?: CSSStyle | string;
|
|
528
|
-
tabindex?: T;
|
|
529
|
-
title?: T;
|
|
530
|
-
translate?: T;
|
|
522
|
+
accesskey?: T | undefined;
|
|
523
|
+
autocapitalize?: T | undefined;
|
|
524
|
+
class?: T | T[] | undefined;
|
|
525
|
+
on?: DOMEvents<any> | undefined;
|
|
526
|
+
ref?: Ref<any> | undefined;
|
|
527
|
+
contenteditable?: T | undefined;
|
|
528
|
+
dir?: T | undefined;
|
|
529
|
+
draggable?: T | undefined;
|
|
530
|
+
hidden?: T | undefined;
|
|
531
|
+
id?: T | undefined;
|
|
532
|
+
itemprop?: T | undefined;
|
|
533
|
+
lang?: T | undefined;
|
|
534
|
+
role?: T | undefined;
|
|
535
|
+
slot?: T | undefined;
|
|
536
|
+
spellcheck?: T | undefined;
|
|
537
|
+
style?: CSSStyle | string | undefined;
|
|
538
|
+
tabindex?: T | undefined;
|
|
539
|
+
title?: T | undefined;
|
|
540
|
+
translate?: T | undefined;
|
|
531
541
|
}
|
|
532
542
|
|
|
543
|
+
/**
|
|
544
|
+
* Attribute/event shape accepted by renderer nodes and JSX intrinsics.
|
|
545
|
+
*
|
|
546
|
+
* Optional attributes accept an explicitly `undefined` value
|
|
547
|
+
* (`disabled?: T | undefined`) and are omitted from the rendered markup.
|
|
548
|
+
*/
|
|
533
549
|
type DOMAttr = EAttr;
|
|
534
550
|
type DOMValue<T = V | V[]> = DVal<T>;
|
|
535
551
|
type DOMRenderable = string | number | boolean | null | undefined | DOM | DOMRenderable[] | IStateful<unknown> | object | (() => maybePromise<DOMRenderable>);
|
|
536
552
|
type DOMContext = maybePromise<DOMRenderable>;
|
|
553
|
+
/**
|
|
554
|
+
* Attributes passed to a Yvee function component: {@link DOMAttr} plus the
|
|
555
|
+
* component's own props.
|
|
556
|
+
*
|
|
557
|
+
* JSX children are **not** part of this object. `dom` forwards them as rest
|
|
558
|
+
* arguments, so `props.children` is always `undefined`; declare components as
|
|
559
|
+
* `(props: P, ...children: DOMContext[])` and render `{children}`.
|
|
560
|
+
*/
|
|
537
561
|
type DOMComponentProps<T extends object = {}> = DOMAttr & T;
|
|
562
|
+
/**
|
|
563
|
+
* Type of a Yvee function component.
|
|
564
|
+
*
|
|
565
|
+
* The first parameter carries attributes/props; JSX children arrive as the
|
|
566
|
+
* remaining rest parameters (they are never placed on the props object).
|
|
567
|
+
*
|
|
568
|
+
* ```tsx
|
|
569
|
+
* function Card(props: { title: string }, ...children: DOMContext[]) {
|
|
570
|
+
* return <section><h2>{props.title}</h2>{children}</section>;
|
|
571
|
+
* }
|
|
572
|
+
* ```
|
|
573
|
+
*/
|
|
538
574
|
type DOMComponent<T extends object = {}> = (attributes: DOMComponentProps<T>, ...children: DOMContext[]) => maybePromise<DOM>;
|
|
539
575
|
type DOMNode = DOM;
|
|
540
576
|
|
|
@@ -548,329 +584,329 @@ declare function dom(tag: string | DOMComponent, attr?: DOMAttr | null, ...ctx:
|
|
|
548
584
|
declare const frag: (_attr: DOMAttr, ...ctx: DOMContext[]) => Promise<DOM>;
|
|
549
585
|
|
|
550
586
|
interface aAttr<T = DVal> extends EAttr {
|
|
551
|
-
download?: T;
|
|
552
|
-
href?: T;
|
|
553
|
-
hreflang?: T;
|
|
554
|
-
media?: T;
|
|
555
|
-
ping?: T;
|
|
556
|
-
referrerpolicy?: T;
|
|
557
|
-
rel?: T;
|
|
558
|
-
shape?: T;
|
|
559
|
-
target?: T;
|
|
587
|
+
download?: T | undefined;
|
|
588
|
+
href?: T | undefined;
|
|
589
|
+
hreflang?: T | undefined;
|
|
590
|
+
media?: T | undefined;
|
|
591
|
+
ping?: T | undefined;
|
|
592
|
+
referrerpolicy?: T | undefined;
|
|
593
|
+
rel?: T | undefined;
|
|
594
|
+
shape?: T | undefined;
|
|
595
|
+
target?: T | undefined;
|
|
560
596
|
}
|
|
561
597
|
interface areaAttr<T = DVal> extends EAttr {
|
|
562
|
-
alt?: T;
|
|
563
|
-
coords?: T;
|
|
564
|
-
download?: T;
|
|
565
|
-
href?: T;
|
|
566
|
-
media?: T;
|
|
567
|
-
ping?: T;
|
|
568
|
-
referrerpolicy?: T;
|
|
569
|
-
rel?: T;
|
|
570
|
-
shape?: T;
|
|
571
|
-
target?: T;
|
|
598
|
+
alt?: T | undefined;
|
|
599
|
+
coords?: T | undefined;
|
|
600
|
+
download?: T | undefined;
|
|
601
|
+
href?: T | undefined;
|
|
602
|
+
media?: T | undefined;
|
|
603
|
+
ping?: T | undefined;
|
|
604
|
+
referrerpolicy?: T | undefined;
|
|
605
|
+
rel?: T | undefined;
|
|
606
|
+
shape?: T | undefined;
|
|
607
|
+
target?: T | undefined;
|
|
572
608
|
}
|
|
573
609
|
interface audioAttr<T = DVal> extends EAttr {
|
|
574
|
-
autoplay?: T;
|
|
575
|
-
controls?: T;
|
|
576
|
-
crossorigin?: T;
|
|
577
|
-
loop?: T;
|
|
578
|
-
muted?: T;
|
|
579
|
-
preload?: T;
|
|
580
|
-
src?: T;
|
|
610
|
+
autoplay?: T | undefined;
|
|
611
|
+
controls?: T | undefined;
|
|
612
|
+
crossorigin?: T | undefined;
|
|
613
|
+
loop?: T | undefined;
|
|
614
|
+
muted?: T | undefined;
|
|
615
|
+
preload?: T | undefined;
|
|
616
|
+
src?: T | undefined;
|
|
581
617
|
}
|
|
582
618
|
interface baseAttr<T = DVal> extends EAttr {
|
|
583
|
-
href?: T;
|
|
584
|
-
target?: T;
|
|
619
|
+
href?: T | undefined;
|
|
620
|
+
target?: T | undefined;
|
|
585
621
|
}
|
|
586
622
|
interface blockquoteAttr<T = DVal> extends EAttr {
|
|
587
|
-
cite?: T;
|
|
623
|
+
cite?: T | undefined;
|
|
588
624
|
}
|
|
589
625
|
interface buttonAttr<T = DVal> extends EAttr {
|
|
590
|
-
disabled?: T;
|
|
591
|
-
form?: T;
|
|
592
|
-
formaction?: T;
|
|
593
|
-
formenctype?: T;
|
|
594
|
-
formmethod?: T;
|
|
595
|
-
formnovalidate?: T;
|
|
596
|
-
formtarget?: T;
|
|
597
|
-
name?: T;
|
|
598
|
-
type?: T;
|
|
599
|
-
value?: T;
|
|
626
|
+
disabled?: T | undefined;
|
|
627
|
+
form?: T | undefined;
|
|
628
|
+
formaction?: T | undefined;
|
|
629
|
+
formenctype?: T | undefined;
|
|
630
|
+
formmethod?: T | undefined;
|
|
631
|
+
formnovalidate?: T | undefined;
|
|
632
|
+
formtarget?: T | undefined;
|
|
633
|
+
name?: T | undefined;
|
|
634
|
+
type?: T | undefined;
|
|
635
|
+
value?: T | undefined;
|
|
600
636
|
}
|
|
601
637
|
interface canvasAttr<T = DVal> extends EAttr {
|
|
602
|
-
height?: T;
|
|
603
|
-
width?: T;
|
|
638
|
+
height?: T | undefined;
|
|
639
|
+
width?: T | undefined;
|
|
604
640
|
}
|
|
605
641
|
interface colAttr<T = DVal> extends EAttr {
|
|
606
|
-
span?: T;
|
|
642
|
+
span?: T | undefined;
|
|
607
643
|
}
|
|
608
644
|
interface colgroupAttr<T = DVal> extends EAttr {
|
|
609
|
-
span?: T;
|
|
645
|
+
span?: T | undefined;
|
|
610
646
|
}
|
|
611
647
|
interface dataAttr<T = DVal> extends EAttr {
|
|
612
|
-
value?: T;
|
|
648
|
+
value?: T | undefined;
|
|
613
649
|
}
|
|
614
650
|
interface delAttr<T = DVal> extends EAttr {
|
|
615
|
-
cite?: T;
|
|
616
|
-
datetime?: T;
|
|
651
|
+
cite?: T | undefined;
|
|
652
|
+
datetime?: T | undefined;
|
|
617
653
|
}
|
|
618
654
|
interface detailsAttr<T = DVal> extends EAttr {
|
|
619
|
-
open?: T;
|
|
655
|
+
open?: T | undefined;
|
|
620
656
|
}
|
|
621
657
|
interface dialogAttr<T = DVal> extends EAttr {
|
|
622
|
-
open?: T;
|
|
658
|
+
open?: T | undefined;
|
|
623
659
|
}
|
|
624
660
|
interface embedAttr<T = DVal> extends EAttr {
|
|
625
|
-
height?: T;
|
|
626
|
-
src?: T;
|
|
627
|
-
type?: T;
|
|
628
|
-
width?: T;
|
|
661
|
+
height?: T | undefined;
|
|
662
|
+
src?: T | undefined;
|
|
663
|
+
type?: T | undefined;
|
|
664
|
+
width?: T | undefined;
|
|
629
665
|
}
|
|
630
666
|
interface fieldsetAttr<T = DVal> extends EAttr {
|
|
631
|
-
disabled?: T;
|
|
632
|
-
form?: T;
|
|
633
|
-
name?: T;
|
|
667
|
+
disabled?: T | undefined;
|
|
668
|
+
form?: T | undefined;
|
|
669
|
+
name?: T | undefined;
|
|
634
670
|
}
|
|
635
671
|
interface formAttr<T = DVal> extends EAttr {
|
|
636
|
-
accept?: T;
|
|
637
|
-
"accept-charset"?: T;
|
|
638
|
-
action?: T;
|
|
639
|
-
autocomplete?: T;
|
|
640
|
-
enctype?: T;
|
|
641
|
-
method?: T;
|
|
642
|
-
name?: T;
|
|
643
|
-
novalidate?: T;
|
|
644
|
-
target?: T;
|
|
672
|
+
accept?: T | undefined;
|
|
673
|
+
"accept-charset"?: T | undefined;
|
|
674
|
+
action?: T | undefined;
|
|
675
|
+
autocomplete?: T | undefined;
|
|
676
|
+
enctype?: T | undefined;
|
|
677
|
+
method?: T | undefined;
|
|
678
|
+
name?: T | undefined;
|
|
679
|
+
novalidate?: T | undefined;
|
|
680
|
+
target?: T | undefined;
|
|
645
681
|
}
|
|
646
682
|
interface iframeAttr<T = DVal> extends EAttr {
|
|
647
|
-
allow?: T;
|
|
648
|
-
csp?: T;
|
|
649
|
-
loading?: T;
|
|
650
|
-
name?: T;
|
|
651
|
-
height?: T;
|
|
652
|
-
referrerpolicy?: T;
|
|
653
|
-
sandbox?: T;
|
|
654
|
-
src?: T;
|
|
655
|
-
srcdoc?: T;
|
|
656
|
-
width?: T;
|
|
683
|
+
allow?: T | undefined;
|
|
684
|
+
csp?: T | undefined;
|
|
685
|
+
loading?: T | undefined;
|
|
686
|
+
name?: T | undefined;
|
|
687
|
+
height?: T | undefined;
|
|
688
|
+
referrerpolicy?: T | undefined;
|
|
689
|
+
sandbox?: T | undefined;
|
|
690
|
+
src?: T | undefined;
|
|
691
|
+
srcdoc?: T | undefined;
|
|
692
|
+
width?: T | undefined;
|
|
657
693
|
}
|
|
658
694
|
interface imgAttr<T = DVal> extends EAttr {
|
|
659
|
-
alt?: T;
|
|
660
|
-
crossorigin?: T;
|
|
661
|
-
decoding?: T;
|
|
662
|
-
ismap?: T;
|
|
663
|
-
loading?: T;
|
|
664
|
-
height?: T;
|
|
665
|
-
referrerpolicy?: T;
|
|
666
|
-
sizes?: T;
|
|
667
|
-
src?: T;
|
|
668
|
-
srcset?: T;
|
|
669
|
-
usemap?: T;
|
|
670
|
-
width?: T;
|
|
695
|
+
alt?: T | undefined;
|
|
696
|
+
crossorigin?: T | undefined;
|
|
697
|
+
decoding?: T | undefined;
|
|
698
|
+
ismap?: T | undefined;
|
|
699
|
+
loading?: T | undefined;
|
|
700
|
+
height?: T | undefined;
|
|
701
|
+
referrerpolicy?: T | undefined;
|
|
702
|
+
sizes?: T | undefined;
|
|
703
|
+
src?: T | undefined;
|
|
704
|
+
srcset?: T | undefined;
|
|
705
|
+
usemap?: T | undefined;
|
|
706
|
+
width?: T | undefined;
|
|
671
707
|
}
|
|
672
708
|
interface inputAttr<T = DVal> extends EAttr {
|
|
673
|
-
accept?: T;
|
|
674
|
-
alt?: T;
|
|
675
|
-
autocomplete?: T;
|
|
676
|
-
capture?: T;
|
|
677
|
-
checked?: T;
|
|
678
|
-
dirname?: T;
|
|
679
|
-
disabled?: T;
|
|
680
|
-
form?: T;
|
|
681
|
-
formaction?: T;
|
|
682
|
-
formenctype?: T;
|
|
683
|
-
formmethod?: T;
|
|
684
|
-
formnovalidate?: T;
|
|
685
|
-
formtarget?: T;
|
|
686
|
-
list?: T;
|
|
687
|
-
max?: T;
|
|
688
|
-
maxlength?: T;
|
|
689
|
-
minlength?: T;
|
|
690
|
-
min?: T;
|
|
691
|
-
multiple?: T;
|
|
692
|
-
name?: T;
|
|
693
|
-
pattern?: T;
|
|
694
|
-
placeholder?: T;
|
|
695
|
-
height?: T;
|
|
696
|
-
readonly?: T;
|
|
697
|
-
required?: T;
|
|
698
|
-
size?: T;
|
|
699
|
-
src?: T;
|
|
700
|
-
step?: T;
|
|
701
|
-
type?: T;
|
|
702
|
-
usemap?: T;
|
|
703
|
-
value?: T;
|
|
704
|
-
width?: T;
|
|
709
|
+
accept?: T | undefined;
|
|
710
|
+
alt?: T | undefined;
|
|
711
|
+
autocomplete?: T | undefined;
|
|
712
|
+
capture?: T | undefined;
|
|
713
|
+
checked?: T | undefined;
|
|
714
|
+
dirname?: T | undefined;
|
|
715
|
+
disabled?: T | undefined;
|
|
716
|
+
form?: T | undefined;
|
|
717
|
+
formaction?: T | undefined;
|
|
718
|
+
formenctype?: T | undefined;
|
|
719
|
+
formmethod?: T | undefined;
|
|
720
|
+
formnovalidate?: T | undefined;
|
|
721
|
+
formtarget?: T | undefined;
|
|
722
|
+
list?: T | undefined;
|
|
723
|
+
max?: T | undefined;
|
|
724
|
+
maxlength?: T | undefined;
|
|
725
|
+
minlength?: T | undefined;
|
|
726
|
+
min?: T | undefined;
|
|
727
|
+
multiple?: T | undefined;
|
|
728
|
+
name?: T | undefined;
|
|
729
|
+
pattern?: T | undefined;
|
|
730
|
+
placeholder?: T | undefined;
|
|
731
|
+
height?: T | undefined;
|
|
732
|
+
readonly?: T | undefined;
|
|
733
|
+
required?: T | undefined;
|
|
734
|
+
size?: T | undefined;
|
|
735
|
+
src?: T | undefined;
|
|
736
|
+
step?: T | undefined;
|
|
737
|
+
type?: T | undefined;
|
|
738
|
+
usemap?: T | undefined;
|
|
739
|
+
value?: T | undefined;
|
|
740
|
+
width?: T | undefined;
|
|
705
741
|
}
|
|
706
742
|
interface insAttr<T = DVal> extends EAttr {
|
|
707
|
-
cite?: T;
|
|
708
|
-
datetime?: T;
|
|
743
|
+
cite?: T | undefined;
|
|
744
|
+
datetime?: T | undefined;
|
|
709
745
|
}
|
|
710
746
|
interface labelAttr<T = DVal> extends EAttr {
|
|
711
|
-
for?: T;
|
|
712
|
-
form?: T;
|
|
747
|
+
for?: T | undefined;
|
|
748
|
+
form?: T | undefined;
|
|
713
749
|
}
|
|
714
750
|
interface liAttr<T = DVal> extends EAttr {
|
|
715
|
-
value?: T;
|
|
751
|
+
value?: T | undefined;
|
|
716
752
|
}
|
|
717
753
|
interface linkAttr<T = DVal> extends EAttr {
|
|
718
|
-
as?: T;
|
|
719
|
-
crossorigin?: T;
|
|
720
|
-
href?: T;
|
|
721
|
-
hreflang?: T;
|
|
722
|
-
integrity?: T;
|
|
723
|
-
media?: T;
|
|
724
|
-
referrerpolicy?: T;
|
|
725
|
-
rel?: T;
|
|
726
|
-
sizes?: T;
|
|
727
|
-
type?: T;
|
|
754
|
+
as?: T | undefined;
|
|
755
|
+
crossorigin?: T | undefined;
|
|
756
|
+
href?: T | undefined;
|
|
757
|
+
hreflang?: T | undefined;
|
|
758
|
+
integrity?: T | undefined;
|
|
759
|
+
media?: T | undefined;
|
|
760
|
+
referrerpolicy?: T | undefined;
|
|
761
|
+
rel?: T | undefined;
|
|
762
|
+
sizes?: T | undefined;
|
|
763
|
+
type?: T | undefined;
|
|
728
764
|
}
|
|
729
765
|
interface mapAttr<T = DVal> extends EAttr {
|
|
730
|
-
name?: T;
|
|
766
|
+
name?: T | undefined;
|
|
731
767
|
}
|
|
732
768
|
interface menuAttr<T = DVal> extends EAttr {
|
|
733
|
-
type?: T;
|
|
769
|
+
type?: T | undefined;
|
|
734
770
|
}
|
|
735
771
|
interface metaAttr<T = DVal> extends EAttr {
|
|
736
|
-
charset?: T;
|
|
737
|
-
content?: T;
|
|
738
|
-
"http-equiv"?: T;
|
|
739
|
-
name?: T;
|
|
772
|
+
charset?: T | undefined;
|
|
773
|
+
content?: T | undefined;
|
|
774
|
+
"http-equiv"?: T | undefined;
|
|
775
|
+
name?: T | undefined;
|
|
740
776
|
}
|
|
741
777
|
interface meterAttr<T = DVal> extends EAttr {
|
|
742
|
-
form?: T;
|
|
743
|
-
high?: T;
|
|
744
|
-
low?: T;
|
|
745
|
-
max?: T;
|
|
746
|
-
min?: T;
|
|
747
|
-
optimum?: T;
|
|
748
|
-
value?: T;
|
|
778
|
+
form?: T | undefined;
|
|
779
|
+
high?: T | undefined;
|
|
780
|
+
low?: T | undefined;
|
|
781
|
+
max?: T | undefined;
|
|
782
|
+
min?: T | undefined;
|
|
783
|
+
optimum?: T | undefined;
|
|
784
|
+
value?: T | undefined;
|
|
749
785
|
}
|
|
750
786
|
interface objectAttr<T = DVal> extends EAttr {
|
|
751
|
-
data?: T;
|
|
752
|
-
form?: T;
|
|
753
|
-
name?: T;
|
|
754
|
-
height?: T;
|
|
755
|
-
type?: T;
|
|
756
|
-
usemap?: T;
|
|
757
|
-
width?: T;
|
|
787
|
+
data?: T | undefined;
|
|
788
|
+
form?: T | undefined;
|
|
789
|
+
name?: T | undefined;
|
|
790
|
+
height?: T | undefined;
|
|
791
|
+
type?: T | undefined;
|
|
792
|
+
usemap?: T | undefined;
|
|
793
|
+
width?: T | undefined;
|
|
758
794
|
}
|
|
759
795
|
interface olAttr<T = DVal> extends EAttr {
|
|
760
|
-
reversed?: T;
|
|
761
|
-
start?: T;
|
|
762
|
-
type?: T;
|
|
796
|
+
reversed?: T | undefined;
|
|
797
|
+
start?: T | undefined;
|
|
798
|
+
type?: T | undefined;
|
|
763
799
|
}
|
|
764
800
|
interface optgroupAttr<T = DVal> extends EAttr {
|
|
765
|
-
disabled?: T;
|
|
766
|
-
label?: T;
|
|
801
|
+
disabled?: T | undefined;
|
|
802
|
+
label?: T | undefined;
|
|
767
803
|
}
|
|
768
804
|
interface optionAttr<T = DVal> extends EAttr {
|
|
769
|
-
disabled?: T;
|
|
770
|
-
label?: T;
|
|
771
|
-
selected?: T;
|
|
772
|
-
value?: T;
|
|
805
|
+
disabled?: T | undefined;
|
|
806
|
+
label?: T | undefined;
|
|
807
|
+
selected?: T | undefined;
|
|
808
|
+
value?: T | undefined;
|
|
773
809
|
}
|
|
774
810
|
interface outputAttr<T = DVal> extends EAttr {
|
|
775
|
-
for?: T;
|
|
776
|
-
form?: T;
|
|
777
|
-
name?: T;
|
|
811
|
+
for?: T | undefined;
|
|
812
|
+
form?: T | undefined;
|
|
813
|
+
name?: T | undefined;
|
|
778
814
|
}
|
|
779
815
|
interface paramAttr<T = DVal> extends EAttr {
|
|
780
|
-
name?: T;
|
|
781
|
-
value?: T;
|
|
816
|
+
name?: T | undefined;
|
|
817
|
+
value?: T | undefined;
|
|
782
818
|
}
|
|
783
819
|
interface progressAttr<T = DVal> extends EAttr {
|
|
784
|
-
form?: T;
|
|
785
|
-
max?: T;
|
|
786
|
-
value?: T;
|
|
820
|
+
form?: T | undefined;
|
|
821
|
+
max?: T | undefined;
|
|
822
|
+
value?: T | undefined;
|
|
787
823
|
}
|
|
788
824
|
interface qAttr<T = DVal> extends EAttr {
|
|
789
|
-
cite?: T;
|
|
825
|
+
cite?: T | undefined;
|
|
790
826
|
}
|
|
791
827
|
interface scriptAttr<T = DVal> extends EAttr {
|
|
792
|
-
async?: T;
|
|
793
|
-
crossorigin?: T;
|
|
794
|
-
defer?: T;
|
|
795
|
-
integrity?: T;
|
|
796
|
-
referrerpolicy?: T;
|
|
797
|
-
src?: T;
|
|
798
|
-
type?: T;
|
|
828
|
+
async?: T | undefined;
|
|
829
|
+
crossorigin?: T | undefined;
|
|
830
|
+
defer?: T | undefined;
|
|
831
|
+
integrity?: T | undefined;
|
|
832
|
+
referrerpolicy?: T | undefined;
|
|
833
|
+
src?: T | undefined;
|
|
834
|
+
type?: T | undefined;
|
|
799
835
|
}
|
|
800
836
|
interface selectAttr<T = DVal> extends EAttr {
|
|
801
|
-
autocomplete?: T;
|
|
802
|
-
disabled?: T;
|
|
803
|
-
form?: T;
|
|
804
|
-
multiple?: T;
|
|
805
|
-
name?: T;
|
|
806
|
-
required?: T;
|
|
807
|
-
size?: T;
|
|
837
|
+
autocomplete?: T | undefined;
|
|
838
|
+
disabled?: T | undefined;
|
|
839
|
+
form?: T | undefined;
|
|
840
|
+
multiple?: T | undefined;
|
|
841
|
+
name?: T | undefined;
|
|
842
|
+
required?: T | undefined;
|
|
843
|
+
size?: T | undefined;
|
|
808
844
|
}
|
|
809
845
|
interface sourceAttr<T = DVal> extends EAttr {
|
|
810
|
-
media?: T;
|
|
811
|
-
sizes?: T;
|
|
812
|
-
src?: T;
|
|
813
|
-
srcset?: T;
|
|
814
|
-
type?: T;
|
|
846
|
+
media?: T | undefined;
|
|
847
|
+
sizes?: T | undefined;
|
|
848
|
+
src?: T | undefined;
|
|
849
|
+
srcset?: T | undefined;
|
|
850
|
+
type?: T | undefined;
|
|
815
851
|
}
|
|
816
852
|
interface styleAttr<T = DVal> extends EAttr {
|
|
817
|
-
media?: T;
|
|
818
|
-
type?: T;
|
|
853
|
+
media?: T | undefined;
|
|
854
|
+
type?: T | undefined;
|
|
819
855
|
}
|
|
820
856
|
interface tdAttr<T = DVal> extends EAttr {
|
|
821
|
-
colspan?: T;
|
|
822
|
-
headers?: T;
|
|
823
|
-
rowspan?: T;
|
|
857
|
+
colspan?: T | undefined;
|
|
858
|
+
headers?: T | undefined;
|
|
859
|
+
rowspan?: T | undefined;
|
|
824
860
|
}
|
|
825
861
|
interface textareaAttr<T = DVal> extends EAttr {
|
|
826
|
-
autocomplete?: T;
|
|
827
|
-
cols?: T;
|
|
828
|
-
dirname?: T;
|
|
829
|
-
disabled?: T;
|
|
830
|
-
enterkeyhint?: T;
|
|
831
|
-
form?: T;
|
|
832
|
-
inputmode?: T;
|
|
833
|
-
maxlength?: T;
|
|
834
|
-
minlength?: T;
|
|
835
|
-
name?: T;
|
|
836
|
-
placeholder?: T;
|
|
837
|
-
readonly?: T;
|
|
838
|
-
required?: T;
|
|
839
|
-
rows?: T;
|
|
840
|
-
wrap?: T;
|
|
862
|
+
autocomplete?: T | undefined;
|
|
863
|
+
cols?: T | undefined;
|
|
864
|
+
dirname?: T | undefined;
|
|
865
|
+
disabled?: T | undefined;
|
|
866
|
+
enterkeyhint?: T | undefined;
|
|
867
|
+
form?: T | undefined;
|
|
868
|
+
inputmode?: T | undefined;
|
|
869
|
+
maxlength?: T | undefined;
|
|
870
|
+
minlength?: T | undefined;
|
|
871
|
+
name?: T | undefined;
|
|
872
|
+
placeholder?: T | undefined;
|
|
873
|
+
readonly?: T | undefined;
|
|
874
|
+
required?: T | undefined;
|
|
875
|
+
rows?: T | undefined;
|
|
876
|
+
wrap?: T | undefined;
|
|
841
877
|
}
|
|
842
878
|
interface thAttr<T = DVal> extends EAttr<T> {
|
|
843
|
-
colspan?: T;
|
|
844
|
-
headers?: T;
|
|
845
|
-
rowspan?: T;
|
|
846
|
-
scope?: T;
|
|
879
|
+
colspan?: T | undefined;
|
|
880
|
+
headers?: T | undefined;
|
|
881
|
+
rowspan?: T | undefined;
|
|
882
|
+
scope?: T | undefined;
|
|
847
883
|
}
|
|
848
884
|
interface timeAttr<T = DVal> extends EAttr {
|
|
849
|
-
datetime?: T;
|
|
885
|
+
datetime?: T | undefined;
|
|
850
886
|
}
|
|
851
887
|
interface trackAttr<T = DVal> extends EAttr {
|
|
852
|
-
default?: T;
|
|
853
|
-
kind?: T;
|
|
854
|
-
label?: T;
|
|
855
|
-
src?: T;
|
|
856
|
-
srclang?: T;
|
|
888
|
+
default?: T | undefined;
|
|
889
|
+
kind?: T | undefined;
|
|
890
|
+
label?: T | undefined;
|
|
891
|
+
src?: T | undefined;
|
|
892
|
+
srclang?: T | undefined;
|
|
857
893
|
}
|
|
858
894
|
interface videoAttr<T = DVal> extends EAttr {
|
|
859
|
-
autoplay?: T;
|
|
860
|
-
controls?: T;
|
|
861
|
-
crossorigin?: T;
|
|
862
|
-
loop?: T;
|
|
863
|
-
muted?: T;
|
|
864
|
-
playsinline?: T;
|
|
865
|
-
height?: T;
|
|
866
|
-
poster?: T;
|
|
867
|
-
preload?: T;
|
|
868
|
-
src?: T;
|
|
869
|
-
width?: T;
|
|
895
|
+
autoplay?: T | undefined;
|
|
896
|
+
controls?: T | undefined;
|
|
897
|
+
crossorigin?: T | undefined;
|
|
898
|
+
loop?: T | undefined;
|
|
899
|
+
muted?: T | undefined;
|
|
900
|
+
playsinline?: T | undefined;
|
|
901
|
+
height?: T | undefined;
|
|
902
|
+
poster?: T | undefined;
|
|
903
|
+
preload?: T | undefined;
|
|
904
|
+
src?: T | undefined;
|
|
905
|
+
width?: T | undefined;
|
|
870
906
|
}
|
|
871
907
|
interface contenteditableAttr<T = DVal> extends EAttr {
|
|
872
|
-
enterkeyhint?: T;
|
|
873
|
-
inputmode?: T;
|
|
908
|
+
enterkeyhint?: T | undefined;
|
|
909
|
+
inputmode?: T | undefined;
|
|
874
910
|
}
|
|
875
911
|
|
|
876
912
|
interface ElementAttributes {
|
|
@@ -984,7 +1020,7 @@ interface ElementAttributes {
|
|
|
984
1020
|
|
|
985
1021
|
interface SVGAttributes {
|
|
986
1022
|
svg: svgAttr & {
|
|
987
|
-
viewBox?: DVal;
|
|
1023
|
+
viewBox?: DVal | undefined;
|
|
988
1024
|
};
|
|
989
1025
|
path: svgEAttr;
|
|
990
1026
|
circle: svgEAttr;
|
|
@@ -1046,57 +1082,66 @@ interface SVGAttributes {
|
|
|
1046
1082
|
view: svgEAttr;
|
|
1047
1083
|
}
|
|
1048
1084
|
interface svgAttr<T = DVal> extends EAttr<T> {
|
|
1049
|
-
height?: T;
|
|
1050
|
-
width?: T;
|
|
1051
|
-
preserveAspectRatio?: T;
|
|
1052
|
-
fill?: T;
|
|
1053
|
-
stroke?: T;
|
|
1054
|
-
strokeWidth?: T;
|
|
1055
|
-
opacity?: T;
|
|
1056
|
-
display?: T;
|
|
1057
|
-
overflow?: T;
|
|
1085
|
+
height?: T | undefined;
|
|
1086
|
+
width?: T | undefined;
|
|
1087
|
+
preserveAspectRatio?: T | undefined;
|
|
1088
|
+
fill?: T | undefined;
|
|
1089
|
+
stroke?: T | undefined;
|
|
1090
|
+
strokeWidth?: T | undefined;
|
|
1091
|
+
opacity?: T | undefined;
|
|
1092
|
+
display?: T | undefined;
|
|
1093
|
+
overflow?: T | undefined;
|
|
1058
1094
|
}
|
|
1059
1095
|
interface svgEAttr<T = DVal> extends svgAttr<T> {
|
|
1060
|
-
transform?: T;
|
|
1061
|
-
role?: T;
|
|
1062
|
-
tabindex?: T;
|
|
1063
|
-
visibility?: T;
|
|
1064
|
-
fillOpacity?: T;
|
|
1065
|
-
fillRule?: T;
|
|
1066
|
-
stroke?: T;
|
|
1067
|
-
strokeWidth?: T;
|
|
1068
|
-
strokeOpacity?: T;
|
|
1069
|
-
strokeLinecap?: T;
|
|
1070
|
-
strokeLinejoin?: T;
|
|
1071
|
-
strokeMiterlimit?: T;
|
|
1072
|
-
strokeDasharray?: T;
|
|
1073
|
-
strokeDashoffset?: T;
|
|
1074
|
-
x?: T;
|
|
1075
|
-
y?: T;
|
|
1076
|
-
x1?: T;
|
|
1077
|
-
y1?: T;
|
|
1078
|
-
x2?: T;
|
|
1079
|
-
y2?: T;
|
|
1080
|
-
cx?: T;
|
|
1081
|
-
cy?: T;
|
|
1082
|
-
r?: T;
|
|
1083
|
-
rx?: T;
|
|
1084
|
-
ry?: T;
|
|
1085
|
-
d?: T;
|
|
1086
|
-
points?: T;
|
|
1096
|
+
transform?: T | undefined;
|
|
1097
|
+
role?: T | undefined;
|
|
1098
|
+
tabindex?: T | undefined;
|
|
1099
|
+
visibility?: T | undefined;
|
|
1100
|
+
fillOpacity?: T | undefined;
|
|
1101
|
+
fillRule?: T | undefined;
|
|
1102
|
+
stroke?: T | undefined;
|
|
1103
|
+
strokeWidth?: T | undefined;
|
|
1104
|
+
strokeOpacity?: T | undefined;
|
|
1105
|
+
strokeLinecap?: T | undefined;
|
|
1106
|
+
strokeLinejoin?: T | undefined;
|
|
1107
|
+
strokeMiterlimit?: T | undefined;
|
|
1108
|
+
strokeDasharray?: T | undefined;
|
|
1109
|
+
strokeDashoffset?: T | undefined;
|
|
1110
|
+
x?: T | undefined;
|
|
1111
|
+
y?: T | undefined;
|
|
1112
|
+
x1?: T | undefined;
|
|
1113
|
+
y1?: T | undefined;
|
|
1114
|
+
x2?: T | undefined;
|
|
1115
|
+
y2?: T | undefined;
|
|
1116
|
+
cx?: T | undefined;
|
|
1117
|
+
cy?: T | undefined;
|
|
1118
|
+
r?: T | undefined;
|
|
1119
|
+
rx?: T | undefined;
|
|
1120
|
+
ry?: T | undefined;
|
|
1121
|
+
d?: T | undefined;
|
|
1122
|
+
points?: T | undefined;
|
|
1087
1123
|
}
|
|
1088
1124
|
interface svgETextAttr<T = DVal> extends svgEAttr<T> {
|
|
1089
|
-
fontSize?: T;
|
|
1090
|
-
fontFamily?: T;
|
|
1091
|
-
fontWeight?: T;
|
|
1092
|
-
textAnchor?: T;
|
|
1093
|
-
dominantBaseline?: T;
|
|
1125
|
+
fontSize?: T | undefined;
|
|
1126
|
+
fontFamily?: T | undefined;
|
|
1127
|
+
fontWeight?: T | undefined;
|
|
1128
|
+
textAnchor?: T | undefined;
|
|
1129
|
+
dominantBaseline?: T | undefined;
|
|
1094
1130
|
}
|
|
1095
1131
|
|
|
1096
1132
|
declare global {
|
|
1097
1133
|
type events<T extends Elements = HTMLElement> = {
|
|
1098
|
-
[P in keyof GlobalEventHandlersEventMap]?: (this: T, e: GlobalEventHandlersEventMap[P]) => void;
|
|
1134
|
+
[P in keyof GlobalEventHandlersEventMap]?: ((this: T, e: GlobalEventHandlersEventMap[P]) => void) | undefined;
|
|
1099
1135
|
} & c_events<T>;
|
|
1136
|
+
/**
|
|
1137
|
+
* Yvee JSX namespace.
|
|
1138
|
+
*
|
|
1139
|
+
* Function components receive their attributes as the first argument and JSX
|
|
1140
|
+
* children as **rest arguments**: declare them as
|
|
1141
|
+
* `(props: P, ...children: DOMContext[])` and render `{children}`.
|
|
1142
|
+
* Children are never placed on `props`, and `props.children` is always
|
|
1143
|
+
* `undefined`.
|
|
1144
|
+
*/
|
|
1100
1145
|
namespace JSX {
|
|
1101
1146
|
type Element = maybePromise<DOM>;
|
|
1102
1147
|
interface IntrinsicElements extends ElementAttributes, SVGAttributes {
|
|
@@ -1214,6 +1259,7 @@ declare function applyHead(config: HeadConfig, owner: string, options?: {
|
|
|
1214
1259
|
}): HeadCleanup;
|
|
1215
1260
|
|
|
1216
1261
|
declare class Page<TData extends Record<string, unknown> = Record<string, unknown>> {
|
|
1262
|
+
#private;
|
|
1217
1263
|
readonly resources: DisposalScope;
|
|
1218
1264
|
url: YveeURL;
|
|
1219
1265
|
path: string;
|
|
@@ -1224,6 +1270,15 @@ declare class Page<TData extends Record<string, unknown> = Record<string, unknow
|
|
|
1224
1270
|
fetch?(context: PageFetchContext<TData>): Partial<TData> | Promise<Partial<TData>>;
|
|
1225
1271
|
head?(): HeadResult | Promise<HeadResult>;
|
|
1226
1272
|
body?(): unknown | Promise<unknown>;
|
|
1273
|
+
/**
|
|
1274
|
+
* Read the server-seeded data for this document at most once.
|
|
1275
|
+
*
|
|
1276
|
+
* During SSR (no `document`) it returns `this.data` on every call, so server
|
|
1277
|
+
* renders are deterministic. In the browser it returns the hydrated payload
|
|
1278
|
+
* for the first call of the initial mount and `undefined` for later calls,
|
|
1279
|
+
* re-renders and client-side navigations. `page.data` is never modified.
|
|
1280
|
+
*/
|
|
1281
|
+
ssrData<T extends Record<string, unknown> = TData>(): T | undefined;
|
|
1227
1282
|
}
|
|
1228
1283
|
interface PageFetchContext<TData extends Record<string, unknown>> {
|
|
1229
1284
|
url: YveeURL;
|
|
@@ -1277,15 +1332,25 @@ interface GuardApp<TData extends Record<string, unknown>> {
|
|
|
1277
1332
|
data: TData;
|
|
1278
1333
|
url: IStateful<YveeURL>;
|
|
1279
1334
|
}
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
} | {
|
|
1283
|
-
kind: "stop";
|
|
1284
|
-
} | {
|
|
1335
|
+
/** A guard redirect decision. */
|
|
1336
|
+
type GuardRedirect = {
|
|
1285
1337
|
kind: "redirect";
|
|
1338
|
+
/** Destination path, optionally carrying its own query and hash. */
|
|
1286
1339
|
to: string;
|
|
1340
|
+
/** Keep the current history entry instead of pushing a new one. */
|
|
1287
1341
|
replace?: boolean;
|
|
1342
|
+
/**
|
|
1343
|
+
* Preserves the URL that was rejected as a `returnTo` query parameter on
|
|
1344
|
+
* `to`. `true` appends the current request URL (`path + search + hash`);
|
|
1345
|
+
* a string appends that explicit value instead. Omit it for a bare redirect.
|
|
1346
|
+
*/
|
|
1347
|
+
returnTo?: boolean | string;
|
|
1288
1348
|
};
|
|
1349
|
+
type GuardResult = void | {
|
|
1350
|
+
kind: "allow";
|
|
1351
|
+
} | {
|
|
1352
|
+
kind: "stop";
|
|
1353
|
+
} | GuardRedirect;
|
|
1289
1354
|
interface GuardContext<TApp = unknown, TPage = unknown, TData extends Record<string, unknown> = Record<string, unknown>> {
|
|
1290
1355
|
app: TApp;
|
|
1291
1356
|
page: TPage;
|
|
@@ -1293,11 +1358,37 @@ interface GuardContext<TApp = unknown, TPage = unknown, TData extends Record<str
|
|
|
1293
1358
|
params: Readonly<Record<string, string>>;
|
|
1294
1359
|
data: TData;
|
|
1295
1360
|
signal: AbortSignal;
|
|
1361
|
+
/**
|
|
1362
|
+
* `true` while guards run without a browser `window` (server rendering or
|
|
1363
|
+
* Bun), `false` for client-side navigation. Always populated by the guard
|
|
1364
|
+
* runner, so guard code can branch without touching globals.
|
|
1365
|
+
*/
|
|
1366
|
+
readonly server: boolean;
|
|
1296
1367
|
}
|
|
1368
|
+
/**
|
|
1369
|
+
* Guard context accepted by the runner before the environment flag is filled
|
|
1370
|
+
* in. Existing call sites may omit `server`; `checkGuards` normalizes it to a
|
|
1371
|
+
* full `GuardContext` for every guard.
|
|
1372
|
+
*/
|
|
1373
|
+
type GuardContextInput<TApp = unknown, TPage = unknown, TData extends Record<string, unknown> = Record<string, unknown>> = Omit<GuardContext<TApp, TPage, TData>, "server"> & {
|
|
1374
|
+
readonly server?: boolean;
|
|
1375
|
+
};
|
|
1297
1376
|
type Guard<TApp = unknown, TPage = unknown, TData extends Record<string, unknown> = Record<string, unknown>> = (context: GuardContext<TApp, TPage, TData>) => GuardResult | Promise<GuardResult>;
|
|
1298
1377
|
type GuardFactory<Args extends unknown[] = [], TContext = GuardContext> = (...args: Args) => (context: TContext) => GuardResult | Promise<GuardResult>;
|
|
1299
1378
|
declare const createGuard: <Args extends unknown[], TContext = GuardContext>(factory: GuardFactory<Args, TContext>) => GuardFactory<Args, TContext>;
|
|
1300
1379
|
declare const use: (...guards: Guard<any, any, any>[]) => <T extends Constructor>(controller: T) => T;
|
|
1380
|
+
/**
|
|
1381
|
+
* Returns `to` with the request URL (`path + search + hash`) appended as an
|
|
1382
|
+
* encoded `returnTo` query parameter. Guards can set `returnTo: true` instead;
|
|
1383
|
+
* this helper is for building a redirect target by hand.
|
|
1384
|
+
*/
|
|
1385
|
+
declare function buildReturnTo(url: YveeURL, to: string): string;
|
|
1386
|
+
/**
|
|
1387
|
+
* Reads and decodes a `returnTo` query parameter from a redirect target, a
|
|
1388
|
+
* `URL`, or a parsed `YveeURL`. Returns `undefined` when the parameter is
|
|
1389
|
+
* absent, so a login view can fall back to its default destination.
|
|
1390
|
+
*/
|
|
1391
|
+
declare function readReturnTo(url: string | URL | YveeURL): string | undefined;
|
|
1301
1392
|
|
|
1302
1393
|
type ContextGuard<C = GuardContext> = (context: C) => GuardResult | Promise<GuardResult>;
|
|
1303
1394
|
type GuardPredicate<C = GuardContext> = (context: C) => boolean | Promise<boolean>;
|
|
@@ -1357,6 +1448,8 @@ interface SocketRouteSource {
|
|
|
1357
1448
|
routes: RouteBook;
|
|
1358
1449
|
}
|
|
1359
1450
|
type MessageFailure = 'parse' | 'validation' | 'handler';
|
|
1451
|
+
/** Lifecycle of a socket connection: waiting to connect or retry, open, or closed/disposed. */
|
|
1452
|
+
type SocketConnectionState = 'connecting' | 'open' | 'closed';
|
|
1360
1453
|
interface JsonMessageOptions<T> {
|
|
1361
1454
|
validate?: (value: unknown) => value is T;
|
|
1362
1455
|
onError?: (error: unknown, phase: MessageFailure, event: MessageEvent) => void;
|
|
@@ -1374,12 +1467,44 @@ declare class SocketController {
|
|
|
1374
1467
|
connection?: WebSocket;
|
|
1375
1468
|
path: string;
|
|
1376
1469
|
params: Record<string, string>;
|
|
1470
|
+
/**
|
|
1471
|
+
* Reactive connection state, bindable from a view like `app.loading`.
|
|
1472
|
+
* Starts as `"connecting"`, becomes `"open"` once the native socket opens and
|
|
1473
|
+
* queued frames flush, and `"closed"` when the socket closes or the hub
|
|
1474
|
+
* disposes the controller. Retries cycle `"closed"` back to `"connecting"`.
|
|
1475
|
+
*/
|
|
1476
|
+
readonly state: IStateful<SocketConnectionState>;
|
|
1477
|
+
private queue;
|
|
1478
|
+
private disposed;
|
|
1377
1479
|
open(_event: Event): void;
|
|
1378
1480
|
message(_event: MessageEvent): void | Promise<void>;
|
|
1379
1481
|
close(_event: CloseEvent): void;
|
|
1380
1482
|
error(_event: Event): void;
|
|
1381
1483
|
messageError(error: unknown, phase: MessageFailure, _event: MessageEvent): void;
|
|
1484
|
+
/**
|
|
1485
|
+
* Sends a JSON frame, queueing it in FIFO order while the socket is missing
|
|
1486
|
+
* or not open. Queued frames flush once when the connection opens, including
|
|
1487
|
+
* after a retry reconnect. Frames sent to a disposed controller are dropped.
|
|
1488
|
+
* The queue is unbounded while waiting, so senders should avoid producing
|
|
1489
|
+
* frames faster than the connection can open. Never throws: serialization
|
|
1490
|
+
* and native send failures are logged and the frame is skipped.
|
|
1491
|
+
*
|
|
1492
|
+
* Unlike `sendJson`, this does not drop frames sent before the socket opens.
|
|
1493
|
+
*/
|
|
1494
|
+
send(value: unknown): void;
|
|
1495
|
+
/** Fire-and-forget: silently drops the frame unless the socket is open now. */
|
|
1382
1496
|
sendJson(value: unknown): void;
|
|
1497
|
+
/** @internal Binds the native socket and enters `"connecting"`. */
|
|
1498
|
+
attach(socket: WebSocket): void;
|
|
1499
|
+
/** @internal Enters `"open"`; the hub flushes queued frames after the `open` hook. */
|
|
1500
|
+
opened(): void;
|
|
1501
|
+
/** @internal Sends queued frames in FIFO order if the socket is open. */
|
|
1502
|
+
flush(): void;
|
|
1503
|
+
/** @internal Enters `"closed"`; queued frames survive for a retry reconnect. */
|
|
1504
|
+
closed(): void;
|
|
1505
|
+
/** @internal Disposes the controller: clears queued frames and enters `"closed"`. */
|
|
1506
|
+
dispose(): void;
|
|
1507
|
+
private transmit;
|
|
1383
1508
|
onMessage<T = unknown>(handler: (value: T, event: MessageEvent) => void | Promise<void>, options?: JsonMessageOptions<T>): this;
|
|
1384
1509
|
}
|
|
1385
1510
|
declare class SocketHub {
|
|
@@ -1457,6 +1582,15 @@ declare class Yvee<T extends Record<string, unknown> = Record<string, unknown>>
|
|
|
1457
1582
|
private load;
|
|
1458
1583
|
}
|
|
1459
1584
|
|
|
1585
|
+
/**
|
|
1586
|
+
* `true` when the module is evaluated in a browser (a global `window` exists).
|
|
1587
|
+
*
|
|
1588
|
+
* Evaluated once at module scope with `typeof window`, so importing this module
|
|
1589
|
+
* during server rendering or in Bun never throws. Use it in guards, pages and
|
|
1590
|
+
* auth helpers instead of repeating `typeof window === "undefined"` checks.
|
|
1591
|
+
*/
|
|
1592
|
+
declare const isClient: boolean;
|
|
1593
|
+
|
|
1460
1594
|
type StoreName = "localStorage" | "sessionStorage";
|
|
1461
1595
|
|
|
1462
1596
|
interface StorageSchema<T> {
|
|
@@ -1512,6 +1646,13 @@ declare class BrowserStore {
|
|
|
1512
1646
|
versioned<T>(key: string, schema: StorageSchema<T>): VersionedValue<T>;
|
|
1513
1647
|
/** Native storage events from other documents; same-document writes do not notify. */
|
|
1514
1648
|
watch(key: string, callback: (change: StorageChange) => void, { signal, scope }?: StorageWatchOptions): Cleanup;
|
|
1649
|
+
/**
|
|
1650
|
+
* Validated read: parses the stored JSON and returns its value only when it
|
|
1651
|
+
* passes `validate`; otherwise `.value` is `undefined`. Invalid entries are
|
|
1652
|
+
* left in storage, so call `.remove()` to discard them. A function argument
|
|
1653
|
+
* is always treated as a validator.
|
|
1654
|
+
*/
|
|
1655
|
+
get<T>(key: string, validate: (value: unknown) => value is T): StoredValue<T | undefined>;
|
|
1515
1656
|
get<T = unknown>(key: string, fallback?: T): StoredValue<T | undefined>;
|
|
1516
1657
|
/** Writes immediately; storage/serialization failures propagate to the caller. */
|
|
1517
1658
|
set<T>(key: string, value: T): StoredValue<T>;
|
|
@@ -1522,22 +1663,83 @@ declare class BrowserStore {
|
|
|
1522
1663
|
declare const local: BrowserStore;
|
|
1523
1664
|
declare const session: BrowserStore;
|
|
1524
1665
|
|
|
1666
|
+
/**
|
|
1667
|
+
* Non-success HTTP response. `body` holds the parsed JSON error body when one
|
|
1668
|
+
* was readable. The message is the explicit `message` argument, then a string
|
|
1669
|
+
* `error` or `message` field on `body`, then `HTTP <status> <statusText>`.
|
|
1670
|
+
*/
|
|
1525
1671
|
declare class HTTPError extends Error {
|
|
1526
1672
|
readonly response: Response;
|
|
1527
|
-
|
|
1673
|
+
/** Parsed JSON body of the response, or `undefined` when it was not JSON. */
|
|
1674
|
+
readonly body?: unknown;
|
|
1675
|
+
constructor(response: Response, message?: string, body?: unknown);
|
|
1676
|
+
/**
|
|
1677
|
+
* Builds an `HTTPError` after cloning the response and parsing its JSON body.
|
|
1678
|
+
* The clone is taken first, so `response` stays readable for other callers.
|
|
1679
|
+
* Parse failures leave `body` undefined.
|
|
1680
|
+
*/
|
|
1681
|
+
static fromResponse(response: Response, message?: string): Promise<HTTPError>;
|
|
1528
1682
|
}
|
|
1529
1683
|
interface RequestRetry {
|
|
1530
1684
|
/** Additional attempts, from 0 to 5. Only GET, HEAD and OPTIONS may retry. */
|
|
1531
1685
|
attempts: number;
|
|
1532
1686
|
delayMs?: number;
|
|
1533
1687
|
}
|
|
1688
|
+
interface CsrfOptions {
|
|
1689
|
+
/** Header carrying the token. Defaults to `x-csrf-token`. */
|
|
1690
|
+
header?: string;
|
|
1691
|
+
/** JSON body field carrying the token. Defaults to `csrfToken`. */
|
|
1692
|
+
field?: string;
|
|
1693
|
+
/** Token minting endpoint. Defaults to `/csrf`; `false` disables minting. */
|
|
1694
|
+
endpoint?: string | false;
|
|
1695
|
+
}
|
|
1534
1696
|
interface JSONRequestOptions<T> extends RequestInit {
|
|
1535
1697
|
validate: (value: unknown) => value is T;
|
|
1536
1698
|
retry?: RequestRetry;
|
|
1537
1699
|
fetch?: typeof globalThis.fetch;
|
|
1700
|
+
/**
|
|
1701
|
+
* Attaches a CSRF token to the request header and, for a JSON body, a body
|
|
1702
|
+
* field. `true` uses the `x-csrf-token` header, the `csrfToken` field, the
|
|
1703
|
+
* `csrf_token` cookie, a `meta[name="csrf-token"]` tag, then a cached or
|
|
1704
|
+
* freshly minted token from `GET /csrf`. Existing body fields are never
|
|
1705
|
+
* overwritten.
|
|
1706
|
+
*/
|
|
1707
|
+
csrf?: boolean | CsrfOptions;
|
|
1538
1708
|
}
|
|
1539
1709
|
/** HTTP/status failures are distinct from JSON parsing and caller validation failures. */
|
|
1540
1710
|
declare function requestJSON<T>(input: RequestInfo | URL, options: JSONRequestOptions<T>): Promise<T>;
|
|
1711
|
+
interface FormRequestOptions<T> extends Omit<RequestInit, "body"> {
|
|
1712
|
+
/** JSON payload, serialized as the request body. Ignored when `body` is set. */
|
|
1713
|
+
data?: unknown;
|
|
1714
|
+
/** Raw body such as `FormData`; takes precedence over `data`. */
|
|
1715
|
+
body?: BodyInit | null;
|
|
1716
|
+
/** Optional validator for the parsed JSON success payload. */
|
|
1717
|
+
validate?: (value: unknown) => value is T;
|
|
1718
|
+
/** CSRF options forwarded to `requestJSON`. */
|
|
1719
|
+
csrf?: boolean | CsrfOptions;
|
|
1720
|
+
fetch?: typeof globalThis.fetch;
|
|
1721
|
+
}
|
|
1722
|
+
interface FormResult<T> {
|
|
1723
|
+
ok: boolean;
|
|
1724
|
+
/** HTTP status, or `0` when no response was received. */
|
|
1725
|
+
status: number;
|
|
1726
|
+
data?: T | undefined;
|
|
1727
|
+
/** Server error text when available, otherwise the failure message. */
|
|
1728
|
+
error?: string | undefined;
|
|
1729
|
+
}
|
|
1730
|
+
/**
|
|
1731
|
+
* Submits a JSON or `FormData` body without throwing.
|
|
1732
|
+
* HTTP and network failures resolve to `{ ok: false, status, error }`; a
|
|
1733
|
+
* missing response reports status `0`. A 204/205 success has no `data`.
|
|
1734
|
+
*/
|
|
1735
|
+
declare function requestForm<T = unknown>(url: string | URL, options?: FormRequestOptions<T>): Promise<FormResult<T>>;
|
|
1736
|
+
|
|
1737
|
+
/**
|
|
1738
|
+
* Reads a cookie from `document.cookie` in the browser.
|
|
1739
|
+
* Returns `undefined` without a `document` or when the cookie is absent.
|
|
1740
|
+
* Values are decoded once; a malformed percent-encoding returns the raw value.
|
|
1741
|
+
*/
|
|
1742
|
+
declare function readCookie(name: string): string | undefined;
|
|
1541
1743
|
|
|
1542
1744
|
interface StreamHandlers {
|
|
1543
1745
|
open?: (event: Event) => void;
|
|
@@ -1558,5 +1760,5 @@ declare function renderJSONScript(value: unknown, options: {
|
|
|
1558
1760
|
nonce?: string;
|
|
1559
1761
|
}): string;
|
|
1560
1762
|
|
|
1561
|
-
export { $, ATTR, BrowserStore, Column, DOM, DbRepository, Derived, DisposalScope, Elem, EventStream, FailurePage, Field, HTTPError, HeadDefaults, IDNotConnected, IndexedDatabase, MissingPage, Page, QState, RecState, RecStateful, Ref, RefState, RouteBook, Schema, Scope, SetState, SetStateful, SocketController, SocketHub, State, StateEffect, StateHook, StateLoaded, Stateful, Stored, StoredValue, Toggled, VersionedValue, Yvee, allGuards, applyHead, attr_value, batch, createGuard, dom, error, eventStream, eventStreams, frag, getElementById, hook, interpolate, loaded, local, normalizePath, page, paramsGuard, renderContent, renderDom, renderJSONScript, requestJSON, requireGuard, route, serializePayload, session, setContentRenderer, shallowEqual, socketRoute, t, toURL, use, useRef, whenGuard };
|
|
1562
|
-
export type { $_, CSSStyle, Cleanup, ColumnType, Constructor, ContentRenderer, ContextGuard, DOMAttr, DOMComponent, DOMComponentProps, DOMContext, DOMEvents, DOMNode, DOMRenderable, DOMValue, DVal, DerivedOptions, DerivedValue, Disposable, EAttr, ElementAttributes, Elements, Equality, EventMap, FieldScopeSet, Guard, GuardApp, GuardContext, GuardFactory, GuardFallback, GuardPredicate, GuardRejection, GuardResult, HeadConfig, HeadResult, IRecStateful, ISetStateful, IStateful, JSONRequestOptions, JsonMessageOptions, Layout, MessageFailure, MountOptions, OpenOptions, PageFetchContext, RenderResult, RenderedContent, RenderedDOM, RequestRetry, RouteEntry, SVGAttributes, ScopeDecorator, ScopeProxy, ScopeSet, ServerDataContext, ServerOptions, ServerRenderer, ServerRequest, ServerStatusResult, SocketLoadOptions, StateHookOptions, StateOptions, StateUpdate, StorageChange, StorageSchema, StorageWatchOptions, StreamHandlers, StreamOptions, TagNames, Transport, YveeOptions, YveeURL, _$, aAttr, areaAttr, audioAttr, baseAttr, blockquoteAttr, buttonAttr, c_events, canvasAttr, colAttr, colgroupAttr, contenteditableAttr, dataAttr, delAttr, detailsAttr, dialogAttr, embedAttr, errorStatus, fieldsetAttr, formAttr, iframeAttr, imgAttr, inputAttr, insAttr, labelAttr, liAttr, linkAttr, mapAttr, menuAttr, metaAttr, meterAttr, objectAttr, olAttr, optgroupAttr, optionAttr, outputAttr, paramAttr, progressAttr, qAttr, renderedDom, scriptAttr, selectAttr, sourceAttr, statefulValue, styleAttr, successStatus, svgAttr, svgEAttr, svgETextAttr, tdAttr, textareaAttr, thAttr, timeAttr, trackAttr, videoAttr };
|
|
1763
|
+
export { $, ATTR, BrowserStore, Column, DOM, DbRepository, Derived, DisposalScope, Elem, EventStream, FailurePage, Field, HTTPError, HeadDefaults, IDNotConnected, IndexedDatabase, MissingPage, Page, QState, RecState, RecStateful, Ref, RefState, RouteBook, Schema, Scope, SetState, SetStateful, SocketController, SocketHub, State, StateEffect, StateHook, StateLoaded, Stateful, Stored, StoredValue, Toggled, VersionedValue, Yvee, allGuards, applyHead, attr_value, batch, buildReturnTo, createGuard, dom, error, eventStream, eventStreams, frag, getElementById, hook, interpolate, isClient, loaded, local, normalizePath, page, paramsGuard, readCookie, readReturnTo, renderContent, renderDom, renderJSONScript, requestForm, requestJSON, requireGuard, route, serializePayload, session, setContentRenderer, shallowEqual, socketRoute, t, toURL, use, useRef, whenGuard };
|
|
1764
|
+
export type { $_, CSSStyle, Cleanup, ColumnType, Constructor, ContentRenderer, ContextGuard, CsrfOptions, DOMAttr, DOMComponent, DOMComponentProps, DOMContext, DOMEvents, DOMNode, DOMRenderable, DOMValue, DVal, DerivedOptions, DerivedValue, Disposable, EAttr, ElementAttributes, Elements, Equality, EventMap, FieldScopeSet, FormRequestOptions, FormResult, Guard, GuardApp, GuardContext, GuardContextInput, GuardFactory, GuardFallback, GuardPredicate, GuardRedirect, GuardRejection, GuardResult, HeadConfig, HeadResult, IRecStateful, ISetStateful, IStateful, JSONRequestOptions, JsonMessageOptions, Layout, MessageFailure, MountOptions, OpenOptions, PageFetchContext, RenderResult, RenderedContent, RenderedDOM, RequestRetry, RouteEntry, SVGAttributes, ScopeDecorator, ScopeProxy, ScopeSet, ServerDataContext, ServerOptions, ServerRenderer, ServerRequest, ServerStatusResult, SocketConnectionState, SocketLoadOptions, StateHookOptions, StateOptions, StateUpdate, StorageChange, StorageSchema, StorageWatchOptions, StreamHandlers, StreamOptions, TagNames, Transport, YveeOptions, YveeURL, _$, aAttr, areaAttr, audioAttr, baseAttr, blockquoteAttr, buttonAttr, c_events, canvasAttr, colAttr, colgroupAttr, contenteditableAttr, dataAttr, delAttr, detailsAttr, dialogAttr, embedAttr, errorStatus, fieldsetAttr, formAttr, iframeAttr, imgAttr, inputAttr, insAttr, labelAttr, liAttr, linkAttr, mapAttr, menuAttr, metaAttr, meterAttr, objectAttr, olAttr, optgroupAttr, optionAttr, outputAttr, paramAttr, progressAttr, qAttr, renderedDom, scriptAttr, selectAttr, sourceAttr, statefulValue, styleAttr, successStatus, svgAttr, svgEAttr, svgETextAttr, tdAttr, textareaAttr, thAttr, timeAttr, trackAttr, videoAttr };
|