mobx 6.12.4 → 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 +17 -5
- package/dist/mobx.cjs.development.js +241 -170
- 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 +241 -170
- package/dist/mobx.esm.development.js.map +1 -1
- package/dist/mobx.esm.js +241 -170
- 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 +241 -170
- 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 +3 -2
- package/package.json +1 -1
- package/src/types/observablemap.ts +2 -1
- package/src/types/observableset.ts +48 -0
- package/src/utils/utils.ts +9 -2
|
@@ -207,10 +207,16 @@ function createInstanceofPredicate(name, theClass) {
|
|
|
207
207
|
};
|
|
208
208
|
}
|
|
209
209
|
function isES6Map(thing) {
|
|
210
|
-
return thing
|
|
210
|
+
return thing != null && Object.prototype.toString.call(thing) === "[object Map]";
|
|
211
|
+
}
|
|
212
|
+
function isPlainES6Map(thing) {
|
|
213
|
+
var mapProto = Object.getPrototypeOf(thing);
|
|
214
|
+
var objectProto = Object.getPrototypeOf(mapProto);
|
|
215
|
+
var nullProto = Object.getPrototypeOf(objectProto);
|
|
216
|
+
return nullProto === null;
|
|
211
217
|
}
|
|
212
218
|
function isES6Set(thing) {
|
|
213
|
-
return thing
|
|
219
|
+
return thing != null && Object.prototype.toString.call(thing) === "[object Set]";
|
|
214
220
|
}
|
|
215
221
|
var hasGetOwnPropertySymbols = typeof Object.getOwnPropertySymbols !== "undefined";
|
|
216
222
|
/**
|
|
@@ -261,99 +267,76 @@ var getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors || function get
|
|
|
261
267
|
return res;
|
|
262
268
|
};
|
|
263
269
|
|
|
264
|
-
function
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
Object.defineProperty(
|
|
277
|
-
writable:
|
|
278
|
-
});
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
287
|
-
target[key] = source[key];
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
return target;
|
|
292
|
-
};
|
|
293
|
-
return _extends.apply(this, arguments);
|
|
294
|
-
}
|
|
295
|
-
function _inheritsLoose(subClass, superClass) {
|
|
296
|
-
subClass.prototype = Object.create(superClass.prototype);
|
|
297
|
-
subClass.prototype.constructor = subClass;
|
|
298
|
-
_setPrototypeOf(subClass, superClass);
|
|
299
|
-
}
|
|
300
|
-
function _setPrototypeOf(o, p) {
|
|
301
|
-
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
302
|
-
o.__proto__ = p;
|
|
303
|
-
return o;
|
|
304
|
-
};
|
|
305
|
-
return _setPrototypeOf(o, p);
|
|
306
|
-
}
|
|
307
|
-
function _assertThisInitialized(self) {
|
|
308
|
-
if (self === void 0) {
|
|
309
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
310
|
-
}
|
|
311
|
-
return self;
|
|
312
|
-
}
|
|
313
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
314
|
-
if (!o) return;
|
|
315
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
316
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
317
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
318
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
319
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
320
|
-
}
|
|
321
|
-
function _arrayLikeToArray(arr, len) {
|
|
322
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
323
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
324
|
-
return arr2;
|
|
325
|
-
}
|
|
326
|
-
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
327
|
-
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
328
|
-
if (it) return (it = it.call(o)).next.bind(it);
|
|
329
|
-
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
330
|
-
if (it) o = it;
|
|
331
|
-
var i = 0;
|
|
270
|
+
function _arrayLikeToArray(r, a) {
|
|
271
|
+
(null == a || a > r.length) && (a = r.length);
|
|
272
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
273
|
+
return n;
|
|
274
|
+
}
|
|
275
|
+
function _defineProperties(e, r) {
|
|
276
|
+
for (var t = 0; t < r.length; t++) {
|
|
277
|
+
var o = r[t];
|
|
278
|
+
o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
function _createClass(e, r, t) {
|
|
282
|
+
return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
|
|
283
|
+
writable: !1
|
|
284
|
+
}), e;
|
|
285
|
+
}
|
|
286
|
+
function _createForOfIteratorHelperLoose(r, e) {
|
|
287
|
+
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
288
|
+
if (t) return (t = t.call(r)).next.bind(t);
|
|
289
|
+
if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) {
|
|
290
|
+
t && (r = t);
|
|
291
|
+
var o = 0;
|
|
332
292
|
return function () {
|
|
333
|
-
|
|
334
|
-
done:
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
value: o[i++]
|
|
293
|
+
return o >= r.length ? {
|
|
294
|
+
done: !0
|
|
295
|
+
} : {
|
|
296
|
+
done: !1,
|
|
297
|
+
value: r[o++]
|
|
339
298
|
};
|
|
340
299
|
};
|
|
341
300
|
}
|
|
342
301
|
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
343
302
|
}
|
|
344
|
-
function
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
303
|
+
function _extends() {
|
|
304
|
+
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
305
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
306
|
+
var t = arguments[e];
|
|
307
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
308
|
+
}
|
|
309
|
+
return n;
|
|
310
|
+
}, _extends.apply(null, arguments);
|
|
311
|
+
}
|
|
312
|
+
function _inheritsLoose(t, o) {
|
|
313
|
+
t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o);
|
|
314
|
+
}
|
|
315
|
+
function _setPrototypeOf(t, e) {
|
|
316
|
+
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
|
|
317
|
+
return t.__proto__ = e, t;
|
|
318
|
+
}, _setPrototypeOf(t, e);
|
|
319
|
+
}
|
|
320
|
+
function _toPrimitive(t, r) {
|
|
321
|
+
if ("object" != typeof t || !t) return t;
|
|
322
|
+
var e = t[Symbol.toPrimitive];
|
|
323
|
+
if (void 0 !== e) {
|
|
324
|
+
var i = e.call(t, r || "default");
|
|
325
|
+
if ("object" != typeof i) return i;
|
|
350
326
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
351
327
|
}
|
|
352
|
-
return (
|
|
328
|
+
return ("string" === r ? String : Number)(t);
|
|
353
329
|
}
|
|
354
|
-
function _toPropertyKey(
|
|
355
|
-
var
|
|
356
|
-
return
|
|
330
|
+
function _toPropertyKey(t) {
|
|
331
|
+
var i = _toPrimitive(t, "string");
|
|
332
|
+
return "symbol" == typeof i ? i : i + "";
|
|
333
|
+
}
|
|
334
|
+
function _unsupportedIterableToArray(r, a) {
|
|
335
|
+
if (r) {
|
|
336
|
+
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
337
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
338
|
+
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;
|
|
339
|
+
}
|
|
357
340
|
}
|
|
358
341
|
|
|
359
342
|
var storedAnnotationsSymbol = /*#__PURE__*/Symbol("mobx-stored-annotations");
|
|
@@ -426,8 +409,6 @@ function assert20223DecoratorType(context, types) {
|
|
|
426
409
|
|
|
427
410
|
var $mobx = /*#__PURE__*/Symbol("mobx administration");
|
|
428
411
|
var Atom = /*#__PURE__*/function () {
|
|
429
|
-
// for effective unobserving. BaseAtom has true, for extra optimization, so its onBecomeUnobserved never gets called, because it's not needed
|
|
430
|
-
|
|
431
412
|
/**
|
|
432
413
|
* Create a new atom. For debugging purposes it is recommended to give it a name.
|
|
433
414
|
* The onBecomeObserved and onBecomeUnobserved callbacks can be used for resource management.
|
|
@@ -438,16 +419,18 @@ var Atom = /*#__PURE__*/function () {
|
|
|
438
419
|
}
|
|
439
420
|
this.name_ = void 0;
|
|
440
421
|
this.isPendingUnobservation = false;
|
|
422
|
+
// for effective unobserving. BaseAtom has true, for extra optimization, so its onBecomeUnobserved never gets called, because it's not needed
|
|
441
423
|
this.isBeingObserved = false;
|
|
442
424
|
this.observers_ = new Set();
|
|
443
425
|
this.diffValue_ = 0;
|
|
444
426
|
this.lastAccessedBy_ = 0;
|
|
445
427
|
this.lowestObserverState_ = IDerivationState_.NOT_TRACKING_;
|
|
428
|
+
// onBecomeObservedListeners
|
|
446
429
|
this.onBOL = void 0;
|
|
430
|
+
// onBecomeUnobservedListeners
|
|
447
431
|
this.onBUOL = void 0;
|
|
448
432
|
this.name_ = name_;
|
|
449
433
|
}
|
|
450
|
-
// onBecomeObservedListeners
|
|
451
434
|
var _proto = Atom.prototype;
|
|
452
435
|
_proto.onBO = function onBO() {
|
|
453
436
|
if (this.onBOL) {
|
|
@@ -629,7 +612,6 @@ function make_(adm, key) {
|
|
|
629
612
|
}
|
|
630
613
|
return 0 /* MakeResult.Cancel */;
|
|
631
614
|
}
|
|
632
|
-
|
|
633
615
|
function extend_(adm, key, descriptor, proxyTrap) {
|
|
634
616
|
die("'" + this.annotationType_ + "' can only be used with 'makeObservable'");
|
|
635
617
|
}
|
|
@@ -662,12 +644,10 @@ function make_$1(adm, key, descriptor, source) {
|
|
|
662
644
|
// rest of the proto chain must be annotated already
|
|
663
645
|
return 1 /* MakeResult.Break */;
|
|
664
646
|
}
|
|
665
|
-
|
|
666
647
|
var actionDescriptor = createActionDescriptor(adm, this, key, descriptor, false);
|
|
667
648
|
defineProperty(source, key, actionDescriptor);
|
|
668
649
|
return 2 /* MakeResult.Continue */;
|
|
669
650
|
}
|
|
670
|
-
|
|
671
651
|
function extend_$1(adm, key, descriptor, proxyTrap) {
|
|
672
652
|
var actionDescriptor = createActionDescriptor(adm, this, key, descriptor);
|
|
673
653
|
return adm.defineProperty_(key, actionDescriptor, proxyTrap);
|
|
@@ -765,18 +745,15 @@ function make_$2(adm, key, descriptor, source) {
|
|
|
765
745
|
return 0 /* MakeResult.Cancel */;
|
|
766
746
|
}
|
|
767
747
|
}
|
|
768
|
-
|
|
769
748
|
if (isFlow(descriptor.value)) {
|
|
770
749
|
// A prototype could have been annotated already by other constructor,
|
|
771
750
|
// rest of the proto chain must be annotated already
|
|
772
751
|
return 1 /* MakeResult.Break */;
|
|
773
752
|
}
|
|
774
|
-
|
|
775
753
|
var flowDescriptor = createFlowDescriptor(adm, this, key, descriptor, false, false);
|
|
776
754
|
defineProperty(source, key, flowDescriptor);
|
|
777
755
|
return 2 /* MakeResult.Continue */;
|
|
778
756
|
}
|
|
779
|
-
|
|
780
757
|
function extend_$2(adm, key, descriptor, proxyTrap) {
|
|
781
758
|
var _this$options_2;
|
|
782
759
|
var flowDescriptor = createFlowDescriptor(adm, this, key, descriptor, (_this$options_2 = this.options_) == null ? void 0 : _this$options_2.bound);
|
|
@@ -853,7 +830,6 @@ function createComputedAnnotation(name, options) {
|
|
|
853
830
|
function make_$3(adm, key, descriptor) {
|
|
854
831
|
return this.extend_(adm, key, descriptor, false) === null ? 0 /* MakeResult.Cancel */ : 1 /* MakeResult.Break */;
|
|
855
832
|
}
|
|
856
|
-
|
|
857
833
|
function extend_$3(adm, key, descriptor, proxyTrap) {
|
|
858
834
|
assertComputedDescriptor(adm, this, key, descriptor);
|
|
859
835
|
return adm.defineComputedProperty_(key, _extends({}, this.options_, {
|
|
@@ -901,7 +877,6 @@ function createObservableAnnotation(name, options) {
|
|
|
901
877
|
function make_$4(adm, key, descriptor) {
|
|
902
878
|
return this.extend_(adm, key, descriptor, false) === null ? 0 /* MakeResult.Cancel */ : 1 /* MakeResult.Break */;
|
|
903
879
|
}
|
|
904
|
-
|
|
905
880
|
function extend_$4(adm, key, descriptor, proxyTrap) {
|
|
906
881
|
var _this$options_$enhanc, _this$options_;
|
|
907
882
|
assertObservableDescriptor(adm, this, key, descriptor);
|
|
@@ -1321,11 +1296,8 @@ function allowStateChangesEnd(prev) {
|
|
|
1321
1296
|
globalState.allowStateChanges = prev;
|
|
1322
1297
|
}
|
|
1323
1298
|
|
|
1324
|
-
var _Symbol$toPrimitive;
|
|
1325
1299
|
var CREATE = "create";
|
|
1326
|
-
_Symbol$toPrimitive = Symbol.toPrimitive;
|
|
1327
1300
|
var ObservableValue = /*#__PURE__*/function (_Atom) {
|
|
1328
|
-
_inheritsLoose(ObservableValue, _Atom);
|
|
1329
1301
|
function ObservableValue(value, enhancer, name_, notifySpy, equals) {
|
|
1330
1302
|
var _this;
|
|
1331
1303
|
if (name_ === void 0) {
|
|
@@ -1354,7 +1326,7 @@ var ObservableValue = /*#__PURE__*/function (_Atom) {
|
|
|
1354
1326
|
// only notify spy if this is a stand-alone observable
|
|
1355
1327
|
spyReport({
|
|
1356
1328
|
type: CREATE,
|
|
1357
|
-
object:
|
|
1329
|
+
object: _this,
|
|
1358
1330
|
observableKind: "value",
|
|
1359
1331
|
debugObjectName: _this.name_,
|
|
1360
1332
|
newValue: "" + _this.value_
|
|
@@ -1362,6 +1334,7 @@ var ObservableValue = /*#__PURE__*/function (_Atom) {
|
|
|
1362
1334
|
}
|
|
1363
1335
|
return _this;
|
|
1364
1336
|
}
|
|
1337
|
+
_inheritsLoose(ObservableValue, _Atom);
|
|
1365
1338
|
var _proto = ObservableValue.prototype;
|
|
1366
1339
|
_proto.dehanceValue = function dehanceValue(value) {
|
|
1367
1340
|
if (this.dehancer !== undefined) {
|
|
@@ -1453,14 +1426,13 @@ var ObservableValue = /*#__PURE__*/function (_Atom) {
|
|
|
1453
1426
|
_proto.valueOf = function valueOf() {
|
|
1454
1427
|
return toPrimitive(this.get());
|
|
1455
1428
|
};
|
|
1456
|
-
_proto[
|
|
1429
|
+
_proto[Symbol.toPrimitive] = function () {
|
|
1457
1430
|
return this.valueOf();
|
|
1458
1431
|
};
|
|
1459
1432
|
return ObservableValue;
|
|
1460
1433
|
}(Atom);
|
|
1461
1434
|
var isObservableValue = /*#__PURE__*/createInstanceofPredicate("ObservableValue", ObservableValue);
|
|
1462
1435
|
|
|
1463
|
-
var _Symbol$toPrimitive$1;
|
|
1464
1436
|
function getFlag(flags, mask) {
|
|
1465
1437
|
return !!(flags & mask);
|
|
1466
1438
|
}
|
|
@@ -1491,13 +1463,7 @@ function setFlag(flags, mask, newValue) {
|
|
|
1491
1463
|
*
|
|
1492
1464
|
* If at any point it's outside batch and it isn't observed: reset everything and go to 1.
|
|
1493
1465
|
*/
|
|
1494
|
-
_Symbol$toPrimitive$1 = Symbol.toPrimitive;
|
|
1495
1466
|
var ComputedValue = /*#__PURE__*/function () {
|
|
1496
|
-
// nodes we are looking at. Our value depends on these nodes
|
|
1497
|
-
// during tracking it's an array with new observed observers
|
|
1498
|
-
|
|
1499
|
-
// N.B: unminified as it is used by MST
|
|
1500
|
-
|
|
1501
1467
|
/**
|
|
1502
1468
|
* Create a new computed value based on a function expression.
|
|
1503
1469
|
*
|
|
@@ -1513,7 +1479,9 @@ var ComputedValue = /*#__PURE__*/function () {
|
|
|
1513
1479
|
function ComputedValue(options) {
|
|
1514
1480
|
this.dependenciesState_ = IDerivationState_.NOT_TRACKING_;
|
|
1515
1481
|
this.observing_ = [];
|
|
1482
|
+
// nodes we are looking at. Our value depends on these nodes
|
|
1516
1483
|
this.newObserving_ = null;
|
|
1484
|
+
// during tracking it's an array with new observed observers
|
|
1517
1485
|
this.observers_ = new Set();
|
|
1518
1486
|
this.diffValue_ = 0;
|
|
1519
1487
|
this.runId_ = 0;
|
|
@@ -1525,6 +1493,7 @@ var ComputedValue = /*#__PURE__*/function () {
|
|
|
1525
1493
|
this.triggeredBy_ = void 0;
|
|
1526
1494
|
this.flags_ = 0;
|
|
1527
1495
|
this.derivation = void 0;
|
|
1496
|
+
// N.B: unminified as it is used by MST
|
|
1528
1497
|
this.setter_ = void 0;
|
|
1529
1498
|
this.isTracing_ = TraceMode.NONE;
|
|
1530
1499
|
this.scope_ = void 0;
|
|
@@ -1706,10 +1675,10 @@ var ComputedValue = /*#__PURE__*/function () {
|
|
|
1706
1675
|
_proto.valueOf = function valueOf() {
|
|
1707
1676
|
return toPrimitive(this.get());
|
|
1708
1677
|
};
|
|
1709
|
-
_proto[
|
|
1678
|
+
_proto[Symbol.toPrimitive] = function () {
|
|
1710
1679
|
return this.valueOf();
|
|
1711
1680
|
};
|
|
1712
|
-
_createClass(ComputedValue, [{
|
|
1681
|
+
return _createClass(ComputedValue, [{
|
|
1713
1682
|
key: "isComputing",
|
|
1714
1683
|
get: function get() {
|
|
1715
1684
|
return getFlag(this.flags_, ComputedValue.isComputingMask_);
|
|
@@ -1742,7 +1711,6 @@ var ComputedValue = /*#__PURE__*/function () {
|
|
|
1742
1711
|
this.flags_ = setFlag(this.flags_, ComputedValue.isPendingUnobservationMask_, newValue);
|
|
1743
1712
|
}
|
|
1744
1713
|
}]);
|
|
1745
|
-
return ComputedValue;
|
|
1746
1714
|
}();
|
|
1747
1715
|
ComputedValue.isComputingMask_ = 1;
|
|
1748
1716
|
ComputedValue.isRunningSetterMask_ = 2;
|
|
@@ -1781,7 +1749,6 @@ var CaughtException = function CaughtException(cause) {
|
|
|
1781
1749
|
this.cause = cause;
|
|
1782
1750
|
// Empty
|
|
1783
1751
|
};
|
|
1784
|
-
|
|
1785
1752
|
function isCaughtException(e) {
|
|
1786
1753
|
return e instanceof CaughtException;
|
|
1787
1754
|
}
|
|
@@ -1845,7 +1812,6 @@ function shouldCompute(derivation) {
|
|
|
1845
1812
|
function isComputingDerivation() {
|
|
1846
1813
|
return globalState.trackingDerivation !== null; // filter out actions inside computations
|
|
1847
1814
|
}
|
|
1848
|
-
|
|
1849
1815
|
function checkIfStateModificationsAreAllowed(atom) {
|
|
1850
1816
|
var hasObservers = atom.observers_.size > 0;
|
|
1851
1817
|
// Should not be possible to change observed state outside strict mode, except during initialization, see #563
|
|
@@ -2016,28 +1982,113 @@ function changeDependenciesStateTo0(derivation) {
|
|
|
2016
1982
|
*/
|
|
2017
1983
|
var persistentKeys = ["mobxGuid", "spyListeners", "enforceActions", "computedRequiresReaction", "reactionRequiresObservable", "observableRequiresReaction", "allowStateReads", "disableErrorBoundaries", "runId", "UNCHANGED", "useProxies"];
|
|
2018
1984
|
var MobXGlobals = function MobXGlobals() {
|
|
1985
|
+
/**
|
|
1986
|
+
* MobXGlobals version.
|
|
1987
|
+
* MobX compatiblity with other versions loaded in memory as long as this version matches.
|
|
1988
|
+
* It indicates that the global state still stores similar information
|
|
1989
|
+
*
|
|
1990
|
+
* N.B: this version is unrelated to the package version of MobX, and is only the version of the
|
|
1991
|
+
* internal state storage of MobX, and can be the same across many different package versions
|
|
1992
|
+
*/
|
|
2019
1993
|
this.version = 6;
|
|
1994
|
+
/**
|
|
1995
|
+
* globally unique token to signal unchanged
|
|
1996
|
+
*/
|
|
2020
1997
|
this.UNCHANGED = {};
|
|
1998
|
+
/**
|
|
1999
|
+
* Currently running derivation
|
|
2000
|
+
*/
|
|
2021
2001
|
this.trackingDerivation = null;
|
|
2002
|
+
/**
|
|
2003
|
+
* Currently running reaction. This determines if we currently have a reactive context.
|
|
2004
|
+
* (Tracking derivation is also set for temporal tracking of computed values inside actions,
|
|
2005
|
+
* but trackingReaction can only be set by a form of Reaction)
|
|
2006
|
+
*/
|
|
2022
2007
|
this.trackingContext = null;
|
|
2008
|
+
/**
|
|
2009
|
+
* Each time a derivation is tracked, it is assigned a unique run-id
|
|
2010
|
+
*/
|
|
2023
2011
|
this.runId = 0;
|
|
2012
|
+
/**
|
|
2013
|
+
* 'guid' for general purpose. Will be persisted amongst resets.
|
|
2014
|
+
*/
|
|
2024
2015
|
this.mobxGuid = 0;
|
|
2016
|
+
/**
|
|
2017
|
+
* Are we in a batch block? (and how many of them)
|
|
2018
|
+
*/
|
|
2025
2019
|
this.inBatch = 0;
|
|
2020
|
+
/**
|
|
2021
|
+
* Observables that don't have observers anymore, and are about to be
|
|
2022
|
+
* suspended, unless somebody else accesses it in the same batch
|
|
2023
|
+
*
|
|
2024
|
+
* @type {IObservable[]}
|
|
2025
|
+
*/
|
|
2026
2026
|
this.pendingUnobservations = [];
|
|
2027
|
+
/**
|
|
2028
|
+
* List of scheduled, not yet executed, reactions.
|
|
2029
|
+
*/
|
|
2027
2030
|
this.pendingReactions = [];
|
|
2031
|
+
/**
|
|
2032
|
+
* Are we currently processing reactions?
|
|
2033
|
+
*/
|
|
2028
2034
|
this.isRunningReactions = false;
|
|
2035
|
+
/**
|
|
2036
|
+
* Is it allowed to change observables at this point?
|
|
2037
|
+
* In general, MobX doesn't allow that when running computations and React.render.
|
|
2038
|
+
* To ensure that those functions stay pure.
|
|
2039
|
+
*/
|
|
2029
2040
|
this.allowStateChanges = false;
|
|
2041
|
+
/**
|
|
2042
|
+
* Is it allowed to read observables at this point?
|
|
2043
|
+
* Used to hold the state needed for `observableRequiresReaction`
|
|
2044
|
+
*/
|
|
2030
2045
|
this.allowStateReads = true;
|
|
2046
|
+
/**
|
|
2047
|
+
* If strict mode is enabled, state changes are by default not allowed
|
|
2048
|
+
*/
|
|
2031
2049
|
this.enforceActions = true;
|
|
2050
|
+
/**
|
|
2051
|
+
* Spy callbacks
|
|
2052
|
+
*/
|
|
2032
2053
|
this.spyListeners = [];
|
|
2054
|
+
/**
|
|
2055
|
+
* Globally attached error handlers that react specifically to errors in reactions
|
|
2056
|
+
*/
|
|
2033
2057
|
this.globalReactionErrorHandlers = [];
|
|
2058
|
+
/**
|
|
2059
|
+
* Warn if computed values are accessed outside a reactive context
|
|
2060
|
+
*/
|
|
2034
2061
|
this.computedRequiresReaction = false;
|
|
2062
|
+
/**
|
|
2063
|
+
* (Experimental)
|
|
2064
|
+
* Warn if you try to create to derivation / reactive context without accessing any observable.
|
|
2065
|
+
*/
|
|
2035
2066
|
this.reactionRequiresObservable = false;
|
|
2067
|
+
/**
|
|
2068
|
+
* (Experimental)
|
|
2069
|
+
* Warn if observables are accessed outside a reactive context
|
|
2070
|
+
*/
|
|
2036
2071
|
this.observableRequiresReaction = false;
|
|
2072
|
+
/*
|
|
2073
|
+
* Don't catch and rethrow exceptions. This is useful for inspecting the state of
|
|
2074
|
+
* the stack when an exception occurs while debugging.
|
|
2075
|
+
*/
|
|
2037
2076
|
this.disableErrorBoundaries = false;
|
|
2077
|
+
/*
|
|
2078
|
+
* If true, we are already handling an exception in an action. Any errors in reactions should be suppressed, as
|
|
2079
|
+
* they are not the cause, see: https://github.com/mobxjs/mobx/issues/1836
|
|
2080
|
+
*/
|
|
2038
2081
|
this.suppressReactionErrors = false;
|
|
2039
2082
|
this.useProxies = true;
|
|
2083
|
+
/*
|
|
2084
|
+
* print warnings about code that would fail if proxies weren't available
|
|
2085
|
+
*/
|
|
2040
2086
|
this.verifyProxies = false;
|
|
2087
|
+
/**
|
|
2088
|
+
* False forces all object's descriptors to
|
|
2089
|
+
* writable: true
|
|
2090
|
+
* configurable: true
|
|
2091
|
+
*/
|
|
2041
2092
|
this.safeDescriptors = true;
|
|
2042
2093
|
};
|
|
2043
2094
|
var canMergeGlobalState = true;
|
|
@@ -2134,7 +2185,6 @@ function addObserver(observable, node) {
|
|
|
2134
2185
|
// invariantObservers(observable);
|
|
2135
2186
|
// invariant(observable._observers.indexOf(node) !== -1, "INTERNAL ERROR didn't add node");
|
|
2136
2187
|
}
|
|
2137
|
-
|
|
2138
2188
|
function removeObserver(observable, node) {
|
|
2139
2189
|
// invariant(globalState.inBatch > 0, "INTERNAL ERROR, remove should be called only inside batch");
|
|
2140
2190
|
// invariant(observable._observers.indexOf(node) !== -1, "INTERNAL ERROR remove already removed node");
|
|
@@ -2147,7 +2197,6 @@ function removeObserver(observable, node) {
|
|
|
2147
2197
|
// invariantObservers(observable);
|
|
2148
2198
|
// invariant(observable._observers.indexOf(node) === -1, "INTERNAL ERROR remove already removed node2");
|
|
2149
2199
|
}
|
|
2150
|
-
|
|
2151
2200
|
function queueForUnobservation(observable) {
|
|
2152
2201
|
if (observable.isPendingUnobservation === false) {
|
|
2153
2202
|
// invariant(observable._observers.length === 0, "INTERNAL ERROR, should only queue for unobservation unobserved observables");
|
|
@@ -2285,7 +2334,6 @@ function propagateMaybeChanged(observable) {
|
|
|
2285
2334
|
});
|
|
2286
2335
|
// invariantLOS(observable, "maybe end");
|
|
2287
2336
|
}
|
|
2288
|
-
|
|
2289
2337
|
function logTraceInfo(derivation, observable) {
|
|
2290
2338
|
console.log("[mobx.trace] '" + derivation.name_ + "' is invalidated due to a change in: '" + observable.name_ + "'");
|
|
2291
2339
|
if (derivation.isTracing_ === TraceMode.BREAK) {
|
|
@@ -2309,8 +2357,6 @@ function printDepTree(tree, lines, depth) {
|
|
|
2309
2357
|
}
|
|
2310
2358
|
|
|
2311
2359
|
var Reaction = /*#__PURE__*/function () {
|
|
2312
|
-
// nodes we are looking at. Our value depends on these nodes
|
|
2313
|
-
|
|
2314
2360
|
function Reaction(name_, onInvalidate_, errorHandler_, requiresObservable_) {
|
|
2315
2361
|
if (name_ === void 0) {
|
|
2316
2362
|
name_ = "Reaction@" + getNextId() ;
|
|
@@ -2320,6 +2366,7 @@ var Reaction = /*#__PURE__*/function () {
|
|
|
2320
2366
|
this.errorHandler_ = void 0;
|
|
2321
2367
|
this.requiresObservable_ = void 0;
|
|
2322
2368
|
this.observing_ = [];
|
|
2369
|
+
// nodes we are looking at. Our value depends on these nodes
|
|
2323
2370
|
this.newObserving_ = [];
|
|
2324
2371
|
this.dependenciesState_ = IDerivationState_.NOT_TRACKING_;
|
|
2325
2372
|
this.diffValue_ = 0;
|
|
@@ -2382,7 +2429,6 @@ var Reaction = /*#__PURE__*/function () {
|
|
|
2382
2429
|
return;
|
|
2383
2430
|
// console.warn("Reaction already disposed") // Note: Not a warning / error in mobx 4 either
|
|
2384
2431
|
}
|
|
2385
|
-
|
|
2386
2432
|
startBatch();
|
|
2387
2433
|
var notify = isSpyEnabled();
|
|
2388
2434
|
var startTime;
|
|
@@ -2457,9 +2503,9 @@ var Reaction = /*#__PURE__*/function () {
|
|
|
2457
2503
|
var _this2 = this;
|
|
2458
2504
|
var dispose = function dispose() {
|
|
2459
2505
|
_this2.dispose();
|
|
2460
|
-
abortSignal == null
|
|
2506
|
+
abortSignal == null || abortSignal.removeEventListener == null || abortSignal.removeEventListener("abort", dispose);
|
|
2461
2507
|
};
|
|
2462
|
-
abortSignal == null
|
|
2508
|
+
abortSignal == null || abortSignal.addEventListener == null || abortSignal.addEventListener("abort", dispose);
|
|
2463
2509
|
dispose[$mobx] = this;
|
|
2464
2510
|
return dispose;
|
|
2465
2511
|
};
|
|
@@ -2511,7 +2557,6 @@ function runReactionsHelper() {
|
|
|
2511
2557
|
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]) );
|
|
2512
2558
|
allReactions.splice(0); // clear reactions
|
|
2513
2559
|
}
|
|
2514
|
-
|
|
2515
2560
|
var remainingReactions = allReactions.splice(0);
|
|
2516
2561
|
for (var i = 0, l = remainingReactions.length; i < l; i++) {
|
|
2517
2562
|
remainingReactions[i].runReaction_();
|
|
@@ -2639,7 +2684,7 @@ function isAction(thing) {
|
|
|
2639
2684
|
* @returns disposer function, which can be used to stop the view from being updated in the future.
|
|
2640
2685
|
*/
|
|
2641
2686
|
function autorun(view, opts) {
|
|
2642
|
-
var _opts$name, _opts, _opts2,
|
|
2687
|
+
var _opts$name, _opts, _opts2, _opts3;
|
|
2643
2688
|
if (opts === void 0) {
|
|
2644
2689
|
opts = EMPTY_OBJECT;
|
|
2645
2690
|
}
|
|
@@ -2678,7 +2723,7 @@ function autorun(view, opts) {
|
|
|
2678
2723
|
function reactionRunner() {
|
|
2679
2724
|
view(reaction);
|
|
2680
2725
|
}
|
|
2681
|
-
if (!((_opts2 = opts) != null && (_opts2
|
|
2726
|
+
if (!((_opts2 = opts) != null && (_opts2 = _opts2.signal) != null && _opts2.aborted)) {
|
|
2682
2727
|
reaction.schedule_();
|
|
2683
2728
|
}
|
|
2684
2729
|
return reaction.getDisposer_((_opts3 = opts) == null ? void 0 : _opts3.signal);
|
|
@@ -2692,7 +2737,7 @@ function createSchedulerFromOptions(opts) {
|
|
|
2692
2737
|
} : run;
|
|
2693
2738
|
}
|
|
2694
2739
|
function reaction(expression, effect, opts) {
|
|
2695
|
-
var _opts$name2, _opts4,
|
|
2740
|
+
var _opts$name2, _opts4, _opts5;
|
|
2696
2741
|
if (opts === void 0) {
|
|
2697
2742
|
opts = EMPTY_OBJECT;
|
|
2698
2743
|
}
|
|
@@ -2741,7 +2786,7 @@ function reaction(expression, effect, opts) {
|
|
|
2741
2786
|
}
|
|
2742
2787
|
firstTime = false;
|
|
2743
2788
|
}
|
|
2744
|
-
if (!((_opts4 = opts) != null && (_opts4
|
|
2789
|
+
if (!((_opts4 = opts) != null && (_opts4 = _opts4.signal) != null && _opts4.aborted)) {
|
|
2745
2790
|
r.schedule_();
|
|
2746
2791
|
}
|
|
2747
2792
|
return r.getDisposer_((_opts5 = opts) == null ? void 0 : _opts5.signal);
|
|
@@ -2950,7 +2995,6 @@ var flow = /*#__PURE__*/Object.assign(function flow(arg1, arg2) {
|
|
|
2950
2995
|
}
|
|
2951
2996
|
onFulfilled(undefined); // kick off the process
|
|
2952
2997
|
});
|
|
2953
|
-
|
|
2954
2998
|
promise.cancel = action(name + " - runid: " + runId + " - cancel", function () {
|
|
2955
2999
|
try {
|
|
2956
3000
|
if (pendingPromise) {
|
|
@@ -2968,7 +3012,6 @@ var flow = /*#__PURE__*/Object.assign(function flow(arg1, arg2) {
|
|
|
2968
3012
|
rejector(e); // there could be a throwing finally block
|
|
2969
3013
|
}
|
|
2970
3014
|
});
|
|
2971
|
-
|
|
2972
3015
|
return promise;
|
|
2973
3016
|
};
|
|
2974
3017
|
res.isMobXFlow = true;
|
|
@@ -2983,7 +3026,6 @@ function cancelPromise(promise) {
|
|
|
2983
3026
|
function flowResult(result) {
|
|
2984
3027
|
return result; // just tricking TypeScript :)
|
|
2985
3028
|
}
|
|
2986
|
-
|
|
2987
3029
|
function isFlow(fn) {
|
|
2988
3030
|
return (fn == null ? void 0 : fn.isMobXFlow) === true;
|
|
2989
3031
|
}
|
|
@@ -3405,10 +3447,10 @@ function whenPromise(predicate, opts) {
|
|
|
3405
3447
|
disposer();
|
|
3406
3448
|
reject(new Error("WHEN_ABORTED"));
|
|
3407
3449
|
};
|
|
3408
|
-
opts == null
|
|
3450
|
+
opts == null || (_opts$signal2 = opts.signal) == null || _opts$signal2.addEventListener == null || _opts$signal2.addEventListener("abort", abort);
|
|
3409
3451
|
})["finally"](function () {
|
|
3410
3452
|
var _opts$signal3;
|
|
3411
|
-
return opts == null
|
|
3453
|
+
return opts == null || (_opts$signal3 = opts.signal) == null || _opts$signal3.removeEventListener == null ? void 0 : _opts$signal3.removeEventListener("abort", abort);
|
|
3412
3454
|
});
|
|
3413
3455
|
res.cancel = cancel;
|
|
3414
3456
|
return res;
|
|
@@ -3625,8 +3667,6 @@ var arrayTraps = {
|
|
|
3625
3667
|
}
|
|
3626
3668
|
};
|
|
3627
3669
|
var ObservableArrayAdministration = /*#__PURE__*/function () {
|
|
3628
|
-
// this is the prop that gets proxied, so can't replace it!
|
|
3629
|
-
|
|
3630
3670
|
function ObservableArrayAdministration(name, enhancer, owned_, legacyMode_) {
|
|
3631
3671
|
if (name === void 0) {
|
|
3632
3672
|
name = "ObservableArray@" + getNextId() ;
|
|
@@ -3635,6 +3675,7 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
|
|
|
3635
3675
|
this.legacyMode_ = void 0;
|
|
3636
3676
|
this.atom_ = void 0;
|
|
3637
3677
|
this.values_ = [];
|
|
3678
|
+
// this is the prop that gets proxied, so can't replace it!
|
|
3638
3679
|
this.interceptors_ = void 0;
|
|
3639
3680
|
this.changeListeners_ = void 0;
|
|
3640
3681
|
this.enhancer_ = void 0;
|
|
@@ -3755,7 +3796,6 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
|
|
|
3755
3796
|
var lengthDelta = newItems.length - deleteCount;
|
|
3756
3797
|
this.updateArrayLength_(length, lengthDelta); // checks if internal array wasn't modified
|
|
3757
3798
|
}
|
|
3758
|
-
|
|
3759
3799
|
var res = this.spliceItemsIntoValues_(index, deleteCount, newItems);
|
|
3760
3800
|
if (deleteCount !== 0 || newItems.length !== 0) {
|
|
3761
3801
|
this.notifyArraySplice_(index, newItems, res);
|
|
@@ -3855,6 +3895,7 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
|
|
|
3855
3895
|
var change = interceptChange(this, {
|
|
3856
3896
|
type: UPDATE,
|
|
3857
3897
|
object: this.proxy_,
|
|
3898
|
+
// since "this" is the real array we need to pass its proxy
|
|
3858
3899
|
index: index,
|
|
3859
3900
|
newValue: newValue
|
|
3860
3901
|
});
|
|
@@ -4070,17 +4111,12 @@ function isObservableArray(thing) {
|
|
|
4070
4111
|
return isObject(thing) && isObservableArrayAdministration(thing[$mobx]);
|
|
4071
4112
|
}
|
|
4072
4113
|
|
|
4073
|
-
var _Symbol$iterator, _Symbol$toStringTag;
|
|
4074
4114
|
var ObservableMapMarker = {};
|
|
4075
4115
|
var ADD = "add";
|
|
4076
4116
|
var DELETE = "delete";
|
|
4077
4117
|
// just extend Map? See also https://gist.github.com/nestharus/13b4d74f2ef4a2f4357dbd3fc23c1e54
|
|
4078
4118
|
// But: https://github.com/mobxjs/mobx/issues/1556
|
|
4079
|
-
_Symbol$iterator = Symbol.iterator;
|
|
4080
|
-
_Symbol$toStringTag = Symbol.toStringTag;
|
|
4081
4119
|
var ObservableMap = /*#__PURE__*/function () {
|
|
4082
|
-
// hasMap, not hashMap >-).
|
|
4083
|
-
|
|
4084
4120
|
function ObservableMap(initialData, enhancer_, name_) {
|
|
4085
4121
|
var _this = this;
|
|
4086
4122
|
if (enhancer_ === void 0) {
|
|
@@ -4094,6 +4130,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4094
4130
|
this[$mobx] = ObservableMapMarker;
|
|
4095
4131
|
this.data_ = void 0;
|
|
4096
4132
|
this.hasMap_ = void 0;
|
|
4133
|
+
// hasMap, not hashMap >-).
|
|
4097
4134
|
this.keysAtom_ = void 0;
|
|
4098
4135
|
this.interceptors_ = void 0;
|
|
4099
4136
|
this.changeListeners_ = void 0;
|
|
@@ -4182,7 +4219,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4182
4219
|
transaction(function () {
|
|
4183
4220
|
var _this3$hasMap_$get;
|
|
4184
4221
|
_this3.keysAtom_.reportChanged();
|
|
4185
|
-
(_this3$hasMap_$get = _this3.hasMap_.get(key)) == null
|
|
4222
|
+
(_this3$hasMap_$get = _this3.hasMap_.get(key)) == null || _this3$hasMap_$get.setNewValue_(false);
|
|
4186
4223
|
var observable = _this3.data_.get(key);
|
|
4187
4224
|
observable.setNewValue_(undefined);
|
|
4188
4225
|
_this3.data_["delete"](key);
|
|
@@ -4232,7 +4269,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4232
4269
|
var observable = new ObservableValue(newValue, _this4.enhancer_, _this4.name_ + "." + stringifyKey(key) , false);
|
|
4233
4270
|
_this4.data_.set(key, observable);
|
|
4234
4271
|
newValue = observable.value_; // value might have been changed
|
|
4235
|
-
(_this4$hasMap_$get = _this4.hasMap_.get(key)) == null
|
|
4272
|
+
(_this4$hasMap_$get = _this4.hasMap_.get(key)) == null || _this4$hasMap_$get.setNewValue_(true);
|
|
4236
4273
|
_this4.keysAtom_.reportChanged();
|
|
4237
4274
|
});
|
|
4238
4275
|
var notifySpy = isSpyEnabled();
|
|
@@ -4301,7 +4338,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4301
4338
|
}
|
|
4302
4339
|
});
|
|
4303
4340
|
};
|
|
4304
|
-
_proto[
|
|
4341
|
+
_proto[Symbol.iterator] = function () {
|
|
4305
4342
|
return this.entries();
|
|
4306
4343
|
};
|
|
4307
4344
|
_proto.forEach = function forEach(callback, thisArg) {
|
|
@@ -4330,7 +4367,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4330
4367
|
return _this5.set(key, value);
|
|
4331
4368
|
});
|
|
4332
4369
|
} else if (isES6Map(other)) {
|
|
4333
|
-
if (other
|
|
4370
|
+
if (!isPlainES6Map(other)) {
|
|
4334
4371
|
die(19, other);
|
|
4335
4372
|
}
|
|
4336
4373
|
other.forEach(function (value, key) {
|
|
@@ -4455,19 +4492,18 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4455
4492
|
_proto.intercept_ = function intercept_(handler) {
|
|
4456
4493
|
return registerInterceptor(this, handler);
|
|
4457
4494
|
};
|
|
4458
|
-
_createClass(ObservableMap, [{
|
|
4495
|
+
return _createClass(ObservableMap, [{
|
|
4459
4496
|
key: "size",
|
|
4460
4497
|
get: function get() {
|
|
4461
4498
|
this.keysAtom_.reportObserved();
|
|
4462
4499
|
return this.data_.size;
|
|
4463
4500
|
}
|
|
4464
4501
|
}, {
|
|
4465
|
-
key:
|
|
4502
|
+
key: Symbol.toStringTag,
|
|
4466
4503
|
get: function get() {
|
|
4467
4504
|
return "Map";
|
|
4468
4505
|
}
|
|
4469
4506
|
}]);
|
|
4470
|
-
return ObservableMap;
|
|
4471
4507
|
}();
|
|
4472
4508
|
// eslint-disable-next-line
|
|
4473
4509
|
var isObservableMap = /*#__PURE__*/createInstanceofPredicate("ObservableMap", ObservableMap);
|
|
@@ -4487,10 +4523,7 @@ function convertToMap(dataStructure) {
|
|
|
4487
4523
|
}
|
|
4488
4524
|
}
|
|
4489
4525
|
|
|
4490
|
-
var _Symbol$iterator$1, _Symbol$toStringTag$1;
|
|
4491
4526
|
var ObservableSetMarker = {};
|
|
4492
|
-
_Symbol$iterator$1 = Symbol.iterator;
|
|
4493
|
-
_Symbol$toStringTag$1 = Symbol.toStringTag;
|
|
4494
4527
|
var ObservableSet = /*#__PURE__*/function () {
|
|
4495
4528
|
function ObservableSet(initialData, enhancer, name_) {
|
|
4496
4529
|
var _this = this;
|
|
@@ -4561,7 +4594,6 @@ var ObservableSet = /*#__PURE__*/function () {
|
|
|
4561
4594
|
// ideally, value = change.value would be done here, so that values can be
|
|
4562
4595
|
// changed by interceptor. Same applies for other Set and Map api's.
|
|
4563
4596
|
}
|
|
4564
|
-
|
|
4565
4597
|
if (!this.has(value)) {
|
|
4566
4598
|
transaction(function () {
|
|
4567
4599
|
_this3.data_.add(_this3.enhancer_(value, undefined));
|
|
@@ -4667,6 +4699,47 @@ var ObservableSet = /*#__PURE__*/function () {
|
|
|
4667
4699
|
}
|
|
4668
4700
|
});
|
|
4669
4701
|
};
|
|
4702
|
+
_proto.intersection = function intersection(otherSet) {
|
|
4703
|
+
if (isES6Set(otherSet)) {
|
|
4704
|
+
return otherSet.intersection(this);
|
|
4705
|
+
} else {
|
|
4706
|
+
var dehancedSet = new Set(this);
|
|
4707
|
+
return dehancedSet.intersection(otherSet);
|
|
4708
|
+
}
|
|
4709
|
+
};
|
|
4710
|
+
_proto.union = function union(otherSet) {
|
|
4711
|
+
if (isES6Set(otherSet)) {
|
|
4712
|
+
return otherSet.union(this);
|
|
4713
|
+
} else {
|
|
4714
|
+
var dehancedSet = new Set(this);
|
|
4715
|
+
return dehancedSet.union(otherSet);
|
|
4716
|
+
}
|
|
4717
|
+
};
|
|
4718
|
+
_proto.difference = function difference(otherSet) {
|
|
4719
|
+
return new Set(this).difference(otherSet);
|
|
4720
|
+
};
|
|
4721
|
+
_proto.symmetricDifference = function symmetricDifference(otherSet) {
|
|
4722
|
+
if (isES6Set(otherSet)) {
|
|
4723
|
+
return otherSet.symmetricDifference(this);
|
|
4724
|
+
} else {
|
|
4725
|
+
var dehancedSet = new Set(this);
|
|
4726
|
+
return dehancedSet.symmetricDifference(otherSet);
|
|
4727
|
+
}
|
|
4728
|
+
};
|
|
4729
|
+
_proto.isSubsetOf = function isSubsetOf(otherSet) {
|
|
4730
|
+
return new Set(this).isSubsetOf(otherSet);
|
|
4731
|
+
};
|
|
4732
|
+
_proto.isSupersetOf = function isSupersetOf(otherSet) {
|
|
4733
|
+
return new Set(this).isSupersetOf(otherSet);
|
|
4734
|
+
};
|
|
4735
|
+
_proto.isDisjointFrom = function isDisjointFrom(otherSet) {
|
|
4736
|
+
if (isES6Set(otherSet)) {
|
|
4737
|
+
return otherSet.isDisjointFrom(this);
|
|
4738
|
+
} else {
|
|
4739
|
+
var dehancedSet = new Set(this);
|
|
4740
|
+
return dehancedSet.isDisjointFrom(otherSet);
|
|
4741
|
+
}
|
|
4742
|
+
};
|
|
4670
4743
|
_proto.replace = function replace(other) {
|
|
4671
4744
|
var _this5 = this;
|
|
4672
4745
|
if (isObservableSet(other)) {
|
|
@@ -4705,22 +4778,21 @@ var ObservableSet = /*#__PURE__*/function () {
|
|
|
4705
4778
|
_proto.toString = function toString() {
|
|
4706
4779
|
return "[object ObservableSet]";
|
|
4707
4780
|
};
|
|
4708
|
-
_proto[
|
|
4781
|
+
_proto[Symbol.iterator] = function () {
|
|
4709
4782
|
return this.values();
|
|
4710
4783
|
};
|
|
4711
|
-
_createClass(ObservableSet, [{
|
|
4784
|
+
return _createClass(ObservableSet, [{
|
|
4712
4785
|
key: "size",
|
|
4713
4786
|
get: function get() {
|
|
4714
4787
|
this.atom_.reportObserved();
|
|
4715
4788
|
return this.data_.size;
|
|
4716
4789
|
}
|
|
4717
4790
|
}, {
|
|
4718
|
-
key:
|
|
4791
|
+
key: Symbol.toStringTag,
|
|
4719
4792
|
get: function get() {
|
|
4720
4793
|
return "Set";
|
|
4721
4794
|
}
|
|
4722
4795
|
}]);
|
|
4723
|
-
return ObservableSet;
|
|
4724
4796
|
}();
|
|
4725
4797
|
// eslint-disable-next-line
|
|
4726
4798
|
var isObservableSet = /*#__PURE__*/createInstanceofPredicate("ObservableSet", ObservableSet);
|
|
@@ -5120,7 +5192,7 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
5120
5192
|
}
|
|
5121
5193
|
// Delete
|
|
5122
5194
|
try {
|
|
5123
|
-
var _this$pendingKeys_
|
|
5195
|
+
var _this$pendingKeys_;
|
|
5124
5196
|
startBatch();
|
|
5125
5197
|
var notify = hasListeners(this);
|
|
5126
5198
|
var notifySpy = "development" !== "production" && isSpyEnabled();
|
|
@@ -5158,7 +5230,7 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
5158
5230
|
this.keysAtom_.reportChanged();
|
|
5159
5231
|
// Notify "has" observers
|
|
5160
5232
|
// "in" as it may still exist in proto
|
|
5161
|
-
(_this$pendingKeys_ = this.pendingKeys_) == null
|
|
5233
|
+
(_this$pendingKeys_ = this.pendingKeys_) == null || (_this$pendingKeys_ = _this$pendingKeys_.get(key)) == null || _this$pendingKeys_.set(key in this.target_);
|
|
5162
5234
|
// Notify spies/listeners
|
|
5163
5235
|
if (notify || notifySpy) {
|
|
5164
5236
|
var _change2 = {
|
|
@@ -5199,7 +5271,7 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
5199
5271
|
return registerInterceptor(this, handler);
|
|
5200
5272
|
};
|
|
5201
5273
|
_proto.notifyPropertyAddition_ = function notifyPropertyAddition_(key, value) {
|
|
5202
|
-
var _this$pendingKeys_2
|
|
5274
|
+
var _this$pendingKeys_2;
|
|
5203
5275
|
var notify = hasListeners(this);
|
|
5204
5276
|
var notifySpy = isSpyEnabled();
|
|
5205
5277
|
if (notify || notifySpy) {
|
|
@@ -5221,7 +5293,7 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
5221
5293
|
spyReportEnd();
|
|
5222
5294
|
}
|
|
5223
5295
|
}
|
|
5224
|
-
(_this$pendingKeys_2 = this.pendingKeys_) == null
|
|
5296
|
+
(_this$pendingKeys_2 = this.pendingKeys_) == null || (_this$pendingKeys_2 = _this$pendingKeys_2.get(key)) == null || _this$pendingKeys_2.set(true);
|
|
5225
5297
|
// Notify "keys/entries/values" observers
|
|
5226
5298
|
this.keysAtom_.reportChanged();
|
|
5227
5299
|
};
|
|
@@ -5283,7 +5355,7 @@ function recordAnnotationApplied(adm, annotation, key) {
|
|
|
5283
5355
|
adm.appliedAnnotations_[key] = annotation;
|
|
5284
5356
|
}
|
|
5285
5357
|
// Remove applied decorator annotation so we don't try to apply it again in subclass constructor
|
|
5286
|
-
(_adm$target_$storedAn = adm.target_[storedAnnotationsSymbol]) == null
|
|
5358
|
+
(_adm$target_$storedAn = adm.target_[storedAnnotationsSymbol]) == null || delete _adm$target_$storedAn[key];
|
|
5287
5359
|
}
|
|
5288
5360
|
function assertAnnotable(adm, annotation, key) {
|
|
5289
5361
|
// Valid annotation
|
|
@@ -5363,8 +5435,7 @@ inherit(StubArray, Array.prototype);
|
|
|
5363
5435
|
// Weex proto freeze protection was here,
|
|
5364
5436
|
// but it is unclear why the hack is need as MobX never changed the prototype
|
|
5365
5437
|
// anyway, so removed it in V6
|
|
5366
|
-
var LegacyObservableArray = /*#__PURE__*/function (_StubArray
|
|
5367
|
-
_inheritsLoose(LegacyObservableArray, _StubArray);
|
|
5438
|
+
var LegacyObservableArray = /*#__PURE__*/function (_StubArray) {
|
|
5368
5439
|
function LegacyObservableArray(initialValues, enhancer, name, owned) {
|
|
5369
5440
|
var _this;
|
|
5370
5441
|
if (name === void 0) {
|
|
@@ -5376,8 +5447,8 @@ var LegacyObservableArray = /*#__PURE__*/function (_StubArray, _Symbol$toStringT
|
|
|
5376
5447
|
_this = _StubArray.call(this) || this;
|
|
5377
5448
|
initObservable(function () {
|
|
5378
5449
|
var adm = new ObservableArrayAdministration(name, enhancer, owned, true);
|
|
5379
|
-
adm.proxy_ =
|
|
5380
|
-
addHiddenFinalProp(
|
|
5450
|
+
adm.proxy_ = _this;
|
|
5451
|
+
addHiddenFinalProp(_this, $mobx, adm);
|
|
5381
5452
|
if (initialValues && initialValues.length) {
|
|
5382
5453
|
// @ts-ignore
|
|
5383
5454
|
_this.spliceWithArray(0, 0, initialValues);
|
|
@@ -5385,11 +5456,12 @@ var LegacyObservableArray = /*#__PURE__*/function (_StubArray, _Symbol$toStringT
|
|
|
5385
5456
|
if (safariPrototypeSetterInheritanceBug) {
|
|
5386
5457
|
// Seems that Safari won't use numeric prototype setter until any * numeric property is
|
|
5387
5458
|
// defined on the instance. After that it works fine, even if this property is deleted.
|
|
5388
|
-
Object.defineProperty(
|
|
5459
|
+
Object.defineProperty(_this, "0", ENTRY_0);
|
|
5389
5460
|
}
|
|
5390
5461
|
});
|
|
5391
5462
|
return _this;
|
|
5392
5463
|
}
|
|
5464
|
+
_inheritsLoose(LegacyObservableArray, _StubArray);
|
|
5393
5465
|
var _proto = LegacyObservableArray.prototype;
|
|
5394
5466
|
_proto.concat = function concat() {
|
|
5395
5467
|
this[$mobx].atom_.reportObserved();
|
|
@@ -5402,7 +5474,7 @@ var LegacyObservableArray = /*#__PURE__*/function (_StubArray, _Symbol$toStringT
|
|
|
5402
5474
|
return isObservableArray(a) ? a.slice() : a;
|
|
5403
5475
|
}));
|
|
5404
5476
|
};
|
|
5405
|
-
_proto[
|
|
5477
|
+
_proto[Symbol.iterator] = function () {
|
|
5406
5478
|
var self = this;
|
|
5407
5479
|
var nextIndex = 0;
|
|
5408
5480
|
return makeIterable({
|
|
@@ -5417,7 +5489,7 @@ var LegacyObservableArray = /*#__PURE__*/function (_StubArray, _Symbol$toStringT
|
|
|
5417
5489
|
}
|
|
5418
5490
|
});
|
|
5419
5491
|
};
|
|
5420
|
-
_createClass(LegacyObservableArray, [{
|
|
5492
|
+
return _createClass(LegacyObservableArray, [{
|
|
5421
5493
|
key: "length",
|
|
5422
5494
|
get: function get() {
|
|
5423
5495
|
return this[$mobx].getArrayLength_();
|
|
@@ -5426,13 +5498,12 @@ var LegacyObservableArray = /*#__PURE__*/function (_StubArray, _Symbol$toStringT
|
|
|
5426
5498
|
this[$mobx].setArrayLength_(newLength);
|
|
5427
5499
|
}
|
|
5428
5500
|
}, {
|
|
5429
|
-
key:
|
|
5501
|
+
key: Symbol.toStringTag,
|
|
5430
5502
|
get: function get() {
|
|
5431
5503
|
return "Array";
|
|
5432
5504
|
}
|
|
5433
5505
|
}]);
|
|
5434
|
-
|
|
5435
|
-
}(StubArray, Symbol.toStringTag, Symbol.iterator);
|
|
5506
|
+
}(StubArray);
|
|
5436
5507
|
Object.entries(arrayExtensions).forEach(function (_ref) {
|
|
5437
5508
|
var prop = _ref[0],
|
|
5438
5509
|
fn = _ref[1];
|