mobx 6.10.2 → 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 (87) hide show
  1. package/dist/api/action.d.ts +16 -15
  2. package/dist/api/annotation.d.ts +19 -18
  3. package/dist/api/autorun.d.ts +25 -25
  4. package/dist/api/become-observed.d.ts +5 -5
  5. package/dist/api/computed.d.ts +14 -13
  6. package/dist/api/configure.d.ts +17 -17
  7. package/dist/api/decorators.d.ts +20 -17
  8. package/dist/api/extendobservable.d.ts +2 -2
  9. package/dist/api/extras.d.ts +10 -10
  10. package/dist/api/flow.d.ts +19 -18
  11. package/dist/api/intercept-read.d.ts +8 -8
  12. package/dist/api/intercept.d.ts +8 -8
  13. package/dist/api/iscomputed.d.ts +3 -3
  14. package/dist/api/isobservable.d.ts +2 -2
  15. package/dist/api/makeObservable.d.ts +6 -6
  16. package/dist/api/object-api.d.ts +36 -36
  17. package/dist/api/observable.d.ts +45 -44
  18. package/dist/api/observe.d.ts +8 -8
  19. package/dist/api/tojs.d.ts +7 -7
  20. package/dist/api/trace.d.ts +3 -3
  21. package/dist/api/transaction.d.ts +8 -8
  22. package/dist/api/when.d.ts +11 -11
  23. package/dist/core/action.d.ts +20 -20
  24. package/dist/core/atom.d.ts +37 -37
  25. package/dist/core/computedvalue.d.ts +99 -99
  26. package/dist/core/derivation.d.ts +73 -73
  27. package/dist/core/globalstate.d.ts +121 -121
  28. package/dist/core/observable.d.ts +45 -45
  29. package/dist/core/reaction.d.ts +62 -62
  30. package/dist/core/spy.d.ts +37 -37
  31. package/dist/errors.d.ts +42 -42
  32. package/dist/internal.d.ts +54 -54
  33. package/dist/mobx.cjs.development.js +422 -252
  34. package/dist/mobx.cjs.development.js.map +1 -1
  35. package/dist/mobx.cjs.production.min.js +1 -1
  36. package/dist/mobx.cjs.production.min.js.map +1 -1
  37. package/dist/mobx.d.ts +2 -2
  38. package/dist/mobx.esm.development.js +422 -252
  39. package/dist/mobx.esm.development.js.map +1 -1
  40. package/dist/mobx.esm.js +422 -252
  41. package/dist/mobx.esm.js.map +1 -1
  42. package/dist/mobx.esm.production.min.js +1 -1
  43. package/dist/mobx.esm.production.min.js.map +1 -1
  44. package/dist/mobx.umd.development.js +422 -252
  45. package/dist/mobx.umd.development.js.map +1 -1
  46. package/dist/mobx.umd.production.min.js +1 -1
  47. package/dist/mobx.umd.production.min.js.map +1 -1
  48. package/dist/types/actionannotation.d.ts +8 -8
  49. package/dist/types/autoannotation.d.ts +3 -3
  50. package/dist/types/computedannotation.d.ts +2 -2
  51. package/dist/types/decorator_fills.d.ts +6 -0
  52. package/dist/types/dynamicobject.d.ts +2 -2
  53. package/dist/types/flowannotation.d.ts +2 -2
  54. package/dist/types/generic-abort-signal.d.ts +6 -6
  55. package/dist/types/intercept-utils.d.ts +8 -8
  56. package/dist/types/legacyobservablearray.d.ts +14 -3
  57. package/dist/types/listen-utils.d.ts +7 -7
  58. package/dist/types/modifiers.d.ts +7 -7
  59. package/dist/types/observableannotation.d.ts +2 -2
  60. package/dist/types/observablearray.d.ts +85 -85
  61. package/dist/types/observablemap.d.ts +78 -78
  62. package/dist/types/observableobject.d.ts +99 -98
  63. package/dist/types/observableset.d.ts +53 -53
  64. package/dist/types/observablevalue.d.ts +49 -49
  65. package/dist/types/overrideannotation.d.ts +4 -3
  66. package/dist/types/type-utils.d.ts +11 -11
  67. package/dist/utils/comparer.d.ts +14 -14
  68. package/dist/utils/eq.d.ts +1 -1
  69. package/dist/utils/global.d.ts +1 -1
  70. package/dist/utils/iterable.d.ts +1 -1
  71. package/dist/utils/utils.d.ts +45 -45
  72. package/package.json +1 -1
  73. package/src/api/action.ts +21 -4
  74. package/src/api/annotation.ts +1 -0
  75. package/src/api/computed.ts +11 -4
  76. package/src/api/decorators.ts +29 -8
  77. package/src/api/flow.ts +10 -3
  78. package/src/api/observable.ts +19 -6
  79. package/src/types/actionannotation.ts +48 -2
  80. package/src/types/autoannotation.ts +8 -2
  81. package/src/types/computedannotation.ts +39 -2
  82. package/src/types/decorator_fills.ts +33 -0
  83. package/src/types/flowannotation.ts +28 -2
  84. package/src/types/legacyobservablearray.ts +1 -1
  85. package/src/types/observableannotation.ts +75 -2
  86. package/src/types/observableobject.ts +16 -0
  87. 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,15 +465,15 @@ var Atom = /*#__PURE__*/function () {
451
465
  });
452
466
  }
453
467
  }
454
- /**
455
- * Invoke this method to notify mobx that your atom has been used somehow.
456
- * Returns true if there is currently a reactive context.
468
+ /**
469
+ * Invoke this method to notify mobx that your atom has been used somehow.
470
+ * Returns true if there is currently a reactive context.
457
471
  */;
458
472
  _proto.reportObserved = function reportObserved$1() {
459
473
  return reportObserved(this);
460
474
  }
461
- /**
462
- * Invoke this method _after_ this method has changed to signal mobx that all its observers should invalidate.
475
+ /**
476
+ * Invoke this method _after_ this method has changed to signal mobx that all its observers should invalidate.
463
477
  */;
464
478
  _proto.reportChanged = function reportChanged() {
465
479
  if (!globalState.inBatch || this.batchId_ !== globalState.batchId) {
@@ -607,7 +621,8 @@ var OVERRIDE = "override";
607
621
  var override = /*#__PURE__*/createDecoratorAnnotation({
608
622
  annotationType_: OVERRIDE,
609
623
  make_: make_,
610
- extend_: extend_
624
+ extend_: extend_,
625
+ decorate_20223_: decorate_20223_
611
626
  });
612
627
  function isOverride(annotation) {
613
628
  return annotation.annotationType_ === OVERRIDE;
@@ -621,47 +636,87 @@ function make_(adm, key) {
621
636
  if ( !hasProp(adm.appliedAnnotations_, key)) {
622
637
  die("'" + adm.name_ + "." + key.toString() + "' is annotated with '" + this.annotationType_ + "', " + "but no such annotated member was found on prototype.");
623
638
  }
624
- return 0 /* Cancel */;
639
+ return 0 /* MakeResult.Cancel */;
625
640
  }
626
641
 
627
642
  function extend_(adm, key, descriptor, proxyTrap) {
628
643
  die("'" + this.annotationType_ + "' can only be used with 'makeObservable'");
629
644
  }
645
+ function decorate_20223_(desc, context) {
646
+ console.warn("'" + this.annotationType_ + "' cannot be used with decorators - this is a no-op");
647
+ }
630
648
 
631
649
  function createActionAnnotation(name, options) {
632
650
  return {
633
651
  annotationType_: name,
634
652
  options_: options,
635
653
  make_: make_$1,
636
- extend_: extend_$1
654
+ extend_: extend_$1,
655
+ decorate_20223_: decorate_20223_$1
637
656
  };
638
657
  }
639
658
  function make_$1(adm, key, descriptor, source) {
640
659
  var _this$options_;
641
660
  // bound
642
661
  if ((_this$options_ = this.options_) != null && _this$options_.bound) {
643
- return this.extend_(adm, key, descriptor, false) === null ? 0 /* Cancel */ : 1 /* Break */;
662
+ return this.extend_(adm, key, descriptor, false) === null ? 0 /* MakeResult.Cancel */ : 1 /* MakeResult.Break */;
644
663
  }
645
664
  // own
646
665
  if (source === adm.target_) {
647
- return this.extend_(adm, key, descriptor, false) === null ? 0 /* Cancel */ : 2 /* Continue */;
666
+ return this.extend_(adm, key, descriptor, false) === null ? 0 /* MakeResult.Cancel */ : 2 /* MakeResult.Continue */;
648
667
  }
649
668
  // prototype
650
669
  if (isAction(descriptor.value)) {
651
670
  // A prototype could have been annotated already by other constructor,
652
671
  // rest of the proto chain must be annotated already
653
- return 1 /* Break */;
672
+ return 1 /* MakeResult.Break */;
654
673
  }
655
674
 
656
675
  var actionDescriptor = createActionDescriptor(adm, this, key, descriptor, false);
657
676
  defineProperty(source, key, actionDescriptor);
658
- return 2 /* Continue */;
677
+ return 2 /* MakeResult.Continue */;
659
678
  }
660
679
 
661
680
  function extend_$1(adm, key, descriptor, proxyTrap) {
662
681
  var actionDescriptor = createActionDescriptor(adm, this, key, descriptor);
663
682
  return adm.defineProperty_(key, actionDescriptor, proxyTrap);
664
683
  }
684
+ function decorate_20223_$1(mthd, context) {
685
+ {
686
+ assert20223DecoratorType(context, ["method", "field"]);
687
+ }
688
+ var kind = context.kind,
689
+ name = context.name,
690
+ addInitializer = context.addInitializer;
691
+ var ann = this;
692
+ var _createAction = function _createAction(m) {
693
+ var _ann$options_$name, _ann$options_, _ann$options_$autoAct, _ann$options_2;
694
+ return createAction((_ann$options_$name = (_ann$options_ = ann.options_) == null ? void 0 : _ann$options_.name) != null ? _ann$options_$name : name.toString(), m, (_ann$options_$autoAct = (_ann$options_2 = ann.options_) == null ? void 0 : _ann$options_2.autoAction) != null ? _ann$options_$autoAct : false);
695
+ };
696
+ // Backwards/Legacy behavior, expects makeObservable(this)
697
+ if (kind == "field") {
698
+ addInitializer(function () {
699
+ storeAnnotation(this, name, ann);
700
+ });
701
+ return;
702
+ }
703
+ if (kind == "method") {
704
+ var _this$options_2;
705
+ if (!isAction(mthd)) {
706
+ mthd = _createAction(mthd);
707
+ }
708
+ if ((_this$options_2 = this.options_) != null && _this$options_2.bound) {
709
+ addInitializer(function () {
710
+ var self = this;
711
+ var bound = self[name].bind(self);
712
+ bound.isMobxAction = true;
713
+ self[name] = bound;
714
+ });
715
+ }
716
+ return mthd;
717
+ }
718
+ die("Cannot apply '" + ann.annotationType_ + "' to '" + String(name) + "' (kind: " + kind + "):" + ("\n'" + ann.annotationType_ + "' can only be used on properties with a function value."));
719
+ }
665
720
  function assertActionDescriptor(adm, _ref, key, _ref2) {
666
721
  var annotationType_ = _ref.annotationType_;
667
722
  var value = _ref2.value;
@@ -702,32 +757,33 @@ function createFlowAnnotation(name, options) {
702
757
  annotationType_: name,
703
758
  options_: options,
704
759
  make_: make_$2,
705
- extend_: extend_$2
760
+ extend_: extend_$2,
761
+ decorate_20223_: decorate_20223_$2
706
762
  };
707
763
  }
708
764
  function make_$2(adm, key, descriptor, source) {
709
765
  var _this$options_;
710
766
  // own
711
767
  if (source === adm.target_) {
712
- return this.extend_(adm, key, descriptor, false) === null ? 0 /* Cancel */ : 2 /* Continue */;
768
+ return this.extend_(adm, key, descriptor, false) === null ? 0 /* MakeResult.Cancel */ : 2 /* MakeResult.Continue */;
713
769
  }
714
770
  // prototype
715
771
  // bound - must annotate protos to support super.flow()
716
772
  if ((_this$options_ = this.options_) != null && _this$options_.bound && (!hasProp(adm.target_, key) || !isFlow(adm.target_[key]))) {
717
773
  if (this.extend_(adm, key, descriptor, false) === null) {
718
- return 0 /* Cancel */;
774
+ return 0 /* MakeResult.Cancel */;
719
775
  }
720
776
  }
721
777
 
722
778
  if (isFlow(descriptor.value)) {
723
779
  // A prototype could have been annotated already by other constructor,
724
780
  // rest of the proto chain must be annotated already
725
- return 1 /* Break */;
781
+ return 1 /* MakeResult.Break */;
726
782
  }
727
783
 
728
784
  var flowDescriptor = createFlowDescriptor(adm, this, key, descriptor, false, false);
729
785
  defineProperty(source, key, flowDescriptor);
730
- return 2 /* Continue */;
786
+ return 2 /* MakeResult.Continue */;
731
787
  }
732
788
 
733
789
  function extend_$2(adm, key, descriptor, proxyTrap) {
@@ -735,6 +791,26 @@ function extend_$2(adm, key, descriptor, proxyTrap) {
735
791
  var flowDescriptor = createFlowDescriptor(adm, this, key, descriptor, (_this$options_2 = this.options_) == null ? void 0 : _this$options_2.bound);
736
792
  return adm.defineProperty_(key, flowDescriptor, proxyTrap);
737
793
  }
794
+ function decorate_20223_$2(mthd, context) {
795
+ var _this$options_3;
796
+ {
797
+ assert20223DecoratorType(context, ["method"]);
798
+ }
799
+ var name = context.name,
800
+ addInitializer = context.addInitializer;
801
+ if (!isFlow(mthd)) {
802
+ mthd = flow(mthd);
803
+ }
804
+ if ((_this$options_3 = this.options_) != null && _this$options_3.bound) {
805
+ addInitializer(function () {
806
+ var self = this;
807
+ var bound = self[name].bind(self);
808
+ bound.isMobXFlow = true;
809
+ self[name] = bound;
810
+ });
811
+ }
812
+ return mthd;
813
+ }
738
814
  function assertFlowDescriptor(adm, _ref, key, _ref2) {
739
815
  var annotationType_ = _ref.annotationType_;
740
816
  var value = _ref2.value;
@@ -779,11 +855,12 @@ function createComputedAnnotation(name, options) {
779
855
  annotationType_: name,
780
856
  options_: options,
781
857
  make_: make_$3,
782
- extend_: extend_$3
858
+ extend_: extend_$3,
859
+ decorate_20223_: decorate_20223_$3
783
860
  };
784
861
  }
785
862
  function make_$3(adm, key, descriptor) {
786
- return this.extend_(adm, key, descriptor, false) === null ? 0 /* Cancel */ : 1 /* Break */;
863
+ return this.extend_(adm, key, descriptor, false) === null ? 0 /* MakeResult.Cancel */ : 1 /* MakeResult.Break */;
787
864
  }
788
865
 
789
866
  function extend_$3(adm, key, descriptor, proxyTrap) {
@@ -793,6 +870,26 @@ function extend_$3(adm, key, descriptor, proxyTrap) {
793
870
  set: descriptor.set
794
871
  }), proxyTrap);
795
872
  }
873
+ function decorate_20223_$3(get, context) {
874
+ {
875
+ assert20223DecoratorType(context, ["getter"]);
876
+ }
877
+ var ann = this;
878
+ var key = context.name,
879
+ addInitializer = context.addInitializer;
880
+ addInitializer(function () {
881
+ var adm = asObservableObject(this)[$mobx];
882
+ var options = _extends({}, ann.options_, {
883
+ get: get,
884
+ context: this
885
+ });
886
+ options.name || (options.name = adm.name_ + "." + key.toString() );
887
+ adm.values_.set(key, new ComputedValue(options));
888
+ });
889
+ return function () {
890
+ return this[$mobx].getObservablePropValue_(key);
891
+ };
892
+ }
796
893
  function assertComputedDescriptor(adm, _ref, key, _ref2) {
797
894
  var annotationType_ = _ref.annotationType_;
798
895
  var get = _ref2.get;
@@ -806,11 +903,12 @@ function createObservableAnnotation(name, options) {
806
903
  annotationType_: name,
807
904
  options_: options,
808
905
  make_: make_$4,
809
- extend_: extend_$4
906
+ extend_: extend_$4,
907
+ decorate_20223_: decorate_20223_$4
810
908
  };
811
909
  }
812
910
  function make_$4(adm, key, descriptor) {
813
- return this.extend_(adm, key, descriptor, false) === null ? 0 /* Cancel */ : 1 /* Break */;
911
+ return this.extend_(adm, key, descriptor, false) === null ? 0 /* MakeResult.Cancel */ : 1 /* MakeResult.Break */;
814
912
  }
815
913
 
816
914
  function extend_$4(adm, key, descriptor, proxyTrap) {
@@ -818,6 +916,58 @@ function extend_$4(adm, key, descriptor, proxyTrap) {
818
916
  assertObservableDescriptor(adm, this, key, descriptor);
819
917
  return adm.defineObservableProperty_(key, descriptor.value, (_this$options_$enhanc = (_this$options_ = this.options_) == null ? void 0 : _this$options_.enhancer) != null ? _this$options_$enhanc : deepEnhancer, proxyTrap);
820
918
  }
919
+ function decorate_20223_$4(desc, context) {
920
+ {
921
+ 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
+ }
821
971
  function assertObservableDescriptor(adm, _ref, key, descriptor) {
822
972
  var annotationType_ = _ref.annotationType_;
823
973
  if ( !("value" in descriptor)) {
@@ -832,7 +982,8 @@ function createAutoAnnotation(options) {
832
982
  annotationType_: AUTO,
833
983
  options_: options,
834
984
  make_: make_$5,
835
- extend_: extend_$5
985
+ extend_: extend_$5,
986
+ decorate_20223_: decorate_20223_$5
836
987
  };
837
988
  }
838
989
  function make_$5(adm, key, descriptor, source) {
@@ -850,14 +1001,14 @@ function make_$5(adm, key, descriptor, source) {
850
1001
  return adm.defineProperty_(key, {
851
1002
  configurable: globalState.safeDescriptors ? adm.isPlainObject_ : true,
852
1003
  set: set
853
- }) === null ? 0 /* Cancel */ : 2 /* Continue */;
1004
+ }) === null ? 0 /* MakeResult.Cancel */ : 2 /* MakeResult.Continue */;
854
1005
  }
855
1006
  // proto
856
1007
  defineProperty(source, key, {
857
1008
  configurable: true,
858
1009
  set: set
859
1010
  });
860
- return 2 /* Continue */;
1011
+ return 2 /* MakeResult.Continue */;
861
1012
  }
862
1013
  // function on proto -> autoAction/flow
863
1014
  if (source !== adm.target_ && typeof descriptor.value === "function") {
@@ -904,6 +1055,9 @@ function extend_$5(adm, key, descriptor, proxyTrap) {
904
1055
  var observableAnnotation = ((_this$options_6 = this.options_) == null ? void 0 : _this$options_6.deep) === false ? observable.ref : observable;
905
1056
  return observableAnnotation.extend_(adm, key, descriptor, proxyTrap);
906
1057
  }
1058
+ function decorate_20223_$5(desc, context) {
1059
+ die("'" + this.annotationType_ + "' cannot be used as a decorator");
1060
+ }
907
1061
 
908
1062
  var OBSERVABLE = "observable";
909
1063
  var OBSERVABLE_REF = "observable.ref";
@@ -943,11 +1097,15 @@ function getEnhancerFromAnnotation(annotation) {
943
1097
  var _annotation$options_$, _annotation$options_;
944
1098
  return !annotation ? deepEnhancer : (_annotation$options_$ = (_annotation$options_ = annotation.options_) == null ? void 0 : _annotation$options_.enhancer) != null ? _annotation$options_$ : deepEnhancer;
945
1099
  }
946
- /**
947
- * Turns an object, array or function into a reactive structure.
948
- * @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.
949
1103
  */
950
1104
  function createObservable(v, arg2, arg3) {
1105
+ // @observable someProp; (2022.3 Decorators)
1106
+ if (is20223Decorator(arg2)) {
1107
+ return observableAnnotation.decorate_20223_(v, arg2);
1108
+ }
951
1109
  // @observable someProp;
952
1110
  if (isStringish(arg2)) {
953
1111
  storeAnnotation(v, arg2, observableAnnotation);
@@ -1017,11 +1175,15 @@ var computedAnnotation = /*#__PURE__*/createComputedAnnotation(COMPUTED);
1017
1175
  var computedStructAnnotation = /*#__PURE__*/createComputedAnnotation(COMPUTED_STRUCT, {
1018
1176
  equals: comparer.structural
1019
1177
  });
1020
- /**
1021
- * Decorator for class properties: @computed get value() { return expr; }.
1022
- * 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)`;
1023
1181
  */
1024
1182
  var computed = function computed(arg1, arg2) {
1183
+ if (is20223Decorator(arg2)) {
1184
+ // @computed (2022.3 Decorators)
1185
+ return computedAnnotation.decorate_20223_(arg1, arg2);
1186
+ }
1025
1187
  if (isStringish(arg2)) {
1026
1188
  // @computed
1027
1189
  return storeAnnotation(arg1, arg2, computedAnnotation);
@@ -1308,24 +1470,24 @@ var ObservableValue = /*#__PURE__*/function (_Atom) {
1308
1470
  var isObservableValue = /*#__PURE__*/createInstanceofPredicate("ObservableValue", ObservableValue);
1309
1471
 
1310
1472
  var _Symbol$toPrimitive$1;
1311
- /**
1312
- * A node in the state dependency root that observes other nodes, and can be observed itself.
1313
- *
1314
- * ComputedValue will remember the result of the computation for the duration of the batch, or
1315
- * while being observed.
1316
- *
1317
- * During this time it will recompute only when one of its direct dependencies changed,
1318
- * but only when it is being accessed with `ComputedValue.get()`.
1319
- *
1320
- * Implementation description:
1321
- * 1. First time it's being accessed it will compute and remember result
1322
- * give back remembered result until 2. happens
1323
- * 2. First time any deep dependency change, propagate POSSIBLY_STALE to all observers, wait for 3.
1324
- * 3. When it's being accessed, recompute if any shallow dependency changed.
1325
- * if result changed: propagate STALE to all observers, that were POSSIBLY_STALE from the last step.
1326
- * go to step 2. either way
1327
- *
1328
- * If at any point it's outside batch and it isn't observed: reset everything and go to 1.
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.
1329
1491
  */
1330
1492
  _Symbol$toPrimitive$1 = Symbol.toPrimitive;
1331
1493
  var ComputedValue = /*#__PURE__*/function () {
@@ -1336,17 +1498,17 @@ var ComputedValue = /*#__PURE__*/function () {
1336
1498
 
1337
1499
  // N.B: unminified as it is used by MST
1338
1500
 
1339
- /**
1340
- * Create a new computed value based on a function expression.
1341
- *
1342
- * The `name` property is for debug purposes only.
1343
- *
1344
- * The `equals` property specifies the comparer function to use to determine if a newly produced
1345
- * value differs from the previous value. Two comparers are provided in the library; `defaultComparer`
1346
- * compares based on identity comparison (===), and `structuralComparer` deeply compares the structure.
1347
- * Structural comparison can be convenient if you always produce a new aggregated object and
1348
- * don't want to notify observers if it is structurally the same.
1349
- * This is useful for working with vectors, mouse coordinates etc.
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.
1350
1512
  */
1351
1513
  function ComputedValue(options) {
1352
1514
  this.dependenciesState_ = IDerivationState_.NOT_TRACKING_;
@@ -1405,9 +1567,9 @@ var ComputedValue = /*#__PURE__*/function () {
1405
1567
  });
1406
1568
  }
1407
1569
  }
1408
- /**
1409
- * Returns the current value of this computed value.
1410
- * 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.
1411
1573
  */;
1412
1574
  _proto.get = function get() {
1413
1575
  if (this.isComputing_) {
@@ -1587,16 +1749,16 @@ var CaughtException = function CaughtException(cause) {
1587
1749
  function isCaughtException(e) {
1588
1750
  return e instanceof CaughtException;
1589
1751
  }
1590
- /**
1591
- * Finds out whether any dependency of the derivation has actually changed.
1592
- * If dependenciesState is 1 then it will recalculate dependencies,
1593
- * if any dependency changed it will propagate it by changing dependenciesState to 2.
1594
- *
1595
- * By iterating over the dependencies in the same order that they were reported and
1596
- * stopping on the first change, all the recalculations are only called for ComputedValues
1597
- * that will be tracked by derivation. That is because we assume that if the first x
1598
- * dependencies of the derivation doesn't change then the derivation should run the same way
1599
- * up until accessing x-th dependency.
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.
1600
1762
  */
1601
1763
  function shouldCompute(derivation) {
1602
1764
  switch (derivation.dependenciesState_) {
@@ -1660,10 +1822,10 @@ function checkIfStateReadsAreAllowed(observable) {
1660
1822
  console.warn("[mobx] Observable '" + observable.name_ + "' being read outside a reactive context.");
1661
1823
  }
1662
1824
  }
1663
- /**
1664
- * Executes the provided function `f` and tracks which observables are being accessed.
1665
- * The tracking information is stored on the `derivation` object and the derivation is registered
1666
- * as observer of any of the accessed observables.
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.
1667
1829
  */
1668
1830
  function trackDerivedFunction(derivation, f, context) {
1669
1831
  var prevAllowStateReads = allowStateReadsStart(true);
@@ -1701,10 +1863,10 @@ function warnAboutDerivationWithoutDependencies(derivation) {
1701
1863
  console.warn("[mobx] Derivation '" + derivation.name_ + "' is created/updated without reading any observable value.");
1702
1864
  }
1703
1865
  }
1704
- /**
1705
- * diffs newObserving with observing.
1706
- * update observing to be newObserving with unique observables
1707
- * 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
1708
1870
  */
1709
1871
  function bindDependencies(derivation) {
1710
1872
  // invariant(derivation.dependenciesState !== IDerivationState.NOT_TRACKING, "INTERNAL ERROR bindDependencies expects derivation.dependenciesState !== -1");
@@ -1795,9 +1957,9 @@ function allowStateReadsStart(allowStateReads) {
1795
1957
  function allowStateReadsEnd(prev) {
1796
1958
  globalState.allowStateReads = prev;
1797
1959
  }
1798
- /**
1799
- * needed to keep `lowestObserverState` correct. when changing from (2 or 1) to 0
1800
- *
1960
+ /**
1961
+ * needed to keep `lowestObserverState` correct. when changing from (2 or 1) to 0
1962
+ *
1801
1963
  */
1802
1964
  function changeDependenciesStateTo0(derivation) {
1803
1965
  if (derivation.dependenciesState_ === IDerivationState_.UP_TO_DATE_) {
@@ -1811,8 +1973,8 @@ function changeDependenciesStateTo0(derivation) {
1811
1973
  }
1812
1974
  }
1813
1975
 
1814
- /**
1815
- * These values will persist if global state is reset
1976
+ /**
1977
+ * These values will persist if global state is reset
1816
1978
  */
1817
1979
  var persistentKeys = ["mobxGuid", "spyListeners", "enforceActions", "computedRequiresReaction", "reactionRequiresObservable", "observableRequiresReaction", "allowStateReads", "disableErrorBoundaries", "runId", "UNCHANGED", "useProxies"];
1818
1980
  var MobXGlobals = function MobXGlobals() {
@@ -1888,9 +2050,9 @@ function isolateGlobalState() {
1888
2050
  function getGlobalState() {
1889
2051
  return globalState;
1890
2052
  }
1891
- /**
1892
- * For testing purposes only; this will break the internal state of existing observables,
1893
- * but can be used to get back at a stable state after throwing errors
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
1894
2056
  */
1895
2057
  function resetGlobalState() {
1896
2058
  var defaultGlobals = new MobXGlobals();
@@ -1957,10 +2119,10 @@ function queueForUnobservation(observable) {
1957
2119
  globalState.pendingUnobservations.push(observable);
1958
2120
  }
1959
2121
  }
1960
- /**
1961
- * Batch starts a transaction, at least for purposes of memoizing ComputedValues when nothing else does.
1962
- * During a batch `onBecomeUnobserved` will be called at most once per observable.
1963
- * Avoids unnecessary recalculations.
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.
1964
2126
  */
1965
2127
  function startBatch() {
1966
2128
  if (globalState.inBatch === 0) {
@@ -1996,10 +2158,10 @@ function reportObserved(observable) {
1996
2158
  checkIfStateReadsAreAllowed(observable);
1997
2159
  var derivation = globalState.trackingDerivation;
1998
2160
  if (derivation !== null) {
1999
- /**
2000
- * Simple optimization, give each derivation run an unique id (runId)
2001
- * Check if last time this observable was accessed the same runId is used
2002
- * if this is the case, the relation is already known
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
2003
2165
  */
2004
2166
  if (derivation.runId_ !== observable.lastAccessedBy_) {
2005
2167
  observable.lastAccessedBy_ = derivation.runId_;
@@ -2029,12 +2191,12 @@ function reportObserved(observable) {
2029
2191
  // observable.lowestObserverState
2030
2192
  // )
2031
2193
  // }
2032
- /**
2033
- * NOTE: current propagation mechanism will in case of self reruning autoruns behave unexpectedly
2034
- * It will propagate changes to observers from previous run
2035
- * It's hard or maybe impossible (with reasonable perf) to get it right with current approach
2036
- * Hopefully self reruning autoruns aren't a feature people should depend on
2037
- * Also most basic use cases should be ok
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
2038
2200
  */
2039
2201
  // Called by Atom when its value changes
2040
2202
  function propagateChanged(observable) {
@@ -2154,8 +2316,8 @@ var Reaction = /*#__PURE__*/function () {
2154
2316
  _proto.isScheduled = function isScheduled() {
2155
2317
  return this.isScheduled_;
2156
2318
  }
2157
- /**
2158
- * internal, use schedule() if you intend to kick off a reaction
2319
+ /**
2320
+ * internal, use schedule() if you intend to kick off a reaction
2159
2321
  */;
2160
2322
  _proto.runReaction_ = function runReaction_() {
2161
2323
  if (!this.isDisposed_) {
@@ -2288,10 +2450,10 @@ function onReactionError(handler) {
2288
2450
  }
2289
2451
  };
2290
2452
  }
2291
- /**
2292
- * Magic number alert!
2293
- * Defines within how many times a reaction is allowed to re-trigger itself
2294
- * until it is assumed that this is gonna be a never ending loop...
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...
2295
2457
  */
2296
2458
  var MAX_REACTION_ITERATIONS = 100;
2297
2459
  var reactionScheduler = function reactionScheduler(f) {
@@ -2403,6 +2565,10 @@ function createActionFactory(autoAction) {
2403
2565
  if (isFunction(arg2)) {
2404
2566
  return createAction(arg1, arg2, autoAction);
2405
2567
  }
2568
+ // @action (2022.3 Decorators)
2569
+ if (is20223Decorator(arg2)) {
2570
+ return (autoAction ? autoActionAnnotation : actionAnnotation).decorate_20223_(arg1, arg2);
2571
+ }
2406
2572
  // @action
2407
2573
  if (isStringish(arg2)) {
2408
2574
  return storeAnnotation(arg1, arg2, autoAction ? autoActionAnnotation : actionAnnotation);
@@ -2433,11 +2599,11 @@ function isAction(thing) {
2433
2599
  return isFunction(thing) && thing.isMobxAction === true;
2434
2600
  }
2435
2601
 
2436
- /**
2437
- * Creates a named reactive view and keeps it alive, so that the view is always
2438
- * updated if one of the dependencies changes, even when the view is not further used by something else.
2439
- * @param view The reactive view
2440
- * @returns disposer function, which can be used to stop the view from being updated in the future.
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.
2441
2607
  */
2442
2608
  function autorun(view, opts) {
2443
2609
  var _opts$name, _opts, _opts2, _opts2$signal, _opts3;
@@ -2693,6 +2859,10 @@ var flowBoundAnnotation = /*#__PURE__*/createFlowAnnotation("flow.bound", {
2693
2859
  bound: true
2694
2860
  });
2695
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
+ }
2696
2866
  // @flow
2697
2867
  if (isStringish(arg2)) {
2698
2868
  return storeAnnotation(arg1, arg2, flowAnnotation);
@@ -3079,11 +3249,11 @@ function toJSHelper(source, __alreadySeen) {
3079
3249
  return _res3;
3080
3250
  }
3081
3251
  }
3082
- /**
3083
- * Recursively converts an observable to it's non-observable native counterpart.
3084
- * It does NOT recurse into non-observables, these are left as they are, even if they contain observables.
3085
- * Computed and other non-enumerable properties are completely ignored.
3086
- * Complex scenarios require custom solution, eg implementing `toJSON` or using `serializr` lib.
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.
3087
3257
  */
3088
3258
  function toJS(source, options) {
3089
3259
  if ( options) {
@@ -3120,12 +3290,12 @@ function getAtomFromArgs(args) {
3120
3290
  }
3121
3291
  }
3122
3292
 
3123
- /**
3124
- * During a transaction no views are updated until the end of the transaction.
3125
- * The transaction will be run synchronously nonetheless.
3126
- *
3127
- * @param action a function that updates some reactive state
3128
- * @returns any value that was returned by the 'action' parameter.
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.
3129
3299
  */
3130
3300
  function transaction(action, thisArg) {
3131
3301
  if (thisArg === void 0) {
@@ -3713,11 +3883,11 @@ var arrayExtensions = {
3713
3883
  toJSON: function toJSON() {
3714
3884
  return this.slice();
3715
3885
  },
3716
- /*
3717
- * functions that do alter the internal structure of the array, (based on lib.es6.d.ts)
3718
- * since these functions alter the inner structure of the array, the have side effects.
3719
- * Because the have side effects, they should not be used in computed function,
3720
- * and for that reason the do not call dependencyState.notifyObserved
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
3721
3891
  */
3722
3892
  splice: function splice(index, deleteCount) {
3723
3893
  for (var _len = arguments.length, newItems = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
@@ -3789,10 +3959,10 @@ var arrayExtensions = {
3789
3959
  return false;
3790
3960
  }
3791
3961
  };
3792
- /**
3793
- * Wrap function from prototype
3794
- * Without this, everything works as well, but this works
3795
- * 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
3796
3966
  */
3797
3967
  addArrayExtension("concat", simpleFunc);
3798
3968
  addArrayExtension("flat", simpleFunc);
@@ -4232,10 +4402,10 @@ var ObservableMap = /*#__PURE__*/function () {
4232
4402
  _proto.toJSON = function toJSON() {
4233
4403
  return Array.from(this);
4234
4404
  };
4235
- /**
4236
- * Observes this object. Triggers for the events 'add', 'update' and 'delete'.
4237
- * See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/observe
4238
- * for callback details
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
4239
4409
  */
4240
4410
  _proto.observe_ = function observe_(listener, fireImmediately) {
4241
4411
  if ( fireImmediately === true) {
@@ -4611,12 +4781,12 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
4611
4781
  }
4612
4782
  return this.target_[key];
4613
4783
  }
4614
- /**
4615
- * @param {PropertyKey} key
4616
- * @param {any} value
4617
- * @param {Annotation|boolean} annotation true - use default annotation, false - copy as is
4618
- * @param {boolean} proxyTrap whether it's called from proxy trap
4619
- * @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor
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
4620
4790
  */;
4621
4791
  _proto.set_ = function set_(key, value, proxyTrap) {
4622
4792
  if (proxyTrap === void 0) {
@@ -4661,9 +4831,9 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
4661
4831
  }
4662
4832
  return entry.get();
4663
4833
  }
4664
- /**
4665
- * @param {PropertyKey} key
4666
- * @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
4667
4837
  */;
4668
4838
  _proto.make_ = function make_(key, annotation) {
4669
4839
  if (annotation === true) {
@@ -4691,10 +4861,10 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
4691
4861
  var descriptor = getDescriptor(source, key);
4692
4862
  if (descriptor) {
4693
4863
  var outcome = annotation.make_(this, key, descriptor, source);
4694
- if (outcome === 0 /* Cancel */) {
4864
+ if (outcome === 0 /* MakeResult.Cancel */) {
4695
4865
  return;
4696
4866
  }
4697
- if (outcome === 1 /* Break */) {
4867
+ if (outcome === 1 /* MakeResult.Break */) {
4698
4868
  break;
4699
4869
  }
4700
4870
  }
@@ -4702,12 +4872,12 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
4702
4872
  }
4703
4873
  recordAnnotationApplied(this, annotation, key);
4704
4874
  }
4705
- /**
4706
- * @param {PropertyKey} key
4707
- * @param {PropertyDescriptor} descriptor
4708
- * @param {Annotation|boolean} annotation true - use default annotation, false - copy as is
4709
- * @param {boolean} proxyTrap whether it's called from proxy trap
4710
- * @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor
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
4711
4881
  */;
4712
4882
  _proto.extend_ = function extend_(key, descriptor, annotation, proxyTrap) {
4713
4883
  if (proxyTrap === void 0) {
@@ -4726,11 +4896,11 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
4726
4896
  }
4727
4897
  return outcome;
4728
4898
  }
4729
- /**
4730
- * @param {PropertyKey} key
4731
- * @param {PropertyDescriptor} descriptor
4732
- * @param {boolean} proxyTrap whether it's called from proxy trap
4733
- * @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor
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
4734
4904
  */;
4735
4905
  _proto.defineProperty_ = function defineProperty_(key, descriptor, proxyTrap) {
4736
4906
  if (proxyTrap === void 0) {
@@ -4882,11 +5052,11 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
4882
5052
  }
4883
5053
  return true;
4884
5054
  }
4885
- /**
4886
- * @param {PropertyKey} key
4887
- * @param {PropertyDescriptor} descriptor
4888
- * @param {boolean} proxyTrap whether it's called from proxy trap
4889
- * @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor
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
4890
5060
  */;
4891
5061
  _proto.delete_ = function delete_(key, proxyTrap) {
4892
5062
  if (proxyTrap === void 0) {
@@ -4975,10 +5145,10 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
4975
5145
  }
4976
5146
  return true;
4977
5147
  }
4978
- /**
4979
- * Observes this object. Triggers for the events 'add', 'update' and 'delete'.
4980
- * See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/observe
4981
- * for callback details
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
4982
5152
  */;
4983
5153
  _proto.observe_ = function observe_(callback, fireImmediately) {
4984
5154
  if ( fireImmediately === true) {
@@ -5081,35 +5251,35 @@ function assertAnnotable(adm, annotation, key) {
5081
5251
  if ( !isAnnotation(annotation)) {
5082
5252
  die("Cannot annotate '" + adm.name_ + "." + key.toString() + "': Invalid annotation.");
5083
5253
  }
5084
- /*
5085
- // Configurable, not sealed, not frozen
5086
- // Possibly not needed, just a little better error then the one thrown by engine.
5087
- // Cases where this would be useful the most (subclass field initializer) are not interceptable by this.
5088
- if (__DEV__) {
5089
- const configurable = getDescriptor(adm.target_, key)?.configurable
5090
- const frozen = Object.isFrozen(adm.target_)
5091
- const sealed = Object.isSealed(adm.target_)
5092
- if (!configurable || frozen || sealed) {
5093
- const fieldName = `${adm.name_}.${key.toString()}`
5094
- const requestedAnnotationType = annotation.annotationType_
5095
- let error = `Cannot apply '${requestedAnnotationType}' to '${fieldName}':`
5096
- if (frozen) {
5097
- error += `\nObject is frozen.`
5098
- }
5099
- if (sealed) {
5100
- error += `\nObject is sealed.`
5101
- }
5102
- if (!configurable) {
5103
- error += `\nproperty is not configurable.`
5104
- // Mention only if caused by us to avoid confusion
5105
- if (hasProp(adm.appliedAnnotations!, key)) {
5106
- error += `\nTo prevent accidental re-definition of a field by a subclass, `
5107
- error += `all annotated fields of non-plain objects (classes) are not configurable.`
5108
- }
5109
- }
5110
- die(error)
5111
- }
5112
- }
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
+ }
5113
5283
  */
5114
5284
  // Not annotated
5115
5285
  if ( !isOverride(annotation) && hasProp(adm.appliedAnnotations_, key)) {
@@ -5133,10 +5303,10 @@ var safariPrototypeSetterInheritanceBug = /*#__PURE__*/function () {
5133
5303
  /*#__PURE__*/Object.create(p)["0"] = 1;
5134
5304
  return v === false;
5135
5305
  }();
5136
- /**
5137
- * This array buffer contains two lists of properties, so that all arrays
5138
- * can recycle their property definitions, which significantly improves performance of creating
5139
- * properties on the fly.
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.
5140
5310
  */
5141
5311
  var OBSERVABLE_ARRAY_BUFFER_SIZE = 0;
5142
5312
  // Typescript workaround to make sure ObservableArray extends Array
@@ -5333,11 +5503,11 @@ function getDebugName(thing, property) {
5333
5503
  }
5334
5504
  return named.name_;
5335
5505
  }
5336
- /**
5337
- * Helper function for initializing observable structures, it applies:
5338
- * 1. allowStateChanges so we don't violate enforceActions.
5339
- * 2. untracked so we don't accidentaly subscribe to anything observable accessed during init in case the observable is created inside derivation.
5340
- * 3. batch to avoid state version updates
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
5341
5511
  */
5342
5512
  function initObservable(cb) {
5343
5513
  var derivation = untrackedStart();
@@ -5519,22 +5689,22 @@ function isAnnotation(thing) {
5519
5689
  );
5520
5690
  }
5521
5691
 
5522
- /**
5523
- * (c) Michel Weststrate 2015 - 2020
5524
- * MIT Licensed
5525
- *
5526
- * Welcome to the mobx sources! To get a global overview of how MobX internally works,
5527
- * this is a good place to start:
5528
- * https://medium.com/@mweststrate/becoming-fully-reactive-an-in-depth-explanation-of-mobservable-55995262a254#.xvbh6qd74
5529
- *
5530
- * Source folders:
5531
- * ===============
5532
- *
5533
- * - api/ Most of the public static methods exposed by the module can be found here.
5534
- * - core/ Implementation of the MobX algorithm; atoms, derivations, reactions, dependency trees, optimizations. Cool stuff can be found here.
5535
- * - types/ All the magic that is need to have observable objects, arrays and values is in this folder. Including the modifiers like `asFlat`.
5536
- * - utils/ Utility stuff.
5537
- *
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
+ *
5538
5708
  */
5539
5709
  ["Symbol", "Map", "Set"].forEach(function (m) {
5540
5710
  var g = getGlobal();