@ngxs/store 19.0.0 → 20.0.0-dev.master-0db0003

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/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Type, ModuleWithProviders, Signal, EnvironmentProviders } from '@angular/core';
3
- import { ɵSharedSelectorOptions as _SharedSelectorOptions, ɵStateClass as _StateClass, ɵActionOptions as _ActionOptions, StateToken, ɵStoreOptions as _StoreOptions } from '@ngxs/store/internals';
2
+ import { ModuleWithProviders, Signal, EnvironmentProviders, Type } from '@angular/core';
3
+ import { ɵActionOptions as _ActionOptions, StateToken, ɵSharedSelectorOptions as _SharedSelectorOptions, ɵStateClass as _StateClass, ɵStoreOptions as _StoreOptions } from '@ngxs/store/internals';
4
4
  export { ɵActionOptions as ActionOptions, StateToken } from '@ngxs/store/internals';
5
5
  import * as rxjs from 'rxjs';
6
6
  import { Observable, Subscription, OperatorFunction } from 'rxjs';
@@ -9,11 +9,6 @@ export { StateOperator } from '@ngxs/store/operators';
9
9
  import { NgxsPlugin, NgxsPluginFn } from '@ngxs/store/plugins';
10
10
  export { InitState, NGXS_PLUGINS, NgxsNextPluginFn, NgxsPlugin, NgxsPluginFn, UpdateState, actionMatcher, getActionTypeFromInstance, getValue, setValue } from '@ngxs/store/plugins';
11
11
 
12
- interface NgxsExecutionStrategy {
13
- enter<T>(func: () => T): T;
14
- leave<T>(func: () => T): T;
15
- }
16
-
17
12
  /**
18
13
  * The NGXS config settings.
19
14
  */
@@ -36,18 +31,6 @@ declare class NgxsConfig {
36
31
  */
37
32
  strictContentSecurityPolicy: boolean;
38
33
  };
39
- /**
40
- * Determines the execution context to perform async operations inside. An implementation can be
41
- * provided to override the default behaviour where the async operations are run
42
- * outside Angular's zone but all observable behaviours of NGXS are run back inside Angular's zone.
43
- * These observable behaviours are from:
44
- * `store.selectSignal(...)`, `store.select(...)`, `actions.subscribe(...)` or `store.dispatch(...).subscribe(...)`
45
- * Every `zone.run` causes Angular to run change detection on the whole tree (`app.tick()`) so of your
46
- * application doesn't rely on zone.js running change detection then you can switch to the
47
- * `NoopNgxsExecutionStrategy` that doesn't interact with zones.
48
- * (default: null)
49
- */
50
- executionStrategy: Type<NgxsExecutionStrategy>;
51
34
  /**
52
35
  * Defining shared selector options
53
36
  */
@@ -276,14 +259,6 @@ declare class Store {
276
259
  */
277
260
  declare function State<T>(options: _StoreOptions<T>): (target: _StateClass) => void;
278
261
 
279
- /**
280
- * Decorator for selecting a slice of state from the store.
281
- *
282
- * @deprecated
283
- * Read the deprecation notice at this link: https://ngxs.io/deprecations/select-decorator-deprecation.
284
- */
285
- declare function Select<T>(rawSelector?: T, ...paths: string[]): PropertyDecorator;
286
-
287
262
  /**
288
263
  * Decorator for setting selector options at a method or class level.
289
264
  */
@@ -292,7 +267,7 @@ declare function SelectorOptions(options: _SharedSelectorOptions): ClassDecorato
292
267
  /**
293
268
  * Status of a dispatched action
294
269
  */
295
- declare const enum ActionStatus {
270
+ declare enum ActionStatus {
296
271
  Dispatched = "DISPATCHED",
297
272
  Successful = "SUCCESSFUL",
298
273
  Canceled = "CANCELED",
@@ -448,11 +423,12 @@ declare function Selector(): SelectorType<unknown>;
448
423
  */
449
424
  declare function Selector<T extends SelectorDefTuple>(selectors: T): SelectorType<T>;
450
425
 
451
- declare class NoopNgxsExecutionStrategy implements NgxsExecutionStrategy {
452
- enter<T>(func: () => T): T;
453
- leave<T>(func: () => T): T;
454
- static ɵfac: i0.ɵɵFactoryDeclaration<NoopNgxsExecutionStrategy, never>;
455
- static ɵprov: i0.ɵɵInjectableDeclaration<NoopNgxsExecutionStrategy>;
426
+ declare class ActionDirector {
427
+ private _registry;
428
+ private _actionHandlerFactory;
429
+ attachAction<TStateModel, TActionType extends ActionDef>(stateToken: StateToken<TStateModel>, Action: TActionType, handlerFn: (ctx: StateContext<TStateModel>, action: InstanceType<TActionType>) => void | Observable<void> | Promise<void>, options?: _ActionOptions): void;
430
+ static ɵfac: i0.ɵɵFactoryDeclaration<ActionDirector, never>;
431
+ static ɵprov: i0.ɵɵInjectableDeclaration<ActionDirector>;
456
432
  }
457
433
 
458
434
  interface NgxsUnhandledErrorContext {
@@ -544,6 +520,9 @@ declare function provideStore(states?: _StateClass[], options?: NgxsModuleOption
544
520
  * }
545
521
  * ];
546
522
  * ```
523
+ *
524
+ * To lazy-load feature states at the route level,
525
+ * please refer to the `lazyProvider` utility function.
547
526
  */
548
527
  declare function provideStates(states: _StateClass[], ...features: EnvironmentProviders[]): EnvironmentProviders;
549
528
 
@@ -608,6 +587,40 @@ declare function createSelectMap<T extends SelectorMap>(selectorMap: T): { reado
608
587
  type ActionMap = Record<string, ActionDef<any>>;
609
588
  declare function createDispatchMap<T extends ActionMap>(actionMap: T): { readonly [K in keyof T]: (...args: ConstructorParameters<T[K]>) => Observable<void>; };
610
589
 
590
+ interface DefaultExport<T> {
591
+ default: T;
592
+ }
593
+ /**
594
+ * This function serves as a utility to lazy-load providers at the injection
595
+ * context level — for example, at the route level. If the feature state needs
596
+ * to be provided in more than one place, it might be indirectly included in
597
+ * the main bundle, which we want to avoid. This function can be used at the
598
+ * guard level to lazy-load the state provider before resolvers run and the
599
+ * component is initialized:
600
+ *
601
+ * ```ts
602
+ * const routes = [
603
+ * {
604
+ * path: 'home',
605
+ * loadComponent: () => import(...),
606
+ * canActivate: [
607
+ * lazyProvider(async () => (await import('path-to-state-library')).invoicesStateProvider)
608
+ * ]
609
+ * }
610
+ * ];
611
+ * ```
612
+ *
613
+ * Where `invoicesStateProvider` is the following:
614
+ *
615
+ * ```ts
616
+ * // path-to-state-library/index.ts
617
+ *
618
+ * export const invoicesStateProvider = provideStates([InvoicesState]);
619
+ * ```
620
+ */
621
+ declare function lazyProvider(factory: () => Promise<EnvironmentProviders | DefaultExport<EnvironmentProviders>>): () => Promise<boolean>;
622
+
611
623
  declare function ɵprovideNgxsInternalStateTokens(): i0.EnvironmentProviders;
612
624
 
613
- export { Action, type ActionCompletion, type ActionContext, type ActionDef, type ActionMap, ActionStatus, type ActionType, Actions, type NgxsAfterBootstrap, NgxsConfig, NgxsDevelopmentModule, type NgxsDevelopmentOptions, type NgxsExecutionStrategy, NgxsModule, type NgxsModuleOptions, type NgxsOnChanges, type NgxsOnInit, NgxsSimpleChange, NgxsUnhandledActionsLogger, type NgxsUnhandledErrorContext, NgxsUnhandledErrorHandler, NoopNgxsExecutionStrategy, type PropertySelectors, Select, Selector, type SelectorMap, SelectorOptions, State, type StateContext, Store, type TypedSelector, createDispatchMap, createModelSelector, createPickSelector, createPropertySelectors, createSelectMap, createSelector, dispatch, ofAction, ofActionCanceled, ofActionCompleted, ofActionDispatched, ofActionErrored, ofActionSuccessful, provideStates, provideStore, select, withNgxsDevelopmentOptions, withNgxsPendingTasks, withNgxsPlugin, withNgxsPreboot, NgxsFeatureModule as ɵNgxsFeatureModule, NgxsRootModule as ɵNgxsRootModule, type ɵSelectorDef, type ɵSelectorFunc, type ɵSelectorReturnType, type ɵStateSelector, ɵprovideNgxsInternalStateTokens };
625
+ export { Action, ActionDirector, ActionStatus, Actions, NgxsConfig, NgxsDevelopmentModule, NgxsModule, NgxsSimpleChange, NgxsUnhandledActionsLogger, NgxsUnhandledErrorHandler, Selector, SelectorOptions, State, Store, createDispatchMap, createModelSelector, createPickSelector, createPropertySelectors, createSelectMap, createSelector, dispatch, lazyProvider, ofAction, ofActionCanceled, ofActionCompleted, ofActionDispatched, ofActionErrored, ofActionSuccessful, provideStates, provideStore, select, withNgxsDevelopmentOptions, withNgxsPendingTasks, withNgxsPlugin, withNgxsPreboot, NgxsFeatureModule as ɵNgxsFeatureModule, NgxsRootModule as ɵNgxsRootModule, ɵprovideNgxsInternalStateTokens };
626
+ export type { ActionCompletion, ActionContext, ActionDef, ActionMap, ActionType, NgxsAfterBootstrap, NgxsDevelopmentOptions, NgxsModuleOptions, NgxsOnChanges, NgxsOnInit, NgxsUnhandledErrorContext, PropertySelectors, SelectorMap, StateContext, TypedSelector, ɵSelectorDef, ɵSelectorFunc, ɵSelectorReturnType, ɵStateSelector };
@@ -1,6 +1,6 @@
1
1
  import * as i0 from '@angular/core';
2
- import { InjectionToken, OnDestroy, Signal } from '@angular/core';
3
- import { ReplaySubject, Subject, BehaviorSubject, MonoTypeOperatorFunction } from 'rxjs';
2
+ import { InjectionToken, Signal } from '@angular/core';
3
+ import { Observable, BehaviorSubject, Subject, MonoTypeOperatorFunction } from 'rxjs';
4
4
 
5
5
  declare class StateToken<T = void> {
6
6
  private readonly _name;
@@ -136,7 +136,7 @@ declare class ɵInitialState {
136
136
  }
137
137
  declare const ɵINITIAL_STATE_TOKEN: InjectionToken<ɵPlainObject>;
138
138
 
139
- declare class ɵNgxsAppBootstrappedState extends ReplaySubject<boolean> {
139
+ declare class ɵNgxsAppBootstrappedState extends BehaviorSubject<boolean> {
140
140
  constructor();
141
141
  bootstrap(): void;
142
142
  static ɵfac: i0.ɵɵFactoryDeclaration<ɵNgxsAppBootstrappedState, never>;
@@ -194,12 +194,25 @@ declare function ɵwrapObserverCalls<TValue>(invokeFn: (fn: () => void) => void)
194
194
  * BehaviorSubject of the entire state.
195
195
  * @ignore
196
196
  */
197
- declare class ɵStateStream extends ɵOrderedBehaviorSubject<ɵPlainObject> implements OnDestroy {
197
+ declare class ɵStateStream extends ɵOrderedBehaviorSubject<ɵPlainObject> {
198
198
  readonly state: Signal<ɵPlainObject>;
199
199
  constructor();
200
- ngOnDestroy(): void;
201
200
  static ɵfac: i0.ɵɵFactoryDeclaration<ɵStateStream, never>;
202
201
  static ɵprov: i0.ɵɵInjectableDeclaration<ɵStateStream>;
203
202
  }
204
203
 
205
- 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 };
204
+ declare const ɵhasOwnProperty: (target: any, key: PropertyKey) => boolean;
205
+ declare const ɵdefineProperty: <T>(o: T, p: PropertyKey, attributes: PropertyDescriptor & ThisType<any>) => T;
206
+
207
+ type ActionHandlerFn = (action: any) => Observable<unknown>;
208
+ declare class ɵNgxsActionRegistry {
209
+ private readonly _actionTypeToHandlersMap;
210
+ constructor();
211
+ get(type: string): Set<ActionHandlerFn> | undefined;
212
+ register(type: string, handler: ActionHandlerFn): () => void;
213
+ static ɵfac: i0.ɵɵFactoryDeclaration<ɵNgxsActionRegistry, never>;
214
+ static ɵprov: i0.ɵɵInjectableDeclaration<ɵNgxsActionRegistry>;
215
+ }
216
+
217
+ export { StateToken, ɵINITIAL_STATE_TOKEN, ɵInitialState, ɵMETA_KEY, ɵMETA_OPTIONS_KEY, ɵNGXS_STATE_CONTEXT_FACTORY, ɵNGXS_STATE_FACTORY, ɵNgxsActionRegistry, ɵNgxsAppBootstrappedState, ɵOrderedBehaviorSubject, ɵOrderedSubject, ɵSELECTOR_META_KEY, ɵStateStream, ɵdefineProperty, ɵensureSelectorMetadata, ɵensureStoreMetadata, ɵgetSelectorMetadata, ɵgetStoreMetadata, ɵhasOwnProperty, ɵmemoize, ɵwrapObserverCalls };
218
+ export type { ɵActionHandlerMetaData, ɵActionOptions, ɵExtractTokenType, ɵMetaDataModel, ɵPlainObject, ɵPlainObjectOf, ɵRuntimeSelectorContext, ɵSelectFromRootState, ɵSelectorFactory, ɵSelectorMetaDataModel, ɵSharedSelectorOptions, ɵStateClass, ɵStateClassInternal, ɵStateToken, ɵStoreOptions, ɵTokenName };
@@ -1,5 +1,6 @@
1
- import { Store, NgxsModuleOptions } from '@ngxs/store';
2
- import { ModuleWithProviders } from '@angular/core';
1
+ import { NgxsModuleOptions, Store } from '@ngxs/store';
2
+ import * as i0 from '@angular/core';
3
+ import { EnvironmentProviders, ModuleWithProviders } from '@angular/core';
3
4
  import { TestBedStatic } from '@angular/core/testing';
4
5
  import { ɵStateClass as _StateClass } from '@ngxs/store/internals';
5
6
 
@@ -28,4 +29,46 @@ type ConsoleRecorder = ConsoleRecord[];
28
29
  declare function loggedError(message: string): ConsoleRecord;
29
30
  declare function skipConsoleLogging<T extends (...args: any[]) => any>(fn: T, consoleRecorder?: ConsoleRecorder): ReturnType<T>;
30
31
 
31
- export { type ConsoleRecord, type ConsoleRecorder, NgxsTestBed, type NgxsTesting, freshPlatform, loggedError, skipConsoleLogging };
32
+ declare class NgxsActionCollector {
33
+ /**
34
+ * Including this in your providers will
35
+ * set up the the action collector to start collecting actions
36
+ * from before NGXS initializes
37
+ * @example
38
+ * // In your providers declaration for your tests:
39
+ * {
40
+ * providers: [
41
+ * NgxsActionCollector.collectActions(),
42
+ * provideStore([MyState]),
43
+ * ],
44
+ * // ...
45
+ * }
46
+ * // and then in your test:
47
+ * const actionCollector = TestBed.inject(NgxsActionCollector);
48
+ * const actionsDispatched = actionCollector.dispatched;
49
+ * const action = actionsDispatched.find(
50
+ * (item) => item instanceof MyAction
51
+ * );
52
+ * expect(action).toBeDefined();
53
+ * @returns An environment initializer that starts the collector immediately
54
+ */
55
+ static collectActions(): EnvironmentProviders;
56
+ private _destroyed$;
57
+ private _stopped$;
58
+ private _started;
59
+ readonly dispatched: any[];
60
+ readonly completed: any[];
61
+ readonly successful: any[];
62
+ readonly errored: any[];
63
+ readonly cancelled: any[];
64
+ private _actions$;
65
+ constructor();
66
+ start(): void;
67
+ reset(): void;
68
+ stop(): void;
69
+ static ɵfac: i0.ɵɵFactoryDeclaration<NgxsActionCollector, never>;
70
+ static ɵprov: i0.ɵɵInjectableDeclaration<NgxsActionCollector>;
71
+ }
72
+
73
+ export { NgxsActionCollector, NgxsTestBed, freshPlatform, loggedError, skipConsoleLogging };
74
+ export type { ConsoleRecord, ConsoleRecorder, NgxsTesting };
@@ -62,8 +62,8 @@ declare function append<T>(items: NoInfer<T[]>): StateOperator<T[]>;
62
62
  declare function compose<T>(...operators: NoInfer<StateOperator<T>[]>): StateOperator<T>;
63
63
 
64
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>;
65
+ declare const isStateOperator: <T>(value: T | StateOperator<T>) => value is StateOperator<T>;
66
+ declare const isPredicate: <T>(value: Predicate<T> | boolean | number) => value is Predicate<T>;
67
67
 
68
68
  /**
69
69
  * @param condition - Condition can be a plain boolean value or a function,
@@ -99,4 +99,5 @@ declare function updateItem<T>(selector: number | NoInfer<Predicate<T>>, operato
99
99
  */
100
100
  declare function removeItem<T>(selector: number | NoInfer<Predicate<T>>): StateOperator<T[]>;
101
101
 
102
- export { type ExistingState, type NoInfer, type Predicate, type StateOperator, append, compose, iif, insertItem, isPredicate, isStateOperator, patch, removeItem, updateItem, type ɵPatchSpec };
102
+ export { append, compose, iif, insertItem, isPredicate, isStateOperator, patch, removeItem, updateItem };
103
+ export type { ExistingState, NoInfer, Predicate, StateOperator, ɵPatchSpec };
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@ngxs/store",
3
- "version": "19.0.0",
3
+ "version": "20.0.0-dev.master-0db0003",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {
7
- "@angular/core": ">=19.0.0 <20.0.0",
7
+ "@angular/core": ">=20.0.0 <21.0.0",
8
8
  "rxjs": ">=7.0.0"
9
9
  },
10
10
  "schematics": "./schematics/collection.json",
@@ -26,14 +26,14 @@
26
26
  "types": "./internals/index.d.ts",
27
27
  "default": "./fesm2022/ngxs-store-internals.mjs"
28
28
  },
29
- "./plugins": {
30
- "types": "./plugins/index.d.ts",
31
- "default": "./fesm2022/ngxs-store-plugins.mjs"
32
- },
33
29
  "./operators": {
34
30
  "types": "./operators/index.d.ts",
35
31
  "default": "./fesm2022/ngxs-store-operators.mjs"
36
32
  },
33
+ "./plugins": {
34
+ "types": "./plugins/index.d.ts",
35
+ "default": "./fesm2022/ngxs-store-plugins.mjs"
36
+ },
37
37
  "./internals/testing": {
38
38
  "types": "./internals/testing/index.d.ts",
39
39
  "default": "./fesm2022/ngxs-store-internals-testing.mjs"
@@ -85,4 +85,4 @@
85
85
  "type": "opencollective",
86
86
  "url": "https://opencollective.com/ngxs"
87
87
  }
88
- }
88
+ }
@@ -66,4 +66,5 @@ declare const setValue: (obj: any, prop: string, val: any) => any;
66
66
  */
67
67
  declare const getValue: (obj: any, prop: string) => any;
68
68
 
69
- export { InitState, NGXS_PLUGINS, type NgxsNextPluginFn, type NgxsPlugin, type NgxsPluginFn, UpdateState, actionMatcher, getActionTypeFromInstance, getValue, setValue, ɵisPluginClass };
69
+ export { InitState, NGXS_PLUGINS, UpdateState, actionMatcher, getActionTypeFromInstance, getValue, setValue, ɵisPluginClass };
70
+ export type { NgxsNextPluginFn, NgxsPlugin, NgxsPluginFn };
@@ -1,3 +1,3 @@
1
1
  {
2
- "@ngxs/store": "19.0.0"
2
+ "@ngxs/store": "20.0.0"
3
3
  }
@@ -1,3 +0,0 @@
1
- {
2
- "module": "../fesm2022/ngxs-store-experimental.mjs"
3
- }
@@ -1,3 +0,0 @@
1
- {
2
- "module": "../fesm2022/ngxs-store-internals.mjs"
3
- }
@@ -1,3 +0,0 @@
1
- {
2
- "module": "../../fesm2022/ngxs-store-internals-testing.mjs"
3
- }
@@ -1,3 +0,0 @@
1
- {
2
- "module": "../fesm2022/ngxs-store-operators.mjs"
3
- }
@@ -1,3 +0,0 @@
1
- {
2
- "module": "../fesm2022/ngxs-store-plugins.mjs"
3
- }