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
package/dist/mobx.esm.js
CHANGED
|
@@ -166,12 +166,11 @@ function isObject(value) {
|
|
|
166
166
|
return value !== null && typeof value === "object";
|
|
167
167
|
}
|
|
168
168
|
function isPlainObject(value) {
|
|
169
|
-
var _proto$constructor;
|
|
170
|
-
|
|
171
169
|
if (!isObject(value)) return false;
|
|
172
170
|
var proto = Object.getPrototypeOf(value);
|
|
173
171
|
if (proto == null) return true;
|
|
174
|
-
|
|
172
|
+
var protoConstructor = Object.hasOwnProperty.call(proto, "constructor") && proto.constructor;
|
|
173
|
+
return typeof protoConstructor === "function" && protoConstructor.toString() === plainObjectString;
|
|
175
174
|
} // https://stackoverflow.com/a/37865170
|
|
176
175
|
|
|
177
176
|
function isGenerator(obj) {
|
|
@@ -266,6 +265,9 @@ function _defineProperties(target, props) {
|
|
|
266
265
|
function _createClass(Constructor, protoProps, staticProps) {
|
|
267
266
|
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
268
267
|
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
268
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
269
|
+
writable: false
|
|
270
|
+
});
|
|
269
271
|
return Constructor;
|
|
270
272
|
}
|
|
271
273
|
|
|
@@ -290,7 +292,17 @@ function _extends() {
|
|
|
290
292
|
function _inheritsLoose(subClass, superClass) {
|
|
291
293
|
subClass.prototype = Object.create(superClass.prototype);
|
|
292
294
|
subClass.prototype.constructor = subClass;
|
|
293
|
-
|
|
295
|
+
|
|
296
|
+
_setPrototypeOf(subClass, superClass);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
function _setPrototypeOf(o, p) {
|
|
300
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
301
|
+
o.__proto__ = p;
|
|
302
|
+
return o;
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
return _setPrototypeOf(o, p);
|
|
294
306
|
}
|
|
295
307
|
|
|
296
308
|
function _assertThisInitialized(self) {
|
|
@@ -319,28 +331,24 @@ function _arrayLikeToArray(arr, len) {
|
|
|
319
331
|
}
|
|
320
332
|
|
|
321
333
|
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
322
|
-
var it;
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
};
|
|
332
|
-
return {
|
|
333
|
-
done: false,
|
|
334
|
-
value: o[i++]
|
|
335
|
-
};
|
|
334
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
335
|
+
if (it) return (it = it.call(o)).next.bind(it);
|
|
336
|
+
|
|
337
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
338
|
+
if (it) o = it;
|
|
339
|
+
var i = 0;
|
|
340
|
+
return function () {
|
|
341
|
+
if (i >= o.length) return {
|
|
342
|
+
done: true
|
|
336
343
|
};
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
344
|
+
return {
|
|
345
|
+
done: false,
|
|
346
|
+
value: o[i++]
|
|
347
|
+
};
|
|
348
|
+
};
|
|
340
349
|
}
|
|
341
350
|
|
|
342
|
-
|
|
343
|
-
return it.next.bind(it);
|
|
351
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
344
352
|
}
|
|
345
353
|
|
|
346
354
|
var storedAnnotationsSymbol = /*#__PURE__*/Symbol("mobx-stored-annotations");
|
|
@@ -624,7 +632,7 @@ function make_$1(adm, key, descriptor, source) {
|
|
|
624
632
|
var _this$options_;
|
|
625
633
|
|
|
626
634
|
// bound
|
|
627
|
-
if ((_this$options_ = this.options_)
|
|
635
|
+
if ((_this$options_ = this.options_) != null && _this$options_.bound) {
|
|
628
636
|
return this.extend_(adm, key, descriptor, false) === null ? 0
|
|
629
637
|
/* Cancel */
|
|
630
638
|
: 1
|
|
@@ -682,7 +690,7 @@ safeDescriptors) {
|
|
|
682
690
|
assertActionDescriptor(adm, annotation, key, descriptor);
|
|
683
691
|
var value = descriptor.value;
|
|
684
692
|
|
|
685
|
-
if ((_annotation$options_ = annotation.options_)
|
|
693
|
+
if ((_annotation$options_ = annotation.options_) != null && _annotation$options_.bound) {
|
|
686
694
|
var _adm$proxy_;
|
|
687
695
|
|
|
688
696
|
value = value.bind((_adm$proxy_ = adm.proxy_) != null ? _adm$proxy_ : adm.target_);
|
|
@@ -690,7 +698,7 @@ safeDescriptors) {
|
|
|
690
698
|
|
|
691
699
|
return {
|
|
692
700
|
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
|
|
693
|
-
(
|
|
701
|
+
(_annotation$options_4 = annotation.options_) != null && _annotation$options_4.bound ? (_adm$proxy_2 = adm.proxy_) != null ? _adm$proxy_2 : adm.target_ : undefined),
|
|
694
702
|
// Non-configurable for classes
|
|
695
703
|
// prevents accidental field redefinition in subclass
|
|
696
704
|
configurable: safeDescriptors ? adm.isPlainObject_ : true,
|
|
@@ -725,7 +733,7 @@ function make_$2(adm, key, descriptor, source) {
|
|
|
725
733
|
// bound - must annotate protos to support super.flow()
|
|
726
734
|
|
|
727
735
|
|
|
728
|
-
if ((
|
|
736
|
+
if ((_this$options_ = this.options_) != null && _this$options_.bound && !isFlow(adm.target_[key])) {
|
|
729
737
|
if (this.extend_(adm, key, descriptor, false) === null) return 0
|
|
730
738
|
/* Cancel */
|
|
731
739
|
;
|
|
@@ -908,11 +916,11 @@ function make_$5(adm, key, descriptor, source) {
|
|
|
908
916
|
if (isGenerator(descriptor.value)) {
|
|
909
917
|
var _this$options_;
|
|
910
918
|
|
|
911
|
-
var flowAnnotation = (
|
|
919
|
+
var flowAnnotation = (_this$options_ = this.options_) != null && _this$options_.autoBind ? flow.bound : flow;
|
|
912
920
|
return flowAnnotation.make_(adm, key, descriptor, source);
|
|
913
921
|
}
|
|
914
922
|
|
|
915
|
-
var actionAnnotation = (
|
|
923
|
+
var actionAnnotation = (_this$options_2 = this.options_) != null && _this$options_2.autoBind ? autoAction.bound : autoAction;
|
|
916
924
|
return actionAnnotation.make_(adm, key, descriptor, source);
|
|
917
925
|
} // other -> observable
|
|
918
926
|
// Copy props from proto as well, see test:
|
|
@@ -921,7 +929,7 @@ function make_$5(adm, key, descriptor, source) {
|
|
|
921
929
|
|
|
922
930
|
var observableAnnotation = ((_this$options_3 = this.options_) == null ? void 0 : _this$options_3.deep) === false ? observable.ref : observable; // if function respect autoBind option
|
|
923
931
|
|
|
924
|
-
if (typeof descriptor.value === "function" && (
|
|
932
|
+
if (typeof descriptor.value === "function" && (_this$options_4 = this.options_) != null && _this$options_4.autoBind) {
|
|
925
933
|
var _adm$proxy_;
|
|
926
934
|
|
|
927
935
|
descriptor.value = descriptor.value.bind((_adm$proxy_ = adm.proxy_) != null ? _adm$proxy_ : adm.target_);
|
|
@@ -949,7 +957,7 @@ function extend_$5(adm, key, descriptor, proxyTrap) {
|
|
|
949
957
|
// if function respect autoBind option
|
|
950
958
|
|
|
951
959
|
|
|
952
|
-
if (typeof descriptor.value === "function" && (
|
|
960
|
+
if (typeof descriptor.value === "function" && (_this$options_5 = this.options_) != null && _this$options_5.autoBind) {
|
|
953
961
|
var _adm$proxy_2;
|
|
954
962
|
|
|
955
963
|
descriptor.value = descriptor.value.bind((_adm$proxy_2 = adm.proxy_) != null ? _adm$proxy_2 : adm.target_);
|
|
@@ -1227,7 +1235,7 @@ function allowStateChangesEnd(prev) {
|
|
|
1227
1235
|
var _Symbol$toPrimitive;
|
|
1228
1236
|
var CREATE = "create";
|
|
1229
1237
|
_Symbol$toPrimitive = Symbol.toPrimitive;
|
|
1230
|
-
var ObservableValue = /*#__PURE__*/function (_Atom) {
|
|
1238
|
+
var ObservableValue = /*#__PURE__*/function (_Atom, _Symbol$toPrimitive2) {
|
|
1231
1239
|
_inheritsLoose(ObservableValue, _Atom);
|
|
1232
1240
|
|
|
1233
1241
|
function ObservableValue(value, enhancer, name_, notifySpy, equals) {
|
|
@@ -1374,12 +1382,12 @@ var ObservableValue = /*#__PURE__*/function (_Atom) {
|
|
|
1374
1382
|
return toPrimitive(this.get());
|
|
1375
1383
|
};
|
|
1376
1384
|
|
|
1377
|
-
_proto[_Symbol$
|
|
1385
|
+
_proto[_Symbol$toPrimitive2] = function () {
|
|
1378
1386
|
return this.valueOf();
|
|
1379
1387
|
};
|
|
1380
1388
|
|
|
1381
1389
|
return ObservableValue;
|
|
1382
|
-
}(Atom);
|
|
1390
|
+
}(Atom, _Symbol$toPrimitive);
|
|
1383
1391
|
var isObservableValue = /*#__PURE__*/createInstanceofPredicate("ObservableValue", ObservableValue);
|
|
1384
1392
|
|
|
1385
1393
|
var _Symbol$toPrimitive$1;
|
|
@@ -1404,7 +1412,7 @@ var _Symbol$toPrimitive$1;
|
|
|
1404
1412
|
*/
|
|
1405
1413
|
|
|
1406
1414
|
_Symbol$toPrimitive$1 = Symbol.toPrimitive;
|
|
1407
|
-
var ComputedValue = /*#__PURE__*/function () {
|
|
1415
|
+
var ComputedValue = /*#__PURE__*/function (_Symbol$toPrimitive2) {
|
|
1408
1416
|
// nodes we are looking at. Our value depends on these nodes
|
|
1409
1417
|
// during tracking it's an array with new observed observers
|
|
1410
1418
|
// to check for cycles
|
|
@@ -1458,7 +1466,7 @@ var ComputedValue = /*#__PURE__*/function () {
|
|
|
1458
1466
|
|
|
1459
1467
|
this.equals_ = options.equals || (options.compareStructural || options.struct ? comparer.structural : comparer["default"]);
|
|
1460
1468
|
this.scope_ = options.context;
|
|
1461
|
-
this.requiresReaction_ =
|
|
1469
|
+
this.requiresReaction_ = options.requiresReaction;
|
|
1462
1470
|
this.keepAlive_ = !!options.keepAlive;
|
|
1463
1471
|
}
|
|
1464
1472
|
|
|
@@ -1627,7 +1635,7 @@ var ComputedValue = /*#__PURE__*/function () {
|
|
|
1627
1635
|
console.log("[mobx.trace] Computed value '" + this.name_ + "' is being read outside a reactive context. Doing a full recompute.");
|
|
1628
1636
|
}
|
|
1629
1637
|
|
|
1630
|
-
if (
|
|
1638
|
+
if (typeof this.requiresReaction_ === "boolean" ? this.requiresReaction_ : globalState.computedRequiresReaction) {
|
|
1631
1639
|
console.warn("[mobx] Computed value '" + this.name_ + "' is being read outside a reactive context. Doing a full recompute.");
|
|
1632
1640
|
}
|
|
1633
1641
|
};
|
|
@@ -1640,12 +1648,12 @@ var ComputedValue = /*#__PURE__*/function () {
|
|
|
1640
1648
|
return toPrimitive(this.get());
|
|
1641
1649
|
};
|
|
1642
1650
|
|
|
1643
|
-
_proto[_Symbol$
|
|
1651
|
+
_proto[_Symbol$toPrimitive2] = function () {
|
|
1644
1652
|
return this.valueOf();
|
|
1645
1653
|
};
|
|
1646
1654
|
|
|
1647
1655
|
return ComputedValue;
|
|
1648
|
-
}();
|
|
1656
|
+
}(_Symbol$toPrimitive$1);
|
|
1649
1657
|
var isComputedValue = /*#__PURE__*/createInstanceofPredicate("ComputedValue", ComputedValue);
|
|
1650
1658
|
|
|
1651
1659
|
var IDerivationState_;
|
|
@@ -2190,8 +2198,8 @@ function propagateChangeConfirmed(observable) {
|
|
|
2190
2198
|
}
|
|
2191
2199
|
} else if (d.dependenciesState_ === IDerivationState_.UP_TO_DATE_ // this happens during computing of `d`, just keep lowestObserverState up to date.
|
|
2192
2200
|
) {
|
|
2193
|
-
|
|
2194
|
-
|
|
2201
|
+
observable.lowestObserverState_ = IDerivationState_.UP_TO_DATE_;
|
|
2202
|
+
}
|
|
2195
2203
|
}); // invariantLOS(observable, "confirmed end");
|
|
2196
2204
|
} // Used by computed when its dependency changed, but we don't wan't to immediately recompute.
|
|
2197
2205
|
|
|
@@ -3225,7 +3233,10 @@ function toJSHelper(source, __alreadySeen) {
|
|
|
3225
3233
|
}
|
|
3226
3234
|
}
|
|
3227
3235
|
/**
|
|
3228
|
-
*
|
|
3236
|
+
* Recursively converts an observable to it's non-observable native counterpart.
|
|
3237
|
+
* It does NOT recurse into non-observables, these are left as they are, even if they contain observables.
|
|
3238
|
+
* Computed and other non-enumerable properties are completely ignored.
|
|
3239
|
+
* Complex scenarios require custom solution, eg implementing `toJSON` or using `serializr` lib.
|
|
3229
3240
|
*/
|
|
3230
3241
|
|
|
3231
3242
|
|
|
@@ -4015,9 +4026,11 @@ var DELETE = "delete"; // just extend Map? See also https://gist.github.com/nest
|
|
|
4015
4026
|
|
|
4016
4027
|
_Symbol$iterator = Symbol.iterator;
|
|
4017
4028
|
_Symbol$toStringTag = Symbol.toStringTag;
|
|
4018
|
-
var ObservableMap = /*#__PURE__*/function () {
|
|
4029
|
+
var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTag2) {
|
|
4019
4030
|
// hasMap, not hashMap >-).
|
|
4020
4031
|
function ObservableMap(initialData, enhancer_, name_) {
|
|
4032
|
+
var _this = this;
|
|
4033
|
+
|
|
4021
4034
|
if (enhancer_ === void 0) {
|
|
4022
4035
|
enhancer_ = deepEnhancer;
|
|
4023
4036
|
}
|
|
@@ -4045,7 +4058,9 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4045
4058
|
this.keysAtom_ = createAtom(process.env.NODE_ENV !== "production" ? this.name_ + ".keys()" : "ObservableMap.keys()");
|
|
4046
4059
|
this.data_ = new Map();
|
|
4047
4060
|
this.hasMap_ = new Map();
|
|
4048
|
-
|
|
4061
|
+
allowStateChanges(true, function () {
|
|
4062
|
+
_this.merge(initialData);
|
|
4063
|
+
});
|
|
4049
4064
|
}
|
|
4050
4065
|
|
|
4051
4066
|
var _proto = ObservableMap.prototype;
|
|
@@ -4055,7 +4070,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4055
4070
|
};
|
|
4056
4071
|
|
|
4057
4072
|
_proto.has = function has(key) {
|
|
4058
|
-
var
|
|
4073
|
+
var _this2 = this;
|
|
4059
4074
|
|
|
4060
4075
|
if (!globalState.trackingDerivation) return this.has_(key);
|
|
4061
4076
|
var entry = this.hasMap_.get(key);
|
|
@@ -4064,7 +4079,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4064
4079
|
var newEntry = entry = new ObservableValue(this.has_(key), referenceEnhancer, process.env.NODE_ENV !== "production" ? this.name_ + "." + stringifyKey(key) + "?" : "ObservableMap.key?", false);
|
|
4065
4080
|
this.hasMap_.set(key, newEntry);
|
|
4066
4081
|
onBecomeUnobserved(newEntry, function () {
|
|
4067
|
-
return
|
|
4082
|
+
return _this2.hasMap_["delete"](key);
|
|
4068
4083
|
});
|
|
4069
4084
|
}
|
|
4070
4085
|
|
|
@@ -4095,7 +4110,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4095
4110
|
};
|
|
4096
4111
|
|
|
4097
4112
|
_proto["delete"] = function _delete(key) {
|
|
4098
|
-
var
|
|
4113
|
+
var _this3 = this;
|
|
4099
4114
|
|
|
4100
4115
|
checkIfStateModificationsAreAllowed(this.keysAtom_);
|
|
4101
4116
|
|
|
@@ -4121,19 +4136,20 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4121
4136
|
name: key
|
|
4122
4137
|
} : null;
|
|
4123
4138
|
|
|
4124
|
-
if (process.env.NODE_ENV !== "production" && notifySpy) spyReportStart(_change);
|
|
4139
|
+
if (process.env.NODE_ENV !== "production" && notifySpy) spyReportStart(_change); // TODO fix type
|
|
4140
|
+
|
|
4125
4141
|
transaction(function () {
|
|
4126
|
-
var
|
|
4142
|
+
var _this3$hasMap_$get;
|
|
4127
4143
|
|
|
4128
|
-
|
|
4144
|
+
_this3.keysAtom_.reportChanged();
|
|
4129
4145
|
|
|
4130
|
-
(
|
|
4146
|
+
(_this3$hasMap_$get = _this3.hasMap_.get(key)) == null ? void 0 : _this3$hasMap_$get.setNewValue_(false);
|
|
4131
4147
|
|
|
4132
|
-
var observable =
|
|
4148
|
+
var observable = _this3.data_.get(key);
|
|
4133
4149
|
|
|
4134
4150
|
observable.setNewValue_(undefined);
|
|
4135
4151
|
|
|
4136
|
-
|
|
4152
|
+
_this3.data_["delete"](key);
|
|
4137
4153
|
});
|
|
4138
4154
|
if (notify) notifyListeners(this, _change);
|
|
4139
4155
|
if (process.env.NODE_ENV !== "production" && notifySpy) spyReportEnd();
|
|
@@ -4159,7 +4175,8 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4159
4175
|
name: key,
|
|
4160
4176
|
newValue: newValue
|
|
4161
4177
|
} : null;
|
|
4162
|
-
if (process.env.NODE_ENV !== "production" && notifySpy) spyReportStart(change);
|
|
4178
|
+
if (process.env.NODE_ENV !== "production" && notifySpy) spyReportStart(change); // TODO fix type
|
|
4179
|
+
|
|
4163
4180
|
observable.setNewValue_(newValue);
|
|
4164
4181
|
if (notify) notifyListeners(this, change);
|
|
4165
4182
|
if (process.env.NODE_ENV !== "production" && notifySpy) spyReportEnd();
|
|
@@ -4167,21 +4184,21 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4167
4184
|
};
|
|
4168
4185
|
|
|
4169
4186
|
_proto.addValue_ = function addValue_(key, newValue) {
|
|
4170
|
-
var
|
|
4187
|
+
var _this4 = this;
|
|
4171
4188
|
|
|
4172
4189
|
checkIfStateModificationsAreAllowed(this.keysAtom_);
|
|
4173
4190
|
transaction(function () {
|
|
4174
|
-
var
|
|
4191
|
+
var _this4$hasMap_$get;
|
|
4175
4192
|
|
|
4176
|
-
var observable = new ObservableValue(newValue,
|
|
4193
|
+
var observable = new ObservableValue(newValue, _this4.enhancer_, process.env.NODE_ENV !== "production" ? _this4.name_ + "." + stringifyKey(key) : "ObservableMap.key", false);
|
|
4177
4194
|
|
|
4178
|
-
|
|
4195
|
+
_this4.data_.set(key, observable);
|
|
4179
4196
|
|
|
4180
4197
|
newValue = observable.value_; // value might have been changed
|
|
4181
4198
|
|
|
4182
|
-
(
|
|
4199
|
+
(_this4$hasMap_$get = _this4.hasMap_.get(key)) == null ? void 0 : _this4$hasMap_$get.setNewValue_(true);
|
|
4183
4200
|
|
|
4184
|
-
|
|
4201
|
+
_this4.keysAtom_.reportChanged();
|
|
4185
4202
|
});
|
|
4186
4203
|
var notifySpy = isSpyEnabled();
|
|
4187
4204
|
var notify = hasListeners(this);
|
|
@@ -4193,7 +4210,8 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4193
4210
|
name: key,
|
|
4194
4211
|
newValue: newValue
|
|
4195
4212
|
} : null;
|
|
4196
|
-
if (process.env.NODE_ENV !== "production" && notifySpy) spyReportStart(change);
|
|
4213
|
+
if (process.env.NODE_ENV !== "production" && notifySpy) spyReportStart(change); // TODO fix type
|
|
4214
|
+
|
|
4197
4215
|
if (notify) notifyListeners(this, change);
|
|
4198
4216
|
if (process.env.NODE_ENV !== "production" && notifySpy) spyReportEnd();
|
|
4199
4217
|
};
|
|
@@ -4250,7 +4268,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4250
4268
|
});
|
|
4251
4269
|
};
|
|
4252
4270
|
|
|
4253
|
-
_proto[_Symbol$
|
|
4271
|
+
_proto[_Symbol$iterator2] = function () {
|
|
4254
4272
|
return this.entries();
|
|
4255
4273
|
};
|
|
4256
4274
|
|
|
@@ -4266,7 +4284,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4266
4284
|
;
|
|
4267
4285
|
|
|
4268
4286
|
_proto.merge = function merge(other) {
|
|
4269
|
-
var
|
|
4287
|
+
var _this5 = this;
|
|
4270
4288
|
|
|
4271
4289
|
if (isObservableMap(other)) {
|
|
4272
4290
|
other = new Map(other);
|
|
@@ -4274,15 +4292,15 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4274
4292
|
|
|
4275
4293
|
transaction(function () {
|
|
4276
4294
|
if (isPlainObject(other)) getPlainObjectKeys(other).forEach(function (key) {
|
|
4277
|
-
return
|
|
4295
|
+
return _this5.set(key, other[key]);
|
|
4278
4296
|
});else if (Array.isArray(other)) other.forEach(function (_ref) {
|
|
4279
4297
|
var key = _ref[0],
|
|
4280
4298
|
value = _ref[1];
|
|
4281
|
-
return
|
|
4299
|
+
return _this5.set(key, value);
|
|
4282
4300
|
});else if (isES6Map(other)) {
|
|
4283
4301
|
if (other.constructor !== Map) die(19, other);
|
|
4284
4302
|
other.forEach(function (value, key) {
|
|
4285
|
-
return
|
|
4303
|
+
return _this5.set(key, value);
|
|
4286
4304
|
});
|
|
4287
4305
|
} else if (other !== null && other !== undefined) die(20, other);
|
|
4288
4306
|
});
|
|
@@ -4290,21 +4308,21 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4290
4308
|
};
|
|
4291
4309
|
|
|
4292
4310
|
_proto.clear = function clear() {
|
|
4293
|
-
var
|
|
4311
|
+
var _this6 = this;
|
|
4294
4312
|
|
|
4295
4313
|
transaction(function () {
|
|
4296
4314
|
untracked(function () {
|
|
4297
|
-
for (var _iterator2 = _createForOfIteratorHelperLoose(
|
|
4315
|
+
for (var _iterator2 = _createForOfIteratorHelperLoose(_this6.keys()), _step2; !(_step2 = _iterator2()).done;) {
|
|
4298
4316
|
var key = _step2.value;
|
|
4299
4317
|
|
|
4300
|
-
|
|
4318
|
+
_this6["delete"](key);
|
|
4301
4319
|
}
|
|
4302
4320
|
});
|
|
4303
4321
|
});
|
|
4304
4322
|
};
|
|
4305
4323
|
|
|
4306
4324
|
_proto.replace = function replace(values) {
|
|
4307
|
-
var
|
|
4325
|
+
var _this7 = this;
|
|
4308
4326
|
|
|
4309
4327
|
// Implementation requirements:
|
|
4310
4328
|
// - respect ordering of replacement map
|
|
@@ -4321,13 +4339,13 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4321
4339
|
// if the key deletion is prevented by interceptor
|
|
4322
4340
|
// add entry at the beginning of the result map
|
|
4323
4341
|
|
|
4324
|
-
for (var _iterator3 = _createForOfIteratorHelperLoose(
|
|
4342
|
+
for (var _iterator3 = _createForOfIteratorHelperLoose(_this7.data_.keys()), _step3; !(_step3 = _iterator3()).done;) {
|
|
4325
4343
|
var key = _step3.value;
|
|
4326
4344
|
|
|
4327
4345
|
// Concurrently iterating/deleting keys
|
|
4328
4346
|
// iterator should handle this correctly
|
|
4329
4347
|
if (!replacementMap.has(key)) {
|
|
4330
|
-
var deleted =
|
|
4348
|
+
var deleted = _this7["delete"](key); // Was the key removed?
|
|
4331
4349
|
|
|
4332
4350
|
|
|
4333
4351
|
if (deleted) {
|
|
@@ -4335,7 +4353,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4335
4353
|
keysReportChangedCalled = true;
|
|
4336
4354
|
} else {
|
|
4337
4355
|
// Delete prevented by interceptor
|
|
4338
|
-
var value =
|
|
4356
|
+
var value = _this7.data_.get(key);
|
|
4339
4357
|
|
|
4340
4358
|
orderedData.set(key, value);
|
|
4341
4359
|
}
|
|
@@ -4349,17 +4367,17 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4349
4367
|
_value = _step4$value[1];
|
|
4350
4368
|
|
|
4351
4369
|
// We will want to know whether a new key is added
|
|
4352
|
-
var keyExisted =
|
|
4370
|
+
var keyExisted = _this7.data_.has(_key); // Add or update value
|
|
4353
4371
|
|
|
4354
4372
|
|
|
4355
|
-
|
|
4373
|
+
_this7.set(_key, _value); // The addition could have been prevent by interceptor
|
|
4356
4374
|
|
|
4357
4375
|
|
|
4358
|
-
if (
|
|
4376
|
+
if (_this7.data_.has(_key)) {
|
|
4359
4377
|
// The update could have been prevented by interceptor
|
|
4360
4378
|
// and also we want to preserve existing values
|
|
4361
4379
|
// so use value from _data map (instead of replacement map)
|
|
4362
|
-
var _value2 =
|
|
4380
|
+
var _value2 = _this7.data_.get(_key);
|
|
4363
4381
|
|
|
4364
4382
|
orderedData.set(_key, _value2); // Was a new key added?
|
|
4365
4383
|
|
|
@@ -4372,11 +4390,11 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4372
4390
|
|
|
4373
4391
|
|
|
4374
4392
|
if (!keysReportChangedCalled) {
|
|
4375
|
-
if (
|
|
4393
|
+
if (_this7.data_.size !== orderedData.size) {
|
|
4376
4394
|
// If size differs, keys are definitely modified
|
|
4377
|
-
|
|
4395
|
+
_this7.keysAtom_.reportChanged();
|
|
4378
4396
|
} else {
|
|
4379
|
-
var iter1 =
|
|
4397
|
+
var iter1 = _this7.data_.keys();
|
|
4380
4398
|
|
|
4381
4399
|
var iter2 = orderedData.keys();
|
|
4382
4400
|
var next1 = iter1.next();
|
|
@@ -4384,7 +4402,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4384
4402
|
|
|
4385
4403
|
while (!next1.done) {
|
|
4386
4404
|
if (next1.value !== next2.value) {
|
|
4387
|
-
|
|
4405
|
+
_this7.keysAtom_.reportChanged();
|
|
4388
4406
|
|
|
4389
4407
|
break;
|
|
4390
4408
|
}
|
|
@@ -4396,7 +4414,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4396
4414
|
} // Use correctly ordered map
|
|
4397
4415
|
|
|
4398
4416
|
|
|
4399
|
-
|
|
4417
|
+
_this7.data_ = orderedData;
|
|
4400
4418
|
});
|
|
4401
4419
|
return this;
|
|
4402
4420
|
};
|
|
@@ -4430,14 +4448,14 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4430
4448
|
return this.data_.size;
|
|
4431
4449
|
}
|
|
4432
4450
|
}, {
|
|
4433
|
-
key: _Symbol$
|
|
4451
|
+
key: _Symbol$toStringTag2,
|
|
4434
4452
|
get: function get() {
|
|
4435
4453
|
return "Map";
|
|
4436
4454
|
}
|
|
4437
4455
|
}]);
|
|
4438
4456
|
|
|
4439
4457
|
return ObservableMap;
|
|
4440
|
-
}(); // eslint-disable-next-line
|
|
4458
|
+
}(_Symbol$iterator, _Symbol$toStringTag); // eslint-disable-next-line
|
|
4441
4459
|
|
|
4442
4460
|
var isObservableMap = /*#__PURE__*/createInstanceofPredicate("ObservableMap", ObservableMap);
|
|
4443
4461
|
|
|
@@ -4463,7 +4481,7 @@ var _Symbol$iterator$1, _Symbol$toStringTag$1;
|
|
|
4463
4481
|
var ObservableSetMarker = {};
|
|
4464
4482
|
_Symbol$iterator$1 = Symbol.iterator;
|
|
4465
4483
|
_Symbol$toStringTag$1 = Symbol.toStringTag;
|
|
4466
|
-
var ObservableSet = /*#__PURE__*/function () {
|
|
4484
|
+
var ObservableSet = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTag2) {
|
|
4467
4485
|
function ObservableSet(initialData, enhancer, name_) {
|
|
4468
4486
|
if (enhancer === void 0) {
|
|
4469
4487
|
enhancer = deepEnhancer;
|
|
@@ -4696,7 +4714,7 @@ var ObservableSet = /*#__PURE__*/function () {
|
|
|
4696
4714
|
return "[object ObservableSet]";
|
|
4697
4715
|
};
|
|
4698
4716
|
|
|
4699
|
-
_proto[_Symbol$
|
|
4717
|
+
_proto[_Symbol$iterator2] = function () {
|
|
4700
4718
|
return this.values();
|
|
4701
4719
|
};
|
|
4702
4720
|
|
|
@@ -4707,14 +4725,14 @@ var ObservableSet = /*#__PURE__*/function () {
|
|
|
4707
4725
|
return this.data_.size;
|
|
4708
4726
|
}
|
|
4709
4727
|
}, {
|
|
4710
|
-
key: _Symbol$
|
|
4728
|
+
key: _Symbol$toStringTag2,
|
|
4711
4729
|
get: function get() {
|
|
4712
4730
|
return "Set";
|
|
4713
4731
|
}
|
|
4714
4732
|
}]);
|
|
4715
4733
|
|
|
4716
4734
|
return ObservableSet;
|
|
4717
|
-
}(); // eslint-disable-next-line
|
|
4735
|
+
}(_Symbol$iterator$1, _Symbol$toStringTag$1); // eslint-disable-next-line
|
|
4718
4736
|
|
|
4719
4737
|
var isObservableSet = /*#__PURE__*/createInstanceofPredicate("ObservableSet", ObservableSet);
|
|
4720
4738
|
|
|
@@ -4900,7 +4918,7 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
4900
4918
|
// When called from super() some props may not exist yet.
|
|
4901
4919
|
// However we don't have to worry about missing prop,
|
|
4902
4920
|
// because the decorator must have been applied to something.
|
|
4903
|
-
if ((_this$target_$storedA = this.target_[storedAnnotationsSymbol])
|
|
4921
|
+
if ((_this$target_$storedA = this.target_[storedAnnotationsSymbol]) != null && _this$target_$storedA[key]) {
|
|
4904
4922
|
return; // will be annotated by subclass constructor
|
|
4905
4923
|
} else {
|
|
4906
4924
|
die(1, annotation.annotationType_, this.name_ + "." + key.toString());
|
|
@@ -5404,7 +5422,7 @@ inherit(StubArray, Array.prototype); // Weex proto freeze protection was here,
|
|
|
5404
5422
|
// but it is unclear why the hack is need as MobX never changed the prototype
|
|
5405
5423
|
// anyway, so removed it in V6
|
|
5406
5424
|
|
|
5407
|
-
var LegacyObservableArray = /*#__PURE__*/function (_StubArray) {
|
|
5425
|
+
var LegacyObservableArray = /*#__PURE__*/function (_StubArray, _Symbol$toStringTag, _Symbol$iterator) {
|
|
5408
5426
|
_inheritsLoose(LegacyObservableArray, _StubArray);
|
|
5409
5427
|
|
|
5410
5428
|
function LegacyObservableArray(initialValues, enhancer, name, owned) {
|
|
@@ -5449,7 +5467,7 @@ var LegacyObservableArray = /*#__PURE__*/function (_StubArray) {
|
|
|
5449
5467
|
}));
|
|
5450
5468
|
};
|
|
5451
5469
|
|
|
5452
|
-
_proto[
|
|
5470
|
+
_proto[_Symbol$iterator] = function () {
|
|
5453
5471
|
var self = this;
|
|
5454
5472
|
var nextIndex = 0;
|
|
5455
5473
|
return makeIterable({
|
|
@@ -5475,14 +5493,14 @@ var LegacyObservableArray = /*#__PURE__*/function (_StubArray) {
|
|
|
5475
5493
|
this[$mobx].setArrayLength_(newLength);
|
|
5476
5494
|
}
|
|
5477
5495
|
}, {
|
|
5478
|
-
key:
|
|
5496
|
+
key: _Symbol$toStringTag,
|
|
5479
5497
|
get: function get() {
|
|
5480
5498
|
return "Array";
|
|
5481
5499
|
}
|
|
5482
5500
|
}]);
|
|
5483
5501
|
|
|
5484
5502
|
return LegacyObservableArray;
|
|
5485
|
-
}(StubArray);
|
|
5503
|
+
}(StubArray, Symbol.toStringTag, Symbol.iterator);
|
|
5486
5504
|
|
|
5487
5505
|
Object.entries(arrayExtensions).forEach(function (_ref) {
|
|
5488
5506
|
var prop = _ref[0],
|
|
@@ -5605,7 +5623,7 @@ function eq(a, b, depth, aStack, bStack) {
|
|
|
5605
5623
|
if (a !== a) return b !== b; // Exhaust primitive checks
|
|
5606
5624
|
|
|
5607
5625
|
var type = typeof a;
|
|
5608
|
-
if (
|
|
5626
|
+
if (type !== "function" && type !== "object" && typeof b != "object") return false; // Compare `[[Class]]` names.
|
|
5609
5627
|
|
|
5610
5628
|
var className = toString.call(a);
|
|
5611
5629
|
if (className !== toString.call(b)) return false;
|