mobx 6.12.5 → 6.13.1

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.
@@ -268,100 +268,88 @@
268
268
  });
269
269
  return res;
270
270
  };
271
-
272
- function _defineProperties(target, props) {
273
- for (var i = 0; i < props.length; i++) {
274
- var descriptor = props[i];
275
- descriptor.enumerable = descriptor.enumerable || false;
276
- descriptor.configurable = true;
277
- if ("value" in descriptor) descriptor.writable = true;
278
- Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
279
- }
280
- }
281
- function _createClass(Constructor, protoProps, staticProps) {
282
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
283
- if (staticProps) _defineProperties(Constructor, staticProps);
284
- Object.defineProperty(Constructor, "prototype", {
285
- writable: false
286
- });
287
- return Constructor;
288
- }
289
- function _extends() {
290
- _extends = Object.assign ? Object.assign.bind() : function (target) {
291
- for (var i = 1; i < arguments.length; i++) {
292
- var source = arguments[i];
293
- for (var key in source) {
294
- if (Object.prototype.hasOwnProperty.call(source, key)) {
295
- target[key] = source[key];
296
- }
297
- }
298
- }
299
- return target;
300
- };
301
- return _extends.apply(this, arguments);
271
+ function getFlag(flags, mask) {
272
+ return !!(flags & mask);
302
273
  }
303
- function _inheritsLoose(subClass, superClass) {
304
- subClass.prototype = Object.create(superClass.prototype);
305
- subClass.prototype.constructor = subClass;
306
- _setPrototypeOf(subClass, superClass);
274
+ function setFlag(flags, mask, newValue) {
275
+ if (newValue) {
276
+ flags |= mask;
277
+ } else {
278
+ flags &= ~mask;
279
+ }
280
+ return flags;
307
281
  }
308
- function _setPrototypeOf(o, p) {
309
- _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
310
- o.__proto__ = p;
311
- return o;
312
- };
313
- return _setPrototypeOf(o, p);
314
- }
315
- function _assertThisInitialized(self) {
316
- if (self === void 0) {
317
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
318
- }
319
- return self;
320
- }
321
- function _unsupportedIterableToArray(o, minLen) {
322
- if (!o) return;
323
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
324
- var n = Object.prototype.toString.call(o).slice(8, -1);
325
- if (n === "Object" && o.constructor) n = o.constructor.name;
326
- if (n === "Map" || n === "Set") return Array.from(o);
327
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
328
- }
329
- function _arrayLikeToArray(arr, len) {
330
- if (len == null || len > arr.length) len = arr.length;
331
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
332
- return arr2;
333
- }
334
- function _createForOfIteratorHelperLoose(o, allowArrayLike) {
335
- var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
336
- if (it) return (it = it.call(o)).next.bind(it);
337
- if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
338
- if (it) o = it;
339
- var i = 0;
282
+
283
+ function _arrayLikeToArray(r, a) {
284
+ (null == a || a > r.length) && (a = r.length);
285
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
286
+ return n;
287
+ }
288
+ function _defineProperties(e, r) {
289
+ for (var t = 0; t < r.length; t++) {
290
+ var o = r[t];
291
+ o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
292
+ }
293
+ }
294
+ function _createClass(e, r, t) {
295
+ return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
296
+ writable: !1
297
+ }), e;
298
+ }
299
+ function _createForOfIteratorHelperLoose(r, e) {
300
+ var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
301
+ if (t) return (t = t.call(r)).next.bind(t);
302
+ if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) {
303
+ t && (r = t);
304
+ var o = 0;
340
305
  return function () {
341
- if (i >= o.length) return {
342
- done: true
343
- };
344
- return {
345
- done: false,
346
- value: o[i++]
306
+ return o >= r.length ? {
307
+ done: !0
308
+ } : {
309
+ done: !1,
310
+ value: r[o++]
347
311
  };
348
312
  };
349
313
  }
350
314
  throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
351
315
  }
352
- function _toPrimitive(input, hint) {
353
- if (typeof input !== "object" || input === null) return input;
354
- var prim = input[Symbol.toPrimitive];
355
- if (prim !== undefined) {
356
- var res = prim.call(input, hint || "default");
357
- if (typeof res !== "object") return res;
316
+ function _extends() {
317
+ return _extends = Object.assign ? Object.assign.bind() : function (n) {
318
+ for (var e = 1; e < arguments.length; e++) {
319
+ var t = arguments[e];
320
+ for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
321
+ }
322
+ return n;
323
+ }, _extends.apply(null, arguments);
324
+ }
325
+ function _inheritsLoose(t, o) {
326
+ t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o);
327
+ }
328
+ function _setPrototypeOf(t, e) {
329
+ return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
330
+ return t.__proto__ = e, t;
331
+ }, _setPrototypeOf(t, e);
332
+ }
333
+ function _toPrimitive(t, r) {
334
+ if ("object" != typeof t || !t) return t;
335
+ var e = t[Symbol.toPrimitive];
336
+ if (void 0 !== e) {
337
+ var i = e.call(t, r || "default");
338
+ if ("object" != typeof i) return i;
358
339
  throw new TypeError("@@toPrimitive must return a primitive value.");
359
340
  }
360
- return (hint === "string" ? String : Number)(input);
341
+ return ("string" === r ? String : Number)(t);
361
342
  }
362
- function _toPropertyKey(arg) {
363
- var key = _toPrimitive(arg, "string");
364
- return typeof key === "symbol" ? key : String(key);
343
+ function _toPropertyKey(t) {
344
+ var i = _toPrimitive(t, "string");
345
+ return "symbol" == typeof i ? i : i + "";
346
+ }
347
+ function _unsupportedIterableToArray(r, a) {
348
+ if (r) {
349
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
350
+ var t = {}.toString.call(r).slice(8, -1);
351
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
352
+ }
365
353
  }
366
354
 
367
355
  var storedAnnotationsSymbol = /*#__PURE__*/Symbol("mobx-stored-annotations");
@@ -434,8 +422,6 @@
434
422
 
435
423
  var $mobx = /*#__PURE__*/Symbol("mobx administration");
436
424
  var Atom = /*#__PURE__*/function () {
437
- // for effective unobserving. BaseAtom has true, for extra optimization, so its onBecomeUnobserved never gets called, because it's not needed
438
-
439
425
  /**
440
426
  * Create a new atom. For debugging purposes it is recommended to give it a name.
441
427
  * The onBecomeObserved and onBecomeUnobserved callbacks can be used for resource management.
@@ -445,17 +431,17 @@
445
431
  name_ = "Atom@" + getNextId() ;
446
432
  }
447
433
  this.name_ = void 0;
448
- this.isPendingUnobservation = false;
449
- this.isBeingObserved = false;
434
+ this.flags_ = 0;
450
435
  this.observers_ = new Set();
451
- this.diffValue_ = 0;
452
436
  this.lastAccessedBy_ = 0;
453
437
  this.lowestObserverState_ = IDerivationState_.NOT_TRACKING_;
438
+ // onBecomeObservedListeners
454
439
  this.onBOL = void 0;
440
+ // onBecomeUnobservedListeners
455
441
  this.onBUOL = void 0;
456
442
  this.name_ = name_;
457
443
  }
458
- // onBecomeObservedListeners
444
+ // for effective unobserving. BaseAtom has true, for extra optimization, so its onBecomeUnobserved never gets called, because it's not needed
459
445
  var _proto = Atom.prototype;
460
446
  _proto.onBO = function onBO() {
461
447
  if (this.onBOL) {
@@ -489,8 +475,35 @@
489
475
  _proto.toString = function toString() {
490
476
  return this.name_;
491
477
  };
492
- return Atom;
478
+ return _createClass(Atom, [{
479
+ key: "isBeingObserved",
480
+ get: function get() {
481
+ return getFlag(this.flags_, Atom.isBeingObservedMask_);
482
+ },
483
+ set: function set(newValue) {
484
+ this.flags_ = setFlag(this.flags_, Atom.isBeingObservedMask_, newValue);
485
+ }
486
+ }, {
487
+ key: "isPendingUnobservation",
488
+ get: function get() {
489
+ return getFlag(this.flags_, Atom.isPendingUnobservationMask_);
490
+ },
491
+ set: function set(newValue) {
492
+ this.flags_ = setFlag(this.flags_, Atom.isPendingUnobservationMask_, newValue);
493
+ }
494
+ }, {
495
+ key: "diffValue",
496
+ get: function get() {
497
+ return getFlag(this.flags_, Atom.diffValueMask_) ? 1 : 0;
498
+ },
499
+ set: function set(newValue) {
500
+ this.flags_ = setFlag(this.flags_, Atom.diffValueMask_, newValue === 1 ? true : false);
501
+ }
502
+ }]);
493
503
  }();
504
+ Atom.isBeingObservedMask_ = 1;
505
+ Atom.isPendingUnobservationMask_ = 2;
506
+ Atom.diffValueMask_ = 4;
494
507
  var isAtom = /*#__PURE__*/createInstanceofPredicate("Atom", Atom);
495
508
  function createAtom(name, onBecomeObservedHandler, onBecomeUnobservedHandler) {
496
509
  if (onBecomeObservedHandler === void 0) {
@@ -637,7 +650,6 @@
637
650
  }
638
651
  return 0 /* MakeResult.Cancel */;
639
652
  }
640
-
641
653
  function extend_(adm, key, descriptor, proxyTrap) {
642
654
  die("'" + this.annotationType_ + "' can only be used with 'makeObservable'");
643
655
  }
@@ -670,12 +682,10 @@
670
682
  // rest of the proto chain must be annotated already
671
683
  return 1 /* MakeResult.Break */;
672
684
  }
673
-
674
685
  var actionDescriptor = createActionDescriptor(adm, this, key, descriptor, false);
675
686
  defineProperty(source, key, actionDescriptor);
676
687
  return 2 /* MakeResult.Continue */;
677
688
  }
678
-
679
689
  function extend_$1(adm, key, descriptor, proxyTrap) {
680
690
  var actionDescriptor = createActionDescriptor(adm, this, key, descriptor);
681
691
  return adm.defineProperty_(key, actionDescriptor, proxyTrap);
@@ -773,18 +783,15 @@
773
783
  return 0 /* MakeResult.Cancel */;
774
784
  }
775
785
  }
776
-
777
786
  if (isFlow(descriptor.value)) {
778
787
  // A prototype could have been annotated already by other constructor,
779
788
  // rest of the proto chain must be annotated already
780
789
  return 1 /* MakeResult.Break */;
781
790
  }
782
-
783
791
  var flowDescriptor = createFlowDescriptor(adm, this, key, descriptor, false, false);
784
792
  defineProperty(source, key, flowDescriptor);
785
793
  return 2 /* MakeResult.Continue */;
786
794
  }
787
-
788
795
  function extend_$2(adm, key, descriptor, proxyTrap) {
789
796
  var _this$options_2;
790
797
  var flowDescriptor = createFlowDescriptor(adm, this, key, descriptor, (_this$options_2 = this.options_) == null ? void 0 : _this$options_2.bound);
@@ -861,7 +868,6 @@
861
868
  function make_$3(adm, key, descriptor) {
862
869
  return this.extend_(adm, key, descriptor, false) === null ? 0 /* MakeResult.Cancel */ : 1 /* MakeResult.Break */;
863
870
  }
864
-
865
871
  function extend_$3(adm, key, descriptor, proxyTrap) {
866
872
  assertComputedDescriptor(adm, this, key, descriptor);
867
873
  return adm.defineComputedProperty_(key, _extends({}, this.options_, {
@@ -909,7 +915,6 @@
909
915
  function make_$4(adm, key, descriptor) {
910
916
  return this.extend_(adm, key, descriptor, false) === null ? 0 /* MakeResult.Cancel */ : 1 /* MakeResult.Break */;
911
917
  }
912
-
913
918
  function extend_$4(adm, key, descriptor, proxyTrap) {
914
919
  var _this$options_$enhanc, _this$options_;
915
920
  assertObservableDescriptor(adm, this, key, descriptor);
@@ -1329,11 +1334,8 @@
1329
1334
  globalState.allowStateChanges = prev;
1330
1335
  }
1331
1336
 
1332
- var _Symbol$toPrimitive;
1333
1337
  var CREATE = "create";
1334
- _Symbol$toPrimitive = Symbol.toPrimitive;
1335
1338
  var ObservableValue = /*#__PURE__*/function (_Atom) {
1336
- _inheritsLoose(ObservableValue, _Atom);
1337
1339
  function ObservableValue(value, enhancer, name_, notifySpy, equals) {
1338
1340
  var _this;
1339
1341
  if (name_ === void 0) {
@@ -1362,7 +1364,7 @@
1362
1364
  // only notify spy if this is a stand-alone observable
1363
1365
  spyReport({
1364
1366
  type: CREATE,
1365
- object: _assertThisInitialized(_this),
1367
+ object: _this,
1366
1368
  observableKind: "value",
1367
1369
  debugObjectName: _this.name_,
1368
1370
  newValue: "" + _this.value_
@@ -1370,6 +1372,7 @@
1370
1372
  }
1371
1373
  return _this;
1372
1374
  }
1375
+ _inheritsLoose(ObservableValue, _Atom);
1373
1376
  var _proto = ObservableValue.prototype;
1374
1377
  _proto.dehanceValue = function dehanceValue(value) {
1375
1378
  if (this.dehancer !== undefined) {
@@ -1461,25 +1464,13 @@
1461
1464
  _proto.valueOf = function valueOf() {
1462
1465
  return toPrimitive(this.get());
1463
1466
  };
1464
- _proto[_Symbol$toPrimitive] = function () {
1467
+ _proto[Symbol.toPrimitive] = function () {
1465
1468
  return this.valueOf();
1466
1469
  };
1467
1470
  return ObservableValue;
1468
1471
  }(Atom);
1469
1472
  var isObservableValue = /*#__PURE__*/createInstanceofPredicate("ObservableValue", ObservableValue);
1470
1473
 
1471
- var _Symbol$toPrimitive$1;
1472
- function getFlag(flags, mask) {
1473
- return !!(flags & mask);
1474
- }
1475
- function setFlag(flags, mask, newValue) {
1476
- if (newValue) {
1477
- flags |= mask;
1478
- } else {
1479
- flags &= ~mask;
1480
- }
1481
- return flags;
1482
- }
1483
1474
  /**
1484
1475
  * A node in the state dependency root that observes other nodes, and can be observed itself.
1485
1476
  *
@@ -1499,13 +1490,7 @@
1499
1490
  *
1500
1491
  * If at any point it's outside batch and it isn't observed: reset everything and go to 1.
1501
1492
  */
1502
- _Symbol$toPrimitive$1 = Symbol.toPrimitive;
1503
1493
  var ComputedValue = /*#__PURE__*/function () {
1504
- // nodes we are looking at. Our value depends on these nodes
1505
- // during tracking it's an array with new observed observers
1506
-
1507
- // N.B: unminified as it is used by MST
1508
-
1509
1494
  /**
1510
1495
  * Create a new computed value based on a function expression.
1511
1496
  *
@@ -1521,9 +1506,10 @@
1521
1506
  function ComputedValue(options) {
1522
1507
  this.dependenciesState_ = IDerivationState_.NOT_TRACKING_;
1523
1508
  this.observing_ = [];
1509
+ // nodes we are looking at. Our value depends on these nodes
1524
1510
  this.newObserving_ = null;
1511
+ // during tracking it's an array with new observed observers
1525
1512
  this.observers_ = new Set();
1526
- this.diffValue_ = 0;
1527
1513
  this.runId_ = 0;
1528
1514
  this.lastAccessedBy_ = 0;
1529
1515
  this.lowestObserverState_ = IDerivationState_.UP_TO_DATE_;
@@ -1533,6 +1519,7 @@
1533
1519
  this.triggeredBy_ = void 0;
1534
1520
  this.flags_ = 0;
1535
1521
  this.derivation = void 0;
1522
+ // N.B: unminified as it is used by MST
1536
1523
  this.setter_ = void 0;
1537
1524
  this.isTracing_ = TraceMode.NONE;
1538
1525
  this.scope_ = void 0;
@@ -1714,10 +1701,10 @@
1714
1701
  _proto.valueOf = function valueOf() {
1715
1702
  return toPrimitive(this.get());
1716
1703
  };
1717
- _proto[_Symbol$toPrimitive$1] = function () {
1704
+ _proto[Symbol.toPrimitive] = function () {
1718
1705
  return this.valueOf();
1719
1706
  };
1720
- _createClass(ComputedValue, [{
1707
+ return _createClass(ComputedValue, [{
1721
1708
  key: "isComputing",
1722
1709
  get: function get() {
1723
1710
  return getFlag(this.flags_, ComputedValue.isComputingMask_);
@@ -1749,13 +1736,21 @@
1749
1736
  set: function set(newValue) {
1750
1737
  this.flags_ = setFlag(this.flags_, ComputedValue.isPendingUnobservationMask_, newValue);
1751
1738
  }
1739
+ }, {
1740
+ key: "diffValue",
1741
+ get: function get() {
1742
+ return getFlag(this.flags_, ComputedValue.diffValueMask_) ? 1 : 0;
1743
+ },
1744
+ set: function set(newValue) {
1745
+ this.flags_ = setFlag(this.flags_, ComputedValue.diffValueMask_, newValue === 1 ? true : false);
1746
+ }
1752
1747
  }]);
1753
- return ComputedValue;
1754
1748
  }();
1755
1749
  ComputedValue.isComputingMask_ = 1;
1756
1750
  ComputedValue.isRunningSetterMask_ = 2;
1757
1751
  ComputedValue.isBeingObservedMask_ = 4;
1758
1752
  ComputedValue.isPendingUnobservationMask_ = 8;
1753
+ ComputedValue.diffValueMask_ = 16;
1759
1754
  var isComputedValue = /*#__PURE__*/createInstanceofPredicate("ComputedValue", ComputedValue);
1760
1755
 
1761
1756
  var IDerivationState_;
@@ -1789,7 +1784,6 @@
1789
1784
  this.cause = cause;
1790
1785
  // Empty
1791
1786
  };
1792
-
1793
1787
  function isCaughtException(e) {
1794
1788
  return e instanceof CaughtException;
1795
1789
  }
@@ -1853,7 +1847,6 @@
1853
1847
  function isComputingDerivation() {
1854
1848
  return globalState.trackingDerivation !== null; // filter out actions inside computations
1855
1849
  }
1856
-
1857
1850
  function checkIfStateModificationsAreAllowed(atom) {
1858
1851
  var hasObservers = atom.observers_.size > 0;
1859
1852
  // Should not be possible to change observed state outside strict mode, except during initialization, see #563
@@ -1926,8 +1919,8 @@
1926
1919
  l = derivation.unboundDepsCount_;
1927
1920
  for (var i = 0; i < l; i++) {
1928
1921
  var dep = observing[i];
1929
- if (dep.diffValue_ === 0) {
1930
- dep.diffValue_ = 1;
1922
+ if (dep.diffValue === 0) {
1923
+ dep.diffValue = 1;
1931
1924
  if (i0 !== i) {
1932
1925
  observing[i0] = dep;
1933
1926
  }
@@ -1947,18 +1940,18 @@
1947
1940
  l = prevObserving.length;
1948
1941
  while (l--) {
1949
1942
  var _dep = prevObserving[l];
1950
- if (_dep.diffValue_ === 0) {
1943
+ if (_dep.diffValue === 0) {
1951
1944
  removeObserver(_dep, derivation);
1952
1945
  }
1953
- _dep.diffValue_ = 0;
1946
+ _dep.diffValue = 0;
1954
1947
  }
1955
1948
  // Go through all new observables and check diffValue: (now it should be unique)
1956
1949
  // 0: it was set to 0 in last loop. don't need to do anything.
1957
1950
  // 1: it wasn't observed, let's observe it. set back to 0
1958
1951
  while (i0--) {
1959
1952
  var _dep2 = observing[i0];
1960
- if (_dep2.diffValue_ === 1) {
1961
- _dep2.diffValue_ = 0;
1953
+ if (_dep2.diffValue === 1) {
1954
+ _dep2.diffValue = 0;
1962
1955
  addObserver(_dep2, derivation);
1963
1956
  }
1964
1957
  }
@@ -2024,28 +2017,113 @@
2024
2017
  */
2025
2018
  var persistentKeys = ["mobxGuid", "spyListeners", "enforceActions", "computedRequiresReaction", "reactionRequiresObservable", "observableRequiresReaction", "allowStateReads", "disableErrorBoundaries", "runId", "UNCHANGED", "useProxies"];
2026
2019
  var MobXGlobals = function MobXGlobals() {
2020
+ /**
2021
+ * MobXGlobals version.
2022
+ * MobX compatiblity with other versions loaded in memory as long as this version matches.
2023
+ * It indicates that the global state still stores similar information
2024
+ *
2025
+ * N.B: this version is unrelated to the package version of MobX, and is only the version of the
2026
+ * internal state storage of MobX, and can be the same across many different package versions
2027
+ */
2027
2028
  this.version = 6;
2029
+ /**
2030
+ * globally unique token to signal unchanged
2031
+ */
2028
2032
  this.UNCHANGED = {};
2033
+ /**
2034
+ * Currently running derivation
2035
+ */
2029
2036
  this.trackingDerivation = null;
2037
+ /**
2038
+ * Currently running reaction. This determines if we currently have a reactive context.
2039
+ * (Tracking derivation is also set for temporal tracking of computed values inside actions,
2040
+ * but trackingReaction can only be set by a form of Reaction)
2041
+ */
2030
2042
  this.trackingContext = null;
2043
+ /**
2044
+ * Each time a derivation is tracked, it is assigned a unique run-id
2045
+ */
2031
2046
  this.runId = 0;
2047
+ /**
2048
+ * 'guid' for general purpose. Will be persisted amongst resets.
2049
+ */
2032
2050
  this.mobxGuid = 0;
2051
+ /**
2052
+ * Are we in a batch block? (and how many of them)
2053
+ */
2033
2054
  this.inBatch = 0;
2055
+ /**
2056
+ * Observables that don't have observers anymore, and are about to be
2057
+ * suspended, unless somebody else accesses it in the same batch
2058
+ *
2059
+ * @type {IObservable[]}
2060
+ */
2034
2061
  this.pendingUnobservations = [];
2062
+ /**
2063
+ * List of scheduled, not yet executed, reactions.
2064
+ */
2035
2065
  this.pendingReactions = [];
2066
+ /**
2067
+ * Are we currently processing reactions?
2068
+ */
2036
2069
  this.isRunningReactions = false;
2070
+ /**
2071
+ * Is it allowed to change observables at this point?
2072
+ * In general, MobX doesn't allow that when running computations and React.render.
2073
+ * To ensure that those functions stay pure.
2074
+ */
2037
2075
  this.allowStateChanges = false;
2076
+ /**
2077
+ * Is it allowed to read observables at this point?
2078
+ * Used to hold the state needed for `observableRequiresReaction`
2079
+ */
2038
2080
  this.allowStateReads = true;
2081
+ /**
2082
+ * If strict mode is enabled, state changes are by default not allowed
2083
+ */
2039
2084
  this.enforceActions = true;
2085
+ /**
2086
+ * Spy callbacks
2087
+ */
2040
2088
  this.spyListeners = [];
2089
+ /**
2090
+ * Globally attached error handlers that react specifically to errors in reactions
2091
+ */
2041
2092
  this.globalReactionErrorHandlers = [];
2093
+ /**
2094
+ * Warn if computed values are accessed outside a reactive context
2095
+ */
2042
2096
  this.computedRequiresReaction = false;
2097
+ /**
2098
+ * (Experimental)
2099
+ * Warn if you try to create to derivation / reactive context without accessing any observable.
2100
+ */
2043
2101
  this.reactionRequiresObservable = false;
2102
+ /**
2103
+ * (Experimental)
2104
+ * Warn if observables are accessed outside a reactive context
2105
+ */
2044
2106
  this.observableRequiresReaction = false;
2107
+ /*
2108
+ * Don't catch and rethrow exceptions. This is useful for inspecting the state of
2109
+ * the stack when an exception occurs while debugging.
2110
+ */
2045
2111
  this.disableErrorBoundaries = false;
2112
+ /*
2113
+ * If true, we are already handling an exception in an action. Any errors in reactions should be suppressed, as
2114
+ * they are not the cause, see: https://github.com/mobxjs/mobx/issues/1836
2115
+ */
2046
2116
  this.suppressReactionErrors = false;
2047
2117
  this.useProxies = true;
2118
+ /*
2119
+ * print warnings about code that would fail if proxies weren't available
2120
+ */
2048
2121
  this.verifyProxies = false;
2122
+ /**
2123
+ * False forces all object's descriptors to
2124
+ * writable: true
2125
+ * configurable: true
2126
+ */
2049
2127
  this.safeDescriptors = true;
2050
2128
  };
2051
2129
  var canMergeGlobalState = true;
@@ -2142,7 +2220,6 @@
2142
2220
  // invariantObservers(observable);
2143
2221
  // invariant(observable._observers.indexOf(node) !== -1, "INTERNAL ERROR didn't add node");
2144
2222
  }
2145
-
2146
2223
  function removeObserver(observable, node) {
2147
2224
  // invariant(globalState.inBatch > 0, "INTERNAL ERROR, remove should be called only inside batch");
2148
2225
  // invariant(observable._observers.indexOf(node) !== -1, "INTERNAL ERROR remove already removed node");
@@ -2155,7 +2232,6 @@
2155
2232
  // invariantObservers(observable);
2156
2233
  // invariant(observable._observers.indexOf(node) === -1, "INTERNAL ERROR remove already removed node2");
2157
2234
  }
2158
-
2159
2235
  function queueForUnobservation(observable) {
2160
2236
  if (observable.isPendingUnobservation === false) {
2161
2237
  // invariant(observable._observers.length === 0, "INTERNAL ERROR, should only queue for unobservation unobserved observables");
@@ -2293,7 +2369,6 @@
2293
2369
  });
2294
2370
  // invariantLOS(observable, "maybe end");
2295
2371
  }
2296
-
2297
2372
  function logTraceInfo(derivation, observable) {
2298
2373
  console.log("[mobx.trace] '" + derivation.name_ + "' is invalidated due to a change in: '" + observable.name_ + "'");
2299
2374
  if (derivation.isTracing_ === TraceMode.BREAK) {
@@ -2317,8 +2392,6 @@
2317
2392
  }
2318
2393
 
2319
2394
  var Reaction = /*#__PURE__*/function () {
2320
- // nodes we are looking at. Our value depends on these nodes
2321
-
2322
2395
  function Reaction(name_, onInvalidate_, errorHandler_, requiresObservable_) {
2323
2396
  if (name_ === void 0) {
2324
2397
  name_ = "Reaction@" + getNextId() ;
@@ -2328,15 +2401,12 @@
2328
2401
  this.errorHandler_ = void 0;
2329
2402
  this.requiresObservable_ = void 0;
2330
2403
  this.observing_ = [];
2404
+ // nodes we are looking at. Our value depends on these nodes
2331
2405
  this.newObserving_ = [];
2332
2406
  this.dependenciesState_ = IDerivationState_.NOT_TRACKING_;
2333
- this.diffValue_ = 0;
2334
2407
  this.runId_ = 0;
2335
2408
  this.unboundDepsCount_ = 0;
2336
- this.isDisposed_ = false;
2337
- this.isScheduled_ = false;
2338
- this.isTrackPending_ = false;
2339
- this.isRunning_ = false;
2409
+ this.flags_ = 0;
2340
2410
  this.isTracing_ = TraceMode.NONE;
2341
2411
  this.name_ = name_;
2342
2412
  this.onInvalidate_ = onInvalidate_;
@@ -2348,29 +2418,26 @@
2348
2418
  this.schedule_();
2349
2419
  };
2350
2420
  _proto.schedule_ = function schedule_() {
2351
- if (!this.isScheduled_) {
2352
- this.isScheduled_ = true;
2421
+ if (!this.isScheduled) {
2422
+ this.isScheduled = true;
2353
2423
  globalState.pendingReactions.push(this);
2354
2424
  runReactions();
2355
2425
  }
2356
- };
2357
- _proto.isScheduled = function isScheduled() {
2358
- return this.isScheduled_;
2359
2426
  }
2360
2427
  /**
2361
2428
  * internal, use schedule() if you intend to kick off a reaction
2362
2429
  */;
2363
2430
  _proto.runReaction_ = function runReaction_() {
2364
- if (!this.isDisposed_) {
2431
+ if (!this.isDisposed) {
2365
2432
  startBatch();
2366
- this.isScheduled_ = false;
2433
+ this.isScheduled = false;
2367
2434
  var prev = globalState.trackingContext;
2368
2435
  globalState.trackingContext = this;
2369
2436
  if (shouldCompute(this)) {
2370
- this.isTrackPending_ = true;
2437
+ this.isTrackPending = true;
2371
2438
  try {
2372
2439
  this.onInvalidate_();
2373
- if ("development" !== "production" && this.isTrackPending_ && isSpyEnabled()) {
2440
+ if ("development" !== "production" && this.isTrackPending && isSpyEnabled()) {
2374
2441
  // onInvalidate didn't trigger track right away..
2375
2442
  spyReport({
2376
2443
  name: this.name_,
@@ -2386,11 +2453,10 @@
2386
2453
  }
2387
2454
  };
2388
2455
  _proto.track = function track(fn) {
2389
- if (this.isDisposed_) {
2456
+ if (this.isDisposed) {
2390
2457
  return;
2391
2458
  // console.warn("Reaction already disposed") // Note: Not a warning / error in mobx 4 either
2392
2459
  }
2393
-
2394
2460
  startBatch();
2395
2461
  var notify = isSpyEnabled();
2396
2462
  var startTime;
@@ -2401,14 +2467,14 @@
2401
2467
  type: "reaction"
2402
2468
  });
2403
2469
  }
2404
- this.isRunning_ = true;
2470
+ this.isRunning = true;
2405
2471
  var prevReaction = globalState.trackingContext; // reactions could create reactions...
2406
2472
  globalState.trackingContext = this;
2407
2473
  var result = trackDerivedFunction(this, fn, undefined);
2408
2474
  globalState.trackingContext = prevReaction;
2409
- this.isRunning_ = false;
2410
- this.isTrackPending_ = false;
2411
- if (this.isDisposed_) {
2475
+ this.isRunning = false;
2476
+ this.isTrackPending = false;
2477
+ if (this.isDisposed) {
2412
2478
  // disposed during last run. Clean up everything that was bound after the dispose call.
2413
2479
  clearObserving(this);
2414
2480
  }
@@ -2451,9 +2517,9 @@
2451
2517
  });
2452
2518
  };
2453
2519
  _proto.dispose = function dispose() {
2454
- if (!this.isDisposed_) {
2455
- this.isDisposed_ = true;
2456
- if (!this.isRunning_) {
2520
+ if (!this.isDisposed) {
2521
+ this.isDisposed = true;
2522
+ if (!this.isRunning) {
2457
2523
  // if disposed while running, clean up later. Maybe not optimal, but rare case
2458
2524
  startBatch();
2459
2525
  clearObserving(this);
@@ -2465,9 +2531,9 @@
2465
2531
  var _this2 = this;
2466
2532
  var dispose = function dispose() {
2467
2533
  _this2.dispose();
2468
- abortSignal == null ? void 0 : abortSignal.removeEventListener == null ? void 0 : abortSignal.removeEventListener("abort", dispose);
2534
+ abortSignal == null || abortSignal.removeEventListener == null || abortSignal.removeEventListener("abort", dispose);
2469
2535
  };
2470
- abortSignal == null ? void 0 : abortSignal.addEventListener == null ? void 0 : abortSignal.addEventListener("abort", dispose);
2536
+ abortSignal == null || abortSignal.addEventListener == null || abortSignal.addEventListener("abort", dispose);
2471
2537
  dispose[$mobx] = this;
2472
2538
  return dispose;
2473
2539
  };
@@ -2480,8 +2546,53 @@
2480
2546
  }
2481
2547
  trace(this, enterBreakPoint);
2482
2548
  };
2483
- return Reaction;
2549
+ return _createClass(Reaction, [{
2550
+ key: "isDisposed",
2551
+ get: function get() {
2552
+ return getFlag(this.flags_, Reaction.isDisposedMask_);
2553
+ },
2554
+ set: function set(newValue) {
2555
+ this.flags_ = setFlag(this.flags_, Reaction.isDisposedMask_, newValue);
2556
+ }
2557
+ }, {
2558
+ key: "isScheduled",
2559
+ get: function get() {
2560
+ return getFlag(this.flags_, Reaction.isScheduledMask_);
2561
+ },
2562
+ set: function set(newValue) {
2563
+ this.flags_ = setFlag(this.flags_, Reaction.isScheduledMask_, newValue);
2564
+ }
2565
+ }, {
2566
+ key: "isTrackPending",
2567
+ get: function get() {
2568
+ return getFlag(this.flags_, Reaction.isTrackPendingMask_);
2569
+ },
2570
+ set: function set(newValue) {
2571
+ this.flags_ = setFlag(this.flags_, Reaction.isTrackPendingMask_, newValue);
2572
+ }
2573
+ }, {
2574
+ key: "isRunning",
2575
+ get: function get() {
2576
+ return getFlag(this.flags_, Reaction.isRunningMask_);
2577
+ },
2578
+ set: function set(newValue) {
2579
+ this.flags_ = setFlag(this.flags_, Reaction.isRunningMask_, newValue);
2580
+ }
2581
+ }, {
2582
+ key: "diffValue",
2583
+ get: function get() {
2584
+ return getFlag(this.flags_, Reaction.diffValueMask_) ? 1 : 0;
2585
+ },
2586
+ set: function set(newValue) {
2587
+ this.flags_ = setFlag(this.flags_, Reaction.diffValueMask_, newValue === 1 ? true : false);
2588
+ }
2589
+ }]);
2484
2590
  }();
2591
+ Reaction.isDisposedMask_ = 1;
2592
+ Reaction.isScheduledMask_ = 2;
2593
+ Reaction.isTrackPendingMask_ = 4;
2594
+ Reaction.isRunningMask_ = 8;
2595
+ Reaction.diffValueMask_ = 16;
2485
2596
  function onReactionError(handler) {
2486
2597
  globalState.globalReactionErrorHandlers.push(handler);
2487
2598
  return function () {
@@ -2519,7 +2630,6 @@
2519
2630
  console.error( "Reaction doesn't converge to a stable state after " + MAX_REACTION_ITERATIONS + " iterations." + (" Probably there is a cycle in the reactive function: " + allReactions[0]) );
2520
2631
  allReactions.splice(0); // clear reactions
2521
2632
  }
2522
-
2523
2633
  var remainingReactions = allReactions.splice(0);
2524
2634
  for (var i = 0, l = remainingReactions.length; i < l; i++) {
2525
2635
  remainingReactions[i].runReaction_();
@@ -2647,7 +2757,7 @@
2647
2757
  * @returns disposer function, which can be used to stop the view from being updated in the future.
2648
2758
  */
2649
2759
  function autorun(view, opts) {
2650
- var _opts$name, _opts, _opts2, _opts2$signal, _opts3;
2760
+ var _opts$name, _opts, _opts2, _opts3;
2651
2761
  if (opts === void 0) {
2652
2762
  opts = EMPTY_OBJECT;
2653
2763
  }
@@ -2676,7 +2786,7 @@
2676
2786
  isScheduled = true;
2677
2787
  scheduler(function () {
2678
2788
  isScheduled = false;
2679
- if (!reaction.isDisposed_) {
2789
+ if (!reaction.isDisposed) {
2680
2790
  reaction.track(reactionRunner);
2681
2791
  }
2682
2792
  });
@@ -2686,7 +2796,7 @@
2686
2796
  function reactionRunner() {
2687
2797
  view(reaction);
2688
2798
  }
2689
- if (!((_opts2 = opts) != null && (_opts2$signal = _opts2.signal) != null && _opts2$signal.aborted)) {
2799
+ if (!((_opts2 = opts) != null && (_opts2 = _opts2.signal) != null && _opts2.aborted)) {
2690
2800
  reaction.schedule_();
2691
2801
  }
2692
2802
  return reaction.getDisposer_((_opts3 = opts) == null ? void 0 : _opts3.signal);
@@ -2700,7 +2810,7 @@
2700
2810
  } : run;
2701
2811
  }
2702
2812
  function reaction(expression, effect, opts) {
2703
- var _opts$name2, _opts4, _opts4$signal, _opts5;
2813
+ var _opts$name2, _opts4, _opts5;
2704
2814
  if (opts === void 0) {
2705
2815
  opts = EMPTY_OBJECT;
2706
2816
  }
@@ -2730,7 +2840,7 @@
2730
2840
  }, opts.onError, opts.requiresObservable);
2731
2841
  function reactionRunner() {
2732
2842
  isScheduled = false;
2733
- if (r.isDisposed_) {
2843
+ if (r.isDisposed) {
2734
2844
  return;
2735
2845
  }
2736
2846
  var changed = false;
@@ -2749,7 +2859,7 @@
2749
2859
  }
2750
2860
  firstTime = false;
2751
2861
  }
2752
- if (!((_opts4 = opts) != null && (_opts4$signal = _opts4.signal) != null && _opts4$signal.aborted)) {
2862
+ if (!((_opts4 = opts) != null && (_opts4 = _opts4.signal) != null && _opts4.aborted)) {
2753
2863
  r.schedule_();
2754
2864
  }
2755
2865
  return r.getDisposer_((_opts5 = opts) == null ? void 0 : _opts5.signal);
@@ -2958,7 +3068,6 @@
2958
3068
  }
2959
3069
  onFulfilled(undefined); // kick off the process
2960
3070
  });
2961
-
2962
3071
  promise.cancel = action(name + " - runid: " + runId + " - cancel", function () {
2963
3072
  try {
2964
3073
  if (pendingPromise) {
@@ -2976,7 +3085,6 @@
2976
3085
  rejector(e); // there could be a throwing finally block
2977
3086
  }
2978
3087
  });
2979
-
2980
3088
  return promise;
2981
3089
  };
2982
3090
  res.isMobXFlow = true;
@@ -2991,7 +3099,6 @@
2991
3099
  function flowResult(result) {
2992
3100
  return result; // just tricking TypeScript :)
2993
3101
  }
2994
-
2995
3102
  function isFlow(fn) {
2996
3103
  return (fn == null ? void 0 : fn.isMobXFlow) === true;
2997
3104
  }
@@ -3360,7 +3467,7 @@
3360
3467
  if (typeof opts.timeout === "number") {
3361
3468
  var error = new Error("WHEN_TIMEOUT");
3362
3469
  timeoutHandle = setTimeout(function () {
3363
- if (!disposer[$mobx].isDisposed_) {
3470
+ if (!disposer[$mobx].isDisposed) {
3364
3471
  disposer();
3365
3472
  if (opts.onError) {
3366
3473
  opts.onError(error);
@@ -3413,10 +3520,10 @@
3413
3520
  disposer();
3414
3521
  reject(new Error("WHEN_ABORTED"));
3415
3522
  };
3416
- opts == null ? void 0 : (_opts$signal2 = opts.signal) == null ? void 0 : _opts$signal2.addEventListener == null ? void 0 : _opts$signal2.addEventListener("abort", abort);
3523
+ opts == null || (_opts$signal2 = opts.signal) == null || _opts$signal2.addEventListener == null || _opts$signal2.addEventListener("abort", abort);
3417
3524
  })["finally"](function () {
3418
3525
  var _opts$signal3;
3419
- return opts == null ? void 0 : (_opts$signal3 = opts.signal) == null ? void 0 : _opts$signal3.removeEventListener == null ? void 0 : _opts$signal3.removeEventListener("abort", abort);
3526
+ return opts == null || (_opts$signal3 = opts.signal) == null || _opts$signal3.removeEventListener == null ? void 0 : _opts$signal3.removeEventListener("abort", abort);
3420
3527
  });
3421
3528
  res.cancel = cancel;
3422
3529
  return res;
@@ -3633,8 +3740,6 @@
3633
3740
  }
3634
3741
  };
3635
3742
  var ObservableArrayAdministration = /*#__PURE__*/function () {
3636
- // this is the prop that gets proxied, so can't replace it!
3637
-
3638
3743
  function ObservableArrayAdministration(name, enhancer, owned_, legacyMode_) {
3639
3744
  if (name === void 0) {
3640
3745
  name = "ObservableArray@" + getNextId() ;
@@ -3643,6 +3748,7 @@
3643
3748
  this.legacyMode_ = void 0;
3644
3749
  this.atom_ = void 0;
3645
3750
  this.values_ = [];
3751
+ // this is the prop that gets proxied, so can't replace it!
3646
3752
  this.interceptors_ = void 0;
3647
3753
  this.changeListeners_ = void 0;
3648
3754
  this.enhancer_ = void 0;
@@ -3763,7 +3869,6 @@
3763
3869
  var lengthDelta = newItems.length - deleteCount;
3764
3870
  this.updateArrayLength_(length, lengthDelta); // checks if internal array wasn't modified
3765
3871
  }
3766
-
3767
3872
  var res = this.spliceItemsIntoValues_(index, deleteCount, newItems);
3768
3873
  if (deleteCount !== 0 || newItems.length !== 0) {
3769
3874
  this.notifyArraySplice_(index, newItems, res);
@@ -3863,6 +3968,7 @@
3863
3968
  var change = interceptChange(this, {
3864
3969
  type: UPDATE,
3865
3970
  object: this.proxy_,
3971
+ // since "this" is the real array we need to pass its proxy
3866
3972
  index: index,
3867
3973
  newValue: newValue
3868
3974
  });
@@ -4078,17 +4184,12 @@
4078
4184
  return isObject(thing) && isObservableArrayAdministration(thing[$mobx]);
4079
4185
  }
4080
4186
 
4081
- var _Symbol$iterator, _Symbol$toStringTag;
4082
4187
  var ObservableMapMarker = {};
4083
4188
  var ADD = "add";
4084
4189
  var DELETE = "delete";
4085
4190
  // just extend Map? See also https://gist.github.com/nestharus/13b4d74f2ef4a2f4357dbd3fc23c1e54
4086
4191
  // But: https://github.com/mobxjs/mobx/issues/1556
4087
- _Symbol$iterator = Symbol.iterator;
4088
- _Symbol$toStringTag = Symbol.toStringTag;
4089
4192
  var ObservableMap = /*#__PURE__*/function () {
4090
- // hasMap, not hashMap >-).
4091
-
4092
4193
  function ObservableMap(initialData, enhancer_, name_) {
4093
4194
  var _this = this;
4094
4195
  if (enhancer_ === void 0) {
@@ -4102,6 +4203,7 @@
4102
4203
  this[$mobx] = ObservableMapMarker;
4103
4204
  this.data_ = void 0;
4104
4205
  this.hasMap_ = void 0;
4206
+ // hasMap, not hashMap >-).
4105
4207
  this.keysAtom_ = void 0;
4106
4208
  this.interceptors_ = void 0;
4107
4209
  this.changeListeners_ = void 0;
@@ -4190,7 +4292,7 @@
4190
4292
  transaction(function () {
4191
4293
  var _this3$hasMap_$get;
4192
4294
  _this3.keysAtom_.reportChanged();
4193
- (_this3$hasMap_$get = _this3.hasMap_.get(key)) == null ? void 0 : _this3$hasMap_$get.setNewValue_(false);
4295
+ (_this3$hasMap_$get = _this3.hasMap_.get(key)) == null || _this3$hasMap_$get.setNewValue_(false);
4194
4296
  var observable = _this3.data_.get(key);
4195
4297
  observable.setNewValue_(undefined);
4196
4298
  _this3.data_["delete"](key);
@@ -4240,7 +4342,7 @@
4240
4342
  var observable = new ObservableValue(newValue, _this4.enhancer_, _this4.name_ + "." + stringifyKey(key) , false);
4241
4343
  _this4.data_.set(key, observable);
4242
4344
  newValue = observable.value_; // value might have been changed
4243
- (_this4$hasMap_$get = _this4.hasMap_.get(key)) == null ? void 0 : _this4$hasMap_$get.setNewValue_(true);
4345
+ (_this4$hasMap_$get = _this4.hasMap_.get(key)) == null || _this4$hasMap_$get.setNewValue_(true);
4244
4346
  _this4.keysAtom_.reportChanged();
4245
4347
  });
4246
4348
  var notifySpy = isSpyEnabled();
@@ -4309,7 +4411,7 @@
4309
4411
  }
4310
4412
  });
4311
4413
  };
4312
- _proto[_Symbol$iterator] = function () {
4414
+ _proto[Symbol.iterator] = function () {
4313
4415
  return this.entries();
4314
4416
  };
4315
4417
  _proto.forEach = function forEach(callback, thisArg) {
@@ -4463,19 +4565,18 @@
4463
4565
  _proto.intercept_ = function intercept_(handler) {
4464
4566
  return registerInterceptor(this, handler);
4465
4567
  };
4466
- _createClass(ObservableMap, [{
4568
+ return _createClass(ObservableMap, [{
4467
4569
  key: "size",
4468
4570
  get: function get() {
4469
4571
  this.keysAtom_.reportObserved();
4470
4572
  return this.data_.size;
4471
4573
  }
4472
4574
  }, {
4473
- key: _Symbol$toStringTag,
4575
+ key: Symbol.toStringTag,
4474
4576
  get: function get() {
4475
4577
  return "Map";
4476
4578
  }
4477
4579
  }]);
4478
- return ObservableMap;
4479
4580
  }();
4480
4581
  // eslint-disable-next-line
4481
4582
  var isObservableMap = /*#__PURE__*/createInstanceofPredicate("ObservableMap", ObservableMap);
@@ -4495,10 +4596,7 @@
4495
4596
  }
4496
4597
  }
4497
4598
 
4498
- var _Symbol$iterator$1, _Symbol$toStringTag$1;
4499
4599
  var ObservableSetMarker = {};
4500
- _Symbol$iterator$1 = Symbol.iterator;
4501
- _Symbol$toStringTag$1 = Symbol.toStringTag;
4502
4600
  var ObservableSet = /*#__PURE__*/function () {
4503
4601
  function ObservableSet(initialData, enhancer, name_) {
4504
4602
  var _this = this;
@@ -4569,7 +4667,6 @@
4569
4667
  // ideally, value = change.value would be done here, so that values can be
4570
4668
  // changed by interceptor. Same applies for other Set and Map api's.
4571
4669
  }
4572
-
4573
4670
  if (!this.has(value)) {
4574
4671
  transaction(function () {
4575
4672
  _this3.data_.add(_this3.enhancer_(value, undefined));
@@ -4675,6 +4772,47 @@
4675
4772
  }
4676
4773
  });
4677
4774
  };
4775
+ _proto.intersection = function intersection(otherSet) {
4776
+ if (isES6Set(otherSet)) {
4777
+ return otherSet.intersection(this);
4778
+ } else {
4779
+ var dehancedSet = new Set(this);
4780
+ return dehancedSet.intersection(otherSet);
4781
+ }
4782
+ };
4783
+ _proto.union = function union(otherSet) {
4784
+ if (isES6Set(otherSet)) {
4785
+ return otherSet.union(this);
4786
+ } else {
4787
+ var dehancedSet = new Set(this);
4788
+ return dehancedSet.union(otherSet);
4789
+ }
4790
+ };
4791
+ _proto.difference = function difference(otherSet) {
4792
+ return new Set(this).difference(otherSet);
4793
+ };
4794
+ _proto.symmetricDifference = function symmetricDifference(otherSet) {
4795
+ if (isES6Set(otherSet)) {
4796
+ return otherSet.symmetricDifference(this);
4797
+ } else {
4798
+ var dehancedSet = new Set(this);
4799
+ return dehancedSet.symmetricDifference(otherSet);
4800
+ }
4801
+ };
4802
+ _proto.isSubsetOf = function isSubsetOf(otherSet) {
4803
+ return new Set(this).isSubsetOf(otherSet);
4804
+ };
4805
+ _proto.isSupersetOf = function isSupersetOf(otherSet) {
4806
+ return new Set(this).isSupersetOf(otherSet);
4807
+ };
4808
+ _proto.isDisjointFrom = function isDisjointFrom(otherSet) {
4809
+ if (isES6Set(otherSet)) {
4810
+ return otherSet.isDisjointFrom(this);
4811
+ } else {
4812
+ var dehancedSet = new Set(this);
4813
+ return dehancedSet.isDisjointFrom(otherSet);
4814
+ }
4815
+ };
4678
4816
  _proto.replace = function replace(other) {
4679
4817
  var _this5 = this;
4680
4818
  if (isObservableSet(other)) {
@@ -4713,22 +4851,21 @@
4713
4851
  _proto.toString = function toString() {
4714
4852
  return "[object ObservableSet]";
4715
4853
  };
4716
- _proto[_Symbol$iterator$1] = function () {
4854
+ _proto[Symbol.iterator] = function () {
4717
4855
  return this.values();
4718
4856
  };
4719
- _createClass(ObservableSet, [{
4857
+ return _createClass(ObservableSet, [{
4720
4858
  key: "size",
4721
4859
  get: function get() {
4722
4860
  this.atom_.reportObserved();
4723
4861
  return this.data_.size;
4724
4862
  }
4725
4863
  }, {
4726
- key: _Symbol$toStringTag$1,
4864
+ key: Symbol.toStringTag,
4727
4865
  get: function get() {
4728
4866
  return "Set";
4729
4867
  }
4730
4868
  }]);
4731
- return ObservableSet;
4732
4869
  }();
4733
4870
  // eslint-disable-next-line
4734
4871
  var isObservableSet = /*#__PURE__*/createInstanceofPredicate("ObservableSet", ObservableSet);
@@ -5128,7 +5265,7 @@
5128
5265
  }
5129
5266
  // Delete
5130
5267
  try {
5131
- var _this$pendingKeys_, _this$pendingKeys_$ge;
5268
+ var _this$pendingKeys_;
5132
5269
  startBatch();
5133
5270
  var notify = hasListeners(this);
5134
5271
  var notifySpy = "development" !== "production" && isSpyEnabled();
@@ -5166,7 +5303,7 @@
5166
5303
  this.keysAtom_.reportChanged();
5167
5304
  // Notify "has" observers
5168
5305
  // "in" as it may still exist in proto
5169
- (_this$pendingKeys_ = this.pendingKeys_) == null ? void 0 : (_this$pendingKeys_$ge = _this$pendingKeys_.get(key)) == null ? void 0 : _this$pendingKeys_$ge.set(key in this.target_);
5306
+ (_this$pendingKeys_ = this.pendingKeys_) == null || (_this$pendingKeys_ = _this$pendingKeys_.get(key)) == null || _this$pendingKeys_.set(key in this.target_);
5170
5307
  // Notify spies/listeners
5171
5308
  if (notify || notifySpy) {
5172
5309
  var _change2 = {
@@ -5207,7 +5344,7 @@
5207
5344
  return registerInterceptor(this, handler);
5208
5345
  };
5209
5346
  _proto.notifyPropertyAddition_ = function notifyPropertyAddition_(key, value) {
5210
- var _this$pendingKeys_2, _this$pendingKeys_2$g;
5347
+ var _this$pendingKeys_2;
5211
5348
  var notify = hasListeners(this);
5212
5349
  var notifySpy = isSpyEnabled();
5213
5350
  if (notify || notifySpy) {
@@ -5229,7 +5366,7 @@
5229
5366
  spyReportEnd();
5230
5367
  }
5231
5368
  }
5232
- (_this$pendingKeys_2 = this.pendingKeys_) == null ? void 0 : (_this$pendingKeys_2$g = _this$pendingKeys_2.get(key)) == null ? void 0 : _this$pendingKeys_2$g.set(true);
5369
+ (_this$pendingKeys_2 = this.pendingKeys_) == null || (_this$pendingKeys_2 = _this$pendingKeys_2.get(key)) == null || _this$pendingKeys_2.set(true);
5233
5370
  // Notify "keys/entries/values" observers
5234
5371
  this.keysAtom_.reportChanged();
5235
5372
  };
@@ -5291,7 +5428,7 @@
5291
5428
  adm.appliedAnnotations_[key] = annotation;
5292
5429
  }
5293
5430
  // Remove applied decorator annotation so we don't try to apply it again in subclass constructor
5294
- (_adm$target_$storedAn = adm.target_[storedAnnotationsSymbol]) == null ? true : delete _adm$target_$storedAn[key];
5431
+ (_adm$target_$storedAn = adm.target_[storedAnnotationsSymbol]) == null || delete _adm$target_$storedAn[key];
5295
5432
  }
5296
5433
  function assertAnnotable(adm, annotation, key) {
5297
5434
  // Valid annotation
@@ -5371,8 +5508,7 @@
5371
5508
  // Weex proto freeze protection was here,
5372
5509
  // but it is unclear why the hack is need as MobX never changed the prototype
5373
5510
  // anyway, so removed it in V6
5374
- var LegacyObservableArray = /*#__PURE__*/function (_StubArray, _Symbol$toStringTag, _Symbol$iterator) {
5375
- _inheritsLoose(LegacyObservableArray, _StubArray);
5511
+ var LegacyObservableArray = /*#__PURE__*/function (_StubArray) {
5376
5512
  function LegacyObservableArray(initialValues, enhancer, name, owned) {
5377
5513
  var _this;
5378
5514
  if (name === void 0) {
@@ -5384,8 +5520,8 @@
5384
5520
  _this = _StubArray.call(this) || this;
5385
5521
  initObservable(function () {
5386
5522
  var adm = new ObservableArrayAdministration(name, enhancer, owned, true);
5387
- adm.proxy_ = _assertThisInitialized(_this);
5388
- addHiddenFinalProp(_assertThisInitialized(_this), $mobx, adm);
5523
+ adm.proxy_ = _this;
5524
+ addHiddenFinalProp(_this, $mobx, adm);
5389
5525
  if (initialValues && initialValues.length) {
5390
5526
  // @ts-ignore
5391
5527
  _this.spliceWithArray(0, 0, initialValues);
@@ -5393,11 +5529,12 @@
5393
5529
  if (safariPrototypeSetterInheritanceBug) {
5394
5530
  // Seems that Safari won't use numeric prototype setter until any * numeric property is
5395
5531
  // defined on the instance. After that it works fine, even if this property is deleted.
5396
- Object.defineProperty(_assertThisInitialized(_this), "0", ENTRY_0);
5532
+ Object.defineProperty(_this, "0", ENTRY_0);
5397
5533
  }
5398
5534
  });
5399
5535
  return _this;
5400
5536
  }
5537
+ _inheritsLoose(LegacyObservableArray, _StubArray);
5401
5538
  var _proto = LegacyObservableArray.prototype;
5402
5539
  _proto.concat = function concat() {
5403
5540
  this[$mobx].atom_.reportObserved();
@@ -5410,7 +5547,7 @@
5410
5547
  return isObservableArray(a) ? a.slice() : a;
5411
5548
  }));
5412
5549
  };
5413
- _proto[_Symbol$iterator] = function () {
5550
+ _proto[Symbol.iterator] = function () {
5414
5551
  var self = this;
5415
5552
  var nextIndex = 0;
5416
5553
  return makeIterable({
@@ -5425,7 +5562,7 @@
5425
5562
  }
5426
5563
  });
5427
5564
  };
5428
- _createClass(LegacyObservableArray, [{
5565
+ return _createClass(LegacyObservableArray, [{
5429
5566
  key: "length",
5430
5567
  get: function get() {
5431
5568
  return this[$mobx].getArrayLength_();
@@ -5434,13 +5571,12 @@
5434
5571
  this[$mobx].setArrayLength_(newLength);
5435
5572
  }
5436
5573
  }, {
5437
- key: _Symbol$toStringTag,
5574
+ key: Symbol.toStringTag,
5438
5575
  get: function get() {
5439
5576
  return "Array";
5440
5577
  }
5441
5578
  }]);
5442
- return LegacyObservableArray;
5443
- }(StubArray, Symbol.toStringTag, Symbol.iterator);
5579
+ }(StubArray);
5444
5580
  Object.entries(arrayExtensions).forEach(function (_ref) {
5445
5581
  var prop = _ref[0],
5446
5582
  fn = _ref[1];