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
|
@@ -263,99 +263,76 @@ var getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors || function get
|
|
|
263
263
|
return res;
|
|
264
264
|
};
|
|
265
265
|
|
|
266
|
-
function
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
Object.defineProperty(
|
|
279
|
-
writable:
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
289
|
-
target[key] = source[key];
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
return target;
|
|
294
|
-
};
|
|
295
|
-
return _extends.apply(this, arguments);
|
|
296
|
-
}
|
|
297
|
-
function _inheritsLoose(subClass, superClass) {
|
|
298
|
-
subClass.prototype = Object.create(superClass.prototype);
|
|
299
|
-
subClass.prototype.constructor = subClass;
|
|
300
|
-
_setPrototypeOf(subClass, superClass);
|
|
301
|
-
}
|
|
302
|
-
function _setPrototypeOf(o, p) {
|
|
303
|
-
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
304
|
-
o.__proto__ = p;
|
|
305
|
-
return o;
|
|
306
|
-
};
|
|
307
|
-
return _setPrototypeOf(o, p);
|
|
308
|
-
}
|
|
309
|
-
function _assertThisInitialized(self) {
|
|
310
|
-
if (self === void 0) {
|
|
311
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
312
|
-
}
|
|
313
|
-
return self;
|
|
314
|
-
}
|
|
315
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
316
|
-
if (!o) return;
|
|
317
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
318
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
319
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
320
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
321
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
322
|
-
}
|
|
323
|
-
function _arrayLikeToArray(arr, len) {
|
|
324
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
325
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
326
|
-
return arr2;
|
|
327
|
-
}
|
|
328
|
-
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
329
|
-
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
330
|
-
if (it) return (it = it.call(o)).next.bind(it);
|
|
331
|
-
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
332
|
-
if (it) o = it;
|
|
333
|
-
var i = 0;
|
|
266
|
+
function _arrayLikeToArray(r, a) {
|
|
267
|
+
(null == a || a > r.length) && (a = r.length);
|
|
268
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
269
|
+
return n;
|
|
270
|
+
}
|
|
271
|
+
function _defineProperties(e, r) {
|
|
272
|
+
for (var t = 0; t < r.length; t++) {
|
|
273
|
+
var o = r[t];
|
|
274
|
+
o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
function _createClass(e, r, t) {
|
|
278
|
+
return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
|
|
279
|
+
writable: !1
|
|
280
|
+
}), e;
|
|
281
|
+
}
|
|
282
|
+
function _createForOfIteratorHelperLoose(r, e) {
|
|
283
|
+
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
284
|
+
if (t) return (t = t.call(r)).next.bind(t);
|
|
285
|
+
if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) {
|
|
286
|
+
t && (r = t);
|
|
287
|
+
var o = 0;
|
|
334
288
|
return function () {
|
|
335
|
-
|
|
336
|
-
done:
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
value: o[i++]
|
|
289
|
+
return o >= r.length ? {
|
|
290
|
+
done: !0
|
|
291
|
+
} : {
|
|
292
|
+
done: !1,
|
|
293
|
+
value: r[o++]
|
|
341
294
|
};
|
|
342
295
|
};
|
|
343
296
|
}
|
|
344
297
|
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
345
298
|
}
|
|
346
|
-
function
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
299
|
+
function _extends() {
|
|
300
|
+
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
301
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
302
|
+
var t = arguments[e];
|
|
303
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
304
|
+
}
|
|
305
|
+
return n;
|
|
306
|
+
}, _extends.apply(null, arguments);
|
|
307
|
+
}
|
|
308
|
+
function _inheritsLoose(t, o) {
|
|
309
|
+
t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o);
|
|
310
|
+
}
|
|
311
|
+
function _setPrototypeOf(t, e) {
|
|
312
|
+
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
|
|
313
|
+
return t.__proto__ = e, t;
|
|
314
|
+
}, _setPrototypeOf(t, e);
|
|
315
|
+
}
|
|
316
|
+
function _toPrimitive(t, r) {
|
|
317
|
+
if ("object" != typeof t || !t) return t;
|
|
318
|
+
var e = t[Symbol.toPrimitive];
|
|
319
|
+
if (void 0 !== e) {
|
|
320
|
+
var i = e.call(t, r || "default");
|
|
321
|
+
if ("object" != typeof i) return i;
|
|
352
322
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
353
323
|
}
|
|
354
|
-
return (
|
|
324
|
+
return ("string" === r ? String : Number)(t);
|
|
355
325
|
}
|
|
356
|
-
function _toPropertyKey(
|
|
357
|
-
var
|
|
358
|
-
return
|
|
326
|
+
function _toPropertyKey(t) {
|
|
327
|
+
var i = _toPrimitive(t, "string");
|
|
328
|
+
return "symbol" == typeof i ? i : i + "";
|
|
329
|
+
}
|
|
330
|
+
function _unsupportedIterableToArray(r, a) {
|
|
331
|
+
if (r) {
|
|
332
|
+
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
333
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
334
|
+
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;
|
|
335
|
+
}
|
|
359
336
|
}
|
|
360
337
|
|
|
361
338
|
var storedAnnotationsSymbol = /*#__PURE__*/Symbol("mobx-stored-annotations");
|
|
@@ -428,8 +405,6 @@ function assert20223DecoratorType(context, types) {
|
|
|
428
405
|
|
|
429
406
|
var $mobx = /*#__PURE__*/Symbol("mobx administration");
|
|
430
407
|
var Atom = /*#__PURE__*/function () {
|
|
431
|
-
// for effective unobserving. BaseAtom has true, for extra optimization, so its onBecomeUnobserved never gets called, because it's not needed
|
|
432
|
-
|
|
433
408
|
/**
|
|
434
409
|
* Create a new atom. For debugging purposes it is recommended to give it a name.
|
|
435
410
|
* The onBecomeObserved and onBecomeUnobserved callbacks can be used for resource management.
|
|
@@ -440,16 +415,18 @@ var Atom = /*#__PURE__*/function () {
|
|
|
440
415
|
}
|
|
441
416
|
this.name_ = void 0;
|
|
442
417
|
this.isPendingUnobservation = false;
|
|
418
|
+
// for effective unobserving. BaseAtom has true, for extra optimization, so its onBecomeUnobserved never gets called, because it's not needed
|
|
443
419
|
this.isBeingObserved = false;
|
|
444
420
|
this.observers_ = new Set();
|
|
445
421
|
this.diffValue_ = 0;
|
|
446
422
|
this.lastAccessedBy_ = 0;
|
|
447
423
|
this.lowestObserverState_ = IDerivationState_.NOT_TRACKING_;
|
|
424
|
+
// onBecomeObservedListeners
|
|
448
425
|
this.onBOL = void 0;
|
|
426
|
+
// onBecomeUnobservedListeners
|
|
449
427
|
this.onBUOL = void 0;
|
|
450
428
|
this.name_ = name_;
|
|
451
429
|
}
|
|
452
|
-
// onBecomeObservedListeners
|
|
453
430
|
var _proto = Atom.prototype;
|
|
454
431
|
_proto.onBO = function onBO() {
|
|
455
432
|
if (this.onBOL) {
|
|
@@ -631,7 +608,6 @@ function make_(adm, key) {
|
|
|
631
608
|
}
|
|
632
609
|
return 0 /* MakeResult.Cancel */;
|
|
633
610
|
}
|
|
634
|
-
|
|
635
611
|
function extend_(adm, key, descriptor, proxyTrap) {
|
|
636
612
|
die("'" + this.annotationType_ + "' can only be used with 'makeObservable'");
|
|
637
613
|
}
|
|
@@ -664,12 +640,10 @@ function make_$1(adm, key, descriptor, source) {
|
|
|
664
640
|
// rest of the proto chain must be annotated already
|
|
665
641
|
return 1 /* MakeResult.Break */;
|
|
666
642
|
}
|
|
667
|
-
|
|
668
643
|
var actionDescriptor = createActionDescriptor(adm, this, key, descriptor, false);
|
|
669
644
|
defineProperty(source, key, actionDescriptor);
|
|
670
645
|
return 2 /* MakeResult.Continue */;
|
|
671
646
|
}
|
|
672
|
-
|
|
673
647
|
function extend_$1(adm, key, descriptor, proxyTrap) {
|
|
674
648
|
var actionDescriptor = createActionDescriptor(adm, this, key, descriptor);
|
|
675
649
|
return adm.defineProperty_(key, actionDescriptor, proxyTrap);
|
|
@@ -767,18 +741,15 @@ function make_$2(adm, key, descriptor, source) {
|
|
|
767
741
|
return 0 /* MakeResult.Cancel */;
|
|
768
742
|
}
|
|
769
743
|
}
|
|
770
|
-
|
|
771
744
|
if (isFlow(descriptor.value)) {
|
|
772
745
|
// A prototype could have been annotated already by other constructor,
|
|
773
746
|
// rest of the proto chain must be annotated already
|
|
774
747
|
return 1 /* MakeResult.Break */;
|
|
775
748
|
}
|
|
776
|
-
|
|
777
749
|
var flowDescriptor = createFlowDescriptor(adm, this, key, descriptor, false, false);
|
|
778
750
|
defineProperty(source, key, flowDescriptor);
|
|
779
751
|
return 2 /* MakeResult.Continue */;
|
|
780
752
|
}
|
|
781
|
-
|
|
782
753
|
function extend_$2(adm, key, descriptor, proxyTrap) {
|
|
783
754
|
var _this$options_2;
|
|
784
755
|
var flowDescriptor = createFlowDescriptor(adm, this, key, descriptor, (_this$options_2 = this.options_) == null ? void 0 : _this$options_2.bound);
|
|
@@ -855,7 +826,6 @@ function createComputedAnnotation(name, options) {
|
|
|
855
826
|
function make_$3(adm, key, descriptor) {
|
|
856
827
|
return this.extend_(adm, key, descriptor, false) === null ? 0 /* MakeResult.Cancel */ : 1 /* MakeResult.Break */;
|
|
857
828
|
}
|
|
858
|
-
|
|
859
829
|
function extend_$3(adm, key, descriptor, proxyTrap) {
|
|
860
830
|
assertComputedDescriptor(adm, this, key, descriptor);
|
|
861
831
|
return adm.defineComputedProperty_(key, _extends({}, this.options_, {
|
|
@@ -903,7 +873,6 @@ function createObservableAnnotation(name, options) {
|
|
|
903
873
|
function make_$4(adm, key, descriptor) {
|
|
904
874
|
return this.extend_(adm, key, descriptor, false) === null ? 0 /* MakeResult.Cancel */ : 1 /* MakeResult.Break */;
|
|
905
875
|
}
|
|
906
|
-
|
|
907
876
|
function extend_$4(adm, key, descriptor, proxyTrap) {
|
|
908
877
|
var _this$options_$enhanc, _this$options_;
|
|
909
878
|
assertObservableDescriptor(adm, this, key, descriptor);
|
|
@@ -1323,11 +1292,8 @@ function allowStateChangesEnd(prev) {
|
|
|
1323
1292
|
globalState.allowStateChanges = prev;
|
|
1324
1293
|
}
|
|
1325
1294
|
|
|
1326
|
-
var _Symbol$toPrimitive;
|
|
1327
1295
|
var CREATE = "create";
|
|
1328
|
-
_Symbol$toPrimitive = Symbol.toPrimitive;
|
|
1329
1296
|
var ObservableValue = /*#__PURE__*/function (_Atom) {
|
|
1330
|
-
_inheritsLoose(ObservableValue, _Atom);
|
|
1331
1297
|
function ObservableValue(value, enhancer, name_, notifySpy, equals) {
|
|
1332
1298
|
var _this;
|
|
1333
1299
|
if (name_ === void 0) {
|
|
@@ -1356,7 +1322,7 @@ var ObservableValue = /*#__PURE__*/function (_Atom) {
|
|
|
1356
1322
|
// only notify spy if this is a stand-alone observable
|
|
1357
1323
|
spyReport({
|
|
1358
1324
|
type: CREATE,
|
|
1359
|
-
object:
|
|
1325
|
+
object: _this,
|
|
1360
1326
|
observableKind: "value",
|
|
1361
1327
|
debugObjectName: _this.name_,
|
|
1362
1328
|
newValue: "" + _this.value_
|
|
@@ -1364,6 +1330,7 @@ var ObservableValue = /*#__PURE__*/function (_Atom) {
|
|
|
1364
1330
|
}
|
|
1365
1331
|
return _this;
|
|
1366
1332
|
}
|
|
1333
|
+
_inheritsLoose(ObservableValue, _Atom);
|
|
1367
1334
|
var _proto = ObservableValue.prototype;
|
|
1368
1335
|
_proto.dehanceValue = function dehanceValue(value) {
|
|
1369
1336
|
if (this.dehancer !== undefined) {
|
|
@@ -1455,14 +1422,13 @@ var ObservableValue = /*#__PURE__*/function (_Atom) {
|
|
|
1455
1422
|
_proto.valueOf = function valueOf() {
|
|
1456
1423
|
return toPrimitive(this.get());
|
|
1457
1424
|
};
|
|
1458
|
-
_proto[
|
|
1425
|
+
_proto[Symbol.toPrimitive] = function () {
|
|
1459
1426
|
return this.valueOf();
|
|
1460
1427
|
};
|
|
1461
1428
|
return ObservableValue;
|
|
1462
1429
|
}(Atom);
|
|
1463
1430
|
var isObservableValue = /*#__PURE__*/createInstanceofPredicate("ObservableValue", ObservableValue);
|
|
1464
1431
|
|
|
1465
|
-
var _Symbol$toPrimitive$1;
|
|
1466
1432
|
function getFlag(flags, mask) {
|
|
1467
1433
|
return !!(flags & mask);
|
|
1468
1434
|
}
|
|
@@ -1493,13 +1459,7 @@ function setFlag(flags, mask, newValue) {
|
|
|
1493
1459
|
*
|
|
1494
1460
|
* If at any point it's outside batch and it isn't observed: reset everything and go to 1.
|
|
1495
1461
|
*/
|
|
1496
|
-
_Symbol$toPrimitive$1 = Symbol.toPrimitive;
|
|
1497
1462
|
var ComputedValue = /*#__PURE__*/function () {
|
|
1498
|
-
// nodes we are looking at. Our value depends on these nodes
|
|
1499
|
-
// during tracking it's an array with new observed observers
|
|
1500
|
-
|
|
1501
|
-
// N.B: unminified as it is used by MST
|
|
1502
|
-
|
|
1503
1463
|
/**
|
|
1504
1464
|
* Create a new computed value based on a function expression.
|
|
1505
1465
|
*
|
|
@@ -1515,7 +1475,9 @@ var ComputedValue = /*#__PURE__*/function () {
|
|
|
1515
1475
|
function ComputedValue(options) {
|
|
1516
1476
|
this.dependenciesState_ = IDerivationState_.NOT_TRACKING_;
|
|
1517
1477
|
this.observing_ = [];
|
|
1478
|
+
// nodes we are looking at. Our value depends on these nodes
|
|
1518
1479
|
this.newObserving_ = null;
|
|
1480
|
+
// during tracking it's an array with new observed observers
|
|
1519
1481
|
this.observers_ = new Set();
|
|
1520
1482
|
this.diffValue_ = 0;
|
|
1521
1483
|
this.runId_ = 0;
|
|
@@ -1527,6 +1489,7 @@ var ComputedValue = /*#__PURE__*/function () {
|
|
|
1527
1489
|
this.triggeredBy_ = void 0;
|
|
1528
1490
|
this.flags_ = 0;
|
|
1529
1491
|
this.derivation = void 0;
|
|
1492
|
+
// N.B: unminified as it is used by MST
|
|
1530
1493
|
this.setter_ = void 0;
|
|
1531
1494
|
this.isTracing_ = TraceMode.NONE;
|
|
1532
1495
|
this.scope_ = void 0;
|
|
@@ -1708,10 +1671,10 @@ var ComputedValue = /*#__PURE__*/function () {
|
|
|
1708
1671
|
_proto.valueOf = function valueOf() {
|
|
1709
1672
|
return toPrimitive(this.get());
|
|
1710
1673
|
};
|
|
1711
|
-
_proto[
|
|
1674
|
+
_proto[Symbol.toPrimitive] = function () {
|
|
1712
1675
|
return this.valueOf();
|
|
1713
1676
|
};
|
|
1714
|
-
_createClass(ComputedValue, [{
|
|
1677
|
+
return _createClass(ComputedValue, [{
|
|
1715
1678
|
key: "isComputing",
|
|
1716
1679
|
get: function get() {
|
|
1717
1680
|
return getFlag(this.flags_, ComputedValue.isComputingMask_);
|
|
@@ -1744,7 +1707,6 @@ var ComputedValue = /*#__PURE__*/function () {
|
|
|
1744
1707
|
this.flags_ = setFlag(this.flags_, ComputedValue.isPendingUnobservationMask_, newValue);
|
|
1745
1708
|
}
|
|
1746
1709
|
}]);
|
|
1747
|
-
return ComputedValue;
|
|
1748
1710
|
}();
|
|
1749
1711
|
ComputedValue.isComputingMask_ = 1;
|
|
1750
1712
|
ComputedValue.isRunningSetterMask_ = 2;
|
|
@@ -1783,7 +1745,6 @@ var CaughtException = function CaughtException(cause) {
|
|
|
1783
1745
|
this.cause = cause;
|
|
1784
1746
|
// Empty
|
|
1785
1747
|
};
|
|
1786
|
-
|
|
1787
1748
|
function isCaughtException(e) {
|
|
1788
1749
|
return e instanceof CaughtException;
|
|
1789
1750
|
}
|
|
@@ -1847,7 +1808,6 @@ function shouldCompute(derivation) {
|
|
|
1847
1808
|
function isComputingDerivation() {
|
|
1848
1809
|
return globalState.trackingDerivation !== null; // filter out actions inside computations
|
|
1849
1810
|
}
|
|
1850
|
-
|
|
1851
1811
|
function checkIfStateModificationsAreAllowed(atom) {
|
|
1852
1812
|
var hasObservers = atom.observers_.size > 0;
|
|
1853
1813
|
// Should not be possible to change observed state outside strict mode, except during initialization, see #563
|
|
@@ -2018,28 +1978,113 @@ function changeDependenciesStateTo0(derivation) {
|
|
|
2018
1978
|
*/
|
|
2019
1979
|
var persistentKeys = ["mobxGuid", "spyListeners", "enforceActions", "computedRequiresReaction", "reactionRequiresObservable", "observableRequiresReaction", "allowStateReads", "disableErrorBoundaries", "runId", "UNCHANGED", "useProxies"];
|
|
2020
1980
|
var MobXGlobals = function MobXGlobals() {
|
|
1981
|
+
/**
|
|
1982
|
+
* MobXGlobals version.
|
|
1983
|
+
* MobX compatiblity with other versions loaded in memory as long as this version matches.
|
|
1984
|
+
* It indicates that the global state still stores similar information
|
|
1985
|
+
*
|
|
1986
|
+
* N.B: this version is unrelated to the package version of MobX, and is only the version of the
|
|
1987
|
+
* internal state storage of MobX, and can be the same across many different package versions
|
|
1988
|
+
*/
|
|
2021
1989
|
this.version = 6;
|
|
1990
|
+
/**
|
|
1991
|
+
* globally unique token to signal unchanged
|
|
1992
|
+
*/
|
|
2022
1993
|
this.UNCHANGED = {};
|
|
1994
|
+
/**
|
|
1995
|
+
* Currently running derivation
|
|
1996
|
+
*/
|
|
2023
1997
|
this.trackingDerivation = null;
|
|
1998
|
+
/**
|
|
1999
|
+
* Currently running reaction. This determines if we currently have a reactive context.
|
|
2000
|
+
* (Tracking derivation is also set for temporal tracking of computed values inside actions,
|
|
2001
|
+
* but trackingReaction can only be set by a form of Reaction)
|
|
2002
|
+
*/
|
|
2024
2003
|
this.trackingContext = null;
|
|
2004
|
+
/**
|
|
2005
|
+
* Each time a derivation is tracked, it is assigned a unique run-id
|
|
2006
|
+
*/
|
|
2025
2007
|
this.runId = 0;
|
|
2008
|
+
/**
|
|
2009
|
+
* 'guid' for general purpose. Will be persisted amongst resets.
|
|
2010
|
+
*/
|
|
2026
2011
|
this.mobxGuid = 0;
|
|
2012
|
+
/**
|
|
2013
|
+
* Are we in a batch block? (and how many of them)
|
|
2014
|
+
*/
|
|
2027
2015
|
this.inBatch = 0;
|
|
2016
|
+
/**
|
|
2017
|
+
* Observables that don't have observers anymore, and are about to be
|
|
2018
|
+
* suspended, unless somebody else accesses it in the same batch
|
|
2019
|
+
*
|
|
2020
|
+
* @type {IObservable[]}
|
|
2021
|
+
*/
|
|
2028
2022
|
this.pendingUnobservations = [];
|
|
2023
|
+
/**
|
|
2024
|
+
* List of scheduled, not yet executed, reactions.
|
|
2025
|
+
*/
|
|
2029
2026
|
this.pendingReactions = [];
|
|
2027
|
+
/**
|
|
2028
|
+
* Are we currently processing reactions?
|
|
2029
|
+
*/
|
|
2030
2030
|
this.isRunningReactions = false;
|
|
2031
|
+
/**
|
|
2032
|
+
* Is it allowed to change observables at this point?
|
|
2033
|
+
* In general, MobX doesn't allow that when running computations and React.render.
|
|
2034
|
+
* To ensure that those functions stay pure.
|
|
2035
|
+
*/
|
|
2031
2036
|
this.allowStateChanges = false;
|
|
2037
|
+
/**
|
|
2038
|
+
* Is it allowed to read observables at this point?
|
|
2039
|
+
* Used to hold the state needed for `observableRequiresReaction`
|
|
2040
|
+
*/
|
|
2032
2041
|
this.allowStateReads = true;
|
|
2042
|
+
/**
|
|
2043
|
+
* If strict mode is enabled, state changes are by default not allowed
|
|
2044
|
+
*/
|
|
2033
2045
|
this.enforceActions = true;
|
|
2046
|
+
/**
|
|
2047
|
+
* Spy callbacks
|
|
2048
|
+
*/
|
|
2034
2049
|
this.spyListeners = [];
|
|
2050
|
+
/**
|
|
2051
|
+
* Globally attached error handlers that react specifically to errors in reactions
|
|
2052
|
+
*/
|
|
2035
2053
|
this.globalReactionErrorHandlers = [];
|
|
2054
|
+
/**
|
|
2055
|
+
* Warn if computed values are accessed outside a reactive context
|
|
2056
|
+
*/
|
|
2036
2057
|
this.computedRequiresReaction = false;
|
|
2058
|
+
/**
|
|
2059
|
+
* (Experimental)
|
|
2060
|
+
* Warn if you try to create to derivation / reactive context without accessing any observable.
|
|
2061
|
+
*/
|
|
2037
2062
|
this.reactionRequiresObservable = false;
|
|
2063
|
+
/**
|
|
2064
|
+
* (Experimental)
|
|
2065
|
+
* Warn if observables are accessed outside a reactive context
|
|
2066
|
+
*/
|
|
2038
2067
|
this.observableRequiresReaction = false;
|
|
2068
|
+
/*
|
|
2069
|
+
* Don't catch and rethrow exceptions. This is useful for inspecting the state of
|
|
2070
|
+
* the stack when an exception occurs while debugging.
|
|
2071
|
+
*/
|
|
2039
2072
|
this.disableErrorBoundaries = false;
|
|
2073
|
+
/*
|
|
2074
|
+
* If true, we are already handling an exception in an action. Any errors in reactions should be suppressed, as
|
|
2075
|
+
* they are not the cause, see: https://github.com/mobxjs/mobx/issues/1836
|
|
2076
|
+
*/
|
|
2040
2077
|
this.suppressReactionErrors = false;
|
|
2041
2078
|
this.useProxies = true;
|
|
2079
|
+
/*
|
|
2080
|
+
* print warnings about code that would fail if proxies weren't available
|
|
2081
|
+
*/
|
|
2042
2082
|
this.verifyProxies = false;
|
|
2083
|
+
/**
|
|
2084
|
+
* False forces all object's descriptors to
|
|
2085
|
+
* writable: true
|
|
2086
|
+
* configurable: true
|
|
2087
|
+
*/
|
|
2043
2088
|
this.safeDescriptors = true;
|
|
2044
2089
|
};
|
|
2045
2090
|
var canMergeGlobalState = true;
|
|
@@ -2136,7 +2181,6 @@ function addObserver(observable, node) {
|
|
|
2136
2181
|
// invariantObservers(observable);
|
|
2137
2182
|
// invariant(observable._observers.indexOf(node) !== -1, "INTERNAL ERROR didn't add node");
|
|
2138
2183
|
}
|
|
2139
|
-
|
|
2140
2184
|
function removeObserver(observable, node) {
|
|
2141
2185
|
// invariant(globalState.inBatch > 0, "INTERNAL ERROR, remove should be called only inside batch");
|
|
2142
2186
|
// invariant(observable._observers.indexOf(node) !== -1, "INTERNAL ERROR remove already removed node");
|
|
@@ -2149,7 +2193,6 @@ function removeObserver(observable, node) {
|
|
|
2149
2193
|
// invariantObservers(observable);
|
|
2150
2194
|
// invariant(observable._observers.indexOf(node) === -1, "INTERNAL ERROR remove already removed node2");
|
|
2151
2195
|
}
|
|
2152
|
-
|
|
2153
2196
|
function queueForUnobservation(observable) {
|
|
2154
2197
|
if (observable.isPendingUnobservation === false) {
|
|
2155
2198
|
// invariant(observable._observers.length === 0, "INTERNAL ERROR, should only queue for unobservation unobserved observables");
|
|
@@ -2287,7 +2330,6 @@ function propagateMaybeChanged(observable) {
|
|
|
2287
2330
|
});
|
|
2288
2331
|
// invariantLOS(observable, "maybe end");
|
|
2289
2332
|
}
|
|
2290
|
-
|
|
2291
2333
|
function logTraceInfo(derivation, observable) {
|
|
2292
2334
|
console.log("[mobx.trace] '" + derivation.name_ + "' is invalidated due to a change in: '" + observable.name_ + "'");
|
|
2293
2335
|
if (derivation.isTracing_ === TraceMode.BREAK) {
|
|
@@ -2311,8 +2353,6 @@ function printDepTree(tree, lines, depth) {
|
|
|
2311
2353
|
}
|
|
2312
2354
|
|
|
2313
2355
|
var Reaction = /*#__PURE__*/function () {
|
|
2314
|
-
// nodes we are looking at. Our value depends on these nodes
|
|
2315
|
-
|
|
2316
2356
|
function Reaction(name_, onInvalidate_, errorHandler_, requiresObservable_) {
|
|
2317
2357
|
if (name_ === void 0) {
|
|
2318
2358
|
name_ = "Reaction@" + getNextId() ;
|
|
@@ -2322,6 +2362,7 @@ var Reaction = /*#__PURE__*/function () {
|
|
|
2322
2362
|
this.errorHandler_ = void 0;
|
|
2323
2363
|
this.requiresObservable_ = void 0;
|
|
2324
2364
|
this.observing_ = [];
|
|
2365
|
+
// nodes we are looking at. Our value depends on these nodes
|
|
2325
2366
|
this.newObserving_ = [];
|
|
2326
2367
|
this.dependenciesState_ = IDerivationState_.NOT_TRACKING_;
|
|
2327
2368
|
this.diffValue_ = 0;
|
|
@@ -2384,7 +2425,6 @@ var Reaction = /*#__PURE__*/function () {
|
|
|
2384
2425
|
return;
|
|
2385
2426
|
// console.warn("Reaction already disposed") // Note: Not a warning / error in mobx 4 either
|
|
2386
2427
|
}
|
|
2387
|
-
|
|
2388
2428
|
startBatch();
|
|
2389
2429
|
var notify = isSpyEnabled();
|
|
2390
2430
|
var startTime;
|
|
@@ -2459,9 +2499,9 @@ var Reaction = /*#__PURE__*/function () {
|
|
|
2459
2499
|
var _this2 = this;
|
|
2460
2500
|
var dispose = function dispose() {
|
|
2461
2501
|
_this2.dispose();
|
|
2462
|
-
abortSignal == null
|
|
2502
|
+
abortSignal == null || abortSignal.removeEventListener == null || abortSignal.removeEventListener("abort", dispose);
|
|
2463
2503
|
};
|
|
2464
|
-
abortSignal == null
|
|
2504
|
+
abortSignal == null || abortSignal.addEventListener == null || abortSignal.addEventListener("abort", dispose);
|
|
2465
2505
|
dispose[$mobx] = this;
|
|
2466
2506
|
return dispose;
|
|
2467
2507
|
};
|
|
@@ -2513,7 +2553,6 @@ function runReactionsHelper() {
|
|
|
2513
2553
|
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]) );
|
|
2514
2554
|
allReactions.splice(0); // clear reactions
|
|
2515
2555
|
}
|
|
2516
|
-
|
|
2517
2556
|
var remainingReactions = allReactions.splice(0);
|
|
2518
2557
|
for (var i = 0, l = remainingReactions.length; i < l; i++) {
|
|
2519
2558
|
remainingReactions[i].runReaction_();
|
|
@@ -2641,7 +2680,7 @@ function isAction(thing) {
|
|
|
2641
2680
|
* @returns disposer function, which can be used to stop the view from being updated in the future.
|
|
2642
2681
|
*/
|
|
2643
2682
|
function autorun(view, opts) {
|
|
2644
|
-
var _opts$name, _opts, _opts2,
|
|
2683
|
+
var _opts$name, _opts, _opts2, _opts3;
|
|
2645
2684
|
if (opts === void 0) {
|
|
2646
2685
|
opts = EMPTY_OBJECT;
|
|
2647
2686
|
}
|
|
@@ -2680,7 +2719,7 @@ function autorun(view, opts) {
|
|
|
2680
2719
|
function reactionRunner() {
|
|
2681
2720
|
view(reaction);
|
|
2682
2721
|
}
|
|
2683
|
-
if (!((_opts2 = opts) != null && (_opts2
|
|
2722
|
+
if (!((_opts2 = opts) != null && (_opts2 = _opts2.signal) != null && _opts2.aborted)) {
|
|
2684
2723
|
reaction.schedule_();
|
|
2685
2724
|
}
|
|
2686
2725
|
return reaction.getDisposer_((_opts3 = opts) == null ? void 0 : _opts3.signal);
|
|
@@ -2694,7 +2733,7 @@ function createSchedulerFromOptions(opts) {
|
|
|
2694
2733
|
} : run;
|
|
2695
2734
|
}
|
|
2696
2735
|
function reaction(expression, effect, opts) {
|
|
2697
|
-
var _opts$name2, _opts4,
|
|
2736
|
+
var _opts$name2, _opts4, _opts5;
|
|
2698
2737
|
if (opts === void 0) {
|
|
2699
2738
|
opts = EMPTY_OBJECT;
|
|
2700
2739
|
}
|
|
@@ -2743,7 +2782,7 @@ function reaction(expression, effect, opts) {
|
|
|
2743
2782
|
}
|
|
2744
2783
|
firstTime = false;
|
|
2745
2784
|
}
|
|
2746
|
-
if (!((_opts4 = opts) != null && (_opts4
|
|
2785
|
+
if (!((_opts4 = opts) != null && (_opts4 = _opts4.signal) != null && _opts4.aborted)) {
|
|
2747
2786
|
r.schedule_();
|
|
2748
2787
|
}
|
|
2749
2788
|
return r.getDisposer_((_opts5 = opts) == null ? void 0 : _opts5.signal);
|
|
@@ -2952,7 +2991,6 @@ var flow = /*#__PURE__*/Object.assign(function flow(arg1, arg2) {
|
|
|
2952
2991
|
}
|
|
2953
2992
|
onFulfilled(undefined); // kick off the process
|
|
2954
2993
|
});
|
|
2955
|
-
|
|
2956
2994
|
promise.cancel = action(name + " - runid: " + runId + " - cancel", function () {
|
|
2957
2995
|
try {
|
|
2958
2996
|
if (pendingPromise) {
|
|
@@ -2970,7 +3008,6 @@ var flow = /*#__PURE__*/Object.assign(function flow(arg1, arg2) {
|
|
|
2970
3008
|
rejector(e); // there could be a throwing finally block
|
|
2971
3009
|
}
|
|
2972
3010
|
});
|
|
2973
|
-
|
|
2974
3011
|
return promise;
|
|
2975
3012
|
};
|
|
2976
3013
|
res.isMobXFlow = true;
|
|
@@ -2985,7 +3022,6 @@ function cancelPromise(promise) {
|
|
|
2985
3022
|
function flowResult(result) {
|
|
2986
3023
|
return result; // just tricking TypeScript :)
|
|
2987
3024
|
}
|
|
2988
|
-
|
|
2989
3025
|
function isFlow(fn) {
|
|
2990
3026
|
return (fn == null ? void 0 : fn.isMobXFlow) === true;
|
|
2991
3027
|
}
|
|
@@ -3407,10 +3443,10 @@ function whenPromise(predicate, opts) {
|
|
|
3407
3443
|
disposer();
|
|
3408
3444
|
reject(new Error("WHEN_ABORTED"));
|
|
3409
3445
|
};
|
|
3410
|
-
opts == null
|
|
3446
|
+
opts == null || (_opts$signal2 = opts.signal) == null || _opts$signal2.addEventListener == null || _opts$signal2.addEventListener("abort", abort);
|
|
3411
3447
|
})["finally"](function () {
|
|
3412
3448
|
var _opts$signal3;
|
|
3413
|
-
return opts == null
|
|
3449
|
+
return opts == null || (_opts$signal3 = opts.signal) == null || _opts$signal3.removeEventListener == null ? void 0 : _opts$signal3.removeEventListener("abort", abort);
|
|
3414
3450
|
});
|
|
3415
3451
|
res.cancel = cancel;
|
|
3416
3452
|
return res;
|
|
@@ -3627,8 +3663,6 @@ var arrayTraps = {
|
|
|
3627
3663
|
}
|
|
3628
3664
|
};
|
|
3629
3665
|
var ObservableArrayAdministration = /*#__PURE__*/function () {
|
|
3630
|
-
// this is the prop that gets proxied, so can't replace it!
|
|
3631
|
-
|
|
3632
3666
|
function ObservableArrayAdministration(name, enhancer, owned_, legacyMode_) {
|
|
3633
3667
|
if (name === void 0) {
|
|
3634
3668
|
name = "ObservableArray@" + getNextId() ;
|
|
@@ -3637,6 +3671,7 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
|
|
|
3637
3671
|
this.legacyMode_ = void 0;
|
|
3638
3672
|
this.atom_ = void 0;
|
|
3639
3673
|
this.values_ = [];
|
|
3674
|
+
// this is the prop that gets proxied, so can't replace it!
|
|
3640
3675
|
this.interceptors_ = void 0;
|
|
3641
3676
|
this.changeListeners_ = void 0;
|
|
3642
3677
|
this.enhancer_ = void 0;
|
|
@@ -3757,7 +3792,6 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
|
|
|
3757
3792
|
var lengthDelta = newItems.length - deleteCount;
|
|
3758
3793
|
this.updateArrayLength_(length, lengthDelta); // checks if internal array wasn't modified
|
|
3759
3794
|
}
|
|
3760
|
-
|
|
3761
3795
|
var res = this.spliceItemsIntoValues_(index, deleteCount, newItems);
|
|
3762
3796
|
if (deleteCount !== 0 || newItems.length !== 0) {
|
|
3763
3797
|
this.notifyArraySplice_(index, newItems, res);
|
|
@@ -3857,6 +3891,7 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
|
|
|
3857
3891
|
var change = interceptChange(this, {
|
|
3858
3892
|
type: UPDATE,
|
|
3859
3893
|
object: this.proxy_,
|
|
3894
|
+
// since "this" is the real array we need to pass its proxy
|
|
3860
3895
|
index: index,
|
|
3861
3896
|
newValue: newValue
|
|
3862
3897
|
});
|
|
@@ -4072,17 +4107,12 @@ function isObservableArray(thing) {
|
|
|
4072
4107
|
return isObject(thing) && isObservableArrayAdministration(thing[$mobx]);
|
|
4073
4108
|
}
|
|
4074
4109
|
|
|
4075
|
-
var _Symbol$iterator, _Symbol$toStringTag;
|
|
4076
4110
|
var ObservableMapMarker = {};
|
|
4077
4111
|
var ADD = "add";
|
|
4078
4112
|
var DELETE = "delete";
|
|
4079
4113
|
// just extend Map? See also https://gist.github.com/nestharus/13b4d74f2ef4a2f4357dbd3fc23c1e54
|
|
4080
4114
|
// But: https://github.com/mobxjs/mobx/issues/1556
|
|
4081
|
-
_Symbol$iterator = Symbol.iterator;
|
|
4082
|
-
_Symbol$toStringTag = Symbol.toStringTag;
|
|
4083
4115
|
var ObservableMap = /*#__PURE__*/function () {
|
|
4084
|
-
// hasMap, not hashMap >-).
|
|
4085
|
-
|
|
4086
4116
|
function ObservableMap(initialData, enhancer_, name_) {
|
|
4087
4117
|
var _this = this;
|
|
4088
4118
|
if (enhancer_ === void 0) {
|
|
@@ -4096,6 +4126,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4096
4126
|
this[$mobx] = ObservableMapMarker;
|
|
4097
4127
|
this.data_ = void 0;
|
|
4098
4128
|
this.hasMap_ = void 0;
|
|
4129
|
+
// hasMap, not hashMap >-).
|
|
4099
4130
|
this.keysAtom_ = void 0;
|
|
4100
4131
|
this.interceptors_ = void 0;
|
|
4101
4132
|
this.changeListeners_ = void 0;
|
|
@@ -4184,7 +4215,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4184
4215
|
transaction(function () {
|
|
4185
4216
|
var _this3$hasMap_$get;
|
|
4186
4217
|
_this3.keysAtom_.reportChanged();
|
|
4187
|
-
(_this3$hasMap_$get = _this3.hasMap_.get(key)) == null
|
|
4218
|
+
(_this3$hasMap_$get = _this3.hasMap_.get(key)) == null || _this3$hasMap_$get.setNewValue_(false);
|
|
4188
4219
|
var observable = _this3.data_.get(key);
|
|
4189
4220
|
observable.setNewValue_(undefined);
|
|
4190
4221
|
_this3.data_["delete"](key);
|
|
@@ -4234,7 +4265,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4234
4265
|
var observable = new ObservableValue(newValue, _this4.enhancer_, _this4.name_ + "." + stringifyKey(key) , false);
|
|
4235
4266
|
_this4.data_.set(key, observable);
|
|
4236
4267
|
newValue = observable.value_; // value might have been changed
|
|
4237
|
-
(_this4$hasMap_$get = _this4.hasMap_.get(key)) == null
|
|
4268
|
+
(_this4$hasMap_$get = _this4.hasMap_.get(key)) == null || _this4$hasMap_$get.setNewValue_(true);
|
|
4238
4269
|
_this4.keysAtom_.reportChanged();
|
|
4239
4270
|
});
|
|
4240
4271
|
var notifySpy = isSpyEnabled();
|
|
@@ -4303,7 +4334,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4303
4334
|
}
|
|
4304
4335
|
});
|
|
4305
4336
|
};
|
|
4306
|
-
_proto[
|
|
4337
|
+
_proto[Symbol.iterator] = function () {
|
|
4307
4338
|
return this.entries();
|
|
4308
4339
|
};
|
|
4309
4340
|
_proto.forEach = function forEach(callback, thisArg) {
|
|
@@ -4457,19 +4488,18 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4457
4488
|
_proto.intercept_ = function intercept_(handler) {
|
|
4458
4489
|
return registerInterceptor(this, handler);
|
|
4459
4490
|
};
|
|
4460
|
-
_createClass(ObservableMap, [{
|
|
4491
|
+
return _createClass(ObservableMap, [{
|
|
4461
4492
|
key: "size",
|
|
4462
4493
|
get: function get() {
|
|
4463
4494
|
this.keysAtom_.reportObserved();
|
|
4464
4495
|
return this.data_.size;
|
|
4465
4496
|
}
|
|
4466
4497
|
}, {
|
|
4467
|
-
key:
|
|
4498
|
+
key: Symbol.toStringTag,
|
|
4468
4499
|
get: function get() {
|
|
4469
4500
|
return "Map";
|
|
4470
4501
|
}
|
|
4471
4502
|
}]);
|
|
4472
|
-
return ObservableMap;
|
|
4473
4503
|
}();
|
|
4474
4504
|
// eslint-disable-next-line
|
|
4475
4505
|
var isObservableMap = /*#__PURE__*/createInstanceofPredicate("ObservableMap", ObservableMap);
|
|
@@ -4489,10 +4519,7 @@ function convertToMap(dataStructure) {
|
|
|
4489
4519
|
}
|
|
4490
4520
|
}
|
|
4491
4521
|
|
|
4492
|
-
var _Symbol$iterator$1, _Symbol$toStringTag$1;
|
|
4493
4522
|
var ObservableSetMarker = {};
|
|
4494
|
-
_Symbol$iterator$1 = Symbol.iterator;
|
|
4495
|
-
_Symbol$toStringTag$1 = Symbol.toStringTag;
|
|
4496
4523
|
var ObservableSet = /*#__PURE__*/function () {
|
|
4497
4524
|
function ObservableSet(initialData, enhancer, name_) {
|
|
4498
4525
|
var _this = this;
|
|
@@ -4563,7 +4590,6 @@ var ObservableSet = /*#__PURE__*/function () {
|
|
|
4563
4590
|
// ideally, value = change.value would be done here, so that values can be
|
|
4564
4591
|
// changed by interceptor. Same applies for other Set and Map api's.
|
|
4565
4592
|
}
|
|
4566
|
-
|
|
4567
4593
|
if (!this.has(value)) {
|
|
4568
4594
|
transaction(function () {
|
|
4569
4595
|
_this3.data_.add(_this3.enhancer_(value, undefined));
|
|
@@ -4669,6 +4695,47 @@ var ObservableSet = /*#__PURE__*/function () {
|
|
|
4669
4695
|
}
|
|
4670
4696
|
});
|
|
4671
4697
|
};
|
|
4698
|
+
_proto.intersection = function intersection(otherSet) {
|
|
4699
|
+
if (isES6Set(otherSet)) {
|
|
4700
|
+
return otherSet.intersection(this);
|
|
4701
|
+
} else {
|
|
4702
|
+
var dehancedSet = new Set(this);
|
|
4703
|
+
return dehancedSet.intersection(otherSet);
|
|
4704
|
+
}
|
|
4705
|
+
};
|
|
4706
|
+
_proto.union = function union(otherSet) {
|
|
4707
|
+
if (isES6Set(otherSet)) {
|
|
4708
|
+
return otherSet.union(this);
|
|
4709
|
+
} else {
|
|
4710
|
+
var dehancedSet = new Set(this);
|
|
4711
|
+
return dehancedSet.union(otherSet);
|
|
4712
|
+
}
|
|
4713
|
+
};
|
|
4714
|
+
_proto.difference = function difference(otherSet) {
|
|
4715
|
+
return new Set(this).difference(otherSet);
|
|
4716
|
+
};
|
|
4717
|
+
_proto.symmetricDifference = function symmetricDifference(otherSet) {
|
|
4718
|
+
if (isES6Set(otherSet)) {
|
|
4719
|
+
return otherSet.symmetricDifference(this);
|
|
4720
|
+
} else {
|
|
4721
|
+
var dehancedSet = new Set(this);
|
|
4722
|
+
return dehancedSet.symmetricDifference(otherSet);
|
|
4723
|
+
}
|
|
4724
|
+
};
|
|
4725
|
+
_proto.isSubsetOf = function isSubsetOf(otherSet) {
|
|
4726
|
+
return new Set(this).isSubsetOf(otherSet);
|
|
4727
|
+
};
|
|
4728
|
+
_proto.isSupersetOf = function isSupersetOf(otherSet) {
|
|
4729
|
+
return new Set(this).isSupersetOf(otherSet);
|
|
4730
|
+
};
|
|
4731
|
+
_proto.isDisjointFrom = function isDisjointFrom(otherSet) {
|
|
4732
|
+
if (isES6Set(otherSet)) {
|
|
4733
|
+
return otherSet.isDisjointFrom(this);
|
|
4734
|
+
} else {
|
|
4735
|
+
var dehancedSet = new Set(this);
|
|
4736
|
+
return dehancedSet.isDisjointFrom(otherSet);
|
|
4737
|
+
}
|
|
4738
|
+
};
|
|
4672
4739
|
_proto.replace = function replace(other) {
|
|
4673
4740
|
var _this5 = this;
|
|
4674
4741
|
if (isObservableSet(other)) {
|
|
@@ -4707,22 +4774,21 @@ var ObservableSet = /*#__PURE__*/function () {
|
|
|
4707
4774
|
_proto.toString = function toString() {
|
|
4708
4775
|
return "[object ObservableSet]";
|
|
4709
4776
|
};
|
|
4710
|
-
_proto[
|
|
4777
|
+
_proto[Symbol.iterator] = function () {
|
|
4711
4778
|
return this.values();
|
|
4712
4779
|
};
|
|
4713
|
-
_createClass(ObservableSet, [{
|
|
4780
|
+
return _createClass(ObservableSet, [{
|
|
4714
4781
|
key: "size",
|
|
4715
4782
|
get: function get() {
|
|
4716
4783
|
this.atom_.reportObserved();
|
|
4717
4784
|
return this.data_.size;
|
|
4718
4785
|
}
|
|
4719
4786
|
}, {
|
|
4720
|
-
key:
|
|
4787
|
+
key: Symbol.toStringTag,
|
|
4721
4788
|
get: function get() {
|
|
4722
4789
|
return "Set";
|
|
4723
4790
|
}
|
|
4724
4791
|
}]);
|
|
4725
|
-
return ObservableSet;
|
|
4726
4792
|
}();
|
|
4727
4793
|
// eslint-disable-next-line
|
|
4728
4794
|
var isObservableSet = /*#__PURE__*/createInstanceofPredicate("ObservableSet", ObservableSet);
|
|
@@ -5122,7 +5188,7 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
5122
5188
|
}
|
|
5123
5189
|
// Delete
|
|
5124
5190
|
try {
|
|
5125
|
-
var _this$pendingKeys_
|
|
5191
|
+
var _this$pendingKeys_;
|
|
5126
5192
|
startBatch();
|
|
5127
5193
|
var notify = hasListeners(this);
|
|
5128
5194
|
var notifySpy = "development" !== "production" && isSpyEnabled();
|
|
@@ -5160,7 +5226,7 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
5160
5226
|
this.keysAtom_.reportChanged();
|
|
5161
5227
|
// Notify "has" observers
|
|
5162
5228
|
// "in" as it may still exist in proto
|
|
5163
|
-
(_this$pendingKeys_ = this.pendingKeys_) == null
|
|
5229
|
+
(_this$pendingKeys_ = this.pendingKeys_) == null || (_this$pendingKeys_ = _this$pendingKeys_.get(key)) == null || _this$pendingKeys_.set(key in this.target_);
|
|
5164
5230
|
// Notify spies/listeners
|
|
5165
5231
|
if (notify || notifySpy) {
|
|
5166
5232
|
var _change2 = {
|
|
@@ -5201,7 +5267,7 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
5201
5267
|
return registerInterceptor(this, handler);
|
|
5202
5268
|
};
|
|
5203
5269
|
_proto.notifyPropertyAddition_ = function notifyPropertyAddition_(key, value) {
|
|
5204
|
-
var _this$pendingKeys_2
|
|
5270
|
+
var _this$pendingKeys_2;
|
|
5205
5271
|
var notify = hasListeners(this);
|
|
5206
5272
|
var notifySpy = isSpyEnabled();
|
|
5207
5273
|
if (notify || notifySpy) {
|
|
@@ -5223,7 +5289,7 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
5223
5289
|
spyReportEnd();
|
|
5224
5290
|
}
|
|
5225
5291
|
}
|
|
5226
|
-
(_this$pendingKeys_2 = this.pendingKeys_) == null
|
|
5292
|
+
(_this$pendingKeys_2 = this.pendingKeys_) == null || (_this$pendingKeys_2 = _this$pendingKeys_2.get(key)) == null || _this$pendingKeys_2.set(true);
|
|
5227
5293
|
// Notify "keys/entries/values" observers
|
|
5228
5294
|
this.keysAtom_.reportChanged();
|
|
5229
5295
|
};
|
|
@@ -5285,7 +5351,7 @@ function recordAnnotationApplied(adm, annotation, key) {
|
|
|
5285
5351
|
adm.appliedAnnotations_[key] = annotation;
|
|
5286
5352
|
}
|
|
5287
5353
|
// Remove applied decorator annotation so we don't try to apply it again in subclass constructor
|
|
5288
|
-
(_adm$target_$storedAn = adm.target_[storedAnnotationsSymbol]) == null
|
|
5354
|
+
(_adm$target_$storedAn = adm.target_[storedAnnotationsSymbol]) == null || delete _adm$target_$storedAn[key];
|
|
5289
5355
|
}
|
|
5290
5356
|
function assertAnnotable(adm, annotation, key) {
|
|
5291
5357
|
// Valid annotation
|
|
@@ -5365,8 +5431,7 @@ inherit(StubArray, Array.prototype);
|
|
|
5365
5431
|
// Weex proto freeze protection was here,
|
|
5366
5432
|
// but it is unclear why the hack is need as MobX never changed the prototype
|
|
5367
5433
|
// anyway, so removed it in V6
|
|
5368
|
-
var LegacyObservableArray = /*#__PURE__*/function (_StubArray
|
|
5369
|
-
_inheritsLoose(LegacyObservableArray, _StubArray);
|
|
5434
|
+
var LegacyObservableArray = /*#__PURE__*/function (_StubArray) {
|
|
5370
5435
|
function LegacyObservableArray(initialValues, enhancer, name, owned) {
|
|
5371
5436
|
var _this;
|
|
5372
5437
|
if (name === void 0) {
|
|
@@ -5378,8 +5443,8 @@ var LegacyObservableArray = /*#__PURE__*/function (_StubArray, _Symbol$toStringT
|
|
|
5378
5443
|
_this = _StubArray.call(this) || this;
|
|
5379
5444
|
initObservable(function () {
|
|
5380
5445
|
var adm = new ObservableArrayAdministration(name, enhancer, owned, true);
|
|
5381
|
-
adm.proxy_ =
|
|
5382
|
-
addHiddenFinalProp(
|
|
5446
|
+
adm.proxy_ = _this;
|
|
5447
|
+
addHiddenFinalProp(_this, $mobx, adm);
|
|
5383
5448
|
if (initialValues && initialValues.length) {
|
|
5384
5449
|
// @ts-ignore
|
|
5385
5450
|
_this.spliceWithArray(0, 0, initialValues);
|
|
@@ -5387,11 +5452,12 @@ var LegacyObservableArray = /*#__PURE__*/function (_StubArray, _Symbol$toStringT
|
|
|
5387
5452
|
if (safariPrototypeSetterInheritanceBug) {
|
|
5388
5453
|
// Seems that Safari won't use numeric prototype setter until any * numeric property is
|
|
5389
5454
|
// defined on the instance. After that it works fine, even if this property is deleted.
|
|
5390
|
-
Object.defineProperty(
|
|
5455
|
+
Object.defineProperty(_this, "0", ENTRY_0);
|
|
5391
5456
|
}
|
|
5392
5457
|
});
|
|
5393
5458
|
return _this;
|
|
5394
5459
|
}
|
|
5460
|
+
_inheritsLoose(LegacyObservableArray, _StubArray);
|
|
5395
5461
|
var _proto = LegacyObservableArray.prototype;
|
|
5396
5462
|
_proto.concat = function concat() {
|
|
5397
5463
|
this[$mobx].atom_.reportObserved();
|
|
@@ -5404,7 +5470,7 @@ var LegacyObservableArray = /*#__PURE__*/function (_StubArray, _Symbol$toStringT
|
|
|
5404
5470
|
return isObservableArray(a) ? a.slice() : a;
|
|
5405
5471
|
}));
|
|
5406
5472
|
};
|
|
5407
|
-
_proto[
|
|
5473
|
+
_proto[Symbol.iterator] = function () {
|
|
5408
5474
|
var self = this;
|
|
5409
5475
|
var nextIndex = 0;
|
|
5410
5476
|
return makeIterable({
|
|
@@ -5419,7 +5485,7 @@ var LegacyObservableArray = /*#__PURE__*/function (_StubArray, _Symbol$toStringT
|
|
|
5419
5485
|
}
|
|
5420
5486
|
});
|
|
5421
5487
|
};
|
|
5422
|
-
_createClass(LegacyObservableArray, [{
|
|
5488
|
+
return _createClass(LegacyObservableArray, [{
|
|
5423
5489
|
key: "length",
|
|
5424
5490
|
get: function get() {
|
|
5425
5491
|
return this[$mobx].getArrayLength_();
|
|
@@ -5428,13 +5494,12 @@ var LegacyObservableArray = /*#__PURE__*/function (_StubArray, _Symbol$toStringT
|
|
|
5428
5494
|
this[$mobx].setArrayLength_(newLength);
|
|
5429
5495
|
}
|
|
5430
5496
|
}, {
|
|
5431
|
-
key:
|
|
5497
|
+
key: Symbol.toStringTag,
|
|
5432
5498
|
get: function get() {
|
|
5433
5499
|
return "Array";
|
|
5434
5500
|
}
|
|
5435
5501
|
}]);
|
|
5436
|
-
|
|
5437
|
-
}(StubArray, Symbol.toStringTag, Symbol.iterator);
|
|
5502
|
+
}(StubArray);
|
|
5438
5503
|
Object.entries(arrayExtensions).forEach(function (_ref) {
|
|
5439
5504
|
var prop = _ref[0],
|
|
5440
5505
|
fn = _ref[1];
|