mobx 6.3.8 → 6.3.9

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.
@@ -170,12 +170,11 @@
170
170
  return value !== null && typeof value === "object";
171
171
  }
172
172
  function isPlainObject(value) {
173
- var _proto$constructor;
174
-
175
173
  if (!isObject(value)) return false;
176
174
  var proto = Object.getPrototypeOf(value);
177
175
  if (proto == null) return true;
178
- return ((_proto$constructor = proto.constructor) == null ? void 0 : _proto$constructor.toString()) === plainObjectString;
176
+ var protoConstructor = Object.hasOwnProperty.call(proto, "constructor") && proto.constructor;
177
+ return typeof protoConstructor === "function" && protoConstructor.toString() === plainObjectString;
179
178
  } // https://stackoverflow.com/a/37865170
180
179
 
181
180
  function isGenerator(obj) {
@@ -270,6 +269,9 @@
270
269
  function _createClass(Constructor, protoProps, staticProps) {
271
270
  if (protoProps) _defineProperties(Constructor.prototype, protoProps);
272
271
  if (staticProps) _defineProperties(Constructor, staticProps);
272
+ Object.defineProperty(Constructor, "prototype", {
273
+ writable: false
274
+ });
273
275
  return Constructor;
274
276
  }
275
277
 
@@ -294,7 +296,17 @@
294
296
  function _inheritsLoose(subClass, superClass) {
295
297
  subClass.prototype = Object.create(superClass.prototype);
296
298
  subClass.prototype.constructor = subClass;
297
- subClass.__proto__ = superClass;
299
+
300
+ _setPrototypeOf(subClass, superClass);
301
+ }
302
+
303
+ function _setPrototypeOf(o, p) {
304
+ _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
305
+ o.__proto__ = p;
306
+ return o;
307
+ };
308
+
309
+ return _setPrototypeOf(o, p);
298
310
  }
299
311
 
300
312
  function _assertThisInitialized(self) {
@@ -323,28 +335,24 @@
323
335
  }
324
336
 
325
337
  function _createForOfIteratorHelperLoose(o, allowArrayLike) {
326
- var it;
327
-
328
- if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
329
- if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
330
- if (it) o = it;
331
- var i = 0;
332
- return function () {
333
- if (i >= o.length) return {
334
- done: true
335
- };
336
- return {
337
- done: false,
338
- value: o[i++]
339
- };
338
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
339
+ if (it) return (it = it.call(o)).next.bind(it);
340
+
341
+ if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
342
+ if (it) o = it;
343
+ var i = 0;
344
+ return function () {
345
+ if (i >= o.length) return {
346
+ done: true
340
347
  };
341
- }
342
-
343
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
348
+ return {
349
+ done: false,
350
+ value: o[i++]
351
+ };
352
+ };
344
353
  }
345
354
 
346
- it = o[Symbol.iterator]();
347
- return it.next.bind(it);
355
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
348
356
  }
349
357
 
350
358
  var storedAnnotationsSymbol = /*#__PURE__*/Symbol("mobx-stored-annotations");
@@ -628,7 +636,7 @@
628
636
  var _this$options_;
629
637
 
630
638
  // bound
631
- if ((_this$options_ = this.options_) == null ? void 0 : _this$options_.bound) {
639
+ if ((_this$options_ = this.options_) != null && _this$options_.bound) {
632
640
  return this.extend_(adm, key, descriptor, false) === null ? 0
633
641
  /* Cancel */
634
642
  : 1
@@ -686,7 +694,7 @@
686
694
  assertActionDescriptor(adm, annotation, key, descriptor);
687
695
  var value = descriptor.value;
688
696
 
689
- if ((_annotation$options_ = annotation.options_) == null ? void 0 : _annotation$options_.bound) {
697
+ if ((_annotation$options_ = annotation.options_) != null && _annotation$options_.bound) {
690
698
  var _adm$proxy_;
691
699
 
692
700
  value = value.bind((_adm$proxy_ = adm.proxy_) != null ? _adm$proxy_ : adm.target_);
@@ -694,7 +702,7 @@
694
702
 
695
703
  return {
696
704
  value: createAction((_annotation$options_$ = (_annotation$options_2 = annotation.options_) == null ? void 0 : _annotation$options_2.name) != null ? _annotation$options_$ : key.toString(), value, (_annotation$options_$2 = (_annotation$options_3 = annotation.options_) == null ? void 0 : _annotation$options_3.autoAction) != null ? _annotation$options_$2 : false, // https://github.com/mobxjs/mobx/discussions/3140
697
- ((_annotation$options_4 = annotation.options_) == null ? void 0 : _annotation$options_4.bound) ? (_adm$proxy_2 = adm.proxy_) != null ? _adm$proxy_2 : adm.target_ : undefined),
705
+ (_annotation$options_4 = annotation.options_) != null && _annotation$options_4.bound ? (_adm$proxy_2 = adm.proxy_) != null ? _adm$proxy_2 : adm.target_ : undefined),
698
706
  // Non-configurable for classes
699
707
  // prevents accidental field redefinition in subclass
700
708
  configurable: safeDescriptors ? adm.isPlainObject_ : true,
@@ -729,7 +737,7 @@
729
737
  // bound - must annotate protos to support super.flow()
730
738
 
731
739
 
732
- if (((_this$options_ = this.options_) == null ? void 0 : _this$options_.bound) && !isFlow(adm.target_[key])) {
740
+ if ((_this$options_ = this.options_) != null && _this$options_.bound && !isFlow(adm.target_[key])) {
733
741
  if (this.extend_(adm, key, descriptor, false) === null) return 0
734
742
  /* Cancel */
735
743
  ;
@@ -912,11 +920,11 @@
912
920
  if (isGenerator(descriptor.value)) {
913
921
  var _this$options_;
914
922
 
915
- var flowAnnotation = ((_this$options_ = this.options_) == null ? void 0 : _this$options_.autoBind) ? flow.bound : flow;
923
+ var flowAnnotation = (_this$options_ = this.options_) != null && _this$options_.autoBind ? flow.bound : flow;
916
924
  return flowAnnotation.make_(adm, key, descriptor, source);
917
925
  }
918
926
 
919
- var actionAnnotation = ((_this$options_2 = this.options_) == null ? void 0 : _this$options_2.autoBind) ? autoAction.bound : autoAction;
927
+ var actionAnnotation = (_this$options_2 = this.options_) != null && _this$options_2.autoBind ? autoAction.bound : autoAction;
920
928
  return actionAnnotation.make_(adm, key, descriptor, source);
921
929
  } // other -> observable
922
930
  // Copy props from proto as well, see test:
@@ -925,7 +933,7 @@
925
933
 
926
934
  var observableAnnotation = ((_this$options_3 = this.options_) == null ? void 0 : _this$options_3.deep) === false ? observable.ref : observable; // if function respect autoBind option
927
935
 
928
- if (typeof descriptor.value === "function" && ((_this$options_4 = this.options_) == null ? void 0 : _this$options_4.autoBind)) {
936
+ if (typeof descriptor.value === "function" && (_this$options_4 = this.options_) != null && _this$options_4.autoBind) {
929
937
  var _adm$proxy_;
930
938
 
931
939
  descriptor.value = descriptor.value.bind((_adm$proxy_ = adm.proxy_) != null ? _adm$proxy_ : adm.target_);
@@ -953,7 +961,7 @@
953
961
  // if function respect autoBind option
954
962
 
955
963
 
956
- if (typeof descriptor.value === "function" && ((_this$options_5 = this.options_) == null ? void 0 : _this$options_5.autoBind)) {
964
+ if (typeof descriptor.value === "function" && (_this$options_5 = this.options_) != null && _this$options_5.autoBind) {
957
965
  var _adm$proxy_2;
958
966
 
959
967
  descriptor.value = descriptor.value.bind((_adm$proxy_2 = adm.proxy_) != null ? _adm$proxy_2 : adm.target_);
@@ -1231,7 +1239,7 @@
1231
1239
  var _Symbol$toPrimitive;
1232
1240
  var CREATE = "create";
1233
1241
  _Symbol$toPrimitive = Symbol.toPrimitive;
1234
- var ObservableValue = /*#__PURE__*/function (_Atom) {
1242
+ var ObservableValue = /*#__PURE__*/function (_Atom, _Symbol$toPrimitive2) {
1235
1243
  _inheritsLoose(ObservableValue, _Atom);
1236
1244
 
1237
1245
  function ObservableValue(value, enhancer, name_, notifySpy, equals) {
@@ -1378,12 +1386,12 @@
1378
1386
  return toPrimitive(this.get());
1379
1387
  };
1380
1388
 
1381
- _proto[_Symbol$toPrimitive] = function () {
1389
+ _proto[_Symbol$toPrimitive2] = function () {
1382
1390
  return this.valueOf();
1383
1391
  };
1384
1392
 
1385
1393
  return ObservableValue;
1386
- }(Atom);
1394
+ }(Atom, _Symbol$toPrimitive);
1387
1395
  var isObservableValue = /*#__PURE__*/createInstanceofPredicate("ObservableValue", ObservableValue);
1388
1396
 
1389
1397
  var _Symbol$toPrimitive$1;
@@ -1408,7 +1416,7 @@
1408
1416
  */
1409
1417
 
1410
1418
  _Symbol$toPrimitive$1 = Symbol.toPrimitive;
1411
- var ComputedValue = /*#__PURE__*/function () {
1419
+ var ComputedValue = /*#__PURE__*/function (_Symbol$toPrimitive2) {
1412
1420
  // nodes we are looking at. Our value depends on these nodes
1413
1421
  // during tracking it's an array with new observed observers
1414
1422
  // to check for cycles
@@ -1462,7 +1470,7 @@
1462
1470
 
1463
1471
  this.equals_ = options.equals || (options.compareStructural || options.struct ? comparer.structural : comparer["default"]);
1464
1472
  this.scope_ = options.context;
1465
- this.requiresReaction_ = !!options.requiresReaction;
1473
+ this.requiresReaction_ = options.requiresReaction;
1466
1474
  this.keepAlive_ = !!options.keepAlive;
1467
1475
  }
1468
1476
 
@@ -1630,7 +1638,7 @@
1630
1638
  console.log("[mobx.trace] Computed value '" + this.name_ + "' is being read outside a reactive context. Doing a full recompute.");
1631
1639
  }
1632
1640
 
1633
- if (globalState.computedRequiresReaction || this.requiresReaction_) {
1641
+ if (typeof this.requiresReaction_ === "boolean" ? this.requiresReaction_ : globalState.computedRequiresReaction) {
1634
1642
  console.warn("[mobx] Computed value '" + this.name_ + "' is being read outside a reactive context. Doing a full recompute.");
1635
1643
  }
1636
1644
  };
@@ -1643,12 +1651,12 @@
1643
1651
  return toPrimitive(this.get());
1644
1652
  };
1645
1653
 
1646
- _proto[_Symbol$toPrimitive$1] = function () {
1654
+ _proto[_Symbol$toPrimitive2] = function () {
1647
1655
  return this.valueOf();
1648
1656
  };
1649
1657
 
1650
1658
  return ComputedValue;
1651
- }();
1659
+ }(_Symbol$toPrimitive$1);
1652
1660
  var isComputedValue = /*#__PURE__*/createInstanceofPredicate("ComputedValue", ComputedValue);
1653
1661
 
1654
1662
  var IDerivationState_;
@@ -2189,8 +2197,8 @@
2189
2197
  }
2190
2198
  } else if (d.dependenciesState_ === IDerivationState_.UP_TO_DATE_ // this happens during computing of `d`, just keep lowestObserverState up to date.
2191
2199
  ) {
2192
- observable.lowestObserverState_ = IDerivationState_.UP_TO_DATE_;
2193
- }
2200
+ observable.lowestObserverState_ = IDerivationState_.UP_TO_DATE_;
2201
+ }
2194
2202
  }); // invariantLOS(observable, "confirmed end");
2195
2203
  } // Used by computed when its dependency changed, but we don't wan't to immediately recompute.
2196
2204
 
@@ -4007,7 +4015,7 @@
4007
4015
 
4008
4016
  _Symbol$iterator = Symbol.iterator;
4009
4017
  _Symbol$toStringTag = Symbol.toStringTag;
4010
- var ObservableMap = /*#__PURE__*/function () {
4018
+ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTag2) {
4011
4019
  // hasMap, not hashMap >-).
4012
4020
  function ObservableMap(initialData, enhancer_, name_) {
4013
4021
  if (enhancer_ === void 0) {
@@ -4113,7 +4121,8 @@
4113
4121
  name: key
4114
4122
  } : null;
4115
4123
 
4116
- if ( notifySpy) spyReportStart(_change);
4124
+ if ( notifySpy) spyReportStart(_change); // TODO fix type
4125
+
4117
4126
  transaction(function () {
4118
4127
  var _this2$hasMap_$get;
4119
4128
 
@@ -4151,7 +4160,8 @@
4151
4160
  name: key,
4152
4161
  newValue: newValue
4153
4162
  } : null;
4154
- if ( notifySpy) spyReportStart(change);
4163
+ if ( notifySpy) spyReportStart(change); // TODO fix type
4164
+
4155
4165
  observable.setNewValue_(newValue);
4156
4166
  if (notify) notifyListeners(this, change);
4157
4167
  if ( notifySpy) spyReportEnd();
@@ -4185,7 +4195,8 @@
4185
4195
  name: key,
4186
4196
  newValue: newValue
4187
4197
  } : null;
4188
- if ( notifySpy) spyReportStart(change);
4198
+ if ( notifySpy) spyReportStart(change); // TODO fix type
4199
+
4189
4200
  if (notify) notifyListeners(this, change);
4190
4201
  if ( notifySpy) spyReportEnd();
4191
4202
  };
@@ -4242,7 +4253,7 @@
4242
4253
  });
4243
4254
  };
4244
4255
 
4245
- _proto[_Symbol$iterator] = function () {
4256
+ _proto[_Symbol$iterator2] = function () {
4246
4257
  return this.entries();
4247
4258
  };
4248
4259
 
@@ -4422,14 +4433,14 @@
4422
4433
  return this.data_.size;
4423
4434
  }
4424
4435
  }, {
4425
- key: _Symbol$toStringTag,
4436
+ key: _Symbol$toStringTag2,
4426
4437
  get: function get() {
4427
4438
  return "Map";
4428
4439
  }
4429
4440
  }]);
4430
4441
 
4431
4442
  return ObservableMap;
4432
- }(); // eslint-disable-next-line
4443
+ }(_Symbol$iterator, _Symbol$toStringTag); // eslint-disable-next-line
4433
4444
 
4434
4445
  var isObservableMap = /*#__PURE__*/createInstanceofPredicate("ObservableMap", ObservableMap);
4435
4446
 
@@ -4455,7 +4466,7 @@
4455
4466
  var ObservableSetMarker = {};
4456
4467
  _Symbol$iterator$1 = Symbol.iterator;
4457
4468
  _Symbol$toStringTag$1 = Symbol.toStringTag;
4458
- var ObservableSet = /*#__PURE__*/function () {
4469
+ var ObservableSet = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTag2) {
4459
4470
  function ObservableSet(initialData, enhancer, name_) {
4460
4471
  if (enhancer === void 0) {
4461
4472
  enhancer = deepEnhancer;
@@ -4688,7 +4699,7 @@
4688
4699
  return "[object ObservableSet]";
4689
4700
  };
4690
4701
 
4691
- _proto[_Symbol$iterator$1] = function () {
4702
+ _proto[_Symbol$iterator2] = function () {
4692
4703
  return this.values();
4693
4704
  };
4694
4705
 
@@ -4699,14 +4710,14 @@
4699
4710
  return this.data_.size;
4700
4711
  }
4701
4712
  }, {
4702
- key: _Symbol$toStringTag$1,
4713
+ key: _Symbol$toStringTag2,
4703
4714
  get: function get() {
4704
4715
  return "Set";
4705
4716
  }
4706
4717
  }]);
4707
4718
 
4708
4719
  return ObservableSet;
4709
- }(); // eslint-disable-next-line
4720
+ }(_Symbol$iterator$1, _Symbol$toStringTag$1); // eslint-disable-next-line
4710
4721
 
4711
4722
  var isObservableSet = /*#__PURE__*/createInstanceofPredicate("ObservableSet", ObservableSet);
4712
4723
 
@@ -4892,7 +4903,7 @@
4892
4903
  // When called from super() some props may not exist yet.
4893
4904
  // However we don't have to worry about missing prop,
4894
4905
  // because the decorator must have been applied to something.
4895
- if ((_this$target_$storedA = this.target_[storedAnnotationsSymbol]) == null ? void 0 : _this$target_$storedA[key]) {
4906
+ if ((_this$target_$storedA = this.target_[storedAnnotationsSymbol]) != null && _this$target_$storedA[key]) {
4896
4907
  return; // will be annotated by subclass constructor
4897
4908
  } else {
4898
4909
  die(1, annotation.annotationType_, this.name_ + "." + key.toString());
@@ -5396,7 +5407,7 @@
5396
5407
  // but it is unclear why the hack is need as MobX never changed the prototype
5397
5408
  // anyway, so removed it in V6
5398
5409
 
5399
- var LegacyObservableArray = /*#__PURE__*/function (_StubArray) {
5410
+ var LegacyObservableArray = /*#__PURE__*/function (_StubArray, _Symbol$toStringTag, _Symbol$iterator) {
5400
5411
  _inheritsLoose(LegacyObservableArray, _StubArray);
5401
5412
 
5402
5413
  function LegacyObservableArray(initialValues, enhancer, name, owned) {
@@ -5441,7 +5452,7 @@
5441
5452
  }));
5442
5453
  };
5443
5454
 
5444
- _proto[Symbol.iterator] = function () {
5455
+ _proto[_Symbol$iterator] = function () {
5445
5456
  var self = this;
5446
5457
  var nextIndex = 0;
5447
5458
  return makeIterable({
@@ -5467,14 +5478,14 @@
5467
5478
  this[$mobx].setArrayLength_(newLength);
5468
5479
  }
5469
5480
  }, {
5470
- key: Symbol.toStringTag,
5481
+ key: _Symbol$toStringTag,
5471
5482
  get: function get() {
5472
5483
  return "Array";
5473
5484
  }
5474
5485
  }]);
5475
5486
 
5476
5487
  return LegacyObservableArray;
5477
- }(StubArray);
5488
+ }(StubArray, Symbol.toStringTag, Symbol.iterator);
5478
5489
 
5479
5490
  Object.entries(arrayExtensions).forEach(function (_ref) {
5480
5491
  var prop = _ref[0],