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