sussudio
Version:
An unofficial VS Code Internal API
129 lines (128 loc) • 4.56 kB
text/typescript
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Emitter, Event } from "./event.mjs";
import { Disposable, IDisposable } from "./lifecycle.mjs";
export interface ITelemetryData {
readonly from?: string;
readonly target?: string;
[key: string]: unknown;
}
export type WorkbenchActionExecutedClassification = {
owner: 'bpasero';
comment: 'TODO @bpasero';
id: {
classification: 'SystemMetaData';
purpose: 'FeatureInsight';
comment: 'The identifier of the action that was run.';
};
from: {
classification: 'SystemMetaData';
purpose: 'FeatureInsight';
comment: 'The name of the component the action was run from.';
};
};
export type WorkbenchActionExecutedEvent = {
id: string;
from: string;
};
export interface IAction {
readonly id: string;
label: string;
tooltip: string;
class: string | undefined;
enabled: boolean;
checked?: boolean;
run(event?: unknown): unknown;
}
export interface IActionRunner extends IDisposable {
readonly onDidRun: Event<IRunEvent>;
readonly onWillRun: Event<IRunEvent>;
run(action: IAction, context?: unknown): unknown;
}
export interface IActionChangeEvent {
readonly label?: string;
readonly tooltip?: string;
readonly class?: string;
readonly enabled?: boolean;
readonly checked?: boolean;
}
export declare class Action extends Disposable implements IAction {
protected _onDidChange: Emitter<IActionChangeEvent>;
readonly onDidChange: Event<IActionChangeEvent>;
protected readonly _id: string;
protected _label: string;
protected _tooltip: string | undefined;
protected _cssClass: string | undefined;
protected _enabled: boolean;
protected _checked?: boolean;
protected readonly _actionCallback?: (event?: unknown) => unknown;
constructor(id: string, label?: string, cssClass?: string, enabled?: boolean, actionCallback?: (event?: unknown) => unknown);
get id(): string;
get label(): string;
set label(value: string);
private _setLabel;
get tooltip(): string;
set tooltip(value: string);
protected _setTooltip(value: string): void;
get class(): string | undefined;
set class(value: string | undefined);
protected _setClass(value: string | undefined): void;
get enabled(): boolean;
set enabled(value: boolean);
protected _setEnabled(value: boolean): void;
get checked(): boolean | undefined;
set checked(value: boolean | undefined);
protected _setChecked(value: boolean | undefined): void;
run(event?: unknown, data?: ITelemetryData): Promise<void>;
}
export interface IRunEvent {
readonly action: IAction;
readonly error?: Error;
}
export declare class ActionRunner extends Disposable implements IActionRunner {
private readonly _onWillRun;
readonly onWillRun: Event<IRunEvent>;
private readonly _onDidRun;
readonly onDidRun: Event<IRunEvent>;
run(action: IAction, context?: unknown): Promise<void>;
protected runAction(action: IAction, context?: unknown): Promise<void>;
}
export declare class Separator implements IAction {
/**
* Joins all non-empty lists of actions with separators.
*/
static join(...actionLists: readonly IAction[][]): IAction[];
static readonly ID = "vs.actions.separator";
readonly id: string;
readonly label: string;
readonly tooltip: string;
readonly class: string;
readonly enabled: boolean;
readonly checked: boolean;
run(): Promise<void>;
}
export declare class SubmenuAction implements IAction {
readonly id: string;
readonly label: string;
readonly class: string | undefined;
readonly tooltip: string;
readonly enabled: boolean;
readonly checked: undefined;
private readonly _actions;
get actions(): readonly IAction[];
constructor(id: string, label: string, actions: readonly IAction[], cssClass?: string);
run(): Promise<void>;
}
export declare class EmptySubmenuAction extends Action {
static readonly ID = "vs.actions.empty";
constructor();
}
export declare function toAction(props: {
id: string;
label: string;
enabled?: boolean;
checked?: boolean;
run: Function;
}): IAction;