@ngxs/storage-plugin 18.1.2 → 18.1.3

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/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2018 <amcdaniel2@gmail.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ 'Software'), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/index.d.ts CHANGED
@@ -1,4 +1,48 @@
1
- /**
2
- * The public api for consumers of @ngxs/storage-plugin
3
- */
4
- export * from './src/public_api';
1
+ import * as i0 from '@angular/core';
2
+ import { ModuleWithProviders, EnvironmentProviders, InjectionToken } from '@angular/core';
3
+ import { NgxsStoragePluginOptions, StorageKey, StorageEngine } from '@ngxs/storage-plugin/internals';
4
+ export { NgxsStoragePluginOptions, STORAGE_ENGINE, StorageEngine, StorageOption } from '@ngxs/storage-plugin/internals';
5
+ import { NgxsPlugin, NgxsNextPluginFn } from '@ngxs/store/plugins';
6
+
7
+ declare class NgxsStoragePluginModule {
8
+ static forRoot(options: NgxsStoragePluginOptions): ModuleWithProviders<NgxsStoragePluginModule>;
9
+ static ɵfac: i0.ɵɵFactoryDeclaration<NgxsStoragePluginModule, never>;
10
+ static ɵmod: i0.ɵɵNgModuleDeclaration<NgxsStoragePluginModule, never, never, never>;
11
+ static ɵinj: i0.ɵɵInjectorDeclaration<NgxsStoragePluginModule>;
12
+ }
13
+ declare function withNgxsStoragePlugin(options: NgxsStoragePluginOptions): EnvironmentProviders;
14
+
15
+ declare function withStorageFeature(storageKeys: StorageKey[]): EnvironmentProviders;
16
+
17
+ interface KeyWithEngine {
18
+ key: string;
19
+ engine: StorageEngine;
20
+ }
21
+ declare class ɵNgxsStoragePluginKeysManager {
22
+ /** Store keys separately in a set so we're able to check if the key already exists. */
23
+ private readonly _keys;
24
+ private readonly _injector;
25
+ private readonly _keysWithEngines;
26
+ constructor();
27
+ getKeysWithEngines(): KeyWithEngine[];
28
+ addKeys(storageKeys: StorageKey[]): void;
29
+ static ɵfac: i0.ɵɵFactoryDeclaration<ɵNgxsStoragePluginKeysManager, never>;
30
+ static ɵprov: i0.ɵɵInjectableDeclaration<ɵNgxsStoragePluginKeysManager>;
31
+ }
32
+
33
+ declare class NgxsStoragePlugin implements NgxsPlugin {
34
+ private _keysManager;
35
+ private _options;
36
+ private _platformId;
37
+ private _allStatesPersisted;
38
+ constructor(_keysManager: ɵNgxsStoragePluginKeysManager, _options: NgxsStoragePluginOptions, _platformId: string);
39
+ handle(state: any, event: any, next: NgxsNextPluginFn): any;
40
+ private _hydrateSelectivelyOnUpdate;
41
+ static ɵfac: i0.ɵɵFactoryDeclaration<NgxsStoragePlugin, never>;
42
+ static ɵprov: i0.ɵɵInjectableDeclaration<NgxsStoragePlugin>;
43
+ }
44
+
45
+ declare const LOCAL_STORAGE_ENGINE: InjectionToken<StorageEngine | null>;
46
+ declare const SESSION_STORAGE_ENGINE: InjectionToken<StorageEngine | null>;
47
+
48
+ export { LOCAL_STORAGE_ENGINE, NgxsStoragePlugin, NgxsStoragePluginModule, SESSION_STORAGE_ENGINE, withNgxsStoragePlugin, withStorageFeature };
@@ -1,2 +1,95 @@
1
- export * from './symbols';
2
- export * from './storage-key';
1
+ import { Type, InjectionToken } from '@angular/core';
2
+ import { StateToken } from '@ngxs/store';
3
+ import { ɵStateClass as _StateClass } from '@ngxs/store/internals';
4
+
5
+ /** This enables the user to provide a storage engine per individual key. */
6
+ 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
+ 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
+ type StorageKey = string | _StateClass | StateToken<any> | KeyWithExplicitEngine;
17
+ declare function ɵextractStringKey(storageKey: StorageKey): string;
18
+
19
+ /**
20
+ * The following key is used to store the entire serialized
21
+ * state when no specific state is provided.
22
+ */
23
+ declare const ɵDEFAULT_STATE_KEY = "@@STATE";
24
+ declare const enum StorageOption {
25
+ LocalStorage = 0,
26
+ SessionStorage = 1
27
+ }
28
+ interface NgxsStoragePluginOptions {
29
+ /**
30
+ * Keys for the state slice to store in the storage engine.
31
+ */
32
+ keys: '*' | StorageKey[];
33
+ /**
34
+ * The namespace is used to prefix the key for the state slice. This is
35
+ * necessary when running micro frontend applications which use storage plugin.
36
+ * The namespace will eliminate the conflict between keys that might overlap.
37
+ */
38
+ namespace?: string;
39
+ /**
40
+ * Storage engine to use. Deaults to localStorage but can provide
41
+ *
42
+ * sessionStorage or custom implementation of the StorageEngine interface
43
+ */
44
+ storage?: StorageOption;
45
+ /**
46
+ * Migration strategies.
47
+ */
48
+ migrations?: {
49
+ /**
50
+ * Version to key off.
51
+ */
52
+ version: number | string;
53
+ /**
54
+ * Method to migrate the previous state.
55
+ */
56
+ migrate: (state: any) => any;
57
+ /**
58
+ * Key to migrate.
59
+ */
60
+ key?: string;
61
+ /**
62
+ * Key for the version. Defaults to 'version'.
63
+ */
64
+ versionKey?: string;
65
+ }[];
66
+ /**
67
+ * Serailizer for the object before its pushed into the engine.
68
+ */
69
+ serialize?(obj: any): string;
70
+ /**
71
+ * Deserializer for the object before its pulled out of the engine.
72
+ */
73
+ deserialize?(obj: any): any;
74
+ /**
75
+ * Method to alter object before serialization.
76
+ */
77
+ beforeSerialize?(obj: any, key: string): any;
78
+ /**
79
+ * Method to alter object after deserialization.
80
+ */
81
+ afterDeserialize?(obj: any, key: string): any;
82
+ }
83
+ interface ɵNgxsTransformedStoragePluginOptions extends NgxsStoragePluginOptions {
84
+ keys: StorageKey[];
85
+ }
86
+ declare const ɵUSER_OPTIONS: InjectionToken<NgxsStoragePluginOptions>;
87
+ declare const ɵALL_STATES_PERSISTED: InjectionToken<boolean>;
88
+ declare const ɵNGXS_STORAGE_PLUGIN_OPTIONS: InjectionToken<ɵNgxsTransformedStoragePluginOptions>;
89
+ declare const STORAGE_ENGINE: InjectionToken<StorageEngine>;
90
+ interface StorageEngine {
91
+ getItem(key: string): any;
92
+ setItem(key: string, value: any): void;
93
+ }
94
+
95
+ export { type KeyWithExplicitEngine, type NgxsStoragePluginOptions, STORAGE_ENGINE, type StorageEngine, type StorageKey, StorageOption, ɵALL_STATES_PERSISTED, ɵDEFAULT_STATE_KEY, ɵNGXS_STORAGE_PLUGIN_OPTIONS, type ɵNgxsTransformedStoragePluginOptions, ɵUSER_OPTIONS, ɵextractStringKey, ɵisKeyWithExplicitEngine };
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@ngxs/storage-plugin",
3
3
  "description": "extendable storage plugin for @ngxs/store",
4
- "version": "18.1.2",
4
+ "version": "18.1.3",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {
7
- "@ngxs/store": "^18.1.2 || ^18.1.2-dev",
7
+ "@ngxs/store": "^18.1.3 || ^18.1.3-dev",
8
8
  "@angular/core": ">=16.0.0 <19.0.0",
9
9
  "rxjs": ">=6.5.5",
10
10
  "ts-morph": "21.0.1"
@@ -1,17 +0,0 @@
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 type StorageKey = string | ɵStateClass | StateToken<any> | KeyWithExplicitEngine;
17
- export declare function ɵextractStringKey(storageKey: StorageKey): string;
@@ -1,77 +0,0 @@
1
- import { InjectionToken } from '@angular/core';
2
- import { StorageKey } from './storage-key';
3
- /**
4
- * The following key is used to store the entire serialized
5
- * state when no specific state is provided.
6
- */
7
- export declare const ɵDEFAULT_STATE_KEY = "@@STATE";
8
- export declare const enum StorageOption {
9
- LocalStorage = 0,
10
- SessionStorage = 1
11
- }
12
- export interface NgxsStoragePluginOptions {
13
- /**
14
- * Keys for the state slice to store in the storage engine.
15
- */
16
- keys: '*' | StorageKey[];
17
- /**
18
- * The namespace is used to prefix the key for the state slice. This is
19
- * necessary when running micro frontend applications which use storage plugin.
20
- * The namespace will eliminate the conflict between keys that might overlap.
21
- */
22
- namespace?: string;
23
- /**
24
- * Storage engine to use. Deaults to localStorage but can provide
25
- *
26
- * sessionStorage or custom implementation of the StorageEngine interface
27
- */
28
- storage?: StorageOption;
29
- /**
30
- * Migration strategies.
31
- */
32
- migrations?: {
33
- /**
34
- * Version to key off.
35
- */
36
- version: number | string;
37
- /**
38
- * Method to migrate the previous state.
39
- */
40
- migrate: (state: any) => any;
41
- /**
42
- * Key to migrate.
43
- */
44
- key?: string;
45
- /**
46
- * Key for the version. Defaults to 'version'.
47
- */
48
- versionKey?: string;
49
- }[];
50
- /**
51
- * Serailizer for the object before its pushed into the engine.
52
- */
53
- serialize?(obj: any): string;
54
- /**
55
- * Deserializer for the object before its pulled out of the engine.
56
- */
57
- deserialize?(obj: any): any;
58
- /**
59
- * Method to alter object before serialization.
60
- */
61
- beforeSerialize?(obj: any, key: string): any;
62
- /**
63
- * Method to alter object after deserialization.
64
- */
65
- afterDeserialize?(obj: any, key: string): any;
66
- }
67
- export interface ɵNgxsTransformedStoragePluginOptions extends NgxsStoragePluginOptions {
68
- keys: StorageKey[];
69
- }
70
- export declare const ɵUSER_OPTIONS: InjectionToken<NgxsStoragePluginOptions>;
71
- export declare const ɵALL_STATES_PERSISTED: InjectionToken<boolean>;
72
- export declare const ɵNGXS_STORAGE_PLUGIN_OPTIONS: InjectionToken<ɵNgxsTransformedStoragePluginOptions>;
73
- export declare const STORAGE_ENGINE: InjectionToken<StorageEngine>;
74
- export interface StorageEngine {
75
- getItem(key: string): any;
76
- setItem(key: string, value: any): void;
77
- }
package/src/engines.d.ts DELETED
@@ -1,4 +0,0 @@
1
- import { InjectionToken } from '@angular/core';
2
- import { StorageEngine } from '@ngxs/storage-plugin/internals';
3
- export declare const LOCAL_STORAGE_ENGINE: InjectionToken<StorageEngine | null>;
4
- export declare const SESSION_STORAGE_ENGINE: InjectionToken<StorageEngine | null>;
@@ -1,4 +0,0 @@
1
- import { StorageEngine, NgxsStoragePluginOptions, ɵNgxsTransformedStoragePluginOptions } from '@ngxs/storage-plugin/internals';
2
- export declare function storageOptionsFactory(options: NgxsStoragePluginOptions): ɵNgxsTransformedStoragePluginOptions;
3
- export declare function engineFactory(options: NgxsStoragePluginOptions, platformId: string): StorageEngine | null;
4
- export declare function getStorageKey(key: string, options?: NgxsStoragePluginOptions): string;
@@ -1,18 +0,0 @@
1
- import { StorageEngine, StorageKey } from '@ngxs/storage-plugin/internals';
2
- import * as i0 from "@angular/core";
3
- interface KeyWithEngine {
4
- key: string;
5
- engine: StorageEngine;
6
- }
7
- export declare class ɵNgxsStoragePluginKeysManager {
8
- /** Store keys separately in a set so we're able to check if the key already exists. */
9
- private readonly _keys;
10
- private readonly _injector;
11
- private readonly _keysWithEngines;
12
- constructor();
13
- getKeysWithEngines(): KeyWithEngine[];
14
- addKeys(storageKeys: StorageKey[]): void;
15
- static ɵfac: i0.ɵɵFactoryDeclaration<ɵNgxsStoragePluginKeysManager, never>;
16
- static ɵprov: i0.ɵɵInjectableDeclaration<ɵNgxsStoragePluginKeysManager>;
17
- }
18
- export {};
@@ -1,5 +0,0 @@
1
- export { NgxsStoragePluginModule, withNgxsStoragePlugin } from './storage.module';
2
- export { withStorageFeature } from './with-storage-feature';
3
- export { NgxsStoragePlugin } from './storage.plugin';
4
- export * from './engines';
5
- export { StorageOption, NgxsStoragePluginOptions, STORAGE_ENGINE, StorageEngine } from '@ngxs/storage-plugin/internals';
@@ -1,10 +0,0 @@
1
- import { ModuleWithProviders, EnvironmentProviders } from '@angular/core';
2
- import { NgxsStoragePluginOptions } from '@ngxs/storage-plugin/internals';
3
- import * as i0 from "@angular/core";
4
- export declare class NgxsStoragePluginModule {
5
- static forRoot(options: NgxsStoragePluginOptions): ModuleWithProviders<NgxsStoragePluginModule>;
6
- static ɵfac: i0.ɵɵFactoryDeclaration<NgxsStoragePluginModule, never>;
7
- static ɵmod: i0.ɵɵNgModuleDeclaration<NgxsStoragePluginModule, never, never, never>;
8
- static ɵinj: i0.ɵɵInjectorDeclaration<NgxsStoragePluginModule>;
9
- }
10
- export declare function withNgxsStoragePlugin(options: NgxsStoragePluginOptions): EnvironmentProviders;
@@ -1,15 +0,0 @@
1
- import { NgxsPlugin, NgxsNextPluginFn } from '@ngxs/store/plugins';
2
- import { NgxsStoragePluginOptions } from '@ngxs/storage-plugin/internals';
3
- import { ɵNgxsStoragePluginKeysManager } from './keys-manager';
4
- import * as i0 from "@angular/core";
5
- export declare class NgxsStoragePlugin implements NgxsPlugin {
6
- private _keysManager;
7
- private _options;
8
- private _platformId;
9
- private _allStatesPersisted;
10
- constructor(_keysManager: ɵNgxsStoragePluginKeysManager, _options: NgxsStoragePluginOptions, _platformId: string);
11
- handle(state: any, event: any, next: NgxsNextPluginFn): any;
12
- private _hydrateSelectivelyOnUpdate;
13
- static ɵfac: i0.ɵɵFactoryDeclaration<NgxsStoragePlugin, never>;
14
- static ɵprov: i0.ɵɵInjectableDeclaration<NgxsStoragePlugin>;
15
- }
@@ -1,3 +0,0 @@
1
- import { EnvironmentProviders } from '@angular/core';
2
- import { StorageKey } from '@ngxs/storage-plugin/internals';
3
- export declare function withStorageFeature(storageKeys: StorageKey[]): EnvironmentProviders;