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

@ngxs/storage-plugin

Package Overview
Dependencies
Maintainers
2
Versions
1265
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ngxs/storage-plugin - npm Package Compare versions

Comparing version 2.0.0-rc.21 to 2.0.0-rc.22

74

bundles/ngxs-storage-plugin.umd.js
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@ngxs/store')) :
typeof define === 'function' && define.amd ? define('@ngxs/storage-plugin', ['exports', '@angular/core', '@ngxs/store'], factory) :
(factory((global.ngxs = global.ngxs || {}, global.ngxs['storage-plugin'] = {}),global.ng.core,global['ngxs-store']));
}(this, (function (exports,core,store) { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@ngxs/store'), require('rxjs/operators')) :
typeof define === 'function' && define.amd ? define('@ngxs/storage-plugin', ['exports', '@angular/core', '@ngxs/store', 'rxjs/operators'], factory) :
(factory((global.ngxs = global.ngxs || {}, global.ngxs['storage-plugin'] = {}),global.ng.core,global['ngxs-store'],global.Rx.Observable.prototype));
}(this, (function (exports,core,store,operators) { 'use strict';

@@ -40,12 +40,20 @@ /*! *****************************************************************************

var StorageOption = {
LocalStorage: 0,
SessionStorage: 1,
};
StorageOption[StorageOption.LocalStorage] = "LocalStorage";
StorageOption[StorageOption.SessionStorage] = "SessionStorage";
var NGXS_STORAGE_PLUGIN_OPTIONS = new core.InjectionToken('NGXS_STORAGE_PLUGIN_OPTION');
var STORAGE_ENGINE = new core.InjectionToken('STORAGE_ENGINE');
var NgxsStoragePlugin = /** @class */ (function () {
function NgxsStoragePlugin(_options) {
function NgxsStoragePlugin(_options, _engine) {
this._options = _options;
this._engine = _engine;
}
NgxsStoragePlugin.prototype.handle = function (state, event, next) {
var _this = this;
var options = this._options || ({});
var isInitAction = store.getActionTypeFromInstance(event) === '@@INIT';
var keys = Array.isArray(options.key) ? options.key : [options.key];
var engine = options.storage || localStorage;
if (isInitAction) {

@@ -55,3 +63,3 @@ try {

var key = keys_1_1.value;
var val = engine.getItem(key);
var val = this._engine.getItem(key);
if (val !== 'undefined' && val !== null) {

@@ -76,4 +84,3 @@ val = options.deserialize(val);

}
var res = next(state, event);
res.subscribe(function (nextState) {
return next(state, event).pipe(operators.tap(function (nextState) {
if (!isInitAction) {

@@ -87,3 +94,3 @@ try {

}
engine.setItem(key, options.serialize(val));
_this._engine.setItem(key, options.serialize(val));
}

@@ -100,4 +107,3 @@ }

var e_2, _a;
});
return res;
}));
var e_1, _a;

@@ -112,9 +118,22 @@ };

{ type: undefined, decorators: [{ type: core.Inject, args: [NGXS_STORAGE_PLUGIN_OPTIONS,] },] },
{ type: undefined, decorators: [{ type: core.Inject, args: [STORAGE_ENGINE,] },] },
]; };
var defaultStoragePluginOptions = {
key: '@@STATE',
storage: localStorage,
serialize: JSON.stringify,
deserialize: JSON.parse
};
function storageOptionsFactory(options) {
return Object.assign({
key: '@@STATE',
storage: StorageOption.LocalStorage,
serialize: JSON.stringify,
deserialize: JSON.parse
}, options);
}
function engineFactory(options) {
if (options.storage === StorageOption.LocalStorage) {
return localStorage;
}
else if (options.storage === StorageOption.SessionStorage) {
return sessionStorage;
}
return null;
}
var USER_OPTIONS = new core.InjectionToken('USER_OPTIONS');
var NgxsStoragePluginModule = /** @class */ (function () {

@@ -128,2 +147,6 @@ function NgxsStoragePluginModule() {

{
provide: USER_OPTIONS,
useValue: options
},
{
provide: store.NGXS_PLUGINS,

@@ -135,3 +158,9 @@ useClass: NgxsStoragePlugin,

provide: NGXS_STORAGE_PLUGIN_OPTIONS,
useValue: Object.assign({}, defaultStoragePluginOptions, options)
useFactory: storageOptionsFactory,
deps: [USER_OPTIONS]
},
{
provide: STORAGE_ENGINE,
useFactory: engineFactory,
deps: [NGXS_STORAGE_PLUGIN_OPTIONS]
}

@@ -150,3 +179,8 @@ ]

exports.NgxsStoragePlugin = NgxsStoragePlugin;
exports.ɵb = NGXS_STORAGE_PLUGIN_OPTIONS;
exports.StorageOption = StorageOption;
exports.NGXS_STORAGE_PLUGIN_OPTIONS = NGXS_STORAGE_PLUGIN_OPTIONS;
exports.STORAGE_ENGINE = STORAGE_ENGINE;
exports.ɵc = USER_OPTIONS;
exports.ɵb = engineFactory;
exports.ɵa = storageOptionsFactory;

@@ -153,0 +187,0 @@ Object.defineProperty(exports, '__esModule', { value: true });

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

!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("@angular/core"),require("@ngxs/store")):"function"==typeof define&&define.amd?define("@ngxs/storage-plugin",["exports","@angular/core","@ngxs/store"],r):r((e.ngxs=e.ngxs||{},e.ngxs["storage-plugin"]={}),e.ng.core,e["ngxs-store"])}(this,function(e,r,p){"use strict";function v(e){var r="function"==typeof Symbol&&e[Symbol.iterator],t=0;return r?r.call(e):{next:function(){return e&&t>=e.length&&(e=void 0),{value:e&&e[t++],done:!e}}}}var t=new r.InjectionToken("NGXS_STORAGE_PLUGIN_OPTION"),n=function(){function e(e){this._options=e}return e.prototype.handle=function(e,r,t){var s=this._options||{},l="@@INIT"===p.getActionTypeFromInstance(r),c=Array.isArray(s.key)?s.key:[s.key],f=s.storage||localStorage;if(l)try{for(var n=v(c),o=n.next();!o.done;o=n.next()){var i=o.value,a=f.getItem(i);"undefined"!==a&&null!==a&&(a=s.deserialize(a),e="@@STATE"!==i?p.setValue(e,i,a):a)}}catch(y){u={error:y}}finally{try{o&&!o.done&&(g=n["return"])&&g.call(n)}finally{if(u)throw u.error}}var u,g,d=t(e,r);return d.subscribe(function(e){if(!l)try{for(var r=v(c),t=r.next();!t.done;t=r.next()){var n=t.value,o=e;"@@STATE"!==n&&(o=p.getValue(e,n)),f.setItem(n,s.serialize(o))}}catch(u){i={error:u}}finally{try{t&&!t.done&&(a=r["return"])&&a.call(r)}finally{if(i)throw i.error}}var i,a}),d},e}();n.decorators=[{type:r.Injectable}],n.ctorParameters=function(){return[{type:undefined,decorators:[{type:r.Inject,args:[t]}]}]};var o={key:"@@STATE",storage:localStorage,serialize:JSON.stringify,deserialize:JSON.parse},i=function(){function r(){}return r.forRoot=function(e){return{ngModule:r,providers:[{provide:p.NGXS_PLUGINS,useClass:n,multi:!0},{provide:t,useValue:Object.assign({},o,e)}]}},r}();i.decorators=[{type:r.NgModule}],i.ctorParameters=function(){return[]},e.NgxsStoragePluginModule=i,e.NgxsStoragePlugin=n,e.ɵb=t,Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("@angular/core"),require("@ngxs/store"),require("rxjs/operators")):"function"==typeof define&&define.amd?define("@ngxs/storage-plugin",["exports","@angular/core","@ngxs/store","rxjs/operators"],r):r((e.ngxs=e.ngxs||{},e.ngxs["storage-plugin"]={}),e.ng.core,e["ngxs-store"],e.Rx.Observable.prototype)}(this,function(e,r,p,S){"use strict";function y(e){var r="function"==typeof Symbol&&e[Symbol.iterator],t=0;return r?r.call(e):{next:function(){return e&&t>=e.length&&(e=void 0),{value:e&&e[t++],done:!e}}}}var t={LocalStorage:0,SessionStorage:1};t[t.LocalStorage]="LocalStorage",t[t.SessionStorage]="SessionStorage";var n=new r.InjectionToken("NGXS_STORAGE_PLUGIN_OPTION"),o=new r.InjectionToken("STORAGE_ENGINE"),a=function(){function e(e,r){this._options=e,this._engine=r}return e.prototype.handle=function(e,r,t){var n,o,u=this,l=this._options||{},c="@@INIT"===p.getActionTypeFromInstance(r),g=Array.isArray(l.key)?l.key:[l.key];if(c)try{for(var a=y(g),i=a.next();!i.done;i=a.next()){var s=i.value,f=this._engine.getItem(s);"undefined"!==f&&null!==f&&(f=l.deserialize(f),e="@@STATE"!==s?p.setValue(e,s,f):f)}}catch(d){n={error:d}}finally{try{i&&!i.done&&(o=a["return"])&&o.call(a)}finally{if(n)throw n.error}}return t(e,r).pipe(S.tap(function(e){if(!c)try{for(var r=y(g),t=r.next();!t.done;t=r.next()){var n=t.value,o=e;"@@STATE"!==n&&(o=p.getValue(e,n)),u._engine.setItem(n,l.serialize(o))}}catch(s){a={error:s}}finally{try{t&&!t.done&&(i=r["return"])&&i.call(r)}finally{if(a)throw a.error}}var a,i}))},e}();function i(e){return Object.assign({key:"@@STATE",storage:t.LocalStorage,serialize:JSON.stringify,deserialize:JSON.parse},e)}function s(e){return e.storage===t.LocalStorage?localStorage:e.storage===t.SessionStorage?sessionStorage:null}a.decorators=[{type:r.Injectable}],a.ctorParameters=function(){return[{type:undefined,decorators:[{type:r.Inject,args:[n]}]},{type:undefined,decorators:[{type:r.Inject,args:[o]}]}]};var u=new r.InjectionToken("USER_OPTIONS"),l=function(){function r(){}return r.forRoot=function(e){return{ngModule:r,providers:[{provide:u,useValue:e},{provide:p.NGXS_PLUGINS,useClass:a,multi:!0},{provide:n,useFactory:i,deps:[u]},{provide:o,useFactory:s,deps:[n]}]}},r}();l.decorators=[{type:r.NgModule}],l.ctorParameters=function(){return[]},e.NgxsStoragePluginModule=l,e.NgxsStoragePlugin=a,e.StorageOption=t,e.NGXS_STORAGE_PLUGIN_OPTIONS=n,e.STORAGE_ENGINE=o,e.ɵc=u,e.ɵb=s,e.ɵa=i,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=ngxs-storage-plugin.umd.min.js.map
import { InjectionToken, Inject, Injectable, NgModule } from '@angular/core';
import { getActionTypeFromInstance, setValue, getValue, NGXS_PLUGINS } from '@ngxs/store';
import { tap } from 'rxjs/operators';

@@ -8,2 +9,9 @@ /**

*/
/** @enum {number} */
const StorageOption = {
LocalStorage: 0,
SessionStorage: 1,
};
StorageOption[StorageOption.LocalStorage] = "LocalStorage";
StorageOption[StorageOption.SessionStorage] = "SessionStorage";
/**

@@ -14,2 +22,6 @@ * @record

const NGXS_STORAGE_PLUGIN_OPTIONS = new InjectionToken('NGXS_STORAGE_PLUGIN_OPTION');
const STORAGE_ENGINE = new InjectionToken('STORAGE_ENGINE');
/**
* @record
*/

@@ -23,5 +35,7 @@ /**

* @param {?} _options
* @param {?} _engine
*/
constructor(_options) {
constructor(_options, _engine) {
this._options = _options;
this._engine = _engine;
}

@@ -38,6 +52,5 @@ /**

const /** @type {?} */ keys = Array.isArray(options.key) ? options.key : [options.key];
const /** @type {?} */ engine = options.storage || localStorage;
if (isInitAction) {
for (const /** @type {?} */ key of keys) {
let /** @type {?} */ val = engine.getItem(key);
let /** @type {?} */ val = this._engine.getItem(key);
if (val !== 'undefined' && val !== null) {

@@ -54,4 +67,3 @@ val = options.deserialize(val);

}
const /** @type {?} */ res = next(state, event);
res.subscribe(nextState => {
return next(state, event).pipe(tap(nextState => {
if (!isInitAction) {

@@ -63,7 +75,6 @@ for (const /** @type {?} */ key of keys) {

}
engine.setItem(key, options.serialize(val));
this._engine.setItem(key, options.serialize(val));
}
}
});
return res;
}));
}

@@ -77,2 +88,3 @@ }

{ type: undefined, decorators: [{ type: Inject, args: [NGXS_STORAGE_PLUGIN_OPTIONS,] },] },
{ type: undefined, decorators: [{ type: Inject, args: [STORAGE_ENGINE,] },] },
];

@@ -84,8 +96,28 @@

*/
const defaultStoragePluginOptions = {
key: '@@STATE',
storage: localStorage,
serialize: JSON.stringify,
deserialize: JSON.parse
};
/**
* @param {?} options
* @return {?}
*/
function storageOptionsFactory(options) {
return Object.assign({
key: '@@STATE',
storage: StorageOption.LocalStorage,
serialize: JSON.stringify,
deserialize: JSON.parse
}, options);
}
/**
* @param {?} options
* @return {?}
*/
function engineFactory(options) {
if (options.storage === StorageOption.LocalStorage) {
return localStorage;
}
else if (options.storage === StorageOption.SessionStorage) {
return sessionStorage;
}
return null;
}
const USER_OPTIONS = new InjectionToken('USER_OPTIONS');
class NgxsStoragePluginModule {

@@ -101,2 +133,6 @@ /**

{
provide: USER_OPTIONS,
useValue: options
},
{
provide: NGXS_PLUGINS,

@@ -108,3 +144,9 @@ useClass: NgxsStoragePlugin,

provide: NGXS_STORAGE_PLUGIN_OPTIONS,
useValue: Object.assign({}, defaultStoragePluginOptions, options)
useFactory: storageOptionsFactory,
deps: [USER_OPTIONS]
},
{
provide: STORAGE_ENGINE,
useFactory: engineFactory,
deps: [NGXS_STORAGE_PLUGIN_OPTIONS]
}

@@ -134,3 +176,3 @@ ]

export { NgxsStoragePluginModule, NgxsStoragePlugin, NGXS_STORAGE_PLUGIN_OPTIONS as ɵb };
export { NgxsStoragePluginModule, NgxsStoragePlugin, StorageOption, NGXS_STORAGE_PLUGIN_OPTIONS, STORAGE_ENGINE, USER_OPTIONS as ɵc, engineFactory as ɵb, storageOptionsFactory as ɵa };
//# sourceMappingURL=ngxs-storage-plugin.js.map
import { __values } from 'tslib';
import { InjectionToken, Inject, Injectable, NgModule } from '@angular/core';
import { getActionTypeFromInstance, setValue, getValue, NGXS_PLUGINS } from '@ngxs/store';
import { tap } from 'rxjs/operators';
var StorageOption = {
LocalStorage: 0,
SessionStorage: 1,
};
StorageOption[StorageOption.LocalStorage] = "LocalStorage";
StorageOption[StorageOption.SessionStorage] = "SessionStorage";
var NGXS_STORAGE_PLUGIN_OPTIONS = new InjectionToken('NGXS_STORAGE_PLUGIN_OPTION');
var STORAGE_ENGINE = new InjectionToken('STORAGE_ENGINE');
var NgxsStoragePlugin = /** @class */ (function () {
function NgxsStoragePlugin(_options) {
function NgxsStoragePlugin(_options, _engine) {
this._options = _options;
this._engine = _engine;
}
NgxsStoragePlugin.prototype.handle = function (state, event, next) {
var _this = this;
var options = this._options || ({});
var isInitAction = getActionTypeFromInstance(event) === '@@INIT';
var keys = Array.isArray(options.key) ? options.key : [options.key];
var engine = options.storage || localStorage;
if (isInitAction) {

@@ -19,3 +28,3 @@ try {

var key = keys_1_1.value;
var val = engine.getItem(key);
var val = this._engine.getItem(key);
if (val !== 'undefined' && val !== null) {

@@ -40,4 +49,3 @@ val = options.deserialize(val);

}
var res = next(state, event);
res.subscribe(function (nextState) {
return next(state, event).pipe(tap(function (nextState) {
if (!isInitAction) {

@@ -51,3 +59,3 @@ try {

}
engine.setItem(key, options.serialize(val));
_this._engine.setItem(key, options.serialize(val));
}

@@ -64,4 +72,3 @@ }

var e_2, _a;
});
return res;
}));
var e_1, _a;

@@ -76,9 +83,22 @@ };

{ type: undefined, decorators: [{ type: Inject, args: [NGXS_STORAGE_PLUGIN_OPTIONS,] },] },
{ type: undefined, decorators: [{ type: Inject, args: [STORAGE_ENGINE,] },] },
]; };
var defaultStoragePluginOptions = {
key: '@@STATE',
storage: localStorage,
serialize: JSON.stringify,
deserialize: JSON.parse
};
function storageOptionsFactory(options) {
return Object.assign({
key: '@@STATE',
storage: StorageOption.LocalStorage,
serialize: JSON.stringify,
deserialize: JSON.parse
}, options);
}
function engineFactory(options) {
if (options.storage === StorageOption.LocalStorage) {
return localStorage;
}
else if (options.storage === StorageOption.SessionStorage) {
return sessionStorage;
}
return null;
}
var USER_OPTIONS = new InjectionToken('USER_OPTIONS');
var NgxsStoragePluginModule = /** @class */ (function () {

@@ -92,2 +112,6 @@ function NgxsStoragePluginModule() {

{
provide: USER_OPTIONS,
useValue: options
},
{
provide: NGXS_PLUGINS,

@@ -99,3 +123,9 @@ useClass: NgxsStoragePlugin,

provide: NGXS_STORAGE_PLUGIN_OPTIONS,
useValue: Object.assign({}, defaultStoragePluginOptions, options)
useFactory: storageOptionsFactory,
deps: [USER_OPTIONS]
},
{
provide: STORAGE_ENGINE,
useFactory: engineFactory,
deps: [NGXS_STORAGE_PLUGIN_OPTIONS]
}

@@ -112,3 +142,3 @@ ]

export { NgxsStoragePluginModule, NgxsStoragePlugin, NGXS_STORAGE_PLUGIN_OPTIONS as ɵb };
export { NgxsStoragePluginModule, NgxsStoragePlugin, StorageOption, NGXS_STORAGE_PLUGIN_OPTIONS, STORAGE_ENGINE, USER_OPTIONS as ɵc, engineFactory as ɵb, storageOptionsFactory as ɵa };
//# sourceMappingURL=ngxs-storage-plugin.js.map
export { NgxsStoragePluginModule } from './src/storage.module';
export { NgxsStoragePlugin } from './src/storage.plugin';
export * from './src/symbols';

@@ -5,2 +5,2 @@ /**

export * from './index';
export { NGXS_STORAGE_PLUGIN_OPTIONS as ɵb, NgxsStoragePluginOptions as ɵa } from './src/symbols';
export { USER_OPTIONS as ɵc, engineFactory as ɵb, storageOptionsFactory as ɵa } from './src/storage.module';

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

{"__symbolic":"module","version":4,"metadata":{"NgxsStoragePluginModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule","line":13,"character":1}}],"members":{},"statics":{"forRoot":{"__symbolic":"function","parameters":["options"],"value":{"ngModule":{"__symbolic":"reference","name":"NgxsStoragePluginModule"},"providers":[{"provide":{"__symbolic":"reference","module":"@ngxs/store","name":"NGXS_PLUGINS","line":20,"character":19},"useClass":{"__symbolic":"reference","name":"NgxsStoragePlugin"},"multi":true},{"provide":{"__symbolic":"reference","name":"ɵb"},"useValue":{}}]}}}},"NgxsStoragePlugin":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":5,"character":1}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject","line":7,"character":15},"arguments":[{"__symbolic":"reference","name":"ɵb"}]}]],"parameters":[{"__symbolic":"reference","name":"ɵa"}]}],"handle":[{"__symbolic":"method"}]}},"ɵa":{"__symbolic":"interface"},"ɵb":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":25,"character":47},"arguments":["NGXS_STORAGE_PLUGIN_OPTION"]}},"origins":{"NgxsStoragePluginModule":"./src/storage.module","NgxsStoragePlugin":"./src/storage.plugin","ɵa":"./src/symbols","ɵb":"./src/symbols"},"importAs":"@ngxs/storage-plugin"}
{"__symbolic":"module","version":4,"metadata":{"ɵa":{"__symbolic":"function","parameters":["options"],"value":{}},"ɵb":{"__symbolic":"function"},"ɵc":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":34,"character":32},"arguments":["USER_OPTIONS"]},"NgxsStoragePluginModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule","line":36,"character":1}}],"members":{},"statics":{"forRoot":{"__symbolic":"function","parameters":["options"],"value":{"ngModule":{"__symbolic":"reference","name":"NgxsStoragePluginModule"},"providers":[{"provide":{"__symbolic":"reference","name":"ɵc"},"useValue":{"__symbolic":"reference","name":"options"}},{"provide":{"__symbolic":"reference","module":"@ngxs/store","name":"NGXS_PLUGINS","line":47,"character":19},"useClass":{"__symbolic":"reference","name":"NgxsStoragePlugin"},"multi":true},{"provide":{"__symbolic":"reference","name":"NGXS_STORAGE_PLUGIN_OPTIONS"},"useFactory":{"__symbolic":"reference","name":"ɵa"},"deps":[{"__symbolic":"reference","name":"ɵc"}]},{"provide":{"__symbolic":"reference","name":"STORAGE_ENGINE"},"useFactory":{"__symbolic":"reference","name":"ɵb"},"deps":[{"__symbolic":"reference","name":"NGXS_STORAGE_PLUGIN_OPTIONS"}]}]}}}},"NgxsStoragePlugin":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":6,"character":1}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject","line":9,"character":5},"arguments":[{"__symbolic":"reference","name":"NGXS_STORAGE_PLUGIN_OPTIONS"}]}],[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject","line":10,"character":5},"arguments":[{"__symbolic":"reference","name":"STORAGE_ENGINE"}]}]],"parameters":[{"__symbolic":"reference","name":"NgxsStoragePluginOptions"},{"__symbolic":"reference","name":"StorageEngine"}]}],"handle":[{"__symbolic":"method"}]}},"StorageOption":{"LocalStorage":0,"SessionStorage":1},"NgxsStoragePluginOptions":{"__symbolic":"interface"},"NGXS_STORAGE_PLUGIN_OPTIONS":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":31,"character":47},"arguments":["NGXS_STORAGE_PLUGIN_OPTION"]},"STORAGE_ENGINE":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":33,"character":34},"arguments":["STORAGE_ENGINE"]},"StorageEngine":{"__symbolic":"interface"}},"origins":{"ɵa":"./src/storage.module","ɵb":"./src/storage.module","ɵc":"./src/storage.module","NgxsStoragePluginModule":"./src/storage.module","NgxsStoragePlugin":"./src/storage.plugin","StorageOption":"./src/symbols","NgxsStoragePluginOptions":"./src/symbols","NGXS_STORAGE_PLUGIN_OPTIONS":"./src/symbols","STORAGE_ENGINE":"./src/symbols","StorageEngine":"./src/symbols"},"importAs":"@ngxs/storage-plugin"}
{
"name": "@ngxs/storage-plugin",
"description": "extendable storage plugin for @ngxs/store",
"version": "2.0.0-rc.21",
"version": "2.0.0-rc.22",
"peerDependencies": {
"@ngxs/store": "2.0.0-rc.21",
"@ngxs/store": "2.0.0-rc.22",
"@angular/core": "^5.0.0"

@@ -8,0 +8,0 @@ },

# @ngxs/storage-plugin
```TS
// app.module.ts
import { NgxsModule } from '@ngxs/store';
import { NgxsStoragePluginModule } from '@ngxs/storage-plugin';
@NgModule({
imports: [
NgxsModule.forRoot(),
NgxsStoragePluginModule.forRoot(),
]
})
export class AppModule { }
```
Storage plugin for NGXS. See [repo](https://github.com/ngxs/store) for more info.

@@ -1,6 +0,16 @@

import { ModuleWithProviders } from '@angular/core';
import { NgxsStoragePluginOptions } from './symbols';
export declare const defaultStoragePluginOptions: NgxsStoragePluginOptions;
import { ModuleWithProviders, InjectionToken } from '@angular/core';
import { NgxsStoragePluginOptions, StorageOption, StorageEngine } from './symbols';
export declare function storageOptionsFactory(options: NgxsStoragePluginOptions): {
key: string | string[];
storage: StorageOption;
serialize: {
(value: any, replacer?: (key: string, value: any) => any, space?: string | number): string;
(value: any, replacer?: (string | number)[], space?: string | number): string;
} | ((obj: any) => any);
deserialize: ((text: string, reviver?: (key: any, value: any) => any) => any) | ((obj: any) => any);
};
export declare function engineFactory(options: NgxsStoragePluginOptions): StorageEngine;
export declare const USER_OPTIONS: InjectionToken<{}>;
export declare class NgxsStoragePluginModule {
static forRoot(options?: NgxsStoragePluginOptions): ModuleWithProviders;
}
import { NgxsPlugin } from '@ngxs/store';
import { NgxsStoragePluginOptions } from './symbols';
import { NgxsStoragePluginOptions, StorageEngine } from './symbols';
export declare class NgxsStoragePlugin implements NgxsPlugin {
private _options;
constructor(_options: NgxsStoragePluginOptions);
private _engine;
constructor(_options: NgxsStoragePluginOptions, _engine: StorageEngine);
handle(state: any, event: any, next: any): any;
}
import { InjectionToken } from '@angular/core';
export declare enum StorageOption {
LocalStorage = 0,
SessionStorage = 1,
}
export interface NgxsStoragePluginOptions {

@@ -9,5 +13,6 @@ /**

* Storage engine to use. Deaults to localStorage but can provide
* sessionStorage or anything that implements those interfaces.
*
* sessionStorage or custom implementation of the StorageEngine interface
*/
storage?: any;
storage?: StorageOption;
/**

@@ -23,1 +28,10 @@ * Serailizer for the object before its pushed into the engine.

export declare const NGXS_STORAGE_PLUGIN_OPTIONS: InjectionToken<{}>;
export declare const STORAGE_ENGINE: InjectionToken<{}>;
export interface StorageEngine {
readonly length: number;
getItem(key: any): any;
setItem(key: any, val: any): void;
removeItem(key: any): void;
clear(): void;
key(val: number): string;
}

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