mobx 6.10.1 → 6.11.0-pre

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 (89) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/api/action.d.ts +16 -15
  3. package/dist/api/annotation.d.ts +19 -18
  4. package/dist/api/autorun.d.ts +25 -25
  5. package/dist/api/become-observed.d.ts +5 -5
  6. package/dist/api/computed.d.ts +14 -13
  7. package/dist/api/configure.d.ts +17 -17
  8. package/dist/api/decorators.d.ts +20 -17
  9. package/dist/api/extendobservable.d.ts +2 -2
  10. package/dist/api/extras.d.ts +10 -10
  11. package/dist/api/flow.d.ts +19 -18
  12. package/dist/api/intercept-read.d.ts +8 -8
  13. package/dist/api/intercept.d.ts +8 -8
  14. package/dist/api/iscomputed.d.ts +3 -3
  15. package/dist/api/isobservable.d.ts +2 -2
  16. package/dist/api/makeObservable.d.ts +6 -6
  17. package/dist/api/object-api.d.ts +36 -36
  18. package/dist/api/observable.d.ts +45 -44
  19. package/dist/api/observe.d.ts +8 -8
  20. package/dist/api/tojs.d.ts +7 -7
  21. package/dist/api/trace.d.ts +3 -3
  22. package/dist/api/transaction.d.ts +8 -8
  23. package/dist/api/when.d.ts +11 -11
  24. package/dist/core/action.d.ts +20 -20
  25. package/dist/core/atom.d.ts +37 -37
  26. package/dist/core/computedvalue.d.ts +99 -99
  27. package/dist/core/derivation.d.ts +73 -73
  28. package/dist/core/globalstate.d.ts +121 -121
  29. package/dist/core/observable.d.ts +45 -45
  30. package/dist/core/reaction.d.ts +62 -62
  31. package/dist/core/spy.d.ts +37 -37
  32. package/dist/errors.d.ts +42 -42
  33. package/dist/internal.d.ts +54 -54
  34. package/dist/mobx.cjs.development.js +428 -260
  35. package/dist/mobx.cjs.development.js.map +1 -1
  36. package/dist/mobx.cjs.production.min.js +1 -1
  37. package/dist/mobx.cjs.production.min.js.map +1 -1
  38. package/dist/mobx.d.ts +2 -2
  39. package/dist/mobx.esm.development.js +428 -260
  40. package/dist/mobx.esm.development.js.map +1 -1
  41. package/dist/mobx.esm.js +428 -260
  42. package/dist/mobx.esm.js.map +1 -1
  43. package/dist/mobx.esm.production.min.js +1 -1
  44. package/dist/mobx.esm.production.min.js.map +1 -1
  45. package/dist/mobx.umd.development.js +428 -260
  46. package/dist/mobx.umd.development.js.map +1 -1
  47. package/dist/mobx.umd.production.min.js +1 -1
  48. package/dist/mobx.umd.production.min.js.map +1 -1
  49. package/dist/types/actionannotation.d.ts +8 -8
  50. package/dist/types/autoannotation.d.ts +3 -3
  51. package/dist/types/computedannotation.d.ts +2 -2
  52. package/dist/types/decorator_fills.d.ts +6 -0
  53. package/dist/types/dynamicobject.d.ts +2 -2
  54. package/dist/types/flowannotation.d.ts +2 -2
  55. package/dist/types/generic-abort-signal.d.ts +6 -6
  56. package/dist/types/intercept-utils.d.ts +8 -8
  57. package/dist/types/legacyobservablearray.d.ts +14 -3
  58. package/dist/types/listen-utils.d.ts +7 -7
  59. package/dist/types/modifiers.d.ts +7 -7
  60. package/dist/types/observableannotation.d.ts +2 -2
  61. package/dist/types/observablearray.d.ts +85 -85
  62. package/dist/types/observablemap.d.ts +78 -78
  63. package/dist/types/observableobject.d.ts +99 -98
  64. package/dist/types/observableset.d.ts +53 -53
  65. package/dist/types/observablevalue.d.ts +49 -49
  66. package/dist/types/overrideannotation.d.ts +4 -3
  67. package/dist/types/type-utils.d.ts +11 -11
  68. package/dist/utils/comparer.d.ts +14 -14
  69. package/dist/utils/eq.d.ts +1 -1
  70. package/dist/utils/global.d.ts +1 -1
  71. package/dist/utils/iterable.d.ts +1 -1
  72. package/dist/utils/utils.d.ts +45 -45
  73. package/package.json +1 -1
  74. package/src/api/action.ts +21 -4
  75. package/src/api/annotation.ts +1 -0
  76. package/src/api/computed.ts +11 -4
  77. package/src/api/decorators.ts +29 -8
  78. package/src/api/flow.ts +10 -3
  79. package/src/api/observable.ts +19 -6
  80. package/src/core/atom.ts +9 -11
  81. package/src/types/actionannotation.ts +48 -2
  82. package/src/types/autoannotation.ts +8 -2
  83. package/src/types/computedannotation.ts +39 -2
  84. package/src/types/decorator_fills.ts +33 -0
  85. package/src/types/flowannotation.ts +28 -2
  86. package/src/types/legacyobservablearray.ts +1 -1
  87. package/src/types/observableannotation.ts +75 -2
  88. package/src/types/observableobject.ts +16 -0
  89. package/src/types/overrideannotation.ts +15 -7
@@ -3,16 +3,16 @@ var niceErrors = {
3
3
  1: function _(annotationType, key) {
4
4
  return "Cannot apply '" + annotationType + "' to '" + key.toString() + "': Field not found.";
5
5
  },
6
- /*
7
- 2(prop) {
8
- return `invalid decorator for '${prop.toString()}'`
9
- },
10
- 3(prop) {
11
- return `Cannot decorate '${prop.toString()}': action can only be used on properties with a function value.`
12
- },
13
- 4(prop) {
14
- return `Cannot decorate '${prop.toString()}': computed can only be used on getter properties.`
15
- },
6
+ /*
7
+ 2(prop) {
8
+ return `invalid decorator for '${prop.toString()}'`
9
+ },
10
+ 3(prop) {
11
+ return `Cannot decorate '${prop.toString()}': action can only be used on properties with a function value.`
12
+ },
13
+ 4(prop) {
14
+ return `Cannot decorate '${prop.toString()}': computed can only be used on getter properties.`
15
+ },
16
16
  */
17
17
  5: "'keys()' can only be used on observable objects, arrays, sets and maps",
18
18
  6: "'values()' can only be used on observable objects, arrays, sets and maps",
@@ -127,8 +127,8 @@ function warnAboutProxyRequirement(msg) {
127
127
  function getNextId() {
128
128
  return ++globalState.mobxGuid;
129
129
  }
130
- /**
131
- * Makes sure that the provided function is invoked at most once.
130
+ /**
131
+ * Makes sure that the provided function is invoked at most once.
132
132
  */
133
133
  function once(func) {
134
134
  var invoked = false;
@@ -209,8 +209,8 @@ function isES6Set(thing) {
209
209
  return thing instanceof Set;
210
210
  }
211
211
  var hasGetOwnPropertySymbols = typeof Object.getOwnPropertySymbols !== "undefined";
212
- /**
213
- * Returns the following: own enumerable keys and symbols.
212
+ /**
213
+ * Returns the following: own enumerable keys and symbols.
214
214
  */
215
215
  function getPlainObjectKeys(object) {
216
216
  var keys = Object.keys(object);
@@ -353,20 +353,24 @@ function _toPropertyKey(arg) {
353
353
  }
354
354
 
355
355
  var storedAnnotationsSymbol = /*#__PURE__*/Symbol("mobx-stored-annotations");
356
- /**
357
- * Creates a function that acts as
358
- * - decorator
359
- * - annotation object
356
+ /**
357
+ * Creates a function that acts as
358
+ * - decorator
359
+ * - annotation object
360
360
  */
361
361
  function createDecoratorAnnotation(annotation) {
362
362
  function decorator(target, property) {
363
- storeAnnotation(target, property, annotation);
363
+ if (is20223Decorator(property)) {
364
+ return annotation.decorate_20223_(target, property);
365
+ } else {
366
+ storeAnnotation(target, property, annotation);
367
+ }
364
368
  }
365
369
  return Object.assign(decorator, annotation);
366
370
  }
367
- /**
368
- * Stores annotation to prototype,
369
- * so it can be inspected later by `makeObservable` called from constructor
371
+ /**
372
+ * Stores annotation to prototype,
373
+ * so it can be inspected later by `makeObservable` called from constructor
370
374
  */
371
375
  function storeAnnotation(prototype, key, annotation) {
372
376
  if (!hasProp(prototype, storedAnnotationsSymbol)) {
@@ -392,27 +396,37 @@ function assertNotDecorated(prototype, annotation, key) {
392
396
  die("Cannot apply '@" + requestedAnnotationType + "' to '" + fieldName + "':" + ("\nThe field is already decorated with '@" + currentAnnotationType + "'.") + "\nRe-decorating fields is not allowed." + "\nUse '@override' decorator for methods overridden by subclass.");
393
397
  }
394
398
  }
395
- /**
396
- * Collects annotations from prototypes and stores them on target (instance)
399
+ /**
400
+ * Collects annotations from prototypes and stores them on target (instance)
397
401
  */
398
402
  function collectStoredAnnotations(target) {
399
403
  if (!hasProp(target, storedAnnotationsSymbol)) {
400
- if ( !target[storedAnnotationsSymbol]) {
401
- die("No annotations were passed to makeObservable, but no decorated members have been found either");
402
- }
404
+ // if (__DEV__ && !target[storedAnnotationsSymbol]) {
405
+ // die(
406
+ // `No annotations were passed to makeObservable, but no decorated members have been found either`
407
+ // )
408
+ // }
403
409
  // We need a copy as we will remove annotation from the list once it's applied.
404
410
  addHiddenProp(target, storedAnnotationsSymbol, _extends({}, target[storedAnnotationsSymbol]));
405
411
  }
406
412
  return target[storedAnnotationsSymbol];
407
413
  }
414
+ function is20223Decorator(context) {
415
+ return typeof context == "object" && typeof context["kind"] == "string";
416
+ }
417
+ function assert20223DecoratorType(context, types) {
418
+ if ( !types.includes(context.kind)) {
419
+ die("Decorator may not be used like this");
420
+ }
421
+ }
408
422
 
409
423
  var $mobx = /*#__PURE__*/Symbol("mobx administration");
410
424
  var Atom = /*#__PURE__*/function () {
411
425
  // for effective unobserving. BaseAtom has true, for extra optimization, so its onBecomeUnobserved never gets called, because it's not needed
412
426
 
413
- /**
414
- * Create a new atom. For debugging purposes it is recommended to give it a name.
415
- * The onBecomeObserved and onBecomeUnobserved callbacks can be used for resource management.
427
+ /**
428
+ * Create a new atom. For debugging purposes it is recommended to give it a name.
429
+ * The onBecomeObserved and onBecomeUnobserved callbacks can be used for resource management.
416
430
  */
417
431
  function Atom(name_) {
418
432
  if (name_ === void 0) {
@@ -447,28 +461,26 @@ var Atom = /*#__PURE__*/function () {
447
461
  });
448
462
  }
449
463
  }
450
- /**
451
- * Invoke this method to notify mobx that your atom has been used somehow.
452
- * Returns true if there is currently a reactive context.
464
+ /**
465
+ * Invoke this method to notify mobx that your atom has been used somehow.
466
+ * Returns true if there is currently a reactive context.
453
467
  */;
454
468
  _proto.reportObserved = function reportObserved$1() {
455
469
  return reportObserved(this);
456
470
  }
457
- /**
458
- * Invoke this method _after_ this method has changed to signal mobx that all its observers should invalidate.
471
+ /**
472
+ * Invoke this method _after_ this method has changed to signal mobx that all its observers should invalidate.
459
473
  */;
460
474
  _proto.reportChanged = function reportChanged() {
461
- if (globalState.inBatch && this.batchId_ === globalState.batchId) {
462
- // Called from the same batch this atom was created in.
463
- return;
475
+ if (!globalState.inBatch || this.batchId_ !== globalState.batchId) {
476
+ // We could update state version only at the end of batch,
477
+ // but we would still have to switch some global flag here to signal a change.
478
+ globalState.stateVersion = globalState.stateVersion < Number.MAX_SAFE_INTEGER ? globalState.stateVersion + 1 : Number.MIN_SAFE_INTEGER;
479
+ // Avoids the possibility of hitting the same globalState.batchId when it cycled through all integers (necessary?)
480
+ this.batchId_ = NaN;
464
481
  }
465
- // Avoids the possibility of hitting the same globalState.batchId when it cycled through all integers (necessary?)
466
- this.batchId_ = NaN;
467
482
  startBatch();
468
483
  propagateChanged(this);
469
- // We could update state version only at the end of batch,
470
- // but we would still have to switch some global flag here to signal a change.
471
- globalState.stateVersion = globalState.stateVersion < Number.MAX_SAFE_INTEGER ? globalState.stateVersion + 1 : Number.MIN_SAFE_INTEGER;
472
484
  endBatch();
473
485
  };
474
486
  _proto.toString = function toString() {
@@ -605,7 +617,8 @@ var OVERRIDE = "override";
605
617
  var override = /*#__PURE__*/createDecoratorAnnotation({
606
618
  annotationType_: OVERRIDE,
607
619
  make_: make_,
608
- extend_: extend_
620
+ extend_: extend_,
621
+ decorate_20223_: decorate_20223_
609
622
  });
610
623
  function isOverride(annotation) {
611
624
  return annotation.annotationType_ === OVERRIDE;
@@ -619,47 +632,87 @@ function make_(adm, key) {
619
632
  if ( !hasProp(adm.appliedAnnotations_, key)) {
620
633
  die("'" + adm.name_ + "." + key.toString() + "' is annotated with '" + this.annotationType_ + "', " + "but no such annotated member was found on prototype.");
621
634
  }
622
- return 0 /* Cancel */;
635
+ return 0 /* MakeResult.Cancel */;
623
636
  }
624
637
 
625
638
  function extend_(adm, key, descriptor, proxyTrap) {
626
639
  die("'" + this.annotationType_ + "' can only be used with 'makeObservable'");
627
640
  }
641
+ function decorate_20223_(desc, context) {
642
+ console.warn("'" + this.annotationType_ + "' cannot be used with decorators - this is a no-op");
643
+ }
628
644
 
629
645
  function createActionAnnotation(name, options) {
630
646
  return {
631
647
  annotationType_: name,
632
648
  options_: options,
633
649
  make_: make_$1,
634
- extend_: extend_$1
650
+ extend_: extend_$1,
651
+ decorate_20223_: decorate_20223_$1
635
652
  };
636
653
  }
637
654
  function make_$1(adm, key, descriptor, source) {
638
655
  var _this$options_;
639
656
  // bound
640
657
  if ((_this$options_ = this.options_) != null && _this$options_.bound) {
641
- return this.extend_(adm, key, descriptor, false) === null ? 0 /* Cancel */ : 1 /* Break */;
658
+ return this.extend_(adm, key, descriptor, false) === null ? 0 /* MakeResult.Cancel */ : 1 /* MakeResult.Break */;
642
659
  }
643
660
  // own
644
661
  if (source === adm.target_) {
645
- return this.extend_(adm, key, descriptor, false) === null ? 0 /* Cancel */ : 2 /* Continue */;
662
+ return this.extend_(adm, key, descriptor, false) === null ? 0 /* MakeResult.Cancel */ : 2 /* MakeResult.Continue */;
646
663
  }
647
664
  // prototype
648
665
  if (isAction(descriptor.value)) {
649
666
  // A prototype could have been annotated already by other constructor,
650
667
  // rest of the proto chain must be annotated already
651
- return 1 /* Break */;
668
+ return 1 /* MakeResult.Break */;
652
669
  }
653
670
 
654
671
  var actionDescriptor = createActionDescriptor(adm, this, key, descriptor, false);
655
672
  defineProperty(source, key, actionDescriptor);
656
- return 2 /* Continue */;
673
+ return 2 /* MakeResult.Continue */;
657
674
  }
658
675
 
659
676
  function extend_$1(adm, key, descriptor, proxyTrap) {
660
677
  var actionDescriptor = createActionDescriptor(adm, this, key, descriptor);
661
678
  return adm.defineProperty_(key, actionDescriptor, proxyTrap);
662
679
  }
680
+ function decorate_20223_$1(mthd, context) {
681
+ {
682
+ assert20223DecoratorType(context, ["method", "field"]);
683
+ }
684
+ var kind = context.kind,
685
+ name = context.name,
686
+ addInitializer = context.addInitializer;
687
+ var ann = this;
688
+ var _createAction = function _createAction(m) {
689
+ var _ann$options_$name, _ann$options_, _ann$options_$autoAct, _ann$options_2;
690
+ return createAction((_ann$options_$name = (_ann$options_ = ann.options_) == null ? void 0 : _ann$options_.name) != null ? _ann$options_$name : name.toString(), m, (_ann$options_$autoAct = (_ann$options_2 = ann.options_) == null ? void 0 : _ann$options_2.autoAction) != null ? _ann$options_$autoAct : false);
691
+ };
692
+ // Backwards/Legacy behavior, expects makeObservable(this)
693
+ if (kind == "field") {
694
+ addInitializer(function () {
695
+ storeAnnotation(this, name, ann);
696
+ });
697
+ return;
698
+ }
699
+ if (kind == "method") {
700
+ var _this$options_2;
701
+ if (!isAction(mthd)) {
702
+ mthd = _createAction(mthd);
703
+ }
704
+ if ((_this$options_2 = this.options_) != null && _this$options_2.bound) {
705
+ addInitializer(function () {
706
+ var self = this;
707
+ var bound = self[name].bind(self);
708
+ bound.isMobxAction = true;
709
+ self[name] = bound;
710
+ });
711
+ }
712
+ return mthd;
713
+ }
714
+ die("Cannot apply '" + ann.annotationType_ + "' to '" + String(name) + "' (kind: " + kind + "):" + ("\n'" + ann.annotationType_ + "' can only be used on properties with a function value."));
715
+ }
663
716
  function assertActionDescriptor(adm, _ref, key, _ref2) {
664
717
  var annotationType_ = _ref.annotationType_;
665
718
  var value = _ref2.value;
@@ -700,32 +753,33 @@ function createFlowAnnotation(name, options) {
700
753
  annotationType_: name,
701
754
  options_: options,
702
755
  make_: make_$2,
703
- extend_: extend_$2
756
+ extend_: extend_$2,
757
+ decorate_20223_: decorate_20223_$2
704
758
  };
705
759
  }
706
760
  function make_$2(adm, key, descriptor, source) {
707
761
  var _this$options_;
708
762
  // own
709
763
  if (source === adm.target_) {
710
- return this.extend_(adm, key, descriptor, false) === null ? 0 /* Cancel */ : 2 /* Continue */;
764
+ return this.extend_(adm, key, descriptor, false) === null ? 0 /* MakeResult.Cancel */ : 2 /* MakeResult.Continue */;
711
765
  }
712
766
  // prototype
713
767
  // bound - must annotate protos to support super.flow()
714
768
  if ((_this$options_ = this.options_) != null && _this$options_.bound && (!hasProp(adm.target_, key) || !isFlow(adm.target_[key]))) {
715
769
  if (this.extend_(adm, key, descriptor, false) === null) {
716
- return 0 /* Cancel */;
770
+ return 0 /* MakeResult.Cancel */;
717
771
  }
718
772
  }
719
773
 
720
774
  if (isFlow(descriptor.value)) {
721
775
  // A prototype could have been annotated already by other constructor,
722
776
  // rest of the proto chain must be annotated already
723
- return 1 /* Break */;
777
+ return 1 /* MakeResult.Break */;
724
778
  }
725
779
 
726
780
  var flowDescriptor = createFlowDescriptor(adm, this, key, descriptor, false, false);
727
781
  defineProperty(source, key, flowDescriptor);
728
- return 2 /* Continue */;
782
+ return 2 /* MakeResult.Continue */;
729
783
  }
730
784
 
731
785
  function extend_$2(adm, key, descriptor, proxyTrap) {
@@ -733,6 +787,26 @@ function extend_$2(adm, key, descriptor, proxyTrap) {
733
787
  var flowDescriptor = createFlowDescriptor(adm, this, key, descriptor, (_this$options_2 = this.options_) == null ? void 0 : _this$options_2.bound);
734
788
  return adm.defineProperty_(key, flowDescriptor, proxyTrap);
735
789
  }
790
+ function decorate_20223_$2(mthd, context) {
791
+ var _this$options_3;
792
+ {
793
+ assert20223DecoratorType(context, ["method"]);
794
+ }
795
+ var name = context.name,
796
+ addInitializer = context.addInitializer;
797
+ if (!isFlow(mthd)) {
798
+ mthd = flow(mthd);
799
+ }
800
+ if ((_this$options_3 = this.options_) != null && _this$options_3.bound) {
801
+ addInitializer(function () {
802
+ var self = this;
803
+ var bound = self[name].bind(self);
804
+ bound.isMobXFlow = true;
805
+ self[name] = bound;
806
+ });
807
+ }
808
+ return mthd;
809
+ }
736
810
  function assertFlowDescriptor(adm, _ref, key, _ref2) {
737
811
  var annotationType_ = _ref.annotationType_;
738
812
  var value = _ref2.value;
@@ -777,11 +851,12 @@ function createComputedAnnotation(name, options) {
777
851
  annotationType_: name,
778
852
  options_: options,
779
853
  make_: make_$3,
780
- extend_: extend_$3
854
+ extend_: extend_$3,
855
+ decorate_20223_: decorate_20223_$3
781
856
  };
782
857
  }
783
858
  function make_$3(adm, key, descriptor) {
784
- return this.extend_(adm, key, descriptor, false) === null ? 0 /* Cancel */ : 1 /* Break */;
859
+ return this.extend_(adm, key, descriptor, false) === null ? 0 /* MakeResult.Cancel */ : 1 /* MakeResult.Break */;
785
860
  }
786
861
 
787
862
  function extend_$3(adm, key, descriptor, proxyTrap) {
@@ -791,6 +866,26 @@ function extend_$3(adm, key, descriptor, proxyTrap) {
791
866
  set: descriptor.set
792
867
  }), proxyTrap);
793
868
  }
869
+ function decorate_20223_$3(get, context) {
870
+ {
871
+ assert20223DecoratorType(context, ["getter"]);
872
+ }
873
+ var ann = this;
874
+ var key = context.name,
875
+ addInitializer = context.addInitializer;
876
+ addInitializer(function () {
877
+ var adm = asObservableObject(this)[$mobx];
878
+ var options = _extends({}, ann.options_, {
879
+ get: get,
880
+ context: this
881
+ });
882
+ options.name || (options.name = adm.name_ + "." + key.toString() );
883
+ adm.values_.set(key, new ComputedValue(options));
884
+ });
885
+ return function () {
886
+ return this[$mobx].getObservablePropValue_(key);
887
+ };
888
+ }
794
889
  function assertComputedDescriptor(adm, _ref, key, _ref2) {
795
890
  var annotationType_ = _ref.annotationType_;
796
891
  var get = _ref2.get;
@@ -804,11 +899,12 @@ function createObservableAnnotation(name, options) {
804
899
  annotationType_: name,
805
900
  options_: options,
806
901
  make_: make_$4,
807
- extend_: extend_$4
902
+ extend_: extend_$4,
903
+ decorate_20223_: decorate_20223_$4
808
904
  };
809
905
  }
810
906
  function make_$4(adm, key, descriptor) {
811
- return this.extend_(adm, key, descriptor, false) === null ? 0 /* Cancel */ : 1 /* Break */;
907
+ return this.extend_(adm, key, descriptor, false) === null ? 0 /* MakeResult.Cancel */ : 1 /* MakeResult.Break */;
812
908
  }
813
909
 
814
910
  function extend_$4(adm, key, descriptor, proxyTrap) {
@@ -816,6 +912,58 @@ function extend_$4(adm, key, descriptor, proxyTrap) {
816
912
  assertObservableDescriptor(adm, this, key, descriptor);
817
913
  return adm.defineObservableProperty_(key, descriptor.value, (_this$options_$enhanc = (_this$options_ = this.options_) == null ? void 0 : _this$options_.enhancer) != null ? _this$options_$enhanc : deepEnhancer, proxyTrap);
818
914
  }
915
+ function decorate_20223_$4(desc, context) {
916
+ {
917
+ assert20223DecoratorType(context, ["accessor", "field"]);
918
+ }
919
+ var ann = this;
920
+ var kind = context.kind,
921
+ name = context.name,
922
+ addInitializer = context.addInitializer;
923
+ // Backwards/Legacy behavior, expects makeObservable(this)
924
+ if (kind == "field") {
925
+ addInitializer(function () {
926
+ storeAnnotation(this, name, ann);
927
+ });
928
+ return;
929
+ }
930
+ // The laziness here is not ideal... It's a workaround to how 2022.3 Decorators are implemented:
931
+ // `addInitializer` callbacks are executed _before_ any accessors are defined (instead of the ideal-for-us right after each).
932
+ // This means that, if we were to do our stuff in an `addInitializer`, we'd attempt to read a private slot
933
+ // before it has been initialized. The runtime doesn't like that and throws a `Cannot read private member
934
+ // from an object whose class did not declare it` error.
935
+ var initializedObjects = new WeakSet();
936
+ function initializeObservable(target, value) {
937
+ var _ann$options_$enhance, _ann$options_;
938
+ var adm = asObservableObject(target)[$mobx];
939
+ var observable = new ObservableValue(value, (_ann$options_$enhance = (_ann$options_ = ann.options_) == null ? void 0 : _ann$options_.enhancer) != null ? _ann$options_$enhance : deepEnhancer, adm.name_ + "." + name.toString() , false);
940
+ adm.values_.set(name, observable);
941
+ initializedObjects.add(target);
942
+ }
943
+ if (kind == "accessor") {
944
+ return {
945
+ get: function get() {
946
+ if (!initializedObjects.has(this)) {
947
+ initializeObservable(this, desc.get.call(this));
948
+ }
949
+ return this[$mobx].getObservablePropValue_(name);
950
+ },
951
+ set: function set(value) {
952
+ if (!initializedObjects.has(this)) {
953
+ initializeObservable(this, value);
954
+ }
955
+ return this[$mobx].setObservablePropValue_(name, value);
956
+ },
957
+ init: function init(value) {
958
+ if (!initializedObjects.has(this)) {
959
+ initializeObservable(this, value);
960
+ }
961
+ return value;
962
+ }
963
+ };
964
+ }
965
+ return;
966
+ }
819
967
  function assertObservableDescriptor(adm, _ref, key, descriptor) {
820
968
  var annotationType_ = _ref.annotationType_;
821
969
  if ( !("value" in descriptor)) {
@@ -830,7 +978,8 @@ function createAutoAnnotation(options) {
830
978
  annotationType_: AUTO,
831
979
  options_: options,
832
980
  make_: make_$5,
833
- extend_: extend_$5
981
+ extend_: extend_$5,
982
+ decorate_20223_: decorate_20223_$5
834
983
  };
835
984
  }
836
985
  function make_$5(adm, key, descriptor, source) {
@@ -848,14 +997,14 @@ function make_$5(adm, key, descriptor, source) {
848
997
  return adm.defineProperty_(key, {
849
998
  configurable: globalState.safeDescriptors ? adm.isPlainObject_ : true,
850
999
  set: set
851
- }) === null ? 0 /* Cancel */ : 2 /* Continue */;
1000
+ }) === null ? 0 /* MakeResult.Cancel */ : 2 /* MakeResult.Continue */;
852
1001
  }
853
1002
  // proto
854
1003
  defineProperty(source, key, {
855
1004
  configurable: true,
856
1005
  set: set
857
1006
  });
858
- return 2 /* Continue */;
1007
+ return 2 /* MakeResult.Continue */;
859
1008
  }
860
1009
  // function on proto -> autoAction/flow
861
1010
  if (source !== adm.target_ && typeof descriptor.value === "function") {
@@ -902,6 +1051,9 @@ function extend_$5(adm, key, descriptor, proxyTrap) {
902
1051
  var observableAnnotation = ((_this$options_6 = this.options_) == null ? void 0 : _this$options_6.deep) === false ? observable.ref : observable;
903
1052
  return observableAnnotation.extend_(adm, key, descriptor, proxyTrap);
904
1053
  }
1054
+ function decorate_20223_$5(desc, context) {
1055
+ die("'" + this.annotationType_ + "' cannot be used as a decorator");
1056
+ }
905
1057
 
906
1058
  var OBSERVABLE = "observable";
907
1059
  var OBSERVABLE_REF = "observable.ref";
@@ -941,11 +1093,15 @@ function getEnhancerFromAnnotation(annotation) {
941
1093
  var _annotation$options_$, _annotation$options_;
942
1094
  return !annotation ? deepEnhancer : (_annotation$options_$ = (_annotation$options_ = annotation.options_) == null ? void 0 : _annotation$options_.enhancer) != null ? _annotation$options_$ : deepEnhancer;
943
1095
  }
944
- /**
945
- * Turns an object, array or function into a reactive structure.
946
- * @param v the value which should become observable.
1096
+ /**
1097
+ * Turns an object, array or function into a reactive structure.
1098
+ * @param v the value which should become observable.
947
1099
  */
948
1100
  function createObservable(v, arg2, arg3) {
1101
+ // @observable someProp; (2022.3 Decorators)
1102
+ if (is20223Decorator(arg2)) {
1103
+ return observableAnnotation.decorate_20223_(v, arg2);
1104
+ }
949
1105
  // @observable someProp;
950
1106
  if (isStringish(arg2)) {
951
1107
  storeAnnotation(v, arg2, observableAnnotation);
@@ -1015,11 +1171,15 @@ var computedAnnotation = /*#__PURE__*/createComputedAnnotation(COMPUTED);
1015
1171
  var computedStructAnnotation = /*#__PURE__*/createComputedAnnotation(COMPUTED_STRUCT, {
1016
1172
  equals: comparer.structural
1017
1173
  });
1018
- /**
1019
- * Decorator for class properties: @computed get value() { return expr; }.
1020
- * For legacy purposes also invokable as ES5 observable created: `computed(() => expr)`;
1174
+ /**
1175
+ * Decorator for class properties: @computed get value() { return expr; }.
1176
+ * For legacy purposes also invokable as ES5 observable created: `computed(() => expr)`;
1021
1177
  */
1022
1178
  var computed = function computed(arg1, arg2) {
1179
+ if (is20223Decorator(arg2)) {
1180
+ // @computed (2022.3 Decorators)
1181
+ return computedAnnotation.decorate_20223_(arg1, arg2);
1182
+ }
1023
1183
  if (isStringish(arg2)) {
1024
1184
  // @computed
1025
1185
  return storeAnnotation(arg1, arg2, computedAnnotation);
@@ -1306,24 +1466,24 @@ var ObservableValue = /*#__PURE__*/function (_Atom) {
1306
1466
  var isObservableValue = /*#__PURE__*/createInstanceofPredicate("ObservableValue", ObservableValue);
1307
1467
 
1308
1468
  var _Symbol$toPrimitive$1;
1309
- /**
1310
- * A node in the state dependency root that observes other nodes, and can be observed itself.
1311
- *
1312
- * ComputedValue will remember the result of the computation for the duration of the batch, or
1313
- * while being observed.
1314
- *
1315
- * During this time it will recompute only when one of its direct dependencies changed,
1316
- * but only when it is being accessed with `ComputedValue.get()`.
1317
- *
1318
- * Implementation description:
1319
- * 1. First time it's being accessed it will compute and remember result
1320
- * give back remembered result until 2. happens
1321
- * 2. First time any deep dependency change, propagate POSSIBLY_STALE to all observers, wait for 3.
1322
- * 3. When it's being accessed, recompute if any shallow dependency changed.
1323
- * if result changed: propagate STALE to all observers, that were POSSIBLY_STALE from the last step.
1324
- * go to step 2. either way
1325
- *
1326
- * If at any point it's outside batch and it isn't observed: reset everything and go to 1.
1469
+ /**
1470
+ * A node in the state dependency root that observes other nodes, and can be observed itself.
1471
+ *
1472
+ * ComputedValue will remember the result of the computation for the duration of the batch, or
1473
+ * while being observed.
1474
+ *
1475
+ * During this time it will recompute only when one of its direct dependencies changed,
1476
+ * but only when it is being accessed with `ComputedValue.get()`.
1477
+ *
1478
+ * Implementation description:
1479
+ * 1. First time it's being accessed it will compute and remember result
1480
+ * give back remembered result until 2. happens
1481
+ * 2. First time any deep dependency change, propagate POSSIBLY_STALE to all observers, wait for 3.
1482
+ * 3. When it's being accessed, recompute if any shallow dependency changed.
1483
+ * if result changed: propagate STALE to all observers, that were POSSIBLY_STALE from the last step.
1484
+ * go to step 2. either way
1485
+ *
1486
+ * If at any point it's outside batch and it isn't observed: reset everything and go to 1.
1327
1487
  */
1328
1488
  _Symbol$toPrimitive$1 = Symbol.toPrimitive;
1329
1489
  var ComputedValue = /*#__PURE__*/function () {
@@ -1334,17 +1494,17 @@ var ComputedValue = /*#__PURE__*/function () {
1334
1494
 
1335
1495
  // N.B: unminified as it is used by MST
1336
1496
 
1337
- /**
1338
- * Create a new computed value based on a function expression.
1339
- *
1340
- * The `name` property is for debug purposes only.
1341
- *
1342
- * The `equals` property specifies the comparer function to use to determine if a newly produced
1343
- * value differs from the previous value. Two comparers are provided in the library; `defaultComparer`
1344
- * compares based on identity comparison (===), and `structuralComparer` deeply compares the structure.
1345
- * Structural comparison can be convenient if you always produce a new aggregated object and
1346
- * don't want to notify observers if it is structurally the same.
1347
- * This is useful for working with vectors, mouse coordinates etc.
1497
+ /**
1498
+ * Create a new computed value based on a function expression.
1499
+ *
1500
+ * The `name` property is for debug purposes only.
1501
+ *
1502
+ * The `equals` property specifies the comparer function to use to determine if a newly produced
1503
+ * value differs from the previous value. Two comparers are provided in the library; `defaultComparer`
1504
+ * compares based on identity comparison (===), and `structuralComparer` deeply compares the structure.
1505
+ * Structural comparison can be convenient if you always produce a new aggregated object and
1506
+ * don't want to notify observers if it is structurally the same.
1507
+ * This is useful for working with vectors, mouse coordinates etc.
1348
1508
  */
1349
1509
  function ComputedValue(options) {
1350
1510
  this.dependenciesState_ = IDerivationState_.NOT_TRACKING_;
@@ -1403,9 +1563,9 @@ var ComputedValue = /*#__PURE__*/function () {
1403
1563
  });
1404
1564
  }
1405
1565
  }
1406
- /**
1407
- * Returns the current value of this computed value.
1408
- * Will evaluate its computation first if needed.
1566
+ /**
1567
+ * Returns the current value of this computed value.
1568
+ * Will evaluate its computation first if needed.
1409
1569
  */;
1410
1570
  _proto.get = function get() {
1411
1571
  if (this.isComputing_) {
@@ -1585,16 +1745,16 @@ var CaughtException = function CaughtException(cause) {
1585
1745
  function isCaughtException(e) {
1586
1746
  return e instanceof CaughtException;
1587
1747
  }
1588
- /**
1589
- * Finds out whether any dependency of the derivation has actually changed.
1590
- * If dependenciesState is 1 then it will recalculate dependencies,
1591
- * if any dependency changed it will propagate it by changing dependenciesState to 2.
1592
- *
1593
- * By iterating over the dependencies in the same order that they were reported and
1594
- * stopping on the first change, all the recalculations are only called for ComputedValues
1595
- * that will be tracked by derivation. That is because we assume that if the first x
1596
- * dependencies of the derivation doesn't change then the derivation should run the same way
1597
- * up until accessing x-th dependency.
1748
+ /**
1749
+ * Finds out whether any dependency of the derivation has actually changed.
1750
+ * If dependenciesState is 1 then it will recalculate dependencies,
1751
+ * if any dependency changed it will propagate it by changing dependenciesState to 2.
1752
+ *
1753
+ * By iterating over the dependencies in the same order that they were reported and
1754
+ * stopping on the first change, all the recalculations are only called for ComputedValues
1755
+ * that will be tracked by derivation. That is because we assume that if the first x
1756
+ * dependencies of the derivation doesn't change then the derivation should run the same way
1757
+ * up until accessing x-th dependency.
1598
1758
  */
1599
1759
  function shouldCompute(derivation) {
1600
1760
  switch (derivation.dependenciesState_) {
@@ -1658,10 +1818,10 @@ function checkIfStateReadsAreAllowed(observable) {
1658
1818
  console.warn("[mobx] Observable '" + observable.name_ + "' being read outside a reactive context.");
1659
1819
  }
1660
1820
  }
1661
- /**
1662
- * Executes the provided function `f` and tracks which observables are being accessed.
1663
- * The tracking information is stored on the `derivation` object and the derivation is registered
1664
- * as observer of any of the accessed observables.
1821
+ /**
1822
+ * Executes the provided function `f` and tracks which observables are being accessed.
1823
+ * The tracking information is stored on the `derivation` object and the derivation is registered
1824
+ * as observer of any of the accessed observables.
1665
1825
  */
1666
1826
  function trackDerivedFunction(derivation, f, context) {
1667
1827
  var prevAllowStateReads = allowStateReadsStart(true);
@@ -1699,10 +1859,10 @@ function warnAboutDerivationWithoutDependencies(derivation) {
1699
1859
  console.warn("[mobx] Derivation '" + derivation.name_ + "' is created/updated without reading any observable value.");
1700
1860
  }
1701
1861
  }
1702
- /**
1703
- * diffs newObserving with observing.
1704
- * update observing to be newObserving with unique observables
1705
- * notify observers that become observed/unobserved
1862
+ /**
1863
+ * diffs newObserving with observing.
1864
+ * update observing to be newObserving with unique observables
1865
+ * notify observers that become observed/unobserved
1706
1866
  */
1707
1867
  function bindDependencies(derivation) {
1708
1868
  // invariant(derivation.dependenciesState !== IDerivationState.NOT_TRACKING, "INTERNAL ERROR bindDependencies expects derivation.dependenciesState !== -1");
@@ -1793,9 +1953,9 @@ function allowStateReadsStart(allowStateReads) {
1793
1953
  function allowStateReadsEnd(prev) {
1794
1954
  globalState.allowStateReads = prev;
1795
1955
  }
1796
- /**
1797
- * needed to keep `lowestObserverState` correct. when changing from (2 or 1) to 0
1798
- *
1956
+ /**
1957
+ * needed to keep `lowestObserverState` correct. when changing from (2 or 1) to 0
1958
+ *
1799
1959
  */
1800
1960
  function changeDependenciesStateTo0(derivation) {
1801
1961
  if (derivation.dependenciesState_ === IDerivationState_.UP_TO_DATE_) {
@@ -1809,8 +1969,8 @@ function changeDependenciesStateTo0(derivation) {
1809
1969
  }
1810
1970
  }
1811
1971
 
1812
- /**
1813
- * These values will persist if global state is reset
1972
+ /**
1973
+ * These values will persist if global state is reset
1814
1974
  */
1815
1975
  var persistentKeys = ["mobxGuid", "spyListeners", "enforceActions", "computedRequiresReaction", "reactionRequiresObservable", "observableRequiresReaction", "allowStateReads", "disableErrorBoundaries", "runId", "UNCHANGED", "useProxies"];
1816
1976
  var MobXGlobals = function MobXGlobals() {
@@ -1886,9 +2046,9 @@ function isolateGlobalState() {
1886
2046
  function getGlobalState() {
1887
2047
  return globalState;
1888
2048
  }
1889
- /**
1890
- * For testing purposes only; this will break the internal state of existing observables,
1891
- * but can be used to get back at a stable state after throwing errors
2049
+ /**
2050
+ * For testing purposes only; this will break the internal state of existing observables,
2051
+ * but can be used to get back at a stable state after throwing errors
1892
2052
  */
1893
2053
  function resetGlobalState() {
1894
2054
  var defaultGlobals = new MobXGlobals();
@@ -1955,10 +2115,10 @@ function queueForUnobservation(observable) {
1955
2115
  globalState.pendingUnobservations.push(observable);
1956
2116
  }
1957
2117
  }
1958
- /**
1959
- * Batch starts a transaction, at least for purposes of memoizing ComputedValues when nothing else does.
1960
- * During a batch `onBecomeUnobserved` will be called at most once per observable.
1961
- * Avoids unnecessary recalculations.
2118
+ /**
2119
+ * Batch starts a transaction, at least for purposes of memoizing ComputedValues when nothing else does.
2120
+ * During a batch `onBecomeUnobserved` will be called at most once per observable.
2121
+ * Avoids unnecessary recalculations.
1962
2122
  */
1963
2123
  function startBatch() {
1964
2124
  if (globalState.inBatch === 0) {
@@ -1994,10 +2154,10 @@ function reportObserved(observable) {
1994
2154
  checkIfStateReadsAreAllowed(observable);
1995
2155
  var derivation = globalState.trackingDerivation;
1996
2156
  if (derivation !== null) {
1997
- /**
1998
- * Simple optimization, give each derivation run an unique id (runId)
1999
- * Check if last time this observable was accessed the same runId is used
2000
- * if this is the case, the relation is already known
2157
+ /**
2158
+ * Simple optimization, give each derivation run an unique id (runId)
2159
+ * Check if last time this observable was accessed the same runId is used
2160
+ * if this is the case, the relation is already known
2001
2161
  */
2002
2162
  if (derivation.runId_ !== observable.lastAccessedBy_) {
2003
2163
  observable.lastAccessedBy_ = derivation.runId_;
@@ -2027,12 +2187,12 @@ function reportObserved(observable) {
2027
2187
  // observable.lowestObserverState
2028
2188
  // )
2029
2189
  // }
2030
- /**
2031
- * NOTE: current propagation mechanism will in case of self reruning autoruns behave unexpectedly
2032
- * It will propagate changes to observers from previous run
2033
- * It's hard or maybe impossible (with reasonable perf) to get it right with current approach
2034
- * Hopefully self reruning autoruns aren't a feature people should depend on
2035
- * Also most basic use cases should be ok
2190
+ /**
2191
+ * NOTE: current propagation mechanism will in case of self reruning autoruns behave unexpectedly
2192
+ * It will propagate changes to observers from previous run
2193
+ * It's hard or maybe impossible (with reasonable perf) to get it right with current approach
2194
+ * Hopefully self reruning autoruns aren't a feature people should depend on
2195
+ * Also most basic use cases should be ok
2036
2196
  */
2037
2197
  // Called by Atom when its value changes
2038
2198
  function propagateChanged(observable) {
@@ -2152,8 +2312,8 @@ var Reaction = /*#__PURE__*/function () {
2152
2312
  _proto.isScheduled = function isScheduled() {
2153
2313
  return this.isScheduled_;
2154
2314
  }
2155
- /**
2156
- * internal, use schedule() if you intend to kick off a reaction
2315
+ /**
2316
+ * internal, use schedule() if you intend to kick off a reaction
2157
2317
  */;
2158
2318
  _proto.runReaction_ = function runReaction_() {
2159
2319
  if (!this.isDisposed_) {
@@ -2286,10 +2446,10 @@ function onReactionError(handler) {
2286
2446
  }
2287
2447
  };
2288
2448
  }
2289
- /**
2290
- * Magic number alert!
2291
- * Defines within how many times a reaction is allowed to re-trigger itself
2292
- * until it is assumed that this is gonna be a never ending loop...
2449
+ /**
2450
+ * Magic number alert!
2451
+ * Defines within how many times a reaction is allowed to re-trigger itself
2452
+ * until it is assumed that this is gonna be a never ending loop...
2293
2453
  */
2294
2454
  var MAX_REACTION_ITERATIONS = 100;
2295
2455
  var reactionScheduler = function reactionScheduler(f) {
@@ -2401,6 +2561,10 @@ function createActionFactory(autoAction) {
2401
2561
  if (isFunction(arg2)) {
2402
2562
  return createAction(arg1, arg2, autoAction);
2403
2563
  }
2564
+ // @action (2022.3 Decorators)
2565
+ if (is20223Decorator(arg2)) {
2566
+ return (autoAction ? autoActionAnnotation : actionAnnotation).decorate_20223_(arg1, arg2);
2567
+ }
2404
2568
  // @action
2405
2569
  if (isStringish(arg2)) {
2406
2570
  return storeAnnotation(arg1, arg2, autoAction ? autoActionAnnotation : actionAnnotation);
@@ -2431,11 +2595,11 @@ function isAction(thing) {
2431
2595
  return isFunction(thing) && thing.isMobxAction === true;
2432
2596
  }
2433
2597
 
2434
- /**
2435
- * Creates a named reactive view and keeps it alive, so that the view is always
2436
- * updated if one of the dependencies changes, even when the view is not further used by something else.
2437
- * @param view The reactive view
2438
- * @returns disposer function, which can be used to stop the view from being updated in the future.
2598
+ /**
2599
+ * Creates a named reactive view and keeps it alive, so that the view is always
2600
+ * updated if one of the dependencies changes, even when the view is not further used by something else.
2601
+ * @param view The reactive view
2602
+ * @returns disposer function, which can be used to stop the view from being updated in the future.
2439
2603
  */
2440
2604
  function autorun(view, opts) {
2441
2605
  var _opts$name, _opts, _opts2, _opts2$signal, _opts3;
@@ -2691,6 +2855,10 @@ var flowBoundAnnotation = /*#__PURE__*/createFlowAnnotation("flow.bound", {
2691
2855
  bound: true
2692
2856
  });
2693
2857
  var flow = /*#__PURE__*/Object.assign(function flow(arg1, arg2) {
2858
+ // @flow (2022.3 Decorators)
2859
+ if (is20223Decorator(arg2)) {
2860
+ return flowAnnotation.decorate_20223_(arg1, arg2);
2861
+ }
2694
2862
  // @flow
2695
2863
  if (isStringish(arg2)) {
2696
2864
  return storeAnnotation(arg1, arg2, flowAnnotation);
@@ -3077,11 +3245,11 @@ function toJSHelper(source, __alreadySeen) {
3077
3245
  return _res3;
3078
3246
  }
3079
3247
  }
3080
- /**
3081
- * Recursively converts an observable to it's non-observable native counterpart.
3082
- * It does NOT recurse into non-observables, these are left as they are, even if they contain observables.
3083
- * Computed and other non-enumerable properties are completely ignored.
3084
- * Complex scenarios require custom solution, eg implementing `toJSON` or using `serializr` lib.
3248
+ /**
3249
+ * Recursively converts an observable to it's non-observable native counterpart.
3250
+ * It does NOT recurse into non-observables, these are left as they are, even if they contain observables.
3251
+ * Computed and other non-enumerable properties are completely ignored.
3252
+ * Complex scenarios require custom solution, eg implementing `toJSON` or using `serializr` lib.
3085
3253
  */
3086
3254
  function toJS(source, options) {
3087
3255
  if ( options) {
@@ -3118,12 +3286,12 @@ function getAtomFromArgs(args) {
3118
3286
  }
3119
3287
  }
3120
3288
 
3121
- /**
3122
- * During a transaction no views are updated until the end of the transaction.
3123
- * The transaction will be run synchronously nonetheless.
3124
- *
3125
- * @param action a function that updates some reactive state
3126
- * @returns any value that was returned by the 'action' parameter.
3289
+ /**
3290
+ * During a transaction no views are updated until the end of the transaction.
3291
+ * The transaction will be run synchronously nonetheless.
3292
+ *
3293
+ * @param action a function that updates some reactive state
3294
+ * @returns any value that was returned by the 'action' parameter.
3127
3295
  */
3128
3296
  function transaction(action, thisArg) {
3129
3297
  if (thisArg === void 0) {
@@ -3711,11 +3879,11 @@ var arrayExtensions = {
3711
3879
  toJSON: function toJSON() {
3712
3880
  return this.slice();
3713
3881
  },
3714
- /*
3715
- * functions that do alter the internal structure of the array, (based on lib.es6.d.ts)
3716
- * since these functions alter the inner structure of the array, the have side effects.
3717
- * Because the have side effects, they should not be used in computed function,
3718
- * and for that reason the do not call dependencyState.notifyObserved
3882
+ /*
3883
+ * functions that do alter the internal structure of the array, (based on lib.es6.d.ts)
3884
+ * since these functions alter the inner structure of the array, the have side effects.
3885
+ * Because the have side effects, they should not be used in computed function,
3886
+ * and for that reason the do not call dependencyState.notifyObserved
3719
3887
  */
3720
3888
  splice: function splice(index, deleteCount) {
3721
3889
  for (var _len = arguments.length, newItems = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
@@ -3787,10 +3955,10 @@ var arrayExtensions = {
3787
3955
  return false;
3788
3956
  }
3789
3957
  };
3790
- /**
3791
- * Wrap function from prototype
3792
- * Without this, everything works as well, but this works
3793
- * faster as everything works on unproxied values
3958
+ /**
3959
+ * Wrap function from prototype
3960
+ * Without this, everything works as well, but this works
3961
+ * faster as everything works on unproxied values
3794
3962
  */
3795
3963
  addArrayExtension("concat", simpleFunc);
3796
3964
  addArrayExtension("flat", simpleFunc);
@@ -4230,10 +4398,10 @@ var ObservableMap = /*#__PURE__*/function () {
4230
4398
  _proto.toJSON = function toJSON() {
4231
4399
  return Array.from(this);
4232
4400
  };
4233
- /**
4234
- * Observes this object. Triggers for the events 'add', 'update' and 'delete'.
4235
- * See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/observe
4236
- * for callback details
4401
+ /**
4402
+ * Observes this object. Triggers for the events 'add', 'update' and 'delete'.
4403
+ * See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/observe
4404
+ * for callback details
4237
4405
  */
4238
4406
  _proto.observe_ = function observe_(listener, fireImmediately) {
4239
4407
  if ( fireImmediately === true) {
@@ -4609,12 +4777,12 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
4609
4777
  }
4610
4778
  return this.target_[key];
4611
4779
  }
4612
- /**
4613
- * @param {PropertyKey} key
4614
- * @param {any} value
4615
- * @param {Annotation|boolean} annotation true - use default annotation, false - copy as is
4616
- * @param {boolean} proxyTrap whether it's called from proxy trap
4617
- * @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor
4780
+ /**
4781
+ * @param {PropertyKey} key
4782
+ * @param {any} value
4783
+ * @param {Annotation|boolean} annotation true - use default annotation, false - copy as is
4784
+ * @param {boolean} proxyTrap whether it's called from proxy trap
4785
+ * @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor
4618
4786
  */;
4619
4787
  _proto.set_ = function set_(key, value, proxyTrap) {
4620
4788
  if (proxyTrap === void 0) {
@@ -4659,9 +4827,9 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
4659
4827
  }
4660
4828
  return entry.get();
4661
4829
  }
4662
- /**
4663
- * @param {PropertyKey} key
4664
- * @param {Annotation|boolean} annotation true - use default annotation, false - ignore prop
4830
+ /**
4831
+ * @param {PropertyKey} key
4832
+ * @param {Annotation|boolean} annotation true - use default annotation, false - ignore prop
4665
4833
  */;
4666
4834
  _proto.make_ = function make_(key, annotation) {
4667
4835
  if (annotation === true) {
@@ -4689,10 +4857,10 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
4689
4857
  var descriptor = getDescriptor(source, key);
4690
4858
  if (descriptor) {
4691
4859
  var outcome = annotation.make_(this, key, descriptor, source);
4692
- if (outcome === 0 /* Cancel */) {
4860
+ if (outcome === 0 /* MakeResult.Cancel */) {
4693
4861
  return;
4694
4862
  }
4695
- if (outcome === 1 /* Break */) {
4863
+ if (outcome === 1 /* MakeResult.Break */) {
4696
4864
  break;
4697
4865
  }
4698
4866
  }
@@ -4700,12 +4868,12 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
4700
4868
  }
4701
4869
  recordAnnotationApplied(this, annotation, key);
4702
4870
  }
4703
- /**
4704
- * @param {PropertyKey} key
4705
- * @param {PropertyDescriptor} descriptor
4706
- * @param {Annotation|boolean} annotation true - use default annotation, false - copy as is
4707
- * @param {boolean} proxyTrap whether it's called from proxy trap
4708
- * @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor
4871
+ /**
4872
+ * @param {PropertyKey} key
4873
+ * @param {PropertyDescriptor} descriptor
4874
+ * @param {Annotation|boolean} annotation true - use default annotation, false - copy as is
4875
+ * @param {boolean} proxyTrap whether it's called from proxy trap
4876
+ * @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor
4709
4877
  */;
4710
4878
  _proto.extend_ = function extend_(key, descriptor, annotation, proxyTrap) {
4711
4879
  if (proxyTrap === void 0) {
@@ -4724,11 +4892,11 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
4724
4892
  }
4725
4893
  return outcome;
4726
4894
  }
4727
- /**
4728
- * @param {PropertyKey} key
4729
- * @param {PropertyDescriptor} descriptor
4730
- * @param {boolean} proxyTrap whether it's called from proxy trap
4731
- * @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor
4895
+ /**
4896
+ * @param {PropertyKey} key
4897
+ * @param {PropertyDescriptor} descriptor
4898
+ * @param {boolean} proxyTrap whether it's called from proxy trap
4899
+ * @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor
4732
4900
  */;
4733
4901
  _proto.defineProperty_ = function defineProperty_(key, descriptor, proxyTrap) {
4734
4902
  if (proxyTrap === void 0) {
@@ -4880,11 +5048,11 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
4880
5048
  }
4881
5049
  return true;
4882
5050
  }
4883
- /**
4884
- * @param {PropertyKey} key
4885
- * @param {PropertyDescriptor} descriptor
4886
- * @param {boolean} proxyTrap whether it's called from proxy trap
4887
- * @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor
5051
+ /**
5052
+ * @param {PropertyKey} key
5053
+ * @param {PropertyDescriptor} descriptor
5054
+ * @param {boolean} proxyTrap whether it's called from proxy trap
5055
+ * @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor
4888
5056
  */;
4889
5057
  _proto.delete_ = function delete_(key, proxyTrap) {
4890
5058
  if (proxyTrap === void 0) {
@@ -4973,10 +5141,10 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
4973
5141
  }
4974
5142
  return true;
4975
5143
  }
4976
- /**
4977
- * Observes this object. Triggers for the events 'add', 'update' and 'delete'.
4978
- * See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/observe
4979
- * for callback details
5144
+ /**
5145
+ * Observes this object. Triggers for the events 'add', 'update' and 'delete'.
5146
+ * See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/observe
5147
+ * for callback details
4980
5148
  */;
4981
5149
  _proto.observe_ = function observe_(callback, fireImmediately) {
4982
5150
  if ( fireImmediately === true) {
@@ -5079,35 +5247,35 @@ function assertAnnotable(adm, annotation, key) {
5079
5247
  if ( !isAnnotation(annotation)) {
5080
5248
  die("Cannot annotate '" + adm.name_ + "." + key.toString() + "': Invalid annotation.");
5081
5249
  }
5082
- /*
5083
- // Configurable, not sealed, not frozen
5084
- // Possibly not needed, just a little better error then the one thrown by engine.
5085
- // Cases where this would be useful the most (subclass field initializer) are not interceptable by this.
5086
- if (__DEV__) {
5087
- const configurable = getDescriptor(adm.target_, key)?.configurable
5088
- const frozen = Object.isFrozen(adm.target_)
5089
- const sealed = Object.isSealed(adm.target_)
5090
- if (!configurable || frozen || sealed) {
5091
- const fieldName = `${adm.name_}.${key.toString()}`
5092
- const requestedAnnotationType = annotation.annotationType_
5093
- let error = `Cannot apply '${requestedAnnotationType}' to '${fieldName}':`
5094
- if (frozen) {
5095
- error += `\nObject is frozen.`
5096
- }
5097
- if (sealed) {
5098
- error += `\nObject is sealed.`
5099
- }
5100
- if (!configurable) {
5101
- error += `\nproperty is not configurable.`
5102
- // Mention only if caused by us to avoid confusion
5103
- if (hasProp(adm.appliedAnnotations!, key)) {
5104
- error += `\nTo prevent accidental re-definition of a field by a subclass, `
5105
- error += `all annotated fields of non-plain objects (classes) are not configurable.`
5106
- }
5107
- }
5108
- die(error)
5109
- }
5110
- }
5250
+ /*
5251
+ // Configurable, not sealed, not frozen
5252
+ // Possibly not needed, just a little better error then the one thrown by engine.
5253
+ // Cases where this would be useful the most (subclass field initializer) are not interceptable by this.
5254
+ if (__DEV__) {
5255
+ const configurable = getDescriptor(adm.target_, key)?.configurable
5256
+ const frozen = Object.isFrozen(adm.target_)
5257
+ const sealed = Object.isSealed(adm.target_)
5258
+ if (!configurable || frozen || sealed) {
5259
+ const fieldName = `${adm.name_}.${key.toString()}`
5260
+ const requestedAnnotationType = annotation.annotationType_
5261
+ let error = `Cannot apply '${requestedAnnotationType}' to '${fieldName}':`
5262
+ if (frozen) {
5263
+ error += `\nObject is frozen.`
5264
+ }
5265
+ if (sealed) {
5266
+ error += `\nObject is sealed.`
5267
+ }
5268
+ if (!configurable) {
5269
+ error += `\nproperty is not configurable.`
5270
+ // Mention only if caused by us to avoid confusion
5271
+ if (hasProp(adm.appliedAnnotations!, key)) {
5272
+ error += `\nTo prevent accidental re-definition of a field by a subclass, `
5273
+ error += `all annotated fields of non-plain objects (classes) are not configurable.`
5274
+ }
5275
+ }
5276
+ die(error)
5277
+ }
5278
+ }
5111
5279
  */
5112
5280
  // Not annotated
5113
5281
  if ( !isOverride(annotation) && hasProp(adm.appliedAnnotations_, key)) {
@@ -5131,10 +5299,10 @@ var safariPrototypeSetterInheritanceBug = /*#__PURE__*/function () {
5131
5299
  /*#__PURE__*/Object.create(p)["0"] = 1;
5132
5300
  return v === false;
5133
5301
  }();
5134
- /**
5135
- * This array buffer contains two lists of properties, so that all arrays
5136
- * can recycle their property definitions, which significantly improves performance of creating
5137
- * properties on the fly.
5302
+ /**
5303
+ * This array buffer contains two lists of properties, so that all arrays
5304
+ * can recycle their property definitions, which significantly improves performance of creating
5305
+ * properties on the fly.
5138
5306
  */
5139
5307
  var OBSERVABLE_ARRAY_BUFFER_SIZE = 0;
5140
5308
  // Typescript workaround to make sure ObservableArray extends Array
@@ -5331,11 +5499,11 @@ function getDebugName(thing, property) {
5331
5499
  }
5332
5500
  return named.name_;
5333
5501
  }
5334
- /**
5335
- * Helper function for initializing observable structures, it applies:
5336
- * 1. allowStateChanges so we don't violate enforceActions.
5337
- * 2. untracked so we don't accidentaly subscribe to anything observable accessed during init in case the observable is created inside derivation.
5338
- * 3. batch to avoid state version updates
5502
+ /**
5503
+ * Helper function for initializing observable structures, it applies:
5504
+ * 1. allowStateChanges so we don't violate enforceActions.
5505
+ * 2. untracked so we don't accidentaly subscribe to anything observable accessed during init in case the observable is created inside derivation.
5506
+ * 3. batch to avoid state version updates
5339
5507
  */
5340
5508
  function initObservable(cb) {
5341
5509
  var derivation = untrackedStart();
@@ -5517,22 +5685,22 @@ function isAnnotation(thing) {
5517
5685
  );
5518
5686
  }
5519
5687
 
5520
- /**
5521
- * (c) Michel Weststrate 2015 - 2020
5522
- * MIT Licensed
5523
- *
5524
- * Welcome to the mobx sources! To get a global overview of how MobX internally works,
5525
- * this is a good place to start:
5526
- * https://medium.com/@mweststrate/becoming-fully-reactive-an-in-depth-explanation-of-mobservable-55995262a254#.xvbh6qd74
5527
- *
5528
- * Source folders:
5529
- * ===============
5530
- *
5531
- * - api/ Most of the public static methods exposed by the module can be found here.
5532
- * - core/ Implementation of the MobX algorithm; atoms, derivations, reactions, dependency trees, optimizations. Cool stuff can be found here.
5533
- * - types/ All the magic that is need to have observable objects, arrays and values is in this folder. Including the modifiers like `asFlat`.
5534
- * - utils/ Utility stuff.
5535
- *
5688
+ /**
5689
+ * (c) Michel Weststrate 2015 - 2020
5690
+ * MIT Licensed
5691
+ *
5692
+ * Welcome to the mobx sources! To get a global overview of how MobX internally works,
5693
+ * this is a good place to start:
5694
+ * https://medium.com/@mweststrate/becoming-fully-reactive-an-in-depth-explanation-of-mobservable-55995262a254#.xvbh6qd74
5695
+ *
5696
+ * Source folders:
5697
+ * ===============
5698
+ *
5699
+ * - api/ Most of the public static methods exposed by the module can be found here.
5700
+ * - core/ Implementation of the MobX algorithm; atoms, derivations, reactions, dependency trees, optimizations. Cool stuff can be found here.
5701
+ * - types/ All the magic that is need to have observable objects, arrays and values is in this folder. Including the modifiers like `asFlat`.
5702
+ * - utils/ Utility stuff.
5703
+ *
5536
5704
  */
5537
5705
  ["Symbol", "Map", "Set"].forEach(function (m) {
5538
5706
  var g = getGlobal();