@opensumi/sumi 2.12.1-next-079c1930
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 +1 -0
- package/build.ts +18 -0
- package/index.d.ts +5 -0
- package/manifest.json +414 -0
- package/package.json +18 -0
- package/sumi-browser.d.ts +273 -0
- package/sumi-worker/sumi-worker.d.ts +2788 -0
- package/sumi-worker/worker.command.d.ts +86 -0
- package/sumi-worker/worker.comments.d.ts +273 -0
- package/sumi-worker/worker.doc.d.ts +356 -0
- package/sumi-worker/worker.editor.d.ts +725 -0
- package/sumi-worker/worker.extensions.d.ts +63 -0
- package/sumi-worker/worker.language.d.ts +2220 -0
- package/sumi-worker/worker.window.d.ts +318 -0
- package/sumi-worker.d.ts +7 -0
- package/sumi.d.ts +822 -0
- package/vscode/typings/vscode.authentication.d.ts +231 -0
- package/vscode/typings/vscode.command.d.ts +86 -0
- package/vscode/typings/vscode.comments.d.ts +292 -0
- package/vscode/typings/vscode.d.ts +3789 -0
- package/vscode/typings/vscode.debug.d.ts +684 -0
- package/vscode/typings/vscode.doc.d.ts +272 -0
- package/vscode/typings/vscode.editor.d.ts +1017 -0
- package/vscode/typings/vscode.env.d.ts +153 -0
- package/vscode/typings/vscode.extension.d.ts +67 -0
- package/vscode/typings/vscode.language.d.ts +2630 -0
- package/vscode/typings/vscode.message.d.ts +195 -0
- package/vscode/typings/vscode.proposed.d.ts +662 -0
- package/vscode/typings/vscode.quickpick.d.ts +491 -0
- package/vscode/typings/vscode.scm.d.ts +254 -0
- package/vscode/typings/vscode.tasks.d.ts +676 -0
- package/vscode/typings/vscode.theme.d.ts +370 -0
- package/vscode/typings/vscode.window.d.ts +870 -0
- package/vscode/typings/vscode.workspace.d.ts +664 -0
- package/vscode/typings-pending/vscode.d.ts +27 -0
- package/vscode/typings-pending/vscode.proposed.d.ts +3 -0
- package/vscode.d.ts +23 -0
package/sumi.d.ts
ADDED
|
@@ -0,0 +1,822 @@
|
|
|
1
|
+
/* tslint:disable callable-types */
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated `kaitian` was deprecated, Please use `sumi` instead.
|
|
4
|
+
*/
|
|
5
|
+
declare module 'kaitian' {
|
|
6
|
+
export * from 'sumi';
|
|
7
|
+
}
|
|
8
|
+
declare module 'sumi' {
|
|
9
|
+
export * from 'vscode';
|
|
10
|
+
|
|
11
|
+
import { ExtensionContext as VSCodeExtensionContext, Disposable, TextEditor, TextEditorEdit, ExtensionKind } from 'vscode';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Represents an extension.
|
|
15
|
+
*
|
|
16
|
+
* To get an instance of an `Extension` use [getExtension](#extensions.getExtension).
|
|
17
|
+
*/
|
|
18
|
+
export interface Extension<T> {
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The canonical extension identifier in the form of: `publisher.name`.
|
|
22
|
+
*/
|
|
23
|
+
readonly id: string;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The absolute file path of the directory containing this extension.
|
|
27
|
+
*/
|
|
28
|
+
readonly extensionPath: string;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* `true` if the extension has been activated.
|
|
32
|
+
*/
|
|
33
|
+
readonly isActive: boolean;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The parsed contents of the extension's package.json.
|
|
37
|
+
*/
|
|
38
|
+
readonly packageJSON: any;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The extension kind describes if an extension runs where the UI runs
|
|
42
|
+
* or if an extension runs where the remote extension host runs. The extension kind
|
|
43
|
+
* if defined in the `package.json` file of extensions but can also be refined
|
|
44
|
+
* via the the `remote.extensionKind`-setting. When no remote extension host exists,
|
|
45
|
+
* the value is [`ExtensionKind.UI`](#ExtensionKind.UI).
|
|
46
|
+
*/
|
|
47
|
+
extensionKind: ExtensionKind;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The public API exported by this extension. It is an invalid action
|
|
51
|
+
* to access this field before this extension has been activated.
|
|
52
|
+
*/
|
|
53
|
+
readonly exports: T;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The public API exported by this extension's node entry. It is an invalid action
|
|
57
|
+
* to access this field before this extension has been activated.
|
|
58
|
+
*/
|
|
59
|
+
readonly extendExports: T;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Activates this extension and returns its public API.
|
|
63
|
+
*
|
|
64
|
+
* @return A promise that will resolve when this extension has been activated.
|
|
65
|
+
*/
|
|
66
|
+
activate(): Thenable<T>;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export namespace extensions {
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Get an extension by its full identifier in the form of: `publisher.name`.
|
|
73
|
+
*
|
|
74
|
+
* @param extensionId An extension identifier.
|
|
75
|
+
* @return An extension or `undefined`.
|
|
76
|
+
*/
|
|
77
|
+
export function getExtension(extensionId: string): Extension<any> | undefined;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Get an extension its full identifier in the form of: `publisher.name`.
|
|
81
|
+
*
|
|
82
|
+
* @param extensionId An extension identifier.
|
|
83
|
+
* @return An extension or `undefined`.
|
|
84
|
+
*/
|
|
85
|
+
export function getExtension<T>(extensionId: string): Extension<T> | undefined;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* All extensions currently known to the system.
|
|
89
|
+
*/
|
|
90
|
+
export const all: ReadonlyArray<Extension<any>>;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* An event which fires when `extensions.all` changes. This can happen when extensions are
|
|
94
|
+
* installed, uninstalled, enabled or disabled.
|
|
95
|
+
*/
|
|
96
|
+
export const onDidChange: Event<void>;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export namespace event {
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* 事件响应的返回结果
|
|
103
|
+
*/
|
|
104
|
+
interface IEventResult<R> {
|
|
105
|
+
/**
|
|
106
|
+
* 如果存在err,说明本次调用存在错误
|
|
107
|
+
*/
|
|
108
|
+
err?: string;
|
|
109
|
+
/**
|
|
110
|
+
* 调用结果
|
|
111
|
+
*/
|
|
112
|
+
result?: R;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* 订阅一个事件
|
|
117
|
+
* @param eventId 事件id
|
|
118
|
+
* @param callback 事件订阅回调
|
|
119
|
+
*/
|
|
120
|
+
export function subscribe(eventId: string, callback: (...args: any[]) => any): IDisposable;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* 发送一个事件
|
|
124
|
+
* @param eventId 事件id
|
|
125
|
+
* @param args 事件参数
|
|
126
|
+
* @returns Promise 返回处理事件响应的listener的返回值
|
|
127
|
+
*/
|
|
128
|
+
export function fire<R = any>(eventId: string, ...args: any[]): Promise<IEventResult<R>[]>;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export namespace layout {
|
|
132
|
+
/**
|
|
133
|
+
* 切换底部面板显示/隐藏
|
|
134
|
+
*/
|
|
135
|
+
export function toggleBottomPanel(): Promise<void>;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* 获取一个 Tab 的 Handle
|
|
139
|
+
* @param id tab id
|
|
140
|
+
*/
|
|
141
|
+
export function getTabbarHandler(id: string): ITabbarHandle;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* 获取一个 Tab 的 Handle
|
|
145
|
+
* @param id tab id, 不限制在本插件注册的handle,需要自己进行字符串拼接
|
|
146
|
+
*/
|
|
147
|
+
export function getExtensionTabbarHandler(id: string, extensionId?: string): ITabbarHandle;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* 切换左侧面板显示/隐藏
|
|
151
|
+
*/
|
|
152
|
+
export function toggleLeftPanel(): Promise<void>;
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* 切换右侧面板显示/隐藏
|
|
156
|
+
*/
|
|
157
|
+
export function toggleRightPanel(): Promise<void>;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* 显示右侧面板
|
|
161
|
+
*/
|
|
162
|
+
export function showRightPanel(): Promise<void>;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* 隐藏右侧面板
|
|
166
|
+
*/
|
|
167
|
+
export function hideRightPanel(): Promise<void>;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* 激活指定 id 的面板,需在注册时指定 activateKeyBinding
|
|
171
|
+
* @param id
|
|
172
|
+
*/
|
|
173
|
+
export function activatePanel(id: string): Promise<void>;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* 返回底部面板是否可见
|
|
177
|
+
*/
|
|
178
|
+
export function isBottomPanelVisible(): Promise<boolean>;
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* 返回左侧面板是否可见
|
|
182
|
+
*/
|
|
183
|
+
export function isLeftPanelVisible(): Promise<boolean>;
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* 返回右侧面板是否可见
|
|
187
|
+
*/
|
|
188
|
+
export function isRightPanelVisible(): Promise<boolean>;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export interface IIDEWindowWebviewOptions {
|
|
192
|
+
/**
|
|
193
|
+
* 窗口宽度,默认 `800`
|
|
194
|
+
*/
|
|
195
|
+
width?: number;
|
|
196
|
+
/**
|
|
197
|
+
* 窗口高度,默认 `600`
|
|
198
|
+
*/
|
|
199
|
+
height?: number;
|
|
200
|
+
|
|
201
|
+
[key: string]: any;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export interface IIDEWindowWebviewEnv {
|
|
205
|
+
/**
|
|
206
|
+
* 注入webview中的环境变量
|
|
207
|
+
*/
|
|
208
|
+
[key: string]: any;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export interface IIDEWebviewWindow extends Disposable {
|
|
212
|
+
/**
|
|
213
|
+
* 加载webview窗口内的资源地址
|
|
214
|
+
* @param url
|
|
215
|
+
*/
|
|
216
|
+
loadUrl(url: string): Promise<void>;
|
|
217
|
+
/**
|
|
218
|
+
* 隐藏webview窗口
|
|
219
|
+
*/
|
|
220
|
+
hide(): Promise<void>;
|
|
221
|
+
/**
|
|
222
|
+
* 展示webview窗口
|
|
223
|
+
*/
|
|
224
|
+
show(): Promise<void>;
|
|
225
|
+
/**
|
|
226
|
+
* 设置webview窗口大小
|
|
227
|
+
* @param size
|
|
228
|
+
*/
|
|
229
|
+
setSize(size: {width: number; height: number}): Promise<void>;
|
|
230
|
+
/**
|
|
231
|
+
* 设置webview窗口是否置顶
|
|
232
|
+
* @param flag
|
|
233
|
+
*/
|
|
234
|
+
setAlwaysOnTop(flag: boolean): Promise<void>;
|
|
235
|
+
/**
|
|
236
|
+
* 传递消息至webview窗口
|
|
237
|
+
* @param message
|
|
238
|
+
*/
|
|
239
|
+
postMessage(message: any): Promise<void>;
|
|
240
|
+
/**
|
|
241
|
+
* 接收webview窗口回传消息事件
|
|
242
|
+
*/
|
|
243
|
+
onMessage: Event<any>;
|
|
244
|
+
/**
|
|
245
|
+
* 接收webview窗口关闭事件
|
|
246
|
+
*/
|
|
247
|
+
onClosed: Event<void>;
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Electron Window 的 windowId
|
|
251
|
+
*/
|
|
252
|
+
windowId: number;
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Electron Window 的 webContentsId
|
|
256
|
+
*/
|
|
257
|
+
webContentsId: number;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export namespace ideWindow {
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* 刷新当前 IDE 窗口
|
|
264
|
+
*/
|
|
265
|
+
export function reloadWindow(): void;
|
|
266
|
+
/**
|
|
267
|
+
* 打开新的窗口 仅支持 Electron 环境
|
|
268
|
+
*/
|
|
269
|
+
export function createWebviewWindow(webviewId: string, options?: IIDEWindowWebviewOptions, env?: IIDEWindowWebviewEnv): Promise<IIDEWebviewWindow>;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export namespace lifecycle {
|
|
273
|
+
/**
|
|
274
|
+
* 设置 IDE 所加载的插件目录,仅 Electron 下可用,调用后需刷新当前窗口
|
|
275
|
+
* @param extensionDir 插件目录
|
|
276
|
+
*/
|
|
277
|
+
export function setExtensionDir(extensionDir: string): Promise<void>;
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* 设置 IDE 所加载的额外插件列表,具体到插件路径
|
|
281
|
+
* @param extensionCandidate 插件列表
|
|
282
|
+
*
|
|
283
|
+
* @example
|
|
284
|
+
* ```typescript
|
|
285
|
+
* lifecycle.setExtensionCandidate([
|
|
286
|
+
* { path: '/path/to/ext-1.0', isBuintin: true }
|
|
287
|
+
* ]);
|
|
288
|
+
* ```
|
|
289
|
+
*/
|
|
290
|
+
export function setExtensionCandidate(extensionCandidate: ExtensionCandidate[]): Promise<void>;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* 主题相关API
|
|
295
|
+
*/
|
|
296
|
+
export namespace theme {
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* 当主题被改变时的通知
|
|
300
|
+
*/
|
|
301
|
+
export const onThemeChanged: Event<void>;
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* 获得当前主题的颜色值
|
|
305
|
+
* 格式 '-分割的颜色名':'颜色值(rgb, rgba或hex)'
|
|
306
|
+
* @example
|
|
307
|
+
* ```json
|
|
308
|
+
* {
|
|
309
|
+
* 'editor-background':'#000000',
|
|
310
|
+
* }
|
|
311
|
+
* ```
|
|
312
|
+
*/
|
|
313
|
+
export function getThemeColors(): Promise<{ [key: string]: string }>;
|
|
314
|
+
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
export enum ExtensionHostKind {
|
|
318
|
+
NODE_HOST = 1,
|
|
319
|
+
WORKER_HOST = 2,
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
export interface ExtensionCandidate {
|
|
323
|
+
path: string;
|
|
324
|
+
isBuintin: boolean;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
export interface IPlainWebviewHandle {
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* 向webview内部发送消息
|
|
331
|
+
* @param message
|
|
332
|
+
*/
|
|
333
|
+
postMessage(message: any): Promise<boolean>;
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* 接受来自webview的信息
|
|
337
|
+
* @example
|
|
338
|
+
* ```typescript
|
|
339
|
+
* const handle = getPlainWebviewHandle('id');
|
|
340
|
+
* handle.onMessage((e: any) => {
|
|
341
|
+
* // your code
|
|
342
|
+
* })
|
|
343
|
+
* ```
|
|
344
|
+
*/
|
|
345
|
+
onMessage: Event<any>;
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* 加载一个url
|
|
349
|
+
*/
|
|
350
|
+
loadUrl(url: string): Promise<void>;
|
|
351
|
+
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
export interface IDisposable {
|
|
355
|
+
/**
|
|
356
|
+
* Dispose this object.
|
|
357
|
+
*/
|
|
358
|
+
dispose(): void;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
export interface Event<T> {
|
|
362
|
+
(listener: (e: T) => any, thisArgs?: any): IDisposable;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
export interface IExtHostPlainWebview extends IPlainWebviewHandle, IDisposable {
|
|
366
|
+
|
|
367
|
+
reveal(groupIndex: number): Promise<void>;
|
|
368
|
+
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
export namespace webview {
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* 获取一个使用<Webview id='xxx'>组件创造的plainWebview的Handle
|
|
375
|
+
* @param id
|
|
376
|
+
*/
|
|
377
|
+
export function getPlainWebviewHandle(id: string): IPlainWebviewHandle;
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* 创建一个用于在编辑器区域展示的plain webview组件
|
|
381
|
+
* @param title
|
|
382
|
+
* @param iconPath
|
|
383
|
+
*/
|
|
384
|
+
export function createPlainWebview(title: string, iconPath?: string): IExtHostPlainWebview;
|
|
385
|
+
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
interface IProxy {
|
|
389
|
+
[methodName: string]: any; // Function;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
interface IComponentProxy {
|
|
393
|
+
[componentIds: string]: IProxy;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
export interface ExtensionContext<T = IComponentProxy> extends VSCodeExtensionContext {
|
|
397
|
+
registerExtendModuleService<S>(service: S): void;
|
|
398
|
+
|
|
399
|
+
componentProxy: T;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
export interface IReporterTimer {
|
|
403
|
+
timeEnd(msg?: string, extra?: any): number;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
export namespace reporter {
|
|
407
|
+
export function time(name: string): IReporterTimer;
|
|
408
|
+
export function point(name: string, msg?: string, extra?: any): void;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
export interface ITabbarHandle {
|
|
412
|
+
|
|
413
|
+
setSize(size: number): void;
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* 修改 Tabbar 标题
|
|
417
|
+
* @param title 标题
|
|
418
|
+
*
|
|
419
|
+
* @example
|
|
420
|
+
* ```ts
|
|
421
|
+
* const tabbar = kaitian.layout.getTabbarHandler('TabbarIconTest');
|
|
422
|
+
* tabbar.setTitle('New Title');
|
|
423
|
+
* ```
|
|
424
|
+
*/
|
|
425
|
+
setTitle(title: string): void;
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* 修改 Tarbbar 图标
|
|
429
|
+
* @param iconPath 图标路径
|
|
430
|
+
*
|
|
431
|
+
* @example
|
|
432
|
+
* ```ts
|
|
433
|
+
* const tabbar = kaitian.layout.getTabbarHandler('TabbarIconTest');
|
|
434
|
+
* tabbar.setIcon('http://path/to/icon.svg');
|
|
435
|
+
* ```
|
|
436
|
+
*/
|
|
437
|
+
setIcon(iconPath: string): void;
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* 修改 Tabbar 徽标文案
|
|
441
|
+
* @param badge 徽标文案
|
|
442
|
+
*
|
|
443
|
+
* 
|
|
444
|
+
*
|
|
445
|
+
* @example
|
|
446
|
+
* ```ts
|
|
447
|
+
* const tabbar = kaitian.layout.getTabbarHandler('TabbarIconTest');
|
|
448
|
+
* tabbar.setBadge('12');
|
|
449
|
+
* ```
|
|
450
|
+
*/
|
|
451
|
+
setBadge(badge: string): void;
|
|
452
|
+
|
|
453
|
+
activate(): void;
|
|
454
|
+
|
|
455
|
+
deactivate(): void;
|
|
456
|
+
|
|
457
|
+
onActivate: Event<void>;
|
|
458
|
+
|
|
459
|
+
onInActivate: Event<void>;
|
|
460
|
+
|
|
461
|
+
setVisible(visible: boolean): void;
|
|
462
|
+
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
interface IExtensionInfo {
|
|
466
|
+
/**
|
|
467
|
+
* package.json 里的 publisher.name
|
|
468
|
+
* 用于插件之前的相互调用
|
|
469
|
+
*/
|
|
470
|
+
readonly id: string;
|
|
471
|
+
/**
|
|
472
|
+
* 插件市场 id
|
|
473
|
+
*/
|
|
474
|
+
readonly extensionId: string;
|
|
475
|
+
/**
|
|
476
|
+
* 是否为内置插件
|
|
477
|
+
*/
|
|
478
|
+
readonly isBuiltin: boolean;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
export type PermittedHandler = (extensionInfo: IExtensionInfo, ...args: any[]) => boolean;
|
|
482
|
+
|
|
483
|
+
export namespace commands {
|
|
484
|
+
/**
|
|
485
|
+
* Registers a command that can be invoked via a keyboard shortcut,
|
|
486
|
+
* a menu item, an action, or directly.
|
|
487
|
+
*
|
|
488
|
+
* Registering a command with an existing command identifier twice
|
|
489
|
+
* will cause an error.
|
|
490
|
+
*
|
|
491
|
+
* @param command A unique identifier for the command.
|
|
492
|
+
* @param callback A command handler function.
|
|
493
|
+
* @param thisArg The `this` context used when invoking the handler function.
|
|
494
|
+
* @return Disposable which unregisters this command on disposal.
|
|
495
|
+
*/
|
|
496
|
+
export function registerCommand(command: string, callback: (...args: any[]) => any, thisArg?: any): Disposable;
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* Executes the command denoted by the given command identifier.
|
|
500
|
+
*
|
|
501
|
+
* * *Note 1:* When executing an editor command not all types are allowed to
|
|
502
|
+
* be passed as arguments. Allowed are the primitive types `string`, `boolean`,
|
|
503
|
+
* `number`, `undefined`, and `null`, as well as [`Position`](#Position), [`Range`](#Range), [`Uri`](#Uri) and [`Location`](#Location).
|
|
504
|
+
* * *Note 2:* There are no restrictions when executing commands that have been contributed
|
|
505
|
+
* by extensions.
|
|
506
|
+
*
|
|
507
|
+
* @param command Identifier of the command to execute.
|
|
508
|
+
* @param rest Parameters passed to the command function.
|
|
509
|
+
* @return A thenable that resolves to the returned value of the given command. `undefined` when
|
|
510
|
+
* the command handler function doesn't return anything.
|
|
511
|
+
*/
|
|
512
|
+
export function executeCommand<T>(command: string, ...rest: any[]): Thenable<T | undefined>;
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* Retrieve the list of all available commands. Commands starting an underscore are
|
|
516
|
+
* treated as internal commands.
|
|
517
|
+
*
|
|
518
|
+
* @param filterInternal Set `true` to not see internal commands (starting with an underscore)
|
|
519
|
+
* @return Thenable that resolves to a list of command ids.
|
|
520
|
+
*/
|
|
521
|
+
export function getCommands(filterInternal?: boolean): Thenable<string[]>;
|
|
522
|
+
/**
|
|
523
|
+
* Registers a text editor command that can be invoked via a keyboard shortcut,
|
|
524
|
+
* a menu item, an action, or directly.
|
|
525
|
+
*
|
|
526
|
+
* Text editor commands are different from ordinary [commands](#commands.registerCommand) as
|
|
527
|
+
* they only execute when there is an active editor when the command is called. Also, the
|
|
528
|
+
* command handler of an editor command has access to the active editor and to an
|
|
529
|
+
* [edit](#TextEditorEdit)-builder.
|
|
530
|
+
*
|
|
531
|
+
* @param command A unique identifier for the command.
|
|
532
|
+
* @param callback A command handler function with access to an [editor](#TextEditor) and an [edit](#TextEditorEdit).
|
|
533
|
+
* @param thisArg The `this` context used when invoking the handler function.
|
|
534
|
+
* @return Disposable which unregisters this command on disposal.
|
|
535
|
+
*/
|
|
536
|
+
export function registerTextEditorCommand(command: string, callback: (textEditor: TextEditor, edit: TextEditorEdit, ...args: any[]) => void, thisArg?: any): Disposable;
|
|
537
|
+
|
|
538
|
+
/**
|
|
539
|
+
* Register a command that requires authentication
|
|
540
|
+
* This command is only registered in the extension host
|
|
541
|
+
* Does not appear in the menu and command palette
|
|
542
|
+
*
|
|
543
|
+
* @param command A unique identifier for the command.
|
|
544
|
+
* @param callback A command handler function.
|
|
545
|
+
* @param isPermitted Check if you have permission to execute command.It first argument is extension information to help you judge.
|
|
546
|
+
* @return Disposable which unregisters this command on disposal.
|
|
547
|
+
*/
|
|
548
|
+
export function registerCommandWithPermit(id: string, command: <T>(...args: any[]) => T | Promise<T>, isPermitted: PermittedHandler): Disposable;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
export namespace toolbar {
|
|
552
|
+
|
|
553
|
+
export interface IToolbarButtonActionHandle {
|
|
554
|
+
|
|
555
|
+
/**
|
|
556
|
+
* 当按钮被点击时触发
|
|
557
|
+
*/
|
|
558
|
+
onClick: Event<void>;
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* 设置 Button 的 State
|
|
562
|
+
* state 需要对应在 kaitianContributes 中配置
|
|
563
|
+
* @param state
|
|
564
|
+
* @param 额外改变的 title
|
|
565
|
+
*/
|
|
566
|
+
setState(state: string, title?: string): Promise<void>;
|
|
567
|
+
|
|
568
|
+
/**
|
|
569
|
+
* 提供了自定义 Popover 组件的场景下,设置 Popover 组件 props 接收到的 context 状态
|
|
570
|
+
*
|
|
571
|
+
* @example
|
|
572
|
+
* ```ts
|
|
573
|
+
* // extension
|
|
574
|
+
* const action = await kaitian.toolbar.getToolbarButtonHandle(<action-id>);
|
|
575
|
+
* action.setContext({ name: 'World' });
|
|
576
|
+
*
|
|
577
|
+
* // CustomPopOverComponent
|
|
578
|
+
*
|
|
579
|
+
* const PopOver = (props) => {
|
|
580
|
+
* return (
|
|
581
|
+
* <div>Hello {props?.name}</div>
|
|
582
|
+
* );
|
|
583
|
+
* };
|
|
584
|
+
* ```
|
|
585
|
+
* @param context {any}
|
|
586
|
+
*/
|
|
587
|
+
setContext(context: any): void;
|
|
588
|
+
|
|
589
|
+
/**
|
|
590
|
+
* State 改变时触发
|
|
591
|
+
*/
|
|
592
|
+
onStateChanged: Event<{from: string, to: string}>;
|
|
593
|
+
|
|
594
|
+
/**
|
|
595
|
+
* 显示 button 元素对应的 popover 元素,需要在 kaitianContributes 中配置
|
|
596
|
+
*/
|
|
597
|
+
showPopover(): Promise<void>;
|
|
598
|
+
|
|
599
|
+
hidePopover(): Promise<void>;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
export interface IToolbarSelectActionHandle<T> {
|
|
603
|
+
|
|
604
|
+
/**
|
|
605
|
+
* 设置 Select 的 State
|
|
606
|
+
* state 需要对应在 kaitianContributes 中配置
|
|
607
|
+
* @param state
|
|
608
|
+
*/
|
|
609
|
+
setState(state: string): Promise<void>;
|
|
610
|
+
|
|
611
|
+
/**
|
|
612
|
+
* 修改可用 options
|
|
613
|
+
* 注意:如果修改过后的options变更,会导致当前选中变更(原有选中如果在新的options中找不到,默认使用第一个),
|
|
614
|
+
* 那么它会引起 onSelect 被触发
|
|
615
|
+
* @param options
|
|
616
|
+
*/
|
|
617
|
+
setOptions(options: {
|
|
618
|
+
iconPath?: string,
|
|
619
|
+
iconMaskMode?: boolean,
|
|
620
|
+
label?: string,
|
|
621
|
+
value: T,
|
|
622
|
+
}[]): void;
|
|
623
|
+
|
|
624
|
+
/**
|
|
625
|
+
* Select 值改变时触发
|
|
626
|
+
*/
|
|
627
|
+
onSelect: Event<T>;
|
|
628
|
+
|
|
629
|
+
/**
|
|
630
|
+
* State 改变时触发
|
|
631
|
+
*/
|
|
632
|
+
onStateChanged: Event<{from: string, to: string}>;
|
|
633
|
+
|
|
634
|
+
/**
|
|
635
|
+
* 使用代码更改选择
|
|
636
|
+
* @param value
|
|
637
|
+
*/
|
|
638
|
+
setSelect(value: T): Promise<void>;
|
|
639
|
+
|
|
640
|
+
/**
|
|
641
|
+
* 获得当前选择值
|
|
642
|
+
*/
|
|
643
|
+
getValue(): T;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
export interface IToolbarActionBasicContribution {
|
|
647
|
+
id: string;
|
|
648
|
+
preferredPosition?: {
|
|
649
|
+
location?: string,
|
|
650
|
+
group?: string,
|
|
651
|
+
};
|
|
652
|
+
strictPosition?: {
|
|
653
|
+
location: string,
|
|
654
|
+
group: string,
|
|
655
|
+
};
|
|
656
|
+
description: string;
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
export interface IToolbarSelectStyle {
|
|
660
|
+
// 背景色
|
|
661
|
+
backgroundColor?: string;
|
|
662
|
+
|
|
663
|
+
// 下拉菜单前景色
|
|
664
|
+
labelForegroundColor?: string;
|
|
665
|
+
|
|
666
|
+
// icon 前景色
|
|
667
|
+
iconForegroundColor?: string;
|
|
668
|
+
|
|
669
|
+
// 宽度
|
|
670
|
+
width?: number;
|
|
671
|
+
|
|
672
|
+
// 最小宽度
|
|
673
|
+
minWidth?: number;
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
export interface IToolbarActionBtnStyle {
|
|
677
|
+
// 指定按钮宽度
|
|
678
|
+
// 不指定,则按默认8px左右边距
|
|
679
|
+
width?: number;
|
|
680
|
+
|
|
681
|
+
// 指定按钮高度
|
|
682
|
+
// 默认值为 22
|
|
683
|
+
height?: number;
|
|
684
|
+
|
|
685
|
+
// 是否显示 Title
|
|
686
|
+
showTitle?: boolean;
|
|
687
|
+
|
|
688
|
+
// icon 前景色
|
|
689
|
+
iconForeground?: string;
|
|
690
|
+
|
|
691
|
+
// icon 背景色
|
|
692
|
+
iconBackground?: string;
|
|
693
|
+
|
|
694
|
+
// title 前景色
|
|
695
|
+
titleForeground?: string;
|
|
696
|
+
|
|
697
|
+
// title 背景色
|
|
698
|
+
titleBackground?: string;
|
|
699
|
+
|
|
700
|
+
// title 字体大小
|
|
701
|
+
titleSize?: string;
|
|
702
|
+
|
|
703
|
+
// icon 图标大小
|
|
704
|
+
iconSize?: string;
|
|
705
|
+
|
|
706
|
+
// 整体背景色
|
|
707
|
+
background?: string;
|
|
708
|
+
|
|
709
|
+
// 样式类型,
|
|
710
|
+
// inline则不会有外边框
|
|
711
|
+
// button则为按钮样式
|
|
712
|
+
btnStyle?: 'inline' | 'button';
|
|
713
|
+
|
|
714
|
+
// button 的文本位置样式
|
|
715
|
+
// vertical: 上icon 下文本
|
|
716
|
+
// horizontal: 左icon 右文本
|
|
717
|
+
btnTitleStyle?: 'vertical' | 'horizontal';
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
export interface IToolbarPopoverStyle {
|
|
721
|
+
|
|
722
|
+
/**
|
|
723
|
+
* 在上方还是在下方, 默认下方
|
|
724
|
+
* // TODO: 暂时只支持 bottom;
|
|
725
|
+
*/
|
|
726
|
+
position?: 'top' | 'bottom';
|
|
727
|
+
|
|
728
|
+
/**
|
|
729
|
+
* ```text
|
|
730
|
+
* 距离右边的偏移量(px), 默认 30
|
|
731
|
+
* [ button ]
|
|
732
|
+
* /\ |<-offset->|
|
|
733
|
+
* [------ -------------]
|
|
734
|
+
* [ ]
|
|
735
|
+
* [ popover ]
|
|
736
|
+
* [ ]
|
|
737
|
+
* [______________________]
|
|
738
|
+
* ```
|
|
739
|
+
*/
|
|
740
|
+
horizontalOffset?: number;
|
|
741
|
+
|
|
742
|
+
/**
|
|
743
|
+
* 点击组件外部时自动隐藏, 默认 true
|
|
744
|
+
*/
|
|
745
|
+
hideOnClickOutside?: boolean;
|
|
746
|
+
|
|
747
|
+
/**
|
|
748
|
+
* 不要带箭头,阴影,背景色等默认样式
|
|
749
|
+
*/
|
|
750
|
+
noContainerStyle?: boolean;
|
|
751
|
+
|
|
752
|
+
/**
|
|
753
|
+
* 指定 popOver 的最小宽度
|
|
754
|
+
*/
|
|
755
|
+
minWidth?: number;
|
|
756
|
+
|
|
757
|
+
/**
|
|
758
|
+
* 指定 popOver 的最小高度
|
|
759
|
+
*/
|
|
760
|
+
minHeight?: number;
|
|
761
|
+
}
|
|
762
|
+
export interface IToolbarButtonContribution extends IToolbarActionBasicContribution {
|
|
763
|
+
type: 'button';
|
|
764
|
+
command?: string;
|
|
765
|
+
title: string;
|
|
766
|
+
iconPath: string;
|
|
767
|
+
iconMaskMode?: boolean;
|
|
768
|
+
popoverComponent?: string;
|
|
769
|
+
popoverStyle?: IToolbarPopoverStyle;
|
|
770
|
+
states?: {
|
|
771
|
+
[key: string]: {
|
|
772
|
+
title?: string,
|
|
773
|
+
iconPath?: string,
|
|
774
|
+
iconMaskMode?: boolean ;
|
|
775
|
+
} & IToolbarActionBtnStyle,
|
|
776
|
+
};
|
|
777
|
+
defaultState?: string;
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
export interface IToolbarSelectContribution<T = any> extends IToolbarActionBasicContribution {
|
|
781
|
+
type: 'select';
|
|
782
|
+
command?: string;
|
|
783
|
+
options: {
|
|
784
|
+
iconPath?: string,
|
|
785
|
+
iconMaskMode?: boolean;
|
|
786
|
+
label?: string,
|
|
787
|
+
value: T
|
|
788
|
+
}[];
|
|
789
|
+
defaultValue: T;
|
|
790
|
+
optionEqualityKey?: string;
|
|
791
|
+
states?: {
|
|
792
|
+
[key: string]: IToolbarSelectStyle,
|
|
793
|
+
};
|
|
794
|
+
defaultState?: string;
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
/**
|
|
798
|
+
* 注册一个 select 类型的 toolbar Action
|
|
799
|
+
* @param contribution IToolbarSelectContribution
|
|
800
|
+
* 返回一个用于操作和响应 toolbar 上对应 select 控件的 handle
|
|
801
|
+
*/
|
|
802
|
+
export function registerToolbarAction<T>(contribution: IToolbarSelectContribution<T>): Promise<IToolbarSelectActionHandle<T>>;
|
|
803
|
+
/**
|
|
804
|
+
* 注册一个 button 类型的 toolbar action
|
|
805
|
+
* @param contribution IToolbarButtonContribution
|
|
806
|
+
* 返回一个用于操作和响应 toolbar 上对应 button 控件的 handle
|
|
807
|
+
*/
|
|
808
|
+
export function registerToolbarAction(contribution: IToolbarButtonContribution): Promise<IToolbarButtonActionHandle>;
|
|
809
|
+
|
|
810
|
+
/**
|
|
811
|
+
* 获得一个 toolbar action 的 handle, 用于操作和响应 toolbar 上的 button
|
|
812
|
+
* @param id
|
|
813
|
+
*/
|
|
814
|
+
export function getToolbarActionButtonHandle(id: string): Promise<IToolbarButtonActionHandle>;
|
|
815
|
+
|
|
816
|
+
/**
|
|
817
|
+
* 获得一个 toolbar action 的 handle, 用于操作和响应 toolbar 上的 select
|
|
818
|
+
* @param id
|
|
819
|
+
*/
|
|
820
|
+
export function getToolbarActionSelectHandle<T = any>(id: string): Promise<IToolbarSelectActionHandle<T>>;
|
|
821
|
+
}
|
|
822
|
+
}
|