UNPKG

@alilc/lowcode-shell

Version:

Shell Layer for AliLowCodeEngine

71 lines 2.16 kB
import _createClass from "@babel/runtime/helpers/createClass"; import { globalContext, untracked } from '@alilc/lowcode-editor-core'; import { getLogger } from '@alilc/lowcode-utils'; var innerSettersSymbol = Symbol('setters'); var settersSymbol = Symbol('setters'); var logger = getLogger({ level: 'warn', bizName: 'shell-setters' }); export var Setters = /*#__PURE__*/function () { function Setters(innerSetters, workspaceMode) { var _this = this; if (workspaceMode === void 0) { workspaceMode = false; } this.workspaceMode = workspaceMode; this[innerSettersSymbol] = void 0; /** * 获取指定 setter * @param type * @returns */ this.getSetter = function (type) { return _this[settersSymbol].getSetter(type); }; /** * 获取已注册的所有 settersMap * @returns */ this.getSettersMap = function () { return _this[settersSymbol].getSettersMap(); }; /** * 注册一个 setter * @param typeOrMaps * @param setter * @returns */ this.registerSetter = function (typeOrMaps, setter) { return _this[settersSymbol].registerSetter(typeOrMaps, setter); }; /** * @deprecated */ this.createSetterContent = function (setter, props) { return _this[settersSymbol].createSetterContent(setter, props); }; this[innerSettersSymbol] = innerSetters; } return _createClass(Setters, [{ key: settersSymbol, get: function get() { var _this2 = this; if (this.workspaceMode) { return this[innerSettersSymbol]; } var workspace = globalContext.get('workspace'); if (workspace.isActive) { return untracked(function () { var _workspace$window; if (!((_workspace$window = workspace.window) !== null && _workspace$window !== void 0 && _workspace$window.innerSetters)) { logger.error('setter api 调用时机出现问题,请检查'); return _this2[innerSettersSymbol]; } return workspace.window.innerSetters; }); } return this[innerSettersSymbol]; } }]); }();