@@ -23,18 +23,19 @@ declare type StringDict = {
23
23
//
24
24
////////////////////////////////////////////////////////////////////////////////
25
25
26
- interface GmailTracker {
26
+ interface GmailTracker < T extends string = never > {
27
+ dom_observers : { [ observer in GmailDomObserver | T ] ?: DomObserverConfig } ;
27
28
globals : any [ ] ;
28
29
view_data : any [ ] ;
29
30
ik : string ;
30
31
hangouts : any ;
31
32
events : { } [ ] ;
32
33
actions : { } [ ] ;
33
34
watchdog : {
34
- before : { } ,
35
- on : { } ,
36
- after : { } ,
37
- dom : { }
35
+ before : { [ action in GmailBindAction | T ] ?: Function [ ] } ;
36
+ on : { [ action in GmailBindAction | T ] ?: Function [ ] } ;
37
+ after : { [ action in GmailBindAction | T ] ?: Function [ ] } ;
38
+ dom : { [ observer in GmailDomObserver | T ] ?: Function [ ] } ;
38
39
} ;
39
40
}
40
41
@@ -55,9 +56,9 @@ declare type GmailPageType =
55
56
declare type GmailEmailAddress = string [ ] ;
56
57
57
58
declare type GmailDomComposeRecipients = {
58
- to : string [ ] ;
59
- cc : string [ ] ;
60
- bcc : string [ ] ;
59
+ to : string [ ] ;
60
+ cc : string [ ] ;
61
+ bcc : string [ ] ;
61
62
}
62
63
63
64
declare type GmailAttachmentDetails = {
@@ -489,7 +490,7 @@ interface GmailDomEmail {
489
490
490
491
declare type GmailDomComposeLookup =
491
492
'to' | 'cc' | 'bcc' | 'id' | 'draft' | 'subject' | 'subjectbox'
492
- | 'all_subjects' | 'body' | 'quoted_reply' | 'reply' | 'forward' | 'from' | 'send_button' | 'show_cc' | 'show_bcc' ;
493
+ | 'all_subjects' | 'body' | 'quoted_reply' | 'reply' | 'forward' | 'from' | 'send_button' | 'show_cc' | 'show_bcc' ;
493
494
494
495
interface GmailMessageRow {
495
496
summary : string ;
@@ -671,7 +672,7 @@ interface GmailTools {
671
672
observes every element inserted into the DOM by Gmail and looks at the classes on those elements,
672
673
checking for any configured observers related to those classes
673
674
*/
674
- insertion_observer ( target : HTMLElement | string , dom_observers : any , dom_observer_map : any , sub : any ) : void ;
675
+ insertion_observer ( target : HTMLElement | string , dom_observers : { [ observer : string ] : DomObserverConfig } , dom_observer_map : { [ className : string ] : string [ ] } , sub ?: string ) : void ;
675
676
676
677
make_request ( link : string , method : GmailHttpRequestMethod , disable_cache : boolean ) : string ;
677
678
make_request_async ( link : string , method : GmailHttpRequestMethod , callback : ( data : string ) => void , disable_cache : boolean ) : void ;
@@ -718,11 +719,11 @@ interface GmailTools {
718
719
add_right_toolbar_button ( content_html : string , onClickFunction : Function , styleClass : string ) : JQuery ;
719
720
add_compose_button ( composeWindow : GmailDomCompose , content_html : string , onClickFunction : Function , styleClass ?: string ) : JQuery ;
720
721
add_more_send_option (
721
- composeWindow : GmailDomCompose ,
722
- buttonText : string ,
723
- onClickFunction : Function ,
724
- styleClass ?: string | undefined ,
725
- imgClass ?: string | undefined
722
+ composeWindow : GmailDomCompose ,
723
+ buttonText : string ,
724
+ onClickFunction : Function ,
725
+ styleClass ?: string | undefined ,
726
+ imgClass ?: string | undefined
726
727
) : JQuery ;
727
728
/**
728
729
adds a button to an email attachment.
@@ -764,23 +765,25 @@ declare type GmailBindAction =
764
765
| 'new_email' | 'refresh' | 'open_email' | 'upload_attachment' | 'compose'
765
766
| 'compose_cancelled' | 'recipient_change' | 'view_thread' | 'view_email'
766
767
| 'load_email_menu' ;
768
+ declare type GmailDomObserver =
769
+ 'view_thread' | 'view_email' | 'load_email_menu' | 'recipient_change' | 'compose'
767
770
768
771
interface HttpEventRequestParams {
769
- url : object ,
770
- url_raw : string ;
771
- body : string ;
772
- body_params : object ;
773
- method : string ;
772
+ url : object ,
773
+ url_raw : string ;
774
+ body : string ;
775
+ body_params : object ;
776
+ method : string ;
774
777
}
775
778
776
779
interface DomObserverConfig {
777
- class : string | string [ ] ;
778
- selector ?: string ;
779
- sub_selector ?: string ;
780
- handler ?: Function ;
781
- }
780
+ class : string | string [ ] ;
781
+ selector ?: string ;
782
+ sub_selector ?: string ;
783
+ handler ?: Function ;
784
+ }
782
785
783
- interface GmailObserve < T extends string = never > {
786
+ interface GmailObserve < T extends string = never > {
784
787
/**
785
788
After an observer has been bound through gmail.observe.bind() (via a
786
789
call to events gmail.observe.before(), gmail.observe.on(), or
@@ -798,7 +801,7 @@ interface GmailObserve<T extends string=never> {
798
801
/**
799
802
Bind a specified callback to an array of callbacks against a specified type & action
800
803
*/
801
- bind ( type : GmailBindType , action : Function , callback : Function ) : void ;
804
+ bind ( type : GmailBindType , action : GmailBindAction | T , callback : Function ) : void ;
802
805
803
806
/**
804
807
an on event is observed just after gmail sends an xhr request
@@ -850,11 +853,11 @@ interface GmailObserve<T extends string=never> {
850
853
Trigger any specified events bound to the passed type
851
854
Returns true or false depending if any events were fired
852
855
*/
853
- trigger ( type : GmailBindType , events : any , xhr : XMLHttpRequest ) : boolean ;
856
+ trigger ( type : GmailBindType , events : { [ action in GmailBindAction | T ] ?: any [ ] } , xhr : XMLHttpRequest ) : boolean ;
854
857
/**
855
858
Trigger any specified DOM events passing a specified element & optional handler
856
859
*/
857
- trigger_dom ( observer : any , element : HTMLElement , handler ?: Function ) : void ;
860
+ trigger_dom ( observer : GmailDomObserver | T , element : HTMLElement , handler ?: Function ) : void ;
858
861
859
862
initialize_dom_observers ( ) : void ;
860
863
@@ -867,7 +870,7 @@ interface GmailObserve<T extends string=never> {
867
870
className / args - for a simple observer, this arg can simply be the class on an inserted DOM element that identifies this event should be
868
871
triggered. For a more complicated observer, this can be an object containing properties for each of the supported DOM observer config arguments
869
872
*/
870
- register ( action : string , args : string | DomObserverConfig ) : void ;
873
+ register ( action : T , args : string | DomObserverConfig ) : void ;
871
874
/**
872
875
Observe DOM nodes being inserted. When a node with a class defined in api.tracker.dom_observers is inserted,
873
876
trigger the related event and fire off any relevant bound callbacks
@@ -1030,15 +1033,15 @@ interface GmailCache {
1030
1033
//
1031
1034
////////////////////////////////////////////////////////////////////////////////
1032
1035
1033
- declare class Gmail < T extends string = never > {
1034
- constructor ( localJQuery ? : JQueryStatic ) ;
1036
+ declare class Gmail < T extends string = never > {
1037
+ constructor ( localJQuery : JQueryStatic | false ) ;
1035
1038
1036
1039
version : string ;
1037
1040
/**
1038
1041
These are some of the variables that are tracked and kept in
1039
1042
memory while the rest of the methods are in use.
1040
1043
*/
1041
- tracker : GmailTracker ;
1044
+ tracker : GmailTracker < T > ;
1042
1045
get : GmailGet ;
1043
1046
check : GmailCheck ;
1044
1047
/**
0 commit comments