mobx 6.3.6 → 6.3.10

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.
@@ -164,12 +164,11 @@ function isObject(value) {
164
164
  return value !== null && typeof value === "object";
165
165
  }
166
166
  function isPlainObject(value) {
167
- var _proto$constructor;
168
-
169
167
  if (!isObject(value)) return false;
170
168
  var proto = Object.getPrototypeOf(value);
171
169
  if (proto == null) return true;
172
- return ((_proto$constructor = proto.constructor) == null ? void 0 : _proto$constructor.toString()) === plainObjectString;
170
+ var protoConstructor = Object.hasOwnProperty.call(proto, "constructor") && proto.constructor;
171
+ return typeof protoConstructor === "function" && protoConstructor.toString() === plainObjectString;
173
172
  } // https://stackoverflow.com/a/37865170
174
173
 
175
174
  function isGenerator(obj) {
@@ -264,6 +263,9 @@ function _defineProperties(target, props) {
264
263
  function _createClass(Constructor, protoProps, staticProps) {
265
264
  if (protoProps) _defineProperties(Constructor.prototype, protoProps);
266
265
  if (staticProps) _defineProperties(Constructor, staticProps);
266
+ Object.defineProperty(Constructor, "prototype", {
267
+ writable: false
268
+ });
267
269
  return Constructor;
268
270
  }
269
271
 
@@ -288,7 +290,17 @@ function _extends() {
288
290
  function _inheritsLoose(subClass, superClass) {
289
291
  subClass.prototype = Object.create(superClass.prototype);
290
292
  subClass.prototype.constructor = subClass;
291
- subClass.__proto__ = superClass;
293
+
294
+ _setPrototypeOf(subClass, superClass);
295
+ }
296
+
297
+ function _setPrototypeOf(o, p) {
298
+ _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
299
+ o.__proto__ = p;
300
+ return o;
301
+ };
302
+
303
+ return _setPrototypeOf(o, p);
292
304
  }
293
305
 
294
306
  function _assertThisInitialized(self) {
@@ -317,28 +329,24 @@ function _arrayLikeToArray(arr, len) {
317
329
  }
318
330
 
319
331
  function _createForOfIteratorHelperLoose(o, allowArrayLike) {
320
- var it;
321
-
322
- if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
323
- if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
324
- if (it) o = it;
325
- var i = 0;
326
- return function () {
327
- if (i >= o.length) return {
328
- done: true
329
- };
330
- return {
331
- done: false,
332
- value: o[i++]
333
- };
332
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
333
+ if (it) return (it = it.call(o)).next.bind(it);
334
+
335
+ if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
336
+ if (it) o = it;
337
+ var i = 0;
338
+ return function () {
339
+ if (i >= o.length) return {
340
+ done: true
334
341
  };
335
- }
336
-
337
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
342
+ return {
343
+ done: false,
344
+ value: o[i++]
345
+ };
346
+ };
338
347
  }
339
348
 
340
- it = o[Symbol.iterator]();
341
- return it.next.bind(it);
349
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
342
350
  }
343
351
 
344
352
  var storedAnnotationsSymbol = /*#__PURE__*/Symbol("mobx-stored-annotations");
@@ -622,7 +630,7 @@ function make_$1(adm, key, descriptor, source) {
622
630
  var _this$options_;
623
631
 
624
632
  // bound
625
- if ((_this$options_ = this.options_) == null ? void 0 : _this$options_.bound) {
633
+ if ((_this$options_ = this.options_) != null && _this$options_.bound) {
626
634
  return this.extend_(adm, key, descriptor, false) === null ? 0
627
635
  /* Cancel */
628
636
  : 1
@@ -680,7 +688,7 @@ safeDescriptors) {
680
688
  assertActionDescriptor(adm, annotation, key, descriptor);
681
689
  var value = descriptor.value;
682
690
 
683
- if ((_annotation$options_ = annotation.options_) == null ? void 0 : _annotation$options_.bound) {
691
+ if ((_annotation$options_ = annotation.options_) != null && _annotation$options_.bound) {
684
692
  var _adm$proxy_;
685
693
 
686
694
  value = value.bind((_adm$proxy_ = adm.proxy_) != null ? _adm$proxy_ : adm.target_);
@@ -688,7 +696,7 @@ safeDescriptors) {
688
696
 
689
697
  return {
690
698
  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
691
- ((_annotation$options_4 = annotation.options_) == null ? void 0 : _annotation$options_4.bound) ? (_adm$proxy_2 = adm.proxy_) != null ? _adm$proxy_2 : adm.target_ : undefined),
699
+ (_annotation$options_4 = annotation.options_) != null && _annotation$options_4.bound ? (_adm$proxy_2 = adm.proxy_) != null ? _adm$proxy_2 : adm.target_ : undefined),
692
700
  // Non-configurable for classes
693
701
  // prevents accidental field redefinition in subclass
694
702
  configurable: safeDescriptors ? adm.isPlainObject_ : true,
@@ -723,7 +731,7 @@ function make_$2(adm, key, descriptor, source) {
723
731
  // bound - must annotate protos to support super.flow()
724
732
 
725
733
 
726
- if (((_this$options_ = this.options_) == null ? void 0 : _this$options_.bound) && !isFlow(adm.target_[key])) {
734
+ if ((_this$options_ = this.options_) != null && _this$options_.bound && !isFlow(adm.target_[key])) {
727
735
  if (this.extend_(adm, key, descriptor, false) === null) return 0
728
736
  /* Cancel */
729
737
  ;
@@ -906,11 +914,11 @@ function make_$5(adm, key, descriptor, source) {
906
914
  if (isGenerator(descriptor.value)) {
907
915
  var _this$options_;
908
916
 
909
- var flowAnnotation = ((_this$options_ = this.options_) == null ? void 0 : _this$options_.autoBind) ? flow.bound : flow;
917
+ var flowAnnotation = (_this$options_ = this.options_) != null && _this$options_.autoBind ? flow.bound : flow;
910
918
  return flowAnnotation.make_(adm, key, descriptor, source);
911
919
  }
912
920
 
913
- var actionAnnotation = ((_this$options_2 = this.options_) == null ? void 0 : _this$options_2.autoBind) ? autoAction.bound : autoAction;
921
+ var actionAnnotation = (_this$options_2 = this.options_) != null && _this$options_2.autoBind ? autoAction.bound : autoAction;
914
922
  return actionAnnotation.make_(adm, key, descriptor, source);
915
923
  } // other -> observable
916
924
  // Copy props from proto as well, see test:
@@ -919,7 +927,7 @@ function make_$5(adm, key, descriptor, source) {
919
927
 
920
928
  var observableAnnotation = ((_this$options_3 = this.options_) == null ? void 0 : _this$options_3.deep) === false ? observable.ref : observable; // if function respect autoBind option
921
929
 
922
- if (typeof descriptor.value === "function" && ((_this$options_4 = this.options_) == null ? void 0 : _this$options_4.autoBind)) {
930
+ if (typeof descriptor.value === "function" && (_this$options_4 = this.options_) != null && _this$options_4.autoBind) {
923
931
  var _adm$proxy_;
924
932
 
925
933
  descriptor.value = descriptor.value.bind((_adm$proxy_ = adm.proxy_) != null ? _adm$proxy_ : adm.target_);
@@ -947,7 +955,7 @@ function extend_$5(adm, key, descriptor, proxyTrap) {
947
955
  // if function respect autoBind option
948
956
 
949
957
 
950
- if (typeof descriptor.value === "function" && ((_this$options_5 = this.options_) == null ? void 0 : _this$options_5.autoBind)) {
958
+ if (typeof descriptor.value === "function" && (_this$options_5 = this.options_) != null && _this$options_5.autoBind) {
951
959
  var _adm$proxy_2;
952
960
 
953
961
  descriptor.value = descriptor.value.bind((_adm$proxy_2 = adm.proxy_) != null ? _adm$proxy_2 : adm.target_);
@@ -1225,7 +1233,7 @@ function allowStateChangesEnd(prev) {
1225
1233
  var _Symbol$toPrimitive;
1226
1234
  var CREATE = "create";
1227
1235
  _Symbol$toPrimitive = Symbol.toPrimitive;
1228
- var ObservableValue = /*#__PURE__*/function (_Atom) {
1236
+ var ObservableValue = /*#__PURE__*/function (_Atom, _Symbol$toPrimitive2) {
1229
1237
  _inheritsLoose(ObservableValue, _Atom);
1230
1238
 
1231
1239
  function ObservableValue(value, enhancer, name_, notifySpy, equals) {
@@ -1372,12 +1380,12 @@ var ObservableValue = /*#__PURE__*/function (_Atom) {
1372
1380
  return toPrimitive(this.get());
1373
1381
  };
1374
1382
 
1375
- _proto[_Symbol$toPrimitive] = function () {
1383
+ _proto[_Symbol$toPrimitive2] = function () {
1376
1384
  return this.valueOf();
1377
1385
  };
1378
1386
 
1379
1387
  return ObservableValue;
1380
- }(Atom);
1388
+ }(Atom, _Symbol$toPrimitive);
1381
1389
  var isObservableValue = /*#__PURE__*/createInstanceofPredicate("ObservableValue", ObservableValue);
1382
1390
 
1383
1391
  var _Symbol$toPrimitive$1;
@@ -1402,7 +1410,7 @@ var _Symbol$toPrimitive$1;
1402
1410
  */
1403
1411
 
1404
1412
  _Symbol$toPrimitive$1 = Symbol.toPrimitive;
1405
- var ComputedValue = /*#__PURE__*/function () {
1413
+ var ComputedValue = /*#__PURE__*/function (_Symbol$toPrimitive2) {
1406
1414
  // nodes we are looking at. Our value depends on these nodes
1407
1415
  // during tracking it's an array with new observed observers
1408
1416
  // to check for cycles
@@ -1456,7 +1464,7 @@ var ComputedValue = /*#__PURE__*/function () {
1456
1464
 
1457
1465
  this.equals_ = options.equals || (options.compareStructural || options.struct ? comparer.structural : comparer["default"]);
1458
1466
  this.scope_ = options.context;
1459
- this.requiresReaction_ = !!options.requiresReaction;
1467
+ this.requiresReaction_ = options.requiresReaction;
1460
1468
  this.keepAlive_ = !!options.keepAlive;
1461
1469
  }
1462
1470
 
@@ -1624,7 +1632,7 @@ var ComputedValue = /*#__PURE__*/function () {
1624
1632
  console.log("[mobx.trace] Computed value '" + this.name_ + "' is being read outside a reactive context. Doing a full recompute.");
1625
1633
  }
1626
1634
 
1627
- if (globalState.computedRequiresReaction || this.requiresReaction_) {
1635
+ if (typeof this.requiresReaction_ === "boolean" ? this.requiresReaction_ : globalState.computedRequiresReaction) {
1628
1636
  console.warn("[mobx] Computed value '" + this.name_ + "' is being read outside a reactive context. Doing a full recompute.");
1629
1637
  }
1630
1638
  };
@@ -1637,12 +1645,12 @@ var ComputedValue = /*#__PURE__*/function () {
1637
1645
  return toPrimitive(this.get());
1638
1646
  };
1639
1647
 
1640
- _proto[_Symbol$toPrimitive$1] = function () {
1648
+ _proto[_Symbol$toPrimitive2] = function () {
1641
1649
  return this.valueOf();
1642
1650
  };
1643
1651
 
1644
1652
  return ComputedValue;
1645
- }();
1653
+ }(_Symbol$toPrimitive$1);
1646
1654
  var isComputedValue = /*#__PURE__*/createInstanceofPredicate("ComputedValue", ComputedValue);
1647
1655
 
1648
1656
  var IDerivationState_;
@@ -2183,8 +2191,8 @@ function propagateChangeConfirmed(observable) {
2183
2191
  }
2184
2192
  } else if (d.dependenciesState_ === IDerivationState_.UP_TO_DATE_ // this happens during computing of `d`, just keep lowestObserverState up to date.
2185
2193
  ) {
2186
- observable.lowestObserverState_ = IDerivationState_.UP_TO_DATE_;
2187
- }
2194
+ observable.lowestObserverState_ = IDerivationState_.UP_TO_DATE_;
2195
+ }
2188
2196
  }); // invariantLOS(observable, "confirmed end");
2189
2197
  } // Used by computed when its dependency changed, but we don't wan't to immediately recompute.
2190
2198
 
@@ -3679,9 +3687,12 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
3679
3687
 
3680
3688
  return (_this$values_ = this.values_).splice.apply(_this$values_, [index, deleteCount].concat(newItems));
3681
3689
  } else {
3682
- var res = this.values_.slice(index, index + deleteCount);
3683
- var oldItems = this.values_.slice(index + deleteCount);
3684
- this.values_.length = index + newItems.length - deleteCount;
3690
+ // The items removed by the splice
3691
+ var res = this.values_.slice(index, index + deleteCount); // The items that that should remain at the end of the array
3692
+
3693
+ var oldItems = this.values_.slice(index + deleteCount); // New length is the previous length + addition count - deletion count
3694
+
3695
+ this.values_.length += newItems.length - deleteCount;
3685
3696
 
3686
3697
  for (var i = 0; i < newItems.length; i++) {
3687
3698
  this.values_[index + i] = newItems[i];
@@ -3998,7 +4009,7 @@ var DELETE = "delete"; // just extend Map? See also https://gist.github.com/nest
3998
4009
 
3999
4010
  _Symbol$iterator = Symbol.iterator;
4000
4011
  _Symbol$toStringTag = Symbol.toStringTag;
4001
- var ObservableMap = /*#__PURE__*/function () {
4012
+ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTag2) {
4002
4013
  // hasMap, not hashMap >-).
4003
4014
  function ObservableMap(initialData, enhancer_, name_) {
4004
4015
  if (enhancer_ === void 0) {
@@ -4104,7 +4115,8 @@ var ObservableMap = /*#__PURE__*/function () {
4104
4115
  name: key
4105
4116
  } : null;
4106
4117
 
4107
- if ( notifySpy) spyReportStart(_change);
4118
+ if ( notifySpy) spyReportStart(_change); // TODO fix type
4119
+
4108
4120
  transaction(function () {
4109
4121
  var _this2$hasMap_$get;
4110
4122
 
@@ -4142,7 +4154,8 @@ var ObservableMap = /*#__PURE__*/function () {
4142
4154
  name: key,
4143
4155
  newValue: newValue
4144
4156
  } : null;
4145
- if ( notifySpy) spyReportStart(change);
4157
+ if ( notifySpy) spyReportStart(change); // TODO fix type
4158
+
4146
4159
  observable.setNewValue_(newValue);
4147
4160
  if (notify) notifyListeners(this, change);
4148
4161
  if ( notifySpy) spyReportEnd();
@@ -4176,7 +4189,8 @@ var ObservableMap = /*#__PURE__*/function () {
4176
4189
  name: key,
4177
4190
  newValue: newValue
4178
4191
  } : null;
4179
- if ( notifySpy) spyReportStart(change);
4192
+ if ( notifySpy) spyReportStart(change); // TODO fix type
4193
+
4180
4194
  if (notify) notifyListeners(this, change);
4181
4195
  if ( notifySpy) spyReportEnd();
4182
4196
  };
@@ -4233,7 +4247,7 @@ var ObservableMap = /*#__PURE__*/function () {
4233
4247
  });
4234
4248
  };
4235
4249
 
4236
- _proto[_Symbol$iterator] = function () {
4250
+ _proto[_Symbol$iterator2] = function () {
4237
4251
  return this.entries();
4238
4252
  };
4239
4253
 
@@ -4413,14 +4427,14 @@ var ObservableMap = /*#__PURE__*/function () {
4413
4427
  return this.data_.size;
4414
4428
  }
4415
4429
  }, {
4416
- key: _Symbol$toStringTag,
4430
+ key: _Symbol$toStringTag2,
4417
4431
  get: function get() {
4418
4432
  return "Map";
4419
4433
  }
4420
4434
  }]);
4421
4435
 
4422
4436
  return ObservableMap;
4423
- }(); // eslint-disable-next-line
4437
+ }(_Symbol$iterator, _Symbol$toStringTag); // eslint-disable-next-line
4424
4438
 
4425
4439
  var isObservableMap = /*#__PURE__*/createInstanceofPredicate("ObservableMap", ObservableMap);
4426
4440
 
@@ -4446,7 +4460,7 @@ var _Symbol$iterator$1, _Symbol$toStringTag$1;
4446
4460
  var ObservableSetMarker = {};
4447
4461
  _Symbol$iterator$1 = Symbol.iterator;
4448
4462
  _Symbol$toStringTag$1 = Symbol.toStringTag;
4449
- var ObservableSet = /*#__PURE__*/function () {
4463
+ var ObservableSet = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTag2) {
4450
4464
  function ObservableSet(initialData, enhancer, name_) {
4451
4465
  if (enhancer === void 0) {
4452
4466
  enhancer = deepEnhancer;
@@ -4679,7 +4693,7 @@ var ObservableSet = /*#__PURE__*/function () {
4679
4693
  return "[object ObservableSet]";
4680
4694
  };
4681
4695
 
4682
- _proto[_Symbol$iterator$1] = function () {
4696
+ _proto[_Symbol$iterator2] = function () {
4683
4697
  return this.values();
4684
4698
  };
4685
4699
 
@@ -4690,14 +4704,14 @@ var ObservableSet = /*#__PURE__*/function () {
4690
4704
  return this.data_.size;
4691
4705
  }
4692
4706
  }, {
4693
- key: _Symbol$toStringTag$1,
4707
+ key: _Symbol$toStringTag2,
4694
4708
  get: function get() {
4695
4709
  return "Set";
4696
4710
  }
4697
4711
  }]);
4698
4712
 
4699
4713
  return ObservableSet;
4700
- }(); // eslint-disable-next-line
4714
+ }(_Symbol$iterator$1, _Symbol$toStringTag$1); // eslint-disable-next-line
4701
4715
 
4702
4716
  var isObservableSet = /*#__PURE__*/createInstanceofPredicate("ObservableSet", ObservableSet);
4703
4717
 
@@ -4883,7 +4897,7 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
4883
4897
  // When called from super() some props may not exist yet.
4884
4898
  // However we don't have to worry about missing prop,
4885
4899
  // because the decorator must have been applied to something.
4886
- if ((_this$target_$storedA = this.target_[storedAnnotationsSymbol]) == null ? void 0 : _this$target_$storedA[key]) {
4900
+ if ((_this$target_$storedA = this.target_[storedAnnotationsSymbol]) != null && _this$target_$storedA[key]) {
4887
4901
  return; // will be annotated by subclass constructor
4888
4902
  } else {
4889
4903
  die(1, annotation.annotationType_, this.name_ + "." + key.toString());
@@ -5387,7 +5401,7 @@ inherit(StubArray, Array.prototype); // Weex proto freeze protection was here,
5387
5401
  // but it is unclear why the hack is need as MobX never changed the prototype
5388
5402
  // anyway, so removed it in V6
5389
5403
 
5390
- var LegacyObservableArray = /*#__PURE__*/function (_StubArray) {
5404
+ var LegacyObservableArray = /*#__PURE__*/function (_StubArray, _Symbol$toStringTag, _Symbol$iterator) {
5391
5405
  _inheritsLoose(LegacyObservableArray, _StubArray);
5392
5406
 
5393
5407
  function LegacyObservableArray(initialValues, enhancer, name, owned) {
@@ -5432,7 +5446,7 @@ var LegacyObservableArray = /*#__PURE__*/function (_StubArray) {
5432
5446
  }));
5433
5447
  };
5434
5448
 
5435
- _proto[Symbol.iterator] = function () {
5449
+ _proto[_Symbol$iterator] = function () {
5436
5450
  var self = this;
5437
5451
  var nextIndex = 0;
5438
5452
  return makeIterable({
@@ -5458,14 +5472,14 @@ var LegacyObservableArray = /*#__PURE__*/function (_StubArray) {
5458
5472
  this[$mobx].setArrayLength_(newLength);
5459
5473
  }
5460
5474
  }, {
5461
- key: Symbol.toStringTag,
5475
+ key: _Symbol$toStringTag,
5462
5476
  get: function get() {
5463
5477
  return "Array";
5464
5478
  }
5465
5479
  }]);
5466
5480
 
5467
5481
  return LegacyObservableArray;
5468
- }(StubArray);
5482
+ }(StubArray, Symbol.toStringTag, Symbol.iterator);
5469
5483
 
5470
5484
  Object.entries(arrayExtensions).forEach(function (_ref) {
5471
5485
  var prop = _ref[0],
@@ -5588,7 +5602,7 @@ function eq(a, b, depth, aStack, bStack) {
5588
5602
  if (a !== a) return b !== b; // Exhaust primitive checks
5589
5603
 
5590
5604
  var type = typeof a;
5591
- if (!isFunction(type) && type !== "object" && typeof b != "object") return false; // Compare `[[Class]]` names.
5605
+ if (type !== "function" && type !== "object" && typeof b != "object") return false; // Compare `[[Class]]` names.
5592
5606
 
5593
5607
  var className = toString.call(a);
5594
5608
  if (className !== toString.call(b)) return false;