You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
4 lines
56 KiB
4 lines
56 KiB
7 years ago
|
/** MobX - (c) Michel Weststrate 2015, 2016 - MIT Licensed */
|
||
|
"use strict";function e(e,t){function n(){this.constructor=e}Xt(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function t(e){return e.interceptors&&e.interceptors.length>0}function n(e,t){var n=e.interceptors||(e.interceptors=[]);return n.push(t),_e(function(){var e=n.indexOf(t);-1!==e&&n.splice(e,1)})}function r(e,t){var n=_t();try{var r=e.interceptors;if(r)for(var o=0,i=r.length;o<i&&(t=r[o](t),xe(!t||t.type,"Intercept handlers should return nothing or a change object"),t);o++);return t}finally{Ot(n)}}function o(e){return e.changeListeners&&e.changeListeners.length>0}function i(e,t){var n=e.changeListeners||(e.changeListeners=[]);return n.push(t),_e(function(){var e=n.indexOf(t);-1!==e&&n.splice(e,1)})}function a(e,t){var n=_t(),r=e.changeListeners;if(r){r=r.slice();for(var o=0,i=r.length;o<i;o++)r[o](t);Ot(n)}}function s(){return!!zn.spyListeners.length}function u(e){if(zn.spyListeners.length)for(var t=zn.spyListeners,n=0,r=t.length;n<r;n++)t[n](e)}function c(e){u(je({},e,{spyReportStart:!0}))}function l(e){u(e?je({},e,tn):tn)}function p(e){return zn.spyListeners.push(e),_e(function(){var t=zn.spyListeners.indexOf(e);-1!==t&&zn.spyListeners.splice(t,1)})}function f(){return"function"==typeof Symbol&&Symbol.iterator||"@@iterator"}function h(e){xe(!0!==e[nn],"Illegal state: cannot recycle array as iterator"),Ee(e,nn,!0);var t=-1;return Ee(e,"next",function(){return t++,{done:t>=this.length,value:t<this.length?this[t]:void 0}}),e}function d(e,t){Ee(e,f(),t)}function v(e,t){void 0!==Object.setPrototypeOf?Object.setPrototypeOf(e.prototype,t):void 0!==e.prototype.__proto__?e.prototype.__proto__=t:e.prototype=t}function b(e){return{enumerable:!1,configurable:!1,get:function(){return this.get(e)},set:function(t){this.set(e,t)}}}function m(e){Object.defineProperty(cn.prototype,""+e,b(e))}function y(e){for(var t=an;t<e;t++)m(t);an=e}function g(e){return Ae(e)&&pn(e.$mobx)}function x(e){return vn[e]}function w(e,t){xe("function"==typeof t,x("m026")),xe("string"==typeof e&&e.length>0,"actions should have valid names, got: '"+e+"'");var n=function(){return _(e,t,this,arguments)};return n.originalFn=t,n.isMobxAction=!0,n}function _(e,t,n,r){var o=O(e,t,n,r);try{return t.apply(n,r)}finally{S(o)}}function O(e,t,n,r){var o=s()&&!!e,i=0;if(o){i=Date.now();var a=r&&r.length||0,u=new Array(a);if(a>0)for(var l=0;l<a;l++)u[l]=r[l];c({type:"action",name:e,fn:t,object:n,arguments:u})}var p=_t();return at(),{prevDerivation:p,prevAllowStateChanges:D(!0),notifySpy:o,startTime:i}}function S(e){T(e.prevAllowStateChanges),st(),Ot(e.prevDerivation),e.notifySpy&&l({time:Date.now()-e.startTime})}function A(e){xe(null===zn.trackingDerivation,x("m028")),zn.strictMode=e,zn.allowStateChanges=!e}function I(){return zn.strictMode}function j(e,t){var n,r=D(e);try{n=t()}finally{T(r)}return n}function D(e){var t=zn.allowStateChanges;return zn.allowStateChanges=e,t}function T(e){zn.allowStateChanges=e}function k(e,t,n,r,o){function i(i,a,s,u,c){if(void 0===c&&(c=0),xe(o||V(arguments),"This function is a decorator, but it wasn't invoked like a decorator"),s){De(i,"__mobxLazyInitializers")||ke(i,"__mobxLazyInitializers",i.__mobxLazyInitializers&&i.__mobxLazyInitializers.slice()||[]);var l=s.value,p=s.initializer;return i.__mobxLazyInitializers.push(function(t){e(t,a,p?p.call(t):l,u,s)}),{enumerable:r,configurable:!0,get:function(){return!0!==this.__mobxDidRunLazyInitializers&&R(this),t.call(this,a)},set:function(e){!0!==this.__mobxDidRunLazyInitializers&&R(this),n.call(this,a,e)}}}var f={enumerable:r,configurable:!0,get:function(){return this.__mobxInitializedProps&&!0===this.__mobxInitializedProps[a]||E(this,a,void 0,e,u,s),t.call(this,a)},set:function(t){this.__mobxInitializedProps&&!0===this.__mobxInitializedProps[a]?n.call(this,a,t):E(this,a,t,e,u,s)}};return(arguments.length<3||5===arguments.length&&c<3)&&Object.defineProperty(i,a,f),f}return o?function(){if(V(arguments))return i.apply(null,arguments);var e=arguments,t=arguments.length;return function(n,r,o){return i(n,r,o,e,t)}}:i}function E(e,t,n,r,o,i){De(e,"__mobxInitialized
|
||
|
;var n=this.$mobx;return n.spliceWithArray(0,0,e),n.values.length},o.prototype.reverse=function(){var e=this.slice();return e.reverse.apply(e,arguments)},o.prototype.sort=function(e){var t=this.slice();return t.sort.apply(t,arguments)},o.prototype.remove=function(e){var t=this.$mobx.dehanceValues(this.$mobx.values).indexOf(e);return t>-1&&(this.splice(t,1),!0)},o.prototype.move=function(e,t){function n(e){if(e<0)throw new Error("[mobx.array] Index out of bounds: "+e+" is negative");var t=this.$mobx.values.length;if(e>=t)throw new Error("[mobx.array] Index out of bounds: "+e+" is not smaller than "+t)}if(n.call(this,e),n.call(this,t),e!==t){var r,o=this.$mobx.values;r=e<t?o.slice(0,e).concat(o.slice(e+1,t+1),[o[e]],o.slice(t+1)):o.slice(0,t).concat([o[e]],o.slice(t,e),o.slice(e+1)),this.replace(r)}},o.prototype.get=function(e){var t=this.$mobx;if(t){if(e<t.values.length)return t.atom.reportObserved(),t.dehanceValue(t.values[e]);console.warn("[mobx.array] Attempt to read an array index ("+e+") that is out of bounds ("+t.values.length+"). Please check length first. Out of bound indices will not be tracked by MobX")}},o.prototype.set=function(e,n){var o=this.$mobx,i=o.values;if(e<i.length){mt(o.atom);var a=i[e];if(t(o)){var s=r(o,{type:"update",object:this,index:e,newValue:n});if(!s)return;n=s.newValue}n=o.enhancer(n,a);n!==a&&(i[e]=n,o.notifyArrayChildUpdate(e,n,a))}else{if(e!==i.length)throw new Error("[mobx.array] Index out of bounds, "+e+" is larger than "+i.length);o.spliceWithArray(e,0,[n])}},o}(sn);d(cn.prototype,function(){return h(this.slice())}),Object.defineProperty(cn.prototype,"length",{enumerable:!1,configurable:!0,get:function(){return this.$mobx.getArrayLength()},set:function(e){this.$mobx.setArrayLength(e)}}),["every","filter","forEach","indexOf","join","lastIndexOf","map","reduce","reduceRight","slice","some","toString","toLocaleString"].forEach(function(e){var t=Array.prototype[e];xe("function"==typeof t,"Base function not defined on Array prototype: '"+e+"'"),ke(cn.prototype,e,function(){return t.apply(this.peek(),arguments)})}),Te(cn.prototype,["constructor","intercept","observe","clear","concat","get","replace","toJS","toJSON","peek","find","findIndex","splice","spliceWithArray","push","pop","set","shift","unshift","reverse","sort","remove","move","toString","toLocaleString"]);var ln=b(0);y(1e3);var pn=Ce("ObservableArrayAdministration",un),fn={},hn=function(p){function f(e,t,n,r){void 0===n&&(n="ObservableValue@"+ye()),void 0===r&&(r=!0);var o=p.call(this,n)||this;return o.enhancer=t,o.hasUnreportedChange=!1,o.dehancer=void 0,o.value=t(e,void 0,n),r&&s()&&u({type:"create",object:o,newValue:o.value}),o}return e(f,p),f.prototype.dehanceValue=function(e){return void 0!==this.dehancer?this.dehancer(e):e},f.prototype.set=function(e){var t=this.value;if((e=this.prepareNewValue(e))!==fn){var n=s();n&&c({type:"update",object:this,newValue:e,oldValue:t}),this.setNewValue(e),n&&l()}},f.prototype.prepareNewValue=function(e){if(mt(this),t(this)){var n=r(this,{object:this,type:"update",newValue:e});if(!n)return fn;e=n.newValue}return e=this.enhancer(e,this.value,this.name),this.value!==e?e:fn},f.prototype.setNewValue=function(e){var t=this.value;this.value=e,this.reportChanged(),o(this)&&a(this,{type:"update",object:this,newValue:e,oldValue:t})},f.prototype.get=function(){return this.reportObserved(),this.dehanceValue(this.value)},f.prototype.intercept=function(e){return n(this,e)},f.prototype.observe=function(e,t){return t&&e({object:this,type:"update",newValue:this.value,oldValue:void 0}),i(this,e)},f.prototype.toJSON=function(){return this.get()},f.prototype.toString=function(){return this.name+"["+this.value+"]"},f.prototype.valueOf=function(){return Ge(this.get())},f}(Qt);hn.prototype[ze()]=hn.prototype.valueOf;var dn=Ce("ObservableValue",hn),vn={m001:"It is not allowed to assign new values to @action fields",m002:"`runInAction` expects a function",m003:"`runInAction` expects a function without arguments",m004:"autorun expects a function",m005:"Warning: attempted to pass an action to autorun. Actions are untr
|
||
|
//# sourceMappingURL=lib/mobx.min.js.map
|