1
0
mirror of https://git.tuxpa.in/a/code-server.git synced 2024-12-30 22:18:44 +00:00
code-server-2/packages/ide-api/api.d.ts
Asher dc2253e718 Refactor evaluations (#285)
* Replace evaluations with proxies and messages

* Return proxies synchronously

Otherwise events can be lost.

* Ensure events cannot be missed

* Refactor remaining fills

* Use more up-to-date version of util

For callbackify.

* Wait for dispose to come back before removing

This prevents issues with the "done" event not always being the last
event fired. For example a socket might close and then end, but only
if the caller called end.

* Remove old node-pty tests

* Fix emitting events twice on duplex streams

* Preserve environment when spawning processes

* Throw a better error if the proxy doesn't exist

* Remove rimraf dependency from ide

* Update net.Server.listening

* Use exit event instead of killed

Doesn't look like killed is even a thing.

* Add response timeout to server

* Fix trash

* Require node-pty & spdlog after they get unpackaged

This fixes an error when running in the binary.

* Fix errors in down emitter preventing reconnecting

* Fix disposing proxies when nothing listens to "error" event

* Refactor event tests to use jest.fn()

* Reject proxy call when disconnected

Otherwise it'll wait for the timeout which is a waste of time since we
already know the connection is dead.

* Use nbin for binary packaging

* Remove additional module requires

* Attempt to remove require for local bootstrap-fork

* Externalize fsevents
2019-03-26 13:01:25 -05:00

222 lines
5.4 KiB
TypeScript

// tslint:disable no-any
export interface EvalHelper { }
interface ActiveEvalEmitter {
removeAllListeners(event?: string): void;
emit(event: string, ...args: any[]): void;
on(event: string, cb: (...args: any[]) => void): void;
}
interface IDisposable {
dispose(): void;
}
interface Disposer extends IDisposable {
onDidDispose: (cb: () => void) => void;
}
interface Event<T> {
(listener: (e: T) => any, thisArgs?: any, disposables?: IDisposable[]): IDisposable;
}
interface IAction extends IDisposable {
id: string;
label: string;
tooltip: string;
class: string | undefined;
enabled: boolean;
checked: boolean;
radio: boolean;
run(event?: any): Promise<any>;
}
interface IStatusbarEntry {
readonly text: string;
readonly tooltip?: string;
readonly color?: string;
readonly command?: string;
readonly arguments?: any[];
readonly showBeak?: boolean;
}
interface IStatusbarService {
addEntry(entry: IStatusbarEntry, alignment: ide.StatusbarAlignment, priority?: number): IDisposable;
setStatusMessage(message: string, autoDisposeAfter?: number, delayBy?: number): IDisposable;
}
type NotificationMessage = string | Error;
interface INotificationProperties {
sticky?: boolean;
silent?: boolean;
}
interface INotification extends INotificationProperties {
severity: ide.Severity;
message: NotificationMessage;
source?: string;
actions?: INotificationActions;
}
interface INotificationActions {
primary?: IAction[];
secondary?: IAction[];
}
interface INotificationProgress {
infinite(): void;
total(value: number): void;
worked(value: number): void;
done(): void;
}
interface INotificationHandle {
readonly onDidClose: Event<void>;
readonly progress: INotificationProgress;
updateSeverity(severity: ide.Severity): void;
updateMessage(message: NotificationMessage): void;
updateActions(actions?: INotificationActions): void;
close(): void;
}
interface IPromptChoice {
label: string;
isSecondary?: boolean;
keepOpen?: boolean;
run: () => void;
}
interface IPromptOptions extends INotificationProperties {
onCancel?: () => void;
}
interface INotificationService {
notify(notification: INotification): INotificationHandle;
info(message: NotificationMessage | NotificationMessage[]): void;
warn(message: NotificationMessage | NotificationMessage[]): void;
error(message: NotificationMessage | NotificationMessage[]): void;
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 {
export const client: {};
export const workbench: {
readonly statusbarService: IStatusbarService;
readonly notificationService: INotificationService;
readonly menuRegistry: IMenuRegistry;
readonly commandRegistry: ICommandRegistry;
onFileCreate(cb: (path: string) => void): void;
onFileMove(cb: (path: string, target: string) => void): void;
onFileDelete(cb: (path: string) => void): void;
onFileSaved(cb: (path: string) => void): void;
onFileCopy(cb: (path: string, target: string) => void): void;
onModelAdded(cb: (path: string, languageId: string) => void): void;
onModelRemoved(cb: (path: string, languageId: string) => void): void;
onModelLanguageChange(cb: (path: string, languageId: string, oldLanguageId: string) => void): void;
onTerminalAdded(cb: () => void): void;
onTerminalRemoved(cb: () => void): void;
};
export enum Severity {
Ignore = 0,
Info = 1,
Warning = 2,
Error = 3,
}
export enum StatusbarAlignment {
LEFT = 0,
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 {
interface Window {
ide?: typeof ide;
addEventListener(event: "ide-ready", callback: (ide: CustomEvent & { readonly ide: typeof ide }) => void): void;
}
}