@angular-architects/ngrx-toolkit 18.1.1 → 19.0.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.
- package/README.md +4 -12
- package/fesm2022/angular-architects-ngrx-toolkit-redux-connector.mjs +15 -15
- package/fesm2022/angular-architects-ngrx-toolkit-redux-connector.mjs.map +1 -1
- package/fesm2022/angular-architects-ngrx-toolkit.mjs +487 -78
- package/fesm2022/angular-architects-ngrx-toolkit.mjs.map +1 -1
- package/index.d.ts +9 -2
- package/lib/devtools/features/with-disabled-name-indicies.d.ts +27 -0
- package/lib/devtools/features/with-glitch-tracking.d.ts +30 -0
- package/lib/devtools/features/with-mapper.d.ts +28 -0
- package/lib/devtools/internal/current-action-names.d.ts +1 -0
- package/lib/devtools/internal/default-tracker.d.ts +13 -0
- package/lib/devtools/internal/devtools-feature.d.ts +24 -0
- package/lib/devtools/internal/devtools-syncer.service.d.ts +35 -0
- package/lib/devtools/internal/glitch-tracker.service.d.ts +18 -0
- package/lib/devtools/internal/models.d.ts +25 -0
- package/lib/devtools/rename-devtools-name.d.ts +7 -0
- package/lib/devtools/update-state.d.ts +17 -0
- package/lib/devtools/with-dev-tools-stub.d.ts +5 -0
- package/lib/devtools/with-devtools.d.ts +30 -0
- package/lib/shared/prettify.d.ts +1 -1
- package/lib/shared/throw-if-null.d.ts +1 -0
- package/lib/with-call-state.d.ts +2 -2
- package/lib/with-data-service.d.ts +3 -3
- package/lib/with-pagination.d.ts +4 -4
- package/lib/with-reset.d.ts +29 -0
- package/lib/with-storage-sync.d.ts +2 -2
- package/lib/with-undo-redo.d.ts +4 -3
- package/package.json +6 -7
- package/redux-connector/src/lib/create-redux.d.ts +4 -4
- package/redux-connector/src/lib/model.d.ts +5 -0
- package/redux-connector/src/lib/rxjs-interop/redux-method.d.ts +5 -2
- package/redux-connector/src/lib/signal-redux-store.d.ts +10 -2
- package/redux-connector/src/lib/util.d.ts +2 -2
- package/esm2022/angular-architects-ngrx-toolkit.mjs +0 -5
- package/esm2022/index.mjs +0 -8
- package/esm2022/lib/assertions/assertions.mjs +0 -6
- package/esm2022/lib/shared/prettify.mjs +0 -2
- package/esm2022/lib/shared/signal-store-models.mjs +0 -2
- package/esm2022/lib/with-call-state.mjs +0 -60
- package/esm2022/lib/with-data-service.mjs +0 -202
- package/esm2022/lib/with-devtools.mjs +0 -92
- package/esm2022/lib/with-pagination.mjs +0 -209
- package/esm2022/lib/with-redux.mjs +0 -100
- package/esm2022/lib/with-storage-sync.mjs +0 -56
- package/esm2022/lib/with-undo-redo.mjs +0 -113
- package/esm2022/redux-connector/angular-architects-ngrx-toolkit-redux-connector.mjs +0 -5
- package/esm2022/redux-connector/index.mjs +0 -3
- package/esm2022/redux-connector/src/lib/create-redux.mjs +0 -41
- package/esm2022/redux-connector/src/lib/model.mjs +0 -2
- package/esm2022/redux-connector/src/lib/rxjs-interop/redux-method.mjs +0 -22
- package/esm2022/redux-connector/src/lib/signal-redux-store.mjs +0 -43
- package/esm2022/redux-connector/src/lib/util.mjs +0 -13
- package/lib/with-devtools.d.ts +0 -38
package/README.md
CHANGED
|
@@ -1,22 +1,14 @@
|
|
|
1
1
|
# NgRx Toolkit
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<img src="https://raw.githubusercontent.com/angular-architects/ngrx-toolkit/main/logo.png" width="320" />
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
<img src="https://raw.githubusercontent.com/angular-architects/ngrx-toolkit/main/logo.png" width="320" style="text-align: center">
|
|
7
|
-
</p>
|
|
8
|
-
|
|
9
|
-
NgRx Toolkit is an extension to the NgRx Signals Store. **It is still in beta** but already offers features, like:
|
|
5
|
+
NgRx Toolkit is a set of extensions to the NgRx Signals Store, like
|
|
10
6
|
|
|
11
7
|
- Devtools: Integration into Redux Devtools
|
|
12
8
|
- Redux: Possibility to use the Redux Pattern (Reducer, Actions, Effects)
|
|
13
9
|
- Storage Sync: Synchronize the Store with Web Storage
|
|
14
10
|
- Redux Connector: Map NgRx Store Actions to a present Signal Store
|
|
15
11
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
```shell
|
|
19
|
-
npm i @angular-architects/ngrx-toolkit
|
|
20
|
-
```
|
|
12
|
+
For a more detailed guide on installation, setup, and usage, head to the [**Documentation**](https://angular-architects.github.io/ngrx-toolkit/).
|
|
21
13
|
|
|
22
|
-
|
|
14
|
+
## https://angular-architects.github.io/ngrx-toolkit
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { Injectable, inject, makeEnvironmentProviders,
|
|
2
|
+
import { Injectable, inject, makeEnvironmentProviders, provideEnvironmentInitializer, Injector } from '@angular/core';
|
|
3
3
|
import { rxMethod } from '@ngrx/signals/rxjs-interop';
|
|
4
4
|
import { pipe, tap, map } from 'rxjs';
|
|
5
5
|
|
|
@@ -10,8 +10,9 @@ function capitalize(str) {
|
|
|
10
10
|
return str ? str[0].toUpperCase() + str.substring(1) : str;
|
|
11
11
|
}
|
|
12
12
|
function isActionCreator(action) {
|
|
13
|
-
return (typeof action === 'function' &&
|
|
13
|
+
return Boolean(typeof action === 'function' &&
|
|
14
14
|
action &&
|
|
15
|
+
'type' in action &&
|
|
15
16
|
action.type &&
|
|
16
17
|
typeof action.type === 'string');
|
|
17
18
|
}
|
|
@@ -41,10 +42,10 @@ class SignalReduxStore {
|
|
|
41
42
|
resultMethod: mapper.resultMethod
|
|
42
43
|
}));
|
|
43
44
|
}
|
|
44
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
45
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
45
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: SignalReduxStore, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
46
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: SignalReduxStore, providedIn: 'root' }); }
|
|
46
47
|
}
|
|
47
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
48
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: SignalReduxStore, decorators: [{
|
|
48
49
|
type: Injectable,
|
|
49
50
|
args: [{
|
|
50
51
|
providedIn: 'root'
|
|
@@ -66,7 +67,7 @@ function mapAction(...args) {
|
|
|
66
67
|
return {
|
|
67
68
|
types,
|
|
68
69
|
storeMethod,
|
|
69
|
-
resultMethod
|
|
70
|
+
resultMethod,
|
|
70
71
|
};
|
|
71
72
|
}
|
|
72
73
|
function withActionMappers(...mappers) {
|
|
@@ -77,18 +78,17 @@ function createReduxState(storeName, signalStore, withActionMappers) {
|
|
|
77
78
|
return {
|
|
78
79
|
[`provide${capitalize(storeName)}Store`]: (connectReduxDevtools = false) => makeEnvironmentProviders([
|
|
79
80
|
isRootProvider ? [] : signalStore,
|
|
80
|
-
{
|
|
81
|
-
|
|
82
|
-
multi: true,
|
|
83
|
-
useFactory: (signalReduxStore = inject(SignalReduxStore), store = inject(signalStore)) => () => {
|
|
81
|
+
provideEnvironmentInitializer(() => {
|
|
82
|
+
const initializerFn = ((signalReduxStore = inject(SignalReduxStore), store = inject(signalStore)) => () => {
|
|
84
83
|
if (connectReduxDevtools) {
|
|
85
84
|
// addStoreToReduxDevtools(store, storeName, false);
|
|
86
85
|
}
|
|
87
86
|
signalReduxStore.connectFeatureStore(withActionMappers(store));
|
|
88
|
-
}
|
|
89
|
-
|
|
87
|
+
})();
|
|
88
|
+
return initializerFn();
|
|
89
|
+
}),
|
|
90
90
|
]),
|
|
91
|
-
[`inject${capitalize(storeName)}Store`]: () => Object.assign(inject(signalStore), { dispatch: injectReduxDispatch() })
|
|
91
|
+
[`inject${capitalize(storeName)}Store`]: () => Object.assign(inject(signalStore), { dispatch: injectReduxDispatch() }),
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
94
|
|
|
@@ -102,10 +102,10 @@ function reduxMethod(generator, resultMethodOrConfig, config) {
|
|
|
102
102
|
injector: config?.injector || injector
|
|
103
103
|
});
|
|
104
104
|
const rxWithInput = rxMethodWithResult(input);
|
|
105
|
-
unsubscribable = { unsubscribe: rxWithInput.
|
|
105
|
+
unsubscribable = { unsubscribe: rxWithInput.destroy.bind(rxWithInput) };
|
|
106
106
|
return rxWithInput;
|
|
107
107
|
});
|
|
108
|
-
inputResultFn.
|
|
108
|
+
inputResultFn.destroy = () => unsubscribable?.unsubscribe();
|
|
109
109
|
return inputResultFn;
|
|
110
110
|
}
|
|
111
111
|
return rxMethod(generator, resultMethodOrConfig);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"angular-architects-ngrx-toolkit-redux-connector.mjs","sources":["../../../../libs/ngrx-toolkit/redux-connector/src/lib/util.ts","../../../../libs/ngrx-toolkit/redux-connector/src/lib/signal-redux-store.ts","../../../../libs/ngrx-toolkit/redux-connector/src/lib/create-redux.ts","../../../../libs/ngrx-toolkit/redux-connector/src/lib/rxjs-interop/redux-method.ts","../../../../libs/ngrx-toolkit/redux-connector/angular-architects-ngrx-toolkit-redux-connector.ts"],"sourcesContent":["import { Action } from '@ngrx/store';\nimport { Unsubscribable } from 'rxjs';\n\n\nexport function isUnsubscribable<F extends (...args: unknown[]) => unknown>(\n fn: F | (F & Unsubscribable)\n): fn is F & Unsubscribable {\n return !!(fn as any as F & Unsubscribable)?.unsubscribe;\n}\n\nexport function capitalize(str: string): string {\n return str ? str[0].toUpperCase() + str.substring(1) : str;\n}\n\nexport function isActionCreator(action: any): action is Action {\n return (\n typeof action === 'function' &&\n action &&\n action.type &&\n typeof action.type === 'string'\n );\n}\n","import { Injectable, inject } from \"@angular/core\";\nimport { rxMethod } from \"@ngrx/signals/rxjs-interop\";\nimport { Action, ActionCreator } from \"@ngrx/store\";\nimport { pipe, tap } from \"rxjs\";\nimport { MapperTypes } from \"./model\";\nimport { isUnsubscribable } from \"./util\";\n\n\n@Injectable({\n providedIn: 'root'\n})\nexport class SignalReduxStore {\n private mapperDict: Record<string, {\n storeMethod: (...args: unknown[]) => unknown,\n resultMethod?: (...args: unknown[]) => unknown,\n }> = {};\n\n dispatch = rxMethod<Action>(pipe(\n tap((action: Action) => {\n const callbacks = this.mapperDict[action.type];\n if (callbacks?.storeMethod) {\n if (\n isUnsubscribable(callbacks.storeMethod) &&\n callbacks.resultMethod\n ) {\n return callbacks.storeMethod(action, (a: Action) => {\n const resultAction = callbacks.resultMethod?.(a) as Action;\n this.dispatch(resultAction);\n });\n }\n\n return callbacks?.storeMethod(action);\n }\n\n return;\n })\n ));\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n connectFeatureStore(mappers: MapperTypes<ActionCreator<any, any>[]>[]): void {\n mappers.forEach(\n mapper => mapper.types.forEach(\n action => this.mapperDict[action] = {\n storeMethod: mapper.storeMethod,\n resultMethod: mapper.resultMethod\n }\n )\n );\n }\n}\n\nexport function injectReduxDispatch() {\n return inject(SignalReduxStore).dispatch;\n}\n","import { ENVIRONMENT_INITIALIZER, inject, makeEnvironmentProviders } from \"@angular/core\";\nimport { ActionCreator, ActionType } from \"@ngrx/store/src/models\";\nimport { CreateReduxState, ExtractActionTypes, MapperTypes, Store } from \"./model\";\nimport { SignalReduxStore, injectReduxDispatch } from \"./signal-redux-store\";\nimport { capitalize, isActionCreator } from \"./util\";\n\n\nexport function mapAction<\n Creators extends readonly ActionCreator[]\n>(\n ...args: [\n ...creators: Creators,\n storeMethod: (action: ActionType<Creators[number]>) => unknown\n ]\n): MapperTypes<Creators>;\nexport function mapAction<\n Creators extends readonly ActionCreator[],\n T\n>(\n ...args: [\n ...creators: Creators,\n storeMethod: (action: ActionType<Creators[number]>, resultMethod: (input: T) => unknown) => unknown,\n resultMethod: (input: T) => unknown\n ]\n): MapperTypes<Creators>;\nexport function mapAction<\n Creators extends readonly ActionCreator[]\n>(\n ...args: [\n ...creators: Creators,\n storeMethod: (action: ActionType<Creators[number]>) => unknown,\n resultMethod?: (input: unknown) => unknown\n ]\n): MapperTypes<Creators> {\n let resultMethod = args.pop() as unknown as ((input: unknown) => unknown ) | undefined;\n let storeMethod = args.pop() as unknown as (action: ActionType<Creators[number]>) => unknown;\n\n if (isActionCreator(storeMethod)) {\n args.push(storeMethod);\n storeMethod = resultMethod || storeMethod;\n resultMethod = undefined;\n }\n\n const types = (args as unknown as Creators).map(\n (creator) => creator.type\n ) as unknown as ExtractActionTypes<Creators>;\n\n return {\n types,\n storeMethod,\n resultMethod\n };\n}\n\nexport function withActionMappers(\n ...mappers: MapperTypes<ActionCreator<any, any>[]>[]\n): MapperTypes<ActionCreator<any, any>[]>[] {\n return mappers;\n}\n\nexport function createReduxState<\n StoreName extends string,\n STORE extends Store\n>(\n storeName: StoreName,\n signalStore: STORE,\n withActionMappers: (store: InstanceType<STORE>) => MapperTypes<ActionCreator<any, any>[]>[],\n): CreateReduxState<StoreName, STORE> {\n const isRootProvider = (signalStore as any)?.ɵprov?.providedIn === 'root';\n return {\n [`provide${capitalize(storeName)}Store`]: (connectReduxDevtools = false) => makeEnvironmentProviders([\n isRootProvider? [] : signalStore,\n {\n provide: ENVIRONMENT_INITIALIZER,\n multi: true,\n useFactory: (\n signalReduxStore = inject(SignalReduxStore),\n store = inject(signalStore)\n ) => () => {\n if (connectReduxDevtools) {\n // addStoreToReduxDevtools(store, storeName, false);\n }\n signalReduxStore.connectFeatureStore(\n withActionMappers(store)\n );\n }\n }\n ]),\n [`inject${capitalize(storeName)}Store`]: () => Object.assign(\n inject(signalStore),\n { dispatch: injectReduxDispatch() }\n )\n } as CreateReduxState<StoreName, STORE>;\n}\n","import { Injector, Signal, inject } from \"@angular/core\";\nimport { rxMethod } from \"@ngrx/signals/rxjs-interop\";\nimport { Observable, Unsubscribable, map, pipe } from \"rxjs\";\n\n\ntype RxMethodInput<Input> = Input | Observable<Input> | Signal<Input>;\n\ntype RxMethod<Input, MethodInput = Input, MethodResult = unknown> = ((\n input: RxMethodInput<Input>,\n resultMethod: (input: MethodInput) => MethodResult\n) => Unsubscribable) & Unsubscribable;\n\nexport function reduxMethod<Input, MethodInput = Input>(\n generator: (source$: Observable<Input>) => Observable<MethodInput>,\n config?: { injector?: Injector }\n): RxMethod<Input, MethodInput>;\nexport function reduxMethod<Input, MethodInput = Input, MethodResult = unknown>(\n generator: (source$: Observable<Input>) => Observable<MethodInput>,\n resultMethod: (input: MethodInput) => MethodResult,\n config?: {\n injector?: Injector\n }\n): RxMethod<Input, MethodInput, MethodResult>;\nexport function reduxMethod<Input, MethodInput = Input, MethodResult = unknown>(\n generator: (source$: Observable<Input>) => Observable<MethodInput>,\n resultMethodOrConfig?: ((input: MethodInput) => MethodResult) | {\n injector?: Injector\n },\n config?: {\n injector?: Injector\n }\n): RxMethod<Input, MethodInput, MethodResult> {\n const injector = inject(Injector);\n\n if (typeof resultMethodOrConfig === 'function') {\n let unsubscribable: Unsubscribable;\n const inputResultFn = ((\n input: RxMethodInput<Input>,\n resultMethod = resultMethodOrConfig\n ) => {\n\n const rxMethodWithResult = rxMethod<Input>(pipe(\n generator,\n map(resultMethod)\n ), {\n ...(config || {}),\n injector: config?.injector || injector\n });\n const rxWithInput = rxMethodWithResult(input);\n unsubscribable = { unsubscribe: rxWithInput.unsubscribe.bind(rxWithInput) };\n\n return rxWithInput;\n }) as RxMethod<Input, MethodInput, MethodResult>;\n\n inputResultFn.unsubscribe = () => unsubscribable?.unsubscribe();\n\n return inputResultFn;\n }\n\n return rxMethod<Input>(generator, resultMethodOrConfig);\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;AAIM,SAAU,gBAAgB,CAC9B,EAA4B,EAAA;AAE5B,IAAA,OAAO,CAAC,CAAE,EAAgC,EAAE,WAAW,CAAC;AAC1D,CAAC;AAEK,SAAU,UAAU,CAAC,GAAW,EAAA;IACpC,OAAO,GAA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E;AACD,gBAAA,IAAI,MAAM,IAAI,EAAE,CAAC;AACjB,gBAAA,QAAQ,EAAE,MAAM,EAAE,QAAQ,IAAI,QAAQ;AACvC,aAAA,CAAC,CAAC;AACH,YAAA,MAAM,WAAW,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;AAC9C,YAAA,cAAc,GAAG,EAAE,WAAW,EAAE,WAAW,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;AAE5E,YAAA,OAAO,WAAW,CAAC;AACrB,SAAC,CAA+C,CAAC;QAEjD,aAAa,CAAC,WAAW,GAAG,MAAM,cAAc,EAAE,WAAW,EAAE,CAAC;AAEhE,QAAA,OAAO,aAAa,CAAC;KACtB;AAED,IAAA,OAAO,QAAQ,CAAQ,SAAS,EAAE,oBAAoB,CAAC,CAAC;AAC1D;;AC5DA;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"angular-architects-ngrx-toolkit-redux-connector.mjs","sources":["../../../../libs/ngrx-toolkit/redux-connector/src/lib/util.ts","../../../../libs/ngrx-toolkit/redux-connector/src/lib/signal-redux-store.ts","../../../../libs/ngrx-toolkit/redux-connector/src/lib/create-redux.ts","../../../../libs/ngrx-toolkit/redux-connector/src/lib/rxjs-interop/redux-method.ts","../../../../libs/ngrx-toolkit/redux-connector/angular-architects-ngrx-toolkit-redux-connector.ts"],"sourcesContent":["import { ActionCreator } from '@ngrx/store';\nimport { Unsubscribable } from 'rxjs';\n\nexport function isUnsubscribable<F extends (...args: unknown[]) => unknown>(\n fn: F | (F & Unsubscribable)\n): fn is F & Unsubscribable {\n return !!(fn as F & Unsubscribable)?.unsubscribe;\n}\n\nexport function capitalize(str: string): string {\n return str ? str[0].toUpperCase() + str.substring(1) : str;\n}\n\nexport function isActionCreator(action: unknown): action is ActionCreator {\n return Boolean(\n typeof action === 'function' &&\n action &&\n 'type' in action &&\n action.type &&\n typeof action.type === 'string'\n );\n}\n","import { Injectable, inject } from \"@angular/core\";\nimport { rxMethod } from \"@ngrx/signals/rxjs-interop\";\nimport { Action, ActionCreator } from \"@ngrx/store\";\nimport { pipe, tap } from \"rxjs\";\nimport { MapperTypes } from \"./model\";\nimport { isUnsubscribable } from \"./util\";\n\n\n@Injectable({\n providedIn: 'root'\n})\nexport class SignalReduxStore {\n private mapperDict: Record<string, {\n storeMethod: (...args: unknown[]) => unknown,\n resultMethod?: (...args: unknown[]) => unknown,\n }> = {};\n\n dispatch = rxMethod<Action>(pipe(\n tap((action: Action) => {\n const callbacks = this.mapperDict[action.type];\n if (callbacks?.storeMethod) {\n if (\n isUnsubscribable(callbacks.storeMethod) &&\n callbacks.resultMethod\n ) {\n return callbacks.storeMethod(action, (a: Action) => {\n const resultAction = callbacks.resultMethod?.(a) as Action;\n this.dispatch(resultAction);\n });\n }\n\n return callbacks?.storeMethod(action);\n }\n\n return;\n })\n ));\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n connectFeatureStore(mappers: MapperTypes<ActionCreator<any, any>[]>[]): void {\n mappers.forEach(\n mapper => mapper.types.forEach(\n action => this.mapperDict[action] = {\n storeMethod: mapper.storeMethod,\n resultMethod: mapper.resultMethod\n }\n )\n );\n }\n}\n\nexport function injectReduxDispatch() {\n return inject(SignalReduxStore).dispatch;\n}\n","import {\n inject,\n makeEnvironmentProviders,\n provideEnvironmentInitializer,\n} from '@angular/core';\nimport { ActionCreator, ActionType } from '@ngrx/store/src/models';\nimport {\n CreateReduxState,\n ExtractActionTypes,\n MapperTypes,\n ServiceWithDecorator,\n Store,\n} from './model';\nimport { SignalReduxStore, injectReduxDispatch } from './signal-redux-store';\nimport { capitalize, isActionCreator } from './util';\n\nexport function mapAction<Creators extends readonly ActionCreator[]>(\n ...args: [\n ...creators: Creators,\n storeMethod: (action: ActionType<Creators[number]>) => unknown\n ]\n): MapperTypes<Creators>;\nexport function mapAction<Creators extends readonly ActionCreator[], T>(\n ...args: [\n ...creators: Creators,\n storeMethod: (\n action: ActionType<Creators[number]>,\n resultMethod: (input: T) => unknown\n ) => unknown,\n resultMethod: (input: T) => unknown\n ]\n): MapperTypes<Creators>;\nexport function mapAction<Creators extends readonly ActionCreator[]>(\n ...args: [\n ...creators: Creators,\n storeMethod: (action: ActionType<Creators[number]>) => unknown,\n resultMethod?: (input: unknown) => unknown\n ]\n): MapperTypes<Creators> {\n let resultMethod = args.pop() as unknown as\n | ((input: unknown) => unknown)\n | undefined;\n let storeMethod = args.pop() as unknown as (\n action: ActionType<Creators[number]>\n ) => unknown;\n\n if (isActionCreator(storeMethod)) {\n args.push(storeMethod);\n storeMethod = resultMethod || storeMethod;\n resultMethod = undefined;\n }\n\n const types = (args as unknown as Creators).map(\n (creator) => creator.type\n ) as unknown as ExtractActionTypes<Creators>;\n\n return {\n types,\n storeMethod,\n resultMethod,\n };\n}\n\nexport function withActionMappers(\n ...mappers: MapperTypes<ActionCreator[]>[]\n): MapperTypes<ActionCreator[]>[] {\n return mappers;\n}\n\nexport function createReduxState<StoreName extends string, STORE extends Store>(\n storeName: StoreName,\n signalStore: STORE,\n withActionMappers: (\n store: InstanceType<STORE>\n ) => MapperTypes<ActionCreator[]>[]\n): CreateReduxState<StoreName, STORE> {\n const isRootProvider =\n (signalStore as ServiceWithDecorator)?.ɵprov?.providedIn === 'root';\n return {\n [`provide${capitalize(storeName)}Store`]: (connectReduxDevtools = false) =>\n makeEnvironmentProviders([\n isRootProvider ? [] : signalStore,\n provideEnvironmentInitializer(() => {\n const initializerFn = (\n (\n signalReduxStore = inject(SignalReduxStore),\n store = inject(signalStore)\n ) =>\n () => {\n if (connectReduxDevtools) {\n // addStoreToReduxDevtools(store, storeName, false);\n }\n signalReduxStore.connectFeatureStore(withActionMappers(store));\n }\n )();\n return initializerFn();\n }),\n ]),\n [`inject${capitalize(storeName)}Store`]: () =>\n Object.assign(inject(signalStore), { dispatch: injectReduxDispatch() }),\n } as CreateReduxState<StoreName, STORE>;\n}\n","import { Injector, Signal, inject } from \"@angular/core\";\nimport { rxMethod } from \"@ngrx/signals/rxjs-interop\";\nimport { Observable, Unsubscribable, map, pipe } from \"rxjs\";\n\n\ntype RxMethodInput<Input> = Input | Observable<Input> | Signal<Input>;\n\ntype RxMethodRef = {\n destroy: () => void;\n}\n\ntype RxMethod<Input, MethodInput = Input, MethodResult = unknown> = ((\n input: RxMethodInput<Input>,\n resultMethod: (input: MethodInput) => MethodResult\n) => RxMethodRef) & RxMethodRef;\n\nexport function reduxMethod<Input, MethodInput = Input>(\n generator: (source$: Observable<Input>) => Observable<MethodInput>,\n config?: { injector?: Injector }\n): RxMethod<Input, MethodInput>;\nexport function reduxMethod<Input, MethodInput = Input, MethodResult = unknown>(\n generator: (source$: Observable<Input>) => Observable<MethodInput>,\n resultMethod: (input: MethodInput) => MethodResult,\n config?: {\n injector?: Injector\n }\n): RxMethod<Input, MethodInput, MethodResult>;\nexport function reduxMethod<Input, MethodInput = Input, MethodResult = unknown>(\n generator: (source$: Observable<Input>) => Observable<MethodInput>,\n resultMethodOrConfig?: ((input: MethodInput) => MethodResult) | {\n injector?: Injector\n },\n config?: {\n injector?: Injector\n }\n): RxMethod<Input, MethodInput, MethodResult> {\n const injector = inject(Injector);\n\n if (typeof resultMethodOrConfig === 'function') {\n let unsubscribable: Unsubscribable;\n const inputResultFn = ((\n input: RxMethodInput<Input>,\n resultMethod = resultMethodOrConfig\n ) => {\n\n const rxMethodWithResult = rxMethod<Input>(pipe(\n generator,\n map(resultMethod)\n ), {\n ...(config || {}),\n injector: config?.injector || injector\n });\n const rxWithInput = rxMethodWithResult(input);\n unsubscribable = { unsubscribe: rxWithInput.destroy.bind(rxWithInput) };\n\n return rxWithInput;\n }) as RxMethod<Input, MethodInput, MethodResult>;\n\n inputResultFn.destroy = () => unsubscribable?.unsubscribe();\n\n return inputResultFn;\n }\n\n return rxMethod<Input>(generator, resultMethodOrConfig);\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;AAGM,SAAU,gBAAgB,CAC9B,EAA4B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