diff --git a/lib/toxic-decorators.browser.js b/lib/toxic-decorators.browser.js index 84a26b8..abc025a 100644 --- a/lib/toxic-decorators.browser.js +++ b/lib/toxic-decorators.browser.js @@ -1,6 +1,6 @@ /** - * toxic-decorators v0.2.3 + * toxic-decorators v0.3.0 * (c) 2017 toxic-johann * Released under GPL-3.0 */ @@ -1270,7 +1270,7 @@ exports.default = function (arr) { var _toConsumableArray = unwrapExports(toConsumableArray); /** - * toxic-utils v0.1.1 + * toxic-utils v0.1.3 * (c) 2017 toxic-johann * Released under MIT */ @@ -1365,7 +1365,9 @@ function isAccessorDescriptor(desc) { * to check if the descirptor is an data descriptor * @param {descriptor} desc it should be a descriptor better */ - +function isDataDescriptor(desc) { + return !!desc && desc.hasOwnProperty('value') && isBoolean(desc.configurable) && isBoolean(desc.enumerable) && isBoolean(desc.writable); +} /** * to check if the descirptor is an initiallizer descriptor * @param {descriptor} desc it should be a descriptor better @@ -1458,7 +1460,7 @@ function getDeepProperty(obj, keys) { var getOwnKeys = isFunction(getOwnPropertySymbols) ? function (obj) { // $FlowFixMe: do not support symwbol yet - return getOwnPropertyNames(obj).concat(getOwnPropertySymbols(obj)); + return Array.from(getOwnPropertyNames(obj).concat(getOwnPropertySymbols(obj))); } : getOwnPropertyNames; // $FlowFixMe: In some environment, Object.getOwnPropertyDescriptors has been implemented; @@ -1531,10 +1533,10 @@ function accessor() { var hasOriginGet = isFunction(originGet); var hasOriginSet = isFunction(originSet); if (!hasOriginGet && hasGet) { - warn("You are trying to set getter via @accessor on one property without getter. That's not a good idea."); + warn('You are trying to set getter via @accessor on ' + prop + ' without getter. That\'s not a good idea.'); } if (!hasOriginSet && hasSet) { - warn("You are trying to set setter via @accessor on one property without setter. That's not a good idea."); + warn('You are trying to set setter via @accessor on ' + prop + ' without setter. That\'s not a good idea.'); } var getter = hasOriginGet || hasGet ? function () { var _this = this; @@ -1852,15 +1854,18 @@ function initialize() { } if (isAccessorDescriptor(descriptor)) { var hasBeenReset = false; + var originSet = descriptor.set; + return accessor({ get: function get(value) { if (hasBeenReset) return value; return bind(fn, this)(value); }, - set: function set(value) { + + set: originSet ? function (value) { hasBeenReset = true; return value; - } + } : undefined })(obj, prop, descriptor); } /** @@ -2010,34 +2015,52 @@ function alias(other, key, option) { var defineProperty$3 = Object.defineProperty; -function autobindClass() { - var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, - _ref$exclude = _ref.exclude, - exclude = _ref$exclude === undefined ? [] : _ref$exclude; - - if (!isArray(exclude)) throw new TypeError('options.exclude must be an array'); - return function (Klass) { - if (!isFunction(Klass)) throw new TypeError('@autobindClass can only be used on class'); - var prototype = Klass.prototype; - - if (isVoid(prototype)) throw new Error('The prototype of the class is empty, please check it'); - - var descs = getOwnPropertyDescriptors(prototype); - var keys = getOwnKeys(prototype); - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i]; - // $FlowFixMe: not support symbol yet - var desc = descs[key]; - if (key === 'constructor' || !isFunction(desc.value) || - // $FlowFixMe: not support symbol yet - exclude.indexOf(key) > -1) continue; - // $FlowFixMe: not support symbol yet - defineProperty$3(prototype, key, autobind(prototype, key, desc)); +function classify(decorator) { + var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, + requirement = _ref.requirement, + _ref$customArgs = _ref.customArgs, + customArgs = _ref$customArgs === undefined ? false : _ref$customArgs; + + return function () { + for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; } + + var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, + _ref2$exclude = _ref2.exclude, + exclude = _ref2$exclude === undefined ? [] : _ref2$exclude, + _ref2$include = _ref2.include, + include = _ref2$include === undefined ? [] : _ref2$include, + _ref2$construct = _ref2.construct, + construct = _ref2$construct === undefined ? false : _ref2$construct, + _ref2$self = _ref2.self, + self = _ref2$self === undefined ? false : _ref2$self; + + if (!isArray(exclude)) throw new TypeError('options.exclude must be an array'); + if (!isArray(include)) throw new TypeError('options.include must be an array'); + return function (Klass) { + var isClass = isFunction(Klass); + if (!self && !isClass) throw new TypeError('@' + decorator.name + 'Class can only be used on class'); + if (self && isPrimitive(Klass)) throw new TypeError('@' + decorator.name + 'Class must be used on non-primitive type value in \'self\' mode'); + var prototype = self ? Klass : Klass.prototype; + if (isVoid(prototype)) throw new Error('The prototype of the ' + Klass.name + ' is empty, please check it'); + var descs = getOwnPropertyDescriptors(prototype); + getOwnKeys(prototype).concat(include).forEach(function (key) { + var desc = descs[key]; + if (key === 'constructor' && !construct || self && isClass && ['name', 'length', 'prototype'].indexOf(key) > -1 || exclude.indexOf(key) > -1 || isFunction(requirement) && requirement(prototype, key, desc, { self: self }) === false) return; + defineProperty$3(prototype, key, (customArgs ? decorator.apply(undefined, toConsumableArray$1(args)) : decorator)(prototype, key, desc)); + }); + }; }; } +var autobindClass = classify(autobind, { + requirement: function requirement(obj, prop, desc) { + // $FlowFixMe: it's data descriptor now + return isDataDescriptor(desc) && isFunction(desc.value); + } +}); + var mapStore = void 0; // save bound function for super function getBoundSuper(obj, fn) { @@ -2179,7 +2202,10 @@ function frozen(obj, prop, descriptor) { var getOwnPropertyDescriptor$2 = Object.getOwnPropertyDescriptor; var defineProperty$5 = Object.defineProperty; -function waituntil(key, other) { +function waituntil(key) { + var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, + other = _ref.other; + if (!isFunction(key) && !isPromise(key) && !isString(key)) throw new TypeError('@waitUntil only accept Function, Promise or String'); return function (obj, prop, descriptor) { if (descriptor === undefined) { @@ -2407,7 +2433,6 @@ var Hooks = function () { var descriptor = getOwnPropertyDescriptor$3(obj, key); if (descriptor.writable === false || descriptor.configurable === false) return; - // $FlowFixMe: flow do not support symbol yet var hooks = new Hooks({ prop: key, handler: handler, deep: deep }); defineProperty$8(obj, key, compressMultipleDecorators(accessor({ set: function set$$1(value) { @@ -2486,6 +2511,46 @@ function nonextendable(obj, prop, descriptor) { })(obj, prop, descriptor); } +function runnable(key) { + var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, + other = _ref.other, + backup = _ref.backup; + + if (!isFunction(key) && !isString(key)) throw new TypeError('@runnable only accept Function or String'); + return function (obj, prop, descriptor) { + if (descriptor === undefined) { + throw new Error('@runnable must used on descriptor, are you using it on undefined property?'); + } + var _value = descriptor.value, + configurable = descriptor.configurable; + + if (!isFunction(_value)) throw new TypeError('@runnable can only be used on method, but not ' + _value + ' on ' + prop); + var canIRun = isFunction(key) ? key : function () { + var keys = key.split('.'); + var originTarget = isPrimitive(other) ? this : other; + return getDeepProperty(originTarget, keys); + }; + backup = isFunction(backup) ? backup : function () {}; + return { + value: function value() { + if (bind(canIRun, this).apply(undefined, arguments) === true) { + return bind(_value, this).apply(undefined, arguments); + } else { + // $FlowFixMe: I have reassign it when it's not a function + return bind(backup, this).apply(undefined, arguments); + } + }, + + // function should not be enmuerable + enumerable: false, + configurable: configurable, + // as we have delay this function + // it's not a good idea to change it + writable: false + }; + }; +} + function enumerable(obj, prop, descriptor) { if (descriptor === undefined) { return { @@ -2621,6 +2686,42 @@ function number$1() { return accessor({ set: args, get: args }); } +var before$1 = classify(before, { + requirement: function requirement(obj, prop, desc) { + // $FlowFixMe: it's data descriptor now + return isDataDescriptor(desc) && isFunction(desc.value); + }, + + customArgs: true +}); + +var after$1 = classify(after, { + requirement: function requirement(obj, prop, desc) { + // $FlowFixMe: it's data descriptor now + return isDataDescriptor(desc) && isFunction(desc.value); + }, + + customArgs: true +}); + +var runnable$1 = classify(runnable, { + requirement: function requirement(obj, prop, desc) { + // $FlowFixMe: it's data descriptor now + return isDataDescriptor(desc) && isFunction(desc.value); + }, + + customArgs: true +}); + +var waituntil$1 = classify(waituntil, { + requirement: function requirement(obj, prop, desc) { + // $FlowFixMe: it's data descriptor now + return isDataDescriptor(desc) && isFunction(desc.value); + }, + + customArgs: true +}); + var defineProperty$9 = Object.defineProperty; var getOwnPropertyDescriptor$4 = Object.getOwnPropertyDescriptor; @@ -2680,6 +2781,7 @@ exports.lazyInit = lazyInit; exports.lock = lock; exports.watch = watch; exports.nonextendable = nonextendable; +exports.runnable = runnable; exports.enumerable = enumerable; exports.nonenumerable = nonenumerable; exports.nonconfigurable = nonconfigurable; @@ -2692,7 +2794,12 @@ exports.alwaysBoolean = boolean$1; exports.alwaysArray = array$1; exports.alwaysNumber = number$1; exports.autobindClass = autobindClass; +exports.beforeClass = before$1; +exports.afterClass = after$1; +exports.runnableClass = runnable$1; +exports.waituntilClass = waituntil$1; exports.applyDecorators = applyDecorators; +exports.classify = classify; exports.getOwnKeys = getOwnKeys; exports.getOwnPropertyDescriptors = getOwnPropertyDescriptors; diff --git a/lib/toxic-decorators.js b/lib/toxic-decorators.js index f9a816a..e828fca 100644 --- a/lib/toxic-decorators.js +++ b/lib/toxic-decorators.js @@ -1,6 +1,6 @@ /** - * toxic-decorators v0.2.3 + * toxic-decorators v0.3.0 * (c) 2017 toxic-johann * Released under GPL-3.0 */ @@ -12,6 +12,7 @@ Object.defineProperty(exports, '__esModule', { value: true }); function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } var _Object$getOwnPropertyDescriptors = _interopDefault(require('babel-runtime/core-js/object/get-own-property-descriptors')); +var _Array$from = _interopDefault(require('babel-runtime/core-js/array/from')); var _Object$defineProperty = _interopDefault(require('babel-runtime/core-js/object/define-property')); var _Object$keys = _interopDefault(require('babel-runtime/core-js/object/keys')); var _Object$getOwnPropertyDescriptor = _interopDefault(require('babel-runtime/core-js/object/get-own-property-descriptor')); @@ -70,7 +71,9 @@ function isAccessorDescriptor(desc) { * to check if the descirptor is an data descriptor * @param {descriptor} desc it should be a descriptor better */ - +function isDataDescriptor(desc) { + return !!desc && desc.hasOwnProperty('value') && toxicPredicateFunctions.isBoolean(desc.configurable) && toxicPredicateFunctions.isBoolean(desc.enumerable) && toxicPredicateFunctions.isBoolean(desc.writable); +} /** * to check if the descirptor is an initiallizer descriptor * @param {descriptor} desc it should be a descriptor better @@ -163,7 +166,7 @@ function getDeepProperty(obj, keys) { var getOwnKeys = toxicPredicateFunctions.isFunction(getOwnPropertySymbols) ? function (obj) { // $FlowFixMe: do not support symwbol yet - return getOwnPropertyNames(obj).concat(getOwnPropertySymbols(obj)); + return _Array$from(getOwnPropertyNames(obj).concat(getOwnPropertySymbols(obj))); } : getOwnPropertyNames; // $FlowFixMe: In some environment, Object.getOwnPropertyDescriptors has been implemented; @@ -236,10 +239,10 @@ function accessor() { var hasOriginGet = toxicPredicateFunctions.isFunction(originGet); var hasOriginSet = toxicPredicateFunctions.isFunction(originSet); if (!hasOriginGet && hasGet) { - warn("You are trying to set getter via @accessor on one property without getter. That's not a good idea."); + warn('You are trying to set getter via @accessor on ' + prop + ' without getter. That\'s not a good idea.'); } if (!hasOriginSet && hasSet) { - warn("You are trying to set setter via @accessor on one property without setter. That's not a good idea."); + warn('You are trying to set setter via @accessor on ' + prop + ' without setter. That\'s not a good idea.'); } var getter = hasOriginGet || hasGet ? function () { var _this = this; @@ -447,15 +450,18 @@ function initialize() { } if (isAccessorDescriptor(descriptor)) { var hasBeenReset = false; + var originSet = descriptor.set; + return accessor({ get: function get(value) { if (hasBeenReset) return value; return toxicUtils.bind(fn, this)(value); }, - set: function set(value) { + + set: originSet ? function (value) { hasBeenReset = true; return value; - } + } : undefined })(obj, prop, descriptor); } /** @@ -605,34 +611,52 @@ function alias(other, key, option) { var defineProperty$1 = _Object$defineProperty; -function autobindClass() { - var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, - _ref$exclude = _ref.exclude, - exclude = _ref$exclude === undefined ? [] : _ref$exclude; - - if (!toxicPredicateFunctions.isArray(exclude)) throw new TypeError('options.exclude must be an array'); - return function (Klass) { - if (!toxicPredicateFunctions.isFunction(Klass)) throw new TypeError('@autobindClass can only be used on class'); - var prototype = Klass.prototype; - - if (toxicPredicateFunctions.isVoid(prototype)) throw new Error('The prototype of the class is empty, please check it'); - - var descs = getOwnPropertyDescriptors(prototype); - var keys = getOwnKeys(prototype); - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i]; - // $FlowFixMe: not support symbol yet - var desc = descs[key]; - if (key === 'constructor' || !toxicPredicateFunctions.isFunction(desc.value) || - // $FlowFixMe: not support symbol yet - exclude.indexOf(key) > -1) continue; - // $FlowFixMe: not support symbol yet - defineProperty$1(prototype, key, autobind(prototype, key, desc)); +function classify(decorator) { + var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, + requirement = _ref.requirement, + _ref$customArgs = _ref.customArgs, + customArgs = _ref$customArgs === undefined ? false : _ref$customArgs; + + return function () { + for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; } + + var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, + _ref2$exclude = _ref2.exclude, + exclude = _ref2$exclude === undefined ? [] : _ref2$exclude, + _ref2$include = _ref2.include, + include = _ref2$include === undefined ? [] : _ref2$include, + _ref2$construct = _ref2.construct, + construct = _ref2$construct === undefined ? false : _ref2$construct, + _ref2$self = _ref2.self, + self = _ref2$self === undefined ? false : _ref2$self; + + if (!toxicPredicateFunctions.isArray(exclude)) throw new TypeError('options.exclude must be an array'); + if (!toxicPredicateFunctions.isArray(include)) throw new TypeError('options.include must be an array'); + return function (Klass) { + var isClass = toxicPredicateFunctions.isFunction(Klass); + if (!self && !isClass) throw new TypeError('@' + decorator.name + 'Class can only be used on class'); + if (self && toxicPredicateFunctions.isPrimitive(Klass)) throw new TypeError('@' + decorator.name + 'Class must be used on non-primitive type value in \'self\' mode'); + var prototype = self ? Klass : Klass.prototype; + if (toxicPredicateFunctions.isVoid(prototype)) throw new Error('The prototype of the ' + Klass.name + ' is empty, please check it'); + var descs = getOwnPropertyDescriptors(prototype); + getOwnKeys(prototype).concat(include).forEach(function (key) { + var desc = descs[key]; + if (key === 'constructor' && !construct || self && isClass && ['name', 'length', 'prototype'].indexOf(key) > -1 || exclude.indexOf(key) > -1 || toxicPredicateFunctions.isFunction(requirement) && requirement(prototype, key, desc, { self: self }) === false) return; + defineProperty$1(prototype, key, (customArgs ? decorator.apply(undefined, _toConsumableArray(args)) : decorator)(prototype, key, desc)); + }); + }; }; } +var autobindClass = classify(autobind, { + requirement: function requirement(obj, prop, desc) { + // $FlowFixMe: it's data descriptor now + return isDataDescriptor(desc) && toxicPredicateFunctions.isFunction(desc.value); + } +}); + var mapStore = void 0; // save bound function for super function getBoundSuper(obj, fn) { @@ -774,7 +798,10 @@ function frozen(obj, prop, descriptor) { var getOwnPropertyDescriptor$2 = _Object$getOwnPropertyDescriptor; var defineProperty$3 = _Object$defineProperty; -function waituntil(key, other) { +function waituntil(key) { + var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, + other = _ref.other; + if (!toxicPredicateFunctions.isFunction(key) && !toxicPredicateFunctions.isPromise(key) && !toxicPredicateFunctions.isString(key)) throw new TypeError('@waitUntil only accept Function, Promise or String'); return function (obj, prop, descriptor) { if (descriptor === undefined) { @@ -1004,7 +1031,6 @@ var Hooks = function () { var descriptor = getOwnPropertyDescriptor$3(obj, key); if (descriptor.writable === false || descriptor.configurable === false) return; - // $FlowFixMe: flow do not support symbol yet var hooks = new Hooks({ prop: key, handler: handler, deep: deep }); defineProperty$6(obj, key, compressMultipleDecorators(accessor({ set: function set(value) { @@ -1084,6 +1110,46 @@ function nonextendable(obj, prop, descriptor) { })(obj, prop, descriptor); } +function runnable(key) { + var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, + other = _ref.other, + backup = _ref.backup; + + if (!toxicPredicateFunctions.isFunction(key) && !toxicPredicateFunctions.isString(key)) throw new TypeError('@runnable only accept Function or String'); + return function (obj, prop, descriptor) { + if (descriptor === undefined) { + throw new Error('@runnable must used on descriptor, are you using it on undefined property?'); + } + var _value = descriptor.value, + configurable = descriptor.configurable; + + if (!toxicPredicateFunctions.isFunction(_value)) throw new TypeError('@runnable can only be used on method, but not ' + _value + ' on ' + prop); + var canIRun = toxicPredicateFunctions.isFunction(key) ? key : function () { + var keys = key.split('.'); + var originTarget = toxicPredicateFunctions.isPrimitive(other) ? this : other; + return getDeepProperty(originTarget, keys); + }; + backup = toxicPredicateFunctions.isFunction(backup) ? backup : function () {}; + return { + value: function value() { + if (toxicUtils.bind(canIRun, this).apply(undefined, arguments) === true) { + return toxicUtils.bind(_value, this).apply(undefined, arguments); + } else { + // $FlowFixMe: I have reassign it when it's not a function + return toxicUtils.bind(backup, this).apply(undefined, arguments); + } + }, + + // function should not be enmuerable + enumerable: false, + configurable: configurable, + // as we have delay this function + // it's not a good idea to change it + writable: false + }; + }; +} + function enumerable(obj, prop, descriptor) { if (descriptor === undefined) { return { @@ -1219,6 +1285,42 @@ function number$1() { return accessor({ set: args, get: args }); } +var before$1 = classify(before, { + requirement: function requirement(obj, prop, desc) { + // $FlowFixMe: it's data descriptor now + return isDataDescriptor(desc) && toxicPredicateFunctions.isFunction(desc.value); + }, + + customArgs: true +}); + +var after$1 = classify(after, { + requirement: function requirement(obj, prop, desc) { + // $FlowFixMe: it's data descriptor now + return isDataDescriptor(desc) && toxicPredicateFunctions.isFunction(desc.value); + }, + + customArgs: true +}); + +var runnable$1 = classify(runnable, { + requirement: function requirement(obj, prop, desc) { + // $FlowFixMe: it's data descriptor now + return isDataDescriptor(desc) && toxicPredicateFunctions.isFunction(desc.value); + }, + + customArgs: true +}); + +var waituntil$1 = classify(waituntil, { + requirement: function requirement(obj, prop, desc) { + // $FlowFixMe: it's data descriptor now + return isDataDescriptor(desc) && toxicPredicateFunctions.isFunction(desc.value); + }, + + customArgs: true +}); + var defineProperty$7 = _Object$defineProperty; var getOwnPropertyDescriptor$4 = _Object$getOwnPropertyDescriptor; @@ -1278,6 +1380,7 @@ exports.lazyInit = lazyInit; exports.lock = lock; exports.watch = watch; exports.nonextendable = nonextendable; +exports.runnable = runnable; exports.enumerable = enumerable; exports.nonenumerable = nonenumerable; exports.nonconfigurable = nonconfigurable; @@ -1290,6 +1393,11 @@ exports.alwaysBoolean = boolean$1; exports.alwaysArray = array$1; exports.alwaysNumber = number$1; exports.autobindClass = autobindClass; +exports.beforeClass = before$1; +exports.afterClass = after$1; +exports.runnableClass = runnable$1; +exports.waituntilClass = waituntil$1; exports.applyDecorators = applyDecorators; +exports.classify = classify; exports.getOwnKeys = getOwnKeys; exports.getOwnPropertyDescriptors = getOwnPropertyDescriptors; diff --git a/lib/toxic-decorators.min.js b/lib/toxic-decorators.min.js index 88191de..383b2ee 100644 --- a/lib/toxic-decorators.min.js +++ b/lib/toxic-decorators.min.js @@ -1 +1 @@ -!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r(e.toxicDecorators=e.toxicDecorators||{})}(this,function(e){"use strict";function r(e){return e&&e.__esModule?e.default:e}function t(e,r){return r={exports:{}},e(r,r.exports),r.exports}function n(e){return void 0===e||null===e}function o(e){return Array.isArray(e)}function i(e){return"function"==typeof e}function u(e){return Object(e)===e&&"[object Object]"===String(e)&&!i(e)&&!o(e)}function a(e){return"number"==typeof e}function f(e){return"string"==typeof e||e instanceof String}function c(e){return"boolean"==typeof e}function l(e){return!!e&&("object"===(void 0===e?"undefined":Jr(e))||"function"==typeof e)&&"function"==typeof e.then}function s(e){return n(e)||c(e)||f(e)||a(e)}function p(e,r){return e.bind?e.bind(r):e.apply?function(){for(var t=arguments.length,n=Array(t),o=0;o1&&void 0!==arguments[1]?arguments[1]:"You must pass me an array of function";if(!o(e)||e.length<1)throw new TypeError(r);if(1===e.length){if(!i(e[0]))throw new TypeError(r);return e[0]}return e.reduce(function(e,t){if(!i(t)||!i(e))throw new TypeError(r);return function(r){return p(t,this)(p(e,this)(r))}})}function g(){var e=console,r=e.warn,t=e.log;if(i(r))return r.apply(void 0,arguments);t.apply(void 0,arguments)}function w(e,r){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=t.throwError,u=void 0!==i&&i,a=t.backup;if(f(r)&&(r=r.split(".")),!o(r))throw new TypeError("keys of getDeepProperty must be string or Array");for(var c=[],l=e,s=0,p=r.length;s0?"."+c.join("."):" itself")+" is "+l);return a}l=l[y],c.push(y)}return l}function m(){for(var e=arguments.length,r=Array(e),t=0;t0&&void 0!==arguments[0]?arguments[0]:{},r=e.get,t=e.set,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},u=n.preGet,a=void 0!==u&&u,f=n.preSet,c=void 0===f||f;if(!(i(r)||i(t)||o(r)&&r.length>0||o(t)&&t.length>0))throw new TypeError("@accessor need a getter or setter. If you don't need to add setter/getter. You should remove @accessor");var l="@accessor only accept function or array of function as getter/setter";return r=o(r)?b(r,l):r,t=o(t)?b(t,l):t,function(e,n,o){var u=o||{},f=u.configurable,l=void 0===f||f,s=u.enumerable,y=void 0===s||s,v=i(r),b=i(t),w=function(e){return v?p(r,this)(e):e},m=function(e){return b?p(t,this)(e):e};if(h(o)){var O=o.get,E=o.set,j=i(O),S=i(E);return!j&&v&&g("You are trying to set getter via @accessor on one property without getter. That's not a good idea."),!S&&b&&g("You are trying to set setter via @accessor on one property without setter. That's not a good idea."),{get:j||v?function(){var e=this,r=p(w,this),t=function(){return j?p(O,e)():void 0};return(a?[r,t]:[t,r]).reduce(function(e,r){return r(e)},void 0)}:void 0,set:S||b?function(e){var r=this,t=p(m,this),n=function(e){return S?p(E,r)(e):e};return(c?[t,n]:[n,t]).reduce(function(e,r){return r(e)},e)}:void 0,configurable:l,enumerable:y}}if(d(o)){var _=o.initializer,P=void 0,A=!1;return{get:function(){var e=p(w,this);return A?e(P):(P=p(_,this)(),A=!0,e(P))},set:function(e){var r=p(m,this);return P=c?r(e):e,A=!0,c||r(P),P},configurable:l,enumerable:y}}var T=(o||{}).value;return{get:function(){return p(w,this)(T)},set:function(e){var r=p(m,this);return T=c?r(e):e,c||r(T),T},configurable:l,enumerable:y}}}function E(){for(var e=arguments.length,r=Array(e),t=0;t2&&y(r[2]))throw new Error("You may use @initialize straightly, @initialize return decorators, you need to call it");var n=b(r,"@initialize only accept function parameter");return function(e,r,t){if(void 0===t)return{value:p(n,e)(),configurable:!0,writable:!0,enumerable:!0};if(h(t)){var o=!1;return O({get:function(e){return o?e:p(n,this)(e)},set:function(e){return o=!0,e}})(e,r,t)}if(d(t)){var i=t.initializer;return{initializer:function(){return p(n,this)(p(i,this)())},configurable:t.configurable,writable:t.writable,enumerable:t.enumerable}}return{value:p(n,this)(t.value),writable:t.writable,configurable:t.configurable,enumerable:t.enumerable}}}function j(e,r,t,n,o,i){var u=t.configurable,a=t.enumerable,f=i.force,c=i.omit,l=It(n,o);if(void 0!==l){if(c)return;if(!f)throw new Error("@alias can't set alias on an existing attribute");if(!l.configurable)throw new Error("You are tring to set alias on an existing attribute which its configurable is false. That's impossible. Please check if you have set @frozen on it.")}Ft(n,o,{get:function(){return e[r]},set:function(t){return e[r]=t,r},configurable:u,enumerable:a})}function S(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).exclude,r=void 0===e?[]:e;if(!o(r))throw new TypeError("options.exclude must be an array");return function(e){if(!i(e))throw new TypeError("@autobindClass can only be used on class");var t=e.prototype;if(n(t))throw new Error("The prototype of the class is empty, please check it");for(var o=At(t),u=Pt(t),a=0,f=u.length;a-1||zt(t,c,P(t,c,l))}}}function _(e,r){if("undefined"==typeof WeakMap)throw new Error("Using @autobind on "+r.name+"() requires WeakMap support due to its use of super."+r.name+"()");Nt||(Nt=new WeakMap),!1===Nt.has(e)&&Nt.set(e,new WeakMap);var t=Nt.get(e);return!1===t.has(r)&&t.set(r,p(r,e)),t.get(r)}function P(e,r,t){if(1===arguments.length)return S()(e);if(!y(t))throw new Error("@autobind must used on descriptor, are you using it on undefined property?");var n=t.value,o=t.configurable;if(!i(n))throw new TypeError("@autobind can only be used on functions, not: "+n+")");var u=e.constructor;return{configurable:o,enumerable:!1,get:function(){var t=this,o=function(){for(var e=arguments.length,r=Array(e),o=0;o0?T:A)(e)},x=function(e){if(void 0==e)throw TypeError("Can't call method on "+e);return e},M=t(function(e){var r=e.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=r)}),I=t(function(e){var r=e.exports={version:"2.4.0"};"number"==typeof __e&&(__e=r)}),F=function(e){if("function"!=typeof e)throw TypeError(e+" is not a function!");return e},z=function(e,r,t){if(F(e),void 0===r)return e;switch(t){case 1:return function(t){return e.call(r,t)};case 2:return function(t,n){return e.call(r,t,n)};case 3:return function(t,n,o){return e.call(r,t,n,o)}}return function(){return e.apply(r,arguments)}},N=function(e){return"object"==typeof e?null!==e:"function"==typeof e},D=function(e){if(!N(e))throw TypeError(e+" is not an object!");return e},Y=function(e){try{return!!e()}catch(e){return!0}},W=!Y(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a}),C=M.document,R=N(C)&&N(C.createElement),V=function(e){return R?C.createElement(e):{}},L=!W&&!Y(function(){return 7!=Object.defineProperty(V("div"),"a",{get:function(){return 7}}).a}),B=function(e,r){if(!N(e))return e;var t,n;if(r&&"function"==typeof(t=e.toString)&&!N(n=t.call(e)))return n;if("function"==typeof(t=e.valueOf)&&!N(n=t.call(e)))return n;if(!r&&"function"==typeof(t=e.toString)&&!N(n=t.call(e)))return n;throw TypeError("Can't convert object to primitive value")},G=Object.defineProperty,J={f:W?Object.defineProperty:function(e,r,t){if(D(e),r=B(r,!0),D(t),L)try{return G(e,r,t)}catch(e){}if("get"in t||"set"in t)throw TypeError("Accessors not supported!");return"value"in t&&(e[r]=t.value),e}},K=function(e,r){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:r}},U=W?function(e,r,t){return J.f(e,r,K(1,t))}:function(e,r,t){return e[r]=t,e},q=function(e,r,t){var n,o,i,u=e&q.F,a=e&q.G,f=e&q.S,c=e&q.P,l=e&q.B,s=e&q.W,p=a?I:I[r]||(I[r]={}),y=p.prototype,h=a?M:f?M[r]:(M[r]||{}).prototype;a&&(t=r);for(n in t)(o=!u&&h&&void 0!==h[n])&&n in p||(i=o?h[n]:t[n],p[n]=a&&"function"!=typeof h[n]?t[n]:l&&o?z(i,M):s&&h[n]==i?function(e){var r=function(r,t,n){if(this instanceof e){switch(arguments.length){case 0:return new e;case 1:return new e(r);case 2:return new e(r,t)}return new e(r,t,n)}return e.apply(this,arguments)};return r.prototype=e.prototype,r}(i):c&&"function"==typeof i?z(Function.call,i):i,c&&((p.virtual||(p.virtual={}))[n]=i,e&q.R&&y&&!y[n]&&U(y,n,i)))};q.F=1,q.G=2,q.S=4,q.P=8,q.B=16,q.W=32,q.U=64,q.R=128;var Q=q,$=U,H={}.hasOwnProperty,X=function(e,r){return H.call(e,r)},Z={},ee={}.toString,re=function(e){return ee.call(e).slice(8,-1)},te=Object("z").propertyIsEnumerable(0)?Object:function(e){return"String"==re(e)?e.split(""):Object(e)},ne=function(e){return te(x(e))},oe=Math.min,ie=function(e){return e>0?oe(k(e),9007199254740991):0},ue=Math.max,ae=Math.min,fe=function(e,r){return e=k(e),e<0?ue(e+r,0):ae(e,r)},ce=M["__core-js_shared__"]||(M["__core-js_shared__"]={}),le=function(e){return ce[e]||(ce[e]={})},se=0,pe=Math.random(),ye=function(e){return"Symbol(".concat(void 0===e?"":e,")_",(++se+pe).toString(36))},he=le("keys"),de=function(e){return he[e]||(he[e]=ye(e))},ve=function(e){return function(r,t,n){var o,i=ne(r),u=ie(i.length),a=fe(n,u);if(e&&t!=t){for(;u>a;)if((o=i[a++])!=o)return!0}else for(;u>a;a++)if((e||a in i)&&i[a]===t)return e||a||0;return!e&&-1}}(!1),be=de("IE_PROTO"),ge=function(e,r){var t,n=ne(e),o=0,i=[];for(t in n)t!=be&&X(n,t)&&i.push(t);for(;r.length>o;)X(n,t=r[o++])&&(~ve(i,t)||i.push(t));return i},we="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(","),me=Object.keys||function(e){return ge(e,we)},Oe=W?Object.defineProperties:function(e,r){D(e);for(var t,n=me(r),o=n.length,i=0;o>i;)J.f(e,t=n[i++],r[t]);return e},Ee=M.document&&document.documentElement,je=de("IE_PROTO"),Se=function(){},_e=function(){var e,r=V("iframe"),t=we.length;for(r.style.display="none",Ee.appendChild(r),r.src="javascript:",(e=r.contentWindow.document).open(),e.write("