import { Deferred, Disposable, Emitter, ExtHostSpawnOptions, ExtensionConnectOption, IDisposable, IExtensionLogger, IExtensionProps, IJSONSchema, ILogger, LifeCyclePhase, LinkedText, MaybePromise, URI, Uri, WithEventBus } from '@opensumi/ide-core-common'; import { IIconService, IconType, ThemeType } from '@opensumi/ide-theme/lib/common/theme.service'; import { ExtHostStorage } from '../hosted/api/vscode/ext.host.storage'; import { Extension } from '../hosted/vscode.extension'; import { ActivatedExtension, ActivatedExtensionJSON, ExtensionsActivator } from './activator'; import { ISumiExtensionContributions } from './sumi/extension'; import { IExtensionContributions, IExtensionLanguagePack, IMainThreadCommands } from './vscode'; import { ThemeIcon } from './vscode/ext-types'; import type { ContextKeyExpression } from '@opensumi/monaco-editor-core/esm/vs/platform/contextkey/common/contextkey'; export interface IExtensionMetaData { id: string; extensionId: string; path: string; uri?: Uri; packageJSON: { [key: string]: any; }; defaultPkgNlsJSON: { [key: string]: any; } | undefined; packageNlsJSON: { [key: string]: any; } | undefined; extraMetadata: JSONType; realPath: string; extendConfig: JSONType; isBuiltin: boolean; isDevelopment?: boolean; } /** * 提供插件扫描时的额外信息读取能力 * 比如 read/changelog/package.nls.json 等等 */ export interface IExtraMetaData { [key: string]: string; } export declare const ExtensionNodeServiceServerPath = "ExtensionNodeServiceServerPath"; export type ExtensionDependencies = (string | { [extensionId: string]: string; })[]; export interface ICreateProcessOptions { /** * 启用插件进程的 Debug 模式 */ enableDebugExtensionHost?: boolean; /** * 调试插件进程的 Host 地址 */ inspectExtensionHost?: string; /** * 插件进程连接时候一些配置选项 */ extensionConnectOption?: ExtensionConnectOption; extHostSpawnOptions?: ExtHostSpawnOptions; } export declare const IExtensionNodeService: unique symbol; export interface IExtensionNodeService { initialize(): Promise; getAllExtensions(scan: string[], extensionCandidate: string[], localization: string, extraMetaData: IExtraMetaData): Promise; createProcess(clientId: string, options?: ICreateProcessOptions): Promise; ensureProcessReady(clientId: string): Promise; getExtProcessId(clientId: string): Promise; getElectronMainThreadListenPath(clientId: string): Promise; getExtServerListenOption(clientId: string): any; getExtension(extensionPath: string, localization: string, extraMetaData?: IExtraMetaData): Promise; setConnectionServiceClient(clientId: string, serviceClient: IExtensionNodeClientService): any; disposeClientExtProcess(clientId: string, info: boolean): Promise; disposeAllClientExtProcess(): Promise; tryEnableInspectPort(clientId: string, delay?: number): Promise; getProcessInspectPort(clientId: string): Promise; } export declare const IExtensionNodeClientService: unique symbol; export interface IExtensionNodeClientService { getElectronMainThreadListenPath(clientId: string): Promise; getAllExtensions(scan: string[], extensionCandidate: string[], localization: string, extraMetaData: IExtraMetaData): Promise; createProcess(clientId: string, options: ICreateProcessOptions): Promise; getExtension(extensionPath: string, localization: string, extraMetaData?: IExtraMetaData): Promise; infoProcessNotExist(): void; infoProcessCrash(): void; restartExtProcessByClient(): void; disposeClientExtProcess(clientId: string, info: boolean): Promise; updateLanguagePack(languageId: string, languagePackPath: string, storagePath: string): Promise; setupNLSConfig(languageId: string, storagePath: string): Promise; getOpenVSXRegistry(): Promise; getLanguagePack(languageId: string): Promise; pid(): Promise; } export type ExtensionHostType = 'node' | 'worker'; export type ExtensionHostTypeUpperCase = 'Node.js' | 'Web Worker'; export interface ChangeExtensionOptions { upgrade: boolean; extensionPath: string; oldExtensionPath?: string; isBuiltin?: boolean; } /** * 管理不同进程内插件注册的 command 的运行环境及其调用 */ export declare abstract class IExtCommandManagement { abstract registerProxyCommandExecutor(env: ExtensionHostType, proxyCommandExecutor: IMainThreadCommands): void; abstract executeExtensionCommand(env: ExtensionHostType, command: string, args: any[]): Promise; /** * @param command command id * @param targetHost 目标插件进程的运行环境,默认 'node' */ abstract registerExtensionCommandEnv(command: string, targetHost?: ExtensionHostType): IDisposable; abstract getExtensionCommandEnv(command: string): ExtensionHostType | undefined; } /** * 为插件市场面板提供数据/交互 */ export declare abstract class AbstractExtensionManagementService { /** * @deprecated 建议直接用 AbstractExtInstanceManagementService#getExtensionInstances 后自行 map#toJSON 即可 */ abstract getAllExtensionJson(): IExtensionProps[]; /** * 禁用插件 */ abstract postDisableExtension(extensionPath: string): Promise; /** * 启用插件 */ abstract postEnableExtension(extensionPath: string): Promise; /** * 安装插件之后开始激活 */ abstract postChangedExtension(options: ChangeExtensionOptions): Promise; abstract postChangedExtension(upgrade: boolean, extensionPath: string, oldExtensionPath?: string): Promise; abstract postChangedExtension(upgrade: boolean | ChangeExtensionOptions, extensionPath?: string, oldExtensionPath?: string): Promise; /** * 卸载插件 */ abstract postUninstallExtension(extensionPath: string): Promise; /** * 通过 extensionPath 获取插件实例 */ abstract getExtensionByPath(extensionPath: string): IExtension | undefined; /** * 通过 extension id 获取插件实例 */ abstract getExtensionByExtId(extensionId: string): IExtension | undefined; /** * 通过 extensionPath 获取插件实例序列化数据及从 node 层获取的 extraMetadata */ abstract getExtensionProps(extensionPath: string, extraMetaData?: IExtraMetaData): Promise; } export declare enum ERestartPolicy { /** * Always restart extension process */ Always = "always", /** * Restart extension process when extension process is not running or not responding */ WhenExit = "when-exit" } export declare abstract class ExtensionService { /** * 激活插件服务 */ abstract activate(): Promise; /** * 重启插件进程 */ abstract restartExtProcess(restartPolicy?: ERestartPolicy): Promise; /** * 激活插件, 给 Extension 实例使用 */ abstract activeExtension(extension: IExtension): Promise; /** * 销毁插件 */ abstract disposeExtensions(): Promise; /** * 执行插件命令 */ abstract executeExtensionCommand(command: string, args: any[]): Promise; /** * @internal 提供获取所有运行中的插件的列表数据 */ abstract getActivatedExtensions(): Promise<{ [key in ExtensionHostType]?: ActivatedExtension[]; }>; abstract runExtensionContributes(): Promise; eagerExtensionsActivated: Deferred; } export declare abstract class ExtensionCapabilityRegistry { abstract getAllExtensions(): Promise; } export declare const LANGUAGE_BUNDLE_FIELD = "languageBundle"; export interface JSONType { [key: string]: any; } export interface IExtension extends IExtensionProps { readonly contributes: IExtensionContributions & ISumiExtensionContributions; activate(visited?: Set): any; enable(): void; reset(): void; toJSON(): IExtensionProps; } export declare const NO_ROOT_URI = ""; export interface ContributesMap { extensionId: string; contributes: T; } export declare abstract class VSCodeContributePoint extends Disposable { protected contributesMap: Array>; protected contributedMap: Array>; static schema: IJSONSchema; protected readonly iconService?: IIconService; abstract contribute(): void | Promise; register(extensionId: string, contributes: T): void; hasUncontributedPoint(): boolean; afterContribute(): void; protected toIconClass(iconContrib: { [index in ThemeType]: string; } | string, type: IconType | undefined, basePath: string): string | undefined; protected getLocalizeFromNlsJSON(title: string, extensionId: string, languageId?: string): string; protected createLocalizedStr(title: string, extensionId: string): import("@opensumi/ide-core-common").ILocalizedStr; } export declare abstract class ExtensionContributesService extends WithEventBus { abstract ContributionPoints: (typeof VSCodeContributePoint)[]; private logger; private lifecycleService; private readonly extensionsSchemaService; private injector; private contributedSet; private contributeQueue; private lifecycles; private getContributionCls; register(extensionId: string, contrib: JSONType): void; private runContributesByPhase; initialize(): Promise; } export declare const CONTRIBUTE_NAME_KEY = "contribute_name"; export declare function Contributes(name: any): (target: any) => void; export declare const LIFE_CYCLE_PHASE_KEY = "phase"; export declare function LifeCycle(name: LifeCyclePhase): (target: any) => void; export declare const EXTENSION_EXTEND_SERVICE_PREFIX = "extension_extend_service"; export declare const MOCK_EXTENSION_EXTEND_PROXY_IDENTIFIER: import("@opensumi/ide-connection").ProxyIdentifier; export interface IExtensionHost { logger: IExtensionLogger; $activateExtension(id: string): Promise; /** * 更新插件进程内的插件相关数据 */ $updateExtHostData(): Promise; $getActivatedExtensions(): Promise; getExtensionExports(id: string): any; getExtensions(): Extension[]; getExtension(extensionId: string): Extension | undefined; isActivated(id: string): boolean; activateExtension(id: string): Promise; extensionsChangeEmitter: Emitter; storage: ExtHostStorage; } export interface IExtensionHostService extends IExtensionHost { $fireChangeEvent(): Promise; init(): Promise; close(): Promise; getExtendExports(id: string): any; extensionsActivator: ExtensionsActivator; /** * 上报插件未捕获异常 * @param error */ reportUnexpectedError(error: Error): void; } export interface IExtensionWorkerHost extends IExtensionHost { staticServicePath: string; } export interface IExtendProxy { [key: string]: any; } export declare const WorkerHostAPIIdentifier: { ExtWorkerHostExtensionService: import("@opensumi/ide-connection").ProxyIdentifier; }; export declare enum ProcessMessageType { REPORTER = 0 } export declare enum EXTENSION_ENABLE { ENABLE = 1, DISABLE = 0 } export declare const EMIT_EXT_HOST_EVENT: { id: string; }; export declare function getExtensionId(extensionId: string): string; export declare enum ExtensionHostKind { NODE_HOST = 1, WORKER_HOST = 2 } export declare const ExtensionHostProfilerServicePath = "ExtensionHostProfilerService"; export declare const ExtensionHostProfilerServiceToken: unique symbol; export interface IExtensionHostProfilerService { $startProfile(clientId: string): Promise; $stopProfile(clientId: string): Promise; $saveLastProfile(filePath: string): Promise; } export declare enum OutputType { STDOUT = 0, STDERR = 1 } export interface Output { type: OutputType; data: string; format: string[]; } export declare const IExtensionHostManager: unique symbol; export interface IExtensionHostManager { init(): MaybePromise; fork(modulePath: string, ...args: any[]): MaybePromise; send(pid: number, message: string): MaybePromise; isRunning(pid: number): MaybePromise; treeKill(pid: number): MaybePromise; kill(pid: number, signal?: string): MaybePromise; isKilled(pid: number): MaybePromise; findDebugPort(startPort: number, giveUpAfter: number, timeout: number): Promise; onOutput(pid: number, listener: (output: Output) => void): MaybePromise; onExit(pid: number, listener: (code: number, signal: string) => void): MaybePromise; onMessage(pid: number, listener: (msg: any) => void): MaybePromise; disposeProcess(pid: number): MaybePromise; dispose(): MaybePromise; } /** * 以下都是 fork 新的插件子进程的时候,传入的命令行参数的 key */ export declare const KT_PROCESS_SOCK_OPTION_KEY = "kt-process-sock-option"; export declare const KT_PROCESS_PRELOAD_KEY = "kt-process-preload"; export declare const KT_APP_CONFIG_KEY = "kt-app-config"; export interface SemanticTokenScopes { scopes?: { [selector: string]: string[]; }; language?: string; } export type SemanticTokenScopesSchema = Array; export interface SemanticTokenType { id: string; description: string; superType?: string; } export type SemanticTokenTypeSchema = Array; export interface SemanticTokenModifier { id: string; description: string; } export type SemanticTokenModifierSchema = Array; export declare function validateTypeOrModifier(contribution: SemanticTokenType | SemanticTokenModifier, extensionPoint: string, logger: ILogger): boolean; export declare const enum ExtensionContributePoint { Terminal = "terminal" } export interface IWalkthrough { id: string; title: string; description: string; order: number; source: string; isFeatured: boolean; next?: string; when: ContextKeyExpression; steps: IWalkthroughStep[]; icon: { type: 'icon'; icon: ThemeIcon; } | { type: 'image'; path: string; }; } export type IWalkthroughLoose = Omit & { steps: (Omit & { description: string; })[]; }; export interface IWalkthroughStep { id: string; title: string; description: LinkedText[]; category: string; when: ContextKeyExpression; order: number; completionEvents: string[]; media: { type: 'image'; path: { hcDark: URI; hcLight: URI; light: URI; dark: URI; }; altText: string; } | { type: 'svg'; path: URI; altText: string; } | { type: 'markdown'; path: URI; base: URI; root: URI; }; } export interface StepProgress { done: boolean; } export interface IResolvedWalkthroughStep extends IWalkthroughStep, StepProgress { } export declare namespace CompletionEventsType { const onLink = "onLink"; const onEvent = "onEvent"; const onView = "onView"; const onSettingChanged = "onSettingChanged"; const onContext = "onContext"; const onStepSelected = "onStepSelected"; const stepSelected = "stepSelected"; const onCommand = "onCommand"; const onExtensionInstalled = "onExtensionInstalled"; const extensionInstalled = "extensionInstalled"; } //# sourceMappingURL=extension.d.ts.map