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

@ngxs/store

Package Overview
Dependencies
Maintainers
2
Versions
1360
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ngxs/store - npm Package Compare versions

Comparing version 2.0.0-dev.6461c78 to 2.0.0-dev.6c52a03

19

bundles/ngxs-store.umd.js

@@ -472,3 +472,8 @@ (function (global, factory) {

}
return this._stateStream.pipe(map.map(selector), operators.distinctUntilChanged());
return this._stateStream.pipe(map.map(selector), operators.catchError(function (err) {
if (err instanceof TypeError) {
return of.of(undefined);
}
throw err;
}), operators.distinctUntilChanged());
};

@@ -783,3 +788,3 @@ Store.prototype.selectOnce = function (selector) {

return function (target, key, descriptor) {
var metadata = target[META_KEY];
var metadata = ensureStoreMetadata(target);
if (descriptor.value !== null) {

@@ -789,3 +794,11 @@ var prev_1 = descriptor.value;

var local = getValue(state, metadata.path);
return prev_1(local);
try {
return prev_1(local);
}
catch (ex) {
if (ex instanceof TypeError) {
return undefined;
}
throw ex;
}
};

@@ -792,0 +805,0 @@ return {

2

bundles/ngxs-store.umd.min.js

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

!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("@angular/core"),require("rxjs/Subject"),require("rxjs/BehaviorSubject"),require("rxjs/Observable"),require("rxjs/operators"),require("rxjs/observable/forkJoin"),require("rxjs/operators/map"),require("rxjs/observable/fromPromise"),require("rxjs/observable/of")):"function"==typeof define&&define.amd?define("@ngxs/store",["exports","@angular/core","rxjs/Subject","rxjs/BehaviorSubject","rxjs/Observable","rxjs/operators","rxjs/observable/forkJoin","rxjs/operators/map","rxjs/observable/fromPromise","rxjs/observable/of"],r):r((t.ngxs=t.ngxs||{},t.ngxs.store={}),t.ng.core,t.Rx,t.Rx,t.Rx,t.Rx.Observable.prototype,t.Rx.Observable,t.Rx.Observable.prototype,t.Rx.Observable,t.Rx.Observable)}(this,function(t,r,e,n,u,o,a,i,c,s){"use strict";var p=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var e in r)r.hasOwnProperty(e)&&(t[e]=r[e])};function f(t,r){function e(){this.constructor=t}p(t,r),t.prototype=null===r?Object.create(r):(e.prototype=r.prototype,new e)}function m(t){var r="function"==typeof Symbol&&t[Symbol.iterator],e=0;return r?r.call(t):{next:function(){return t&&e>=t.length&&(t=void 0),{value:t&&t[e++],done:!t}}}}function l(t,r){var e="function"==typeof Symbol&&t[Symbol.iterator];if(!e)return t;var n,o,a=e.call(t),i=[];try{for(;(void 0===r||0<r--)&&!(n=a.next()).done;)i.push(n.value)}catch(s){o={error:s}}finally{try{n&&!n.done&&(e=a["return"])&&e.call(a)}finally{if(o)throw o.error}}return i}function S(){for(var t=[],r=0;r<arguments.length;r++)t=t.concat(l(arguments[r]));return t}var h=new r.InjectionToken("ROOT_STATE_TOKEN"),y=new r.InjectionToken("FEATURE_STATE_TOKEN"),j="NGXS_META",d=new r.InjectionToken("NGXS_PLUGINS");function v(t){if(!t.hasOwnProperty(j)){Object.defineProperty(t,j,{value:{name:null,actions:{},defaults:{},path:null,children:[]}})}return t[j]}function b(t){for(var r=t,e="store."+r[0],n=0,o=r.length,a=e;++n<o;)a=a+" && "+(e=e+"."+r[n]);return new Function("store","return "+a+";")}function g(t){return t.constructor.type?t.constructor.type:t.constructor.name?t.constructor.name:t.type?t.type:void 0}var _=function(t,r,e){t=Object.assign({},t);var n=r.split("."),o=n[n.length-1];return n.reduce(function(t,r){return t[r]=r===o?e:Object.assign({},t[r]),t&&t[r]},t),t},x=function(t,r){return r.split(".").reduce(function(t,r){return t&&t[r]},t)},w=function(){function t(t,r){this._injector=t,this._parentFactory=r,this._states=[]}return Object.defineProperty(t.prototype,"states",{get:function(){return this._parentFactory?this._parentFactory.states:this._states},enumerable:!0,configurable:!0}),t.prototype.add=function(t){Array.isArray(t)||(t=[t]);var e,a,n,o,i,s,r,u,c,p=(a=function(r){var t=e.find(function(t){return t===r});if(!t)throw new Error("Child state not found: "+r);if(!t[j])throw new Error("States must be decorated with @State() decorator");return t[j].name},(e=t).reduce(function(t,r){if(!r[j])throw new Error("States must be decorated with @State() decorator");var e=r[j],n=e.name,o=e.children;return t[n]=(o||[]).map(a),t},{})),f=(n=p,o=[],i={},s=function(r,e){void 0===e&&(e=[]),Array.isArray(e)||(e=[]),e.push(r),i[r]=!0,n[r].forEach(function(t){if(0<=e.indexOf(t))throw new Error("Circular dependency '"+t+"' is required by '"+r+"': "+e.join(" -> "));i[t]||s(t,e.slice(0))}),o.indexOf(r)<0&&o.push(r)},Object.keys(n).forEach(function(t){return s(t)}),o.reverse()),l=function(t,r){void 0===r&&(r={});var o=function(t,r){for(var e in t)if(t.hasOwnProperty(e)&&0<=t[e].indexOf(r)){var n=o(t,e);return null!==n?n+"."+e:e}return null};for(var e in t)if(t.hasOwnProperty(e)){var n=o(t,e);r[e]=n?n+"."+e:e}return r}(p),h=t.reduce(function(t,r){if(!r[j])throw new Error("States must be decorated with @State() decorator");return t[r[j].name]=r,t},{}),y=[],d=function(r){var t=h[r];if(!t[j])throw new Error("States must be decorated with @State() decorator");var e,n=l[r],o=t[j].actions,a=t[j].defaults;if(t[j].path=n,v.states.find(function(t){return t.name===r}))throw new Error("Store has already been added: "+r);Array.isArray(a)?a=S(a):"object"==typeof(e=a)&&null!==e||"function"==typeof e?a=Object.assign({},a):a===undefined&&(a={});var i=v._injector.get(t);y.push({actions:o,instance:i,defaults:a,name:r,depth:n})},v=this;try{for(var b=m(f),g=b.next();!g.done;g=b.next()){d(g.value)}}catch(_){r={error:_}}finally{try{g&&!g.done&&(u=b["return"])&&u.call(b)}finally{if(r)throw r.error}}return(c=this.states).push.apply(c,S(y)),y},t.prototype.addAndReturnDefaults=function(t){return this.add(t).reduce(function(t,r){return _(t,r.depth,r.defaults)},{})},t.prototype.invokeActions=function(f,l,h,y){var t,r,d=[],e=function(o){var t,r,e=g(y),n=o.actions[e];if(n)try{for(var a=m(n),i=a.next();!i.done;i=a.next()){var s=i.value,u={getState:function(){var t=f();return x(t,o.depth)},patchState:function(t){if(Array.isArray(t))throw new Error("Patching arrays is not supported.");var r=f(),e=x(r,o.depth);for(var n in t)e[n]=t[n];return r=_(r,o.depth,Object.assign({},e)),l(r),r},setState:function(t){var r=f();return r=_(r,o.depth,t),l(r),r},dispatch:function(t){return h(t)}},c=o.instance[s.fn](u,y);c&&d.push(c)}}catch(p){t={error:p}}finally{try{i&&!i.done&&(r=a["return"])&&r.call(a)}finally{if(t)throw t.error}}};try{for(var n=m(this.states),o=n.next();!o.done;o=n.next()){e(o.value)}}catch(a){t={error:a}}finally{try{o&&!o.done&&(r=n["return"])&&r.call(n)}finally{if(t)throw t.error}}return d},t}();w.decorators=[{type:r.Injectable}],w.ctorParameters=function(){return[{type:r.Injector},{type:w,decorators:[{type:r.Optional},{type:r.SkipSelf}]}]};var O=function(e){function t(t){var r=e.call(this)||this;return t&&Object.assign(r,t),r}return f(t,e),t}(e.Subject);O.decorators=[{type:r.Injectable}],O.ctorParameters=function(){return[{type:O,decorators:[{type:r.Optional},{type:r.SkipSelf}]}]};var A=function(e){return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return e.shift().apply(void 0,S(t,[function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return A(e).apply(void 0,S(t))}]))}},P=function(e){function t(t){var r=e.call(this,{})||this;return t&&Object.assign(r,t),r}return f(t,e),t}(n.BehaviorSubject);P.decorators=[{type:r.Injectable}],P.ctorParameters=function(){return[{type:P,decorators:[{type:r.Optional},{type:r.SkipSelf}]}]};var E=function(){function t(t,r){this._parentManager=t,this._plugins=r,this.plugins=[],this.register()}return t.prototype.register=function(){var t;this._plugins&&(this.plugins=this._plugins.map(function(t){return t.handle?t.handle.bind(t):t}),this._parentManager&&(t=this._parentManager.plugins).push.apply(t,S(this.plugins)))},t}();E.decorators=[{type:r.Injectable}],E.ctorParameters=function(){return[{type:E,decorators:[{type:r.Optional},{type:r.SkipSelf}]},{type:Array,decorators:[{type:r.Inject,args:[d]},{type:r.Optional}]}]};var I=function(){function t(t,r,e,n,o){this._errorHandler=t,this._actions=r,this._storeFactory=e,this._pluginManager=n,this._stateStream=o}return t.prototype.dispatch=function(t){var r,e=this;return(r=Array.isArray(t)?a.forkJoin(t.map(function(t){return e._dispatch(t)})):this._dispatch(t)).pipe(o.catchError(function(t){return e._errorHandler.handleError(t),s.of(t)})),r.subscribe(),r},t.prototype.select=function(t){if(t[j]&&t[j].path){var r=b(t[j].path.split("."));return this._stateStream.pipe(i.map(r),o.distinctUntilChanged())}return this._stateStream.pipe(i.map(t),o.distinctUntilChanged())},t.prototype.selectOnce=function(t){return this.select(t).pipe(o.take(1))},t.prototype.subscribe=function(t){return this._stateStream.subscribe(t)},t.prototype._dispatch=function(t){var e=this,n=this._stateStream.getValue(),r=this._pluginManager.plugins;return A(S(r,[function(t,r){return t!==n&&e._stateStream.next(t),e._actions.next(r),e._dispatchActions(r).pipe(i.map(function(){return e._stateStream.getValue()}))}]))(n,t).pipe(o.shareReplay())},t.prototype._dispatchActions=function(t){var r=this,e=this._storeFactory.invokeActions(function(){return r._stateStream.getValue()},function(t){return r._stateStream.next(t)},function(t){return r.dispatch(t)},t);return(e.length?a.forkJoin(this._handleNesting(e)):s.of({})).pipe(o.shareReplay())},t.prototype._handleNesting=function(t){var r,e,n=[];try{for(var o=m(t),a=o.next();!a.done;a=o.next()){var i=a.value;i instanceof Promise&&(i=c.fromPromise(i)),i instanceof u.Observable&&n.push(i)}}catch(s){r={error:s}}finally{try{a&&!a.done&&(e=o["return"])&&e.call(o)}finally{if(r)throw r.error}}return n},t}();I.decorators=[{type:r.Injectable}],I.ctorParameters=function(){return[{type:r.ErrorHandler},{type:O},{type:w},{type:E},{type:P}]};var k=function(t){};k.store=undefined,k.decorators=[{type:r.Injectable}],k.ctorParameters=function(){return[{type:I}]};var T=function(){};T.type="@@INIT";var R=function(){};R.type="@@UPDATE_STATE";var M=function(){function t(t,r,e,n,o){this._factory=t,this._stateStream=r,this.initStates(o),e.dispatch(new T)}return t.prototype.initStates=function(t){if(t){var r=this._factory.addAndReturnDefaults(t),e=this._stateStream.getValue();this._stateStream.next(Object.assign({},e,r))}},t}();M.decorators=[{type:r.NgModule}],M.ctorParameters=function(){return[{type:w},{type:P},{type:I},{type:k},{type:Array,decorators:[{type:r.Optional},{type:r.Inject,args:[h]}]}]};var N=function(){function t(t,r,e,n,o){this._stateStream=e,this._factory=n;var a=[].concat.apply([],S(o));this.initStates(a),r.dispatch(new R)}return t.prototype.initStates=function(t){if(t){var r=this._factory.addAndReturnDefaults(t),e=this._stateStream.getValue();this._stateStream.next(Object.assign({},e,r))}},t}();N.decorators=[{type:r.NgModule,args:[{}]}],N.ctorParameters=function(){return[{type:M},{type:I},{type:P},{type:w},{type:Array,decorators:[{type:r.Optional},{type:r.Inject,args:[y]}]}]};var q=function(){function t(){}return t.forRoot=function(t){return void 0===t&&(t=[]),{ngModule:M,providers:S([w,O,I,P,k,E],t,[{provide:h,useValue:t}])}},t.forFeature=function(t){return{ngModule:N,providers:S([w,E],t,[{provide:y,multi:!0,useValue:t}])}},t}();q.decorators=[{type:r.NgModule,args:[{}]}],q.ctorParameters=function(){return[]},t.NgxsModule=q,t.Action=function(l){return function(t,r,e){var n,o,a,i=v(t.constructor);Array.isArray(l)||(l=[l]);try{for(var s=m(l),u=s.next();!u.done;u=s.next()){var c=u.value,p=(n=c).type?n.type:n.name?n.name:void 0;i.actions[p]||(i.actions[p]=[]),i.actions[p].push({fn:r,type:p})}}catch(f){o={error:f}}finally{try{u&&!u.done&&(a=s["return"])&&a.call(s)}finally{if(o)throw o.error}}}},t.Store=I,t.State=function(n){return function(t){var r=v(t);if(t.__proto__.hasOwnProperty(j)){var e=t.__proto__[j];r.actions=Object.assign({},r.actions,e.actions)}if(r.children=n.children,r.defaults=n.defaults,r.name=n.name,!n.name)throw new Error("States must register a 'name' property")}},t.Select=function(n){for(var o=[],t=1;t<arguments.length;t++)o[t-1]=arguments[t];return function(t,r){var e="__"+r+"__selector";if(n||(n=r.lastIndexOf("$")===r.length-1?r.substring(0,r.length-1):r),t[e])throw new Error("You cannot use @Select decorator and a "+e+" property.");delete t[r]&&(Object.defineProperty(t,e,{writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(t,r,{get:function(){return this[e]||(this[e]=function(t){var r=k.store;if(!r)throw new Error("SelectFactory not connected to store!");return r.select(t)}.apply(this,["string"==typeof n?b(o.length?S([n],o):n.split(".")):n[j]&&n[j].path?b(n[j].path.split(".")):n]))},enumerable:!0,configurable:!0}))}},t.Actions=O,t.ofAction=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var e={};return t.forEach(function(t){return e[t.type||t.name]=!0}),o.filter(function(t){return e[t.constructor.type||t.constructor.name]})},t.Selector=function(){for(var i=[],t=0;t<arguments.length;t++)i[t]=arguments[t];return function(t,r,e){var n=t[j];if(null!==e.value){var o=e.value,a=function(t){var r=x(t,n.path);return o(r)};return{configurable:!0,get:function(){return function(a,i){var s=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var e=i?i.apply(this,t):t[0],n=s.cache;if(n.has(e))return n.get(e);var o=a.apply(this,t);return s.cache=n.set(e,o)||n,o};return s.cache=new WeakMap,s}.apply(null,S([a],i))}}}throw new Error("Selectors only work on methods")}},t.getActionTypeFromInstance=g,t.NGXS_PLUGINS=d,t.StateStream=P,t.setValue=_,t.getValue=x,t.InitState=T,t.UpdateState=R,t.ɵb=N,t.ɵa=M,t.ɵg=E,t.ɵc=k,t.ɵf=w,t.ɵe=y,t.ɵd=h,Object.defineProperty(t,"__esModule",{value:!0})});
!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("@angular/core"),require("rxjs/Subject"),require("rxjs/BehaviorSubject"),require("rxjs/Observable"),require("rxjs/operators"),require("rxjs/observable/forkJoin"),require("rxjs/operators/map"),require("rxjs/observable/fromPromise"),require("rxjs/observable/of")):"function"==typeof define&&define.amd?define("@ngxs/store",["exports","@angular/core","rxjs/Subject","rxjs/BehaviorSubject","rxjs/Observable","rxjs/operators","rxjs/observable/forkJoin","rxjs/operators/map","rxjs/observable/fromPromise","rxjs/observable/of"],r):r((t.ngxs=t.ngxs||{},t.ngxs.store={}),t.ng.core,t.Rx,t.Rx,t.Rx,t.Rx.Observable.prototype,t.Rx.Observable,t.Rx.Observable.prototype,t.Rx.Observable,t.Rx.Observable)}(this,function(t,r,e,n,u,o,a,i,c,s){"use strict";var f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var e in r)r.hasOwnProperty(e)&&(t[e]=r[e])};function p(t,r){function e(){this.constructor=t}f(t,r),t.prototype=null===r?Object.create(r):(e.prototype=r.prototype,new e)}function m(t){var r="function"==typeof Symbol&&t[Symbol.iterator],e=0;return r?r.call(t):{next:function(){return t&&e>=t.length&&(t=void 0),{value:t&&t[e++],done:!t}}}}function l(t,r){var e="function"==typeof Symbol&&t[Symbol.iterator];if(!e)return t;var n,o,a=e.call(t),i=[];try{for(;(void 0===r||0<r--)&&!(n=a.next()).done;)i.push(n.value)}catch(s){o={error:s}}finally{try{n&&!n.done&&(e=a["return"])&&e.call(a)}finally{if(o)throw o.error}}return i}function S(){for(var t=[],r=0;r<arguments.length;r++)t=t.concat(l(arguments[r]));return t}var h=new r.InjectionToken("ROOT_STATE_TOKEN"),y=new r.InjectionToken("FEATURE_STATE_TOKEN"),j="NGXS_META",d=new r.InjectionToken("NGXS_PLUGINS");function v(t){if(!t.hasOwnProperty(j)){Object.defineProperty(t,j,{value:{name:null,actions:{},defaults:{},path:null,children:[]}})}return t[j]}function b(t){for(var r=t,e="store."+r[0],n=0,o=r.length,a=e;++n<o;)a=a+" && "+(e=e+"."+r[n]);return new Function("store","return "+a+";")}function g(t){return t.constructor.type?t.constructor.type:t.constructor.name?t.constructor.name:t.type?t.type:void 0}var _=function(t,r,e){t=Object.assign({},t);var n=r.split("."),o=n[n.length-1];return n.reduce(function(t,r){return t[r]=r===o?e:Object.assign({},t[r]),t&&t[r]},t),t},x=function(t,r){return r.split(".").reduce(function(t,r){return t&&t[r]},t)},w=function(){function t(t,r){this._injector=t,this._parentFactory=r,this._states=[]}return Object.defineProperty(t.prototype,"states",{get:function(){return this._parentFactory?this._parentFactory.states:this._states},enumerable:!0,configurable:!0}),t.prototype.add=function(t){Array.isArray(t)||(t=[t]);var e,a,n,o,i,s,r,u,c,f=(a=function(r){var t=e.find(function(t){return t===r});if(!t)throw new Error("Child state not found: "+r);if(!t[j])throw new Error("States must be decorated with @State() decorator");return t[j].name},(e=t).reduce(function(t,r){if(!r[j])throw new Error("States must be decorated with @State() decorator");var e=r[j],n=e.name,o=e.children;return t[n]=(o||[]).map(a),t},{})),p=(n=f,o=[],i={},s=function(r,e){void 0===e&&(e=[]),Array.isArray(e)||(e=[]),e.push(r),i[r]=!0,n[r].forEach(function(t){if(0<=e.indexOf(t))throw new Error("Circular dependency '"+t+"' is required by '"+r+"': "+e.join(" -> "));i[t]||s(t,e.slice(0))}),o.indexOf(r)<0&&o.push(r)},Object.keys(n).forEach(function(t){return s(t)}),o.reverse()),l=function(t,r){void 0===r&&(r={});var o=function(t,r){for(var e in t)if(t.hasOwnProperty(e)&&0<=t[e].indexOf(r)){var n=o(t,e);return null!==n?n+"."+e:e}return null};for(var e in t)if(t.hasOwnProperty(e)){var n=o(t,e);r[e]=n?n+"."+e:e}return r}(f),h=t.reduce(function(t,r){if(!r[j])throw new Error("States must be decorated with @State() decorator");return t[r[j].name]=r,t},{}),y=[],d=function(r){var t=h[r];if(!t[j])throw new Error("States must be decorated with @State() decorator");var e,n=l[r],o=t[j].actions,a=t[j].defaults;if(t[j].path=n,v.states.find(function(t){return t.name===r}))throw new Error("Store has already been added: "+r);Array.isArray(a)?a=S(a):"object"==typeof(e=a)&&null!==e||"function"==typeof e?a=Object.assign({},a):a===undefined&&(a={});var i=v._injector.get(t);y.push({actions:o,instance:i,defaults:a,name:r,depth:n})},v=this;try{for(var b=m(p),g=b.next();!g.done;g=b.next()){d(g.value)}}catch(_){r={error:_}}finally{try{g&&!g.done&&(u=b["return"])&&u.call(b)}finally{if(r)throw r.error}}return(c=this.states).push.apply(c,S(y)),y},t.prototype.addAndReturnDefaults=function(t){return this.add(t).reduce(function(t,r){return _(t,r.depth,r.defaults)},{})},t.prototype.invokeActions=function(p,l,h,y){var t,r,d=[],e=function(o){var t,r,e=g(y),n=o.actions[e];if(n)try{for(var a=m(n),i=a.next();!i.done;i=a.next()){var s=i.value,u={getState:function(){var t=p();return x(t,o.depth)},patchState:function(t){if(Array.isArray(t))throw new Error("Patching arrays is not supported.");var r=p(),e=x(r,o.depth);for(var n in t)e[n]=t[n];return r=_(r,o.depth,Object.assign({},e)),l(r),r},setState:function(t){var r=p();return r=_(r,o.depth,t),l(r),r},dispatch:function(t){return h(t)}},c=o.instance[s.fn](u,y);c&&d.push(c)}}catch(f){t={error:f}}finally{try{i&&!i.done&&(r=a["return"])&&r.call(a)}finally{if(t)throw t.error}}};try{for(var n=m(this.states),o=n.next();!o.done;o=n.next()){e(o.value)}}catch(a){t={error:a}}finally{try{o&&!o.done&&(r=n["return"])&&r.call(n)}finally{if(t)throw t.error}}return d},t}();w.decorators=[{type:r.Injectable}],w.ctorParameters=function(){return[{type:r.Injector},{type:w,decorators:[{type:r.Optional},{type:r.SkipSelf}]}]};var O=function(e){function t(t){var r=e.call(this)||this;return t&&Object.assign(r,t),r}return p(t,e),t}(e.Subject);O.decorators=[{type:r.Injectable}],O.ctorParameters=function(){return[{type:O,decorators:[{type:r.Optional},{type:r.SkipSelf}]}]};var A=function(e){return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return e.shift().apply(void 0,S(t,[function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return A(e).apply(void 0,S(t))}]))}},E=function(e){function t(t){var r=e.call(this,{})||this;return t&&Object.assign(r,t),r}return p(t,e),t}(n.BehaviorSubject);E.decorators=[{type:r.Injectable}],E.ctorParameters=function(){return[{type:E,decorators:[{type:r.Optional},{type:r.SkipSelf}]}]};var P=function(){function t(t,r){this._parentManager=t,this._plugins=r,this.plugins=[],this.register()}return t.prototype.register=function(){var t;this._plugins&&(this.plugins=this._plugins.map(function(t){return t.handle?t.handle.bind(t):t}),this._parentManager&&(t=this._parentManager.plugins).push.apply(t,S(this.plugins)))},t}();P.decorators=[{type:r.Injectable}],P.ctorParameters=function(){return[{type:P,decorators:[{type:r.Optional},{type:r.SkipSelf}]},{type:Array,decorators:[{type:r.Inject,args:[d]},{type:r.Optional}]}]};var I=function(){function t(t,r,e,n,o){this._errorHandler=t,this._actions=r,this._storeFactory=e,this._pluginManager=n,this._stateStream=o}return t.prototype.dispatch=function(t){var r,e=this;return(r=Array.isArray(t)?a.forkJoin(t.map(function(t){return e._dispatch(t)})):this._dispatch(t)).pipe(o.catchError(function(t){return e._errorHandler.handleError(t),s.of(t)})),r.subscribe(),r},t.prototype.select=function(t){if(t[j]&&t[j].path){var r=b(t[j].path.split("."));return this._stateStream.pipe(i.map(r),o.distinctUntilChanged())}return this._stateStream.pipe(i.map(t),o.catchError(function(t){if(t instanceof TypeError)return s.of(undefined);throw t}),o.distinctUntilChanged())},t.prototype.selectOnce=function(t){return this.select(t).pipe(o.take(1))},t.prototype.subscribe=function(t){return this._stateStream.subscribe(t)},t.prototype._dispatch=function(t){var e=this,n=this._stateStream.getValue(),r=this._pluginManager.plugins;return A(S(r,[function(t,r){return t!==n&&e._stateStream.next(t),e._actions.next(r),e._dispatchActions(r).pipe(i.map(function(){return e._stateStream.getValue()}))}]))(n,t).pipe(o.shareReplay())},t.prototype._dispatchActions=function(t){var r=this,e=this._storeFactory.invokeActions(function(){return r._stateStream.getValue()},function(t){return r._stateStream.next(t)},function(t){return r.dispatch(t)},t);return(e.length?a.forkJoin(this._handleNesting(e)):s.of({})).pipe(o.shareReplay())},t.prototype._handleNesting=function(t){var r,e,n=[];try{for(var o=m(t),a=o.next();!a.done;a=o.next()){var i=a.value;i instanceof Promise&&(i=c.fromPromise(i)),i instanceof u.Observable&&n.push(i)}}catch(s){r={error:s}}finally{try{a&&!a.done&&(e=o["return"])&&e.call(o)}finally{if(r)throw r.error}}return n},t}();I.decorators=[{type:r.Injectable}],I.ctorParameters=function(){return[{type:r.ErrorHandler},{type:O},{type:w},{type:P},{type:E}]};var T=function(t){};T.store=undefined,T.decorators=[{type:r.Injectable}],T.ctorParameters=function(){return[{type:I}]};var k=function(){};k.type="@@INIT";var R=function(){};R.type="@@UPDATE_STATE";var M=function(){function t(t,r,e,n,o){this._factory=t,this._stateStream=r,this.initStates(o),e.dispatch(new k)}return t.prototype.initStates=function(t){if(t){var r=this._factory.addAndReturnDefaults(t),e=this._stateStream.getValue();this._stateStream.next(Object.assign({},e,r))}},t}();M.decorators=[{type:r.NgModule}],M.ctorParameters=function(){return[{type:w},{type:E},{type:I},{type:T},{type:Array,decorators:[{type:r.Optional},{type:r.Inject,args:[h]}]}]};var N=function(){function t(t,r,e,n,o){this._stateStream=e,this._factory=n;var a=[].concat.apply([],S(o));this.initStates(a),r.dispatch(new R)}return t.prototype.initStates=function(t){if(t){var r=this._factory.addAndReturnDefaults(t),e=this._stateStream.getValue();this._stateStream.next(Object.assign({},e,r))}},t}();N.decorators=[{type:r.NgModule,args:[{}]}],N.ctorParameters=function(){return[{type:M},{type:I},{type:E},{type:w},{type:Array,decorators:[{type:r.Optional},{type:r.Inject,args:[y]}]}]};var q=function(){function t(){}return t.forRoot=function(t){return void 0===t&&(t=[]),{ngModule:M,providers:S([w,O,I,E,T,P],t,[{provide:h,useValue:t}])}},t.forFeature=function(t){return{ngModule:N,providers:S([w,P],t,[{provide:y,multi:!0,useValue:t}])}},t}();q.decorators=[{type:r.NgModule,args:[{}]}],q.ctorParameters=function(){return[]},t.NgxsModule=q,t.Action=function(l){return function(t,r,e){var n,o,a,i=v(t.constructor);Array.isArray(l)||(l=[l]);try{for(var s=m(l),u=s.next();!u.done;u=s.next()){var c=u.value,f=(n=c).type?n.type:n.name?n.name:void 0;i.actions[f]||(i.actions[f]=[]),i.actions[f].push({fn:r,type:f})}}catch(p){o={error:p}}finally{try{u&&!u.done&&(a=s["return"])&&a.call(s)}finally{if(o)throw o.error}}}},t.Store=I,t.State=function(n){return function(t){var r=v(t);if(t.__proto__.hasOwnProperty(j)){var e=t.__proto__[j];r.actions=Object.assign({},r.actions,e.actions)}if(r.children=n.children,r.defaults=n.defaults,r.name=n.name,!n.name)throw new Error("States must register a 'name' property")}},t.Select=function(n){for(var o=[],t=1;t<arguments.length;t++)o[t-1]=arguments[t];return function(t,r){var e="__"+r+"__selector";if(n||(n=r.lastIndexOf("$")===r.length-1?r.substring(0,r.length-1):r),t[e])throw new Error("You cannot use @Select decorator and a "+e+" property.");delete t[r]&&(Object.defineProperty(t,e,{writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(t,r,{get:function(){return this[e]||(this[e]=function(t){var r=T.store;if(!r)throw new Error("SelectFactory not connected to store!");return r.select(t)}.apply(this,["string"==typeof n?b(o.length?S([n],o):n.split(".")):n[j]&&n[j].path?b(n[j].path.split(".")):n]))},enumerable:!0,configurable:!0}))}},t.Actions=O,t.ofAction=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var e={};return t.forEach(function(t){return e[t.type||t.name]=!0}),o.filter(function(t){return e[t.constructor.type||t.constructor.name]})},t.Selector=function(){for(var i=[],t=0;t<arguments.length;t++)i[t]=arguments[t];return function(t,r,e){var n=v(t);if(null!==e.value){var o=e.value,a=function(t){var r=x(t,n.path);try{return o(r)}catch(e){if(e instanceof TypeError)return undefined;throw e}};return{configurable:!0,get:function(){return function(a,i){var s=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var e=i?i.apply(this,t):t[0],n=s.cache;if(n.has(e))return n.get(e);var o=a.apply(this,t);return s.cache=n.set(e,o)||n,o};return s.cache=new WeakMap,s}.apply(null,S([a],i))}}}throw new Error("Selectors only work on methods")}},t.getActionTypeFromInstance=g,t.NGXS_PLUGINS=d,t.StateStream=E,t.setValue=_,t.getValue=x,t.InitState=k,t.UpdateState=R,t.ɵb=N,t.ɵa=M,t.ɵg=P,t.ɵc=T,t.ɵf=w,t.ɵe=y,t.ɵd=h,Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=ngxs-store.umd.min.js.map

@@ -628,3 +628,10 @@ import { InjectionToken, Injector, Injectable, SkipSelf, Optional, Inject, ErrorHandler, NgModule } from '@angular/core';

}
return this._stateStream.pipe(map(selector), distinctUntilChanged());
return this._stateStream.pipe(map(selector), catchError(err => {
// if error is TypeError we swallow it to prevent usual errors with property access
if (err instanceof TypeError) {
return of(undefined);
}
// rethrow other errors
throw err;
}), distinctUntilChanged());
}

@@ -1029,3 +1036,3 @@ /**

return (target, key, descriptor) => {
const /** @type {?} */ metadata = target[META_KEY];
const /** @type {?} */ metadata = ensureStoreMetadata(target);
if (descriptor.value !== null) {

@@ -1035,3 +1042,13 @@ const /** @type {?} */ prev = descriptor.value;

const /** @type {?} */ local = getValue(state, metadata.path);
return prev(local);
// if the lambda tries to access a something on the state that doesn't exist, it will throw a TypeError.
// since this is quite usual behaviour, we simply return undefined if so.
try {
return prev(local);
}
catch (/** @type {?} */ ex) {
if (ex instanceof TypeError) {
return undefined;
}
throw ex;
}
};

@@ -1038,0 +1055,0 @@ return {

@@ -416,3 +416,8 @@ import { __spread, __values, __extends } from 'tslib';

}
return this._stateStream.pipe(map(selector), distinctUntilChanged());
return this._stateStream.pipe(map(selector), catchError(function (err) {
if (err instanceof TypeError) {
return of(undefined);
}
throw err;
}), distinctUntilChanged());
};

@@ -727,3 +732,3 @@ Store.prototype.selectOnce = function (selector) {

return function (target, key, descriptor) {
var metadata = target[META_KEY];
var metadata = ensureStoreMetadata(target);
if (descriptor.value !== null) {

@@ -733,3 +738,11 @@ var prev_1 = descriptor.value;

var local = getValue(state, metadata.path);
return prev_1(local);
try {
return prev_1(local);
}
catch (ex) {
if (ex instanceof TypeError) {
return undefined;
}
throw ex;
}
};

@@ -736,0 +749,0 @@ return {

{
"name": "@ngxs/store",
"version": "2.0.0-dev.6461c78",
"version": "2.0.0-dev.6c52a03",
"license": "MIT",

@@ -5,0 +5,0 @@ "peerDependencies": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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