mobx 6.12.5 → 6.13.0

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.
@@ -269,99 +269,76 @@
269
269
  return res;
270
270
  };
271
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);
302
- }
303
- function _inheritsLoose(subClass, superClass) {
304
- subClass.prototype = Object.create(superClass.prototype);
305
- subClass.prototype.constructor = subClass;
306
- _setPrototypeOf(subClass, superClass);
307
- }
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;
272
+ function _arrayLikeToArray(r, a) {
273
+ (null == a || a > r.length) && (a = r.length);
274
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
275
+ return n;
276
+ }
277
+ function _defineProperties(e, r) {
278
+ for (var t = 0; t < r.length; t++) {
279
+ var o = r[t];
280
+ o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
281
+ }
282
+ }
283
+ function _createClass(e, r, t) {
284
+ return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
285
+ writable: !1
286
+ }), e;
287
+ }
288
+ function _createForOfIteratorHelperLoose(r, e) {
289
+ var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
290
+ if (t) return (t = t.call(r)).next.bind(t);
291
+ if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) {
292
+ t && (r = t);
293
+ var o = 0;
340
294
  return function () {
341
- if (i >= o.length) return {
342
- done: true
343
- };
344
- return {
345
- done: false,
346
- value: o[i++]
295
+ return o >= r.length ? {
296
+ done: !0
297
+ } : {
298
+ done: !1,
299
+ value: r[o++]
347
300
  };
348
301
  };
349
302
  }
350
303
  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
304
  }
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;
305
+ function _extends() {
306
+ return _extends = Object.assign ? Object.assign.bind() : function (n) {
307
+ for (var e = 1; e < arguments.length; e++) {
308
+ var t = arguments[e];
309
+ for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
310
+ }
311
+ return n;
312
+ }, _extends.apply(null, arguments);
313
+ }
314
+ function _inheritsLoose(t, o) {
315
+ t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o);
316
+ }
317
+ function _setPrototypeOf(t, e) {
318
+ return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
319
+ return t.__proto__ = e, t;
320
+ }, _setPrototypeOf(t, e);
321
+ }
322
+ function _toPrimitive(t, r) {
323
+ if ("object" != typeof t || !t) return t;
324
+ var e = t[Symbol.toPrimitive];
325
+ if (void 0 !== e) {
326
+ var i = e.call(t, r || "default");
327
+ if ("object" != typeof i) return i;
358
328
  throw new TypeError("@@toPrimitive must return a primitive value.");
359
329
  }
360
- return (hint === "string" ? String : Number)(input);
330
+ return ("string" === r ? String : Number)(t);
361
331
  }
362
- function _toPropertyKey(arg) {
363
- var key = _toPrimitive(arg, "string");
364
- return typeof key === "symbol" ? key : String(key);
332
+ function _toPropertyKey(t) {
333
+ var i = _toPrimitive(t, "string");
334
+ return "symbol" == typeof i ? i : i + "";
335
+ }
336
+ function _unsupportedIterableToArray(r, a) {
337
+ if (r) {
338
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
339
+ var t = {}.toString.call(r).slice(8, -1);
340
+ 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;
341
+ }
365
342
  }
366
343
 
367
344
  var storedAnnotationsSymbol = /*#__PURE__*/Symbol("mobx-stored-annotations");
@@ -434,8 +411,6 @@
434
411
 
435
412
  var $mobx = /*#__PURE__*/Symbol("mobx administration");
436
413
  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
414
  /**
440
415
  * Create a new atom. For debugging purposes it is recommended to give it a name.
441
416
  * The onBecomeObserved and onBecomeUnobserved callbacks can be used for resource management.
@@ -446,16 +421,18 @@
446
421
  }
447
422
  this.name_ = void 0;
448
423
  this.isPendingUnobservation = false;
424
+ // for effective unobserving. BaseAtom has true, for extra optimization, so its onBecomeUnobserved never gets called, because it's not needed
449
425
  this.isBeingObserved = false;
450
426
  this.observers_ = new Set();
451
427
  this.diffValue_ = 0;
452
428
  this.lastAccessedBy_ = 0;
453
429
  this.lowestObserverState_ = IDerivationState_.NOT_TRACKING_;
430
+ // onBecomeObservedListeners
454
431
  this.onBOL = void 0;
432
+ // onBecomeUnobservedListeners
455
433
  this.onBUOL = void 0;
456
434
  this.name_ = name_;
457
435
  }
458
- // onBecomeObservedListeners
459
436
  var _proto = Atom.prototype;
460
437
  _proto.onBO = function onBO() {
461
438
  if (this.onBOL) {
@@ -637,7 +614,6 @@
637
614
  }
638
615
  return 0 /* MakeResult.Cancel */;
639
616
  }
640
-
641
617
  function extend_(adm, key, descriptor, proxyTrap) {
642
618
  die("'" + this.annotationType_ + "' can only be used with 'makeObservable'");
643
619
  }
@@ -670,12 +646,10 @@
670
646
  // rest of the proto chain must be annotated already
671
647
  return 1 /* MakeResult.Break */;
672
648
  }
673
-
674
649
  var actionDescriptor = createActionDescriptor(adm, this, key, descriptor, false);
675
650
  defineProperty(source, key, actionDescriptor);
676
651
  return 2 /* MakeResult.Continue */;
677
652
  }
678
-
679
653
  function extend_$1(adm, key, descriptor, proxyTrap) {
680
654
  var actionDescriptor = createActionDescriptor(adm, this, key, descriptor);
681
655
  return adm.defineProperty_(key, actionDescriptor, proxyTrap);
@@ -773,18 +747,15 @@
773
747
  return 0 /* MakeResult.Cancel */;
774
748
  }
775
749
  }
776
-
777
750
  if (isFlow(descriptor.value)) {
778
751
  // A prototype could have been annotated already by other constructor,
779
752
  // rest of the proto chain must be annotated already
780
753
  return 1 /* MakeResult.Break */;
781
754
  }
782
-
783
755
  var flowDescriptor = createFlowDescriptor(adm, this, key, descriptor, false, false);
784
756
  defineProperty(source, key, flowDescriptor);
785
757
  return 2 /* MakeResult.Continue */;
786
758
  }
787
-
788
759
  function extend_$2(adm, key, descriptor, proxyTrap) {
789
760
  var _this$options_2;
790
761
  var flowDescriptor = createFlowDescriptor(adm, this, key, descriptor, (_this$options_2 = this.options_) == null ? void 0 : _this$options_2.bound);
@@ -861,7 +832,6 @@
861
832
  function make_$3(adm, key, descriptor) {
862
833
  return this.extend_(adm, key, descriptor, false) === null ? 0 /* MakeResult.Cancel */ : 1 /* MakeResult.Break */;
863
834
  }
864
-
865
835
  function extend_$3(adm, key, descriptor, proxyTrap) {
866
836
  assertComputedDescriptor(adm, this, key, descriptor);
867
837
  return adm.defineComputedProperty_(key, _extends({}, this.options_, {
@@ -909,7 +879,6 @@
909
879
  function make_$4(adm, key, descriptor) {
910
880
  return this.extend_(adm, key, descriptor, false) === null ? 0 /* MakeResult.Cancel */ : 1 /* MakeResult.Break */;
911
881
  }
912
-
913
882
  function extend_$4(adm, key, descriptor, proxyTrap) {
914
883
  var _this$options_$enhanc, _this$options_;
915
884
  assertObservableDescriptor(adm, this, key, descriptor);
@@ -1329,11 +1298,8 @@
1329
1298
  globalState.allowStateChanges = prev;
1330
1299
  }
1331
1300
 
1332
- var _Symbol$toPrimitive;
1333
1301
  var CREATE = "create";
1334
- _Symbol$toPrimitive = Symbol.toPrimitive;
1335
1302
  var ObservableValue = /*#__PURE__*/function (_Atom) {
1336
- _inheritsLoose(ObservableValue, _Atom);
1337
1303
  function ObservableValue(value, enhancer, name_, notifySpy, equals) {
1338
1304
  var _this;
1339
1305
  if (name_ === void 0) {
@@ -1362,7 +1328,7 @@
1362
1328
  // only notify spy if this is a stand-alone observable
1363
1329
  spyReport({
1364
1330
  type: CREATE,
1365
- object: _assertThisInitialized(_this),
1331
+ object: _this,
1366
1332
  observableKind: "value",
1367
1333
  debugObjectName: _this.name_,
1368
1334
  newValue: "" + _this.value_
@@ -1370,6 +1336,7 @@
1370
1336
  }
1371
1337
  return _this;
1372
1338
  }
1339
+ _inheritsLoose(ObservableValue, _Atom);
1373
1340
  var _proto = ObservableValue.prototype;
1374
1341
  _proto.dehanceValue = function dehanceValue(value) {
1375
1342
  if (this.dehancer !== undefined) {
@@ -1461,14 +1428,13 @@
1461
1428
  _proto.valueOf = function valueOf() {
1462
1429
  return toPrimitive(this.get());
1463
1430
  };
1464
- _proto[_Symbol$toPrimitive] = function () {
1431
+ _proto[Symbol.toPrimitive] = function () {
1465
1432
  return this.valueOf();
1466
1433
  };
1467
1434
  return ObservableValue;
1468
1435
  }(Atom);
1469
1436
  var isObservableValue = /*#__PURE__*/createInstanceofPredicate("ObservableValue", ObservableValue);
1470
1437
 
1471
- var _Symbol$toPrimitive$1;
1472
1438
  function getFlag(flags, mask) {
1473
1439
  return !!(flags & mask);
1474
1440
  }
@@ -1499,13 +1465,7 @@
1499
1465
  *
1500
1466
  * If at any point it's outside batch and it isn't observed: reset everything and go to 1.
1501
1467
  */
1502
- _Symbol$toPrimitive$1 = Symbol.toPrimitive;
1503
1468
  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
1469
  /**
1510
1470
  * Create a new computed value based on a function expression.
1511
1471
  *
@@ -1521,7 +1481,9 @@
1521
1481
  function ComputedValue(options) {
1522
1482
  this.dependenciesState_ = IDerivationState_.NOT_TRACKING_;
1523
1483
  this.observing_ = [];
1484
+ // nodes we are looking at. Our value depends on these nodes
1524
1485
  this.newObserving_ = null;
1486
+ // during tracking it's an array with new observed observers
1525
1487
  this.observers_ = new Set();
1526
1488
  this.diffValue_ = 0;
1527
1489
  this.runId_ = 0;
@@ -1533,6 +1495,7 @@
1533
1495
  this.triggeredBy_ = void 0;
1534
1496
  this.flags_ = 0;
1535
1497
  this.derivation = void 0;
1498
+ // N.B: unminified as it is used by MST
1536
1499
  this.setter_ = void 0;
1537
1500
  this.isTracing_ = TraceMode.NONE;
1538
1501
  this.scope_ = void 0;
@@ -1714,10 +1677,10 @@
1714
1677
  _proto.valueOf = function valueOf() {
1715
1678
  return toPrimitive(this.get());
1716
1679
  };
1717
- _proto[_Symbol$toPrimitive$1] = function () {
1680
+ _proto[Symbol.toPrimitive] = function () {
1718
1681
  return this.valueOf();
1719
1682
  };
1720
- _createClass(ComputedValue, [{
1683
+ return _createClass(ComputedValue, [{
1721
1684
  key: "isComputing",
1722
1685
  get: function get() {
1723
1686
  return getFlag(this.flags_, ComputedValue.isComputingMask_);
@@ -1750,7 +1713,6 @@
1750
1713
  this.flags_ = setFlag(this.flags_, ComputedValue.isPendingUnobservationMask_, newValue);
1751
1714
  }
1752
1715
  }]);
1753
- return ComputedValue;
1754
1716
  }();
1755
1717
  ComputedValue.isComputingMask_ = 1;
1756
1718
  ComputedValue.isRunningSetterMask_ = 2;
@@ -1789,7 +1751,6 @@
1789
1751
  this.cause = cause;
1790
1752
  // Empty
1791
1753
  };
1792
-
1793
1754
  function isCaughtException(e) {
1794
1755
  return e instanceof CaughtException;
1795
1756
  }
@@ -1853,7 +1814,6 @@
1853
1814
  function isComputingDerivation() {
1854
1815
  return globalState.trackingDerivation !== null; // filter out actions inside computations
1855
1816
  }
1856
-
1857
1817
  function checkIfStateModificationsAreAllowed(atom) {
1858
1818
  var hasObservers = atom.observers_.size > 0;
1859
1819
  // Should not be possible to change observed state outside strict mode, except during initialization, see #563
@@ -2024,28 +1984,113 @@
2024
1984
  */
2025
1985
  var persistentKeys = ["mobxGuid", "spyListeners", "enforceActions", "computedRequiresReaction", "reactionRequiresObservable", "observableRequiresReaction", "allowStateReads", "disableErrorBoundaries", "runId", "UNCHANGED", "useProxies"];
2026
1986
  var MobXGlobals = function MobXGlobals() {
1987
+ /**
1988
+ * MobXGlobals version.
1989
+ * MobX compatiblity with other versions loaded in memory as long as this version matches.
1990
+ * It indicates that the global state still stores similar information
1991
+ *
1992
+ * N.B: this version is unrelated to the package version of MobX, and is only the version of the
1993
+ * internal state storage of MobX, and can be the same across many different package versions
1994
+ */
2027
1995
  this.version = 6;
1996
+ /**
1997
+ * globally unique token to signal unchanged
1998
+ */
2028
1999
  this.UNCHANGED = {};
2000
+ /**
2001
+ * Currently running derivation
2002
+ */
2029
2003
  this.trackingDerivation = null;
2004
+ /**
2005
+ * Currently running reaction. This determines if we currently have a reactive context.
2006
+ * (Tracking derivation is also set for temporal tracking of computed values inside actions,
2007
+ * but trackingReaction can only be set by a form of Reaction)
2008
+ */
2030
2009
  this.trackingContext = null;
2010
+ /**
2011
+ * Each time a derivation is tracked, it is assigned a unique run-id
2012
+ */
2031
2013
  this.runId = 0;
2014
+ /**
2015
+ * 'guid' for general purpose. Will be persisted amongst resets.
2016
+ */
2032
2017
  this.mobxGuid = 0;
2018
+ /**
2019
+ * Are we in a batch block? (and how many of them)
2020
+ */
2033
2021
  this.inBatch = 0;
2022
+ /**
2023
+ * Observables that don't have observers anymore, and are about to be
2024
+ * suspended, unless somebody else accesses it in the same batch
2025
+ *
2026
+ * @type {IObservable[]}
2027
+ */
2034
2028
  this.pendingUnobservations = [];
2029
+ /**
2030
+ * List of scheduled, not yet executed, reactions.
2031
+ */
2035
2032
  this.pendingReactions = [];
2033
+ /**
2034
+ * Are we currently processing reactions?
2035
+ */
2036
2036
  this.isRunningReactions = false;
2037
+ /**
2038
+ * Is it allowed to change observables at this point?
2039
+ * In general, MobX doesn't allow that when running computations and React.render.
2040
+ * To ensure that those functions stay pure.
2041
+ */
2037
2042
  this.allowStateChanges = false;
2043
+ /**
2044
+ * Is it allowed to read observables at this point?
2045
+ * Used to hold the state needed for `observableRequiresReaction`
2046
+ */
2038
2047
  this.allowStateReads = true;
2048
+ /**
2049
+ * If strict mode is enabled, state changes are by default not allowed
2050
+ */
2039
2051
  this.enforceActions = true;
2052
+ /**
2053
+ * Spy callbacks
2054
+ */
2040
2055
  this.spyListeners = [];
2056
+ /**
2057
+ * Globally attached error handlers that react specifically to errors in reactions
2058
+ */
2041
2059
  this.globalReactionErrorHandlers = [];
2060
+ /**
2061
+ * Warn if computed values are accessed outside a reactive context
2062
+ */
2042
2063
  this.computedRequiresReaction = false;
2064
+ /**
2065
+ * (Experimental)
2066
+ * Warn if you try to create to derivation / reactive context without accessing any observable.
2067
+ */
2043
2068
  this.reactionRequiresObservable = false;
2069
+ /**
2070
+ * (Experimental)
2071
+ * Warn if observables are accessed outside a reactive context
2072
+ */
2044
2073
  this.observableRequiresReaction = false;
2074
+ /*
2075
+ * Don't catch and rethrow exceptions. This is useful for inspecting the state of
2076
+ * the stack when an exception occurs while debugging.
2077
+ */
2045
2078
  this.disableErrorBoundaries = false;
2079
+ /*
2080
+ * If true, we are already handling an exception in an action. Any errors in reactions should be suppressed, as
2081
+ * they are not the cause, see: https://github.com/mobxjs/mobx/issues/1836
2082
+ */
2046
2083
  this.suppressReactionErrors = false;
2047
2084
  this.useProxies = true;
2085
+ /*
2086
+ * print warnings about code that would fail if proxies weren't available
2087
+ */
2048
2088
  this.verifyProxies = false;
2089
+ /**
2090
+ * False forces all object's descriptors to
2091
+ * writable: true
2092
+ * configurable: true
2093
+ */
2049
2094
  this.safeDescriptors = true;
2050
2095
  };
2051
2096
  var canMergeGlobalState = true;
@@ -2142,7 +2187,6 @@
2142
2187
  // invariantObservers(observable);
2143
2188
  // invariant(observable._observers.indexOf(node) !== -1, "INTERNAL ERROR didn't add node");
2144
2189
  }
2145
-
2146
2190
  function removeObserver(observable, node) {
2147
2191
  // invariant(globalState.inBatch > 0, "INTERNAL ERROR, remove should be called only inside batch");
2148
2192
  // invariant(observable._observers.indexOf(node) !== -1, "INTERNAL ERROR remove already removed node");
@@ -2155,7 +2199,6 @@
2155
2199
  // invariantObservers(observable);
2156
2200
  // invariant(observable._observers.indexOf(node) === -1, "INTERNAL ERROR remove already removed node2");
2157
2201
  }
2158
-
2159
2202
  function queueForUnobservation(observable) {
2160
2203
  if (observable.isPendingUnobservation === false) {
2161
2204
  // invariant(observable._observers.length === 0, "INTERNAL ERROR, should only queue for unobservation unobserved observables");
@@ -2293,7 +2336,6 @@
2293
2336
  });
2294
2337
  // invariantLOS(observable, "maybe end");
2295
2338
  }
2296
-
2297
2339
  function logTraceInfo(derivation, observable) {
2298
2340
  console.log("[mobx.trace] '" + derivation.name_ + "' is invalidated due to a change in: '" + observable.name_ + "'");
2299
2341
  if (derivation.isTracing_ === TraceMode.BREAK) {
@@ -2317,8 +2359,6 @@
2317
2359
  }
2318
2360
 
2319
2361
  var Reaction = /*#__PURE__*/function () {
2320
- // nodes we are looking at. Our value depends on these nodes
2321
-
2322
2362
  function Reaction(name_, onInvalidate_, errorHandler_, requiresObservable_) {
2323
2363
  if (name_ === void 0) {
2324
2364
  name_ = "Reaction@" + getNextId() ;
@@ -2328,6 +2368,7 @@
2328
2368
  this.errorHandler_ = void 0;
2329
2369
  this.requiresObservable_ = void 0;
2330
2370
  this.observing_ = [];
2371
+ // nodes we are looking at. Our value depends on these nodes
2331
2372
  this.newObserving_ = [];
2332
2373
  this.dependenciesState_ = IDerivationState_.NOT_TRACKING_;
2333
2374
  this.diffValue_ = 0;
@@ -2390,7 +2431,6 @@
2390
2431
  return;
2391
2432
  // console.warn("Reaction already disposed") // Note: Not a warning / error in mobx 4 either
2392
2433
  }
2393
-
2394
2434
  startBatch();
2395
2435
  var notify = isSpyEnabled();
2396
2436
  var startTime;
@@ -2465,9 +2505,9 @@
2465
2505
  var _this2 = this;
2466
2506
  var dispose = function dispose() {
2467
2507
  _this2.dispose();
2468
- abortSignal == null ? void 0 : abortSignal.removeEventListener == null ? void 0 : abortSignal.removeEventListener("abort", dispose);
2508
+ abortSignal == null || abortSignal.removeEventListener == null || abortSignal.removeEventListener("abort", dispose);
2469
2509
  };
2470
- abortSignal == null ? void 0 : abortSignal.addEventListener == null ? void 0 : abortSignal.addEventListener("abort", dispose);
2510
+ abortSignal == null || abortSignal.addEventListener == null || abortSignal.addEventListener("abort", dispose);
2471
2511
  dispose[$mobx] = this;
2472
2512
  return dispose;
2473
2513
  };
@@ -2519,7 +2559,6 @@
2519
2559
  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
2560
  allReactions.splice(0); // clear reactions
2521
2561
  }
2522
-
2523
2562
  var remainingReactions = allReactions.splice(0);
2524
2563
  for (var i = 0, l = remainingReactions.length; i < l; i++) {
2525
2564
  remainingReactions[i].runReaction_();
@@ -2647,7 +2686,7 @@
2647
2686
  * @returns disposer function, which can be used to stop the view from being updated in the future.
2648
2687
  */
2649
2688
  function autorun(view, opts) {
2650
- var _opts$name, _opts, _opts2, _opts2$signal, _opts3;
2689
+ var _opts$name, _opts, _opts2, _opts3;
2651
2690
  if (opts === void 0) {
2652
2691
  opts = EMPTY_OBJECT;
2653
2692
  }
@@ -2686,7 +2725,7 @@
2686
2725
  function reactionRunner() {
2687
2726
  view(reaction);
2688
2727
  }
2689
- if (!((_opts2 = opts) != null && (_opts2$signal = _opts2.signal) != null && _opts2$signal.aborted)) {
2728
+ if (!((_opts2 = opts) != null && (_opts2 = _opts2.signal) != null && _opts2.aborted)) {
2690
2729
  reaction.schedule_();
2691
2730
  }
2692
2731
  return reaction.getDisposer_((_opts3 = opts) == null ? void 0 : _opts3.signal);
@@ -2700,7 +2739,7 @@
2700
2739
  } : run;
2701
2740
  }
2702
2741
  function reaction(expression, effect, opts) {
2703
- var _opts$name2, _opts4, _opts4$signal, _opts5;
2742
+ var _opts$name2, _opts4, _opts5;
2704
2743
  if (opts === void 0) {
2705
2744
  opts = EMPTY_OBJECT;
2706
2745
  }
@@ -2749,7 +2788,7 @@
2749
2788
  }
2750
2789
  firstTime = false;
2751
2790
  }
2752
- if (!((_opts4 = opts) != null && (_opts4$signal = _opts4.signal) != null && _opts4$signal.aborted)) {
2791
+ if (!((_opts4 = opts) != null && (_opts4 = _opts4.signal) != null && _opts4.aborted)) {
2753
2792
  r.schedule_();
2754
2793
  }
2755
2794
  return r.getDisposer_((_opts5 = opts) == null ? void 0 : _opts5.signal);
@@ -2958,7 +2997,6 @@
2958
2997
  }
2959
2998
  onFulfilled(undefined); // kick off the process
2960
2999
  });
2961
-
2962
3000
  promise.cancel = action(name + " - runid: " + runId + " - cancel", function () {
2963
3001
  try {
2964
3002
  if (pendingPromise) {
@@ -2976,7 +3014,6 @@
2976
3014
  rejector(e); // there could be a throwing finally block
2977
3015
  }
2978
3016
  });
2979
-
2980
3017
  return promise;
2981
3018
  };
2982
3019
  res.isMobXFlow = true;
@@ -2991,7 +3028,6 @@
2991
3028
  function flowResult(result) {
2992
3029
  return result; // just tricking TypeScript :)
2993
3030
  }
2994
-
2995
3031
  function isFlow(fn) {
2996
3032
  return (fn == null ? void 0 : fn.isMobXFlow) === true;
2997
3033
  }
@@ -3413,10 +3449,10 @@
3413
3449
  disposer();
3414
3450
  reject(new Error("WHEN_ABORTED"));
3415
3451
  };
3416
- opts == null ? void 0 : (_opts$signal2 = opts.signal) == null ? void 0 : _opts$signal2.addEventListener == null ? void 0 : _opts$signal2.addEventListener("abort", abort);
3452
+ opts == null || (_opts$signal2 = opts.signal) == null || _opts$signal2.addEventListener == null || _opts$signal2.addEventListener("abort", abort);
3417
3453
  })["finally"](function () {
3418
3454
  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);
3455
+ return opts == null || (_opts$signal3 = opts.signal) == null || _opts$signal3.removeEventListener == null ? void 0 : _opts$signal3.removeEventListener("abort", abort);
3420
3456
  });
3421
3457
  res.cancel = cancel;
3422
3458
  return res;
@@ -3633,8 +3669,6 @@
3633
3669
  }
3634
3670
  };
3635
3671
  var ObservableArrayAdministration = /*#__PURE__*/function () {
3636
- // this is the prop that gets proxied, so can't replace it!
3637
-
3638
3672
  function ObservableArrayAdministration(name, enhancer, owned_, legacyMode_) {
3639
3673
  if (name === void 0) {
3640
3674
  name = "ObservableArray@" + getNextId() ;
@@ -3643,6 +3677,7 @@
3643
3677
  this.legacyMode_ = void 0;
3644
3678
  this.atom_ = void 0;
3645
3679
  this.values_ = [];
3680
+ // this is the prop that gets proxied, so can't replace it!
3646
3681
  this.interceptors_ = void 0;
3647
3682
  this.changeListeners_ = void 0;
3648
3683
  this.enhancer_ = void 0;
@@ -3763,7 +3798,6 @@
3763
3798
  var lengthDelta = newItems.length - deleteCount;
3764
3799
  this.updateArrayLength_(length, lengthDelta); // checks if internal array wasn't modified
3765
3800
  }
3766
-
3767
3801
  var res = this.spliceItemsIntoValues_(index, deleteCount, newItems);
3768
3802
  if (deleteCount !== 0 || newItems.length !== 0) {
3769
3803
  this.notifyArraySplice_(index, newItems, res);
@@ -3863,6 +3897,7 @@
3863
3897
  var change = interceptChange(this, {
3864
3898
  type: UPDATE,
3865
3899
  object: this.proxy_,
3900
+ // since "this" is the real array we need to pass its proxy
3866
3901
  index: index,
3867
3902
  newValue: newValue
3868
3903
  });
@@ -4078,17 +4113,12 @@
4078
4113
  return isObject(thing) && isObservableArrayAdministration(thing[$mobx]);
4079
4114
  }
4080
4115
 
4081
- var _Symbol$iterator, _Symbol$toStringTag;
4082
4116
  var ObservableMapMarker = {};
4083
4117
  var ADD = "add";
4084
4118
  var DELETE = "delete";
4085
4119
  // just extend Map? See also https://gist.github.com/nestharus/13b4d74f2ef4a2f4357dbd3fc23c1e54
4086
4120
  // But: https://github.com/mobxjs/mobx/issues/1556
4087
- _Symbol$iterator = Symbol.iterator;
4088
- _Symbol$toStringTag = Symbol.toStringTag;
4089
4121
  var ObservableMap = /*#__PURE__*/function () {
4090
- // hasMap, not hashMap >-).
4091
-
4092
4122
  function ObservableMap(initialData, enhancer_, name_) {
4093
4123
  var _this = this;
4094
4124
  if (enhancer_ === void 0) {
@@ -4102,6 +4132,7 @@
4102
4132
  this[$mobx] = ObservableMapMarker;
4103
4133
  this.data_ = void 0;
4104
4134
  this.hasMap_ = void 0;
4135
+ // hasMap, not hashMap >-).
4105
4136
  this.keysAtom_ = void 0;
4106
4137
  this.interceptors_ = void 0;
4107
4138
  this.changeListeners_ = void 0;
@@ -4190,7 +4221,7 @@
4190
4221
  transaction(function () {
4191
4222
  var _this3$hasMap_$get;
4192
4223
  _this3.keysAtom_.reportChanged();
4193
- (_this3$hasMap_$get = _this3.hasMap_.get(key)) == null ? void 0 : _this3$hasMap_$get.setNewValue_(false);
4224
+ (_this3$hasMap_$get = _this3.hasMap_.get(key)) == null || _this3$hasMap_$get.setNewValue_(false);
4194
4225
  var observable = _this3.data_.get(key);
4195
4226
  observable.setNewValue_(undefined);
4196
4227
  _this3.data_["delete"](key);
@@ -4240,7 +4271,7 @@
4240
4271
  var observable = new ObservableValue(newValue, _this4.enhancer_, _this4.name_ + "." + stringifyKey(key) , false);
4241
4272
  _this4.data_.set(key, observable);
4242
4273
  newValue = observable.value_; // value might have been changed
4243
- (_this4$hasMap_$get = _this4.hasMap_.get(key)) == null ? void 0 : _this4$hasMap_$get.setNewValue_(true);
4274
+ (_this4$hasMap_$get = _this4.hasMap_.get(key)) == null || _this4$hasMap_$get.setNewValue_(true);
4244
4275
  _this4.keysAtom_.reportChanged();
4245
4276
  });
4246
4277
  var notifySpy = isSpyEnabled();
@@ -4309,7 +4340,7 @@
4309
4340
  }
4310
4341
  });
4311
4342
  };
4312
- _proto[_Symbol$iterator] = function () {
4343
+ _proto[Symbol.iterator] = function () {
4313
4344
  return this.entries();
4314
4345
  };
4315
4346
  _proto.forEach = function forEach(callback, thisArg) {
@@ -4463,19 +4494,18 @@
4463
4494
  _proto.intercept_ = function intercept_(handler) {
4464
4495
  return registerInterceptor(this, handler);
4465
4496
  };
4466
- _createClass(ObservableMap, [{
4497
+ return _createClass(ObservableMap, [{
4467
4498
  key: "size",
4468
4499
  get: function get() {
4469
4500
  this.keysAtom_.reportObserved();
4470
4501
  return this.data_.size;
4471
4502
  }
4472
4503
  }, {
4473
- key: _Symbol$toStringTag,
4504
+ key: Symbol.toStringTag,
4474
4505
  get: function get() {
4475
4506
  return "Map";
4476
4507
  }
4477
4508
  }]);
4478
- return ObservableMap;
4479
4509
  }();
4480
4510
  // eslint-disable-next-line
4481
4511
  var isObservableMap = /*#__PURE__*/createInstanceofPredicate("ObservableMap", ObservableMap);
@@ -4495,10 +4525,7 @@
4495
4525
  }
4496
4526
  }
4497
4527
 
4498
- var _Symbol$iterator$1, _Symbol$toStringTag$1;
4499
4528
  var ObservableSetMarker = {};
4500
- _Symbol$iterator$1 = Symbol.iterator;
4501
- _Symbol$toStringTag$1 = Symbol.toStringTag;
4502
4529
  var ObservableSet = /*#__PURE__*/function () {
4503
4530
  function ObservableSet(initialData, enhancer, name_) {
4504
4531
  var _this = this;
@@ -4569,7 +4596,6 @@
4569
4596
  // ideally, value = change.value would be done here, so that values can be
4570
4597
  // changed by interceptor. Same applies for other Set and Map api's.
4571
4598
  }
4572
-
4573
4599
  if (!this.has(value)) {
4574
4600
  transaction(function () {
4575
4601
  _this3.data_.add(_this3.enhancer_(value, undefined));
@@ -4675,6 +4701,47 @@
4675
4701
  }
4676
4702
  });
4677
4703
  };
4704
+ _proto.intersection = function intersection(otherSet) {
4705
+ if (isES6Set(otherSet)) {
4706
+ return otherSet.intersection(this);
4707
+ } else {
4708
+ var dehancedSet = new Set(this);
4709
+ return dehancedSet.intersection(otherSet);
4710
+ }
4711
+ };
4712
+ _proto.union = function union(otherSet) {
4713
+ if (isES6Set(otherSet)) {
4714
+ return otherSet.union(this);
4715
+ } else {
4716
+ var dehancedSet = new Set(this);
4717
+ return dehancedSet.union(otherSet);
4718
+ }
4719
+ };
4720
+ _proto.difference = function difference(otherSet) {
4721
+ return new Set(this).difference(otherSet);
4722
+ };
4723
+ _proto.symmetricDifference = function symmetricDifference(otherSet) {
4724
+ if (isES6Set(otherSet)) {
4725
+ return otherSet.symmetricDifference(this);
4726
+ } else {
4727
+ var dehancedSet = new Set(this);
4728
+ return dehancedSet.symmetricDifference(otherSet);
4729
+ }
4730
+ };
4731
+ _proto.isSubsetOf = function isSubsetOf(otherSet) {
4732
+ return new Set(this).isSubsetOf(otherSet);
4733
+ };
4734
+ _proto.isSupersetOf = function isSupersetOf(otherSet) {
4735
+ return new Set(this).isSupersetOf(otherSet);
4736
+ };
4737
+ _proto.isDisjointFrom = function isDisjointFrom(otherSet) {
4738
+ if (isES6Set(otherSet)) {
4739
+ return otherSet.isDisjointFrom(this);
4740
+ } else {
4741
+ var dehancedSet = new Set(this);
4742
+ return dehancedSet.isDisjointFrom(otherSet);
4743
+ }
4744
+ };
4678
4745
  _proto.replace = function replace(other) {
4679
4746
  var _this5 = this;
4680
4747
  if (isObservableSet(other)) {
@@ -4713,22 +4780,21 @@
4713
4780
  _proto.toString = function toString() {
4714
4781
  return "[object ObservableSet]";
4715
4782
  };
4716
- _proto[_Symbol$iterator$1] = function () {
4783
+ _proto[Symbol.iterator] = function () {
4717
4784
  return this.values();
4718
4785
  };
4719
- _createClass(ObservableSet, [{
4786
+ return _createClass(ObservableSet, [{
4720
4787
  key: "size",
4721
4788
  get: function get() {
4722
4789
  this.atom_.reportObserved();
4723
4790
  return this.data_.size;
4724
4791
  }
4725
4792
  }, {
4726
- key: _Symbol$toStringTag$1,
4793
+ key: Symbol.toStringTag,
4727
4794
  get: function get() {
4728
4795
  return "Set";
4729
4796
  }
4730
4797
  }]);
4731
- return ObservableSet;
4732
4798
  }();
4733
4799
  // eslint-disable-next-line
4734
4800
  var isObservableSet = /*#__PURE__*/createInstanceofPredicate("ObservableSet", ObservableSet);
@@ -5128,7 +5194,7 @@
5128
5194
  }
5129
5195
  // Delete
5130
5196
  try {
5131
- var _this$pendingKeys_, _this$pendingKeys_$ge;
5197
+ var _this$pendingKeys_;
5132
5198
  startBatch();
5133
5199
  var notify = hasListeners(this);
5134
5200
  var notifySpy = "development" !== "production" && isSpyEnabled();
@@ -5166,7 +5232,7 @@
5166
5232
  this.keysAtom_.reportChanged();
5167
5233
  // Notify "has" observers
5168
5234
  // "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_);
5235
+ (_this$pendingKeys_ = this.pendingKeys_) == null || (_this$pendingKeys_ = _this$pendingKeys_.get(key)) == null || _this$pendingKeys_.set(key in this.target_);
5170
5236
  // Notify spies/listeners
5171
5237
  if (notify || notifySpy) {
5172
5238
  var _change2 = {
@@ -5207,7 +5273,7 @@
5207
5273
  return registerInterceptor(this, handler);
5208
5274
  };
5209
5275
  _proto.notifyPropertyAddition_ = function notifyPropertyAddition_(key, value) {
5210
- var _this$pendingKeys_2, _this$pendingKeys_2$g;
5276
+ var _this$pendingKeys_2;
5211
5277
  var notify = hasListeners(this);
5212
5278
  var notifySpy = isSpyEnabled();
5213
5279
  if (notify || notifySpy) {
@@ -5229,7 +5295,7 @@
5229
5295
  spyReportEnd();
5230
5296
  }
5231
5297
  }
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);
5298
+ (_this$pendingKeys_2 = this.pendingKeys_) == null || (_this$pendingKeys_2 = _this$pendingKeys_2.get(key)) == null || _this$pendingKeys_2.set(true);
5233
5299
  // Notify "keys/entries/values" observers
5234
5300
  this.keysAtom_.reportChanged();
5235
5301
  };
@@ -5291,7 +5357,7 @@
5291
5357
  adm.appliedAnnotations_[key] = annotation;
5292
5358
  }
5293
5359
  // 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];
5360
+ (_adm$target_$storedAn = adm.target_[storedAnnotationsSymbol]) == null || delete _adm$target_$storedAn[key];
5295
5361
  }
5296
5362
  function assertAnnotable(adm, annotation, key) {
5297
5363
  // Valid annotation
@@ -5371,8 +5437,7 @@
5371
5437
  // Weex proto freeze protection was here,
5372
5438
  // but it is unclear why the hack is need as MobX never changed the prototype
5373
5439
  // anyway, so removed it in V6
5374
- var LegacyObservableArray = /*#__PURE__*/function (_StubArray, _Symbol$toStringTag, _Symbol$iterator) {
5375
- _inheritsLoose(LegacyObservableArray, _StubArray);
5440
+ var LegacyObservableArray = /*#__PURE__*/function (_StubArray) {
5376
5441
  function LegacyObservableArray(initialValues, enhancer, name, owned) {
5377
5442
  var _this;
5378
5443
  if (name === void 0) {
@@ -5384,8 +5449,8 @@
5384
5449
  _this = _StubArray.call(this) || this;
5385
5450
  initObservable(function () {
5386
5451
  var adm = new ObservableArrayAdministration(name, enhancer, owned, true);
5387
- adm.proxy_ = _assertThisInitialized(_this);
5388
- addHiddenFinalProp(_assertThisInitialized(_this), $mobx, adm);
5452
+ adm.proxy_ = _this;
5453
+ addHiddenFinalProp(_this, $mobx, adm);
5389
5454
  if (initialValues && initialValues.length) {
5390
5455
  // @ts-ignore
5391
5456
  _this.spliceWithArray(0, 0, initialValues);
@@ -5393,11 +5458,12 @@
5393
5458
  if (safariPrototypeSetterInheritanceBug) {
5394
5459
  // Seems that Safari won't use numeric prototype setter until any * numeric property is
5395
5460
  // defined on the instance. After that it works fine, even if this property is deleted.
5396
- Object.defineProperty(_assertThisInitialized(_this), "0", ENTRY_0);
5461
+ Object.defineProperty(_this, "0", ENTRY_0);
5397
5462
  }
5398
5463
  });
5399
5464
  return _this;
5400
5465
  }
5466
+ _inheritsLoose(LegacyObservableArray, _StubArray);
5401
5467
  var _proto = LegacyObservableArray.prototype;
5402
5468
  _proto.concat = function concat() {
5403
5469
  this[$mobx].atom_.reportObserved();
@@ -5410,7 +5476,7 @@
5410
5476
  return isObservableArray(a) ? a.slice() : a;
5411
5477
  }));
5412
5478
  };
5413
- _proto[_Symbol$iterator] = function () {
5479
+ _proto[Symbol.iterator] = function () {
5414
5480
  var self = this;
5415
5481
  var nextIndex = 0;
5416
5482
  return makeIterable({
@@ -5425,7 +5491,7 @@
5425
5491
  }
5426
5492
  });
5427
5493
  };
5428
- _createClass(LegacyObservableArray, [{
5494
+ return _createClass(LegacyObservableArray, [{
5429
5495
  key: "length",
5430
5496
  get: function get() {
5431
5497
  return this[$mobx].getArrayLength_();
@@ -5434,13 +5500,12 @@
5434
5500
  this[$mobx].setArrayLength_(newLength);
5435
5501
  }
5436
5502
  }, {
5437
- key: _Symbol$toStringTag,
5503
+ key: Symbol.toStringTag,
5438
5504
  get: function get() {
5439
5505
  return "Array";
5440
5506
  }
5441
5507
  }]);
5442
- return LegacyObservableArray;
5443
- }(StubArray, Symbol.toStringTag, Symbol.iterator);
5508
+ }(StubArray);
5444
5509
  Object.entries(arrayExtensions).forEach(function (_ref) {
5445
5510
  var prop = _ref[0],
5446
5511
  fn = _ref[1];