@angular-architects/ngrx-toolkit 18.0.2 → 18.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/README.md +1 -428
  2. package/esm2022/index.mjs +1 -3
  3. package/esm2022/lib/with-undo-redo.mjs +10 -4
  4. package/esm2022/redux-connector/angular-architects-ngrx-toolkit-redux-connector.mjs +5 -0
  5. package/esm2022/redux-connector/index.mjs +3 -0
  6. package/esm2022/redux-connector/src/lib/create-redux.mjs +41 -0
  7. package/esm2022/redux-connector/src/lib/model.mjs +2 -0
  8. package/esm2022/redux-connector/src/lib/rxjs-interop/redux-method.mjs +22 -0
  9. package/esm2022/redux-connector/src/lib/signal-redux-store.mjs +43 -0
  10. package/esm2022/redux-connector/src/lib/util.mjs +13 -0
  11. package/fesm2022/angular-architects-ngrx-toolkit-redux-connector.mjs +119 -0
  12. package/fesm2022/angular-architects-ngrx-toolkit-redux-connector.mjs.map +1 -0
  13. package/fesm2022/angular-architects-ngrx-toolkit.mjs +34 -138
  14. package/fesm2022/angular-architects-ngrx-toolkit.mjs.map +1 -1
  15. package/index.d.ts +0 -2
  16. package/lib/with-undo-redo.d.ts +14 -25
  17. package/package.json +14 -2
  18. package/redux-connector/index.d.ts +2 -0
  19. package/esm2022/lib/redux-connector/create-redux.mjs +0 -41
  20. package/esm2022/lib/redux-connector/index.mjs +0 -2
  21. package/esm2022/lib/redux-connector/model.mjs +0 -2
  22. package/esm2022/lib/redux-connector/rxjs-interop/index.mjs +0 -2
  23. package/esm2022/lib/redux-connector/rxjs-interop/redux-method.mjs +0 -22
  24. package/esm2022/lib/redux-connector/signal-redux-store.mjs +0 -43
  25. package/esm2022/lib/redux-connector/util.mjs +0 -13
  26. package/lib/redux-connector/index.d.ts +0 -1
  27. package/lib/redux-connector/rxjs-interop/index.d.ts +0 -1
  28. /package/{lib/redux-connector → redux-connector/src/lib}/create-redux.d.ts +0 -0
  29. /package/{lib/redux-connector → redux-connector/src/lib}/model.d.ts +0 -0
  30. /package/{lib/redux-connector → redux-connector/src/lib}/rxjs-interop/redux-method.d.ts +0 -0
  31. /package/{lib/redux-connector → redux-connector/src/lib}/signal-redux-store.d.ts +0 -0
  32. /package/{lib/redux-connector → redux-connector/src/lib}/util.d.ts +0 -0
@@ -0,0 +1,43 @@
1
+ import { Injectable, inject } from "@angular/core";
2
+ import { rxMethod } from "@ngrx/signals/rxjs-interop";
3
+ import { pipe, tap } from "rxjs";
4
+ import { isUnsubscribable } from "./util";
5
+ import * as i0 from "@angular/core";
6
+ export class SignalReduxStore {
7
+ constructor() {
8
+ this.mapperDict = {};
9
+ this.dispatch = rxMethod(pipe(tap((action) => {
10
+ const callbacks = this.mapperDict[action.type];
11
+ if (callbacks?.storeMethod) {
12
+ if (isUnsubscribable(callbacks.storeMethod) &&
13
+ callbacks.resultMethod) {
14
+ return callbacks.storeMethod(action, (a) => {
15
+ const resultAction = callbacks.resultMethod?.(a);
16
+ this.dispatch(resultAction);
17
+ });
18
+ }
19
+ return callbacks?.storeMethod(action);
20
+ }
21
+ return;
22
+ })));
23
+ }
24
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
25
+ connectFeatureStore(mappers) {
26
+ mappers.forEach(mapper => mapper.types.forEach(action => this.mapperDict[action] = {
27
+ storeMethod: mapper.storeMethod,
28
+ resultMethod: mapper.resultMethod
29
+ }));
30
+ }
31
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.1", ngImport: i0, type: SignalReduxStore, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
32
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.1.1", ngImport: i0, type: SignalReduxStore, providedIn: 'root' }); }
33
+ }
34
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.1", ngImport: i0, type: SignalReduxStore, decorators: [{
35
+ type: Injectable,
36
+ args: [{
37
+ providedIn: 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4ge1xuICAgICAgICAgICAgY29uc3QgcmVzdWx0QWN0aW9uID0gY2FsbGJhY2tzLnJlc3VsdE1ldGhvZD8uKGEpIGFzIEFjdGlvbjtcbiAgICAgICAgICAgIHRoaXMuZGlzcGF0Y2gocmVzdWx0QWN0aW9uKTtcbiAgICAgICAgICB9KTtcbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiBjYWxsYmFja3M/LnN0b3JlTWV0aG9kKGFjdGlvbik7XG4gICAgICB9XG5cbiAgICAgIHJldHVybjtcbiAgICB9KVxuICApKTtcblxuICAvLyBlc2xpbnQtZGlzYWJsZS1uZXh0LWxpbmUgQHR5cGVzY3JpcHQtZXNsaW50L25vLWV4cGxpY2l0LWFueVxuICBjb25uZWN0RmVhdHVyZVN0b3JlKG1hcHBlcnM6IE1hcHBlclR5cGVzPEFjdGlvbkNyZWF0b3I8YW55LCBhbnk+W10+W10pOiB2b2lkIHtcbiAgICBtYXBwZXJzLmZvckVhY2goXG4gICAgICBtYXBwZXIgPT4gbWFwcGVyLnR5cGVzLmZvckVhY2goXG4gICAgICAgIGFjdGlvbiA9PiB0aGlzLm1hcHBlckRpY3RbYWN0aW9uXSA9IHtcbiAgICAgICAgICBzdG9yZU1ldGhvZDogbWFwcGVyLnN0b3JlTWV0aG9kLFxuICAgICAgICAgIHJlc3VsdE1ldGhvZDogbWFwcGVyLnJlc3VsdE1ldGhvZFxuICAgICAgICB9XG4gICAgICApXG4gICAgKTtcbiAgfVxufVxuXG5leHBvcnQgZnVuY3Rpb24gaW5qZWN0UmVkdXhEaXNwYXRjaCgpIHtcbiAgcmV0dXJuIGluamVjdChTaWduYWxSZWR1eFN0b3JlKS5kaXNwYXRjaDtcbn1cbiJdfQ==
@@ -0,0 +1,13 @@
1
+ export function isUnsubscribable(fn) {
2
+ return !!fn?.unsubscribe;
3
+ }
4
+ export function capitalize(str) {
5
+ return str ? str[0].toUpperCase() + str.substring(1) : str;
6
+ }
7
+ export function isActionCreator(action) {
8
+ return (typeof action === 'function' &&
9
+ action &&
10
+ action.type &&
11
+ typeof action.type === 'string');
12
+ }
13
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uL2xpYnMvbmdyeC10b29sa2l0L3JlZHV4LWNvbm5lY3Rvci9zcmMvbGliL3V0aWwudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBSUEsTUFBTSxVQUFVLGdCQUFnQixDQUM5QixFQUE0QjtJQUU1QixPQUFPLENBQUMsQ0FBRSxFQUFnQyxFQUFFLFdBQVcsQ0FBQztBQUMxRCxDQUFDO0FBRUQsTUFBTSxVQUFVLFVBQVUsQ0FBQyxHQUFXO0lBQ3BDLE9BQU8sR0FBRyxDQUFDLENBQUMsQ0FBQyxHQUFHLENBQUMsQ0FBQyxDQUFDLENBQUMsV0FBVyxFQUFFLEdBQUcsR0FBRyxDQUFDLFNBQVMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxDQUFDO0FBQzdELENBQUM7QUFFRCxNQUFNLFVBQVUsZUFBZSxDQUFDLE1BQVc7SUFDekMsT0FBTyxDQUNMLE9BQU8sTUFBTSxLQUFLLFVBQVU7UUFDNUIsTUFBTTtRQUNOLE1BQU0sQ0FBQyxJQUFJO1FBQ1gsT0FBTyxNQUFNLENBQUMsSUFBSSxLQUFLLFFBQVEsQ0FDaEMsQ0FBQztBQUNKLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBBY3Rpb24gfSBmcm9tICdAbmdyeC9zdG9yZSc7XG5pbXBvcnQgeyBVbnN1YnNjcmliYWJsZSB9IGZyb20gJ3J4anMnO1xuXG5cbmV4cG9ydCBmdW5jdGlvbiBpc1Vuc3Vic2NyaWJhYmxlPEYgZXh0ZW5kcyAoLi4uYXJnczogdW5rbm93bltdKSA9PiB1bmtub3duPihcbiAgZm46IEYgfCAoRiAmIFVuc3Vic2NyaWJhYmxlKVxuKTogZm4gaXMgRiAmIFVuc3Vic2NyaWJhYmxlIHtcbiAgcmV0dXJuICEhKGZuIGFzIGFueSBhcyBGICYgVW5zdWJzY3JpYmFibGUpPy51bnN1YnNjcmliZTtcbn1cblxuZXhwb3J0IGZ1bmN0aW9uIGNhcGl0YWxpemUoc3RyOiBzdHJpbmcpOiBzdHJpbmcge1xuICByZXR1cm4gc3RyID8gc3RyWzBdLnRvVXBwZXJDYXNlKCkgKyBzdHIuc3Vic3RyaW5nKDEpIDogc3RyO1xufVxuXG5leHBvcnQgZnVuY3Rpb24gaXNBY3Rpb25DcmVhdG9yKGFjdGlvbjogYW55KTogYWN0aW9uIGlzIEFjdGlvbiB7XG4gIHJldHVybiAoXG4gICAgdHlwZW9mIGFjdGlvbiA9PT0gJ2Z1bmN0aW9uJyAmJlxuICAgIGFjdGlvbiAmJlxuICAgIGFjdGlvbi50eXBlICYmXG4gICAgdHlwZW9mIGFjdGlvbi50eXBlID09PSAnc3RyaW5nJ1xuICApO1xufVxuIl19
@@ -0,0 +1,119 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Injectable, inject, makeEnvironmentProviders, ENVIRONMENT_INITIALIZER, Injector } from '@angular/core';
3
+ import { rxMethod } from '@ngrx/signals/rxjs-interop';
4
+ import { pipe, tap, map } from 'rxjs';
5
+
6
+ function isUnsubscribable(fn) {
7
+ return !!fn?.unsubscribe;
8
+ }
9
+ function capitalize(str) {
10
+ return str ? str[0].toUpperCase() + str.substring(1) : str;
11
+ }
12
+ function isActionCreator(action) {
13
+ return (typeof action === 'function' &&
14
+ action &&
15
+ action.type &&
16
+ typeof action.type === 'string');
17
+ }
18
+
19
+ class SignalReduxStore {
20
+ constructor() {
21
+ this.mapperDict = {};
22
+ this.dispatch = rxMethod(pipe(tap((action) => {
23
+ const callbacks = this.mapperDict[action.type];
24
+ if (callbacks?.storeMethod) {
25
+ if (isUnsubscribable(callbacks.storeMethod) &&
26
+ callbacks.resultMethod) {
27
+ return callbacks.storeMethod(action, (a) => {
28
+ const resultAction = callbacks.resultMethod?.(a);
29
+ this.dispatch(resultAction);
30
+ });
31
+ }
32
+ return callbacks?.storeMethod(action);
33
+ }
34
+ return;
35
+ })));
36
+ }
37
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
38
+ connectFeatureStore(mappers) {
39
+ mappers.forEach(mapper => mapper.types.forEach(action => this.mapperDict[action] = {
40
+ storeMethod: mapper.storeMethod,
41
+ resultMethod: mapper.resultMethod
42
+ }));
43
+ }
44
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.1", ngImport: i0, type: SignalReduxStore, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
45
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.1.1", ngImport: i0, type: SignalReduxStore, providedIn: 'root' }); }
46
+ }
47
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.1", ngImport: i0, type: SignalReduxStore, decorators: [{
48
+ type: Injectable,
49
+ args: [{
50
+ providedIn: 'root'
51
+ }]
52
+ }] });
53
+ function injectReduxDispatch() {
54
+ return inject(SignalReduxStore).dispatch;
55
+ }
56
+
57
+ function mapAction(...args) {
58
+ let resultMethod = args.pop();
59
+ let storeMethod = args.pop();
60
+ if (isActionCreator(storeMethod)) {
61
+ args.push(storeMethod);
62
+ storeMethod = resultMethod || storeMethod;
63
+ resultMethod = undefined;
64
+ }
65
+ const types = args.map((creator) => creator.type);
66
+ return {
67
+ types,
68
+ storeMethod,
69
+ resultMethod
70
+ };
71
+ }
72
+ function withActionMappers(...mappers) {
73
+ return mappers;
74
+ }
75
+ function createReduxState(storeName, signalStore, withActionMappers) {
76
+ const isRootProvider = signalStore?.ɵprov?.providedIn === 'root';
77
+ return {
78
+ [`provide${capitalize(storeName)}Store`]: (connectReduxDevtools = false) => makeEnvironmentProviders([
79
+ isRootProvider ? [] : signalStore,
80
+ {
81
+ provide: ENVIRONMENT_INITIALIZER,
82
+ multi: true,
83
+ useFactory: (signalReduxStore = inject(SignalReduxStore), store = inject(signalStore)) => () => {
84
+ if (connectReduxDevtools) {
85
+ // addStoreToReduxDevtools(store, storeName, false);
86
+ }
87
+ signalReduxStore.connectFeatureStore(withActionMappers(store));
88
+ }
89
+ }
90
+ ]),
91
+ [`inject${capitalize(storeName)}Store`]: () => Object.assign(inject(signalStore), { dispatch: injectReduxDispatch() })
92
+ };
93
+ }
94
+
95
+ function reduxMethod(generator, resultMethodOrConfig, config) {
96
+ const injector = inject(Injector);
97
+ if (typeof resultMethodOrConfig === 'function') {
98
+ let unsubscribable;
99
+ const inputResultFn = ((input, resultMethod = resultMethodOrConfig) => {
100
+ const rxMethodWithResult = rxMethod(pipe(generator, map(resultMethod)), {
101
+ ...(config || {}),
102
+ injector: config?.injector || injector
103
+ });
104
+ const rxWithInput = rxMethodWithResult(input);
105
+ unsubscribable = { unsubscribe: rxWithInput.unsubscribe.bind(rxWithInput) };
106
+ return rxWithInput;
107
+ });
108
+ inputResultFn.unsubscribe = () => unsubscribable?.unsubscribe();
109
+ return inputResultFn;
110
+ }
111
+ return rxMethod(generator, resultMethodOrConfig);
112
+ }
113
+
114
+ /**
115
+ * Generated bundle index. Do not edit.
116
+ */
117
+
118
+ export { createReduxState, mapAction, reduxMethod, withActionMappers };
119
+ //# sourceMappingURL=angular-architects-ngrx-toolkit-redux-connector.mjs.map
@@ -0,0 +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,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;AAC7D,CAAC;AAEK,SAAU,eAAe,CAAC,MAAW,EAAA;AACzC,IAAA,QACE,OAAO,MAAM,KAAK,UAAU;QAC5B,MAAM;AACN,QAAA,MAAM,CAAC,IAAI;AACX,QAAA,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,EAC/B;AACJ;;MCVa,gBAAgB,CAAA;AAH7B,IAAA,WAAA,GAAA;QAIU,IAAU,CAAA,UAAA,GAGb,EAAE,CAAC;QAER,IAAQ,CAAA,QAAA,GAAG,QAAQ,CAAS,IAAI,CAC9B,GAAG,CAAC,CAAC,MAAc,KAAI;YACrB,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AAC/C,YAAA,IAAI,SAAS,EAAE,WAAW,EAAE;AAC1B,gBAAA,IACE,gBAAgB,CAAC,SAAS,CAAC,WAAW,CAAC;oBACvC,SAAS,CAAC,YAAY,EACtB;oBACA,OAAO,SAAS,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC,CAAS,KAAI;wBACjD,MAA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C,WAAW,CAAC,EACnB,EAAE,QAAQ,EAAE,mBAAmB,EAAE,EAAE,CACpC;KACoC,CAAC;AAC1C;;SCtEgB,WAAW,CACzB,SAAkE,EAClE,oBAEC,EACD,MAEC,EAAA;AAED,IAAA,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;AAElC,IAAA,IAAI,OAAO,oBAAoB,KAAK,UAAU,EAAE;AAC9C,QAAA,IAAI,cAA8B,CAAC;QACnC,MAAM,aAAa,IAAI,CACrB,KAA2B,EAC3B,YAAY,GAAG,oBAAoB,KACjC;AAEF,YAAA,MAAM,kBAAkB,GAAG,QAAQ,CAAQ,IAAI,CAC7C,SAAS,EACT,GAAG,CAAC,YAAY,CAAC,CAClB,EAAE;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,10 +1,8 @@
1
1
  import { patchState as patchState$1, signalStoreFeature, withState, withComputed, withMethods, withHooks, getState } from '@ngrx/signals';
2
- import * as i0 from '@angular/core';
3
- import { signal, effect, inject, PLATFORM_ID, computed, isSignal, untracked, Injectable, makeEnvironmentProviders, ENVIRONMENT_INITIALIZER, Injector } from '@angular/core';
2
+ import { signal, effect, inject, PLATFORM_ID, computed, isSignal, untracked } from '@angular/core';
4
3
  import { isPlatformServer } from '@angular/common';
5
- import { Subject, pipe, tap, map } from 'rxjs';
4
+ import { Subject } from 'rxjs';
6
5
  import { setAllEntities, addEntity, updateEntity, removeEntity } from '@ngrx/signals/entities';
7
- import { rxMethod } from '@ngrx/signals/rxjs-interop';
8
6
 
9
7
  const storeRegistry = signal({});
10
8
  let currentActionNames = new Set();
@@ -257,7 +255,7 @@ function setError(error, prop) {
257
255
  }
258
256
  }
259
257
 
260
- function capitalize$1(str) {
258
+ function capitalize(str) {
261
259
  return str ? str[0].toUpperCase() + str.substring(1) : str;
262
260
  }
263
261
  function getDataServiceKeys(options) {
@@ -265,40 +263,40 @@ function getDataServiceKeys(options) {
265
263
  ? `${options.collection}Filter`
266
264
  : 'filter';
267
265
  const selectedIdsKey = options.collection
268
- ? `selected${capitalize$1(options.collection)}Ids`
266
+ ? `selected${capitalize(options.collection)}Ids`
269
267
  : 'selectedIds';
270
268
  const selectedEntitiesKey = options.collection
271
- ? `selected${capitalize$1(options.collection)}Entities`
269
+ ? `selected${capitalize(options.collection)}Entities`
272
270
  : 'selectedEntities';
273
271
  const updateFilterKey = options.collection
274
- ? `update${capitalize$1(options.collection)}Filter`
272
+ ? `update${capitalize(options.collection)}Filter`
275
273
  : 'updateFilter';
276
274
  const updateSelectedKey = options.collection
277
- ? `updateSelected${capitalize$1(options.collection)}Entities`
275
+ ? `updateSelected${capitalize(options.collection)}Entities`
278
276
  : 'updateSelected';
279
277
  const loadKey = options.collection
280
- ? `load${capitalize$1(options.collection)}Entities`
278
+ ? `load${capitalize(options.collection)}Entities`
281
279
  : 'load';
282
280
  const currentKey = options.collection
283
- ? `current${capitalize$1(options.collection)}`
281
+ ? `current${capitalize(options.collection)}`
284
282
  : 'current';
285
283
  const loadByIdKey = options.collection
286
- ? `load${capitalize$1(options.collection)}ById`
284
+ ? `load${capitalize(options.collection)}ById`
287
285
  : 'loadById';
288
286
  const setCurrentKey = options.collection
289
- ? `setCurrent${capitalize$1(options.collection)}`
287
+ ? `setCurrent${capitalize(options.collection)}`
290
288
  : 'setCurrent';
291
289
  const createKey = options.collection
292
- ? `create${capitalize$1(options.collection)}`
290
+ ? `create${capitalize(options.collection)}`
293
291
  : 'create';
294
292
  const updateKey = options.collection
295
- ? `update${capitalize$1(options.collection)}`
293
+ ? `update${capitalize(options.collection)}`
296
294
  : 'update';
297
295
  const updateAllKey = options.collection
298
- ? `updateAll${capitalize$1(options.collection)}`
296
+ ? `updateAll${capitalize(options.collection)}`
299
297
  : 'updateAll';
300
298
  const deleteKey = options.collection
301
- ? `delete${capitalize$1(options.collection)}`
299
+ ? `delete${capitalize(options.collection)}`
302
300
  : 'delete';
303
301
  // TODO: Take these from @ngrx/signals/entities, when they are exported
304
302
  const entitiesKey = options.collection
@@ -457,19 +455,21 @@ function withDataService(options) {
457
455
 
458
456
  const defaultOptions = {
459
457
  maxStackSize: 100,
458
+ keys: [],
459
+ skip: 0,
460
460
  };
461
461
  function getUndoRedoKeys(collections) {
462
462
  if (collections) {
463
463
  return collections.flatMap((c) => [
464
464
  `${c}EntityMap`,
465
465
  `${c}Ids`,
466
- `selected${capitalize$1(c)}Ids`,
466
+ `selected${capitalize(c)}Ids`,
467
467
  `${c}Filter`,
468
468
  ]);
469
469
  }
470
470
  return ['entityMap', 'ids', 'selectedIds', 'filter'];
471
471
  }
472
- function withUndoRedo(options = {}) {
472
+ function withUndoRedo(options) {
473
473
  let previous = null;
474
474
  let skipOnce = false;
475
475
  const normalized = {
@@ -488,7 +488,7 @@ function withUndoRedo(options = {}) {
488
488
  canUndo.set(undoStack.length !== 0);
489
489
  canRedo.set(redoStack.length !== 0);
490
490
  };
491
- const keys = getUndoRedoKeys(normalized?.collections);
491
+ const keys = [...getUndoRedoKeys(normalized.collections), ...normalized.keys];
492
492
  return signalStoreFeature(withComputed(() => ({
493
493
  canUndo: canUndo.asReadonly(),
494
494
  canRedo: canRedo.asReadonly(),
@@ -530,6 +530,10 @@ function withUndoRedo(options = {}) {
530
530
  }
531
531
  return acc;
532
532
  }, {});
533
+ if (normalized.skip > 0) {
534
+ normalized.skip--;
535
+ return;
536
+ }
533
537
  if (skipOnce) {
534
538
  skipOnce = false;
535
539
  return;
@@ -721,7 +725,7 @@ function createPaginationKeys(options) {
721
725
  ? `${options.collection}Entities`
722
726
  : 'entities';
723
727
  const selectedPageEntitiesKey = options?.collection
724
- ? `selectedPage${capitalize$1(options?.collection)}Entities`
728
+ ? `selectedPage${capitalize(options?.collection)}Entities`
725
729
  : 'selectedPageEntities';
726
730
  const pageKey = options?.collection
727
731
  ? `${options.collection}CurrentPage`
@@ -742,28 +746,28 @@ function createPaginationKeys(options) {
742
746
  ? `${options.collection}PageNavigationArray`
743
747
  : 'pageNavigationArray';
744
748
  const setPageSizeKey = options?.collection
745
- ? `set${capitalize$1(options.collection)}PageSize`
749
+ ? `set${capitalize(options.collection)}PageSize`
746
750
  : 'setPageSize';
747
751
  const nextPageKey = options?.collection
748
- ? `next${capitalize$1(options.collection)}Page`
752
+ ? `next${capitalize(options.collection)}Page`
749
753
  : 'nextPage';
750
754
  const previousPageKey = options?.collection
751
- ? `previous${capitalize$1(options.collection)}Page`
755
+ ? `previous${capitalize(options.collection)}Page`
752
756
  : 'previousPage';
753
757
  const lastPageKey = options?.collection
754
- ? `last${capitalize$1(options.collection)}Page`
758
+ ? `last${capitalize(options.collection)}Page`
755
759
  : 'lastPage';
756
760
  const firstPageKey = options?.collection
757
- ? `first${capitalize$1(options.collection)}Page`
761
+ ? `first${capitalize(options.collection)}Page`
758
762
  : 'firstPage';
759
763
  const gotoPageKey = options?.collection
760
- ? `goto${capitalize$1(options.collection)}Page`
764
+ ? `goto${capitalize(options.collection)}Page`
761
765
  : 'gotoPage';
762
766
  const hasNextPageKey = options?.collection
763
- ? `hasNext${capitalize$1(options.collection)}Page`
767
+ ? `hasNext${capitalize(options.collection)}Page`
764
768
  : 'hasNextPage';
765
769
  const hasPreviousPageKey = options?.collection
766
- ? `hasPrevious${capitalize$1(options.collection)}Page`
770
+ ? `hasPrevious${capitalize(options.collection)}Page`
767
771
  : 'hasPreviousPage';
768
772
  return {
769
773
  pageKey,
@@ -818,117 +822,9 @@ function createPageArray(currentPage, itemsPerPage, totalItems, paginationRange)
818
822
  return pages;
819
823
  }
820
824
 
821
- function isUnsubscribable(fn) {
822
- return !!fn?.unsubscribe;
823
- }
824
- function capitalize(str) {
825
- return str ? str[0].toUpperCase() + str.substring(1) : str;
826
- }
827
- function isActionCreator(action) {
828
- return (typeof action === 'function' &&
829
- action &&
830
- action.type &&
831
- typeof action.type === 'string');
832
- }
833
-
834
- class SignalReduxStore {
835
- constructor() {
836
- this.mapperDict = {};
837
- this.dispatch = rxMethod(pipe(tap((action) => {
838
- const callbacks = this.mapperDict[action.type];
839
- if (callbacks?.storeMethod) {
840
- if (isUnsubscribable(callbacks.storeMethod) &&
841
- callbacks.resultMethod) {
842
- return callbacks.storeMethod(action, (a) => {
843
- const resultAction = callbacks.resultMethod?.(a);
844
- this.dispatch(resultAction);
845
- });
846
- }
847
- return callbacks?.storeMethod(action);
848
- }
849
- return;
850
- })));
851
- }
852
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
853
- connectFeatureStore(mappers) {
854
- mappers.forEach(mapper => mapper.types.forEach(action => this.mapperDict[action] = {
855
- storeMethod: mapper.storeMethod,
856
- resultMethod: mapper.resultMethod
857
- }));
858
- }
859
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.1", ngImport: i0, type: SignalReduxStore, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
860
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.1.1", ngImport: i0, type: SignalReduxStore, providedIn: 'root' }); }
861
- }
862
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.1", ngImport: i0, type: SignalReduxStore, decorators: [{
863
- type: Injectable,
864
- args: [{
865
- providedIn: 'root'
866
- }]
867
- }] });
868
- function injectReduxDispatch() {
869
- return inject(SignalReduxStore).dispatch;
870
- }
871
-
872
- function mapAction(...args) {
873
- let resultMethod = args.pop();
874
- let storeMethod = args.pop();
875
- if (isActionCreator(storeMethod)) {
876
- args.push(storeMethod);
877
- storeMethod = resultMethod || storeMethod;
878
- resultMethod = undefined;
879
- }
880
- const types = args.map((creator) => creator.type);
881
- return {
882
- types,
883
- storeMethod,
884
- resultMethod
885
- };
886
- }
887
- function withActionMappers(...mappers) {
888
- return mappers;
889
- }
890
- function createReduxState(storeName, signalStore, withActionMappers) {
891
- const isRootProvider = signalStore?.ɵprov?.providedIn === 'root';
892
- return {
893
- [`provide${capitalize(storeName)}Store`]: (connectReduxDevtools = false) => makeEnvironmentProviders([
894
- isRootProvider ? [] : signalStore,
895
- {
896
- provide: ENVIRONMENT_INITIALIZER,
897
- multi: true,
898
- useFactory: (signalReduxStore = inject(SignalReduxStore), store = inject(signalStore)) => () => {
899
- if (connectReduxDevtools) {
900
- // addStoreToReduxDevtools(store, storeName, false);
901
- }
902
- signalReduxStore.connectFeatureStore(withActionMappers(store));
903
- }
904
- }
905
- ]),
906
- [`inject${capitalize(storeName)}Store`]: () => Object.assign(inject(signalStore), { dispatch: injectReduxDispatch() })
907
- };
908
- }
909
-
910
- function reduxMethod(generator, resultMethodOrConfig, config) {
911
- const injector = inject(Injector);
912
- if (typeof resultMethodOrConfig === 'function') {
913
- let unsubscribable;
914
- const inputResultFn = ((input, resultMethod = resultMethodOrConfig) => {
915
- const rxMethodWithResult = rxMethod(pipe(generator, map(resultMethod)), {
916
- ...(config || {}),
917
- injector: config?.injector || injector
918
- });
919
- const rxWithInput = rxMethodWithResult(input);
920
- unsubscribable = { unsubscribe: rxWithInput.unsubscribe.bind(rxWithInput) };
921
- return rxWithInput;
922
- });
923
- inputResultFn.unsubscribe = () => unsubscribable?.unsubscribe();
924
- return inputResultFn;
925
- }
926
- return rxMethod(generator, resultMethodOrConfig);
927
- }
928
-
929
825
  /**
930
826
  * Generated bundle index. Do not edit.
931
827
  */
932
828
 
933
- export { capitalize$1 as capitalize, createPageArray, createReduxState, firstPage, getCallStateKeys, getDataServiceKeys, getUndoRedoKeys, gotoPage, mapAction, nextPage, noPayload, patchState, payload, previousPage, reduxMethod, setError, setLoaded, setLoading, setMaxPageNavigationArrayItems, setPageSize, updateState, withActionMappers, withCallState, withDataService, withDevtools, withPagination, withRedux, withStorageSync, withUndoRedo };
829
+ export { capitalize, createPageArray, firstPage, getCallStateKeys, getDataServiceKeys, getUndoRedoKeys, gotoPage, nextPage, noPayload, patchState, payload, previousPage, setError, setLoaded, setLoading, setMaxPageNavigationArrayItems, setPageSize, updateState, withCallState, withDataService, withDevtools, withPagination, withRedux, withStorageSync, withUndoRedo };
934
830
  //# sourceMappingURL=angular-architects-ngrx-toolkit.mjs.map