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.
@@ -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
 
@@ -4001,7 +4009,7 @@ var DELETE = "delete"; // just extend Map? See also https://gist.github.com/nest
4001
4009
 
4002
4010
  _Symbol$iterator = Symbol.iterator;
4003
4011
  _Symbol$toStringTag = Symbol.toStringTag;
4004
- var ObservableMap = /*#__PURE__*/function () {
4012
+ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTag2) {
4005
4013
  // hasMap, not hashMap >-).
4006
4014
  function ObservableMap(initialData, enhancer_, name_) {
4007
4015
  if (enhancer_ === void 0) {
@@ -4107,7 +4115,8 @@ var ObservableMap = /*#__PURE__*/function () {
4107
4115
  name: key
4108
4116
  } : null;
4109
4117
 
4110
- if ( notifySpy) spyReportStart(_change);
4118
+ if ( notifySpy) spyReportStart(_change); // TODO fix type
4119
+
4111
4120
  transaction(function () {
4112
4121
  var _this2$hasMap_$get;
4113
4122
 
@@ -4145,7 +4154,8 @@ var ObservableMap = /*#__PURE__*/function () {
4145
4154
  name: key,
4146
4155
  newValue: newValue
4147
4156
  } : null;
4148
- if ( notifySpy) spyReportStart(change);
4157
+ if ( notifySpy) spyReportStart(change); // TODO fix type
4158
+
4149
4159
  observable.setNewValue_(newValue);
4150
4160
  if (notify) notifyListeners(this, change);
4151
4161
  if ( notifySpy) spyReportEnd();
@@ -4179,7 +4189,8 @@ var ObservableMap = /*#__PURE__*/function () {
4179
4189
  name: key,
4180
4190
  newValue: newValue
4181
4191
  } : null;
4182
- if ( notifySpy) spyReportStart(change);
4192
+ if ( notifySpy) spyReportStart(change); // TODO fix type
4193
+
4183
4194
  if (notify) notifyListeners(this, change);
4184
4195
  if ( notifySpy) spyReportEnd();
4185
4196
  };
@@ -4236,7 +4247,7 @@ var ObservableMap = /*#__PURE__*/function () {
4236
4247
  });
4237
4248
  };
4238
4249
 
4239
- _proto[_Symbol$iterator] = function () {
4250
+ _proto[_Symbol$iterator2] = function () {
4240
4251
  return this.entries();
4241
4252
  };
4242
4253
 
@@ -4416,14 +4427,14 @@ var ObservableMap = /*#__PURE__*/function () {
4416
4427
  return this.data_.size;
4417
4428
  }
4418
4429
  }, {
4419
- key: _Symbol$toStringTag,
4430
+ key: _Symbol$toStringTag2,
4420
4431
  get: function get() {
4421
4432
  return "Map";
4422
4433
  }
4423
4434
  }]);
4424
4435
 
4425
4436
  return ObservableMap;
4426
- }(); // eslint-disable-next-line
4437
+ }(_Symbol$iterator, _Symbol$toStringTag); // eslint-disable-next-line
4427
4438
 
4428
4439
  var isObservableMap = /*#__PURE__*/createInstanceofPredicate("ObservableMap", ObservableMap);
4429
4440
 
@@ -4449,7 +4460,7 @@ var _Symbol$iterator$1, _Symbol$toStringTag$1;
4449
4460
  var ObservableSetMarker = {};
4450
4461
  _Symbol$iterator$1 = Symbol.iterator;
4451
4462
  _Symbol$toStringTag$1 = Symbol.toStringTag;
4452
- var ObservableSet = /*#__PURE__*/function () {
4463
+ var ObservableSet = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTag2) {
4453
4464
  function ObservableSet(initialData, enhancer, name_) {
4454
4465
  if (enhancer === void 0) {
4455
4466
  enhancer = deepEnhancer;
@@ -4682,7 +4693,7 @@ var ObservableSet = /*#__PURE__*/function () {
4682
4693
  return "[object ObservableSet]";
4683
4694
  };
4684
4695
 
4685
- _proto[_Symbol$iterator$1] = function () {
4696
+ _proto[_Symbol$iterator2] = function () {
4686
4697
  return this.values();
4687
4698
  };
4688
4699
 
@@ -4693,14 +4704,14 @@ var ObservableSet = /*#__PURE__*/function () {
4693
4704
  return this.data_.size;
4694
4705
  }
4695
4706
  }, {
4696
- key: _Symbol$toStringTag$1,
4707
+ key: _Symbol$toStringTag2,
4697
4708
  get: function get() {
4698
4709
  return "Set";
4699
4710
  }
4700
4711
  }]);
4701
4712
 
4702
4713
  return ObservableSet;
4703
- }(); // eslint-disable-next-line
4714
+ }(_Symbol$iterator$1, _Symbol$toStringTag$1); // eslint-disable-next-line
4704
4715
 
4705
4716
  var isObservableSet = /*#__PURE__*/createInstanceofPredicate("ObservableSet", ObservableSet);
4706
4717
 
@@ -4886,7 +4897,7 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
4886
4897
  // When called from super() some props may not exist yet.
4887
4898
  // However we don't have to worry about missing prop,
4888
4899
  // because the decorator must have been applied to something.
4889
- 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]) {
4890
4901
  return; // will be annotated by subclass constructor
4891
4902
  } else {
4892
4903
  die(1, annotation.annotationType_, this.name_ + "." + key.toString());
@@ -5390,7 +5401,7 @@ inherit(StubArray, Array.prototype); // Weex proto freeze protection was here,
5390
5401
  // but it is unclear why the hack is need as MobX never changed the prototype
5391
5402
  // anyway, so removed it in V6
5392
5403
 
5393
- var LegacyObservableArray = /*#__PURE__*/function (_StubArray) {
5404
+ var LegacyObservableArray = /*#__PURE__*/function (_StubArray, _Symbol$toStringTag, _Symbol$iterator) {
5394
5405
  _inheritsLoose(LegacyObservableArray, _StubArray);
5395
5406
 
5396
5407
  function LegacyObservableArray(initialValues, enhancer, name, owned) {
@@ -5435,7 +5446,7 @@ var LegacyObservableArray = /*#__PURE__*/function (_StubArray) {
5435
5446
  }));
5436
5447
  };
5437
5448
 
5438
- _proto[Symbol.iterator] = function () {
5449
+ _proto[_Symbol$iterator] = function () {
5439
5450
  var self = this;
5440
5451
  var nextIndex = 0;
5441
5452
  return makeIterable({
@@ -5461,14 +5472,14 @@ var LegacyObservableArray = /*#__PURE__*/function (_StubArray) {
5461
5472
  this[$mobx].setArrayLength_(newLength);
5462
5473
  }
5463
5474
  }, {
5464
- key: Symbol.toStringTag,
5475
+ key: _Symbol$toStringTag,
5465
5476
  get: function get() {
5466
5477
  return "Array";
5467
5478
  }
5468
5479
  }]);
5469
5480
 
5470
5481
  return LegacyObservableArray;
5471
- }(StubArray);
5482
+ }(StubArray, Symbol.toStringTag, Symbol.iterator);
5472
5483
 
5473
5484
  Object.entries(arrayExtensions).forEach(function (_ref) {
5474
5485
  var prop = _ref[0],