@codingame/monaco-vscode-extensions-service-override
Version:
VSCode public API plugged on the monaco editor - extensions service-override
68 lines (65 loc) • 2.81 kB
JavaScript
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
import { ProgressLocation } from 'vscode/vscode/vs/platform/progress/common/progress';
import { IProgressService } from 'vscode/vscode/vs/platform/progress/common/progress.service';
import { ExtHostContext, MainContext } from 'vscode/vscode/vs/workbench/api/common/extHost.protocol';
import { extHostNamedCustomer } from '../../services/extensions/common/extHostCustomers.js';
import { Action } from 'vscode/vscode/vs/base/common/actions';
import { ICommandService } from 'vscode/vscode/vs/platform/commands/common/commands.service';
import { localize } from 'vscode/vscode/vs/nls';
class ManageExtensionAction extends Action {
constructor(extensionId, label, commandService) {
super(extensionId, label, undefined, true, () => {
return commandService.executeCommand('_extensions.manage', extensionId);
});
}
}
let MainThreadProgress = class MainThreadProgress {
constructor(extHostContext, progressService, _commandService) {
this._commandService = _commandService;
this._progress = ( (new Map()));
this._proxy = ( (extHostContext.getProxy(ExtHostContext.ExtHostProgress)));
this._progressService = progressService;
}
dispose() {
this._progress.forEach(handle => handle.resolve());
this._progress.clear();
}
async $startProgress(handle, options, extensionId) {
const task = this._createTask(handle);
if (options.location === ProgressLocation.Notification && extensionId) {
const notificationOptions = {
...options,
location: ProgressLocation.Notification,
secondaryActions: [( (new ManageExtensionAction(extensionId, ( localize(4863, "Manage Extension")), this._commandService)))]
};
options = notificationOptions;
}
this._progressService.withProgress(options, task, () => this._proxy.$acceptProgressCanceled(handle));
}
$progressReport(handle, message) {
const entry = this._progress.get(handle);
entry?.progress.report(message);
}
$progressEnd(handle) {
const entry = this._progress.get(handle);
if (entry) {
entry.resolve();
this._progress.delete(handle);
}
}
_createTask(handle) {
return (progress) => {
return (
(new Promise(resolve => {
this._progress.set(handle, { resolve, progress });
}))
);
};
}
};
MainThreadProgress = __decorate([
extHostNamedCustomer(MainContext.MainThreadProgress),
( (__param(1, IProgressService))),
( (__param(2, ICommandService)))
], MainThreadProgress);
export { MainThreadProgress };