ngssm-store 22.1.0 → 22.2.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"ngssm-store-caching.mjs","sources":["../../../projects/ngssm-store/caching/src/actions/ngssm-caching-action-type.ts","../../../projects/ngssm-store/caching/src/model/cached-item-status.ts","../../../projects/ngssm-store/caching/src/actions/set-cached-item.action.ts","../../../projects/ngssm-store/caching/src/actions/unset-cached-item.action.ts","../../../projects/ngssm-store/caching/src/state/ngssm-caching.state.ts","../../../projects/ngssm-store/caching/src/state/selectors.ts","../../../projects/ngssm-store/caching/src/reducers/cached-item.reducer.ts","../../../projects/ngssm-store/caching/src/provide-ngssm-caching.ts","../../../projects/ngssm-store/caching/src/cached-item-signal.ts","../../../projects/ngssm-store/caching/ngssm-store-caching.ts"],"sourcesContent":["export enum NgssmCachingActionType {\n setCachedItem = '[NgssmCachingActionType] setCachedItem',\n unsetCachedItem = '[NgssmCachingActionType] unsetCachedItem'\n}\n","export enum CachedItemStatus {\n notSet = 'Not Set',\n loading = 'Loading',\n set = 'Set',\n error = 'Error'\n}\n","import { Action } from 'ngssm-store';\n\nimport { NgssmCachingActionType } from './ngssm-caching-action-type';\nimport { CachedItemStatus } from '../model';\n\n/**\n * Represents an action to set a cached item in the state. If key is already set in the state, the value is replaced by the new one.\n *\n * @template TData The type of the cached item's data.\n * @implements {Action}\n *\n * @property {string} cachedItemKey - The unique key identifying the cached item.\n * @property {TData} cachedItem - The data to be cached.\n * @property {CachedItemStatus} [status=CachedItemStatus.set] - The status of the cached item operation.\n * @property {string} [error] - An optional error message if the caching operation failed.\n *\n * @remarks\n * This action is dispatched to update the cache with a new or modified item, along with its status and any error information.\n */\nexport class SetCachedItemAction<TData = unknown> implements Action {\n public readonly type: string = NgssmCachingActionType.setCachedItem;\n\n constructor(\n public readonly cachedItemKey: string,\n public readonly cachedItem: TData,\n public readonly status = CachedItemStatus.set,\n public readonly error?: string\n ) {}\n}\n","import { Action } from 'ngssm-store';\nimport { NgssmCachingActionType } from './ngssm-caching-action-type';\n\nexport class UnsetCachedItemAction implements Action {\n public readonly type: string = NgssmCachingActionType.unsetCachedItem;\n\n constructor(public readonly cachedItemKey: string) {}\n}\n","import update, { CustomCommands, Spec } from 'immutability-helper';\n\nimport { NgSsmFeatureState, State } from 'ngssm-store';\nimport { CachedItem } from '../model';\n\nexport const selectNgssmCachingState = (state: State): NgssmCachingState =>\n state[NgssmCachingStateSpecification.featureStateKey] as NgssmCachingState;\n\nexport const updateNgssmCachingState = <T extends CustomCommands<object> = never>(\n state: State,\n command: Spec<NgssmCachingState, T>\n): State =>\n update(state, {\n [NgssmCachingStateSpecification.featureStateKey]: command\n });\n\nexport interface NgssmCachingState {\n caches: Record<string, CachedItem>;\n}\n\n@NgSsmFeatureState({\n featureStateKey: NgssmCachingStateSpecification.featureStateKey,\n initialState: NgssmCachingStateSpecification.initialState\n})\nexport class NgssmCachingStateSpecification {\n public static readonly featureStateKey = 'ngssm-caching-state';\n public static readonly initialState: NgssmCachingState = {\n caches: {}\n };\n}\n","import { State } from 'ngssm-store';\nimport { CachedItem } from '../model';\nimport { selectNgssmCachingState } from './ngssm-caching.state';\n\nexport const selectNgssmCachedItem = <T = unknown>(state: State, key: string): CachedItem<T> | undefined =>\n selectNgssmCachingState(state).caches[key] as CachedItem<T>;\n","import { Injectable } from '@angular/core';\n\nimport { Reducer, State, Action } from 'ngssm-store';\n\nimport { NgssmCachingActionType, SetCachedItemAction, UnsetCachedItemAction } from '../actions';\nimport { selectNgssmCachedItem, updateNgssmCachingState } from '../state';\n\n@Injectable()\nexport class CachedItemReducer implements Reducer {\n public readonly processedActions: string[] = [NgssmCachingActionType.setCachedItem, NgssmCachingActionType.unsetCachedItem];\n\n public updateState(state: State, action: Action): State {\n switch (action.type) {\n case NgssmCachingActionType.setCachedItem: {\n const setCachedItemAction = action as SetCachedItemAction;\n\n return updateNgssmCachingState(state, {\n caches: {\n [setCachedItemAction.cachedItemKey]: {\n $set: {\n status: setCachedItemAction.status,\n error: setCachedItemAction.error,\n item: setCachedItemAction.cachedItem\n }\n }\n }\n });\n }\n\n case NgssmCachingActionType.unsetCachedItem: {\n const unsetCachedItemAction = action as UnsetCachedItemAction;\n if (selectNgssmCachedItem(state, unsetCachedItemAction.cachedItemKey) === undefined) {\n return state;\n }\n\n return updateNgssmCachingState(state, {\n caches: { $unset: [unsetCachedItemAction.cachedItemKey] }\n });\n }\n }\n\n return state;\n }\n}\n","import { EnvironmentProviders, makeEnvironmentProviders } from '@angular/core';\nimport { provideReducers } from 'ngssm-store';\nimport { CachedItemReducer } from './reducers';\n\nexport const provideNgssmCaching = (): EnvironmentProviders => {\n return makeEnvironmentProviders([provideReducers(CachedItemReducer)]);\n};\n","import { computed, inject, Signal } from '@angular/core';\nimport { Store } from 'ngssm-store';\n\nimport { CachedItemStatus } from './model';\nimport { selectNgssmCachedItem } from './state';\n\nexport interface NgssmCachedItemSignal<T = unknown> {\n key: string;\n value: Signal<T>;\n}\n\nexport type NgssmCachedItemSignalType = 'item' | 'status' | 'error';\n\nexport interface NgssmCachedItemSignalOptions<T = unknown> {\n type?: NgssmCachedItemSignalType;\n defaultValue?: T;\n}\n\nexport const cachedItemToSignal = <T = unknown>(key: string, options?: NgssmCachedItemSignalOptions<T>): NgssmCachedItemSignal<T> => {\n const store = inject(Store);\n\n const usedOptions = options ?? { type: 'item' };\n if (!usedOptions.type) {\n usedOptions.type = 'item';\n }\n\n switch (usedOptions.type) {\n case 'status':\n return {\n key,\n value: computed(\n () => selectNgssmCachedItem(store.state(), key)?.status ?? options?.defaultValue ?? CachedItemStatus.notSet\n ) as Signal<T>\n };\n\n case 'error':\n return {\n key,\n value: computed(() => selectNgssmCachedItem(store.state(), key)?.error ?? options?.defaultValue) as Signal<T>\n };\n\n case 'item':\n return {\n key,\n value: computed(() => selectNgssmCachedItem<T>(store.state(), key)?.item ?? options?.defaultValue) as Signal<T>\n };\n }\n};\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I,OAAO,EAAE,YAAY;aAChG;AAEH,QAAA,KAAK,MAAM;YACT,OAAO;gBACL,GAAG;gBACH,KAAK,EAAE,QAAQ,CAAC,MAAM,qBAAqB,CAAI,KAAK,CAAC,KAAK,EAAE,EAAE,GAAG,CAAC,EAAE,IAAI,IAAI,OAAO,EAAE,YAAY;aAClG;;AAEP;;AC/CA;;AAEG;;;;"}
1
+ {"version":3,"file":"ngssm-store-caching.mjs","names":[],"sources":["../../../projects/ngssm-store/caching/src/actions/ngssm-caching-action-type.ts","../../../projects/ngssm-store/caching/src/model/cached-item-status.ts","../../../projects/ngssm-store/caching/src/actions/set-cached-item.action.ts","../../../projects/ngssm-store/caching/src/actions/unset-cached-item.action.ts","../../../projects/ngssm-store/caching/src/state/ngssm-caching.state.ts","../../../projects/ngssm-store/caching/src/state/selectors.ts","../../../projects/ngssm-store/caching/src/reducers/cached-item.reducer.ts","../../../projects/ngssm-store/caching/src/provide-ngssm-caching.ts","../../../projects/ngssm-store/caching/src/cached-item-signal.ts"],"sourcesContent":["export enum NgssmCachingActionType {\n setCachedItem = '[NgssmCachingActionType] setCachedItem',\n unsetCachedItem = '[NgssmCachingActionType] unsetCachedItem'\n}\n","export enum CachedItemStatus {\n notSet = 'Not Set',\n loading = 'Loading',\n set = 'Set',\n error = 'Error'\n}\n","import { Action } from 'ngssm-store';\n\nimport { NgssmCachingActionType } from './ngssm-caching-action-type';\nimport { CachedItemStatus } from '../model';\n\n/**\n * Represents an action to set a cached item in the state. If key is already set in the state, the value is replaced by the new one.\n *\n * @template TData The type of the cached item's data.\n * @implements {Action}\n *\n * @property {string} cachedItemKey - The unique key identifying the cached item.\n * @property {TData} cachedItem - The data to be cached.\n * @property {CachedItemStatus} [status=CachedItemStatus.set] - The status of the cached item operation.\n * @property {string} [error] - An optional error message if the caching operation failed.\n *\n * @remarks\n * This action is dispatched to update the cache with a new or modified item, along with its status and any error information.\n */\nexport class SetCachedItemAction<TData = unknown> implements Action {\n public readonly type: string = NgssmCachingActionType.setCachedItem;\n\n constructor(\n public readonly cachedItemKey: string,\n public readonly cachedItem: TData,\n public readonly status = CachedItemStatus.set,\n public readonly error?: string\n ) {}\n}\n","import { Action } from 'ngssm-store';\nimport { NgssmCachingActionType } from './ngssm-caching-action-type';\n\nexport class UnsetCachedItemAction implements Action {\n public readonly type: string = NgssmCachingActionType.unsetCachedItem;\n\n constructor(public readonly cachedItemKey: string) {}\n}\n","import update, { CustomCommands, Spec } from 'immutability-helper';\n\nimport { NgSsmFeatureState, State } from 'ngssm-store';\nimport { CachedItem } from '../model';\n\nexport const selectNgssmCachingState = (state: State): NgssmCachingState =>\n state[NgssmCachingStateSpecification.featureStateKey] as NgssmCachingState;\n\nexport const updateNgssmCachingState = <T extends CustomCommands<object> = never>(\n state: State,\n command: Spec<NgssmCachingState, T>\n): State =>\n update(state, {\n [NgssmCachingStateSpecification.featureStateKey]: command\n });\n\nexport interface NgssmCachingState {\n caches: Record<string, CachedItem>;\n}\n\n@NgSsmFeatureState({\n featureStateKey: NgssmCachingStateSpecification.featureStateKey,\n initialState: NgssmCachingStateSpecification.initialState\n})\nexport class NgssmCachingStateSpecification {\n public static readonly featureStateKey = 'ngssm-caching-state';\n public static readonly initialState: NgssmCachingState = {\n caches: {}\n };\n}\n","import { State } from 'ngssm-store';\nimport { CachedItem } from '../model';\nimport { selectNgssmCachingState } from './ngssm-caching.state';\n\nexport const selectNgssmCachedItem = <T = unknown>(state: State, key: string): CachedItem<T> | undefined =>\n selectNgssmCachingState(state).caches[key] as CachedItem<T>;\n","import { Injectable } from '@angular/core';\n\nimport { Reducer, State, Action } from 'ngssm-store';\n\nimport { NgssmCachingActionType, SetCachedItemAction, UnsetCachedItemAction } from '../actions';\nimport { selectNgssmCachedItem, updateNgssmCachingState } from '../state';\n\n@Injectable()\nexport class CachedItemReducer implements Reducer {\n public readonly processedActions: string[] = [NgssmCachingActionType.setCachedItem, NgssmCachingActionType.unsetCachedItem];\n\n public updateState(state: State, action: Action): State {\n switch (action.type) {\n case NgssmCachingActionType.setCachedItem: {\n const setCachedItemAction = action as SetCachedItemAction;\n\n return updateNgssmCachingState(state, {\n caches: {\n [setCachedItemAction.cachedItemKey]: {\n $set: {\n status: setCachedItemAction.status,\n error: setCachedItemAction.error,\n item: setCachedItemAction.cachedItem\n }\n }\n }\n });\n }\n\n case NgssmCachingActionType.unsetCachedItem: {\n const unsetCachedItemAction = action as UnsetCachedItemAction;\n if (selectNgssmCachedItem(state, unsetCachedItemAction.cachedItemKey) === undefined) {\n return state;\n }\n\n return updateNgssmCachingState(state, {\n caches: { $unset: [unsetCachedItemAction.cachedItemKey] }\n });\n }\n }\n\n return state;\n }\n}\n","import { EnvironmentProviders, makeEnvironmentProviders } from '@angular/core';\nimport { provideReducers } from 'ngssm-store';\nimport { CachedItemReducer } from './reducers';\n\nexport const provideNgssmCaching = (): EnvironmentProviders => {\n return makeEnvironmentProviders([provideReducers(CachedItemReducer)]);\n};\n","import { computed, inject, Signal } from '@angular/core';\nimport { Store } from 'ngssm-store';\n\nimport { CachedItemStatus } from './model';\nimport { selectNgssmCachedItem } from './state';\n\nexport interface NgssmCachedItemSignal<T = unknown> {\n key: string;\n value: Signal<T>;\n}\n\nexport type NgssmCachedItemSignalType = 'item' | 'status' | 'error';\n\nexport interface NgssmCachedItemSignalOptions<T = unknown> {\n type?: NgssmCachedItemSignalType;\n defaultValue?: T;\n}\n\nexport const cachedItemToSignal = <T = unknown>(key: string, options?: NgssmCachedItemSignalOptions<T>): NgssmCachedItemSignal<T> => {\n const store = inject(Store);\n\n const usedOptions = options ?? { type: 'item' };\n if (!usedOptions.type) {\n usedOptions.type = 'item';\n }\n\n switch (usedOptions.type) {\n case 'status':\n return {\n key,\n value: computed(\n () => selectNgssmCachedItem(store.state(), key)?.status ?? options?.defaultValue ?? CachedItemStatus.notSet\n ) as Signal<T>\n };\n\n case 'error':\n return {\n key,\n value: computed(() => selectNgssmCachedItem(store.state(), key)?.error ?? options?.defaultValue) as Signal<T>\n };\n\n case 'item':\n return {\n key,\n value: computed(() => selectNgssmCachedItem<T>(store.state(), key)?.item ?? options?.defaultValue) as Signal<T>\n };\n }\n};\n"],"mappings":";;;;;AAAA,IAAY;CAAZ,SAAY,wBAAsB;CAChC,uBAAA,mBAAA;CACA,uBAAA,qBAAA;AACF,EAAA,CAHY,2BAAA,yBAAsB,CAAA,EAAA;ACAlC,IAAY;CAAZ,SAAY,kBAAgB;CAC1B,iBAAA,YAAA;CACA,iBAAA,aAAA;CACA,iBAAA,SAAA;CACA,iBAAA,WAAA;AACF,EAAA,CALY,qBAAA,mBAAgB,CAAA,EAAA;ACmB5B,IAAa,sBAAb,MAAgC;CAIZ;CACA;CACA;CACA;CANF,OAAe,uBAAuB;CAEtD,YACkB,eACA,YACA,SAAS,iBAAiB,KAC1B,OAAc;EAHd,KAAA,gBAAA;EACA,KAAA,aAAA;EACA,KAAA,SAAA;EACA,KAAA,QAAA;CACf;AACJ;ACzBD,IAAa,wBAAb,MAAkC;CAGJ;CAFZ,OAAe,uBAAuB;CAEtD,YAA4B,eAAqB;EAArB,KAAA,gBAAA;CAAwB;AACrD;ACFD,MAAa,2BAA2B,UACtC,MAAM,+BAA+B;AAEvC,MAAa,2BACX,OACA,YAEA,OAAO,OAAO,GACX,+BAA+B,kBAAkB,QACnD,CAAA;AAUI,IAAM,iCAAN,MAAM,+BAA8B;CAClC,OAAgB,kBAAkB;CAClC,OAAgB,eAAkC,EACvD,QAAQ,CAAA,EACT;;AAJU,iCAA8B,WAAA,CAJ1C,kBAAkB;CACjB,iBAAiB,+BAA+B;CAChD,cAAc,+BAA+B;AAC9C,CAAA,CACY,GAAA,8BAA8B;ACpB3C,MAAa,yBAAsC,OAAc,QAC/D,wBAAwB,KAAK,CAAC,CAAC,OAAO;ACGxC,IAAa,oBAAb,MAAa,kBAAiB;CACZ,mBAA6B,CAAC,uBAAuB,eAAe,uBAAuB,eAAe;CAEnH,YAAY,OAAc,QAAc;EAC7C,QAAQ,OAAO,MAAf;GACE,KAAK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AAK,GAAI,GAAG,CAAC,EAAE,SAAS,SAAS,YAAY;EAChG;EAEH,KAAK,QACH,OAAO;GACL;GACA,OAAO,eAAe,sBAAyB,MAAM,MAAK,GAAI,GAAG,CAAC,EAAE,QAAQ,SAAS,YAAY;EAClG;CACL;AACF"}
@@ -1,67 +1,39 @@
1
- import { signal, makeEnvironmentProviders } from '@angular/core';
2
- import { BehaviorSubject } from 'rxjs';
3
- import { Store } from 'ngssm-store';
4
-
5
- class StoreMock {
6
- state$;
7
- state;
8
- logsEnabled = false;
9
- processedAction = signal({ type: '' }, /* @ts-ignore */
10
- ...(ngDevMode ? [{ debugName: "processedAction" }] : /* istanbul ignore next */ []));
11
- _stateValue = {};
12
- constructor(initialState) {
13
- this.state$ = new BehaviorSubject(this._stateValue);
14
- this.state = signal(this._stateValue, /* @ts-ignore */
15
- ...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
16
- this.stateValue = initialState;
17
- }
18
- get stateValue() {
19
- return this._stateValue;
20
- }
21
- set stateValue(value) {
22
- this._stateValue = value;
23
- this.state$.next(value);
24
- this.state.set(value);
25
- }
26
- dispatchAction(action) {
27
- if (this.logsEnabled) {
28
- console.log('[StoreMock - dispatchAction]', action);
29
- }
30
- }
31
- dispatchActionType(type) {
32
- if (this.logsEnabled) {
33
- console.log('[StoreMock - dispatchActionType]', type);
34
- }
35
- }
36
- }
37
-
38
- /**
39
- * Provides a testing environment provider for the `Store` service using a mock implementation.
40
- *
41
- * This function returns Angular environment providers that replace the actual `Store` service
42
- * with a `StoreMock` instance, allowing for isolated and controlled testing of components or services
43
- * that depend on the `Store`.
44
- *
45
- * This function registers the `Store` and the `StoreMock` with the same value.
46
- *
47
- * @param action Optional callback function that receives the mock `Store` instance. Can be used to configure
48
- * or manipulate the mock store before it is provided to the testing environment.
49
- * @returns The environment providers configured with the `StoreMock`.
50
- */
1
+ import { makeEnvironmentProviders, signal } from "@angular/core";
2
+ import { Store } from "ngssm-store";
3
+ var StoreMock = class {
4
+ state;
5
+ logsEnabled = false;
6
+ processedAction = signal({ type: "" }, ...ngDevMode ? [{ debugName: "processedAction" }] : /* istanbul ignore next */ []);
7
+ _stateValue = {};
8
+ constructor(initialState) {
9
+ this.state = signal(this._stateValue, ...ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []);
10
+ this.stateValue = initialState;
11
+ }
12
+ get stateValue() {
13
+ return this._stateValue;
14
+ }
15
+ set stateValue(value) {
16
+ this._stateValue = value;
17
+ this.state.set(value);
18
+ }
19
+ dispatchAction(action) {
20
+ if (this.logsEnabled) console.log("[StoreMock - dispatchAction]", action);
21
+ }
22
+ dispatchActionType(type) {
23
+ if (this.logsEnabled) console.log("[StoreMock - dispatchActionType]", type);
24
+ }
25
+ };
51
26
  const provideNgssmStoreTesting = (action) => {
52
- const store = new StoreMock({});
53
- if (action) {
54
- action(store);
55
- }
56
- return makeEnvironmentProviders([
57
- { provide: Store, useValue: store },
58
- { provide: StoreMock, useValue: store }
59
- ]);
27
+ const store = new StoreMock({});
28
+ if (action) action(store);
29
+ return makeEnvironmentProviders([{
30
+ provide: Store,
31
+ useValue: store
32
+ }, {
33
+ provide: StoreMock,
34
+ useValue: store
35
+ }]);
60
36
  };
61
-
62
- /**
63
- * Generated bundle index. Do not edit.
64
- */
65
-
66
37
  export { StoreMock, provideNgssmStoreTesting };
67
- //# sourceMappingURL=ngssm-store-testing.mjs.map
38
+
39
+ //# sourceMappingURL=ngssm-store-testing.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ngssm-store-testing.mjs","sources":["../../../projects/ngssm-store/testing/src/store-mock.ts","../../../projects/ngssm-store/testing/src/provide-ngssm-store-testing.ts","../../../projects/ngssm-store/testing/ngssm-store-testing.ts"],"sourcesContent":["import { WritableSignal, signal } from '@angular/core';\nimport { BehaviorSubject } from 'rxjs';\n\nimport { Action, ActionDispatcher, State } from 'ngssm-store';\n\nexport class StoreMock implements ActionDispatcher {\n public readonly state$: BehaviorSubject<State>;\n public readonly state: WritableSignal<State>;\n public logsEnabled = false;\n public processedAction = signal<Action>({ type: '' });\n\n private _stateValue: State = {};\n\n constructor(initialState: State) {\n this.state$ = new BehaviorSubject<State>(this._stateValue);\n this.state = signal<State>(this._stateValue);\n this.stateValue = initialState;\n }\n\n public get stateValue(): State {\n return this._stateValue;\n }\n\n public set stateValue(value: State) {\n this._stateValue = value;\n this.state$.next(value);\n this.state.set(value);\n }\n\n public dispatchAction(action: Action): void {\n if (this.logsEnabled) {\n console.log('[StoreMock - dispatchAction]', action);\n }\n }\n\n public dispatchActionType(type: string): void {\n if (this.logsEnabled) {\n console.log('[StoreMock - dispatchActionType]', type);\n }\n }\n}\n","import { EnvironmentProviders, makeEnvironmentProviders } from '@angular/core';\n\nimport { Store } from 'ngssm-store';\n\nimport { StoreMock } from './store-mock';\n\n/**\n * Provides a testing environment provider for the `Store` service using a mock implementation.\n *\n * This function returns Angular environment providers that replace the actual `Store` service\n * with a `StoreMock` instance, allowing for isolated and controlled testing of components or services\n * that depend on the `Store`.\n *\n * This function registers the `Store` and the `StoreMock` with the same value.\n *\n * @param action Optional callback function that receives the mock `Store` instance. Can be used to configure\n * or manipulate the mock store before it is provided to the testing environment.\n * @returns The environment providers configured with the `StoreMock`.\n */\nexport const provideNgssmStoreTesting = (action?: (store: StoreMock) => void): EnvironmentProviders => {\n const store = new StoreMock({});\n if (action) {\n action(store);\n }\n return makeEnvironmentProviders([\n { provide: Store, useValue: store },\n { provide: StoreMock, useValue: store }\n ]);\n};\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;MAKa,SAAS,CAAA;AACJ,IAAA,MAAM;AACN,IAAA,KAAK;IACd,WAAW,GAAG,KAAK;AACnB,IAAA,eAAe,GAAG,MAAM,CAAS,EAAE,IAAI,EAAE,EAAE,EAAE;wFAAC;IAE7C,WAAW,GAAU,EAAE;AAE/B,IAAA,WAAA,CAAY,YAAmB,EAAA;QAC7B,IAAI,CAAC,MAAM,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../../projects/ngssm-store/testing/src/provide-ngssm-store-testing.ts"],"sourcesContent":["import { WritableSignal, signal } from '@angular/core';\n\nimport { Action, ActionDispatcher, State } from 'ngssm-store';\n\nexport class StoreMock implements ActionDispatcher {\n public readonly state: WritableSignal<State>;\n public logsEnabled = false;\n public processedAction = signal<Action>({ type: '' });\n\n private _stateValue: State = {};\n\n constructor(initialState: State) {\n this.state = signal<State>(this._stateValue);\n this.stateValue = initialState;\n }\n\n public get stateValue(): State {\n return this._stateValue;\n }\n\n public set stateValue(value: State) {\n this._stateValue = value;\n this.state.set(value);\n }\n\n public dispatchAction(action: Action): void {\n if (this.logsEnabled) {\n console.log('[StoreMock - dispatchAction]', action);\n }\n }\n\n public dispatchActionType(type: string): void {\n if (this.logsEnabled) {\n console.log('[StoreMock - dispatchActionType]', type);\n }\n }\n}\n","import { EnvironmentProviders, makeEnvironmentProviders } from '@angular/core';\n\nimport { Store } from 'ngssm-store';\n\nimport { StoreMock } from './store-mock';\n\n/**\n * Provides a testing environment provider for the `Store` service using a mock implementation.\n *\n * This function returns Angular environment providers that replace the actual `Store` service\n * with a `StoreMock` instance, allowing for isolated and controlled testing of components or services\n * that depend on the `Store`.\n *\n * This function registers the `Store` and the `StoreMock` with the same value.\n *\n * @param action Optional callback function that receives the mock `Store` instance. Can be used to configure\n * or manipulate the mock store before it is provided to the testing environment.\n * @returns The environment providers configured with the `StoreMock`.\n */\nexport const provideNgssmStoreTesting = (action?: (store: StoreMock) => void): EnvironmentProviders => {\n const store = new StoreMock({});\n if (action) {\n action(store);\n }\n return makeEnvironmentProviders([\n { provide: Store, useValue: store },\n { provide: StoreMock, useValue: store }\n ]);\n};\n"],"mappings":";;AAIA,IAAa,YAAb,MAAsB;CACJ;CACT,cAAc;CACd,kBAAkB,OAAe,EAAE,MAAM,GAAE,GAAG,GAAA,YAAA,CAAA,EAAA,WAAA,kBAAA,CAAA,+BAAA,CAAA,CAAA;CAE7C,cAAqB,CAAA;CAE7B,YAAY,cAAmB;EAC7B,KAAK,QAAQ,OAAc,KAAK,aAAY,GAAA,YAAA,CAAA,EAAA,WAAA,QAAA,CAAA,+BAAA,CAAA,CAAA;EAC5C,KAAK,aAAa;CACpB;CAEA,IAAW,aAAU;EACnB,OAAO,KAAK;CACd;CAEA,IAAW,WAAW,OAAY;EAChC,KAAK,cAAc;EACnB,KAAK,MAAM,IAAI,KAAK;CACtB;CAEO,eAAe,QAAc;EAClC,IAAI,KAAK,aACP,QAAQ,IAAI,gCAAgC,MAAM;CAEtD;CAEO,mBAAmB,MAAY;EACpC,IAAI,KAAK,aACP,QAAQ,IAAI,oCAAoC,IAAI;CAExD;AACD;ACjBD,MAAa,4BAA4B,WAA6D;CACpG,MAAM,QAAQ,IAAI,UAAU,CAAA,CAAE;CAC9B,IAAI,QACF,OAAO,KAAK;CAEd,OAAO,yBAAyB,CAC9B;EAAE,SAAS;EAAO,UAAU;CAAK,GACjC;EAAE,SAAS;EAAW,UAAU;CAAK,CACtC,CAAA;AACH"}
@@ -1,81 +1,59 @@
1
- import * as i0 from '@angular/core';
2
- import { inject, Injectable, makeEnvironmentProviders, provideAppInitializer } from '@angular/core';
3
- import { Store, Logger } from 'ngssm-store';
4
- import { StoreMock } from 'ngssm-store/testing';
5
- import { VisibilityReducer, ShowElementAction, HideElementAction, ToggleElementVisibilityAction, NgssmVisibilityStateSpecification } from 'ngssm-store/visibility';
6
- import { TestBed } from '@angular/core/testing';
7
-
8
- /**
9
- * Utility service for manipulating element visibility state in the StoreMock during tests.
10
- * Provides methods to show, hide, or toggle the visibility of an element.
11
- */
12
- class NgssmVisibilitySetter {
13
- store = inject(Store);
14
- reducer = new VisibilityReducer();
15
- /**
16
- * Sets the specified element as visible in the StoreMock.
17
- * @param elementKey The key of the element to show.
18
- * @returns The NgssmVisibilitySetter instance for chaining.
19
- */
20
- showElement(elementKey) {
21
- this.store.stateValue = this.reducer.updateState(this.store.stateValue, new ShowElementAction(elementKey));
22
- return this;
23
- }
24
- /**
25
- * Sets the specified element as hidden in the StoreMock.
26
- * @param elementKey The key of the element to hide.
27
- * @returns The NgssmVisibilitySetter instance for chaining.
28
- */
29
- hideElement(elementKey) {
30
- this.store.stateValue = this.reducer.updateState(this.store.stateValue, new HideElementAction(elementKey));
31
- return this;
32
- }
33
- /**
34
- * Toggles the visibility of the specified element in the StoreMock.
35
- * @param elementKey The key of the element to toggle.
36
- * @returns The NgssmVisibilitySetter instance for chaining.
37
- */
38
- toggleElementVisibility(elementKey) {
39
- this.store.stateValue = this.reducer.updateState(this.store.stateValue, new ToggleElementVisibilityAction(elementKey));
40
- return this;
41
- }
42
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.1", ngImport: i0, type: NgssmVisibilitySetter, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
43
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.1.1", ngImport: i0, type: NgssmVisibilitySetter });
44
- }
45
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.1", ngImport: i0, type: NgssmVisibilitySetter, decorators: [{
46
- type: Injectable
47
- }] });
48
- /**
49
- * Helper function to retrieve the NgssmVisibilitySetter instance from the TestBed.
50
- */
1
+ import * as i0 from "@angular/core";
2
+ import { Injectable, inject, makeEnvironmentProviders, provideAppInitializer } from "@angular/core";
3
+ import { Logger, Store } from "ngssm-store";
4
+ import { StoreMock } from "ngssm-store/testing";
5
+ import { HideElementAction, NgssmVisibilityStateSpecification, ShowElementAction, ToggleElementVisibilityAction, VisibilityReducer } from "ngssm-store/visibility";
6
+ import { TestBed } from "@angular/core/testing";
7
+ var NgssmVisibilitySetter = class NgssmVisibilitySetter {
8
+ store = inject(Store);
9
+ reducer = new VisibilityReducer();
10
+ showElement(elementKey) {
11
+ this.store.stateValue = this.reducer.updateState(this.store.stateValue, new ShowElementAction(elementKey));
12
+ return this;
13
+ }
14
+ hideElement(elementKey) {
15
+ this.store.stateValue = this.reducer.updateState(this.store.stateValue, new HideElementAction(elementKey));
16
+ return this;
17
+ }
18
+ toggleElementVisibility(elementKey) {
19
+ this.store.stateValue = this.reducer.updateState(this.store.stateValue, new ToggleElementVisibilityAction(elementKey));
20
+ return this;
21
+ }
22
+ static ɵfac = i0.ɵɵngDeclareFactory({
23
+ minVersion: "12.0.0",
24
+ version: "22.2.0",
25
+ ngImport: i0,
26
+ type: NgssmVisibilitySetter,
27
+ deps: [],
28
+ target: i0.ɵɵFactoryTarget.Injectable
29
+ });
30
+ static ɵprov = i0.ɵɵngDeclareInjectable({
31
+ minVersion: "12.0.0",
32
+ version: "22.2.0",
33
+ ngImport: i0,
34
+ type: NgssmVisibilitySetter
35
+ });
36
+ };
37
+ i0.ɵɵngDeclareClassMetadata({
38
+ minVersion: "12.0.0",
39
+ version: "22.2.0",
40
+ ngImport: i0,
41
+ type: NgssmVisibilitySetter,
42
+ decorators: [{ type: Injectable }]
43
+ });
51
44
  const ngssmVisibilitySetter = () => TestBed.inject(NgssmVisibilitySetter);
52
-
53
- /**
54
- * App initializer that sets up the ngssm state visibility in the StoreMock for testing purposes.
55
- * Throws an error if StoreMock is not registered.
56
- */
57
45
  const ngssmVisibilityStateInitializer = () => {
58
- const logger = inject(Logger);
59
- logger.information('[ngssm-visibility-testing] Initialization of state');
60
- const store = inject(Store);
61
- if (!(store instanceof StoreMock)) {
62
- throw new Error('StoreMock is not registered.');
63
- }
64
- store.stateValue = {
65
- ...store.stateValue,
66
- [NgssmVisibilityStateSpecification.featureStateKey]: NgssmVisibilityStateSpecification.initialState
67
- };
46
+ inject(Logger).information("[ngssm-visibility-testing] Initialization of state");
47
+ const store = inject(Store);
48
+ if (!(store instanceof StoreMock)) throw new Error("StoreMock is not registered.");
49
+ store.stateValue = {
50
+ ...store.stateValue,
51
+ [NgssmVisibilityStateSpecification.featureStateKey]: NgssmVisibilityStateSpecification.initialState
52
+ };
68
53
  };
69
- /**
70
- * Provides environment providers for ngssm visibility testing, including the state initializer.
71
- */
72
54
  const provideNgssmVisibilityTesting = () => {
73
- return makeEnvironmentProviders([provideAppInitializer(ngssmVisibilityStateInitializer), NgssmVisibilitySetter]);
55
+ return makeEnvironmentProviders([provideAppInitializer(ngssmVisibilityStateInitializer), NgssmVisibilitySetter]);
74
56
  };
75
-
76
- /**
77
- * Generated bundle index. Do not edit.
78
- */
79
-
80
57
  export { NgssmVisibilitySetter, ngssmVisibilitySetter, ngssmVisibilityStateInitializer, provideNgssmVisibilityTesting };
81
- //# sourceMappingURL=ngssm-store-visibility-testing.mjs.map
58
+
59
+ //# sourceMappingURL=ngssm-store-visibility-testing.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ngssm-store-visibility-testing.mjs","sources":["../../../projects/ngssm-store/visibility/testing/src/ngssm-visibility-setter.ts","../../../projects/ngssm-store/visibility/testing/src/provide-ngssm-visibility-testing.ts","../../../projects/ngssm-store/visibility/testing/ngssm-store-visibility-testing.ts"],"sourcesContent":["import { inject, Injectable } from '@angular/core';\nimport { TestBed } from '@angular/core/testing';\n\nimport { Store } from 'ngssm-store';\nimport { StoreMock } from 'ngssm-store/testing';\nimport { HideElementAction, ShowElementAction, ToggleElementVisibilityAction, VisibilityReducer } from 'ngssm-store/visibility';\n\n/**\n * Utility service for manipulating element visibility state in the StoreMock during tests.\n * Provides methods to show, hide, or toggle the visibility of an element.\n */\n@Injectable()\nexport class NgssmVisibilitySetter {\n public readonly store = inject(Store) as unknown as StoreMock;\n\n private readonly reducer = new VisibilityReducer();\n\n /**\n * Sets the specified element as visible in the StoreMock.\n * @param elementKey The key of the element to show.\n * @returns The NgssmVisibilitySetter instance for chaining.\n */\n public showElement(elementKey: string): NgssmVisibilitySetter {\n this.store.stateValue = this.reducer.updateState(this.store.stateValue, new ShowElementAction(elementKey));\n return this;\n }\n\n /**\n * Sets the specified element as hidden in the StoreMock.\n * @param elementKey The key of the element to hide.\n * @returns The NgssmVisibilitySetter instance for chaining.\n */\n public hideElement(elementKey: string): NgssmVisibilitySetter {\n this.store.stateValue = this.reducer.updateState(this.store.stateValue, new HideElementAction(elementKey));\n return this;\n }\n\n /**\n * Toggles the visibility of the specified element in the StoreMock.\n * @param elementKey The key of the element to toggle.\n * @returns The NgssmVisibilitySetter instance for chaining.\n */\n public toggleElementVisibility(elementKey: string): NgssmVisibilitySetter {\n this.store.stateValue = this.reducer.updateState(this.store.stateValue, new ToggleElementVisibilityAction(elementKey));\n return this;\n }\n}\n\n/**\n * Helper function to retrieve the NgssmVisibilitySetter instance from the TestBed.\n */\nexport const ngssmVisibilitySetter = () => TestBed.inject(NgssmVisibilitySetter);\n","import { EnvironmentProviders, inject, makeEnvironmentProviders, provideAppInitializer } from '@angular/core';\n\nimport { Logger, Store } from 'ngssm-store';\nimport { StoreMock } from 'ngssm-store/testing';\nimport { NgssmVisibilityStateSpecification } from 'ngssm-store/visibility';\n\nimport { NgssmVisibilitySetter } from './ngssm-visibility-setter';\n\n/**\n * App initializer that sets up the ngssm state visibility in the StoreMock for testing purposes.\n * Throws an error if StoreMock is not registered.\n */\nexport const ngssmVisibilityStateInitializer = () => {\n const logger = inject(Logger);\n logger.information('[ngssm-visibility-testing] Initialization of state');\n const store = inject(Store);\n if (!(store instanceof StoreMock)) {\n throw new Error('StoreMock is not registered.');\n }\n\n store.stateValue = {\n ...store.stateValue,\n [NgssmVisibilityStateSpecification.featureStateKey]: NgssmVisibilityStateSpecification.initialState\n };\n};\n\n/**\n * Provides environment providers for ngssm visibility testing, including the state initializer.\n */\nexport const provideNgssmVisibilityTesting = (): EnvironmentProviders => {\n return makeEnvironmentProviders([provideAppInitializer(ngssmVisibilityStateInitializer), NgssmVisibilitySetter]);\n};\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;;;;AAOA;;;AAGG;MAEU,qBAAqB,CAAA;AAChB,IAAA,KAAK,GAAG,MAAM,CAAC,KAAK,CAAyB;AAE5C,IAAA,OAAO,GAAG,IAAI,iBAAiB,EAAE;AAElD;;;;AAIG;AACI,IAAA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CAAC,8BAA8B,CAAC;IACjD;IAEA,KAAK,CAAC,UAAU,GAAG;QACjB,GAAG,KAAK,CAAC,UAAU;AACnB,QAAA,CAAC,iCAAiC,CAAC,eAAe,GAAG,iCAAiC,CAAC;KACxF;AACH;AAEA;;AAEG;AACI,MAAM,6BAA6B,GAAG,MAA2B;IACtE,OAAO,wBAAwB,CAAC,CAAC,qBAAqB,CAAC,+BAA+B,CAAC,EAAE,qBAAqB,CAAC,CAAC;AAClH;;AC/BA;;AAEG;;;;"}
1
+ {"version":3,"file":"ngssm-store-visibility-testing.mjs","names":[],"sources":["../../../projects/ngssm-store/visibility/testing/src/ngssm-visibility-setter.ts","../../../projects/ngssm-store/visibility/testing/src/provide-ngssm-visibility-testing.ts"],"sourcesContent":["import { inject, Injectable } from '@angular/core';\nimport { TestBed } from '@angular/core/testing';\n\nimport { Store } from 'ngssm-store';\nimport { StoreMock } from 'ngssm-store/testing';\nimport { HideElementAction, ShowElementAction, ToggleElementVisibilityAction, VisibilityReducer } from 'ngssm-store/visibility';\n\n/**\n * Utility service for manipulating element visibility state in the StoreMock during tests.\n * Provides methods to show, hide, or toggle the visibility of an element.\n */\n@Injectable()\nexport class NgssmVisibilitySetter {\n public readonly store = inject(Store) as unknown as StoreMock;\n\n private readonly reducer = new VisibilityReducer();\n\n /**\n * Sets the specified element as visible in the StoreMock.\n * @param elementKey The key of the element to show.\n * @returns The NgssmVisibilitySetter instance for chaining.\n */\n public showElement(elementKey: string): NgssmVisibilitySetter {\n this.store.stateValue = this.reducer.updateState(this.store.stateValue, new ShowElementAction(elementKey));\n return this;\n }\n\n /**\n * Sets the specified element as hidden in the StoreMock.\n * @param elementKey The key of the element to hide.\n * @returns The NgssmVisibilitySetter instance for chaining.\n */\n public hideElement(elementKey: string): NgssmVisibilitySetter {\n this.store.stateValue = this.reducer.updateState(this.store.stateValue, new HideElementAction(elementKey));\n return this;\n }\n\n /**\n * Toggles the visibility of the specified element in the StoreMock.\n * @param elementKey The key of the element to toggle.\n * @returns The NgssmVisibilitySetter instance for chaining.\n */\n public toggleElementVisibility(elementKey: string): NgssmVisibilitySetter {\n this.store.stateValue = this.reducer.updateState(this.store.stateValue, new ToggleElementVisibilityAction(elementKey));\n return this;\n }\n}\n\n/**\n * Helper function to retrieve the NgssmVisibilitySetter instance from the TestBed.\n */\nexport const ngssmVisibilitySetter = () => TestBed.inject(NgssmVisibilitySetter);\n","import { EnvironmentProviders, inject, makeEnvironmentProviders, provideAppInitializer } from '@angular/core';\n\nimport { Logger, Store } from 'ngssm-store';\nimport { StoreMock } from 'ngssm-store/testing';\nimport { NgssmVisibilityStateSpecification } from 'ngssm-store/visibility';\n\nimport { NgssmVisibilitySetter } from './ngssm-visibility-setter';\n\n/**\n * App initializer that sets up the ngssm state visibility in the StoreMock for testing purposes.\n * Throws an error if StoreMock is not registered.\n */\nexport const ngssmVisibilityStateInitializer = () => {\n const logger = inject(Logger);\n logger.information('[ngssm-visibility-testing] Initialization of state');\n const store = inject(Store);\n if (!(store instanceof StoreMock)) {\n throw new Error('StoreMock is not registered.');\n }\n\n store.stateValue = {\n ...store.stateValue,\n [NgssmVisibilityStateSpecification.featureStateKey]: NgssmVisibilityStateSpecification.initialState\n };\n};\n\n/**\n * Provides environment providers for ngssm visibility testing, including the state initializer.\n */\nexport const provideNgssmVisibilityTesting = (): EnvironmentProviders => {\n return makeEnvironmentProviders([provideAppInitializer(ngssmVisibilityStateInitializer), NgssmVisibilitySetter]);\n};\n"],"mappings":";;;;;;AAYA,IAAa,wBAAb,MAAa,sBAAqB;CAChB,QAAQ,OAAO,KAAK;CAEnB,UAAU,IAAI,kBAAiB;CAOzC,YAAY,YAAkB;EACnC,KAAK,MAAM,aAAa,KAAK,QAAQ,YAAY,KAAK,MAAM,YAAY,IAAI,kBAAkB,UAAU,CAAC;EACzG,OAAO;CACT;CAOO,YAAY,YAAkB;EACnC,KAAK,MAAM,aAAa,KAAK,QAAQ,YAAY,KAAK,MAAM,YAAY,IAAI,kBAAkB,UAA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