New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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.7.0 to 0.7.1

2

bower.json
{
"name": "imvvm",
"version": "0.7.0",
"version": "0.7.1",
"homepage": "https://github.com/entrendipity/imvvm",

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

@@ -27,2 +27,10 @@ ## 0.6.17

## 0.7.1
- callbacks return domainDataContext
- rename `undo` to `revert`
- rename `redo` to `advance`
- rename `canUndo` to `canRevert`
- rename `canRedo` to `canAdvance`

@@ -33,3 +33,4 @@ !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){

watchedDataContext,
link;
link,
calledBack = false;

@@ -93,3 +94,3 @@ var appStateChangedHandler = function(caller, newState, newAppState, callback) {

appState = new ApplicationDataContext(nextState, prevState, redoState, enableUndo);
callback();
callback(appState);
return;

@@ -113,7 +114,2 @@ }

if(typeof callback === 'function'){
callback();
return;
}
transientStateKeysLen = transientStateKeys.length - 1;

@@ -223,3 +219,3 @@

prevState = appState;
prevState = calledBack ? appState.previousState : appState;

@@ -235,5 +231,11 @@ }

Object.freeze(appState.state);
if(typeof callback === 'function'){
calledBack = true;
callback(appState);
return;
}
//All the work is done! -> Notify the View
stateChangedHandler(appState);
calledBack = false;
transientState = {};

@@ -468,8 +470,8 @@ processedState = {};

desc.proto.undo = function(){
desc.proto.revert = function(){
this.setState(this.previousState, !!this.previousState ? this : void(0));
};
desc.proto.redo = function(){
if(this.canRedo){
desc.proto.advance = function(){
if(this.canAdvance){
this.setState(this.nextState, this.nextState.nextState);

@@ -493,3 +495,3 @@ }

});
Object.defineProperty(domainModel, 'canUndo', {
Object.defineProperty(domainModel, 'canRevert', {
configurable: false,

@@ -501,3 +503,3 @@ enumerable: false,

} else {
Object.defineProperty(domainModel, 'canUndo', {
Object.defineProperty(domainModel, 'canRevert', {
configurable: false,

@@ -516,3 +518,3 @@ enumerable: false,

});
Object.defineProperty(domainModel, 'canRedo', {
Object.defineProperty(domainModel, 'canAdvance', {
configurable: false,

@@ -524,3 +526,3 @@ enumerable: false,

} else {
Object.defineProperty(domainModel, 'canRedo', {
Object.defineProperty(domainModel, 'canAdvance', {
configurable: false,

@@ -527,0 +529,0 @@ enumerable: false,

@@ -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,m,v,k){if(typeof v!=="function"){throw new TypeError("stateChangedHandler must be a function!")}k===void (0)?true:k;var A,u={},r={},B,j={},y={},t,q={},o={},x,w,z,s,p;var n=function(E,J,L,Q){var S={},O=void (0),G=void (0),M,H,F,D,I,K=[],P,N,C,R;if(typeof L==="function"){Q=L;L={}}J=J||{};M=Object.keys(J);if(Object.getPrototypeOf(J).constructor.classType==="DomainViewModel"){S=i(J);O=J.previousState;G=L;for(D in B){S[D]=new r[D](S[D])}for(D in B){if(B.hasOwnProperty(D)){for(I in j[D]){if(j[D].hasOwnProperty(I)){S[D].state[j[D][I]]=(I in B)?i(S[I].state):S[I]}}}}if(typeof Q==="function"){u=new A(S,O,G,k);Q();return}}else{if(!!M.length){if(E===l){S=i(J)}else{S[E]=i(J)}}q=i(S,q,L);transientStateKeys=Object.keys(q);if(transientStateKeys.length===0){return}if(typeof Q==="function"){Q();return}F=transientStateKeys.length-1;for(H=F;H>=0;H--){if(transientStateKeys[H] in B){S[transientStateKeys[H]]=i(u[transientStateKeys[H]],q[transientStateKeys[H]]);S[transientStateKeys[H]]=new r[transientStateKeys[H]](S[transientStateKeys[H]])}else{S[transientStateKeys[H]]=q[transientStateKeys[H]]}}o=i(o,S);S=i(u,o);q={};for(H=F;H>=0;H--){if(transientStateKeys[H] in y){for(N in y[transientStateKeys[H]]){if(y[transientStateKeys[H]].hasOwnProperty(N)){if(M.indexOf(N)!==-1){C=y[transientStateKeys[H]][N];for(R in C){if(C.hasOwnProperty(R)){if(R in j){for(D in j[R]){if(j[R].hasOwnProperty(D)){S[R].state[j[R][D]]=(D in B)?i(S[D].state):S[D]}if(D in j){for(dataContext2 in j[D]){if(j[D].hasOwnProperty(dataContext2)){S[D].state[j[D][dataContext2]]=(dataContext2 in B)?i(S[dataContext2].state):S[dataContext2]}}}}}q=i(q,C[R].call(u[R],S[transientStateKeys[H]][N],u[transientStateKeys[H]][N],N,transientStateKeys[H]))}}}}}}}if(!!Object.keys(q).length){n(void (0),{},q);return}K=Object.keys(o);P=K.length-1;for(H=P;H>=0;H--){if(E===l){if(K[H] in j[l]){for(D in j[l][K[H]]){if(j[l][K[H]].hasOwnProperty(D)){S[D].state[j[l][K[H]][D]]=S[K[H]]}if(D in j){for(dataContext2 in j[D]){if(j[D].hasOwnProperty(dataContext2)){S[D].state[j[D][dataContext2]]=(dataContext2 in B)?i(S[dataContext2].state):S[dataContext2]}}}}}}else{if(K[H] in j){for(D in j[K[H]]){if(j[K[H]].hasOwnProperty(D)){S[K[H]].state[j[K[H]][D]]=(D in B)?i(S[D].state):S[D]}if(D in j){for(dataContext2 in j[D]){if(j[D].hasOwnProperty(dataContext2)){S[D].state[j[D][dataContext2]]=(dataContext2 in B)?i(S[dataContext2].state):S[dataContext2]}}}}}}}O=u}if(!!O){Object.freeze(O)}u=new A(S,O,G,k);Object.freeze(u);Object.freeze(u.state);v(u);q={};o={}};A=m.call(this,n.bind(this,l));u=new A(void (0),void (0),void (0),k);u.state=u.state||{};B=u.constructor.originalSpec.getDomainDataContext();delete u.constructor.originalSpec.getDomainDataContext;for(t in B){if(B.hasOwnProperty(t)){r[t]=B[t].call(this,n.bind(this,t));u.state[t]=new r[t](u.state[t],true)}}for(t in B){if(B.hasOwnProperty(t)){if("getWatchedState" in u[t].constructor.originalSpec){x=u[t].constructor.originalSpec.getWatchedState();for(w in x){if(x.hasOwnProperty(w)){if(w in B||w in u.state){if("alias" in x[w]){if(!(t in j)){j[t]={}}j[t][w]=x[w].alias;if(!(w in B)){if(!(l in j)){j[l]={}}if(!(t in j[l])){j[l][w]={}}j[l][w][t]=x[w].alias}}for(z in x[w].fields){if(x[w].fields.hasOwnProperty(z)){if(w in B){s={};if(!(w in y)){y[w]={}}s[z]={};s[z][t]=x[w].fields[z];y[w]=s}}}}}}}}}for(t in B){if(B.hasOwnProperty(t)){for(p in j[t]){if(j[t].hasOwnProperty(p)){u[t].state[j[t][p]]=(p in B)?i(u[p].state):u[p]}}}}for(t in B){if(B.hasOwnProperty(t)){u.state[t]=new r[t](u.state[t],true)}}u=new A(u,void (0),void (0),k);Object.freeze(u.state);Object.freeze(u);return u}},{"./utils":8}],3:[function(f,g,j){var k=f("./imvvmModel");var p=f("./imvvmViewModel");var i=f("./imvvmDomainViewModel");var r=f("./mixin");var q=f("./utils");var o=q.extend;var m=q.mixInto;var l=function(){};var h=function(){};var n=function(){};m(l,k.Mixin);m(h,p.Mixin);m(n,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;w.getDescriptor=function(){var E={},D=this.prototype,B={},z=[],A={},C;if("__processedSpec__" in this.originalSpec){return this.originalSpec.__processedSpec__}for(C in this.originalSpec){if(this.originalSpec.hasOwnProperty(C)){if("get" in this.originalSpec[C]||"set" in this.originalSpec[C]){this.originalSpec[C].enumerable=true;if("viewModel" in this.originalSpec[C]){B[C]=this.originalSpec[C].viewModel;delete this.originalSpec[C].viewModel;delete this.originalSpec[C].set}else{if("aliasFor" in this.originalSpec[C]){A[this.originalSpec[C].aliasFor]=C;delete this.originalSpec[C].aliasFor}if("kind" in this.originalSpec[C]){if(this.originalSpec[C].kind==="pseudo"){this.originalSpec[C].enumerable=false}else{if(this.originalSpec[C].kind==="instance"||this.originalSpec[C].kind==="array"){z.push({fieldName:C,kind:this.originalSpec[C].kind})}else{throw new TypeError('"'+this.originalSpec[C].kind+'" is not a valid "kind" value. Valid values are "pseudo","instance" and "array". Please review field "'+C+'".')}}delete this.originalSpec[C].kind}}E[C]=this.originalSpec[C]}else{if(C!=="getInitialState"&&C!=="getWatchedState"){D[C]=this.originalSpec[C]}}}}if(!!Object.keys(B).length){this.originalSpec.getDomainDataContext=function(){return B}}this.originalSpec.__processedSpec__={descriptor:E,proto:D,originalSpec:this.originalSpec||{},freezeFields:z,aliases:A};return this.originalSpec.__processedSpec__};return w}};var s={createModel:e.createClass.bind(this,l,"Model"),createViewModel:e.createClass.bind(this,h,"ViewModel"),createDomainViewModel:e.createClass.bind(this,n,"DomainViewModel"),mixin:r,extend:o};g.exports=s},{"./imvvmDomainViewModel":4,"./imvvmModel":5,"./imvvmViewModel":6,"./mixin":7,"./utils":8}],4:[function(i,h,g){var f=i("./utils");var j=f.extend;var e={Mixin:{construct:function(l){var m=this.getDescriptor();m.proto.setState=l;m.proto.undo=function(){this.setState(this.previousState,!!this.previousState?this:void (0))};m.proto.redo=function(){if(this.canRedo){this.setState(this.nextState,this.nextState.nextState)}};var k=function(p,t,o,s){var r=m.freezeFields,q=Object.create(m.proto,m.descriptor),n;if(!!s){if(!!t){Object.defineProperty(q,"previousState",{configurable:false,enumerable:false,writable:false,value:t});Object.defineProperty(q,"canUndo",{configurable:false,enumerable:false,writable:false,value:true})}else{Object.defineProperty(q,"canUndo",{configurable:false,enumerable:false,writable:false,value:false})}if(!!o&&"state" in o){Object.defineProperty(q,"nextState",{configurable:false,enumerable:false,writable:false,value:o});Object.defineProperty(q,"canRedo",{configurable:false,enumerable:false,writable:false,value:true})}else{Object.defineProperty(q,"canRedo",{configurable:false,enumerable:false,writable:false,value:false})}}if(p===void (0)){p=("getInitialState" in m.originalSpec)?m.originalSpec.getInitialState.call(q):{}}else{if("state" in p){delete p.state;Object.defineProperty(q,"state",{configurable:true,enumerable:false,writable:true,value:p});p=j(p,q)}}for(n=r.length-1;n>=0;n--){if(r[n].kind==="array"){p[r[n].fieldName]=p[r[n].fieldName]||[];Object.freeze(p[r[n].fieldName])}else{throw new TypeError('kind:"instance" can only be specified in a ViewModel.')}}Object.defineProperty(q,"state",{configurable:false,enumerable:false,writable:false,value:p});return q};return k}}};h.exports=e},{"./utils":8}],5:[function(h,g,f){var e=h("./utils");var j=e.extend;var i={Mixin:{construct:function(l){var m=this.getDescriptor();var k=function(r,p,n){var s=m.freezeFields,q,o=Object.create(m.proto,m.descriptor);if(r===void (0)){n=true}else{if(typeof r==="boolean"){n=r;r=void (0)}else{if(typeof p==="boolean"){n=p;p=void (0)}}}r=j(r,p);Object.defineProperty(o,"state",{configurable:true,enumerable:false,writable:true,value:r});r=j(r,o);if(n){for(var t in m.aliases){if(m.aliases.hasOwnProperty(t)&&t in r){r[m.aliases[t]]=r[t];delete r[t]}}if("getInitialState" in m.originalSpec){r=j(r,m.originalSpec.getInitialState.call(o))}}for(q=s.length-1;q>=0;q--){if(s[q].kind==="array"){r[s[q].fieldName]=r[s[q].fieldName]||[];Object.freeze(r[s[q].fieldName])}else{throw new TypeError('kind:"instance" can only be specified in a ViewModel.')}}Object.defineProperty(o,"state",{configurable:false,enumerable:false,writable:false,value:r});o.__stateChangedHandler=(function(){return l})();return Object.freeze(o)};return k}}};g.exports=i},{"./utils":8}],6:[function(i,h,g){var f=i("./utils");var j=f.extend;var e={Mixin:{construct:function(l){var m=this.getDescriptor(this);m.proto.setState=l;var k=function(r,n){r=r||{};r=("state" in r?r.state:r);var s=m.freezeFields,q,p=Object.create(m.proto,m.descriptor),t,o;Object.defineProperty(p,"state",{configurable:true,enumerable:false,writable:true,value:r});if(n){r=("getInitialState" in m.originalSpec)?j(r,m.originalSpec.getInitialState.call(p)):r;Object.defineProperty(p,"state",{configurable:true,enumerable:false,writable:true,value:r})}for(q=s.length-1;q>=0;q--){if(s[q].kind==="instance"){if(p[s[q].fieldName]){t=p[s[q].fieldName].constructor.originalSpec.__processedSpec__;o=Object.create(t.proto,t.descriptor);o.__stateChangedHandler=(function(u){return p[u].__stateChangedHandler})(s[q].fieldName);Object.defineProperty(o,"state",{configurable:true,enumerable:false,writable:true,value:p[s[q].fieldName].state});o.__proto__.setState=function(u,v){this.__stateChangedHandler.call(p,j(this.state,u),v)};Object.freeze(p[s[q].fieldName])}}else{r[s[q].fieldName]=r[s[q].fieldName]||[];Object.freeze(r[s[q].fieldName])}}Object.defineProperty(p,"state",{configurable:false,enumerable:false,writable:false,value:r});return Object.freeze(p)};return k}}};h.exports=e},{"./utils":8}],7:[function(j,i,h){var f=j("./core");var e="__IMVVM__";var g={stateChangedHandler:function(k){this.setState({domainDataContext:k})},getInitialState:function(){var k=f.getInitialState(e,this.props.domainModel,this.stateChangedHandler,this.props.enableUndo);return{domainDataContext:k}}};i.exports=g},{"./core":2}],8:[function(h,g,f){var e={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,n,w,l){if(typeof w!=="function"){throw new TypeError("stateChangedHandler must be a function!")}l===void (0)?true:l;var B,v={},s={},C,k={},z={},u,r={},p={},y,x,A,t,q,j=false;var o=function(F,K,M,R){var T={},P=void (0),H=void (0),N,I,G,E,J,L=[],Q,O,D,S;if(typeof M==="function"){R=M;M={}}K=K||{};N=Object.keys(K);if(Object.getPrototypeOf(K).constructor.classType==="DomainViewModel"){T=i(K);P=K.previousState;H=M;for(E in C){T[E]=new s[E](T[E])}for(E in C){if(C.hasOwnProperty(E)){for(J in k[E]){if(k[E].hasOwnProperty(J)){T[E].state[k[E][J]]=(J in C)?i(T[J].state):T[J]}}}}if(typeof R==="function"){v=new B(T,P,H,l);R(v);return}}else{if(!!N.length){if(F===m){T=i(K)}else{T[F]=i(K)}}r=i(T,r,M);transientStateKeys=Object.keys(r);if(transientStateKeys.length===0){return}G=transientStateKeys.length-1;for(I=G;I>=0;I--){if(transientStateKeys[I] in C){T[transientStateKeys[I]]=i(v[transientStateKeys[I]],r[transientStateKeys[I]]);T[transientStateKeys[I]]=new s[transientStateKeys[I]](T[transientStateKeys[I]])}else{T[transientStateKeys[I]]=r[transientStateKeys[I]]}}p=i(p,T);T=i(v,p);r={};for(I=G;I>=0;I--){if(transientStateKeys[I] in z){for(O in z[transientStateKeys[I]]){if(z[transientStateKeys[I]].hasOwnProperty(O)){if(N.indexOf(O)!==-1){D=z[transientStateKeys[I]][O];for(S in D){if(D.hasOwnProperty(S)){if(S in k){for(E in k[S]){if(k[S].hasOwnProperty(E)){T[S].state[k[S][E]]=(E in C)?i(T[E].state):T[E]}if(E in k){for(dataContext2 in k[E]){if(k[E].hasOwnProperty(dataContext2)){T[E].state[k[E][dataContext2]]=(dataContext2 in C)?i(T[dataContext2].state):T[dataContext2]}}}}}r=i(r,D[S].call(v[S],T[transientStateKeys[I]][O],v[transientStateKeys[I]][O],O,transientStateKeys[I]))}}}}}}}if(!!Object.keys(r).length){o(void (0),{},r);return}L=Object.keys(p);Q=L.length-1;for(I=Q;I>=0;I--){if(F===m){if(L[I] in k[m]){for(E in k[m][L[I]]){if(k[m][L[I]].hasOwnProperty(E)){T[E].state[k[m][L[I]][E]]=T[L[I]]}if(E in k){for(dataContext2 in k[E]){if(k[E].hasOwnProperty(dataContext2)){T[E].state[k[E][dataContext2]]=(dataContext2 in C)?i(T[dataContext2].state):T[dataContext2]}}}}}}else{if(L[I] in k){for(E in k[L[I]]){if(k[L[I]].hasOwnProperty(E)){T[L[I]].state[k[L[I]][E]]=(E in C)?i(T[E].state):T[E]}if(E in k){for(dataContext2 in k[E]){if(k[E].hasOwnProperty(dataContext2)){T[E].state[k[E][dataContext2]]=(dataContext2 in C)?i(T[dataContext2].state):T[dataContext2]}}}}}}}P=j?v.previousState:v}if(!!P){Object.freeze(P)}v=new B(T,P,H,l);Object.freeze(v);Object.freeze(v.state);if(typeof R==="function"){j=true;R(v);return}w(v);j=false;r={};p={}};B=n.call(this,o.bind(this,m));v=new B(void (0),void (0),void (0),l);v.state=v.state||{};C=v.constructor.originalSpec.getDomainDataContext();delete v.constructor.originalSpec.getDomainDataContext;for(u in C){if(C.hasOwnProperty(u)){s[u]=C[u].call(this,o.bind(this,u));v.state[u]=new s[u](v.state[u],true)}}for(u in C){if(C.hasOwnProperty(u)){if("getWatchedState" in v[u].constructor.originalSpec){y=v[u].constructor.originalSpec.getWatchedState();for(x in y){if(y.hasOwnProperty(x)){if(x in C||x in v.state){if("alias" in y[x]){if(!(u in k)){k[u]={}}k[u][x]=y[x].alias;if(!(x in C)){if(!(m in k)){k[m]={}}if(!(u in k[m])){k[m][x]={}}k[m][x][u]=y[x].alias}}for(A in y[x].fields){if(y[x].fields.hasOwnProperty(A)){if(x in C){t={};if(!(x in z)){z[x]={}}t[A]={};t[A][u]=y[x].fields[A];z[x]=t}}}}}}}}}for(u in C){if(C.hasOwnProperty(u)){for(q in k[u]){if(k[u].hasOwnProperty(q)){v[u].state[k[u][q]]=(q in C)?i(v[q].state):v[q]}}}}for(u in C){if(C.hasOwnProperty(u)){v.state[u]=new s[u](v.state[u],true)}}v=new B(v,void (0),void (0),l);Object.freeze(v.state);Object.freeze(v);return v}},{"./utils":8}],3:[function(f,g,j){var k=f("./imvvmModel");var p=f("./imvvmViewModel");var i=f("./imvvmDomainViewModel");var r=f("./mixin");var q=f("./utils");var o=q.extend;var m=q.mixInto;var l=function(){};var h=function(){};var n=function(){};m(l,k.Mixin);m(h,p.Mixin);m(n,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;w.getDescriptor=function(){var E={},D=this.prototype,B={},z=[],A={},C;if("__processedSpec__" in this.originalSpec){return this.originalSpec.__processedSpec__}for(C in this.originalSpec){if(this.originalSpec.hasOwnProperty(C)){if("get" in this.originalSpec[C]||"set" in this.originalSpec[C]){this.originalSpec[C].enumerable=true;if("viewModel" in this.originalSpec[C]){B[C]=this.originalSpec[C].viewModel;delete this.originalSpec[C].viewModel;delete this.originalSpec[C].set}else{if("aliasFor" in this.originalSpec[C]){A[this.originalSpec[C].aliasFor]=C;delete this.originalSpec[C].aliasFor}if("kind" in this.originalSpec[C]){if(this.originalSpec[C].kind==="pseudo"){this.originalSpec[C].enumerable=false}else{if(this.originalSpec[C].kind==="instance"||this.originalSpec[C].kind==="array"){z.push({fieldName:C,kind:this.originalSpec[C].kind})}else{throw new TypeError('"'+this.originalSpec[C].kind+'" is not a valid "kind" value. Valid values are "pseudo","instance" and "array". Please review field "'+C+'".')}}delete this.originalSpec[C].kind}}E[C]=this.originalSpec[C]}else{if(C!=="getInitialState"&&C!=="getWatchedState"){D[C]=this.originalSpec[C]}}}}if(!!Object.keys(B).length){this.originalSpec.getDomainDataContext=function(){return B}}this.originalSpec.__processedSpec__={descriptor:E,proto:D,originalSpec:this.originalSpec||{},freezeFields:z,aliases:A};return this.originalSpec.__processedSpec__};return w}};var s={createModel:e.createClass.bind(this,l,"Model"),createViewModel:e.createClass.bind(this,h,"ViewModel"),createDomainViewModel:e.createClass.bind(this,n,"DomainViewModel"),mixin:r,extend:o};g.exports=s},{"./imvvmDomainViewModel":4,"./imvvmModel":5,"./imvvmViewModel":6,"./mixin":7,"./utils":8}],4:[function(i,h,g){var f=i("./utils");var j=f.extend;var e={Mixin:{construct:function(l){var m=this.getDescriptor();m.proto.setState=l;m.proto.revert=function(){this.setState(this.previousState,!!this.previousState?this:void (0))};m.proto.advance=function(){if(this.canAdvance){this.setState(this.nextState,this.nextState.nextState)}};var k=function(p,t,o,s){var r=m.freezeFields,q=Object.create(m.proto,m.descriptor),n;if(!!s){if(!!t){Object.defineProperty(q,"previousState",{configurable:false,enumerable:false,writable:false,value:t});Object.defineProperty(q,"canRevert",{configurable:false,enumerable:false,writable:false,value:true})}else{Object.defineProperty(q,"canRevert",{configurable:false,enumerable:false,writable:false,value:false})}if(!!o&&"state" in o){Object.defineProperty(q,"nextState",{configurable:false,enumerable:false,writable:false,value:o});Object.defineProperty(q,"canAdvance",{configurable:false,enumerable:false,writable:false,value:true})}else{Object.defineProperty(q,"canAdvance",{configurable:false,enumerable:false,writable:false,value:false})}}if(p===void (0)){p=("getInitialState" in m.originalSpec)?m.originalSpec.getInitialState.call(q):{}}else{if("state" in p){delete p.state;Object.defineProperty(q,"state",{configurable:true,enumerable:false,writable:true,value:p});p=j(p,q)}}for(n=r.length-1;n>=0;n--){if(r[n].kind==="array"){p[r[n].fieldName]=p[r[n].fieldName]||[];Object.freeze(p[r[n].fieldName])}else{throw new TypeError('kind:"instance" can only be specified in a ViewModel.')}}Object.defineProperty(q,"state",{configurable:false,enumerable:false,writable:false,value:p});return q};return k}}};h.exports=e},{"./utils":8}],5:[function(h,g,f){var e=h("./utils");var j=e.extend;var i={Mixin:{construct:function(l){var m=this.getDescriptor();var k=function(r,p,n){var s=m.freezeFields,q,o=Object.create(m.proto,m.descriptor);if(r===void (0)){n=true}else{if(typeof r==="boolean"){n=r;r=void (0)}else{if(typeof p==="boolean"){n=p;p=void (0)}}}r=j(r,p);Object.defineProperty(o,"state",{configurable:true,enumerable:false,writable:true,value:r});r=j(r,o);if(n){for(var t in m.aliases){if(m.aliases.hasOwnProperty(t)&&t in r){r[m.aliases[t]]=r[t];delete r[t]}}if("getInitialState" in m.originalSpec){r=j(r,m.originalSpec.getInitialState.call(o))}}for(q=s.length-1;q>=0;q--){if(s[q].kind==="array"){r[s[q].fieldName]=r[s[q].fieldName]||[];Object.freeze(r[s[q].fieldName])}else{throw new TypeError('kind:"instance" can only be specified in a ViewModel.')}}Object.defineProperty(o,"state",{configurable:false,enumerable:false,writable:false,value:r});o.__stateChangedHandler=(function(){return l})();return Object.freeze(o)};return k}}};g.exports=i},{"./utils":8}],6:[function(i,h,g){var f=i("./utils");var j=f.extend;var e={Mixin:{construct:function(l){var m=this.getDescriptor(this);m.proto.setState=l;var k=function(r,n){r=r||{};r=("state" in r?r.state:r);var s=m.freezeFields,q,p=Object.create(m.proto,m.descriptor),t,o;Object.defineProperty(p,"state",{configurable:true,enumerable:false,writable:true,value:r});if(n){r=("getInitialState" in m.originalSpec)?j(r,m.originalSpec.getInitialState.call(p)):r;Object.defineProperty(p,"state",{configurable:true,enumerable:false,writable:true,value:r})}for(q=s.length-1;q>=0;q--){if(s[q].kind==="instance"){if(p[s[q].fieldName]){t=p[s[q].fieldName].constructor.originalSpec.__processedSpec__;o=Object.create(t.proto,t.descriptor);o.__stateChangedHandler=(function(u){return p[u].__stateChangedHandler})(s[q].fieldName);Object.defineProperty(o,"state",{configurable:true,enumerable:false,writable:true,value:p[s[q].fieldName].state});o.__proto__.setState=function(u,v){this.__stateChangedHandler.call(p,j(this.state,u),v)};Object.freeze(p[s[q].fieldName])}}else{r[s[q].fieldName]=r[s[q].fieldName]||[];Object.freeze(r[s[q].fieldName])}}Object.defineProperty(p,"state",{configurable:false,enumerable:false,writable:false,value:r});return Object.freeze(p)};return k}}};h.exports=e},{"./utils":8}],7:[function(j,i,h){var f=j("./core");var e="__IMVVM__";var g={stateChangedHandler:function(k){this.setState({domainDataContext:k})},getInitialState:function(){var k=f.getInitialState(e,this.props.domainModel,this.stateChangedHandler,this.props.enableUndo);return{domainDataContext:k}}};i.exports=g},{"./core":2}],8:[function(h,g,f){var e={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)});

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

e.stopPropagation();
this.props.appContext.undo();
this.props.appContext.revert();
},

@@ -24,3 +24,3 @@ redo: function(e){

e.stopPropagation();
this.props.appContext.redo();
this.props.appContext.advance();
},

@@ -56,6 +56,6 @@ toggleOnlineState: function(e){

<form className="navbar-form navbar-left" role="search">
<button onClick={this.undo} disabled={!this.props.appContext.canUndo} className="btn btn-default">
<button onClick={this.undo} disabled={!this.props.appContext.canRevert} className="btn btn-default">
Undo
</button>
<button onClick={this.redo} disabled={!this.props.appContext.canRedo} className="btn btn-default">
<button onClick={this.redo} disabled={!this.props.appContext.canAdvance} className="btn btn-default">
Redo

@@ -62,0 +62,0 @@ </button>

{
"name": "imvvm",
"description": "Immutable MVVM for React",
"version": "0.7.0",
"version": "0.7.1",
"keywords": [

@@ -6,0 +6,0 @@ "mvvm",

@@ -586,3 +586,11 @@ IMVVM

Used to do sequential setState calls.
Used to do sequential setState calls and returns latest Domain Data Context state.
___example___ ***n.b. This example is not part of the reference implementation.It demonstrates how a callback can be used. Here the callback updates an amount property on a currentTarget object, which had been selected by the calling function `selectTarget` and passed back as `returnedAppContext`. Notice that you do not need to bind to `this` using this approach.***
```javascript
handleChange: function(target, e){
this.props.appContext.positionsContext.selectTarget(target, function(returnedAppContext){
returnedAppContext.positionsContext.currentTarget.amount = Utils.unformat(e.target.value);
});
},
```

@@ -592,9 +600,9 @@ _Available in:_ DomainViewModel, ViewModel, Model

___
#####object undo()
`undo` transitions state to the previous state. Requires [`enableUndo`](#enableundo-boolean-default--false) to be `true` to enable this functionality.
#####object revert()
`revert` transitions state to the previous state. Requires [`enableUndo`](#enableundo-boolean-default--false) to be `true` to enable this functionality.
_Available in:_ DomainViewModel
___
#####object redo()
`redo` transitions state to the next state. Requires [`enableUndo`](#enableundo-boolean-default--false) to be `true` to enable this functionality.
#####object advance()
`advance` transitions state to the next state. Requires [`enableUndo`](#enableundo-boolean-default--false) to be `true` to enable this functionality.

@@ -622,6 +630,6 @@ _Available in:_ DomainViewModel

___
#####canUndo
`true` - can transition to previous state.
#####canRevert
`true` - can revert to previous state.
`false` - can not transition to previous state.
`false` - can not revert to previous state.

@@ -631,6 +639,6 @@ _Available in:_ DomainViewModel

___
#####canRedo
`true` - can revert back to next state.
#####canAdvance
`true` - can advance to next state.
`false` - can not revert back to next state.
`false` - can not advance to next state.

@@ -735,2 +743,4 @@ _Available in:_ DomainViewModel

Returns latest Domain Data Context state.
```javascript

@@ -737,0 +747,0 @@ personStateChangedHandler: function(nextState){

@@ -26,3 +26,4 @@

watchedDataContext,
link;
link,
calledBack = false;

@@ -86,3 +87,3 @@ var appStateChangedHandler = function(caller, newState, newAppState, callback) {

appState = new ApplicationDataContext(nextState, prevState, redoState, enableUndo);
callback();
callback(appState);
return;

@@ -106,7 +107,2 @@ }

if(typeof callback === 'function'){
callback();
return;
}
transientStateKeysLen = transientStateKeys.length - 1;

@@ -216,3 +212,3 @@

prevState = appState;
prevState = calledBack ? appState.previousState : appState;

@@ -228,5 +224,11 @@ }

Object.freeze(appState.state);
if(typeof callback === 'function'){
calledBack = true;
callback(appState);
return;
}
//All the work is done! -> Notify the View
stateChangedHandler(appState);
calledBack = false;
transientState = {};

@@ -233,0 +235,0 @@ processedState = {};

@@ -12,8 +12,8 @@

desc.proto.undo = function(){
desc.proto.revert = function(){
this.setState(this.previousState, !!this.previousState ? this : void(0));
};
desc.proto.redo = function(){
if(this.canRedo){
desc.proto.advance = function(){
if(this.canAdvance){
this.setState(this.nextState, this.nextState.nextState);

@@ -37,3 +37,3 @@ }

});
Object.defineProperty(domainModel, 'canUndo', {
Object.defineProperty(domainModel, 'canRevert', {
configurable: false,

@@ -45,3 +45,3 @@ enumerable: false,

} else {
Object.defineProperty(domainModel, 'canUndo', {
Object.defineProperty(domainModel, 'canRevert', {
configurable: false,

@@ -60,3 +60,3 @@ enumerable: false,

});
Object.defineProperty(domainModel, 'canRedo', {
Object.defineProperty(domainModel, 'canAdvance', {
configurable: false,

@@ -68,3 +68,3 @@ enumerable: false,

} else {
Object.defineProperty(domainModel, 'canRedo', {
Object.defineProperty(domainModel, 'canAdvance', {
configurable: false,

@@ -71,0 +71,0 @@ enumerable: false,

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