mobx 6.3.8 → 6.3.12
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 +26 -0
- package/dist/api/tojs.d.ts +4 -1
- package/dist/mobx.cjs.development.js +112 -94
- 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 +112 -94
- package/dist/mobx.esm.development.js.map +1 -1
- package/dist/mobx.esm.js +112 -94
- 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 +112 -94
- 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/observableobject.d.ts +3 -3
- package/dist/utils/utils.d.ts +3 -3
- package/package.json +1 -1
- package/src/api/tojs.ts +4 -1
- package/src/api/when.ts +1 -1
- package/src/core/computedvalue.ts +3 -3
- package/src/types/dynamicobject.ts +1 -1
- package/src/types/observablemap.ts +12 -7
- package/src/types/observableobject.ts +3 -2
- package/src/utils/eq.ts +1 -1
- package/src/utils/utils.ts +7 -6
|
@@ -170,12 +170,11 @@
|
|
|
170
170
|
return value !== null && typeof value === "object";
|
|
171
171
|
}
|
|
172
172
|
function isPlainObject(value) {
|
|
173
|
-
var _proto$constructor;
|
|
174
|
-
|
|
175
173
|
if (!isObject(value)) return false;
|
|
176
174
|
var proto = Object.getPrototypeOf(value);
|
|
177
175
|
if (proto == null) return true;
|
|
178
|
-
|
|
176
|
+
var protoConstructor = Object.hasOwnProperty.call(proto, "constructor") && proto.constructor;
|
|
177
|
+
return typeof protoConstructor === "function" && protoConstructor.toString() === plainObjectString;
|
|
179
178
|
} // https://stackoverflow.com/a/37865170
|
|
180
179
|
|
|
181
180
|
function isGenerator(obj) {
|
|
@@ -270,6 +269,9 @@
|
|
|
270
269
|
function _createClass(Constructor, protoProps, staticProps) {
|
|
271
270
|
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
272
271
|
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
272
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
273
|
+
writable: false
|
|
274
|
+
});
|
|
273
275
|
return Constructor;
|
|
274
276
|
}
|
|
275
277
|
|
|
@@ -294,7 +296,17 @@
|
|
|
294
296
|
function _inheritsLoose(subClass, superClass) {
|
|
295
297
|
subClass.prototype = Object.create(superClass.prototype);
|
|
296
298
|
subClass.prototype.constructor = subClass;
|
|
297
|
-
|
|
299
|
+
|
|
300
|
+
_setPrototypeOf(subClass, superClass);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
function _setPrototypeOf(o, p) {
|
|
304
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
305
|
+
o.__proto__ = p;
|
|
306
|
+
return o;
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
return _setPrototypeOf(o, p);
|
|
298
310
|
}
|
|
299
311
|
|
|
300
312
|
function _assertThisInitialized(self) {
|
|
@@ -323,28 +335,24 @@
|
|
|
323
335
|
}
|
|
324
336
|
|
|
325
337
|
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
326
|
-
var it;
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
};
|
|
336
|
-
return {
|
|
337
|
-
done: false,
|
|
338
|
-
value: o[i++]
|
|
339
|
-
};
|
|
338
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
339
|
+
if (it) return (it = it.call(o)).next.bind(it);
|
|
340
|
+
|
|
341
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
342
|
+
if (it) o = it;
|
|
343
|
+
var i = 0;
|
|
344
|
+
return function () {
|
|
345
|
+
if (i >= o.length) return {
|
|
346
|
+
done: true
|
|
340
347
|
};
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
348
|
+
return {
|
|
349
|
+
done: false,
|
|
350
|
+
value: o[i++]
|
|
351
|
+
};
|
|
352
|
+
};
|
|
344
353
|
}
|
|
345
354
|
|
|
346
|
-
|
|
347
|
-
return it.next.bind(it);
|
|
355
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
348
356
|
}
|
|
349
357
|
|
|
350
358
|
var storedAnnotationsSymbol = /*#__PURE__*/Symbol("mobx-stored-annotations");
|
|
@@ -628,7 +636,7 @@
|
|
|
628
636
|
var _this$options_;
|
|
629
637
|
|
|
630
638
|
// bound
|
|
631
|
-
if ((_this$options_ = this.options_)
|
|
639
|
+
if ((_this$options_ = this.options_) != null && _this$options_.bound) {
|
|
632
640
|
return this.extend_(adm, key, descriptor, false) === null ? 0
|
|
633
641
|
/* Cancel */
|
|
634
642
|
: 1
|
|
@@ -686,7 +694,7 @@
|
|
|
686
694
|
assertActionDescriptor(adm, annotation, key, descriptor);
|
|
687
695
|
var value = descriptor.value;
|
|
688
696
|
|
|
689
|
-
if ((_annotation$options_ = annotation.options_)
|
|
697
|
+
if ((_annotation$options_ = annotation.options_) != null && _annotation$options_.bound) {
|
|
690
698
|
var _adm$proxy_;
|
|
691
699
|
|
|
692
700
|
value = value.bind((_adm$proxy_ = adm.proxy_) != null ? _adm$proxy_ : adm.target_);
|
|
@@ -694,7 +702,7 @@
|
|
|
694
702
|
|
|
695
703
|
return {
|
|
696
704
|
value: createAction((_annotation$options_$ = (_annotation$options_2 = annotation.options_) == null ? void 0 : _annotation$options_2.name) != null ? _annotation$options_$ : key.toString(), value, (_annotation$options_$2 = (_annotation$options_3 = annotation.options_) == null ? void 0 : _annotation$options_3.autoAction) != null ? _annotation$options_$2 : false, // https://github.com/mobxjs/mobx/discussions/3140
|
|
697
|
-
(
|
|
705
|
+
(_annotation$options_4 = annotation.options_) != null && _annotation$options_4.bound ? (_adm$proxy_2 = adm.proxy_) != null ? _adm$proxy_2 : adm.target_ : undefined),
|
|
698
706
|
// Non-configurable for classes
|
|
699
707
|
// prevents accidental field redefinition in subclass
|
|
700
708
|
configurable: safeDescriptors ? adm.isPlainObject_ : true,
|
|
@@ -729,7 +737,7 @@
|
|
|
729
737
|
// bound - must annotate protos to support super.flow()
|
|
730
738
|
|
|
731
739
|
|
|
732
|
-
if ((
|
|
740
|
+
if ((_this$options_ = this.options_) != null && _this$options_.bound && !isFlow(adm.target_[key])) {
|
|
733
741
|
if (this.extend_(adm, key, descriptor, false) === null) return 0
|
|
734
742
|
/* Cancel */
|
|
735
743
|
;
|
|
@@ -912,11 +920,11 @@
|
|
|
912
920
|
if (isGenerator(descriptor.value)) {
|
|
913
921
|
var _this$options_;
|
|
914
922
|
|
|
915
|
-
var flowAnnotation = (
|
|
923
|
+
var flowAnnotation = (_this$options_ = this.options_) != null && _this$options_.autoBind ? flow.bound : flow;
|
|
916
924
|
return flowAnnotation.make_(adm, key, descriptor, source);
|
|
917
925
|
}
|
|
918
926
|
|
|
919
|
-
var actionAnnotation = (
|
|
927
|
+
var actionAnnotation = (_this$options_2 = this.options_) != null && _this$options_2.autoBind ? autoAction.bound : autoAction;
|
|
920
928
|
return actionAnnotation.make_(adm, key, descriptor, source);
|
|
921
929
|
} // other -> observable
|
|
922
930
|
// Copy props from proto as well, see test:
|
|
@@ -925,7 +933,7 @@
|
|
|
925
933
|
|
|
926
934
|
var observableAnnotation = ((_this$options_3 = this.options_) == null ? void 0 : _this$options_3.deep) === false ? observable.ref : observable; // if function respect autoBind option
|
|
927
935
|
|
|
928
|
-
if (typeof descriptor.value === "function" && (
|
|
936
|
+
if (typeof descriptor.value === "function" && (_this$options_4 = this.options_) != null && _this$options_4.autoBind) {
|
|
929
937
|
var _adm$proxy_;
|
|
930
938
|
|
|
931
939
|
descriptor.value = descriptor.value.bind((_adm$proxy_ = adm.proxy_) != null ? _adm$proxy_ : adm.target_);
|
|
@@ -953,7 +961,7 @@
|
|
|
953
961
|
// if function respect autoBind option
|
|
954
962
|
|
|
955
963
|
|
|
956
|
-
if (typeof descriptor.value === "function" && (
|
|
964
|
+
if (typeof descriptor.value === "function" && (_this$options_5 = this.options_) != null && _this$options_5.autoBind) {
|
|
957
965
|
var _adm$proxy_2;
|
|
958
966
|
|
|
959
967
|
descriptor.value = descriptor.value.bind((_adm$proxy_2 = adm.proxy_) != null ? _adm$proxy_2 : adm.target_);
|
|
@@ -1231,7 +1239,7 @@
|
|
|
1231
1239
|
var _Symbol$toPrimitive;
|
|
1232
1240
|
var CREATE = "create";
|
|
1233
1241
|
_Symbol$toPrimitive = Symbol.toPrimitive;
|
|
1234
|
-
var ObservableValue = /*#__PURE__*/function (_Atom) {
|
|
1242
|
+
var ObservableValue = /*#__PURE__*/function (_Atom, _Symbol$toPrimitive2) {
|
|
1235
1243
|
_inheritsLoose(ObservableValue, _Atom);
|
|
1236
1244
|
|
|
1237
1245
|
function ObservableValue(value, enhancer, name_, notifySpy, equals) {
|
|
@@ -1378,12 +1386,12 @@
|
|
|
1378
1386
|
return toPrimitive(this.get());
|
|
1379
1387
|
};
|
|
1380
1388
|
|
|
1381
|
-
_proto[_Symbol$
|
|
1389
|
+
_proto[_Symbol$toPrimitive2] = function () {
|
|
1382
1390
|
return this.valueOf();
|
|
1383
1391
|
};
|
|
1384
1392
|
|
|
1385
1393
|
return ObservableValue;
|
|
1386
|
-
}(Atom);
|
|
1394
|
+
}(Atom, _Symbol$toPrimitive);
|
|
1387
1395
|
var isObservableValue = /*#__PURE__*/createInstanceofPredicate("ObservableValue", ObservableValue);
|
|
1388
1396
|
|
|
1389
1397
|
var _Symbol$toPrimitive$1;
|
|
@@ -1408,7 +1416,7 @@
|
|
|
1408
1416
|
*/
|
|
1409
1417
|
|
|
1410
1418
|
_Symbol$toPrimitive$1 = Symbol.toPrimitive;
|
|
1411
|
-
var ComputedValue = /*#__PURE__*/function () {
|
|
1419
|
+
var ComputedValue = /*#__PURE__*/function (_Symbol$toPrimitive2) {
|
|
1412
1420
|
// nodes we are looking at. Our value depends on these nodes
|
|
1413
1421
|
// during tracking it's an array with new observed observers
|
|
1414
1422
|
// to check for cycles
|
|
@@ -1462,7 +1470,7 @@
|
|
|
1462
1470
|
|
|
1463
1471
|
this.equals_ = options.equals || (options.compareStructural || options.struct ? comparer.structural : comparer["default"]);
|
|
1464
1472
|
this.scope_ = options.context;
|
|
1465
|
-
this.requiresReaction_ =
|
|
1473
|
+
this.requiresReaction_ = options.requiresReaction;
|
|
1466
1474
|
this.keepAlive_ = !!options.keepAlive;
|
|
1467
1475
|
}
|
|
1468
1476
|
|
|
@@ -1630,7 +1638,7 @@
|
|
|
1630
1638
|
console.log("[mobx.trace] Computed value '" + this.name_ + "' is being read outside a reactive context. Doing a full recompute.");
|
|
1631
1639
|
}
|
|
1632
1640
|
|
|
1633
|
-
if (
|
|
1641
|
+
if (typeof this.requiresReaction_ === "boolean" ? this.requiresReaction_ : globalState.computedRequiresReaction) {
|
|
1634
1642
|
console.warn("[mobx] Computed value '" + this.name_ + "' is being read outside a reactive context. Doing a full recompute.");
|
|
1635
1643
|
}
|
|
1636
1644
|
};
|
|
@@ -1643,12 +1651,12 @@
|
|
|
1643
1651
|
return toPrimitive(this.get());
|
|
1644
1652
|
};
|
|
1645
1653
|
|
|
1646
|
-
_proto[_Symbol$
|
|
1654
|
+
_proto[_Symbol$toPrimitive2] = function () {
|
|
1647
1655
|
return this.valueOf();
|
|
1648
1656
|
};
|
|
1649
1657
|
|
|
1650
1658
|
return ComputedValue;
|
|
1651
|
-
}();
|
|
1659
|
+
}(_Symbol$toPrimitive$1);
|
|
1652
1660
|
var isComputedValue = /*#__PURE__*/createInstanceofPredicate("ComputedValue", ComputedValue);
|
|
1653
1661
|
|
|
1654
1662
|
var IDerivationState_;
|
|
@@ -2189,8 +2197,8 @@
|
|
|
2189
2197
|
}
|
|
2190
2198
|
} else if (d.dependenciesState_ === IDerivationState_.UP_TO_DATE_ // this happens during computing of `d`, just keep lowestObserverState up to date.
|
|
2191
2199
|
) {
|
|
2192
|
-
|
|
2193
|
-
|
|
2200
|
+
observable.lowestObserverState_ = IDerivationState_.UP_TO_DATE_;
|
|
2201
|
+
}
|
|
2194
2202
|
}); // invariantLOS(observable, "confirmed end");
|
|
2195
2203
|
} // Used by computed when its dependency changed, but we don't wan't to immediately recompute.
|
|
2196
2204
|
|
|
@@ -3218,7 +3226,10 @@
|
|
|
3218
3226
|
}
|
|
3219
3227
|
}
|
|
3220
3228
|
/**
|
|
3221
|
-
*
|
|
3229
|
+
* Recursively converts an observable to it's non-observable native counterpart.
|
|
3230
|
+
* It does NOT recurse into non-observables, these are left as they are, even if they contain observables.
|
|
3231
|
+
* Computed and other non-enumerable properties are completely ignored.
|
|
3232
|
+
* Complex scenarios require custom solution, eg implementing `toJSON` or using `serializr` lib.
|
|
3222
3233
|
*/
|
|
3223
3234
|
|
|
3224
3235
|
|
|
@@ -4007,9 +4018,11 @@
|
|
|
4007
4018
|
|
|
4008
4019
|
_Symbol$iterator = Symbol.iterator;
|
|
4009
4020
|
_Symbol$toStringTag = Symbol.toStringTag;
|
|
4010
|
-
var ObservableMap = /*#__PURE__*/function () {
|
|
4021
|
+
var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTag2) {
|
|
4011
4022
|
// hasMap, not hashMap >-).
|
|
4012
4023
|
function ObservableMap(initialData, enhancer_, name_) {
|
|
4024
|
+
var _this = this;
|
|
4025
|
+
|
|
4013
4026
|
if (enhancer_ === void 0) {
|
|
4014
4027
|
enhancer_ = deepEnhancer;
|
|
4015
4028
|
}
|
|
@@ -4037,7 +4050,9 @@
|
|
|
4037
4050
|
this.keysAtom_ = createAtom( this.name_ + ".keys()" );
|
|
4038
4051
|
this.data_ = new Map();
|
|
4039
4052
|
this.hasMap_ = new Map();
|
|
4040
|
-
|
|
4053
|
+
allowStateChanges(true, function () {
|
|
4054
|
+
_this.merge(initialData);
|
|
4055
|
+
});
|
|
4041
4056
|
}
|
|
4042
4057
|
|
|
4043
4058
|
var _proto = ObservableMap.prototype;
|
|
@@ -4047,7 +4062,7 @@
|
|
|
4047
4062
|
};
|
|
4048
4063
|
|
|
4049
4064
|
_proto.has = function has(key) {
|
|
4050
|
-
var
|
|
4065
|
+
var _this2 = this;
|
|
4051
4066
|
|
|
4052
4067
|
if (!globalState.trackingDerivation) return this.has_(key);
|
|
4053
4068
|
var entry = this.hasMap_.get(key);
|
|
@@ -4056,7 +4071,7 @@
|
|
|
4056
4071
|
var newEntry = entry = new ObservableValue(this.has_(key), referenceEnhancer, this.name_ + "." + stringifyKey(key) + "?" , false);
|
|
4057
4072
|
this.hasMap_.set(key, newEntry);
|
|
4058
4073
|
onBecomeUnobserved(newEntry, function () {
|
|
4059
|
-
return
|
|
4074
|
+
return _this2.hasMap_["delete"](key);
|
|
4060
4075
|
});
|
|
4061
4076
|
}
|
|
4062
4077
|
|
|
@@ -4087,7 +4102,7 @@
|
|
|
4087
4102
|
};
|
|
4088
4103
|
|
|
4089
4104
|
_proto["delete"] = function _delete(key) {
|
|
4090
|
-
var
|
|
4105
|
+
var _this3 = this;
|
|
4091
4106
|
|
|
4092
4107
|
checkIfStateModificationsAreAllowed(this.keysAtom_);
|
|
4093
4108
|
|
|
@@ -4113,19 +4128,20 @@
|
|
|
4113
4128
|
name: key
|
|
4114
4129
|
} : null;
|
|
4115
4130
|
|
|
4116
|
-
if ( notifySpy) spyReportStart(_change);
|
|
4131
|
+
if ( notifySpy) spyReportStart(_change); // TODO fix type
|
|
4132
|
+
|
|
4117
4133
|
transaction(function () {
|
|
4118
|
-
var
|
|
4134
|
+
var _this3$hasMap_$get;
|
|
4119
4135
|
|
|
4120
|
-
|
|
4136
|
+
_this3.keysAtom_.reportChanged();
|
|
4121
4137
|
|
|
4122
|
-
(
|
|
4138
|
+
(_this3$hasMap_$get = _this3.hasMap_.get(key)) == null ? void 0 : _this3$hasMap_$get.setNewValue_(false);
|
|
4123
4139
|
|
|
4124
|
-
var observable =
|
|
4140
|
+
var observable = _this3.data_.get(key);
|
|
4125
4141
|
|
|
4126
4142
|
observable.setNewValue_(undefined);
|
|
4127
4143
|
|
|
4128
|
-
|
|
4144
|
+
_this3.data_["delete"](key);
|
|
4129
4145
|
});
|
|
4130
4146
|
if (notify) notifyListeners(this, _change);
|
|
4131
4147
|
if ( notifySpy) spyReportEnd();
|
|
@@ -4151,7 +4167,8 @@
|
|
|
4151
4167
|
name: key,
|
|
4152
4168
|
newValue: newValue
|
|
4153
4169
|
} : null;
|
|
4154
|
-
if ( notifySpy) spyReportStart(change);
|
|
4170
|
+
if ( notifySpy) spyReportStart(change); // TODO fix type
|
|
4171
|
+
|
|
4155
4172
|
observable.setNewValue_(newValue);
|
|
4156
4173
|
if (notify) notifyListeners(this, change);
|
|
4157
4174
|
if ( notifySpy) spyReportEnd();
|
|
@@ -4159,21 +4176,21 @@
|
|
|
4159
4176
|
};
|
|
4160
4177
|
|
|
4161
4178
|
_proto.addValue_ = function addValue_(key, newValue) {
|
|
4162
|
-
var
|
|
4179
|
+
var _this4 = this;
|
|
4163
4180
|
|
|
4164
4181
|
checkIfStateModificationsAreAllowed(this.keysAtom_);
|
|
4165
4182
|
transaction(function () {
|
|
4166
|
-
var
|
|
4183
|
+
var _this4$hasMap_$get;
|
|
4167
4184
|
|
|
4168
|
-
var observable = new ObservableValue(newValue,
|
|
4185
|
+
var observable = new ObservableValue(newValue, _this4.enhancer_, _this4.name_ + "." + stringifyKey(key) , false);
|
|
4169
4186
|
|
|
4170
|
-
|
|
4187
|
+
_this4.data_.set(key, observable);
|
|
4171
4188
|
|
|
4172
4189
|
newValue = observable.value_; // value might have been changed
|
|
4173
4190
|
|
|
4174
|
-
(
|
|
4191
|
+
(_this4$hasMap_$get = _this4.hasMap_.get(key)) == null ? void 0 : _this4$hasMap_$get.setNewValue_(true);
|
|
4175
4192
|
|
|
4176
|
-
|
|
4193
|
+
_this4.keysAtom_.reportChanged();
|
|
4177
4194
|
});
|
|
4178
4195
|
var notifySpy = isSpyEnabled();
|
|
4179
4196
|
var notify = hasListeners(this);
|
|
@@ -4185,7 +4202,8 @@
|
|
|
4185
4202
|
name: key,
|
|
4186
4203
|
newValue: newValue
|
|
4187
4204
|
} : null;
|
|
4188
|
-
if ( notifySpy) spyReportStart(change);
|
|
4205
|
+
if ( notifySpy) spyReportStart(change); // TODO fix type
|
|
4206
|
+
|
|
4189
4207
|
if (notify) notifyListeners(this, change);
|
|
4190
4208
|
if ( notifySpy) spyReportEnd();
|
|
4191
4209
|
};
|
|
@@ -4242,7 +4260,7 @@
|
|
|
4242
4260
|
});
|
|
4243
4261
|
};
|
|
4244
4262
|
|
|
4245
|
-
_proto[_Symbol$
|
|
4263
|
+
_proto[_Symbol$iterator2] = function () {
|
|
4246
4264
|
return this.entries();
|
|
4247
4265
|
};
|
|
4248
4266
|
|
|
@@ -4258,7 +4276,7 @@
|
|
|
4258
4276
|
;
|
|
4259
4277
|
|
|
4260
4278
|
_proto.merge = function merge(other) {
|
|
4261
|
-
var
|
|
4279
|
+
var _this5 = this;
|
|
4262
4280
|
|
|
4263
4281
|
if (isObservableMap(other)) {
|
|
4264
4282
|
other = new Map(other);
|
|
@@ -4266,15 +4284,15 @@
|
|
|
4266
4284
|
|
|
4267
4285
|
transaction(function () {
|
|
4268
4286
|
if (isPlainObject(other)) getPlainObjectKeys(other).forEach(function (key) {
|
|
4269
|
-
return
|
|
4287
|
+
return _this5.set(key, other[key]);
|
|
4270
4288
|
});else if (Array.isArray(other)) other.forEach(function (_ref) {
|
|
4271
4289
|
var key = _ref[0],
|
|
4272
4290
|
value = _ref[1];
|
|
4273
|
-
return
|
|
4291
|
+
return _this5.set(key, value);
|
|
4274
4292
|
});else if (isES6Map(other)) {
|
|
4275
4293
|
if (other.constructor !== Map) die(19, other);
|
|
4276
4294
|
other.forEach(function (value, key) {
|
|
4277
|
-
return
|
|
4295
|
+
return _this5.set(key, value);
|
|
4278
4296
|
});
|
|
4279
4297
|
} else if (other !== null && other !== undefined) die(20, other);
|
|
4280
4298
|
});
|
|
@@ -4282,21 +4300,21 @@
|
|
|
4282
4300
|
};
|
|
4283
4301
|
|
|
4284
4302
|
_proto.clear = function clear() {
|
|
4285
|
-
var
|
|
4303
|
+
var _this6 = this;
|
|
4286
4304
|
|
|
4287
4305
|
transaction(function () {
|
|
4288
4306
|
untracked(function () {
|
|
4289
|
-
for (var _iterator2 = _createForOfIteratorHelperLoose(
|
|
4307
|
+
for (var _iterator2 = _createForOfIteratorHelperLoose(_this6.keys()), _step2; !(_step2 = _iterator2()).done;) {
|
|
4290
4308
|
var key = _step2.value;
|
|
4291
4309
|
|
|
4292
|
-
|
|
4310
|
+
_this6["delete"](key);
|
|
4293
4311
|
}
|
|
4294
4312
|
});
|
|
4295
4313
|
});
|
|
4296
4314
|
};
|
|
4297
4315
|
|
|
4298
4316
|
_proto.replace = function replace(values) {
|
|
4299
|
-
var
|
|
4317
|
+
var _this7 = this;
|
|
4300
4318
|
|
|
4301
4319
|
// Implementation requirements:
|
|
4302
4320
|
// - respect ordering of replacement map
|
|
@@ -4313,13 +4331,13 @@
|
|
|
4313
4331
|
// if the key deletion is prevented by interceptor
|
|
4314
4332
|
// add entry at the beginning of the result map
|
|
4315
4333
|
|
|
4316
|
-
for (var _iterator3 = _createForOfIteratorHelperLoose(
|
|
4334
|
+
for (var _iterator3 = _createForOfIteratorHelperLoose(_this7.data_.keys()), _step3; !(_step3 = _iterator3()).done;) {
|
|
4317
4335
|
var key = _step3.value;
|
|
4318
4336
|
|
|
4319
4337
|
// Concurrently iterating/deleting keys
|
|
4320
4338
|
// iterator should handle this correctly
|
|
4321
4339
|
if (!replacementMap.has(key)) {
|
|
4322
|
-
var deleted =
|
|
4340
|
+
var deleted = _this7["delete"](key); // Was the key removed?
|
|
4323
4341
|
|
|
4324
4342
|
|
|
4325
4343
|
if (deleted) {
|
|
@@ -4327,7 +4345,7 @@
|
|
|
4327
4345
|
keysReportChangedCalled = true;
|
|
4328
4346
|
} else {
|
|
4329
4347
|
// Delete prevented by interceptor
|
|
4330
|
-
var value =
|
|
4348
|
+
var value = _this7.data_.get(key);
|
|
4331
4349
|
|
|
4332
4350
|
orderedData.set(key, value);
|
|
4333
4351
|
}
|
|
@@ -4341,17 +4359,17 @@
|
|
|
4341
4359
|
_value = _step4$value[1];
|
|
4342
4360
|
|
|
4343
4361
|
// We will want to know whether a new key is added
|
|
4344
|
-
var keyExisted =
|
|
4362
|
+
var keyExisted = _this7.data_.has(_key); // Add or update value
|
|
4345
4363
|
|
|
4346
4364
|
|
|
4347
|
-
|
|
4365
|
+
_this7.set(_key, _value); // The addition could have been prevent by interceptor
|
|
4348
4366
|
|
|
4349
4367
|
|
|
4350
|
-
if (
|
|
4368
|
+
if (_this7.data_.has(_key)) {
|
|
4351
4369
|
// The update could have been prevented by interceptor
|
|
4352
4370
|
// and also we want to preserve existing values
|
|
4353
4371
|
// so use value from _data map (instead of replacement map)
|
|
4354
|
-
var _value2 =
|
|
4372
|
+
var _value2 = _this7.data_.get(_key);
|
|
4355
4373
|
|
|
4356
4374
|
orderedData.set(_key, _value2); // Was a new key added?
|
|
4357
4375
|
|
|
@@ -4364,11 +4382,11 @@
|
|
|
4364
4382
|
|
|
4365
4383
|
|
|
4366
4384
|
if (!keysReportChangedCalled) {
|
|
4367
|
-
if (
|
|
4385
|
+
if (_this7.data_.size !== orderedData.size) {
|
|
4368
4386
|
// If size differs, keys are definitely modified
|
|
4369
|
-
|
|
4387
|
+
_this7.keysAtom_.reportChanged();
|
|
4370
4388
|
} else {
|
|
4371
|
-
var iter1 =
|
|
4389
|
+
var iter1 = _this7.data_.keys();
|
|
4372
4390
|
|
|
4373
4391
|
var iter2 = orderedData.keys();
|
|
4374
4392
|
var next1 = iter1.next();
|
|
@@ -4376,7 +4394,7 @@
|
|
|
4376
4394
|
|
|
4377
4395
|
while (!next1.done) {
|
|
4378
4396
|
if (next1.value !== next2.value) {
|
|
4379
|
-
|
|
4397
|
+
_this7.keysAtom_.reportChanged();
|
|
4380
4398
|
|
|
4381
4399
|
break;
|
|
4382
4400
|
}
|
|
@@ -4388,7 +4406,7 @@
|
|
|
4388
4406
|
} // Use correctly ordered map
|
|
4389
4407
|
|
|
4390
4408
|
|
|
4391
|
-
|
|
4409
|
+
_this7.data_ = orderedData;
|
|
4392
4410
|
});
|
|
4393
4411
|
return this;
|
|
4394
4412
|
};
|
|
@@ -4422,14 +4440,14 @@
|
|
|
4422
4440
|
return this.data_.size;
|
|
4423
4441
|
}
|
|
4424
4442
|
}, {
|
|
4425
|
-
key: _Symbol$
|
|
4443
|
+
key: _Symbol$toStringTag2,
|
|
4426
4444
|
get: function get() {
|
|
4427
4445
|
return "Map";
|
|
4428
4446
|
}
|
|
4429
4447
|
}]);
|
|
4430
4448
|
|
|
4431
4449
|
return ObservableMap;
|
|
4432
|
-
}(); // eslint-disable-next-line
|
|
4450
|
+
}(_Symbol$iterator, _Symbol$toStringTag); // eslint-disable-next-line
|
|
4433
4451
|
|
|
4434
4452
|
var isObservableMap = /*#__PURE__*/createInstanceofPredicate("ObservableMap", ObservableMap);
|
|
4435
4453
|
|
|
@@ -4455,7 +4473,7 @@
|
|
|
4455
4473
|
var ObservableSetMarker = {};
|
|
4456
4474
|
_Symbol$iterator$1 = Symbol.iterator;
|
|
4457
4475
|
_Symbol$toStringTag$1 = Symbol.toStringTag;
|
|
4458
|
-
var ObservableSet = /*#__PURE__*/function () {
|
|
4476
|
+
var ObservableSet = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTag2) {
|
|
4459
4477
|
function ObservableSet(initialData, enhancer, name_) {
|
|
4460
4478
|
if (enhancer === void 0) {
|
|
4461
4479
|
enhancer = deepEnhancer;
|
|
@@ -4688,7 +4706,7 @@
|
|
|
4688
4706
|
return "[object ObservableSet]";
|
|
4689
4707
|
};
|
|
4690
4708
|
|
|
4691
|
-
_proto[_Symbol$
|
|
4709
|
+
_proto[_Symbol$iterator2] = function () {
|
|
4692
4710
|
return this.values();
|
|
4693
4711
|
};
|
|
4694
4712
|
|
|
@@ -4699,14 +4717,14 @@
|
|
|
4699
4717
|
return this.data_.size;
|
|
4700
4718
|
}
|
|
4701
4719
|
}, {
|
|
4702
|
-
key: _Symbol$
|
|
4720
|
+
key: _Symbol$toStringTag2,
|
|
4703
4721
|
get: function get() {
|
|
4704
4722
|
return "Set";
|
|
4705
4723
|
}
|
|
4706
4724
|
}]);
|
|
4707
4725
|
|
|
4708
4726
|
return ObservableSet;
|
|
4709
|
-
}(); // eslint-disable-next-line
|
|
4727
|
+
}(_Symbol$iterator$1, _Symbol$toStringTag$1); // eslint-disable-next-line
|
|
4710
4728
|
|
|
4711
4729
|
var isObservableSet = /*#__PURE__*/createInstanceofPredicate("ObservableSet", ObservableSet);
|
|
4712
4730
|
|
|
@@ -4892,7 +4910,7 @@
|
|
|
4892
4910
|
// When called from super() some props may not exist yet.
|
|
4893
4911
|
// However we don't have to worry about missing prop,
|
|
4894
4912
|
// because the decorator must have been applied to something.
|
|
4895
|
-
if ((_this$target_$storedA = this.target_[storedAnnotationsSymbol])
|
|
4913
|
+
if ((_this$target_$storedA = this.target_[storedAnnotationsSymbol]) != null && _this$target_$storedA[key]) {
|
|
4896
4914
|
return; // will be annotated by subclass constructor
|
|
4897
4915
|
} else {
|
|
4898
4916
|
die(1, annotation.annotationType_, this.name_ + "." + key.toString());
|
|
@@ -5396,7 +5414,7 @@
|
|
|
5396
5414
|
// but it is unclear why the hack is need as MobX never changed the prototype
|
|
5397
5415
|
// anyway, so removed it in V6
|
|
5398
5416
|
|
|
5399
|
-
var LegacyObservableArray = /*#__PURE__*/function (_StubArray) {
|
|
5417
|
+
var LegacyObservableArray = /*#__PURE__*/function (_StubArray, _Symbol$toStringTag, _Symbol$iterator) {
|
|
5400
5418
|
_inheritsLoose(LegacyObservableArray, _StubArray);
|
|
5401
5419
|
|
|
5402
5420
|
function LegacyObservableArray(initialValues, enhancer, name, owned) {
|
|
@@ -5441,7 +5459,7 @@
|
|
|
5441
5459
|
}));
|
|
5442
5460
|
};
|
|
5443
5461
|
|
|
5444
|
-
_proto[
|
|
5462
|
+
_proto[_Symbol$iterator] = function () {
|
|
5445
5463
|
var self = this;
|
|
5446
5464
|
var nextIndex = 0;
|
|
5447
5465
|
return makeIterable({
|
|
@@ -5467,14 +5485,14 @@
|
|
|
5467
5485
|
this[$mobx].setArrayLength_(newLength);
|
|
5468
5486
|
}
|
|
5469
5487
|
}, {
|
|
5470
|
-
key:
|
|
5488
|
+
key: _Symbol$toStringTag,
|
|
5471
5489
|
get: function get() {
|
|
5472
5490
|
return "Array";
|
|
5473
5491
|
}
|
|
5474
5492
|
}]);
|
|
5475
5493
|
|
|
5476
5494
|
return LegacyObservableArray;
|
|
5477
|
-
}(StubArray);
|
|
5495
|
+
}(StubArray, Symbol.toStringTag, Symbol.iterator);
|
|
5478
5496
|
|
|
5479
5497
|
Object.entries(arrayExtensions).forEach(function (_ref) {
|
|
5480
5498
|
var prop = _ref[0],
|
|
@@ -5597,7 +5615,7 @@
|
|
|
5597
5615
|
if (a !== a) return b !== b; // Exhaust primitive checks
|
|
5598
5616
|
|
|
5599
5617
|
var type = typeof a;
|
|
5600
|
-
if (
|
|
5618
|
+
if (type !== "function" && type !== "object" && typeof b != "object") return false; // Compare `[[Class]]` names.
|
|
5601
5619
|
|
|
5602
5620
|
var className = toString.call(a);
|
|
5603
5621
|
if (className !== toString.call(b)) return false;
|