Socket
Socket
Sign inDemoInstall

mobservable

Package Overview
Dependencies
Maintainers
1
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mobservable - npm Package Compare versions

Comparing version 0.7.0 to 0.7.1

dist/typings/core.d.ts

4

CHANGELOG.md

@@ -0,1 +1,5 @@

# 0.7.1
* Backported Babel support for the @observable decorator from the 1.0 branch. The decorator should now behave the same when compiled with either Typescript or Babeljs.
# 0.7.0

@@ -2,0 +6,0 @@

2

dist/mobservable.min.js

@@ -1,1 +0,1 @@

var mobservable;!function(a){var b;!function(a){function b(a){var b=!1;return function(){return b?void 0:(b=!0,a.apply(this,arguments))}}function c(){}function d(a){var b=[];return a.forEach(function(a){-1===b.indexOf(a)&&b.push(a)}),b}function e(a){return null!==a&&"object"==typeof a&&Object.getPrototypeOf(a)===Object.prototype}function f(b,c){if(null===b&&null===c)return!0;if(void 0===b&&void 0===c)return!0;var d=Array.isArray(b)||b instanceof a.ObservableArray;if(d!==(Array.isArray(c)||c instanceof a.ObservableArray))return!1;if(d){if(b.length!==c.length)return!1;for(var e=b.length;e>=0;e--)if(!f(b[e],c[e]))return!1;return!0}if("object"==typeof b&&"object"==typeof c){if(null===b||null===c)return!1;if(Object.keys(b).length!==Object.keys(c).length)return!1;for(var g in b){if(!c.hasOwnProperty(g))return!1;if(!f(b[g],c[g]))return!1}return!0}return b===c}function g(a,b){if(!b||!b.length)return[a,[]];if(!a||!a.length)return[[],b];for(var c=[],d=[],e=0,f=0,g=a.length,h=!1,i=0,j=0,k=b.length,l=!1,m=!1;!m&&!h;){if(!l){if(g>e&&k>i&&a[e]===b[i]){if(e++,i++,e===g&&i===k)return[c,d];continue}f=e,j=i,l=!0}j+=1,f+=1,j>=k&&(m=!0),f>=g&&(h=!0),h||a[f]!==b[i]?m||b[j]!==a[e]||(d.push.apply(d,b.slice(i,j)),i=j+1,e++,l=!1):(c.push.apply(c,a.slice(e,f)),e=f+1,i++,l=!1)}return c.push.apply(c,a.slice(e)),d.push.apply(d,b.slice(i)),[c,d]}a.once=b,a.noop=c,a.unique=d,a.isPlainObject=e,a.deepEquals=f,a.quickDiff=g}(b=a._||(a._={}))}(mobservable||(mobservable={}));var mobservable;!function(a){var b;!function(a){var b=function(){function a(){}return a.schedule=function(b){a.inBatch<1?b():a.tasks[a.tasks.length]=b},a.runPostBatchActions=function(){for(var b=0;a.tasks.length;)try{for(;b<a.tasks.length;b++)a.tasks[b]();a.tasks=[]}catch(c){console.error("Failed to run scheduled action, the action has been dropped from the queue: "+c,c),a.tasks.splice(0,b+1)}},a.batch=function(b){a.inBatch+=1;try{return b()}finally{0===--a.inBatch&&(a.inBatch+=1,a.runPostBatchActions(),a.inBatch-=1)}},a.inBatch=0,a.tasks=[],a}();a.Scheduler=b}(b=a._||(a._={}))}(mobservable||(mobservable={}));var mobservable;!function(a){var b;!function(a){var b=function(){function b(){this.listeners=[]}return b.prototype.emit=function(){var a=this.listeners.slice(),b=a.length;switch(arguments.length){case 0:for(var c=0;b>c;c++)a[c]();break;case 1:for(var d=arguments[0],c=0;b>c;c++)a[c](d);break;default:for(var c=0;b>c;c++)a[c].apply(null,arguments)}},b.prototype.on=function(b){var c=this;return this.listeners.push(b),a.once(function(){var a=c.listeners.indexOf(b);-1!==a&&c.listeners.splice(a,1)})},b.prototype.once=function(a){var b=this.on(function(){b(),a.apply(this,arguments)});return b},b}();a.SimpleEventEmitter=b}(b=a._||(a._={}))}(mobservable||(mobservable={}));var __extends=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)},mobservable;!function(a){var b=function(){return this}();if(b.__mobservableTrackingStack)throw new Error("[mobservable] An incompatible version of mobservable is already loaded.");b.__mobservableViewStack=[];var c;!function(b){function c(b){if(e()&&a.strict===!0){var c=__mobservableViewStack;throw new Error("[mobservable] It is not allowed to change the state during the computation of a reactive view if 'mobservable.strict' mode is enabled:\n Should the data you are trying to modify actually be a view?\n View name: "+b.name+".\n Current stack size is "+c.length+', active view: "'+c[c.length-1].toString()+'".')}}function d(){return __mobservableViewStack.length}function e(){return __mobservableViewStack.length>0}var f=0;b.checkIfStateIsBeingModifiedDuringView=c,function(a){a[a.STALE=0]="STALE",a[a.PENDING=1]="PENDING",a[a.READY=2]="READY"}(b.NodeState||(b.NodeState={}));var g=b.NodeState,h=function(){function a(a){this.context=a,this.id=++f,this.state=g.READY,this.observers=[],this.isDisposed=!1,this.externalRefenceCount=0,a.name||(a.name="[m#"+this.id+"]")}return a.prototype.setRefCount=function(a){this.externalRefenceCount+=a},a.prototype.addObserver=function(a){this.observers[this.observers.length]=a},a.prototype.removeObserver=function(a){var b=this.observers,c=b.indexOf(a);-1!==c&&b.splice(c,1)},a.prototype.markStale=function(){this.state===g.READY&&(this.state=g.STALE,b.transitionTracker&&b.reportTransition(this,"STALE"),this.notifyObservers())},a.prototype.markReady=function(a){this.state!==g.READY&&(this.state=g.READY,b.transitionTracker&&b.reportTransition(this,"READY",!0,this._value),this.notifyObservers(a))},a.prototype.notifyObservers=function(a){void 0===a&&(a=!1);for(var b=this.observers.slice(),c=b.length,d=0;c>d;d++)b[d].notifyStateChange(this,a)},a.prototype.notifyObserved=function(){var a=__mobservableViewStack,b=a.length;if(b>0){var c=a[b-1].observing,d=c.length;c[d-1]!==this&&c[d-2]!==this&&(c[d]=this)}},a.prototype.dispose=function(){if(this.observers.length)throw new Error("[mobservable] Cannot dispose DNode; it is still being observed");this.isDisposed=!0},a.prototype.toString=function(){return"DNode["+this.context.name+", state: "+this.state+", observers: "+this.observers.length+"]"},a}();b.DataNode=h;var i=function(c){function d(){c.apply(this,arguments),this.isSleeping=!0,this.hasCycle=!1,this.observing=[],this.prevObserving=null,this.dependencyChangeCount=0,this.dependencyStaleCount=0}return __extends(d,c),d.prototype.setRefCount=function(a){var b=this.externalRefenceCount+=a;0===b?this.tryToSleep():b===a&&this.wakeUp()},d.prototype.removeObserver=function(a){c.prototype.removeObserver.call(this,a),this.tryToSleep()},d.prototype.tryToSleep=function(){if(!this.isSleeping&&0===this.observers.length&&0===this.externalRefenceCount){for(var a=0,b=this.observing.length;b>a;a++)this.observing[a].removeObserver(this);this.observing=[],this.isSleeping=!0}},d.prototype.wakeUp=function(){this.isSleeping&&(this.isSleeping=!1,this.state=g.PENDING,this.computeNextState())},d.prototype.notifyStateChange=function(a,c){var d=this;a.state===g.STALE?1===++this.dependencyStaleCount&&this.markStale():(c&&(this.dependencyChangeCount+=1),0===--this.dependencyStaleCount&&(this.state=g.PENDING,b.Scheduler.schedule(function(){d.dependencyChangeCount>0?d.computeNextState():d.markReady(!1),d.dependencyChangeCount=0})))},d.prototype.computeNextState=function(){this.trackDependencies(),b.transitionTracker&&b.reportTransition(this,"PENDING");var a=this.compute();this.bindDependencies(),this.markReady(a)},d.prototype.compute=function(){throw"Abstract!"},d.prototype.trackDependencies=function(){this.prevObserving=this.observing,this.observing=[],__mobservableViewStack[__mobservableViewStack.length]=this},d.prototype.bindDependencies=function(){__mobservableViewStack.length-=1,0===this.observing.length&&a.logLevel>1&&!this.isDisposed&&console.error("[mobservable] You have created a view function that doesn't observe any values, did you forget to make its dependencies observable?");var c=b.quickDiff(this.observing,this.prevObserving),e=c[0],f=c[1];this.prevObserving=null,this.hasCycle=!1;for(var g=0,h=e.length;h>g;g++){var i=e[g];i instanceof d&&i.findCycle(this)?(this.hasCycle=!0,this.observing.splice(this.observing.indexOf(e[g]),1),i.hasCycle=!0):e[g].addObserver(this)}for(var g=0,h=f.length;h>g;g++)f[g].removeObserver(this)},d.prototype.findCycle=function(a){var b=this.observing;if(-1!==b.indexOf(a))return!0;for(var c=b.length,e=0;c>e;e++)if(b[e]instanceof d&&b[e].findCycle(a))return!0;return!1},d.prototype.dispose=function(){if(this.observing)for(var a=this.observing.length,b=0;a>b;b++)this.observing[b].removeObserver(this);this.observing=null,c.prototype.dispose.call(this)},d}(h);b.ViewNode=i,b.stackDepth=d,b.isComputingView=e}(c=a._||(a._={}))}(mobservable||(mobservable={}));var mobservable;!function(a){var b;!function(a){var b=function(b){function c(c,d,e){b.call(this,e),this.value=c,this.mode=d,this.changeEvent=new a.SimpleEventEmitter;var f=a.getValueModeFromValue(c,a.ValueMode.Recursive),g=f[0],h=f[1];this.mode===a.ValueMode.Recursive&&(this.mode=g),this._value=this.makeReferenceValueReactive(h)}return __extends(c,b),c.prototype.makeReferenceValueReactive=function(b){return a.makeChildReactive(b,this.mode,this.context)},c.prototype.set=function(b){a.assertUnwrapped(b,"Modifiers cannot be used on non-initial values."),a.checkIfStateIsBeingModifiedDuringView(this.context);var c=this.mode===a.ValueMode.Structure?!a.deepEquals(b,this._value):b!==this._value;if(c){var d=this._value;this.markStale(),this._value=this.makeReferenceValueReactive(b),this.markReady(!0),this.changeEvent.emit(this._value,d)}},c.prototype.get=function(){return this.notifyObserved(),this._value},c.prototype.observe=function(a,b){return void 0===b&&(b=!1),b&&a(this.get(),void 0),this.changeEvent.on(a)},c.prototype.asPropertyDescriptor=function(){var a=this;return{configurable:!1,enumerable:!0,get:function(){return a.get()},set:function(b){return a.set(b)}}},c.prototype.toString=function(){return"Observable["+this.context.name+":"+this._value+"]"},c}(a.DataNode);a.ObservableValue=b}(b=a._||(a._={}))}(mobservable||(mobservable={}));var mobservable;!function(a){var b;!function(a){function b(b){var c={enumerable:!1,configurable:!1,set:function(c){if(a.assertUnwrapped(c,"Modifiers cannot be used on array values. For non-reactive array values use makeReactive(asFlat(array))."),b<this.$mobservable.values.length){var d=this.$mobservable.values[b],e=this.$mobservable.mode===a.ValueMode.Structure?!a.deepEquals(d,c):d!==c;e&&(this.$mobservable.values[b]=this.makeReactiveArrayItem(c),this.notifyChildUpdate(b,d))}else{if(b!==this.$mobservable.values.length)throw new Error("[mobservable.array] Index out of bounds, "+b+" is larger than "+this.values.length);this.push(this.makeReactiveArrayItem(c))}},get:function(){return b<this.$mobservable.values.length?(this.$mobservable.notifyObserved(),this.$mobservable.values[b]):void 0}};Object.defineProperty(f.prototype,""+b,c),c.enumerable=!0,c.configurable=!0,h[b]=c}function c(a){for(var c=g;a>c;c++)b(c);g=a}var d=function(){function a(){}return a}();d.prototype=[];var e=function(b){function c(c,d,e){b.call(this,e),this.array=c,this.mode=d,this.values=[],this.changeEvent=new a.SimpleEventEmitter,e.object||(e.object=c)}return __extends(c,b),c}(a.DataNode);a.ObservableArrayAdministration=e;var f=function(b){function d(a,c,d){b.call(this),Object.defineProperty(this,"$mobservable",{enumerable:!1,configurable:!1,value:new e(this,c,d)}),a&&a.length&&this.replace(a)}return __extends(d,b),Object.defineProperty(d.prototype,"length",{get:function(){return this.$mobservable.notifyObserved(),this.$mobservable.values.length},set:function(a){if("number"!=typeof a||0>a)throw new Error("[mobservable.array] Out of range: "+a);var b=this.$mobservable.values.length;a!==b&&(a>b?this.spliceWithArray(b,0,new Array(a-b)):this.spliceWithArray(a,b-a))},enumerable:!0,configurable:!0}),d.prototype.updateLength=function(a,b){if(0>b)for(var d=a+b;a>d;d++)delete this[d];else if(b>0){a+b>g&&c(a+b);for(var d=a,e=a+b;e>d;d++)Object.defineProperty(this,""+d,h[d])}},d.prototype.spliceWithArray=function(a,b,c){var d=this,e=this.$mobservable.values.length;if(!(void 0!==c&&0!==c.length||0!==b&&0!==e))return[];void 0===a?a=0:a>e?a=e:0>a&&(a=Math.max(0,e+a)),b=1===arguments.length?e-a:void 0===b||null===b?0:Math.max(0,Math.min(b,e-a)),c=void 0===c?[]:c.map(function(a){return d.makeReactiveArrayItem(a)});var f=c.length-b,g=(h=this.$mobservable.values).splice.apply(h,[a,b].concat(c));return this.updateLength(e,f),this.notifySplice(a,g,c),g;var h},d.prototype.makeReactiveArrayItem=function(b){return a.assertUnwrapped(b,"Array values cannot have modifiers"),a.makeChildReactive(b,this.$mobservable.mode,{object:this.$mobservable.context.object,name:this.$mobservable.context.name+"[x]"})},d.prototype.notifyChildUpdate=function(a,b){this.notifyChanged(),this.$mobservable.changeEvent.emit({object:this,type:"update",index:a,oldValue:b})},d.prototype.notifySplice=function(a,b,c){(0!==b.length||0!==c.length)&&(this.notifyChanged(),this.$mobservable.changeEvent.emit({object:this,type:"splice",index:a,addedCount:c.length,removed:b}))},d.prototype.notifyChanged=function(){a.checkIfStateIsBeingModifiedDuringView(this.$mobservable.context),this.$mobservable.markStale(),this.$mobservable.markReady(!0)},d.prototype.observe=function(a,b){return void 0===b&&(b=!1),b&&a({object:this,type:"splice",index:0,addedCount:this.$mobservable.values.length,removed:[]}),this.$mobservable.changeEvent.on(a)},d.prototype.clear=function(){return this.splice(0)},d.prototype.replace=function(a){return this.spliceWithArray(0,this.$mobservable.values.length,a)},d.prototype.values=function(){return console.warn("mobservable.array.values is deprecated and will be removed in 0.7, use slice() instead"),this.$mobservable.notifyObserved(),this.$mobservable.values.slice()},d.prototype.toJSON=function(){return this.$mobservable.notifyObserved(),this.$mobservable.values.slice()},d.prototype.clone=function(){return console.warn("mobservable.array.clone is deprecated and will be removed in 0.7"),this.$mobservable.notifyObserved(),new d(this.$mobservable.values,this.$mobservable.mode,{object:null,name:this.$mobservable.context.name+"[clone]"})},d.prototype.find=function(a,b,c){void 0===c&&(c=0),this.$mobservable.notifyObserved();for(var d=this.$mobservable.values,e=d.length,f=c;e>f;f++)if(a.call(b,d[f],f,this))return d[f];return null},d.prototype.splice=function(a,b){for(var c=[],d=2;d<arguments.length;d++)c[d-2]=arguments[d];switch(arguments.length){case 0:return[];case 1:return this.spliceWithArray(a);case 2:return this.spliceWithArray(a,b)}return this.spliceWithArray(a,b,c)},d.prototype.push=function(){for(var a=[],b=0;b<arguments.length;b++)a[b-0]=arguments[b];return this.spliceWithArray(this.$mobservable.values.length,0,a),this.$mobservable.values.length},d.prototype.pop=function(){return this.splice(Math.max(this.$mobservable.values.length-1,0),1)[0]},d.prototype.shift=function(){return this.splice(0,1)[0]},d.prototype.unshift=function(){for(var a=[],b=0;b<arguments.length;b++)a[b-0]=arguments[b];return this.spliceWithArray(0,0,a),this.$mobservable.values.length},d.prototype.reverse=function(){return this.replace(this.$mobservable.values.reverse())},d.prototype.sort=function(a){return this.replace(this.$mobservable.values.sort.apply(this.$mobservable.values,arguments))},d.prototype.remove=function(a){var b=this.$mobservable.values.indexOf(a);return b>-1?(this.splice(b,1),!0):!1},d.prototype.toString=function(){return"[mobservable.array] "+Array.prototype.toString.apply(this.$mobservable.values,arguments)},d.prototype.toLocaleString=function(){return"[mobservable.array] "+Array.prototype.toLocaleString.apply(this.$mobservable.values,arguments)},d.prototype.concat=function(){throw"Illegal state"},d.prototype.join=function(a){throw"Illegal state"},d.prototype.slice=function(a,b){throw"Illegal state"},d.prototype.indexOf=function(a,b){throw"Illegal state"},d.prototype.lastIndexOf=function(a,b){throw"Illegal state"},d.prototype.every=function(a,b){throw"Illegal state"},d.prototype.some=function(a,b){throw"Illegal state"},d.prototype.forEach=function(a,b){throw"Illegal state"},d.prototype.map=function(a,b){throw"Illegal state"},d.prototype.filter=function(a,b){throw"Illegal state"},d.prototype.reduce=function(a,b){throw"Illegal state"},d.prototype.reduceRight=function(a,b){throw"Illegal state"},d}(d);a.ObservableArray=f,["concat","join","slice","indexOf","lastIndexOf","every","some","forEach","map","filter","reduce","reduceRight"].forEach(function(a){var b=Array.prototype[a];f.prototype[a]=function(){return this.$mobservable.notifyObserved(),b.apply(this.$mobservable.values,arguments)}});var g=0,h=[];c(1e3)}(b=a._||(a._={}))}(mobservable||(mobservable={}));var mobservable;!function(a){var b;!function(a){var b=function(){function b(a,b,c){if(this.target=a,this.context=b,this.mode=c,this.values={},a.$mobservable)throw new Error("Illegal state: already an reactive object");b?b.object||(b.object=a):this.context={object:a,name:""},Object.defineProperty(a,"$mobservable",{enumerable:!1,configurable:!1,value:this})}return b.asReactive=function(a,c,d){return a.$mobservable?a.$mobservable:new b(a,c,d)},b.prototype.set=function(a,b){this.values[a]?this.target[a]=b:this.defineReactiveProperty(a,b)},b.prototype.defineReactiveProperty=function(b,c){var d,e={object:this.context.object,name:(this.context.name||"")+"."+b};d="function"==typeof c&&0===c.length?new a.ObservableView(c,this.target,e,!1):c instanceof a.AsStructure&&"function"==typeof c.value&&0===c.value.length?new a.ObservableView(c.value,this.target,e,!0):new a.ObservableValue(c,this.mode,e),this.values[b]=d,Object.defineProperty(this.target,b,d.asPropertyDescriptor())},b}();a.ObservableObject=b}(b=a._||(a._={}))}(mobservable||(mobservable={}));var mobservable;!function(a){var b;!function(b){function c(){throw new Error("[mobservable.view '"+this.context.name+"'] View functions do not accept new values")}b.throwingViewSetter=c;var d=function(d){function e(a,c,e,f){d.call(this,e),this.func=a,this.scope=c,this.compareStructural=f,this.isComputing=!1,this.hasError=!1,this.changeEvent=new b.SimpleEventEmitter}return __extends(e,d),e.prototype.get=function(){if(this.isComputing)throw new Error("[mobservable.view '"+this.context.name+"'] Cycle detected");if(this.isSleeping?b.isComputingView()?(this.wakeUp(),this.notifyObserved()):(this.wakeUp(),this.tryToSleep()):this.notifyObserved(),this.hasCycle)throw new Error("[mobservable.view '"+this.context.name+"'] Cycle detected");if(this.hasError)throw a.logLevel>0&&console.error("[mobservable.view '"+this.context.name+"'] Rethrowing caught exception to observer: "+this._value+(this._value.cause||"")),this._value;return this._value},e.prototype.set=function(){c.call(this)},e.prototype.compute=function(){var a;try{if(this.isComputing)throw new Error("[mobservable.view '"+this.context.name+"'] Cycle detected");this.isComputing=!0,a=this.func.call(this.scope),this.hasError=!1}catch(c){this.hasError=!0,console.error("[mobservable.view '"+this.context.name+"'] Caught error during computation: ",c,"View function:",this.func.toString()),console.trace(),c instanceof Error?a=c:(a=new Error("[mobservable.view '"+this.context.name+"'] Error during computation (see error.cause) in "+this.func.toString()),a.cause=c)}this.isComputing=!1;var d=this.compareStructural?!b.deepEquals(a,this._value):a!==this._value;if(d){var e=this._value;return this._value=a,this.changeEvent.emit(a,e),!0}return!1},e.prototype.observe=function(a,c){var d=this;void 0===c&&(c=!1),this.setRefCount(1),c&&a(this.get(),void 0);var e=this.changeEvent.on(a);return b.once(function(){d.setRefCount(-1),e()})},e.prototype.asPropertyDescriptor=function(){var a=this;return{configurable:!1,enumerable:!1,get:function(){return a.get()},set:c}},e.prototype.toString=function(){return"ComputedObservable["+this.context.name+":"+this._value+"] "+this.func.toString()},e}(b.ViewNode);b.ObservableView=d}(b=a._||(a._={}))}(mobservable||(mobservable={}));var mobservable;!function(a){function b(b){console.warn("The use of mobservable.reactiveComponent and mobservable.reactiveMixin is deprecated, please use reactiveComponent from the mobservable-react package");var c=b.prototype||b,d=c.componentWillMount,e=c.componentWillUnmount;return c.componentWillMount=function(){a.reactiveMixin.componentWillMount.apply(this,arguments),d&&d.apply(this,arguments)},c.componentWillUnmount=function(){a.reactiveMixin.componentWillUnmount.apply(this,arguments),e&&e.apply(this,arguments)},c.shouldComponentUpdate||(c.shouldComponentUpdate=a.reactiveMixin.shouldComponentUpdate),b}var c=1;a.reactiveMixin={componentWillMount:function(){var b=(this.displayName||this.constructor.name||"ReactiveComponent")+c++,d=this.render;this.render=function(){var c=this;this._watchDisposer&&this._watchDisposer();var e=a.observeUntilInvalid(function(){return d.call(c)},function(){c.forceUpdate()},{object:this,name:b}),f=e[0],g=e[1],h=e[2];return this.$mobservable=h,this._watchDisposer=g,f}},componentWillUnmount:function(){this._watchDisposer&&this._watchDisposer(),delete this._mobservableDNode},shouldComponentUpdate:function(a,b){if(this.state!==b)return!0;var c,d=Object.keys(this.props);if(d.length!==Object.keys(a).length)return!0;for(var e=d.length-1;c=d[e];e--)if(a[c]!==this.props[c])return!0;return!1}},a.reactiveComponent=b}(mobservable||(mobservable={}));var mobservable;!function(a){var b;!function(b){function c(c,d){if(!a.isReactive(c))throw new Error("[mobservable.getDNode] "+c+" doesn't seem to be reactive");if(void 0!==d){var e=c.$mobservable,f=e.values&&e.values[d];if(!f)throw new Error("[mobservable.getDNode] property '"+d+"' of '"+c+"' doesn't seem to be a reactive property");return f}if(c.$mobservable){if(c.$mobservable instanceof b.ObservableObject)throw new Error("[mobservable.getDNode] missing properties parameter. Please specify a property of '"+c+"'.");return c.$mobservable}throw new Error("[mobservable.getDNode] "+c+" doesn't seem to be reactive")}function d(a,c,d,e){void 0===d&&(d=!1),void 0===e&&(e=null),b.transitionTracker.emit({id:a.id,name:a.context.name,context:a.context.object,state:c,changed:d,newValue:e})}b.getDNode=c,b.reportTransition=d,b.transitionTracker=null}(b=a._||(a._={}));var c;!function(a){function c(a,c){return d(b.getDNode(a,c))}function d(a){var c={id:a.id,name:a.context.name,context:a.context.object||null};return a instanceof b.ViewNode&&a.observing.length&&(c.dependencies=b.unique(a.observing).map(d)),c}function e(a,c){return f(b.getDNode(a,c))}function f(a){var c={id:a.id,name:a.context.name,context:a.context.object||null};return a.observers.length&&(c.observers=b.unique(a.observers).map(f)),a.externalRefenceCount>0&&(c.listeners=a.externalRefenceCount),c}function g(a){var b=[],c=!1;return function(d){(a||d.changed)&&b.push(d),c||(c=!0,setTimeout(function(){console[console.table?"table":"dir"](b),b=[],c=!1},1))}}function h(a,c){void 0===a&&(a=!1),b.transitionTracker||(b.transitionTracker=new b.SimpleEventEmitter);var d=c?function(b){(a||b.changed)&&c(b)}:g(a),e=b.transitionTracker.on(d);return b.once(function(){e(),0===b.transitionTracker.listeners.length&&(b.transitionTracker=null)})}a.getDependencyTree=c,a.getObserverTree=e,a.trackTransitions=h}(c=a.extras||(a.extras={}))}(mobservable||(mobservable={}));var mobservable;!function(a){function b(a,b,c){if(f(a))return a;var d=s.isPlainObject(b)?b:{},e=s.getValueModeFromValue(a,s.ValueMode.Recursive),g=e[0],h=e[1];d.recurse===!1?(console.warn("[mobservable.makeReactive] option 'recurse: false' is deprecated, use 'mobservable.asFlat' instead"),g=s.ValueMode.Flat):"reference"===d.as&&(console.warn("[mobservable.makeReactive] option 'as: \"reference\"' is deprecated, use 'mobservable.asReference' instead"),g=s.ValueMode.Reference);var i=g===s.ValueMode.Reference?s.ValueType.Reference:s.getTypeOfValue(h),j=(d.scope||(b&&"object"==typeof b?b:null),{name:c||d.name,object:d.context||d.scope});switch(i){case s.ValueType.Reference:case s.ValueType.ComplexObject:return s.toGetterSetterFunction(new s.ObservableValue(h,g,j));case s.ValueType.ComplexFunction:throw new Error("[mobservable.makeReactive] Creating reactive functions from functions with multiple arguments is currently not supported, see https://github.com/mweststrate/mobservable/issues/12");case s.ValueType.ViewFunction:return j.name||(j.name=h.name),s.toGetterSetterFunction(new s.ObservableView(h,d.scope||d.context,j,g===s.ValueMode.Structure));case s.ValueType.Array:case s.ValueType.PlainObject:return s.makeChildReactive(h,g,j)}throw"Illegal State"}function c(a){return new s.AsReference(a)}function d(a){return new s.AsStructure(a)}function e(a){return new s.AsFlat(a)}function f(a){return null===a||void 0===a?!1:!!a.$mobservable}function g(a,b){return console.warn("[mobservable.sideEffect] 'sideEffect' has been renamed to 'observe' and will be removed in a later version."),h(a,b)}function h(b,c){var d=s.getValueModeFromValue(b,s.ValueMode.Recursive),e=d[0],f=d[1],g=new s.ObservableView(f,c,{object:c,name:b.name},e===s.ValueMode.Structure);g.setRefCount(1);var h=s.once(function(){g.setRefCount(-1)});return a.logLevel>=2&&0===g.observing.length&&console.warn("[mobservable.observe] not a single observable was used inside the observing function. This observer is now a no-op."),h.$mobservable=g,h}function i(a,b,c){var d=h(function(){a.call(c)&&(d(),b.call(c))});return d}function j(a,b,c,d){void 0===c&&(c=1);var e,f=void 0,g=h(function(){f=a.call(d),e||(e=setTimeout(function(){b.call(d,f),e=null},c))});return s.once(function(){g(),e&&clearTimeout(e)})}function k(a,b,c){return console.error("[mobservable.when] deprecated, please use 'mobservable.observeUntil'"),i(a,b,c)}function l(a,c){if(!s.isComputingView())throw new Error("[mobservable.expr] 'expr' can only be used inside a computed value.");return b(a,{scope:c})()}function m(a,b,c){return s.extendReactive(a,b,s.ValueMode.Recursive,c)}function n(a,b,c){var d=c&&!c.hasOwnProperty("value"),e=c||{},f=d?e.get:e.value;if(!d&&"function"==typeof f)throw new Error("@observable functions are deprecated. Use @observable on a getter function if you want to create a view, or wrap the value in 'asReference' if you want to store a value (found on member '"+b+"').");if(d){if("function"!=typeof f)throw new Error("@observable expects a getter function if used on a property (found on member '"+b+"').");if(e.set)throw new Error("@observable properties cannot have a setter (found on member '"+b+"').");if(0!==f.length)throw new Error("@observable getter functions should not take arguments (found on member '"+b+"').")}e.configurable=!0,e.enumerable=!0,delete e.value,delete e.writable,e.get=function(){return s.ObservableObject.asReactive(this,null,s.ValueMode.Recursive).set(b,f),this[b]},e.set=d?s.throwingViewSetter:function(a){s.ObservableObject.asReactive(this,null,s.ValueMode.Recursive).set(b,a)},d||Object.defineProperty(a,b,e)}function o(a){if(!a)return a;if(Array.isArray(a)||a instanceof s.ObservableArray)return a.map(o);if("object"==typeof a&&s.isPlainObject(a)){var b={};for(var c in a)a.hasOwnProperty(c)&&(b[c]=o(a[c]));return b}return a}function p(a){return console.warn("mobservable.toJson is deprecated, use mobservable.toJSON instead"),o(a)}function q(a){return s.Scheduler.batch(a)}function r(a,b,c){console.warn("mobservable.observeUntilInvalid is deprecated and will be removed in 0.7");var d,e=!1,f=h(function(){e?b():(e=!0,d=a())});return[d,f,f.$mobservable]}a.makeReactive=b,a.asReference=c,a.asStructure=d,a.asFlat=e,a.isReactive=f,a.sideEffect=g,a.observe=h,a.observeUntil=i,a.observeAsync=j,a.when=k,a.expr=l,a.extendReactive=m,a.observable=n,a.toJSON=o,a.toJson=p,a.transaction=q,a.observeUntilInvalid=r,a.logLevel=1,a.strict=!0,setTimeout(function(){a.logLevel>0&&console.info("Welcome to mobservable. Current logLevel = "+a.logLevel+". Change mobservable.logLevel according to your needs: 0 = production, 1 = development, 2 = debugging. Strict mode is "+(a.strict?"enabled":"disabled")+".")},1);var s;!function(a){function b(b){return null===b||void 0===b?i.Reference:"function"==typeof b?b.length?i.ComplexFunction:i.ViewFunction:Array.isArray(b)||b instanceof a.ObservableArray?i.Array:"object"==typeof b?a.isPlainObject(b)?i.PlainObject:i.ComplexObject:i.Reference}function c(b,c,d,e){var f=a.ObservableObject.asReactive(b,e,d);for(var g in c)c.hasOwnProperty(g)&&f.set(g,c[g]);return b}function d(a){var b=function(b){return arguments.length>0?void a.set(b):a.get()};return b.$mobservable=a,b.observe=function(b,c){return a.observe(b,c)},b.toString=function(){return a.toString()},b}function e(a,b){return a instanceof k?[j.Reference,a.value]:a instanceof l?[j.Structure,a.value]:a instanceof m?[j.Flat,a.value]:[b,a]}function g(b,c,d){var g;if(f(b))return b;switch(c){case j.Reference:return b;case j.Flat:h(b,"Items inside 'asFlat' canont have modifiers"),g=j.Reference;break;case j.Structure:h(b,"Items inside 'asStructure' canont have modifiers"),g=j.Structure;break;case j.Recursive:i=e(b,j.Recursive),g=i[0],b=i[1];break;default:throw"Illegal State"}return Array.isArray(b)?new a.ObservableArray(b.slice(),g,d):a.isPlainObject(b)?a.extendReactive(b,b,g,d):b;var i}function h(a,b){if(a instanceof k||a instanceof l||a instanceof m)throw new Error("[mobservable] asStructure / asReference / asFlat cannot be used here. "+b)}!function(a){a[a.Reference=0]="Reference",a[a.PlainObject=1]="PlainObject",a[a.ComplexObject=2]="ComplexObject",a[a.Array=3]="Array",a[a.ViewFunction=4]="ViewFunction",a[a.ComplexFunction=5]="ComplexFunction"}(a.ValueType||(a.ValueType={}));var i=a.ValueType;!function(a){a[a.Recursive=0]="Recursive",a[a.Reference=1]="Reference",a[a.Structure=2]="Structure",a[a.Flat=3]="Flat"}(a.ValueMode||(a.ValueMode={}));var j=a.ValueMode;a.getTypeOfValue=b,a.extendReactive=c,a.toGetterSetterFunction=d;var k=function(){function a(a){this.value=a,h(a,"Modifiers are not allowed to be nested")}return a}();a.AsReference=k;var l=function(){function a(a){this.value=a,h(a,"Modifiers are not allowed to be nested")}return a}();a.AsStructure=l;var m=function(){function a(a){this.value=a,h(a,"Modifiers are not allowed to be nested")}return a}();a.AsFlat=m,a.getValueModeFromValue=e,a.makeChildReactive=g,a.assertUnwrapped=h}(s=a._||(a._={}))}(mobservable||(mobservable={}));var forCompilerVerificationOnly=mobservable;!function(a,b){"function"==typeof define&&define.amd?define("mobservable",[],function(){return b()}):"object"==typeof exports?module.exports=b():a.mobservable=b()}(this,function(){var a=mobservable.makeReactive;a["default"]=mobservable.makeReactive;for(var b in mobservable)mobservable.hasOwnProperty(b)&&(a[b]=mobservable[b]);return Object.defineProperties(a,{logLevel:{get:function(){return mobservable.logLevel},set:function(a){return mobservable.logLevel=a},enumerable:!0},strict:{get:function(){return mobservable.strict},set:function(a){return mobservable.strict=a},enumerable:!0}}),a});
var mobservable;!function(a){var b;!function(a){function b(a){var b=!1;return function(){return b?void 0:(b=!0,a.apply(this,arguments))}}function c(){}function d(a){var b=[];return a.forEach(function(a){-1===b.indexOf(a)&&b.push(a)}),b}function e(a){return null!==a&&"object"==typeof a&&Object.getPrototypeOf(a)===Object.prototype}function f(b,c){if(null===b&&null===c)return!0;if(void 0===b&&void 0===c)return!0;var d=Array.isArray(b)||b instanceof a.ObservableArray;if(d!==(Array.isArray(c)||c instanceof a.ObservableArray))return!1;if(d){if(b.length!==c.length)return!1;for(var e=b.length;e>=0;e--)if(!f(b[e],c[e]))return!1;return!0}if("object"==typeof b&&"object"==typeof c){if(null===b||null===c)return!1;if(Object.keys(b).length!==Object.keys(c).length)return!1;for(var g in b){if(!c.hasOwnProperty(g))return!1;if(!f(b[g],c[g]))return!1}return!0}return b===c}function g(a,b){if(!b||!b.length)return[a,[]];if(!a||!a.length)return[[],b];for(var c=[],d=[],e=0,f=0,g=a.length,h=!1,i=0,j=0,k=b.length,l=!1,m=!1;!m&&!h;){if(!l){if(g>e&&k>i&&a[e]===b[i]){if(e++,i++,e===g&&i===k)return[c,d];continue}f=e,j=i,l=!0}j+=1,f+=1,j>=k&&(m=!0),f>=g&&(h=!0),h||a[f]!==b[i]?m||b[j]!==a[e]||(d.push.apply(d,b.slice(i,j)),i=j+1,e++,l=!1):(c.push.apply(c,a.slice(e,f)),e=f+1,i++,l=!1)}return c.push.apply(c,a.slice(e)),d.push.apply(d,b.slice(i)),[c,d]}a.once=b,a.noop=c,a.unique=d,a.isPlainObject=e,a.deepEquals=f,a.quickDiff=g}(b=a._||(a._={}))}(mobservable||(mobservable={}));var mobservable;!function(a){var b;!function(a){var b=function(){function a(){}return a.schedule=function(b){a.inBatch<1?b():a.tasks[a.tasks.length]=b},a.runPostBatchActions=function(){for(var b=0;a.tasks.length;)try{for(;b<a.tasks.length;b++)a.tasks[b]();a.tasks=[]}catch(c){console.error("Failed to run scheduled action, the action has been dropped from the queue: "+c,c),a.tasks.splice(0,b+1)}},a.batch=function(b){a.inBatch+=1;try{return b()}finally{0===--a.inBatch&&(a.inBatch+=1,a.runPostBatchActions(),a.inBatch-=1)}},a.inBatch=0,a.tasks=[],a}();a.Scheduler=b}(b=a._||(a._={}))}(mobservable||(mobservable={}));var mobservable;!function(a){var b;!function(a){var b=function(){function b(){this.listeners=[]}return b.prototype.emit=function(){var a=this.listeners.slice(),b=a.length;switch(arguments.length){case 0:for(var c=0;b>c;c++)a[c]();break;case 1:for(var d=arguments[0],c=0;b>c;c++)a[c](d);break;default:for(var c=0;b>c;c++)a[c].apply(null,arguments)}},b.prototype.on=function(b){var c=this;return this.listeners.push(b),a.once(function(){var a=c.listeners.indexOf(b);-1!==a&&c.listeners.splice(a,1)})},b.prototype.once=function(a){var b=this.on(function(){b(),a.apply(this,arguments)});return b},b}();a.SimpleEventEmitter=b}(b=a._||(a._={}))}(mobservable||(mobservable={}));var __extends=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)},mobservable;!function(a){var b=function(){return this}();if(b.__mobservableTrackingStack)throw new Error("[mobservable] An incompatible version of mobservable is already loaded.");b.__mobservableViewStack=[];var c;!function(b){function c(b){if(e()&&a.strict===!0){var c=__mobservableViewStack;throw new Error("[mobservable] It is not allowed to change the state during the computation of a reactive view if 'mobservable.strict' mode is enabled:\n Should the data you are trying to modify actually be a view?\n View name: "+b.name+".\n Current stack size is "+c.length+', active view: "'+c[c.length-1].toString()+'".')}}function d(){return __mobservableViewStack.length}function e(){return __mobservableViewStack.length>0}var f=0;b.checkIfStateIsBeingModifiedDuringView=c,function(a){a[a.STALE=0]="STALE",a[a.PENDING=1]="PENDING",a[a.READY=2]="READY"}(b.NodeState||(b.NodeState={}));var g=b.NodeState,h=function(){function a(a){this.context=a,this.id=++f,this.state=g.READY,this.observers=[],this.isDisposed=!1,this.externalRefenceCount=0,a.name||(a.name="[m#"+this.id+"]")}return a.prototype.setRefCount=function(a){this.externalRefenceCount+=a},a.prototype.addObserver=function(a){this.observers[this.observers.length]=a},a.prototype.removeObserver=function(a){var b=this.observers,c=b.indexOf(a);-1!==c&&b.splice(c,1)},a.prototype.markStale=function(){this.state===g.READY&&(this.state=g.STALE,b.transitionTracker&&b.reportTransition(this,"STALE"),this.notifyObservers())},a.prototype.markReady=function(a){this.state!==g.READY&&(this.state=g.READY,b.transitionTracker&&b.reportTransition(this,"READY",!0,this._value),this.notifyObservers(a))},a.prototype.notifyObservers=function(a){void 0===a&&(a=!1);for(var b=this.observers.slice(),c=b.length,d=0;c>d;d++)b[d].notifyStateChange(this,a)},a.prototype.notifyObserved=function(){var a=__mobservableViewStack,b=a.length;if(b>0){var c=a[b-1].observing,d=c.length;c[d-1]!==this&&c[d-2]!==this&&(c[d]=this)}},a.prototype.dispose=function(){if(this.observers.length)throw new Error("[mobservable] Cannot dispose DNode; it is still being observed");this.isDisposed=!0},a.prototype.toString=function(){return"DNode["+this.context.name+", state: "+this.state+", observers: "+this.observers.length+"]"},a}();b.DataNode=h;var i=function(c){function d(){c.apply(this,arguments),this.isSleeping=!0,this.hasCycle=!1,this.observing=[],this.prevObserving=null,this.dependencyChangeCount=0,this.dependencyStaleCount=0}return __extends(d,c),d.prototype.setRefCount=function(a){var b=this.externalRefenceCount+=a;0===b?this.tryToSleep():b===a&&this.wakeUp()},d.prototype.removeObserver=function(a){c.prototype.removeObserver.call(this,a),this.tryToSleep()},d.prototype.tryToSleep=function(){if(!this.isSleeping&&0===this.observers.length&&0===this.externalRefenceCount){for(var a=0,b=this.observing.length;b>a;a++)this.observing[a].removeObserver(this);this.observing=[],this.isSleeping=!0}},d.prototype.wakeUp=function(){this.isSleeping&&(this.isSleeping=!1,this.state=g.PENDING,this.computeNextState())},d.prototype.notifyStateChange=function(a,c){var d=this;a.state===g.STALE?1===++this.dependencyStaleCount&&this.markStale():(c&&(this.dependencyChangeCount+=1),0===--this.dependencyStaleCount&&(this.state=g.PENDING,b.Scheduler.schedule(function(){d.dependencyChangeCount>0?d.computeNextState():d.markReady(!1),d.dependencyChangeCount=0})))},d.prototype.computeNextState=function(){this.trackDependencies(),b.transitionTracker&&b.reportTransition(this,"PENDING");var a=this.compute();this.bindDependencies(),this.markReady(a)},d.prototype.compute=function(){throw"Abstract!"},d.prototype.trackDependencies=function(){this.prevObserving=this.observing,this.observing=[],__mobservableViewStack[__mobservableViewStack.length]=this},d.prototype.bindDependencies=function(){__mobservableViewStack.length-=1,0===this.observing.length&&a.logLevel>1&&!this.isDisposed&&console.error("[mobservable] You have created a view function that doesn't observe any values, did you forget to make its dependencies observable?");var c=b.quickDiff(this.observing,this.prevObserving),e=c[0],f=c[1];this.prevObserving=null,this.hasCycle=!1;for(var g=0,h=e.length;h>g;g++){var i=e[g];i instanceof d&&i.findCycle(this)?(this.hasCycle=!0,this.observing.splice(this.observing.indexOf(e[g]),1),i.hasCycle=!0):e[g].addObserver(this)}for(var g=0,h=f.length;h>g;g++)f[g].removeObserver(this)},d.prototype.findCycle=function(a){var b=this.observing;if(-1!==b.indexOf(a))return!0;for(var c=b.length,e=0;c>e;e++)if(b[e]instanceof d&&b[e].findCycle(a))return!0;return!1},d.prototype.dispose=function(){if(this.observing)for(var a=this.observing.length,b=0;a>b;b++)this.observing[b].removeObserver(this);this.observing=null,c.prototype.dispose.call(this)},d}(h);b.ViewNode=i,b.stackDepth=d,b.isComputingView=e}(c=a._||(a._={}))}(mobservable||(mobservable={}));var mobservable;!function(a){var b;!function(a){var b=function(b){function c(c,d,e){b.call(this,e),this.value=c,this.mode=d,this.changeEvent=new a.SimpleEventEmitter;var f=a.getValueModeFromValue(c,a.ValueMode.Recursive),g=f[0],h=f[1];this.mode===a.ValueMode.Recursive&&(this.mode=g),this._value=this.makeReferenceValueReactive(h)}return __extends(c,b),c.prototype.makeReferenceValueReactive=function(b){return a.makeChildReactive(b,this.mode,this.context)},c.prototype.set=function(b){a.assertUnwrapped(b,"Modifiers cannot be used on non-initial values."),a.checkIfStateIsBeingModifiedDuringView(this.context);var c=this.mode===a.ValueMode.Structure?!a.deepEquals(b,this._value):b!==this._value;if(c){var d=this._value;this.markStale(),this._value=this.makeReferenceValueReactive(b),this.markReady(!0),this.changeEvent.emit(this._value,d)}},c.prototype.get=function(){return this.notifyObserved(),this._value},c.prototype.observe=function(a,b){return void 0===b&&(b=!1),b&&a(this.get(),void 0),this.changeEvent.on(a)},c.prototype.asPropertyDescriptor=function(){var a=this;return{configurable:!1,enumerable:!0,get:function(){return a.get()},set:function(b){return a.set(b)}}},c.prototype.toString=function(){return"Observable["+this.context.name+":"+this._value+"]"},c}(a.DataNode);a.ObservableValue=b}(b=a._||(a._={}))}(mobservable||(mobservable={}));var mobservable;!function(a){var b;!function(a){function b(b){var c={enumerable:!1,configurable:!1,set:function(c){if(a.assertUnwrapped(c,"Modifiers cannot be used on array values. For non-reactive array values use makeReactive(asFlat(array))."),b<this.$mobservable.values.length){var d=this.$mobservable.values[b],e=this.$mobservable.mode===a.ValueMode.Structure?!a.deepEquals(d,c):d!==c;e&&(this.$mobservable.values[b]=this.makeReactiveArrayItem(c),this.notifyChildUpdate(b,d))}else{if(b!==this.$mobservable.values.length)throw new Error("[mobservable.array] Index out of bounds, "+b+" is larger than "+this.values.length);this.push(this.makeReactiveArrayItem(c))}},get:function(){return b<this.$mobservable.values.length?(this.$mobservable.notifyObserved(),this.$mobservable.values[b]):void 0}};Object.defineProperty(f.prototype,""+b,c),c.enumerable=!0,c.configurable=!0,h[b]=c}function c(a){for(var c=g;a>c;c++)b(c);g=a}var d=function(){function a(){}return a}();d.prototype=[];var e=function(b){function c(c,d,e){b.call(this,e),this.array=c,this.mode=d,this.values=[],this.changeEvent=new a.SimpleEventEmitter,e.object||(e.object=c)}return __extends(c,b),c}(a.DataNode);a.ObservableArrayAdministration=e;var f=function(b){function d(a,c,d){b.call(this),Object.defineProperty(this,"$mobservable",{enumerable:!1,configurable:!1,value:new e(this,c,d)}),a&&a.length&&this.replace(a)}return __extends(d,b),Object.defineProperty(d.prototype,"length",{get:function(){return this.$mobservable.notifyObserved(),this.$mobservable.values.length},set:function(a){if("number"!=typeof a||0>a)throw new Error("[mobservable.array] Out of range: "+a);var b=this.$mobservable.values.length;a!==b&&(a>b?this.spliceWithArray(b,0,new Array(a-b)):this.spliceWithArray(a,b-a))},enumerable:!0,configurable:!0}),d.prototype.updateLength=function(a,b){if(0>b)for(var d=a+b;a>d;d++)delete this[d];else if(b>0){a+b>g&&c(a+b);for(var d=a,e=a+b;e>d;d++)Object.defineProperty(this,""+d,h[d])}},d.prototype.spliceWithArray=function(a,b,c){var d=this,e=this.$mobservable.values.length;if(!(void 0!==c&&0!==c.length||0!==b&&0!==e))return[];void 0===a?a=0:a>e?a=e:0>a&&(a=Math.max(0,e+a)),b=1===arguments.length?e-a:void 0===b||null===b?0:Math.max(0,Math.min(b,e-a)),c=void 0===c?[]:c.map(function(a){return d.makeReactiveArrayItem(a)});var f=c.length-b,g=(h=this.$mobservable.values).splice.apply(h,[a,b].concat(c));return this.updateLength(e,f),this.notifySplice(a,g,c),g;var h},d.prototype.makeReactiveArrayItem=function(b){return a.assertUnwrapped(b,"Array values cannot have modifiers"),a.makeChildReactive(b,this.$mobservable.mode,{object:this.$mobservable.context.object,name:this.$mobservable.context.name+"[x]"})},d.prototype.notifyChildUpdate=function(a,b){this.notifyChanged(),this.$mobservable.changeEvent.emit({object:this,type:"update",index:a,oldValue:b})},d.prototype.notifySplice=function(a,b,c){(0!==b.length||0!==c.length)&&(this.notifyChanged(),this.$mobservable.changeEvent.emit({object:this,type:"splice",index:a,addedCount:c.length,removed:b}))},d.prototype.notifyChanged=function(){a.checkIfStateIsBeingModifiedDuringView(this.$mobservable.context),this.$mobservable.markStale(),this.$mobservable.markReady(!0)},d.prototype.observe=function(a,b){return void 0===b&&(b=!1),b&&a({object:this,type:"splice",index:0,addedCount:this.$mobservable.values.length,removed:[]}),this.$mobservable.changeEvent.on(a)},d.prototype.clear=function(){return this.splice(0)},d.prototype.replace=function(a){return this.spliceWithArray(0,this.$mobservable.values.length,a)},d.prototype.values=function(){return console.warn("mobservable.array.values is deprecated and will be removed in 0.7, use slice() instead"),this.$mobservable.notifyObserved(),this.$mobservable.values.slice()},d.prototype.toJSON=function(){return this.$mobservable.notifyObserved(),this.$mobservable.values.slice()},d.prototype.clone=function(){return console.warn("mobservable.array.clone is deprecated and will be removed in 0.7"),this.$mobservable.notifyObserved(),new d(this.$mobservable.values,this.$mobservable.mode,{object:null,name:this.$mobservable.context.name+"[clone]"})},d.prototype.find=function(a,b,c){void 0===c&&(c=0),this.$mobservable.notifyObserved();for(var d=this.$mobservable.values,e=d.length,f=c;e>f;f++)if(a.call(b,d[f],f,this))return d[f];return null},d.prototype.splice=function(a,b){for(var c=[],d=2;d<arguments.length;d++)c[d-2]=arguments[d];switch(arguments.length){case 0:return[];case 1:return this.spliceWithArray(a);case 2:return this.spliceWithArray(a,b)}return this.spliceWithArray(a,b,c)},d.prototype.push=function(){for(var a=[],b=0;b<arguments.length;b++)a[b-0]=arguments[b];return this.spliceWithArray(this.$mobservable.values.length,0,a),this.$mobservable.values.length},d.prototype.pop=function(){return this.splice(Math.max(this.$mobservable.values.length-1,0),1)[0]},d.prototype.shift=function(){return this.splice(0,1)[0]},d.prototype.unshift=function(){for(var a=[],b=0;b<arguments.length;b++)a[b-0]=arguments[b];return this.spliceWithArray(0,0,a),this.$mobservable.values.length},d.prototype.reverse=function(){return this.replace(this.$mobservable.values.reverse())},d.prototype.sort=function(a){return this.replace(this.$mobservable.values.sort.apply(this.$mobservable.values,arguments))},d.prototype.remove=function(a){var b=this.$mobservable.values.indexOf(a);return b>-1?(this.splice(b,1),!0):!1},d.prototype.toString=function(){return"[mobservable.array] "+Array.prototype.toString.apply(this.$mobservable.values,arguments)},d.prototype.toLocaleString=function(){return"[mobservable.array] "+Array.prototype.toLocaleString.apply(this.$mobservable.values,arguments)},d.prototype.concat=function(){throw"Illegal state"},d.prototype.join=function(a){throw"Illegal state"},d.prototype.slice=function(a,b){throw"Illegal state"},d.prototype.indexOf=function(a,b){throw"Illegal state"},d.prototype.lastIndexOf=function(a,b){throw"Illegal state"},d.prototype.every=function(a,b){throw"Illegal state"},d.prototype.some=function(a,b){throw"Illegal state"},d.prototype.forEach=function(a,b){throw"Illegal state"},d.prototype.map=function(a,b){throw"Illegal state"},d.prototype.filter=function(a,b){throw"Illegal state"},d.prototype.reduce=function(a,b){throw"Illegal state"},d.prototype.reduceRight=function(a,b){throw"Illegal state"},d}(d);a.ObservableArray=f,["concat","join","slice","indexOf","lastIndexOf","every","some","forEach","map","filter","reduce","reduceRight"].forEach(function(a){var b=Array.prototype[a];f.prototype[a]=function(){return this.$mobservable.notifyObserved(),b.apply(this.$mobservable.values,arguments)}});var g=0,h=[];c(1e3)}(b=a._||(a._={}))}(mobservable||(mobservable={}));var mobservable;!function(a){var b;!function(a){var b=function(){function b(a,b,c){if(this.target=a,this.context=b,this.mode=c,this.values={},a.$mobservable)throw new Error("Illegal state: already an reactive object");b?b.object||(b.object=a):this.context={object:a,name:""},Object.defineProperty(a,"$mobservable",{enumerable:!1,configurable:!1,value:this})}return b.asReactive=function(a,c,d){return a.$mobservable?a.$mobservable:new b(a,c,d)},b.prototype.set=function(a,b){this.values[a]?this.target[a]=b:this.defineReactiveProperty(a,b)},b.prototype.defineReactiveProperty=function(b,c){var d,e={object:this.context.object,name:(this.context.name||"")+"."+b};d="function"==typeof c&&0===c.length?new a.ObservableView(c,this.target,e,!1):c instanceof a.AsStructure&&"function"==typeof c.value&&0===c.value.length?new a.ObservableView(c.value,this.target,e,!0):new a.ObservableValue(c,this.mode,e),this.values[b]=d,Object.defineProperty(this.target,b,d.asPropertyDescriptor())},b}();a.ObservableObject=b}(b=a._||(a._={}))}(mobservable||(mobservable={}));var mobservable;!function(a){var b;!function(b){function c(){throw new Error("[mobservable.view '"+this.context.name+"'] View functions do not accept new values")}b.throwingViewSetter=c;var d=function(d){function e(a,c,e,f){d.call(this,e),this.func=a,this.scope=c,this.compareStructural=f,this.isComputing=!1,this.hasError=!1,this.changeEvent=new b.SimpleEventEmitter}return __extends(e,d),e.prototype.get=function(){if(this.isComputing)throw new Error("[mobservable.view '"+this.context.name+"'] Cycle detected");if(this.isSleeping?b.isComputingView()?(this.wakeUp(),this.notifyObserved()):(this.wakeUp(),this.tryToSleep()):this.notifyObserved(),this.hasCycle)throw new Error("[mobservable.view '"+this.context.name+"'] Cycle detected");if(this.hasError)throw a.logLevel>0&&console.error("[mobservable.view '"+this.context.name+"'] Rethrowing caught exception to observer: "+this._value+(this._value.cause||"")),this._value;return this._value},e.prototype.set=function(){c.call(this)},e.prototype.compute=function(){var a;try{if(this.isComputing)throw new Error("[mobservable.view '"+this.context.name+"'] Cycle detected");this.isComputing=!0,a=this.func.call(this.scope),this.hasError=!1}catch(c){this.hasError=!0,console.error("[mobservable.view '"+this.context.name+"'] Caught error during computation: ",c,"View function:",this.func.toString()),console.trace(),c instanceof Error?a=c:(a=new Error("[mobservable.view '"+this.context.name+"'] Error during computation (see error.cause) in "+this.func.toString()),a.cause=c)}this.isComputing=!1;var d=this.compareStructural?!b.deepEquals(a,this._value):a!==this._value;if(d){var e=this._value;return this._value=a,this.changeEvent.emit(a,e),!0}return!1},e.prototype.observe=function(a,c){var d=this;void 0===c&&(c=!1),this.setRefCount(1),c&&a(this.get(),void 0);var e=this.changeEvent.on(a);return b.once(function(){d.setRefCount(-1),e()})},e.prototype.asPropertyDescriptor=function(){var a=this;return{configurable:!1,enumerable:!1,get:function(){return a.get()},set:c}},e.prototype.toString=function(){return"ComputedObservable["+this.context.name+":"+this._value+"] "+this.func.toString()},e}(b.ViewNode);b.ObservableView=d}(b=a._||(a._={}))}(mobservable||(mobservable={}));var mobservable;!function(a){function b(b){console.warn("The use of mobservable.reactiveComponent and mobservable.reactiveMixin is deprecated, please use reactiveComponent from the mobservable-react package");var c=b.prototype||b,d=c.componentWillMount,e=c.componentWillUnmount;return c.componentWillMount=function(){a.reactiveMixin.componentWillMount.apply(this,arguments),d&&d.apply(this,arguments)},c.componentWillUnmount=function(){a.reactiveMixin.componentWillUnmount.apply(this,arguments),e&&e.apply(this,arguments)},c.shouldComponentUpdate||(c.shouldComponentUpdate=a.reactiveMixin.shouldComponentUpdate),b}var c=1;a.reactiveMixin={componentWillMount:function(){var b=(this.displayName||this.constructor.name||"ReactiveComponent")+c++,d=this.render;this.render=function(){var c=this;this._watchDisposer&&this._watchDisposer();var e=a.observeUntilInvalid(function(){return d.call(c)},function(){c.forceUpdate()},{object:this,name:b}),f=e[0],g=e[1],h=e[2];return this.$mobservable=h,this._watchDisposer=g,f}},componentWillUnmount:function(){this._watchDisposer&&this._watchDisposer(),delete this._mobservableDNode},shouldComponentUpdate:function(a,b){if(this.state!==b)return!0;var c,d=Object.keys(this.props);if(d.length!==Object.keys(a).length)return!0;for(var e=d.length-1;c=d[e];e--)if(a[c]!==this.props[c])return!0;return!1}},a.reactiveComponent=b}(mobservable||(mobservable={}));var mobservable;!function(a){var b;!function(b){function c(c,d){if(!a.isReactive(c))throw new Error("[mobservable.getDNode] "+c+" doesn't seem to be reactive");if(void 0!==d){var e=c.$mobservable,f=e.values&&e.values[d];if(!f)throw new Error("[mobservable.getDNode] property '"+d+"' of '"+c+"' doesn't seem to be a reactive property");return f}if(c.$mobservable){if(c.$mobservable instanceof b.ObservableObject)throw new Error("[mobservable.getDNode] missing properties parameter. Please specify a property of '"+c+"'.");return c.$mobservable}throw new Error("[mobservable.getDNode] "+c+" doesn't seem to be reactive")}function d(a,c,d,e){void 0===d&&(d=!1),void 0===e&&(e=null),b.transitionTracker.emit({id:a.id,name:a.context.name,context:a.context.object,state:c,changed:d,newValue:e})}b.getDNode=c,b.reportTransition=d,b.transitionTracker=null}(b=a._||(a._={}));var c;!function(a){function c(a,c){return d(b.getDNode(a,c))}function d(a){var c={id:a.id,name:a.context.name,context:a.context.object||null};return a instanceof b.ViewNode&&a.observing.length&&(c.dependencies=b.unique(a.observing).map(d)),c}function e(a,c){return f(b.getDNode(a,c))}function f(a){var c={id:a.id,name:a.context.name,context:a.context.object||null};return a.observers.length&&(c.observers=b.unique(a.observers).map(f)),a.externalRefenceCount>0&&(c.listeners=a.externalRefenceCount),c}function g(a){var b=[],c=!1;return function(d){(a||d.changed)&&b.push(d),c||(c=!0,setTimeout(function(){console[console.table?"table":"dir"](b),b=[],c=!1},1))}}function h(a,c){void 0===a&&(a=!1),b.transitionTracker||(b.transitionTracker=new b.SimpleEventEmitter);var d=c?function(b){(a||b.changed)&&c(b)}:g(a),e=b.transitionTracker.on(d);return b.once(function(){e(),0===b.transitionTracker.listeners.length&&(b.transitionTracker=null)})}a.getDependencyTree=c,a.getObserverTree=e,a.trackTransitions=h}(c=a.extras||(a.extras={}))}(mobservable||(mobservable={}));var mobservable;!function(a){function b(a,b,c){if(f(a))return a;var d=s.isPlainObject(b)?b:{},e=s.getValueModeFromValue(a,s.ValueMode.Recursive),g=e[0],h=e[1];d.recurse===!1?(console.warn("[mobservable.makeReactive] option 'recurse: false' is deprecated, use 'mobservable.asFlat' instead"),g=s.ValueMode.Flat):"reference"===d.as&&(console.warn("[mobservable.makeReactive] option 'as: \"reference\"' is deprecated, use 'mobservable.asReference' instead"),g=s.ValueMode.Reference);var i=g===s.ValueMode.Reference?s.ValueType.Reference:s.getTypeOfValue(h),j=(d.scope||(b&&"object"==typeof b?b:null),{name:c||d.name,object:d.context||d.scope});switch(i){case s.ValueType.Reference:case s.ValueType.ComplexObject:return s.toGetterSetterFunction(new s.ObservableValue(h,g,j));case s.ValueType.ComplexFunction:throw new Error("[mobservable.makeReactive] Creating reactive functions from functions with multiple arguments is currently not supported, see https://github.com/mweststrate/mobservable/issues/12");case s.ValueType.ViewFunction:return j.name||(j.name=h.name),s.toGetterSetterFunction(new s.ObservableView(h,d.scope||d.context,j,g===s.ValueMode.Structure));case s.ValueType.Array:case s.ValueType.PlainObject:return s.makeChildReactive(h,g,j)}throw"Illegal State"}function c(a){return new s.AsReference(a)}function d(a){return new s.AsStructure(a)}function e(a){return new s.AsFlat(a)}function f(a){return null===a||void 0===a?!1:!!a.$mobservable}function g(a,b){return console.warn("[mobservable.sideEffect] 'sideEffect' has been renamed to 'observe' and will be removed in a later version."),h(a,b)}function h(b,c){var d=s.getValueModeFromValue(b,s.ValueMode.Recursive),e=d[0],f=d[1],g=new s.ObservableView(f,c,{object:c,name:b.name},e===s.ValueMode.Structure);g.setRefCount(1);var h=s.once(function(){g.setRefCount(-1)});return a.logLevel>=2&&0===g.observing.length&&console.warn("[mobservable.observe] not a single observable was used inside the observing function. This observer is now a no-op."),h.$mobservable=g,h}function i(a,b,c){var d=h(function(){a.call(c)&&(d(),b.call(c))});return d}function j(a,b,c,d){void 0===c&&(c=1);var e,f=void 0,g=h(function(){f=a.call(d),e||(e=setTimeout(function(){b.call(d,f),e=null},c))});return s.once(function(){g(),e&&clearTimeout(e)})}function k(a,b,c){return console.error("[mobservable.when] deprecated, please use 'mobservable.observeUntil'"),i(a,b,c)}function l(a,c){if(!s.isComputingView())throw new Error("[mobservable.expr] 'expr' can only be used inside a computed value.");return b(a,{scope:c})()}function m(a,b,c){return s.extendReactive(a,b,s.ValueMode.Recursive,c)}function n(b,d,e){var f=e&&e.hasOwnProperty("get"),g={},h=void 0;if(e&&(e.hasOwnProperty("get")?h=e.get:e.hasOwnProperty("value")?h=e.value:e.initializer&&(h=e.initializer(),"function"==typeof h&&(h=c(h)))),!b||"object"!=typeof b)throw new Error("The @observable decorator can only be used on objects");if(f){if("function"!=typeof h)throw new Error("@observable expects a getter function if used on a property (in member: '"+d+"').");if(g.set)throw new Error("@observable properties cannot have a setter (in member: '"+d+"').");if(0!==h.length)throw new Error("@observable getter functions should not take arguments (in member: '"+d+"').")}return g.configurable=!0,g.enumerable=!0,g.get=function(){var b=a.strict;return a.strict=!1,s.ObservableObject.asReactive(this,null,s.ValueMode.Recursive).set(d,h),a.strict=b,this[d]},g.set=f?s.throwingViewSetter:function(a){s.ObservableObject.asReactive(this,null,s.ValueMode.Recursive).set(d,"function"==typeof a?c(a):a)},e?g:void Object.defineProperty(b,d,g)}function o(a){if(!a)return a;if(Array.isArray(a)||a instanceof s.ObservableArray)return a.map(o);if("object"==typeof a&&s.isPlainObject(a)){var b={};for(var c in a)a.hasOwnProperty(c)&&(b[c]=o(a[c]));return b}return a}function p(a){return console.warn("mobservable.toJson is deprecated, use mobservable.toJSON instead"),o(a)}function q(a){return s.Scheduler.batch(a)}function r(a,b,c){console.warn("mobservable.observeUntilInvalid is deprecated and will be removed in 0.7");var d,e=!1,f=h(function(){e?b():(e=!0,d=a())});return[d,f,f.$mobservable]}a.makeReactive=b,a.asReference=c,a.asStructure=d,a.asFlat=e,a.isReactive=f,a.sideEffect=g,a.observe=h,a.observeUntil=i,a.observeAsync=j,a.when=k,a.expr=l,a.extendReactive=m,a.observable=n,a.toJSON=o,a.toJson=p,a.transaction=q,a.observeUntilInvalid=r,a.logLevel=1,a.strict=!0,setTimeout(function(){a.logLevel>0&&console.info("Welcome to mobservable. Current logLevel = "+a.logLevel+". Change mobservable.logLevel according to your needs: 0 = production, 1 = development, 2 = debugging. Strict mode is "+(a.strict?"enabled":"disabled")+".")},1);var s;!function(a){function b(b){return null===b||void 0===b?i.Reference:"function"==typeof b?b.length?i.ComplexFunction:i.ViewFunction:Array.isArray(b)||b instanceof a.ObservableArray?i.Array:"object"==typeof b?a.isPlainObject(b)?i.PlainObject:i.ComplexObject:i.Reference}function c(b,c,d,e){var f=a.ObservableObject.asReactive(b,e,d);for(var g in c)c.hasOwnProperty(g)&&f.set(g,c[g]);return b}function d(a){var b=function(b){return arguments.length>0?void a.set(b):a.get()};return b.$mobservable=a,b.observe=function(b,c){return a.observe(b,c)},b.toString=function(){return a.toString()},b}function e(a,b){return a instanceof k?[j.Reference,a.value]:a instanceof l?[j.Structure,a.value]:a instanceof m?[j.Flat,a.value]:[b,a]}function g(b,c,d){var g;if(f(b))return b;switch(c){case j.Reference:return b;case j.Flat:h(b,"Items inside 'asFlat' canont have modifiers"),g=j.Reference;break;case j.Structure:h(b,"Items inside 'asStructure' canont have modifiers"),g=j.Structure;break;case j.Recursive:i=e(b,j.Recursive),g=i[0],b=i[1];break;default:throw"Illegal State"}return Array.isArray(b)?new a.ObservableArray(b.slice(),g,d):a.isPlainObject(b)?a.extendReactive(b,b,g,d):b;var i}function h(a,b){if(a instanceof k||a instanceof l||a instanceof m)throw new Error("[mobservable] asStructure / asReference / asFlat cannot be used here. "+b)}!function(a){a[a.Reference=0]="Reference",a[a.PlainObject=1]="PlainObject",a[a.ComplexObject=2]="ComplexObject",a[a.Array=3]="Array",a[a.ViewFunction=4]="ViewFunction",a[a.ComplexFunction=5]="ComplexFunction"}(a.ValueType||(a.ValueType={}));var i=a.ValueType;!function(a){a[a.Recursive=0]="Recursive",a[a.Reference=1]="Reference",a[a.Structure=2]="Structure",a[a.Flat=3]="Flat"}(a.ValueMode||(a.ValueMode={}));var j=a.ValueMode;a.getTypeOfValue=b,a.extendReactive=c,a.toGetterSetterFunction=d;var k=function(){function a(a){this.value=a,h(a,"Modifiers are not allowed to be nested")}return a}();a.AsReference=k;var l=function(){function a(a){this.value=a,h(a,"Modifiers are not allowed to be nested")}return a}();a.AsStructure=l;var m=function(){function a(a){this.value=a,h(a,"Modifiers are not allowed to be nested")}return a}();a.AsFlat=m,a.getValueModeFromValue=e,a.makeChildReactive=g,a.assertUnwrapped=h}(s=a._||(a._={}))}(mobservable||(mobservable={}));var forCompilerVerificationOnly=mobservable;!function(a,b){"function"==typeof define&&define.amd?define("mobservable",[],function(){return b()}):"object"==typeof exports?module.exports=b():a.mobservable=b()}(this,function(){var a=mobservable.makeReactive;a["default"]=mobservable.makeReactive;for(var b in mobservable)mobservable.hasOwnProperty(b)&&(a[b]=mobservable[b]);return Object.defineProperties(a,{logLevel:{get:function(){return mobservable.logLevel},set:function(a){return mobservable.logLevel=a},enumerable:!0},strict:{get:function(){return mobservable.strict},set:function(a){return mobservable.strict=a},enumerable:!0}}),a});
{
"name": "mobservable",
"version": "0.7.0",
"version": "0.7.1",
"description": "Keeps views automatically in sync with state. Unobtrusively.",

@@ -5,0 +5,0 @@ "main": "dist/mobservable.js",

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc