@ngxs/storage-plugin 3.7.5-dev.master-66b90a9 → 3.7.5-dev.master-7ca104f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/ngxs-storage-plugin.umd.js +162 -66
- package/bundles/ngxs-storage-plugin.umd.js.map +1 -1
- package/bundles/ngxs-storage-plugin.umd.min.js +1 -1
- package/bundles/ngxs-storage-plugin.umd.min.js.map +1 -1
- package/esm2015/index.js +2 -2
- package/esm2015/ngxs-storage-plugin.js +4 -3
- package/esm2015/src/engines.js +22 -0
- package/esm2015/src/internals/final-options.js +42 -0
- package/esm2015/src/internals/storage-key.js +47 -0
- package/esm2015/src/internals.js +13 -35
- package/esm2015/src/public_api.js +2 -1
- package/esm2015/src/storage.module.js +9 -3
- package/esm2015/src/storage.plugin.js +24 -30
- package/esm2015/src/symbols.js +9 -2
- package/esm5/index.js +2 -2
- package/esm5/ngxs-storage-plugin.js +4 -3
- package/esm5/src/engines.js +22 -0
- package/esm5/src/internals/final-options.js +43 -0
- package/esm5/src/internals/storage-key.js +47 -0
- package/esm5/src/internals.js +13 -35
- package/esm5/src/public_api.js +2 -1
- package/esm5/src/storage.module.js +9 -3
- package/esm5/src/storage.plugin.js +28 -33
- package/esm5/src/symbols.js +9 -2
- package/fesm2015/ngxs-storage-plugin.js +154 -63
- package/fesm2015/ngxs-storage-plugin.js.map +1 -1
- package/fesm5/ngxs-storage-plugin.js +158 -66
- package/fesm5/ngxs-storage-plugin.js.map +1 -1
- package/ngxs-storage-plugin.d.ts +2 -1
- package/ngxs-storage-plugin.metadata.json +1 -1
- package/package.json +1 -1
- package/src/engines.d.ts +4 -0
- package/src/internals/final-options.d.ts +10 -0
- package/src/internals/storage-key.d.ts +17 -0
- package/src/internals.d.ts +3 -9
- package/src/public_api.d.ts +1 -0
- package/src/storage.plugin.d.ts +3 -4
- package/src/symbols.d.ts +9 -3
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "../../node_modules/ng-packagr/package.schema.json",
|
|
3
3
|
"name": "@ngxs/storage-plugin",
|
|
4
4
|
"description": "extendable storage plugin for @ngxs/store",
|
|
5
|
-
"version": "3.7.5-dev.master-
|
|
5
|
+
"version": "3.7.5-dev.master-7ca104f",
|
|
6
6
|
"sideEffects": true,
|
|
7
7
|
"peerDependencies": {
|
|
8
8
|
"@angular/core": ">=6.1.0 <16.0.0",
|
package/src/engines.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { InjectionToken, Injector } from '@angular/core';
|
|
2
|
+
import { NgxsStoragePluginOptions, StorageEngine } from '../symbols';
|
|
3
|
+
export interface FinalNgxsStoragePluginOptions extends NgxsStoragePluginOptions {
|
|
4
|
+
keysWithEngines: {
|
|
5
|
+
key: string;
|
|
6
|
+
engine: StorageEngine;
|
|
7
|
+
}[];
|
|
8
|
+
}
|
|
9
|
+
export declare const FINAL_NGXS_STORAGE_PLUGIN_OPTIONS: InjectionToken<FinalNgxsStoragePluginOptions>;
|
|
10
|
+
export declare function createFinalStoragePluginOptions(injector: Injector, options: NgxsStoragePluginOptions): FinalNgxsStoragePluginOptions;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { InjectionToken, Type } from '@angular/core';
|
|
2
|
+
import { StateToken } from '@ngxs/store';
|
|
3
|
+
import { StateClass } from '@ngxs/store/internals';
|
|
4
|
+
import { StorageEngine } from '../symbols';
|
|
5
|
+
/** This enables the user to provide a storage engine per individual key. */
|
|
6
|
+
export interface KeyWithExplicitEngine {
|
|
7
|
+
key: string | StateClass | StateToken<any>;
|
|
8
|
+
engine: Type<StorageEngine> | InjectionToken<StorageEngine>;
|
|
9
|
+
}
|
|
10
|
+
/** Determines whether the provided key has the following structure. */
|
|
11
|
+
export declare function isKeyWithExplicitEngine(key: any): key is KeyWithExplicitEngine;
|
|
12
|
+
/**
|
|
13
|
+
* This tuples all of the possible types allowed in the `key` property.
|
|
14
|
+
* This is not exposed publicly and used internally only.
|
|
15
|
+
*/
|
|
16
|
+
export declare type StorageKey = string | StateClass | StateToken<any> | KeyWithExplicitEngine;
|
|
17
|
+
export declare function exctractStringKey(storageKey: StorageKey): string;
|
package/src/internals.d.ts
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
import { StateClass } from '@ngxs/store/internals';
|
|
2
|
-
import { StateToken } from '@ngxs/store';
|
|
3
1
|
import { StorageEngine, NgxsStoragePluginOptions } from './symbols';
|
|
4
2
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
3
|
+
* The following key is used to store the entire serialized
|
|
4
|
+
* state when there's no specific state provided.
|
|
7
5
|
*/
|
|
8
6
|
export declare const DEFAULT_STATE_KEY = "@@STATE";
|
|
9
|
-
/**
|
|
10
|
-
* Internal type definition for the `key` option provided
|
|
11
|
-
* in the `forRoot` method when importing module
|
|
12
|
-
*/
|
|
13
|
-
export declare type StorageKey = string | StateClass | StateToken<any> | (string | StateClass | StateToken<any>)[];
|
|
14
7
|
export declare function storageOptionsFactory(options: NgxsStoragePluginOptions | undefined): NgxsStoragePluginOptions;
|
|
15
8
|
export declare function engineFactory(options: NgxsStoragePluginOptions, platformId: string): StorageEngine | null;
|
|
9
|
+
export declare function getStorageKey(key: string, options?: NgxsStoragePluginOptions): string;
|
package/src/public_api.d.ts
CHANGED
package/src/storage.plugin.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { NgxsPlugin, NgxsNextPluginFn } from '@ngxs/store';
|
|
2
|
-
import {
|
|
2
|
+
import { FinalNgxsStoragePluginOptions } from './internals/final-options';
|
|
3
3
|
export declare class NgxsStoragePlugin implements NgxsPlugin {
|
|
4
4
|
private _options;
|
|
5
|
-
private _engine;
|
|
6
5
|
private _platformId;
|
|
7
|
-
private
|
|
6
|
+
private _keysWithEngines;
|
|
8
7
|
private _usesDefaultStateKey;
|
|
9
|
-
constructor(_options:
|
|
8
|
+
constructor(_options: FinalNgxsStoragePluginOptions, _platformId: string);
|
|
10
9
|
handle(state: any, event: any, next: NgxsNextPluginFn): any;
|
|
11
10
|
}
|
package/src/symbols.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { InjectionToken } from '@angular/core';
|
|
2
|
-
import { StorageKey } from './internals';
|
|
2
|
+
import { StorageKey } from './internals/storage-key';
|
|
3
3
|
export declare const enum StorageOption {
|
|
4
4
|
LocalStorage = 0,
|
|
5
5
|
SessionStorage = 1
|
|
@@ -8,7 +8,13 @@ export interface NgxsStoragePluginOptions {
|
|
|
8
8
|
/**
|
|
9
9
|
* Key for the state slice to store in the storage engine.
|
|
10
10
|
*/
|
|
11
|
-
key?: undefined | StorageKey;
|
|
11
|
+
key?: undefined | StorageKey | StorageKey[];
|
|
12
|
+
/**
|
|
13
|
+
* The namespace is used to prefix the key for the state slice. This is
|
|
14
|
+
* necessary when running micro frontend applications which use storage plugin.
|
|
15
|
+
* The namespace will eliminate the conflict between keys that might overlap.
|
|
16
|
+
*/
|
|
17
|
+
namespace?: string;
|
|
12
18
|
/**
|
|
13
19
|
* Storage engine to use. Deaults to localStorage but can provide
|
|
14
20
|
*
|
|
@@ -54,7 +60,7 @@ export interface NgxsStoragePluginOptions {
|
|
|
54
60
|
afterDeserialize?(obj: any, key: string): any;
|
|
55
61
|
}
|
|
56
62
|
export declare const NGXS_STORAGE_PLUGIN_OPTIONS: InjectionToken<{}>;
|
|
57
|
-
export declare const STORAGE_ENGINE: InjectionToken<
|
|
63
|
+
export declare const STORAGE_ENGINE: InjectionToken<StorageEngine>;
|
|
58
64
|
export interface StorageEngine {
|
|
59
65
|
readonly length: number;
|
|
60
66
|
getItem(key: string): any;
|