mobx 6.10.1 → 6.11.0-pre

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/api/action.d.ts +16 -15
  3. package/dist/api/annotation.d.ts +19 -18
  4. package/dist/api/autorun.d.ts +25 -25
  5. package/dist/api/become-observed.d.ts +5 -5
  6. package/dist/api/computed.d.ts +14 -13
  7. package/dist/api/configure.d.ts +17 -17
  8. package/dist/api/decorators.d.ts +20 -17
  9. package/dist/api/extendobservable.d.ts +2 -2
  10. package/dist/api/extras.d.ts +10 -10
  11. package/dist/api/flow.d.ts +19 -18
  12. package/dist/api/intercept-read.d.ts +8 -8
  13. package/dist/api/intercept.d.ts +8 -8
  14. package/dist/api/iscomputed.d.ts +3 -3
  15. package/dist/api/isobservable.d.ts +2 -2
  16. package/dist/api/makeObservable.d.ts +6 -6
  17. package/dist/api/object-api.d.ts +36 -36
  18. package/dist/api/observable.d.ts +45 -44
  19. package/dist/api/observe.d.ts +8 -8
  20. package/dist/api/tojs.d.ts +7 -7
  21. package/dist/api/trace.d.ts +3 -3
  22. package/dist/api/transaction.d.ts +8 -8
  23. package/dist/api/when.d.ts +11 -11
  24. package/dist/core/action.d.ts +20 -20
  25. package/dist/core/atom.d.ts +37 -37
  26. package/dist/core/computedvalue.d.ts +99 -99
  27. package/dist/core/derivation.d.ts +73 -73
  28. package/dist/core/globalstate.d.ts +121 -121
  29. package/dist/core/observable.d.ts +45 -45
  30. package/dist/core/reaction.d.ts +62 -62
  31. package/dist/core/spy.d.ts +37 -37
  32. package/dist/errors.d.ts +42 -42
  33. package/dist/internal.d.ts +54 -54
  34. package/dist/mobx.cjs.development.js +428 -260
  35. package/dist/mobx.cjs.development.js.map +1 -1
  36. package/dist/mobx.cjs.production.min.js +1 -1
  37. package/dist/mobx.cjs.production.min.js.map +1 -1
  38. package/dist/mobx.d.ts +2 -2
  39. package/dist/mobx.esm.development.js +428 -260
  40. package/dist/mobx.esm.development.js.map +1 -1
  41. package/dist/mobx.esm.js +428 -260
  42. package/dist/mobx.esm.js.map +1 -1
  43. package/dist/mobx.esm.production.min.js +1 -1
  44. package/dist/mobx.esm.production.min.js.map +1 -1
  45. package/dist/mobx.umd.development.js +428 -260
  46. package/dist/mobx.umd.development.js.map +1 -1
  47. package/dist/mobx.umd.production.min.js +1 -1
  48. package/dist/mobx.umd.production.min.js.map +1 -1
  49. package/dist/types/actionannotation.d.ts +8 -8
  50. package/dist/types/autoannotation.d.ts +3 -3
  51. package/dist/types/computedannotation.d.ts +2 -2
  52. package/dist/types/decorator_fills.d.ts +6 -0
  53. package/dist/types/dynamicobject.d.ts +2 -2
  54. package/dist/types/flowannotation.d.ts +2 -2
  55. package/dist/types/generic-abort-signal.d.ts +6 -6
  56. package/dist/types/intercept-utils.d.ts +8 -8
  57. package/dist/types/legacyobservablearray.d.ts +14 -3
  58. package/dist/types/listen-utils.d.ts +7 -7
  59. package/dist/types/modifiers.d.ts +7 -7
  60. package/dist/types/observableannotation.d.ts +2 -2
  61. package/dist/types/observablearray.d.ts +85 -85
  62. package/dist/types/observablemap.d.ts +78 -78
  63. package/dist/types/observableobject.d.ts +99 -98
  64. package/dist/types/observableset.d.ts +53 -53
  65. package/dist/types/observablevalue.d.ts +49 -49
  66. package/dist/types/overrideannotation.d.ts +4 -3
  67. package/dist/types/type-utils.d.ts +11 -11
  68. package/dist/utils/comparer.d.ts +14 -14
  69. package/dist/utils/eq.d.ts +1 -1
  70. package/dist/utils/global.d.ts +1 -1
  71. package/dist/utils/iterable.d.ts +1 -1
  72. package/dist/utils/utils.d.ts +45 -45
  73. package/package.json +1 -1
  74. package/src/api/action.ts +21 -4
  75. package/src/api/annotation.ts +1 -0
  76. package/src/api/computed.ts +11 -4
  77. package/src/api/decorators.ts +29 -8
  78. package/src/api/flow.ts +10 -3
  79. package/src/api/observable.ts +19 -6
  80. package/src/core/atom.ts +9 -11
  81. package/src/types/actionannotation.ts +48 -2
  82. package/src/types/autoannotation.ts +8 -2
  83. package/src/types/computedannotation.ts +39 -2
  84. package/src/types/decorator_fills.ts +33 -0
  85. package/src/types/flowannotation.ts +28 -2
  86. package/src/types/legacyobservablearray.ts +1 -1
  87. package/src/types/observableannotation.ts +75 -2
  88. package/src/types/observableobject.ts +16 -0
  89. package/src/types/overrideannotation.ts +15 -7
@@ -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("Decorator may not be used like this");
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,28 +465,26 @@ 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
- if (globalState.inBatch && this.batchId_ === globalState.batchId) {
466
- // Called from the same batch this atom was created in.
467
- return;
479
+ if (!globalState.inBatch || this.batchId_ !== globalState.batchId) {
480
+ // We could update state version only at the end of batch,
481
+ // but we would still have to switch some global flag here to signal a change.
482
+ globalState.stateVersion = globalState.stateVersion < Number.MAX_SAFE_INTEGER ? globalState.stateVersion + 1 : Number.MIN_SAFE_INTEGER;
483
+ // Avoids the possibility of hitting the same globalState.batchId when it cycled through all integers (necessary?)
484
+ this.batchId_ = NaN;
468
485
  }
469
- // Avoids the possibility of hitting the same globalState.batchId when it cycled through all integers (necessary?)
470
- this.batchId_ = NaN;
471
486
  startBatch();
472
487
  propagateChanged(this);
473
- // We could update state version only at the end of batch,
474
- // but we would still have to switch some global flag here to signal a change.
475
- globalState.stateVersion = globalState.stateVersion < Number.MAX_SAFE_INTEGER ? globalState.stateVersion + 1 : Number.MIN_SAFE_INTEGER;
476
488
  endBatch();
477
489
  };
478
490
  _proto.toString = function toString() {
@@ -609,7 +621,8 @@ var OVERRIDE = "override";
609
621
  var override = /*#__PURE__*/createDecoratorAnnotation({
610
622
  annotationType_: OVERRIDE,
611
623
  make_: make_,
612
- extend_: extend_
624
+ extend_: extend_,
625
+ decorate_20223_: decorate_20223_
613
626
  });
614
627
  function isOverride(annotation) {
615
628
  return annotation.annotationType_ === OVERRIDE;
@@ -623,47 +636,87 @@ function make_(adm, key) {
623
636
  if ( !hasProp(adm.appliedAnnotations_, key)) {
624
637
  die("'" + adm.name_ + "." + key.toString() + "' is annotated with '" + this.annotationType_ + "', " + "but no such annotated member was found on prototype.");
625
638
  }
626
- return 0 /* Cancel */;
639
+ return 0 /* MakeResult.Cancel */;
627
640
  }
628
641
 
629
642
  function extend_(adm, key, descriptor, proxyTrap) {
630
643
  die("'" + this.annotationType_ + "' can only be used with 'makeObservable'");
631
644
  }
645
+ function decorate_20223_(desc, context) {
646
+ console.warn("'" + this.annotationType_ + "' cannot be used with decorators - this is a no-op");
647
+ }
632
648
 
633
649
  function createActionAnnotation(name, options) {
634
650
  return {
635
651
  annotationType_: name,
636
652
  options_: options,
637
653
  make_: make_$1,
638
- extend_: extend_$1
654
+ extend_: extend_$1,
655
+ decorate_20223_: decorate_20223_$1
639
656
  };
640
657
  }
641
658
  function make_$1(adm, key, descriptor, source) {
642
659
  var _this$options_;
643
660
  // bound
644
661
  if ((_this$options_ = this.options_) != null && _this$options_.bound) {
645
- 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 */;
646
663
  }
647
664
  // own
648
665
  if (source === adm.target_) {
649
- 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 */;
650
667
  }
651
668
  // prototype
652
669
  if (isAction(descriptor.value)) {
653
670
  // A prototype could have been annotated already by other constructor,
654
671
  // rest of the proto chain must be annotated already
655
- return 1 /* Break */;
672
+ return 1 /* MakeResult.Break */;
656
673
  }
657
674
 
658
675
  var actionDescriptor = createActionDescriptor(adm, this, key, descriptor, false);
659
676
  defineProperty(source, key, actionDescriptor);
660
- return 2 /* Continue */;
677
+ return 2 /* MakeResult.Continue */;
661
678
  }
662
679
 
663
680
  function extend_$1(adm, key, descriptor, proxyTrap) {
664
681
  var actionDescriptor = createActionDescriptor(adm, this, key, descriptor);
665
682
  return adm.defineProperty_(key, actionDescriptor, proxyTrap);
666
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
+ }
667
720
  function assertActionDescriptor(adm, _ref, key, _ref2) {
668
721
  var annotationType_ = _ref.annotationType_;
669
722
  var value = _ref2.value;
@@ -704,32 +757,33 @@ function createFlowAnnotation(name, options) {
704
757
  annotationType_: name,
705
758
  options_: options,
706
759
  make_: make_$2,
707
- extend_: extend_$2
760
+ extend_: extend_$2,
761
+ decorate_20223_: decorate_20223_$2
708
762
  };
709
763
  }
710
764
  function make_$2(adm, key, descriptor, source) {
711
765
  var _this$options_;
712
766
  // own
713
767
  if (source === adm.target_) {
714
- 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 */;
715
769
  }
716
770
  // prototype
717
771
  // bound - must annotate protos to support super.flow()
718
772
  if ((_this$options_ = this.options_) != null && _this$options_.bound && (!hasProp(adm.target_, key) || !isFlow(adm.target_[key]))) {
719
773
  if (this.extend_(adm, key, descriptor, false) === null) {
720
- return 0 /* Cancel */;
774
+ return 0 /* MakeResult.Cancel */;
721
775
  }
722
776
  }
723
777
 
724
778
  if (isFlow(descriptor.value)) {
725
779
  // A prototype could have been annotated already by other constructor,
726
780
  // rest of the proto chain must be annotated already
727
- return 1 /* Break */;
781
+ return 1 /* MakeResult.Break */;
728
782
  }
729
783
 
730
784
  var flowDescriptor = createFlowDescriptor(adm, this, key, descriptor, false, false);
731
785
  defineProperty(source, key, flowDescriptor);
732
- return 2 /* Continue */;
786
+ return 2 /* MakeResult.Continue */;
733
787
  }
734
788
 
735
789
  function extend_$2(adm, key, descriptor, proxyTrap) {
@@ -737,6 +791,26 @@ function extend_$2(adm, key, descriptor, proxyTrap) {
737
791
  var flowDescriptor = createFlowDescriptor(adm, this, key, descriptor, (_this$options_2 = this.options_) == null ? void 0 : _this$options_2.bound);
738
792
  return adm.defineProperty_(key, flowDescriptor, proxyTrap);
739
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
+ }
740
814
  function assertFlowDescriptor(adm, _ref, key, _ref2) {
741
815
  var annotationType_ = _ref.annotationType_;
742
816
  var value = _ref2.value;
@@ -781,11 +855,12 @@ function createComputedAnnotation(name, options) {
781
855
  annotationType_: name,
782
856
  options_: options,
783
857
  make_: make_$3,
784
- extend_: extend_$3
858
+ extend_: extend_$3,
859
+ decorate_20223_: decorate_20223_$3
785
860
  };
786
861
  }
787
862
  function make_$3(adm, key, descriptor) {
788
- 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 */;
789
864
  }
790
865
 
791
866
  function extend_$3(adm, key, descriptor, proxyTrap) {
@@ -795,6 +870,26 @@ function extend_$3(adm, key, descriptor, proxyTrap) {
795
870
  set: descriptor.set
796
871
  }), proxyTrap);
797
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
+ }
798
893
  function assertComputedDescriptor(adm, _ref, key, _ref2) {
799
894
  var annotationType_ = _ref.annotationType_;
800
895
  var get = _ref2.get;
@@ -808,11 +903,12 @@ function createObservableAnnotation(name, options) {
808
903
  annotationType_: name,
809
904
  options_: options,
810
905
  make_: make_$4,
811
- extend_: extend_$4
906
+ extend_: extend_$4,
907
+ decorate_20223_: decorate_20223_$4
812
908
  };
813
909
  }
814
910
  function make_$4(adm, key, descriptor) {
815
- 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 */;
816
912
  }
817
913
 
818
914
  function extend_$4(adm, key, descriptor, proxyTrap) {
@@ -820,6 +916,58 @@ function extend_$4(adm, key, descriptor, proxyTrap) {
820
916
  assertObservableDescriptor(adm, this, key, descriptor);
821
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);
822
918
  }
919
+ function decorate_20223_$4(desc, context) {
920
+ {
921
+ assert20223DecoratorType(context, ["accessor", "field"]);
922
+ }
923
+ var ann = this;
924
+ var kind = context.kind,
925
+ name = context.name,
926
+ addInitializer = context.addInitializer;
927
+ // Backwards/Legacy behavior, expects makeObservable(this)
928
+ if (kind == "field") {
929
+ addInitializer(function () {
930
+ storeAnnotation(this, name, ann);
931
+ });
932
+ return;
933
+ }
934
+ // The laziness here is not ideal... It's a workaround to how 2022.3 Decorators are implemented:
935
+ // `addInitializer` callbacks are executed _before_ any accessors are defined (instead of the ideal-for-us right after each).
936
+ // This means that, if we were to do our stuff in an `addInitializer`, we'd attempt to read a private slot
937
+ // before it has been initialized. The runtime doesn't like that and throws a `Cannot read private member
938
+ // from an object whose class did not declare it` error.
939
+ var initializedObjects = new WeakSet();
940
+ function initializeObservable(target, value) {
941
+ var _ann$options_$enhance, _ann$options_;
942
+ var adm = asObservableObject(target)[$mobx];
943
+ 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);
944
+ adm.values_.set(name, observable);
945
+ initializedObjects.add(target);
946
+ }
947
+ if (kind == "accessor") {
948
+ return {
949
+ get: function get() {
950
+ if (!initializedObjects.has(this)) {
951
+ initializeObservable(this, desc.get.call(this));
952
+ }
953
+ return this[$mobx].getObservablePropValue_(name);
954
+ },
955
+ set: function set(value) {
956
+ if (!initializedObjects.has(this)) {
957
+ initializeObservable(this, value);
958
+ }
959
+ return this[$mobx].setObservablePropValue_(name, value);
960
+ },
961
+ init: function init(value) {
962
+ if (!initializedObjects.has(this)) {
963
+ initializeObservable(this, value);
964
+ }
965
+ return value;
966
+ }
967
+ };
968
+ }
969
+ return;
970
+ }
823
971
  function assertObservableDescriptor(adm, _ref, key, descriptor) {
824
972
  var annotationType_ = _ref.annotationType_;
825
973
  if ( !("value" in descriptor)) {
@@ -834,7 +982,8 @@ function createAutoAnnotation(options) {
834
982
  annotationType_: AUTO,
835
983
  options_: options,
836
984
  make_: make_$5,
837
- extend_: extend_$5
985
+ extend_: extend_$5,
986
+ decorate_20223_: decorate_20223_$5
838
987
  };
839
988
  }
840
989
  function make_$5(adm, key, descriptor, source) {
@@ -852,14 +1001,14 @@ function make_$5(adm, key, descriptor, source) {
852
1001
  return adm.defineProperty_(key, {
853
1002
  configurable: globalState.safeDescriptors ? adm.isPlainObject_ : true,
854
1003
  set: set
855
- }) === null ? 0 /* Cancel */ : 2 /* Continue */;
1004
+ }) === null ? 0 /* MakeResult.Cancel */ : 2 /* MakeResult.Continue */;
856
1005
  }
857
1006
  // proto
858
1007
  defineProperty(source, key, {
859
1008
  configurable: true,
860
1009
  set: set
861
1010
  });
862
- return 2 /* Continue */;
1011
+ return 2 /* MakeResult.Continue */;
863
1012
  }
864
1013
  // function on proto -> autoAction/flow
865
1014
  if (source !== adm.target_ && typeof descriptor.value === "function") {
@@ -906,6 +1055,9 @@ function extend_$5(adm, key, descriptor, proxyTrap) {
906
1055
  var observableAnnotation = ((_this$options_6 = this.options_) == null ? void 0 : _this$options_6.deep) === false ? observable.ref : observable;
907
1056
  return observableAnnotation.extend_(adm, key, descriptor, proxyTrap);
908
1057
  }
1058
+ function decorate_20223_$5(desc, context) {
1059
+ die("'" + this.annotationType_ + "' cannot be used as a decorator");
1060
+ }
909
1061
 
910
1062
  var OBSERVABLE = "observable";
911
1063
  var OBSERVABLE_REF = "observable.ref";
@@ -945,11 +1097,15 @@ function getEnhancerFromAnnotation(annotation) {
945
1097
  var _annotation$options_$, _annotation$options_;
946
1098
  return !annotation ? deepEnhancer : (_annotation$options_$ = (_annotation$options_ = annotation.options_) == null ? void 0 : _annotation$options_.enhancer) != null ? _annotation$options_$ : deepEnhancer;
947
1099
  }
948
- /**
949
- * Turns an object, array or function into a reactive structure.
950
- * @param v the value which should become observable.
1100
+ /**
1101
+ * Turns an object, array or function into a reactive structure.
1102
+ * @param v the value which should become observable.
951
1103
  */
952
1104
  function createObservable(v, arg2, arg3) {
1105
+ // @observable someProp; (2022.3 Decorators)
1106
+ if (is20223Decorator(arg2)) {
1107
+ return observableAnnotation.decorate_20223_(v, arg2);
1108
+ }
953
1109
  // @observable someProp;
954
1110
  if (isStringish(arg2)) {
955
1111
  storeAnnotation(v, arg2, observableAnnotation);
@@ -1019,11 +1175,15 @@ var computedAnnotation = /*#__PURE__*/createComputedAnnotation(COMPUTED);
1019
1175
  var computedStructAnnotation = /*#__PURE__*/createComputedAnnotation(COMPUTED_STRUCT, {
1020
1176
  equals: comparer.structural
1021
1177
  });
1022
- /**
1023
- * Decorator for class properties: @computed get value() { return expr; }.
1024
- * For legacy purposes also invokable as ES5 observable created: `computed(() => expr)`;
1178
+ /**
1179
+ * Decorator for class properties: @computed get value() { return expr; }.
1180
+ * For legacy purposes also invokable as ES5 observable created: `computed(() => expr)`;
1025
1181
  */
1026
1182
  var computed = function computed(arg1, arg2) {
1183
+ if (is20223Decorator(arg2)) {
1184
+ // @computed (2022.3 Decorators)
1185
+ return computedAnnotation.decorate_20223_(arg1, arg2);
1186
+ }
1027
1187
  if (isStringish(arg2)) {
1028
1188
  // @computed
1029
1189
  return storeAnnotation(arg1, arg2, computedAnnotation);
@@ -1310,24 +1470,24 @@ var ObservableValue = /*#__PURE__*/function (_Atom) {
1310
1470
  var isObservableValue = /*#__PURE__*/createInstanceofPredicate("ObservableValue", ObservableValue);
1311
1471
 
1312
1472
  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.
1473
+ /**
1474
+ * A node in the state dependency root that observes other nodes, and can be observed itself.
1475
+ *
1476
+ * ComputedValue will remember the result of the computation for the duration of the batch, or
1477
+ * while being observed.
1478
+ *
1479
+ * During this time it will recompute only when one of its direct dependencies changed,
1480
+ * but only when it is being accessed with `ComputedValue.get()`.
1481
+ *
1482
+ * Implementation description:
1483
+ * 1. First time it's being accessed it will compute and remember result
1484
+ * give back remembered result until 2. happens
1485
+ * 2. First time any deep dependency change, propagate POSSIBLY_STALE to all observers, wait for 3.
1486
+ * 3. When it's being accessed, recompute if any shallow dependency changed.
1487
+ * if result changed: propagate STALE to all observers, that were POSSIBLY_STALE from the last step.
1488
+ * go to step 2. either way
1489
+ *
1490
+ * If at any point it's outside batch and it isn't observed: reset everything and go to 1.
1331
1491
  */
1332
1492
  _Symbol$toPrimitive$1 = Symbol.toPrimitive;
1333
1493
  var ComputedValue = /*#__PURE__*/function () {
@@ -1338,17 +1498,17 @@ var ComputedValue = /*#__PURE__*/function () {
1338
1498
 
1339
1499
  // N.B: unminified as it is used by MST
1340
1500
 
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.
1501
+ /**
1502
+ * Create a new computed value based on a function expression.
1503
+ *
1504
+ * The `name` property is for debug purposes only.
1505
+ *
1506
+ * The `equals` property specifies the comparer function to use to determine if a newly produced
1507
+ * value differs from the previous value. Two comparers are provided in the library; `defaultComparer`
1508
+ * compares based on identity comparison (===), and `structuralComparer` deeply compares the structure.
1509
+ * Structural comparison can be convenient if you always produce a new aggregated object and
1510
+ * don't want to notify observers if it is structurally the same.
1511
+ * This is useful for working with vectors, mouse coordinates etc.
1352
1512
  */
1353
1513
  function ComputedValue(options) {
1354
1514
  this.dependenciesState_ = IDerivationState_.NOT_TRACKING_;
@@ -1407,9 +1567,9 @@ var ComputedValue = /*#__PURE__*/function () {
1407
1567
  });
1408
1568
  }
1409
1569
  }
1410
- /**
1411
- * Returns the current value of this computed value.
1412
- * Will evaluate its computation first if needed.
1570
+ /**
1571
+ * Returns the current value of this computed value.
1572
+ * Will evaluate its computation first if needed.
1413
1573
  */;
1414
1574
  _proto.get = function get() {
1415
1575
  if (this.isComputing_) {
@@ -1589,16 +1749,16 @@ var CaughtException = function CaughtException(cause) {
1589
1749
  function isCaughtException(e) {
1590
1750
  return e instanceof CaughtException;
1591
1751
  }
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.
1752
+ /**
1753
+ * Finds out whether any dependency of the derivation has actually changed.
1754
+ * If dependenciesState is 1 then it will recalculate dependencies,
1755
+ * if any dependency changed it will propagate it by changing dependenciesState to 2.
1756
+ *
1757
+ * By iterating over the dependencies in the same order that they were reported and
1758
+ * stopping on the first change, all the recalculations are only called for ComputedValues
1759
+ * that will be tracked by derivation. That is because we assume that if the first x
1760
+ * dependencies of the derivation doesn't change then the derivation should run the same way
1761
+ * up until accessing x-th dependency.
1602
1762
  */
1603
1763
  function shouldCompute(derivation) {
1604
1764
  switch (derivation.dependenciesState_) {
@@ -1662,10 +1822,10 @@ function checkIfStateReadsAreAllowed(observable) {
1662
1822
  console.warn("[mobx] Observable '" + observable.name_ + "' being read outside a reactive context.");
1663
1823
  }
1664
1824
  }
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.
1825
+ /**
1826
+ * Executes the provided function `f` and tracks which observables are being accessed.
1827
+ * The tracking information is stored on the `derivation` object and the derivation is registered
1828
+ * as observer of any of the accessed observables.
1669
1829
  */
1670
1830
  function trackDerivedFunction(derivation, f, context) {
1671
1831
  var prevAllowStateReads = allowStateReadsStart(true);
@@ -1703,10 +1863,10 @@ function warnAboutDerivationWithoutDependencies(derivation) {
1703
1863
  console.warn("[mobx] Derivation '" + derivation.name_ + "' is created/updated without reading any observable value.");
1704
1864
  }
1705
1865
  }
1706
- /**
1707
- * diffs newObserving with observing.
1708
- * update observing to be newObserving with unique observables
1709
- * notify observers that become observed/unobserved
1866
+ /**
1867
+ * diffs newObserving with observing.
1868
+ * update observing to be newObserving with unique observables
1869
+ * notify observers that become observed/unobserved
1710
1870
  */
1711
1871
  function bindDependencies(derivation) {
1712
1872
  // invariant(derivation.dependenciesState !== IDerivationState.NOT_TRACKING, "INTERNAL ERROR bindDependencies expects derivation.dependenciesState !== -1");
@@ -1797,9 +1957,9 @@ function allowStateReadsStart(allowStateReads) {
1797
1957
  function allowStateReadsEnd(prev) {
1798
1958
  globalState.allowStateReads = prev;
1799
1959
  }
1800
- /**
1801
- * needed to keep `lowestObserverState` correct. when changing from (2 or 1) to 0
1802
- *
1960
+ /**
1961
+ * needed to keep `lowestObserverState` correct. when changing from (2 or 1) to 0
1962
+ *
1803
1963
  */
1804
1964
  function changeDependenciesStateTo0(derivation) {
1805
1965
  if (derivation.dependenciesState_ === IDerivationState_.UP_TO_DATE_) {
@@ -1813,8 +1973,8 @@ function changeDependenciesStateTo0(derivation) {
1813
1973
  }
1814
1974
  }
1815
1975
 
1816
- /**
1817
- * These values will persist if global state is reset
1976
+ /**
1977
+ * These values will persist if global state is reset
1818
1978
  */
1819
1979
  var persistentKeys = ["mobxGuid", "spyListeners", "enforceActions", "computedRequiresReaction", "reactionRequiresObservable", "observableRequiresReaction", "allowStateReads", "disableErrorBoundaries", "runId", "UNCHANGED", "useProxies"];
1820
1980
  var MobXGlobals = function MobXGlobals() {
@@ -1890,9 +2050,9 @@ function isolateGlobalState() {
1890
2050
  function getGlobalState() {
1891
2051
  return globalState;
1892
2052
  }
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
2053
+ /**
2054
+ * For testing purposes only; this will break the internal state of existing observables,
2055
+ * but can be used to get back at a stable state after throwing errors
1896
2056
  */
1897
2057
  function resetGlobalState() {
1898
2058
  var defaultGlobals = new MobXGlobals();
@@ -1959,10 +2119,10 @@ function queueForUnobservation(observable) {
1959
2119
  globalState.pendingUnobservations.push(observable);
1960
2120
  }
1961
2121
  }
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.
2122
+ /**
2123
+ * Batch starts a transaction, at least for purposes of memoizing ComputedValues when nothing else does.
2124
+ * During a batch `onBecomeUnobserved` will be called at most once per observable.
2125
+ * Avoids unnecessary recalculations.
1966
2126
  */
1967
2127
  function startBatch() {
1968
2128
  if (globalState.inBatch === 0) {
@@ -1998,10 +2158,10 @@ function reportObserved(observable) {
1998
2158
  checkIfStateReadsAreAllowed(observable);
1999
2159
  var derivation = globalState.trackingDerivation;
2000
2160
  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
2161
+ /**
2162
+ * Simple optimization, give each derivation run an unique id (runId)
2163
+ * Check if last time this observable was accessed the same runId is used
2164
+ * if this is the case, the relation is already known
2005
2165
  */
2006
2166
  if (derivation.runId_ !== observable.lastAccessedBy_) {
2007
2167
  observable.lastAccessedBy_ = derivation.runId_;
@@ -2031,12 +2191,12 @@ function reportObserved(observable) {
2031
2191
  // observable.lowestObserverState
2032
2192
  // )
2033
2193
  // }
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
2194
+ /**
2195
+ * NOTE: current propagation mechanism will in case of self reruning autoruns behave unexpectedly
2196
+ * It will propagate changes to observers from previous run
2197
+ * It's hard or maybe impossible (with reasonable perf) to get it right with current approach
2198
+ * Hopefully self reruning autoruns aren't a feature people should depend on
2199
+ * Also most basic use cases should be ok
2040
2200
  */
2041
2201
  // Called by Atom when its value changes
2042
2202
  function propagateChanged(observable) {
@@ -2156,8 +2316,8 @@ var Reaction = /*#__PURE__*/function () {
2156
2316
  _proto.isScheduled = function isScheduled() {
2157
2317
  return this.isScheduled_;
2158
2318
  }
2159
- /**
2160
- * internal, use schedule() if you intend to kick off a reaction
2319
+ /**
2320
+ * internal, use schedule() if you intend to kick off a reaction
2161
2321
  */;
2162
2322
  _proto.runReaction_ = function runReaction_() {
2163
2323
  if (!this.isDisposed_) {
@@ -2290,10 +2450,10 @@ function onReactionError(handler) {
2290
2450
  }
2291
2451
  };
2292
2452
  }
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...
2453
+ /**
2454
+ * Magic number alert!
2455
+ * Defines within how many times a reaction is allowed to re-trigger itself
2456
+ * until it is assumed that this is gonna be a never ending loop...
2297
2457
  */
2298
2458
  var MAX_REACTION_ITERATIONS = 100;
2299
2459
  var reactionScheduler = function reactionScheduler(f) {
@@ -2405,6 +2565,10 @@ function createActionFactory(autoAction) {
2405
2565
  if (isFunction(arg2)) {
2406
2566
  return createAction(arg1, arg2, autoAction);
2407
2567
  }
2568
+ // @action (2022.3 Decorators)
2569
+ if (is20223Decorator(arg2)) {
2570
+ return (autoAction ? autoActionAnnotation : actionAnnotation).decorate_20223_(arg1, arg2);
2571
+ }
2408
2572
  // @action
2409
2573
  if (isStringish(arg2)) {
2410
2574
  return storeAnnotation(arg1, arg2, autoAction ? autoActionAnnotation : actionAnnotation);
@@ -2435,11 +2599,11 @@ function isAction(thing) {
2435
2599
  return isFunction(thing) && thing.isMobxAction === true;
2436
2600
  }
2437
2601
 
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.
2602
+ /**
2603
+ * Creates a named reactive view and keeps it alive, so that the view is always
2604
+ * updated if one of the dependencies changes, even when the view is not further used by something else.
2605
+ * @param view The reactive view
2606
+ * @returns disposer function, which can be used to stop the view from being updated in the future.
2443
2607
  */
2444
2608
  function autorun(view, opts) {
2445
2609
  var _opts$name, _opts, _opts2, _opts2$signal, _opts3;
@@ -2695,6 +2859,10 @@ var flowBoundAnnotation = /*#__PURE__*/createFlowAnnotation("flow.bound", {
2695
2859
  bound: true
2696
2860
  });
2697
2861
  var flow = /*#__PURE__*/Object.assign(function flow(arg1, arg2) {
2862
+ // @flow (2022.3 Decorators)
2863
+ if (is20223Decorator(arg2)) {
2864
+ return flowAnnotation.decorate_20223_(arg1, arg2);
2865
+ }
2698
2866
  // @flow
2699
2867
  if (isStringish(arg2)) {
2700
2868
  return storeAnnotation(arg1, arg2, flowAnnotation);
@@ -3081,11 +3249,11 @@ function toJSHelper(source, __alreadySeen) {
3081
3249
  return _res3;
3082
3250
  }
3083
3251
  }
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.
3252
+ /**
3253
+ * Recursively converts an observable to it's non-observable native counterpart.
3254
+ * It does NOT recurse into non-observables, these are left as they are, even if they contain observables.
3255
+ * Computed and other non-enumerable properties are completely ignored.
3256
+ * Complex scenarios require custom solution, eg implementing `toJSON` or using `serializr` lib.
3089
3257
  */
3090
3258
  function toJS(source, options) {
3091
3259
  if ( options) {
@@ -3122,12 +3290,12 @@ function getAtomFromArgs(args) {
3122
3290
  }
3123
3291
  }
3124
3292
 
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.
3293
+ /**
3294
+ * During a transaction no views are updated until the end of the transaction.
3295
+ * The transaction will be run synchronously nonetheless.
3296
+ *
3297
+ * @param action a function that updates some reactive state
3298
+ * @returns any value that was returned by the 'action' parameter.
3131
3299
  */
3132
3300
  function transaction(action, thisArg) {
3133
3301
  if (thisArg === void 0) {
@@ -3715,11 +3883,11 @@ var arrayExtensions = {
3715
3883
  toJSON: function toJSON() {
3716
3884
  return this.slice();
3717
3885
  },
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
3886
+ /*
3887
+ * functions that do alter the internal structure of the array, (based on lib.es6.d.ts)
3888
+ * since these functions alter the inner structure of the array, the have side effects.
3889
+ * Because the have side effects, they should not be used in computed function,
3890
+ * and for that reason the do not call dependencyState.notifyObserved
3723
3891
  */
3724
3892
  splice: function splice(index, deleteCount) {
3725
3893
  for (var _len = arguments.length, newItems = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
@@ -3791,10 +3959,10 @@ var arrayExtensions = {
3791
3959
  return false;
3792
3960
  }
3793
3961
  };
3794
- /**
3795
- * Wrap function from prototype
3796
- * Without this, everything works as well, but this works
3797
- * faster as everything works on unproxied values
3962
+ /**
3963
+ * Wrap function from prototype
3964
+ * Without this, everything works as well, but this works
3965
+ * faster as everything works on unproxied values
3798
3966
  */
3799
3967
  addArrayExtension("concat", simpleFunc);
3800
3968
  addArrayExtension("flat", simpleFunc);
@@ -4234,10 +4402,10 @@ var ObservableMap = /*#__PURE__*/function () {
4234
4402
  _proto.toJSON = function toJSON() {
4235
4403
  return Array.from(this);
4236
4404
  };
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
4405
+ /**
4406
+ * Observes this object. Triggers for the events 'add', 'update' and 'delete'.
4407
+ * See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/observe
4408
+ * for callback details
4241
4409
  */
4242
4410
  _proto.observe_ = function observe_(listener, fireImmediately) {
4243
4411
  if ( fireImmediately === true) {
@@ -4613,12 +4781,12 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
4613
4781
  }
4614
4782
  return this.target_[key];
4615
4783
  }
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
4784
+ /**
4785
+ * @param {PropertyKey} key
4786
+ * @param {any} value
4787
+ * @param {Annotation|boolean} annotation true - use default annotation, false - copy as is
4788
+ * @param {boolean} proxyTrap whether it's called from proxy trap
4789
+ * @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor
4622
4790
  */;
4623
4791
  _proto.set_ = function set_(key, value, proxyTrap) {
4624
4792
  if (proxyTrap === void 0) {
@@ -4663,9 +4831,9 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
4663
4831
  }
4664
4832
  return entry.get();
4665
4833
  }
4666
- /**
4667
- * @param {PropertyKey} key
4668
- * @param {Annotation|boolean} annotation true - use default annotation, false - ignore prop
4834
+ /**
4835
+ * @param {PropertyKey} key
4836
+ * @param {Annotation|boolean} annotation true - use default annotation, false - ignore prop
4669
4837
  */;
4670
4838
  _proto.make_ = function make_(key, annotation) {
4671
4839
  if (annotation === true) {
@@ -4693,10 +4861,10 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
4693
4861
  var descriptor = getDescriptor(source, key);
4694
4862
  if (descriptor) {
4695
4863
  var outcome = annotation.make_(this, key, descriptor, source);
4696
- if (outcome === 0 /* Cancel */) {
4864
+ if (outcome === 0 /* MakeResult.Cancel */) {
4697
4865
  return;
4698
4866
  }
4699
- if (outcome === 1 /* Break */) {
4867
+ if (outcome === 1 /* MakeResult.Break */) {
4700
4868
  break;
4701
4869
  }
4702
4870
  }
@@ -4704,12 +4872,12 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
4704
4872
  }
4705
4873
  recordAnnotationApplied(this, annotation, key);
4706
4874
  }
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
4875
+ /**
4876
+ * @param {PropertyKey} key
4877
+ * @param {PropertyDescriptor} descriptor
4878
+ * @param {Annotation|boolean} annotation true - use default annotation, false - copy as is
4879
+ * @param {boolean} proxyTrap whether it's called from proxy trap
4880
+ * @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor
4713
4881
  */;
4714
4882
  _proto.extend_ = function extend_(key, descriptor, annotation, proxyTrap) {
4715
4883
  if (proxyTrap === void 0) {
@@ -4728,11 +4896,11 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
4728
4896
  }
4729
4897
  return outcome;
4730
4898
  }
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
4899
+ /**
4900
+ * @param {PropertyKey} key
4901
+ * @param {PropertyDescriptor} descriptor
4902
+ * @param {boolean} proxyTrap whether it's called from proxy trap
4903
+ * @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor
4736
4904
  */;
4737
4905
  _proto.defineProperty_ = function defineProperty_(key, descriptor, proxyTrap) {
4738
4906
  if (proxyTrap === void 0) {
@@ -4884,11 +5052,11 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
4884
5052
  }
4885
5053
  return true;
4886
5054
  }
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
5055
+ /**
5056
+ * @param {PropertyKey} key
5057
+ * @param {PropertyDescriptor} descriptor
5058
+ * @param {boolean} proxyTrap whether it's called from proxy trap
5059
+ * @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor
4892
5060
  */;
4893
5061
  _proto.delete_ = function delete_(key, proxyTrap) {
4894
5062
  if (proxyTrap === void 0) {
@@ -4977,10 +5145,10 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
4977
5145
  }
4978
5146
  return true;
4979
5147
  }
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
5148
+ /**
5149
+ * Observes this object. Triggers for the events 'add', 'update' and 'delete'.
5150
+ * See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/observe
5151
+ * for callback details
4984
5152
  */;
4985
5153
  _proto.observe_ = function observe_(callback, fireImmediately) {
4986
5154
  if ( fireImmediately === true) {
@@ -5083,35 +5251,35 @@ function assertAnnotable(adm, annotation, key) {
5083
5251
  if ( !isAnnotation(annotation)) {
5084
5252
  die("Cannot annotate '" + adm.name_ + "." + key.toString() + "': Invalid annotation.");
5085
5253
  }
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
- }
5254
+ /*
5255
+ // Configurable, not sealed, not frozen
5256
+ // Possibly not needed, just a little better error then the one thrown by engine.
5257
+ // Cases where this would be useful the most (subclass field initializer) are not interceptable by this.
5258
+ if (__DEV__) {
5259
+ const configurable = getDescriptor(adm.target_, key)?.configurable
5260
+ const frozen = Object.isFrozen(adm.target_)
5261
+ const sealed = Object.isSealed(adm.target_)
5262
+ if (!configurable || frozen || sealed) {
5263
+ const fieldName = `${adm.name_}.${key.toString()}`
5264
+ const requestedAnnotationType = annotation.annotationType_
5265
+ let error = `Cannot apply '${requestedAnnotationType}' to '${fieldName}':`
5266
+ if (frozen) {
5267
+ error += `\nObject is frozen.`
5268
+ }
5269
+ if (sealed) {
5270
+ error += `\nObject is sealed.`
5271
+ }
5272
+ if (!configurable) {
5273
+ error += `\nproperty is not configurable.`
5274
+ // Mention only if caused by us to avoid confusion
5275
+ if (hasProp(adm.appliedAnnotations!, key)) {
5276
+ error += `\nTo prevent accidental re-definition of a field by a subclass, `
5277
+ error += `all annotated fields of non-plain objects (classes) are not configurable.`
5278
+ }
5279
+ }
5280
+ die(error)
5281
+ }
5282
+ }
5115
5283
  */
5116
5284
  // Not annotated
5117
5285
  if ( !isOverride(annotation) && hasProp(adm.appliedAnnotations_, key)) {
@@ -5135,10 +5303,10 @@ var safariPrototypeSetterInheritanceBug = /*#__PURE__*/function () {
5135
5303
  /*#__PURE__*/Object.create(p)["0"] = 1;
5136
5304
  return v === false;
5137
5305
  }();
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.
5306
+ /**
5307
+ * This array buffer contains two lists of properties, so that all arrays
5308
+ * can recycle their property definitions, which significantly improves performance of creating
5309
+ * properties on the fly.
5142
5310
  */
5143
5311
  var OBSERVABLE_ARRAY_BUFFER_SIZE = 0;
5144
5312
  // Typescript workaround to make sure ObservableArray extends Array
@@ -5335,11 +5503,11 @@ function getDebugName(thing, property) {
5335
5503
  }
5336
5504
  return named.name_;
5337
5505
  }
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
5506
+ /**
5507
+ * Helper function for initializing observable structures, it applies:
5508
+ * 1. allowStateChanges so we don't violate enforceActions.
5509
+ * 2. untracked so we don't accidentaly subscribe to anything observable accessed during init in case the observable is created inside derivation.
5510
+ * 3. batch to avoid state version updates
5343
5511
  */
5344
5512
  function initObservable(cb) {
5345
5513
  var derivation = untrackedStart();
@@ -5521,22 +5689,22 @@ function isAnnotation(thing) {
5521
5689
  );
5522
5690
  }
5523
5691
 
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
- *
5692
+ /**
5693
+ * (c) Michel Weststrate 2015 - 2020
5694
+ * MIT Licensed
5695
+ *
5696
+ * Welcome to the mobx sources! To get a global overview of how MobX internally works,
5697
+ * this is a good place to start:
5698
+ * https://medium.com/@mweststrate/becoming-fully-reactive-an-in-depth-explanation-of-mobservable-55995262a254#.xvbh6qd74
5699
+ *
5700
+ * Source folders:
5701
+ * ===============
5702
+ *
5703
+ * - api/ Most of the public static methods exposed by the module can be found here.
5704
+ * - core/ Implementation of the MobX algorithm; atoms, derivations, reactions, dependency trees, optimizations. Cool stuff can be found here.
5705
+ * - types/ All the magic that is need to have observable objects, arrays and values is in this folder. Including the modifiers like `asFlat`.
5706
+ * - utils/ Utility stuff.
5707
+ *
5540
5708
  */
5541
5709
  ["Symbol", "Map", "Set"].forEach(function (m) {
5542
5710
  var g = getGlobal();