UNPKG

youzanyun-devtool-worker

Version:

75 lines (74 loc) 2.58 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const spring4js_nodejs_1 = require("spring4js-nodejs"); let ContentWindowService = class ContentWindowService { constructor() { this.contentMap = new Map(); this._contentWindowEvent = new spring4js_nodejs_1.Emitter(); this.onContentWindowEvent = this._contentWindowEvent.registerEvent; } async showContent(workbenchId, param) { await this.showContentV2(workbenchId, -1, param); } async showContentV2(workbenchId, projectId, param) { const { hasNavigator, docKey } = param; if (!hasNavigator) { await this.toolBarService.setControlPanelButton(workbenchId, projectId, []); await this.toolWindowService.closeDevtool(workbenchId); } else { if (param.commands && param.commands.length > 0) { this.toolBarService.setControlPanelButton(workbenchId, projectId, param.commands); } } if (docKey) { await this.toolBarService.setDocKey({ workbenchId, docKey }); } this.contentMap.set(workbenchId, param); this._contentWindowEvent.fire({ workbenchId, type: 'show', showContentParam: param, }); } async openBrowser(workbenchId, projectId, url) { this._contentWindowEvent.fire({ workbenchId, type: 'open-browser', url, }); } async refreshContent(workbenchId) { this._contentWindowEvent.fire({ workbenchId, type: 'refresh', }); } getContentUrl(workbenchId) { let param = this.contentMap.get(workbenchId); if (!param) { return ''; } const contentTypes = ['webview', 'h5-preview', 'h5-preview-editor']; if (contentTypes.indexOf(param.contentType) > -1) { return param.url; } else { return ''; } } async goBack(workbenchId, projectId, params) { await this.showContentV2(workbenchId, projectId, params); } }; tslib_1.__decorate([ (0, spring4js_nodejs_1.Resource)() ], ContentWindowService.prototype, "toolBarService", void 0); tslib_1.__decorate([ (0, spring4js_nodejs_1.Resource)() ], ContentWindowService.prototype, "toolWindowService", void 0); ContentWindowService = tslib_1.__decorate([ (0, spring4js_nodejs_1.Service)() ], ContentWindowService); exports.default = ContentWindowService;