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
|
@@ -164,12 +164,11 @@ function isObject(value) {
|
|
|
164
164
|
return value !== null && typeof value === "object";
|
|
165
165
|
}
|
|
166
166
|
function isPlainObject(value) {
|
|
167
|
-
var _proto$constructor;
|
|
168
|
-
|
|
169
167
|
if (!isObject(value)) return false;
|
|
170
168
|
var proto = Object.getPrototypeOf(value);
|
|
171
169
|
if (proto == null) return true;
|
|
172
|
-
|
|
170
|
+
var protoConstructor = Object.hasOwnProperty.call(proto, "constructor") && proto.constructor;
|
|
171
|
+
return typeof protoConstructor === "function" && protoConstructor.toString() === plainObjectString;
|
|
173
172
|
} // https://stackoverflow.com/a/37865170
|
|
174
173
|
|
|
175
174
|
function isGenerator(obj) {
|
|
@@ -264,6 +263,9 @@ function _defineProperties(target, props) {
|
|
|
264
263
|
function _createClass(Constructor, protoProps, staticProps) {
|
|
265
264
|
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
266
265
|
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
266
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
267
|
+
writable: false
|
|
268
|
+
});
|
|
267
269
|
return Constructor;
|
|
268
270
|
}
|
|
269
271
|
|
|
@@ -288,7 +290,17 @@ function _extends() {
|
|
|
288
290
|
function _inheritsLoose(subClass, superClass) {
|
|
289
291
|
subClass.prototype = Object.create(superClass.prototype);
|
|
290
292
|
subClass.prototype.constructor = subClass;
|
|
291
|
-
|
|
293
|
+
|
|
294
|
+
_setPrototypeOf(subClass, superClass);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
function _setPrototypeOf(o, p) {
|
|
298
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
299
|
+
o.__proto__ = p;
|
|
300
|
+
return o;
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
return _setPrototypeOf(o, p);
|
|
292
304
|
}
|
|
293
305
|
|
|
294
306
|
function _assertThisInitialized(self) {
|
|
@@ -317,28 +329,24 @@ function _arrayLikeToArray(arr, len) {
|
|
|
317
329
|
}
|
|
318
330
|
|
|
319
331
|
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
320
|
-
var it;
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
};
|
|
330
|
-
return {
|
|
331
|
-
done: false,
|
|
332
|
-
value: o[i++]
|
|
333
|
-
};
|
|
332
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
333
|
+
if (it) return (it = it.call(o)).next.bind(it);
|
|
334
|
+
|
|
335
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
336
|
+
if (it) o = it;
|
|
337
|
+
var i = 0;
|
|
338
|
+
return function () {
|
|
339
|
+
if (i >= o.length) return {
|
|
340
|
+
done: true
|
|
334
341
|
};
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
342
|
+
return {
|
|
343
|
+
done: false,
|
|
344
|
+
value: o[i++]
|
|
345
|
+
};
|
|
346
|
+
};
|
|
338
347
|
}
|
|
339
348
|
|
|
340
|
-
|
|
341
|
-
return it.next.bind(it);
|
|
349
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
342
350
|
}
|
|
343
351
|
|
|
344
352
|
var storedAnnotationsSymbol = /*#__PURE__*/Symbol("mobx-stored-annotations");
|
|
@@ -622,7 +630,7 @@ function make_$1(adm, key, descriptor, source) {
|
|
|
622
630
|
var _this$options_;
|
|
623
631
|
|
|
624
632
|
// bound
|
|
625
|
-
if ((_this$options_ = this.options_)
|
|
633
|
+
if ((_this$options_ = this.options_) != null && _this$options_.bound) {
|
|
626
634
|
return this.extend_(adm, key, descriptor, false) === null ? 0
|
|
627
635
|
/* Cancel */
|
|
628
636
|
: 1
|
|
@@ -680,7 +688,7 @@ safeDescriptors) {
|
|
|
680
688
|
assertActionDescriptor(adm, annotation, key, descriptor);
|
|
681
689
|
var value = descriptor.value;
|
|
682
690
|
|
|
683
|
-
if ((_annotation$options_ = annotation.options_)
|
|
691
|
+
if ((_annotation$options_ = annotation.options_) != null && _annotation$options_.bound) {
|
|
684
692
|
var _adm$proxy_;
|
|
685
693
|
|
|
686
694
|
value = value.bind((_adm$proxy_ = adm.proxy_) != null ? _adm$proxy_ : adm.target_);
|
|
@@ -688,7 +696,7 @@ safeDescriptors) {
|
|
|
688
696
|
|
|
689
697
|
return {
|
|
690
698
|
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
|
|
691
|
-
(
|
|
699
|
+
(_annotation$options_4 = annotation.options_) != null && _annotation$options_4.bound ? (_adm$proxy_2 = adm.proxy_) != null ? _adm$proxy_2 : adm.target_ : undefined),
|
|
692
700
|
// Non-configurable for classes
|
|
693
701
|
// prevents accidental field redefinition in subclass
|
|
694
702
|
configurable: safeDescriptors ? adm.isPlainObject_ : true,
|
|
@@ -723,7 +731,7 @@ function make_$2(adm, key, descriptor, source) {
|
|
|
723
731
|
// bound - must annotate protos to support super.flow()
|
|
724
732
|
|
|
725
733
|
|
|
726
|
-
if ((
|
|
734
|
+
if ((_this$options_ = this.options_) != null && _this$options_.bound && !isFlow(adm.target_[key])) {
|
|
727
735
|
if (this.extend_(adm, key, descriptor, false) === null) return 0
|
|
728
736
|
/* Cancel */
|
|
729
737
|
;
|
|
@@ -906,11 +914,11 @@ function make_$5(adm, key, descriptor, source) {
|
|
|
906
914
|
if (isGenerator(descriptor.value)) {
|
|
907
915
|
var _this$options_;
|
|
908
916
|
|
|
909
|
-
var flowAnnotation = (
|
|
917
|
+
var flowAnnotation = (_this$options_ = this.options_) != null && _this$options_.autoBind ? flow.bound : flow;
|
|
910
918
|
return flowAnnotation.make_(adm, key, descriptor, source);
|
|
911
919
|
}
|
|
912
920
|
|
|
913
|
-
var actionAnnotation = (
|
|
921
|
+
var actionAnnotation = (_this$options_2 = this.options_) != null && _this$options_2.autoBind ? autoAction.bound : autoAction;
|
|
914
922
|
return actionAnnotation.make_(adm, key, descriptor, source);
|
|
915
923
|
} // other -> observable
|
|
916
924
|
// Copy props from proto as well, see test:
|
|
@@ -919,7 +927,7 @@ function make_$5(adm, key, descriptor, source) {
|
|
|
919
927
|
|
|
920
928
|
var observableAnnotation = ((_this$options_3 = this.options_) == null ? void 0 : _this$options_3.deep) === false ? observable.ref : observable; // if function respect autoBind option
|
|
921
929
|
|
|
922
|
-
if (typeof descriptor.value === "function" && (
|
|
930
|
+
if (typeof descriptor.value === "function" && (_this$options_4 = this.options_) != null && _this$options_4.autoBind) {
|
|
923
931
|
var _adm$proxy_;
|
|
924
932
|
|
|
925
933
|
descriptor.value = descriptor.value.bind((_adm$proxy_ = adm.proxy_) != null ? _adm$proxy_ : adm.target_);
|
|
@@ -947,7 +955,7 @@ function extend_$5(adm, key, descriptor, proxyTrap) {
|
|
|
947
955
|
// if function respect autoBind option
|
|
948
956
|
|
|
949
957
|
|
|
950
|
-
if (typeof descriptor.value === "function" && (
|
|
958
|
+
if (typeof descriptor.value === "function" && (_this$options_5 = this.options_) != null && _this$options_5.autoBind) {
|
|
951
959
|
var _adm$proxy_2;
|
|
952
960
|
|
|
953
961
|
descriptor.value = descriptor.value.bind((_adm$proxy_2 = adm.proxy_) != null ? _adm$proxy_2 : adm.target_);
|
|
@@ -1225,7 +1233,7 @@ function allowStateChangesEnd(prev) {
|
|
|
1225
1233
|
var _Symbol$toPrimitive;
|
|
1226
1234
|
var CREATE = "create";
|
|
1227
1235
|
_Symbol$toPrimitive = Symbol.toPrimitive;
|
|
1228
|
-
var ObservableValue = /*#__PURE__*/function (_Atom) {
|
|
1236
|
+
var ObservableValue = /*#__PURE__*/function (_Atom, _Symbol$toPrimitive2) {
|
|
1229
1237
|
_inheritsLoose(ObservableValue, _Atom);
|
|
1230
1238
|
|
|
1231
1239
|
function ObservableValue(value, enhancer, name_, notifySpy, equals) {
|
|
@@ -1372,12 +1380,12 @@ var ObservableValue = /*#__PURE__*/function (_Atom) {
|
|
|
1372
1380
|
return toPrimitive(this.get());
|
|
1373
1381
|
};
|
|
1374
1382
|
|
|
1375
|
-
_proto[_Symbol$
|
|
1383
|
+
_proto[_Symbol$toPrimitive2] = function () {
|
|
1376
1384
|
return this.valueOf();
|
|
1377
1385
|
};
|
|
1378
1386
|
|
|
1379
1387
|
return ObservableValue;
|
|
1380
|
-
}(Atom);
|
|
1388
|
+
}(Atom, _Symbol$toPrimitive);
|
|
1381
1389
|
var isObservableValue = /*#__PURE__*/createInstanceofPredicate("ObservableValue", ObservableValue);
|
|
1382
1390
|
|
|
1383
1391
|
var _Symbol$toPrimitive$1;
|
|
@@ -1402,7 +1410,7 @@ var _Symbol$toPrimitive$1;
|
|
|
1402
1410
|
*/
|
|
1403
1411
|
|
|
1404
1412
|
_Symbol$toPrimitive$1 = Symbol.toPrimitive;
|
|
1405
|
-
var ComputedValue = /*#__PURE__*/function () {
|
|
1413
|
+
var ComputedValue = /*#__PURE__*/function (_Symbol$toPrimitive2) {
|
|
1406
1414
|
// nodes we are looking at. Our value depends on these nodes
|
|
1407
1415
|
// during tracking it's an array with new observed observers
|
|
1408
1416
|
// to check for cycles
|
|
@@ -1456,7 +1464,7 @@ var ComputedValue = /*#__PURE__*/function () {
|
|
|
1456
1464
|
|
|
1457
1465
|
this.equals_ = options.equals || (options.compareStructural || options.struct ? comparer.structural : comparer["default"]);
|
|
1458
1466
|
this.scope_ = options.context;
|
|
1459
|
-
this.requiresReaction_ =
|
|
1467
|
+
this.requiresReaction_ = options.requiresReaction;
|
|
1460
1468
|
this.keepAlive_ = !!options.keepAlive;
|
|
1461
1469
|
}
|
|
1462
1470
|
|
|
@@ -1624,7 +1632,7 @@ var ComputedValue = /*#__PURE__*/function () {
|
|
|
1624
1632
|
console.log("[mobx.trace] Computed value '" + this.name_ + "' is being read outside a reactive context. Doing a full recompute.");
|
|
1625
1633
|
}
|
|
1626
1634
|
|
|
1627
|
-
if (
|
|
1635
|
+
if (typeof this.requiresReaction_ === "boolean" ? this.requiresReaction_ : globalState.computedRequiresReaction) {
|
|
1628
1636
|
console.warn("[mobx] Computed value '" + this.name_ + "' is being read outside a reactive context. Doing a full recompute.");
|
|
1629
1637
|
}
|
|
1630
1638
|
};
|
|
@@ -1637,12 +1645,12 @@ var ComputedValue = /*#__PURE__*/function () {
|
|
|
1637
1645
|
return toPrimitive(this.get());
|
|
1638
1646
|
};
|
|
1639
1647
|
|
|
1640
|
-
_proto[_Symbol$
|
|
1648
|
+
_proto[_Symbol$toPrimitive2] = function () {
|
|
1641
1649
|
return this.valueOf();
|
|
1642
1650
|
};
|
|
1643
1651
|
|
|
1644
1652
|
return ComputedValue;
|
|
1645
|
-
}();
|
|
1653
|
+
}(_Symbol$toPrimitive$1);
|
|
1646
1654
|
var isComputedValue = /*#__PURE__*/createInstanceofPredicate("ComputedValue", ComputedValue);
|
|
1647
1655
|
|
|
1648
1656
|
var IDerivationState_;
|
|
@@ -2183,8 +2191,8 @@ function propagateChangeConfirmed(observable) {
|
|
|
2183
2191
|
}
|
|
2184
2192
|
} else if (d.dependenciesState_ === IDerivationState_.UP_TO_DATE_ // this happens during computing of `d`, just keep lowestObserverState up to date.
|
|
2185
2193
|
) {
|
|
2186
|
-
|
|
2187
|
-
|
|
2194
|
+
observable.lowestObserverState_ = IDerivationState_.UP_TO_DATE_;
|
|
2195
|
+
}
|
|
2188
2196
|
}); // invariantLOS(observable, "confirmed end");
|
|
2189
2197
|
} // Used by computed when its dependency changed, but we don't wan't to immediately recompute.
|
|
2190
2198
|
|
|
@@ -3212,7 +3220,10 @@ function toJSHelper(source, __alreadySeen) {
|
|
|
3212
3220
|
}
|
|
3213
3221
|
}
|
|
3214
3222
|
/**
|
|
3215
|
-
*
|
|
3223
|
+
* Recursively converts an observable to it's non-observable native counterpart.
|
|
3224
|
+
* It does NOT recurse into non-observables, these are left as they are, even if they contain observables.
|
|
3225
|
+
* Computed and other non-enumerable properties are completely ignored.
|
|
3226
|
+
* Complex scenarios require custom solution, eg implementing `toJSON` or using `serializr` lib.
|
|
3216
3227
|
*/
|
|
3217
3228
|
|
|
3218
3229
|
|
|
@@ -4001,9 +4012,11 @@ var DELETE = "delete"; // just extend Map? See also https://gist.github.com/nest
|
|
|
4001
4012
|
|
|
4002
4013
|
_Symbol$iterator = Symbol.iterator;
|
|
4003
4014
|
_Symbol$toStringTag = Symbol.toStringTag;
|
|
4004
|
-
var ObservableMap = /*#__PURE__*/function () {
|
|
4015
|
+
var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTag2) {
|
|
4005
4016
|
// hasMap, not hashMap >-).
|
|
4006
4017
|
function ObservableMap(initialData, enhancer_, name_) {
|
|
4018
|
+
var _this = this;
|
|
4019
|
+
|
|
4007
4020
|
if (enhancer_ === void 0) {
|
|
4008
4021
|
enhancer_ = deepEnhancer;
|
|
4009
4022
|
}
|
|
@@ -4031,7 +4044,9 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4031
4044
|
this.keysAtom_ = createAtom( this.name_ + ".keys()" );
|
|
4032
4045
|
this.data_ = new Map();
|
|
4033
4046
|
this.hasMap_ = new Map();
|
|
4034
|
-
|
|
4047
|
+
allowStateChanges(true, function () {
|
|
4048
|
+
_this.merge(initialData);
|
|
4049
|
+
});
|
|
4035
4050
|
}
|
|
4036
4051
|
|
|
4037
4052
|
var _proto = ObservableMap.prototype;
|
|
@@ -4041,7 +4056,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4041
4056
|
};
|
|
4042
4057
|
|
|
4043
4058
|
_proto.has = function has(key) {
|
|
4044
|
-
var
|
|
4059
|
+
var _this2 = this;
|
|
4045
4060
|
|
|
4046
4061
|
if (!globalState.trackingDerivation) return this.has_(key);
|
|
4047
4062
|
var entry = this.hasMap_.get(key);
|
|
@@ -4050,7 +4065,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4050
4065
|
var newEntry = entry = new ObservableValue(this.has_(key), referenceEnhancer, this.name_ + "." + stringifyKey(key) + "?" , false);
|
|
4051
4066
|
this.hasMap_.set(key, newEntry);
|
|
4052
4067
|
onBecomeUnobserved(newEntry, function () {
|
|
4053
|
-
return
|
|
4068
|
+
return _this2.hasMap_["delete"](key);
|
|
4054
4069
|
});
|
|
4055
4070
|
}
|
|
4056
4071
|
|
|
@@ -4081,7 +4096,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4081
4096
|
};
|
|
4082
4097
|
|
|
4083
4098
|
_proto["delete"] = function _delete(key) {
|
|
4084
|
-
var
|
|
4099
|
+
var _this3 = this;
|
|
4085
4100
|
|
|
4086
4101
|
checkIfStateModificationsAreAllowed(this.keysAtom_);
|
|
4087
4102
|
|
|
@@ -4107,19 +4122,20 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4107
4122
|
name: key
|
|
4108
4123
|
} : null;
|
|
4109
4124
|
|
|
4110
|
-
if ( notifySpy) spyReportStart(_change);
|
|
4125
|
+
if ( notifySpy) spyReportStart(_change); // TODO fix type
|
|
4126
|
+
|
|
4111
4127
|
transaction(function () {
|
|
4112
|
-
var
|
|
4128
|
+
var _this3$hasMap_$get;
|
|
4113
4129
|
|
|
4114
|
-
|
|
4130
|
+
_this3.keysAtom_.reportChanged();
|
|
4115
4131
|
|
|
4116
|
-
(
|
|
4132
|
+
(_this3$hasMap_$get = _this3.hasMap_.get(key)) == null ? void 0 : _this3$hasMap_$get.setNewValue_(false);
|
|
4117
4133
|
|
|
4118
|
-
var observable =
|
|
4134
|
+
var observable = _this3.data_.get(key);
|
|
4119
4135
|
|
|
4120
4136
|
observable.setNewValue_(undefined);
|
|
4121
4137
|
|
|
4122
|
-
|
|
4138
|
+
_this3.data_["delete"](key);
|
|
4123
4139
|
});
|
|
4124
4140
|
if (notify) notifyListeners(this, _change);
|
|
4125
4141
|
if ( notifySpy) spyReportEnd();
|
|
@@ -4145,7 +4161,8 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4145
4161
|
name: key,
|
|
4146
4162
|
newValue: newValue
|
|
4147
4163
|
} : null;
|
|
4148
|
-
if ( notifySpy) spyReportStart(change);
|
|
4164
|
+
if ( notifySpy) spyReportStart(change); // TODO fix type
|
|
4165
|
+
|
|
4149
4166
|
observable.setNewValue_(newValue);
|
|
4150
4167
|
if (notify) notifyListeners(this, change);
|
|
4151
4168
|
if ( notifySpy) spyReportEnd();
|
|
@@ -4153,21 +4170,21 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4153
4170
|
};
|
|
4154
4171
|
|
|
4155
4172
|
_proto.addValue_ = function addValue_(key, newValue) {
|
|
4156
|
-
var
|
|
4173
|
+
var _this4 = this;
|
|
4157
4174
|
|
|
4158
4175
|
checkIfStateModificationsAreAllowed(this.keysAtom_);
|
|
4159
4176
|
transaction(function () {
|
|
4160
|
-
var
|
|
4177
|
+
var _this4$hasMap_$get;
|
|
4161
4178
|
|
|
4162
|
-
var observable = new ObservableValue(newValue,
|
|
4179
|
+
var observable = new ObservableValue(newValue, _this4.enhancer_, _this4.name_ + "." + stringifyKey(key) , false);
|
|
4163
4180
|
|
|
4164
|
-
|
|
4181
|
+
_this4.data_.set(key, observable);
|
|
4165
4182
|
|
|
4166
4183
|
newValue = observable.value_; // value might have been changed
|
|
4167
4184
|
|
|
4168
|
-
(
|
|
4185
|
+
(_this4$hasMap_$get = _this4.hasMap_.get(key)) == null ? void 0 : _this4$hasMap_$get.setNewValue_(true);
|
|
4169
4186
|
|
|
4170
|
-
|
|
4187
|
+
_this4.keysAtom_.reportChanged();
|
|
4171
4188
|
});
|
|
4172
4189
|
var notifySpy = isSpyEnabled();
|
|
4173
4190
|
var notify = hasListeners(this);
|
|
@@ -4179,7 +4196,8 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4179
4196
|
name: key,
|
|
4180
4197
|
newValue: newValue
|
|
4181
4198
|
} : null;
|
|
4182
|
-
if ( notifySpy) spyReportStart(change);
|
|
4199
|
+
if ( notifySpy) spyReportStart(change); // TODO fix type
|
|
4200
|
+
|
|
4183
4201
|
if (notify) notifyListeners(this, change);
|
|
4184
4202
|
if ( notifySpy) spyReportEnd();
|
|
4185
4203
|
};
|
|
@@ -4236,7 +4254,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4236
4254
|
});
|
|
4237
4255
|
};
|
|
4238
4256
|
|
|
4239
|
-
_proto[_Symbol$
|
|
4257
|
+
_proto[_Symbol$iterator2] = function () {
|
|
4240
4258
|
return this.entries();
|
|
4241
4259
|
};
|
|
4242
4260
|
|
|
@@ -4252,7 +4270,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4252
4270
|
;
|
|
4253
4271
|
|
|
4254
4272
|
_proto.merge = function merge(other) {
|
|
4255
|
-
var
|
|
4273
|
+
var _this5 = this;
|
|
4256
4274
|
|
|
4257
4275
|
if (isObservableMap(other)) {
|
|
4258
4276
|
other = new Map(other);
|
|
@@ -4260,15 +4278,15 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4260
4278
|
|
|
4261
4279
|
transaction(function () {
|
|
4262
4280
|
if (isPlainObject(other)) getPlainObjectKeys(other).forEach(function (key) {
|
|
4263
|
-
return
|
|
4281
|
+
return _this5.set(key, other[key]);
|
|
4264
4282
|
});else if (Array.isArray(other)) other.forEach(function (_ref) {
|
|
4265
4283
|
var key = _ref[0],
|
|
4266
4284
|
value = _ref[1];
|
|
4267
|
-
return
|
|
4285
|
+
return _this5.set(key, value);
|
|
4268
4286
|
});else if (isES6Map(other)) {
|
|
4269
4287
|
if (other.constructor !== Map) die(19, other);
|
|
4270
4288
|
other.forEach(function (value, key) {
|
|
4271
|
-
return
|
|
4289
|
+
return _this5.set(key, value);
|
|
4272
4290
|
});
|
|
4273
4291
|
} else if (other !== null && other !== undefined) die(20, other);
|
|
4274
4292
|
});
|
|
@@ -4276,21 +4294,21 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4276
4294
|
};
|
|
4277
4295
|
|
|
4278
4296
|
_proto.clear = function clear() {
|
|
4279
|
-
var
|
|
4297
|
+
var _this6 = this;
|
|
4280
4298
|
|
|
4281
4299
|
transaction(function () {
|
|
4282
4300
|
untracked(function () {
|
|
4283
|
-
for (var _iterator2 = _createForOfIteratorHelperLoose(
|
|
4301
|
+
for (var _iterator2 = _createForOfIteratorHelperLoose(_this6.keys()), _step2; !(_step2 = _iterator2()).done;) {
|
|
4284
4302
|
var key = _step2.value;
|
|
4285
4303
|
|
|
4286
|
-
|
|
4304
|
+
_this6["delete"](key);
|
|
4287
4305
|
}
|
|
4288
4306
|
});
|
|
4289
4307
|
});
|
|
4290
4308
|
};
|
|
4291
4309
|
|
|
4292
4310
|
_proto.replace = function replace(values) {
|
|
4293
|
-
var
|
|
4311
|
+
var _this7 = this;
|
|
4294
4312
|
|
|
4295
4313
|
// Implementation requirements:
|
|
4296
4314
|
// - respect ordering of replacement map
|
|
@@ -4307,13 +4325,13 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4307
4325
|
// if the key deletion is prevented by interceptor
|
|
4308
4326
|
// add entry at the beginning of the result map
|
|
4309
4327
|
|
|
4310
|
-
for (var _iterator3 = _createForOfIteratorHelperLoose(
|
|
4328
|
+
for (var _iterator3 = _createForOfIteratorHelperLoose(_this7.data_.keys()), _step3; !(_step3 = _iterator3()).done;) {
|
|
4311
4329
|
var key = _step3.value;
|
|
4312
4330
|
|
|
4313
4331
|
// Concurrently iterating/deleting keys
|
|
4314
4332
|
// iterator should handle this correctly
|
|
4315
4333
|
if (!replacementMap.has(key)) {
|
|
4316
|
-
var deleted =
|
|
4334
|
+
var deleted = _this7["delete"](key); // Was the key removed?
|
|
4317
4335
|
|
|
4318
4336
|
|
|
4319
4337
|
if (deleted) {
|
|
@@ -4321,7 +4339,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4321
4339
|
keysReportChangedCalled = true;
|
|
4322
4340
|
} else {
|
|
4323
4341
|
// Delete prevented by interceptor
|
|
4324
|
-
var value =
|
|
4342
|
+
var value = _this7.data_.get(key);
|
|
4325
4343
|
|
|
4326
4344
|
orderedData.set(key, value);
|
|
4327
4345
|
}
|
|
@@ -4335,17 +4353,17 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4335
4353
|
_value = _step4$value[1];
|
|
4336
4354
|
|
|
4337
4355
|
// We will want to know whether a new key is added
|
|
4338
|
-
var keyExisted =
|
|
4356
|
+
var keyExisted = _this7.data_.has(_key); // Add or update value
|
|
4339
4357
|
|
|
4340
4358
|
|
|
4341
|
-
|
|
4359
|
+
_this7.set(_key, _value); // The addition could have been prevent by interceptor
|
|
4342
4360
|
|
|
4343
4361
|
|
|
4344
|
-
if (
|
|
4362
|
+
if (_this7.data_.has(_key)) {
|
|
4345
4363
|
// The update could have been prevented by interceptor
|
|
4346
4364
|
// and also we want to preserve existing values
|
|
4347
4365
|
// so use value from _data map (instead of replacement map)
|
|
4348
|
-
var _value2 =
|
|
4366
|
+
var _value2 = _this7.data_.get(_key);
|
|
4349
4367
|
|
|
4350
4368
|
orderedData.set(_key, _value2); // Was a new key added?
|
|
4351
4369
|
|
|
@@ -4358,11 +4376,11 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4358
4376
|
|
|
4359
4377
|
|
|
4360
4378
|
if (!keysReportChangedCalled) {
|
|
4361
|
-
if (
|
|
4379
|
+
if (_this7.data_.size !== orderedData.size) {
|
|
4362
4380
|
// If size differs, keys are definitely modified
|
|
4363
|
-
|
|
4381
|
+
_this7.keysAtom_.reportChanged();
|
|
4364
4382
|
} else {
|
|
4365
|
-
var iter1 =
|
|
4383
|
+
var iter1 = _this7.data_.keys();
|
|
4366
4384
|
|
|
4367
4385
|
var iter2 = orderedData.keys();
|
|
4368
4386
|
var next1 = iter1.next();
|
|
@@ -4370,7 +4388,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4370
4388
|
|
|
4371
4389
|
while (!next1.done) {
|
|
4372
4390
|
if (next1.value !== next2.value) {
|
|
4373
|
-
|
|
4391
|
+
_this7.keysAtom_.reportChanged();
|
|
4374
4392
|
|
|
4375
4393
|
break;
|
|
4376
4394
|
}
|
|
@@ -4382,7 +4400,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4382
4400
|
} // Use correctly ordered map
|
|
4383
4401
|
|
|
4384
4402
|
|
|
4385
|
-
|
|
4403
|
+
_this7.data_ = orderedData;
|
|
4386
4404
|
});
|
|
4387
4405
|
return this;
|
|
4388
4406
|
};
|
|
@@ -4416,14 +4434,14 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4416
4434
|
return this.data_.size;
|
|
4417
4435
|
}
|
|
4418
4436
|
}, {
|
|
4419
|
-
key: _Symbol$
|
|
4437
|
+
key: _Symbol$toStringTag2,
|
|
4420
4438
|
get: function get() {
|
|
4421
4439
|
return "Map";
|
|
4422
4440
|
}
|
|
4423
4441
|
}]);
|
|
4424
4442
|
|
|
4425
4443
|
return ObservableMap;
|
|
4426
|
-
}(); // eslint-disable-next-line
|
|
4444
|
+
}(_Symbol$iterator, _Symbol$toStringTag); // eslint-disable-next-line
|
|
4427
4445
|
|
|
4428
4446
|
var isObservableMap = /*#__PURE__*/createInstanceofPredicate("ObservableMap", ObservableMap);
|
|
4429
4447
|
|
|
@@ -4449,7 +4467,7 @@ var _Symbol$iterator$1, _Symbol$toStringTag$1;
|
|
|
4449
4467
|
var ObservableSetMarker = {};
|
|
4450
4468
|
_Symbol$iterator$1 = Symbol.iterator;
|
|
4451
4469
|
_Symbol$toStringTag$1 = Symbol.toStringTag;
|
|
4452
|
-
var ObservableSet = /*#__PURE__*/function () {
|
|
4470
|
+
var ObservableSet = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTag2) {
|
|
4453
4471
|
function ObservableSet(initialData, enhancer, name_) {
|
|
4454
4472
|
if (enhancer === void 0) {
|
|
4455
4473
|
enhancer = deepEnhancer;
|
|
@@ -4682,7 +4700,7 @@ var ObservableSet = /*#__PURE__*/function () {
|
|
|
4682
4700
|
return "[object ObservableSet]";
|
|
4683
4701
|
};
|
|
4684
4702
|
|
|
4685
|
-
_proto[_Symbol$
|
|
4703
|
+
_proto[_Symbol$iterator2] = function () {
|
|
4686
4704
|
return this.values();
|
|
4687
4705
|
};
|
|
4688
4706
|
|
|
@@ -4693,14 +4711,14 @@ var ObservableSet = /*#__PURE__*/function () {
|
|
|
4693
4711
|
return this.data_.size;
|
|
4694
4712
|
}
|
|
4695
4713
|
}, {
|
|
4696
|
-
key: _Symbol$
|
|
4714
|
+
key: _Symbol$toStringTag2,
|
|
4697
4715
|
get: function get() {
|
|
4698
4716
|
return "Set";
|
|
4699
4717
|
}
|
|
4700
4718
|
}]);
|
|
4701
4719
|
|
|
4702
4720
|
return ObservableSet;
|
|
4703
|
-
}(); // eslint-disable-next-line
|
|
4721
|
+
}(_Symbol$iterator$1, _Symbol$toStringTag$1); // eslint-disable-next-line
|
|
4704
4722
|
|
|
4705
4723
|
var isObservableSet = /*#__PURE__*/createInstanceofPredicate("ObservableSet", ObservableSet);
|
|
4706
4724
|
|
|
@@ -4886,7 +4904,7 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
4886
4904
|
// When called from super() some props may not exist yet.
|
|
4887
4905
|
// However we don't have to worry about missing prop,
|
|
4888
4906
|
// because the decorator must have been applied to something.
|
|
4889
|
-
if ((_this$target_$storedA = this.target_[storedAnnotationsSymbol])
|
|
4907
|
+
if ((_this$target_$storedA = this.target_[storedAnnotationsSymbol]) != null && _this$target_$storedA[key]) {
|
|
4890
4908
|
return; // will be annotated by subclass constructor
|
|
4891
4909
|
} else {
|
|
4892
4910
|
die(1, annotation.annotationType_, this.name_ + "." + key.toString());
|
|
@@ -5390,7 +5408,7 @@ inherit(StubArray, Array.prototype); // Weex proto freeze protection was here,
|
|
|
5390
5408
|
// but it is unclear why the hack is need as MobX never changed the prototype
|
|
5391
5409
|
// anyway, so removed it in V6
|
|
5392
5410
|
|
|
5393
|
-
var LegacyObservableArray = /*#__PURE__*/function (_StubArray) {
|
|
5411
|
+
var LegacyObservableArray = /*#__PURE__*/function (_StubArray, _Symbol$toStringTag, _Symbol$iterator) {
|
|
5394
5412
|
_inheritsLoose(LegacyObservableArray, _StubArray);
|
|
5395
5413
|
|
|
5396
5414
|
function LegacyObservableArray(initialValues, enhancer, name, owned) {
|
|
@@ -5435,7 +5453,7 @@ var LegacyObservableArray = /*#__PURE__*/function (_StubArray) {
|
|
|
5435
5453
|
}));
|
|
5436
5454
|
};
|
|
5437
5455
|
|
|
5438
|
-
_proto[
|
|
5456
|
+
_proto[_Symbol$iterator] = function () {
|
|
5439
5457
|
var self = this;
|
|
5440
5458
|
var nextIndex = 0;
|
|
5441
5459
|
return makeIterable({
|
|
@@ -5461,14 +5479,14 @@ var LegacyObservableArray = /*#__PURE__*/function (_StubArray) {
|
|
|
5461
5479
|
this[$mobx].setArrayLength_(newLength);
|
|
5462
5480
|
}
|
|
5463
5481
|
}, {
|
|
5464
|
-
key:
|
|
5482
|
+
key: _Symbol$toStringTag,
|
|
5465
5483
|
get: function get() {
|
|
5466
5484
|
return "Array";
|
|
5467
5485
|
}
|
|
5468
5486
|
}]);
|
|
5469
5487
|
|
|
5470
5488
|
return LegacyObservableArray;
|
|
5471
|
-
}(StubArray);
|
|
5489
|
+
}(StubArray, Symbol.toStringTag, Symbol.iterator);
|
|
5472
5490
|
|
|
5473
5491
|
Object.entries(arrayExtensions).forEach(function (_ref) {
|
|
5474
5492
|
var prop = _ref[0],
|
|
@@ -5591,7 +5609,7 @@ function eq(a, b, depth, aStack, bStack) {
|
|
|
5591
5609
|
if (a !== a) return b !== b; // Exhaust primitive checks
|
|
5592
5610
|
|
|
5593
5611
|
var type = typeof a;
|
|
5594
|
-
if (
|
|
5612
|
+
if (type !== "function" && type !== "object" && typeof b != "object") return false; // Compare `[[Class]]` names.
|
|
5595
5613
|
|
|
5596
5614
|
var className = toString.call(a);
|
|
5597
5615
|
if (className !== toString.call(b)) return false;
|