@ngxs/store 18.1.2-dev.master-cbc269d → 18.1.2-dev.master-eaf3f9d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/experimental/index.d.ts +12 -1
- package/index.d.ts +745 -6
- package/internals/index.d.ts +206 -10
- package/internals/testing/index.d.ts +31 -4
- package/operators/index.d.ts +101 -13
- package/package.json +1 -1
- package/plugins/index.d.ts +62 -3
- package/experimental/pending-tasks.d.ts +0 -8
- package/internals/custom-rxjs-operators.d.ts +0 -2
- package/internals/custom-rxjs-subjects.d.ts +0 -42
- package/internals/initial-state.d.ts +0 -8
- package/internals/internal-tokens.d.ts +0 -3
- package/internals/memoize.d.ts +0 -9
- package/internals/metadata.d.ts +0 -25
- package/internals/ngxs-app-bootstrapped-state.d.ts +0 -8
- package/internals/state-stream.d.ts +0 -15
- package/internals/state-token.d.ts +0 -7
- package/internals/symbols.d.ts +0 -88
- package/internals/testing/fresh-platform.d.ts +0 -1
- package/internals/testing/helpers/ngxs-test.component.d.ts +0 -8
- package/internals/testing/helpers/ngxs-test.module.d.ts +0 -10
- package/internals/testing/ngxs.setup.d.ts +0 -7
- package/internals/testing/skip-console-logging.d.ts +0 -4
- package/internals/testing/symbol.d.ts +0 -14
- package/operators/append.d.ts +0 -5
- package/operators/compose.d.ts +0 -2
- package/operators/iif.d.ts +0 -10
- package/operators/insert-item.d.ts +0 -6
- package/operators/patch.d.ts +0 -7
- package/operators/remove-item.d.ts +0 -6
- package/operators/types.d.ts +0 -56
- package/operators/update-item.d.ts +0 -9
- package/operators/utils.d.ts +0 -8
- package/plugins/actions.d.ts +0 -15
- package/plugins/symbols.d.ts +0 -13
- package/plugins/utils.d.ts +0 -29
- package/schematics/src/actions/actions.factory.d.ts +0 -3
- package/schematics/src/ng-add/add-declaration.d.ts +0 -4
- package/schematics/src/ng-add/ng-add.factory.d.ts +0 -9
- package/schematics/src/starter-kit/starter-kit.factory.d.ts +0 -3
- package/schematics/src/state/state.factory.d.ts +0 -3
- package/schematics/src/store/store.factory.d.ts +0 -3
- package/schematics/src/utils/common/lib.config.d.ts +0 -10
- package/schematics/src/utils/common/project-files.config.d.ts +0 -3
- package/schematics/src/utils/common/properties.d.ts +0 -1
- package/schematics/src/utils/config.d.ts +0 -119
- package/schematics/src/utils/generate-utils.d.ts +0 -4
- package/schematics/src/utils/interfaces/package.interface.d.ts +0 -7
- package/schematics/src/utils/normalize-options.d.ts +0 -11
- package/schematics/src/utils/project.d.ts +0 -20
- package/src/actions/action-registry.d.ts +0 -12
- package/src/actions/symbols.d.ts +0 -7
- package/src/actions-stream.d.ts +0 -39
- package/src/configs/messages.config.d.ts +0 -13
- package/src/decorators/action.d.ts +0 -30
- package/src/decorators/select/select-factory.d.ts +0 -16
- package/src/decorators/select/select.d.ts +0 -7
- package/src/decorators/select/symbols.d.ts +0 -9
- package/src/decorators/selector/selector.d.ts +0 -9
- package/src/decorators/selector/symbols.d.ts +0 -73
- package/src/decorators/selector-options.d.ts +0 -5
- package/src/decorators/state.d.ts +0 -5
- package/src/dev-features/ngxs-development.module.d.ts +0 -10
- package/src/dev-features/ngxs-unhandled-actions-logger.d.ts +0 -17
- package/src/dev-features/symbols.d.ts +0 -8
- package/src/execution/dispatch-outside-zone-ngxs-execution-strategy.d.ts +0 -14
- package/src/execution/internal-ngxs-execution-strategy.d.ts +0 -10
- package/src/execution/noop-ngxs-execution-strategy.d.ts +0 -8
- package/src/execution/symbols.d.ts +0 -16
- package/src/internal/dispatcher.d.ts +0 -36
- package/src/internal/fallback-subscriber.d.ts +0 -3
- package/src/internal/internals.d.ts +0 -105
- package/src/internal/lifecycle-state-manager.d.ts +0 -24
- package/src/internal/state-context-factory.d.ts +0 -17
- package/src/internal/state-factory.d.ts +0 -57
- package/src/internal/state-operations.d.ts +0 -21
- package/src/internal/state-operators.d.ts +0 -2
- package/src/internal/unhandled-rxjs-error-callback.d.ts +0 -2
- package/src/ivy/ivy-enabled-in-dev-mode.d.ts +0 -6
- package/src/module.d.ts +0 -13
- package/src/modules/ngxs-feature.module.d.ts +0 -10
- package/src/modules/ngxs-root.module.d.ts +0 -10
- package/src/ngxs-unhandled-error-handler.d.ts +0 -16
- package/src/operators/leave-ngxs.d.ts +0 -6
- package/src/operators/of-action.d.ts +0 -56
- package/src/plugin-manager.d.ts +0 -13
- package/src/plugin_api.d.ts +0 -1
- package/src/private_api.d.ts +0 -3
- package/src/public_api.d.ts +0 -23
- package/src/selectors/create-model-selector.d.ts +0 -10
- package/src/selectors/create-pick-selector.d.ts +0 -6
- package/src/selectors/create-property-selectors.d.ts +0 -5
- package/src/selectors/create-selector.d.ts +0 -19
- package/src/selectors/index.d.ts +0 -5
- package/src/selectors/private_api.d.ts +0 -7
- package/src/selectors/selector-checks.util.d.ts +0 -9
- package/src/selectors/selector-metadata.d.ts +0 -7
- package/src/selectors/selector-models.d.ts +0 -10
- package/src/selectors/selector-types.util.d.ts +0 -6
- package/src/selectors/selector-utils.d.ts +0 -9
- package/src/standalone-features/feature-providers.d.ts +0 -7
- package/src/standalone-features/index.d.ts +0 -4
- package/src/standalone-features/initializers.d.ts +0 -29
- package/src/standalone-features/plugin.d.ts +0 -17
- package/src/standalone-features/preboot.d.ts +0 -26
- package/src/standalone-features/provide-states.d.ts +0 -18
- package/src/standalone-features/provide-store.d.ts +0 -22
- package/src/standalone-features/root-providers.d.ts +0 -8
- package/src/store.d.ts +0 -60
- package/src/symbols.d.ts +0 -102
- package/src/utils/compose.d.ts +0 -23
- package/src/utils/create-dispatch-map.d.ts +0 -4
- package/src/utils/create-select-map.d.ts +0 -4
- package/src/utils/dispatch.d.ts +0 -2
- package/src/utils/freeze.d.ts +0 -5
- package/src/utils/public_api.d.ts +0 -4
- package/src/utils/select.d.ts +0 -16
- package/src/utils/store-validators.d.ts +0 -5
package/internals/index.d.ts
CHANGED
|
@@ -1,10 +1,206 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { InjectionToken, OnDestroy, Signal } from '@angular/core';
|
|
3
|
+
import { ReplaySubject, Subject, BehaviorSubject, MonoTypeOperatorFunction } from 'rxjs';
|
|
4
|
+
|
|
5
|
+
declare class StateToken<T = void> {
|
|
6
|
+
private readonly _name;
|
|
7
|
+
constructor(_name: ɵTokenName<T>);
|
|
8
|
+
getName(): string;
|
|
9
|
+
toString(): string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface ɵPlainObject {
|
|
13
|
+
[key: string]: any;
|
|
14
|
+
}
|
|
15
|
+
interface ɵPlainObjectOf<T> {
|
|
16
|
+
[key: string]: T;
|
|
17
|
+
}
|
|
18
|
+
type ɵStateClass<T = any> = new (...args: any[]) => T;
|
|
19
|
+
declare const ɵMETA_KEY = "NGXS_META";
|
|
20
|
+
declare const ɵMETA_OPTIONS_KEY = "NGXS_OPTIONS_META";
|
|
21
|
+
declare const ɵSELECTOR_META_KEY = "NGXS_SELECTOR_META";
|
|
22
|
+
interface ɵStateToken<T, U> {
|
|
23
|
+
new (name: ɵTokenName<T>): U;
|
|
24
|
+
getName(): string;
|
|
25
|
+
toString(): string;
|
|
26
|
+
}
|
|
27
|
+
type RequireGeneric<T, U> = T extends void ? 'You must provide a type parameter' : U;
|
|
28
|
+
type ɵTokenName<T> = string & RequireGeneric<T, string>;
|
|
29
|
+
type ɵExtractTokenType<P> = P extends StateToken<infer T> ? T : never;
|
|
30
|
+
/**
|
|
31
|
+
* Options that can be provided to the store.
|
|
32
|
+
*/
|
|
33
|
+
interface ɵStoreOptions<T> {
|
|
34
|
+
/**
|
|
35
|
+
* Name of the state. Required.
|
|
36
|
+
*/
|
|
37
|
+
name: string | StateToken<T>;
|
|
38
|
+
/**
|
|
39
|
+
* Default values for the state. If not provided, uses empty object.
|
|
40
|
+
*/
|
|
41
|
+
defaults?: T;
|
|
42
|
+
/**
|
|
43
|
+
* Sub states for the given state.
|
|
44
|
+
*
|
|
45
|
+
* @deprecated
|
|
46
|
+
* Read the deprecation notice at this link: https://ngxs.io/deprecations/sub-states-deprecation.
|
|
47
|
+
*/
|
|
48
|
+
children?: ɵStateClass[];
|
|
49
|
+
}
|
|
50
|
+
interface ɵStateClassInternal<T = any, U = any> extends ɵStateClass<T> {
|
|
51
|
+
[ɵMETA_KEY]?: ɵMetaDataModel;
|
|
52
|
+
[ɵMETA_OPTIONS_KEY]?: ɵStoreOptions<U>;
|
|
53
|
+
}
|
|
54
|
+
interface ɵMetaDataModel {
|
|
55
|
+
name: string | null;
|
|
56
|
+
actions: ɵPlainObjectOf<ɵActionHandlerMetaData[]>;
|
|
57
|
+
defaults: any;
|
|
58
|
+
path: string | null;
|
|
59
|
+
makeRootSelector: ɵSelectorFactory | null;
|
|
60
|
+
/** @deprecated */
|
|
61
|
+
children?: ɵStateClassInternal[];
|
|
62
|
+
}
|
|
63
|
+
interface ɵSelectorMetaDataModel {
|
|
64
|
+
makeRootSelector: ɵSelectorFactory | null;
|
|
65
|
+
originalFn: Function | null;
|
|
66
|
+
containerClass: any;
|
|
67
|
+
selectorName: string | null;
|
|
68
|
+
getSelectorOptions: () => ɵSharedSelectorOptions;
|
|
69
|
+
}
|
|
70
|
+
interface ɵSharedSelectorOptions {
|
|
71
|
+
/**
|
|
72
|
+
* @deprecated
|
|
73
|
+
* Read the deprecation notice at this link: https://ngxs.io/deprecations/inject-container-state-deprecation.md.
|
|
74
|
+
*/
|
|
75
|
+
injectContainerState?: boolean;
|
|
76
|
+
suppressErrors?: boolean;
|
|
77
|
+
}
|
|
78
|
+
interface ɵRuntimeSelectorContext {
|
|
79
|
+
getStateGetter(key: any): (state: any) => any;
|
|
80
|
+
getSelectorOptions(localOptions?: ɵSharedSelectorOptions): ɵSharedSelectorOptions;
|
|
81
|
+
}
|
|
82
|
+
type ɵSelectFromRootState = (rootState: any) => any;
|
|
83
|
+
type ɵSelectorFactory = (runtimeContext: ɵRuntimeSelectorContext) => ɵSelectFromRootState;
|
|
84
|
+
/**
|
|
85
|
+
* Actions that can be provided in a action decorator.
|
|
86
|
+
*/
|
|
87
|
+
interface ɵActionOptions {
|
|
88
|
+
/**
|
|
89
|
+
* Cancel the previous uncompleted observable(s).
|
|
90
|
+
*/
|
|
91
|
+
cancelUncompleted?: boolean;
|
|
92
|
+
}
|
|
93
|
+
interface ɵActionHandlerMetaData {
|
|
94
|
+
fn: string | symbol;
|
|
95
|
+
options: ɵActionOptions;
|
|
96
|
+
type: string;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Ensures metadata is attached to the class and returns it.
|
|
101
|
+
*
|
|
102
|
+
* @ignore
|
|
103
|
+
*/
|
|
104
|
+
declare function ɵensureStoreMetadata(target: ɵStateClassInternal): ɵMetaDataModel;
|
|
105
|
+
/**
|
|
106
|
+
* Get the metadata attached to the state class if it exists.
|
|
107
|
+
*
|
|
108
|
+
* @ignore
|
|
109
|
+
*/
|
|
110
|
+
declare function ɵgetStoreMetadata(target: ɵStateClassInternal): ɵMetaDataModel;
|
|
111
|
+
/**
|
|
112
|
+
* Ensures metadata is attached to the selector and returns it.
|
|
113
|
+
*
|
|
114
|
+
* @ignore
|
|
115
|
+
*/
|
|
116
|
+
declare function ɵensureSelectorMetadata(target: Function): ɵSelectorMetaDataModel;
|
|
117
|
+
/**
|
|
118
|
+
* Get the metadata attached to the selector if it exists.
|
|
119
|
+
*
|
|
120
|
+
* @ignore
|
|
121
|
+
*/
|
|
122
|
+
declare function ɵgetSelectorMetadata(target: any): ɵSelectorMetaDataModel;
|
|
123
|
+
|
|
124
|
+
declare function defaultEqualityCheck(a: any, b: any): boolean;
|
|
125
|
+
/**
|
|
126
|
+
* Memoize a function on its last inputs only.
|
|
127
|
+
* Originally from: https://github.com/reduxjs/reselect/blob/master/src/index.js
|
|
128
|
+
*
|
|
129
|
+
* @ignore
|
|
130
|
+
*/
|
|
131
|
+
declare function ɵmemoize<T extends (...args: any[]) => any>(func: T, equalityCheck?: typeof defaultEqualityCheck): T;
|
|
132
|
+
|
|
133
|
+
declare class ɵInitialState {
|
|
134
|
+
private static _value;
|
|
135
|
+
static set(state: ɵPlainObject): void;
|
|
136
|
+
static pop(): ɵPlainObject;
|
|
137
|
+
}
|
|
138
|
+
declare const ɵINITIAL_STATE_TOKEN: InjectionToken<ɵPlainObject>;
|
|
139
|
+
|
|
140
|
+
declare class ɵNgxsAppBootstrappedState extends ReplaySubject<boolean> {
|
|
141
|
+
constructor();
|
|
142
|
+
bootstrap(): void;
|
|
143
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ɵNgxsAppBootstrappedState, never>;
|
|
144
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<ɵNgxsAppBootstrappedState>;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
declare const ɵNGXS_STATE_FACTORY: InjectionToken<any>;
|
|
148
|
+
declare const ɵNGXS_STATE_CONTEXT_FACTORY: InjectionToken<any>;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Custom Subject that ensures that subscribers are notified of values in the order that they arrived.
|
|
152
|
+
* A standard Subject does not have this guarantee.
|
|
153
|
+
* For example, given the following code:
|
|
154
|
+
* ```typescript
|
|
155
|
+
* const subject = new Subject<string>();
|
|
156
|
+
subject.subscribe(value => {
|
|
157
|
+
if (value === 'start') subject.next('end');
|
|
158
|
+
});
|
|
159
|
+
subject.subscribe(value => { });
|
|
160
|
+
subject.next('start');
|
|
161
|
+
* ```
|
|
162
|
+
* When `subject` is a standard `Subject<T>` the second subscriber would recieve `end` and then `start`.
|
|
163
|
+
* When `subject` is a `OrderedSubject<T>` the second subscriber would recieve `start` and then `end`.
|
|
164
|
+
*/
|
|
165
|
+
declare class ɵOrderedSubject<T> extends Subject<T> {
|
|
166
|
+
private _orderedNext;
|
|
167
|
+
next(value?: T): void;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Custom BehaviorSubject that ensures that subscribers are notified of values in the order that they arrived.
|
|
171
|
+
* A standard BehaviorSubject does not have this guarantee.
|
|
172
|
+
* For example, given the following code:
|
|
173
|
+
* ```typescript
|
|
174
|
+
* const subject = new BehaviorSubject<string>();
|
|
175
|
+
subject.subscribe(value => {
|
|
176
|
+
if (value === 'start') subject.next('end');
|
|
177
|
+
});
|
|
178
|
+
subject.subscribe(value => { });
|
|
179
|
+
subject.next('start');
|
|
180
|
+
* ```
|
|
181
|
+
* When `subject` is a standard `BehaviorSubject<T>` the second subscriber would recieve `end` and then `start`.
|
|
182
|
+
* When `subject` is a `OrderedBehaviorSubject<T>` the second subscriber would recieve `start` and then `end`.
|
|
183
|
+
*/
|
|
184
|
+
declare class ɵOrderedBehaviorSubject<T> extends BehaviorSubject<T> {
|
|
185
|
+
private _orderedNext;
|
|
186
|
+
private _currentValue;
|
|
187
|
+
constructor(value: T);
|
|
188
|
+
getValue(): T;
|
|
189
|
+
next(value: T): void;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
declare function ɵwrapObserverCalls<TValue>(invokeFn: (fn: () => void) => void): MonoTypeOperatorFunction<TValue>;
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* BehaviorSubject of the entire state.
|
|
196
|
+
* @ignore
|
|
197
|
+
*/
|
|
198
|
+
declare class ɵStateStream extends ɵOrderedBehaviorSubject<ɵPlainObject> implements OnDestroy {
|
|
199
|
+
readonly state: Signal<ɵPlainObject>;
|
|
200
|
+
constructor();
|
|
201
|
+
ngOnDestroy(): void;
|
|
202
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ɵStateStream, never>;
|
|
203
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<ɵStateStream>;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export { StateToken, type ɵActionHandlerMetaData, type ɵActionOptions, type ɵExtractTokenType, ɵINITIAL_STATE_TOKEN, ɵInitialState, ɵMETA_KEY, ɵMETA_OPTIONS_KEY, type ɵMetaDataModel, ɵNGXS_STATE_CONTEXT_FACTORY, ɵNGXS_STATE_FACTORY, ɵNgxsAppBootstrappedState, ɵOrderedBehaviorSubject, ɵOrderedSubject, type ɵPlainObject, type ɵPlainObjectOf, type ɵRuntimeSelectorContext, ɵSELECTOR_META_KEY, type ɵSelectFromRootState, type ɵSelectorFactory, type ɵSelectorMetaDataModel, type ɵSharedSelectorOptions, type ɵStateClass, type ɵStateClassInternal, ɵStateStream, type ɵStateToken, type ɵStoreOptions, type ɵTokenName, ɵensureSelectorMetadata, ɵensureStoreMetadata, ɵgetSelectorMetadata, ɵgetStoreMetadata, ɵmemoize, ɵwrapObserverCalls };
|
|
@@ -1,4 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { Store, NgxsModuleOptions } from '@ngxs/store';
|
|
2
|
+
import { ModuleWithProviders } from '@angular/core';
|
|
3
|
+
import { TestBedStatic } from '@angular/core/testing';
|
|
4
|
+
import { ɵStateClass as _StateClass } from '@ngxs/store/internals';
|
|
5
|
+
|
|
6
|
+
declare function freshPlatform(fn: (done?: VoidFunction) => Promise<void>): () => Promise<void>;
|
|
7
|
+
|
|
8
|
+
interface NgxsOptionsTesting {
|
|
9
|
+
states?: _StateClass[];
|
|
10
|
+
ngxsOptions?: NgxsModuleOptions;
|
|
11
|
+
imports?: ModuleWithProviders<any>[];
|
|
12
|
+
before?: () => void;
|
|
13
|
+
}
|
|
14
|
+
interface NgxsTesting {
|
|
15
|
+
store: Store;
|
|
16
|
+
getTestBed: TestBedStatic;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
declare class NgxsTestBed {
|
|
20
|
+
static configureTestingStates(options: NgxsOptionsTesting): NgxsTesting;
|
|
21
|
+
private static ngxsBootstrap;
|
|
22
|
+
private static resetTestBed;
|
|
23
|
+
private static createRootNode;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
type ConsoleRecord = [string, any[]];
|
|
27
|
+
type ConsoleRecorder = ConsoleRecord[];
|
|
28
|
+
declare function loggedError(message: string): ConsoleRecord;
|
|
29
|
+
declare function skipConsoleLogging<T extends (...args: any[]) => any>(fn: T, consoleRecorder?: ConsoleRecorder): ReturnType<T>;
|
|
30
|
+
|
|
31
|
+
export { type ConsoleRecord, type ConsoleRecorder, NgxsTestBed, type NgxsTesting, freshPlatform, loggedError, skipConsoleLogging };
|
package/operators/index.d.ts
CHANGED
|
@@ -1,14 +1,102 @@
|
|
|
1
|
+
type _NoInfer<T> = T extends infer S ? S : never;
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
3
|
+
* Blocks the ability of the typescript inferrence engine to be able to use the provided type as part of
|
|
4
|
+
* inferring any type parameters from this usage.
|
|
5
|
+
* @example
|
|
6
|
+
* Primarily used to wrap parameters of functions in order to prevent the TypeScript inferrence engine
|
|
7
|
+
* from inferring a type parameter of the function from the value provided to this parameter.
|
|
8
|
+
* This essentially blocks the Contravariance of the function (through its parameters) so that the
|
|
9
|
+
* function type parameter is purely determined by the Covariant requirements of the function's return type.
|
|
10
|
+
* This is key to creating `StateOperator`s that are typed based on their contextual usage and not on the arguments
|
|
11
|
+
* provided to them. This is critical for type safety and intellisense for State Operators.
|
|
12
|
+
* Here is an example of how this benefits a state operator:
|
|
13
|
+
* ```ts
|
|
14
|
+
* declare function append<T>(items: NoInfer<T[]>): StateOperator<T[]>;
|
|
15
|
+
* declare function appendBad<T>(items: T[]): StateOperator<T[]>;
|
|
16
|
+
*
|
|
17
|
+
* interface AAA {
|
|
18
|
+
* foo?: boolean;
|
|
19
|
+
* bar?: boolean;
|
|
20
|
+
* }
|
|
21
|
+
*
|
|
22
|
+
* // Works
|
|
23
|
+
* // (T in append is correctly inferred as AAA)
|
|
24
|
+
* patch<{ test: AAA[] }>({ test: append([{ foo: true }]) });
|
|
25
|
+
*
|
|
26
|
+
* // Incorrectly throws: Type 'AAA' is not assignable to type '{ foo: true; }'.ts(2322)
|
|
27
|
+
* // (T in appendBad is incorrectly inferred as { foo: true; })
|
|
28
|
+
* patch<{ test: AAA[] }>({ test: appendBad([{ foo: true }]) });
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
*/
|
|
32
|
+
type NoInfer<T> = T extends (infer O)[] ? _NoInfer<O>[] : _NoInfer<T>;
|
|
33
|
+
/**
|
|
34
|
+
* IMPORTANT NOTE: This should not be used externally to the library, rather
|
|
35
|
+
* the exported type `ExistingState<T>` should be used instead.
|
|
36
|
+
*
|
|
37
|
+
* Used to convert a type to its readonly form. This can be given any type, from
|
|
38
|
+
* primitives to objects or arrays that could already be readonly or not.
|
|
39
|
+
* This does not apply the readonly construct to nested objects, but only to the top level type.
|
|
40
|
+
*/
|
|
41
|
+
type ɵAsReadonly<T> = T extends Readonly<infer O> ? (O extends T ? Readonly<T> : T) : T;
|
|
42
|
+
/**
|
|
43
|
+
* Represents the existing state that is passed into a `StateOperator` which should
|
|
44
|
+
* not be modified but will be used to build the new state returned by the `StateOperator`.
|
|
45
|
+
*/
|
|
46
|
+
type ExistingState<T> = T extends any ? ɵAsReadonly<T> : never;
|
|
47
|
+
/**
|
|
48
|
+
* This is a monotype unary function that is used to create a new state from an existing state.
|
|
49
|
+
* A state operator is usually created by a function that is given some data
|
|
50
|
+
* to integrate with the state and returns a state operator which integrates this data or instruction.
|
|
51
|
+
*
|
|
52
|
+
* In state management terminology this creator function is commonly referred to as a state operator
|
|
53
|
+
* because it represents the operation to be performed. ie. `patch`, `append`, `insertItem`, `compose`, `iif`, etc.
|
|
54
|
+
*/
|
|
55
|
+
type StateOperator<T> = (existing: ExistingState<T>) => T;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @param items - Specific items to append to the end of an array
|
|
59
|
+
*/
|
|
60
|
+
declare function append<T>(items: NoInfer<T[]>): StateOperator<T[]>;
|
|
61
|
+
|
|
62
|
+
declare function compose<T>(...operators: NoInfer<StateOperator<T>[]>): StateOperator<T>;
|
|
63
|
+
|
|
64
|
+
type Predicate<T = any> = (value: T | Readonly<T>) => boolean;
|
|
65
|
+
declare function isStateOperator<T>(value: T | StateOperator<T>): value is StateOperator<T>;
|
|
66
|
+
declare function isPredicate<T>(value: Predicate<T> | boolean | number): value is Predicate<T>;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* @param condition - Condition can be a plain boolean value or a function,
|
|
70
|
+
* that returns boolean, also this function can take a value as an argument
|
|
71
|
+
* to which this state operator applies
|
|
72
|
+
* @param trueOperatorOrValue - Any value or a state operator
|
|
73
|
+
* @param elseOperatorOrValue - Any value or a state operator
|
|
74
|
+
*/
|
|
75
|
+
declare function iif<T>(condition: NoInfer<Predicate<T>> | boolean, trueOperatorOrValue: NoInfer<StateOperator<T> | T>, elseOperatorOrValue?: NoInfer<StateOperator<T> | T>): StateOperator<T>;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @param value - Value to insert
|
|
79
|
+
* @param [beforePosition] - Specified index to insert value before, optional
|
|
80
|
+
*/
|
|
81
|
+
declare function insertItem<T>(value: NoInfer<T>, beforePosition?: number): StateOperator<T[]>;
|
|
82
|
+
|
|
83
|
+
type NotUndefined<T> = T extends undefined ? never : T;
|
|
84
|
+
type ɵPatchSpec<T> = {
|
|
85
|
+
[P in keyof T]?: T[P] | StateOperator<NotUndefined<T[P]>>;
|
|
86
|
+
};
|
|
87
|
+
declare function patch<T extends Record<string, any>>(patchObject: NoInfer<ɵPatchSpec<T>>): StateOperator<T>;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* @param selector - Index of item in the array or a predicate function
|
|
91
|
+
* that can be provided in `Array.prototype.findIndex`
|
|
92
|
+
* @param operatorOrValue - New value under the `selector` index or a
|
|
93
|
+
* function that can be applied to an existing value
|
|
94
|
+
*/
|
|
95
|
+
declare function updateItem<T>(selector: number | NoInfer<Predicate<T>>, operatorOrValue: NoInfer<T> | NoInfer<StateOperator<T>>): StateOperator<T[]>;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* @param selector - index or predicate to remove an item from an array by
|
|
99
|
+
*/
|
|
100
|
+
declare function removeItem<T>(selector: number | NoInfer<Predicate<T>>): StateOperator<T[]>;
|
|
101
|
+
|
|
102
|
+
export { type ExistingState, type NoInfer, type Predicate, type StateOperator, append, compose, iif, insertItem, isPredicate, isStateOperator, patch, removeItem, updateItem, type ɵPatchSpec };
|
package/package.json
CHANGED
package/plugins/index.d.ts
CHANGED
|
@@ -1,3 +1,62 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { ɵPlainObject as _PlainObject } from '@ngxs/store/internals';
|
|
2
|
+
import { InjectionToken } from '@angular/core';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Init action
|
|
6
|
+
*/
|
|
7
|
+
declare class InitState {
|
|
8
|
+
static readonly type = "@@INIT";
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Update action
|
|
12
|
+
*/
|
|
13
|
+
declare class UpdateState {
|
|
14
|
+
readonly addedStates?: _PlainObject | undefined;
|
|
15
|
+
static readonly type = "@@UPDATE_STATE";
|
|
16
|
+
constructor(addedStates?: _PlainObject | undefined);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
declare const NGXS_PLUGINS: InjectionToken<unknown>;
|
|
20
|
+
type NgxsPluginFn = (state: any, mutation: any, next: NgxsNextPluginFn) => any;
|
|
21
|
+
type NgxsNextPluginFn = (state: any, mutation: any) => any;
|
|
22
|
+
/**
|
|
23
|
+
* Plugin interface
|
|
24
|
+
*/
|
|
25
|
+
interface NgxsPlugin {
|
|
26
|
+
/**
|
|
27
|
+
* Handle the state/action before its submitted to the state handlers.
|
|
28
|
+
*/
|
|
29
|
+
handle(state: any, action: any, next: NgxsNextPluginFn): any;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Returns the type from an action instance/class.
|
|
34
|
+
* @ignore
|
|
35
|
+
*/
|
|
36
|
+
declare function getActionTypeFromInstance(action: any): string | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Matches a action
|
|
39
|
+
* @ignore
|
|
40
|
+
*/
|
|
41
|
+
declare function actionMatcher(action1: any): (action2: any) => boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Set a deeply nested value. Example:
|
|
44
|
+
*
|
|
45
|
+
* setValue({ foo: { bar: { eat: false } } },
|
|
46
|
+
* 'foo.bar.eat', true) //=> { foo: { bar: { eat: true } } }
|
|
47
|
+
*
|
|
48
|
+
* While it traverses it also creates new objects from top down.
|
|
49
|
+
*
|
|
50
|
+
* @ignore
|
|
51
|
+
*/
|
|
52
|
+
declare const setValue: (obj: any, prop: string, val: any) => any;
|
|
53
|
+
/**
|
|
54
|
+
* Get a deeply nested value. Example:
|
|
55
|
+
*
|
|
56
|
+
* getValue({ foo: bar: [] }, 'foo.bar') //=> []
|
|
57
|
+
*
|
|
58
|
+
* @ignore
|
|
59
|
+
*/
|
|
60
|
+
declare const getValue: (obj: any, prop: string) => any;
|
|
61
|
+
|
|
62
|
+
export { InitState, NGXS_PLUGINS, type NgxsNextPluginFn, type NgxsPlugin, type NgxsPluginFn, UpdateState, actionMatcher, getActionTypeFromInstance, getValue, setValue };
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This is an experimental feature that contributes to app stability,
|
|
3
|
-
* which is required during server-side rendering. With asynchronous
|
|
4
|
-
* actions being dispatched and handled, Angular is unaware of them in
|
|
5
|
-
* zoneless mode and doesn't know whether the app is still unstable.
|
|
6
|
-
* This may prematurely serialize the final HTML that is sent to the client.
|
|
7
|
-
*/
|
|
8
|
-
export declare function withExperimentalNgxsPendingTasks(): import("@angular/core").EnvironmentProviders;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { BehaviorSubject, Subject } from 'rxjs';
|
|
2
|
-
/**
|
|
3
|
-
* Custom Subject that ensures that subscribers are notified of values in the order that they arrived.
|
|
4
|
-
* A standard Subject does not have this guarantee.
|
|
5
|
-
* For example, given the following code:
|
|
6
|
-
* ```typescript
|
|
7
|
-
* const subject = new Subject<string>();
|
|
8
|
-
subject.subscribe(value => {
|
|
9
|
-
if (value === 'start') subject.next('end');
|
|
10
|
-
});
|
|
11
|
-
subject.subscribe(value => { });
|
|
12
|
-
subject.next('start');
|
|
13
|
-
* ```
|
|
14
|
-
* When `subject` is a standard `Subject<T>` the second subscriber would recieve `end` and then `start`.
|
|
15
|
-
* When `subject` is a `OrderedSubject<T>` the second subscriber would recieve `start` and then `end`.
|
|
16
|
-
*/
|
|
17
|
-
export declare class ɵOrderedSubject<T> extends Subject<T> {
|
|
18
|
-
private _orderedNext;
|
|
19
|
-
next(value?: T): void;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Custom BehaviorSubject that ensures that subscribers are notified of values in the order that they arrived.
|
|
23
|
-
* A standard BehaviorSubject does not have this guarantee.
|
|
24
|
-
* For example, given the following code:
|
|
25
|
-
* ```typescript
|
|
26
|
-
* const subject = new BehaviorSubject<string>();
|
|
27
|
-
subject.subscribe(value => {
|
|
28
|
-
if (value === 'start') subject.next('end');
|
|
29
|
-
});
|
|
30
|
-
subject.subscribe(value => { });
|
|
31
|
-
subject.next('start');
|
|
32
|
-
* ```
|
|
33
|
-
* When `subject` is a standard `BehaviorSubject<T>` the second subscriber would recieve `end` and then `start`.
|
|
34
|
-
* When `subject` is a `OrderedBehaviorSubject<T>` the second subscriber would recieve `start` and then `end`.
|
|
35
|
-
*/
|
|
36
|
-
export declare class ɵOrderedBehaviorSubject<T> extends BehaviorSubject<T> {
|
|
37
|
-
private _orderedNext;
|
|
38
|
-
private _currentValue;
|
|
39
|
-
constructor(value: T);
|
|
40
|
-
getValue(): T;
|
|
41
|
-
next(value: T): void;
|
|
42
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { InjectionToken } from '@angular/core';
|
|
2
|
-
import { ɵPlainObject } from './symbols';
|
|
3
|
-
export declare class ɵInitialState {
|
|
4
|
-
private static _value;
|
|
5
|
-
static set(state: ɵPlainObject): void;
|
|
6
|
-
static pop(): ɵPlainObject;
|
|
7
|
-
}
|
|
8
|
-
export declare const ɵINITIAL_STATE_TOKEN: InjectionToken<ɵPlainObject>;
|
package/internals/memoize.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
declare function defaultEqualityCheck(a: any, b: any): boolean;
|
|
2
|
-
/**
|
|
3
|
-
* Memoize a function on its last inputs only.
|
|
4
|
-
* Originally from: https://github.com/reduxjs/reselect/blob/master/src/index.js
|
|
5
|
-
*
|
|
6
|
-
* @ignore
|
|
7
|
-
*/
|
|
8
|
-
export declare function ɵmemoize<T extends (...args: any[]) => any>(func: T, equalityCheck?: typeof defaultEqualityCheck): T;
|
|
9
|
-
export {};
|
package/internals/metadata.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { ɵMetaDataModel, ɵStateClassInternal, ɵSelectorMetaDataModel } from './symbols';
|
|
2
|
-
/**
|
|
3
|
-
* Ensures metadata is attached to the class and returns it.
|
|
4
|
-
*
|
|
5
|
-
* @ignore
|
|
6
|
-
*/
|
|
7
|
-
export declare function ɵensureStoreMetadata(target: ɵStateClassInternal): ɵMetaDataModel;
|
|
8
|
-
/**
|
|
9
|
-
* Get the metadata attached to the state class if it exists.
|
|
10
|
-
*
|
|
11
|
-
* @ignore
|
|
12
|
-
*/
|
|
13
|
-
export declare function ɵgetStoreMetadata(target: ɵStateClassInternal): ɵMetaDataModel;
|
|
14
|
-
/**
|
|
15
|
-
* Ensures metadata is attached to the selector and returns it.
|
|
16
|
-
*
|
|
17
|
-
* @ignore
|
|
18
|
-
*/
|
|
19
|
-
export declare function ɵensureSelectorMetadata(target: Function): ɵSelectorMetaDataModel;
|
|
20
|
-
/**
|
|
21
|
-
* Get the metadata attached to the selector if it exists.
|
|
22
|
-
*
|
|
23
|
-
* @ignore
|
|
24
|
-
*/
|
|
25
|
-
export declare function ɵgetSelectorMetadata(target: any): ɵSelectorMetaDataModel;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ReplaySubject } from 'rxjs';
|
|
2
|
-
import * as i0 from "@angular/core";
|
|
3
|
-
export declare class ɵNgxsAppBootstrappedState extends ReplaySubject<boolean> {
|
|
4
|
-
constructor();
|
|
5
|
-
bootstrap(): void;
|
|
6
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<ɵNgxsAppBootstrappedState, never>;
|
|
7
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<ɵNgxsAppBootstrappedState>;
|
|
8
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { OnDestroy, Signal } from '@angular/core';
|
|
2
|
-
import { ɵOrderedBehaviorSubject } from './custom-rxjs-subjects';
|
|
3
|
-
import { ɵPlainObject } from './symbols';
|
|
4
|
-
import * as i0 from "@angular/core";
|
|
5
|
-
/**
|
|
6
|
-
* BehaviorSubject of the entire state.
|
|
7
|
-
* @ignore
|
|
8
|
-
*/
|
|
9
|
-
export declare class ɵStateStream extends ɵOrderedBehaviorSubject<ɵPlainObject> implements OnDestroy {
|
|
10
|
-
readonly state: Signal<ɵPlainObject>;
|
|
11
|
-
constructor();
|
|
12
|
-
ngOnDestroy(): void;
|
|
13
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<ɵStateStream, never>;
|
|
14
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<ɵStateStream>;
|
|
15
|
-
}
|