@ngxs/store 3.7.4-dev.master-a63a5af → 3.7.4-dev.master-2826e05

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 (43) hide show
  1. package/bundles/ngxs-store-internals.umd.js +0 -241
  2. package/bundles/ngxs-store-internals.umd.js.map +1 -1
  3. package/bundles/ngxs-store-internals.umd.min.js +1 -1
  4. package/bundles/ngxs-store-internals.umd.min.js.map +1 -1
  5. package/bundles/ngxs-store.umd.js +25 -100
  6. package/bundles/ngxs-store.umd.js.map +1 -1
  7. package/bundles/ngxs-store.umd.min.js +1 -1
  8. package/bundles/ngxs-store.umd.min.js.map +1 -1
  9. package/esm2015/internals/index.js +1 -2
  10. package/esm2015/internals/ngxs-store-internals.js +2 -2
  11. package/esm2015/ngxs-store.js +5 -4
  12. package/esm2015/src/decorators/select/select-factory.js +2 -6
  13. package/esm2015/src/decorators/select/select.js +11 -39
  14. package/esm2015/src/decorators/select/symbols.js +11 -55
  15. package/esm2015/src/module.js +3 -1
  16. package/esm2015/src/modules/ngxs-root.module.js +5 -8
  17. package/esm5/internals/index.js +1 -2
  18. package/esm5/internals/ngxs-store-internals.js +2 -2
  19. package/esm5/ngxs-store.js +5 -4
  20. package/esm5/src/decorators/select/select-factory.js +2 -6
  21. package/esm5/src/decorators/select/select.js +5 -40
  22. package/esm5/src/decorators/select/symbols.js +11 -55
  23. package/esm5/src/module.js +3 -1
  24. package/esm5/src/modules/ngxs-root.module.js +4 -7
  25. package/fesm2015/ngxs-store-internals.js +2 -240
  26. package/fesm2015/ngxs-store-internals.js.map +1 -1
  27. package/fesm2015/ngxs-store.js +27 -96
  28. package/fesm2015/ngxs-store.js.map +1 -1
  29. package/fesm5/ngxs-store-internals.js +2 -240
  30. package/fesm5/ngxs-store-internals.js.map +1 -1
  31. package/fesm5/ngxs-store.js +20 -96
  32. package/fesm5/ngxs-store.js.map +1 -1
  33. package/internals/index.d.ts +0 -1
  34. package/internals/ngxs-store-internals.metadata.json +1 -1
  35. package/ngxs-store.d.ts +5 -4
  36. package/ngxs-store.metadata.json +1 -1
  37. package/package.json +1 -1
  38. package/src/decorators/select/select.d.ts +1 -0
  39. package/src/decorators/select/symbols.d.ts +2 -6
  40. package/src/modules/ngxs-root.module.d.ts +2 -2
  41. package/esm2015/internals/decorator-injector-adapter.js +0 -242
  42. package/esm5/internals/decorator-injector-adapter.js +0 -242
  43. package/internals/decorator-injector-adapter.d.ts +0 -15
@@ -1,5 +1,5 @@
1
1
  import { NgZone, Injectable, Inject, PLATFORM_ID, defineInjectable, inject, InjectionToken, INJECTOR, ɵglobal, Optional, SkipSelf, ErrorHandler, Injector, ɵivyEnabled, NgModule, APP_BOOTSTRAP_LISTENER } from '@angular/core';
2
- import { isAngularInTestMode, memoize, INITIAL_STATE_TOKEN, NgxsBootstrapper, NGXS_STATE_CONTEXT_FACTORY, NGXS_STATE_FACTORY, InitialState, ensureInjectorNotifierIsCaptured, localInject, ensureLocalInjectorCaptured } from '@ngxs/store/internals';
2
+ import { isAngularInTestMode, memoize, INITIAL_STATE_TOKEN, NgxsBootstrapper, NGXS_STATE_CONTEXT_FACTORY, NGXS_STATE_FACTORY, InitialState } from '@ngxs/store/internals';
3
3
  import { isPlatformServer } from '@angular/common';
4
4
  import { Observable, Subject, BehaviorSubject, of, forkJoin, throwError, EMPTY, from } from 'rxjs';
5
5
  import { filter, map, shareReplay, take, exhaustMap, mergeMap, defaultIfEmpty, catchError, takeUntil, tap, publishReplay, refCount, distinctUntilChanged } from 'rxjs/operators';
@@ -3290,14 +3290,13 @@ class SelectFactory {
3290
3290
  SelectFactory.store = null;
3291
3291
  SelectFactory.config = null;
3292
3292
  SelectFactory.decorators = [
3293
- { type: Injectable, args: [{ providedIn: 'root' },] }
3293
+ { type: Injectable }
3294
3294
  ];
3295
3295
  /** @nocollapse */
3296
3296
  SelectFactory.ctorParameters = () => [
3297
3297
  { type: Store },
3298
3298
  { type: NgxsConfig }
3299
3299
  ];
3300
- /** @nocollapse */ SelectFactory.ngInjectableDef = defineInjectable({ factory: function SelectFactory_Factory() { return new SelectFactory(inject(Store), inject(NgxsConfig)); }, token: SelectFactory, providedIn: "root" });
3301
3300
  if (false) {
3302
3301
  /** @type {?} */
3303
3302
  SelectFactory.store;
@@ -3357,14 +3356,11 @@ class NgxsRootModule {
3357
3356
  * @param {?} factory
3358
3357
  * @param {?} internalStateOperations
3359
3358
  * @param {?} _store
3360
- * @param {?} injector
3359
+ * @param {?} _select
3361
3360
  * @param {?=} states
3362
3361
  * @param {?=} lifecycleStateManager
3363
3362
  */
3364
- constructor(factory, internalStateOperations, _store, injector, states = [], lifecycleStateManager) {
3365
- // If the user is running View Engine then we create the `SelectFactory` instance,
3366
- // otherwise it'll be tree-shaken away in Ivy.
3367
- !ɵivyEnabled && injector.get(SelectFactory);
3363
+ constructor(factory, internalStateOperations, _store, _select, states = [], lifecycleStateManager) {
3368
3364
  // Add stores to the state graph and return their defaults
3369
3365
  /** @type {?} */
3370
3366
  const results = factory.addAndReturnDefaults(states);
@@ -3383,7 +3379,7 @@ NgxsRootModule.ctorParameters = () => [
3383
3379
  { type: StateFactory },
3384
3380
  { type: InternalStateOperations },
3385
3381
  { type: Store },
3386
- { type: Injector },
3382
+ { type: SelectFactory },
3387
3383
  { type: Array, decorators: [{ type: Optional }, { type: Inject, args: [ROOT_STATE_TOKEN,] }] },
3388
3384
  { type: LifecycleStateManager }
3389
3385
  ];
@@ -3474,6 +3470,7 @@ class NgxsModule {
3474
3470
  InternalNgxsExecutionStrategy,
3475
3471
  Store,
3476
3472
  StateStream,
3473
+ SelectFactory,
3477
3474
  PluginManager,
3478
3475
  ...states,
3479
3476
  ...NgxsModule.ngxsTokenProviders(states, options)
@@ -3713,37 +3710,30 @@ const DOLLAR_CHAR_CODE = 36;
3713
3710
  /**
3714
3711
  * @template T
3715
3712
  * @param {?} selector
3716
- * @param {?} store
3717
3713
  * @return {?}
3718
3714
  */
3719
- function createSelectObservable(selector, store) {
3720
- // We're doing this stuff to tree-shake the `SelectFactory` when the user
3721
- // is running Ivy since NGXS will select the state from the provided `store` argument.
3722
- return ɵivyEnabled
3723
- ? createSelectObservableIvy(selector, store)
3724
- : createSelectObservableViewEngine(selector);
3715
+ function createSelectObservable(selector) {
3716
+ if (!SelectFactory.store) {
3717
+ throwSelectFactoryNotConnectedError();
3718
+ }
3719
+ return (/** @type {?} */ (SelectFactory.store)).select(selector);
3725
3720
  }
3726
3721
  /**
3727
- * @param {?} config
3728
3722
  * @param {?} name
3729
3723
  * @param {?=} rawSelector
3730
3724
  * @param {?=} paths
3731
3725
  * @return {?}
3732
3726
  */
3733
- function createSelectorFn(config, name, rawSelector, paths = []) {
3734
- rawSelector = rawSelector || removeDollarAtTheEnd(name);
3735
- if (typeof rawSelector !== 'string') {
3736
- return rawSelector;
3737
- }
3738
- else {
3727
+ function createSelectorFn(name, rawSelector, paths = []) {
3728
+ rawSelector = !rawSelector ? removeDollarAtTheEnd(name) : rawSelector;
3729
+ if (typeof rawSelector === 'string') {
3739
3730
  /** @type {?} */
3740
3731
  const propsArray = paths.length
3741
3732
  ? [rawSelector, ...paths]
3742
3733
  : rawSelector.split('.');
3743
- return ɵivyEnabled
3744
- ? createSelectorFnIvy(propsArray, config)
3745
- : createSelectorFnViewEngine(propsArray);
3734
+ return propGetter(propsArray, (/** @type {?} */ (SelectFactory.config)));
3746
3735
  }
3736
+ return rawSelector;
3747
3737
  }
3748
3738
  /**
3749
3739
  * \@example If `foo$` => make it just `foo`
@@ -3757,42 +3747,6 @@ function removeDollarAtTheEnd(name) {
3757
3747
  const dollarAtTheEnd = name.charCodeAt(lastCharIndex) === DOLLAR_CHAR_CODE;
3758
3748
  return dollarAtTheEnd ? name.slice(0, lastCharIndex) : name;
3759
3749
  }
3760
- /**
3761
- * @template T
3762
- * @param {?} selector
3763
- * @param {?} store
3764
- * @return {?}
3765
- */
3766
- function createSelectObservableIvy(selector, store) {
3767
- return ngDevMode && !store ? throwSelectFactoryNotConnectedError() : (/** @type {?} */ (store)).select(selector);
3768
- }
3769
- /**
3770
- * @template T
3771
- * @param {?} selector
3772
- * @return {?}
3773
- */
3774
- function createSelectObservableViewEngine(selector) {
3775
- return SelectFactory.store
3776
- ? SelectFactory.store.select(selector)
3777
- : throwSelectFactoryNotConnectedError();
3778
- }
3779
- /**
3780
- * @param {?} propsArray
3781
- * @param {?} config
3782
- * @return {?}
3783
- */
3784
- function createSelectorFnIvy(propsArray, config) {
3785
- return ngDevMode && !config
3786
- ? throwSelectFactoryNotConnectedError()
3787
- : propGetter(propsArray, (/** @type {?} */ (config)));
3788
- }
3789
- /**
3790
- * @param {?} propsArray
3791
- * @return {?}
3792
- */
3793
- function createSelectorFnViewEngine(propsArray) {
3794
- return propGetter(propsArray, (/** @type {?} */ (SelectFactory.config)));
3795
- }
3796
3750
 
3797
3751
  /**
3798
3752
  * @fileoverview added by tsickle
@@ -3800,6 +3754,7 @@ function createSelectorFnViewEngine(propsArray) {
3800
3754
  */
3801
3755
  /**
3802
3756
  * Decorator for selecting a slice of state from the store.
3757
+ * @deprecated
3803
3758
  * @template T
3804
3759
  * @param {?=} rawSelector
3805
3760
  * @param {...?} paths
@@ -3812,17 +3767,19 @@ function Select(rawSelector, ...paths) {
3812
3767
  * @return {?}
3813
3768
  */
3814
3769
  function (target, key) {
3770
+ console.warn(`
3771
+ The @Select decorator has been deprecated due to the following reasons:
3772
+ 1) Lack of type-safety (compare to 'store.select()')
3773
+ 2) Not compatible with server-side rendering because it uses a global 'Store' instance, which might change between renders
3774
+ 3) Not compatible with module federation
3775
+ Consider replacing it the with store.select.
3776
+ `);
3815
3777
  /** @type {?} */
3816
3778
  const name = key.toString();
3817
3779
  /** @type {?} */
3818
3780
  const selectorId = `__${name}__selector`;
3819
3781
  /** @type {?} */
3820
- let selector = null;
3821
- /** @type {?} */
3822
- let injectorNotifier$ = null;
3823
- if (ɵivyEnabled) {
3824
- injectorNotifier$ = ensureInjectorNotifierIsCaptured(target);
3825
- }
3782
+ const selector = createSelectorFn(name, rawSelector, paths);
3826
3783
  Object.defineProperties(target, {
3827
3784
  [selectorId]: {
3828
3785
  writable: true,
@@ -3836,36 +3793,10 @@ function Select(rawSelector, ...paths) {
3836
3793
  * @return {?}
3837
3794
  */
3838
3795
  get() {
3839
- if (this[selectorId]) {
3840
- return this[selectorId];
3841
- }
3842
- // The `localInject` will be tree-shaken away in apps that
3843
- // still use the View Engine.
3844
- if (ɵivyEnabled) {
3845
- this[selectorId] = (/** @type {?} */ (injectorNotifier$)).pipe(mergeMap((/**
3846
- * @return {?}
3847
- */
3848
- () => {
3849
- /** @type {?} */
3850
- const store = localInject(this, Store);
3851
- /** @type {?} */
3852
- const config = localInject(this, NgxsConfig);
3853
- selector = selector || createSelectorFn(config, name, rawSelector, paths);
3854
- return createSelectObservable(selector, store);
3855
- })));
3856
- }
3857
- else {
3858
- selector = selector || createSelectorFn(null, name, rawSelector, paths);
3859
- this[selectorId] = createSelectObservable(selector, null);
3860
- }
3861
- return this[selectorId];
3796
+ return this[selectorId] || (this[selectorId] = createSelectObservable(selector));
3862
3797
  }
3863
3798
  }
3864
3799
  });
3865
- // Keep this `if` guard here so the below stuff will be tree-shaken away in apps that still use the View Engine.
3866
- if (ɵivyEnabled) {
3867
- ensureLocalInjectorCaptured(target);
3868
- }
3869
3800
  });
3870
3801
  }
3871
3802
 
@@ -4086,5 +4017,5 @@ if (false) {
4086
4017
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4087
4018
  */
4088
4019
 
4089
- export { Action, Actions, InitState, NGXS_PLUGINS, NgxsModule, NgxsSimpleChange, NoopNgxsExecutionStrategy, Select, Selector, SelectorOptions, State, StateStream, StateToken, Store, UpdateState, actionMatcher, createSelector, ensureSelectorMetadata$1 as ensureSelectorMetadata, ensureStoreMetadata$1 as ensureStoreMetadata, getActionTypeFromInstance, getSelectorMetadata$1 as getSelectorMetadata, getStoreMetadata$1 as getStoreMetadata, getValue, ofAction, ofActionCanceled, ofActionCompleted, ofActionDispatched, ofActionErrored, ofActionSuccessful, setValue, OrderedSubject as ɵa, InternalActions as ɵb, ROOT_STATE_TOKEN as ɵc, FEATURE_STATE_TOKEN as ɵd, SELECTOR_META_KEY as ɵe, NgxsConfig as ɵf, mergeDeep as ɵg, USER_PROVIDED_NGXS_EXECUTION_STRATEGY as ɵh, NGXS_EXECUTION_STRATEGY as ɵi, NgxsRootModule as ɵj, StateFactory as ɵk, InternalDispatchedActionResults as ɵl, InternalDispatcher as ɵm, StateContextFactory as ɵn, InternalStateOperations as ɵo, PluginManager as ɵp, InternalNgxsExecutionStrategy as ɵq, ensureStoreMetadata as ɵs, getStoreMetadata as ɵt, ensureSelectorMetadata as ɵu, getSelectorMetadata as ɵv, LifecycleStateManager as ɵw, NgxsFeatureModule as ɵx };
4020
+ export { Action, Actions, InitState, NGXS_PLUGINS, NgxsModule, NgxsSimpleChange, NoopNgxsExecutionStrategy, Select, Selector, SelectorOptions, State, StateStream, StateToken, Store, UpdateState, actionMatcher, createSelector, ensureSelectorMetadata$1 as ensureSelectorMetadata, ensureStoreMetadata$1 as ensureStoreMetadata, getActionTypeFromInstance, getSelectorMetadata$1 as getSelectorMetadata, getStoreMetadata$1 as getStoreMetadata, getValue, ofAction, ofActionCanceled, ofActionCompleted, ofActionDispatched, ofActionErrored, ofActionSuccessful, setValue, OrderedSubject as ɵa, InternalActions as ɵb, ROOT_STATE_TOKEN as ɵc, FEATURE_STATE_TOKEN as ɵd, SELECTOR_META_KEY as ɵe, NgxsConfig as ɵf, mergeDeep as ɵg, USER_PROVIDED_NGXS_EXECUTION_STRATEGY as ɵh, NGXS_EXECUTION_STRATEGY as ɵi, NgxsRootModule as ɵj, StateFactory as ɵk, InternalDispatchedActionResults as ɵl, InternalDispatcher as ɵm, StateContextFactory as ɵn, InternalStateOperations as ɵo, PluginManager as ɵp, InternalNgxsExecutionStrategy as ɵq, SelectFactory as ɵr, ensureStoreMetadata as ɵt, getStoreMetadata as ɵu, ensureSelectorMetadata as ɵv, getSelectorMetadata as ɵw, LifecycleStateManager as ɵx, NgxsFeatureModule as ɵy };
4090
4021
  //# sourceMappingURL=ngxs-store.js.map