|
1 |
| -// tslint:disable no-any |
| 1 | +import * as vscode from "vscode"; |
2 | 2 |
|
3 |
| -import { ITerminalService } from "vs/workbench/contrib/terminal/common/terminal"; |
4 |
| -import { IWorkbenchActionRegistry } from 'vs/workbench/common/actions'; |
5 |
| -import { Action } from 'vs/base/common/actions'; |
6 |
| -import { SyncActionDescriptor } from 'vs/platform/actions/common/actions'; |
| 3 | +export { vscode }; |
7 | 4 |
|
8 |
| -export interface EvalHelper { } |
9 |
| -interface ActiveEvalEmitter { |
10 |
| - removeAllListeners(event?: string): void; |
11 |
| - emit(event: string, ...args: any[]): void; |
12 |
| - on(event: string, cb: (...args: any[]) => void): void; |
13 |
| -} |
14 |
| -interface IDisposable { |
15 |
| - dispose(): void; |
16 |
| -} |
17 |
| -interface Disposer extends IDisposable { |
18 |
| - onDidDispose: (cb: () => void) => void; |
19 |
| -} |
20 |
| -interface Event<T> { |
21 |
| - (listener: (e: T) => any, thisArgs?: any, disposables?: IDisposable[]): IDisposable; |
22 |
| -} |
23 |
| -interface IAction extends IDisposable { |
24 |
| - id: string; |
25 |
| - label: string; |
26 |
| - tooltip: string; |
27 |
| - class: string | undefined; |
28 |
| - enabled: boolean; |
29 |
| - checked: boolean; |
30 |
| - radio: boolean; |
31 |
| - run(event?: any): Promise<any>; |
32 |
| -} |
33 |
| -interface IStatusbarEntry { |
34 |
| - readonly text: string; |
35 |
| - readonly tooltip?: string; |
36 |
| - readonly color?: string; |
37 |
| - readonly command?: string; |
38 |
| - readonly arguments?: any[]; |
39 |
| - readonly showBeak?: boolean; |
40 |
| -} |
41 |
| -interface IStatusbarService { |
42 |
| - addEntry(entry: IStatusbarEntry, alignment: ide.StatusbarAlignment, priority?: number): IDisposable; |
43 |
| - setStatusMessage(message: string, autoDisposeAfter?: number, delayBy?: number): IDisposable; |
44 |
| -} |
45 |
| -type NotificationMessage = string | Error; |
46 |
| -interface INotificationProperties { |
47 |
| - sticky?: boolean; |
48 |
| - silent?: boolean; |
49 |
| -} |
50 |
| -interface INotification extends INotificationProperties { |
51 |
| - severity: ide.Severity; |
52 |
| - message: NotificationMessage; |
53 |
| - source?: string; |
54 |
| - actions?: INotificationActions; |
55 |
| -} |
56 |
| -interface INotificationActions { |
57 |
| - primary?: IAction[]; |
58 |
| - secondary?: IAction[]; |
59 |
| -} |
60 |
| - |
61 |
| -interface INotificationProgress { |
62 |
| - infinite(): void; |
63 |
| - total(value: number): void; |
64 |
| - worked(value: number): void; |
65 |
| - done(): void; |
66 |
| -} |
67 |
| - |
68 |
| -interface INotificationHandle { |
69 |
| - readonly onDidClose: Event<void>; |
70 |
| - readonly progress: INotificationProgress; |
71 |
| - updateSeverity(severity: ide.Severity): void; |
72 |
| - updateMessage(message: NotificationMessage): void; |
73 |
| - updateActions(actions?: INotificationActions): void; |
74 |
| - close(): void; |
75 |
| -} |
76 |
| - |
77 |
| -interface IPromptChoice { |
78 |
| - label: string; |
79 |
| - isSecondary?: boolean; |
80 |
| - keepOpen?: boolean; |
81 |
| - run: () => void; |
82 |
| -} |
83 |
| - |
84 |
| -interface IPromptOptions extends INotificationProperties { |
85 |
| - onCancel?: () => void; |
86 |
| -} |
87 |
| - |
88 |
| -interface INotificationService { |
89 |
| - notify(notification: INotification): INotificationHandle; |
90 |
| - info(message: NotificationMessage | NotificationMessage[]): void; |
91 |
| - warn(message: NotificationMessage | NotificationMessage[]): void; |
92 |
| - error(message: NotificationMessage | NotificationMessage[]): void; |
93 |
| - prompt(severity: ide.Severity, message: string, choices: IPromptChoice[], options?: IPromptOptions): INotificationHandle; |
94 |
| -} |
95 |
| - |
96 |
| -interface IBaseCommandAction { |
97 |
| - id: string; |
98 |
| - title: string; |
99 |
| - category?: string; |
100 |
| -} |
101 |
| - |
102 |
| -interface ICommandAction extends IBaseCommandAction { |
103 |
| - // iconLocation?: { dark: URI; light?: URI; }; |
104 |
| - // precondition?: ContextKeyExpr; |
105 |
| - // toggled?: ContextKeyExpr; |
106 |
| -} |
107 |
| - |
108 |
| -interface ISerializableCommandAction extends IBaseCommandAction { |
109 |
| - // iconLocation?: { dark: UriComponents; light?: UriComponents; }; |
110 |
| -} |
111 |
| - |
112 |
| -interface IMenuItem { |
113 |
| - command: ICommandAction; |
114 |
| - alt?: ICommandAction; |
115 |
| - // when?: ContextKeyExpr; |
116 |
| - group?: "navigation" | string; |
117 |
| - order?: number; |
118 |
| -} |
119 |
| - |
120 |
| -interface IMenuRegistry { |
121 |
| - appendMenuItem(menu: ide.MenuId, item: IMenuItem): IDisposable; |
122 |
| -} |
123 |
| - |
124 |
| -export interface ICommandHandler { |
125 |
| - (accessor: any, ...args: any[]): void; |
126 |
| -} |
127 |
| - |
128 |
| -export interface ICommand { |
129 |
| - id: string; |
130 |
| - handler: ICommandHandler; |
131 |
| - description?: ICommandHandlerDescription | null; |
132 |
| -} |
133 |
| - |
134 |
| -export interface ICommandHandlerDescription { |
135 |
| - description: string; |
136 |
| - args: { name: string; description?: string; }[]; |
137 |
| - returns?: string; |
138 |
| -} |
139 |
| - |
140 |
| -interface ICommandRegistry { |
141 |
| - registerCommand(command: ICommand): IDisposable; |
142 |
| -} |
| 5 | +// Honestly no idea why this works. |
| 6 | +export import ide = coder; |
143 | 7 |
|
144 |
| -interface IStorageService { |
145 |
| - save(): Promise<void>; |
146 |
| -} |
147 |
| - |
148 |
| -declare namespace ide { |
149 |
| - export const client: {}; |
150 |
| - |
151 |
| - export const workbench: { |
152 |
| - readonly action: Action, |
153 |
| - readonly syncActionDescriptor: SyncActionDescriptor, |
154 |
| - readonly statusbarService: IStatusbarService; |
155 |
| - readonly actionsRegistry: IWorkbenchActionRegistry; |
156 |
| - readonly notificationService: INotificationService; |
157 |
| - readonly storageService: IStorageService; |
158 |
| - readonly menuRegistry: IMenuRegistry; |
159 |
| - readonly commandRegistry: ICommandRegistry; |
160 |
| - readonly terminalService: ITerminalService; |
161 |
| - |
162 |
| - onFileCreate(cb: (path: string) => void): void; |
163 |
| - onFileMove(cb: (path: string, target: string) => void): void; |
164 |
| - onFileDelete(cb: (path: string) => void): void; |
165 |
| - onFileSaved(cb: (path: string) => void): void; |
166 |
| - onFileCopy(cb: (path: string, target: string) => void): void; |
167 |
| - |
168 |
| - onModelAdded(cb: (path: string, languageId: string) => void): void; |
169 |
| - onModelRemoved(cb: (path: string, languageId: string) => void): void; |
170 |
| - onModelLanguageChange(cb: (path: string, languageId: string, oldLanguageId: string) => void): void; |
171 |
| - |
172 |
| - onTerminalAdded(cb: () => void): void; |
173 |
| - onTerminalRemoved(cb: () => void): void; |
174 |
| - }; |
175 |
| - |
176 |
| - export enum Severity { |
177 |
| - Ignore = 0, |
178 |
| - Info = 1, |
179 |
| - Warning = 2, |
180 |
| - Error = 3, |
181 |
| - } |
182 |
| - |
183 |
| - export enum StatusbarAlignment { |
184 |
| - LEFT = 0, |
185 |
| - RIGHT = 1, |
186 |
| - } |
187 |
| - |
188 |
| - export enum MenuId { |
189 |
| - CommandPalette, |
190 |
| - DebugBreakpointsContext, |
191 |
| - DebugCallStackContext, |
192 |
| - DebugConsoleContext, |
193 |
| - DebugVariablesContext, |
194 |
| - DebugWatchContext, |
195 |
| - EditorContext, |
196 |
| - EditorTitle, |
197 |
| - EditorTitleContext, |
198 |
| - EmptyEditorGroupContext, |
199 |
| - ExplorerContext, |
200 |
| - MenubarAppearanceMenu, |
201 |
| - MenubarDebugMenu, |
202 |
| - MenubarEditMenu, |
203 |
| - MenubarFileMenu, |
204 |
| - MenubarGoMenu, |
205 |
| - MenubarHelpMenu, |
206 |
| - MenubarLayoutMenu, |
207 |
| - MenubarNewBreakpointMenu, |
208 |
| - MenubarPreferencesMenu, |
209 |
| - MenubarRecentMenu, |
210 |
| - MenubarSelectionMenu, |
211 |
| - MenubarSwitchEditorMenu, |
212 |
| - MenubarSwitchGroupMenu, |
213 |
| - MenubarTerminalMenu, |
214 |
| - MenubarViewMenu, |
215 |
| - OpenEditorsContext, |
216 |
| - ProblemsPanelContext, |
217 |
| - SCMChangeContext, |
218 |
| - SCMResourceContext, |
219 |
| - SCMResourceGroupContext, |
220 |
| - SCMSourceControl, |
221 |
| - SCMTitle, |
222 |
| - SearchContext, |
223 |
| - TouchBarContext, |
224 |
| - ViewItemContext, |
225 |
| - ViewTitle, |
226 |
| - } |
| 8 | +export interface IdeReadyEvent extends CustomEvent<void> { |
| 9 | + readonly vscode: typeof vscode; |
| 10 | + readonly ide: typeof ide; |
227 | 11 | }
|
228 | 12 |
|
229 | 13 | declare global {
|
230 | 14 | interface Window {
|
| 15 | + /** |
| 16 | + * Full VS Code extension API. |
| 17 | + */ |
| 18 | + vscode?: typeof vscode; |
| 19 | + |
| 20 | + /** |
| 21 | + * Coder API. |
| 22 | + */ |
231 | 23 | ide?: typeof ide;
|
232 | 24 |
|
233 |
| - addEventListener(event: "ide-ready", callback: (ide: CustomEvent & { readonly ide: typeof ide }) => void): void; |
| 25 | + /** |
| 26 | + * Listen for when the IDE API has been set and is ready to use. |
| 27 | + */ |
| 28 | + addEventListener(event: "ide-ready", callback: (event: IdeReadyEvent) => void): void; |
234 | 29 | }
|
235 | 30 | }
|
0 commit comments