mobx 6.1.4 → 6.1.8
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 +35 -0
- package/dist/api/annotation.d.ts +0 -1
- package/dist/api/iscomputed.d.ts +2 -2
- package/dist/core/computedvalue.d.ts +0 -1
- package/dist/core/derivation.d.ts +0 -1
- package/dist/core/reaction.d.ts +0 -1
- package/dist/mobx.cjs.development.js +92 -46
- 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 +92 -46
- package/dist/mobx.esm.development.js.map +1 -1
- package/dist/mobx.esm.js +92 -46
- 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 +92 -46
- 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/observablearray.d.ts +1 -1
- package/dist/types/type-utils.d.ts +1 -1
- package/package.json +1 -1
- package/src/api/annotation.ts +0 -1
- package/src/api/autorun.ts +3 -2
- package/src/api/computed.ts +1 -1
- package/src/api/decorators.ts +1 -4
- package/src/api/iscomputed.ts +2 -2
- package/src/api/makeObservable.ts +10 -2
- package/src/api/observable.ts +1 -1
- package/src/api/when.ts +5 -2
- package/src/core/atom.ts +1 -1
- package/src/core/computedvalue.ts +7 -3
- package/src/core/derivation.ts +0 -1
- package/src/core/reaction.ts +1 -2
- package/src/types/actionannotation.ts +3 -2
- package/src/types/computedannotation.ts +3 -2
- package/src/types/flowannotation.ts +3 -2
- package/src/types/legacyobservablearray.ts +1 -1
- package/src/types/observableannotation.ts +3 -2
- package/src/types/observablearray.ts +5 -4
- package/src/types/observablemap.ts +4 -4
- package/src/types/observableobject.ts +27 -14
- package/src/types/observableset.ts +1 -1
- package/src/types/observablevalue.ts +1 -1
- package/src/types/type-utils.ts +11 -4
- package/src/utils/global.ts +3 -0
|
@@ -76,6 +76,10 @@ function die(error) {
|
|
|
76
76
|
|
|
77
77
|
var mockGlobal = {};
|
|
78
78
|
function getGlobal() {
|
|
79
|
+
if (typeof globalThis !== "undefined") {
|
|
80
|
+
return globalThis;
|
|
81
|
+
}
|
|
82
|
+
|
|
79
83
|
if (typeof window !== "undefined") {
|
|
80
84
|
return window;
|
|
81
85
|
}
|
|
@@ -357,9 +361,7 @@ function storeAnnotation(prototype, key, annotation) {
|
|
|
357
361
|
assertNotDecorated(prototype, annotation, key); // Ignore override
|
|
358
362
|
|
|
359
363
|
if (!isOverride(annotation)) {
|
|
360
|
-
prototype[storedAnnotationsSymbol][key] =
|
|
361
|
-
isDecorator_: true
|
|
362
|
-
});
|
|
364
|
+
prototype[storedAnnotationsSymbol][key] = annotation;
|
|
363
365
|
}
|
|
364
366
|
}
|
|
365
367
|
|
|
@@ -399,7 +401,7 @@ var Atom = /*#__PURE__*/function () {
|
|
|
399
401
|
*/
|
|
400
402
|
function Atom(name_) {
|
|
401
403
|
if (name_ === void 0) {
|
|
402
|
-
name_ =
|
|
404
|
+
name_ = "Atom@" + getNextId() ;
|
|
403
405
|
}
|
|
404
406
|
|
|
405
407
|
this.name_ = void 0;
|
|
@@ -589,7 +591,7 @@ function createActionAnnotation(name, options) {
|
|
|
589
591
|
}
|
|
590
592
|
|
|
591
593
|
function make_$1(adm, key) {
|
|
592
|
-
var _this$options_$bound, _this$options_;
|
|
594
|
+
var _this$options_$bound, _this$options_, _adm$target_$storedAn;
|
|
593
595
|
|
|
594
596
|
var annotated = false;
|
|
595
597
|
var source = adm.target_;
|
|
@@ -639,7 +641,7 @@ function make_$1(adm, key) {
|
|
|
639
641
|
|
|
640
642
|
if (annotated) {
|
|
641
643
|
recordAnnotationApplied(adm, this, key);
|
|
642
|
-
} else if (!
|
|
644
|
+
} else if (!((_adm$target_$storedAn = adm.target_[storedAnnotationsSymbol]) == null ? void 0 : _adm$target_$storedAn[key])) {
|
|
643
645
|
// Throw on missing key, except for decorators:
|
|
644
646
|
// Decorator annotations are collected from whole prototype chain.
|
|
645
647
|
// When called from super() some props may not exist yet.
|
|
@@ -703,6 +705,8 @@ function createFlowAnnotation(name, options) {
|
|
|
703
705
|
}
|
|
704
706
|
|
|
705
707
|
function make_$2(adm, key) {
|
|
708
|
+
var _adm$target_$storedAn;
|
|
709
|
+
|
|
706
710
|
var annotated = false;
|
|
707
711
|
var source = adm.target_;
|
|
708
712
|
|
|
@@ -740,7 +744,7 @@ function make_$2(adm, key) {
|
|
|
740
744
|
|
|
741
745
|
if (annotated) {
|
|
742
746
|
recordAnnotationApplied(adm, this, key);
|
|
743
|
-
} else if (!
|
|
747
|
+
} else if (!((_adm$target_$storedAn = adm.target_[storedAnnotationsSymbol]) == null ? void 0 : _adm$target_$storedAn[key])) {
|
|
744
748
|
// Throw on missing key, except for decorators:
|
|
745
749
|
// Decorator annotations are collected from whole prototype chain.
|
|
746
750
|
// When called from super() some props may not exist yet.
|
|
@@ -794,6 +798,8 @@ function createComputedAnnotation(name, options) {
|
|
|
794
798
|
}
|
|
795
799
|
|
|
796
800
|
function make_$3(adm, key) {
|
|
801
|
+
var _adm$target_$storedAn;
|
|
802
|
+
|
|
797
803
|
var source = adm.target_;
|
|
798
804
|
|
|
799
805
|
while (source && source !== objectPrototype) {
|
|
@@ -818,7 +824,7 @@ function make_$3(adm, key) {
|
|
|
818
824
|
source = Object.getPrototypeOf(source);
|
|
819
825
|
}
|
|
820
826
|
|
|
821
|
-
if (!
|
|
827
|
+
if (!((_adm$target_$storedAn = adm.target_[storedAnnotationsSymbol]) == null ? void 0 : _adm$target_$storedAn[key])) {
|
|
822
828
|
// Throw on missing key, except for decorators:
|
|
823
829
|
// Decorator annotations are collected from whole prototype chain.
|
|
824
830
|
// When called from super() some props may not exist yet.
|
|
@@ -855,6 +861,8 @@ function createObservableAnnotation(name, options) {
|
|
|
855
861
|
}
|
|
856
862
|
|
|
857
863
|
function make_$4(adm, key) {
|
|
864
|
+
var _adm$target_$storedAn;
|
|
865
|
+
|
|
858
866
|
var source = adm.target_; // Copy props from proto as well, see test:
|
|
859
867
|
// "decorate should work with Object.create"
|
|
860
868
|
|
|
@@ -879,7 +887,7 @@ function make_$4(adm, key) {
|
|
|
879
887
|
source = Object.getPrototypeOf(source);
|
|
880
888
|
}
|
|
881
889
|
|
|
882
|
-
if (!
|
|
890
|
+
if (!((_adm$target_$storedAn = adm.target_[storedAnnotationsSymbol]) == null ? void 0 : _adm$target_$storedAn[key])) {
|
|
883
891
|
// Throw on missing key, except for decorators:
|
|
884
892
|
// Decorator annotations are collected from whole prototype chain.
|
|
885
893
|
// When called from super() some props may not exist yet.
|
|
@@ -963,7 +971,7 @@ function createObservable(v, arg2, arg3) {
|
|
|
963
971
|
|
|
964
972
|
if (typeof v === "object" && v !== null) return v; // anything else
|
|
965
973
|
|
|
966
|
-
return observable.box(v);
|
|
974
|
+
return observable.box(v, arg2);
|
|
967
975
|
}
|
|
968
976
|
|
|
969
977
|
Object.assign(createObservable, observableDecoratorAnnotation);
|
|
@@ -1025,7 +1033,7 @@ var computed = function computed(arg1, arg2) {
|
|
|
1025
1033
|
|
|
1026
1034
|
var opts = isPlainObject(arg2) ? arg2 : {};
|
|
1027
1035
|
opts.get = arg1;
|
|
1028
|
-
opts.name
|
|
1036
|
+
opts.name || (opts.name = arg1.name || "");
|
|
1029
1037
|
/* for generated name */
|
|
1030
1038
|
|
|
1031
1039
|
return new ComputedValue(opts);
|
|
@@ -1173,7 +1181,7 @@ var ObservableValue = /*#__PURE__*/function (_Atom) {
|
|
|
1173
1181
|
var _this;
|
|
1174
1182
|
|
|
1175
1183
|
if (name_ === void 0) {
|
|
1176
|
-
name_ =
|
|
1184
|
+
name_ = "ObservableValue@" + getNextId() ;
|
|
1177
1185
|
}
|
|
1178
1186
|
|
|
1179
1187
|
if (notifySpy === void 0) {
|
|
@@ -1373,7 +1381,6 @@ var ComputedValue = /*#__PURE__*/function () {
|
|
|
1373
1381
|
this.lastAccessedBy_ = 0;
|
|
1374
1382
|
this.lowestObserverState_ = IDerivationState_.UP_TO_DATE_;
|
|
1375
1383
|
this.unboundDepsCount_ = 0;
|
|
1376
|
-
this.mapid_ = "#" + getNextId();
|
|
1377
1384
|
this.value_ = new CaughtException(null);
|
|
1378
1385
|
this.name_ = void 0;
|
|
1379
1386
|
this.triggeredBy_ = void 0;
|
|
@@ -1390,8 +1397,12 @@ var ComputedValue = /*#__PURE__*/function () {
|
|
|
1390
1397
|
this.onBUOL = void 0;
|
|
1391
1398
|
if (!options.get) die(31);
|
|
1392
1399
|
this.derivation = options.get;
|
|
1393
|
-
this.name_ = options.name || "ComputedValue@" + getNextId();
|
|
1394
|
-
|
|
1400
|
+
this.name_ = options.name || ( "ComputedValue@" + getNextId() );
|
|
1401
|
+
|
|
1402
|
+
if (options.set) {
|
|
1403
|
+
this.setter_ = createAction( this.name_ + "-setter" , options.set);
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1395
1406
|
this.equals_ = options.equals || (options.compareStructural || options.struct ? comparer.structural : comparer["default"]);
|
|
1396
1407
|
this.scope_ = options.context;
|
|
1397
1408
|
this.requiresReaction_ = !!options.requiresReaction;
|
|
@@ -2162,7 +2173,7 @@ var Reaction = /*#__PURE__*/function () {
|
|
|
2162
2173
|
// nodes we are looking at. Our value depends on these nodes
|
|
2163
2174
|
function Reaction(name_, onInvalidate_, errorHandler_, requiresObservable_) {
|
|
2164
2175
|
if (name_ === void 0) {
|
|
2165
|
-
name_ =
|
|
2176
|
+
name_ = "Reaction@" + getNextId() ;
|
|
2166
2177
|
}
|
|
2167
2178
|
|
|
2168
2179
|
if (requiresObservable_ === void 0) {
|
|
@@ -2179,7 +2190,6 @@ var Reaction = /*#__PURE__*/function () {
|
|
|
2179
2190
|
this.diffValue_ = 0;
|
|
2180
2191
|
this.runId_ = 0;
|
|
2181
2192
|
this.unboundDepsCount_ = 0;
|
|
2182
|
-
this.mapid_ = "#" + getNextId();
|
|
2183
2193
|
this.isDisposed_ = false;
|
|
2184
2194
|
this.isScheduled_ = false;
|
|
2185
2195
|
this.isTrackPending_ = false;
|
|
@@ -2512,6 +2522,8 @@ function isAction(thing) {
|
|
|
2512
2522
|
*/
|
|
2513
2523
|
|
|
2514
2524
|
function autorun(view, opts) {
|
|
2525
|
+
var _opts$name, _opts;
|
|
2526
|
+
|
|
2515
2527
|
if (opts === void 0) {
|
|
2516
2528
|
opts = EMPTY_OBJECT;
|
|
2517
2529
|
}
|
|
@@ -2521,7 +2533,7 @@ function autorun(view, opts) {
|
|
|
2521
2533
|
if (isAction(view)) die("Autorun does not accept actions since actions are untrackable");
|
|
2522
2534
|
}
|
|
2523
2535
|
|
|
2524
|
-
var name = opts
|
|
2536
|
+
var name = (_opts$name = (_opts = opts) == null ? void 0 : _opts.name) != null ? _opts$name : view.name || "Autorun@" + getNextId() ;
|
|
2525
2537
|
var runSync = !opts.scheduler && !opts.delay;
|
|
2526
2538
|
var reaction;
|
|
2527
2539
|
|
|
@@ -2564,6 +2576,8 @@ function createSchedulerFromOptions(opts) {
|
|
|
2564
2576
|
}
|
|
2565
2577
|
|
|
2566
2578
|
function reaction(expression, effect, opts) {
|
|
2579
|
+
var _opts$name2;
|
|
2580
|
+
|
|
2567
2581
|
if (opts === void 0) {
|
|
2568
2582
|
opts = EMPTY_OBJECT;
|
|
2569
2583
|
}
|
|
@@ -2573,7 +2587,7 @@ function reaction(expression, effect, opts) {
|
|
|
2573
2587
|
if (!isPlainObject(opts)) die("Third argument of reactions should be an object");
|
|
2574
2588
|
}
|
|
2575
2589
|
|
|
2576
|
-
var name = opts.name
|
|
2590
|
+
var name = (_opts$name2 = opts.name) != null ? _opts$name2 : "Reaction@" + getNextId() ;
|
|
2577
2591
|
var effectAction = action(name, opts.onError ? wrapErrorHandler(opts.onError, effect) : effect);
|
|
2578
2592
|
var runSync = !opts.scheduler && !opts.delay;
|
|
2579
2593
|
var scheduler = createSchedulerFromOptions(opts);
|
|
@@ -3210,8 +3224,8 @@ function _when(predicate, effect, opts) {
|
|
|
3210
3224
|
}, opts.timeout);
|
|
3211
3225
|
}
|
|
3212
3226
|
|
|
3213
|
-
opts.name =
|
|
3214
|
-
var effectAction = createAction(opts.name + "-effect", effect); // eslint-disable-next-line
|
|
3227
|
+
opts.name = opts.name || "When@" + getNextId() ;
|
|
3228
|
+
var effectAction = createAction( opts.name + "-effect" , effect); // eslint-disable-next-line
|
|
3215
3229
|
|
|
3216
3230
|
var disposer = autorun(function (r) {
|
|
3217
3231
|
// predicate should not change state
|
|
@@ -3395,9 +3409,20 @@ function makeAutoObservable(target, overrides, options) {
|
|
|
3395
3409
|
startBatch();
|
|
3396
3410
|
|
|
3397
3411
|
try {
|
|
3412
|
+
// Use cached inferred annotations if available (only in classes)
|
|
3398
3413
|
if (target[inferredAnnotationsSymbol]) {
|
|
3399
|
-
|
|
3400
|
-
adm.make_(key,
|
|
3414
|
+
target[inferredAnnotationsSymbol].forEach(function (value, key) {
|
|
3415
|
+
return adm.make_(key, value);
|
|
3416
|
+
}); // Overrides are not cached, unless `true`, see #2832
|
|
3417
|
+
|
|
3418
|
+
if (overrides) {
|
|
3419
|
+
ownKeys(overrides).forEach(function (key) {
|
|
3420
|
+
var annotation = overrides[key];
|
|
3421
|
+
|
|
3422
|
+
if (annotation !== true) {
|
|
3423
|
+
adm.make_(key, annotation);
|
|
3424
|
+
}
|
|
3425
|
+
});
|
|
3401
3426
|
}
|
|
3402
3427
|
} else {
|
|
3403
3428
|
var _ignoreKeys;
|
|
@@ -3468,6 +3493,10 @@ var arrayTraps = {
|
|
|
3468
3493
|
var ObservableArrayAdministration = /*#__PURE__*/function () {
|
|
3469
3494
|
// this is the prop that gets proxied, so can't replace it!
|
|
3470
3495
|
function ObservableArrayAdministration(name, enhancer, owned_, legacyMode_) {
|
|
3496
|
+
if (name === void 0) {
|
|
3497
|
+
name = "ObservableArray@" + getNextId() ;
|
|
3498
|
+
}
|
|
3499
|
+
|
|
3471
3500
|
this.owned_ = void 0;
|
|
3472
3501
|
this.legacyMode_ = void 0;
|
|
3473
3502
|
this.atom_ = void 0;
|
|
@@ -3480,10 +3509,10 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
|
|
|
3480
3509
|
this.lastKnownLength_ = 0;
|
|
3481
3510
|
this.owned_ = owned_;
|
|
3482
3511
|
this.legacyMode_ = legacyMode_;
|
|
3483
|
-
this.atom_ = new Atom(name
|
|
3512
|
+
this.atom_ = new Atom(name);
|
|
3484
3513
|
|
|
3485
3514
|
this.enhancer_ = function (newV, oldV) {
|
|
3486
|
-
return enhancer(newV, oldV,
|
|
3515
|
+
return enhancer(newV, oldV, name + "[..]" );
|
|
3487
3516
|
};
|
|
3488
3517
|
}
|
|
3489
3518
|
|
|
@@ -3698,7 +3727,7 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
|
|
|
3698
3727
|
}();
|
|
3699
3728
|
function createObservableArray(initialValues, enhancer, name, owned) {
|
|
3700
3729
|
if (name === void 0) {
|
|
3701
|
-
name =
|
|
3730
|
+
name = "ObservableArray@" + getNextId() ;
|
|
3702
3731
|
}
|
|
3703
3732
|
|
|
3704
3733
|
if (owned === void 0) {
|
|
@@ -3920,7 +3949,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
3920
3949
|
}
|
|
3921
3950
|
|
|
3922
3951
|
if (name_ === void 0) {
|
|
3923
|
-
name_ =
|
|
3952
|
+
name_ = "ObservableMap@" + getNextId() ;
|
|
3924
3953
|
}
|
|
3925
3954
|
|
|
3926
3955
|
this.enhancer_ = void 0;
|
|
@@ -3939,7 +3968,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
3939
3968
|
die(18);
|
|
3940
3969
|
}
|
|
3941
3970
|
|
|
3942
|
-
this.keysAtom_ = createAtom(this.name_ + ".keys()");
|
|
3971
|
+
this.keysAtom_ = createAtom( this.name_ + ".keys()" );
|
|
3943
3972
|
this.data_ = new Map();
|
|
3944
3973
|
this.hasMap_ = new Map();
|
|
3945
3974
|
this.merge(initialData);
|
|
@@ -3958,7 +3987,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
3958
3987
|
var entry = this.hasMap_.get(key);
|
|
3959
3988
|
|
|
3960
3989
|
if (!entry) {
|
|
3961
|
-
var newEntry = entry = new ObservableValue(this.has_(key), referenceEnhancer,
|
|
3990
|
+
var newEntry = entry = new ObservableValue(this.has_(key), referenceEnhancer, this.name_ + "." + stringifyKey(key) + "?" , false);
|
|
3962
3991
|
this.hasMap_.set(key, newEntry);
|
|
3963
3992
|
onBecomeUnobserved(newEntry, function () {
|
|
3964
3993
|
return _this.hasMap_["delete"](key);
|
|
@@ -4074,7 +4103,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4074
4103
|
|
|
4075
4104
|
checkIfStateModificationsAreAllowed(this.keysAtom_);
|
|
4076
4105
|
transaction(function () {
|
|
4077
|
-
var observable = new ObservableValue(newValue, _this3.enhancer_,
|
|
4106
|
+
var observable = new ObservableValue(newValue, _this3.enhancer_, _this3.name_ + "." + stringifyKey(key) , false);
|
|
4078
4107
|
|
|
4079
4108
|
_this3.data_.set(key, observable);
|
|
4080
4109
|
|
|
@@ -4371,7 +4400,7 @@ var ObservableSet = /*#__PURE__*/function () {
|
|
|
4371
4400
|
}
|
|
4372
4401
|
|
|
4373
4402
|
if (name_ === void 0) {
|
|
4374
|
-
name_ =
|
|
4403
|
+
name_ = "ObservableSet@" + getNextId() ;
|
|
4375
4404
|
}
|
|
4376
4405
|
|
|
4377
4406
|
this.name_ = void 0;
|
|
@@ -4655,7 +4684,7 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
4655
4684
|
this.name_ = name_;
|
|
4656
4685
|
this.defaultAnnotation_ = defaultAnnotation_;
|
|
4657
4686
|
this.autoBind_ = autoBind_;
|
|
4658
|
-
this.keysAtom_ = new Atom(name_ + ".keys"); // Optimization: we use this frequently
|
|
4687
|
+
this.keysAtom_ = new Atom( this.name_ + ".keys" ); // Optimization: we use this frequently
|
|
4659
4688
|
|
|
4660
4689
|
this.isPlainObject_ = isPlainObject(this.target_);
|
|
4661
4690
|
|
|
@@ -4782,7 +4811,7 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
4782
4811
|
var entry = this.pendingKeys_.get(key);
|
|
4783
4812
|
|
|
4784
4813
|
if (!entry) {
|
|
4785
|
-
entry = new ObservableValue(key in this.target_, referenceEnhancer,
|
|
4814
|
+
entry = new ObservableValue(key in this.target_, referenceEnhancer, this.name_ + "." + stringifyKey(key) + "?" , false);
|
|
4786
4815
|
this.pendingKeys_.set(key, entry);
|
|
4787
4816
|
}
|
|
4788
4817
|
|
|
@@ -4842,7 +4871,7 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
4842
4871
|
var _this$target_$inferre;
|
|
4843
4872
|
|
|
4844
4873
|
// Inherited is fine - annotation cannot differ in subclass
|
|
4845
|
-
var annotation = (_this$target_$inferre = this.target_[inferredAnnotationsSymbol]) == null ? void 0 : _this$target_$inferre
|
|
4874
|
+
var annotation = (_this$target_$inferre = this.target_[inferredAnnotationsSymbol]) == null ? void 0 : _this$target_$inferre.get(key);
|
|
4846
4875
|
if (annotation) return annotation;
|
|
4847
4876
|
var current = this.target_;
|
|
4848
4877
|
|
|
@@ -4869,10 +4898,10 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
4869
4898
|
var closestProto = Object.getPrototypeOf(this.target_);
|
|
4870
4899
|
|
|
4871
4900
|
if (!hasProp(closestProto, inferredAnnotationsSymbol)) {
|
|
4872
|
-
addHiddenProp(closestProto, inferredAnnotationsSymbol,
|
|
4901
|
+
addHiddenProp(closestProto, inferredAnnotationsSymbol, new Map());
|
|
4873
4902
|
}
|
|
4874
4903
|
|
|
4875
|
-
closestProto[inferredAnnotationsSymbol]
|
|
4904
|
+
closestProto[inferredAnnotationsSymbol].set(key, annotation);
|
|
4876
4905
|
}
|
|
4877
4906
|
|
|
4878
4907
|
return annotation;
|
|
@@ -4980,7 +5009,7 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
4980
5009
|
defineProperty(this.target_, key, descriptor);
|
|
4981
5010
|
}
|
|
4982
5011
|
|
|
4983
|
-
var _observable = new ObservableValue(value, enhancer, this.name_ + "." +
|
|
5012
|
+
var _observable = new ObservableValue(value, enhancer, "development" !== "production" ? this.name_ + "." + key.toString() : "ObservableObject.key", false);
|
|
4984
5013
|
|
|
4985
5014
|
this.values_.set(key, _observable); // Notify (value possibly changed by ObservableValue)
|
|
4986
5015
|
|
|
@@ -5019,7 +5048,7 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
5019
5048
|
if (!change) return null;
|
|
5020
5049
|
}
|
|
5021
5050
|
|
|
5022
|
-
options.name || (options.name = this.name_ + "." +
|
|
5051
|
+
options.name || (options.name = "development" !== "production" ? this.name_ + "." + key.toString() : "ObservableObject.key");
|
|
5023
5052
|
options.context = this.proxy_ || this.target_;
|
|
5024
5053
|
var cachedDescriptor = getCachedObservablePropDescriptor(key);
|
|
5025
5054
|
var descriptor = {
|
|
@@ -5211,10 +5240,17 @@ function asObservableObject(target, options) {
|
|
|
5211
5240
|
die("Options can't be provided for already observable objects.");
|
|
5212
5241
|
}
|
|
5213
5242
|
|
|
5214
|
-
if (hasProp(target, $mobx))
|
|
5243
|
+
if (hasProp(target, $mobx)) {
|
|
5244
|
+
if ( !(getAdministration(target) instanceof ObservableObjectAdministration)) {
|
|
5245
|
+
die("Cannot convert '" + getDebugName(target) + "' into observable object:" + "\nThe target is already observable of different type." + "\nExtending builtins is not supported.");
|
|
5246
|
+
}
|
|
5247
|
+
|
|
5248
|
+
return target;
|
|
5249
|
+
}
|
|
5250
|
+
|
|
5215
5251
|
if ( !Object.isExtensible(target)) die("Cannot make the designated object observable; it is not extensible");
|
|
5216
|
-
var name = (_options$name = options == null ? void 0 : options.name) != null ? _options$name :
|
|
5217
|
-
var adm = new ObservableObjectAdministration(target, new Map(),
|
|
5252
|
+
var name = (_options$name = options == null ? void 0 : options.name) != null ? _options$name : (isPlainObject(target) ? "ObservableObject" : target.constructor.name) + "@" + getNextId() ;
|
|
5253
|
+
var adm = new ObservableObjectAdministration(target, new Map(), String(name), getAnnotationFromOptions(options), options == null ? void 0 : options.autoBind);
|
|
5218
5254
|
addHiddenProp(target, $mobx, adm);
|
|
5219
5255
|
return target;
|
|
5220
5256
|
}
|
|
@@ -5239,14 +5275,14 @@ function isObservableObject(thing) {
|
|
|
5239
5275
|
return false;
|
|
5240
5276
|
}
|
|
5241
5277
|
function recordAnnotationApplied(adm, annotation, key) {
|
|
5278
|
+
var _adm$target_$storedAn;
|
|
5279
|
+
|
|
5242
5280
|
{
|
|
5243
5281
|
adm.appliedAnnotations_[key] = annotation;
|
|
5244
5282
|
} // Remove applied decorator annotation so we don't try to apply it again in subclass constructor
|
|
5245
5283
|
|
|
5246
5284
|
|
|
5247
|
-
|
|
5248
|
-
delete adm.target_[storedAnnotationsSymbol][key];
|
|
5249
|
-
}
|
|
5285
|
+
(_adm$target_$storedAn = adm.target_[storedAnnotationsSymbol]) == null ? true : delete _adm$target_$storedAn[key];
|
|
5250
5286
|
}
|
|
5251
5287
|
|
|
5252
5288
|
function assertAnnotable(adm, annotation, key) {
|
|
@@ -5326,7 +5362,7 @@ var LegacyObservableArray = /*#__PURE__*/function (_StubArray) {
|
|
|
5326
5362
|
var _this;
|
|
5327
5363
|
|
|
5328
5364
|
if (name === void 0) {
|
|
5329
|
-
name =
|
|
5365
|
+
name = "ObservableArray@" + getNextId() ;
|
|
5330
5366
|
}
|
|
5331
5367
|
|
|
5332
5368
|
if (owned === void 0) {
|
|
@@ -5485,7 +5521,17 @@ function getAdministration(thing, property) {
|
|
|
5485
5521
|
}
|
|
5486
5522
|
function getDebugName(thing, property) {
|
|
5487
5523
|
var named;
|
|
5488
|
-
|
|
5524
|
+
|
|
5525
|
+
if (property !== undefined) {
|
|
5526
|
+
named = getAtom(thing, property);
|
|
5527
|
+
} else if (isAction(thing)) {
|
|
5528
|
+
return thing.name;
|
|
5529
|
+
} else if (isObservableObject(thing) || isObservableMap(thing) || isObservableSet(thing)) {
|
|
5530
|
+
named = getAdministration(thing);
|
|
5531
|
+
} else {
|
|
5532
|
+
// valid for arrays as well
|
|
5533
|
+
named = getAtom(thing);
|
|
5534
|
+
}
|
|
5489
5535
|
|
|
5490
5536
|
return named.name_;
|
|
5491
5537
|
}
|