Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

imvvm

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

imvvm - npm Package Compare versions

Comparing version 0.4.1-alpha to 0.4.2-alpha

2

bower.json
{
"name": "imvvm",
"version": "0.4.1-alpha",
"version": "0.4.2-alpha",
"homepage": "https://github.com/entrendipity/imvvm",

@@ -5,0 +5,0 @@ "authors": [

@@ -172,2 +172,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){

Object.freeze(thisAppState);
Object.freeze(thisAppState.state);
stateChangedHandler(thisAppState, caller, callback);

@@ -290,3 +291,3 @@ return thisAppState;

var DataContext = function(initState, callback){
var initialize = function(initState, callback){
return desc.proto.setState(initState, callback, true);

@@ -303,3 +304,3 @@ }

desc.proto.getInitialState = function(){
return DataContext();
return initialize();
}

@@ -309,3 +310,3 @@ } else {

desc.proto.getInitialState = function(){
return DataContext(initFunc.call(this));
return initialize(initFunc.call(this));
}

@@ -466,2 +467,9 @@ }

Object.keys(model).forEach(function(key){
if(Object.prototype.toString.call(this[key]) === '[object Object]' ||
Object.prototype.toString.call(this[key]) === '[object Array]'){
Object.freeze(this[key]);
}
}.bind(model));
if(!withContext){

@@ -572,3 +580,3 @@ Object.freeze(model);

Object.freeze(nextState);
return model;
return Object.freeze(model);

@@ -575,0 +583,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(k,p,u,y){if(typeof u!=="function"){throw new TypeError()}var x,w={},j={},v,n={},q,t=false;y===void (0)?false:y;var o=function(C,G,E){var H=false,F,B;G=G||{};if(C===void (0)){B=true;C={}}var D=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=C[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 A in q){if(q.hasOwnProperty(A)){F=D(q[A]);if(B){C[A]=new j[A](C[A],F,G[A]).getInitialState()}else{C[A]=new j[A](C[A],F,G[A])}if(E){if(H&&E.subscribers.indexOf(A)!==-1){F=D(q[E.name]);C[E.name]=new j[E.name](C[E.name],F,G[E.name])}H=H?H:A===E.name}}}return C};var m=function(C,E,M,I){var P={},L={},O=void (0),J,H,N,K=false;I===void (0)?false:I;if(!I&&(E===void (0)||E===null||Object.keys(E).length===0)){return}var G=!!E?Object.getPrototypeOf(E).constructor.classType==="DomainModel":false;if(G){P=i(E);L=E.previousState;K=true}else{if(C in n){J=Object.keys(E);H=J.length;N={};for(var F=0;F<H;F++){if(n[C][J[F]]){N[n[C][J[F]]]=true}}O={};O.name=C;O.subscribers=Object.keys(N);O=!!O.subscribers.length?O:void (0)}if(C!==k){P[C]=E;P=i(w.state,P)}else{if(I){P=i(o(),E)}else{P=i(w.state,E)}}L=t?w.previousState:w;P=o(P,w.state,O)}L=L||{};Object.freeze(L);w=new x(P,L,y);if(!!w.validateState&&!K&&!t){var B=w.validateState(w.state,w.previousState);var A=Object.keys(B);for(var D=A.length-1;D>=0;D--){if(Object.prototype.toString.call(B[A[D]])!=="[object Object]"&&Object.prototype.toString.call(B[A[D]])!=="[object Array]"&&B[A[D]]!==w.state[A[D]]){t=true;w.setState(i(w.state,B));t=false;break}}}if(!t){Object.freeze(w);u(w,C,M);return w}};x=p.call(this,m.bind(this,k));var z=new x({},{},y);q=z.dataContexts();for(var l in q){if(q.hasOwnProperty(l)){j[l]=q[l].viewModel.call(this,m.bind(this,l));if("dependsOn" in q[l]){for(var r=0,s=q[l].dependsOn.length;r<s;r++){v=q[l].dependsOn[r].property.split(".");if(v.length>1){n[v[0]]=n[v[0]]||{};n[v[0]][v[1]]=n[v[0]][v[1]]||[];if(n[v[0]][v[1]].indexOf(l)===-1){n[v[0]][v[1]].push(l)}}}}}}return z.getInitialState()}},{"./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 o=g.call(this);o.proto.setState=m;var n=function(p,q){return o.proto.setState(p,q,true)};var l=function(t,v,p){var w;var u;t=t||{};v=v||{};if(!("getInitialState" in o.proto)){o.proto.getInitialState=function(){return n()}}else{w=o.proto.getInitialState;o.proto.getInitialState=function(){return n(w.call(this))}}var r=Object.create(o.proto,o.descriptor);Object.defineProperty(r,"state",{configurable:true,enumerable:false,writable:true,value:t});t=k(t,r);if(!!o.originalSpec.getInitialCalculatedState){for(var s=o.calculatedFields.length-1;s>=0;s--){if(!(o.calculatedFields[s] in t)||t[o.calculatedFields[s]]===void (0)){u={};u[o.calculatedFields[s]]=o.originalSpec.getInitialCalculatedState.call(r,t,v)[o.calculatedFields[s]];if(u[o.calculatedFields[s]]!==void (0)){t=k(t,u)}}}}if(!p&&!!Object.keys(v).length){Object.defineProperty(t,"previousState",{configurable:false,enumerable:false,writable:false,value:v})}Object.defineProperty(t,"state",{configurable:false,enumerable:false,writable:false,value:k(t)});for(var q in o.descriptor){if(o.descriptor.hasOwnProperty(q)){Object.defineProperty(t,q,o.descriptor[q])}}t.__proto__=r.__proto__;return t};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(s,u,o){var p=Object.create(n.proto,n.descriptor);var v=arguments.length;var r=typeof Array.prototype.slice.call(arguments,-1)[0]==="boolean";var t;if(v===0){s={};u={};o=true}else{if(v===1){if(r){o=s;s={};u={}}else{u=s;o=true}}else{if(v===2){if(r){o=u;u=s}else{o=true}}}}s=("state" in s)?s.state:s;u=("state" in u)?u.state:u;Object.defineProperty(p,"state",{configurable:true,enumerable:false,writable:true,value:s});s=k(s,p);if(!!n.originalSpec.getInitialCalculatedState){for(var q=n.calculatedFields.length-1;q>=0;q--){if(!(n.calculatedFields[q] in s)||s[n.calculatedFields[q]]===void (0)){t={};t[n.calculatedFields[q]]=n.originalSpec.getInitialCalculatedState.call(p,s,u)[n.calculatedFields[q]];if(t[n.calculatedFields[q]]!==void (0)){s=k(s,t)}}}}if(n.originalSpec.validateState){s=k(s,n.originalSpec.validateState.call(p,s,u))}if(o){Object.defineProperty(p,"context",{configurable:true,enumerable:true,set:function(w){this.setState=function(x,y){return m.bind(w).call(w,k(this.state,x),this.state,y)}.bind(this);delete this.context}})}Object.defineProperty(p,"state",{configurable:false,enumerable:false,writable:false,value:s});if(!o){Object.freeze(p)}return p};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(q,r,u){var v;var t;q=k(q,r);u=u||{};u=("state" in u)?u.state:u;if(!("getInitialState" in n.proto)){n.proto.getInitialState=function(){return l()}}else{v=n.proto.getInitialState;n.proto.getInitialState=function(){return l(v.call(this))}}var o=Object.create(n.proto,n.descriptor);Object.defineProperty(o,"state",{configurable:true,enumerable:false,writable:true,value:q});q=k(q,o);if(!!n.originalSpec.getInitialCalculatedState){for(var p=n.calculatedFields.length-1;p>=0;p--){if(!(n.calculatedFields[p] in q)||q[n.calculatedFields[p]]===void (0)){t={};t[n.calculatedFields[p]]=n.originalSpec.getInitialCalculatedState.call(o,q,u)[n.calculatedFields[p]];if(t[n.calculatedFields[p]]!==void (0)){q=k(q,t)}}}}if(n.originalSpec.validateState){q=k(q,n.originalSpec.validateState.call(o,q,u))}Object.defineProperty(o,"state",{configurable:false,enumerable:false,writable:false,value:q});Object.keys(o).forEach(function(w){if(Object.prototype.toString.call(this[w])==="[object Object]"&&("context" in this[w])){this[w].context=this;Object.freeze(this[w])}else{if(Object.prototype.toString.call(this[w])==="[object Array]"){Object.freeze(this[w])}}}.bind(o));for(var s in r){if(r.hasOwnProperty(s)&&s[0]!=="_"){Object.defineProperty(o,s,{configurable:false,enumerable:false,writable:false,value:r[s]})}}Object.freeze(q);return o};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.stateChangedHandler,this.props.disableUndo);return{applicationDataContext:k}}};i.exports=g},{"./core":2}],8:[function(h,g,f){var e={getDescriptor:function(){var l={};var k=this.prototype;var i=[];for(var j in this.originalSpec){if(this.originalSpec.hasOwnProperty(j)){if("get" in this.originalSpec[j]||"set" in this.originalSpec[j]){if("calculated" in this.originalSpec[j]){l[j]=e.extend(this.originalSpec[j]);l[j].enumerable=!this.originalSpec[j].calculated;delete l[j].calculated;i.push(j)}else{if(!("enumerable" in this.originalSpec[j])){this.originalSpec[j].enumerable=true;l[j]=this.originalSpec[j]}else{l[j]=this.originalSpec[j]}}}else{k[j]=this.originalSpec[j]}}}if(!("extend" in k)){k.extend=e.extend}return{descriptor:l,proto:k,originalSpec:this.originalSpec||{},calculatedFields:i}},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(k,p,u,y){if(typeof u!=="function"){throw new TypeError()}var x,w={},j={},v,n={},q,t=false;y===void (0)?false:y;var o=function(C,G,E){var H=false,F,B;G=G||{};if(C===void (0)){B=true;C={}}var D=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=C[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 A in q){if(q.hasOwnProperty(A)){F=D(q[A]);if(B){C[A]=new j[A](C[A],F,G[A]).getInitialState()}else{C[A]=new j[A](C[A],F,G[A])}if(E){if(H&&E.subscribers.indexOf(A)!==-1){F=D(q[E.name]);C[E.name]=new j[E.name](C[E.name],F,G[E.name])}H=H?H:A===E.name}}}return C};var m=function(C,E,M,I){var P={},L={},O=void (0),J,H,N,K=false;I===void (0)?false:I;if(!I&&(E===void (0)||E===null||Object.keys(E).length===0)){return}var G=!!E?Object.getPrototypeOf(E).constructor.classType==="DomainModel":false;if(G){P=i(E);L=E.previousState;K=true}else{if(C in n){J=Object.keys(E);H=J.length;N={};for(var F=0;F<H;F++){if(n[C][J[F]]){N[n[C][J[F]]]=true}}O={};O.name=C;O.subscribers=Object.keys(N);O=!!O.subscribers.length?O:void (0)}if(C!==k){P[C]=E;P=i(w.state,P)}else{if(I){P=i(o(),E)}else{P=i(w.state,E)}}L=t?w.previousState:w;P=o(P,w.state,O)}L=L||{};Object.freeze(L);w=new x(P,L,y);if(!!w.validateState&&!K&&!t){var B=w.validateState(w.state,w.previousState);var A=Object.keys(B);for(var D=A.length-1;D>=0;D--){if(Object.prototype.toString.call(B[A[D]])!=="[object Object]"&&Object.prototype.toString.call(B[A[D]])!=="[object Array]"&&B[A[D]]!==w.state[A[D]]){t=true;w.setState(i(w.state,B));t=false;break}}}if(!t){Object.freeze(w);Object.freeze(w.state);u(w,C,M);return w}};x=p.call(this,m.bind(this,k));var z=new x({},{},y);q=z.dataContexts();for(var l in q){if(q.hasOwnProperty(l)){j[l]=q[l].viewModel.call(this,m.bind(this,l));if("dependsOn" in q[l]){for(var r=0,s=q[l].dependsOn.length;r<s;r++){v=q[l].dependsOn[r].property.split(".");if(v.length>1){n[v[0]]=n[v[0]]||{};n[v[0]][v[1]]=n[v[0]][v[1]]||[];if(n[v[0]][v[1]].indexOf(l)===-1){n[v[0]][v[1]].push(l)}}}}}}return z.getInitialState()}},{"./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(n){var o=g.call(this);o.proto.setState=n;var m=function(p,q){return o.proto.setState(p,q,true)};var l=function(t,v,p){var w;var u;t=t||{};v=v||{};if(!("getInitialState" in o.proto)){o.proto.getInitialState=function(){return m()}}else{w=o.proto.getInitialState;o.proto.getInitialState=function(){return m(w.call(this))}}var r=Object.create(o.proto,o.descriptor);Object.defineProperty(r,"state",{configurable:true,enumerable:false,writable:true,value:t});t=k(t,r);if(!!o.originalSpec.getInitialCalculatedState){for(var s=o.calculatedFields.length-1;s>=0;s--){if(!(o.calculatedFields[s] in t)||t[o.calculatedFields[s]]===void (0)){u={};u[o.calculatedFields[s]]=o.originalSpec.getInitialCalculatedState.call(r,t,v)[o.calculatedFields[s]];if(u[o.calculatedFields[s]]!==void (0)){t=k(t,u)}}}}if(!p&&!!Object.keys(v).length){Object.defineProperty(t,"previousState",{configurable:false,enumerable:false,writable:false,value:v})}Object.defineProperty(t,"state",{configurable:false,enumerable:false,writable:false,value:k(t)});for(var q in o.descriptor){if(o.descriptor.hasOwnProperty(q)){Object.defineProperty(t,q,o.descriptor[q])}}t.__proto__=r.__proto__;return t};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(s,u,o){var p=Object.create(n.proto,n.descriptor);var v=arguments.length;var r=typeof Array.prototype.slice.call(arguments,-1)[0]==="boolean";var t;if(v===0){s={};u={};o=true}else{if(v===1){if(r){o=s;s={};u={}}else{u=s;o=true}}else{if(v===2){if(r){o=u;u=s}else{o=true}}}}s=("state" in s)?s.state:s;u=("state" in u)?u.state:u;Object.defineProperty(p,"state",{configurable:true,enumerable:false,writable:true,value:s});s=k(s,p);if(!!n.originalSpec.getInitialCalculatedState){for(var q=n.calculatedFields.length-1;q>=0;q--){if(!(n.calculatedFields[q] in s)||s[n.calculatedFields[q]]===void (0)){t={};t[n.calculatedFields[q]]=n.originalSpec.getInitialCalculatedState.call(p,s,u)[n.calculatedFields[q]];if(t[n.calculatedFields[q]]!==void (0)){s=k(s,t)}}}}if(n.originalSpec.validateState){s=k(s,n.originalSpec.validateState.call(p,s,u))}if(o){Object.defineProperty(p,"context",{configurable:true,enumerable:true,set:function(w){this.setState=function(x,y){return m.bind(w).call(w,k(this.state,x),this.state,y)}.bind(this);delete this.context}})}Object.defineProperty(p,"state",{configurable:false,enumerable:false,writable:false,value:s});Object.keys(p).forEach(function(w){if(Object.prototype.toString.call(this[w])==="[object Object]"||Object.prototype.toString.call(this[w])==="[object Array]"){Object.freeze(this[w])}}.bind(p));if(!o){Object.freeze(p)}return p};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(q,r,u){var v;var t;q=k(q,r);u=u||{};u=("state" in u)?u.state:u;if(!("getInitialState" in n.proto)){n.proto.getInitialState=function(){return l()}}else{v=n.proto.getInitialState;n.proto.getInitialState=function(){return l(v.call(this))}}var o=Object.create(n.proto,n.descriptor);Object.defineProperty(o,"state",{configurable:true,enumerable:false,writable:true,value:q});q=k(q,o);if(!!n.originalSpec.getInitialCalculatedState){for(var p=n.calculatedFields.length-1;p>=0;p--){if(!(n.calculatedFields[p] in q)||q[n.calculatedFields[p]]===void (0)){t={};t[n.calculatedFields[p]]=n.originalSpec.getInitialCalculatedState.call(o,q,u)[n.calculatedFields[p]];if(t[n.calculatedFields[p]]!==void (0)){q=k(q,t)}}}}if(n.originalSpec.validateState){q=k(q,n.originalSpec.validateState.call(o,q,u))}Object.defineProperty(o,"state",{configurable:false,enumerable:false,writable:false,value:q});Object.keys(o).forEach(function(w){if(Object.prototype.toString.call(this[w])==="[object Object]"&&("context" in this[w])){this[w].context=this;Object.freeze(this[w])}else{if(Object.prototype.toString.call(this[w])==="[object Array]"){Object.freeze(this[w])}}}.bind(o));for(var s in r){if(r.hasOwnProperty(s)&&s[0]!=="_"){Object.defineProperty(o,s,{configurable:false,enumerable:false,writable:false,value:r[s]})}}Object.freeze(q);return Object.freeze(o)};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.stateChangedHandler,this.props.disableUndo);return{applicationDataContext:k}}};i.exports=g},{"./core":2}],8:[function(h,g,f){var e={getDescriptor:function(){var l={};var k=this.prototype;var i=[];for(var j in this.originalSpec){if(this.originalSpec.hasOwnProperty(j)){if("get" in this.originalSpec[j]||"set" in this.originalSpec[j]){if("calculated" in this.originalSpec[j]){l[j]=e.extend(this.originalSpec[j]);l[j].enumerable=!this.originalSpec[j].calculated;delete l[j].calculated;i.push(j)}else{if(!("enumerable" in this.originalSpec[j])){this.originalSpec[j].enumerable=true;l[j]=this.originalSpec[j]}else{l[j]=this.originalSpec[j]}}}else{k[j]=this.originalSpec[j]}}}if(!("extend" in k)){k.extend=e.extend}return{descriptor:l,proto:k,originalSpec:this.originalSpec||{},calculatedFields:i}},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)});

@@ -9,2 +9,3 @@ /*jshint unused: vars */

//run once
getInitialState: function(){ //optional

@@ -15,2 +16,3 @@ return {

},
//runs to initialize calculated fields
getInitialCalculatedState: function(nextState, prevState){

@@ -21,3 +23,5 @@ return {

},
validateState: function(nextState, prevState){
//runs last every time transition to new State (after all ViewModels have been updated)
getValidState: function(nextState, prevState){
if(!!nextState.hobbies.selected){

@@ -34,2 +38,8 @@ return {busy: true};

personCount: {
get: function(){
return this.persons ? this.persons.collection.length : 0;
}
},
busy: {

@@ -40,5 +50,2 @@ calculated: true,

},
// set: function(newValue){
// this.setState({'busy': newValue });
// }
},

@@ -54,3 +61,9 @@

},
//dataContext keys define the dataContext names that will appear in
//the View. viewModel refer to the ViewModels and
//dependsOn will enable props to be transfered to other ViewModels.
//if alias is supplied that prop name will appear in ViewModel state
//otherwise it will appear concatenated by '$' i.e. hobbies$selected
//if you would like dependency prop to not appear in the View, supply
//and alias with a preceding underscore i.e. alias: _busy
dataContexts: function(){

@@ -57,0 +70,0 @@ return {

@@ -39,4 +39,5 @@ /*jshint unused: false */

var DOB = new Date(dob);
var ageDate = new Date(Date.now() - DOB.getTime()); // miliseconds from epoch
return Math.abs(ageDate.getFullYear() - 1970) + ' years old';
var ageDate = new Date(Date.now() - DOB.getTime()); // miliseconds from
var age = Math.abs(ageDate.getFullYear() - 1970);
return Number.isNaN(age) ? 'Enter your Birthday' : age + ' years old';
},

@@ -76,4 +77,4 @@

enumerable: false, //calculated fields should set enumerable to false
//calculated: true, //Only set this if you getInitialCalculatedState
//otherwise you must set enumerable to false - one or the other
//calculated: true, //Only set this if you use getInitialCalculatedState
//otherwise set enumerable to false - one or the other
get: function(){

@@ -117,2 +118,5 @@ if(this.lastName === void(0)){

}
if(newValue.length === 0){
nextState.age = 'C\'mon. When\'s your Birthday?';
}
nextState.dob = newValue;

@@ -119,0 +123,0 @@ this.setState(nextState);

@@ -35,3 +35,3 @@ /*jshint unused: false */

hobbies: {
enumerable: false,
enumerable: false, //false because its not calculated but is supplied externally
get: function(){

@@ -41,4 +41,5 @@ return this.state._selectedPerson.hobbies;

},
validateState: function(nextState, prevState){
//runs everytime transition to state occurs
getValidState: function(nextState, prevState){
return {

@@ -50,2 +51,3 @@ selected: this.resetSelected(nextState, prevState),

busyText: {
enumerable: false, //false because its not calculated but is supplied externally
get: function(){

@@ -52,0 +54,0 @@ return this.state._busy ? 'Im Busy! Go away...' : 'Not doing too much.';

@@ -9,3 +9,2 @@ /*jshint unused: false */

select: function(id){
console.log(this);
var nextState = {};

@@ -56,3 +55,4 @@ nextState.collection = this.collection.map(function(person){

},
//runs once to initialize
getInitialState: function(){

@@ -59,0 +59,0 @@ var nextState = {};

@@ -18,3 +18,15 @@ /**

console.log(this.state.applicationDataContext);
/*console.log(Object.isFrozen(this.state.applicationDataContext.previousState || {}));
console.log(Object.isFrozen(this.state.applicationDataContext));
console.log(Object.isFrozen(this.state.applicationDataContext.state));
console.log(Object.isFrozen(this.state.applicationDataContext.persons));
console.log(Object.isFrozen(this.state.applicationDataContext.persons.collection));
console.log(Object.isFrozen(this.state.applicationDataContext.persons.selected));
console.log(Object.isFrozen(this.state.applicationDataContext.persons.selected.hobbies));
console.log(Object.isFrozen(this.state.applicationDataContext.persons.state));
console.log(Object.isFrozen(this.state.applicationDataContext.persons.state.collection));
console.log(Object.isFrozen(this.state.applicationDataContext.persons.state.collection[1]));
console.log(Object.isFrozen(this.state.applicationDataContext.persons.state.collection[1].hobbies));
console.log(Object.isFrozen(this.state.applicationDataContext.hobbies.state._selectedPerson));*/
return (

@@ -21,0 +33,0 @@ <div>

@@ -28,2 +28,3 @@ /**

var onlineBtnClass = this.props.appContext.online ? "btn btn-success": "btn btn-danger";
var noOfPeople = this.props.appContext.personCount;
return (

@@ -42,6 +43,8 @@ <nav className="navbar navbar-default" role="navigation">

</button>
<a className="navbar-brand" href="#">IMVVM Demo Application</a>
<a className="navbar-brand" href="#">
IMVVM Demo has {noOfPeople} {noOfPeople === 1 ? "person" : "people"}
</a>
</div>
<div ref="menu" className="collapse navbar-collapse">
<div ref="menu" className="collapse navbar-collapse pull-right">
<form className="navbar-form navbar-left" role="search">

@@ -56,2 +59,3 @@ <button onClick={this.undo} className="btn btn-default">

</div>
</div>

@@ -58,0 +62,0 @@ </nav>

@@ -5,3 +5,3 @@ 'use strict';

getData: function() {
return [{id:'1', firstName:'Frank', lastName: "Smith", gender:'male', dob:'1980-03-03', occupation:'dentist', hobbies: ['reading', 'golf', 'computer programming']},
return [{id:'1', firstName:'Frank', lastName: "Smith", gender:'male', dob:'1980-03-03', occupation:'dentist', hobbies: ['reading', 'golfing', 'computer programming']},
{id:'2', firstName:'Lisa', lastName: "Jones", gender:'female', dob:'1985-02-22', occupation:'accountant', hobbies: ['reading']},

@@ -8,0 +8,0 @@ { firstName: "John", lastName: "Citizen", gender:'male', dob:'1975-12-11', occupation:'unemployed', hobbies: ['watching TV']}];

{
"name": "imvvm",
"description": "Immutable MVVM for React",
"version": "0.4.1-alpha",
"version": "0.4.2-alpha",
"keywords": [

@@ -6,0 +6,0 @@ "imvvm",

@@ -147,4 +147,4 @@

thisAppState = new ApplicationDataContext(nextState, prevState, disableUndo);
if(!!thisAppState.validateState && !rollback && !reprocessing) {
var validationObj = thisAppState.validateState(thisAppState.state, thisAppState.previousState);
if(!!thisAppState.getValidState && !rollback && !reprocessing) {
var validationObj = thisAppState.getValidState(thisAppState.state, thisAppState.previousState);
var validationKeys = Object.keys(validationObj);

@@ -166,2 +166,3 @@ for (var keyIdx = validationKeys.length - 1; keyIdx >= 0; keyIdx--) {

Object.freeze(thisAppState);
Object.freeze(thisAppState.state);
stateChangedHandler(thisAppState, caller, callback);

@@ -168,0 +169,0 @@ return thisAppState;

@@ -12,3 +12,3 @@

var DataContext = function(initState, callback){
var initialize = function(initState, callback){
return desc.proto.setState(initState, callback, true);

@@ -25,3 +25,3 @@ }

desc.proto.getInitialState = function(){
return DataContext();
return initialize();
}

@@ -31,3 +31,3 @@ } else {

desc.proto.getInitialState = function(){
return DataContext(initFunc.call(this));
return initialize(initFunc.call(this));
}

@@ -34,0 +34,0 @@ }

@@ -67,5 +67,5 @@

//runs everytime
if(desc.originalSpec.validateState){
if(desc.originalSpec.getValidState){
nextState = extend(nextState,
desc.originalSpec.validateState.call(model, nextState, prevState));
desc.originalSpec.getValidState.call(model, nextState, prevState));
}

@@ -95,2 +95,9 @@

Object.keys(model).forEach(function(key){
if(Object.prototype.toString.call(this[key]) === '[object Object]' ||
Object.prototype.toString.call(this[key]) === '[object Array]'){
Object.freeze(this[key]);
}
}.bind(model));
if(!withContext){

@@ -97,0 +104,0 @@ Object.freeze(model);

@@ -58,5 +58,5 @@

//runs everytime
if(desc.originalSpec.validateState){
if(desc.originalSpec.getValidState){
nextState = extend(nextState,
desc.originalSpec.validateState.call(model, nextState, prevState));
desc.originalSpec.getValidState.call(model, nextState, prevState));
}

@@ -94,3 +94,3 @@

Object.freeze(nextState);
return model;
return Object.freeze(model);

@@ -97,0 +97,0 @@ };

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