choerodon-ui
Version:
An enterprise-class UI design language and React-based implementation
1,531 lines (1,279 loc) • 7.06 MB
JavaScript
/*!
*
* choerodon-ui v1.5.3
*
*/
(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
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // 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;
/******/ }
/******/
/******/
/******/ // 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 = "";
/******/
/******/
/******/ // 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",
"./bar-code/style/index.tsx": "./components/bar-code/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",
"./config-provider/style/index.tsx": "./components/config-provider/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",
"./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",
"./use-config/style/index.tsx": "./components/use-config/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-dataset/axios/cacheAdapterEnhancer.tsx":
/*!***********************************************************!*\
!*** ./components-dataset/axios/cacheAdapterEnhancer.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 cacheAdapterEnhancer; });
/* harmony import */ var _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "./node_modules/@babel/runtime/helpers/asyncToGenerator.js");
/* harmony import */ var _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @babel/runtime/regenerator */ "./node_modules/@babel/runtime/regenerator/index.js");
/* harmony import */ var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_regenerator__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 _configure__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../configure */ "./components-dataset/configure/index.tsx");
/* harmony import */ var _cache__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../cache */ "./components-dataset/cache/index.tsx");
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./utils */ "./components-dataset/axios/utils.tsx");
function getDefaultCache() {
var lookupCache = Object(mobx__WEBPACK_IMPORTED_MODULE_2__["toJS"])(Object(_configure__WEBPACK_IMPORTED_MODULE_3__["getConfig"])('lookupCache'));
var cache = new _cache__WEBPACK_IMPORTED_MODULE_4__["default"](lookupCache);
Object(_cache__WEBPACK_IMPORTED_MODULE_4__["refreshCacheOptions"])(cache);
return cache;
}
function cacheAdapterEnhancer(adapter) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var _options$enabledByDef = options.enabledByDefault,
enabledByDefault = _options$enabledByDef === void 0 ? true : _options$enabledByDef,
_options$cacheFlag = options.cacheFlag,
cacheFlag = _options$cacheFlag === void 0 ? 'cache' : _options$cacheFlag,
_options$defaultCache = options.defaultCache,
defaultCache = _options$defaultCache === void 0 ? getDefaultCache() : _options$defaultCache;
return function (config) {
var useCache = config[cacheFlag] !== undefined && config[cacheFlag] !== null ? config[cacheFlag] : enabledByDefault;
if (useCache) {
var cache = Object(_utils__WEBPACK_IMPORTED_MODULE_5__["isCacheLike"])(useCache) ? useCache : defaultCache;
var index = Object(_utils__WEBPACK_IMPORTED_MODULE_5__["buildURLWithAxiosConfig"])(config);
var responsePromise = cache.get(index);
if (!responsePromise) {
responsePromise = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0___default()( /*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default.a.mark(function _callee() {
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default.a.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.prev = 0;
_context.next = 3;
return adapter(config);
case 3:
return _context.abrupt("return", _context.sent);
case 6:
_context.prev = 6;
_context.t0 = _context["catch"](0);
cache.del(index);
throw _context.t0;
case 10:
case "end":
return _context.stop();
}
}
}, _callee, null, [[0, 6]]);
}))();
if (process.env.LOGGER_LEVEL === 'info') {
// eslint-disable-next-line no-console
console.info("request: ".concat(index));
}
cache.set(index, responsePromise);
return responsePromise;
}
if (process.env.LOGGER_LEVEL === 'info') {
// eslint-disable-next-line no-console
console.info("request cached by cache adapter: ".concat(index));
}
return responsePromise;
}
return adapter(config);
};
}
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../node_modules/process/browser.js */ "./node_modules/process/browser.js")))
/***/ }),
/***/ "./components-dataset/axios/index.tsx":
/*!********************************************!*\
!*** ./components-dataset/axios/index.tsx ***!
\********************************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! axios */ "./node_modules/axios/index.js");
/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(axios__WEBPACK_IMPORTED_MODULE_0__);
var jsonMimeType = 'application/json';
var instance = axios__WEBPACK_IMPORTED_MODULE_0___default.a.create({
timeout: 30000,
headers: {
'Content-Type': jsonMimeType,
Accept: jsonMimeType,
'X-Requested-With': 'XMLHttpRequest'
}
}); // http response 拦截器
instance.interceptors.response.use(function (response) {
var status = response.status,
data = response.data;
if (status === 204) {
return response;
}
if (data.success === false) {
throw data;
} else {
return data;
}
});
/* harmony default export */ __webpack_exports__["default"] = (instance);
/***/ }),
/***/ "./components-dataset/axios/throttleAdapterEnhancer.tsx":
/*!**************************************************************!*\
!*** ./components-dataset/axios/throttleAdapterEnhancer.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 throttleAdapterEnhancer; });
/* harmony import */ var _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "./node_modules/@babel/runtime/helpers/asyncToGenerator.js");
/* harmony import */ var _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @babel/runtime/regenerator */ "./node_modules/@babel/runtime/regenerator/index.js");
/* harmony import */ var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _cache__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../cache */ "./components-dataset/cache/index.tsx");
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./utils */ "./components-dataset/axios/utils.tsx");
function throttleAdapterEnhancer(adapter) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var _options$threshold = options.threshold,
threshold = _options$threshold === void 0 ? 1000 : _options$threshold,
_options$cache = options.cache,
cache = _options$cache === void 0 ? new _cache__WEBPACK_IMPORTED_MODULE_2__["default"]({
max: 10
}) : _options$cache;
var recordCacheWithRequest = function recordCacheWithRequest(index, config) {
var responsePromise = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0___default()( /*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default.a.mark(function _callee() {
var response;
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default.a.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.prev = 0;
_context.next = 3;
return adapter(config);
case 3:
response = _context.sent;
cache.set(index, {
timestamp: Date.now(),
value: Promise.resolve(response)
});
return _context.abrupt("return", response);
case 8:
_context.prev = 8;
_context.t0 = _context["catch"](0);
cache.del(index);
throw _context.t0;
case 12:
case "end":
return _context.stop();
}
}
}, _callee, null, [[0, 8]]);
}))();
cache.set(index, {
timestamp: Date.now(),
value: responsePromise
});
return responsePromise;
};
return function (config) {
var index = Object(_utils__WEBPACK_IMPORTED_MODULE_3__["buildURLWithAxiosConfig"])(config);
var now = Date.now();
var cachedRecord = cache.get(index) || {
timestamp: now
};
if (now - cachedRecord.timestamp <= threshold) {
var responsePromise = cachedRecord.value;
if (responsePromise) {
if (process.env.LOGGER_LEVEL === 'info') {
// eslint-disable-next-line no-console
console.info("request cached by throttle adapter: ".concat(index));
}
return responsePromise;
}
}
return recordCacheWithRequest(index, config);
};
}
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../node_modules/process/browser.js */ "./node_modules/process/browser.js")))
/***/ }),
/***/ "./components-dataset/axios/utils.tsx":
/*!********************************************!*\
!*** ./components-dataset/axios/utils.tsx ***!
\********************************************/
/*! exports provided: buildSortedURL, buildURLWithAxiosConfig, isCacheLike */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "buildSortedURL", function() { return buildSortedURL; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "buildURLWithAxiosConfig", function() { return buildURLWithAxiosConfig; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isCacheLike", function() { return isCacheLike; });
/* harmony import */ var _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ "./node_modules/@babel/runtime/helpers/slicedToArray.js");
/* harmony import */ var _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var axios_lib_helpers_buildURL__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! axios/lib/helpers/buildURL */ "./node_modules/axios/lib/helpers/buildURL.js");
/* harmony import */ var axios_lib_helpers_buildURL__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(axios_lib_helpers_buildURL__WEBPACK_IMPORTED_MODULE_1__);
function buildSortedURL() {
var builtURL = axios_lib_helpers_buildURL__WEBPACK_IMPORTED_MODULE_1___default.a.apply(void 0, arguments);
var _builtURL$split = builtURL.split('?'),
_builtURL$split2 = _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_0___default()(_builtURL$split, 2),
urlPath = _builtURL$split2[0],
queryString = _builtURL$split2[1];
if (queryString) {
var paramsPair = queryString.split('&');
return "".concat(urlPath, "?").concat(paramsPair.sort().join('&'));
}
return builtURL;
}
function buildURLWithAxiosConfig(config) {
var data = config.data,
url = config.url,
params = config.params,
paramsSerializer = config.paramsSerializer;
var builtURL = buildSortedURL(url, params, paramsSerializer);
if (data) {
return "".concat(builtURL, "|").concat(JSON.stringify(data));
}
return builtURL;
}
function isCacheLike(cache) {
return !!(cache.set && cache.get && cache.del && typeof cache.get === 'function' && typeof cache.set === 'function' && typeof cache.del === 'function');
}
/***/ }),
/***/ "./components-dataset/cache/Yallist.tsx":
/*!**********************************************!*\
!*** ./components-dataset/cache/Yallist.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() { return Yallist; });
/* harmony import */ var _babel_runtime_helpers_construct__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/construct */ "./node_modules/@babel/runtime/helpers/construct.js");
/* harmony import */ var _babel_runtime_helpers_construct__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_construct__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @babel/runtime/helpers/createClass */ "./node_modules/@babel/runtime/helpers/createClass.js");
/* harmony import */ var _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "./node_modules/@babel/runtime/helpers/classCallCheck.js");
/* harmony import */ var _babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @babel/runtime/regenerator */ "./node_modules/@babel/runtime/regenerator/index.js");
/* harmony import */ var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_3__);
var Node = /*#__PURE__*/_babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_1___default()(function Node(value, prev, next, list) {
_babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_2___default()(this, Node);
if (!(this instanceof Node)) {
return new Node(value, prev, next, list);
}
this.list = list;
this.value = value;
if (prev) {
prev.next = this;
this.prev = prev;
} else {
this.prev = null;
}
if (next) {
next.prev = this;
this.next = next;
} else {
this.next = null;
}
});
function insert(self, node, value) {
var inserted = node === self.head ? new Node(value, null, node, self) : new Node(value, node, node.next, self);
if (inserted.next === null) {
self.tail = inserted;
}
if (inserted.prev === null) {
self.head = inserted;
}
self.length++;
return inserted;
}
function _push(self, item) {
self.tail = new Node(item, self.tail, null, self);
if (!self.head) {
self.head = self.tail;
}
self.length++;
}
function _unshift(self, item) {
self.head = new Node(item, null, self.head, self);
if (!self.tail) {
self.tail = self.head;
}
self.length++;
}
var Yallist = /*#__PURE__*/function () {
function Yallist() {
_babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_2___default()(this, Yallist);
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
if (!(this instanceof Yallist)) {
return _babel_runtime_helpers_construct__WEBPACK_IMPORTED_MODULE_0___default()(Yallist, args);
}
this.tail = null;
this.head = null;
this.length = 0;
var list = args[0];
if (list && typeof list.forEach === 'function') {
list.forEach(function (item) {
this.push(item);
});
} else if (args.length > 0) {
this.push.apply(this, args);
}
}
_babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_1___default()(Yallist, [{
key: "removeNode",
value: function removeNode(node) {
if (node.list !== this) {
throw new Error('removing node which does not belong to this list');
}
var next = node.next,
prev = node.prev;
if (next) {
next.prev = prev;
}
if (prev) {
prev.next = next;
}
if (node === this.head) {
this.head = next;
}
if (node === this.tail) {
this.tail = prev;
}
node.list.length--;
node.next = null;
node.prev = null;
node.list = null;
return next;
}
}, {
key: "unshiftNode",
value: function unshiftNode(node) {
if (node === this.head) {
return;
}
if (node.list) {
node.list.removeNode(node);
}
var head = this.head;
node.list = this;
node.next = head;
if (head) {
head.prev = node;
}
this.head = node;
if (!this.tail) {
this.tail = node;
}
this.length++;
}
}, {
key: "pushNode",
value: function pushNode(node) {
if (node === this.tail) {
return;
}
if (node.list) {
node.list.removeNode(node);
}
var tail = this.tail;
node.list = this;
node.prev = tail;
if (tail) {
tail.next = node;
}
this.tail = node;
if (!this.head) {
this.head = node;
}
this.length++;
}
}, {
key: "push",
value: function push() {
var _this = this;
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
args.forEach(function (item) {
return _push(_this, item);
});
return this.length;
}
}, {
key: "unshift",
value: function unshift() {
var _this2 = this;
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
args[_key3] = arguments[_key3];
}
args.forEach(function (item) {
return _unshift(_this2, item);
});
return this.length;
}
}, {
key: "pop",
value: function pop() {
if (!this.tail) {
return undefined;
}
var value = this.tail.value;
this.tail = this.tail.prev;
if (this.tail) {
this.tail.next = null;
} else {
this.head = null;
}
this.length--;
return value;
}
}, {
key: "shift",
value: function shift() {
if (!this.head) {
return undefined;
}
var value = this.head.value;
this.head = this.head.next;
if (this.head) {
this.head.prev = null;
} else {
this.tail = null;
}
this.length--;
return value;
}
}, {
key: "forEach",
value: function forEach(fn, thisp) {
thisp = thisp || this;
for (var walker = this.head, i = 0; walker !== null; i++) {
fn.call(thisp, walker.value, i, this);
walker = walker.next;
}
}
}, {
key: "forEachReverse",
value: function forEachReverse(fn, thisp) {
thisp = thisp || this;
for (var walker = this.tail, i = this.length - 1; walker !== null; i--) {
fn.call(thisp, walker.value, i, this);
walker = walker.prev;
}
}
}, {
key: "get",
value: function get(n) {
var i = 0;
var walker = this.head;
for (; walker !== null && i < n; i++) {
walker = walker.next;
}
if (i === n && walker !== null) {
return walker.value;
}
}
}, {
key: "getReverse",
value: function getReverse(n) {
var i = 0;
var walker = this.tail;
for (; walker !== null && i < n; i++) {
// abort out of the list early if we hit a cycle
walker = walker.prev;
}
if (i === n && walker !== null) {
return walker.value;
}
}
}, {
key: "map",
value: function map(fn, thisp) {
thisp = thisp || this;
var res = new Yallist();
for (var walker = this.head; walker !== null;) {
res.push(fn.call(thisp, walker.value, this));
walker = walker.next;
}
return res;
}
}, {
key: "mapReverse",
value: function mapReverse(fn, thisp) {
thisp = thisp || this;
var res = new Yallist();
for (var walker = this.tail; walker !== null;) {
res.push(fn.call(thisp, walker.value, this));
walker = walker.prev;
}
return res;
}
}, {
key: "reduce",
value: function reduce() {
var fn = arguments.length <= 0 ? undefined : arguments[0];
var acc;
var walker = this.head;
if (arguments.length > 1) {
acc = arguments.length <= 1 ? undefined : arguments[1];
} else if (this.head) {
walker = this.head.next;
acc = this.head.value;
} else {
throw new TypeError('Reduce of empty list with no initial value');
}
for (var i = 0; walker !== null; i++) {
acc = fn(acc, walker.value, i);
walker = walker.next;
}
return acc;
}
}, {
key: "reduceReverse",
value: function reduceReverse() {
var fn = arguments.length <= 0 ? undefined : arguments[0];
var acc;
var walker = this.tail;
if (arguments.length > 1) {
acc = arguments.length <= 1 ? undefined : arguments[1];
} else if (this.tail) {
walker = this.tail.prev;
acc = this.tail.value;
} else {
throw new TypeError('Reduce of empty list with no initial value');
}
for (var i = this.length - 1; walker !== null; i--) {
acc = fn(acc, walker.value, i);
walker = walker.prev;
}
return acc;
}
}, {
key: "toArray",
value: function toArray() {
var arr = new Array(this.length);
for (var i = 0, walker = this.head; walker !== null; i++) {
arr[i] = walker.value;
walker = walker.next;
}
return arr;
}
}, {
key: "toArrayReverse",
value: function toArrayReverse() {
var arr = new Array(this.length);
for (var i = 0, walker = this.tail; walker !== null; i++) {
arr[i] = walker.value;
walker = walker.prev;
}
return arr;
}
}, {
key: "slice",
value: function slice(from, to) {
to = to || this.length;
if (to < 0) {
to += this.length;
}
from = from || 0;
if (from < 0) {
from += this.length;
}
var ret = new Yallist();
if (to < from || to < 0) {
return ret;
}
if (from < 0) {
from = 0;
}
if (to > this.length) {
to = this.length;
}
var i = 0;
var walker = this.head;
for (; walker !== null && i < from; i++) {
walker = walker.next;
}
for (; walker !== null && i < to; i++, walker = walker.next) {
ret.push(walker.value);
}
return ret;
}
}, {
key: "sliceReverse",
value: function sliceReverse(from, to) {
to = to || this.length;
if (to < 0) {
to += this.length;
}
from = from || 0;
if (from < 0) {
from += this.length;
}
var ret = new Yallist();
if (to < from || to < 0) {
return ret;
}
if (from < 0) {
from = 0;
}
if (to > this.length) {
to = this.length;
}
var i = this.length;
var walker = this.tail;
for (; walker !== null && i > to; i--) {
walker = walker.prev;
}
for (; walker !== null && i > from; i--, walker = walker.prev) {
ret.push(walker.value);
}
return ret;
}
}, {
key: "splice",
value: function splice(start, deleteCount) {
var _this3 = this;
if (start > this.length) {
start = this.length - 1;
}
if (start < 0) {
start = this.length + start;
}
var walker = this.head;
for (var i = 0; walker !== null && i < start; i++) {
walker = walker.next;
}
var ret = [];
for (var _i = 0; walker && _i < deleteCount; _i++) {
ret.push(walker.value);
walker = this.removeNode(walker);
}
if (walker === null) {
walker = this.tail;
}
if (walker !== this.head && walker !== this.tail && walker !== null) {
walker = walker.prev;
}
for (var _len4 = arguments.length, nodes = new Array(_len4 > 2 ? _len4 - 2 : 0), _key4 = 2; _key4 < _len4; _key4++) {
nodes[_key4 - 2] = arguments[_key4];
}
nodes.forEach(function (item) {
walker = insert(_this3, walker, item);
});
return ret;
}
}, {
key: "reverse",
value: function reverse() {
var head = this.head,
tail = this.tail;
for (var walker = head; walker !== null; walker = walker.prev) {
var _walker = walker,
prev = _walker.prev;
walker.prev = walker.next;
walker.next = prev;
}
this.head = tail;
this.tail = head;
return this;
}
}]);
return Yallist;
}();
Yallist.Node = Node;
Yallist.create = Yallist;
try {
Yallist.prototype[Symbol.iterator] = /*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_3___default.a.mark(function _callee() {
var walker;
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_3___default.a.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
walker = this.head;
case 1:
if (!walker) {
_context.next = 7;
break;
}
_context.next = 4;
return walker.value;
case 4:
walker = walker.next;
_context.next = 1;
break;
case 7:
case "end":
return _context.stop();
}
}
}, _callee, this);
}); // eslint-disable-next-line no-empty
} catch (er) {}
/***/ }),
/***/ "./components-dataset/cache/index.tsx":
/*!********************************************!*\
!*** ./components-dataset/cache/index.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 _configure__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../configure */ "./components-dataset/configure/index.tsx");
/* harmony import */ var _Yallist__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Yallist */ "./components-dataset/cache/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 = /*#__PURE__*/_babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_0___default()(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: "max",
get: function get() {
return this[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);
}
}, {
key: "allowStale",
get: function get() {
return this[ALLOW_STALE];
},
set: function set(allowStale) {
this[ALLOW_STALE] = !!allowStale;
}
}, {
key: "maxAge",
get: function get() {
return this[MAX_AGE];
} // resize the cache when the lengthCalculator changes.
,
set: function set(mA) {
if (typeof mA !== 'number') throw new TypeError('maxAge must be a non-negative number');
this[MAX_AGE] = mA;
trim(this);
}
}, {
key: "lengthCalculator",
get: function get() {
return this[LENGTH_CALCULATOR];
},
set: function set(lC) {
var _this = 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 = _this[LENGTH_CALCULATOR](hit.value, hit.key);
_this[LENGTH] += hit.length;
});
}
trim(this);
}
}, {
key: "length",
get: function get() {
return this[LENGTH];
}
}, {
key: "itemCount",
get: function get() {
return this[LIST].length;
}
}, {
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 _this2 = this;
if (this[DISPOSE] && this[LIST] && this[LIST].length) {
this[LIST].forEach(function (hit) {
return _this2[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 _this3 = this;
return this[LIST].map(function (hit) {
return isStale(_this3, 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 _this4 = this;
this[CACHE].forEach(function (_value, key) {
return _get(_this4, key, false);
});
}
}]);
return Cache;
}();
function refreshCacheOptions(cache) {
return Object(mobx__WEBPACK_IMPORTED_MODULE_2__["reaction"])(function () {
return Object(_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) {