Skip to content

Commit f6d2d17

Browse files
committed
Update ide-api
1 parent 68cb19a commit f6d2d17

File tree

3 files changed

+117
-15
lines changed

3 files changed

+117
-15
lines changed

packages/ide-api/api.d.ts

Lines changed: 99 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
interface EvalHelper { }
1+
export interface EvalHelper { }
22
interface ActiveEvalEmitter {
33
removeAllListeners(event?: string): void;
44
emit(event: string, ...args: any[]): void;
@@ -32,7 +32,7 @@ interface IStatusbarEntry {
3232
readonly showBeak?: boolean;
3333
}
3434
interface IStatusbarService {
35-
addEntry(entry: IStatusbarEntry, alignment: StatusbarAlignment, priority?: number): IDisposable;
35+
addEntry(entry: IStatusbarEntry, alignment: ide.StatusbarAlignment, priority?: number): IDisposable;
3636
setStatusMessage(message: string, autoDisposeAfter?: number, delayBy?: number): IDisposable;
3737
}
3838
type NotificationMessage = string | Error;
@@ -41,7 +41,7 @@ interface INotificationProperties {
4141
silent?: boolean;
4242
}
4343
interface INotification extends INotificationProperties {
44-
severity: Severity;
44+
severity: ide.Severity;
4545
message: NotificationMessage;
4646
source?: string;
4747
actions?: INotificationActions;
@@ -58,32 +58,80 @@ interface INotificationProgress {
5858
done(): void;
5959
}
6060

61-
export interface INotificationHandle {
61+
interface INotificationHandle {
6262
readonly onDidClose: Event<void>;
6363
readonly progress: INotificationProgress;
64-
updateSeverity(severity: Severity): void;
64+
updateSeverity(severity: ide.Severity): void;
6565
updateMessage(message: NotificationMessage): void;
6666
updateActions(actions?: INotificationActions): void;
6767
close(): void;
6868
}
6969

70-
export interface IPromptChoice {
70+
interface IPromptChoice {
7171
label: string;
7272
isSecondary?: boolean;
7373
keepOpen?: boolean;
7474
run: () => void;
7575
}
7676

77-
export interface IPromptOptions extends INotificationProperties {
77+
interface IPromptOptions extends INotificationProperties {
7878
onCancel?: () => void;
7979
}
8080

81-
export interface INotificationService {
81+
interface INotificationService {
8282
notify(notification: INotification): INotificationHandle;
8383
info(message: NotificationMessage | NotificationMessage[]): void;
8484
warn(message: NotificationMessage | NotificationMessage[]): void;
8585
error(message: NotificationMessage | NotificationMessage[]): void;
86-
prompt(severity: Severity, message: string, choices: IPromptChoice[], options?: IPromptOptions): INotificationHandle;
86+
prompt(severity: ide.Severity, message: string, choices: IPromptChoice[], options?: IPromptOptions): INotificationHandle;
87+
}
88+
89+
interface IBaseCommandAction {
90+
id: string;
91+
title: string;
92+
category?: string;
93+
}
94+
95+
interface ICommandAction extends IBaseCommandAction {
96+
// iconLocation?: { dark: URI; light?: URI; };
97+
// precondition?: ContextKeyExpr;
98+
// toggled?: ContextKeyExpr;
99+
}
100+
101+
interface ISerializableCommandAction extends IBaseCommandAction {
102+
// iconLocation?: { dark: UriComponents; light?: UriComponents; };
103+
}
104+
105+
interface IMenuItem {
106+
command: ICommandAction;
107+
alt?: ICommandAction;
108+
// when?: ContextKeyExpr;
109+
group?: 'navigation' | string;
110+
order?: number;
111+
}
112+
113+
interface IMenuRegistry {
114+
appendMenuItem(menu: ide.MenuId, item: IMenuItem): IDisposable;
115+
}
116+
117+
export interface ICommandHandler {
118+
(accessor: any, ...args: any[]): void;
119+
}
120+
121+
export interface ICommand {
122+
id: string;
123+
handler: ICommandHandler;
124+
description?: ICommandHandlerDescription | null;
125+
}
126+
127+
export interface ICommandHandlerDescription {
128+
description: string;
129+
args: { name: string; description?: string; }[];
130+
returns?: string;
131+
}
132+
133+
interface ICommandRegistry {
134+
registerCommand(command: ICommand): IDisposable;
87135
}
88136

89137
declare namespace ide {
@@ -108,6 +156,8 @@ declare namespace ide {
108156
export const workbench: {
109157
readonly statusbarService: IStatusbarService;
110158
readonly notificationService: INotificationService;
159+
readonly menuRegistry: IMenuRegistry;
160+
readonly commandRegistry: ICommandRegistry;
111161
};
112162

113163
export enum Severity {
@@ -121,6 +171,46 @@ declare namespace ide {
121171
LEFT = 0,
122172
RIGHT = 1,
123173
}
174+
175+
export enum MenuId {
176+
CommandPalette,
177+
DebugBreakpointsContext,
178+
DebugCallStackContext,
179+
DebugConsoleContext,
180+
DebugVariablesContext,
181+
DebugWatchContext,
182+
EditorContext,
183+
EditorTitle,
184+
EditorTitleContext,
185+
EmptyEditorGroupContext,
186+
ExplorerContext,
187+
MenubarAppearanceMenu,
188+
MenubarDebugMenu,
189+
MenubarEditMenu,
190+
MenubarFileMenu,
191+
MenubarGoMenu,
192+
MenubarHelpMenu,
193+
MenubarLayoutMenu,
194+
MenubarNewBreakpointMenu,
195+
MenubarPreferencesMenu,
196+
MenubarRecentMenu,
197+
MenubarSelectionMenu,
198+
MenubarSwitchEditorMenu,
199+
MenubarSwitchGroupMenu,
200+
MenubarTerminalMenu,
201+
MenubarViewMenu,
202+
OpenEditorsContext,
203+
ProblemsPanelContext,
204+
SCMChangeContext,
205+
SCMResourceContext,
206+
SCMResourceGroupContext,
207+
SCMSourceControl,
208+
SCMTitle,
209+
SearchContext,
210+
TouchBarContext,
211+
ViewItemContext,
212+
ViewTitle,
213+
}
124214
}
125215

126216
declare global {

packages/ide-api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@coder/ide-api",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"typings": "api.d.ts",
55
"author": "Coder",
66
"license": "MIT",

packages/vscode/src/client.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ import { IdeClient } from "@coder/ide";
22
import { client as ideClientInstance } from "@coder/ide/src/fill/client";
33
import Severity from "vs/base/common/severity";
44
import { INotificationService } from "vs/platform/notification/common/notification";
5-
import { IStatusbarService } from "vs/platform/statusbar/common/statusbar";
5+
import { IStatusbarService, StatusbarAlignment } from "vs/platform/statusbar/common/statusbar";
66
import * as paths from "./fill/paths";
77
import "./vscode.scss";
8+
import { MenuId, MenuRegistry } from "vs/platform/actions/common/actions";
9+
import { CommandsRegistry } from "vs/platform/commands/common/commands";
810
// NOTE: shouldn't import anything from VS Code here or anything that will
911
// depend on a synchronous fill like `os`.
1012

@@ -21,15 +23,25 @@ class VSClient extends IdeClient {
2123

2224
// tslint:disable-next-line:no-any
2325
const getService = <T>(id: any): T => workbench.serviceCollection.get<T>(id) as T;
24-
enum StatusbarAlignment { LEFT, RIGHT }
2526
window.ide = {
2627
client: ideClientInstance,
2728
workbench: {
28-
statusbarService: getService<IStatusbarService>(IStatusbarService),
29+
commandRegistry: CommandsRegistry,
30+
// tslint:disable-next-line:no-any
31+
menuRegistry: MenuRegistry as any,
32+
// tslint:disable-next-line:no-any
33+
statusbarService: getService<IStatusbarService>(IStatusbarService) as any,
2934
notificationService: getService<INotificationService>(INotificationService),
3035
},
31-
Severity: Severity,
32-
StatusbarAlignment: StatusbarAlignment,
36+
37+
// @ts-ignore
38+
// tslint:disable-next-line:no-any
39+
MenuId: MenuId as any,
40+
// tslint:disable-next-line:no-any
41+
Severity: Severity as any,
42+
// @ts-ignore
43+
// tslint:disable-next-line:no-any
44+
StatusbarAlignment: StatusbarAlignment as any,
3345
};
3446

3547
const event = new CustomEvent("ide-ready");

0 commit comments

Comments
 (0)