mobx 6.1.4 → 6.1.8

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 (47) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/dist/api/annotation.d.ts +0 -1
  3. package/dist/api/iscomputed.d.ts +2 -2
  4. package/dist/core/computedvalue.d.ts +0 -1
  5. package/dist/core/derivation.d.ts +0 -1
  6. package/dist/core/reaction.d.ts +0 -1
  7. package/dist/mobx.cjs.development.js +92 -46
  8. package/dist/mobx.cjs.development.js.map +1 -1
  9. package/dist/mobx.cjs.production.min.js +1 -1
  10. package/dist/mobx.cjs.production.min.js.map +1 -1
  11. package/dist/mobx.esm.development.js +92 -46
  12. package/dist/mobx.esm.development.js.map +1 -1
  13. package/dist/mobx.esm.js +92 -46
  14. package/dist/mobx.esm.js.map +1 -1
  15. package/dist/mobx.esm.production.min.js +1 -1
  16. package/dist/mobx.esm.production.min.js.map +1 -1
  17. package/dist/mobx.umd.development.js +92 -46
  18. package/dist/mobx.umd.development.js.map +1 -1
  19. package/dist/mobx.umd.production.min.js +1 -1
  20. package/dist/mobx.umd.production.min.js.map +1 -1
  21. package/dist/types/observablearray.d.ts +1 -1
  22. package/dist/types/type-utils.d.ts +1 -1
  23. package/package.json +1 -1
  24. package/src/api/annotation.ts +0 -1
  25. package/src/api/autorun.ts +3 -2
  26. package/src/api/computed.ts +1 -1
  27. package/src/api/decorators.ts +1 -4
  28. package/src/api/iscomputed.ts +2 -2
  29. package/src/api/makeObservable.ts +10 -2
  30. package/src/api/observable.ts +1 -1
  31. package/src/api/when.ts +5 -2
  32. package/src/core/atom.ts +1 -1
  33. package/src/core/computedvalue.ts +7 -3
  34. package/src/core/derivation.ts +0 -1
  35. package/src/core/reaction.ts +1 -2
  36. package/src/types/actionannotation.ts +3 -2
  37. package/src/types/computedannotation.ts +3 -2
  38. package/src/types/flowannotation.ts +3 -2
  39. package/src/types/legacyobservablearray.ts +1 -1
  40. package/src/types/observableannotation.ts +3 -2
  41. package/src/types/observablearray.ts +5 -4
  42. package/src/types/observablemap.ts +4 -4
  43. package/src/types/observableobject.ts +27 -14
  44. package/src/types/observableset.ts +1 -1
  45. package/src/types/observablevalue.ts +1 -1
  46. package/src/types/type-utils.ts +11 -4
  47. package/src/utils/global.ts +3 -0
package/dist/mobx.esm.js CHANGED
@@ -78,6 +78,10 @@ function die(error) {
78
78
 
79
79
  var mockGlobal = {};
80
80
  function getGlobal() {
81
+ if (typeof globalThis !== "undefined") {
82
+ return globalThis;
83
+ }
84
+
81
85
  if (typeof window !== "undefined") {
82
86
  return window;
83
87
  }
@@ -359,9 +363,7 @@ function storeAnnotation(prototype, key, annotation) {
359
363
  assertNotDecorated(prototype, annotation, key); // Ignore override
360
364
 
361
365
  if (!isOverride(annotation)) {
362
- prototype[storedAnnotationsSymbol][key] = _extends({}, annotation, {
363
- isDecorator_: true
364
- });
366
+ prototype[storedAnnotationsSymbol][key] = annotation;
365
367
  }
366
368
  }
367
369
 
@@ -401,7 +403,7 @@ var Atom = /*#__PURE__*/function () {
401
403
  */
402
404
  function Atom(name_) {
403
405
  if (name_ === void 0) {
404
- name_ = "Atom@" + getNextId();
406
+ name_ = process.env.NODE_ENV !== "production" ? "Atom@" + getNextId() : "Atom";
405
407
  }
406
408
 
407
409
  this.name_ = void 0;
@@ -591,7 +593,7 @@ function createActionAnnotation(name, options) {
591
593
  }
592
594
 
593
595
  function make_$1(adm, key) {
594
- var _this$options_$bound, _this$options_;
596
+ var _this$options_$bound, _this$options_, _adm$target_$storedAn;
595
597
 
596
598
  var annotated = false;
597
599
  var source = adm.target_;
@@ -641,7 +643,7 @@ function make_$1(adm, key) {
641
643
 
642
644
  if (annotated) {
643
645
  recordAnnotationApplied(adm, this, key);
644
- } else if (!this.isDecorator_) {
646
+ } else if (!((_adm$target_$storedAn = adm.target_[storedAnnotationsSymbol]) == null ? void 0 : _adm$target_$storedAn[key])) {
645
647
  // Throw on missing key, except for decorators:
646
648
  // Decorator annotations are collected from whole prototype chain.
647
649
  // When called from super() some props may not exist yet.
@@ -705,6 +707,8 @@ function createFlowAnnotation(name, options) {
705
707
  }
706
708
 
707
709
  function make_$2(adm, key) {
710
+ var _adm$target_$storedAn;
711
+
708
712
  var annotated = false;
709
713
  var source = adm.target_;
710
714
 
@@ -742,7 +746,7 @@ function make_$2(adm, key) {
742
746
 
743
747
  if (annotated) {
744
748
  recordAnnotationApplied(adm, this, key);
745
- } else if (!this.isDecorator_) {
749
+ } else if (!((_adm$target_$storedAn = adm.target_[storedAnnotationsSymbol]) == null ? void 0 : _adm$target_$storedAn[key])) {
746
750
  // Throw on missing key, except for decorators:
747
751
  // Decorator annotations are collected from whole prototype chain.
748
752
  // When called from super() some props may not exist yet.
@@ -796,6 +800,8 @@ function createComputedAnnotation(name, options) {
796
800
  }
797
801
 
798
802
  function make_$3(adm, key) {
803
+ var _adm$target_$storedAn;
804
+
799
805
  var source = adm.target_;
800
806
 
801
807
  while (source && source !== objectPrototype) {
@@ -820,7 +826,7 @@ function make_$3(adm, key) {
820
826
  source = Object.getPrototypeOf(source);
821
827
  }
822
828
 
823
- if (!this.isDecorator_) {
829
+ if (!((_adm$target_$storedAn = adm.target_[storedAnnotationsSymbol]) == null ? void 0 : _adm$target_$storedAn[key])) {
824
830
  // Throw on missing key, except for decorators:
825
831
  // Decorator annotations are collected from whole prototype chain.
826
832
  // When called from super() some props may not exist yet.
@@ -857,6 +863,8 @@ function createObservableAnnotation(name, options) {
857
863
  }
858
864
 
859
865
  function make_$4(adm, key) {
866
+ var _adm$target_$storedAn;
867
+
860
868
  var source = adm.target_; // Copy props from proto as well, see test:
861
869
  // "decorate should work with Object.create"
862
870
 
@@ -881,7 +889,7 @@ function make_$4(adm, key) {
881
889
  source = Object.getPrototypeOf(source);
882
890
  }
883
891
 
884
- if (!this.isDecorator_) {
892
+ if (!((_adm$target_$storedAn = adm.target_[storedAnnotationsSymbol]) == null ? void 0 : _adm$target_$storedAn[key])) {
885
893
  // Throw on missing key, except for decorators:
886
894
  // Decorator annotations are collected from whole prototype chain.
887
895
  // When called from super() some props may not exist yet.
@@ -965,7 +973,7 @@ function createObservable(v, arg2, arg3) {
965
973
 
966
974
  if (typeof v === "object" && v !== null) return v; // anything else
967
975
 
968
- return observable.box(v);
976
+ return observable.box(v, arg2);
969
977
  }
970
978
 
971
979
  Object.assign(createObservable, observableDecoratorAnnotation);
@@ -1027,7 +1035,7 @@ var computed = function computed(arg1, arg2) {
1027
1035
 
1028
1036
  var opts = isPlainObject(arg2) ? arg2 : {};
1029
1037
  opts.get = arg1;
1030
- opts.name = opts.name || arg1.name || "";
1038
+ opts.name || (opts.name = arg1.name || "");
1031
1039
  /* for generated name */
1032
1040
 
1033
1041
  return new ComputedValue(opts);
@@ -1175,7 +1183,7 @@ var ObservableValue = /*#__PURE__*/function (_Atom) {
1175
1183
  var _this;
1176
1184
 
1177
1185
  if (name_ === void 0) {
1178
- name_ = "ObservableValue@" + getNextId();
1186
+ name_ = process.env.NODE_ENV !== "production" ? "ObservableValue@" + getNextId() : "ObservableValue";
1179
1187
  }
1180
1188
 
1181
1189
  if (notifySpy === void 0) {
@@ -1375,7 +1383,6 @@ var ComputedValue = /*#__PURE__*/function () {
1375
1383
  this.lastAccessedBy_ = 0;
1376
1384
  this.lowestObserverState_ = IDerivationState_.UP_TO_DATE_;
1377
1385
  this.unboundDepsCount_ = 0;
1378
- this.mapid_ = "#" + getNextId();
1379
1386
  this.value_ = new CaughtException(null);
1380
1387
  this.name_ = void 0;
1381
1388
  this.triggeredBy_ = void 0;
@@ -1392,8 +1399,12 @@ var ComputedValue = /*#__PURE__*/function () {
1392
1399
  this.onBUOL = void 0;
1393
1400
  if (!options.get) die(31);
1394
1401
  this.derivation = options.get;
1395
- this.name_ = options.name || "ComputedValue@" + getNextId();
1396
- if (options.set) this.setter_ = createAction(this.name_ + "-setter", options.set);
1402
+ this.name_ = options.name || (process.env.NODE_ENV !== "production" ? "ComputedValue@" + getNextId() : "ComputedValue");
1403
+
1404
+ if (options.set) {
1405
+ this.setter_ = createAction(process.env.NODE_ENV !== "production" ? this.name_ + "-setter" : "ComputedValue-setter", options.set);
1406
+ }
1407
+
1397
1408
  this.equals_ = options.equals || (options.compareStructural || options.struct ? comparer.structural : comparer["default"]);
1398
1409
  this.scope_ = options.context;
1399
1410
  this.requiresReaction_ = !!options.requiresReaction;
@@ -2169,7 +2180,7 @@ var Reaction = /*#__PURE__*/function () {
2169
2180
  // nodes we are looking at. Our value depends on these nodes
2170
2181
  function Reaction(name_, onInvalidate_, errorHandler_, requiresObservable_) {
2171
2182
  if (name_ === void 0) {
2172
- name_ = "Reaction@" + getNextId();
2183
+ name_ = process.env.NODE_ENV !== "production" ? "Reaction@" + getNextId() : "Reaction";
2173
2184
  }
2174
2185
 
2175
2186
  if (requiresObservable_ === void 0) {
@@ -2186,7 +2197,6 @@ var Reaction = /*#__PURE__*/function () {
2186
2197
  this.diffValue_ = 0;
2187
2198
  this.runId_ = 0;
2188
2199
  this.unboundDepsCount_ = 0;
2189
- this.mapid_ = "#" + getNextId();
2190
2200
  this.isDisposed_ = false;
2191
2201
  this.isScheduled_ = false;
2192
2202
  this.isTrackPending_ = false;
@@ -2525,6 +2535,8 @@ function isAction(thing) {
2525
2535
  */
2526
2536
 
2527
2537
  function autorun(view, opts) {
2538
+ var _opts$name, _opts;
2539
+
2528
2540
  if (opts === void 0) {
2529
2541
  opts = EMPTY_OBJECT;
2530
2542
  }
@@ -2534,7 +2546,7 @@ function autorun(view, opts) {
2534
2546
  if (isAction(view)) die("Autorun does not accept actions since actions are untrackable");
2535
2547
  }
2536
2548
 
2537
- var name = opts && opts.name || view.name || "Autorun@" + getNextId();
2549
+ var name = (_opts$name = (_opts = opts) == null ? void 0 : _opts.name) != null ? _opts$name : process.env.NODE_ENV !== "production" ? view.name || "Autorun@" + getNextId() : "Autorun";
2538
2550
  var runSync = !opts.scheduler && !opts.delay;
2539
2551
  var reaction;
2540
2552
 
@@ -2577,6 +2589,8 @@ function createSchedulerFromOptions(opts) {
2577
2589
  }
2578
2590
 
2579
2591
  function reaction(expression, effect, opts) {
2592
+ var _opts$name2;
2593
+
2580
2594
  if (opts === void 0) {
2581
2595
  opts = EMPTY_OBJECT;
2582
2596
  }
@@ -2586,7 +2600,7 @@ function reaction(expression, effect, opts) {
2586
2600
  if (!isPlainObject(opts)) die("Third argument of reactions should be an object");
2587
2601
  }
2588
2602
 
2589
- var name = opts.name || "Reaction@" + getNextId();
2603
+ var name = (_opts$name2 = opts.name) != null ? _opts$name2 : process.env.NODE_ENV !== "production" ? "Reaction@" + getNextId() : "Reaction";
2590
2604
  var effectAction = action(name, opts.onError ? wrapErrorHandler(opts.onError, effect) : effect);
2591
2605
  var runSync = !opts.scheduler && !opts.delay;
2592
2606
  var scheduler = createSchedulerFromOptions(opts);
@@ -3224,8 +3238,8 @@ function _when(predicate, effect, opts) {
3224
3238
  }, opts.timeout);
3225
3239
  }
3226
3240
 
3227
- opts.name = opts.name || "When@" + getNextId();
3228
- var effectAction = createAction(opts.name + "-effect", effect); // eslint-disable-next-line
3241
+ opts.name = process.env.NODE_ENV !== "production" ? opts.name || "When@" + getNextId() : "When";
3242
+ var effectAction = createAction(process.env.NODE_ENV !== "production" ? opts.name + "-effect" : "When-effect", effect); // eslint-disable-next-line
3229
3243
 
3230
3244
  var disposer = autorun(function (r) {
3231
3245
  // predicate should not change state
@@ -3409,9 +3423,20 @@ function makeAutoObservable(target, overrides, options) {
3409
3423
  startBatch();
3410
3424
 
3411
3425
  try {
3426
+ // Use cached inferred annotations if available (only in classes)
3412
3427
  if (target[inferredAnnotationsSymbol]) {
3413
- for (var key in target[inferredAnnotationsSymbol]) {
3414
- adm.make_(key, target[inferredAnnotationsSymbol][key]);
3428
+ target[inferredAnnotationsSymbol].forEach(function (value, key) {
3429
+ return adm.make_(key, value);
3430
+ }); // Overrides are not cached, unless `true`, see #2832
3431
+
3432
+ if (overrides) {
3433
+ ownKeys(overrides).forEach(function (key) {
3434
+ var annotation = overrides[key];
3435
+
3436
+ if (annotation !== true) {
3437
+ adm.make_(key, annotation);
3438
+ }
3439
+ });
3415
3440
  }
3416
3441
  } else {
3417
3442
  var _ignoreKeys;
@@ -3482,6 +3507,10 @@ var arrayTraps = {
3482
3507
  var ObservableArrayAdministration = /*#__PURE__*/function () {
3483
3508
  // this is the prop that gets proxied, so can't replace it!
3484
3509
  function ObservableArrayAdministration(name, enhancer, owned_, legacyMode_) {
3510
+ if (name === void 0) {
3511
+ name = process.env.NODE_ENV !== "production" ? "ObservableArray@" + getNextId() : "ObservableArray";
3512
+ }
3513
+
3485
3514
  this.owned_ = void 0;
3486
3515
  this.legacyMode_ = void 0;
3487
3516
  this.atom_ = void 0;
@@ -3494,10 +3523,10 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
3494
3523
  this.lastKnownLength_ = 0;
3495
3524
  this.owned_ = owned_;
3496
3525
  this.legacyMode_ = legacyMode_;
3497
- this.atom_ = new Atom(name || "ObservableArray@" + getNextId());
3526
+ this.atom_ = new Atom(name);
3498
3527
 
3499
3528
  this.enhancer_ = function (newV, oldV) {
3500
- return enhancer(newV, oldV, name + "[..]");
3529
+ return enhancer(newV, oldV, process.env.NODE_ENV !== "production" ? name + "[..]" : "ObservableArray[..]");
3501
3530
  };
3502
3531
  }
3503
3532
 
@@ -3712,7 +3741,7 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
3712
3741
  }();
3713
3742
  function createObservableArray(initialValues, enhancer, name, owned) {
3714
3743
  if (name === void 0) {
3715
- name = "ObservableArray@" + getNextId();
3744
+ name = process.env.NODE_ENV !== "production" ? "ObservableArray@" + getNextId() : "ObservableArray";
3716
3745
  }
3717
3746
 
3718
3747
  if (owned === void 0) {
@@ -3934,7 +3963,7 @@ var ObservableMap = /*#__PURE__*/function () {
3934
3963
  }
3935
3964
 
3936
3965
  if (name_ === void 0) {
3937
- name_ = "ObservableMap@" + getNextId();
3966
+ name_ = process.env.NODE_ENV !== "production" ? "ObservableMap@" + getNextId() : "ObservableMap";
3938
3967
  }
3939
3968
 
3940
3969
  this.enhancer_ = void 0;
@@ -3953,7 +3982,7 @@ var ObservableMap = /*#__PURE__*/function () {
3953
3982
  die(18);
3954
3983
  }
3955
3984
 
3956
- this.keysAtom_ = createAtom(this.name_ + ".keys()");
3985
+ this.keysAtom_ = createAtom(process.env.NODE_ENV !== "production" ? this.name_ + ".keys()" : "ObservableMap.keys()");
3957
3986
  this.data_ = new Map();
3958
3987
  this.hasMap_ = new Map();
3959
3988
  this.merge(initialData);
@@ -3972,7 +4001,7 @@ var ObservableMap = /*#__PURE__*/function () {
3972
4001
  var entry = this.hasMap_.get(key);
3973
4002
 
3974
4003
  if (!entry) {
3975
- var newEntry = entry = new ObservableValue(this.has_(key), referenceEnhancer, this.name_ + "." + stringifyKey(key) + "?", false);
4004
+ var newEntry = entry = new ObservableValue(this.has_(key), referenceEnhancer, process.env.NODE_ENV !== "production" ? this.name_ + "." + stringifyKey(key) + "?" : "ObservableMap.key?", false);
3976
4005
  this.hasMap_.set(key, newEntry);
3977
4006
  onBecomeUnobserved(newEntry, function () {
3978
4007
  return _this.hasMap_["delete"](key);
@@ -4088,7 +4117,7 @@ var ObservableMap = /*#__PURE__*/function () {
4088
4117
 
4089
4118
  checkIfStateModificationsAreAllowed(this.keysAtom_);
4090
4119
  transaction(function () {
4091
- var observable = new ObservableValue(newValue, _this3.enhancer_, _this3.name_ + "." + stringifyKey(key), false);
4120
+ var observable = new ObservableValue(newValue, _this3.enhancer_, process.env.NODE_ENV !== "production" ? _this3.name_ + "." + stringifyKey(key) : "ObservableMap.key", false);
4092
4121
 
4093
4122
  _this3.data_.set(key, observable);
4094
4123
 
@@ -4385,7 +4414,7 @@ var ObservableSet = /*#__PURE__*/function () {
4385
4414
  }
4386
4415
 
4387
4416
  if (name_ === void 0) {
4388
- name_ = "ObservableSet@" + getNextId();
4417
+ name_ = process.env.NODE_ENV !== "production" ? "ObservableSet@" + getNextId() : "ObservableSet";
4389
4418
  }
4390
4419
 
4391
4420
  this.name_ = void 0;
@@ -4669,7 +4698,7 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
4669
4698
  this.name_ = name_;
4670
4699
  this.defaultAnnotation_ = defaultAnnotation_;
4671
4700
  this.autoBind_ = autoBind_;
4672
- this.keysAtom_ = new Atom(name_ + ".keys"); // Optimization: we use this frequently
4701
+ this.keysAtom_ = new Atom(process.env.NODE_ENV !== "production" ? this.name_ + ".keys" : "ObservableObject.keys"); // Optimization: we use this frequently
4673
4702
 
4674
4703
  this.isPlainObject_ = isPlainObject(this.target_);
4675
4704
 
@@ -4796,7 +4825,7 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
4796
4825
  var entry = this.pendingKeys_.get(key);
4797
4826
 
4798
4827
  if (!entry) {
4799
- entry = new ObservableValue(key in this.target_, referenceEnhancer, this.name_ + "." + stringifyKey(key) + "?", false);
4828
+ entry = new ObservableValue(key in this.target_, referenceEnhancer, process.env.NODE_ENV !== "production" ? this.name_ + "." + stringifyKey(key) + "?" : "ObservableObject.key?", false);
4800
4829
  this.pendingKeys_.set(key, entry);
4801
4830
  }
4802
4831
 
@@ -4856,7 +4885,7 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
4856
4885
  var _this$target_$inferre;
4857
4886
 
4858
4887
  // Inherited is fine - annotation cannot differ in subclass
4859
- var annotation = (_this$target_$inferre = this.target_[inferredAnnotationsSymbol]) == null ? void 0 : _this$target_$inferre[key];
4888
+ var annotation = (_this$target_$inferre = this.target_[inferredAnnotationsSymbol]) == null ? void 0 : _this$target_$inferre.get(key);
4860
4889
  if (annotation) return annotation;
4861
4890
  var current = this.target_;
4862
4891
 
@@ -4883,10 +4912,10 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
4883
4912
  var closestProto = Object.getPrototypeOf(this.target_);
4884
4913
 
4885
4914
  if (!hasProp(closestProto, inferredAnnotationsSymbol)) {
4886
- addHiddenProp(closestProto, inferredAnnotationsSymbol, {});
4915
+ addHiddenProp(closestProto, inferredAnnotationsSymbol, new Map());
4887
4916
  }
4888
4917
 
4889
- closestProto[inferredAnnotationsSymbol][key] = annotation;
4918
+ closestProto[inferredAnnotationsSymbol].set(key, annotation);
4890
4919
  }
4891
4920
 
4892
4921
  return annotation;
@@ -4994,7 +5023,7 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
4994
5023
  defineProperty(this.target_, key, descriptor);
4995
5024
  }
4996
5025
 
4997
- var _observable = new ObservableValue(value, enhancer, this.name_ + "." + stringifyKey(key), false);
5026
+ var _observable = new ObservableValue(value, enhancer, process.env.NODE_ENV !== "production" ? this.name_ + "." + key.toString() : "ObservableObject.key", false);
4998
5027
 
4999
5028
  this.values_.set(key, _observable); // Notify (value possibly changed by ObservableValue)
5000
5029
 
@@ -5033,7 +5062,7 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
5033
5062
  if (!change) return null;
5034
5063
  }
5035
5064
 
5036
- options.name || (options.name = this.name_ + "." + stringifyKey(key));
5065
+ options.name || (options.name = process.env.NODE_ENV !== "production" ? this.name_ + "." + key.toString() : "ObservableObject.key");
5037
5066
  options.context = this.proxy_ || this.target_;
5038
5067
  var cachedDescriptor = getCachedObservablePropDescriptor(key);
5039
5068
  var descriptor = {
@@ -5225,10 +5254,17 @@ function asObservableObject(target, options) {
5225
5254
  die("Options can't be provided for already observable objects.");
5226
5255
  }
5227
5256
 
5228
- if (hasProp(target, $mobx)) return target;
5257
+ if (hasProp(target, $mobx)) {
5258
+ if (process.env.NODE_ENV !== "production" && !(getAdministration(target) instanceof ObservableObjectAdministration)) {
5259
+ die("Cannot convert '" + getDebugName(target) + "' into observable object:" + "\nThe target is already observable of different type." + "\nExtending builtins is not supported.");
5260
+ }
5261
+
5262
+ return target;
5263
+ }
5264
+
5229
5265
  if (process.env.NODE_ENV !== "production" && !Object.isExtensible(target)) die("Cannot make the designated object observable; it is not extensible");
5230
- var name = (_options$name = options == null ? void 0 : options.name) != null ? _options$name : (isPlainObject(target) ? "ObservableObject" : target.constructor.name) + "@" + getNextId();
5231
- var adm = new ObservableObjectAdministration(target, new Map(), stringifyKey(name), getAnnotationFromOptions(options), options == null ? void 0 : options.autoBind);
5266
+ var name = (_options$name = options == null ? void 0 : options.name) != null ? _options$name : process.env.NODE_ENV !== "production" ? (isPlainObject(target) ? "ObservableObject" : target.constructor.name) + "@" + getNextId() : "ObservableObject";
5267
+ var adm = new ObservableObjectAdministration(target, new Map(), String(name), getAnnotationFromOptions(options), options == null ? void 0 : options.autoBind);
5232
5268
  addHiddenProp(target, $mobx, adm);
5233
5269
  return target;
5234
5270
  }
@@ -5253,14 +5289,14 @@ function isObservableObject(thing) {
5253
5289
  return false;
5254
5290
  }
5255
5291
  function recordAnnotationApplied(adm, annotation, key) {
5292
+ var _adm$target_$storedAn;
5293
+
5256
5294
  if (process.env.NODE_ENV !== "production") {
5257
5295
  adm.appliedAnnotations_[key] = annotation;
5258
5296
  } // Remove applied decorator annotation so we don't try to apply it again in subclass constructor
5259
5297
 
5260
5298
 
5261
- if (annotation.isDecorator_) {
5262
- delete adm.target_[storedAnnotationsSymbol][key];
5263
- }
5299
+ (_adm$target_$storedAn = adm.target_[storedAnnotationsSymbol]) == null ? true : delete _adm$target_$storedAn[key];
5264
5300
  }
5265
5301
 
5266
5302
  function assertAnnotable(adm, annotation, key) {
@@ -5340,7 +5376,7 @@ var LegacyObservableArray = /*#__PURE__*/function (_StubArray) {
5340
5376
  var _this;
5341
5377
 
5342
5378
  if (name === void 0) {
5343
- name = "ObservableArray@" + getNextId();
5379
+ name = process.env.NODE_ENV !== "production" ? "ObservableArray@" + getNextId() : "ObservableArray";
5344
5380
  }
5345
5381
 
5346
5382
  if (owned === void 0) {
@@ -5499,7 +5535,17 @@ function getAdministration(thing, property) {
5499
5535
  }
5500
5536
  function getDebugName(thing, property) {
5501
5537
  var named;
5502
- if (property !== undefined) named = getAtom(thing, property);else if (isObservableObject(thing) || isObservableMap(thing) || isObservableSet(thing)) named = getAdministration(thing);else named = getAtom(thing); // valid for arrays as well
5538
+
5539
+ if (property !== undefined) {
5540
+ named = getAtom(thing, property);
5541
+ } else if (isAction(thing)) {
5542
+ return thing.name;
5543
+ } else if (isObservableObject(thing) || isObservableMap(thing) || isObservableSet(thing)) {
5544
+ named = getAdministration(thing);
5545
+ } else {
5546
+ // valid for arrays as well
5547
+ named = getAtom(thing);
5548
+ }
5503
5549
 
5504
5550
  return named.name_;
5505
5551
  }