Archived
1
0

Update ide-api

This commit is contained in:
Kyle Carberry 2019-02-27 15:36:39 -06:00
parent 68cb19ab6f
commit f6d2d17085
No known key found for this signature in database
GPG Key ID: A0409BDB6B0B3EDB
3 changed files with 117 additions and 15 deletions

View File

@ -1,4 +1,4 @@
interface EvalHelper { } export interface EvalHelper { }
interface ActiveEvalEmitter { interface ActiveEvalEmitter {
removeAllListeners(event?: string): void; removeAllListeners(event?: string): void;
emit(event: string, ...args: any[]): void; emit(event: string, ...args: any[]): void;
@ -32,7 +32,7 @@ interface IStatusbarEntry {
readonly showBeak?: boolean; readonly showBeak?: boolean;
} }
interface IStatusbarService { interface IStatusbarService {
addEntry(entry: IStatusbarEntry, alignment: StatusbarAlignment, priority?: number): IDisposable; addEntry(entry: IStatusbarEntry, alignment: ide.StatusbarAlignment, priority?: number): IDisposable;
setStatusMessage(message: string, autoDisposeAfter?: number, delayBy?: number): IDisposable; setStatusMessage(message: string, autoDisposeAfter?: number, delayBy?: number): IDisposable;
} }
type NotificationMessage = string | Error; type NotificationMessage = string | Error;
@ -41,7 +41,7 @@ interface INotificationProperties {
silent?: boolean; silent?: boolean;
} }
interface INotification extends INotificationProperties { interface INotification extends INotificationProperties {
severity: Severity; severity: ide.Severity;
message: NotificationMessage; message: NotificationMessage;
source?: string; source?: string;
actions?: INotificationActions; actions?: INotificationActions;
@ -58,32 +58,80 @@ interface INotificationProgress {
done(): void; done(): void;
} }
export interface INotificationHandle { interface INotificationHandle {
readonly onDidClose: Event<void>; readonly onDidClose: Event<void>;
readonly progress: INotificationProgress; readonly progress: INotificationProgress;
updateSeverity(severity: Severity): void; updateSeverity(severity: ide.Severity): void;
updateMessage(message: NotificationMessage): void; updateMessage(message: NotificationMessage): void;
updateActions(actions?: INotificationActions): void; updateActions(actions?: INotificationActions): void;
close(): void; close(): void;
} }
export interface IPromptChoice { interface IPromptChoice {
label: string; label: string;
isSecondary?: boolean; isSecondary?: boolean;
keepOpen?: boolean; keepOpen?: boolean;
run: () => void; run: () => void;
} }
export interface IPromptOptions extends INotificationProperties { interface IPromptOptions extends INotificationProperties {
onCancel?: () => void; onCancel?: () => void;
} }
export interface INotificationService { interface INotificationService {
notify(notification: INotification): INotificationHandle; notify(notification: INotification): INotificationHandle;
info(message: NotificationMessage | NotificationMessage[]): void; info(message: NotificationMessage | NotificationMessage[]): void;
warn(message: NotificationMessage | NotificationMessage[]): void; warn(message: NotificationMessage | NotificationMessage[]): void;
error(message: NotificationMessage | NotificationMessage[]): void; error(message: NotificationMessage | NotificationMessage[]): void;
prompt(severity: Severity, message: string, choices: IPromptChoice[], options?: IPromptOptions): INotificationHandle; prompt(severity: ide.Severity, message: string, choices: IPromptChoice[], options?: IPromptOptions): INotificationHandle;
}
interface IBaseCommandAction {
id: string;
title: string;
category?: string;
}
interface ICommandAction extends IBaseCommandAction {
// iconLocation?: { dark: URI; light?: URI; };
// precondition?: ContextKeyExpr;
// toggled?: ContextKeyExpr;
}
interface ISerializableCommandAction extends IBaseCommandAction {
// iconLocation?: { dark: UriComponents; light?: UriComponents; };
}
interface IMenuItem {
command: ICommandAction;
alt?: ICommandAction;
// when?: ContextKeyExpr;
group?: 'navigation' | string;
order?: number;
}
interface IMenuRegistry {
appendMenuItem(menu: ide.MenuId, item: IMenuItem): IDisposable;
}
export interface ICommandHandler {
(accessor: any, ...args: any[]): void;
}
export interface ICommand {
id: string;
handler: ICommandHandler;
description?: ICommandHandlerDescription | null;
}
export interface ICommandHandlerDescription {
description: string;
args: { name: string; description?: string; }[];
returns?: string;
}
interface ICommandRegistry {
registerCommand(command: ICommand): IDisposable;
} }
declare namespace ide { declare namespace ide {
@ -108,6 +156,8 @@ declare namespace ide {
export const workbench: { export const workbench: {
readonly statusbarService: IStatusbarService; readonly statusbarService: IStatusbarService;
readonly notificationService: INotificationService; readonly notificationService: INotificationService;
readonly menuRegistry: IMenuRegistry;
readonly commandRegistry: ICommandRegistry;
}; };
export enum Severity { export enum Severity {
@ -121,6 +171,46 @@ declare namespace ide {
LEFT = 0, LEFT = 0,
RIGHT = 1, RIGHT = 1,
} }
export enum MenuId {
CommandPalette,
DebugBreakpointsContext,
DebugCallStackContext,
DebugConsoleContext,
DebugVariablesContext,
DebugWatchContext,
EditorContext,
EditorTitle,
EditorTitleContext,
EmptyEditorGroupContext,
ExplorerContext,
MenubarAppearanceMenu,
MenubarDebugMenu,
MenubarEditMenu,
MenubarFileMenu,
MenubarGoMenu,
MenubarHelpMenu,
MenubarLayoutMenu,
MenubarNewBreakpointMenu,
MenubarPreferencesMenu,
MenubarRecentMenu,
MenubarSelectionMenu,
MenubarSwitchEditorMenu,
MenubarSwitchGroupMenu,
MenubarTerminalMenu,
MenubarViewMenu,
OpenEditorsContext,
ProblemsPanelContext,
SCMChangeContext,
SCMResourceContext,
SCMResourceGroupContext,
SCMSourceControl,
SCMTitle,
SearchContext,
TouchBarContext,
ViewItemContext,
ViewTitle,
}
} }
declare global { declare global {

View File

@ -1,6 +1,6 @@
{ {
"name": "@coder/ide-api", "name": "@coder/ide-api",
"version": "1.0.1", "version": "1.0.2",
"typings": "api.d.ts", "typings": "api.d.ts",
"author": "Coder", "author": "Coder",
"license": "MIT", "license": "MIT",

View File

@ -2,9 +2,11 @@ import { IdeClient } from "@coder/ide";
import { client as ideClientInstance } from "@coder/ide/src/fill/client"; import { client as ideClientInstance } from "@coder/ide/src/fill/client";
import Severity from "vs/base/common/severity"; import Severity from "vs/base/common/severity";
import { INotificationService } from "vs/platform/notification/common/notification"; import { INotificationService } from "vs/platform/notification/common/notification";
import { IStatusbarService } from "vs/platform/statusbar/common/statusbar"; import { IStatusbarService, StatusbarAlignment } from "vs/platform/statusbar/common/statusbar";
import * as paths from "./fill/paths"; import * as paths from "./fill/paths";
import "./vscode.scss"; import "./vscode.scss";
import { MenuId, MenuRegistry } from "vs/platform/actions/common/actions";
import { CommandsRegistry } from "vs/platform/commands/common/commands";
// NOTE: shouldn't import anything from VS Code here or anything that will // NOTE: shouldn't import anything from VS Code here or anything that will
// depend on a synchronous fill like `os`. // depend on a synchronous fill like `os`.
@ -21,15 +23,25 @@ class VSClient extends IdeClient {
// tslint:disable-next-line:no-any // tslint:disable-next-line:no-any
const getService = <T>(id: any): T => workbench.serviceCollection.get<T>(id) as T; const getService = <T>(id: any): T => workbench.serviceCollection.get<T>(id) as T;
enum StatusbarAlignment { LEFT, RIGHT }
window.ide = { window.ide = {
client: ideClientInstance, client: ideClientInstance,
workbench: { workbench: {
statusbarService: getService<IStatusbarService>(IStatusbarService), commandRegistry: CommandsRegistry,
// tslint:disable-next-line:no-any
menuRegistry: MenuRegistry as any,
// tslint:disable-next-line:no-any
statusbarService: getService<IStatusbarService>(IStatusbarService) as any,
notificationService: getService<INotificationService>(INotificationService), notificationService: getService<INotificationService>(INotificationService),
}, },
Severity: Severity,
StatusbarAlignment: StatusbarAlignment, // @ts-ignore
// tslint:disable-next-line:no-any
MenuId: MenuId as any,
// tslint:disable-next-line:no-any
Severity: Severity as any,
// @ts-ignore
// tslint:disable-next-line:no-any
StatusbarAlignment: StatusbarAlignment as any,
}; };
const event = new CustomEvent("ide-ready"); const event = new CustomEvent("ide-ready");