@@ -4,12 +4,90 @@ interface ActiveEvalEmitter {
4
4
emit ( event : string , ...args : any [ ] ) : void ;
5
5
on ( event : string , cb : ( ...args : any [ ] ) => void ) : void ;
6
6
}
7
- interface Disposer {
8
- onDidDispose : ( cb : ( ) => void ) => void ;
7
+ interface IDisposable {
9
8
dispose ( ) : void ;
10
9
}
11
- interface IdeApi {
12
- readonly client : {
10
+ interface Disposer extends IDisposable {
11
+ onDidDispose : ( cb : ( ) => void ) => void ;
12
+ }
13
+ interface Event < T > {
14
+ ( listener : ( e : T ) => any , thisArgs ?: any , disposables ?: IDisposable [ ] ) : IDisposable ;
15
+ }
16
+ interface IAction extends IDisposable {
17
+ id : string ;
18
+ label : string ;
19
+ tooltip : string ;
20
+ class : string | undefined ;
21
+ enabled : boolean ;
22
+ checked : boolean ;
23
+ radio : boolean ;
24
+ run ( event ?: any ) : Promise < any > ;
25
+ }
26
+ interface IStatusbarEntry {
27
+ readonly text : string ;
28
+ readonly tooltip ?: string ;
29
+ readonly color ?: string ;
30
+ readonly command ?: string ;
31
+ readonly arguments ?: any [ ] ;
32
+ readonly showBeak ?: boolean ;
33
+ }
34
+ interface IStatusbarService {
35
+ addEntry ( entry : IStatusbarEntry , alignment : StatusbarAlignment , priority ?: number ) : IDisposable ;
36
+ setStatusMessage ( message : string , autoDisposeAfter ?: number , delayBy ?: number ) : IDisposable ;
37
+ }
38
+ type NotificationMessage = string | Error ;
39
+ interface INotificationProperties {
40
+ sticky ?: boolean ;
41
+ silent ?: boolean ;
42
+ }
43
+ interface INotification extends INotificationProperties {
44
+ severity : Severity ;
45
+ message : NotificationMessage ;
46
+ source ?: string ;
47
+ actions ?: INotificationActions ;
48
+ }
49
+ interface INotificationActions {
50
+ primary ?: IAction [ ] ;
51
+ secondary ?: IAction [ ] ;
52
+ }
53
+
54
+ interface INotificationProgress {
55
+ infinite ( ) : void ;
56
+ total ( value : number ) : void ;
57
+ worked ( value : number ) : void ;
58
+ done ( ) : void ;
59
+ }
60
+
61
+ export interface INotificationHandle {
62
+ readonly onDidClose : Event < void > ;
63
+ readonly progress : INotificationProgress ;
64
+ updateSeverity ( severity : Severity ) : void ;
65
+ updateMessage ( message : NotificationMessage ) : void ;
66
+ updateActions ( actions ?: INotificationActions ) : void ;
67
+ close ( ) : void ;
68
+ }
69
+
70
+ export interface IPromptChoice {
71
+ label : string ;
72
+ isSecondary ?: boolean ;
73
+ keepOpen ?: boolean ;
74
+ run : ( ) => void ;
75
+ }
76
+
77
+ export interface IPromptOptions extends INotificationProperties {
78
+ onCancel ?: ( ) => void ;
79
+ }
80
+
81
+ export interface INotificationService {
82
+ notify ( notification : INotification ) : INotificationHandle ;
83
+ info ( message : NotificationMessage | NotificationMessage [ ] ) : void ;
84
+ warn ( message : NotificationMessage | NotificationMessage [ ] ) : void ;
85
+ error ( message : NotificationMessage | NotificationMessage [ ] ) : void ;
86
+ prompt ( severity : Severity , message : string , choices : IPromptChoice [ ] , options ?: IPromptOptions ) : INotificationHandle ;
87
+ }
88
+
89
+ declare namespace ide {
90
+ export const client : {
13
91
run ( func : ( helper : ActiveEvalEmitter ) => Disposer ) : ActiveEvalEmitter ;
14
92
run < T1 > ( func : ( helper : ActiveEvalEmitter , a1 : T1 ) => Disposer , a1 : T1 ) : ActiveEvalEmitter ;
15
93
run < T1 , T2 > ( func : ( helper : ActiveEvalEmitter , a1 : T1 , a2 : T2 ) => Disposer , a1 : T1 , a2 : T2 ) : ActiveEvalEmitter ;
@@ -26,13 +104,29 @@ interface IdeApi {
26
104
evaluate < R , T1 , T2 , T3 , T4 , T5 > ( func : ( helper : EvalHelper , a1 : T1 , a2 : T2 , a3 : T3 , a4 : T4 , a5 : T5 ) => R | Promise < R > , a1 : T1 , a2 : T2 , a3 : T3 , a4 : T4 , a5 : T5 ) : Promise < R > ;
27
105
evaluate < R , T1 , T2 , T3 , T4 , T5 , T6 > ( func : ( helper : EvalHelper , a1 : T1 , a2 : T2 , a3 : T3 , a4 : T4 , a5 : T5 , a6 : T6 ) => R | Promise < R > , a1 : T1 , a2 : T2 , a3 : T3 , a4 : T4 , a5 : T5 , a6 : T6 ) : Promise < R > ;
28
106
} ;
29
- readonly workbench : {
30
- getService < T > ( identifier : any ) : T | undefined ;
107
+
108
+ export const workbench : {
109
+ readonly statusbarService : IStatusbarService ;
110
+ readonly notificationService : INotificationService ;
31
111
} ;
32
- }
33
112
34
- declare interface Window {
35
- ide ?: IdeApi ;
113
+ export enum Severity {
114
+ Ignore = 0 ,
115
+ Info = 1 ,
116
+ Warning = 2 ,
117
+ Error = 3
118
+ }
36
119
37
- addEventListener ( event : "ide-ready" , callback : ( ide : CustomEvent & { readonly ide : IdeApi } ) => void ) : void ;
38
- }
120
+ export enum StatusbarAlignment {
121
+ LEFT = 0 ,
122
+ RIGHT = 1 ,
123
+ }
124
+ }
125
+
126
+ declare global {
127
+ interface Window {
128
+ ide ?: typeof ide ;
129
+
130
+ addEventListener ( event : "ide-ready" , callback : ( ide : CustomEvent & { readonly ide : IdeApi } ) => void ) : void ;
131
+ }
132
+ }
0 commit comments