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
package/dist/mobx.esm.js
CHANGED
|
@@ -204,10 +204,16 @@ function createInstanceofPredicate(name, theClass) {
|
|
|
204
204
|
};
|
|
205
205
|
}
|
|
206
206
|
function isES6Map(thing) {
|
|
207
|
-
return thing
|
|
207
|
+
return thing != null && Object.prototype.toString.call(thing) === "[object Map]";
|
|
208
|
+
}
|
|
209
|
+
function isPlainES6Map(thing) {
|
|
210
|
+
var mapProto = Object.getPrototypeOf(thing);
|
|
211
|
+
var objectProto = Object.getPrototypeOf(mapProto);
|
|
212
|
+
var nullProto = Object.getPrototypeOf(objectProto);
|
|
213
|
+
return nullProto === null;
|
|
208
214
|
}
|
|
209
215
|
function isES6Set(thing) {
|
|
210
|
-
return thing
|
|
216
|
+
return thing != null && Object.prototype.toString.call(thing) === "[object Set]";
|
|
211
217
|
}
|
|
212
218
|
var hasGetOwnPropertySymbols = typeof Object.getOwnPropertySymbols !== "undefined";
|
|
213
219
|
/**
|
|
@@ -258,99 +264,76 @@ var getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors || function get
|
|
|
258
264
|
return res;
|
|
259
265
|
};
|
|
260
266
|
|
|
261
|
-
function
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
Object.defineProperty(
|
|
274
|
-
writable:
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
284
|
-
target[key] = source[key];
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
return target;
|
|
289
|
-
};
|
|
290
|
-
return _extends.apply(this, arguments);
|
|
291
|
-
}
|
|
292
|
-
function _inheritsLoose(subClass, superClass) {
|
|
293
|
-
subClass.prototype = Object.create(superClass.prototype);
|
|
294
|
-
subClass.prototype.constructor = subClass;
|
|
295
|
-
_setPrototypeOf(subClass, superClass);
|
|
296
|
-
}
|
|
297
|
-
function _setPrototypeOf(o, p) {
|
|
298
|
-
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
299
|
-
o.__proto__ = p;
|
|
300
|
-
return o;
|
|
301
|
-
};
|
|
302
|
-
return _setPrototypeOf(o, p);
|
|
303
|
-
}
|
|
304
|
-
function _assertThisInitialized(self) {
|
|
305
|
-
if (self === void 0) {
|
|
306
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
307
|
-
}
|
|
308
|
-
return self;
|
|
309
|
-
}
|
|
310
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
311
|
-
if (!o) return;
|
|
312
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
313
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
314
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
315
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
316
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
317
|
-
}
|
|
318
|
-
function _arrayLikeToArray(arr, len) {
|
|
319
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
320
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
321
|
-
return arr2;
|
|
322
|
-
}
|
|
323
|
-
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
324
|
-
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
325
|
-
if (it) return (it = it.call(o)).next.bind(it);
|
|
326
|
-
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
327
|
-
if (it) o = it;
|
|
328
|
-
var i = 0;
|
|
267
|
+
function _arrayLikeToArray(r, a) {
|
|
268
|
+
(null == a || a > r.length) && (a = r.length);
|
|
269
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
270
|
+
return n;
|
|
271
|
+
}
|
|
272
|
+
function _defineProperties(e, r) {
|
|
273
|
+
for (var t = 0; t < r.length; t++) {
|
|
274
|
+
var o = r[t];
|
|
275
|
+
o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
function _createClass(e, r, t) {
|
|
279
|
+
return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
|
|
280
|
+
writable: !1
|
|
281
|
+
}), e;
|
|
282
|
+
}
|
|
283
|
+
function _createForOfIteratorHelperLoose(r, e) {
|
|
284
|
+
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
285
|
+
if (t) return (t = t.call(r)).next.bind(t);
|
|
286
|
+
if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) {
|
|
287
|
+
t && (r = t);
|
|
288
|
+
var o = 0;
|
|
329
289
|
return function () {
|
|
330
|
-
|
|
331
|
-
done:
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
value: o[i++]
|
|
290
|
+
return o >= r.length ? {
|
|
291
|
+
done: !0
|
|
292
|
+
} : {
|
|
293
|
+
done: !1,
|
|
294
|
+
value: r[o++]
|
|
336
295
|
};
|
|
337
296
|
};
|
|
338
297
|
}
|
|
339
298
|
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
340
299
|
}
|
|
341
|
-
function
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
300
|
+
function _extends() {
|
|
301
|
+
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
302
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
303
|
+
var t = arguments[e];
|
|
304
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
305
|
+
}
|
|
306
|
+
return n;
|
|
307
|
+
}, _extends.apply(null, arguments);
|
|
308
|
+
}
|
|
309
|
+
function _inheritsLoose(t, o) {
|
|
310
|
+
t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o);
|
|
311
|
+
}
|
|
312
|
+
function _setPrototypeOf(t, e) {
|
|
313
|
+
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
|
|
314
|
+
return t.__proto__ = e, t;
|
|
315
|
+
}, _setPrototypeOf(t, e);
|
|
316
|
+
}
|
|
317
|
+
function _toPrimitive(t, r) {
|
|
318
|
+
if ("object" != typeof t || !t) return t;
|
|
319
|
+
var e = t[Symbol.toPrimitive];
|
|
320
|
+
if (void 0 !== e) {
|
|
321
|
+
var i = e.call(t, r || "default");
|
|
322
|
+
if ("object" != typeof i) return i;
|
|
347
323
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
348
324
|
}
|
|
349
|
-
return (
|
|
325
|
+
return ("string" === r ? String : Number)(t);
|
|
350
326
|
}
|
|
351
|
-
function _toPropertyKey(
|
|
352
|
-
var
|
|
353
|
-
return
|
|
327
|
+
function _toPropertyKey(t) {
|
|
328
|
+
var i = _toPrimitive(t, "string");
|
|
329
|
+
return "symbol" == typeof i ? i : i + "";
|
|
330
|
+
}
|
|
331
|
+
function _unsupportedIterableToArray(r, a) {
|
|
332
|
+
if (r) {
|
|
333
|
+
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
334
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
335
|
+
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
|
|
336
|
+
}
|
|
354
337
|
}
|
|
355
338
|
|
|
356
339
|
var storedAnnotationsSymbol = /*#__PURE__*/Symbol("mobx-stored-annotations");
|
|
@@ -423,8 +406,6 @@ function assert20223DecoratorType(context, types) {
|
|
|
423
406
|
|
|
424
407
|
var $mobx = /*#__PURE__*/Symbol("mobx administration");
|
|
425
408
|
var Atom = /*#__PURE__*/function () {
|
|
426
|
-
// for effective unobserving. BaseAtom has true, for extra optimization, so its onBecomeUnobserved never gets called, because it's not needed
|
|
427
|
-
|
|
428
409
|
/**
|
|
429
410
|
* Create a new atom. For debugging purposes it is recommended to give it a name.
|
|
430
411
|
* The onBecomeObserved and onBecomeUnobserved callbacks can be used for resource management.
|
|
@@ -435,16 +416,18 @@ var Atom = /*#__PURE__*/function () {
|
|
|
435
416
|
}
|
|
436
417
|
this.name_ = void 0;
|
|
437
418
|
this.isPendingUnobservation = false;
|
|
419
|
+
// for effective unobserving. BaseAtom has true, for extra optimization, so its onBecomeUnobserved never gets called, because it's not needed
|
|
438
420
|
this.isBeingObserved = false;
|
|
439
421
|
this.observers_ = new Set();
|
|
440
422
|
this.diffValue_ = 0;
|
|
441
423
|
this.lastAccessedBy_ = 0;
|
|
442
424
|
this.lowestObserverState_ = IDerivationState_.NOT_TRACKING_;
|
|
425
|
+
// onBecomeObservedListeners
|
|
443
426
|
this.onBOL = void 0;
|
|
427
|
+
// onBecomeUnobservedListeners
|
|
444
428
|
this.onBUOL = void 0;
|
|
445
429
|
this.name_ = name_;
|
|
446
430
|
}
|
|
447
|
-
// onBecomeObservedListeners
|
|
448
431
|
var _proto = Atom.prototype;
|
|
449
432
|
_proto.onBO = function onBO() {
|
|
450
433
|
if (this.onBOL) {
|
|
@@ -626,7 +609,6 @@ function make_(adm, key) {
|
|
|
626
609
|
}
|
|
627
610
|
return 0 /* MakeResult.Cancel */;
|
|
628
611
|
}
|
|
629
|
-
|
|
630
612
|
function extend_(adm, key, descriptor, proxyTrap) {
|
|
631
613
|
die("'" + this.annotationType_ + "' can only be used with 'makeObservable'");
|
|
632
614
|
}
|
|
@@ -659,12 +641,10 @@ function make_$1(adm, key, descriptor, source) {
|
|
|
659
641
|
// rest of the proto chain must be annotated already
|
|
660
642
|
return 1 /* MakeResult.Break */;
|
|
661
643
|
}
|
|
662
|
-
|
|
663
644
|
var actionDescriptor = createActionDescriptor(adm, this, key, descriptor, false);
|
|
664
645
|
defineProperty(source, key, actionDescriptor);
|
|
665
646
|
return 2 /* MakeResult.Continue */;
|
|
666
647
|
}
|
|
667
|
-
|
|
668
648
|
function extend_$1(adm, key, descriptor, proxyTrap) {
|
|
669
649
|
var actionDescriptor = createActionDescriptor(adm, this, key, descriptor);
|
|
670
650
|
return adm.defineProperty_(key, actionDescriptor, proxyTrap);
|
|
@@ -762,18 +742,15 @@ function make_$2(adm, key, descriptor, source) {
|
|
|
762
742
|
return 0 /* MakeResult.Cancel */;
|
|
763
743
|
}
|
|
764
744
|
}
|
|
765
|
-
|
|
766
745
|
if (isFlow(descriptor.value)) {
|
|
767
746
|
// A prototype could have been annotated already by other constructor,
|
|
768
747
|
// rest of the proto chain must be annotated already
|
|
769
748
|
return 1 /* MakeResult.Break */;
|
|
770
749
|
}
|
|
771
|
-
|
|
772
750
|
var flowDescriptor = createFlowDescriptor(adm, this, key, descriptor, false, false);
|
|
773
751
|
defineProperty(source, key, flowDescriptor);
|
|
774
752
|
return 2 /* MakeResult.Continue */;
|
|
775
753
|
}
|
|
776
|
-
|
|
777
754
|
function extend_$2(adm, key, descriptor, proxyTrap) {
|
|
778
755
|
var _this$options_2;
|
|
779
756
|
var flowDescriptor = createFlowDescriptor(adm, this, key, descriptor, (_this$options_2 = this.options_) == null ? void 0 : _this$options_2.bound);
|
|
@@ -850,7 +827,6 @@ function createComputedAnnotation(name, options) {
|
|
|
850
827
|
function make_$3(adm, key, descriptor) {
|
|
851
828
|
return this.extend_(adm, key, descriptor, false) === null ? 0 /* MakeResult.Cancel */ : 1 /* MakeResult.Break */;
|
|
852
829
|
}
|
|
853
|
-
|
|
854
830
|
function extend_$3(adm, key, descriptor, proxyTrap) {
|
|
855
831
|
assertComputedDescriptor(adm, this, key, descriptor);
|
|
856
832
|
return adm.defineComputedProperty_(key, _extends({}, this.options_, {
|
|
@@ -898,7 +874,6 @@ function createObservableAnnotation(name, options) {
|
|
|
898
874
|
function make_$4(adm, key, descriptor) {
|
|
899
875
|
return this.extend_(adm, key, descriptor, false) === null ? 0 /* MakeResult.Cancel */ : 1 /* MakeResult.Break */;
|
|
900
876
|
}
|
|
901
|
-
|
|
902
877
|
function extend_$4(adm, key, descriptor, proxyTrap) {
|
|
903
878
|
var _this$options_$enhanc, _this$options_;
|
|
904
879
|
assertObservableDescriptor(adm, this, key, descriptor);
|
|
@@ -1318,11 +1293,8 @@ function allowStateChangesEnd(prev) {
|
|
|
1318
1293
|
globalState.allowStateChanges = prev;
|
|
1319
1294
|
}
|
|
1320
1295
|
|
|
1321
|
-
var _Symbol$toPrimitive;
|
|
1322
1296
|
var CREATE = "create";
|
|
1323
|
-
_Symbol$toPrimitive = Symbol.toPrimitive;
|
|
1324
1297
|
var ObservableValue = /*#__PURE__*/function (_Atom) {
|
|
1325
|
-
_inheritsLoose(ObservableValue, _Atom);
|
|
1326
1298
|
function ObservableValue(value, enhancer, name_, notifySpy, equals) {
|
|
1327
1299
|
var _this;
|
|
1328
1300
|
if (name_ === void 0) {
|
|
@@ -1351,7 +1323,7 @@ var ObservableValue = /*#__PURE__*/function (_Atom) {
|
|
|
1351
1323
|
// only notify spy if this is a stand-alone observable
|
|
1352
1324
|
spyReport({
|
|
1353
1325
|
type: CREATE,
|
|
1354
|
-
object:
|
|
1326
|
+
object: _this,
|
|
1355
1327
|
observableKind: "value",
|
|
1356
1328
|
debugObjectName: _this.name_,
|
|
1357
1329
|
newValue: "" + _this.value_
|
|
@@ -1359,6 +1331,7 @@ var ObservableValue = /*#__PURE__*/function (_Atom) {
|
|
|
1359
1331
|
}
|
|
1360
1332
|
return _this;
|
|
1361
1333
|
}
|
|
1334
|
+
_inheritsLoose(ObservableValue, _Atom);
|
|
1362
1335
|
var _proto = ObservableValue.prototype;
|
|
1363
1336
|
_proto.dehanceValue = function dehanceValue(value) {
|
|
1364
1337
|
if (this.dehancer !== undefined) {
|
|
@@ -1450,14 +1423,13 @@ var ObservableValue = /*#__PURE__*/function (_Atom) {
|
|
|
1450
1423
|
_proto.valueOf = function valueOf() {
|
|
1451
1424
|
return toPrimitive(this.get());
|
|
1452
1425
|
};
|
|
1453
|
-
_proto[
|
|
1426
|
+
_proto[Symbol.toPrimitive] = function () {
|
|
1454
1427
|
return this.valueOf();
|
|
1455
1428
|
};
|
|
1456
1429
|
return ObservableValue;
|
|
1457
1430
|
}(Atom);
|
|
1458
1431
|
var isObservableValue = /*#__PURE__*/createInstanceofPredicate("ObservableValue", ObservableValue);
|
|
1459
1432
|
|
|
1460
|
-
var _Symbol$toPrimitive$1;
|
|
1461
1433
|
function getFlag(flags, mask) {
|
|
1462
1434
|
return !!(flags & mask);
|
|
1463
1435
|
}
|
|
@@ -1488,13 +1460,7 @@ function setFlag(flags, mask, newValue) {
|
|
|
1488
1460
|
*
|
|
1489
1461
|
* If at any point it's outside batch and it isn't observed: reset everything and go to 1.
|
|
1490
1462
|
*/
|
|
1491
|
-
_Symbol$toPrimitive$1 = Symbol.toPrimitive;
|
|
1492
1463
|
var ComputedValue = /*#__PURE__*/function () {
|
|
1493
|
-
// nodes we are looking at. Our value depends on these nodes
|
|
1494
|
-
// during tracking it's an array with new observed observers
|
|
1495
|
-
|
|
1496
|
-
// N.B: unminified as it is used by MST
|
|
1497
|
-
|
|
1498
1464
|
/**
|
|
1499
1465
|
* Create a new computed value based on a function expression.
|
|
1500
1466
|
*
|
|
@@ -1510,7 +1476,9 @@ var ComputedValue = /*#__PURE__*/function () {
|
|
|
1510
1476
|
function ComputedValue(options) {
|
|
1511
1477
|
this.dependenciesState_ = IDerivationState_.NOT_TRACKING_;
|
|
1512
1478
|
this.observing_ = [];
|
|
1479
|
+
// nodes we are looking at. Our value depends on these nodes
|
|
1513
1480
|
this.newObserving_ = null;
|
|
1481
|
+
// during tracking it's an array with new observed observers
|
|
1514
1482
|
this.observers_ = new Set();
|
|
1515
1483
|
this.diffValue_ = 0;
|
|
1516
1484
|
this.runId_ = 0;
|
|
@@ -1522,6 +1490,7 @@ var ComputedValue = /*#__PURE__*/function () {
|
|
|
1522
1490
|
this.triggeredBy_ = void 0;
|
|
1523
1491
|
this.flags_ = 0;
|
|
1524
1492
|
this.derivation = void 0;
|
|
1493
|
+
// N.B: unminified as it is used by MST
|
|
1525
1494
|
this.setter_ = void 0;
|
|
1526
1495
|
this.isTracing_ = TraceMode.NONE;
|
|
1527
1496
|
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
|
if (!(process.env.NODE_ENV !== "production")) {
|
|
1851
1817
|
return;
|
|
@@ -2022,28 +1988,113 @@ function changeDependenciesStateTo0(derivation) {
|
|
|
2022
1988
|
*/
|
|
2023
1989
|
var persistentKeys = ["mobxGuid", "spyListeners", "enforceActions", "computedRequiresReaction", "reactionRequiresObservable", "observableRequiresReaction", "allowStateReads", "disableErrorBoundaries", "runId", "UNCHANGED", "useProxies"];
|
|
2024
1990
|
var MobXGlobals = function MobXGlobals() {
|
|
1991
|
+
/**
|
|
1992
|
+
* MobXGlobals version.
|
|
1993
|
+
* MobX compatiblity with other versions loaded in memory as long as this version matches.
|
|
1994
|
+
* It indicates that the global state still stores similar information
|
|
1995
|
+
*
|
|
1996
|
+
* N.B: this version is unrelated to the package version of MobX, and is only the version of the
|
|
1997
|
+
* internal state storage of MobX, and can be the same across many different package versions
|
|
1998
|
+
*/
|
|
2025
1999
|
this.version = 6;
|
|
2000
|
+
/**
|
|
2001
|
+
* globally unique token to signal unchanged
|
|
2002
|
+
*/
|
|
2026
2003
|
this.UNCHANGED = {};
|
|
2004
|
+
/**
|
|
2005
|
+
* Currently running derivation
|
|
2006
|
+
*/
|
|
2027
2007
|
this.trackingDerivation = null;
|
|
2008
|
+
/**
|
|
2009
|
+
* Currently running reaction. This determines if we currently have a reactive context.
|
|
2010
|
+
* (Tracking derivation is also set for temporal tracking of computed values inside actions,
|
|
2011
|
+
* but trackingReaction can only be set by a form of Reaction)
|
|
2012
|
+
*/
|
|
2028
2013
|
this.trackingContext = null;
|
|
2014
|
+
/**
|
|
2015
|
+
* Each time a derivation is tracked, it is assigned a unique run-id
|
|
2016
|
+
*/
|
|
2029
2017
|
this.runId = 0;
|
|
2018
|
+
/**
|
|
2019
|
+
* 'guid' for general purpose. Will be persisted amongst resets.
|
|
2020
|
+
*/
|
|
2030
2021
|
this.mobxGuid = 0;
|
|
2022
|
+
/**
|
|
2023
|
+
* Are we in a batch block? (and how many of them)
|
|
2024
|
+
*/
|
|
2031
2025
|
this.inBatch = 0;
|
|
2026
|
+
/**
|
|
2027
|
+
* Observables that don't have observers anymore, and are about to be
|
|
2028
|
+
* suspended, unless somebody else accesses it in the same batch
|
|
2029
|
+
*
|
|
2030
|
+
* @type {IObservable[]}
|
|
2031
|
+
*/
|
|
2032
2032
|
this.pendingUnobservations = [];
|
|
2033
|
+
/**
|
|
2034
|
+
* List of scheduled, not yet executed, reactions.
|
|
2035
|
+
*/
|
|
2033
2036
|
this.pendingReactions = [];
|
|
2037
|
+
/**
|
|
2038
|
+
* Are we currently processing reactions?
|
|
2039
|
+
*/
|
|
2034
2040
|
this.isRunningReactions = false;
|
|
2041
|
+
/**
|
|
2042
|
+
* Is it allowed to change observables at this point?
|
|
2043
|
+
* In general, MobX doesn't allow that when running computations and React.render.
|
|
2044
|
+
* To ensure that those functions stay pure.
|
|
2045
|
+
*/
|
|
2035
2046
|
this.allowStateChanges = false;
|
|
2047
|
+
/**
|
|
2048
|
+
* Is it allowed to read observables at this point?
|
|
2049
|
+
* Used to hold the state needed for `observableRequiresReaction`
|
|
2050
|
+
*/
|
|
2036
2051
|
this.allowStateReads = true;
|
|
2052
|
+
/**
|
|
2053
|
+
* If strict mode is enabled, state changes are by default not allowed
|
|
2054
|
+
*/
|
|
2037
2055
|
this.enforceActions = true;
|
|
2056
|
+
/**
|
|
2057
|
+
* Spy callbacks
|
|
2058
|
+
*/
|
|
2038
2059
|
this.spyListeners = [];
|
|
2060
|
+
/**
|
|
2061
|
+
* Globally attached error handlers that react specifically to errors in reactions
|
|
2062
|
+
*/
|
|
2039
2063
|
this.globalReactionErrorHandlers = [];
|
|
2064
|
+
/**
|
|
2065
|
+
* Warn if computed values are accessed outside a reactive context
|
|
2066
|
+
*/
|
|
2040
2067
|
this.computedRequiresReaction = false;
|
|
2068
|
+
/**
|
|
2069
|
+
* (Experimental)
|
|
2070
|
+
* Warn if you try to create to derivation / reactive context without accessing any observable.
|
|
2071
|
+
*/
|
|
2041
2072
|
this.reactionRequiresObservable = false;
|
|
2073
|
+
/**
|
|
2074
|
+
* (Experimental)
|
|
2075
|
+
* Warn if observables are accessed outside a reactive context
|
|
2076
|
+
*/
|
|
2042
2077
|
this.observableRequiresReaction = false;
|
|
2078
|
+
/*
|
|
2079
|
+
* Don't catch and rethrow exceptions. This is useful for inspecting the state of
|
|
2080
|
+
* the stack when an exception occurs while debugging.
|
|
2081
|
+
*/
|
|
2043
2082
|
this.disableErrorBoundaries = false;
|
|
2083
|
+
/*
|
|
2084
|
+
* If true, we are already handling an exception in an action. Any errors in reactions should be suppressed, as
|
|
2085
|
+
* they are not the cause, see: https://github.com/mobxjs/mobx/issues/1836
|
|
2086
|
+
*/
|
|
2044
2087
|
this.suppressReactionErrors = false;
|
|
2045
2088
|
this.useProxies = true;
|
|
2089
|
+
/*
|
|
2090
|
+
* print warnings about code that would fail if proxies weren't available
|
|
2091
|
+
*/
|
|
2046
2092
|
this.verifyProxies = false;
|
|
2093
|
+
/**
|
|
2094
|
+
* False forces all object's descriptors to
|
|
2095
|
+
* writable: true
|
|
2096
|
+
* configurable: true
|
|
2097
|
+
*/
|
|
2047
2098
|
this.safeDescriptors = true;
|
|
2048
2099
|
};
|
|
2049
2100
|
var canMergeGlobalState = true;
|
|
@@ -2140,7 +2191,6 @@ function addObserver(observable, node) {
|
|
|
2140
2191
|
// invariantObservers(observable);
|
|
2141
2192
|
// invariant(observable._observers.indexOf(node) !== -1, "INTERNAL ERROR didn't add node");
|
|
2142
2193
|
}
|
|
2143
|
-
|
|
2144
2194
|
function removeObserver(observable, node) {
|
|
2145
2195
|
// invariant(globalState.inBatch > 0, "INTERNAL ERROR, remove should be called only inside batch");
|
|
2146
2196
|
// invariant(observable._observers.indexOf(node) !== -1, "INTERNAL ERROR remove already removed node");
|
|
@@ -2153,7 +2203,6 @@ function removeObserver(observable, node) {
|
|
|
2153
2203
|
// invariantObservers(observable);
|
|
2154
2204
|
// invariant(observable._observers.indexOf(node) === -1, "INTERNAL ERROR remove already removed node2");
|
|
2155
2205
|
}
|
|
2156
|
-
|
|
2157
2206
|
function queueForUnobservation(observable) {
|
|
2158
2207
|
if (observable.isPendingUnobservation === false) {
|
|
2159
2208
|
// invariant(observable._observers.length === 0, "INTERNAL ERROR, should only queue for unobservation unobserved observables");
|
|
@@ -2291,7 +2340,6 @@ function propagateMaybeChanged(observable) {
|
|
|
2291
2340
|
});
|
|
2292
2341
|
// invariantLOS(observable, "maybe end");
|
|
2293
2342
|
}
|
|
2294
|
-
|
|
2295
2343
|
function logTraceInfo(derivation, observable) {
|
|
2296
2344
|
console.log("[mobx.trace] '" + derivation.name_ + "' is invalidated due to a change in: '" + observable.name_ + "'");
|
|
2297
2345
|
if (derivation.isTracing_ === TraceMode.BREAK) {
|
|
@@ -2315,8 +2363,6 @@ function printDepTree(tree, lines, depth) {
|
|
|
2315
2363
|
}
|
|
2316
2364
|
|
|
2317
2365
|
var Reaction = /*#__PURE__*/function () {
|
|
2318
|
-
// nodes we are looking at. Our value depends on these nodes
|
|
2319
|
-
|
|
2320
2366
|
function Reaction(name_, onInvalidate_, errorHandler_, requiresObservable_) {
|
|
2321
2367
|
if (name_ === void 0) {
|
|
2322
2368
|
name_ = process.env.NODE_ENV !== "production" ? "Reaction@" + getNextId() : "Reaction";
|
|
@@ -2326,6 +2372,7 @@ var Reaction = /*#__PURE__*/function () {
|
|
|
2326
2372
|
this.errorHandler_ = void 0;
|
|
2327
2373
|
this.requiresObservable_ = void 0;
|
|
2328
2374
|
this.observing_ = [];
|
|
2375
|
+
// nodes we are looking at. Our value depends on these nodes
|
|
2329
2376
|
this.newObserving_ = [];
|
|
2330
2377
|
this.dependenciesState_ = IDerivationState_.NOT_TRACKING_;
|
|
2331
2378
|
this.diffValue_ = 0;
|
|
@@ -2388,7 +2435,6 @@ var Reaction = /*#__PURE__*/function () {
|
|
|
2388
2435
|
return;
|
|
2389
2436
|
// console.warn("Reaction already disposed") // Note: Not a warning / error in mobx 4 either
|
|
2390
2437
|
}
|
|
2391
|
-
|
|
2392
2438
|
startBatch();
|
|
2393
2439
|
var notify = isSpyEnabled();
|
|
2394
2440
|
var startTime;
|
|
@@ -2463,9 +2509,9 @@ var Reaction = /*#__PURE__*/function () {
|
|
|
2463
2509
|
var _this2 = this;
|
|
2464
2510
|
var dispose = function dispose() {
|
|
2465
2511
|
_this2.dispose();
|
|
2466
|
-
abortSignal == null
|
|
2512
|
+
abortSignal == null || abortSignal.removeEventListener == null || abortSignal.removeEventListener("abort", dispose);
|
|
2467
2513
|
};
|
|
2468
|
-
abortSignal == null
|
|
2514
|
+
abortSignal == null || abortSignal.addEventListener == null || abortSignal.addEventListener("abort", dispose);
|
|
2469
2515
|
dispose[$mobx] = this;
|
|
2470
2516
|
return dispose;
|
|
2471
2517
|
};
|
|
@@ -2517,7 +2563,6 @@ function runReactionsHelper() {
|
|
|
2517
2563
|
console.error(process.env.NODE_ENV !== "production" ? "Reaction doesn't converge to a stable state after " + MAX_REACTION_ITERATIONS + " iterations." + (" Probably there is a cycle in the reactive function: " + allReactions[0]) : "[mobx] cycle in reaction: " + allReactions[0]);
|
|
2518
2564
|
allReactions.splice(0); // clear reactions
|
|
2519
2565
|
}
|
|
2520
|
-
|
|
2521
2566
|
var remainingReactions = allReactions.splice(0);
|
|
2522
2567
|
for (var i = 0, l = remainingReactions.length; i < l; i++) {
|
|
2523
2568
|
remainingReactions[i].runReaction_();
|
|
@@ -2657,7 +2702,7 @@ function isAction(thing) {
|
|
|
2657
2702
|
* @returns disposer function, which can be used to stop the view from being updated in the future.
|
|
2658
2703
|
*/
|
|
2659
2704
|
function autorun(view, opts) {
|
|
2660
|
-
var _opts$name, _opts, _opts2,
|
|
2705
|
+
var _opts$name, _opts, _opts2, _opts3;
|
|
2661
2706
|
if (opts === void 0) {
|
|
2662
2707
|
opts = EMPTY_OBJECT;
|
|
2663
2708
|
}
|
|
@@ -2696,7 +2741,7 @@ function autorun(view, opts) {
|
|
|
2696
2741
|
function reactionRunner() {
|
|
2697
2742
|
view(reaction);
|
|
2698
2743
|
}
|
|
2699
|
-
if (!((_opts2 = opts) != null && (_opts2
|
|
2744
|
+
if (!((_opts2 = opts) != null && (_opts2 = _opts2.signal) != null && _opts2.aborted)) {
|
|
2700
2745
|
reaction.schedule_();
|
|
2701
2746
|
}
|
|
2702
2747
|
return reaction.getDisposer_((_opts3 = opts) == null ? void 0 : _opts3.signal);
|
|
@@ -2710,7 +2755,7 @@ function createSchedulerFromOptions(opts) {
|
|
|
2710
2755
|
} : run;
|
|
2711
2756
|
}
|
|
2712
2757
|
function reaction(expression, effect, opts) {
|
|
2713
|
-
var _opts$name2, _opts4,
|
|
2758
|
+
var _opts$name2, _opts4, _opts5;
|
|
2714
2759
|
if (opts === void 0) {
|
|
2715
2760
|
opts = EMPTY_OBJECT;
|
|
2716
2761
|
}
|
|
@@ -2759,7 +2804,7 @@ function reaction(expression, effect, opts) {
|
|
|
2759
2804
|
}
|
|
2760
2805
|
firstTime = false;
|
|
2761
2806
|
}
|
|
2762
|
-
if (!((_opts4 = opts) != null && (_opts4
|
|
2807
|
+
if (!((_opts4 = opts) != null && (_opts4 = _opts4.signal) != null && _opts4.aborted)) {
|
|
2763
2808
|
r.schedule_();
|
|
2764
2809
|
}
|
|
2765
2810
|
return r.getDisposer_((_opts5 = opts) == null ? void 0 : _opts5.signal);
|
|
@@ -2968,7 +3013,6 @@ var flow = /*#__PURE__*/Object.assign(function flow(arg1, arg2) {
|
|
|
2968
3013
|
}
|
|
2969
3014
|
onFulfilled(undefined); // kick off the process
|
|
2970
3015
|
});
|
|
2971
|
-
|
|
2972
3016
|
promise.cancel = action(name + " - runid: " + runId + " - cancel", function () {
|
|
2973
3017
|
try {
|
|
2974
3018
|
if (pendingPromise) {
|
|
@@ -2986,7 +3030,6 @@ var flow = /*#__PURE__*/Object.assign(function flow(arg1, arg2) {
|
|
|
2986
3030
|
rejector(e); // there could be a throwing finally block
|
|
2987
3031
|
}
|
|
2988
3032
|
});
|
|
2989
|
-
|
|
2990
3033
|
return promise;
|
|
2991
3034
|
};
|
|
2992
3035
|
res.isMobXFlow = true;
|
|
@@ -3001,7 +3044,6 @@ function cancelPromise(promise) {
|
|
|
3001
3044
|
function flowResult(result) {
|
|
3002
3045
|
return result; // just tricking TypeScript :)
|
|
3003
3046
|
}
|
|
3004
|
-
|
|
3005
3047
|
function isFlow(fn) {
|
|
3006
3048
|
return (fn == null ? void 0 : fn.isMobXFlow) === true;
|
|
3007
3049
|
}
|
|
@@ -3426,10 +3468,10 @@ function whenPromise(predicate, opts) {
|
|
|
3426
3468
|
disposer();
|
|
3427
3469
|
reject(new Error("WHEN_ABORTED"));
|
|
3428
3470
|
};
|
|
3429
|
-
opts == null
|
|
3471
|
+
opts == null || (_opts$signal2 = opts.signal) == null || _opts$signal2.addEventListener == null || _opts$signal2.addEventListener("abort", abort);
|
|
3430
3472
|
})["finally"](function () {
|
|
3431
3473
|
var _opts$signal3;
|
|
3432
|
-
return opts == null
|
|
3474
|
+
return opts == null || (_opts$signal3 = opts.signal) == null || _opts$signal3.removeEventListener == null ? void 0 : _opts$signal3.removeEventListener("abort", abort);
|
|
3433
3475
|
});
|
|
3434
3476
|
res.cancel = cancel;
|
|
3435
3477
|
return res;
|
|
@@ -3646,8 +3688,6 @@ var arrayTraps = {
|
|
|
3646
3688
|
}
|
|
3647
3689
|
};
|
|
3648
3690
|
var ObservableArrayAdministration = /*#__PURE__*/function () {
|
|
3649
|
-
// this is the prop that gets proxied, so can't replace it!
|
|
3650
|
-
|
|
3651
3691
|
function ObservableArrayAdministration(name, enhancer, owned_, legacyMode_) {
|
|
3652
3692
|
if (name === void 0) {
|
|
3653
3693
|
name = process.env.NODE_ENV !== "production" ? "ObservableArray@" + getNextId() : "ObservableArray";
|
|
@@ -3656,6 +3696,7 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
|
|
|
3656
3696
|
this.legacyMode_ = void 0;
|
|
3657
3697
|
this.atom_ = void 0;
|
|
3658
3698
|
this.values_ = [];
|
|
3699
|
+
// this is the prop that gets proxied, so can't replace it!
|
|
3659
3700
|
this.interceptors_ = void 0;
|
|
3660
3701
|
this.changeListeners_ = void 0;
|
|
3661
3702
|
this.enhancer_ = void 0;
|
|
@@ -3776,7 +3817,6 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
|
|
|
3776
3817
|
var lengthDelta = newItems.length - deleteCount;
|
|
3777
3818
|
this.updateArrayLength_(length, lengthDelta); // checks if internal array wasn't modified
|
|
3778
3819
|
}
|
|
3779
|
-
|
|
3780
3820
|
var res = this.spliceItemsIntoValues_(index, deleteCount, newItems);
|
|
3781
3821
|
if (deleteCount !== 0 || newItems.length !== 0) {
|
|
3782
3822
|
this.notifyArraySplice_(index, newItems, res);
|
|
@@ -3876,6 +3916,7 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
|
|
|
3876
3916
|
var change = interceptChange(this, {
|
|
3877
3917
|
type: UPDATE,
|
|
3878
3918
|
object: this.proxy_,
|
|
3919
|
+
// since "this" is the real array we need to pass its proxy
|
|
3879
3920
|
index: index,
|
|
3880
3921
|
newValue: newValue
|
|
3881
3922
|
});
|
|
@@ -4091,17 +4132,12 @@ function isObservableArray(thing) {
|
|
|
4091
4132
|
return isObject(thing) && isObservableArrayAdministration(thing[$mobx]);
|
|
4092
4133
|
}
|
|
4093
4134
|
|
|
4094
|
-
var _Symbol$iterator, _Symbol$toStringTag;
|
|
4095
4135
|
var ObservableMapMarker = {};
|
|
4096
4136
|
var ADD = "add";
|
|
4097
4137
|
var DELETE = "delete";
|
|
4098
4138
|
// just extend Map? See also https://gist.github.com/nestharus/13b4d74f2ef4a2f4357dbd3fc23c1e54
|
|
4099
4139
|
// But: https://github.com/mobxjs/mobx/issues/1556
|
|
4100
|
-
_Symbol$iterator = Symbol.iterator;
|
|
4101
|
-
_Symbol$toStringTag = Symbol.toStringTag;
|
|
4102
4140
|
var ObservableMap = /*#__PURE__*/function () {
|
|
4103
|
-
// hasMap, not hashMap >-).
|
|
4104
|
-
|
|
4105
4141
|
function ObservableMap(initialData, enhancer_, name_) {
|
|
4106
4142
|
var _this = this;
|
|
4107
4143
|
if (enhancer_ === void 0) {
|
|
@@ -4115,6 +4151,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4115
4151
|
this[$mobx] = ObservableMapMarker;
|
|
4116
4152
|
this.data_ = void 0;
|
|
4117
4153
|
this.hasMap_ = void 0;
|
|
4154
|
+
// hasMap, not hashMap >-).
|
|
4118
4155
|
this.keysAtom_ = void 0;
|
|
4119
4156
|
this.interceptors_ = void 0;
|
|
4120
4157
|
this.changeListeners_ = void 0;
|
|
@@ -4203,7 +4240,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4203
4240
|
transaction(function () {
|
|
4204
4241
|
var _this3$hasMap_$get;
|
|
4205
4242
|
_this3.keysAtom_.reportChanged();
|
|
4206
|
-
(_this3$hasMap_$get = _this3.hasMap_.get(key)) == null
|
|
4243
|
+
(_this3$hasMap_$get = _this3.hasMap_.get(key)) == null || _this3$hasMap_$get.setNewValue_(false);
|
|
4207
4244
|
var observable = _this3.data_.get(key);
|
|
4208
4245
|
observable.setNewValue_(undefined);
|
|
4209
4246
|
_this3.data_["delete"](key);
|
|
@@ -4253,7 +4290,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4253
4290
|
var observable = new ObservableValue(newValue, _this4.enhancer_, process.env.NODE_ENV !== "production" ? _this4.name_ + "." + stringifyKey(key) : "ObservableMap.key", false);
|
|
4254
4291
|
_this4.data_.set(key, observable);
|
|
4255
4292
|
newValue = observable.value_; // value might have been changed
|
|
4256
|
-
(_this4$hasMap_$get = _this4.hasMap_.get(key)) == null
|
|
4293
|
+
(_this4$hasMap_$get = _this4.hasMap_.get(key)) == null || _this4$hasMap_$get.setNewValue_(true);
|
|
4257
4294
|
_this4.keysAtom_.reportChanged();
|
|
4258
4295
|
});
|
|
4259
4296
|
var notifySpy = isSpyEnabled();
|
|
@@ -4322,7 +4359,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4322
4359
|
}
|
|
4323
4360
|
});
|
|
4324
4361
|
};
|
|
4325
|
-
_proto[
|
|
4362
|
+
_proto[Symbol.iterator] = function () {
|
|
4326
4363
|
return this.entries();
|
|
4327
4364
|
};
|
|
4328
4365
|
_proto.forEach = function forEach(callback, thisArg) {
|
|
@@ -4351,7 +4388,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4351
4388
|
return _this5.set(key, value);
|
|
4352
4389
|
});
|
|
4353
4390
|
} else if (isES6Map(other)) {
|
|
4354
|
-
if (other
|
|
4391
|
+
if (!isPlainES6Map(other)) {
|
|
4355
4392
|
die(19, other);
|
|
4356
4393
|
}
|
|
4357
4394
|
other.forEach(function (value, key) {
|
|
@@ -4476,19 +4513,18 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4476
4513
|
_proto.intercept_ = function intercept_(handler) {
|
|
4477
4514
|
return registerInterceptor(this, handler);
|
|
4478
4515
|
};
|
|
4479
|
-
_createClass(ObservableMap, [{
|
|
4516
|
+
return _createClass(ObservableMap, [{
|
|
4480
4517
|
key: "size",
|
|
4481
4518
|
get: function get() {
|
|
4482
4519
|
this.keysAtom_.reportObserved();
|
|
4483
4520
|
return this.data_.size;
|
|
4484
4521
|
}
|
|
4485
4522
|
}, {
|
|
4486
|
-
key:
|
|
4523
|
+
key: Symbol.toStringTag,
|
|
4487
4524
|
get: function get() {
|
|
4488
4525
|
return "Map";
|
|
4489
4526
|
}
|
|
4490
4527
|
}]);
|
|
4491
|
-
return ObservableMap;
|
|
4492
4528
|
}();
|
|
4493
4529
|
// eslint-disable-next-line
|
|
4494
4530
|
var isObservableMap = /*#__PURE__*/createInstanceofPredicate("ObservableMap", ObservableMap);
|
|
@@ -4508,10 +4544,7 @@ function convertToMap(dataStructure) {
|
|
|
4508
4544
|
}
|
|
4509
4545
|
}
|
|
4510
4546
|
|
|
4511
|
-
var _Symbol$iterator$1, _Symbol$toStringTag$1;
|
|
4512
4547
|
var ObservableSetMarker = {};
|
|
4513
|
-
_Symbol$iterator$1 = Symbol.iterator;
|
|
4514
|
-
_Symbol$toStringTag$1 = Symbol.toStringTag;
|
|
4515
4548
|
var ObservableSet = /*#__PURE__*/function () {
|
|
4516
4549
|
function ObservableSet(initialData, enhancer, name_) {
|
|
4517
4550
|
var _this = this;
|
|
@@ -4582,7 +4615,6 @@ var ObservableSet = /*#__PURE__*/function () {
|
|
|
4582
4615
|
// ideally, value = change.value would be done here, so that values can be
|
|
4583
4616
|
// changed by interceptor. Same applies for other Set and Map api's.
|
|
4584
4617
|
}
|
|
4585
|
-
|
|
4586
4618
|
if (!this.has(value)) {
|
|
4587
4619
|
transaction(function () {
|
|
4588
4620
|
_this3.data_.add(_this3.enhancer_(value, undefined));
|
|
@@ -4688,6 +4720,47 @@ var ObservableSet = /*#__PURE__*/function () {
|
|
|
4688
4720
|
}
|
|
4689
4721
|
});
|
|
4690
4722
|
};
|
|
4723
|
+
_proto.intersection = function intersection(otherSet) {
|
|
4724
|
+
if (isES6Set(otherSet)) {
|
|
4725
|
+
return otherSet.intersection(this);
|
|
4726
|
+
} else {
|
|
4727
|
+
var dehancedSet = new Set(this);
|
|
4728
|
+
return dehancedSet.intersection(otherSet);
|
|
4729
|
+
}
|
|
4730
|
+
};
|
|
4731
|
+
_proto.union = function union(otherSet) {
|
|
4732
|
+
if (isES6Set(otherSet)) {
|
|
4733
|
+
return otherSet.union(this);
|
|
4734
|
+
} else {
|
|
4735
|
+
var dehancedSet = new Set(this);
|
|
4736
|
+
return dehancedSet.union(otherSet);
|
|
4737
|
+
}
|
|
4738
|
+
};
|
|
4739
|
+
_proto.difference = function difference(otherSet) {
|
|
4740
|
+
return new Set(this).difference(otherSet);
|
|
4741
|
+
};
|
|
4742
|
+
_proto.symmetricDifference = function symmetricDifference(otherSet) {
|
|
4743
|
+
if (isES6Set(otherSet)) {
|
|
4744
|
+
return otherSet.symmetricDifference(this);
|
|
4745
|
+
} else {
|
|
4746
|
+
var dehancedSet = new Set(this);
|
|
4747
|
+
return dehancedSet.symmetricDifference(otherSet);
|
|
4748
|
+
}
|
|
4749
|
+
};
|
|
4750
|
+
_proto.isSubsetOf = function isSubsetOf(otherSet) {
|
|
4751
|
+
return new Set(this).isSubsetOf(otherSet);
|
|
4752
|
+
};
|
|
4753
|
+
_proto.isSupersetOf = function isSupersetOf(otherSet) {
|
|
4754
|
+
return new Set(this).isSupersetOf(otherSet);
|
|
4755
|
+
};
|
|
4756
|
+
_proto.isDisjointFrom = function isDisjointFrom(otherSet) {
|
|
4757
|
+
if (isES6Set(otherSet)) {
|
|
4758
|
+
return otherSet.isDisjointFrom(this);
|
|
4759
|
+
} else {
|
|
4760
|
+
var dehancedSet = new Set(this);
|
|
4761
|
+
return dehancedSet.isDisjointFrom(otherSet);
|
|
4762
|
+
}
|
|
4763
|
+
};
|
|
4691
4764
|
_proto.replace = function replace(other) {
|
|
4692
4765
|
var _this5 = this;
|
|
4693
4766
|
if (isObservableSet(other)) {
|
|
@@ -4726,22 +4799,21 @@ var ObservableSet = /*#__PURE__*/function () {
|
|
|
4726
4799
|
_proto.toString = function toString() {
|
|
4727
4800
|
return "[object ObservableSet]";
|
|
4728
4801
|
};
|
|
4729
|
-
_proto[
|
|
4802
|
+
_proto[Symbol.iterator] = function () {
|
|
4730
4803
|
return this.values();
|
|
4731
4804
|
};
|
|
4732
|
-
_createClass(ObservableSet, [{
|
|
4805
|
+
return _createClass(ObservableSet, [{
|
|
4733
4806
|
key: "size",
|
|
4734
4807
|
get: function get() {
|
|
4735
4808
|
this.atom_.reportObserved();
|
|
4736
4809
|
return this.data_.size;
|
|
4737
4810
|
}
|
|
4738
4811
|
}, {
|
|
4739
|
-
key:
|
|
4812
|
+
key: Symbol.toStringTag,
|
|
4740
4813
|
get: function get() {
|
|
4741
4814
|
return "Set";
|
|
4742
4815
|
}
|
|
4743
4816
|
}]);
|
|
4744
|
-
return ObservableSet;
|
|
4745
4817
|
}();
|
|
4746
4818
|
// eslint-disable-next-line
|
|
4747
4819
|
var isObservableSet = /*#__PURE__*/createInstanceofPredicate("ObservableSet", ObservableSet);
|
|
@@ -5141,7 +5213,7 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
5141
5213
|
}
|
|
5142
5214
|
// Delete
|
|
5143
5215
|
try {
|
|
5144
|
-
var _this$pendingKeys_
|
|
5216
|
+
var _this$pendingKeys_;
|
|
5145
5217
|
startBatch();
|
|
5146
5218
|
var notify = hasListeners(this);
|
|
5147
5219
|
var notifySpy = process.env.NODE_ENV !== "production" && isSpyEnabled();
|
|
@@ -5179,7 +5251,7 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
5179
5251
|
this.keysAtom_.reportChanged();
|
|
5180
5252
|
// Notify "has" observers
|
|
5181
5253
|
// "in" as it may still exist in proto
|
|
5182
|
-
(_this$pendingKeys_ = this.pendingKeys_) == null
|
|
5254
|
+
(_this$pendingKeys_ = this.pendingKeys_) == null || (_this$pendingKeys_ = _this$pendingKeys_.get(key)) == null || _this$pendingKeys_.set(key in this.target_);
|
|
5183
5255
|
// Notify spies/listeners
|
|
5184
5256
|
if (notify || notifySpy) {
|
|
5185
5257
|
var _change2 = {
|
|
@@ -5220,7 +5292,7 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
5220
5292
|
return registerInterceptor(this, handler);
|
|
5221
5293
|
};
|
|
5222
5294
|
_proto.notifyPropertyAddition_ = function notifyPropertyAddition_(key, value) {
|
|
5223
|
-
var _this$pendingKeys_2
|
|
5295
|
+
var _this$pendingKeys_2;
|
|
5224
5296
|
var notify = hasListeners(this);
|
|
5225
5297
|
var notifySpy = process.env.NODE_ENV !== "production" && isSpyEnabled();
|
|
5226
5298
|
if (notify || notifySpy) {
|
|
@@ -5242,7 +5314,7 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
5242
5314
|
spyReportEnd();
|
|
5243
5315
|
}
|
|
5244
5316
|
}
|
|
5245
|
-
(_this$pendingKeys_2 = this.pendingKeys_) == null
|
|
5317
|
+
(_this$pendingKeys_2 = this.pendingKeys_) == null || (_this$pendingKeys_2 = _this$pendingKeys_2.get(key)) == null || _this$pendingKeys_2.set(true);
|
|
5246
5318
|
// Notify "keys/entries/values" observers
|
|
5247
5319
|
this.keysAtom_.reportChanged();
|
|
5248
5320
|
};
|
|
@@ -5304,7 +5376,7 @@ function recordAnnotationApplied(adm, annotation, key) {
|
|
|
5304
5376
|
adm.appliedAnnotations_[key] = annotation;
|
|
5305
5377
|
}
|
|
5306
5378
|
// Remove applied decorator annotation so we don't try to apply it again in subclass constructor
|
|
5307
|
-
(_adm$target_$storedAn = adm.target_[storedAnnotationsSymbol]) == null
|
|
5379
|
+
(_adm$target_$storedAn = adm.target_[storedAnnotationsSymbol]) == null || delete _adm$target_$storedAn[key];
|
|
5308
5380
|
}
|
|
5309
5381
|
function assertAnnotable(adm, annotation, key) {
|
|
5310
5382
|
// Valid annotation
|
|
@@ -5384,8 +5456,7 @@ inherit(StubArray, Array.prototype);
|
|
|
5384
5456
|
// Weex proto freeze protection was here,
|
|
5385
5457
|
// but it is unclear why the hack is need as MobX never changed the prototype
|
|
5386
5458
|
// anyway, so removed it in V6
|
|
5387
|
-
var LegacyObservableArray = /*#__PURE__*/function (_StubArray
|
|
5388
|
-
_inheritsLoose(LegacyObservableArray, _StubArray);
|
|
5459
|
+
var LegacyObservableArray = /*#__PURE__*/function (_StubArray) {
|
|
5389
5460
|
function LegacyObservableArray(initialValues, enhancer, name, owned) {
|
|
5390
5461
|
var _this;
|
|
5391
5462
|
if (name === void 0) {
|
|
@@ -5397,8 +5468,8 @@ var LegacyObservableArray = /*#__PURE__*/function (_StubArray, _Symbol$toStringT
|
|
|
5397
5468
|
_this = _StubArray.call(this) || this;
|
|
5398
5469
|
initObservable(function () {
|
|
5399
5470
|
var adm = new ObservableArrayAdministration(name, enhancer, owned, true);
|
|
5400
|
-
adm.proxy_ =
|
|
5401
|
-
addHiddenFinalProp(
|
|
5471
|
+
adm.proxy_ = _this;
|
|
5472
|
+
addHiddenFinalProp(_this, $mobx, adm);
|
|
5402
5473
|
if (initialValues && initialValues.length) {
|
|
5403
5474
|
// @ts-ignore
|
|
5404
5475
|
_this.spliceWithArray(0, 0, initialValues);
|
|
@@ -5406,11 +5477,12 @@ var LegacyObservableArray = /*#__PURE__*/function (_StubArray, _Symbol$toStringT
|
|
|
5406
5477
|
if (safariPrototypeSetterInheritanceBug) {
|
|
5407
5478
|
// Seems that Safari won't use numeric prototype setter until any * numeric property is
|
|
5408
5479
|
// defined on the instance. After that it works fine, even if this property is deleted.
|
|
5409
|
-
Object.defineProperty(
|
|
5480
|
+
Object.defineProperty(_this, "0", ENTRY_0);
|
|
5410
5481
|
}
|
|
5411
5482
|
});
|
|
5412
5483
|
return _this;
|
|
5413
5484
|
}
|
|
5485
|
+
_inheritsLoose(LegacyObservableArray, _StubArray);
|
|
5414
5486
|
var _proto = LegacyObservableArray.prototype;
|
|
5415
5487
|
_proto.concat = function concat() {
|
|
5416
5488
|
this[$mobx].atom_.reportObserved();
|
|
@@ -5423,7 +5495,7 @@ var LegacyObservableArray = /*#__PURE__*/function (_StubArray, _Symbol$toStringT
|
|
|
5423
5495
|
return isObservableArray(a) ? a.slice() : a;
|
|
5424
5496
|
}));
|
|
5425
5497
|
};
|
|
5426
|
-
_proto[
|
|
5498
|
+
_proto[Symbol.iterator] = function () {
|
|
5427
5499
|
var self = this;
|
|
5428
5500
|
var nextIndex = 0;
|
|
5429
5501
|
return makeIterable({
|
|
@@ -5438,7 +5510,7 @@ var LegacyObservableArray = /*#__PURE__*/function (_StubArray, _Symbol$toStringT
|
|
|
5438
5510
|
}
|
|
5439
5511
|
});
|
|
5440
5512
|
};
|
|
5441
|
-
_createClass(LegacyObservableArray, [{
|
|
5513
|
+
return _createClass(LegacyObservableArray, [{
|
|
5442
5514
|
key: "length",
|
|
5443
5515
|
get: function get() {
|
|
5444
5516
|
return this[$mobx].getArrayLength_();
|
|
@@ -5447,13 +5519,12 @@ var LegacyObservableArray = /*#__PURE__*/function (_StubArray, _Symbol$toStringT
|
|
|
5447
5519
|
this[$mobx].setArrayLength_(newLength);
|
|
5448
5520
|
}
|
|
5449
5521
|
}, {
|
|
5450
|
-
key:
|
|
5522
|
+
key: Symbol.toStringTag,
|
|
5451
5523
|
get: function get() {
|
|
5452
5524
|
return "Array";
|
|
5453
5525
|
}
|
|
5454
5526
|
}]);
|
|
5455
|
-
|
|
5456
|
-
}(StubArray, Symbol.toStringTag, Symbol.iterator);
|
|
5527
|
+
}(StubArray);
|
|
5457
5528
|
Object.entries(arrayExtensions).forEach(function (_ref) {
|
|
5458
5529
|
var prop = _ref[0],
|
|
5459
5530
|
fn = _ref[1];
|