mobx 6.3.9 → 6.3.13
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 +24 -0
- package/dist/api/tojs.d.ts +4 -1
- package/dist/mobx.cjs.development.js +55 -41
- 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 +55 -41
- package/dist/mobx.esm.development.js.map +1 -1
- package/dist/mobx.esm.js +55 -41
- 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 +55 -41
- 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/package.json +1 -1
- package/src/api/tojs.ts +4 -1
- package/src/types/flowannotation.ts +11 -3
- package/src/types/observablemap.ts +5 -2
- package/src/utils/eq.ts +1 -1
|
@@ -737,7 +737,7 @@
|
|
|
737
737
|
// bound - must annotate protos to support super.flow()
|
|
738
738
|
|
|
739
739
|
|
|
740
|
-
if ((_this$options_ = this.options_) != null && _this$options_.bound && !isFlow(adm.target_[key])) {
|
|
740
|
+
if ((_this$options_ = this.options_) != null && _this$options_.bound && (!hasProp(adm.target_, key) || !isFlow(adm.target_[key]))) {
|
|
741
741
|
if (this.extend_(adm, key, descriptor, false) === null) return 0
|
|
742
742
|
/* Cancel */
|
|
743
743
|
;
|
|
@@ -781,16 +781,23 @@
|
|
|
781
781
|
}
|
|
782
782
|
|
|
783
783
|
assertFlowDescriptor(adm, annotation, key, descriptor);
|
|
784
|
-
var value = descriptor.value;
|
|
784
|
+
var value = descriptor.value; // In case of flow.bound, the descriptor can be from already annotated prototype
|
|
785
|
+
|
|
786
|
+
if (!isFlow(value)) {
|
|
787
|
+
value = flow(value);
|
|
788
|
+
}
|
|
785
789
|
|
|
786
790
|
if (bound) {
|
|
787
791
|
var _adm$proxy_;
|
|
788
792
|
|
|
789
|
-
|
|
793
|
+
// We do not keep original function around, so we bind the existing flow
|
|
794
|
+
value = value.bind((_adm$proxy_ = adm.proxy_) != null ? _adm$proxy_ : adm.target_); // This is normally set by `flow`, but `bind` returns new function...
|
|
795
|
+
|
|
796
|
+
value.isMobXFlow = true;
|
|
790
797
|
}
|
|
791
798
|
|
|
792
799
|
return {
|
|
793
|
-
value:
|
|
800
|
+
value: value,
|
|
794
801
|
// Non-configurable for classes
|
|
795
802
|
// prevents accidental field redefinition in subclass
|
|
796
803
|
configurable: safeDescriptors ? adm.isPlainObject_ : true,
|
|
@@ -3226,7 +3233,10 @@
|
|
|
3226
3233
|
}
|
|
3227
3234
|
}
|
|
3228
3235
|
/**
|
|
3229
|
-
*
|
|
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.
|
|
3230
3240
|
*/
|
|
3231
3241
|
|
|
3232
3242
|
|
|
@@ -4018,6 +4028,8 @@
|
|
|
4018
4028
|
var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTag2) {
|
|
4019
4029
|
// hasMap, not hashMap >-).
|
|
4020
4030
|
function ObservableMap(initialData, enhancer_, name_) {
|
|
4031
|
+
var _this = this;
|
|
4032
|
+
|
|
4021
4033
|
if (enhancer_ === void 0) {
|
|
4022
4034
|
enhancer_ = deepEnhancer;
|
|
4023
4035
|
}
|
|
@@ -4045,7 +4057,9 @@
|
|
|
4045
4057
|
this.keysAtom_ = createAtom( this.name_ + ".keys()" );
|
|
4046
4058
|
this.data_ = new Map();
|
|
4047
4059
|
this.hasMap_ = new Map();
|
|
4048
|
-
|
|
4060
|
+
allowStateChanges(true, function () {
|
|
4061
|
+
_this.merge(initialData);
|
|
4062
|
+
});
|
|
4049
4063
|
}
|
|
4050
4064
|
|
|
4051
4065
|
var _proto = ObservableMap.prototype;
|
|
@@ -4055,7 +4069,7 @@
|
|
|
4055
4069
|
};
|
|
4056
4070
|
|
|
4057
4071
|
_proto.has = function has(key) {
|
|
4058
|
-
var
|
|
4072
|
+
var _this2 = this;
|
|
4059
4073
|
|
|
4060
4074
|
if (!globalState.trackingDerivation) return this.has_(key);
|
|
4061
4075
|
var entry = this.hasMap_.get(key);
|
|
@@ -4064,7 +4078,7 @@
|
|
|
4064
4078
|
var newEntry = entry = new ObservableValue(this.has_(key), referenceEnhancer, this.name_ + "." + stringifyKey(key) + "?" , false);
|
|
4065
4079
|
this.hasMap_.set(key, newEntry);
|
|
4066
4080
|
onBecomeUnobserved(newEntry, function () {
|
|
4067
|
-
return
|
|
4081
|
+
return _this2.hasMap_["delete"](key);
|
|
4068
4082
|
});
|
|
4069
4083
|
}
|
|
4070
4084
|
|
|
@@ -4095,7 +4109,7 @@
|
|
|
4095
4109
|
};
|
|
4096
4110
|
|
|
4097
4111
|
_proto["delete"] = function _delete(key) {
|
|
4098
|
-
var
|
|
4112
|
+
var _this3 = this;
|
|
4099
4113
|
|
|
4100
4114
|
checkIfStateModificationsAreAllowed(this.keysAtom_);
|
|
4101
4115
|
|
|
@@ -4124,17 +4138,17 @@
|
|
|
4124
4138
|
if ( notifySpy) spyReportStart(_change); // TODO fix type
|
|
4125
4139
|
|
|
4126
4140
|
transaction(function () {
|
|
4127
|
-
var
|
|
4141
|
+
var _this3$hasMap_$get;
|
|
4128
4142
|
|
|
4129
|
-
|
|
4143
|
+
_this3.keysAtom_.reportChanged();
|
|
4130
4144
|
|
|
4131
|
-
(
|
|
4145
|
+
(_this3$hasMap_$get = _this3.hasMap_.get(key)) == null ? void 0 : _this3$hasMap_$get.setNewValue_(false);
|
|
4132
4146
|
|
|
4133
|
-
var observable =
|
|
4147
|
+
var observable = _this3.data_.get(key);
|
|
4134
4148
|
|
|
4135
4149
|
observable.setNewValue_(undefined);
|
|
4136
4150
|
|
|
4137
|
-
|
|
4151
|
+
_this3.data_["delete"](key);
|
|
4138
4152
|
});
|
|
4139
4153
|
if (notify) notifyListeners(this, _change);
|
|
4140
4154
|
if ( notifySpy) spyReportEnd();
|
|
@@ -4169,21 +4183,21 @@
|
|
|
4169
4183
|
};
|
|
4170
4184
|
|
|
4171
4185
|
_proto.addValue_ = function addValue_(key, newValue) {
|
|
4172
|
-
var
|
|
4186
|
+
var _this4 = this;
|
|
4173
4187
|
|
|
4174
4188
|
checkIfStateModificationsAreAllowed(this.keysAtom_);
|
|
4175
4189
|
transaction(function () {
|
|
4176
|
-
var
|
|
4190
|
+
var _this4$hasMap_$get;
|
|
4177
4191
|
|
|
4178
|
-
var observable = new ObservableValue(newValue,
|
|
4192
|
+
var observable = new ObservableValue(newValue, _this4.enhancer_, _this4.name_ + "." + stringifyKey(key) , false);
|
|
4179
4193
|
|
|
4180
|
-
|
|
4194
|
+
_this4.data_.set(key, observable);
|
|
4181
4195
|
|
|
4182
4196
|
newValue = observable.value_; // value might have been changed
|
|
4183
4197
|
|
|
4184
|
-
(
|
|
4198
|
+
(_this4$hasMap_$get = _this4.hasMap_.get(key)) == null ? void 0 : _this4$hasMap_$get.setNewValue_(true);
|
|
4185
4199
|
|
|
4186
|
-
|
|
4200
|
+
_this4.keysAtom_.reportChanged();
|
|
4187
4201
|
});
|
|
4188
4202
|
var notifySpy = isSpyEnabled();
|
|
4189
4203
|
var notify = hasListeners(this);
|
|
@@ -4269,7 +4283,7 @@
|
|
|
4269
4283
|
;
|
|
4270
4284
|
|
|
4271
4285
|
_proto.merge = function merge(other) {
|
|
4272
|
-
var
|
|
4286
|
+
var _this5 = this;
|
|
4273
4287
|
|
|
4274
4288
|
if (isObservableMap(other)) {
|
|
4275
4289
|
other = new Map(other);
|
|
@@ -4277,15 +4291,15 @@
|
|
|
4277
4291
|
|
|
4278
4292
|
transaction(function () {
|
|
4279
4293
|
if (isPlainObject(other)) getPlainObjectKeys(other).forEach(function (key) {
|
|
4280
|
-
return
|
|
4294
|
+
return _this5.set(key, other[key]);
|
|
4281
4295
|
});else if (Array.isArray(other)) other.forEach(function (_ref) {
|
|
4282
4296
|
var key = _ref[0],
|
|
4283
4297
|
value = _ref[1];
|
|
4284
|
-
return
|
|
4298
|
+
return _this5.set(key, value);
|
|
4285
4299
|
});else if (isES6Map(other)) {
|
|
4286
4300
|
if (other.constructor !== Map) die(19, other);
|
|
4287
4301
|
other.forEach(function (value, key) {
|
|
4288
|
-
return
|
|
4302
|
+
return _this5.set(key, value);
|
|
4289
4303
|
});
|
|
4290
4304
|
} else if (other !== null && other !== undefined) die(20, other);
|
|
4291
4305
|
});
|
|
@@ -4293,21 +4307,21 @@
|
|
|
4293
4307
|
};
|
|
4294
4308
|
|
|
4295
4309
|
_proto.clear = function clear() {
|
|
4296
|
-
var
|
|
4310
|
+
var _this6 = this;
|
|
4297
4311
|
|
|
4298
4312
|
transaction(function () {
|
|
4299
4313
|
untracked(function () {
|
|
4300
|
-
for (var _iterator2 = _createForOfIteratorHelperLoose(
|
|
4314
|
+
for (var _iterator2 = _createForOfIteratorHelperLoose(_this6.keys()), _step2; !(_step2 = _iterator2()).done;) {
|
|
4301
4315
|
var key = _step2.value;
|
|
4302
4316
|
|
|
4303
|
-
|
|
4317
|
+
_this6["delete"](key);
|
|
4304
4318
|
}
|
|
4305
4319
|
});
|
|
4306
4320
|
});
|
|
4307
4321
|
};
|
|
4308
4322
|
|
|
4309
4323
|
_proto.replace = function replace(values) {
|
|
4310
|
-
var
|
|
4324
|
+
var _this7 = this;
|
|
4311
4325
|
|
|
4312
4326
|
// Implementation requirements:
|
|
4313
4327
|
// - respect ordering of replacement map
|
|
@@ -4324,13 +4338,13 @@
|
|
|
4324
4338
|
// if the key deletion is prevented by interceptor
|
|
4325
4339
|
// add entry at the beginning of the result map
|
|
4326
4340
|
|
|
4327
|
-
for (var _iterator3 = _createForOfIteratorHelperLoose(
|
|
4341
|
+
for (var _iterator3 = _createForOfIteratorHelperLoose(_this7.data_.keys()), _step3; !(_step3 = _iterator3()).done;) {
|
|
4328
4342
|
var key = _step3.value;
|
|
4329
4343
|
|
|
4330
4344
|
// Concurrently iterating/deleting keys
|
|
4331
4345
|
// iterator should handle this correctly
|
|
4332
4346
|
if (!replacementMap.has(key)) {
|
|
4333
|
-
var deleted =
|
|
4347
|
+
var deleted = _this7["delete"](key); // Was the key removed?
|
|
4334
4348
|
|
|
4335
4349
|
|
|
4336
4350
|
if (deleted) {
|
|
@@ -4338,7 +4352,7 @@
|
|
|
4338
4352
|
keysReportChangedCalled = true;
|
|
4339
4353
|
} else {
|
|
4340
4354
|
// Delete prevented by interceptor
|
|
4341
|
-
var value =
|
|
4355
|
+
var value = _this7.data_.get(key);
|
|
4342
4356
|
|
|
4343
4357
|
orderedData.set(key, value);
|
|
4344
4358
|
}
|
|
@@ -4352,17 +4366,17 @@
|
|
|
4352
4366
|
_value = _step4$value[1];
|
|
4353
4367
|
|
|
4354
4368
|
// We will want to know whether a new key is added
|
|
4355
|
-
var keyExisted =
|
|
4369
|
+
var keyExisted = _this7.data_.has(_key); // Add or update value
|
|
4356
4370
|
|
|
4357
4371
|
|
|
4358
|
-
|
|
4372
|
+
_this7.set(_key, _value); // The addition could have been prevent by interceptor
|
|
4359
4373
|
|
|
4360
4374
|
|
|
4361
|
-
if (
|
|
4375
|
+
if (_this7.data_.has(_key)) {
|
|
4362
4376
|
// The update could have been prevented by interceptor
|
|
4363
4377
|
// and also we want to preserve existing values
|
|
4364
4378
|
// so use value from _data map (instead of replacement map)
|
|
4365
|
-
var _value2 =
|
|
4379
|
+
var _value2 = _this7.data_.get(_key);
|
|
4366
4380
|
|
|
4367
4381
|
orderedData.set(_key, _value2); // Was a new key added?
|
|
4368
4382
|
|
|
@@ -4375,11 +4389,11 @@
|
|
|
4375
4389
|
|
|
4376
4390
|
|
|
4377
4391
|
if (!keysReportChangedCalled) {
|
|
4378
|
-
if (
|
|
4392
|
+
if (_this7.data_.size !== orderedData.size) {
|
|
4379
4393
|
// If size differs, keys are definitely modified
|
|
4380
|
-
|
|
4394
|
+
_this7.keysAtom_.reportChanged();
|
|
4381
4395
|
} else {
|
|
4382
|
-
var iter1 =
|
|
4396
|
+
var iter1 = _this7.data_.keys();
|
|
4383
4397
|
|
|
4384
4398
|
var iter2 = orderedData.keys();
|
|
4385
4399
|
var next1 = iter1.next();
|
|
@@ -4387,7 +4401,7 @@
|
|
|
4387
4401
|
|
|
4388
4402
|
while (!next1.done) {
|
|
4389
4403
|
if (next1.value !== next2.value) {
|
|
4390
|
-
|
|
4404
|
+
_this7.keysAtom_.reportChanged();
|
|
4391
4405
|
|
|
4392
4406
|
break;
|
|
4393
4407
|
}
|
|
@@ -4399,7 +4413,7 @@
|
|
|
4399
4413
|
} // Use correctly ordered map
|
|
4400
4414
|
|
|
4401
4415
|
|
|
4402
|
-
|
|
4416
|
+
_this7.data_ = orderedData;
|
|
4403
4417
|
});
|
|
4404
4418
|
return this;
|
|
4405
4419
|
};
|
|
@@ -5608,7 +5622,7 @@
|
|
|
5608
5622
|
if (a !== a) return b !== b; // Exhaust primitive checks
|
|
5609
5623
|
|
|
5610
5624
|
var type = typeof a;
|
|
5611
|
-
if (
|
|
5625
|
+
if (type !== "function" && type !== "object" && typeof b != "object") return false; // Compare `[[Class]]` names.
|
|
5612
5626
|
|
|
5613
5627
|
var className = toString.call(a);
|
|
5614
5628
|
if (className !== toString.call(b)) return false;
|