@rs-x/state-manager 0.4.22 → 1.0.2

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/dist/index.js CHANGED
@@ -61,8 +61,8 @@ var AbstractObserver = class {
61
61
  };
62
62
 
63
63
  // lib/grouped-change-subscriptions-for-context-manager.ts
64
- import { SingletonFactoryWithGuid } from "@rs-x/core";
65
- var GroupedChangeSubscriptionsForContextManager = class extends SingletonFactoryWithGuid {
64
+ import { GuidKeyedInstanceFactory } from "@rs-x/core";
65
+ var GroupedChangeSubscriptionsForContextManager = class extends GuidKeyedInstanceFactory {
66
66
  static {
67
67
  __name(this, "GroupedChangeSubscriptionsForContextManager");
68
68
  }
@@ -317,7 +317,6 @@ var RsXStateManagerInjectionTokens = {
317
317
  IMapProxyFactory: Symbol("IMapProxyFactory"),
318
318
  ISetProxyFactory: Symbol("ISetProxyFactory"),
319
319
  IDateProxyFactory: Symbol("IDateProxyFactory"),
320
- IProxyRegistry: Symbol("IProxyRegistry"),
321
320
  IPromiseProxyFactory: Symbol("IPromiseProxyFactory"),
322
321
  IObservableProxyFactory: Symbol("IObservableProxyFactory"),
323
322
  IObjectPropertyObserverProxyPairManager: Symbol("IObjectPropertyObserverProxyPairManager"),
@@ -747,7 +746,7 @@ ObjectObserverProxyPairFactoryProvider = _ts_decorate8([
747
746
  ], ObjectObserverProxyPairFactoryProvider);
748
747
 
749
748
  // lib/object-observer/object-observer-proxy-pair-manager.ts
750
- import { Inject as Inject8, Injectable as Injectable9, InvalidOperationException, RsXCoreInjectionTokens as RsXCoreInjectionTokens5, SingletonFactoryWithGuid as SingletonFactoryWithGuid2, Type as Type4 } from "@rs-x/core";
749
+ import { GuidKeyedInstanceFactory as GuidKeyedInstanceFactory2, Inject as Inject8, Injectable as Injectable9, InvalidOperationException, RsXCoreInjectionTokens as RsXCoreInjectionTokens5, Type as Type4 } from "@rs-x/core";
751
750
  function _ts_decorate9(decorators, target, key, desc) {
752
751
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
753
752
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -765,7 +764,7 @@ function _ts_param9(paramIndex, decorator) {
765
764
  };
766
765
  }
767
766
  __name(_ts_param9, "_ts_param");
768
- var ObjectObserverProxyPairManager = class extends SingletonFactoryWithGuid2 {
767
+ var ObjectObserverProxyPairManager = class extends GuidKeyedInstanceFactory2 {
769
768
  static {
770
769
  __name(this, "ObjectObserverProxyPairManager");
771
770
  }
@@ -800,7 +799,7 @@ var ObjectObserverProxyPairManager = class extends SingletonFactoryWithGuid2 {
800
799
  ObjectObserverProxyPairManager = _ts_decorate9([
801
800
  Injectable9(),
802
801
  _ts_param9(0, Inject8(RsXStateManagerInjectionTokens.IObjectObserverProxyPairFactoryProviderFactory)),
803
- _ts_param9(1, Inject8(RsXStateManagerInjectionTokens.IProxyRegistry)),
802
+ _ts_param9(1, Inject8(RsXCoreInjectionTokens5.IProxyRegistry)),
804
803
  _ts_param9(2, Inject8(RsXCoreInjectionTokens5.IGuidFactory)),
805
804
  _ts_metadata9("design:type", Function),
806
805
  _ts_metadata9("design:paramtypes", [
@@ -811,7 +810,7 @@ ObjectObserverProxyPairManager = _ts_decorate9([
811
810
  ], ObjectObserverProxyPairManager);
812
811
 
813
812
  // lib/object-property-observer-proxy-pair-manager.ts
814
- import { Inject as Inject9, Injectable as Injectable10, MultiInject as MultiInject2, RsXCoreInjectionTokens as RsXCoreInjectionTokens6, SingletonFactory, SingletonFactoryWithGuid as SingletonFactoryWithGuid3, Type as Type5, UnsupportedException } from "@rs-x/core";
813
+ import { GuidKeyedInstanceFactory as GuidKeyedInstanceFactory3, Inject as Inject9, Injectable as Injectable10, KeyedInstanceFactory, MultiInject as MultiInject2, RsXCoreInjectionTokens as RsXCoreInjectionTokens6, Type as Type5, UnsupportedException } from "@rs-x/core";
815
814
  function _ts_decorate10(decorators, target, key, desc) {
816
815
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
817
816
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -829,7 +828,7 @@ function _ts_param10(paramIndex, decorator) {
829
828
  };
830
829
  }
831
830
  __name(_ts_param10, "_ts_param");
832
- var PropertyObserverProxyPairManager = class PropertyObserverProxyPairManager2 extends SingletonFactoryWithGuid3 {
831
+ var PropertyObserverProxyPairManager = class PropertyObserverProxyPairManager2 extends GuidKeyedInstanceFactory3 {
833
832
  static {
834
833
  __name(this, "PropertyObserverProxyPairManager");
835
834
  }
@@ -868,7 +867,7 @@ var PropertyObserverProxyPairManager = class PropertyObserverProxyPairManager2 e
868
867
  return observerFactory;
869
868
  }
870
869
  };
871
- var ObjectPropertyObserverProxyPairManager = class extends SingletonFactory {
870
+ var ObjectPropertyObserverProxyPairManager = class extends KeyedInstanceFactory {
872
871
  static {
873
872
  __name(this, "ObjectPropertyObserverProxyPairManager");
874
873
  }
@@ -899,7 +898,7 @@ ObjectPropertyObserverProxyPairManager = _ts_decorate10([
899
898
  ], ObjectPropertyObserverProxyPairManager);
900
899
 
901
900
  // lib/property-observer/factories/collection-item/collection-item-observer-manager.ts
902
- import { Inject as Inject10, Injectable as Injectable11, RsXCoreInjectionTokens as RsXCoreInjectionTokens7, SingletonFactory as SingletonFactory2 } from "@rs-x/core";
901
+ import { Inject as Inject10, Injectable as Injectable11, KeyedInstanceFactory as KeyedInstanceFactory2, RsXCoreInjectionTokens as RsXCoreInjectionTokens7 } from "@rs-x/core";
903
902
  function _ts_decorate11(decorators, target, key, desc) {
904
903
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
905
904
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -961,7 +960,7 @@ var CollectionIndexObserver = class CollectionIndexObserver2 extends AbstractObs
961
960
  }
962
961
  }, "onChanged");
963
962
  };
964
- var CollectionIndexObserverManager = class CollectionIndexObserverManager2 extends SingletonFactory2 {
963
+ var CollectionIndexObserverManager = class CollectionIndexObserverManager2 extends KeyedInstanceFactory2 {
965
964
  static {
966
965
  __name(this, "CollectionIndexObserverManager");
967
966
  }
@@ -993,7 +992,7 @@ var CollectionIndexObserverManager = class CollectionIndexObserverManager2 exten
993
992
  this.releaseObject();
994
993
  }
995
994
  };
996
- var CollectionItemObserverManager = class extends SingletonFactory2 {
995
+ var CollectionItemObserverManager = class extends KeyedInstanceFactory2 {
997
996
  static {
998
997
  __name(this, "CollectionItemObserverManager");
999
998
  }
@@ -1039,7 +1038,7 @@ import { Inject as Inject11, Injectable as Injectable12, RsXCoreInjectionTokens
1039
1038
  import { Type as Type6, UnexpectedException } from "@rs-x/core";
1040
1039
 
1041
1040
  // lib/property-observer/factories/indexed-value-observer-proxy-pair/index-change-subscription-manager.ts
1042
- import { SingletonFactory as SingletonFactory3 } from "@rs-x/core";
1041
+ import { KeyedInstanceFactory as KeyedInstanceFactory3 } from "@rs-x/core";
1043
1042
  var IndexChangeSubscriptionsForContextManager = class IndexChangeSubscriptionsForContextManager2 extends GroupedChangeSubscriptionsForContextManager {
1044
1043
  static {
1045
1044
  __name(this, "IndexChangeSubscriptionsForContextManager");
@@ -1081,7 +1080,7 @@ var IndexChangeSubscriptionsForContextManager = class IndexChangeSubscriptionsFo
1081
1080
  return observer;
1082
1081
  }
1083
1082
  };
1084
- var IndexChangeSubscriptionManager = class extends SingletonFactory3 {
1083
+ var IndexChangeSubscriptionManager = class extends KeyedInstanceFactory3 {
1085
1084
  static {
1086
1085
  __name(this, "IndexChangeSubscriptionManager");
1087
1086
  }
@@ -1240,7 +1239,7 @@ CollectionItemObserverProxyPairFactory = _ts_decorate12([
1240
1239
  _ts_param12(2, Inject11(RsXCoreInjectionTokens8.IErrorLog)),
1241
1240
  _ts_param12(3, Inject11(RsXCoreInjectionTokens8.IGuidFactory)),
1242
1241
  _ts_param12(4, Inject11(RsXCoreInjectionTokens8.IIndexValueAccessor)),
1243
- _ts_param12(5, Inject11(RsXStateManagerInjectionTokens.IProxyRegistry)),
1242
+ _ts_param12(5, Inject11(RsXCoreInjectionTokens8.IProxyRegistry)),
1244
1243
  _ts_param12(6, Inject11(RsXCoreInjectionTokens8.IValueMetadata)),
1245
1244
  _ts_metadata12("design:type", Function),
1246
1245
  _ts_metadata12("design:paramtypes", [
@@ -1255,7 +1254,7 @@ CollectionItemObserverProxyPairFactory = _ts_decorate12([
1255
1254
  ], CollectionItemObserverProxyPairFactory);
1256
1255
 
1257
1256
  // lib/property-observer/factories/date-property/data-property-observer-manager.ts
1258
- import { Inject as Inject12, Injectable as Injectable13, RsXCoreInjectionTokens as RsXCoreInjectionTokens9, SingletonFactory as SingletonFactory4 } from "@rs-x/core";
1257
+ import { Inject as Inject12, Injectable as Injectable13, KeyedInstanceFactory as KeyedInstanceFactory4, RsXCoreInjectionTokens as RsXCoreInjectionTokens9 } from "@rs-x/core";
1259
1258
  function _ts_decorate13(decorators, target, key, desc) {
1260
1259
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1261
1260
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -1306,7 +1305,7 @@ var DatePropertyObserver = class DatePropertyObserver2 extends AbstractObserver
1306
1305
  this._oldValue = change.newValue;
1307
1306
  }, "onDateChanged");
1308
1307
  };
1309
- var ProperForDataObserverManager = class ProperForDataObserverManager2 extends SingletonFactory4 {
1308
+ var ProperForDataObserverManager = class ProperForDataObserverManager2 extends KeyedInstanceFactory4 {
1310
1309
  static {
1311
1310
  __name(this, "ProperForDataObserverManager");
1312
1311
  }
@@ -1343,7 +1342,7 @@ var ProperForDataObserverManager = class ProperForDataObserverManager2 extends S
1343
1342
  this.releaseObject();
1344
1343
  }
1345
1344
  };
1346
- var DatePropertyObserverManager = class extends SingletonFactory4 {
1345
+ var DatePropertyObserverManager = class extends KeyedInstanceFactory4 {
1347
1346
  static {
1348
1347
  __name(this, "DatePropertyObserverManager");
1349
1348
  }
@@ -1416,7 +1415,7 @@ DatePropertyObserverProxyPairFactory = _ts_decorate14([
1416
1415
  _ts_param14(2, Inject13(RsXCoreInjectionTokens10.IErrorLog)),
1417
1416
  _ts_param14(3, Inject13(RsXCoreInjectionTokens10.IGuidFactory)),
1418
1417
  _ts_param14(4, Inject13(RsXCoreInjectionTokens10.IIndexValueAccessor)),
1419
- _ts_param14(5, Inject13(RsXStateManagerInjectionTokens.IProxyRegistry)),
1418
+ _ts_param14(5, Inject13(RsXCoreInjectionTokens10.IProxyRegistry)),
1420
1419
  _ts_param14(6, Inject13(RsXCoreInjectionTokens10.IValueMetadata)),
1421
1420
  _ts_metadata14("design:type", Function),
1422
1421
  _ts_metadata14("design:paramtypes", [
@@ -1470,7 +1469,7 @@ NonIterableObjectPropertyObserverProxyPairFactory = _ts_decorate15([
1470
1469
  _ts_param15(2, Inject14(RsXCoreInjectionTokens11.IErrorLog)),
1471
1470
  _ts_param15(3, Inject14(RsXCoreInjectionTokens11.IGuidFactory)),
1472
1471
  _ts_param15(4, Inject14(RsXCoreInjectionTokens11.IIndexValueAccessor)),
1473
- _ts_param15(5, Inject14(RsXStateManagerInjectionTokens.IProxyRegistry)),
1472
+ _ts_param15(5, Inject14(RsXCoreInjectionTokens11.IProxyRegistry)),
1474
1473
  _ts_param15(6, Inject14(RsXCoreInjectionTokens11.IValueMetadata)),
1475
1474
  _ts_metadata15("design:type", Function),
1476
1475
  _ts_metadata15("design:paramtypes", [
@@ -1486,7 +1485,7 @@ NonIterableObjectPropertyObserverProxyPairFactory = _ts_decorate15([
1486
1485
 
1487
1486
  // lib/property-observer/factories/non-iterable-object-property/object-property-observer-manager.ts
1488
1487
  import { Subject as Subject2 } from "rxjs";
1489
- import { Inject as Inject15, Injectable as Injectable16, InvalidOperationException as InvalidOperationException2, PropertyDescriptorType, SingletonFactory as SingletonFactory5, Type as Type8 } from "@rs-x/core";
1488
+ import { Inject as Inject15, Injectable as Injectable16, InvalidOperationException as InvalidOperationException2, KeyedInstanceFactory as KeyedInstanceFactory5, PropertyDescriptorType, RsXCoreInjectionTokens as RsXCoreInjectionTokens12, Type as Type8 } from "@rs-x/core";
1490
1489
  function _ts_decorate16(decorators, target, key, desc) {
1491
1490
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1492
1491
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -1618,7 +1617,7 @@ var PropertObserver = class PropertObserver2 extends AbstractObserver {
1618
1617
  return newDescriptor;
1619
1618
  }
1620
1619
  };
1621
- var PropertyObserverManager = class PropertyObserverManager2 extends SingletonFactory5 {
1620
+ var PropertyObserverManager = class PropertyObserverManager2 extends KeyedInstanceFactory5 {
1622
1621
  static {
1623
1622
  __name(this, "PropertyObserverManager");
1624
1623
  }
@@ -1647,7 +1646,7 @@ var PropertyObserverManager = class PropertyObserverManager2 extends SingletonFa
1647
1646
  observer.dispose();
1648
1647
  }
1649
1648
  };
1650
- var ObjectPropertyObserverManager = class extends SingletonFactory5 {
1649
+ var ObjectPropertyObserverManager = class extends KeyedInstanceFactory5 {
1651
1650
  static {
1652
1651
  __name(this, "ObjectPropertyObserverManager");
1653
1652
  }
@@ -1670,7 +1669,7 @@ var ObjectPropertyObserverManager = class extends SingletonFactory5 {
1670
1669
  };
1671
1670
  ObjectPropertyObserverManager = _ts_decorate16([
1672
1671
  Injectable16(),
1673
- _ts_param16(0, Inject15(RsXStateManagerInjectionTokens.IProxyRegistry)),
1672
+ _ts_param16(0, Inject15(RsXCoreInjectionTokens12.IProxyRegistry)),
1674
1673
  _ts_metadata16("design:type", Function),
1675
1674
  _ts_metadata16("design:paramtypes", [
1676
1675
  typeof IProxyRegistry === "undefined" ? Object : IProxyRegistry
@@ -1679,7 +1678,7 @@ ObjectPropertyObserverManager = _ts_decorate16([
1679
1678
 
1680
1679
  // lib/proxies/array-proxy/array-proxy.factory.ts
1681
1680
  import { Subject as Subject3 } from "rxjs";
1682
- import { Inject as Inject16, Injectable as Injectable17, SingletonFactory as SingletonFactory6, Type as Type9 } from "@rs-x/core";
1681
+ import { Inject as Inject16, Injectable as Injectable17, KeyedInstanceFactory as KeyedInstanceFactory6, RsXCoreInjectionTokens as RsXCoreInjectionTokens13, Type as Type9 } from "@rs-x/core";
1683
1682
  function _ts_decorate17(decorators, target, key, desc) {
1684
1683
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1685
1684
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -1834,7 +1833,7 @@ var ArrayProxy = class ArrayProxy2 extends AbstractObserver {
1834
1833
  }
1835
1834
  }
1836
1835
  };
1837
- var ArrayProxyFactory = class extends SingletonFactory6 {
1836
+ var ArrayProxyFactory = class extends KeyedInstanceFactory6 {
1838
1837
  static {
1839
1838
  __name(this, "ArrayProxyFactory");
1840
1839
  }
@@ -1869,7 +1868,7 @@ var ArrayProxyFactory = class extends SingletonFactory6 {
1869
1868
  };
1870
1869
  ArrayProxyFactory = _ts_decorate17([
1871
1870
  Injectable17(),
1872
- _ts_param17(0, Inject16(RsXStateManagerInjectionTokens.IProxyRegistry)),
1871
+ _ts_param17(0, Inject16(RsXCoreInjectionTokens13.IProxyRegistry)),
1873
1872
  _ts_metadata17("design:type", Function),
1874
1873
  _ts_metadata17("design:paramtypes", [
1875
1874
  typeof IProxyRegistry === "undefined" ? Object : IProxyRegistry
@@ -1878,7 +1877,7 @@ ArrayProxyFactory = _ts_decorate17([
1878
1877
 
1879
1878
  // lib/proxies/date-proxy/date-proxy.factory.ts
1880
1879
  import { Subject as Subject4 } from "rxjs";
1881
- import { Inject as Inject17, Injectable as Injectable18, RsXCoreInjectionTokens as RsXCoreInjectionTokens12, SingletonFactoryWithGuid as SingletonFactoryWithGuid4, Type as Type10 } from "@rs-x/core";
1880
+ import { GuidKeyedInstanceFactory as GuidKeyedInstanceFactory4, Inject as Inject17, Injectable as Injectable18, RsXCoreInjectionTokens as RsXCoreInjectionTokens14, Type as Type10 } from "@rs-x/core";
1882
1881
  function _ts_decorate18(decorators, target, key, desc) {
1883
1882
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1884
1883
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -2113,7 +2112,7 @@ var DateProxy = class DateProxy2 extends AbstractObserver {
2113
2112
  this.target = Type10.cast(void 0);
2114
2113
  }
2115
2114
  };
2116
- var DateProxyFactory = class extends SingletonFactoryWithGuid4 {
2115
+ var DateProxyFactory = class extends GuidKeyedInstanceFactory4 {
2117
2116
  static {
2118
2117
  __name(this, "DateProxyFactory");
2119
2118
  }
@@ -2144,8 +2143,8 @@ var DateProxyFactory = class extends SingletonFactoryWithGuid4 {
2144
2143
  };
2145
2144
  DateProxyFactory = _ts_decorate18([
2146
2145
  Injectable18(),
2147
- _ts_param18(0, Inject17(RsXCoreInjectionTokens12.IGuidFactory)),
2148
- _ts_param18(1, Inject17(RsXStateManagerInjectionTokens.IProxyRegistry)),
2146
+ _ts_param18(0, Inject17(RsXCoreInjectionTokens14.IGuidFactory)),
2147
+ _ts_param18(1, Inject17(RsXCoreInjectionTokens14.IProxyRegistry)),
2149
2148
  _ts_metadata18("design:type", Function),
2150
2149
  _ts_metadata18("design:paramtypes", [
2151
2150
  typeof IGuidFactory === "undefined" ? Object : IGuidFactory,
@@ -2154,7 +2153,7 @@ DateProxyFactory = _ts_decorate18([
2154
2153
  ], DateProxyFactory);
2155
2154
 
2156
2155
  // lib/proxies/map-proxy/map-proxy.factory.ts
2157
- import { Inject as Inject18, Injectable as Injectable19, SingletonFactory as SingletonFactory7, Type as Type11 } from "@rs-x/core";
2156
+ import { Inject as Inject18, Injectable as Injectable19, KeyedInstanceFactory as KeyedInstanceFactory7, RsXCoreInjectionTokens as RsXCoreInjectionTokens15, Type as Type11 } from "@rs-x/core";
2158
2157
  function _ts_decorate19(decorators, target, key, desc) {
2159
2158
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2160
2159
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -2245,7 +2244,7 @@ var MapProxy = class extends AbstractObserver {
2245
2244
  });
2246
2245
  }
2247
2246
  };
2248
- var MapProxyFactory = class extends SingletonFactory7 {
2247
+ var MapProxyFactory = class extends KeyedInstanceFactory7 {
2249
2248
  static {
2250
2249
  __name(this, "MapProxyFactory");
2251
2250
  }
@@ -2279,7 +2278,7 @@ var MapProxyFactory = class extends SingletonFactory7 {
2279
2278
  };
2280
2279
  MapProxyFactory = _ts_decorate19([
2281
2280
  Injectable19(),
2282
- _ts_param19(0, Inject18(RsXStateManagerInjectionTokens.IProxyRegistry)),
2281
+ _ts_param19(0, Inject18(RsXCoreInjectionTokens15.IProxyRegistry)),
2283
2282
  _ts_metadata19("design:type", Function),
2284
2283
  _ts_metadata19("design:paramtypes", [
2285
2284
  typeof IProxyRegistry === "undefined" ? Object : IProxyRegistry
@@ -2288,7 +2287,7 @@ MapProxyFactory = _ts_decorate19([
2288
2287
 
2289
2288
  // lib/proxies/observable-proxy/observable-proxy.factory.ts
2290
2289
  import { ReplaySubject as ReplaySubject2 } from "rxjs";
2291
- import { Inject as Inject19, Injectable as Injectable20, RsXCoreInjectionTokens as RsXCoreInjectionTokens13, SingletonFactory as SingletonFactory8 } from "@rs-x/core";
2290
+ import { Inject as Inject19, Injectable as Injectable20, KeyedInstanceFactory as KeyedInstanceFactory8, RsXCoreInjectionTokens as RsXCoreInjectionTokens16 } from "@rs-x/core";
2292
2291
  function _ts_decorate20(decorators, target, key, desc) {
2293
2292
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2294
2293
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -2343,7 +2342,7 @@ var ObservableProxy = class ObservableProxy2 extends AbstractObserver {
2343
2342
  });
2344
2343
  }, "emitObservableChange");
2345
2344
  };
2346
- var ObservableProxyFactory = class extends SingletonFactory8 {
2345
+ var ObservableProxyFactory = class extends KeyedInstanceFactory8 {
2347
2346
  static {
2348
2347
  __name(this, "ObservableProxyFactory");
2349
2348
  }
@@ -2377,7 +2376,7 @@ var ObservableProxyFactory = class extends SingletonFactory8 {
2377
2376
  };
2378
2377
  ObservableProxyFactory = _ts_decorate20([
2379
2378
  Injectable20(),
2380
- _ts_param20(0, Inject19(RsXCoreInjectionTokens13.IObservableAccessor)),
2379
+ _ts_param20(0, Inject19(RsXCoreInjectionTokens16.IObservableAccessor)),
2381
2380
  _ts_metadata20("design:type", Function),
2382
2381
  _ts_metadata20("design:paramtypes", [
2383
2382
  typeof IObservableAccessor === "undefined" ? Object : IObservableAccessor
@@ -2386,7 +2385,7 @@ ObservableProxyFactory = _ts_decorate20([
2386
2385
 
2387
2386
  // lib/proxies/promise-proxy/promise-proxy.factory.ts
2388
2387
  import { ReplaySubject as ReplaySubject3 } from "rxjs";
2389
- import { Inject as Inject20, Injectable as Injectable21, RsXCoreInjectionTokens as RsXCoreInjectionTokens14, SingletonFactory as SingletonFactory9 } from "@rs-x/core";
2388
+ import { Inject as Inject20, Injectable as Injectable21, KeyedInstanceFactory as KeyedInstanceFactory9, RsXCoreInjectionTokens as RsXCoreInjectionTokens17 } from "@rs-x/core";
2390
2389
  function _ts_decorate21(decorators, target, key, desc) {
2391
2390
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2392
2391
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -2429,7 +2428,7 @@ var PromiseObserver = class PromiseObserver2 extends AbstractObserver {
2429
2428
  });
2430
2429
  }, "onValueResolved");
2431
2430
  };
2432
- var PromiseProxyFactory = class extends SingletonFactory9 {
2431
+ var PromiseProxyFactory = class extends KeyedInstanceFactory9 {
2433
2432
  static {
2434
2433
  __name(this, "PromiseProxyFactory");
2435
2434
  }
@@ -2463,15 +2462,15 @@ var PromiseProxyFactory = class extends SingletonFactory9 {
2463
2462
  };
2464
2463
  PromiseProxyFactory = _ts_decorate21([
2465
2464
  Injectable21(),
2466
- _ts_param21(0, Inject20(RsXCoreInjectionTokens14.IPromiseAccessor)),
2465
+ _ts_param21(0, Inject20(RsXCoreInjectionTokens17.IPromiseAccessor)),
2467
2466
  _ts_metadata21("design:type", Function),
2468
2467
  _ts_metadata21("design:paramtypes", [
2469
2468
  typeof IPromiseAccessor === "undefined" ? Object : IPromiseAccessor
2470
2469
  ])
2471
2470
  ], PromiseProxyFactory);
2472
2471
 
2473
- // lib/proxies/proxy-registry/proxy-registry.ts
2474
- import { Injectable as Injectable22 } from "@rs-x/core";
2472
+ // lib/proxies/set-proxy/set-proxy.factory.ts
2473
+ import { Inject as Inject21, Injectable as Injectable22, KeyedInstanceFactory as KeyedInstanceFactory10, RsXCoreInjectionTokens as RsXCoreInjectionTokens18, Type as Type12 } from "@rs-x/core";
2475
2474
  function _ts_decorate22(decorators, target, key, desc) {
2476
2475
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2477
2476
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -2479,40 +2478,6 @@ function _ts_decorate22(decorators, target, key, desc) {
2479
2478
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2480
2479
  }
2481
2480
  __name(_ts_decorate22, "_ts_decorate");
2482
- var ProxyRegistry = class {
2483
- static {
2484
- __name(this, "ProxyRegistry");
2485
- }
2486
- _proxies = /* @__PURE__ */ new Map();
2487
- getProxyTarget(proxyToFind) {
2488
- return Array.from(this._proxies.entries()).find(([_, proxy]) => proxy === proxyToFind)?.[0];
2489
- }
2490
- getProxy(proxyTarget) {
2491
- return this._proxies.get(proxyTarget);
2492
- }
2493
- register(proxyTarget, proxy) {
2494
- this._proxies.set(proxyTarget, proxy);
2495
- }
2496
- unregister(proxyTarget) {
2497
- this._proxies.delete(proxyTarget);
2498
- }
2499
- isProxy(object) {
2500
- return !!this.getProxyTarget(object);
2501
- }
2502
- };
2503
- ProxyRegistry = _ts_decorate22([
2504
- Injectable22()
2505
- ], ProxyRegistry);
2506
-
2507
- // lib/proxies/set-proxy/set-proxy.factory.ts
2508
- import { Inject as Inject21, Injectable as Injectable23, SingletonFactory as SingletonFactory10, Type as Type12 } from "@rs-x/core";
2509
- function _ts_decorate23(decorators, target, key, desc) {
2510
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2511
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
2512
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2513
- return c > 3 && r && Object.defineProperty(target, key, r), r;
2514
- }
2515
- __name(_ts_decorate23, "_ts_decorate");
2516
2481
  function _ts_metadata22(k, v) {
2517
2482
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
2518
2483
  }
@@ -2584,7 +2549,7 @@ var SetProxy = class extends AbstractObserver {
2584
2549
  });
2585
2550
  }
2586
2551
  };
2587
- var SetProxyFactory = class extends SingletonFactory10 {
2552
+ var SetProxyFactory = class extends KeyedInstanceFactory10 {
2588
2553
  static {
2589
2554
  __name(this, "SetProxyFactory");
2590
2555
  }
@@ -2616,9 +2581,9 @@ var SetProxyFactory = class extends SingletonFactory10 {
2616
2581
  setObserverWithProxy.observer.dispose();
2617
2582
  }
2618
2583
  };
2619
- SetProxyFactory = _ts_decorate23([
2620
- Injectable23(),
2621
- _ts_param22(0, Inject21(RsXStateManagerInjectionTokens.IProxyRegistry)),
2584
+ SetProxyFactory = _ts_decorate22([
2585
+ Injectable22(),
2586
+ _ts_param22(0, Inject21(RsXCoreInjectionTokens18.IProxyRegistry)),
2622
2587
  _ts_metadata22("design:type", Function),
2623
2588
  _ts_metadata22("design:paramtypes", [
2624
2589
  typeof IProxyRegistry === "undefined" ? Object : IProxyRegistry
@@ -2629,14 +2594,14 @@ SetProxyFactory = _ts_decorate23([
2629
2594
  import { ContainerModule, InjectionContainer, registerMultiInjectServices, RsXCoreModule } from "@rs-x/core";
2630
2595
 
2631
2596
  // lib/state-manager/object-state-manager.ts
2632
- import { Inject as Inject22, Injectable as Injectable24, RsXCoreInjectionTokens as RsXCoreInjectionTokens15, SingletonFactory as SingletonFactory11, UnsupportedException as UnsupportedException2 } from "@rs-x/core";
2633
- function _ts_decorate24(decorators, target, key, desc) {
2597
+ import { Inject as Inject22, Injectable as Injectable23, KeyedInstanceFactory as KeyedInstanceFactory11, RsXCoreInjectionTokens as RsXCoreInjectionTokens19, UnsupportedException as UnsupportedException2 } from "@rs-x/core";
2598
+ function _ts_decorate23(decorators, target, key, desc) {
2634
2599
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2635
2600
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
2636
2601
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2637
2602
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2638
2603
  }
2639
- __name(_ts_decorate24, "_ts_decorate");
2604
+ __name(_ts_decorate23, "_ts_decorate");
2640
2605
  function _ts_metadata23(k, v) {
2641
2606
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
2642
2607
  }
@@ -2647,7 +2612,7 @@ function _ts_param23(paramIndex, decorator) {
2647
2612
  };
2648
2613
  }
2649
2614
  __name(_ts_param23, "_ts_param");
2650
- var StateForObjectManager = class extends SingletonFactory11 {
2615
+ var StateForObjectManager = class extends KeyedInstanceFactory11 {
2651
2616
  static {
2652
2617
  __name(this, "StateForObjectManager");
2653
2618
  }
@@ -2664,6 +2629,8 @@ var StateForObjectManager = class extends SingletonFactory11 {
2664
2629
  if (state) {
2665
2630
  state.valueCopy = this.deepClone(key, value);
2666
2631
  state.value = value;
2632
+ state.watched = watched;
2633
+ state.ownerId = ownerId;
2667
2634
  } else {
2668
2635
  this.create({
2669
2636
  key,
@@ -2677,6 +2644,9 @@ var StateForObjectManager = class extends SingletonFactory11 {
2677
2644
  return data.key;
2678
2645
  }
2679
2646
  deepClone(key, data) {
2647
+ if (data === null || typeof data !== "object" && typeof data !== "function") {
2648
+ return data;
2649
+ }
2680
2650
  try {
2681
2651
  return this._deepClone.clone(data);
2682
2652
  } catch (e) {
@@ -2695,7 +2665,7 @@ var StateForObjectManager = class extends SingletonFactory11 {
2695
2665
  this.releaseContext();
2696
2666
  }
2697
2667
  };
2698
- var ObjectStateManager = class extends SingletonFactory11 {
2668
+ var ObjectStateManager = class extends KeyedInstanceFactory11 {
2699
2669
  static {
2700
2670
  __name(this, "ObjectStateManager");
2701
2671
  }
@@ -2740,9 +2710,9 @@ var ObjectStateManager = class extends SingletonFactory11 {
2740
2710
  return new StateForObjectManager(this._deepClone, () => this.release(context));
2741
2711
  }
2742
2712
  };
2743
- ObjectStateManager = _ts_decorate24([
2744
- Injectable24(),
2745
- _ts_param23(0, Inject22(RsXCoreInjectionTokens15.IDeepClone)),
2713
+ ObjectStateManager = _ts_decorate23([
2714
+ Injectable23(),
2715
+ _ts_param23(0, Inject22(RsXCoreInjectionTokens19.IDeepClone)),
2746
2716
  _ts_metadata23("design:type", Function),
2747
2717
  _ts_metadata23("design:paramtypes", [
2748
2718
  typeof IDeepClone === "undefined" ? Object : IDeepClone
@@ -2751,10 +2721,10 @@ ObjectStateManager = _ts_decorate24([
2751
2721
 
2752
2722
  // lib/state-manager/state-manager.ts
2753
2723
  import { Subject as Subject5 } from "rxjs";
2754
- import { Assertion, Inject as Inject23, Injectable as Injectable25, PENDING, RsXCoreInjectionTokens as RsXCoreInjectionTokens16, truePredicate as truePredicate6 } from "@rs-x/core";
2724
+ import { Assertion, Inject as Inject23, Injectable as Injectable24, PENDING, RsXCoreInjectionTokens as RsXCoreInjectionTokens20, truePredicate as truePredicate6 } from "@rs-x/core";
2755
2725
 
2756
2726
  // lib/state-manager/state-change-subscription-manager/state-change-subsription-manager.ts
2757
- import { SingletonFactory as SingletonFactory12 } from "@rs-x/core";
2727
+ import { KeyedInstanceFactory as KeyedInstanceFactory12 } from "@rs-x/core";
2758
2728
  var StateChangeSubscriptionsForContextManager = class StateChangeSubscriptionsForContextManager2 extends GroupedChangeSubscriptionsForContextManager {
2759
2729
  static {
2760
2730
  __name(this, "StateChangeSubscriptionsForContextManager");
@@ -2785,7 +2755,7 @@ var StateChangeSubscriptionsForContextManager = class StateChangeSubscriptionsFo
2785
2755
  };
2786
2756
  }
2787
2757
  };
2788
- var StateChangeSubscriptionManager = class extends SingletonFactory12 {
2758
+ var StateChangeSubscriptionManager = class extends KeyedInstanceFactory12 {
2789
2759
  static {
2790
2760
  __name(this, "StateChangeSubscriptionManager");
2791
2761
  }
@@ -2821,13 +2791,13 @@ var StateChangeSubscriptionManager = class extends SingletonFactory12 {
2821
2791
  };
2822
2792
 
2823
2793
  // lib/state-manager/state-manager.ts
2824
- function _ts_decorate25(decorators, target, key, desc) {
2794
+ function _ts_decorate24(decorators, target, key, desc) {
2825
2795
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2826
2796
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
2827
2797
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2828
2798
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2829
2799
  }
2830
- __name(_ts_decorate25, "_ts_decorate");
2800
+ __name(_ts_decorate24, "_ts_decorate");
2831
2801
  function _ts_metadata24(k, v) {
2832
2802
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
2833
2803
  }
@@ -2851,6 +2821,8 @@ var StateManager = class {
2851
2821
  _endChangeCycle = new Subject5();
2852
2822
  _stateChangeSubscriptionManager;
2853
2823
  _pending = /* @__PURE__ */ new Map();
2824
+ _stateEventSubscriptionsByContext = /* @__PURE__ */ new Map();
2825
+ _stateEventSubscriptionPool = [];
2854
2826
  constructor(objectObserverManager, _objectStateManager, errorLog, guidFactory, _indexValueAccessor, _equalityService) {
2855
2827
  this._objectStateManager = _objectStateManager;
2856
2828
  this._indexValueAccessor = _indexValueAccessor;
@@ -2895,6 +2867,13 @@ var StateManager = class {
2895
2867
  return this.increaseStateReferenceCount(context, index, true, options?.ownerId);
2896
2868
  }
2897
2869
  }
2870
+ subscribeStateEvents(context, index, listener) {
2871
+ const subscription = this.acquireStateEventSubscription(context, index, listener);
2872
+ this.addStateEventSubscription(context, index, subscription);
2873
+ return () => {
2874
+ this.removeStateEventSubscription(subscription.context, subscription.index, subscription);
2875
+ };
2876
+ }
2898
2877
  releaseState(context, index, indexWatchRule) {
2899
2878
  if (!this._objectStateManager.getFromId(context)?.has(index)) {
2900
2879
  return;
@@ -2904,16 +2883,28 @@ var StateManager = class {
2904
2883
  clear() {
2905
2884
  this._stateChangeSubscriptionManager.dispose();
2906
2885
  this._objectStateManager.dispose();
2886
+ this._stateEventSubscriptionsByContext.clear();
2887
+ this._stateEventSubscriptionPool.length = 0;
2907
2888
  }
2908
2889
  getState(context, index) {
2909
2890
  return this._objectStateManager.getFromId(context)?.getFromId(index)?.value;
2910
2891
  }
2911
2892
  setState(context, index, value, ownerId) {
2912
- this.internalSetState(context, index, value, {
2913
- context,
2914
- value: this.getState(context, index),
2915
- shouldEmitChange: truePredicate6
2916
- }, ownerId);
2893
+ const isExternalSetState = ownerId === void 0;
2894
+ if (isExternalSetState) {
2895
+ this._startChangeCycle.next();
2896
+ }
2897
+ try {
2898
+ this.internalSetState(context, index, value, {
2899
+ context,
2900
+ value: this.getState(context, index),
2901
+ shouldEmitChange: truePredicate6
2902
+ }, ownerId);
2903
+ } finally {
2904
+ if (isExternalSetState) {
2905
+ this._endChangeCycle.next();
2906
+ }
2907
+ }
2917
2908
  }
2918
2909
  internalSetState(context, index, value, transferValue, ownerId) {
2919
2910
  this.tryRebindingNestedState(value, transferValue.value, ownerId);
@@ -2942,16 +2933,25 @@ var StateManager = class {
2942
2933
  }
2943
2934
  }
2944
2935
  emitChange(context, index, newValue, oldValue, oldContext) {
2945
- if (this._equalityService.isEqual(newValue, oldValue)) {
2936
+ if (newValue === oldValue || newValue !== newValue && oldValue !== oldValue) {
2937
+ return;
2938
+ }
2939
+ const newValueIsObjectLike = newValue !== null && (typeof newValue === "object" || typeof newValue === "function");
2940
+ const oldValueIsObjectLike = oldValue !== null && (typeof oldValue === "object" || typeof oldValue === "function");
2941
+ if ((newValueIsObjectLike || oldValueIsObjectLike) && this._equalityService.isEqual(newValue, oldValue)) {
2946
2942
  return;
2947
2943
  }
2948
- this._changed.next({
2944
+ const stateChange = {
2949
2945
  oldContext: oldContext ?? context,
2950
2946
  context,
2951
2947
  index,
2952
2948
  oldValue,
2953
2949
  newValue
2954
- });
2950
+ };
2951
+ this.emitStateChangeEvents(stateChange);
2952
+ if (this.shouldPublish(this._changed)) {
2953
+ this._changed.next(stateChange);
2954
+ }
2955
2955
  }
2956
2956
  updateState(newContext, oldContext, index, newValue, watched, ownerId) {
2957
2957
  this._objectStateManager.replaceState(index, newContext, newValue, oldContext, watched, ownerId);
@@ -2994,57 +2994,80 @@ var StateManager = class {
2994
2994
  if (!oldState) {
2995
2995
  return [];
2996
2996
  }
2997
- return Array.from(oldState.ids()).map((index) => {
2998
- const { value: oldValue, watched, ownerId } = oldState.getFromId(index) ?? {};
2997
+ const stateChanges = [];
2998
+ this.collectStateChanges(oldContext, newContext, parentOwnerId, oldState, stateChanges);
2999
+ return stateChanges;
3000
+ }
3001
+ collectStateChanges(oldContext, newContext, parentOwnerId, oldState, changes) {
3002
+ if (!oldState) {
3003
+ return;
3004
+ }
3005
+ for (const index of oldState.ids()) {
3006
+ const state = oldState.getFromId(index);
3007
+ if (!state) {
3008
+ continue;
3009
+ }
3010
+ const { value: oldValue, watched, ownerId } = state;
2999
3011
  if (ownerId !== parentOwnerId) {
3000
- return [];
3012
+ continue;
3001
3013
  }
3002
3014
  const newValue = this.getValue(newContext, index);
3003
- if (oldContext === newContext && this._equalityService.isEqual(oldValue, newValue)) {
3004
- return [];
3015
+ if (oldContext === newContext) {
3016
+ if (oldValue === newValue || oldValue !== oldValue && newValue !== newValue) {
3017
+ continue;
3018
+ }
3019
+ const newValueIsObjectLike = newValue !== null && (typeof newValue === "object" || typeof newValue === "function");
3020
+ const oldValueIsObjectLike = oldValue !== null && (typeof oldValue === "object" || typeof oldValue === "function");
3021
+ if ((newValueIsObjectLike || oldValueIsObjectLike) && this._equalityService.isEqual(oldValue, newValue)) {
3022
+ continue;
3023
+ }
3005
3024
  }
3006
3025
  if (newValue === PENDING) {
3007
3026
  this._pending.set(newContext, oldValue);
3008
3027
  }
3009
- const stateInfo = {
3028
+ changes.push({
3010
3029
  oldContext,
3011
3030
  context: newContext,
3012
3031
  index,
3013
3032
  oldValue,
3014
3033
  newValue,
3015
3034
  watched
3016
- };
3017
- return newValue === PENDING ? [
3018
- stateInfo
3019
- ] : [
3020
- stateInfo,
3021
- ...this.getStateChanges(oldValue, newValue, ownerId)
3022
- ];
3023
- }).reduce((a, b) => a.concat(b), []);
3035
+ });
3036
+ if (newValue === PENDING) {
3037
+ continue;
3038
+ }
3039
+ this.collectStateChanges(oldValue, newValue, ownerId, this._objectStateManager.getFromId(oldValue), changes);
3040
+ }
3024
3041
  }
3025
3042
  tryRebindingNestedState(newValue, oldValue, ownerId) {
3026
3043
  const stateChanges = this.getStateChanges(oldValue, newValue, ownerId);
3027
3044
  if (stateChanges.length === 0) {
3028
3045
  return;
3029
3046
  }
3030
- const emitted = [];
3047
+ const emittedByContext = /* @__PURE__ */ new Map();
3031
3048
  const shouldEmitChange = /* @__PURE__ */ __name((context, index) => {
3032
- if (emitted.some(([c, i]) => c === context && i === index)) {
3049
+ let emittedIndexes = emittedByContext.get(context);
3050
+ if (!emittedIndexes) {
3051
+ emittedIndexes = /* @__PURE__ */ new Set();
3052
+ emittedByContext.set(context, emittedIndexes);
3053
+ }
3054
+ if (emittedIndexes.has(index)) {
3033
3055
  return false;
3034
3056
  }
3035
- emitted.push([
3036
- context,
3037
- index
3038
- ]);
3057
+ emittedIndexes.add(index);
3039
3058
  return true;
3040
3059
  }, "shouldEmitChange");
3041
3060
  for (const stateChange of stateChanges) {
3042
3061
  Assertion.assert(() => stateChange.context !== stateChange.oldContext, "Expected old and new context not to be equal");
3043
- this._contextChanged.next({
3062
+ const contextChange = {
3044
3063
  context: stateChange.context,
3045
3064
  oldContext: stateChange.oldContext,
3046
3065
  index: stateChange.index
3047
- });
3066
+ };
3067
+ this.emitContextChangedEvents(contextChange);
3068
+ if (this.shouldPublish(this._contextChanged)) {
3069
+ this._contextChanged.next(contextChange);
3070
+ }
3048
3071
  if (!stateChange.watched) {
3049
3072
  this.internalUnregister(stateChange.oldContext, stateChange.index, void 0);
3050
3073
  this.internalSetState(stateChange.context, stateChange.index, stateChange.newValue, {
@@ -3069,6 +3092,97 @@ var StateManager = class {
3069
3092
  }
3070
3093
  }
3071
3094
  }
3095
+ addStateEventSubscription(context, index, subscription) {
3096
+ let subscriptionsByIndex = this._stateEventSubscriptionsByContext.get(context);
3097
+ if (!subscriptionsByIndex) {
3098
+ subscriptionsByIndex = /* @__PURE__ */ new Map();
3099
+ this._stateEventSubscriptionsByContext.set(context, subscriptionsByIndex);
3100
+ }
3101
+ let subscriptions = subscriptionsByIndex.get(index);
3102
+ if (!subscriptions) {
3103
+ subscriptions = /* @__PURE__ */ new Set();
3104
+ subscriptionsByIndex.set(index, subscriptions);
3105
+ }
3106
+ subscriptions.add(subscription);
3107
+ }
3108
+ removeStateEventSubscription(context, index, subscription, releaseToPool = true) {
3109
+ if (!subscription.active) {
3110
+ return;
3111
+ }
3112
+ const subscriptionsByIndex = this._stateEventSubscriptionsByContext.get(context);
3113
+ if (!subscriptionsByIndex) {
3114
+ if (releaseToPool) {
3115
+ this.releaseStateEventSubscription(subscription);
3116
+ }
3117
+ return;
3118
+ }
3119
+ const subscriptions = subscriptionsByIndex.get(index);
3120
+ if (!subscriptions) {
3121
+ if (releaseToPool) {
3122
+ this.releaseStateEventSubscription(subscription);
3123
+ }
3124
+ return;
3125
+ }
3126
+ subscriptions.delete(subscription);
3127
+ if (subscriptions.size === 0) {
3128
+ subscriptionsByIndex.delete(index);
3129
+ }
3130
+ if (subscriptionsByIndex.size === 0) {
3131
+ this._stateEventSubscriptionsByContext.delete(context);
3132
+ }
3133
+ if (releaseToPool) {
3134
+ this.releaseStateEventSubscription(subscription);
3135
+ }
3136
+ }
3137
+ emitStateChangeEvents(change) {
3138
+ const subscriptions = this._stateEventSubscriptionsByContext.get(change.context)?.get(change.index);
3139
+ if (!subscriptions || subscriptions.size === 0) {
3140
+ return;
3141
+ }
3142
+ for (const subscription of subscriptions) {
3143
+ subscription.listener.onStateChange(change);
3144
+ }
3145
+ }
3146
+ emitContextChangedEvents(change) {
3147
+ const subscriptions = this._stateEventSubscriptionsByContext.get(change.oldContext)?.get(change.index);
3148
+ if (!subscriptions || subscriptions.size === 0) {
3149
+ return;
3150
+ }
3151
+ while (subscriptions.size > 0) {
3152
+ const subscriptionIterator = subscriptions.values().next();
3153
+ if (subscriptionIterator.done) {
3154
+ break;
3155
+ }
3156
+ const subscription = subscriptionIterator.value;
3157
+ this.removeStateEventSubscription(subscription.context, subscription.index, subscription, false);
3158
+ subscription.context = change.context;
3159
+ this.addStateEventSubscription(subscription.context, subscription.index, subscription);
3160
+ subscription.listener.onContextChanged(change);
3161
+ }
3162
+ }
3163
+ shouldPublish(subject) {
3164
+ return subject.observed === void 0 || subject.observed;
3165
+ }
3166
+ acquireStateEventSubscription(context, index, listener) {
3167
+ const subscription = this._stateEventSubscriptionPool.pop() ?? {
3168
+ active: true,
3169
+ context,
3170
+ index,
3171
+ listener
3172
+ };
3173
+ subscription.active = true;
3174
+ subscription.context = context;
3175
+ subscription.index = index;
3176
+ subscription.listener = listener;
3177
+ return subscription;
3178
+ }
3179
+ releaseStateEventSubscription(subscription) {
3180
+ if (!subscription.active) {
3181
+ return;
3182
+ }
3183
+ subscription.active = false;
3184
+ this._stateEventSubscriptionPool.push(subscription);
3185
+ }
3072
3186
  setInitialValue(context, index, initialValue, transferedValue, watched, ownerId) {
3073
3187
  this.updateState(context, transferedValue?.context ?? context, index, initialValue, watched, ownerId);
3074
3188
  if (!transferedValue?.shouldEmitChange || transferedValue.shouldEmitChange(context, index)) {
@@ -3076,28 +3190,57 @@ var StateManager = class {
3076
3190
  }
3077
3191
  }
3078
3192
  getChainChanges(chain) {
3079
- if (!chain) {
3193
+ if (!chain || chain.length === 0) {
3080
3194
  return [];
3081
3195
  }
3082
- const registeredChainParts = chain.filter((chainPart) => this._stateChangeSubscriptionManager.isRegistered(chainPart.context, chainPart.index));
3083
- return registeredChainParts.map((chainPart) => ({
3084
- ...chainPart,
3085
- oldValue: this.getOldValue(chainPart.context, chainPart.index),
3086
- value: this.getValue(chainPart.context, chainPart.index)
3087
- }));
3196
+ const chainChanges = [];
3197
+ for (let i = 0; i < chain.length; i++) {
3198
+ const chainPart = chain[i];
3199
+ const { context, index } = chainPart;
3200
+ if (!this._stateChangeSubscriptionManager.isRegistered(context, index)) {
3201
+ continue;
3202
+ }
3203
+ chainChanges.push({
3204
+ context,
3205
+ index,
3206
+ oldValue: this.getOldValue(context, index),
3207
+ value: this.getValue(context, index)
3208
+ });
3209
+ }
3210
+ return chainChanges;
3088
3211
  }
3089
3212
  getCurrentValue(context, index) {
3090
- const value = this._pending.get(context);
3091
- if (value !== void 0) {
3213
+ if (this._pending.has(context)) {
3214
+ const value = this._pending.get(context);
3092
3215
  this._pending.delete(context);
3093
3216
  return value;
3094
3217
  }
3095
3218
  return this.getState(context, index);
3096
3219
  }
3097
- getOwnerId(context, index) {
3098
- return this._objectStateManager.getFromId(context)?.getFromId(index)?.ownerId;
3099
- }
3100
3220
  onChange(change, watched = false, ownerId) {
3221
+ const chain = change.chain;
3222
+ if (!chain || chain.length === 0) {
3223
+ return;
3224
+ }
3225
+ if (chain.length === 1) {
3226
+ const chainPart = chain[0];
3227
+ const { context, index } = chainPart;
3228
+ if (!this._stateChangeSubscriptionManager.isRegistered(context, index)) {
3229
+ return;
3230
+ }
3231
+ const value = this.getValue(context, index);
3232
+ const oldValue = this.getOldValue(context, index);
3233
+ this._startChangeCycle.next();
3234
+ try {
3235
+ const currentValue = this.getCurrentValue(context, index);
3236
+ this.tryRebindingNestedState(change.newValue, currentValue, ownerId);
3237
+ this.updateState(context, context, index, value, watched, ownerId);
3238
+ this.emitChange(context, index, value, oldValue);
3239
+ } finally {
3240
+ this._endChangeCycle.next();
3241
+ }
3242
+ return;
3243
+ }
3101
3244
  const chainChanges = this.getChainChanges(change.chain);
3102
3245
  if (chainChanges.length === 0) {
3103
3246
  return;
@@ -3107,21 +3250,27 @@ var StateManager = class {
3107
3250
  const chainLeaf = chainChanges[chainChanges.length - 1];
3108
3251
  const currentValue = this.getCurrentValue(chainLeaf.context, chainLeaf.index);
3109
3252
  this.tryRebindingNestedState(change.newValue, currentValue, ownerId);
3110
- this.updateState(chainLeaf.context, chainLeaf.context, chainLeaf.index, chainLeaf.value, watched, ownerId);
3111
- chainChanges.forEach((chainChange) => this.emitChange(chainChange.context, chainChange.index, chainChange.value, chainChange.oldValue));
3253
+ for (let i = 0; i < chainChanges.length; i++) {
3254
+ const chainChange = chainChanges[i];
3255
+ this.updateState(chainChange.context, chainChange.context, chainChange.index, chainChange.value, watched, ownerId);
3256
+ }
3257
+ for (let i = 0; i < chainChanges.length; i++) {
3258
+ const chainChange = chainChanges[i];
3259
+ this.emitChange(chainChange.context, chainChange.index, chainChange.value, chainChange.oldValue);
3260
+ }
3112
3261
  } finally {
3113
3262
  this._endChangeCycle.next();
3114
3263
  }
3115
3264
  }
3116
3265
  };
3117
- StateManager = _ts_decorate25([
3118
- Injectable25(),
3266
+ StateManager = _ts_decorate24([
3267
+ Injectable24(),
3119
3268
  _ts_param24(0, Inject23(RsXStateManagerInjectionTokens.IObjectPropertyObserverProxyPairManager)),
3120
3269
  _ts_param24(1, Inject23(RsXStateManagerInjectionTokens.IObjectStateManager)),
3121
- _ts_param24(2, Inject23(RsXCoreInjectionTokens16.IErrorLog)),
3122
- _ts_param24(3, Inject23(RsXCoreInjectionTokens16.IGuidFactory)),
3123
- _ts_param24(4, Inject23(RsXCoreInjectionTokens16.IIndexValueAccessor)),
3124
- _ts_param24(5, Inject23(RsXCoreInjectionTokens16.IEqualityService)),
3270
+ _ts_param24(2, Inject23(RsXCoreInjectionTokens20.IErrorLog)),
3271
+ _ts_param24(3, Inject23(RsXCoreInjectionTokens20.IGuidFactory)),
3272
+ _ts_param24(4, Inject23(RsXCoreInjectionTokens20.IIndexValueAccessor)),
3273
+ _ts_param24(5, Inject23(RsXCoreInjectionTokens20.IEqualityService)),
3125
3274
  _ts_metadata24("design:type", Function),
3126
3275
  _ts_metadata24("design:paramtypes", [
3127
3276
  typeof IObjectPropertyObserverProxyPairManager === "undefined" ? Object : IObjectPropertyObserverProxyPairManager,
@@ -3186,7 +3335,6 @@ var RsXStateManagerModule = new ContainerModule((options) => {
3186
3335
  options.bind(RsXStateManagerInjectionTokens.IDateProxyFactory).to(DateProxyFactory).inSingletonScope();
3187
3336
  options.bind(RsXStateManagerInjectionTokens.IPromiseProxyFactory).to(PromiseProxyFactory).inSingletonScope();
3188
3337
  options.bind(RsXStateManagerInjectionTokens.IObservableProxyFactory).to(ObservableProxyFactory).inSingletonScope();
3189
- options.bind(RsXStateManagerInjectionTokens.IProxyRegistry).to(ProxyRegistry).inSingletonScope();
3190
3338
  options.bind(RsXStateManagerInjectionTokens.IObjectPropertyObserverProxyPairManager).to(ObjectPropertyObserverProxyPairManager).inSingletonScope();
3191
3339
  registerMultiInjectServices(options, RsXStateManagerInjectionTokens.IObjectObserverProxyPairFactoryList, defaultObjectObserverProxyPairFactoryList);
3192
3340
  registerMultiInjectServices(options, RsXStateManagerInjectionTokens.IPropertyObserverProxyPairFactoryList, defaultPropertyObserverProxyPairFactoryList);
@@ -3236,7 +3384,6 @@ export {
3236
3384
  PlainObjectObserverProxyPairFactory,
3237
3385
  PromiseObserverProxyPairFactory,
3238
3386
  PromiseProxyFactory,
3239
- ProxyRegistry,
3240
3387
  RsXStateManagerInjectionTokens,
3241
3388
  RsXStateManagerModule,
3242
3389
  SetObserverProxyPairFactory,