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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # mobx
2
2
 
3
+ ## 6.3.9
4
+
5
+ ### Patch Changes
6
+
7
+ - [`87e5a037`](https://github.com/mobxjs/mobx/commit/87e5a03735dbc1930e54a15b5ce88ad684bc3dc1) [#3214](https://github.com/mobxjs/mobx/pull/3214) Thanks [@urugator](https://github.com/urugator)! - `requiresReaction` always takes precedence over global `computedRequiresReaction`
8
+
9
+ * [`9b90e25c`](https://github.com/mobxjs/mobx/commit/9b90e25c7bc0cdc0a07d1f847683604e86790f24) [#3198](https://github.com/mobxjs/mobx/pull/3198) Thanks [@urugator](https://github.com/urugator)! - fix `isPlainObject` impl (fixes #3197)
10
+
3
11
  ## 6.3.8
4
12
 
5
13
  ### Patch Changes
@@ -168,12 +168,11 @@ function isObject(value) {
168
168
  return value !== null && typeof value === "object";
169
169
  }
170
170
  function isPlainObject(value) {
171
- var _proto$constructor;
172
-
173
171
  if (!isObject(value)) return false;
174
172
  var proto = Object.getPrototypeOf(value);
175
173
  if (proto == null) return true;
176
- return ((_proto$constructor = proto.constructor) == null ? void 0 : _proto$constructor.toString()) === plainObjectString;
174
+ var protoConstructor = Object.hasOwnProperty.call(proto, "constructor") && proto.constructor;
175
+ return typeof protoConstructor === "function" && protoConstructor.toString() === plainObjectString;
177
176
  } // https://stackoverflow.com/a/37865170
178
177
 
179
178
  function isGenerator(obj) {
@@ -268,6 +267,9 @@ function _defineProperties(target, props) {
268
267
  function _createClass(Constructor, protoProps, staticProps) {
269
268
  if (protoProps) _defineProperties(Constructor.prototype, protoProps);
270
269
  if (staticProps) _defineProperties(Constructor, staticProps);
270
+ Object.defineProperty(Constructor, "prototype", {
271
+ writable: false
272
+ });
271
273
  return Constructor;
272
274
  }
273
275
 
@@ -292,7 +294,17 @@ function _extends() {
292
294
  function _inheritsLoose(subClass, superClass) {
293
295
  subClass.prototype = Object.create(superClass.prototype);
294
296
  subClass.prototype.constructor = subClass;
295
- subClass.__proto__ = superClass;
297
+
298
+ _setPrototypeOf(subClass, superClass);
299
+ }
300
+
301
+ function _setPrototypeOf(o, p) {
302
+ _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
303
+ o.__proto__ = p;
304
+ return o;
305
+ };
306
+
307
+ return _setPrototypeOf(o, p);
296
308
  }
297
309
 
298
310
  function _assertThisInitialized(self) {
@@ -321,28 +333,24 @@ function _arrayLikeToArray(arr, len) {
321
333
  }
322
334
 
323
335
  function _createForOfIteratorHelperLoose(o, allowArrayLike) {
324
- var it;
325
-
326
- if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
327
- if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
328
- if (it) o = it;
329
- var i = 0;
330
- return function () {
331
- if (i >= o.length) return {
332
- done: true
333
- };
334
- return {
335
- done: false,
336
- value: o[i++]
337
- };
336
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
337
+ if (it) return (it = it.call(o)).next.bind(it);
338
+
339
+ if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
340
+ if (it) o = it;
341
+ var i = 0;
342
+ return function () {
343
+ if (i >= o.length) return {
344
+ done: true
338
345
  };
339
- }
340
-
341
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
346
+ return {
347
+ done: false,
348
+ value: o[i++]
349
+ };
350
+ };
342
351
  }
343
352
 
344
- it = o[Symbol.iterator]();
345
- return it.next.bind(it);
353
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
346
354
  }
347
355
 
348
356
  var storedAnnotationsSymbol = /*#__PURE__*/Symbol("mobx-stored-annotations");
@@ -626,7 +634,7 @@ function make_$1(adm, key, descriptor, source) {
626
634
  var _this$options_;
627
635
 
628
636
  // bound
629
- if ((_this$options_ = this.options_) == null ? void 0 : _this$options_.bound) {
637
+ if ((_this$options_ = this.options_) != null && _this$options_.bound) {
630
638
  return this.extend_(adm, key, descriptor, false) === null ? 0
631
639
  /* Cancel */
632
640
  : 1
@@ -684,7 +692,7 @@ safeDescriptors) {
684
692
  assertActionDescriptor(adm, annotation, key, descriptor);
685
693
  var value = descriptor.value;
686
694
 
687
- if ((_annotation$options_ = annotation.options_) == null ? void 0 : _annotation$options_.bound) {
695
+ if ((_annotation$options_ = annotation.options_) != null && _annotation$options_.bound) {
688
696
  var _adm$proxy_;
689
697
 
690
698
  value = value.bind((_adm$proxy_ = adm.proxy_) != null ? _adm$proxy_ : adm.target_);
@@ -692,7 +700,7 @@ safeDescriptors) {
692
700
 
693
701
  return {
694
702
  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
695
- ((_annotation$options_4 = annotation.options_) == null ? void 0 : _annotation$options_4.bound) ? (_adm$proxy_2 = adm.proxy_) != null ? _adm$proxy_2 : adm.target_ : undefined),
703
+ (_annotation$options_4 = annotation.options_) != null && _annotation$options_4.bound ? (_adm$proxy_2 = adm.proxy_) != null ? _adm$proxy_2 : adm.target_ : undefined),
696
704
  // Non-configurable for classes
697
705
  // prevents accidental field redefinition in subclass
698
706
  configurable: safeDescriptors ? adm.isPlainObject_ : true,
@@ -727,7 +735,7 @@ function make_$2(adm, key, descriptor, source) {
727
735
  // bound - must annotate protos to support super.flow()
728
736
 
729
737
 
730
- if (((_this$options_ = this.options_) == null ? void 0 : _this$options_.bound) && !isFlow(adm.target_[key])) {
738
+ if ((_this$options_ = this.options_) != null && _this$options_.bound && !isFlow(adm.target_[key])) {
731
739
  if (this.extend_(adm, key, descriptor, false) === null) return 0
732
740
  /* Cancel */
733
741
  ;
@@ -910,11 +918,11 @@ function make_$5(adm, key, descriptor, source) {
910
918
  if (isGenerator(descriptor.value)) {
911
919
  var _this$options_;
912
920
 
913
- var flowAnnotation = ((_this$options_ = this.options_) == null ? void 0 : _this$options_.autoBind) ? flow.bound : flow;
921
+ var flowAnnotation = (_this$options_ = this.options_) != null && _this$options_.autoBind ? flow.bound : flow;
914
922
  return flowAnnotation.make_(adm, key, descriptor, source);
915
923
  }
916
924
 
917
- var actionAnnotation = ((_this$options_2 = this.options_) == null ? void 0 : _this$options_2.autoBind) ? autoAction.bound : autoAction;
925
+ var actionAnnotation = (_this$options_2 = this.options_) != null && _this$options_2.autoBind ? autoAction.bound : autoAction;
918
926
  return actionAnnotation.make_(adm, key, descriptor, source);
919
927
  } // other -> observable
920
928
  // Copy props from proto as well, see test:
@@ -923,7 +931,7 @@ function make_$5(adm, key, descriptor, source) {
923
931
 
924
932
  var observableAnnotation = ((_this$options_3 = this.options_) == null ? void 0 : _this$options_3.deep) === false ? observable.ref : observable; // if function respect autoBind option
925
933
 
926
- if (typeof descriptor.value === "function" && ((_this$options_4 = this.options_) == null ? void 0 : _this$options_4.autoBind)) {
934
+ if (typeof descriptor.value === "function" && (_this$options_4 = this.options_) != null && _this$options_4.autoBind) {
927
935
  var _adm$proxy_;
928
936
 
929
937
  descriptor.value = descriptor.value.bind((_adm$proxy_ = adm.proxy_) != null ? _adm$proxy_ : adm.target_);
@@ -951,7 +959,7 @@ function extend_$5(adm, key, descriptor, proxyTrap) {
951
959
  // if function respect autoBind option
952
960
 
953
961
 
954
- if (typeof descriptor.value === "function" && ((_this$options_5 = this.options_) == null ? void 0 : _this$options_5.autoBind)) {
962
+ if (typeof descriptor.value === "function" && (_this$options_5 = this.options_) != null && _this$options_5.autoBind) {
955
963
  var _adm$proxy_2;
956
964
 
957
965
  descriptor.value = descriptor.value.bind((_adm$proxy_2 = adm.proxy_) != null ? _adm$proxy_2 : adm.target_);
@@ -1229,7 +1237,7 @@ function allowStateChangesEnd(prev) {
1229
1237
  var _Symbol$toPrimitive;
1230
1238
  var CREATE = "create";
1231
1239
  _Symbol$toPrimitive = Symbol.toPrimitive;
1232
- var ObservableValue = /*#__PURE__*/function (_Atom) {
1240
+ var ObservableValue = /*#__PURE__*/function (_Atom, _Symbol$toPrimitive2) {
1233
1241
  _inheritsLoose(ObservableValue, _Atom);
1234
1242
 
1235
1243
  function ObservableValue(value, enhancer, name_, notifySpy, equals) {
@@ -1376,12 +1384,12 @@ var ObservableValue = /*#__PURE__*/function (_Atom) {
1376
1384
  return toPrimitive(this.get());
1377
1385
  };
1378
1386
 
1379
- _proto[_Symbol$toPrimitive] = function () {
1387
+ _proto[_Symbol$toPrimitive2] = function () {
1380
1388
  return this.valueOf();
1381
1389
  };
1382
1390
 
1383
1391
  return ObservableValue;
1384
- }(Atom);
1392
+ }(Atom, _Symbol$toPrimitive);
1385
1393
  var isObservableValue = /*#__PURE__*/createInstanceofPredicate("ObservableValue", ObservableValue);
1386
1394
 
1387
1395
  var _Symbol$toPrimitive$1;
@@ -1406,7 +1414,7 @@ var _Symbol$toPrimitive$1;
1406
1414
  */
1407
1415
 
1408
1416
  _Symbol$toPrimitive$1 = Symbol.toPrimitive;
1409
- var ComputedValue = /*#__PURE__*/function () {
1417
+ var ComputedValue = /*#__PURE__*/function (_Symbol$toPrimitive2) {
1410
1418
  // nodes we are looking at. Our value depends on these nodes
1411
1419
  // during tracking it's an array with new observed observers
1412
1420
  // to check for cycles
@@ -1460,7 +1468,7 @@ var ComputedValue = /*#__PURE__*/function () {
1460
1468
 
1461
1469
  this.equals_ = options.equals || (options.compareStructural || options.struct ? comparer.structural : comparer["default"]);
1462
1470
  this.scope_ = options.context;
1463
- this.requiresReaction_ = !!options.requiresReaction;
1471
+ this.requiresReaction_ = options.requiresReaction;
1464
1472
  this.keepAlive_ = !!options.keepAlive;
1465
1473
  }
1466
1474
 
@@ -1628,7 +1636,7 @@ var ComputedValue = /*#__PURE__*/function () {
1628
1636
  console.log("[mobx.trace] Computed value '" + this.name_ + "' is being read outside a reactive context. Doing a full recompute.");
1629
1637
  }
1630
1638
 
1631
- if (globalState.computedRequiresReaction || this.requiresReaction_) {
1639
+ if (typeof this.requiresReaction_ === "boolean" ? this.requiresReaction_ : globalState.computedRequiresReaction) {
1632
1640
  console.warn("[mobx] Computed value '" + this.name_ + "' is being read outside a reactive context. Doing a full recompute.");
1633
1641
  }
1634
1642
  };
@@ -1641,12 +1649,12 @@ var ComputedValue = /*#__PURE__*/function () {
1641
1649
  return toPrimitive(this.get());
1642
1650
  };
1643
1651
 
1644
- _proto[_Symbol$toPrimitive$1] = function () {
1652
+ _proto[_Symbol$toPrimitive2] = function () {
1645
1653
  return this.valueOf();
1646
1654
  };
1647
1655
 
1648
1656
  return ComputedValue;
1649
- }();
1657
+ }(_Symbol$toPrimitive$1);
1650
1658
  var isComputedValue = /*#__PURE__*/createInstanceofPredicate("ComputedValue", ComputedValue);
1651
1659
 
1652
1660
  var IDerivationState_;
@@ -2187,8 +2195,8 @@ function propagateChangeConfirmed(observable) {
2187
2195
  }
2188
2196
  } else if (d.dependenciesState_ === IDerivationState_.UP_TO_DATE_ // this happens during computing of `d`, just keep lowestObserverState up to date.
2189
2197
  ) {
2190
- observable.lowestObserverState_ = IDerivationState_.UP_TO_DATE_;
2191
- }
2198
+ observable.lowestObserverState_ = IDerivationState_.UP_TO_DATE_;
2199
+ }
2192
2200
  }); // invariantLOS(observable, "confirmed end");
2193
2201
  } // Used by computed when its dependency changed, but we don't wan't to immediately recompute.
2194
2202
 
@@ -4005,7 +4013,7 @@ var DELETE = "delete"; // just extend Map? See also https://gist.github.com/nest
4005
4013
 
4006
4014
  _Symbol$iterator = Symbol.iterator;
4007
4015
  _Symbol$toStringTag = Symbol.toStringTag;
4008
- var ObservableMap = /*#__PURE__*/function () {
4016
+ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTag2) {
4009
4017
  // hasMap, not hashMap >-).
4010
4018
  function ObservableMap(initialData, enhancer_, name_) {
4011
4019
  if (enhancer_ === void 0) {
@@ -4111,7 +4119,8 @@ var ObservableMap = /*#__PURE__*/function () {
4111
4119
  name: key
4112
4120
  } : null;
4113
4121
 
4114
- if ( notifySpy) spyReportStart(_change);
4122
+ if ( notifySpy) spyReportStart(_change); // TODO fix type
4123
+
4115
4124
  transaction(function () {
4116
4125
  var _this2$hasMap_$get;
4117
4126
 
@@ -4149,7 +4158,8 @@ var ObservableMap = /*#__PURE__*/function () {
4149
4158
  name: key,
4150
4159
  newValue: newValue
4151
4160
  } : null;
4152
- if ( notifySpy) spyReportStart(change);
4161
+ if ( notifySpy) spyReportStart(change); // TODO fix type
4162
+
4153
4163
  observable.setNewValue_(newValue);
4154
4164
  if (notify) notifyListeners(this, change);
4155
4165
  if ( notifySpy) spyReportEnd();
@@ -4183,7 +4193,8 @@ var ObservableMap = /*#__PURE__*/function () {
4183
4193
  name: key,
4184
4194
  newValue: newValue
4185
4195
  } : null;
4186
- if ( notifySpy) spyReportStart(change);
4196
+ if ( notifySpy) spyReportStart(change); // TODO fix type
4197
+
4187
4198
  if (notify) notifyListeners(this, change);
4188
4199
  if ( notifySpy) spyReportEnd();
4189
4200
  };
@@ -4240,7 +4251,7 @@ var ObservableMap = /*#__PURE__*/function () {
4240
4251
  });
4241
4252
  };
4242
4253
 
4243
- _proto[_Symbol$iterator] = function () {
4254
+ _proto[_Symbol$iterator2] = function () {
4244
4255
  return this.entries();
4245
4256
  };
4246
4257
 
@@ -4420,14 +4431,14 @@ var ObservableMap = /*#__PURE__*/function () {
4420
4431
  return this.data_.size;
4421
4432
  }
4422
4433
  }, {
4423
- key: _Symbol$toStringTag,
4434
+ key: _Symbol$toStringTag2,
4424
4435
  get: function get() {
4425
4436
  return "Map";
4426
4437
  }
4427
4438
  }]);
4428
4439
 
4429
4440
  return ObservableMap;
4430
- }(); // eslint-disable-next-line
4441
+ }(_Symbol$iterator, _Symbol$toStringTag); // eslint-disable-next-line
4431
4442
 
4432
4443
  var isObservableMap = /*#__PURE__*/createInstanceofPredicate("ObservableMap", ObservableMap);
4433
4444
 
@@ -4453,7 +4464,7 @@ var _Symbol$iterator$1, _Symbol$toStringTag$1;
4453
4464
  var ObservableSetMarker = {};
4454
4465
  _Symbol$iterator$1 = Symbol.iterator;
4455
4466
  _Symbol$toStringTag$1 = Symbol.toStringTag;
4456
- var ObservableSet = /*#__PURE__*/function () {
4467
+ var ObservableSet = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTag2) {
4457
4468
  function ObservableSet(initialData, enhancer, name_) {
4458
4469
  if (enhancer === void 0) {
4459
4470
  enhancer = deepEnhancer;
@@ -4686,7 +4697,7 @@ var ObservableSet = /*#__PURE__*/function () {
4686
4697
  return "[object ObservableSet]";
4687
4698
  };
4688
4699
 
4689
- _proto[_Symbol$iterator$1] = function () {
4700
+ _proto[_Symbol$iterator2] = function () {
4690
4701
  return this.values();
4691
4702
  };
4692
4703
 
@@ -4697,14 +4708,14 @@ var ObservableSet = /*#__PURE__*/function () {
4697
4708
  return this.data_.size;
4698
4709
  }
4699
4710
  }, {
4700
- key: _Symbol$toStringTag$1,
4711
+ key: _Symbol$toStringTag2,
4701
4712
  get: function get() {
4702
4713
  return "Set";
4703
4714
  }
4704
4715
  }]);
4705
4716
 
4706
4717
  return ObservableSet;
4707
- }(); // eslint-disable-next-line
4718
+ }(_Symbol$iterator$1, _Symbol$toStringTag$1); // eslint-disable-next-line
4708
4719
 
4709
4720
  var isObservableSet = /*#__PURE__*/createInstanceofPredicate("ObservableSet", ObservableSet);
4710
4721
 
@@ -4890,7 +4901,7 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
4890
4901
  // When called from super() some props may not exist yet.
4891
4902
  // However we don't have to worry about missing prop,
4892
4903
  // because the decorator must have been applied to something.
4893
- if ((_this$target_$storedA = this.target_[storedAnnotationsSymbol]) == null ? void 0 : _this$target_$storedA[key]) {
4904
+ if ((_this$target_$storedA = this.target_[storedAnnotationsSymbol]) != null && _this$target_$storedA[key]) {
4894
4905
  return; // will be annotated by subclass constructor
4895
4906
  } else {
4896
4907
  die(1, annotation.annotationType_, this.name_ + "." + key.toString());
@@ -5394,7 +5405,7 @@ inherit(StubArray, Array.prototype); // Weex proto freeze protection was here,
5394
5405
  // but it is unclear why the hack is need as MobX never changed the prototype
5395
5406
  // anyway, so removed it in V6
5396
5407
 
5397
- var LegacyObservableArray = /*#__PURE__*/function (_StubArray) {
5408
+ var LegacyObservableArray = /*#__PURE__*/function (_StubArray, _Symbol$toStringTag, _Symbol$iterator) {
5398
5409
  _inheritsLoose(LegacyObservableArray, _StubArray);
5399
5410
 
5400
5411
  function LegacyObservableArray(initialValues, enhancer, name, owned) {
@@ -5439,7 +5450,7 @@ var LegacyObservableArray = /*#__PURE__*/function (_StubArray) {
5439
5450
  }));
5440
5451
  };
5441
5452
 
5442
- _proto[Symbol.iterator] = function () {
5453
+ _proto[_Symbol$iterator] = function () {
5443
5454
  var self = this;
5444
5455
  var nextIndex = 0;
5445
5456
  return makeIterable({
@@ -5465,14 +5476,14 @@ var LegacyObservableArray = /*#__PURE__*/function (_StubArray) {
5465
5476
  this[$mobx].setArrayLength_(newLength);
5466
5477
  }
5467
5478
  }, {
5468
- key: Symbol.toStringTag,
5479
+ key: _Symbol$toStringTag,
5469
5480
  get: function get() {
5470
5481
  return "Array";
5471
5482
  }
5472
5483
  }]);
5473
5484
 
5474
5485
  return LegacyObservableArray;
5475
- }(StubArray);
5486
+ }(StubArray, Symbol.toStringTag, Symbol.iterator);
5476
5487
 
5477
5488
  Object.entries(arrayExtensions).forEach(function (_ref) {
5478
5489
  var prop = _ref[0],