@ngxs/store 3.8.2-dev.master-67d50ea → 3.8.2-dev.master-728bfff

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
2
  import { Type, ModuleWithProviders, OnDestroy, NgZone, Injector, Signal, EnvironmentProviders } from '@angular/core';
3
- import { ɵSharedSelectorOptions as _SharedSelectorOptions, ɵStateClass as _StateClass, ɵActionOptions as _ActionOptions, ɵPlainObjectOf as _PlainObjectOf, ɵStateClassInternal as _StateClassInternal, ɵActionHandlerMetaData as _ActionHandlerMetaData, ɵOrderedSubject as _OrderedSubject, ɵStateStream as _StateStream, ɵRuntimeSelectorContext as _RuntimeSelectorContext, StateToken, ɵStoreOptions as _StoreOptions, ɵExtractTokenType as _ExtractTokenType } from '@ngxs/store/internals';
3
+ import { ɵSharedSelectorOptions as _SharedSelectorOptions, ɵStateClass as _StateClass, ɵActionOptions as _ActionOptions, ɵPlainObjectOf as _PlainObjectOf, ɵStateClassInternal as _StateClassInternal, ɵActionHandlerMetaData as _ActionHandlerMetaData, ɵOrderedSubject as _OrderedSubject, ɵStateStream as _StateStream, ɵRuntimeSelectorContext as _RuntimeSelectorContext, StateToken, ɵ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, Subject, Subscription, OperatorFunction } from 'rxjs';
@@ -507,8 +507,77 @@ declare function ofActionCompleted<T extends ActionType[]>(...allowedTypes: T):
507
507
  */
508
508
  declare function ofActionErrored<T extends ActionType[]>(...allowedTypes: T): OperatorFunction<ActionContext<Constructed<T[TupleKeys<T>]>>, ActionCompletion<Constructed<T[TupleKeys<T>]>>>;
509
509
 
510
- type SelectorSpec<T, U> = [T] extends [never] ? (...states: any[]) => any : T extends StateToken<any> ? (state: _ExtractTokenType<T>) => U : (...states: any[]) => any;
511
- type SelectorType<T> = <U>(target: any, key: string | symbol, descriptor: TypedPropertyDescriptor<SelectorSpec<T, U>>) => TypedPropertyDescriptor<SelectorSpec<T, U>> | void;
510
+ /**
511
+ * Defines a tuple of selector functions, state tokens, and state classes that a selector decorated
512
+ * by `@Selector()` can depend on.
513
+ */
514
+ type SelectorDefTuple = ɵSelectorDef<any>[] | [ɵSelectorDef<any>];
515
+ type UnknownToAny<T> = unknown extends T ? any : T;
516
+ type EnsureArray<T> = T extends any[] ? T : never;
517
+ /**
518
+ * Given a tuple of selector functions, state tokens, state classes, etc., returns a tuple of what
519
+ * a dependent selector would expect to receive for that parent as an argument when called.
520
+ *
521
+ * For example, if the first element in `ParentsTuple` is a selector function that returns a
522
+ * `number`, then the first element of the result tuple will be `number`. If the second element
523
+ * in `ParentsTuple` is a state class with model `{ name: string }`, then the second element of
524
+ * the result tuple will be `{ name: string }`.
525
+ */
526
+ type SelectorReturnTypeList<ParentsTuple extends SelectorDefTuple> = EnsureArray<{
527
+ [ParentsTupleIndex in keyof ParentsTuple]: ParentsTuple[ParentsTupleIndex] extends ɵSelectorDef<any> ? UnknownToAny<ɵSelectorReturnType<ParentsTuple[ParentsTupleIndex]>> : never;
528
+ }>;
529
+ /**
530
+ * Defines a selector function matching a given argument list of parent selectors/states/tokens
531
+ * and a given return type.
532
+ */
533
+ type SelectorSpec<ParentsTuple, Return> = ParentsTuple extends [] ? () => any : ParentsTuple extends SelectorDefTuple ? (...states: SelectorReturnTypeList<ParentsTuple>) => Return : () => any;
534
+ /**
535
+ * Defines a selector function matching `SelectorSpec<ParentsTuple, Return>` but with the assumption that the
536
+ * container state has been injected as the first argument.
537
+ */
538
+ type SelectorSpecWithInjectedState<ParentsTuple, Return> = SelectorSpec<ParentsTuple extends SelectorDefTuple ? [any, ...ParentsTuple] : [any], ParentsTuple extends SelectorDefTuple ? Return : any>;
539
+ /**
540
+ * Defines a property descriptor for the `@Selector` decorator that decorates a function with
541
+ * parent selectors/states/tokens `ParentsTuple` and return type `Return`.
542
+ */
543
+ type DescriptorWithNoInjectedState<ParentsTuple, Return> = TypedPropertyDescriptor<SelectorSpec<ParentsTuple, Return>>;
544
+ /**
545
+ * Same as `DescriptorWithNoInjectedState` but with state injected as the first argument.
546
+ */
547
+ type DescriptorWithInjectedState<ParentsTuple, Return> = TypedPropertyDescriptor<SelectorSpecWithInjectedState<ParentsTuple, Return>>;
548
+ type DecoratorArgs<Descriptor> = [target: any, key: string | symbol, descriptor?: Descriptor];
549
+ /**
550
+ * Defines the return type of a call to `@Selector` when there is no argument given
551
+ * (e.g. `@Selector()` counts, but `@Selector([])` does not)
552
+ *
553
+ * This result is a decorator that can only be used to decorate a function with no arguments or a
554
+ * single argument that is the container state.
555
+ */
556
+ type SelectorTypeNoDecoratorArgs = {
557
+ <Return>(...args: DecoratorArgs<DescriptorWithNoInjectedState<unknown, Return>>): void | DescriptorWithNoInjectedState<unknown, Return>;
558
+ <Return>(...args: DecoratorArgs<DescriptorWithInjectedState<unknown, Return>>): void | DescriptorWithInjectedState<unknown, Return>;
559
+ };
560
+ /**
561
+ * Defines the return type of a call to `@Selector` when there is an argument given.
562
+ * (e.g. `@Selector([])` counts, but `@Selector()` does not)
563
+ *
564
+ * This result is a decorator that can only be used to decorate a function with an argument list
565
+ * matching the results of the tuple of parents `ParentsTuple`.
566
+ */
567
+ type SelectorTypeWithDecoratorArgs<ParentsTuple> = {
568
+ <Return>(...args: DecoratorArgs<DescriptorWithNoInjectedState<ParentsTuple, Return>>): void | DescriptorWithNoInjectedState<ParentsTuple, Return>;
569
+ /**
570
+ * @deprecated
571
+ * Read the deprecation notice at this link: https://ngxs.io/deprecations/inject-container-state-deprecation.md.
572
+ */
573
+ <Return>(...args: DecoratorArgs<DescriptorWithInjectedState<ParentsTuple, Return>>): void | DescriptorWithInjectedState<ParentsTuple, Return>;
574
+ };
575
+ /**
576
+ * Defines the return type of a call to `@Selector`. This result is a decorator that can only be
577
+ * used to decorate a function with an argument list matching `ParentsTuple`, the results of the
578
+ * tuple of parent selectors/state tokens/state classes.
579
+ */
580
+ type SelectorType<ParentsTuple> = unknown extends ParentsTuple ? SelectorTypeNoDecoratorArgs : SelectorTypeWithDecoratorArgs<ParentsTuple>;
512
581
 
513
582
  /**
514
583
  * Decorator for creating a state selector for the current state.
@@ -517,7 +586,7 @@ declare function Selector(): SelectorType<unknown>;
517
586
  /**
518
587
  * Decorator for creating a state selector from the provided selectors (and optionally the container State, depending on the applicable Selector Options).
519
588
  */
520
- declare function Selector<T extends ɵSelectorDef<any>>(selectors: T[]): SelectorType<T>;
589
+ declare function Selector<T extends SelectorDefTuple>(selectors: T): SelectorType<T>;
521
590
 
522
591
  declare class NoopNgxsExecutionStrategy implements NgxsExecutionStrategy {
523
592
  enter<T>(func: () => T): T;
@@ -624,6 +693,28 @@ declare function provideStates(states: _StateClass[], ...features: EnvironmentPr
624
693
  */
625
694
  declare function withNgxsPlugin(plugin: Type<NgxsPlugin>): EnvironmentProviders;
626
695
 
696
+ /**
697
+ * This function registers a preboot function which will be called before the root
698
+ * store initializer is run, but after all of the NGXS features are provided and
699
+ * available for injection. This is useful for registering action stream listeners
700
+ * before any action is dispatched.
701
+ *
702
+ * ```ts
703
+ * bootstrapApplication(AppComponent, {
704
+ * providers: [
705
+ * provideStore(
706
+ * [CountriesState],
707
+ * withNgxsPreboot(() => {
708
+ * const actions$ = inject(Actions);
709
+ * actions$.subscribe(ctx => console.log(ctx));
710
+ * })
711
+ * )
712
+ * ]
713
+ * });
714
+ * ```
715
+ */
716
+ declare function withNgxsPreboot(prebootFn: VoidFunction): i0.EnvironmentProviders;
717
+
627
718
  /**
628
719
  * This function serves as a utility and has multiple purposes.
629
720
  * Firstly, it allows you to select properties from the state class
@@ -647,4 +738,4 @@ declare function createSelectMap<T extends SelectorMap>(selectorMap: T): { reado
647
738
  type ActionMap = Record<string, ActionDef<any>>;
648
739
  declare function createDispatchMap<T extends ActionMap>(actionMap: T): { readonly [K in keyof T]: (...args: ConstructorParameters<T[K]>) => Observable<void>; };
649
740
 
650
- 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, withNgxsPlugin, NgxsFeatureModule as ɵNgxsFeatureModule, NgxsRootModule as ɵNgxsRootModule, type ɵSelectorDef, type ɵSelectorFunc, type ɵSelectorReturnType, type ɵStateSelector };
741
+ 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, withNgxsPlugin, withNgxsPreboot, NgxsFeatureModule as ɵNgxsFeatureModule, NgxsRootModule as ɵNgxsRootModule, type ɵSelectorDef, type ɵSelectorFunc, type ɵSelectorReturnType, type ɵStateSelector };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ngxs/store",
3
- "version": "3.8.2-dev.master-67d50ea",
3
+ "version": "3.8.2-dev.master-728bfff",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {