Comparing version 0.1.4-alpha to 0.1.5-alpha
{ | ||
"name": "imvvm", | ||
"version": "0.1.4-alpha", | ||
"version": "0.1.5-alpha", | ||
"homepage": "https://github.com/entrendipity/imvvm", | ||
@@ -5,0 +5,0 @@ "authors": [ |
@@ -176,80 +176,8 @@ !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){ | ||
}; | ||
},{"./utils":9}],3:[function(_dereq_,module,exports){ | ||
'use strict' | ||
},{"./utils":8}],3:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
var base = _dereq_('./imvvmBase'); | ||
var mixin = _dereq_('./mixin'); | ||
var IMVVM = { | ||
createModel: base.createModel, | ||
createViewModel: base.createViewModel, | ||
createAppViewModel: base.createAppViewModel, | ||
mixin: mixin | ||
}; | ||
module.exports = IMVVM; | ||
},{"./imvvmBase":5,"./mixin":8}],4:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
var utils = _dereq_('./utils'); | ||
var extend = utils.extend; | ||
var getDescriptor = utils.getDescriptor; | ||
var IMVVMAppViewModel = { | ||
Mixin: { | ||
construct: function(raiseStateChangeHandler){ | ||
var desc = getDescriptor.call(this); | ||
desc.proto.setState = raiseStateChangeHandler; | ||
var dataContext = function(state, previousState, oldState) { | ||
state = state || {}; | ||
if(!!previousState){ | ||
Object.defineProperty(state, 'previousState', { | ||
configurable: false, | ||
enumerable: true, | ||
writable: false, | ||
value: previousState | ||
}); | ||
} | ||
//Do this after previousState is set so that it is included | ||
if(desc.originalSpec.getInitialState){ | ||
state = extend(state, desc.originalSpec.getInitialState(state, previousState ? previousState.state: void 0)); | ||
} | ||
desc.proto.DataContext = function(newState, callback, initialize){ | ||
return desc.proto.setState(newState, callback, true); | ||
} | ||
if(!('init' in desc.proto)){ | ||
desc.proto.init = function(){ | ||
return this.DataContext(); | ||
} | ||
} | ||
var model = Object.create(desc.proto, desc.descriptor); | ||
//set this last | ||
//TODO - rework this, as __proto__ is deprecated | ||
state.__proto__ = model.__proto__; | ||
Object.defineProperty(model, 'state', { | ||
configurable: false, | ||
enumerable: false, | ||
writable: false, | ||
value: state | ||
}); | ||
return model; | ||
}; | ||
return dataContext; | ||
} | ||
} | ||
}; | ||
module.exports = IMVVMAppViewModel; | ||
},{"./utils":9}],5:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
var utils = _dereq_('./utils'); | ||
var extend = utils.extend; | ||
var mixInto = utils.mixInto; | ||
@@ -318,11 +246,12 @@ | ||
}; | ||
var IMVVMConstructors = { | ||
var IMVVM = { | ||
createModel: IMVVMClass.createClass.bind(this, ModelBase, 'Model'), | ||
createViewModel: IMVVMClass.createClass.bind(this, ViewModelBase, 'ViewModel'), | ||
createAppViewModel: IMVVMClass.createClass.bind(this, AppViewModelBase, 'AppViewModel') | ||
createAppViewModel: IMVVMClass.createClass.bind(this, AppViewModelBase, 'AppViewModel'), | ||
mixin: mixin | ||
}; | ||
module.exports = IMVVMConstructors; | ||
module.exports = IMVVM; | ||
},{"./imvvmAppViewModel":4,"./imvvmModel":6,"./imvvmViewModel":7,"./utils":9}],6:[function(_dereq_,module,exports){ | ||
},{"./imvvmAppViewModel":4,"./imvvmModel":5,"./imvvmViewModel":6,"./mixin":7,"./utils":8}],4:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -334,2 +263,61 @@ | ||
var IMVVMAppViewModel = { | ||
Mixin: { | ||
construct: function(raiseStateChangeHandler){ | ||
var desc = getDescriptor.call(this); | ||
desc.proto.setState = raiseStateChangeHandler; | ||
var dataContext = function(state, previousState, oldState) { | ||
state = state || {}; | ||
if(!!previousState){ | ||
Object.defineProperty(state, 'previousState', { | ||
configurable: false, | ||
enumerable: true, | ||
writable: false, | ||
value: previousState | ||
}); | ||
} | ||
//Do this after previousState is set so that it is included | ||
if(desc.originalSpec.getInitialState){ | ||
state = extend(state, desc.originalSpec.getInitialState(state, previousState ? previousState.state: void 0)); | ||
} | ||
desc.proto.DataContext = function(newState, callback, initialize){ | ||
return desc.proto.setState(newState, callback, true); | ||
} | ||
if(!('init' in desc.proto)){ | ||
desc.proto.init = function(){ | ||
return this.DataContext(); | ||
} | ||
} | ||
var model = Object.create(desc.proto, desc.descriptor); | ||
//set this last | ||
//TODO - rework this, as __proto__ is deprecated | ||
state.__proto__ = model.__proto__; | ||
Object.defineProperty(model, 'state', { | ||
configurable: false, | ||
enumerable: false, | ||
writable: false, | ||
value: state | ||
}); | ||
return model; | ||
}; | ||
return dataContext; | ||
} | ||
} | ||
}; | ||
module.exports = IMVVMAppViewModel; | ||
},{"./utils":8}],5:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
var utils = _dereq_('./utils'); | ||
var extend = utils.extend; | ||
var getDescriptor = utils.getDescriptor; | ||
var IMVVMModel = { | ||
@@ -397,6 +385,5 @@ Mixin: { | ||
module.exports = IMVVMModel; | ||
},{"./utils":9}],7:[function(_dereq_,module,exports){ | ||
},{"./utils":8}],6:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -459,3 +446,3 @@ | ||
},{"./utils":9}],8:[function(_dereq_,module,exports){ | ||
},{"./utils":8}],7:[function(_dereq_,module,exports){ | ||
/*jshint quotmark:false */ | ||
@@ -499,3 +486,3 @@ /*jshint white:false */ | ||
module.exports = mixin; | ||
},{"./core":2}],9:[function(_dereq_,module,exports){ | ||
},{"./core":2}],8:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
@@ -502,0 +489,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(m,u,k,l,v,q){if(typeof v!=="function"){throw new TypeError()}var j=m,y=void 0,p={},w,o={};var r=function(B,G,D){var H=false,E,A;G=G||{};if(B===void 0){A=true;B={}}var C=function(J){var L={},K,I;if("dependsOn" in J){J.dependsOn.forEach(function(M){I={};K=M.property.split(".");K.forEach(function(O,N){if(N===0){I=B[O]}else{I=I?I[O]:void 0}});if("alias" in M){L[M.alias]=I}else{L[K.join("_")]=I}})}return L};for(var F in l){if(l.hasOwnProperty(F)){E=C(l[F]);if(A){B[F]=new p[F](B[F],E,G[F]).init(l[F].initArgs)}else{B[F]=new p[F](B[F],E,G[F])}if(D){if(H&&D.subscribers.indexOf(F)!==-1){E=C(l[D.name]);B[D.name]=new p[D.name](B[D.name],E,G[D.name])}H=H?H:F===D.name}}}return B};var n=function(B,C,J,F){var I,M={},H=void 0,L=void 0,G,E,K;if(B in o){G=Object.keys(C);E=G.length;K={};for(var D=0;D<E;D++){if(o[B][G[D]]){K[o[B][G[D]]]=true}}L={};L.name=B;L.subscribers=Object.keys(K);L=!!L.subscribers.length?L:void 0}var A=!!C?Object.getPrototypeOf(C).constructor.classType==="AppViewModel":false;if(A){M=i(C.state);H=C.state.previousState}else{if(B!==j){M[B]=C;M=i(y.state,M)}else{if(F){M=i(r(),C)}else{M=i(y.state,C)}}H=y;M=r(M,y?y.state:void 0,L)}if(H){Object.freeze(H)}y=new z(M,q?void 0:H);I=Object.freeze(y.state);v(I,J);return I};var z=u.call(this,n.bind(this,j));for(var x in l){if(l.hasOwnProperty(x)){p[x]=l[x].viewModel.call(this,n.bind(this,x));if("dependsOn" in l[x]){for(var s=0,t=l[x].dependsOn.length;s<t;s++){w=l[x].dependsOn[s].property.split(".");if(w.length>1){o[w[0]]=o[w[0]]||{};o[w[0]][w[1]]=o[w[0]][w[1]]||[];if(o[w[0]][w[1]].indexOf(x)===-1){o[w[0]][w[1]].push(x)}}}}}}return new z().init(k)}},{"./utils":9}],3:[function(i,h,g){var j=i("./imvvmBase");var f=i("./mixin");var e={createModel:j.createModel,createViewModel:j.createViewModel,createAppViewModel:j.createAppViewModel,mixin:f};h.exports=e},{"./imvvmBase":5,"./mixin":8}],4:[function(j,i,g){var e=j("./utils");var k=e.extend;var h=e.getDescriptor;var f={Mixin:{construct:function(m){var n=h.call(this);n.proto.setState=m;var l=function(r,o,q){r=r||{};if(!!o){Object.defineProperty(r,"previousState",{configurable:false,enumerable:true,writable:false,value:o})}if(n.originalSpec.getInitialState){r=k(r,n.originalSpec.getInitialState(r,o?o.state:void 0))}n.proto.DataContext=function(t,u,s){return n.proto.setState(t,u,true)};if(!("init" in n.proto)){n.proto.init=function(){return this.DataContext()}}var p=Object.create(n.proto,n.descriptor);r.__proto__=p.__proto__;Object.defineProperty(p,"state",{configurable:false,enumerable:false,writable:false,value:r});return p};return l}}};i.exports=f},{"./utils":9}],5:[function(f,g,j){var r=f("./utils");var p=r.extend;var n=r.mixInto;var k=f("./imvvmModel");var q=f("./imvvmViewModel");var m=f("./imvvmAppViewModel");var l=function(){};var i=function(){};var h=function(){};n(l,k.Mixin);n(i,q.Mixin);n(h,m.Mixin);var e={createClass:function(t,u,s){var x=function(){};x.prototype=new t();x.prototype.constructor=x;var w=x;var v=function(y){var z=new w();return z.construct.apply(v,arguments)};v.componentConstructor=x;x.ConvenienceConstructor=v;v.originalSpec=s;v.type=x;x.prototype.type=x;v.classType=u;x.prototype.classType=u;return v}};var o={createModel:e.createClass.bind(this,l,"Model"),createViewModel:e.createClass.bind(this,i,"ViewModel"),createAppViewModel:e.createClass.bind(this,h,"AppViewModel")};g.exports=o},{"./imvvmAppViewModel":4,"./imvvmModel":6,"./imvvmViewModel":7,"./utils":9}],6:[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(t,o,s){var r=Object.create(n.proto,n.descriptor);var u=arguments.length;var q=typeof Array.prototype.slice.call(arguments,-1)[0]==="boolean";if(u===1){if(q){o=t;t={}}else{o=true}}else{if(u===2){if(!q){s=o;o=true}}else{if(u===3){if(q){var p=o;o=s;s=p}}else{t={};o=true}}}if(n.originalSpec.getInitialState){t=k(t,n.originalSpec.getInitialState(t,s))}if(o){Object.defineProperty(r,"context",{configurable:true,enumerable:true,set:function(v){this.setState=m(v);delete this.context}})}Object.defineProperty(r,"state",{configurable:false,enumerable:false,writable:false,value:t});return r};return l}}};h.exports=j},{"./utils":9}],7:[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(r,q,p){r=r||{};r=k(r,q);if(n.originalSpec.getInitialState){r=k(r,n.originalSpec.getInitialState(r,p))}n.proto.DataContext=l;if(!("init" in n.proto)){n.proto.init=function(){return this.DataContext()}}var o=Object.create(n.proto,n.descriptor);Object.defineProperty(o,"state",{configurable:false,enumerable:false,writable:false,value:r});Object.keys(o).map(function(s){if(Object.prototype.toString.call(this[s])==="[object Object]"&&("context" in this[s])){this[s].context=this;Object.freeze(this[s])}}.bind(o));r.__proto__=o.__proto__;return Object.freeze(r)};return l}}};i.exports=e},{"./utils":9}],8:[function(j,i,h){var f=j("./core");var e="__IMVVM__";var g={stateChangedHandler:function(k,l){this.setState({appContext:k},function(){if(typeof l==="function"){if(this.state!==null&&("appContext" in this.state)){l(this.state.appContext)}else{l(void 0)}}}.bind(this))},getInitialState:function(){var k=f.getInitialState(e,this.props.viewModel,this.props.initArgs,this.props.dataContexts,this.stateChangedHandler,this.props.noUndo);return{appContext:k}}};i.exports=g},{"./core":2}],9:[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]}}}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(m,u,k,l,v,q){if(typeof v!=="function"){throw new TypeError()}var j=m,y=void 0,p={},w,o={};var r=function(B,G,D){var H=false,E,A;G=G||{};if(B===void 0){A=true;B={}}var C=function(J){var L={},K,I;if("dependsOn" in J){J.dependsOn.forEach(function(M){I={};K=M.property.split(".");K.forEach(function(O,N){if(N===0){I=B[O]}else{I=I?I[O]:void 0}});if("alias" in M){L[M.alias]=I}else{L[K.join("_")]=I}})}return L};for(var F in l){if(l.hasOwnProperty(F)){E=C(l[F]);if(A){B[F]=new p[F](B[F],E,G[F]).init(l[F].initArgs)}else{B[F]=new p[F](B[F],E,G[F])}if(D){if(H&&D.subscribers.indexOf(F)!==-1){E=C(l[D.name]);B[D.name]=new p[D.name](B[D.name],E,G[D.name])}H=H?H:F===D.name}}}return B};var n=function(B,C,J,F){var I,M={},H=void 0,L=void 0,G,E,K;if(B in o){G=Object.keys(C);E=G.length;K={};for(var D=0;D<E;D++){if(o[B][G[D]]){K[o[B][G[D]]]=true}}L={};L.name=B;L.subscribers=Object.keys(K);L=!!L.subscribers.length?L:void 0}var A=!!C?Object.getPrototypeOf(C).constructor.classType==="AppViewModel":false;if(A){M=i(C.state);H=C.state.previousState}else{if(B!==j){M[B]=C;M=i(y.state,M)}else{if(F){M=i(r(),C)}else{M=i(y.state,C)}}H=y;M=r(M,y?y.state:void 0,L)}if(H){Object.freeze(H)}y=new z(M,q?void 0:H);I=Object.freeze(y.state);v(I,J);return I};var z=u.call(this,n.bind(this,j));for(var x in l){if(l.hasOwnProperty(x)){p[x]=l[x].viewModel.call(this,n.bind(this,x));if("dependsOn" in l[x]){for(var s=0,t=l[x].dependsOn.length;s<t;s++){w=l[x].dependsOn[s].property.split(".");if(w.length>1){o[w[0]]=o[w[0]]||{};o[w[0]][w[1]]=o[w[0]][w[1]]||[];if(o[w[0]][w[1]].indexOf(x)===-1){o[w[0]][w[1]].push(x)}}}}}}return new z().init(k)}},{"./utils":8}],3:[function(f,g,j){var r=f("./mixin");var q=f("./utils");var o=q.extend;var n=q.mixInto;var k=f("./imvvmModel");var p=f("./imvvmViewModel");var m=f("./imvvmAppViewModel");var l=function(){};var i=function(){};var h=function(){};n(l,k.Mixin);n(i,p.Mixin);n(h,m.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,i,"ViewModel"),createAppViewModel:e.createClass.bind(this,h,"AppViewModel"),mixin:r};g.exports=s},{"./imvvmAppViewModel":4,"./imvvmModel":5,"./imvvmViewModel":6,"./mixin":7,"./utils":8}],4:[function(j,i,g){var e=j("./utils");var k=e.extend;var h=e.getDescriptor;var f={Mixin:{construct:function(m){var n=h.call(this);n.proto.setState=m;var l=function(r,o,q){r=r||{};if(!!o){Object.defineProperty(r,"previousState",{configurable:false,enumerable:true,writable:false,value:o})}if(n.originalSpec.getInitialState){r=k(r,n.originalSpec.getInitialState(r,o?o.state:void 0))}n.proto.DataContext=function(t,u,s){return n.proto.setState(t,u,true)};if(!("init" in n.proto)){n.proto.init=function(){return this.DataContext()}}var p=Object.create(n.proto,n.descriptor);r.__proto__=p.__proto__;Object.defineProperty(p,"state",{configurable:false,enumerable:false,writable:false,value:r});return p};return l}}};i.exports=f},{"./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(t,o,s){var r=Object.create(n.proto,n.descriptor);var u=arguments.length;var q=typeof Array.prototype.slice.call(arguments,-1)[0]==="boolean";if(u===1){if(q){o=t;t={}}else{o=true}}else{if(u===2){if(!q){s=o;o=true}}else{if(u===3){if(q){var p=o;o=s;s=p}}else{t={};o=true}}}if(n.originalSpec.getInitialState){t=k(t,n.originalSpec.getInitialState(t,s))}if(o){Object.defineProperty(r,"context",{configurable:true,enumerable:true,set:function(v){this.setState=m(v);delete this.context}})}Object.defineProperty(r,"state",{configurable:false,enumerable:false,writable:false,value:t});return r};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(r,q,p){r=r||{};r=k(r,q);if(n.originalSpec.getInitialState){r=k(r,n.originalSpec.getInitialState(r,p))}n.proto.DataContext=l;if(!("init" in n.proto)){n.proto.init=function(){return this.DataContext()}}var o=Object.create(n.proto,n.descriptor);Object.defineProperty(o,"state",{configurable:false,enumerable:false,writable:false,value:r});Object.keys(o).map(function(s){if(Object.prototype.toString.call(this[s])==="[object Object]"&&("context" in this[s])){this[s].context=this;Object.freeze(this[s])}}.bind(o));r.__proto__=o.__proto__;return Object.freeze(r)};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){this.setState({appContext:k},function(){if(typeof l==="function"){if(this.state!==null&&("appContext" in this.state)){l(this.state.appContext)}else{l(void 0)}}}.bind(this))},getInitialState:function(){var k=f.getInitialState(e,this.props.viewModel,this.props.initArgs,this.props.dataContexts,this.stateChangedHandler,this.props.noUndo);return{appContext: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]}}}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)}); |
{ | ||
"name": "imvvm", | ||
"description": "Immutable MVVM for React", | ||
"version": "0.1.4-alpha", | ||
"version": "0.1.5-alpha", | ||
"keywords": [ | ||
@@ -6,0 +6,0 @@ "imvvm", |
@@ -1,13 +0,77 @@ | ||
'use strict' | ||
'use strict'; | ||
var base = require('./imvvmBase'); | ||
var model = require('./imvvmModel'); | ||
var viewModel = require('./imvvmViewModel'); | ||
var appViewModel = require('./imvvmAppViewModel'); | ||
var mixin = require('./mixin'); | ||
var utils = require('./utils'); | ||
var extend = utils.extend; | ||
var mixInto = utils.mixInto; | ||
var ModelBase = function() {}; | ||
var ViewModelBase = function() {}; | ||
var AppViewModelBase = function() {}; | ||
mixInto(ModelBase, model.Mixin); | ||
mixInto(ViewModelBase, viewModel.Mixin); | ||
mixInto(AppViewModelBase, appViewModel.Mixin); | ||
var IMVVMClass = { | ||
createClass: function(ctor, classType, spec){ | ||
var Constructor = function(){}; | ||
Constructor.prototype = new ctor(); | ||
Constructor.prototype.constructor = Constructor; | ||
var DescriptorConstructor = Constructor; | ||
var ConvenienceConstructor = function(raiseStateChangeHandler) { | ||
var descriptor = new DescriptorConstructor(); | ||
return descriptor.construct.apply(ConvenienceConstructor, arguments); | ||
}; | ||
ConvenienceConstructor.componentConstructor = Constructor; | ||
Constructor.ConvenienceConstructor = ConvenienceConstructor; | ||
ConvenienceConstructor.originalSpec = spec; | ||
// Expose the convience constructor on the prototype so that it can be | ||
// easily accessed on descriptors. E.g. <Foo />.type === Foo.type and for | ||
// static methods like <Foo />.type.staticMethod(); | ||
// This should not be named constructor since this may not be the function | ||
// that created the descriptor, and it may not even be a constructor. | ||
ConvenienceConstructor.type = Constructor; | ||
Constructor.prototype.type = Constructor; | ||
ConvenienceConstructor.classType = classType; | ||
Constructor.prototype.classType = classType; | ||
/* // Reduce time spent doing lookups by setting these on the prototype. | ||
for (var methodName in IMVVMInterface) { | ||
if (!Constructor.prototype[methodName]) { | ||
Constructor.prototype[methodName] = null; | ||
} | ||
} | ||
*/ | ||
/* | ||
if (__DEV__) { | ||
// In DEV the convenience constructor generates a proxy to another | ||
// instance around it to warn about access to properties on the | ||
// descriptor. | ||
DescriptorConstructor = createDescriptorProxy(Constructor); | ||
}*/ | ||
return ConvenienceConstructor; | ||
}, | ||
}; | ||
var IMVVM = { | ||
createModel: base.createModel, | ||
createViewModel: base.createViewModel, | ||
createAppViewModel: base.createAppViewModel, | ||
mixin: mixin | ||
createModel: IMVVMClass.createClass.bind(this, ModelBase, 'Model'), | ||
createViewModel: IMVVMClass.createClass.bind(this, ViewModelBase, 'ViewModel'), | ||
createAppViewModel: IMVVMClass.createClass.bind(this, AppViewModelBase, 'AppViewModel'), | ||
mixin: mixin | ||
}; | ||
module.exports = IMVVM; | ||
module.exports = IMVVM; |
119716
49
2044