mobx 6.10.2 → 6.11.0

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