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
|
@@ -203,10 +203,16 @@ function createInstanceofPredicate(name, theClass) {
|
|
|
203
203
|
};
|
|
204
204
|
}
|
|
205
205
|
function isES6Map(thing) {
|
|
206
|
-
return thing
|
|
206
|
+
return thing != null && Object.prototype.toString.call(thing) === "[object Map]";
|
|
207
|
+
}
|
|
208
|
+
function isPlainES6Map(thing) {
|
|
209
|
+
var mapProto = Object.getPrototypeOf(thing);
|
|
210
|
+
var objectProto = Object.getPrototypeOf(mapProto);
|
|
211
|
+
var nullProto = Object.getPrototypeOf(objectProto);
|
|
212
|
+
return nullProto === null;
|
|
207
213
|
}
|
|
208
214
|
function isES6Set(thing) {
|
|
209
|
-
return thing
|
|
215
|
+
return thing != null && Object.prototype.toString.call(thing) === "[object Set]";
|
|
210
216
|
}
|
|
211
217
|
var hasGetOwnPropertySymbols = typeof Object.getOwnPropertySymbols !== "undefined";
|
|
212
218
|
/**
|
|
@@ -257,99 +263,76 @@ var getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors || function get
|
|
|
257
263
|
return res;
|
|
258
264
|
};
|
|
259
265
|
|
|
260
|
-
function
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
Object.defineProperty(
|
|
273
|
-
writable:
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
283
|
-
target[key] = source[key];
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
return target;
|
|
288
|
-
};
|
|
289
|
-
return _extends.apply(this, arguments);
|
|
290
|
-
}
|
|
291
|
-
function _inheritsLoose(subClass, superClass) {
|
|
292
|
-
subClass.prototype = Object.create(superClass.prototype);
|
|
293
|
-
subClass.prototype.constructor = subClass;
|
|
294
|
-
_setPrototypeOf(subClass, superClass);
|
|
295
|
-
}
|
|
296
|
-
function _setPrototypeOf(o, p) {
|
|
297
|
-
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
298
|
-
o.__proto__ = p;
|
|
299
|
-
return o;
|
|
300
|
-
};
|
|
301
|
-
return _setPrototypeOf(o, p);
|
|
302
|
-
}
|
|
303
|
-
function _assertThisInitialized(self) {
|
|
304
|
-
if (self === void 0) {
|
|
305
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
306
|
-
}
|
|
307
|
-
return self;
|
|
308
|
-
}
|
|
309
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
310
|
-
if (!o) return;
|
|
311
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
312
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
313
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
314
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
315
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
316
|
-
}
|
|
317
|
-
function _arrayLikeToArray(arr, len) {
|
|
318
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
319
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
320
|
-
return arr2;
|
|
321
|
-
}
|
|
322
|
-
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
323
|
-
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
324
|
-
if (it) return (it = it.call(o)).next.bind(it);
|
|
325
|
-
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
326
|
-
if (it) o = it;
|
|
327
|
-
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;
|
|
328
288
|
return function () {
|
|
329
|
-
|
|
330
|
-
done:
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
value: o[i++]
|
|
289
|
+
return o >= r.length ? {
|
|
290
|
+
done: !0
|
|
291
|
+
} : {
|
|
292
|
+
done: !1,
|
|
293
|
+
value: r[o++]
|
|
335
294
|
};
|
|
336
295
|
};
|
|
337
296
|
}
|
|
338
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.");
|
|
339
298
|
}
|
|
340
|
-
function
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
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;
|
|
346
322
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
347
323
|
}
|
|
348
|
-
return (
|
|
324
|
+
return ("string" === r ? String : Number)(t);
|
|
349
325
|
}
|
|
350
|
-
function _toPropertyKey(
|
|
351
|
-
var
|
|
352
|
-
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
|
+
}
|
|
353
336
|
}
|
|
354
337
|
|
|
355
338
|
var storedAnnotationsSymbol = /*#__PURE__*/Symbol("mobx-stored-annotations");
|
|
@@ -422,8 +405,6 @@ function assert20223DecoratorType(context, types) {
|
|
|
422
405
|
|
|
423
406
|
var $mobx = /*#__PURE__*/Symbol("mobx administration");
|
|
424
407
|
var Atom = /*#__PURE__*/function () {
|
|
425
|
-
// for effective unobserving. BaseAtom has true, for extra optimization, so its onBecomeUnobserved never gets called, because it's not needed
|
|
426
|
-
|
|
427
408
|
/**
|
|
428
409
|
* Create a new atom. For debugging purposes it is recommended to give it a name.
|
|
429
410
|
* The onBecomeObserved and onBecomeUnobserved callbacks can be used for resource management.
|
|
@@ -434,16 +415,18 @@ var Atom = /*#__PURE__*/function () {
|
|
|
434
415
|
}
|
|
435
416
|
this.name_ = void 0;
|
|
436
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
|
|
437
419
|
this.isBeingObserved = false;
|
|
438
420
|
this.observers_ = new Set();
|
|
439
421
|
this.diffValue_ = 0;
|
|
440
422
|
this.lastAccessedBy_ = 0;
|
|
441
423
|
this.lowestObserverState_ = IDerivationState_.NOT_TRACKING_;
|
|
424
|
+
// onBecomeObservedListeners
|
|
442
425
|
this.onBOL = void 0;
|
|
426
|
+
// onBecomeUnobservedListeners
|
|
443
427
|
this.onBUOL = void 0;
|
|
444
428
|
this.name_ = name_;
|
|
445
429
|
}
|
|
446
|
-
// onBecomeObservedListeners
|
|
447
430
|
var _proto = Atom.prototype;
|
|
448
431
|
_proto.onBO = function onBO() {
|
|
449
432
|
if (this.onBOL) {
|
|
@@ -625,7 +608,6 @@ function make_(adm, key) {
|
|
|
625
608
|
}
|
|
626
609
|
return 0 /* MakeResult.Cancel */;
|
|
627
610
|
}
|
|
628
|
-
|
|
629
611
|
function extend_(adm, key, descriptor, proxyTrap) {
|
|
630
612
|
die("'" + this.annotationType_ + "' can only be used with 'makeObservable'");
|
|
631
613
|
}
|
|
@@ -658,12 +640,10 @@ function make_$1(adm, key, descriptor, source) {
|
|
|
658
640
|
// rest of the proto chain must be annotated already
|
|
659
641
|
return 1 /* MakeResult.Break */;
|
|
660
642
|
}
|
|
661
|
-
|
|
662
643
|
var actionDescriptor = createActionDescriptor(adm, this, key, descriptor, false);
|
|
663
644
|
defineProperty(source, key, actionDescriptor);
|
|
664
645
|
return 2 /* MakeResult.Continue */;
|
|
665
646
|
}
|
|
666
|
-
|
|
667
647
|
function extend_$1(adm, key, descriptor, proxyTrap) {
|
|
668
648
|
var actionDescriptor = createActionDescriptor(adm, this, key, descriptor);
|
|
669
649
|
return adm.defineProperty_(key, actionDescriptor, proxyTrap);
|
|
@@ -761,18 +741,15 @@ function make_$2(adm, key, descriptor, source) {
|
|
|
761
741
|
return 0 /* MakeResult.Cancel */;
|
|
762
742
|
}
|
|
763
743
|
}
|
|
764
|
-
|
|
765
744
|
if (isFlow(descriptor.value)) {
|
|
766
745
|
// A prototype could have been annotated already by other constructor,
|
|
767
746
|
// rest of the proto chain must be annotated already
|
|
768
747
|
return 1 /* MakeResult.Break */;
|
|
769
748
|
}
|
|
770
|
-
|
|
771
749
|
var flowDescriptor = createFlowDescriptor(adm, this, key, descriptor, false, false);
|
|
772
750
|
defineProperty(source, key, flowDescriptor);
|
|
773
751
|
return 2 /* MakeResult.Continue */;
|
|
774
752
|
}
|
|
775
|
-
|
|
776
753
|
function extend_$2(adm, key, descriptor, proxyTrap) {
|
|
777
754
|
var _this$options_2;
|
|
778
755
|
var flowDescriptor = createFlowDescriptor(adm, this, key, descriptor, (_this$options_2 = this.options_) == null ? void 0 : _this$options_2.bound);
|
|
@@ -849,7 +826,6 @@ function createComputedAnnotation(name, options) {
|
|
|
849
826
|
function make_$3(adm, key, descriptor) {
|
|
850
827
|
return this.extend_(adm, key, descriptor, false) === null ? 0 /* MakeResult.Cancel */ : 1 /* MakeResult.Break */;
|
|
851
828
|
}
|
|
852
|
-
|
|
853
829
|
function extend_$3(adm, key, descriptor, proxyTrap) {
|
|
854
830
|
assertComputedDescriptor(adm, this, key, descriptor);
|
|
855
831
|
return adm.defineComputedProperty_(key, _extends({}, this.options_, {
|
|
@@ -897,7 +873,6 @@ function createObservableAnnotation(name, options) {
|
|
|
897
873
|
function make_$4(adm, key, descriptor) {
|
|
898
874
|
return this.extend_(adm, key, descriptor, false) === null ? 0 /* MakeResult.Cancel */ : 1 /* MakeResult.Break */;
|
|
899
875
|
}
|
|
900
|
-
|
|
901
876
|
function extend_$4(adm, key, descriptor, proxyTrap) {
|
|
902
877
|
var _this$options_$enhanc, _this$options_;
|
|
903
878
|
assertObservableDescriptor(adm, this, key, descriptor);
|
|
@@ -1317,11 +1292,8 @@ function allowStateChangesEnd(prev) {
|
|
|
1317
1292
|
globalState.allowStateChanges = prev;
|
|
1318
1293
|
}
|
|
1319
1294
|
|
|
1320
|
-
var _Symbol$toPrimitive;
|
|
1321
1295
|
var CREATE = "create";
|
|
1322
|
-
_Symbol$toPrimitive = Symbol.toPrimitive;
|
|
1323
1296
|
var ObservableValue = /*#__PURE__*/function (_Atom) {
|
|
1324
|
-
_inheritsLoose(ObservableValue, _Atom);
|
|
1325
1297
|
function ObservableValue(value, enhancer, name_, notifySpy, equals) {
|
|
1326
1298
|
var _this;
|
|
1327
1299
|
if (name_ === void 0) {
|
|
@@ -1350,7 +1322,7 @@ var ObservableValue = /*#__PURE__*/function (_Atom) {
|
|
|
1350
1322
|
// only notify spy if this is a stand-alone observable
|
|
1351
1323
|
spyReport({
|
|
1352
1324
|
type: CREATE,
|
|
1353
|
-
object:
|
|
1325
|
+
object: _this,
|
|
1354
1326
|
observableKind: "value",
|
|
1355
1327
|
debugObjectName: _this.name_,
|
|
1356
1328
|
newValue: "" + _this.value_
|
|
@@ -1358,6 +1330,7 @@ var ObservableValue = /*#__PURE__*/function (_Atom) {
|
|
|
1358
1330
|
}
|
|
1359
1331
|
return _this;
|
|
1360
1332
|
}
|
|
1333
|
+
_inheritsLoose(ObservableValue, _Atom);
|
|
1361
1334
|
var _proto = ObservableValue.prototype;
|
|
1362
1335
|
_proto.dehanceValue = function dehanceValue(value) {
|
|
1363
1336
|
if (this.dehancer !== undefined) {
|
|
@@ -1449,14 +1422,13 @@ var ObservableValue = /*#__PURE__*/function (_Atom) {
|
|
|
1449
1422
|
_proto.valueOf = function valueOf() {
|
|
1450
1423
|
return toPrimitive(this.get());
|
|
1451
1424
|
};
|
|
1452
|
-
_proto[
|
|
1425
|
+
_proto[Symbol.toPrimitive] = function () {
|
|
1453
1426
|
return this.valueOf();
|
|
1454
1427
|
};
|
|
1455
1428
|
return ObservableValue;
|
|
1456
1429
|
}(Atom);
|
|
1457
1430
|
var isObservableValue = /*#__PURE__*/createInstanceofPredicate("ObservableValue", ObservableValue);
|
|
1458
1431
|
|
|
1459
|
-
var _Symbol$toPrimitive$1;
|
|
1460
1432
|
function getFlag(flags, mask) {
|
|
1461
1433
|
return !!(flags & mask);
|
|
1462
1434
|
}
|
|
@@ -1487,13 +1459,7 @@ function setFlag(flags, mask, newValue) {
|
|
|
1487
1459
|
*
|
|
1488
1460
|
* If at any point it's outside batch and it isn't observed: reset everything and go to 1.
|
|
1489
1461
|
*/
|
|
1490
|
-
_Symbol$toPrimitive$1 = Symbol.toPrimitive;
|
|
1491
1462
|
var ComputedValue = /*#__PURE__*/function () {
|
|
1492
|
-
// nodes we are looking at. Our value depends on these nodes
|
|
1493
|
-
// during tracking it's an array with new observed observers
|
|
1494
|
-
|
|
1495
|
-
// N.B: unminified as it is used by MST
|
|
1496
|
-
|
|
1497
1463
|
/**
|
|
1498
1464
|
* Create a new computed value based on a function expression.
|
|
1499
1465
|
*
|
|
@@ -1509,7 +1475,9 @@ var ComputedValue = /*#__PURE__*/function () {
|
|
|
1509
1475
|
function ComputedValue(options) {
|
|
1510
1476
|
this.dependenciesState_ = IDerivationState_.NOT_TRACKING_;
|
|
1511
1477
|
this.observing_ = [];
|
|
1478
|
+
// nodes we are looking at. Our value depends on these nodes
|
|
1512
1479
|
this.newObserving_ = null;
|
|
1480
|
+
// during tracking it's an array with new observed observers
|
|
1513
1481
|
this.observers_ = new Set();
|
|
1514
1482
|
this.diffValue_ = 0;
|
|
1515
1483
|
this.runId_ = 0;
|
|
@@ -1521,6 +1489,7 @@ var ComputedValue = /*#__PURE__*/function () {
|
|
|
1521
1489
|
this.triggeredBy_ = void 0;
|
|
1522
1490
|
this.flags_ = 0;
|
|
1523
1491
|
this.derivation = void 0;
|
|
1492
|
+
// N.B: unminified as it is used by MST
|
|
1524
1493
|
this.setter_ = void 0;
|
|
1525
1494
|
this.isTracing_ = TraceMode.NONE;
|
|
1526
1495
|
this.scope_ = void 0;
|
|
@@ -1702,10 +1671,10 @@ var ComputedValue = /*#__PURE__*/function () {
|
|
|
1702
1671
|
_proto.valueOf = function valueOf() {
|
|
1703
1672
|
return toPrimitive(this.get());
|
|
1704
1673
|
};
|
|
1705
|
-
_proto[
|
|
1674
|
+
_proto[Symbol.toPrimitive] = function () {
|
|
1706
1675
|
return this.valueOf();
|
|
1707
1676
|
};
|
|
1708
|
-
_createClass(ComputedValue, [{
|
|
1677
|
+
return _createClass(ComputedValue, [{
|
|
1709
1678
|
key: "isComputing",
|
|
1710
1679
|
get: function get() {
|
|
1711
1680
|
return getFlag(this.flags_, ComputedValue.isComputingMask_);
|
|
@@ -1738,7 +1707,6 @@ var ComputedValue = /*#__PURE__*/function () {
|
|
|
1738
1707
|
this.flags_ = setFlag(this.flags_, ComputedValue.isPendingUnobservationMask_, newValue);
|
|
1739
1708
|
}
|
|
1740
1709
|
}]);
|
|
1741
|
-
return ComputedValue;
|
|
1742
1710
|
}();
|
|
1743
1711
|
ComputedValue.isComputingMask_ = 1;
|
|
1744
1712
|
ComputedValue.isRunningSetterMask_ = 2;
|
|
@@ -1777,7 +1745,6 @@ var CaughtException = function CaughtException(cause) {
|
|
|
1777
1745
|
this.cause = cause;
|
|
1778
1746
|
// Empty
|
|
1779
1747
|
};
|
|
1780
|
-
|
|
1781
1748
|
function isCaughtException(e) {
|
|
1782
1749
|
return e instanceof CaughtException;
|
|
1783
1750
|
}
|
|
@@ -1841,7 +1808,6 @@ function shouldCompute(derivation) {
|
|
|
1841
1808
|
function isComputingDerivation() {
|
|
1842
1809
|
return globalState.trackingDerivation !== null; // filter out actions inside computations
|
|
1843
1810
|
}
|
|
1844
|
-
|
|
1845
1811
|
function checkIfStateModificationsAreAllowed(atom) {
|
|
1846
1812
|
var hasObservers = atom.observers_.size > 0;
|
|
1847
1813
|
// Should not be possible to change observed state outside strict mode, except during initialization, see #563
|
|
@@ -2012,28 +1978,113 @@ function changeDependenciesStateTo0(derivation) {
|
|
|
2012
1978
|
*/
|
|
2013
1979
|
var persistentKeys = ["mobxGuid", "spyListeners", "enforceActions", "computedRequiresReaction", "reactionRequiresObservable", "observableRequiresReaction", "allowStateReads", "disableErrorBoundaries", "runId", "UNCHANGED", "useProxies"];
|
|
2014
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
|
+
*/
|
|
2015
1989
|
this.version = 6;
|
|
1990
|
+
/**
|
|
1991
|
+
* globally unique token to signal unchanged
|
|
1992
|
+
*/
|
|
2016
1993
|
this.UNCHANGED = {};
|
|
1994
|
+
/**
|
|
1995
|
+
* Currently running derivation
|
|
1996
|
+
*/
|
|
2017
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
|
+
*/
|
|
2018
2003
|
this.trackingContext = null;
|
|
2004
|
+
/**
|
|
2005
|
+
* Each time a derivation is tracked, it is assigned a unique run-id
|
|
2006
|
+
*/
|
|
2019
2007
|
this.runId = 0;
|
|
2008
|
+
/**
|
|
2009
|
+
* 'guid' for general purpose. Will be persisted amongst resets.
|
|
2010
|
+
*/
|
|
2020
2011
|
this.mobxGuid = 0;
|
|
2012
|
+
/**
|
|
2013
|
+
* Are we in a batch block? (and how many of them)
|
|
2014
|
+
*/
|
|
2021
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
|
+
*/
|
|
2022
2022
|
this.pendingUnobservations = [];
|
|
2023
|
+
/**
|
|
2024
|
+
* List of scheduled, not yet executed, reactions.
|
|
2025
|
+
*/
|
|
2023
2026
|
this.pendingReactions = [];
|
|
2027
|
+
/**
|
|
2028
|
+
* Are we currently processing reactions?
|
|
2029
|
+
*/
|
|
2024
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
|
+
*/
|
|
2025
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
|
+
*/
|
|
2026
2041
|
this.allowStateReads = true;
|
|
2042
|
+
/**
|
|
2043
|
+
* If strict mode is enabled, state changes are by default not allowed
|
|
2044
|
+
*/
|
|
2027
2045
|
this.enforceActions = true;
|
|
2046
|
+
/**
|
|
2047
|
+
* Spy callbacks
|
|
2048
|
+
*/
|
|
2028
2049
|
this.spyListeners = [];
|
|
2050
|
+
/**
|
|
2051
|
+
* Globally attached error handlers that react specifically to errors in reactions
|
|
2052
|
+
*/
|
|
2029
2053
|
this.globalReactionErrorHandlers = [];
|
|
2054
|
+
/**
|
|
2055
|
+
* Warn if computed values are accessed outside a reactive context
|
|
2056
|
+
*/
|
|
2030
2057
|
this.computedRequiresReaction = false;
|
|
2058
|
+
/**
|
|
2059
|
+
* (Experimental)
|
|
2060
|
+
* Warn if you try to create to derivation / reactive context without accessing any observable.
|
|
2061
|
+
*/
|
|
2031
2062
|
this.reactionRequiresObservable = false;
|
|
2063
|
+
/**
|
|
2064
|
+
* (Experimental)
|
|
2065
|
+
* Warn if observables are accessed outside a reactive context
|
|
2066
|
+
*/
|
|
2032
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
|
+
*/
|
|
2033
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
|
+
*/
|
|
2034
2077
|
this.suppressReactionErrors = false;
|
|
2035
2078
|
this.useProxies = true;
|
|
2079
|
+
/*
|
|
2080
|
+
* print warnings about code that would fail if proxies weren't available
|
|
2081
|
+
*/
|
|
2036
2082
|
this.verifyProxies = false;
|
|
2083
|
+
/**
|
|
2084
|
+
* False forces all object's descriptors to
|
|
2085
|
+
* writable: true
|
|
2086
|
+
* configurable: true
|
|
2087
|
+
*/
|
|
2037
2088
|
this.safeDescriptors = true;
|
|
2038
2089
|
};
|
|
2039
2090
|
var canMergeGlobalState = true;
|
|
@@ -2130,7 +2181,6 @@ function addObserver(observable, node) {
|
|
|
2130
2181
|
// invariantObservers(observable);
|
|
2131
2182
|
// invariant(observable._observers.indexOf(node) !== -1, "INTERNAL ERROR didn't add node");
|
|
2132
2183
|
}
|
|
2133
|
-
|
|
2134
2184
|
function removeObserver(observable, node) {
|
|
2135
2185
|
// invariant(globalState.inBatch > 0, "INTERNAL ERROR, remove should be called only inside batch");
|
|
2136
2186
|
// invariant(observable._observers.indexOf(node) !== -1, "INTERNAL ERROR remove already removed node");
|
|
@@ -2143,7 +2193,6 @@ function removeObserver(observable, node) {
|
|
|
2143
2193
|
// invariantObservers(observable);
|
|
2144
2194
|
// invariant(observable._observers.indexOf(node) === -1, "INTERNAL ERROR remove already removed node2");
|
|
2145
2195
|
}
|
|
2146
|
-
|
|
2147
2196
|
function queueForUnobservation(observable) {
|
|
2148
2197
|
if (observable.isPendingUnobservation === false) {
|
|
2149
2198
|
// invariant(observable._observers.length === 0, "INTERNAL ERROR, should only queue for unobservation unobserved observables");
|
|
@@ -2281,7 +2330,6 @@ function propagateMaybeChanged(observable) {
|
|
|
2281
2330
|
});
|
|
2282
2331
|
// invariantLOS(observable, "maybe end");
|
|
2283
2332
|
}
|
|
2284
|
-
|
|
2285
2333
|
function logTraceInfo(derivation, observable) {
|
|
2286
2334
|
console.log("[mobx.trace] '" + derivation.name_ + "' is invalidated due to a change in: '" + observable.name_ + "'");
|
|
2287
2335
|
if (derivation.isTracing_ === TraceMode.BREAK) {
|
|
@@ -2305,8 +2353,6 @@ function printDepTree(tree, lines, depth) {
|
|
|
2305
2353
|
}
|
|
2306
2354
|
|
|
2307
2355
|
var Reaction = /*#__PURE__*/function () {
|
|
2308
|
-
// nodes we are looking at. Our value depends on these nodes
|
|
2309
|
-
|
|
2310
2356
|
function Reaction(name_, onInvalidate_, errorHandler_, requiresObservable_) {
|
|
2311
2357
|
if (name_ === void 0) {
|
|
2312
2358
|
name_ = "Reaction@" + getNextId() ;
|
|
@@ -2316,6 +2362,7 @@ var Reaction = /*#__PURE__*/function () {
|
|
|
2316
2362
|
this.errorHandler_ = void 0;
|
|
2317
2363
|
this.requiresObservable_ = void 0;
|
|
2318
2364
|
this.observing_ = [];
|
|
2365
|
+
// nodes we are looking at. Our value depends on these nodes
|
|
2319
2366
|
this.newObserving_ = [];
|
|
2320
2367
|
this.dependenciesState_ = IDerivationState_.NOT_TRACKING_;
|
|
2321
2368
|
this.diffValue_ = 0;
|
|
@@ -2378,7 +2425,6 @@ var Reaction = /*#__PURE__*/function () {
|
|
|
2378
2425
|
return;
|
|
2379
2426
|
// console.warn("Reaction already disposed") // Note: Not a warning / error in mobx 4 either
|
|
2380
2427
|
}
|
|
2381
|
-
|
|
2382
2428
|
startBatch();
|
|
2383
2429
|
var notify = isSpyEnabled();
|
|
2384
2430
|
var startTime;
|
|
@@ -2453,9 +2499,9 @@ var Reaction = /*#__PURE__*/function () {
|
|
|
2453
2499
|
var _this2 = this;
|
|
2454
2500
|
var dispose = function dispose() {
|
|
2455
2501
|
_this2.dispose();
|
|
2456
|
-
abortSignal == null
|
|
2502
|
+
abortSignal == null || abortSignal.removeEventListener == null || abortSignal.removeEventListener("abort", dispose);
|
|
2457
2503
|
};
|
|
2458
|
-
abortSignal == null
|
|
2504
|
+
abortSignal == null || abortSignal.addEventListener == null || abortSignal.addEventListener("abort", dispose);
|
|
2459
2505
|
dispose[$mobx] = this;
|
|
2460
2506
|
return dispose;
|
|
2461
2507
|
};
|
|
@@ -2507,7 +2553,6 @@ function runReactionsHelper() {
|
|
|
2507
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]) );
|
|
2508
2554
|
allReactions.splice(0); // clear reactions
|
|
2509
2555
|
}
|
|
2510
|
-
|
|
2511
2556
|
var remainingReactions = allReactions.splice(0);
|
|
2512
2557
|
for (var i = 0, l = remainingReactions.length; i < l; i++) {
|
|
2513
2558
|
remainingReactions[i].runReaction_();
|
|
@@ -2635,7 +2680,7 @@ function isAction(thing) {
|
|
|
2635
2680
|
* @returns disposer function, which can be used to stop the view from being updated in the future.
|
|
2636
2681
|
*/
|
|
2637
2682
|
function autorun(view, opts) {
|
|
2638
|
-
var _opts$name, _opts, _opts2,
|
|
2683
|
+
var _opts$name, _opts, _opts2, _opts3;
|
|
2639
2684
|
if (opts === void 0) {
|
|
2640
2685
|
opts = EMPTY_OBJECT;
|
|
2641
2686
|
}
|
|
@@ -2674,7 +2719,7 @@ function autorun(view, opts) {
|
|
|
2674
2719
|
function reactionRunner() {
|
|
2675
2720
|
view(reaction);
|
|
2676
2721
|
}
|
|
2677
|
-
if (!((_opts2 = opts) != null && (_opts2
|
|
2722
|
+
if (!((_opts2 = opts) != null && (_opts2 = _opts2.signal) != null && _opts2.aborted)) {
|
|
2678
2723
|
reaction.schedule_();
|
|
2679
2724
|
}
|
|
2680
2725
|
return reaction.getDisposer_((_opts3 = opts) == null ? void 0 : _opts3.signal);
|
|
@@ -2688,7 +2733,7 @@ function createSchedulerFromOptions(opts) {
|
|
|
2688
2733
|
} : run;
|
|
2689
2734
|
}
|
|
2690
2735
|
function reaction(expression, effect, opts) {
|
|
2691
|
-
var _opts$name2, _opts4,
|
|
2736
|
+
var _opts$name2, _opts4, _opts5;
|
|
2692
2737
|
if (opts === void 0) {
|
|
2693
2738
|
opts = EMPTY_OBJECT;
|
|
2694
2739
|
}
|
|
@@ -2737,7 +2782,7 @@ function reaction(expression, effect, opts) {
|
|
|
2737
2782
|
}
|
|
2738
2783
|
firstTime = false;
|
|
2739
2784
|
}
|
|
2740
|
-
if (!((_opts4 = opts) != null && (_opts4
|
|
2785
|
+
if (!((_opts4 = opts) != null && (_opts4 = _opts4.signal) != null && _opts4.aborted)) {
|
|
2741
2786
|
r.schedule_();
|
|
2742
2787
|
}
|
|
2743
2788
|
return r.getDisposer_((_opts5 = opts) == null ? void 0 : _opts5.signal);
|
|
@@ -2946,7 +2991,6 @@ var flow = /*#__PURE__*/Object.assign(function flow(arg1, arg2) {
|
|
|
2946
2991
|
}
|
|
2947
2992
|
onFulfilled(undefined); // kick off the process
|
|
2948
2993
|
});
|
|
2949
|
-
|
|
2950
2994
|
promise.cancel = action(name + " - runid: " + runId + " - cancel", function () {
|
|
2951
2995
|
try {
|
|
2952
2996
|
if (pendingPromise) {
|
|
@@ -2964,7 +3008,6 @@ var flow = /*#__PURE__*/Object.assign(function flow(arg1, arg2) {
|
|
|
2964
3008
|
rejector(e); // there could be a throwing finally block
|
|
2965
3009
|
}
|
|
2966
3010
|
});
|
|
2967
|
-
|
|
2968
3011
|
return promise;
|
|
2969
3012
|
};
|
|
2970
3013
|
res.isMobXFlow = true;
|
|
@@ -2979,7 +3022,6 @@ function cancelPromise(promise) {
|
|
|
2979
3022
|
function flowResult(result) {
|
|
2980
3023
|
return result; // just tricking TypeScript :)
|
|
2981
3024
|
}
|
|
2982
|
-
|
|
2983
3025
|
function isFlow(fn) {
|
|
2984
3026
|
return (fn == null ? void 0 : fn.isMobXFlow) === true;
|
|
2985
3027
|
}
|
|
@@ -3401,10 +3443,10 @@ function whenPromise(predicate, opts) {
|
|
|
3401
3443
|
disposer();
|
|
3402
3444
|
reject(new Error("WHEN_ABORTED"));
|
|
3403
3445
|
};
|
|
3404
|
-
opts == null
|
|
3446
|
+
opts == null || (_opts$signal2 = opts.signal) == null || _opts$signal2.addEventListener == null || _opts$signal2.addEventListener("abort", abort);
|
|
3405
3447
|
})["finally"](function () {
|
|
3406
3448
|
var _opts$signal3;
|
|
3407
|
-
return opts == null
|
|
3449
|
+
return opts == null || (_opts$signal3 = opts.signal) == null || _opts$signal3.removeEventListener == null ? void 0 : _opts$signal3.removeEventListener("abort", abort);
|
|
3408
3450
|
});
|
|
3409
3451
|
res.cancel = cancel;
|
|
3410
3452
|
return res;
|
|
@@ -3621,8 +3663,6 @@ var arrayTraps = {
|
|
|
3621
3663
|
}
|
|
3622
3664
|
};
|
|
3623
3665
|
var ObservableArrayAdministration = /*#__PURE__*/function () {
|
|
3624
|
-
// this is the prop that gets proxied, so can't replace it!
|
|
3625
|
-
|
|
3626
3666
|
function ObservableArrayAdministration(name, enhancer, owned_, legacyMode_) {
|
|
3627
3667
|
if (name === void 0) {
|
|
3628
3668
|
name = "ObservableArray@" + getNextId() ;
|
|
@@ -3631,6 +3671,7 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
|
|
|
3631
3671
|
this.legacyMode_ = void 0;
|
|
3632
3672
|
this.atom_ = void 0;
|
|
3633
3673
|
this.values_ = [];
|
|
3674
|
+
// this is the prop that gets proxied, so can't replace it!
|
|
3634
3675
|
this.interceptors_ = void 0;
|
|
3635
3676
|
this.changeListeners_ = void 0;
|
|
3636
3677
|
this.enhancer_ = void 0;
|
|
@@ -3751,7 +3792,6 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
|
|
|
3751
3792
|
var lengthDelta = newItems.length - deleteCount;
|
|
3752
3793
|
this.updateArrayLength_(length, lengthDelta); // checks if internal array wasn't modified
|
|
3753
3794
|
}
|
|
3754
|
-
|
|
3755
3795
|
var res = this.spliceItemsIntoValues_(index, deleteCount, newItems);
|
|
3756
3796
|
if (deleteCount !== 0 || newItems.length !== 0) {
|
|
3757
3797
|
this.notifyArraySplice_(index, newItems, res);
|
|
@@ -3851,6 +3891,7 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
|
|
|
3851
3891
|
var change = interceptChange(this, {
|
|
3852
3892
|
type: UPDATE,
|
|
3853
3893
|
object: this.proxy_,
|
|
3894
|
+
// since "this" is the real array we need to pass its proxy
|
|
3854
3895
|
index: index,
|
|
3855
3896
|
newValue: newValue
|
|
3856
3897
|
});
|
|
@@ -4066,17 +4107,12 @@ function isObservableArray(thing) {
|
|
|
4066
4107
|
return isObject(thing) && isObservableArrayAdministration(thing[$mobx]);
|
|
4067
4108
|
}
|
|
4068
4109
|
|
|
4069
|
-
var _Symbol$iterator, _Symbol$toStringTag;
|
|
4070
4110
|
var ObservableMapMarker = {};
|
|
4071
4111
|
var ADD = "add";
|
|
4072
4112
|
var DELETE = "delete";
|
|
4073
4113
|
// just extend Map? See also https://gist.github.com/nestharus/13b4d74f2ef4a2f4357dbd3fc23c1e54
|
|
4074
4114
|
// But: https://github.com/mobxjs/mobx/issues/1556
|
|
4075
|
-
_Symbol$iterator = Symbol.iterator;
|
|
4076
|
-
_Symbol$toStringTag = Symbol.toStringTag;
|
|
4077
4115
|
var ObservableMap = /*#__PURE__*/function () {
|
|
4078
|
-
// hasMap, not hashMap >-).
|
|
4079
|
-
|
|
4080
4116
|
function ObservableMap(initialData, enhancer_, name_) {
|
|
4081
4117
|
var _this = this;
|
|
4082
4118
|
if (enhancer_ === void 0) {
|
|
@@ -4090,6 +4126,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4090
4126
|
this[$mobx] = ObservableMapMarker;
|
|
4091
4127
|
this.data_ = void 0;
|
|
4092
4128
|
this.hasMap_ = void 0;
|
|
4129
|
+
// hasMap, not hashMap >-).
|
|
4093
4130
|
this.keysAtom_ = void 0;
|
|
4094
4131
|
this.interceptors_ = void 0;
|
|
4095
4132
|
this.changeListeners_ = void 0;
|
|
@@ -4178,7 +4215,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4178
4215
|
transaction(function () {
|
|
4179
4216
|
var _this3$hasMap_$get;
|
|
4180
4217
|
_this3.keysAtom_.reportChanged();
|
|
4181
|
-
(_this3$hasMap_$get = _this3.hasMap_.get(key)) == null
|
|
4218
|
+
(_this3$hasMap_$get = _this3.hasMap_.get(key)) == null || _this3$hasMap_$get.setNewValue_(false);
|
|
4182
4219
|
var observable = _this3.data_.get(key);
|
|
4183
4220
|
observable.setNewValue_(undefined);
|
|
4184
4221
|
_this3.data_["delete"](key);
|
|
@@ -4228,7 +4265,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4228
4265
|
var observable = new ObservableValue(newValue, _this4.enhancer_, _this4.name_ + "." + stringifyKey(key) , false);
|
|
4229
4266
|
_this4.data_.set(key, observable);
|
|
4230
4267
|
newValue = observable.value_; // value might have been changed
|
|
4231
|
-
(_this4$hasMap_$get = _this4.hasMap_.get(key)) == null
|
|
4268
|
+
(_this4$hasMap_$get = _this4.hasMap_.get(key)) == null || _this4$hasMap_$get.setNewValue_(true);
|
|
4232
4269
|
_this4.keysAtom_.reportChanged();
|
|
4233
4270
|
});
|
|
4234
4271
|
var notifySpy = isSpyEnabled();
|
|
@@ -4297,7 +4334,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4297
4334
|
}
|
|
4298
4335
|
});
|
|
4299
4336
|
};
|
|
4300
|
-
_proto[
|
|
4337
|
+
_proto[Symbol.iterator] = function () {
|
|
4301
4338
|
return this.entries();
|
|
4302
4339
|
};
|
|
4303
4340
|
_proto.forEach = function forEach(callback, thisArg) {
|
|
@@ -4326,7 +4363,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4326
4363
|
return _this5.set(key, value);
|
|
4327
4364
|
});
|
|
4328
4365
|
} else if (isES6Map(other)) {
|
|
4329
|
-
if (other
|
|
4366
|
+
if (!isPlainES6Map(other)) {
|
|
4330
4367
|
die(19, other);
|
|
4331
4368
|
}
|
|
4332
4369
|
other.forEach(function (value, key) {
|
|
@@ -4451,19 +4488,18 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4451
4488
|
_proto.intercept_ = function intercept_(handler) {
|
|
4452
4489
|
return registerInterceptor(this, handler);
|
|
4453
4490
|
};
|
|
4454
|
-
_createClass(ObservableMap, [{
|
|
4491
|
+
return _createClass(ObservableMap, [{
|
|
4455
4492
|
key: "size",
|
|
4456
4493
|
get: function get() {
|
|
4457
4494
|
this.keysAtom_.reportObserved();
|
|
4458
4495
|
return this.data_.size;
|
|
4459
4496
|
}
|
|
4460
4497
|
}, {
|
|
4461
|
-
key:
|
|
4498
|
+
key: Symbol.toStringTag,
|
|
4462
4499
|
get: function get() {
|
|
4463
4500
|
return "Map";
|
|
4464
4501
|
}
|
|
4465
4502
|
}]);
|
|
4466
|
-
return ObservableMap;
|
|
4467
4503
|
}();
|
|
4468
4504
|
// eslint-disable-next-line
|
|
4469
4505
|
var isObservableMap = /*#__PURE__*/createInstanceofPredicate("ObservableMap", ObservableMap);
|
|
@@ -4483,10 +4519,7 @@ function convertToMap(dataStructure) {
|
|
|
4483
4519
|
}
|
|
4484
4520
|
}
|
|
4485
4521
|
|
|
4486
|
-
var _Symbol$iterator$1, _Symbol$toStringTag$1;
|
|
4487
4522
|
var ObservableSetMarker = {};
|
|
4488
|
-
_Symbol$iterator$1 = Symbol.iterator;
|
|
4489
|
-
_Symbol$toStringTag$1 = Symbol.toStringTag;
|
|
4490
4523
|
var ObservableSet = /*#__PURE__*/function () {
|
|
4491
4524
|
function ObservableSet(initialData, enhancer, name_) {
|
|
4492
4525
|
var _this = this;
|
|
@@ -4557,7 +4590,6 @@ var ObservableSet = /*#__PURE__*/function () {
|
|
|
4557
4590
|
// ideally, value = change.value would be done here, so that values can be
|
|
4558
4591
|
// changed by interceptor. Same applies for other Set and Map api's.
|
|
4559
4592
|
}
|
|
4560
|
-
|
|
4561
4593
|
if (!this.has(value)) {
|
|
4562
4594
|
transaction(function () {
|
|
4563
4595
|
_this3.data_.add(_this3.enhancer_(value, undefined));
|
|
@@ -4663,6 +4695,47 @@ var ObservableSet = /*#__PURE__*/function () {
|
|
|
4663
4695
|
}
|
|
4664
4696
|
});
|
|
4665
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
|
+
};
|
|
4666
4739
|
_proto.replace = function replace(other) {
|
|
4667
4740
|
var _this5 = this;
|
|
4668
4741
|
if (isObservableSet(other)) {
|
|
@@ -4701,22 +4774,21 @@ var ObservableSet = /*#__PURE__*/function () {
|
|
|
4701
4774
|
_proto.toString = function toString() {
|
|
4702
4775
|
return "[object ObservableSet]";
|
|
4703
4776
|
};
|
|
4704
|
-
_proto[
|
|
4777
|
+
_proto[Symbol.iterator] = function () {
|
|
4705
4778
|
return this.values();
|
|
4706
4779
|
};
|
|
4707
|
-
_createClass(ObservableSet, [{
|
|
4780
|
+
return _createClass(ObservableSet, [{
|
|
4708
4781
|
key: "size",
|
|
4709
4782
|
get: function get() {
|
|
4710
4783
|
this.atom_.reportObserved();
|
|
4711
4784
|
return this.data_.size;
|
|
4712
4785
|
}
|
|
4713
4786
|
}, {
|
|
4714
|
-
key:
|
|
4787
|
+
key: Symbol.toStringTag,
|
|
4715
4788
|
get: function get() {
|
|
4716
4789
|
return "Set";
|
|
4717
4790
|
}
|
|
4718
4791
|
}]);
|
|
4719
|
-
return ObservableSet;
|
|
4720
4792
|
}();
|
|
4721
4793
|
// eslint-disable-next-line
|
|
4722
4794
|
var isObservableSet = /*#__PURE__*/createInstanceofPredicate("ObservableSet", ObservableSet);
|
|
@@ -5116,7 +5188,7 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
5116
5188
|
}
|
|
5117
5189
|
// Delete
|
|
5118
5190
|
try {
|
|
5119
|
-
var _this$pendingKeys_
|
|
5191
|
+
var _this$pendingKeys_;
|
|
5120
5192
|
startBatch();
|
|
5121
5193
|
var notify = hasListeners(this);
|
|
5122
5194
|
var notifySpy = "development" !== "production" && isSpyEnabled();
|
|
@@ -5154,7 +5226,7 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
5154
5226
|
this.keysAtom_.reportChanged();
|
|
5155
5227
|
// Notify "has" observers
|
|
5156
5228
|
// "in" as it may still exist in proto
|
|
5157
|
-
(_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_);
|
|
5158
5230
|
// Notify spies/listeners
|
|
5159
5231
|
if (notify || notifySpy) {
|
|
5160
5232
|
var _change2 = {
|
|
@@ -5195,7 +5267,7 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
5195
5267
|
return registerInterceptor(this, handler);
|
|
5196
5268
|
};
|
|
5197
5269
|
_proto.notifyPropertyAddition_ = function notifyPropertyAddition_(key, value) {
|
|
5198
|
-
var _this$pendingKeys_2
|
|
5270
|
+
var _this$pendingKeys_2;
|
|
5199
5271
|
var notify = hasListeners(this);
|
|
5200
5272
|
var notifySpy = isSpyEnabled();
|
|
5201
5273
|
if (notify || notifySpy) {
|
|
@@ -5217,7 +5289,7 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
5217
5289
|
spyReportEnd();
|
|
5218
5290
|
}
|
|
5219
5291
|
}
|
|
5220
|
-
(_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);
|
|
5221
5293
|
// Notify "keys/entries/values" observers
|
|
5222
5294
|
this.keysAtom_.reportChanged();
|
|
5223
5295
|
};
|
|
@@ -5279,7 +5351,7 @@ function recordAnnotationApplied(adm, annotation, key) {
|
|
|
5279
5351
|
adm.appliedAnnotations_[key] = annotation;
|
|
5280
5352
|
}
|
|
5281
5353
|
// Remove applied decorator annotation so we don't try to apply it again in subclass constructor
|
|
5282
|
-
(_adm$target_$storedAn = adm.target_[storedAnnotationsSymbol]) == null
|
|
5354
|
+
(_adm$target_$storedAn = adm.target_[storedAnnotationsSymbol]) == null || delete _adm$target_$storedAn[key];
|
|
5283
5355
|
}
|
|
5284
5356
|
function assertAnnotable(adm, annotation, key) {
|
|
5285
5357
|
// Valid annotation
|
|
@@ -5359,8 +5431,7 @@ inherit(StubArray, Array.prototype);
|
|
|
5359
5431
|
// Weex proto freeze protection was here,
|
|
5360
5432
|
// but it is unclear why the hack is need as MobX never changed the prototype
|
|
5361
5433
|
// anyway, so removed it in V6
|
|
5362
|
-
var LegacyObservableArray = /*#__PURE__*/function (_StubArray
|
|
5363
|
-
_inheritsLoose(LegacyObservableArray, _StubArray);
|
|
5434
|
+
var LegacyObservableArray = /*#__PURE__*/function (_StubArray) {
|
|
5364
5435
|
function LegacyObservableArray(initialValues, enhancer, name, owned) {
|
|
5365
5436
|
var _this;
|
|
5366
5437
|
if (name === void 0) {
|
|
@@ -5372,8 +5443,8 @@ var LegacyObservableArray = /*#__PURE__*/function (_StubArray, _Symbol$toStringT
|
|
|
5372
5443
|
_this = _StubArray.call(this) || this;
|
|
5373
5444
|
initObservable(function () {
|
|
5374
5445
|
var adm = new ObservableArrayAdministration(name, enhancer, owned, true);
|
|
5375
|
-
adm.proxy_ =
|
|
5376
|
-
addHiddenFinalProp(
|
|
5446
|
+
adm.proxy_ = _this;
|
|
5447
|
+
addHiddenFinalProp(_this, $mobx, adm);
|
|
5377
5448
|
if (initialValues && initialValues.length) {
|
|
5378
5449
|
// @ts-ignore
|
|
5379
5450
|
_this.spliceWithArray(0, 0, initialValues);
|
|
@@ -5381,11 +5452,12 @@ var LegacyObservableArray = /*#__PURE__*/function (_StubArray, _Symbol$toStringT
|
|
|
5381
5452
|
if (safariPrototypeSetterInheritanceBug) {
|
|
5382
5453
|
// Seems that Safari won't use numeric prototype setter until any * numeric property is
|
|
5383
5454
|
// defined on the instance. After that it works fine, even if this property is deleted.
|
|
5384
|
-
Object.defineProperty(
|
|
5455
|
+
Object.defineProperty(_this, "0", ENTRY_0);
|
|
5385
5456
|
}
|
|
5386
5457
|
});
|
|
5387
5458
|
return _this;
|
|
5388
5459
|
}
|
|
5460
|
+
_inheritsLoose(LegacyObservableArray, _StubArray);
|
|
5389
5461
|
var _proto = LegacyObservableArray.prototype;
|
|
5390
5462
|
_proto.concat = function concat() {
|
|
5391
5463
|
this[$mobx].atom_.reportObserved();
|
|
@@ -5398,7 +5470,7 @@ var LegacyObservableArray = /*#__PURE__*/function (_StubArray, _Symbol$toStringT
|
|
|
5398
5470
|
return isObservableArray(a) ? a.slice() : a;
|
|
5399
5471
|
}));
|
|
5400
5472
|
};
|
|
5401
|
-
_proto[
|
|
5473
|
+
_proto[Symbol.iterator] = function () {
|
|
5402
5474
|
var self = this;
|
|
5403
5475
|
var nextIndex = 0;
|
|
5404
5476
|
return makeIterable({
|
|
@@ -5413,7 +5485,7 @@ var LegacyObservableArray = /*#__PURE__*/function (_StubArray, _Symbol$toStringT
|
|
|
5413
5485
|
}
|
|
5414
5486
|
});
|
|
5415
5487
|
};
|
|
5416
|
-
_createClass(LegacyObservableArray, [{
|
|
5488
|
+
return _createClass(LegacyObservableArray, [{
|
|
5417
5489
|
key: "length",
|
|
5418
5490
|
get: function get() {
|
|
5419
5491
|
return this[$mobx].getArrayLength_();
|
|
@@ -5422,13 +5494,12 @@ var LegacyObservableArray = /*#__PURE__*/function (_StubArray, _Symbol$toStringT
|
|
|
5422
5494
|
this[$mobx].setArrayLength_(newLength);
|
|
5423
5495
|
}
|
|
5424
5496
|
}, {
|
|
5425
|
-
key:
|
|
5497
|
+
key: Symbol.toStringTag,
|
|
5426
5498
|
get: function get() {
|
|
5427
5499
|
return "Array";
|
|
5428
5500
|
}
|
|
5429
5501
|
}]);
|
|
5430
|
-
|
|
5431
|
-
}(StubArray, Symbol.toStringTag, Symbol.iterator);
|
|
5502
|
+
}(StubArray);
|
|
5432
5503
|
Object.entries(arrayExtensions).forEach(function (_ref) {
|
|
5433
5504
|
var prop = _ref[0],
|
|
5434
5505
|
fn = _ref[1];
|