mobx 6.3.3 → 6.3.7
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/README.md +1 -1
- package/dist/api/autorun.d.ts +3 -3
- package/dist/api/intercept.d.ts +4 -4
- package/dist/api/observe.d.ts +3 -3
- package/dist/mobx.cjs.development.js +38 -38
- 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 +38 -38
- package/dist/mobx.esm.development.js.map +1 -1
- package/dist/mobx.esm.js +38 -38
- 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 +38 -38
- 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/observablemap.d.ts +0 -1
- package/package.json +1 -1
- package/src/api/autorun.ts +15 -8
- package/src/api/extendobservable.ts +1 -1
- package/src/api/intercept.ts +4 -4
- package/src/api/iscomputed.ts +6 -6
- package/src/api/makeObservable.ts +7 -1
- package/src/api/observe.ts +4 -3
- package/src/api/when.ts +1 -1
- package/src/core/computedvalue.ts +11 -11
- package/src/core/globalstate.ts +2 -0
- package/src/core/observable.ts +1 -1
- package/src/types/actionannotation.ts +4 -2
- package/src/types/observablearray.ts +1 -1
- package/src/types/observablemap.ts +2 -9
package/dist/mobx.esm.js
CHANGED
|
@@ -673,7 +673,7 @@ function assertActionDescriptor(adm, _ref, key, _ref2) {
|
|
|
673
673
|
|
|
674
674
|
function createActionDescriptor(adm, annotation, key, descriptor, // provides ability to disable safeDescriptors for prototypes
|
|
675
675
|
safeDescriptors) {
|
|
676
|
-
var _annotation$options_, _annotation$options_$, _annotation$options_2, _annotation$options_$2, _annotation$options_3;
|
|
676
|
+
var _annotation$options_, _annotation$options_$, _annotation$options_2, _annotation$options_$2, _annotation$options_3, _annotation$options_4, _adm$proxy_2;
|
|
677
677
|
|
|
678
678
|
if (safeDescriptors === void 0) {
|
|
679
679
|
safeDescriptors = globalState.safeDescriptors;
|
|
@@ -689,7 +689,8 @@ safeDescriptors) {
|
|
|
689
689
|
}
|
|
690
690
|
|
|
691
691
|
return {
|
|
692
|
-
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
|
|
692
|
+
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
|
+
((_annotation$options_4 = annotation.options_) == null ? void 0 : _annotation$options_4.bound) ? (_adm$proxy_2 = adm.proxy_) != null ? _adm$proxy_2 : adm.target_ : undefined),
|
|
693
694
|
// Non-configurable for classes
|
|
694
695
|
// prevents accidental field redefinition in subclass
|
|
695
696
|
configurable: safeDescriptors ? adm.isPlainObject_ : true,
|
|
@@ -1536,22 +1537,21 @@ var ComputedValue = /*#__PURE__*/function () {
|
|
|
1536
1537
|
/* see #1208 */
|
|
1537
1538
|
this.dependenciesState_ === IDerivationState_.NOT_TRACKING_;
|
|
1538
1539
|
var newValue = this.computeValue_(true);
|
|
1539
|
-
|
|
1540
|
-
if (process.env.NODE_ENV !== "production" && isSpyEnabled()) {
|
|
1541
|
-
spyReport({
|
|
1542
|
-
observableKind: "computed",
|
|
1543
|
-
debugObjectName: this.name_,
|
|
1544
|
-
object: this.scope_,
|
|
1545
|
-
type: "update",
|
|
1546
|
-
oldValue: this.value_,
|
|
1547
|
-
newValue: newValue
|
|
1548
|
-
});
|
|
1549
|
-
}
|
|
1550
|
-
|
|
1551
1540
|
var changed = wasSuspended || isCaughtException(oldValue) || isCaughtException(newValue) || !this.equals_(oldValue, newValue);
|
|
1552
1541
|
|
|
1553
1542
|
if (changed) {
|
|
1554
1543
|
this.value_ = newValue;
|
|
1544
|
+
|
|
1545
|
+
if (process.env.NODE_ENV !== "production" && isSpyEnabled()) {
|
|
1546
|
+
spyReport({
|
|
1547
|
+
observableKind: "computed",
|
|
1548
|
+
debugObjectName: this.name_,
|
|
1549
|
+
object: this.scope_,
|
|
1550
|
+
type: "update",
|
|
1551
|
+
oldValue: oldValue,
|
|
1552
|
+
newValue: newValue
|
|
1553
|
+
});
|
|
1554
|
+
}
|
|
1555
1555
|
}
|
|
1556
1556
|
|
|
1557
1557
|
return changed;
|
|
@@ -1975,6 +1975,8 @@ var globalState = /*#__PURE__*/function () {
|
|
|
1975
1975
|
if (global.__mobxGlobals && global.__mobxGlobals.version !== new MobXGlobals().version) canMergeGlobalState = false;
|
|
1976
1976
|
|
|
1977
1977
|
if (!canMergeGlobalState) {
|
|
1978
|
+
// Because this is a IIFE we need to let isolateCalled a chance to change
|
|
1979
|
+
// so we run it after the event loop completed at least 1 iteration
|
|
1978
1980
|
setTimeout(function () {
|
|
1979
1981
|
if (!isolateCalled) {
|
|
1980
1982
|
die(35);
|
|
@@ -2222,8 +2224,7 @@ function printDepTree(tree, lines, depth) {
|
|
|
2222
2224
|
return;
|
|
2223
2225
|
}
|
|
2224
2226
|
|
|
2225
|
-
lines.push("" +
|
|
2226
|
-
|
|
2227
|
+
lines.push("" + "\t".repeat(depth - 1) + tree.name);
|
|
2227
2228
|
if (tree.dependencies) tree.dependencies.forEach(function (child) {
|
|
2228
2229
|
return printDepTree(child, lines, depth + 1);
|
|
2229
2230
|
});
|
|
@@ -2660,8 +2661,7 @@ function reaction(expression, effect, opts) {
|
|
|
2660
2661
|
var firstTime = true;
|
|
2661
2662
|
var isScheduled = false;
|
|
2662
2663
|
var value;
|
|
2663
|
-
var oldValue
|
|
2664
|
-
|
|
2664
|
+
var oldValue;
|
|
2665
2665
|
var equals = opts.compareStructural ? comparer.structural : opts.equals || comparer["default"];
|
|
2666
2666
|
var r = new Reaction(name, function () {
|
|
2667
2667
|
if (firstTime || runSync) {
|
|
@@ -2777,7 +2777,7 @@ function extendObservable(target, properties, annotations, options) {
|
|
|
2777
2777
|
if (arguments.length > 4) die("'extendObservable' expected 2-4 arguments");
|
|
2778
2778
|
if (typeof target !== "object") die("'extendObservable' expects an object as first argument");
|
|
2779
2779
|
if (isObservableMap(target)) die("'extendObservable' should not be used on maps, use map.merge instead");
|
|
2780
|
-
if (!isPlainObject(properties)) die("'
|
|
2780
|
+
if (!isPlainObject(properties)) die("'extendObservable' only accepts plain objects as second argument");
|
|
2781
2781
|
if (isObservable(properties) || isObservable(annotations)) die("Extending an object with another observable (object) is not supported");
|
|
2782
2782
|
} // Pull descriptors first, so we don't have to deal with props added by administration ($mobx)
|
|
2783
2783
|
|
|
@@ -2968,14 +2968,14 @@ function interceptProperty(thing, property, handler) {
|
|
|
2968
2968
|
}
|
|
2969
2969
|
|
|
2970
2970
|
function _isComputed(value, property) {
|
|
2971
|
-
if (property
|
|
2972
|
-
|
|
2973
|
-
if (!value[$mobx].values_.has(property)) return false;
|
|
2974
|
-
var atom = getAtom(value, property);
|
|
2975
|
-
return isComputedValue(atom);
|
|
2971
|
+
if (property === undefined) {
|
|
2972
|
+
return isComputedValue(value);
|
|
2976
2973
|
}
|
|
2977
2974
|
|
|
2978
|
-
|
|
2975
|
+
if (isObservableObject(value) === false) return false;
|
|
2976
|
+
if (!value[$mobx].values_.has(property)) return false;
|
|
2977
|
+
var atom = getAtom(value, property);
|
|
2978
|
+
return isComputedValue(atom);
|
|
2979
2979
|
}
|
|
2980
2980
|
function isComputed(value) {
|
|
2981
2981
|
if (process.env.NODE_ENV !== "production" && arguments.length > 1) return die("isComputed expects only 1 argument. Use isComputedProp to inspect the observability of a property");
|
|
@@ -3335,7 +3335,7 @@ function whenPromise(predicate, opts) {
|
|
|
3335
3335
|
|
|
3336
3336
|
cancel = function cancel() {
|
|
3337
3337
|
disposer();
|
|
3338
|
-
reject("WHEN_CANCELLED");
|
|
3338
|
+
reject(new Error("WHEN_CANCELLED"));
|
|
3339
3339
|
};
|
|
3340
3340
|
});
|
|
3341
3341
|
res.cancel = cancel;
|
|
@@ -3466,7 +3466,11 @@ function makeObservable(target, annotations, options) {
|
|
|
3466
3466
|
try {
|
|
3467
3467
|
var _annotations;
|
|
3468
3468
|
|
|
3469
|
-
|
|
3469
|
+
if (process.env.NODE_ENV !== "production" && annotations && target[storedAnnotationsSymbol]) {
|
|
3470
|
+
die("makeObservable second arg must be nullish when using decorators. Mixing @decorator syntax with annotations is not supported.");
|
|
3471
|
+
} // Default to decorators
|
|
3472
|
+
|
|
3473
|
+
|
|
3470
3474
|
(_annotations = annotations) != null ? _annotations : annotations = collectStoredAnnotations(target); // Annotate
|
|
3471
3475
|
|
|
3472
3476
|
ownKeys(annotations).forEach(function (key) {
|
|
@@ -3627,7 +3631,7 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
|
|
|
3627
3631
|
};
|
|
3628
3632
|
|
|
3629
3633
|
_proto.setArrayLength_ = function setArrayLength_(newLength) {
|
|
3630
|
-
if (typeof newLength !== "number" || newLength < 0) die("Out of range: " + newLength);
|
|
3634
|
+
if (typeof newLength !== "number" || isNaN(newLength) || newLength < 0) die("Out of range: " + newLength);
|
|
3631
3635
|
var currentLength = this.values_.length;
|
|
3632
3636
|
if (newLength === currentLength) return;else if (newLength > currentLength) {
|
|
3633
3637
|
var newItems = new Array(newLength - currentLength);
|
|
@@ -4116,9 +4120,11 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4116
4120
|
|
|
4117
4121
|
if (process.env.NODE_ENV !== "production" && notifySpy) spyReportStart(_change);
|
|
4118
4122
|
transaction(function () {
|
|
4123
|
+
var _this2$hasMap_$get;
|
|
4124
|
+
|
|
4119
4125
|
_this2.keysAtom_.reportChanged();
|
|
4120
4126
|
|
|
4121
|
-
_this2.
|
|
4127
|
+
(_this2$hasMap_$get = _this2.hasMap_.get(key)) == null ? void 0 : _this2$hasMap_$get.setNewValue_(false);
|
|
4122
4128
|
|
|
4123
4129
|
var observable = _this2.data_.get(key);
|
|
4124
4130
|
|
|
@@ -4134,14 +4140,6 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4134
4140
|
return false;
|
|
4135
4141
|
};
|
|
4136
4142
|
|
|
4137
|
-
_proto.updateHasMapEntry_ = function updateHasMapEntry_(key, value) {
|
|
4138
|
-
var entry = this.hasMap_.get(key);
|
|
4139
|
-
|
|
4140
|
-
if (entry) {
|
|
4141
|
-
entry.setNewValue_(value);
|
|
4142
|
-
}
|
|
4143
|
-
};
|
|
4144
|
-
|
|
4145
4143
|
_proto.updateValue_ = function updateValue_(key, newValue) {
|
|
4146
4144
|
var observable = this.data_.get(key);
|
|
4147
4145
|
newValue = observable.prepareNewValue_(newValue);
|
|
@@ -4170,13 +4168,15 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4170
4168
|
|
|
4171
4169
|
checkIfStateModificationsAreAllowed(this.keysAtom_);
|
|
4172
4170
|
transaction(function () {
|
|
4171
|
+
var _this3$hasMap_$get;
|
|
4172
|
+
|
|
4173
4173
|
var observable = new ObservableValue(newValue, _this3.enhancer_, process.env.NODE_ENV !== "production" ? _this3.name_ + "." + stringifyKey(key) : "ObservableMap.key", false);
|
|
4174
4174
|
|
|
4175
4175
|
_this3.data_.set(key, observable);
|
|
4176
4176
|
|
|
4177
4177
|
newValue = observable.value_; // value might have been changed
|
|
4178
4178
|
|
|
4179
|
-
_this3.
|
|
4179
|
+
(_this3$hasMap_$get = _this3.hasMap_.get(key)) == null ? void 0 : _this3$hasMap_$get.setNewValue_(true);
|
|
4180
4180
|
|
|
4181
4181
|
_this3.keysAtom_.reportChanged();
|
|
4182
4182
|
});
|