UNPKG

youzanyun-devtool-worker

Version:

49 lines (48 loc) 2.03 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const path_1 = tslib_1.__importDefault(require("path")); const spring4js_nodejs_1 = require("spring4js-nodejs"); let H5ExtensionPreviewEditorService = class H5ExtensionPreviewEditorService { constructor() { this.previewCompsMap = {}; } async start() { } async getTouchJsPath() { const touchJsPath = path_1.default.resolve(this.configService.getWorkerDir(), 'assets/utils/touch-emulator.js'); return touchJsPath; } async updatePreviewComps(projectId, implId, previewComps) { const key = projectId + '_' + implId; this.previewCompsMap[key] = previewComps; return true; } async getPreviewComps(projectId, implId) { const key = projectId + '_' + implId; let result = null; result = JSON.parse(JSON.stringify(this.previewCompsMap[key]) || '[]') || []; if (!result || !result.length) { const localPageImpl = await this.h5ExtensionImplService.getLocalPageImplDetail(projectId, implId); if (!localPageImpl) { const originalImpl = await this.h5ExtensionImplService.getPageImplDetail(projectId, implId); if (originalImpl && originalImpl.content) { result = JSON.parse(originalImpl.content); } } else if (localPageImpl.content) { result = JSON.parse(localPageImpl.content); } } return result; } }; tslib_1.__decorate([ (0, spring4js_nodejs_1.Resource)() ], H5ExtensionPreviewEditorService.prototype, "configService", void 0); tslib_1.__decorate([ (0, spring4js_nodejs_1.Resource)() ], H5ExtensionPreviewEditorService.prototype, "h5ExtensionImplService", void 0); H5ExtensionPreviewEditorService = tslib_1.__decorate([ (0, spring4js_nodejs_1.Service)() ], H5ExtensionPreviewEditorService); exports.default = H5ExtensionPreviewEditorService;