ng-simple-state 20.1.6 → 20.1.8
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/README.md
CHANGED
|
@@ -513,6 +513,21 @@ export abstract class NgSimpleStateBaseRxjsStore<S extends object | Array<any>>
|
|
|
513
513
|
* @returns True if the state is changed
|
|
514
514
|
*/
|
|
515
515
|
setState(stateFn: NgSimpleStateSetState<S>, actionName?: string): boolean;
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* Replace state
|
|
519
|
+
* @param newState New state
|
|
520
|
+
* @param actionName The action label into Redux DevTools (default is parent function name)
|
|
521
|
+
* @returns True if the state is changed
|
|
522
|
+
*/
|
|
523
|
+
replaceState(newState: S, actionName?: string): boolean;
|
|
524
|
+
/**
|
|
525
|
+
* Replace state
|
|
526
|
+
* @param selectFn State reducer
|
|
527
|
+
* @param actionName The action label into Redux DevTools (default is parent function name)
|
|
528
|
+
* @returns True if the state is changed
|
|
529
|
+
*/
|
|
530
|
+
replaceState(stateFn: NgSimpleStateReplaceState<S>, actionName?: string): boolean;
|
|
516
531
|
}
|
|
517
532
|
```
|
|
518
533
|
## Signal Store
|
|
@@ -960,7 +975,22 @@ export abstract class NgSimpleStateBaseSignalStore<S extends object | Array<any>
|
|
|
960
975
|
* @param actionName The action label into Redux DevTools (default is parent function name)
|
|
961
976
|
* @returns True if the state is changed
|
|
962
977
|
*/
|
|
963
|
-
setState(stateFn: NgSimpleStateSetState<S>, actionName?: string): boolean;
|
|
978
|
+
setState(stateFn: NgSimpleStateSetState<S>, actionName?: string): boolean;
|
|
979
|
+
|
|
980
|
+
/**
|
|
981
|
+
* Replace state
|
|
982
|
+
* @param newState New state
|
|
983
|
+
* @param actionName The action label into Redux DevTools (default is parent function name)
|
|
984
|
+
* @returns True if the state is changed
|
|
985
|
+
*/
|
|
986
|
+
replaceState(newState: S, actionName?: string): boolean;
|
|
987
|
+
/**
|
|
988
|
+
* Replace state
|
|
989
|
+
* @param selectFn State reducer
|
|
990
|
+
* @param actionName The action label into Redux DevTools (default is parent function name)
|
|
991
|
+
* @returns True if the state is changed
|
|
992
|
+
*/
|
|
993
|
+
replaceState(stateFn: NgSimpleStateReplaceState<S>, actionName?: string): boolean;
|
|
964
994
|
}
|
|
965
995
|
```
|
|
966
996
|
|
|
@@ -8,6 +8,7 @@ import { map, distinctUntilChanged, observeOn } from 'rxjs/operators';
|
|
|
8
8
|
*/
|
|
9
9
|
const NG_SIMPLE_STORE_CONFIG = new InjectionToken('ng-simple-state.config');
|
|
10
10
|
|
|
11
|
+
/** @deprecated use `provideNgSimpleState(ngSimpleStateConfig)` */
|
|
11
12
|
class NgSimpleStateModule {
|
|
12
13
|
static forRoot(ngSimpleStateConfig) {
|
|
13
14
|
return {
|
|
@@ -20,11 +21,11 @@ class NgSimpleStateModule {
|
|
|
20
21
|
],
|
|
21
22
|
};
|
|
22
23
|
}
|
|
23
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
24
|
-
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "
|
|
25
|
-
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
|
|
24
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.0", ngImport: i0, type: NgSimpleStateModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
25
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.0.0", ngImport: i0, type: NgSimpleStateModule }); }
|
|
26
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.0.0", ngImport: i0, type: NgSimpleStateModule }); }
|
|
26
27
|
}
|
|
27
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
28
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.0", ngImport: i0, type: NgSimpleStateModule, decorators: [{
|
|
28
29
|
type: NgModule
|
|
29
30
|
}] });
|
|
30
31
|
|
|
@@ -70,10 +71,10 @@ class NgSimpleStateDevTool {
|
|
|
70
71
|
}
|
|
71
72
|
return false;
|
|
72
73
|
}
|
|
73
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
74
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
74
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.0", ngImport: i0, type: NgSimpleStateDevTool, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
75
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.0", ngImport: i0, type: NgSimpleStateDevTool, providedIn: 'root' }); }
|
|
75
76
|
}
|
|
76
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
77
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.0", ngImport: i0, type: NgSimpleStateDevTool, decorators: [{
|
|
77
78
|
type: Injectable,
|
|
78
79
|
args: [{ providedIn: 'root' }]
|
|
79
80
|
}], ctorParameters: () => [] });
|
|
@@ -199,15 +200,15 @@ class NgSimpleStateBaseCommonStore {
|
|
|
199
200
|
* - otherwise the initial state provided from `initialState()` method.
|
|
200
201
|
*/
|
|
201
202
|
resetState() {
|
|
202
|
-
return this.
|
|
203
|
+
return this.replaceState(this.firstState, 'resetState');
|
|
203
204
|
}
|
|
204
205
|
/**
|
|
205
206
|
* Restart the store to initial state provided from `initialState()` method
|
|
206
207
|
*/
|
|
207
208
|
restartState() {
|
|
208
|
-
return this.
|
|
209
|
+
return this.replaceState(this.initState, 'restartState');
|
|
209
210
|
}
|
|
210
|
-
|
|
211
|
+
_setState(stateFnOrNewState, actionName) {
|
|
211
212
|
const currState = this.getCurrentState();
|
|
212
213
|
let newState;
|
|
213
214
|
if (typeof stateFnOrNewState === 'function') {
|
|
@@ -238,6 +239,27 @@ class NgSimpleStateBaseCommonStore {
|
|
|
238
239
|
this.storage && this.statePersist(state);
|
|
239
240
|
return state;
|
|
240
241
|
}
|
|
242
|
+
_replaceState(stateFnOrReplaceState, actionName) {
|
|
243
|
+
const currState = this.getCurrentState();
|
|
244
|
+
let newState;
|
|
245
|
+
if (typeof stateFnOrReplaceState === 'function') {
|
|
246
|
+
newState = stateFnOrReplaceState(currState);
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
newState = stateFnOrReplaceState;
|
|
250
|
+
}
|
|
251
|
+
if (currState === newState) {
|
|
252
|
+
return undefined;
|
|
253
|
+
}
|
|
254
|
+
// If comparator is provided, use it to detect equality (avoids further work)
|
|
255
|
+
if (this.comparator && this.comparator(currState, newState)) {
|
|
256
|
+
return undefined;
|
|
257
|
+
}
|
|
258
|
+
// avoid function call if not necessary
|
|
259
|
+
this.devTool && this.devToolSend(newState, actionName);
|
|
260
|
+
this.storage && this.statePersist(newState);
|
|
261
|
+
return newState;
|
|
262
|
+
}
|
|
241
263
|
/**
|
|
242
264
|
* Send to dev tool a new state
|
|
243
265
|
* @param newState new state
|
|
@@ -303,11 +325,11 @@ class NgSimpleStateBaseCommonStore {
|
|
|
303
325
|
this.storage.setItem(this.storeName, state);
|
|
304
326
|
}
|
|
305
327
|
}
|
|
306
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
307
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "
|
|
308
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
328
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.0", ngImport: i0, type: NgSimpleStateBaseCommonStore, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
329
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.0.0", type: NgSimpleStateBaseCommonStore, isStandalone: true, ngImport: i0 }); }
|
|
330
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.0", ngImport: i0, type: NgSimpleStateBaseCommonStore }); }
|
|
309
331
|
}
|
|
310
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
332
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.0", ngImport: i0, type: NgSimpleStateBaseCommonStore, decorators: [{
|
|
311
333
|
type: Injectable
|
|
312
334
|
}, {
|
|
313
335
|
type: Directive
|
|
@@ -355,18 +377,26 @@ class NgSimpleStateBaseRxjsStore extends NgSimpleStateBaseCommonStore {
|
|
|
355
377
|
return this.devMode ? this.deepFreeze(this.state$.getValue()) : this.state$.getValue();
|
|
356
378
|
}
|
|
357
379
|
setState(stateFnOrNewState, actionName) {
|
|
358
|
-
const state = this.
|
|
380
|
+
const state = this._setState(stateFnOrNewState, actionName);
|
|
359
381
|
if (typeof state !== 'undefined') {
|
|
360
382
|
this.state$.next(state);
|
|
361
383
|
return true;
|
|
362
384
|
}
|
|
363
385
|
return false;
|
|
364
386
|
}
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
387
|
+
replaceState(stateFnOrNewState, actionName) {
|
|
388
|
+
const state = this._replaceState(stateFnOrNewState, actionName);
|
|
389
|
+
if (typeof state !== 'undefined') {
|
|
390
|
+
this.state$.next(state);
|
|
391
|
+
return true;
|
|
392
|
+
}
|
|
393
|
+
return false;
|
|
394
|
+
}
|
|
395
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.0", ngImport: i0, type: NgSimpleStateBaseRxjsStore, deps: null, target: i0.ɵɵFactoryTarget.Directive }); }
|
|
396
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.0.0", type: NgSimpleStateBaseRxjsStore, isStandalone: true, usesInheritance: true, ngImport: i0 }); }
|
|
397
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.0", ngImport: i0, type: NgSimpleStateBaseRxjsStore }); }
|
|
368
398
|
}
|
|
369
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
399
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.0", ngImport: i0, type: NgSimpleStateBaseRxjsStore, decorators: [{
|
|
370
400
|
type: Injectable
|
|
371
401
|
}, {
|
|
372
402
|
type: Directive
|
|
@@ -377,7 +407,7 @@ class NgSimpleStateBaseSignalStore extends NgSimpleStateBaseCommonStore {
|
|
|
377
407
|
constructor() {
|
|
378
408
|
super(...arguments);
|
|
379
409
|
this.stackPoint = 4;
|
|
380
|
-
this.stateSig = signal(this.firstState);
|
|
410
|
+
this.stateSig = signal(this.firstState, ...(ngDevMode ? [{ debugName: "stateSig" }] : []));
|
|
381
411
|
this.stateSigRo = this.stateSig.asReadonly();
|
|
382
412
|
}
|
|
383
413
|
/**
|
|
@@ -407,32 +437,46 @@ class NgSimpleStateBaseSignalStore extends NgSimpleStateBaseCommonStore {
|
|
|
407
437
|
return this.devMode ? this.deepFreeze(this.stateSig()) : this.stateSig();
|
|
408
438
|
}
|
|
409
439
|
setState(stateFnOrNewState, actionName) {
|
|
410
|
-
const state = this.
|
|
440
|
+
const state = this._setState(stateFnOrNewState, actionName);
|
|
441
|
+
if (typeof state !== 'undefined') {
|
|
442
|
+
this.stateSig.set(state);
|
|
443
|
+
return true;
|
|
444
|
+
}
|
|
445
|
+
return false;
|
|
446
|
+
}
|
|
447
|
+
replaceState(stateFnOrReplaceState, actionName) {
|
|
448
|
+
const state = this._replaceState(stateFnOrReplaceState, actionName);
|
|
411
449
|
if (typeof state !== 'undefined') {
|
|
412
450
|
this.stateSig.set(state);
|
|
413
451
|
return true;
|
|
414
452
|
}
|
|
415
453
|
return false;
|
|
416
454
|
}
|
|
417
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
418
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "
|
|
419
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
455
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.0", ngImport: i0, type: NgSimpleStateBaseSignalStore, deps: null, target: i0.ɵɵFactoryTarget.Directive }); }
|
|
456
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.0.0", type: NgSimpleStateBaseSignalStore, isStandalone: true, usesInheritance: true, ngImport: i0 }); }
|
|
457
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.0", ngImport: i0, type: NgSimpleStateBaseSignalStore }); }
|
|
420
458
|
}
|
|
421
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
459
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.0", ngImport: i0, type: NgSimpleStateBaseSignalStore, decorators: [{
|
|
422
460
|
type: Injectable
|
|
423
461
|
}, {
|
|
424
462
|
type: Directive
|
|
425
463
|
}] });
|
|
426
464
|
|
|
465
|
+
/**
|
|
466
|
+
* Provide NgSimpleState with optional global configuration
|
|
467
|
+
* @param {NgSimpleStateConfig} ngSimpleStateConfig
|
|
468
|
+
* @returns {EnvironmentProviders[]}
|
|
469
|
+
*/
|
|
427
470
|
function provideNgSimpleState(ngSimpleStateConfig) {
|
|
428
|
-
const providers = [];
|
|
429
471
|
if (ngSimpleStateConfig) {
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
472
|
+
return [
|
|
473
|
+
makeEnvironmentProviders([{
|
|
474
|
+
provide: NG_SIMPLE_STORE_CONFIG,
|
|
475
|
+
useValue: ngSimpleStateConfig,
|
|
476
|
+
}])
|
|
477
|
+
];
|
|
434
478
|
}
|
|
435
|
-
return
|
|
479
|
+
return [];
|
|
436
480
|
}
|
|
437
481
|
|
|
438
482
|
/*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ng-simple-state.mjs","sources":["../../../projects/ng-simple-state/src/lib/ng-simple-state-models.ts","../../../projects/ng-simple-state/src/lib/ng-simple-state.module.ts","../../../projects/ng-simple-state/src/lib/tool/ng-simple-state-dev-tool.ts","../../../projects/ng-simple-state/src/lib/storage/ng-simple-state-browser-storage.ts","../../../projects/ng-simple-state/src/lib/storage/ng-simple-state-local-storage.ts","../../../projects/ng-simple-state/src/lib/storage/ng-simple-state-session-storage.ts","../../../projects/ng-simple-state/src/lib/ng-simple-state-common.ts","../../../projects/ng-simple-state/src/lib/rxjs/ng-simple-state-base-store.ts","../../../projects/ng-simple-state/src/lib/signal/ng-simple-state-base-store.ts","../../../projects/ng-simple-state/src/lib/ng-simple-state-provider.ts","../../../projects/ng-simple-state/src/public-api.ts","../../../projects/ng-simple-state/src/ng-simple-state.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\nimport type { NgSimpleStateStorage } from './storage/ng-simple-state-browser-storage';\n\nexport type NgSimpleStateSetState<S> = (currentState: Readonly<S>) => Partial<S>;\nexport type NgSimpleStateSelectState<S, K> = (state: Readonly<S>) => K;\n/* eslint-disable-next-line @typescript-eslint/no-explicit-any */\nexport type NgSimpleStateComparator<K = any> = (previous: K, current: K) => boolean;\n\n/**\n * NgSimpleState config option\n */\n/* eslint-disable-next-line @typescript-eslint/no-explicit-any */\nexport interface NgSimpleStateConfig<K = any> {\n /**\n * if `true` enable `Redux DevTools` browser extension for inspect the state of the store.\n */\n enableDevTool?: boolean;\n /**\n * Set the persistent storage `local`, `session` or instance of `NgSimpleStateStorage`.\n */\n persistentStorage?: 'session' | 'local' | NgSimpleStateStorage;\n /**\n * A function used to compare the previous and current state for equality. \n */\n comparator?: NgSimpleStateComparator<K>;\n /**\n * A function used to serialize the state to a string.\n */\n serializeState?: (state: K) => string;\n /**\n * A function used to deserialize the state from a string. \n */\n deserializeState?: (state: string) => K;\n}\n\n/**\n * NgSimpleState config option for store\n */\n/* eslint-disable-next-line @typescript-eslint/no-explicit-any */\nexport interface NgSimpleStateStoreConfig<K = any> extends NgSimpleStateConfig<K> {\n /** \n * The store name \n */\n storeName: string;\n}\n\n/**\n * NgSimpleState config InjectionToken\n */\nexport const NG_SIMPLE_STORE_CONFIG = new InjectionToken<NgSimpleStateConfig>(\n 'ng-simple-state.config'\n);\n\nexport type StateFnOrNewState<S> = Partial<S> | NgSimpleStateSetState<S>;\n","import { ModuleWithProviders, NgModule } from '@angular/core';\r\nimport { NgSimpleStateConfig, NG_SIMPLE_STORE_CONFIG } from './ng-simple-state-models';\r\n\r\n@NgModule()\r\nexport class NgSimpleStateModule {\r\n static forRoot(\r\n ngSimpleStateConfig?: NgSimpleStateConfig\r\n ): ModuleWithProviders<NgSimpleStateModule> {\r\n return {\r\n ngModule: NgSimpleStateModule,\r\n providers: [\r\n {\r\n provide: NG_SIMPLE_STORE_CONFIG,\r\n useValue: ngSimpleStateConfig,\r\n },\r\n ],\r\n };\r\n }\r\n}\r\n","import { inject, Injectable, NgZone } from '@angular/core';\n\ninterface DevtoolsLocal {\n init: (state: object) => void;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n send: <T>(action: string, state: Record<string, T>, options: any, instanceId: string) => void;\n}\ninterface Devtools {\n connect(options: { name: string, instanceId: string }): DevtoolsLocal;\n}\n\ndeclare global {\n interface Window {\n __REDUX_DEVTOOLS_EXTENSION__: Devtools;\n devToolsExtension: Devtools;\n }\n}\n\nconst instanceId = `ng-simple-state-${Date.now()}-${Math.random()}`;\n\n@Injectable({ providedIn: 'root' })\nexport class NgSimpleStateDevTool {\n\n private readonly globalDevtools: Devtools = window.__REDUX_DEVTOOLS_EXTENSION__ || window.devToolsExtension;\n private localDevTool!: DevtoolsLocal;\n private readonly baseState: Record<string, object> = {};\n\n constructor() {\n if (this.globalDevtools) {\n // The `connect` method adds `message` event listener since it communicates\n // with an extension through `window.postMessage` and message events.\n // We handle only 2 events; thus, we don't want to run many change detections\n // because the extension sends events that we don't have to handle.\n inject(NgZone).runOutsideAngular(() => {\n this.localDevTool = this.globalDevtools.connect({\n name: 'NgSimpleState',\n instanceId: instanceId\n });\n if (this.localDevTool) {\n this.localDevTool.init(this.baseState);\n }\n });\n }\n }\n\n /**\n * Return true if dev tool is active\n * @returns True if dev tool is active\n */\n isActive(): boolean {\n return !!this.localDevTool;\n }\n\n /**\n * Send to dev tool a new state\n * @param storeName The store name\n * @param actionName The action name\n * @param state the state\n * @returns True if dev tool is enabled and action is send\n */\n send<T>(storeName: string, actionName: string, state: T): boolean {\n if (this.localDevTool) {\n this.localDevTool.send<T>(`${storeName}.${actionName}`, Object.assign(this.baseState, { [storeName]: state }), false, instanceId);\n return true;\n }\n return false;\n }\n}\n","import { NgSimpleStateStoreConfig } from \"../ng-simple-state-models\";\n\nexport const BASE_KEY = 'NgSimpleState::';\n\nexport abstract class NgSimpleStateStorage<K = unknown> {\n\n /**\n * A function used to serialize the state to a string.\n */\n private serializeState: (state: K) => string;\n \n /**\n * A function used to deserialize the state from a string. \n */\n private deserializeState: (state: string) => K;\n\n constructor(private storage: Storage, config?: NgSimpleStateStoreConfig<K>) { \n this.serializeState = config?.serializeState ? config.serializeState : JSON.stringify;\n this.deserializeState = config?.deserializeState ? config.deserializeState : JSON.parse;\n }\n\n /**\n * Set item into storage\n * @param key key name\n * @param state state value\n * @returns True if item is stored into storage\n */\n setItem(key: string, state: K): boolean {\n this.storage.setItem(BASE_KEY + key, this.serializeState(state));\n return true;\n }\n\n /**\n * Return item from storage\n * @param key key name\n * @returns the item\n */\n getItem(key: string): K | null {\n const state = this.storage.getItem(BASE_KEY + key);\n if (state) {\n return this.deserializeState(state);\n }\n return null;\n }\n\n /**\n * Remove item from storage\n * @param {string} key key name\n * @returns True if item is removed\n */\n removeItem(key: string): boolean {\n this.storage.removeItem(BASE_KEY + key);\n return true;\n }\n\n /**\n * Removes all key/value pairs, if there are any.\n * @returns True if storage is cleared\n */\n clear(): boolean {\n for (let i = this.storage.length; i >= 0; i--) {\n const key = this.storage.key(i);\n if (key && key.startsWith(BASE_KEY)) {\n this.storage.removeItem(key);\n }\n }\n return true;\n }\n}\n","import { NgSimpleStateStoreConfig } from '../ng-simple-state-models';\nimport { NgSimpleStateStorage } from './ng-simple-state-browser-storage';\n\nexport class NgSimpleStateLocalStorage<K = unknown> extends NgSimpleStateStorage<K> {\n constructor(config?: NgSimpleStateStoreConfig<K>) {\n super(localStorage, config);\n }\n}\n","\nimport { NgSimpleStateStoreConfig } from '../ng-simple-state-models';\nimport { NgSimpleStateStorage } from './ng-simple-state-browser-storage';\n\nexport class NgSimpleStateSessionStorage<K = unknown> extends NgSimpleStateStorage<K> {\n constructor(config?: NgSimpleStateStoreConfig<K>) {\n super(sessionStorage, config);\n }\n}\n","import { Injectable, OnDestroy, Directive, isDevMode, inject } from '@angular/core';\nimport { NgSimpleStateDevTool } from './tool/ng-simple-state-dev-tool';\nimport type { NgSimpleStateStorage } from './storage/ng-simple-state-browser-storage';\nimport { NgSimpleStateLocalStorage } from './storage/ng-simple-state-local-storage';\nimport { NgSimpleStateSessionStorage } from './storage/ng-simple-state-session-storage';\nimport { type NgSimpleStateStoreConfig, NG_SIMPLE_STORE_CONFIG, type NgSimpleStateSetState, type NgSimpleStateComparator, type NgSimpleStateSelectState, type StateFnOrNewState, NgSimpleStateConfig } from './ng-simple-state-models';\n\n\n@Injectable()\n@Directive()\nexport abstract class NgSimpleStateBaseCommonStore<S extends object | Array<unknown>> implements OnDestroy {\n\n protected abstract stackPoint: number;\n protected devTool?: NgSimpleStateDevTool;\n protected storage?: NgSimpleStateStorage<S>;\n protected storeName: string;\n protected firstState!: S;\n protected initState!: S;\n protected isArray: boolean;\n protected devMode: boolean = isDevMode();\n protected comparator?: NgSimpleStateComparator<S>;\n\n constructor() {\n\n const globalConfig: NgSimpleStateConfig<S> | null = inject(NG_SIMPLE_STORE_CONFIG, { optional: true })\n const storeConfig = this.storeConfig();\n const config = { ...globalConfig, ...storeConfig };\n\n if (config.persistentStorage === 'local') {\n this.storage = new NgSimpleStateLocalStorage(config);\n } else if (config.persistentStorage === 'session') {\n this.storage = new NgSimpleStateSessionStorage(config);\n } else if (typeof config.persistentStorage === 'object') {\n this.storage = config.persistentStorage as NgSimpleStateStorage<S>;\n }\n\n if (config.enableDevTool) {\n this.devTool = inject(NgSimpleStateDevTool);\n }\n\n this.storeName = config.storeName;\n\n if (typeof config.comparator === 'function') {\n this.comparator = config.comparator;\n }\n\n if (this.storage) {\n const firstState = this.storage.getItem(this.storeName);\n if (firstState) {\n this.firstState = firstState;\n }\n }\n\n this.initState = this.initialState();\n if (!this.firstState) {\n this.firstState = this.initState;\n }\n\n this.devToolSend(this.firstState, 'initialState');\n\n this.isArray = Array.isArray(this.firstState);\n }\n\n /**\n * When you override this method, you have to call the `super.ngOnDestroy()` method in your `ngOnDestroy()` method.\n */\n ngOnDestroy(): void {\n this.devToolSend(undefined, 'ngOnDestroy');\n }\n\n /**\n * Override this method for set a specific config for the store\n * @returns NgSimpleStateStoreConfig\n */\n protected abstract storeConfig(): NgSimpleStateStoreConfig;\n\n /**\n * Set into the store the initial state\n * @returns The state object\n */\n protected abstract initialState(): S;\n\n /**\n * Select a store state\n * @param selectFn State selector (if not provided return full state)\n * @param comparator A function used to compare the previous and current state for equality. Defaults to a `===` check.\n * @returns Observable of the selected state\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n abstract selectState<K = Partial<S>>(selectFn?: NgSimpleStateSelectState<S, K>, comparator?: NgSimpleStateComparator<K>): any;\n\n /**\n * Set a new state\n * @param newState New state\n * @param actionName The action label into Redux DevTools (default is parent function name)\n * @returns True if the state is changed\n */\n abstract setState(newState: Partial<S>, actionName?: string): boolean;\n\n /**\n * Set a new state\n * @param selectFn State reducer\n * @param actionName The action label into Redux DevTools (default is parent function name)\n * @returns True if the state is changed\n */\n abstract setState(stateFn: NgSimpleStateSetState<S>, actionName?: string): boolean;\n\n /**\n * Return the current store state (snapshot)\n * @returns The current state\n */\n abstract getCurrentState(): Readonly<S>;\n\n /**\n * Return the first loaded store state:\n * the last saved state\n * otherwise the initial state provided from `initialState()` method.\n * @returns The first state\n */\n getFirstState(): Readonly<S> | null {\n return this.deepFreeze(this.firstState);\n }\n\n /**\n * Reset store to first loaded store state:\n * - the last saved state\n * - otherwise the initial state provided from `initialState()` method.\n */\n resetState(): boolean {\n return this.setState(this.firstState, 'resetState');\n }\n\n /**\n * Restart the store to initial state provided from `initialState()` method\n */\n restartState(): boolean {\n return this.setState(this.initState, 'restartState');\n }\n\n /**\n * Set a new state\n * @param newState New state\n * @param actionName The action label into Redux DevTools (default is parent function name)\n * @returns state\n */\n protected patchState(newState: Partial<S>, actionName?: string): S | undefined;\n /**\n * Set a new state\n * @param selectFn State reducer\n * @param actionName The action label into Redux DevTools (default is parent function name)\n * @returns state\n */\n protected patchState(stateFn: NgSimpleStateSetState<S>, actionName?: string): S | undefined;\n /**\n * Set a new state\n * @param stateFnOrNewState State reducer or new state\n * @param actionName The action label into Redux DevTools (default is parent function name)\n * @returns state\n */\n protected patchState(stateFnOrNewState: StateFnOrNewState<S>, actionName?: string): S | undefined;\n protected patchState(stateFnOrNewState: StateFnOrNewState<S>, actionName?: string): S | undefined {\n const currState = this.getCurrentState();\n let newState: Partial<S>;\n if (typeof stateFnOrNewState === 'function') {\n newState = stateFnOrNewState(currState);\n } else {\n newState = stateFnOrNewState;\n }\n if (currState === newState) {\n return undefined;\n }\n let state: S;\n if (this.isArray) {\n // when working with arrays we treat payload as full replacement; avoid copying currState\n state = (newState as unknown as S);\n } else {\n // shallow merge using Object.assign (faster than spread in hot paths)\n // create a new object to avoid mutating current state\n state = Object.assign({}, currState, newState) as S;\n }\n\n // If comparator is provided, use it to detect equality (avoids further work)\n if (this.comparator && this.comparator(currState, state)) {\n return undefined;\n }\n // avoid function call if not necessary\n this.devTool && this.devToolSend(state, actionName);\n this.storage && this.statePersist(state);\n return state;\n }\n\n /**\n * Send to dev tool a new state\n * @param newState new state\n * @param actionName The action name\n * @returns True if dev tools are enabled\n */\n protected devToolSend(newState: S | undefined, actionName?: string): boolean {\n if (!this.devTool) {\n return false;\n }\n if (!actionName) {\n // retrieve the parent (of parent) method into the stack trace\n try {\n actionName = new Error().stack\n ?.split('\\n')[this.stackPoint]\n ?.trim()\n ?.split(' ')[1]\n ?.split('.')[1] || 'unknown';\n /* eslint-disable-next-line @typescript-eslint/no-unused-vars */\n } catch (_) {\n /* istanbul ignore next */\n actionName = 'unknown';\n }\n }\n if (!this.devTool.send(this.storeName, actionName, newState)) {\n /* istanbul ignore next */\n console.log(this.storeName + '.' + actionName, newState);\n }\n return true;\n }\n\n /**\n * Recursively Object.freeze simple Javascript structures consisting of plain objects, arrays, and primitives.\n * Make the data immutable.\n * @returns immutable object\n */\n protected deepFreeze(object: S): Readonly<S> {\n // No freezing in production (for better performance).\n if (!this.devMode || !object) {\n return object as Readonly<S>;\n }\n\n // When already frozen, we assume its children are frozen (for better performance).\n // This should be true if you always use `deepFreeze` to freeze objects.\n //\n // Note that Object.isFrozen will also return `true` for primitives (numbers,\n // strings, booleans, undefined, null), so there is no need to check for\n // those explicitly.\n if (Object.isFrozen(object)) {\n return object as Readonly<S>;\n }\n\n // At this point we know that we're dealing with either an array or plain object, so\n // just freeze it and recurse on its values.\n Object.freeze(object);\n /* eslint-disable @typescript-eslint/no-explicit-any */\n Object.keys(object).forEach(key => this.deepFreeze((object as any)[key]));\n\n return object as Readonly<S>;\n }\n\n /**\n * Persist state to storage\n */\n protected statePersist(state: S) {\n if (this.storage) {\n this.storage.setItem(this.storeName, state);\n }\n }\n}\n","import { Injectable, OnDestroy, Directive } from '@angular/core';\nimport { BehaviorSubject, Observable, asyncScheduler } from 'rxjs';\nimport { map, distinctUntilChanged, observeOn } from 'rxjs/operators';\nimport { NgSimpleStateBaseCommonStore } from '../ng-simple-state-common';\nimport type { NgSimpleStateComparator, NgSimpleStateSelectState, NgSimpleStateSetState, StateFnOrNewState } from '../ng-simple-state-models';\n\n@Injectable()\n@Directive()\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport abstract class NgSimpleStateBaseRxjsStore<S extends object | Array<any>> extends NgSimpleStateBaseCommonStore<S> implements OnDestroy {\n\n protected stackPoint: number = 4;\n private readonly state$: BehaviorSubject<S> = new BehaviorSubject<S>(this.firstState);\n private readonly stateObs: Observable<S> = this.state$.asObservable();\n\n /**\n * Return the observable of the state\n * @returns Observable of the state\n */\n public get state(): Observable<S> {\n return this.stateObs;\n }\n\n /**\n * When you override this method, you have to call the `super.ngOnDestroy()` method in your `ngOnDestroy()` method.\n */\n override ngOnDestroy(): void {\n super.ngOnDestroy();\n this.state$.complete();\n }\n\n /**\n * Select a store state\n * @param selectFn State selector (if not provided return full state)\n * @param comparator A function used to compare the previous and current state for equality. Defaults to a `===` check.\n * @returns Observable of the selected state\n */\n selectState<K = Partial<S>>(selectFn?: NgSimpleStateSelectState<S, K>, comparator?: NgSimpleStateComparator<K>): Observable<K> {\n if (!selectFn) {\n return this.stateObs as unknown as Observable<K>;\n }\n return this.state$.pipe(\n map(state => selectFn(state as Readonly<S>)),\n distinctUntilChanged(comparator ?? this.comparator as NgSimpleStateComparator),\n observeOn(asyncScheduler)\n );\n }\n\n /**\n * Return the current store state (snapshot)\n * @returns The current state\n */\n getCurrentState(): Readonly<S> {\n return this.devMode ? this.deepFreeze(this.state$.getValue()) : this.state$.getValue();\n }\n\n /**\n * Set a new state\n * @param newState New state\n * @param actionName The action label into Redux DevTools (default is parent function name)\n * @returns True if the state is changed\n */\n setState(newState: Partial<S>, actionName?: string): boolean;\n /**\n * Set a new state\n * @param selectFn State reducer\n * @param actionName The action label into Redux DevTools (default is parent function name)\n * @returns True if the state is changed\n */\n setState(stateFn: NgSimpleStateSetState<S>, actionName?: string): boolean;\n setState(stateFnOrNewState: StateFnOrNewState<S>, actionName?: string): boolean {\n const state = this.patchState(stateFnOrNewState, actionName);\n if (typeof state !== 'undefined') {\n this.state$.next(state);\n return true;\n }\n return false;\n }\n}\n","import { Injectable, Directive, Signal, signal, computed, WritableSignal } from '@angular/core';\nimport { NgSimpleStateBaseCommonStore } from '../ng-simple-state-common';\nimport type { NgSimpleStateComparator, NgSimpleStateSelectState, NgSimpleStateSetState, StateFnOrNewState } from '../ng-simple-state-models';\n\n@Injectable()\n@Directive()\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport abstract class NgSimpleStateBaseSignalStore<S extends object | Array<any>> extends NgSimpleStateBaseCommonStore<S> {\n\n protected stackPoint: number = 4;\n private readonly stateSig: WritableSignal<S> = signal<S>(this.firstState);\n private readonly stateSigRo: Signal<S> = this.stateSig.asReadonly();\n\n /**\n * Return the Signal of the state\n * @returns Signal of the state\n */\n public get state(): Signal<S> {\n return this.stateSigRo;\n }\n\n /**\n * Select a store state\n * @param selectFn State selector (if not provided return full state)\n * @param comparator A function used to compare the previous and current state for equality. Defaults to a `===` check.\n * @returns Signal of the selected state\n */\n selectState<K = Partial<S>>(selectFn?: NgSimpleStateSelectState<S, K>, comparator?: NgSimpleStateComparator<K>): Signal<K> {\n if (!selectFn) {\n return this.stateSigRo as unknown as Signal<K>;\n }\n return computed(() => selectFn(this.stateSig() as Readonly<S>), { equal: comparator ?? this.comparator as NgSimpleStateComparator });\n }\n\n /**\n * Return the current store state (snapshot)\n * @returns The current state\n */\n getCurrentState(): Readonly<S> {\n return this.devMode ? this.deepFreeze(this.stateSig()) : this.stateSig();\n }\n\n /**\n * Set a new state\n * @param newState New state\n * @param actionName The action label into Redux DevTools (default is parent function name)\n * @returns True if the state is changed\n */\n setState(newState: Partial<S>, actionName?: string): boolean;\n /**\n * Set a new state\n * @param selectFn State reducer\n * @param actionName The action label into Redux DevTools (default is parent function name)\n * @returns True if the state is changed\n */\n setState(stateFn: NgSimpleStateSetState<S>, actionName?: string): boolean;\n setState(stateFnOrNewState: StateFnOrNewState<S>, actionName?: string): boolean {\n const state = this.patchState(stateFnOrNewState, actionName);\n if (typeof state !== 'undefined') {\n this.stateSig.set(state);\n return true;\n }\n return false;\n }\n}\n","import { EnvironmentProviders, makeEnvironmentProviders } from \"@angular/core\";\r\nimport { NG_SIMPLE_STORE_CONFIG, NgSimpleStateConfig } from \"./ng-simple-state-models\";\r\n\r\nexport function provideNgSimpleState(ngSimpleStateConfig?: NgSimpleStateConfig): EnvironmentProviders[] {\r\n const providers: EnvironmentProviders[] = [];\r\n if (ngSimpleStateConfig) {\r\n providers.push(makeEnvironmentProviders([{\r\n provide: NG_SIMPLE_STORE_CONFIG,\r\n useValue: ngSimpleStateConfig,\r\n }]));\r\n }\r\n return providers;\r\n}\r\n","/*\r\n * Public API Surface of ng-simple-state\r\n */\r\nexport * from './lib/ng-simple-state.module';\r\nexport * from './lib/rxjs/ng-simple-state-base-store';\r\nexport * from './lib/signal/ng-simple-state-base-store';\r\nexport * from './lib/tool/ng-simple-state-dev-tool';\r\nexport * from './lib/storage/ng-simple-state-local-storage';\r\nexport * from './lib/storage/ng-simple-state-session-storage';\r\nexport * from './lib/ng-simple-state-models';\r\nexport * from './lib/ng-simple-state-common';\r\nexport * from './lib/ng-simple-state-provider';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;AA8CA;;AAEG;MACU,sBAAsB,GAAG,IAAI,cAAc,CACpD,wBAAwB;;MC9Cf,mBAAmB,CAAA;IAC5B,OAAO,OAAO,CACV,mBAAyC,EAAA;QAEzC,OAAO;AACH,YAAA,QAAQ,EAAE,mBAAmB;AAC7B,YAAA,SAAS,EAAE;AACP,gBAAA;AACI,oBAAA,OAAO,EAAE,sBAAsB;AAC/B,oBAAA,QAAQ,EAAE,mBAAmB;AAChC,iBAAA;AACJ,aAAA;SACJ;;8GAZI,mBAAm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GxI;;;AAGG;IACH,eAAe,GAAA;QACX,OAAO,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,GAAG,IAAI,CAAC,QAAQ,EAAE;;IAiB5E,QAAQ,CAAC,iBAAuC,EAAE,UAAmB,EAAA;QACjE,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,iBAAiB,EAAE,UAAU,CAAC;AAC5D,QAAA,IAAI,OAAO,KAAK,KAAK,WAAW,EAAE;AAC9B,YAAA,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC;AACxB,YAAA,OAAO,IAAI;;AAEf,QAAA,OAAO,KAAK;;8GAvDE,4BAA4B,EAAA,IAAA,EAAA,IAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA,CAAA;kGAA5B,4BAA4B,EAAA,YAAA,EAAA,IAAA,EAAA,eAAA,EAAA,IAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA,CAAA;kHAA5B,4BAA4B,EAAA,CAAA,CAAA;;2FAA5B,4BAA4B,EAAA,UAAA,EAAA,CAAA;kBAHjD;;kBACA;;;ACFK,SAAU,oBAAoB,CAAC,mBAAyC,EAAA;IAC1E,MAAM,SAAS,GAA2B,EAAE;IAC5C,IAAI,mBAAmB,EAAE;AACrB,QAAA,SAAS,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;AACrC,gBAAA,OAAO,EAAE,sBAAsB;AAC/B,gBAAA,QAAQ,EAAE,mBAAmB;aAChC,CAAC,CAAC,CAAC;;AAER,IAAA,OAAO,SAAS;AACpB;;ACZA;;AAEG;;ACFH;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"ng-simple-state.mjs","sources":["../../../projects/ng-simple-state/src/lib/ng-simple-state-models.ts","../../../projects/ng-simple-state/src/lib/ng-simple-state.module.ts","../../../projects/ng-simple-state/src/lib/tool/ng-simple-state-dev-tool.ts","../../../projects/ng-simple-state/src/lib/storage/ng-simple-state-browser-storage.ts","../../../projects/ng-simple-state/src/lib/storage/ng-simple-state-local-storage.ts","../../../projects/ng-simple-state/src/lib/storage/ng-simple-state-session-storage.ts","../../../projects/ng-simple-state/src/lib/ng-simple-state-common.ts","../../../projects/ng-simple-state/src/lib/rxjs/ng-simple-state-base-store.ts","../../../projects/ng-simple-state/src/lib/signal/ng-simple-state-base-store.ts","../../../projects/ng-simple-state/src/lib/ng-simple-state-provider.ts","../../../projects/ng-simple-state/src/public-api.ts","../../../projects/ng-simple-state/src/ng-simple-state.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\nimport type { NgSimpleStateStorage } from './storage/ng-simple-state-browser-storage';\n\nexport type NgSimpleStateReplaceState<S> = (currentState: Readonly<S>) => S;\nexport type NgSimpleStateSetState<S> = (currentState: Readonly<S>) => Partial<S>;\nexport type NgSimpleStateSelectState<S, K> = (state: Readonly<S>) => K;\n/* eslint-disable-next-line @typescript-eslint/no-explicit-any */\nexport type NgSimpleStateComparator<K = any> = (previous: K, current: K) => boolean;\n\n/**\n * NgSimpleState config option\n */\n/* eslint-disable-next-line @typescript-eslint/no-explicit-any */\nexport interface NgSimpleStateConfig<K = any> {\n /**\n * if `true` enable `Redux DevTools` browser extension for inspect the state of the store.\n */\n enableDevTool?: boolean;\n /**\n * Set the persistent storage `local`, `session` or instance of `NgSimpleStateStorage`.\n */\n persistentStorage?: 'session' | 'local' | NgSimpleStateStorage;\n /**\n * A function used to compare the previous and current state for equality. \n */\n comparator?: NgSimpleStateComparator<K>;\n /**\n * A function used to serialize the state to a string.\n */\n serializeState?: (state: K) => string;\n /**\n * A function used to deserialize the state from a string. \n */\n deserializeState?: (state: string) => K;\n}\n\n/**\n * NgSimpleState config option for store\n */\n/* eslint-disable-next-line @typescript-eslint/no-explicit-any */\nexport interface NgSimpleStateStoreConfig<K = any> extends NgSimpleStateConfig<K> {\n /** \n * The store name \n */\n storeName: string;\n}\n\n/**\n * NgSimpleState config InjectionToken\n */\nexport const NG_SIMPLE_STORE_CONFIG = new InjectionToken<NgSimpleStateConfig>(\n 'ng-simple-state.config'\n);\n\nexport type StateFnOrNewState<S> = Partial<S> | NgSimpleStateSetState<S>;\nexport type StateFnOrReplaceState<S> = S | NgSimpleStateReplaceState<S>;\n","import { ModuleWithProviders, NgModule } from '@angular/core';\r\nimport { NgSimpleStateConfig, NG_SIMPLE_STORE_CONFIG } from './ng-simple-state-models';\r\n\r\n@NgModule()\r\n/** @deprecated use `provideNgSimpleState(ngSimpleStateConfig)` */\r\nexport class NgSimpleStateModule {\r\n static forRoot(\r\n ngSimpleStateConfig?: NgSimpleStateConfig\r\n ): ModuleWithProviders<NgSimpleStateModule> {\r\n return {\r\n ngModule: NgSimpleStateModule,\r\n providers: [\r\n {\r\n provide: NG_SIMPLE_STORE_CONFIG,\r\n useValue: ngSimpleStateConfig,\r\n },\r\n ],\r\n };\r\n }\r\n}\r\n","import { inject, Injectable, NgZone } from '@angular/core';\n\ninterface DevtoolsLocal {\n init: (state: object) => void;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n send: <T>(action: string, state: Record<string, T>, options: any, instanceId: string) => void;\n}\ninterface Devtools {\n connect(options: { name: string, instanceId: string }): DevtoolsLocal;\n}\n\ndeclare global {\n interface Window {\n __REDUX_DEVTOOLS_EXTENSION__: Devtools;\n devToolsExtension: Devtools;\n }\n}\n\nconst instanceId = `ng-simple-state-${Date.now()}-${Math.random()}`;\n\n@Injectable({ providedIn: 'root' })\nexport class NgSimpleStateDevTool {\n\n private readonly globalDevtools: Devtools = window.__REDUX_DEVTOOLS_EXTENSION__ || window.devToolsExtension;\n private localDevTool!: DevtoolsLocal;\n private readonly baseState: Record<string, object> = {};\n\n constructor() {\n if (this.globalDevtools) {\n // The `connect` method adds `message` event listener since it communicates\n // with an extension through `window.postMessage` and message events.\n // We handle only 2 events; thus, we don't want to run many change detections\n // because the extension sends events that we don't have to handle.\n inject(NgZone).runOutsideAngular(() => {\n this.localDevTool = this.globalDevtools.connect({\n name: 'NgSimpleState',\n instanceId: instanceId\n });\n if (this.localDevTool) {\n this.localDevTool.init(this.baseState);\n }\n });\n }\n }\n\n /**\n * Return true if dev tool is active\n * @returns True if dev tool is active\n */\n isActive(): boolean {\n return !!this.localDevTool;\n }\n\n /**\n * Send to dev tool a new state\n * @param storeName The store name\n * @param actionName The action name\n * @param state the state\n * @returns True if dev tool is enabled and action is send\n */\n send<T>(storeName: string, actionName: string, state: T): boolean {\n if (this.localDevTool) {\n this.localDevTool.send<T>(`${storeName}.${actionName}`, Object.assign(this.baseState, { [storeName]: state }), false, instanceId);\n return true;\n }\n return false;\n }\n}\n","import { NgSimpleStateStoreConfig } from \"../ng-simple-state-models\";\n\nexport const BASE_KEY = 'NgSimpleState::';\n\nexport abstract class NgSimpleStateStorage<K = unknown> {\n\n /**\n * A function used to serialize the state to a string.\n */\n private serializeState: (state: K) => string;\n \n /**\n * A function used to deserialize the state from a string. \n */\n private deserializeState: (state: string) => K;\n\n constructor(private storage: Storage, config?: NgSimpleStateStoreConfig<K>) { \n this.serializeState = config?.serializeState ? config.serializeState : JSON.stringify;\n this.deserializeState = config?.deserializeState ? config.deserializeState : JSON.parse;\n }\n\n /**\n * Set item into storage\n * @param key key name\n * @param state state value\n * @returns True if item is stored into storage\n */\n setItem(key: string, state: K): boolean {\n this.storage.setItem(BASE_KEY + key, this.serializeState(state));\n return true;\n }\n\n /**\n * Return item from storage\n * @param key key name\n * @returns the item\n */\n getItem(key: string): K | null {\n const state = this.storage.getItem(BASE_KEY + key);\n if (state) {\n return this.deserializeState(state);\n }\n return null;\n }\n\n /**\n * Remove item from storage\n * @param {string} key key name\n * @returns True if item is removed\n */\n removeItem(key: string): boolean {\n this.storage.removeItem(BASE_KEY + key);\n return true;\n }\n\n /**\n * Removes all key/value pairs, if there are any.\n * @returns True if storage is cleared\n */\n clear(): boolean {\n for (let i = this.storage.length; i >= 0; i--) {\n const key = this.storage.key(i);\n if (key && key.startsWith(BASE_KEY)) {\n this.storage.removeItem(key);\n }\n }\n return true;\n }\n}\n","import { NgSimpleStateStoreConfig } from '../ng-simple-state-models';\nimport { NgSimpleStateStorage } from './ng-simple-state-browser-storage';\n\nexport class NgSimpleStateLocalStorage<K = unknown> extends NgSimpleStateStorage<K> {\n constructor(config?: NgSimpleStateStoreConfig<K>) {\n super(localStorage, config);\n }\n}\n","\nimport { NgSimpleStateStoreConfig } from '../ng-simple-state-models';\nimport { NgSimpleStateStorage } from './ng-simple-state-browser-storage';\n\nexport class NgSimpleStateSessionStorage<K = unknown> extends NgSimpleStateStorage<K> {\n constructor(config?: NgSimpleStateStoreConfig<K>) {\n super(sessionStorage, config);\n }\n}\n","import { Injectable, OnDestroy, Directive, isDevMode, inject } from '@angular/core';\nimport { NgSimpleStateDevTool } from './tool/ng-simple-state-dev-tool';\nimport type { NgSimpleStateStorage } from './storage/ng-simple-state-browser-storage';\nimport { NgSimpleStateLocalStorage } from './storage/ng-simple-state-local-storage';\nimport { NgSimpleStateSessionStorage } from './storage/ng-simple-state-session-storage';\nimport { type NgSimpleStateStoreConfig, NG_SIMPLE_STORE_CONFIG, type NgSimpleStateSetState, type NgSimpleStateComparator, type NgSimpleStateSelectState, type StateFnOrNewState, NgSimpleStateConfig, NgSimpleStateReplaceState, StateFnOrReplaceState } from './ng-simple-state-models';\n\n\n@Injectable()\n@Directive()\nexport abstract class NgSimpleStateBaseCommonStore<S extends object | Array<unknown>> implements OnDestroy {\n\n protected abstract stackPoint: number;\n protected devTool?: NgSimpleStateDevTool;\n protected storage?: NgSimpleStateStorage<S>;\n protected storeName: string;\n protected firstState!: S;\n protected initState!: S;\n protected isArray: boolean;\n protected devMode: boolean = isDevMode();\n protected comparator?: NgSimpleStateComparator<S>;\n\n constructor() {\n\n const globalConfig: NgSimpleStateConfig<S> | null = inject(NG_SIMPLE_STORE_CONFIG, { optional: true })\n const storeConfig = this.storeConfig();\n const config = { ...globalConfig, ...storeConfig };\n\n if (config.persistentStorage === 'local') {\n this.storage = new NgSimpleStateLocalStorage(config);\n } else if (config.persistentStorage === 'session') {\n this.storage = new NgSimpleStateSessionStorage(config);\n } else if (typeof config.persistentStorage === 'object') {\n this.storage = config.persistentStorage as NgSimpleStateStorage<S>;\n }\n\n if (config.enableDevTool) {\n this.devTool = inject(NgSimpleStateDevTool);\n }\n\n this.storeName = config.storeName;\n\n if (typeof config.comparator === 'function') {\n this.comparator = config.comparator;\n }\n\n if (this.storage) {\n const firstState = this.storage.getItem(this.storeName);\n if (firstState) {\n this.firstState = firstState;\n }\n }\n\n this.initState = this.initialState();\n if (!this.firstState) {\n this.firstState = this.initState;\n }\n\n this.devToolSend(this.firstState, 'initialState');\n\n this.isArray = Array.isArray(this.firstState);\n }\n\n /**\n * When you override this method, you have to call the `super.ngOnDestroy()` method in your `ngOnDestroy()` method.\n */\n ngOnDestroy(): void {\n this.devToolSend(undefined, 'ngOnDestroy');\n }\n\n /**\n * Override this method for set a specific config for the store\n * @returns NgSimpleStateStoreConfig\n */\n protected abstract storeConfig(): NgSimpleStateStoreConfig;\n\n /**\n * Set into the store the initial state\n * @returns The state object\n */\n protected abstract initialState(): S;\n\n /**\n * Select a store state\n * @param selectFn State selector (if not provided return full state)\n * @param comparator A function used to compare the previous and current state for equality. Defaults to a `===` check.\n * @returns Observable of the selected state\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n abstract selectState<K = Partial<S>>(selectFn?: NgSimpleStateSelectState<S, K>, comparator?: NgSimpleStateComparator<K>): any;\n\n /**\n * Set a new state\n * @param newState New state\n * @param actionName The action label into Redux DevTools (default is parent function name)\n * @returns True if the state is changed\n */\n abstract setState(newState: Partial<S>, actionName?: string): boolean;\n\n /**\n * Set a new state\n * @param selectFn State reducer\n * @param actionName The action label into Redux DevTools (default is parent function name)\n * @returns True if the state is changed\n */\n abstract setState(stateFn: NgSimpleStateSetState<S>, actionName?: string): boolean;\n\n /**\n * Replace state\n * @param newState New state\n * @param actionName The action label into Redux DevTools (default is parent function name)\n * @returns True if the state is changed\n */\n abstract replaceState(newState: S, actionName?: string): boolean;\n\n /**\n * Replace state\n * @param selectFn State reducer\n * @param actionName The action label into Redux DevTools (default is parent function name)\n * @returns True if the state is changed\n */\n abstract replaceState(stateFn: NgSimpleStateReplaceState<S>, actionName?: string): boolean;\n\n /**\n * Return the current store state (snapshot)\n * @returns The current state\n */\n abstract getCurrentState(): Readonly<S>;\n\n /**\n * Return the first loaded store state:\n * the last saved state\n * otherwise the initial state provided from `initialState()` method.\n * @returns The first state\n */\n getFirstState(): Readonly<S> | null {\n return this.deepFreeze(this.firstState);\n }\n\n /**\n * Reset store to first loaded store state:\n * - the last saved state\n * - otherwise the initial state provided from `initialState()` method.\n */\n resetState(): boolean {\n return this.replaceState(this.firstState, 'resetState');\n }\n\n /**\n * Restart the store to initial state provided from `initialState()` method\n */\n restartState(): boolean {\n return this.replaceState(this.initState, 'restartState');\n }\n\n /**\n * Set a new state\n * @param newState New state\n * @param actionName The action label into Redux DevTools (default is parent function name)\n * @returns state\n * @private\n */\n protected _setState(newState: Partial<S>, actionName?: string): S | undefined;\n /**\n * Set a new state\n * @param selectFn State reducer\n * @param actionName The action label into Redux DevTools (default is parent function name)\n * @returns state\n * @private\n */\n protected _setState(stateFn: NgSimpleStateSetState<S>, actionName?: string): S | undefined;\n /**\n * Set a new state\n * @param stateFnOrNewState State reducer or new state\n * @param actionName The action label into Redux DevTools (default is parent function name)\n * @returns state\n * @private\n */\n protected _setState(stateFnOrNewState: StateFnOrNewState<S>, actionName?: string): S | undefined;\n protected _setState(stateFnOrNewState: StateFnOrNewState<S>, actionName?: string): S | undefined {\n const currState = this.getCurrentState();\n let newState: Partial<S>;\n if (typeof stateFnOrNewState === 'function') {\n newState = stateFnOrNewState(currState);\n } else {\n newState = stateFnOrNewState;\n }\n if (currState === newState) {\n return undefined;\n }\n let state: S;\n if (this.isArray) {\n // when working with arrays we treat payload as full replacement; avoid copying currState\n state = (newState as unknown as S);\n } else {\n // shallow merge using Object.assign (faster than spread in hot paths)\n // create a new object to avoid mutating current state\n state = Object.assign({}, currState, newState) as S;\n }\n\n // If comparator is provided, use it to detect equality (avoids further work)\n if (this.comparator && this.comparator(currState, state)) {\n return undefined;\n }\n // avoid function call if not necessary\n this.devTool && this.devToolSend(state, actionName);\n this.storage && this.statePersist(state);\n return state;\n }\n\n /**\n * Replace state\n * @param newState state\n * @param actionName The action label into Redux DevTools (default is parent function name)\n * @returns state\n * @private\n */\n protected _replaceState(newState: S, actionName?: string): S | undefined;\n /**\n * Replace state\n * @param selectFn State reducer\n * @param actionName The action label into Redux DevTools (default is parent function name)\n * @returns state\n * @private\n */\n protected _replaceState(stateFn: NgSimpleStateReplaceState<S>, actionName?: string): S | undefined;\n /**\n * Replace state\n * @param stateFnOrReplaceState State reducer or state\n * @param actionName The action label into Redux DevTools (default is parent function name)\n * @returns state\n * @private\n */\n protected _replaceState(stateFnOrReplaceState: StateFnOrReplaceState<S>, actionName?: string): S | undefined;\n protected _replaceState(stateFnOrReplaceState: StateFnOrReplaceState<S>, actionName?: string): S | undefined {\n const currState = this.getCurrentState();\n let newState: S;\n if (typeof stateFnOrReplaceState === 'function') {\n newState = stateFnOrReplaceState(currState);\n } else {\n newState = stateFnOrReplaceState;\n }\n if (currState === newState) {\n return undefined;\n }\n // If comparator is provided, use it to detect equality (avoids further work)\n if (this.comparator && this.comparator(currState, newState)) {\n return undefined;\n }\n // avoid function call if not necessary\n this.devTool && this.devToolSend(newState, actionName);\n this.storage && this.statePersist(newState);\n return newState;\n }\n\n /**\n * Send to dev tool a new state\n * @param newState new state\n * @param actionName The action name\n * @returns True if dev tools are enabled\n */\n protected devToolSend(newState: S | undefined, actionName?: string): boolean {\n if (!this.devTool) {\n return false;\n }\n if (!actionName) {\n // retrieve the parent (of parent) method into the stack trace\n try {\n actionName = new Error().stack\n ?.split('\\n')[this.stackPoint]\n ?.trim()\n ?.split(' ')[1]\n ?.split('.')[1] || 'unknown';\n /* eslint-disable-next-line @typescript-eslint/no-unused-vars */\n } catch (_) {\n /* istanbul ignore next */\n actionName = 'unknown';\n }\n }\n if (!this.devTool.send(this.storeName, actionName, newState)) {\n /* istanbul ignore next */\n console.log(this.storeName + '.' + actionName, newState);\n }\n return true;\n }\n\n /**\n * Recursively Object.freeze simple Javascript structures consisting of plain objects, arrays, and primitives.\n * Make the data immutable.\n * @returns immutable object\n */\n protected deepFreeze(object: S): Readonly<S> {\n // No freezing in production (for better performance).\n if (!this.devMode || !object) {\n return object as Readonly<S>;\n }\n\n // When already frozen, we assume its children are frozen (for better performance).\n // This should be true if you always use `deepFreeze` to freeze objects.\n //\n // Note that Object.isFrozen will also return `true` for primitives (numbers,\n // strings, booleans, undefined, null), so there is no need to check for\n // those explicitly.\n if (Object.isFrozen(object)) {\n return object as Readonly<S>;\n }\n\n // At this point we know that we're dealing with either an array or plain object, so\n // just freeze it and recurse on its values.\n Object.freeze(object);\n /* eslint-disable @typescript-eslint/no-explicit-any */\n Object.keys(object).forEach(key => this.deepFreeze((object as any)[key]));\n\n return object as Readonly<S>;\n }\n\n /**\n * Persist state to storage\n */\n protected statePersist(state: S) {\n if (this.storage) {\n this.storage.setItem(this.storeName, state);\n }\n }\n}\n","import { Injectable, OnDestroy, Directive } from '@angular/core';\nimport { BehaviorSubject, Observable, asyncScheduler } from 'rxjs';\nimport { map, distinctUntilChanged, observeOn } from 'rxjs/operators';\nimport { NgSimpleStateBaseCommonStore } from '../ng-simple-state-common';\nimport type { NgSimpleStateComparator, NgSimpleStateReplaceState, NgSimpleStateSelectState, NgSimpleStateSetState, StateFnOrNewState, StateFnOrReplaceState } from '../ng-simple-state-models';\n\n@Injectable()\n@Directive()\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport abstract class NgSimpleStateBaseRxjsStore<S extends object | Array<any>> extends NgSimpleStateBaseCommonStore<S> implements OnDestroy {\n\n protected stackPoint: number = 4;\n private readonly state$: BehaviorSubject<S> = new BehaviorSubject<S>(this.firstState);\n private readonly stateObs: Observable<S> = this.state$.asObservable();\n\n /**\n * Return the observable of the state\n * @returns Observable of the state\n */\n public get state(): Observable<S> {\n return this.stateObs;\n }\n\n /**\n * When you override this method, you have to call the `super.ngOnDestroy()` method in your `ngOnDestroy()` method.\n */\n override ngOnDestroy(): void {\n super.ngOnDestroy();\n this.state$.complete();\n }\n\n /**\n * Select a store state\n * @param selectFn State selector (if not provided return full state)\n * @param comparator A function used to compare the previous and current state for equality. Defaults to a `===` check.\n * @returns Observable of the selected state\n */\n selectState<K = Partial<S>>(selectFn?: NgSimpleStateSelectState<S, K>, comparator?: NgSimpleStateComparator<K>): Observable<K> {\n if (!selectFn) {\n return this.stateObs as unknown as Observable<K>;\n }\n return this.state$.pipe(\n map(state => selectFn(state as Readonly<S>)),\n distinctUntilChanged(comparator ?? this.comparator as NgSimpleStateComparator),\n observeOn(asyncScheduler)\n );\n }\n\n /**\n * Return the current store state (snapshot)\n * @returns The current state\n */\n getCurrentState(): Readonly<S> {\n return this.devMode ? this.deepFreeze(this.state$.getValue()) : this.state$.getValue();\n }\n\n /**\n * Set a new state\n * @param newState New state\n * @param actionName The action label into Redux DevTools (default is parent function name)\n * @returns True if the state is changed\n */\n setState(newState: Partial<S>, actionName?: string): boolean;\n /**\n * Set a new state\n * @param selectFn State reducer\n * @param actionName The action label into Redux DevTools (default is parent function name)\n * @returns True if the state is changed\n */\n setState(stateFn: NgSimpleStateSetState<S>, actionName?: string): boolean;\n setState(stateFnOrNewState: StateFnOrNewState<S>, actionName?: string): boolean {\n const state = this._setState(stateFnOrNewState, actionName);\n if (typeof state !== 'undefined') {\n this.state$.next(state);\n return true;\n }\n return false;\n }\n\n /**\n * Replace state\n * @param newState New state\n * @param actionName The action label into Redux DevTools (default is parent function name)\n * @returns True if the state is changed\n */\n replaceState(newState: S, actionName?: string): boolean;\n /**\n * Replace state\n * @param selectFn State reducer\n * @param actionName The action label into Redux DevTools (default is parent function name)\n * @returns True if the state is changed\n */\n replaceState(stateFn: NgSimpleStateReplaceState<S>, actionName?: string): boolean;\n replaceState(stateFnOrNewState: StateFnOrReplaceState<S>, actionName?: string): boolean {\n const state = this._replaceState(stateFnOrNewState, actionName);\n if (typeof state !== 'undefined') {\n this.state$.next(state);\n return true;\n }\n return false;\n }\n}\n","import { Injectable, Directive, Signal, signal, computed, WritableSignal } from '@angular/core';\nimport { NgSimpleStateBaseCommonStore } from '../ng-simple-state-common';\nimport type { NgSimpleStateComparator, NgSimpleStateReplaceState, NgSimpleStateSelectState, NgSimpleStateSetState, StateFnOrNewState, StateFnOrReplaceState } from '../ng-simple-state-models';\n\n@Injectable()\n@Directive()\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport abstract class NgSimpleStateBaseSignalStore<S extends object | Array<any>> extends NgSimpleStateBaseCommonStore<S> {\n\n protected stackPoint: number = 4;\n private readonly stateSig: WritableSignal<S> = signal<S>(this.firstState);\n private readonly stateSigRo: Signal<S> = this.stateSig.asReadonly();\n\n /**\n * Return the Signal of the state\n * @returns Signal of the state\n */\n public get state(): Signal<S> {\n return this.stateSigRo;\n }\n\n /**\n * Select a store state\n * @param selectFn State selector (if not provided return full state)\n * @param comparator A function used to compare the previous and current state for equality. Defaults to a `===` check.\n * @returns Signal of the selected state\n */\n selectState<K = Partial<S>>(selectFn?: NgSimpleStateSelectState<S, K>, comparator?: NgSimpleStateComparator<K>): Signal<K> {\n if (!selectFn) {\n return this.stateSigRo as unknown as Signal<K>;\n }\n return computed(() => selectFn(this.stateSig() as Readonly<S>), { equal: comparator ?? this.comparator as NgSimpleStateComparator });\n }\n\n /**\n * Return the current store state (snapshot)\n * @returns The current state\n */\n getCurrentState(): Readonly<S> {\n return this.devMode ? this.deepFreeze(this.stateSig()) : this.stateSig();\n }\n\n /**\n * Set a new state\n * @param newState New state\n * @param actionName The action label into Redux DevTools (default is parent function name)\n * @returns True if the state is changed\n */\n setState(newState: Partial<S>, actionName?: string): boolean;\n /**\n * Set a new state\n * @param selectFn State reducer\n * @param actionName The action label into Redux DevTools (default is parent function name)\n * @returns True if the state is changed\n */\n setState(stateFn: NgSimpleStateSetState<S>, actionName?: string): boolean;\n setState(stateFnOrNewState: StateFnOrNewState<S>, actionName?: string): boolean {\n const state = this._setState(stateFnOrNewState, actionName);\n if (typeof state !== 'undefined') {\n this.stateSig.set(state);\n return true;\n }\n return false;\n }\n\n /**\n * Replace state\n * @param newState New state\n * @param actionName The action label into Redux DevTools (default is parent function name)\n * @returns True if the state is changed\n */\n replaceState(newState: S, actionName?: string): boolean;\n /**\n * Replace state\n * @param selectFn State reducer\n * @param actionName The action label into Redux DevTools (default is parent function name)\n * @returns True if the state is changed\n */\n replaceState(stateFn: NgSimpleStateReplaceState<S>, actionName?: string): boolean;\n replaceState(stateFnOrReplaceState: StateFnOrReplaceState<S>, actionName?: string): boolean {\n const state = this._replaceState(stateFnOrReplaceState, actionName);\n if (typeof state !== 'undefined') {\n this.stateSig.set(state);\n return true;\n }\n return false;\n }\n}\n","import { EnvironmentProviders, makeEnvironmentProviders } from \"@angular/core\";\r\nimport { NG_SIMPLE_STORE_CONFIG, NgSimpleStateConfig } from \"./ng-simple-state-models\";\r\n\r\n/**\r\n * Provide NgSimpleState with optional global configuration\r\n * @param {NgSimpleStateConfig} ngSimpleStateConfig \r\n * @returns {EnvironmentProviders[]}\r\n */\r\nexport function provideNgSimpleState(ngSimpleStateConfig?: NgSimpleStateConfig): EnvironmentProviders[] {\r\n if (ngSimpleStateConfig) {\r\n return [\r\n makeEnvironmentProviders([{\r\n provide: NG_SIMPLE_STORE_CONFIG,\r\n useValue: ngSimpleStateConfig,\r\n }])\r\n ];\r\n }\r\n return [];\r\n}\r\n","/*\r\n * Public API Surface of ng-simple-state\r\n */\r\nexport * from './lib/ng-simple-state.module';\r\nexport * from './lib/rxjs/ng-simple-state-base-store';\r\nexport * from './lib/signal/ng-simple-state-base-store';\r\nexport * from './lib/tool/ng-simple-state-dev-tool';\r\nexport * from './lib/storage/ng-simple-state-local-storage';\r\nexport * from './lib/storage/ng-simple-state-session-storage';\r\nexport * from './lib/ng-simple-state-models';\r\nexport * from './lib/ng-simple-state-common';\r\nexport * from './lib/ng-simple-state-provider';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;AA+CA;;AAEG;MACU,sBAAsB,GAAG,IAAI,cAAc,CACpD,wBAAwB;;AC/C5B;MACa,mBAAmB,CAAA;IAC5B,OAAO,OAAO,CACV,mBAAyC,EAAA;QAEzC,OAAO;AACH,YAAA,QAAQ,EAAE,mBAAmB;AAC7B,YAAA,SAAS,EAAE;AACP,gBAAA;AACI,oBAAA,OAAO,EAAE,sBAAsB;AAC/B,oBAAA,QAAQ,EAAE,mBAAmB;AAChC,iBAAA;AACJ,aAAA;SACJ;IACL;8GAbS,mBAAmB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;+GAAnB,mBAAmB,EAAA,CAAA,CAAA;+GAAnB,mBAAmB,EAAA,CAAA,CAAA;;2FAAnB,mBAAmB,EAAA,UAAA,EAAA,CAAA;kBAF/B;;;ACeD,MAAM,UAAU,GAAG,CAAA,gBAAA,EAAmB,IAAI,CAAC,GAAG,EAAE,CAAA,CAAA,EAAI,IAAI,CAAC,MAAM,EAAE,EAAE;MAGtD,oBAAoB,CAAA;AAM7B,IAAA,WAAA,GAAA;QAJiB,IAAA,CAAA,cAAc,GAAa,MAAM,CAAC,4BAA4B,IAAI,MAAM,CAAC,iBAAiB;QAE1F,IAAA,CAAA,SAAS,GAA2B,EAAE;AAGnD,QAAA,IAAI,IAAI,CAAC,cAAc,EAAE;;;;;AAKrB,YAAA,MAAM,CAAC,MAAM,CAAC,CAAC,iBAAiB,CAAC,MAAK;gBAClC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC;AAC5C,oBAAA,IAAI,EAAE,eAAe;AACrB,oBAAA,UAAU,EAAE;AACf,iBAAA,CAAC;AACF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AA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA,CAAA;kGAA5B,4BAA4B,EAAA,YAAA,EAAA,IAAA,EAAA,eAAA,EAAA,IAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA,CAAA;kHAA5B,4BAA4B,EAAA,CAAA,CAAA;;2FAA5B,4BAA4B,EAAA,UAAA,EAAA,CAAA;kBAHjD;;kBACA;;;ACFD;;;;AAIG;AACG,SAAU,oBAAoB,CAAC,mBAAyC,EAAA;IAC1E,IAAI,mBAAmB,EAAE;QACrB,OAAO;AACH,YAAA,wBAAwB,CAAC,CAAC;AACtB,oBAAA,OAAO,EAAE,sBAAsB;AAC/B,oBAAA,QAAQ,EAAE,mBAAmB;AAChC,iBAAA,CAAC;SACL;IACL;AACA,IAAA,OAAO,EAAE;AACb;;AClBA;;AAEG;;ACFH;;AAEG;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ng-simple-state",
|
|
3
|
-
"version": "20.1.
|
|
3
|
+
"version": "20.1.8",
|
|
4
4
|
"description": "Simple state management in Angular with only Services and RxJS or Signal.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -26,13 +26,13 @@
|
|
|
26
26
|
"tslib": "^2.3.0"
|
|
27
27
|
},
|
|
28
28
|
"module": "fesm2022/ng-simple-state.mjs",
|
|
29
|
-
"typings": "
|
|
29
|
+
"typings": "types/ng-simple-state.d.ts",
|
|
30
30
|
"exports": {
|
|
31
31
|
"./package.json": {
|
|
32
32
|
"default": "./package.json"
|
|
33
33
|
},
|
|
34
34
|
".": {
|
|
35
|
-
"types": "./
|
|
35
|
+
"types": "./types/ng-simple-state.d.ts",
|
|
36
36
|
"default": "./fesm2022/ng-simple-state.mjs"
|
|
37
37
|
}
|
|
38
38
|
},
|
|
@@ -39,6 +39,7 @@ declare abstract class NgSimpleStateStorage<K = unknown> {
|
|
|
39
39
|
clear(): boolean;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
type NgSimpleStateReplaceState<S> = (currentState: Readonly<S>) => S;
|
|
42
43
|
type NgSimpleStateSetState<S> = (currentState: Readonly<S>) => Partial<S>;
|
|
43
44
|
type NgSimpleStateSelectState<S, K> = (state: Readonly<S>) => K;
|
|
44
45
|
type NgSimpleStateComparator<K = any> = (previous: K, current: K) => boolean;
|
|
@@ -81,6 +82,7 @@ interface NgSimpleStateStoreConfig<K = any> extends NgSimpleStateConfig<K> {
|
|
|
81
82
|
*/
|
|
82
83
|
declare const NG_SIMPLE_STORE_CONFIG: InjectionToken<NgSimpleStateConfig<any>>;
|
|
83
84
|
type StateFnOrNewState<S> = Partial<S> | NgSimpleStateSetState<S>;
|
|
85
|
+
type StateFnOrReplaceState<S> = S | NgSimpleStateReplaceState<S>;
|
|
84
86
|
|
|
85
87
|
declare class NgSimpleStateModule {
|
|
86
88
|
static forRoot(ngSimpleStateConfig?: NgSimpleStateConfig): ModuleWithProviders<NgSimpleStateModule>;
|
|
@@ -173,6 +175,20 @@ declare abstract class NgSimpleStateBaseCommonStore<S extends object | Array<unk
|
|
|
173
175
|
* @returns True if the state is changed
|
|
174
176
|
*/
|
|
175
177
|
abstract setState(stateFn: NgSimpleStateSetState<S>, actionName?: string): boolean;
|
|
178
|
+
/**
|
|
179
|
+
* Replace state
|
|
180
|
+
* @param newState New state
|
|
181
|
+
* @param actionName The action label into Redux DevTools (default is parent function name)
|
|
182
|
+
* @returns True if the state is changed
|
|
183
|
+
*/
|
|
184
|
+
abstract replaceState(newState: S, actionName?: string): boolean;
|
|
185
|
+
/**
|
|
186
|
+
* Replace state
|
|
187
|
+
* @param selectFn State reducer
|
|
188
|
+
* @param actionName The action label into Redux DevTools (default is parent function name)
|
|
189
|
+
* @returns True if the state is changed
|
|
190
|
+
*/
|
|
191
|
+
abstract replaceState(stateFn: NgSimpleStateReplaceState<S>, actionName?: string): boolean;
|
|
176
192
|
/**
|
|
177
193
|
* Return the current store state (snapshot)
|
|
178
194
|
* @returns The current state
|
|
@@ -200,22 +216,49 @@ declare abstract class NgSimpleStateBaseCommonStore<S extends object | Array<unk
|
|
|
200
216
|
* @param newState New state
|
|
201
217
|
* @param actionName The action label into Redux DevTools (default is parent function name)
|
|
202
218
|
* @returns state
|
|
219
|
+
* @private
|
|
203
220
|
*/
|
|
204
|
-
protected
|
|
221
|
+
protected _setState(newState: Partial<S>, actionName?: string): S | undefined;
|
|
205
222
|
/**
|
|
206
223
|
* Set a new state
|
|
207
224
|
* @param selectFn State reducer
|
|
208
225
|
* @param actionName The action label into Redux DevTools (default is parent function name)
|
|
209
226
|
* @returns state
|
|
227
|
+
* @private
|
|
210
228
|
*/
|
|
211
|
-
protected
|
|
229
|
+
protected _setState(stateFn: NgSimpleStateSetState<S>, actionName?: string): S | undefined;
|
|
212
230
|
/**
|
|
213
231
|
* Set a new state
|
|
214
232
|
* @param stateFnOrNewState State reducer or new state
|
|
215
233
|
* @param actionName The action label into Redux DevTools (default is parent function name)
|
|
216
234
|
* @returns state
|
|
235
|
+
* @private
|
|
236
|
+
*/
|
|
237
|
+
protected _setState(stateFnOrNewState: StateFnOrNewState<S>, actionName?: string): S | undefined;
|
|
238
|
+
/**
|
|
239
|
+
* Replace state
|
|
240
|
+
* @param newState state
|
|
241
|
+
* @param actionName The action label into Redux DevTools (default is parent function name)
|
|
242
|
+
* @returns state
|
|
243
|
+
* @private
|
|
244
|
+
*/
|
|
245
|
+
protected _replaceState(newState: S, actionName?: string): S | undefined;
|
|
246
|
+
/**
|
|
247
|
+
* Replace state
|
|
248
|
+
* @param selectFn State reducer
|
|
249
|
+
* @param actionName The action label into Redux DevTools (default is parent function name)
|
|
250
|
+
* @returns state
|
|
251
|
+
* @private
|
|
252
|
+
*/
|
|
253
|
+
protected _replaceState(stateFn: NgSimpleStateReplaceState<S>, actionName?: string): S | undefined;
|
|
254
|
+
/**
|
|
255
|
+
* Replace state
|
|
256
|
+
* @param stateFnOrReplaceState State reducer or state
|
|
257
|
+
* @param actionName The action label into Redux DevTools (default is parent function name)
|
|
258
|
+
* @returns state
|
|
259
|
+
* @private
|
|
217
260
|
*/
|
|
218
|
-
protected
|
|
261
|
+
protected _replaceState(stateFnOrReplaceState: StateFnOrReplaceState<S>, actionName?: string): S | undefined;
|
|
219
262
|
/**
|
|
220
263
|
* Send to dev tool a new state
|
|
221
264
|
* @param newState new state
|
|
@@ -277,6 +320,20 @@ declare abstract class NgSimpleStateBaseRxjsStore<S extends object | Array<any>>
|
|
|
277
320
|
* @returns True if the state is changed
|
|
278
321
|
*/
|
|
279
322
|
setState(stateFn: NgSimpleStateSetState<S>, actionName?: string): boolean;
|
|
323
|
+
/**
|
|
324
|
+
* Replace state
|
|
325
|
+
* @param newState New state
|
|
326
|
+
* @param actionName The action label into Redux DevTools (default is parent function name)
|
|
327
|
+
* @returns True if the state is changed
|
|
328
|
+
*/
|
|
329
|
+
replaceState(newState: S, actionName?: string): boolean;
|
|
330
|
+
/**
|
|
331
|
+
* Replace state
|
|
332
|
+
* @param selectFn State reducer
|
|
333
|
+
* @param actionName The action label into Redux DevTools (default is parent function name)
|
|
334
|
+
* @returns True if the state is changed
|
|
335
|
+
*/
|
|
336
|
+
replaceState(stateFn: NgSimpleStateReplaceState<S>, actionName?: string): boolean;
|
|
280
337
|
static ɵfac: i0.ɵɵFactoryDeclaration<NgSimpleStateBaseRxjsStore<any>, never>;
|
|
281
338
|
static ɵdir: i0.ɵɵDirectiveDeclaration<NgSimpleStateBaseRxjsStore<any>, never, never, {}, {}, never, never, true, never>;
|
|
282
339
|
static ɵprov: i0.ɵɵInjectableDeclaration<NgSimpleStateBaseRxjsStore<any>>;
|
|
@@ -317,6 +374,20 @@ declare abstract class NgSimpleStateBaseSignalStore<S extends object | Array<any
|
|
|
317
374
|
* @returns True if the state is changed
|
|
318
375
|
*/
|
|
319
376
|
setState(stateFn: NgSimpleStateSetState<S>, actionName?: string): boolean;
|
|
377
|
+
/**
|
|
378
|
+
* Replace state
|
|
379
|
+
* @param newState New state
|
|
380
|
+
* @param actionName The action label into Redux DevTools (default is parent function name)
|
|
381
|
+
* @returns True if the state is changed
|
|
382
|
+
*/
|
|
383
|
+
replaceState(newState: S, actionName?: string): boolean;
|
|
384
|
+
/**
|
|
385
|
+
* Replace state
|
|
386
|
+
* @param selectFn State reducer
|
|
387
|
+
* @param actionName The action label into Redux DevTools (default is parent function name)
|
|
388
|
+
* @returns True if the state is changed
|
|
389
|
+
*/
|
|
390
|
+
replaceState(stateFn: NgSimpleStateReplaceState<S>, actionName?: string): boolean;
|
|
320
391
|
static ɵfac: i0.ɵɵFactoryDeclaration<NgSimpleStateBaseSignalStore<any>, never>;
|
|
321
392
|
static ɵdir: i0.ɵɵDirectiveDeclaration<NgSimpleStateBaseSignalStore<any>, never, never, {}, {}, never, never, true, never>;
|
|
322
393
|
static ɵprov: i0.ɵɵInjectableDeclaration<NgSimpleStateBaseSignalStore<any>>;
|
|
@@ -330,7 +401,12 @@ declare class NgSimpleStateSessionStorage<K = unknown> extends NgSimpleStateStor
|
|
|
330
401
|
constructor(config?: NgSimpleStateStoreConfig<K>);
|
|
331
402
|
}
|
|
332
403
|
|
|
404
|
+
/**
|
|
405
|
+
* Provide NgSimpleState with optional global configuration
|
|
406
|
+
* @param {NgSimpleStateConfig} ngSimpleStateConfig
|
|
407
|
+
* @returns {EnvironmentProviders[]}
|
|
408
|
+
*/
|
|
333
409
|
declare function provideNgSimpleState(ngSimpleStateConfig?: NgSimpleStateConfig): EnvironmentProviders[];
|
|
334
410
|
|
|
335
411
|
export { NG_SIMPLE_STORE_CONFIG, NgSimpleStateBaseCommonStore, NgSimpleStateBaseRxjsStore, NgSimpleStateBaseSignalStore, NgSimpleStateDevTool, NgSimpleStateLocalStorage, NgSimpleStateModule, NgSimpleStateSessionStorage, provideNgSimpleState };
|
|
336
|
-
export type { NgSimpleStateComparator, NgSimpleStateConfig, NgSimpleStateSelectState, NgSimpleStateSetState, NgSimpleStateStoreConfig, StateFnOrNewState };
|
|
412
|
+
export type { NgSimpleStateComparator, NgSimpleStateConfig, NgSimpleStateReplaceState, NgSimpleStateSelectState, NgSimpleStateSetState, NgSimpleStateStoreConfig, StateFnOrNewState, StateFnOrReplaceState };
|