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
|
@@ -677,7 +677,7 @@
|
|
|
677
677
|
|
|
678
678
|
function createActionDescriptor(adm, annotation, key, descriptor, // provides ability to disable safeDescriptors for prototypes
|
|
679
679
|
safeDescriptors) {
|
|
680
|
-
var _annotation$options_, _annotation$options_$, _annotation$options_2, _annotation$options_$2, _annotation$options_3;
|
|
680
|
+
var _annotation$options_, _annotation$options_$, _annotation$options_2, _annotation$options_$2, _annotation$options_3, _annotation$options_4, _adm$proxy_2;
|
|
681
681
|
|
|
682
682
|
if (safeDescriptors === void 0) {
|
|
683
683
|
safeDescriptors = globalState.safeDescriptors;
|
|
@@ -693,7 +693,8 @@
|
|
|
693
693
|
}
|
|
694
694
|
|
|
695
695
|
return {
|
|
696
|
-
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
|
|
696
|
+
value: createAction((_annotation$options_$ = (_annotation$options_2 = annotation.options_) == null ? void 0 : _annotation$options_2.name) != null ? _annotation$options_$ : key.toString(), value, (_annotation$options_$2 = (_annotation$options_3 = annotation.options_) == null ? void 0 : _annotation$options_3.autoAction) != null ? _annotation$options_$2 : false, // https://github.com/mobxjs/mobx/discussions/3140
|
|
697
|
+
((_annotation$options_4 = annotation.options_) == null ? void 0 : _annotation$options_4.bound) ? (_adm$proxy_2 = adm.proxy_) != null ? _adm$proxy_2 : adm.target_ : undefined),
|
|
697
698
|
// Non-configurable for classes
|
|
698
699
|
// prevents accidental field redefinition in subclass
|
|
699
700
|
configurable: safeDescriptors ? adm.isPlainObject_ : true,
|
|
@@ -1540,22 +1541,21 @@
|
|
|
1540
1541
|
/* see #1208 */
|
|
1541
1542
|
this.dependenciesState_ === IDerivationState_.NOT_TRACKING_;
|
|
1542
1543
|
var newValue = this.computeValue_(true);
|
|
1543
|
-
|
|
1544
|
-
if ( isSpyEnabled()) {
|
|
1545
|
-
spyReport({
|
|
1546
|
-
observableKind: "computed",
|
|
1547
|
-
debugObjectName: this.name_,
|
|
1548
|
-
object: this.scope_,
|
|
1549
|
-
type: "update",
|
|
1550
|
-
oldValue: this.value_,
|
|
1551
|
-
newValue: newValue
|
|
1552
|
-
});
|
|
1553
|
-
}
|
|
1554
|
-
|
|
1555
1544
|
var changed = wasSuspended || isCaughtException(oldValue) || isCaughtException(newValue) || !this.equals_(oldValue, newValue);
|
|
1556
1545
|
|
|
1557
1546
|
if (changed) {
|
|
1558
1547
|
this.value_ = newValue;
|
|
1548
|
+
|
|
1549
|
+
if ( isSpyEnabled()) {
|
|
1550
|
+
spyReport({
|
|
1551
|
+
observableKind: "computed",
|
|
1552
|
+
debugObjectName: this.name_,
|
|
1553
|
+
object: this.scope_,
|
|
1554
|
+
type: "update",
|
|
1555
|
+
oldValue: oldValue,
|
|
1556
|
+
newValue: newValue
|
|
1557
|
+
});
|
|
1558
|
+
}
|
|
1559
1559
|
}
|
|
1560
1560
|
|
|
1561
1561
|
return changed;
|
|
@@ -1974,6 +1974,8 @@
|
|
|
1974
1974
|
if (global.__mobxGlobals && global.__mobxGlobals.version !== new MobXGlobals().version) canMergeGlobalState = false;
|
|
1975
1975
|
|
|
1976
1976
|
if (!canMergeGlobalState) {
|
|
1977
|
+
// Because this is a IIFE we need to let isolateCalled a chance to change
|
|
1978
|
+
// so we run it after the event loop completed at least 1 iteration
|
|
1977
1979
|
setTimeout(function () {
|
|
1978
1980
|
if (!isolateCalled) {
|
|
1979
1981
|
die(35);
|
|
@@ -2221,8 +2223,7 @@
|
|
|
2221
2223
|
return;
|
|
2222
2224
|
}
|
|
2223
2225
|
|
|
2224
|
-
lines.push("" +
|
|
2225
|
-
|
|
2226
|
+
lines.push("" + "\t".repeat(depth - 1) + tree.name);
|
|
2226
2227
|
if (tree.dependencies) tree.dependencies.forEach(function (child) {
|
|
2227
2228
|
return printDepTree(child, lines, depth + 1);
|
|
2228
2229
|
});
|
|
@@ -2653,8 +2654,7 @@
|
|
|
2653
2654
|
var firstTime = true;
|
|
2654
2655
|
var isScheduled = false;
|
|
2655
2656
|
var value;
|
|
2656
|
-
var oldValue
|
|
2657
|
-
|
|
2657
|
+
var oldValue;
|
|
2658
2658
|
var equals = opts.compareStructural ? comparer.structural : opts.equals || comparer["default"];
|
|
2659
2659
|
var r = new Reaction(name, function () {
|
|
2660
2660
|
if (firstTime || runSync) {
|
|
@@ -2770,7 +2770,7 @@
|
|
|
2770
2770
|
if (arguments.length > 4) die("'extendObservable' expected 2-4 arguments");
|
|
2771
2771
|
if (typeof target !== "object") die("'extendObservable' expects an object as first argument");
|
|
2772
2772
|
if (isObservableMap(target)) die("'extendObservable' should not be used on maps, use map.merge instead");
|
|
2773
|
-
if (!isPlainObject(properties)) die("'
|
|
2773
|
+
if (!isPlainObject(properties)) die("'extendObservable' only accepts plain objects as second argument");
|
|
2774
2774
|
if (isObservable(properties) || isObservable(annotations)) die("Extending an object with another observable (object) is not supported");
|
|
2775
2775
|
} // Pull descriptors first, so we don't have to deal with props added by administration ($mobx)
|
|
2776
2776
|
|
|
@@ -2961,14 +2961,14 @@
|
|
|
2961
2961
|
}
|
|
2962
2962
|
|
|
2963
2963
|
function _isComputed(value, property) {
|
|
2964
|
-
if (property
|
|
2965
|
-
|
|
2966
|
-
if (!value[$mobx].values_.has(property)) return false;
|
|
2967
|
-
var atom = getAtom(value, property);
|
|
2968
|
-
return isComputedValue(atom);
|
|
2964
|
+
if (property === undefined) {
|
|
2965
|
+
return isComputedValue(value);
|
|
2969
2966
|
}
|
|
2970
2967
|
|
|
2971
|
-
|
|
2968
|
+
if (isObservableObject(value) === false) return false;
|
|
2969
|
+
if (!value[$mobx].values_.has(property)) return false;
|
|
2970
|
+
var atom = getAtom(value, property);
|
|
2971
|
+
return isComputedValue(atom);
|
|
2972
2972
|
}
|
|
2973
2973
|
function isComputed(value) {
|
|
2974
2974
|
if ( arguments.length > 1) return die("isComputed expects only 1 argument. Use isComputedProp to inspect the observability of a property");
|
|
@@ -3327,7 +3327,7 @@
|
|
|
3327
3327
|
|
|
3328
3328
|
cancel = function cancel() {
|
|
3329
3329
|
disposer();
|
|
3330
|
-
reject("WHEN_CANCELLED");
|
|
3330
|
+
reject(new Error("WHEN_CANCELLED"));
|
|
3331
3331
|
};
|
|
3332
3332
|
});
|
|
3333
3333
|
res.cancel = cancel;
|
|
@@ -3458,7 +3458,11 @@
|
|
|
3458
3458
|
try {
|
|
3459
3459
|
var _annotations;
|
|
3460
3460
|
|
|
3461
|
-
|
|
3461
|
+
if ("development" !== "production" && annotations && target[storedAnnotationsSymbol]) {
|
|
3462
|
+
die("makeObservable second arg must be nullish when using decorators. Mixing @decorator syntax with annotations is not supported.");
|
|
3463
|
+
} // Default to decorators
|
|
3464
|
+
|
|
3465
|
+
|
|
3462
3466
|
(_annotations = annotations) != null ? _annotations : annotations = collectStoredAnnotations(target); // Annotate
|
|
3463
3467
|
|
|
3464
3468
|
ownKeys(annotations).forEach(function (key) {
|
|
@@ -3619,7 +3623,7 @@
|
|
|
3619
3623
|
};
|
|
3620
3624
|
|
|
3621
3625
|
_proto.setArrayLength_ = function setArrayLength_(newLength) {
|
|
3622
|
-
if (typeof newLength !== "number" || newLength < 0) die("Out of range: " + newLength);
|
|
3626
|
+
if (typeof newLength !== "number" || isNaN(newLength) || newLength < 0) die("Out of range: " + newLength);
|
|
3623
3627
|
var currentLength = this.values_.length;
|
|
3624
3628
|
if (newLength === currentLength) return;else if (newLength > currentLength) {
|
|
3625
3629
|
var newItems = new Array(newLength - currentLength);
|
|
@@ -4108,9 +4112,11 @@
|
|
|
4108
4112
|
|
|
4109
4113
|
if ( notifySpy) spyReportStart(_change);
|
|
4110
4114
|
transaction(function () {
|
|
4115
|
+
var _this2$hasMap_$get;
|
|
4116
|
+
|
|
4111
4117
|
_this2.keysAtom_.reportChanged();
|
|
4112
4118
|
|
|
4113
|
-
_this2.
|
|
4119
|
+
(_this2$hasMap_$get = _this2.hasMap_.get(key)) == null ? void 0 : _this2$hasMap_$get.setNewValue_(false);
|
|
4114
4120
|
|
|
4115
4121
|
var observable = _this2.data_.get(key);
|
|
4116
4122
|
|
|
@@ -4126,14 +4132,6 @@
|
|
|
4126
4132
|
return false;
|
|
4127
4133
|
};
|
|
4128
4134
|
|
|
4129
|
-
_proto.updateHasMapEntry_ = function updateHasMapEntry_(key, value) {
|
|
4130
|
-
var entry = this.hasMap_.get(key);
|
|
4131
|
-
|
|
4132
|
-
if (entry) {
|
|
4133
|
-
entry.setNewValue_(value);
|
|
4134
|
-
}
|
|
4135
|
-
};
|
|
4136
|
-
|
|
4137
4135
|
_proto.updateValue_ = function updateValue_(key, newValue) {
|
|
4138
4136
|
var observable = this.data_.get(key);
|
|
4139
4137
|
newValue = observable.prepareNewValue_(newValue);
|
|
@@ -4162,13 +4160,15 @@
|
|
|
4162
4160
|
|
|
4163
4161
|
checkIfStateModificationsAreAllowed(this.keysAtom_);
|
|
4164
4162
|
transaction(function () {
|
|
4163
|
+
var _this3$hasMap_$get;
|
|
4164
|
+
|
|
4165
4165
|
var observable = new ObservableValue(newValue, _this3.enhancer_, _this3.name_ + "." + stringifyKey(key) , false);
|
|
4166
4166
|
|
|
4167
4167
|
_this3.data_.set(key, observable);
|
|
4168
4168
|
|
|
4169
4169
|
newValue = observable.value_; // value might have been changed
|
|
4170
4170
|
|
|
4171
|
-
_this3.
|
|
4171
|
+
(_this3$hasMap_$get = _this3.hasMap_.get(key)) == null ? void 0 : _this3$hasMap_$get.setNewValue_(true);
|
|
4172
4172
|
|
|
4173
4173
|
_this3.keysAtom_.reportChanged();
|
|
4174
4174
|
});
|