UNPKG

youzanyun-devtool-worker

Version:

- web - ws - proxy

72 lines (71 loc) 2.67 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const spring4js_nodejs_1 = require("spring4js-nodejs"); let ToolBarService = class ToolBarService { constructor() { this.commandMap = {}; this.currentCommandsMap = {}; this._controlPanelChange = new spring4js_nodejs_1.Emitter(); this.onControlPanelChange = this._controlPanelChange.registerEvent; this._openBrowser = new spring4js_nodejs_1.Emitter(); this.onOpenBrowser = this._openBrowser.registerEvent; this._docKeyChange = new spring4js_nodejs_1.Emitter(); this.onDocKeyChange = this._docKeyChange.registerEvent; } async start() { this.commandMap[this.commandCloseAllMock.getKey()] = this.commandCloseAllMock; this.commandMap[this.commandToggleDevtool.getKey()] = this.commandToggleDevtool; this.commandMap[this.commandContentRefresh.getKey()] = this.commandContentRefresh; } openBrowser(workbenchId, url) { this._openBrowser.fire({ workbenchId, url }); } async excuteCommand(workbenchId, projectId, commandKey) { let command = this.commandMap[commandKey]; if (command) { await command.execute(workbenchId, projectId); } } async updateControlPanel(workbenchId, projectId) { let commandkeys = this.currentCommandsMap[workbenchId] || []; let commands = []; for (let commandKey of commandkeys) { let command = this.commandMap[commandKey]; if (command) { let btn = await command.getDescription(workbenchId, projectId); commands.push(btn); } } this._controlPanelChange.fire({ workbenchId, commands }); } async setControlPanelButton(workbenchId, projectId, commands) { this.currentCommandsMap[workbenchId] = commands; await this.updateControlPanel(workbenchId, projectId); } setDocKey({ workbenchId, docKey }) { this._docKeyChange.fire({ workbenchId, docKey }); } }; tslib_1.__decorate([ spring4js_nodejs_1.Resource() ], ToolBarService.prototype, "commandCloseAllMock", void 0); tslib_1.__decorate([ spring4js_nodejs_1.Resource() ], ToolBarService.prototype, "commandToggleDevtool", void 0); tslib_1.__decorate([ spring4js_nodejs_1.Resource() ], ToolBarService.prototype, "commandContentRefresh", void 0); ToolBarService = tslib_1.__decorate([ spring4js_nodejs_1.Service() ], ToolBarService); exports.default = ToolBarService;