UNPKG

elmer-ui-core

Version:

web app framework

88 lines (87 loc) 3.12 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.__extends = exports.addToClassPool = exports.getGlobalVar = exports.defineGlobalVar = exports.getGlobalState = exports.defineGlobalState = void 0; var GlobalUtils = (function () { function GlobalUtils() { } GlobalUtils.prototype.isDev = function () { return true; }; return GlobalUtils; }()); exports.default = GlobalUtils; var defineGlobalState = function (stateKey, stateValue, ignoreError) { if (stateKey !== undefined && stateKey !== null && stateKey.length > 0) { Object.defineProperty(elmerData.elmerState, stateKey, { configurable: false, enumerable: true, value: stateValue, writable: false }); } else { if (!ignoreError) { throw new Error("定义全局状态失败,stateKey不能为空!"); } } }; exports.defineGlobalState = defineGlobalState; var getGlobalState = function (stateKey) { return elmerData.elmerState[stateKey]; }; exports.getGlobalState = getGlobalState; var defineGlobalVar = function (varKey, varValue) { if (varKey !== undefined && varKey !== null && varKey.length > 0) { Object.defineProperty(window, varKey, { configurable: false, enumerable: true, value: varValue, writable: false }); } else { throw new Error("定义全局状态失败,stateKey不能为空!"); } }; exports.defineGlobalVar = defineGlobalVar; var getGlobalVar = function (varkey) { return window[varkey]; }; exports.getGlobalVar = getGlobalVar; var addToClassPool = function (className, factory, fn) { if (factory) { var hasExists = false; factory.prototype.className = className; if (typeof window !== "undefined" && window["elmerData"]) { for (var _i = 0, _a = elmerData.classPool; _i < _a.length; _i++) { var tmpClass = _a[_i]; if (tmpClass.prototype.className === className) { hasExists = true; break; } } if (!hasExists) { typeof fn === "function" && fn(); elmerData.classPool.push(factory); } } } }; exports.addToClassPool = addToClassPool; exports.__extends = (this && this.__extends) || (function () { var ignorePropKeys = ["selector", "template", "model", "service", "i18n", "connect", "setData", "setState", "render"]; var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) { if (b.hasOwnProperty(p) && ignorePropKeys.indexOf(p) < 0) { d[p] = b[p]; } } }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })();