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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# mobx
|
|
2
2
|
|
|
3
|
+
## 6.3.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`654a2013`](https://github.com/mobxjs/mobx/commit/654a2013107ac6e5bbe3851e4eed22f0c9130525) [#3257](https://github.com/mobxjs/mobx/pull/3257) Thanks [@urugator](https://github.com/urugator)! - fix: observable map initialization violates `enforceActions: "always"`
|
|
8
|
+
|
|
9
|
+
## 6.3.11
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`bf5da6ba`](https://github.com/mobxjs/mobx/commit/bf5da6bad982dc3d955d5f27f7fea6f94b041ea7) [#3239](https://github.com/mobxjs/mobx/pull/3239) Thanks [@bernardobelchior](https://github.com/bernardobelchior)! - Improved `toJS` jsdoc
|
|
14
|
+
|
|
15
|
+
## 6.3.10
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [`2d70798e`](https://github.com/mobxjs/mobx/commit/2d70798eb327187d93757757ceaf410a608735b2) [#3233](https://github.com/mobxjs/mobx/pull/3233) Thanks [@anderlaw](https://github.com/anderlaw)! - `eq.ts` fix comparer logic
|
|
20
|
+
|
|
21
|
+
## 6.3.9
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- [`87e5a037`](https://github.com/mobxjs/mobx/commit/87e5a03735dbc1930e54a15b5ce88ad684bc3dc1) [#3214](https://github.com/mobxjs/mobx/pull/3214) Thanks [@urugator](https://github.com/urugator)! - `requiresReaction` always takes precedence over global `computedRequiresReaction`
|
|
26
|
+
|
|
27
|
+
* [`9b90e25c`](https://github.com/mobxjs/mobx/commit/9b90e25c7bc0cdc0a07d1f847683604e86790f24) [#3198](https://github.com/mobxjs/mobx/pull/3198) Thanks [@urugator](https://github.com/urugator)! - fix `isPlainObject` impl (fixes #3197)
|
|
28
|
+
|
|
3
29
|
## 6.3.8
|
|
4
30
|
|
|
5
31
|
### Patch Changes
|
package/dist/api/tojs.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Recursively converts an observable to it's non-observable native counterpart.
|
|
3
|
+
* It does NOT recurse into non-observables, these are left as they are, even if they contain observables.
|
|
4
|
+
* Computed and other non-enumerable properties are completely ignored.
|
|
5
|
+
* Complex scenarios require custom solution, eg implementing `toJSON` or using `serializr` lib.
|
|
3
6
|
*/
|
|
4
7
|
export declare function toJS<T>(source: T, options?: any): T;
|
|
@@ -168,12 +168,11 @@ function isObject(value) {
|
|
|
168
168
|
return value !== null && typeof value === "object";
|
|
169
169
|
}
|
|
170
170
|
function isPlainObject(value) {
|
|
171
|
-
var _proto$constructor;
|
|
172
|
-
|
|
173
171
|
if (!isObject(value)) return false;
|
|
174
172
|
var proto = Object.getPrototypeOf(value);
|
|
175
173
|
if (proto == null) return true;
|
|
176
|
-
|
|
174
|
+
var protoConstructor = Object.hasOwnProperty.call(proto, "constructor") && proto.constructor;
|
|
175
|
+
return typeof protoConstructor === "function" && protoConstructor.toString() === plainObjectString;
|
|
177
176
|
} // https://stackoverflow.com/a/37865170
|
|
178
177
|
|
|
179
178
|
function isGenerator(obj) {
|
|
@@ -268,6 +267,9 @@ function _defineProperties(target, props) {
|
|
|
268
267
|
function _createClass(Constructor, protoProps, staticProps) {
|
|
269
268
|
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
270
269
|
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
270
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
271
|
+
writable: false
|
|
272
|
+
});
|
|
271
273
|
return Constructor;
|
|
272
274
|
}
|
|
273
275
|
|
|
@@ -292,7 +294,17 @@ function _extends() {
|
|
|
292
294
|
function _inheritsLoose(subClass, superClass) {
|
|
293
295
|
subClass.prototype = Object.create(superClass.prototype);
|
|
294
296
|
subClass.prototype.constructor = subClass;
|
|
295
|
-
|
|
297
|
+
|
|
298
|
+
_setPrototypeOf(subClass, superClass);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
function _setPrototypeOf(o, p) {
|
|
302
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
303
|
+
o.__proto__ = p;
|
|
304
|
+
return o;
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
return _setPrototypeOf(o, p);
|
|
296
308
|
}
|
|
297
309
|
|
|
298
310
|
function _assertThisInitialized(self) {
|
|
@@ -321,28 +333,24 @@ function _arrayLikeToArray(arr, len) {
|
|
|
321
333
|
}
|
|
322
334
|
|
|
323
335
|
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
324
|
-
var it;
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
};
|
|
334
|
-
return {
|
|
335
|
-
done: false,
|
|
336
|
-
value: o[i++]
|
|
337
|
-
};
|
|
336
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
337
|
+
if (it) return (it = it.call(o)).next.bind(it);
|
|
338
|
+
|
|
339
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
340
|
+
if (it) o = it;
|
|
341
|
+
var i = 0;
|
|
342
|
+
return function () {
|
|
343
|
+
if (i >= o.length) return {
|
|
344
|
+
done: true
|
|
338
345
|
};
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
346
|
+
return {
|
|
347
|
+
done: false,
|
|
348
|
+
value: o[i++]
|
|
349
|
+
};
|
|
350
|
+
};
|
|
342
351
|
}
|
|
343
352
|
|
|
344
|
-
|
|
345
|
-
return it.next.bind(it);
|
|
353
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
346
354
|
}
|
|
347
355
|
|
|
348
356
|
var storedAnnotationsSymbol = /*#__PURE__*/Symbol("mobx-stored-annotations");
|
|
@@ -626,7 +634,7 @@ function make_$1(adm, key, descriptor, source) {
|
|
|
626
634
|
var _this$options_;
|
|
627
635
|
|
|
628
636
|
// bound
|
|
629
|
-
if ((_this$options_ = this.options_)
|
|
637
|
+
if ((_this$options_ = this.options_) != null && _this$options_.bound) {
|
|
630
638
|
return this.extend_(adm, key, descriptor, false) === null ? 0
|
|
631
639
|
/* Cancel */
|
|
632
640
|
: 1
|
|
@@ -684,7 +692,7 @@ safeDescriptors) {
|
|
|
684
692
|
assertActionDescriptor(adm, annotation, key, descriptor);
|
|
685
693
|
var value = descriptor.value;
|
|
686
694
|
|
|
687
|
-
if ((_annotation$options_ = annotation.options_)
|
|
695
|
+
if ((_annotation$options_ = annotation.options_) != null && _annotation$options_.bound) {
|
|
688
696
|
var _adm$proxy_;
|
|
689
697
|
|
|
690
698
|
value = value.bind((_adm$proxy_ = adm.proxy_) != null ? _adm$proxy_ : adm.target_);
|
|
@@ -692,7 +700,7 @@ safeDescriptors) {
|
|
|
692
700
|
|
|
693
701
|
return {
|
|
694
702
|
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
|
|
695
|
-
(
|
|
703
|
+
(_annotation$options_4 = annotation.options_) != null && _annotation$options_4.bound ? (_adm$proxy_2 = adm.proxy_) != null ? _adm$proxy_2 : adm.target_ : undefined),
|
|
696
704
|
// Non-configurable for classes
|
|
697
705
|
// prevents accidental field redefinition in subclass
|
|
698
706
|
configurable: safeDescriptors ? adm.isPlainObject_ : true,
|
|
@@ -727,7 +735,7 @@ function make_$2(adm, key, descriptor, source) {
|
|
|
727
735
|
// bound - must annotate protos to support super.flow()
|
|
728
736
|
|
|
729
737
|
|
|
730
|
-
if ((
|
|
738
|
+
if ((_this$options_ = this.options_) != null && _this$options_.bound && !isFlow(adm.target_[key])) {
|
|
731
739
|
if (this.extend_(adm, key, descriptor, false) === null) return 0
|
|
732
740
|
/* Cancel */
|
|
733
741
|
;
|
|
@@ -910,11 +918,11 @@ function make_$5(adm, key, descriptor, source) {
|
|
|
910
918
|
if (isGenerator(descriptor.value)) {
|
|
911
919
|
var _this$options_;
|
|
912
920
|
|
|
913
|
-
var flowAnnotation = (
|
|
921
|
+
var flowAnnotation = (_this$options_ = this.options_) != null && _this$options_.autoBind ? flow.bound : flow;
|
|
914
922
|
return flowAnnotation.make_(adm, key, descriptor, source);
|
|
915
923
|
}
|
|
916
924
|
|
|
917
|
-
var actionAnnotation = (
|
|
925
|
+
var actionAnnotation = (_this$options_2 = this.options_) != null && _this$options_2.autoBind ? autoAction.bound : autoAction;
|
|
918
926
|
return actionAnnotation.make_(adm, key, descriptor, source);
|
|
919
927
|
} // other -> observable
|
|
920
928
|
// Copy props from proto as well, see test:
|
|
@@ -923,7 +931,7 @@ function make_$5(adm, key, descriptor, source) {
|
|
|
923
931
|
|
|
924
932
|
var observableAnnotation = ((_this$options_3 = this.options_) == null ? void 0 : _this$options_3.deep) === false ? observable.ref : observable; // if function respect autoBind option
|
|
925
933
|
|
|
926
|
-
if (typeof descriptor.value === "function" && (
|
|
934
|
+
if (typeof descriptor.value === "function" && (_this$options_4 = this.options_) != null && _this$options_4.autoBind) {
|
|
927
935
|
var _adm$proxy_;
|
|
928
936
|
|
|
929
937
|
descriptor.value = descriptor.value.bind((_adm$proxy_ = adm.proxy_) != null ? _adm$proxy_ : adm.target_);
|
|
@@ -951,7 +959,7 @@ function extend_$5(adm, key, descriptor, proxyTrap) {
|
|
|
951
959
|
// if function respect autoBind option
|
|
952
960
|
|
|
953
961
|
|
|
954
|
-
if (typeof descriptor.value === "function" && (
|
|
962
|
+
if (typeof descriptor.value === "function" && (_this$options_5 = this.options_) != null && _this$options_5.autoBind) {
|
|
955
963
|
var _adm$proxy_2;
|
|
956
964
|
|
|
957
965
|
descriptor.value = descriptor.value.bind((_adm$proxy_2 = adm.proxy_) != null ? _adm$proxy_2 : adm.target_);
|
|
@@ -1229,7 +1237,7 @@ function allowStateChangesEnd(prev) {
|
|
|
1229
1237
|
var _Symbol$toPrimitive;
|
|
1230
1238
|
var CREATE = "create";
|
|
1231
1239
|
_Symbol$toPrimitive = Symbol.toPrimitive;
|
|
1232
|
-
var ObservableValue = /*#__PURE__*/function (_Atom) {
|
|
1240
|
+
var ObservableValue = /*#__PURE__*/function (_Atom, _Symbol$toPrimitive2) {
|
|
1233
1241
|
_inheritsLoose(ObservableValue, _Atom);
|
|
1234
1242
|
|
|
1235
1243
|
function ObservableValue(value, enhancer, name_, notifySpy, equals) {
|
|
@@ -1376,12 +1384,12 @@ var ObservableValue = /*#__PURE__*/function (_Atom) {
|
|
|
1376
1384
|
return toPrimitive(this.get());
|
|
1377
1385
|
};
|
|
1378
1386
|
|
|
1379
|
-
_proto[_Symbol$
|
|
1387
|
+
_proto[_Symbol$toPrimitive2] = function () {
|
|
1380
1388
|
return this.valueOf();
|
|
1381
1389
|
};
|
|
1382
1390
|
|
|
1383
1391
|
return ObservableValue;
|
|
1384
|
-
}(Atom);
|
|
1392
|
+
}(Atom, _Symbol$toPrimitive);
|
|
1385
1393
|
var isObservableValue = /*#__PURE__*/createInstanceofPredicate("ObservableValue", ObservableValue);
|
|
1386
1394
|
|
|
1387
1395
|
var _Symbol$toPrimitive$1;
|
|
@@ -1406,7 +1414,7 @@ var _Symbol$toPrimitive$1;
|
|
|
1406
1414
|
*/
|
|
1407
1415
|
|
|
1408
1416
|
_Symbol$toPrimitive$1 = Symbol.toPrimitive;
|
|
1409
|
-
var ComputedValue = /*#__PURE__*/function () {
|
|
1417
|
+
var ComputedValue = /*#__PURE__*/function (_Symbol$toPrimitive2) {
|
|
1410
1418
|
// nodes we are looking at. Our value depends on these nodes
|
|
1411
1419
|
// during tracking it's an array with new observed observers
|
|
1412
1420
|
// to check for cycles
|
|
@@ -1460,7 +1468,7 @@ var ComputedValue = /*#__PURE__*/function () {
|
|
|
1460
1468
|
|
|
1461
1469
|
this.equals_ = options.equals || (options.compareStructural || options.struct ? comparer.structural : comparer["default"]);
|
|
1462
1470
|
this.scope_ = options.context;
|
|
1463
|
-
this.requiresReaction_ =
|
|
1471
|
+
this.requiresReaction_ = options.requiresReaction;
|
|
1464
1472
|
this.keepAlive_ = !!options.keepAlive;
|
|
1465
1473
|
}
|
|
1466
1474
|
|
|
@@ -1628,7 +1636,7 @@ var ComputedValue = /*#__PURE__*/function () {
|
|
|
1628
1636
|
console.log("[mobx.trace] Computed value '" + this.name_ + "' is being read outside a reactive context. Doing a full recompute.");
|
|
1629
1637
|
}
|
|
1630
1638
|
|
|
1631
|
-
if (
|
|
1639
|
+
if (typeof this.requiresReaction_ === "boolean" ? this.requiresReaction_ : globalState.computedRequiresReaction) {
|
|
1632
1640
|
console.warn("[mobx] Computed value '" + this.name_ + "' is being read outside a reactive context. Doing a full recompute.");
|
|
1633
1641
|
}
|
|
1634
1642
|
};
|
|
@@ -1641,12 +1649,12 @@ var ComputedValue = /*#__PURE__*/function () {
|
|
|
1641
1649
|
return toPrimitive(this.get());
|
|
1642
1650
|
};
|
|
1643
1651
|
|
|
1644
|
-
_proto[_Symbol$
|
|
1652
|
+
_proto[_Symbol$toPrimitive2] = function () {
|
|
1645
1653
|
return this.valueOf();
|
|
1646
1654
|
};
|
|
1647
1655
|
|
|
1648
1656
|
return ComputedValue;
|
|
1649
|
-
}();
|
|
1657
|
+
}(_Symbol$toPrimitive$1);
|
|
1650
1658
|
var isComputedValue = /*#__PURE__*/createInstanceofPredicate("ComputedValue", ComputedValue);
|
|
1651
1659
|
|
|
1652
1660
|
var IDerivationState_;
|
|
@@ -2187,8 +2195,8 @@ function propagateChangeConfirmed(observable) {
|
|
|
2187
2195
|
}
|
|
2188
2196
|
} else if (d.dependenciesState_ === IDerivationState_.UP_TO_DATE_ // this happens during computing of `d`, just keep lowestObserverState up to date.
|
|
2189
2197
|
) {
|
|
2190
|
-
|
|
2191
|
-
|
|
2198
|
+
observable.lowestObserverState_ = IDerivationState_.UP_TO_DATE_;
|
|
2199
|
+
}
|
|
2192
2200
|
}); // invariantLOS(observable, "confirmed end");
|
|
2193
2201
|
} // Used by computed when its dependency changed, but we don't wan't to immediately recompute.
|
|
2194
2202
|
|
|
@@ -3216,7 +3224,10 @@ function toJSHelper(source, __alreadySeen) {
|
|
|
3216
3224
|
}
|
|
3217
3225
|
}
|
|
3218
3226
|
/**
|
|
3219
|
-
*
|
|
3227
|
+
* Recursively converts an observable to it's non-observable native counterpart.
|
|
3228
|
+
* It does NOT recurse into non-observables, these are left as they are, even if they contain observables.
|
|
3229
|
+
* Computed and other non-enumerable properties are completely ignored.
|
|
3230
|
+
* Complex scenarios require custom solution, eg implementing `toJSON` or using `serializr` lib.
|
|
3220
3231
|
*/
|
|
3221
3232
|
|
|
3222
3233
|
|
|
@@ -4005,9 +4016,11 @@ var DELETE = "delete"; // just extend Map? See also https://gist.github.com/nest
|
|
|
4005
4016
|
|
|
4006
4017
|
_Symbol$iterator = Symbol.iterator;
|
|
4007
4018
|
_Symbol$toStringTag = Symbol.toStringTag;
|
|
4008
|
-
var ObservableMap = /*#__PURE__*/function () {
|
|
4019
|
+
var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTag2) {
|
|
4009
4020
|
// hasMap, not hashMap >-).
|
|
4010
4021
|
function ObservableMap(initialData, enhancer_, name_) {
|
|
4022
|
+
var _this = this;
|
|
4023
|
+
|
|
4011
4024
|
if (enhancer_ === void 0) {
|
|
4012
4025
|
enhancer_ = deepEnhancer;
|
|
4013
4026
|
}
|
|
@@ -4035,7 +4048,9 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4035
4048
|
this.keysAtom_ = createAtom( this.name_ + ".keys()" );
|
|
4036
4049
|
this.data_ = new Map();
|
|
4037
4050
|
this.hasMap_ = new Map();
|
|
4038
|
-
|
|
4051
|
+
allowStateChanges(true, function () {
|
|
4052
|
+
_this.merge(initialData);
|
|
4053
|
+
});
|
|
4039
4054
|
}
|
|
4040
4055
|
|
|
4041
4056
|
var _proto = ObservableMap.prototype;
|
|
@@ -4045,7 +4060,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4045
4060
|
};
|
|
4046
4061
|
|
|
4047
4062
|
_proto.has = function has(key) {
|
|
4048
|
-
var
|
|
4063
|
+
var _this2 = this;
|
|
4049
4064
|
|
|
4050
4065
|
if (!globalState.trackingDerivation) return this.has_(key);
|
|
4051
4066
|
var entry = this.hasMap_.get(key);
|
|
@@ -4054,7 +4069,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4054
4069
|
var newEntry = entry = new ObservableValue(this.has_(key), referenceEnhancer, this.name_ + "." + stringifyKey(key) + "?" , false);
|
|
4055
4070
|
this.hasMap_.set(key, newEntry);
|
|
4056
4071
|
onBecomeUnobserved(newEntry, function () {
|
|
4057
|
-
return
|
|
4072
|
+
return _this2.hasMap_["delete"](key);
|
|
4058
4073
|
});
|
|
4059
4074
|
}
|
|
4060
4075
|
|
|
@@ -4085,7 +4100,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4085
4100
|
};
|
|
4086
4101
|
|
|
4087
4102
|
_proto["delete"] = function _delete(key) {
|
|
4088
|
-
var
|
|
4103
|
+
var _this3 = this;
|
|
4089
4104
|
|
|
4090
4105
|
checkIfStateModificationsAreAllowed(this.keysAtom_);
|
|
4091
4106
|
|
|
@@ -4111,19 +4126,20 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4111
4126
|
name: key
|
|
4112
4127
|
} : null;
|
|
4113
4128
|
|
|
4114
|
-
if ( notifySpy) spyReportStart(_change);
|
|
4129
|
+
if ( notifySpy) spyReportStart(_change); // TODO fix type
|
|
4130
|
+
|
|
4115
4131
|
transaction(function () {
|
|
4116
|
-
var
|
|
4132
|
+
var _this3$hasMap_$get;
|
|
4117
4133
|
|
|
4118
|
-
|
|
4134
|
+
_this3.keysAtom_.reportChanged();
|
|
4119
4135
|
|
|
4120
|
-
(
|
|
4136
|
+
(_this3$hasMap_$get = _this3.hasMap_.get(key)) == null ? void 0 : _this3$hasMap_$get.setNewValue_(false);
|
|
4121
4137
|
|
|
4122
|
-
var observable =
|
|
4138
|
+
var observable = _this3.data_.get(key);
|
|
4123
4139
|
|
|
4124
4140
|
observable.setNewValue_(undefined);
|
|
4125
4141
|
|
|
4126
|
-
|
|
4142
|
+
_this3.data_["delete"](key);
|
|
4127
4143
|
});
|
|
4128
4144
|
if (notify) notifyListeners(this, _change);
|
|
4129
4145
|
if ( notifySpy) spyReportEnd();
|
|
@@ -4149,7 +4165,8 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4149
4165
|
name: key,
|
|
4150
4166
|
newValue: newValue
|
|
4151
4167
|
} : null;
|
|
4152
|
-
if ( notifySpy) spyReportStart(change);
|
|
4168
|
+
if ( notifySpy) spyReportStart(change); // TODO fix type
|
|
4169
|
+
|
|
4153
4170
|
observable.setNewValue_(newValue);
|
|
4154
4171
|
if (notify) notifyListeners(this, change);
|
|
4155
4172
|
if ( notifySpy) spyReportEnd();
|
|
@@ -4157,21 +4174,21 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4157
4174
|
};
|
|
4158
4175
|
|
|
4159
4176
|
_proto.addValue_ = function addValue_(key, newValue) {
|
|
4160
|
-
var
|
|
4177
|
+
var _this4 = this;
|
|
4161
4178
|
|
|
4162
4179
|
checkIfStateModificationsAreAllowed(this.keysAtom_);
|
|
4163
4180
|
transaction(function () {
|
|
4164
|
-
var
|
|
4181
|
+
var _this4$hasMap_$get;
|
|
4165
4182
|
|
|
4166
|
-
var observable = new ObservableValue(newValue,
|
|
4183
|
+
var observable = new ObservableValue(newValue, _this4.enhancer_, _this4.name_ + "." + stringifyKey(key) , false);
|
|
4167
4184
|
|
|
4168
|
-
|
|
4185
|
+
_this4.data_.set(key, observable);
|
|
4169
4186
|
|
|
4170
4187
|
newValue = observable.value_; // value might have been changed
|
|
4171
4188
|
|
|
4172
|
-
(
|
|
4189
|
+
(_this4$hasMap_$get = _this4.hasMap_.get(key)) == null ? void 0 : _this4$hasMap_$get.setNewValue_(true);
|
|
4173
4190
|
|
|
4174
|
-
|
|
4191
|
+
_this4.keysAtom_.reportChanged();
|
|
4175
4192
|
});
|
|
4176
4193
|
var notifySpy = isSpyEnabled();
|
|
4177
4194
|
var notify = hasListeners(this);
|
|
@@ -4183,7 +4200,8 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4183
4200
|
name: key,
|
|
4184
4201
|
newValue: newValue
|
|
4185
4202
|
} : null;
|
|
4186
|
-
if ( notifySpy) spyReportStart(change);
|
|
4203
|
+
if ( notifySpy) spyReportStart(change); // TODO fix type
|
|
4204
|
+
|
|
4187
4205
|
if (notify) notifyListeners(this, change);
|
|
4188
4206
|
if ( notifySpy) spyReportEnd();
|
|
4189
4207
|
};
|
|
@@ -4240,7 +4258,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4240
4258
|
});
|
|
4241
4259
|
};
|
|
4242
4260
|
|
|
4243
|
-
_proto[_Symbol$
|
|
4261
|
+
_proto[_Symbol$iterator2] = function () {
|
|
4244
4262
|
return this.entries();
|
|
4245
4263
|
};
|
|
4246
4264
|
|
|
@@ -4256,7 +4274,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4256
4274
|
;
|
|
4257
4275
|
|
|
4258
4276
|
_proto.merge = function merge(other) {
|
|
4259
|
-
var
|
|
4277
|
+
var _this5 = this;
|
|
4260
4278
|
|
|
4261
4279
|
if (isObservableMap(other)) {
|
|
4262
4280
|
other = new Map(other);
|
|
@@ -4264,15 +4282,15 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4264
4282
|
|
|
4265
4283
|
transaction(function () {
|
|
4266
4284
|
if (isPlainObject(other)) getPlainObjectKeys(other).forEach(function (key) {
|
|
4267
|
-
return
|
|
4285
|
+
return _this5.set(key, other[key]);
|
|
4268
4286
|
});else if (Array.isArray(other)) other.forEach(function (_ref) {
|
|
4269
4287
|
var key = _ref[0],
|
|
4270
4288
|
value = _ref[1];
|
|
4271
|
-
return
|
|
4289
|
+
return _this5.set(key, value);
|
|
4272
4290
|
});else if (isES6Map(other)) {
|
|
4273
4291
|
if (other.constructor !== Map) die(19, other);
|
|
4274
4292
|
other.forEach(function (value, key) {
|
|
4275
|
-
return
|
|
4293
|
+
return _this5.set(key, value);
|
|
4276
4294
|
});
|
|
4277
4295
|
} else if (other !== null && other !== undefined) die(20, other);
|
|
4278
4296
|
});
|
|
@@ -4280,21 +4298,21 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4280
4298
|
};
|
|
4281
4299
|
|
|
4282
4300
|
_proto.clear = function clear() {
|
|
4283
|
-
var
|
|
4301
|
+
var _this6 = this;
|
|
4284
4302
|
|
|
4285
4303
|
transaction(function () {
|
|
4286
4304
|
untracked(function () {
|
|
4287
|
-
for (var _iterator2 = _createForOfIteratorHelperLoose(
|
|
4305
|
+
for (var _iterator2 = _createForOfIteratorHelperLoose(_this6.keys()), _step2; !(_step2 = _iterator2()).done;) {
|
|
4288
4306
|
var key = _step2.value;
|
|
4289
4307
|
|
|
4290
|
-
|
|
4308
|
+
_this6["delete"](key);
|
|
4291
4309
|
}
|
|
4292
4310
|
});
|
|
4293
4311
|
});
|
|
4294
4312
|
};
|
|
4295
4313
|
|
|
4296
4314
|
_proto.replace = function replace(values) {
|
|
4297
|
-
var
|
|
4315
|
+
var _this7 = this;
|
|
4298
4316
|
|
|
4299
4317
|
// Implementation requirements:
|
|
4300
4318
|
// - respect ordering of replacement map
|
|
@@ -4311,13 +4329,13 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4311
4329
|
// if the key deletion is prevented by interceptor
|
|
4312
4330
|
// add entry at the beginning of the result map
|
|
4313
4331
|
|
|
4314
|
-
for (var _iterator3 = _createForOfIteratorHelperLoose(
|
|
4332
|
+
for (var _iterator3 = _createForOfIteratorHelperLoose(_this7.data_.keys()), _step3; !(_step3 = _iterator3()).done;) {
|
|
4315
4333
|
var key = _step3.value;
|
|
4316
4334
|
|
|
4317
4335
|
// Concurrently iterating/deleting keys
|
|
4318
4336
|
// iterator should handle this correctly
|
|
4319
4337
|
if (!replacementMap.has(key)) {
|
|
4320
|
-
var deleted =
|
|
4338
|
+
var deleted = _this7["delete"](key); // Was the key removed?
|
|
4321
4339
|
|
|
4322
4340
|
|
|
4323
4341
|
if (deleted) {
|
|
@@ -4325,7 +4343,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4325
4343
|
keysReportChangedCalled = true;
|
|
4326
4344
|
} else {
|
|
4327
4345
|
// Delete prevented by interceptor
|
|
4328
|
-
var value =
|
|
4346
|
+
var value = _this7.data_.get(key);
|
|
4329
4347
|
|
|
4330
4348
|
orderedData.set(key, value);
|
|
4331
4349
|
}
|
|
@@ -4339,17 +4357,17 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4339
4357
|
_value = _step4$value[1];
|
|
4340
4358
|
|
|
4341
4359
|
// We will want to know whether a new key is added
|
|
4342
|
-
var keyExisted =
|
|
4360
|
+
var keyExisted = _this7.data_.has(_key); // Add or update value
|
|
4343
4361
|
|
|
4344
4362
|
|
|
4345
|
-
|
|
4363
|
+
_this7.set(_key, _value); // The addition could have been prevent by interceptor
|
|
4346
4364
|
|
|
4347
4365
|
|
|
4348
|
-
if (
|
|
4366
|
+
if (_this7.data_.has(_key)) {
|
|
4349
4367
|
// The update could have been prevented by interceptor
|
|
4350
4368
|
// and also we want to preserve existing values
|
|
4351
4369
|
// so use value from _data map (instead of replacement map)
|
|
4352
|
-
var _value2 =
|
|
4370
|
+
var _value2 = _this7.data_.get(_key);
|
|
4353
4371
|
|
|
4354
4372
|
orderedData.set(_key, _value2); // Was a new key added?
|
|
4355
4373
|
|
|
@@ -4362,11 +4380,11 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4362
4380
|
|
|
4363
4381
|
|
|
4364
4382
|
if (!keysReportChangedCalled) {
|
|
4365
|
-
if (
|
|
4383
|
+
if (_this7.data_.size !== orderedData.size) {
|
|
4366
4384
|
// If size differs, keys are definitely modified
|
|
4367
|
-
|
|
4385
|
+
_this7.keysAtom_.reportChanged();
|
|
4368
4386
|
} else {
|
|
4369
|
-
var iter1 =
|
|
4387
|
+
var iter1 = _this7.data_.keys();
|
|
4370
4388
|
|
|
4371
4389
|
var iter2 = orderedData.keys();
|
|
4372
4390
|
var next1 = iter1.next();
|
|
@@ -4374,7 +4392,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4374
4392
|
|
|
4375
4393
|
while (!next1.done) {
|
|
4376
4394
|
if (next1.value !== next2.value) {
|
|
4377
|
-
|
|
4395
|
+
_this7.keysAtom_.reportChanged();
|
|
4378
4396
|
|
|
4379
4397
|
break;
|
|
4380
4398
|
}
|
|
@@ -4386,7 +4404,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4386
4404
|
} // Use correctly ordered map
|
|
4387
4405
|
|
|
4388
4406
|
|
|
4389
|
-
|
|
4407
|
+
_this7.data_ = orderedData;
|
|
4390
4408
|
});
|
|
4391
4409
|
return this;
|
|
4392
4410
|
};
|
|
@@ -4420,14 +4438,14 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4420
4438
|
return this.data_.size;
|
|
4421
4439
|
}
|
|
4422
4440
|
}, {
|
|
4423
|
-
key: _Symbol$
|
|
4441
|
+
key: _Symbol$toStringTag2,
|
|
4424
4442
|
get: function get() {
|
|
4425
4443
|
return "Map";
|
|
4426
4444
|
}
|
|
4427
4445
|
}]);
|
|
4428
4446
|
|
|
4429
4447
|
return ObservableMap;
|
|
4430
|
-
}(); // eslint-disable-next-line
|
|
4448
|
+
}(_Symbol$iterator, _Symbol$toStringTag); // eslint-disable-next-line
|
|
4431
4449
|
|
|
4432
4450
|
var isObservableMap = /*#__PURE__*/createInstanceofPredicate("ObservableMap", ObservableMap);
|
|
4433
4451
|
|
|
@@ -4453,7 +4471,7 @@ var _Symbol$iterator$1, _Symbol$toStringTag$1;
|
|
|
4453
4471
|
var ObservableSetMarker = {};
|
|
4454
4472
|
_Symbol$iterator$1 = Symbol.iterator;
|
|
4455
4473
|
_Symbol$toStringTag$1 = Symbol.toStringTag;
|
|
4456
|
-
var ObservableSet = /*#__PURE__*/function () {
|
|
4474
|
+
var ObservableSet = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTag2) {
|
|
4457
4475
|
function ObservableSet(initialData, enhancer, name_) {
|
|
4458
4476
|
if (enhancer === void 0) {
|
|
4459
4477
|
enhancer = deepEnhancer;
|
|
@@ -4686,7 +4704,7 @@ var ObservableSet = /*#__PURE__*/function () {
|
|
|
4686
4704
|
return "[object ObservableSet]";
|
|
4687
4705
|
};
|
|
4688
4706
|
|
|
4689
|
-
_proto[_Symbol$
|
|
4707
|
+
_proto[_Symbol$iterator2] = function () {
|
|
4690
4708
|
return this.values();
|
|
4691
4709
|
};
|
|
4692
4710
|
|
|
@@ -4697,14 +4715,14 @@ var ObservableSet = /*#__PURE__*/function () {
|
|
|
4697
4715
|
return this.data_.size;
|
|
4698
4716
|
}
|
|
4699
4717
|
}, {
|
|
4700
|
-
key: _Symbol$
|
|
4718
|
+
key: _Symbol$toStringTag2,
|
|
4701
4719
|
get: function get() {
|
|
4702
4720
|
return "Set";
|
|
4703
4721
|
}
|
|
4704
4722
|
}]);
|
|
4705
4723
|
|
|
4706
4724
|
return ObservableSet;
|
|
4707
|
-
}(); // eslint-disable-next-line
|
|
4725
|
+
}(_Symbol$iterator$1, _Symbol$toStringTag$1); // eslint-disable-next-line
|
|
4708
4726
|
|
|
4709
4727
|
var isObservableSet = /*#__PURE__*/createInstanceofPredicate("ObservableSet", ObservableSet);
|
|
4710
4728
|
|
|
@@ -4890,7 +4908,7 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
4890
4908
|
// When called from super() some props may not exist yet.
|
|
4891
4909
|
// However we don't have to worry about missing prop,
|
|
4892
4910
|
// because the decorator must have been applied to something.
|
|
4893
|
-
if ((_this$target_$storedA = this.target_[storedAnnotationsSymbol])
|
|
4911
|
+
if ((_this$target_$storedA = this.target_[storedAnnotationsSymbol]) != null && _this$target_$storedA[key]) {
|
|
4894
4912
|
return; // will be annotated by subclass constructor
|
|
4895
4913
|
} else {
|
|
4896
4914
|
die(1, annotation.annotationType_, this.name_ + "." + key.toString());
|
|
@@ -5394,7 +5412,7 @@ inherit(StubArray, Array.prototype); // Weex proto freeze protection was here,
|
|
|
5394
5412
|
// but it is unclear why the hack is need as MobX never changed the prototype
|
|
5395
5413
|
// anyway, so removed it in V6
|
|
5396
5414
|
|
|
5397
|
-
var LegacyObservableArray = /*#__PURE__*/function (_StubArray) {
|
|
5415
|
+
var LegacyObservableArray = /*#__PURE__*/function (_StubArray, _Symbol$toStringTag, _Symbol$iterator) {
|
|
5398
5416
|
_inheritsLoose(LegacyObservableArray, _StubArray);
|
|
5399
5417
|
|
|
5400
5418
|
function LegacyObservableArray(initialValues, enhancer, name, owned) {
|
|
@@ -5439,7 +5457,7 @@ var LegacyObservableArray = /*#__PURE__*/function (_StubArray) {
|
|
|
5439
5457
|
}));
|
|
5440
5458
|
};
|
|
5441
5459
|
|
|
5442
|
-
_proto[
|
|
5460
|
+
_proto[_Symbol$iterator] = function () {
|
|
5443
5461
|
var self = this;
|
|
5444
5462
|
var nextIndex = 0;
|
|
5445
5463
|
return makeIterable({
|
|
@@ -5465,14 +5483,14 @@ var LegacyObservableArray = /*#__PURE__*/function (_StubArray) {
|
|
|
5465
5483
|
this[$mobx].setArrayLength_(newLength);
|
|
5466
5484
|
}
|
|
5467
5485
|
}, {
|
|
5468
|
-
key:
|
|
5486
|
+
key: _Symbol$toStringTag,
|
|
5469
5487
|
get: function get() {
|
|
5470
5488
|
return "Array";
|
|
5471
5489
|
}
|
|
5472
5490
|
}]);
|
|
5473
5491
|
|
|
5474
5492
|
return LegacyObservableArray;
|
|
5475
|
-
}(StubArray);
|
|
5493
|
+
}(StubArray, Symbol.toStringTag, Symbol.iterator);
|
|
5476
5494
|
|
|
5477
5495
|
Object.entries(arrayExtensions).forEach(function (_ref) {
|
|
5478
5496
|
var prop = _ref[0],
|
|
@@ -5595,7 +5613,7 @@ function eq(a, b, depth, aStack, bStack) {
|
|
|
5595
5613
|
if (a !== a) return b !== b; // Exhaust primitive checks
|
|
5596
5614
|
|
|
5597
5615
|
var type = typeof a;
|
|
5598
|
-
if (
|
|
5616
|
+
if (type !== "function" && type !== "object" && typeof b != "object") return false; // Compare `[[Class]]` names.
|
|
5599
5617
|
|
|
5600
5618
|
var className = toString.call(a);
|
|
5601
5619
|
if (className !== toString.call(b)) return false;
|