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.
- package/CHANGELOG.md +11 -5
- package/dist/mobx.cjs.development.js +232 -167
- package/dist/mobx.cjs.development.js.map +1 -1
- package/dist/mobx.cjs.production.min.js +1 -1
- package/dist/mobx.cjs.production.min.js.map +1 -1
- package/dist/mobx.esm.development.js +232 -167
- package/dist/mobx.esm.development.js.map +1 -1
- package/dist/mobx.esm.js +232 -167
- package/dist/mobx.esm.js.map +1 -1
- package/dist/mobx.esm.production.min.js +1 -1
- package/dist/mobx.esm.production.min.js.map +1 -1
- package/dist/mobx.umd.development.js +232 -167
- package/dist/mobx.umd.development.js.map +1 -1
- package/dist/mobx.umd.production.min.js +1 -1
- package/dist/mobx.umd.production.min.js.map +1 -1
- package/dist/types/observableset.d.ts +7 -0
- package/dist/utils/utils.d.ts +2 -2
- package/package.json +1 -1
- package/src/types/observableset.ts +48 -0
package/dist/mobx.esm.js
CHANGED
|
@@ -264,99 +264,76 @@ var getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors || function get
|
|
|
264
264
|
return res;
|
|
265
265
|
};
|
|
266
266
|
|
|
267
|
-
function
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
Object.defineProperty(
|
|
280
|
-
writable:
|
|
281
|
-
});
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
290
|
-
target[key] = source[key];
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
return target;
|
|
295
|
-
};
|
|
296
|
-
return _extends.apply(this, arguments);
|
|
297
|
-
}
|
|
298
|
-
function _inheritsLoose(subClass, superClass) {
|
|
299
|
-
subClass.prototype = Object.create(superClass.prototype);
|
|
300
|
-
subClass.prototype.constructor = subClass;
|
|
301
|
-
_setPrototypeOf(subClass, superClass);
|
|
302
|
-
}
|
|
303
|
-
function _setPrototypeOf(o, p) {
|
|
304
|
-
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
305
|
-
o.__proto__ = p;
|
|
306
|
-
return o;
|
|
307
|
-
};
|
|
308
|
-
return _setPrototypeOf(o, p);
|
|
309
|
-
}
|
|
310
|
-
function _assertThisInitialized(self) {
|
|
311
|
-
if (self === void 0) {
|
|
312
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
313
|
-
}
|
|
314
|
-
return self;
|
|
315
|
-
}
|
|
316
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
317
|
-
if (!o) return;
|
|
318
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
319
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
320
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
321
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
322
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
323
|
-
}
|
|
324
|
-
function _arrayLikeToArray(arr, len) {
|
|
325
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
326
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
327
|
-
return arr2;
|
|
328
|
-
}
|
|
329
|
-
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
330
|
-
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
331
|
-
if (it) return (it = it.call(o)).next.bind(it);
|
|
332
|
-
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
333
|
-
if (it) o = it;
|
|
334
|
-
var i = 0;
|
|
267
|
+
function _arrayLikeToArray(r, a) {
|
|
268
|
+
(null == a || a > r.length) && (a = r.length);
|
|
269
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
270
|
+
return n;
|
|
271
|
+
}
|
|
272
|
+
function _defineProperties(e, r) {
|
|
273
|
+
for (var t = 0; t < r.length; t++) {
|
|
274
|
+
var o = r[t];
|
|
275
|
+
o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
function _createClass(e, r, t) {
|
|
279
|
+
return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
|
|
280
|
+
writable: !1
|
|
281
|
+
}), e;
|
|
282
|
+
}
|
|
283
|
+
function _createForOfIteratorHelperLoose(r, e) {
|
|
284
|
+
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
285
|
+
if (t) return (t = t.call(r)).next.bind(t);
|
|
286
|
+
if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) {
|
|
287
|
+
t && (r = t);
|
|
288
|
+
var o = 0;
|
|
335
289
|
return function () {
|
|
336
|
-
|
|
337
|
-
done:
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
value: o[i++]
|
|
290
|
+
return o >= r.length ? {
|
|
291
|
+
done: !0
|
|
292
|
+
} : {
|
|
293
|
+
done: !1,
|
|
294
|
+
value: r[o++]
|
|
342
295
|
};
|
|
343
296
|
};
|
|
344
297
|
}
|
|
345
298
|
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
299
|
}
|
|
347
|
-
function
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
300
|
+
function _extends() {
|
|
301
|
+
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
302
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
303
|
+
var t = arguments[e];
|
|
304
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
305
|
+
}
|
|
306
|
+
return n;
|
|
307
|
+
}, _extends.apply(null, arguments);
|
|
308
|
+
}
|
|
309
|
+
function _inheritsLoose(t, o) {
|
|
310
|
+
t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o);
|
|
311
|
+
}
|
|
312
|
+
function _setPrototypeOf(t, e) {
|
|
313
|
+
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
|
|
314
|
+
return t.__proto__ = e, t;
|
|
315
|
+
}, _setPrototypeOf(t, e);
|
|
316
|
+
}
|
|
317
|
+
function _toPrimitive(t, r) {
|
|
318
|
+
if ("object" != typeof t || !t) return t;
|
|
319
|
+
var e = t[Symbol.toPrimitive];
|
|
320
|
+
if (void 0 !== e) {
|
|
321
|
+
var i = e.call(t, r || "default");
|
|
322
|
+
if ("object" != typeof i) return i;
|
|
353
323
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
354
324
|
}
|
|
355
|
-
return (
|
|
325
|
+
return ("string" === r ? String : Number)(t);
|
|
356
326
|
}
|
|
357
|
-
function _toPropertyKey(
|
|
358
|
-
var
|
|
359
|
-
return
|
|
327
|
+
function _toPropertyKey(t) {
|
|
328
|
+
var i = _toPrimitive(t, "string");
|
|
329
|
+
return "symbol" == typeof i ? i : i + "";
|
|
330
|
+
}
|
|
331
|
+
function _unsupportedIterableToArray(r, a) {
|
|
332
|
+
if (r) {
|
|
333
|
+
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
334
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
335
|
+
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;
|
|
336
|
+
}
|
|
360
337
|
}
|
|
361
338
|
|
|
362
339
|
var storedAnnotationsSymbol = /*#__PURE__*/Symbol("mobx-stored-annotations");
|
|
@@ -429,8 +406,6 @@ function assert20223DecoratorType(context, types) {
|
|
|
429
406
|
|
|
430
407
|
var $mobx = /*#__PURE__*/Symbol("mobx administration");
|
|
431
408
|
var Atom = /*#__PURE__*/function () {
|
|
432
|
-
// for effective unobserving. BaseAtom has true, for extra optimization, so its onBecomeUnobserved never gets called, because it's not needed
|
|
433
|
-
|
|
434
409
|
/**
|
|
435
410
|
* Create a new atom. For debugging purposes it is recommended to give it a name.
|
|
436
411
|
* The onBecomeObserved and onBecomeUnobserved callbacks can be used for resource management.
|
|
@@ -441,16 +416,18 @@ var Atom = /*#__PURE__*/function () {
|
|
|
441
416
|
}
|
|
442
417
|
this.name_ = void 0;
|
|
443
418
|
this.isPendingUnobservation = false;
|
|
419
|
+
// for effective unobserving. BaseAtom has true, for extra optimization, so its onBecomeUnobserved never gets called, because it's not needed
|
|
444
420
|
this.isBeingObserved = false;
|
|
445
421
|
this.observers_ = new Set();
|
|
446
422
|
this.diffValue_ = 0;
|
|
447
423
|
this.lastAccessedBy_ = 0;
|
|
448
424
|
this.lowestObserverState_ = IDerivationState_.NOT_TRACKING_;
|
|
425
|
+
// onBecomeObservedListeners
|
|
449
426
|
this.onBOL = void 0;
|
|
427
|
+
// onBecomeUnobservedListeners
|
|
450
428
|
this.onBUOL = void 0;
|
|
451
429
|
this.name_ = name_;
|
|
452
430
|
}
|
|
453
|
-
// onBecomeObservedListeners
|
|
454
431
|
var _proto = Atom.prototype;
|
|
455
432
|
_proto.onBO = function onBO() {
|
|
456
433
|
if (this.onBOL) {
|
|
@@ -632,7 +609,6 @@ function make_(adm, key) {
|
|
|
632
609
|
}
|
|
633
610
|
return 0 /* MakeResult.Cancel */;
|
|
634
611
|
}
|
|
635
|
-
|
|
636
612
|
function extend_(adm, key, descriptor, proxyTrap) {
|
|
637
613
|
die("'" + this.annotationType_ + "' can only be used with 'makeObservable'");
|
|
638
614
|
}
|
|
@@ -665,12 +641,10 @@ function make_$1(adm, key, descriptor, source) {
|
|
|
665
641
|
// rest of the proto chain must be annotated already
|
|
666
642
|
return 1 /* MakeResult.Break */;
|
|
667
643
|
}
|
|
668
|
-
|
|
669
644
|
var actionDescriptor = createActionDescriptor(adm, this, key, descriptor, false);
|
|
670
645
|
defineProperty(source, key, actionDescriptor);
|
|
671
646
|
return 2 /* MakeResult.Continue */;
|
|
672
647
|
}
|
|
673
|
-
|
|
674
648
|
function extend_$1(adm, key, descriptor, proxyTrap) {
|
|
675
649
|
var actionDescriptor = createActionDescriptor(adm, this, key, descriptor);
|
|
676
650
|
return adm.defineProperty_(key, actionDescriptor, proxyTrap);
|
|
@@ -768,18 +742,15 @@ function make_$2(adm, key, descriptor, source) {
|
|
|
768
742
|
return 0 /* MakeResult.Cancel */;
|
|
769
743
|
}
|
|
770
744
|
}
|
|
771
|
-
|
|
772
745
|
if (isFlow(descriptor.value)) {
|
|
773
746
|
// A prototype could have been annotated already by other constructor,
|
|
774
747
|
// rest of the proto chain must be annotated already
|
|
775
748
|
return 1 /* MakeResult.Break */;
|
|
776
749
|
}
|
|
777
|
-
|
|
778
750
|
var flowDescriptor = createFlowDescriptor(adm, this, key, descriptor, false, false);
|
|
779
751
|
defineProperty(source, key, flowDescriptor);
|
|
780
752
|
return 2 /* MakeResult.Continue */;
|
|
781
753
|
}
|
|
782
|
-
|
|
783
754
|
function extend_$2(adm, key, descriptor, proxyTrap) {
|
|
784
755
|
var _this$options_2;
|
|
785
756
|
var flowDescriptor = createFlowDescriptor(adm, this, key, descriptor, (_this$options_2 = this.options_) == null ? void 0 : _this$options_2.bound);
|
|
@@ -856,7 +827,6 @@ function createComputedAnnotation(name, options) {
|
|
|
856
827
|
function make_$3(adm, key, descriptor) {
|
|
857
828
|
return this.extend_(adm, key, descriptor, false) === null ? 0 /* MakeResult.Cancel */ : 1 /* MakeResult.Break */;
|
|
858
829
|
}
|
|
859
|
-
|
|
860
830
|
function extend_$3(adm, key, descriptor, proxyTrap) {
|
|
861
831
|
assertComputedDescriptor(adm, this, key, descriptor);
|
|
862
832
|
return adm.defineComputedProperty_(key, _extends({}, this.options_, {
|
|
@@ -904,7 +874,6 @@ function createObservableAnnotation(name, options) {
|
|
|
904
874
|
function make_$4(adm, key, descriptor) {
|
|
905
875
|
return this.extend_(adm, key, descriptor, false) === null ? 0 /* MakeResult.Cancel */ : 1 /* MakeResult.Break */;
|
|
906
876
|
}
|
|
907
|
-
|
|
908
877
|
function extend_$4(adm, key, descriptor, proxyTrap) {
|
|
909
878
|
var _this$options_$enhanc, _this$options_;
|
|
910
879
|
assertObservableDescriptor(adm, this, key, descriptor);
|
|
@@ -1324,11 +1293,8 @@ function allowStateChangesEnd(prev) {
|
|
|
1324
1293
|
globalState.allowStateChanges = prev;
|
|
1325
1294
|
}
|
|
1326
1295
|
|
|
1327
|
-
var _Symbol$toPrimitive;
|
|
1328
1296
|
var CREATE = "create";
|
|
1329
|
-
_Symbol$toPrimitive = Symbol.toPrimitive;
|
|
1330
1297
|
var ObservableValue = /*#__PURE__*/function (_Atom) {
|
|
1331
|
-
_inheritsLoose(ObservableValue, _Atom);
|
|
1332
1298
|
function ObservableValue(value, enhancer, name_, notifySpy, equals) {
|
|
1333
1299
|
var _this;
|
|
1334
1300
|
if (name_ === void 0) {
|
|
@@ -1357,7 +1323,7 @@ var ObservableValue = /*#__PURE__*/function (_Atom) {
|
|
|
1357
1323
|
// only notify spy if this is a stand-alone observable
|
|
1358
1324
|
spyReport({
|
|
1359
1325
|
type: CREATE,
|
|
1360
|
-
object:
|
|
1326
|
+
object: _this,
|
|
1361
1327
|
observableKind: "value",
|
|
1362
1328
|
debugObjectName: _this.name_,
|
|
1363
1329
|
newValue: "" + _this.value_
|
|
@@ -1365,6 +1331,7 @@ var ObservableValue = /*#__PURE__*/function (_Atom) {
|
|
|
1365
1331
|
}
|
|
1366
1332
|
return _this;
|
|
1367
1333
|
}
|
|
1334
|
+
_inheritsLoose(ObservableValue, _Atom);
|
|
1368
1335
|
var _proto = ObservableValue.prototype;
|
|
1369
1336
|
_proto.dehanceValue = function dehanceValue(value) {
|
|
1370
1337
|
if (this.dehancer !== undefined) {
|
|
@@ -1456,14 +1423,13 @@ var ObservableValue = /*#__PURE__*/function (_Atom) {
|
|
|
1456
1423
|
_proto.valueOf = function valueOf() {
|
|
1457
1424
|
return toPrimitive(this.get());
|
|
1458
1425
|
};
|
|
1459
|
-
_proto[
|
|
1426
|
+
_proto[Symbol.toPrimitive] = function () {
|
|
1460
1427
|
return this.valueOf();
|
|
1461
1428
|
};
|
|
1462
1429
|
return ObservableValue;
|
|
1463
1430
|
}(Atom);
|
|
1464
1431
|
var isObservableValue = /*#__PURE__*/createInstanceofPredicate("ObservableValue", ObservableValue);
|
|
1465
1432
|
|
|
1466
|
-
var _Symbol$toPrimitive$1;
|
|
1467
1433
|
function getFlag(flags, mask) {
|
|
1468
1434
|
return !!(flags & mask);
|
|
1469
1435
|
}
|
|
@@ -1494,13 +1460,7 @@ function setFlag(flags, mask, newValue) {
|
|
|
1494
1460
|
*
|
|
1495
1461
|
* If at any point it's outside batch and it isn't observed: reset everything and go to 1.
|
|
1496
1462
|
*/
|
|
1497
|
-
_Symbol$toPrimitive$1 = Symbol.toPrimitive;
|
|
1498
1463
|
var ComputedValue = /*#__PURE__*/function () {
|
|
1499
|
-
// nodes we are looking at. Our value depends on these nodes
|
|
1500
|
-
// during tracking it's an array with new observed observers
|
|
1501
|
-
|
|
1502
|
-
// N.B: unminified as it is used by MST
|
|
1503
|
-
|
|
1504
1464
|
/**
|
|
1505
1465
|
* Create a new computed value based on a function expression.
|
|
1506
1466
|
*
|
|
@@ -1516,7 +1476,9 @@ var ComputedValue = /*#__PURE__*/function () {
|
|
|
1516
1476
|
function ComputedValue(options) {
|
|
1517
1477
|
this.dependenciesState_ = IDerivationState_.NOT_TRACKING_;
|
|
1518
1478
|
this.observing_ = [];
|
|
1479
|
+
// nodes we are looking at. Our value depends on these nodes
|
|
1519
1480
|
this.newObserving_ = null;
|
|
1481
|
+
// during tracking it's an array with new observed observers
|
|
1520
1482
|
this.observers_ = new Set();
|
|
1521
1483
|
this.diffValue_ = 0;
|
|
1522
1484
|
this.runId_ = 0;
|
|
@@ -1528,6 +1490,7 @@ var ComputedValue = /*#__PURE__*/function () {
|
|
|
1528
1490
|
this.triggeredBy_ = void 0;
|
|
1529
1491
|
this.flags_ = 0;
|
|
1530
1492
|
this.derivation = void 0;
|
|
1493
|
+
// N.B: unminified as it is used by MST
|
|
1531
1494
|
this.setter_ = void 0;
|
|
1532
1495
|
this.isTracing_ = TraceMode.NONE;
|
|
1533
1496
|
this.scope_ = void 0;
|
|
@@ -1712,10 +1675,10 @@ var ComputedValue = /*#__PURE__*/function () {
|
|
|
1712
1675
|
_proto.valueOf = function valueOf() {
|
|
1713
1676
|
return toPrimitive(this.get());
|
|
1714
1677
|
};
|
|
1715
|
-
_proto[
|
|
1678
|
+
_proto[Symbol.toPrimitive] = function () {
|
|
1716
1679
|
return this.valueOf();
|
|
1717
1680
|
};
|
|
1718
|
-
_createClass(ComputedValue, [{
|
|
1681
|
+
return _createClass(ComputedValue, [{
|
|
1719
1682
|
key: "isComputing",
|
|
1720
1683
|
get: function get() {
|
|
1721
1684
|
return getFlag(this.flags_, ComputedValue.isComputingMask_);
|
|
@@ -1748,7 +1711,6 @@ var ComputedValue = /*#__PURE__*/function () {
|
|
|
1748
1711
|
this.flags_ = setFlag(this.flags_, ComputedValue.isPendingUnobservationMask_, newValue);
|
|
1749
1712
|
}
|
|
1750
1713
|
}]);
|
|
1751
|
-
return ComputedValue;
|
|
1752
1714
|
}();
|
|
1753
1715
|
ComputedValue.isComputingMask_ = 1;
|
|
1754
1716
|
ComputedValue.isRunningSetterMask_ = 2;
|
|
@@ -1787,7 +1749,6 @@ var CaughtException = function CaughtException(cause) {
|
|
|
1787
1749
|
this.cause = cause;
|
|
1788
1750
|
// Empty
|
|
1789
1751
|
};
|
|
1790
|
-
|
|
1791
1752
|
function isCaughtException(e) {
|
|
1792
1753
|
return e instanceof CaughtException;
|
|
1793
1754
|
}
|
|
@@ -1851,7 +1812,6 @@ function shouldCompute(derivation) {
|
|
|
1851
1812
|
function isComputingDerivation() {
|
|
1852
1813
|
return globalState.trackingDerivation !== null; // filter out actions inside computations
|
|
1853
1814
|
}
|
|
1854
|
-
|
|
1855
1815
|
function checkIfStateModificationsAreAllowed(atom) {
|
|
1856
1816
|
if (!(process.env.NODE_ENV !== "production")) {
|
|
1857
1817
|
return;
|
|
@@ -2028,28 +1988,113 @@ function changeDependenciesStateTo0(derivation) {
|
|
|
2028
1988
|
*/
|
|
2029
1989
|
var persistentKeys = ["mobxGuid", "spyListeners", "enforceActions", "computedRequiresReaction", "reactionRequiresObservable", "observableRequiresReaction", "allowStateReads", "disableErrorBoundaries", "runId", "UNCHANGED", "useProxies"];
|
|
2030
1990
|
var MobXGlobals = function MobXGlobals() {
|
|
1991
|
+
/**
|
|
1992
|
+
* MobXGlobals version.
|
|
1993
|
+
* MobX compatiblity with other versions loaded in memory as long as this version matches.
|
|
1994
|
+
* It indicates that the global state still stores similar information
|
|
1995
|
+
*
|
|
1996
|
+
* N.B: this version is unrelated to the package version of MobX, and is only the version of the
|
|
1997
|
+
* internal state storage of MobX, and can be the same across many different package versions
|
|
1998
|
+
*/
|
|
2031
1999
|
this.version = 6;
|
|
2000
|
+
/**
|
|
2001
|
+
* globally unique token to signal unchanged
|
|
2002
|
+
*/
|
|
2032
2003
|
this.UNCHANGED = {};
|
|
2004
|
+
/**
|
|
2005
|
+
* Currently running derivation
|
|
2006
|
+
*/
|
|
2033
2007
|
this.trackingDerivation = null;
|
|
2008
|
+
/**
|
|
2009
|
+
* Currently running reaction. This determines if we currently have a reactive context.
|
|
2010
|
+
* (Tracking derivation is also set for temporal tracking of computed values inside actions,
|
|
2011
|
+
* but trackingReaction can only be set by a form of Reaction)
|
|
2012
|
+
*/
|
|
2034
2013
|
this.trackingContext = null;
|
|
2014
|
+
/**
|
|
2015
|
+
* Each time a derivation is tracked, it is assigned a unique run-id
|
|
2016
|
+
*/
|
|
2035
2017
|
this.runId = 0;
|
|
2018
|
+
/**
|
|
2019
|
+
* 'guid' for general purpose. Will be persisted amongst resets.
|
|
2020
|
+
*/
|
|
2036
2021
|
this.mobxGuid = 0;
|
|
2022
|
+
/**
|
|
2023
|
+
* Are we in a batch block? (and how many of them)
|
|
2024
|
+
*/
|
|
2037
2025
|
this.inBatch = 0;
|
|
2026
|
+
/**
|
|
2027
|
+
* Observables that don't have observers anymore, and are about to be
|
|
2028
|
+
* suspended, unless somebody else accesses it in the same batch
|
|
2029
|
+
*
|
|
2030
|
+
* @type {IObservable[]}
|
|
2031
|
+
*/
|
|
2038
2032
|
this.pendingUnobservations = [];
|
|
2033
|
+
/**
|
|
2034
|
+
* List of scheduled, not yet executed, reactions.
|
|
2035
|
+
*/
|
|
2039
2036
|
this.pendingReactions = [];
|
|
2037
|
+
/**
|
|
2038
|
+
* Are we currently processing reactions?
|
|
2039
|
+
*/
|
|
2040
2040
|
this.isRunningReactions = false;
|
|
2041
|
+
/**
|
|
2042
|
+
* Is it allowed to change observables at this point?
|
|
2043
|
+
* In general, MobX doesn't allow that when running computations and React.render.
|
|
2044
|
+
* To ensure that those functions stay pure.
|
|
2045
|
+
*/
|
|
2041
2046
|
this.allowStateChanges = false;
|
|
2047
|
+
/**
|
|
2048
|
+
* Is it allowed to read observables at this point?
|
|
2049
|
+
* Used to hold the state needed for `observableRequiresReaction`
|
|
2050
|
+
*/
|
|
2042
2051
|
this.allowStateReads = true;
|
|
2052
|
+
/**
|
|
2053
|
+
* If strict mode is enabled, state changes are by default not allowed
|
|
2054
|
+
*/
|
|
2043
2055
|
this.enforceActions = true;
|
|
2056
|
+
/**
|
|
2057
|
+
* Spy callbacks
|
|
2058
|
+
*/
|
|
2044
2059
|
this.spyListeners = [];
|
|
2060
|
+
/**
|
|
2061
|
+
* Globally attached error handlers that react specifically to errors in reactions
|
|
2062
|
+
*/
|
|
2045
2063
|
this.globalReactionErrorHandlers = [];
|
|
2064
|
+
/**
|
|
2065
|
+
* Warn if computed values are accessed outside a reactive context
|
|
2066
|
+
*/
|
|
2046
2067
|
this.computedRequiresReaction = false;
|
|
2068
|
+
/**
|
|
2069
|
+
* (Experimental)
|
|
2070
|
+
* Warn if you try to create to derivation / reactive context without accessing any observable.
|
|
2071
|
+
*/
|
|
2047
2072
|
this.reactionRequiresObservable = false;
|
|
2073
|
+
/**
|
|
2074
|
+
* (Experimental)
|
|
2075
|
+
* Warn if observables are accessed outside a reactive context
|
|
2076
|
+
*/
|
|
2048
2077
|
this.observableRequiresReaction = false;
|
|
2078
|
+
/*
|
|
2079
|
+
* Don't catch and rethrow exceptions. This is useful for inspecting the state of
|
|
2080
|
+
* the stack when an exception occurs while debugging.
|
|
2081
|
+
*/
|
|
2049
2082
|
this.disableErrorBoundaries = false;
|
|
2083
|
+
/*
|
|
2084
|
+
* If true, we are already handling an exception in an action. Any errors in reactions should be suppressed, as
|
|
2085
|
+
* they are not the cause, see: https://github.com/mobxjs/mobx/issues/1836
|
|
2086
|
+
*/
|
|
2050
2087
|
this.suppressReactionErrors = false;
|
|
2051
2088
|
this.useProxies = true;
|
|
2089
|
+
/*
|
|
2090
|
+
* print warnings about code that would fail if proxies weren't available
|
|
2091
|
+
*/
|
|
2052
2092
|
this.verifyProxies = false;
|
|
2093
|
+
/**
|
|
2094
|
+
* False forces all object's descriptors to
|
|
2095
|
+
* writable: true
|
|
2096
|
+
* configurable: true
|
|
2097
|
+
*/
|
|
2053
2098
|
this.safeDescriptors = true;
|
|
2054
2099
|
};
|
|
2055
2100
|
var canMergeGlobalState = true;
|
|
@@ -2146,7 +2191,6 @@ function addObserver(observable, node) {
|
|
|
2146
2191
|
// invariantObservers(observable);
|
|
2147
2192
|
// invariant(observable._observers.indexOf(node) !== -1, "INTERNAL ERROR didn't add node");
|
|
2148
2193
|
}
|
|
2149
|
-
|
|
2150
2194
|
function removeObserver(observable, node) {
|
|
2151
2195
|
// invariant(globalState.inBatch > 0, "INTERNAL ERROR, remove should be called only inside batch");
|
|
2152
2196
|
// invariant(observable._observers.indexOf(node) !== -1, "INTERNAL ERROR remove already removed node");
|
|
@@ -2159,7 +2203,6 @@ function removeObserver(observable, node) {
|
|
|
2159
2203
|
// invariantObservers(observable);
|
|
2160
2204
|
// invariant(observable._observers.indexOf(node) === -1, "INTERNAL ERROR remove already removed node2");
|
|
2161
2205
|
}
|
|
2162
|
-
|
|
2163
2206
|
function queueForUnobservation(observable) {
|
|
2164
2207
|
if (observable.isPendingUnobservation === false) {
|
|
2165
2208
|
// invariant(observable._observers.length === 0, "INTERNAL ERROR, should only queue for unobservation unobserved observables");
|
|
@@ -2297,7 +2340,6 @@ function propagateMaybeChanged(observable) {
|
|
|
2297
2340
|
});
|
|
2298
2341
|
// invariantLOS(observable, "maybe end");
|
|
2299
2342
|
}
|
|
2300
|
-
|
|
2301
2343
|
function logTraceInfo(derivation, observable) {
|
|
2302
2344
|
console.log("[mobx.trace] '" + derivation.name_ + "' is invalidated due to a change in: '" + observable.name_ + "'");
|
|
2303
2345
|
if (derivation.isTracing_ === TraceMode.BREAK) {
|
|
@@ -2321,8 +2363,6 @@ function printDepTree(tree, lines, depth) {
|
|
|
2321
2363
|
}
|
|
2322
2364
|
|
|
2323
2365
|
var Reaction = /*#__PURE__*/function () {
|
|
2324
|
-
// nodes we are looking at. Our value depends on these nodes
|
|
2325
|
-
|
|
2326
2366
|
function Reaction(name_, onInvalidate_, errorHandler_, requiresObservable_) {
|
|
2327
2367
|
if (name_ === void 0) {
|
|
2328
2368
|
name_ = process.env.NODE_ENV !== "production" ? "Reaction@" + getNextId() : "Reaction";
|
|
@@ -2332,6 +2372,7 @@ var Reaction = /*#__PURE__*/function () {
|
|
|
2332
2372
|
this.errorHandler_ = void 0;
|
|
2333
2373
|
this.requiresObservable_ = void 0;
|
|
2334
2374
|
this.observing_ = [];
|
|
2375
|
+
// nodes we are looking at. Our value depends on these nodes
|
|
2335
2376
|
this.newObserving_ = [];
|
|
2336
2377
|
this.dependenciesState_ = IDerivationState_.NOT_TRACKING_;
|
|
2337
2378
|
this.diffValue_ = 0;
|
|
@@ -2394,7 +2435,6 @@ var Reaction = /*#__PURE__*/function () {
|
|
|
2394
2435
|
return;
|
|
2395
2436
|
// console.warn("Reaction already disposed") // Note: Not a warning / error in mobx 4 either
|
|
2396
2437
|
}
|
|
2397
|
-
|
|
2398
2438
|
startBatch();
|
|
2399
2439
|
var notify = isSpyEnabled();
|
|
2400
2440
|
var startTime;
|
|
@@ -2469,9 +2509,9 @@ var Reaction = /*#__PURE__*/function () {
|
|
|
2469
2509
|
var _this2 = this;
|
|
2470
2510
|
var dispose = function dispose() {
|
|
2471
2511
|
_this2.dispose();
|
|
2472
|
-
abortSignal == null
|
|
2512
|
+
abortSignal == null || abortSignal.removeEventListener == null || abortSignal.removeEventListener("abort", dispose);
|
|
2473
2513
|
};
|
|
2474
|
-
abortSignal == null
|
|
2514
|
+
abortSignal == null || abortSignal.addEventListener == null || abortSignal.addEventListener("abort", dispose);
|
|
2475
2515
|
dispose[$mobx] = this;
|
|
2476
2516
|
return dispose;
|
|
2477
2517
|
};
|
|
@@ -2523,7 +2563,6 @@ function runReactionsHelper() {
|
|
|
2523
2563
|
console.error(process.env.NODE_ENV !== "production" ? "Reaction doesn't converge to a stable state after " + MAX_REACTION_ITERATIONS + " iterations." + (" Probably there is a cycle in the reactive function: " + allReactions[0]) : "[mobx] cycle in reaction: " + allReactions[0]);
|
|
2524
2564
|
allReactions.splice(0); // clear reactions
|
|
2525
2565
|
}
|
|
2526
|
-
|
|
2527
2566
|
var remainingReactions = allReactions.splice(0);
|
|
2528
2567
|
for (var i = 0, l = remainingReactions.length; i < l; i++) {
|
|
2529
2568
|
remainingReactions[i].runReaction_();
|
|
@@ -2663,7 +2702,7 @@ function isAction(thing) {
|
|
|
2663
2702
|
* @returns disposer function, which can be used to stop the view from being updated in the future.
|
|
2664
2703
|
*/
|
|
2665
2704
|
function autorun(view, opts) {
|
|
2666
|
-
var _opts$name, _opts, _opts2,
|
|
2705
|
+
var _opts$name, _opts, _opts2, _opts3;
|
|
2667
2706
|
if (opts === void 0) {
|
|
2668
2707
|
opts = EMPTY_OBJECT;
|
|
2669
2708
|
}
|
|
@@ -2702,7 +2741,7 @@ function autorun(view, opts) {
|
|
|
2702
2741
|
function reactionRunner() {
|
|
2703
2742
|
view(reaction);
|
|
2704
2743
|
}
|
|
2705
|
-
if (!((_opts2 = opts) != null && (_opts2
|
|
2744
|
+
if (!((_opts2 = opts) != null && (_opts2 = _opts2.signal) != null && _opts2.aborted)) {
|
|
2706
2745
|
reaction.schedule_();
|
|
2707
2746
|
}
|
|
2708
2747
|
return reaction.getDisposer_((_opts3 = opts) == null ? void 0 : _opts3.signal);
|
|
@@ -2716,7 +2755,7 @@ function createSchedulerFromOptions(opts) {
|
|
|
2716
2755
|
} : run;
|
|
2717
2756
|
}
|
|
2718
2757
|
function reaction(expression, effect, opts) {
|
|
2719
|
-
var _opts$name2, _opts4,
|
|
2758
|
+
var _opts$name2, _opts4, _opts5;
|
|
2720
2759
|
if (opts === void 0) {
|
|
2721
2760
|
opts = EMPTY_OBJECT;
|
|
2722
2761
|
}
|
|
@@ -2765,7 +2804,7 @@ function reaction(expression, effect, opts) {
|
|
|
2765
2804
|
}
|
|
2766
2805
|
firstTime = false;
|
|
2767
2806
|
}
|
|
2768
|
-
if (!((_opts4 = opts) != null && (_opts4
|
|
2807
|
+
if (!((_opts4 = opts) != null && (_opts4 = _opts4.signal) != null && _opts4.aborted)) {
|
|
2769
2808
|
r.schedule_();
|
|
2770
2809
|
}
|
|
2771
2810
|
return r.getDisposer_((_opts5 = opts) == null ? void 0 : _opts5.signal);
|
|
@@ -2974,7 +3013,6 @@ var flow = /*#__PURE__*/Object.assign(function flow(arg1, arg2) {
|
|
|
2974
3013
|
}
|
|
2975
3014
|
onFulfilled(undefined); // kick off the process
|
|
2976
3015
|
});
|
|
2977
|
-
|
|
2978
3016
|
promise.cancel = action(name + " - runid: " + runId + " - cancel", function () {
|
|
2979
3017
|
try {
|
|
2980
3018
|
if (pendingPromise) {
|
|
@@ -2992,7 +3030,6 @@ var flow = /*#__PURE__*/Object.assign(function flow(arg1, arg2) {
|
|
|
2992
3030
|
rejector(e); // there could be a throwing finally block
|
|
2993
3031
|
}
|
|
2994
3032
|
});
|
|
2995
|
-
|
|
2996
3033
|
return promise;
|
|
2997
3034
|
};
|
|
2998
3035
|
res.isMobXFlow = true;
|
|
@@ -3007,7 +3044,6 @@ function cancelPromise(promise) {
|
|
|
3007
3044
|
function flowResult(result) {
|
|
3008
3045
|
return result; // just tricking TypeScript :)
|
|
3009
3046
|
}
|
|
3010
|
-
|
|
3011
3047
|
function isFlow(fn) {
|
|
3012
3048
|
return (fn == null ? void 0 : fn.isMobXFlow) === true;
|
|
3013
3049
|
}
|
|
@@ -3432,10 +3468,10 @@ function whenPromise(predicate, opts) {
|
|
|
3432
3468
|
disposer();
|
|
3433
3469
|
reject(new Error("WHEN_ABORTED"));
|
|
3434
3470
|
};
|
|
3435
|
-
opts == null
|
|
3471
|
+
opts == null || (_opts$signal2 = opts.signal) == null || _opts$signal2.addEventListener == null || _opts$signal2.addEventListener("abort", abort);
|
|
3436
3472
|
})["finally"](function () {
|
|
3437
3473
|
var _opts$signal3;
|
|
3438
|
-
return opts == null
|
|
3474
|
+
return opts == null || (_opts$signal3 = opts.signal) == null || _opts$signal3.removeEventListener == null ? void 0 : _opts$signal3.removeEventListener("abort", abort);
|
|
3439
3475
|
});
|
|
3440
3476
|
res.cancel = cancel;
|
|
3441
3477
|
return res;
|
|
@@ -3652,8 +3688,6 @@ var arrayTraps = {
|
|
|
3652
3688
|
}
|
|
3653
3689
|
};
|
|
3654
3690
|
var ObservableArrayAdministration = /*#__PURE__*/function () {
|
|
3655
|
-
// this is the prop that gets proxied, so can't replace it!
|
|
3656
|
-
|
|
3657
3691
|
function ObservableArrayAdministration(name, enhancer, owned_, legacyMode_) {
|
|
3658
3692
|
if (name === void 0) {
|
|
3659
3693
|
name = process.env.NODE_ENV !== "production" ? "ObservableArray@" + getNextId() : "ObservableArray";
|
|
@@ -3662,6 +3696,7 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
|
|
|
3662
3696
|
this.legacyMode_ = void 0;
|
|
3663
3697
|
this.atom_ = void 0;
|
|
3664
3698
|
this.values_ = [];
|
|
3699
|
+
// this is the prop that gets proxied, so can't replace it!
|
|
3665
3700
|
this.interceptors_ = void 0;
|
|
3666
3701
|
this.changeListeners_ = void 0;
|
|
3667
3702
|
this.enhancer_ = void 0;
|
|
@@ -3782,7 +3817,6 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
|
|
|
3782
3817
|
var lengthDelta = newItems.length - deleteCount;
|
|
3783
3818
|
this.updateArrayLength_(length, lengthDelta); // checks if internal array wasn't modified
|
|
3784
3819
|
}
|
|
3785
|
-
|
|
3786
3820
|
var res = this.spliceItemsIntoValues_(index, deleteCount, newItems);
|
|
3787
3821
|
if (deleteCount !== 0 || newItems.length !== 0) {
|
|
3788
3822
|
this.notifyArraySplice_(index, newItems, res);
|
|
@@ -3882,6 +3916,7 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
|
|
|
3882
3916
|
var change = interceptChange(this, {
|
|
3883
3917
|
type: UPDATE,
|
|
3884
3918
|
object: this.proxy_,
|
|
3919
|
+
// since "this" is the real array we need to pass its proxy
|
|
3885
3920
|
index: index,
|
|
3886
3921
|
newValue: newValue
|
|
3887
3922
|
});
|
|
@@ -4097,17 +4132,12 @@ function isObservableArray(thing) {
|
|
|
4097
4132
|
return isObject(thing) && isObservableArrayAdministration(thing[$mobx]);
|
|
4098
4133
|
}
|
|
4099
4134
|
|
|
4100
|
-
var _Symbol$iterator, _Symbol$toStringTag;
|
|
4101
4135
|
var ObservableMapMarker = {};
|
|
4102
4136
|
var ADD = "add";
|
|
4103
4137
|
var DELETE = "delete";
|
|
4104
4138
|
// just extend Map? See also https://gist.github.com/nestharus/13b4d74f2ef4a2f4357dbd3fc23c1e54
|
|
4105
4139
|
// But: https://github.com/mobxjs/mobx/issues/1556
|
|
4106
|
-
_Symbol$iterator = Symbol.iterator;
|
|
4107
|
-
_Symbol$toStringTag = Symbol.toStringTag;
|
|
4108
4140
|
var ObservableMap = /*#__PURE__*/function () {
|
|
4109
|
-
// hasMap, not hashMap >-).
|
|
4110
|
-
|
|
4111
4141
|
function ObservableMap(initialData, enhancer_, name_) {
|
|
4112
4142
|
var _this = this;
|
|
4113
4143
|
if (enhancer_ === void 0) {
|
|
@@ -4121,6 +4151,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4121
4151
|
this[$mobx] = ObservableMapMarker;
|
|
4122
4152
|
this.data_ = void 0;
|
|
4123
4153
|
this.hasMap_ = void 0;
|
|
4154
|
+
// hasMap, not hashMap >-).
|
|
4124
4155
|
this.keysAtom_ = void 0;
|
|
4125
4156
|
this.interceptors_ = void 0;
|
|
4126
4157
|
this.changeListeners_ = void 0;
|
|
@@ -4209,7 +4240,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4209
4240
|
transaction(function () {
|
|
4210
4241
|
var _this3$hasMap_$get;
|
|
4211
4242
|
_this3.keysAtom_.reportChanged();
|
|
4212
|
-
(_this3$hasMap_$get = _this3.hasMap_.get(key)) == null
|
|
4243
|
+
(_this3$hasMap_$get = _this3.hasMap_.get(key)) == null || _this3$hasMap_$get.setNewValue_(false);
|
|
4213
4244
|
var observable = _this3.data_.get(key);
|
|
4214
4245
|
observable.setNewValue_(undefined);
|
|
4215
4246
|
_this3.data_["delete"](key);
|
|
@@ -4259,7 +4290,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4259
4290
|
var observable = new ObservableValue(newValue, _this4.enhancer_, process.env.NODE_ENV !== "production" ? _this4.name_ + "." + stringifyKey(key) : "ObservableMap.key", false);
|
|
4260
4291
|
_this4.data_.set(key, observable);
|
|
4261
4292
|
newValue = observable.value_; // value might have been changed
|
|
4262
|
-
(_this4$hasMap_$get = _this4.hasMap_.get(key)) == null
|
|
4293
|
+
(_this4$hasMap_$get = _this4.hasMap_.get(key)) == null || _this4$hasMap_$get.setNewValue_(true);
|
|
4263
4294
|
_this4.keysAtom_.reportChanged();
|
|
4264
4295
|
});
|
|
4265
4296
|
var notifySpy = isSpyEnabled();
|
|
@@ -4328,7 +4359,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4328
4359
|
}
|
|
4329
4360
|
});
|
|
4330
4361
|
};
|
|
4331
|
-
_proto[
|
|
4362
|
+
_proto[Symbol.iterator] = function () {
|
|
4332
4363
|
return this.entries();
|
|
4333
4364
|
};
|
|
4334
4365
|
_proto.forEach = function forEach(callback, thisArg) {
|
|
@@ -4482,19 +4513,18 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4482
4513
|
_proto.intercept_ = function intercept_(handler) {
|
|
4483
4514
|
return registerInterceptor(this, handler);
|
|
4484
4515
|
};
|
|
4485
|
-
_createClass(ObservableMap, [{
|
|
4516
|
+
return _createClass(ObservableMap, [{
|
|
4486
4517
|
key: "size",
|
|
4487
4518
|
get: function get() {
|
|
4488
4519
|
this.keysAtom_.reportObserved();
|
|
4489
4520
|
return this.data_.size;
|
|
4490
4521
|
}
|
|
4491
4522
|
}, {
|
|
4492
|
-
key:
|
|
4523
|
+
key: Symbol.toStringTag,
|
|
4493
4524
|
get: function get() {
|
|
4494
4525
|
return "Map";
|
|
4495
4526
|
}
|
|
4496
4527
|
}]);
|
|
4497
|
-
return ObservableMap;
|
|
4498
4528
|
}();
|
|
4499
4529
|
// eslint-disable-next-line
|
|
4500
4530
|
var isObservableMap = /*#__PURE__*/createInstanceofPredicate("ObservableMap", ObservableMap);
|
|
@@ -4514,10 +4544,7 @@ function convertToMap(dataStructure) {
|
|
|
4514
4544
|
}
|
|
4515
4545
|
}
|
|
4516
4546
|
|
|
4517
|
-
var _Symbol$iterator$1, _Symbol$toStringTag$1;
|
|
4518
4547
|
var ObservableSetMarker = {};
|
|
4519
|
-
_Symbol$iterator$1 = Symbol.iterator;
|
|
4520
|
-
_Symbol$toStringTag$1 = Symbol.toStringTag;
|
|
4521
4548
|
var ObservableSet = /*#__PURE__*/function () {
|
|
4522
4549
|
function ObservableSet(initialData, enhancer, name_) {
|
|
4523
4550
|
var _this = this;
|
|
@@ -4588,7 +4615,6 @@ var ObservableSet = /*#__PURE__*/function () {
|
|
|
4588
4615
|
// ideally, value = change.value would be done here, so that values can be
|
|
4589
4616
|
// changed by interceptor. Same applies for other Set and Map api's.
|
|
4590
4617
|
}
|
|
4591
|
-
|
|
4592
4618
|
if (!this.has(value)) {
|
|
4593
4619
|
transaction(function () {
|
|
4594
4620
|
_this3.data_.add(_this3.enhancer_(value, undefined));
|
|
@@ -4694,6 +4720,47 @@ var ObservableSet = /*#__PURE__*/function () {
|
|
|
4694
4720
|
}
|
|
4695
4721
|
});
|
|
4696
4722
|
};
|
|
4723
|
+
_proto.intersection = function intersection(otherSet) {
|
|
4724
|
+
if (isES6Set(otherSet)) {
|
|
4725
|
+
return otherSet.intersection(this);
|
|
4726
|
+
} else {
|
|
4727
|
+
var dehancedSet = new Set(this);
|
|
4728
|
+
return dehancedSet.intersection(otherSet);
|
|
4729
|
+
}
|
|
4730
|
+
};
|
|
4731
|
+
_proto.union = function union(otherSet) {
|
|
4732
|
+
if (isES6Set(otherSet)) {
|
|
4733
|
+
return otherSet.union(this);
|
|
4734
|
+
} else {
|
|
4735
|
+
var dehancedSet = new Set(this);
|
|
4736
|
+
return dehancedSet.union(otherSet);
|
|
4737
|
+
}
|
|
4738
|
+
};
|
|
4739
|
+
_proto.difference = function difference(otherSet) {
|
|
4740
|
+
return new Set(this).difference(otherSet);
|
|
4741
|
+
};
|
|
4742
|
+
_proto.symmetricDifference = function symmetricDifference(otherSet) {
|
|
4743
|
+
if (isES6Set(otherSet)) {
|
|
4744
|
+
return otherSet.symmetricDifference(this);
|
|
4745
|
+
} else {
|
|
4746
|
+
var dehancedSet = new Set(this);
|
|
4747
|
+
return dehancedSet.symmetricDifference(otherSet);
|
|
4748
|
+
}
|
|
4749
|
+
};
|
|
4750
|
+
_proto.isSubsetOf = function isSubsetOf(otherSet) {
|
|
4751
|
+
return new Set(this).isSubsetOf(otherSet);
|
|
4752
|
+
};
|
|
4753
|
+
_proto.isSupersetOf = function isSupersetOf(otherSet) {
|
|
4754
|
+
return new Set(this).isSupersetOf(otherSet);
|
|
4755
|
+
};
|
|
4756
|
+
_proto.isDisjointFrom = function isDisjointFrom(otherSet) {
|
|
4757
|
+
if (isES6Set(otherSet)) {
|
|
4758
|
+
return otherSet.isDisjointFrom(this);
|
|
4759
|
+
} else {
|
|
4760
|
+
var dehancedSet = new Set(this);
|
|
4761
|
+
return dehancedSet.isDisjointFrom(otherSet);
|
|
4762
|
+
}
|
|
4763
|
+
};
|
|
4697
4764
|
_proto.replace = function replace(other) {
|
|
4698
4765
|
var _this5 = this;
|
|
4699
4766
|
if (isObservableSet(other)) {
|
|
@@ -4732,22 +4799,21 @@ var ObservableSet = /*#__PURE__*/function () {
|
|
|
4732
4799
|
_proto.toString = function toString() {
|
|
4733
4800
|
return "[object ObservableSet]";
|
|
4734
4801
|
};
|
|
4735
|
-
_proto[
|
|
4802
|
+
_proto[Symbol.iterator] = function () {
|
|
4736
4803
|
return this.values();
|
|
4737
4804
|
};
|
|
4738
|
-
_createClass(ObservableSet, [{
|
|
4805
|
+
return _createClass(ObservableSet, [{
|
|
4739
4806
|
key: "size",
|
|
4740
4807
|
get: function get() {
|
|
4741
4808
|
this.atom_.reportObserved();
|
|
4742
4809
|
return this.data_.size;
|
|
4743
4810
|
}
|
|
4744
4811
|
}, {
|
|
4745
|
-
key:
|
|
4812
|
+
key: Symbol.toStringTag,
|
|
4746
4813
|
get: function get() {
|
|
4747
4814
|
return "Set";
|
|
4748
4815
|
}
|
|
4749
4816
|
}]);
|
|
4750
|
-
return ObservableSet;
|
|
4751
4817
|
}();
|
|
4752
4818
|
// eslint-disable-next-line
|
|
4753
4819
|
var isObservableSet = /*#__PURE__*/createInstanceofPredicate("ObservableSet", ObservableSet);
|
|
@@ -5147,7 +5213,7 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
5147
5213
|
}
|
|
5148
5214
|
// Delete
|
|
5149
5215
|
try {
|
|
5150
|
-
var _this$pendingKeys_
|
|
5216
|
+
var _this$pendingKeys_;
|
|
5151
5217
|
startBatch();
|
|
5152
5218
|
var notify = hasListeners(this);
|
|
5153
5219
|
var notifySpy = process.env.NODE_ENV !== "production" && isSpyEnabled();
|
|
@@ -5185,7 +5251,7 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
5185
5251
|
this.keysAtom_.reportChanged();
|
|
5186
5252
|
// Notify "has" observers
|
|
5187
5253
|
// "in" as it may still exist in proto
|
|
5188
|
-
(_this$pendingKeys_ = this.pendingKeys_) == null
|
|
5254
|
+
(_this$pendingKeys_ = this.pendingKeys_) == null || (_this$pendingKeys_ = _this$pendingKeys_.get(key)) == null || _this$pendingKeys_.set(key in this.target_);
|
|
5189
5255
|
// Notify spies/listeners
|
|
5190
5256
|
if (notify || notifySpy) {
|
|
5191
5257
|
var _change2 = {
|
|
@@ -5226,7 +5292,7 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
5226
5292
|
return registerInterceptor(this, handler);
|
|
5227
5293
|
};
|
|
5228
5294
|
_proto.notifyPropertyAddition_ = function notifyPropertyAddition_(key, value) {
|
|
5229
|
-
var _this$pendingKeys_2
|
|
5295
|
+
var _this$pendingKeys_2;
|
|
5230
5296
|
var notify = hasListeners(this);
|
|
5231
5297
|
var notifySpy = process.env.NODE_ENV !== "production" && isSpyEnabled();
|
|
5232
5298
|
if (notify || notifySpy) {
|
|
@@ -5248,7 +5314,7 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
5248
5314
|
spyReportEnd();
|
|
5249
5315
|
}
|
|
5250
5316
|
}
|
|
5251
|
-
(_this$pendingKeys_2 = this.pendingKeys_) == null
|
|
5317
|
+
(_this$pendingKeys_2 = this.pendingKeys_) == null || (_this$pendingKeys_2 = _this$pendingKeys_2.get(key)) == null || _this$pendingKeys_2.set(true);
|
|
5252
5318
|
// Notify "keys/entries/values" observers
|
|
5253
5319
|
this.keysAtom_.reportChanged();
|
|
5254
5320
|
};
|
|
@@ -5310,7 +5376,7 @@ function recordAnnotationApplied(adm, annotation, key) {
|
|
|
5310
5376
|
adm.appliedAnnotations_[key] = annotation;
|
|
5311
5377
|
}
|
|
5312
5378
|
// Remove applied decorator annotation so we don't try to apply it again in subclass constructor
|
|
5313
|
-
(_adm$target_$storedAn = adm.target_[storedAnnotationsSymbol]) == null
|
|
5379
|
+
(_adm$target_$storedAn = adm.target_[storedAnnotationsSymbol]) == null || delete _adm$target_$storedAn[key];
|
|
5314
5380
|
}
|
|
5315
5381
|
function assertAnnotable(adm, annotation, key) {
|
|
5316
5382
|
// Valid annotation
|
|
@@ -5390,8 +5456,7 @@ inherit(StubArray, Array.prototype);
|
|
|
5390
5456
|
// Weex proto freeze protection was here,
|
|
5391
5457
|
// but it is unclear why the hack is need as MobX never changed the prototype
|
|
5392
5458
|
// anyway, so removed it in V6
|
|
5393
|
-
var LegacyObservableArray = /*#__PURE__*/function (_StubArray
|
|
5394
|
-
_inheritsLoose(LegacyObservableArray, _StubArray);
|
|
5459
|
+
var LegacyObservableArray = /*#__PURE__*/function (_StubArray) {
|
|
5395
5460
|
function LegacyObservableArray(initialValues, enhancer, name, owned) {
|
|
5396
5461
|
var _this;
|
|
5397
5462
|
if (name === void 0) {
|
|
@@ -5403,8 +5468,8 @@ var LegacyObservableArray = /*#__PURE__*/function (_StubArray, _Symbol$toStringT
|
|
|
5403
5468
|
_this = _StubArray.call(this) || this;
|
|
5404
5469
|
initObservable(function () {
|
|
5405
5470
|
var adm = new ObservableArrayAdministration(name, enhancer, owned, true);
|
|
5406
|
-
adm.proxy_ =
|
|
5407
|
-
addHiddenFinalProp(
|
|
5471
|
+
adm.proxy_ = _this;
|
|
5472
|
+
addHiddenFinalProp(_this, $mobx, adm);
|
|
5408
5473
|
if (initialValues && initialValues.length) {
|
|
5409
5474
|
// @ts-ignore
|
|
5410
5475
|
_this.spliceWithArray(0, 0, initialValues);
|
|
@@ -5412,11 +5477,12 @@ var LegacyObservableArray = /*#__PURE__*/function (_StubArray, _Symbol$toStringT
|
|
|
5412
5477
|
if (safariPrototypeSetterInheritanceBug) {
|
|
5413
5478
|
// Seems that Safari won't use numeric prototype setter until any * numeric property is
|
|
5414
5479
|
// defined on the instance. After that it works fine, even if this property is deleted.
|
|
5415
|
-
Object.defineProperty(
|
|
5480
|
+
Object.defineProperty(_this, "0", ENTRY_0);
|
|
5416
5481
|
}
|
|
5417
5482
|
});
|
|
5418
5483
|
return _this;
|
|
5419
5484
|
}
|
|
5485
|
+
_inheritsLoose(LegacyObservableArray, _StubArray);
|
|
5420
5486
|
var _proto = LegacyObservableArray.prototype;
|
|
5421
5487
|
_proto.concat = function concat() {
|
|
5422
5488
|
this[$mobx].atom_.reportObserved();
|
|
@@ -5429,7 +5495,7 @@ var LegacyObservableArray = /*#__PURE__*/function (_StubArray, _Symbol$toStringT
|
|
|
5429
5495
|
return isObservableArray(a) ? a.slice() : a;
|
|
5430
5496
|
}));
|
|
5431
5497
|
};
|
|
5432
|
-
_proto[
|
|
5498
|
+
_proto[Symbol.iterator] = function () {
|
|
5433
5499
|
var self = this;
|
|
5434
5500
|
var nextIndex = 0;
|
|
5435
5501
|
return makeIterable({
|
|
@@ -5444,7 +5510,7 @@ var LegacyObservableArray = /*#__PURE__*/function (_StubArray, _Symbol$toStringT
|
|
|
5444
5510
|
}
|
|
5445
5511
|
});
|
|
5446
5512
|
};
|
|
5447
|
-
_createClass(LegacyObservableArray, [{
|
|
5513
|
+
return _createClass(LegacyObservableArray, [{
|
|
5448
5514
|
key: "length",
|
|
5449
5515
|
get: function get() {
|
|
5450
5516
|
return this[$mobx].getArrayLength_();
|
|
@@ -5453,13 +5519,12 @@ var LegacyObservableArray = /*#__PURE__*/function (_StubArray, _Symbol$toStringT
|
|
|
5453
5519
|
this[$mobx].setArrayLength_(newLength);
|
|
5454
5520
|
}
|
|
5455
5521
|
}, {
|
|
5456
|
-
key:
|
|
5522
|
+
key: Symbol.toStringTag,
|
|
5457
5523
|
get: function get() {
|
|
5458
5524
|
return "Array";
|
|
5459
5525
|
}
|
|
5460
5526
|
}]);
|
|
5461
|
-
|
|
5462
|
-
}(StubArray, Symbol.toStringTag, Symbol.iterator);
|
|
5527
|
+
}(StubArray);
|
|
5463
5528
|
Object.entries(arrayExtensions).forEach(function (_ref) {
|
|
5464
5529
|
var prop = _ref[0],
|
|
5465
5530
|
fn = _ref[1];
|