UNPKG

@alilc/lowcode-shell

Version:

Shell Layer for AliLowCodeEngine

139 lines 5.08 kB
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator"; import _createClass from "@babel/runtime/helpers/createClass"; import _regeneratorRuntime from "@babel/runtime/regenerator"; import { resourceSymbol, workspaceSymbol } from '../symbols'; import { Resource as ShellResource, Window as ShellWindow } from '../model'; import { Plugins } from './plugins'; import { Skeleton } from './skeleton'; export var Workspace = /*#__PURE__*/function () { function Workspace(innerWorkspace) { this[workspaceSymbol] = void 0; this[workspaceSymbol] = innerWorkspace; } var _proto = Workspace.prototype; _proto.setResourceList = function setResourceList(resourceList) { this[workspaceSymbol].setResourceList(resourceList); }; _proto.onResourceListChange = function onResourceListChange(fn) { return this[workspaceSymbol].onResourceListChange(fn); }; _proto.onWindowRendererReady = function onWindowRendererReady(fn) { return this[workspaceSymbol].onWindowRendererReady(fn); }; _proto.registerResourceType = function registerResourceType(resourceTypeModel) { this[workspaceSymbol].registerResourceType(resourceTypeModel); }; _proto.openEditorWindow = /*#__PURE__*/function () { var _openEditorWindow = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() { var _arguments$, _args = arguments; return _regeneratorRuntime.wrap(function _callee$(_context) { while (1) switch (_context.prev = _context.next) { case 0: if (!(typeof _args[0] === 'string')) { _context.next = 5; break; } _context.next = 3; return this[workspaceSymbol].openEditorWindow(_args[0], _args[1], _args[2], _args[3], _args[4]); case 3: _context.next = 7; break; case 5: _context.next = 7; return this[workspaceSymbol].openEditorWindowByResource((_arguments$ = _args[0]) === null || _arguments$ === void 0 ? void 0 : _arguments$[resourceSymbol], _args[1]); case 7: case "end": return _context.stop(); } }, _callee, this); })); function openEditorWindow() { return _openEditorWindow.apply(this, arguments); } return openEditorWindow; }(); _proto.openEditorWindowById = function openEditorWindowById(id) { this[workspaceSymbol].openEditorWindowById(id); }; _proto.removeEditorWindow = function removeEditorWindow() { if (typeof arguments[0] === 'string') { this[workspaceSymbol].removeEditorWindow(arguments[0], arguments[1]); } else { var _arguments$2; this[workspaceSymbol].removeEditorWindowByResource((_arguments$2 = arguments[0]) === null || _arguments$2 === void 0 ? void 0 : _arguments$2[resourceSymbol]); } }; _proto.removeEditorWindowById = function removeEditorWindowById(id) { this[workspaceSymbol].removeEditorWindowById(id); }; _proto.onChangeWindows = function onChangeWindows(fn) { return this[workspaceSymbol].onChangeWindows(fn); }; _proto.onChangeActiveWindow = function onChangeActiveWindow(fn) { return this[workspaceSymbol].onChangeActiveWindow(fn); }; _proto.onChangeActiveEditorView = function onChangeActiveEditorView(fn) { return this[workspaceSymbol].onChangeActiveEditorView(fn); }; return _createClass(Workspace, [{ key: "resourceList", get: function get() { return this[workspaceSymbol].getResourceList().map(function (d) { return new ShellResource(d); }); } }, { key: "isActive", get: function get() { return this[workspaceSymbol].isActive; } }, { key: "window", get: function get() { if (!this[workspaceSymbol].window) { return null; } return new ShellWindow(this[workspaceSymbol].window); } }, { key: "resourceTypeList", get: function get() { return Array.from(this[workspaceSymbol].resourceTypeMap.values()).map(function (d) { var resourceName = d.name, resourceType = d.type; var _d$resourceTypeModel = d.resourceTypeModel({}, {}), description = _d$resourceTypeModel.description, editorViews = _d$resourceTypeModel.editorViews; return { resourceName: resourceName, resourceType: resourceType, description: description, editorViews: editorViews.map(function (d) { return { viewName: d.viewName, viewType: d.viewType || 'editor' }; }) }; }); } }, { key: "plugins", get: function get() { return new Plugins(this[workspaceSymbol].plugins, true).toProxy(); } }, { key: "skeleton", get: function get() { return new Skeleton(this[workspaceSymbol].skeleton, 'workspace', true); } }, { key: "windows", get: function get() { return this[workspaceSymbol].windows.map(function (d) { return new ShellWindow(d); }); } }]); }();