choerodon-ui
Version:
An enterprise-class UI design language and React-based implementation
1,318 lines (1,125 loc) • 7.52 MB
JavaScript
/*!
*
* choerodon-ui v1.4.5
*
*/
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory(require("mobx"), require("moment"), require("react"), require("react-dom"));
else if(typeof define === 'function' && define.amd)
define(["mobx", "moment", "react", "react-dom"], factory);
else if(typeof exports === 'object')
exports["choerodon-ui"] = factory(require("mobx"), require("moment"), require("react"), require("react-dom"));
else
root["choerodon-ui"] = factory(root["mobx"], root["moment"], root["React"], root["ReactDOM"]);
})(window, function(__WEBPACK_EXTERNAL_MODULE_mobx__, __WEBPACK_EXTERNAL_MODULE_moment__, __WEBPACK_EXTERNAL_MODULE_react__, __WEBPACK_EXTERNAL_MODULE_react_dom__) {
return /******/ (function(modules) { // webpackBootstrap
/******/ // install a JSONP callback for chunk loading
/******/ function webpackJsonpCallback(data) {
/******/ var chunkIds = data[0];
/******/ var moreModules = data[1];
/******/
/******/
/******/ // add "moreModules" to the modules object,
/******/ // then flag all "chunkIds" as loaded and fire callback
/******/ var moduleId, chunkId, i = 0, resolves = [];
/******/ for(;i < chunkIds.length; i++) {
/******/ chunkId = chunkIds[i];
/******/ if(Object.prototype.hasOwnProperty.call(installedChunks, chunkId) && installedChunks[chunkId]) {
/******/ resolves.push(installedChunks[chunkId][0]);
/******/ }
/******/ installedChunks[chunkId] = 0;
/******/ }
/******/ for(moduleId in moreModules) {
/******/ if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {
/******/ modules[moduleId] = moreModules[moduleId];
/******/ }
/******/ }
/******/ if(parentJsonpFunction) parentJsonpFunction(data);
/******/
/******/ while(resolves.length) {
/******/ resolves.shift()();
/******/ }
/******/
/******/ };
/******/
/******/
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // object to store loaded and loading chunks
/******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
/******/ // Promise = chunk loading, 0 = chunk loaded
/******/ var installedChunks = {
/******/ "choerodon-ui": 0
/******/ };
/******/
/******/
/******/
/******/ // script path function
/******/ function jsonpScriptSrc(chunkId) {
/******/ return __webpack_require__.p + "" + ({}[chunkId]||chunkId) + ".js"
/******/ }
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/ // This file contains only the entry chunk.
/******/ // The chunk loading function for additional chunks
/******/ __webpack_require__.e = function requireEnsure(chunkId) {
/******/ var promises = [];
/******/
/******/
/******/ // JSONP chunk loading for javascript
/******/
/******/ var installedChunkData = installedChunks[chunkId];
/******/ if(installedChunkData !== 0) { // 0 means "already installed".
/******/
/******/ // a Promise means "currently loading".
/******/ if(installedChunkData) {
/******/ promises.push(installedChunkData[2]);
/******/ } else {
/******/ // setup Promise in chunk cache
/******/ var promise = new Promise(function(resolve, reject) {
/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject];
/******/ });
/******/ promises.push(installedChunkData[2] = promise);
/******/
/******/ // start chunk loading
/******/ var script = document.createElement('script');
/******/ var onScriptComplete;
/******/
/******/ script.charset = 'utf-8';
/******/ script.timeout = 120;
/******/ if (__webpack_require__.nc) {
/******/ script.setAttribute("nonce", __webpack_require__.nc);
/******/ }
/******/ script.src = jsonpScriptSrc(chunkId);
/******/
/******/ // create error before stack unwound to get useful stacktrace later
/******/ var error = new Error();
/******/ onScriptComplete = function (event) {
/******/ // avoid mem leaks in IE.
/******/ script.onerror = script.onload = null;
/******/ clearTimeout(timeout);
/******/ var chunk = installedChunks[chunkId];
/******/ if(chunk !== 0) {
/******/ if(chunk) {
/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type);
/******/ var realSrc = event && event.target && event.target.src;
/******/ error.message = 'Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')';
/******/ error.name = 'ChunkLoadError';
/******/ error.type = errorType;
/******/ error.request = realSrc;
/******/ chunk[1](error);
/******/ }
/******/ installedChunks[chunkId] = undefined;
/******/ }
/******/ };
/******/ var timeout = setTimeout(function(){
/******/ onScriptComplete({ type: 'timeout', target: script });
/******/ }, 120000);
/******/ script.onerror = script.onload = onScriptComplete;
/******/ document.head.appendChild(script);
/******/ }
/******/ }
/******/ return Promise.all(promises);
/******/ };
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // on error function for async loading
/******/ __webpack_require__.oe = function(err) { console.error(err); throw err; };
/******/
/******/ var jsonpArray = window["webpackJsonp_name_"] = window["webpackJsonp_name_"] || [];
/******/ var oldJsonpFunction = jsonpArray.push.bind(jsonpArray);
/******/ jsonpArray.push = webpackJsonpCallback;
/******/ jsonpArray = jsonpArray.slice();
/******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);
/******/ var parentJsonpFunction = oldJsonpFunction;
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 0);
/******/ })
/************************************************************************/
/******/ ({
/***/ "./components sync recursive ^\\.\\/[^_][\\w-]+\\/style\\/index\\.tsx?$":
/*!**************************************************************!*\
!*** ./components sync ^\.\/[^_][\w-]+\/style\/index\.tsx?$ ***!
\**************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
var map = {
"./affix/style/index.tsx": "./components/affix/style/index.tsx",
"./alert/style/index.tsx": "./components/alert/style/index.tsx",
"./align/style/index.tsx": "./components/align/style/index.tsx",
"./anchor/style/index.tsx": "./components/anchor/style/index.tsx",
"./animate/style/index.tsx": "./components/animate/style/index.tsx",
"./auto-complete/style/index.tsx": "./components/auto-complete/style/index.tsx",
"./avatar/style/index.tsx": "./components/avatar/style/index.tsx",
"./back-top/style/index.tsx": "./components/back-top/style/index.tsx",
"./badge/style/index.tsx": "./components/badge/style/index.tsx",
"./breadcrumb/style/index.tsx": "./components/breadcrumb/style/index.tsx",
"./button/style/index.tsx": "./components/button/style/index.tsx",
"./calendar/style/index.tsx": "./components/calendar/style/index.tsx",
"./card/style/index.tsx": "./components/card/style/index.tsx",
"./carousel/style/index.tsx": "./components/carousel/style/index.tsx",
"./cascader/style/index.tsx": "./components/cascader/style/index.tsx",
"./checkbox/style/index.tsx": "./components/checkbox/style/index.tsx",
"./col/style/index.tsx": "./components/col/style/index.tsx",
"./collapse/style/index.tsx": "./components/collapse/style/index.tsx",
"./configure/style/index.tsx": "./components/configure/style/index.tsx",
"./date-picker/style/index.tsx": "./components/date-picker/style/index.tsx",
"./divider/style/index.tsx": "./components/divider/style/index.tsx",
"./dropdown/style/index.tsx": "./components/dropdown/style/index.tsx",
"./form/style/index.tsx": "./components/form/style/index.tsx",
"./get-config/style/index.tsx": "./components/get-config/style/index.tsx",
"./grid/style/index.tsx": "./components/grid/style/index.tsx",
"./icon-select/style/index.tsx": "./components/icon-select/style/index.tsx",
"./icon/style/index.tsx": "./components/icon/style/index.tsx",
"./image-crop/style/index.tsx": "./components/image-crop/style/index.tsx",
"./input-number/style/index.tsx": "./components/input-number/style/index.tsx",
"./input/style/index.tsx": "./components/input/style/index.tsx",
"./layout/style/index.tsx": "./components/layout/style/index.tsx",
"./list/style/index.tsx": "./components/list/style/index.tsx",
"./locale-provider/style/index.tsx": "./components/locale-provider/style/index.tsx",
"./mention/style/index.tsx": "./components/mention/style/index.tsx",
"./menu/style/index.tsx": "./components/menu/style/index.tsx",
"./message/style/index.tsx": "./components/message/style/index.tsx",
"./modal/style/index.tsx": "./components/modal/style/index.tsx",
"./notification/style/index.tsx": "./components/notification/style/index.tsx",
"./pagination/style/index.tsx": "./components/pagination/style/index.tsx",
"./popconfirm/style/index.tsx": "./components/popconfirm/style/index.tsx",
"./popover/style/index.tsx": "./components/popover/style/index.tsx",
"./progress/style/index.tsx": "./components/progress/style/index.tsx",
"./radio/style/index.tsx": "./components/radio/style/index.tsx",
"./rate/style/index.tsx": "./components/rate/style/index.tsx",
"./responsive/style/index.tsx": "./components/responsive/style/index.tsx",
"./result/style/index.tsx": "./components/result/style/index.tsx",
"./ripple/style/index.tsx": "./components/ripple/style/index.tsx",
"./row/style/index.tsx": "./components/row/style/index.tsx",
"./select/style/index.tsx": "./components/select/style/index.tsx",
"./skeleton/style/index.tsx": "./components/skeleton/style/index.tsx",
"./slider/style/index.tsx": "./components/slider/style/index.tsx",
"./spin/style/index.tsx": "./components/spin/style/index.tsx",
"./statistic/style/index.tsx": "./components/statistic/style/index.tsx",
"./steps/style/index.tsx": "./components/steps/style/index.tsx",
"./switch/style/index.tsx": "./components/switch/style/index.tsx",
"./table/style/index.tsx": "./components/table/style/index.tsx",
"./tabs/style/index.tsx": "./components/tabs/style/index.tsx",
"./tag/style/index.tsx": "./components/tag/style/index.tsx",
"./time-picker/style/index.tsx": "./components/time-picker/style/index.tsx",
"./timeline/style/index.tsx": "./components/timeline/style/index.tsx",
"./tooltip/style/index.tsx": "./components/tooltip/style/index.tsx",
"./transfer/style/index.tsx": "./components/transfer/style/index.tsx",
"./tree-select/style/index.tsx": "./components/tree-select/style/index.tsx",
"./tree/style/index.tsx": "./components/tree/style/index.tsx",
"./trigger/style/index.tsx": "./components/trigger/style/index.tsx",
"./upload/style/index.tsx": "./components/upload/style/index.tsx",
"./version/style/index.tsx": "./components/version/style/index.tsx"
};
function webpackContext(req) {
var id = webpackContextResolve(req);
return __webpack_require__(id);
}
function webpackContextResolve(req) {
if(!__webpack_require__.o(map, req)) {
var e = new Error("Cannot find module '" + req + "'");
e.code = 'MODULE_NOT_FOUND';
throw e;
}
return map[req];
}
webpackContext.keys = function webpackContextKeys() {
return Object.keys(map);
};
webpackContext.resolve = webpackContextResolve;
module.exports = webpackContext;
webpackContext.id = "./components sync recursive ^\\.\\/[^_][\\w-]+\\/style\\/index\\.tsx?$";
/***/ }),
/***/ "./components-pro/_util/AsyncComponent.tsx":
/*!*************************************************!*\
!*** ./components-pro/_util/AsyncComponent.tsx ***!
\*************************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/extends */ "./node_modules/@babel/runtime/helpers/extends.js");
/* harmony import */ var _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "./node_modules/@babel/runtime/helpers/classCallCheck.js");
/* harmony import */ var _babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @babel/runtime/helpers/createClass */ "./node_modules/@babel/runtime/helpers/createClass.js");
/* harmony import */ var _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _babel_runtime_helpers_inherits__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @babel/runtime/helpers/inherits */ "./node_modules/@babel/runtime/helpers/inherits.js");
/* harmony import */ var _babel_runtime_helpers_inherits__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_inherits__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var _babel_runtime_helpers_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @babel/runtime/helpers/possibleConstructorReturn */ "./node_modules/@babel/runtime/helpers/possibleConstructorReturn.js");
/* harmony import */ var _babel_runtime_helpers_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_4__);
/* harmony import */ var _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @babel/runtime/helpers/getPrototypeOf */ "./node_modules/@babel/runtime/helpers/getPrototypeOf.js");
/* harmony import */ var _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_5__);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! react */ "react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_6__);
/* harmony import */ var _spin__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../spin */ "./components-pro/spin/index.tsx");
/* harmony import */ var _exception__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./exception */ "./components-pro/_util/exception.tsx");
function _createSuper(Derived) {
function isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
if (Reflect.construct.sham) return false;
if (typeof Proxy === "function") return true;
try {
Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
return true;
} catch (e) {
return false;
}
}
return function () {
var Super = _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_5___default()(Derived),
result;
if (isNativeReflectConstruct()) {
var NewTarget = _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_5___default()(this).constructor;
result = Reflect.construct(Super, arguments, NewTarget);
} else {
result = Super.apply(this, arguments);
}
return _babel_runtime_helpers_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_4___default()(this, result);
};
}
var asyncComponent = function asyncComponent(importComponent) {
var AsyncComponent =
/*#__PURE__*/
function (_Component) {
_babel_runtime_helpers_inherits__WEBPACK_IMPORTED_MODULE_3___default()(AsyncComponent, _Component);
var _super = _createSuper(AsyncComponent);
function AsyncComponent() {
var _this;
_babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_1___default()(this, AsyncComponent);
_this = _super.apply(this, arguments);
_this.state = {};
return _this;
}
_babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_2___default()(AsyncComponent, [{
key: "componentDidMount",
value: function componentDidMount() {
var _this2 = this;
importComponent().then(function (_ref) {
var component = _ref["default"];
_this2.setState({
component: component
});
}, _exception__WEBPACK_IMPORTED_MODULE_8__["default"]);
}
}, {
key: "render",
value: function render() {
var Cmp = this.state.component;
return Cmp ? react__WEBPACK_IMPORTED_MODULE_6___default.a.createElement(Cmp, _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({}, this.props)) : react__WEBPACK_IMPORTED_MODULE_6___default.a.createElement(_spin__WEBPACK_IMPORTED_MODULE_7__["default"], null);
}
}]);
return AsyncComponent;
}(react__WEBPACK_IMPORTED_MODULE_6__["Component"]);
return AsyncComponent;
};
/* harmony default export */ __webpack_exports__["default"] = (asyncComponent);
/***/ }),
/***/ "./components-pro/_util/Cache.tsx":
/*!****************************************!*\
!*** ./components-pro/_util/Cache.tsx ***!
\****************************************/
/*! exports provided: default, refreshCacheOptions */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return Cache; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "refreshCacheOptions", function() { return refreshCacheOptions; });
/* harmony import */ var _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/createClass */ "./node_modules/@babel/runtime/helpers/createClass.js");
/* harmony import */ var _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "./node_modules/@babel/runtime/helpers/classCallCheck.js");
/* harmony import */ var _babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var mobx__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! mobx */ "mobx");
/* harmony import */ var mobx__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(mobx__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var choerodon_ui_lib_configure__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! choerodon-ui/lib/configure */ "./components/configure/index.tsx");
/* harmony import */ var _Yallist__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Yallist */ "./components-pro/_util/Yallist.tsx");
// 双向链表 -> 缓存更新性能优化
var MAX = Symbol('max'); // 最大值
var LENGTH = Symbol('length'); // 长度
var LENGTH_CALCULATOR = Symbol('lengthCalculator'); // 长度计算
var ALLOW_STALE = Symbol('allowStale'); // 允许过时
var MAX_AGE = Symbol('maxAge'); // 最大时效(缓存时长)
var DISPOSE = Symbol('dispose'); // 处置 处理
var NO_DISPOSE_ON_SET = Symbol('noDisposeOnSet'); // 不可处理
var LIST = Symbol('list'); // 列表
var CACHE = Symbol('cache'); // 缓存
var UPDATE_AGE_ON_GET = Symbol('updateAgeOnGet'); // 获取更新时效
var naiveLength = function naiveLength() {
return 1;
};
/**
* 是否过时
* @param self
* @param hit
*/
function isStale(self, hit) {
if (!hit || !hit.maxAge && !self[MAX_AGE]) return false;
var diff = Date.now() - hit.now;
return hit.maxAge ? diff > hit.maxAge : self[MAX_AGE] && diff > self[MAX_AGE];
}
/**
* 删除
* @param self
* @param node
*/
function _del(self, node) {
if (node) {
var hit = node.value;
if (self[DISPOSE]) self[DISPOSE](hit.key, hit.value);
self[LENGTH] -= hit.length;
self[CACHE]["delete"](hit.key);
self[LIST].removeNode(node);
}
}
/**
* 获取
* @param self
* @param key
* @param doUse
*/
function _get(self, key, doUse) {
var node = self[CACHE].get(key);
if (node) {
var hit = node.value;
if (isStale(self, hit)) {
_del(self, node);
if (!self[ALLOW_STALE]) return undefined;
} else if (doUse) {
if (self[UPDATE_AGE_ON_GET]) node.value.now = Date.now();
self[LIST].unshiftNode(node);
}
return hit.value;
}
}
/**
* 修整
* @param self
*/
function trim(self) {
if (self[LENGTH] > self[MAX]) {
for (var walker = self[LIST].tail; self[LENGTH] > self[MAX] && walker !== null;) {
// We know that we're about to delete this one, and also
// what the next least recently used key will be, so just
// go ahead and set it now.
var prev = walker.prev;
_del(self, walker);
walker = prev;
}
}
}
/**
* 遍历步骤
* @param self
* @param fn
* @param node
* @param thisp
*/
function forEachStep(self, fn, node, thisp) {
var hit = node.value;
if (isStale(self, hit)) {
_del(self, node);
if (!self[ALLOW_STALE]) hit = undefined;
}
if (hit) fn.call(thisp, hit.value, hit.key, self);
}
/**
* 构造 Entry 类
*/
var Entry = function Entry(key, value, length, now) {
var maxAge = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
_babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_1___default()(this, Entry);
this.key = key;
this.value = value;
this.length = length;
this.now = now;
this.maxAge = maxAge;
};
/**
* 导出 Cache 类
*/
var Cache =
/*#__PURE__*/
function () {
function Cache(options) {
_babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_1___default()(this, Cache);
if (typeof options === 'number') options = {
max: options
};
if (!options) options = {};
if (options.max && (typeof options.max !== 'number' || options.max < 0)) throw new TypeError('max must be a non-negative number');
this[MAX] = options.max || 0;
var lc = options.length || naiveLength;
this[LENGTH_CALCULATOR] = typeof lc !== 'function' ? naiveLength : lc;
this[ALLOW_STALE] = options.stale || false;
if (options.maxAge && typeof options.maxAge !== 'number') throw new TypeError('maxAge must be a number');
this[MAX_AGE] = options.maxAge || 0;
this[DISPOSE] = options.dispose;
this[NO_DISPOSE_ON_SET] = options.noDisposeOnSet || false;
this[UPDATE_AGE_ON_GET] = options.updateAgeOnGet || false;
this.reset();
} // resize the cache when the max changes.
_babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_0___default()(Cache, [{
key: "rforEach",
value: function rforEach(fn, thisp) {
thisp = thisp || this;
for (var walker = this[LIST].tail; walker !== null;) {
var prev = walker.prev;
forEachStep(this, fn, walker, thisp);
walker = prev;
}
}
}, {
key: "forEach",
value: function forEach(fn, thisp) {
thisp = thisp || this;
for (var walker = this[LIST].head; walker !== null;) {
var next = walker.next;
forEachStep(this, fn, walker, thisp);
walker = next;
}
}
}, {
key: "keys",
value: function keys() {
return this[LIST].toArray().map(function (k) {
return k.key;
});
}
}, {
key: "values",
value: function values() {
return this[LIST].toArray().map(function (k) {
return k.value;
});
}
}, {
key: "reset",
value: function reset() {
var _this = this;
if (this[DISPOSE] && this[LIST] && this[LIST].length) {
this[LIST].forEach(function (hit) {
return _this[DISPOSE](hit.key, hit.value);
});
}
this[CACHE] = new Map(); // hash of items by key
this[LIST] = new _Yallist__WEBPACK_IMPORTED_MODULE_4__["default"](); // list of items in order of use recency
this[LENGTH] = 0; // length of items in the list
}
}, {
key: "dump",
value: function dump() {
var _this2 = this;
return this[LIST].map(function (hit) {
return isStale(_this2, hit) ? false : {
k: hit.key,
v: hit.value,
e: hit.now + (hit.maxAge || 0)
};
}).toArray().filter(function (h) {
return h;
});
}
}, {
key: "dumpLru",
value: function dumpLru() {
return this[LIST];
}
}, {
key: "set",
value: function set(key, value, maxAge) {
maxAge = maxAge || this[MAX_AGE];
if (maxAge && typeof maxAge !== 'number') throw new TypeError('maxAge must be a number');
var now = maxAge ? Date.now() : 0;
var len = this[LENGTH_CALCULATOR](value, key);
if (this[CACHE].has(key)) {
if (len > this[MAX]) {
_del(this, this[CACHE].get(key));
return false;
}
var node = this[CACHE].get(key);
var item = node.value;
if (this[DISPOSE]) {
if (!this[NO_DISPOSE_ON_SET]) this[DISPOSE](key, item.value);
}
item.now = now;
item.maxAge = maxAge;
item.value = value;
this[LENGTH] += len - item.length;
item.length = len;
this.get(key);
trim(this);
return true;
}
var hit = new Entry(key, value, len, now, maxAge);
if (hit.length > this[MAX]) {
if (this[DISPOSE]) this[DISPOSE](key, value);
return false;
}
this[LENGTH] += hit.length;
this[LIST].unshift(hit);
this[CACHE].set(key, this[LIST].head);
trim(this);
return true;
}
}, {
key: "has",
value: function has(key) {
if (!this[CACHE].has(key)) return false;
var hit = this[CACHE].get(key).value;
return !isStale(this, hit);
}
}, {
key: "get",
value: function get(key) {
return _get(this, key, true);
}
}, {
key: "peek",
value: function peek(key) {
return _get(this, key, false);
}
}, {
key: "pop",
value: function pop() {
var node = this[LIST].tail;
if (!node) return null;
_del(this, node);
return node.value;
}
}, {
key: "del",
value: function del(key) {
_del(this, this[CACHE].get(key));
}
}, {
key: "load",
value: function load(arr) {
this.reset();
var now = Date.now(); // A previous serialized cache has the most recent items first
for (var l = arr.length - 1; l >= 0; l--) {
var hit = arr[l];
var expiresAt = hit.e || 0;
if (expiresAt === 0) // the item was created without expiration in a non aged cache
this.set(hit.k, hit.v);else {
var maxAge = expiresAt - now; // dont add already expired items
if (maxAge > 0) {
this.set(hit.k, hit.v, maxAge);
}
}
}
}
}, {
key: "prune",
value: function prune() {
var _this3 = this;
this[CACHE].forEach(function (_value, key) {
return _get(_this3, key, false);
});
}
}, {
key: "max",
set: function set(mL) {
if (typeof mL !== 'number' || mL < 0) throw new TypeError('max must be a non-negative number');
this[MAX] = mL || Infinity;
trim(this);
},
get: function get() {
return this[MAX];
}
}, {
key: "allowStale",
set: function set(allowStale) {
this[ALLOW_STALE] = !!allowStale;
},
get: function get() {
return this[ALLOW_STALE];
}
}, {
key: "maxAge",
set: function set(mA) {
if (typeof mA !== 'number') throw new TypeError('maxAge must be a non-negative number');
this[MAX_AGE] = mA;
trim(this);
},
get: function get() {
return this[MAX_AGE];
} // resize the cache when the lengthCalculator changes.
}, {
key: "lengthCalculator",
set: function set(lC) {
var _this4 = this;
if (typeof lC !== 'function') lC = naiveLength;
if (lC !== this[LENGTH_CALCULATOR]) {
this[LENGTH_CALCULATOR] = lC;
this[LENGTH] = 0;
this[LIST].forEach(function (hit) {
hit.length = _this4[LENGTH_CALCULATOR](hit.value, hit.key);
_this4[LENGTH] += hit.length;
});
}
trim(this);
},
get: function get() {
return this[LENGTH_CALCULATOR];
}
}, {
key: "length",
get: function get() {
return this[LENGTH];
}
}, {
key: "itemCount",
get: function get() {
return this[LIST].length;
}
}]);
return Cache;
}();
function refreshCacheOptions(cache) {
return Object(mobx__WEBPACK_IMPORTED_MODULE_2__["reaction"])(function () {
return Object(choerodon_ui_lib_configure__WEBPACK_IMPORTED_MODULE_3__["getConfig"])('lookupCache') || {};
}, function (lookupCache) {
if ('max' in lookupCache) {
cache.max = lookupCache.max;
}
if ('maxAge' in lookupCache) {
cache.maxAge = lookupCache.maxAge;
}
if ('stale' in lookupCache) {
cache.allowStale = lookupCache.stale;
}
if ('length' in lookupCache) {
cache.lengthCalculator = lookupCache.length;
}
});
}
/***/ }),
/***/ "./components-pro/_util/DocumentUtils.tsx":
/*!************************************************!*\
!*** ./components-pro/_util/DocumentUtils.tsx ***!
\************************************************/
/*! exports provided: getDocument, getDocuments, findIFrame, getMousePosition */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getDocument", function() { return getDocument; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getDocuments", function() { return getDocuments; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "findIFrame", function() { return findIFrame; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getMousePosition", function() { return getMousePosition; });
/* harmony import */ var _babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/toConsumableArray */ "./node_modules/@babel/runtime/helpers/toConsumableArray.js");
/* harmony import */ var _babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0__);
function getDocument(self) {
try {
var parent = self.parent,
top = self.top;
if (parent !== top) {
return getDocument(parent);
}
return parent.document;
} catch (e) {
return self.document;
}
}
function getDocuments(self) {
var list = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
try {
var parent = self.parent,
top = self.top;
if (parent !== top) {
return getDocuments(parent, list);
}
return list.concat(parent.document);
} catch (e) {
return list.concat(self.document);
}
}
function findIFrame(self) {
return _babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0___default()(self.parent.document.querySelectorAll('iframe')).find(function (frame) {
return frame.contentWindow === self;
});
}
function getPageMousePosition(x, y, self) {
var _self$document$docume = self.document.documentElement,
scrollTop = _self$document$docume.scrollTop,
scrollLeft = _self$document$docume.scrollLeft;
return {
x: x + scrollLeft,
y: y + scrollTop
};
}
function getMousePosition(x, y, self, client) {
try {
if (self.top === self) {
return client ? {
x: x,
y: y
} : getPageMousePosition(x, y, self);
}
var parent = self.parent;
var iframe = findIFrame(self);
var _ref = iframe ? iframe.getBoundingClientRect() : {
top: 0,
left: 0
},
top = _ref.top,
left = _ref.left;
var newX = x + left;
var newY = y + top;
if (parent === self.top) {
return client ? {
x: newX,
y: newY
} : getPageMousePosition(newX, newY, parent);
}
return getMousePosition(newX, newY, parent);
} catch (e) {
return client ? {
x: x,
y: y
} : getPageMousePosition(x, y, self);
}
}
/***/ }),
/***/ "./components-pro/_util/EventManager.tsx":
/*!***********************************************!*\
!*** ./components-pro/_util/EventManager.tsx ***!
\***********************************************/
/*! exports provided: default, preventDefault, stopPropagation, stopEvent */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var choerodon_ui_lib_util_EventManager__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! choerodon-ui/lib/_util/EventManager */ "./components/_util/EventManager.tsx");
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "preventDefault", function() { return choerodon_ui_lib_util_EventManager__WEBPACK_IMPORTED_MODULE_0__["preventDefault"]; });
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "stopPropagation", function() { return choerodon_ui_lib_util_EventManager__WEBPACK_IMPORTED_MODULE_0__["stopPropagation"]; });
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "stopEvent", function() { return choerodon_ui_lib_util_EventManager__WEBPACK_IMPORTED_MODULE_0__["stopEvent"]; });
/* harmony default export */ __webpack_exports__["default"] = (choerodon_ui_lib_util_EventManager__WEBPACK_IMPORTED_MODULE_0__["default"]);
/***/ }),
/***/ "./components-pro/_util/MobxUtils.tsx":
/*!********************************************!*\
!*** ./components-pro/_util/MobxUtils.tsx ***!
\********************************************/
/*! exports provided: mobxGet, mobxSet, mobxRemove */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mobxGet", function() { return mobxGet; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mobxSet", function() { return mobxSet; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mobxRemove", function() { return mobxRemove; });
/* harmony import */ var mobx__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! mobx */ "mobx");
/* harmony import */ var mobx__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(mobx__WEBPACK_IMPORTED_MODULE_0__);
function mobxGet(obj, key) {
if (Object(mobx__WEBPACK_IMPORTED_MODULE_0__["isObservableObject"])(obj)) {
return Object(mobx__WEBPACK_IMPORTED_MODULE_0__["get"])(obj, key);
}
return obj[key];
}
function mobxSet(obj, key, value) {
if (Object(mobx__WEBPACK_IMPORTED_MODULE_0__["isObservableObject"])(obj)) {
Object(mobx__WEBPACK_IMPORTED_MODULE_0__["runInAction"])(function () {
Object(mobx__WEBPACK_IMPORTED_MODULE_0__["set"])(obj, key, value);
});
} else {
obj[key] = value;
}
}
function mobxRemove(obj, key) {
if (Object(mobx__WEBPACK_IMPORTED_MODULE_0__["isObservableObject"])(obj)) {
Object(mobx__WEBPACK_IMPORTED_MODULE_0__["runInAction"])(function () {
Object(mobx__WEBPACK_IMPORTED_MODULE_0__["remove"])(obj, key);
});
} else {
delete obj[key];
}
}
/***/ }),
/***/ "./components-pro/_util/ObjectChainValue.tsx":
/*!***************************************************!*\
!*** ./components-pro/_util/ObjectChainValue.tsx ***!
\***************************************************/
/*! exports provided: get, set, remove */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "get", function() { return get; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "set", function() { return set; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "remove", function() { return remove; });
/* harmony import */ var lodash_isObject__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! lodash/isObject */ "./node_modules/lodash/isObject.js");
/* harmony import */ var lodash_isObject__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(lodash_isObject__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var mobx__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! mobx */ "mobx");
/* harmony import */ var mobx__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(mobx__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _MobxUtils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./MobxUtils */ "./components-pro/_util/MobxUtils.tsx");
function get(obj, prop) {
if (obj === null) {
return null;
}
if (obj !== undefined) {
var index = prop.indexOf('.');
if (index !== -1) {
var key = prop.slice(0, index);
var restKey = prop.slice(index + 1);
var value = Object(_MobxUtils__WEBPACK_IMPORTED_MODULE_2__["mobxGet"])(obj, key);
if (value === null) {
return null;
}
if (Object(mobx__WEBPACK_IMPORTED_MODULE_1__["isArrayLike"])(value)) {
return value.map(function (item) {
return get(item, restKey);
}).filter(function (item) {
return !!item;
});
}
if (lodash_isObject__WEBPACK_IMPORTED_MODULE_0___default()(value)) {
return get(value, restKey);
}
} else {
return Object(_MobxUtils__WEBPACK_IMPORTED_MODULE_2__["mobxGet"])(obj, prop);
}
}
}
function set(data, prop, value) {
var fields = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : mobx__WEBPACK_IMPORTED_MODULE_1__["observable"].map();
var index = prop.indexOf('.');
if (index !== -1) {
var key = prop.slice(0, index);
if (!data[key] && value !== undefined) {
var field = fields.get(key);
if (field && field.get('multiple')) {
Object(_MobxUtils__WEBPACK_IMPORTED_MODULE_2__["mobxSet"])(data, key, []);
} else {
Object(_MobxUtils__WEBPACK_IMPORTED_MODULE_2__["mobxSet"])(data, key, {});
}
}
var obj = Object(_MobxUtils__WEBPACK_IMPORTED_MODULE_2__["mobxGet"])(data, key);
if (Object(mobx__WEBPACK_IMPORTED_MODULE_1__["isArrayLike"])(obj)) {
if (Object(mobx__WEBPACK_IMPORTED_MODULE_1__["isArrayLike"])(value)) {
value.forEach(function (item, i) {
if (obj.length === i) {
obj.push({});
} else if (!obj[i]) {
obj[i] = {};
}
set(obj[i], prop.slice(index + 1), item);
});
}
} else if (lodash_isObject__WEBPACK_IMPORTED_MODULE_0___default()(obj)) {
set(obj, prop.slice(index + 1), value);
}
} else {
Object(_MobxUtils__WEBPACK_IMPORTED_MODULE_2__["mobxSet"])(data, prop, value);
}
}
function remove(obj, prop) {
var index = prop.indexOf('.');
if (index !== -1) {
var value = Object(_MobxUtils__WEBPACK_IMPORTED_MODULE_2__["mobxGet"])(obj, prop.slice(0, index));
if (value) {
var restKey = prop.slice(index + 1);
if (Object(mobx__WEBPACK_IMPORTED_MODULE_1__["isArrayLike"])(value)) {
value.forEach(function (item) {
return remove(item, restKey);
});
} else if (lodash_isObject__WEBPACK_IMPORTED_MODULE_0___default()(value)) {
remove(value, restKey);
}
}
} else {
Object(_MobxUtils__WEBPACK_IMPORTED_MODULE_2__["mobxRemove"])(obj, prop);
}
}
/***/ }),
/***/ "./components-pro/_util/PromiseMerger.tsx":
/*!************************************************!*\
!*** ./components-pro/_util/PromiseMerger.tsx ***!
\************************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* WEBPACK VAR INJECTION */(function(process) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return PromiseMerger; });
/* harmony import */ var _babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/toConsumableArray */ "./node_modules/@babel/runtime/helpers/toConsumableArray.js");
/* harmony import */ var _babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "./node_modules/@babel/runtime/helpers/classCallCheck.js");
/* harmony import */ var _babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @babel/runtime/helpers/createClass */ "./node_modules/@babel/runtime/helpers/createClass.js");
/* harmony import */ var _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js");
/* harmony import */ var mobx__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! mobx */ "mobx");
/* harmony import */ var mobx__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(mobx__WEBPACK_IMPORTED_MODULE_4__);
/* harmony import */ var _Cache__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Cache */ "./components-pro/_util/Cache.tsx");
var KEY = Symbol('KEY');
var PromiseMerger =
/*#__PURE__*/
function () {
function PromiseMerger(callback, config) {
var timeout = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 200;
_babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_1___default()(this, PromiseMerger);
this.timeout = timeout;
this.promiseMap = new Map();
this.cache = new _Cache__WEBPACK_IMPORTED_MODULE_5__["default"](Object(mobx__WEBPACK_IMPORTED_MODULE_4__["toJS"])(config));
this.callback = callback;
this.reaction = Object(_Cache__WEBPACK_IMPORTED_MODULE_5__["refreshCacheOptions"])(this.cache);
}
_babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_2___default()(PromiseMerger, [{
key: "dispose",
value: function dispose() {
this.reaction();
}
}, {
key: "add",
value: function add(code, getBatchKey, args) {
var _this = this;
var cache = this.cache,
promiseMap = this.promiseMap;
var item = cache.get(code);
if (item) {
return Promise.resolve(item);
}
var batchKey = getBatchKey ? getBatchKey(KEY) : KEY;
return new Promise(function (resolve, reject) {
var promiseList = promiseMap.get(batchKey) || new Map();
promiseMap.set(batchKey, promiseList);
var promise = promiseList.get(code);
var resolveCallback = function resolveCallback() {
resolve(cache.get(code));
};
if (promise) {
promise.resolves.push(resolveCallback);
promise.rejects.push(reject);
} else {
if (_this.waitID) {
clearTimeout(_this.waitID);
}
promise = {
resolves: [resolveCallback],
rejects: [reject]
};
promiseList.set(code, promise);
_this.waitID = setTimeout(function () {
var codeList = _babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0___default()(promiseList.keys());
if (process.env.LOGGER_LEVEL === 'info') {
// eslint-disable-next-line no-console
console.info("batch request: ".concat(codeList));
}
_this.callback(codeList, args).then(function (res) {
codeList.forEach(function (key) {
var value = promiseList.get(key);
var data = res[key];
_this.cache.set(key, data);
promiseList["delete"](key);
var _ref = value || {},
_ref$resolves = _ref.resolves,
resolves = _ref$resolves === void 0 ? [] : _ref$resolves;
resolves.forEach(function (r) {
return r(data);
});
});
})["catch"](function (error) {
codeList.forEach(function (key) {
var value = promiseList.get(key);
promiseList["delete"](key);
var _ref2 = value || {},
_ref2$rejects = _ref2.rejects,
rejects = _ref2$rejects === void 0 ? [] : _ref2$rejects;
rejects.forEach(function (r) {
return r(error);
});
});
});
}, _this.timeout);
}
});
}
}]);
return PromiseMerger;
}();
Object(tslib__WEBPACK_IMPORTED_MODULE_3__["__decorate"])([mobx__WEBPACK_IMPORTED_MODULE_4__["action"]], PromiseMerger.prototype, "add", null);
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../node_modules/process/browser.js */ "./node_modules/process/browser.js")))
/***/ }),
/***/ "./components-pro/_util/PromiseQueue.tsx":
/*!***********************************************!*\
!*** ./components-pro/_util/PromiseQueue.tsx ***!
\***********************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() {