Comparing version 0.3.1-alpha to 0.3.2-alpha
{ | ||
"name": "imvvm", | ||
"version": "0.3.1-alpha", | ||
"version": "0.3.2-alpha", | ||
"homepage": "https://github.com/entrendipity/imvvm", | ||
@@ -5,0 +5,0 @@ "authors": [ |
@@ -361,3 +361,3 @@ !function(e){if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.IMVVM=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){ | ||
if(desc.originalSpec.getInitialState){ | ||
nextState = extend(nextState, desc.originalSpec.getInitialState.call(model, nextState, prevState)); | ||
nextState = extend(nextState, desc.originalSpec.getInitialState.call(model, nextState, ('state' in prevState) ? prevState.state : prevState)); | ||
} | ||
@@ -364,0 +364,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(b){if("object"==typeof exports){module.exports=b()}else{if("function"==typeof define&&define.amd){define(b)}else{var a;"undefined"!=typeof window?a=window:"undefined"!=typeof global?a=global:"undefined"!=typeof self&&(a=self),a.IMVVM=b()}}}(function(){var d,b,a;return(function c(f,k,h){function g(n,l){if(!k[n]){if(!f[n]){var i=typeof require=="function"&&require;if(!l&&i){return i(n,!0)}if(e){return e(n,!0)}throw new Error("Cannot find module '"+n+"'")}var m=k[n]={exports:{}};f[n][0].call(m.exports,function(o){var p=f[n][1][o];return g(p?p:o)},m,m.exports,c,f,k,h)}return k[n].exports}var e=typeof require=="function"&&require;for(var j=0;j<h.length;j++){g(h[j])}return g})({1:[function(h,g,f){var e=h("./src/imvvm.js");g.exports=e},{"./src/imvvm.js":3}],2:[function(h,g,f){var e=h("./utils");var i=e.extend;f.getInitialState=function(l,q,k,r,u,y){if(typeof u!=="function"){throw new TypeError()}var x,w={},j={},v,o={};y===void (0)?false:y;var p=function(B,F,D){var G=false,E,A;F=F||{};if(B===void (0)){A=true;B={}}var C=function(I){var K={},J,H;if("dependsOn" in I){I.dependsOn.forEach(function(L){H={};J=L.property.split(".");J.forEach(function(N,M){if(M===0){H=B[N]}else{H=H?H[N]:void (0)}});if("alias" in L){K[L.alias]=H}else{K[J.join("$")]=H}})}return K};for(var z in r){if(r.hasOwnProperty(z)){E=C(r[z]);if(A){B[z]=new j[z](B[z],E,F[z]).init(r[z].initArgs)}else{B[z]=new j[z](B[z],E,F[z])}if(D){if(G&&D.subscribers.indexOf(z)!==-1){E=C(r[D.name]);B[D.name]=new j[D.name](B[D.name],E,F[D.name])}G=G?G:z===D.name}}}return B};var n=function(z,A,I,E){var H={},L={},G={},K=void (0),F,D,J;E===void (0)?false:E;if(!E&&(A===void (0)||A===null||Object.keys(A).length===0)){return}var C=!!A?Object.getPrototypeOf(A).constructor.classType==="DomainModel":false;if(C){L=i(A);G=A.previousState}else{if(z in o){F=Object.keys(A);D=F.length;J={};for(var B=0;B<D;B++){if(o[z][F[B]]){J[o[z][F[B]]]=true}}K={};K.name=z;K.subscribers=Object.keys(J);K=!!K.subscribers.length?K:void (0)}if(z!==l){L[z]=A;L=i(w.state,L)}else{if(E){L=i(p(),A)}else{L=i(w.state,A)}}G=w.state;L=p(L,w.state,K)}G=G||{};Object.freeze(G);w=new x(L,G,y,E);H=w.state;if(!E&&!y){H.previousState=w.previousState}Object.freeze(H);u(H,z,I);return H};x=q.call(this,n.bind(this,l));for(var m in r){if(r.hasOwnProperty(m)){j[m]=r[m].viewModel.call(this,n.bind(this,m));if("dependsOn" in r[m]){for(var s=0,t=r[m].dependsOn.length;s<t;s++){v=r[m].dependsOn[s].property.split(".");if(v.length>1){o[v[0]]=o[v[0]]||{};o[v[0]][v[1]]=o[v[0]][v[1]]||[];if(o[v[0]][v[1]].indexOf(m)===-1){o[v[0]][v[1]].push(m)}}}}}}return new x().init(k)}},{"./utils":8}],3:[function(f,g,j){var k=f("./imvvmModel");var p=f("./imvvmViewModel");var i=f("./imvvmDomainModel");var r=f("./mixin");var q=f("./utils");var n=q.extend;var m=q.mixInto;var l=function(){};var h=function(){};var o=function(){};m(l,k.Mixin);m(h,p.Mixin);m(o,i.Mixin);var e={createClass:function(u,v,t){var y=function(){};y.prototype=new u();y.prototype.constructor=y;var x=y;var w=function(z){var A=new x();return A.construct.apply(w,arguments)};w.componentConstructor=y;y.ConvenienceConstructor=w;w.originalSpec=t;w.type=y;y.prototype.type=y;w.classType=v;y.prototype.classType=v;return w}};var s={createModel:e.createClass.bind(this,l,"Model"),createViewModel:e.createClass.bind(this,h,"ViewModel"),createDomainModel:e.createClass.bind(this,o,"DomainModel"),mixin:r};g.exports=s},{"./imvvmDomainModel":4,"./imvvmModel":5,"./imvvmViewModel":6,"./mixin":7,"./utils":8}],4:[function(j,h,f){var e=j("./utils");var k=e.extend;var g=e.getDescriptor;var i={Mixin:{construct:function(m){var n=g.call(this);n.proto.setState=m;var l=function(s,q,p,o){s=s||{};q=q||{};if(!("DataContext" in n.proto)){n.proto.DataContext=function(t,u){return n.proto.setState(t,u,true)}}if(!("init" in n.proto)){n.proto.init=function(){return this.DataContext()}}var r=Object.create(n.proto,n.descriptor);if(n.originalSpec.getInitialState){s=k(s,n.originalSpec.getInitialState.call(r,s,q))}if(!o&&!p){Object.defineProperty(r,"previousState",{configurable:false,enumerable:false,writable:false,value:q})}s.__proto__=r.__proto__;Object.defineProperty(r,"state",{configurable:false,enumerable:false,writable:false,value:s});return r};return l}}};h.exports=i},{"./utils":8}],5:[function(i,h,f){var e=i("./utils");var k=e.extend;var g=e.getDescriptor;var j={Mixin:{construct:function(m){var n=g.call(this);var l=function(r,s,o){var q=Object.create(n.proto,n.descriptor);var t=arguments.length;var p=typeof Array.prototype.slice.call(arguments,-1)[0]==="boolean";if(t===0){r={};s={};o=true}else{if(t===1){if(p){o=r;r={};s={}}else{s=r;o=true}}else{if(t===2){if(p){o=s;s=r}else{o=true}}}}if(n.originalSpec.getInitialState){r=k(r,n.originalSpec.getInitialState.call(q,r,s))}if(o){Object.defineProperty(q,"context",{configurable:true,enumerable:true,set:function(u){this.setState=function(v,w){return m.bind(u).call(u,k(this.state,v),this.state,w)}.bind(this);delete this.context}})}Object.defineProperty(q,"state",{configurable:false,enumerable:false,writable:false,value:r});if(!o){Object.freeze(q)}return q};return l}}};h.exports=j},{"./utils":8}],6:[function(j,i,g){var f=j("./utils");var k=f.extend;var h=f.getDescriptor;var e={Mixin:{construct:function(m){var n=h.call(this);n.proto.setState=m;var l=function(p,q,r){r=r||{};p=k(p,q);n.proto.DataContext=l;if(!("init" in n.proto)){n.proto.init=function(){return this.DataContext()}}var o=Object.create(n.proto,n.descriptor);if(n.originalSpec.getInitialState){p=k(p,n.originalSpec.getInitialState.call(o,p,r))}Object.defineProperty(o,"state",{configurable:false,enumerable:false,writable:false,value:p});Object.keys(o).forEach(function(s){if(Object.prototype.toString.call(this[s])==="[object Object]"&&("context" in this[s])){this[s].context=this;Object.freeze(this[s])}if(Object.prototype.toString.call(this[s])==="[object Array]"){Object.freeze(this[s])}}.bind(o));p.__proto__=o.__proto__;return Object.freeze(p)};return l}}};i.exports=e},{"./utils":8}],7:[function(j,i,h){var f=j("./core");var e="__IMVVM__";var g={stateChangedHandler:function(k,l,m){this.setState({applicationDataContext:k},function(){if(typeof m==="function"){if(this.state===null||!("applicationDataContext" in this.state)){m(void (0))}else{if(l in this.state.applicationDataContext){m(this.state.applicationDataContext[l])}else{if(l===e){m(this.state.applicationDataContext)}else{m(void (0))}}}}}.bind(this))},getInitialState:function(){var k=f.getInitialState(e,this.props.domainModel,this.props.initArgs,this.props.domain,this.stateChangedHandler,this.props.disableUndo);return{applicationDataContext:k}}};i.exports=g},{"./core":2}],8:[function(h,g,f){var e={getDescriptor:function(){var k={};var j=this.prototype;for(var i in this.originalSpec){if(this.originalSpec.hasOwnProperty(i)){if("get" in this.originalSpec[i]||"set" in this.originalSpec[i]){if(!("enumerable" in this.originalSpec[i])){this.originalSpec[i].enumerable=true}k[i]=this.originalSpec[i]}else{j[i]=this.originalSpec[i]}}}if(!("extend" in j)){j.extend=e.extend}return{descriptor:k,proto:j,originalSpec:this.originalSpec||{}}},extend:function(){var j={};for(var l=0;l<arguments.length;l++){var m=arguments[l];for(var k in m){if(m.hasOwnProperty(k)){j[k]=m[k]}}}return j},mixInto:function(j,k){var i;for(i in k){if(!k.hasOwnProperty(i)){continue}j.prototype[i]=k[i]}}};g.exports=e},{}]},{},[1])(1)}); | ||
!function(b){if("object"==typeof exports){module.exports=b()}else{if("function"==typeof define&&define.amd){define(b)}else{var a;"undefined"!=typeof window?a=window:"undefined"!=typeof global?a=global:"undefined"!=typeof self&&(a=self),a.IMVVM=b()}}}(function(){var d,b,a;return(function c(f,k,h){function g(n,l){if(!k[n]){if(!f[n]){var i=typeof require=="function"&&require;if(!l&&i){return i(n,!0)}if(e){return e(n,!0)}throw new Error("Cannot find module '"+n+"'")}var m=k[n]={exports:{}};f[n][0].call(m.exports,function(o){var p=f[n][1][o];return g(p?p:o)},m,m.exports,c,f,k,h)}return k[n].exports}var e=typeof require=="function"&&require;for(var j=0;j<h.length;j++){g(h[j])}return g})({1:[function(h,g,f){var e=h("./src/imvvm.js");g.exports=e},{"./src/imvvm.js":3}],2:[function(h,g,f){var e=h("./utils");var i=e.extend;f.getInitialState=function(l,q,k,r,u,y){if(typeof u!=="function"){throw new TypeError()}var x,w={},j={},v,o={};y===void (0)?false:y;var p=function(B,F,D){var G=false,E,A;F=F||{};if(B===void (0)){A=true;B={}}var C=function(I){var K={},J,H;if("dependsOn" in I){I.dependsOn.forEach(function(L){H={};J=L.property.split(".");J.forEach(function(N,M){if(M===0){H=B[N]}else{H=H?H[N]:void (0)}});if("alias" in L){K[L.alias]=H}else{K[J.join("$")]=H}})}return K};for(var z in r){if(r.hasOwnProperty(z)){E=C(r[z]);if(A){B[z]=new j[z](B[z],E,F[z]).init(r[z].initArgs)}else{B[z]=new j[z](B[z],E,F[z])}if(D){if(G&&D.subscribers.indexOf(z)!==-1){E=C(r[D.name]);B[D.name]=new j[D.name](B[D.name],E,F[D.name])}G=G?G:z===D.name}}}return B};var n=function(z,A,I,E){var H={},L={},G={},K=void (0),F,D,J;E===void (0)?false:E;if(!E&&(A===void (0)||A===null||Object.keys(A).length===0)){return}var C=!!A?Object.getPrototypeOf(A).constructor.classType==="DomainModel":false;if(C){L=i(A);G=A.previousState}else{if(z in o){F=Object.keys(A);D=F.length;J={};for(var B=0;B<D;B++){if(o[z][F[B]]){J[o[z][F[B]]]=true}}K={};K.name=z;K.subscribers=Object.keys(J);K=!!K.subscribers.length?K:void (0)}if(z!==l){L[z]=A;L=i(w.state,L)}else{if(E){L=i(p(),A)}else{L=i(w.state,A)}}G=w.state;L=p(L,w.state,K)}G=G||{};Object.freeze(G);w=new x(L,G,y,E);H=w.state;if(!E&&!y){H.previousState=w.previousState}Object.freeze(H);u(H,z,I);return H};x=q.call(this,n.bind(this,l));for(var m in r){if(r.hasOwnProperty(m)){j[m]=r[m].viewModel.call(this,n.bind(this,m));if("dependsOn" in r[m]){for(var s=0,t=r[m].dependsOn.length;s<t;s++){v=r[m].dependsOn[s].property.split(".");if(v.length>1){o[v[0]]=o[v[0]]||{};o[v[0]][v[1]]=o[v[0]][v[1]]||[];if(o[v[0]][v[1]].indexOf(m)===-1){o[v[0]][v[1]].push(m)}}}}}}return new x().init(k)}},{"./utils":8}],3:[function(f,g,j){var k=f("./imvvmModel");var p=f("./imvvmViewModel");var i=f("./imvvmDomainModel");var r=f("./mixin");var q=f("./utils");var n=q.extend;var m=q.mixInto;var l=function(){};var h=function(){};var o=function(){};m(l,k.Mixin);m(h,p.Mixin);m(o,i.Mixin);var e={createClass:function(u,v,t){var y=function(){};y.prototype=new u();y.prototype.constructor=y;var x=y;var w=function(z){var A=new x();return A.construct.apply(w,arguments)};w.componentConstructor=y;y.ConvenienceConstructor=w;w.originalSpec=t;w.type=y;y.prototype.type=y;w.classType=v;y.prototype.classType=v;return w}};var s={createModel:e.createClass.bind(this,l,"Model"),createViewModel:e.createClass.bind(this,h,"ViewModel"),createDomainModel:e.createClass.bind(this,o,"DomainModel"),mixin:r};g.exports=s},{"./imvvmDomainModel":4,"./imvvmModel":5,"./imvvmViewModel":6,"./mixin":7,"./utils":8}],4:[function(j,h,f){var e=j("./utils");var k=e.extend;var g=e.getDescriptor;var i={Mixin:{construct:function(m){var n=g.call(this);n.proto.setState=m;var l=function(s,q,p,o){s=s||{};q=q||{};if(!("DataContext" in n.proto)){n.proto.DataContext=function(t,u){return n.proto.setState(t,u,true)}}if(!("init" in n.proto)){n.proto.init=function(){return this.DataContext()}}var r=Object.create(n.proto,n.descriptor);if(n.originalSpec.getInitialState){s=k(s,n.originalSpec.getInitialState.call(r,s,q))}if(!o&&!p){Object.defineProperty(r,"previousState",{configurable:false,enumerable:false,writable:false,value:q})}s.__proto__=r.__proto__;Object.defineProperty(r,"state",{configurable:false,enumerable:false,writable:false,value:s});return r};return l}}};h.exports=i},{"./utils":8}],5:[function(i,h,f){var e=i("./utils");var k=e.extend;var g=e.getDescriptor;var j={Mixin:{construct:function(m){var n=g.call(this);var l=function(r,s,o){var q=Object.create(n.proto,n.descriptor);var t=arguments.length;var p=typeof Array.prototype.slice.call(arguments,-1)[0]==="boolean";if(t===0){r={};s={};o=true}else{if(t===1){if(p){o=r;r={};s={}}else{s=r;o=true}}else{if(t===2){if(p){o=s;s=r}else{o=true}}}}if(n.originalSpec.getInitialState){r=k(r,n.originalSpec.getInitialState.call(q,r,("state" in s)?s.state:s))}if(o){Object.defineProperty(q,"context",{configurable:true,enumerable:true,set:function(u){this.setState=function(v,w){return m.bind(u).call(u,k(this.state,v),this.state,w)}.bind(this);delete this.context}})}Object.defineProperty(q,"state",{configurable:false,enumerable:false,writable:false,value:r});if(!o){Object.freeze(q)}return q};return l}}};h.exports=j},{"./utils":8}],6:[function(j,i,g){var f=j("./utils");var k=f.extend;var h=f.getDescriptor;var e={Mixin:{construct:function(m){var n=h.call(this);n.proto.setState=m;var l=function(p,q,r){r=r||{};p=k(p,q);n.proto.DataContext=l;if(!("init" in n.proto)){n.proto.init=function(){return this.DataContext()}}var o=Object.create(n.proto,n.descriptor);if(n.originalSpec.getInitialState){p=k(p,n.originalSpec.getInitialState.call(o,p,r))}Object.defineProperty(o,"state",{configurable:false,enumerable:false,writable:false,value:p});Object.keys(o).forEach(function(s){if(Object.prototype.toString.call(this[s])==="[object Object]"&&("context" in this[s])){this[s].context=this;Object.freeze(this[s])}if(Object.prototype.toString.call(this[s])==="[object Array]"){Object.freeze(this[s])}}.bind(o));p.__proto__=o.__proto__;return Object.freeze(p)};return l}}};i.exports=e},{"./utils":8}],7:[function(j,i,h){var f=j("./core");var e="__IMVVM__";var g={stateChangedHandler:function(k,l,m){this.setState({applicationDataContext:k},function(){if(typeof m==="function"){if(this.state===null||!("applicationDataContext" in this.state)){m(void (0))}else{if(l in this.state.applicationDataContext){m(this.state.applicationDataContext[l])}else{if(l===e){m(this.state.applicationDataContext)}else{m(void (0))}}}}}.bind(this))},getInitialState:function(){var k=f.getInitialState(e,this.props.domainModel,this.props.initArgs,this.props.domain,this.stateChangedHandler,this.props.disableUndo);return{applicationDataContext:k}}};i.exports=g},{"./core":2}],8:[function(h,g,f){var e={getDescriptor:function(){var k={};var j=this.prototype;for(var i in this.originalSpec){if(this.originalSpec.hasOwnProperty(i)){if("get" in this.originalSpec[i]||"set" in this.originalSpec[i]){if(!("enumerable" in this.originalSpec[i])){this.originalSpec[i].enumerable=true}k[i]=this.originalSpec[i]}else{j[i]=this.originalSpec[i]}}}if(!("extend" in j)){j.extend=e.extend}return{descriptor:k,proto:j,originalSpec:this.originalSpec||{}}},extend:function(){var j={};for(var l=0;l<arguments.length;l++){var m=arguments[l];for(var k in m){if(m.hasOwnProperty(k)){j[k]=m[k]}}}return j},mixInto:function(j,k){var i;for(i in k){if(!k.hasOwnProperty(i)){continue}j.prototype[i]=k[i]}}};g.exports=e},{}]},{},[1])(1)}); |
@@ -44,3 +44,2 @@ /*jshint unused: false */ | ||
getInitialState: function(nextState, prevState){ | ||
console.log(prevState); | ||
return { | ||
@@ -47,0 +46,0 @@ id: nextState.id ? nextState.id : this.uuid(), |
{ | ||
"name": "imvvm", | ||
"description": "Immutable MVVM for React", | ||
"version": "0.3.1-alpha", | ||
"version": "0.3.2-alpha", | ||
"keywords": [ | ||
@@ -6,0 +6,0 @@ "imvvm", |
@@ -38,4 +38,2 @@ | ||
} | ||
} else { | ||
prevState = ('state' in prevState) ? prevState.state : prevState; | ||
} | ||
@@ -45,3 +43,3 @@ | ||
if(desc.originalSpec.getInitialState){ | ||
nextState = extend(nextState, desc.originalSpec.getInitialState.call(model, nextState, prevState)); | ||
nextState = extend(nextState, desc.originalSpec.getInitialState.call(model, nextState, ('state' in prevState) ? prevState.state : prevState)); | ||
} | ||
@@ -48,0 +46,0 @@ |
121413
2042