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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# mobx
|
|
2
2
|
|
|
3
|
+
## 6.1.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`ca4914f9`](https://github.com/mobxjs/mobx/commit/ca4914f978aef427e7b2223328fd66b82e522d89) [#2836](https://github.com/mobxjs/mobx/pull/2836) Thanks [@urugator](https://github.com/urugator)! - Fix [#2832](https://github.com/mobxjs/mobx/issues/2832) - annotation cache ignores overrides
|
|
8
|
+
|
|
9
|
+
## 6.1.7
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`5640aa77`](https://github.com/mobxjs/mobx/commit/5640aa7794420a5fc2f99ac0819de11696d6ba71) [#2799](https://github.com/mobxjs/mobx/pull/2799) Thanks [@urugator](https://github.com/urugator)! - - fix: user provided debug names are not preserved on production
|
|
14
|
+
- fix: property atom's debug name is dynamic on production
|
|
15
|
+
- fix: `observable(primitive, options)` ignores `options`
|
|
16
|
+
- fix: `getDebugName(action)` throws `[MobX] Cannot obtain atom from undefined`
|
|
17
|
+
- [fix: terser using `unsafe: true`](https://github.com/mobxjs/mobx/issues/2751#issuecomment-778171773)
|
|
18
|
+
|
|
19
|
+
## 6.1.6
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- [`9b195b17`](https://github.com/mobxjs/mobx/commit/9b195b17bd661b9c0c4ab3a8ef323e23c2f118e4) [#2780](https://github.com/mobxjs/mobx/pull/2780) Thanks [@iChenLei](https://github.com/iChenLei)! - The overall memory usage of MobX has been reduced in production builds by skipping the generation of debug identifiers. The internal `mapid_` field of Reaction has been removed as part of the change.
|
|
24
|
+
|
|
25
|
+
## 6.1.5
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- [`3979bee3`](https://github.com/mobxjs/mobx/commit/3979bee36c82d342050978834197ea15a7ddbbf8) [#2773](https://github.com/mobxjs/mobx/pull/2773) Thanks [@urugator](https://github.com/urugator)! - Decorators optimization
|
|
30
|
+
|
|
31
|
+
* [`7820e5ea`](https://github.com/mobxjs/mobx/commit/7820e5eae0c9dcdfa1e69cf92e0bfa209b2b478b) [#2769](https://github.com/mobxjs/mobx/pull/2769) Thanks [@iChenLei](https://github.com/iChenLei)! - add warn for extending builtins
|
|
32
|
+
|
|
33
|
+
- [`a7c15171`](https://github.com/mobxjs/mobx/commit/a7c1517133915c2891e92a865fe5475627b6b89f) [#2775](https://github.com/mobxjs/mobx/pull/2775) Thanks [@pkit](https://github.com/pkit)! - use globalThis in global detection
|
|
34
|
+
|
|
35
|
+
* [`5d41b646`](https://github.com/mobxjs/mobx/commit/5d41b6462cf609df869a088e353bc485846c88f8) [#2774](https://github.com/mobxjs/mobx/pull/2774) Thanks [@urugator](https://github.com/urugator)! - Fix: `makeAutoObservable` now working properly with symbolic keys
|
|
36
|
+
Fix: `isComputedProp` and `getAtom` second arg type is incompatible with Symbols
|
|
37
|
+
|
|
3
38
|
## 6.1.4
|
|
4
39
|
|
|
5
40
|
### Patch Changes
|
package/dist/api/annotation.d.ts
CHANGED
|
@@ -4,7 +4,6 @@ export declare type Annotation = {
|
|
|
4
4
|
make_(adm: ObservableObjectAdministration, key: PropertyKey): void;
|
|
5
5
|
extend_(adm: ObservableObjectAdministration, key: PropertyKey, descriptor: PropertyDescriptor, proxyTrap: boolean): boolean | null;
|
|
6
6
|
options_?: any;
|
|
7
|
-
isDecorator_?: boolean;
|
|
8
7
|
};
|
|
9
8
|
export declare type AnnotationMapEntry = Annotation | true | false;
|
|
10
9
|
export declare type AnnotationsMap<T, AdditionalFields extends PropertyKey> = {
|
package/dist/api/iscomputed.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare function _isComputed(value: any, property?:
|
|
1
|
+
export declare function _isComputed(value: any, property?: PropertyKey): boolean;
|
|
2
2
|
export declare function isComputed(value: any): boolean;
|
|
3
|
-
export declare function isComputedProp(value: any, propName:
|
|
3
|
+
export declare function isComputedProp(value: any, propName: PropertyKey): boolean;
|
|
@@ -52,7 +52,6 @@ export declare class ComputedValue<T> implements IObservable, IComputedValue<T>,
|
|
|
52
52
|
lastAccessedBy_: number;
|
|
53
53
|
lowestObserverState_: IDerivationState_;
|
|
54
54
|
unboundDepsCount_: number;
|
|
55
|
-
mapid_: string;
|
|
56
55
|
protected value_: T | undefined | CaughtException;
|
|
57
56
|
name_: string;
|
|
58
57
|
triggeredBy_?: string;
|
package/dist/core/reaction.d.ts
CHANGED
|
@@ -80,6 +80,10 @@ function die(error) {
|
|
|
80
80
|
|
|
81
81
|
var mockGlobal = {};
|
|
82
82
|
function getGlobal() {
|
|
83
|
+
if (typeof globalThis !== "undefined") {
|
|
84
|
+
return globalThis;
|
|
85
|
+
}
|
|
86
|
+
|
|
83
87
|
if (typeof window !== "undefined") {
|
|
84
88
|
return window;
|
|
85
89
|
}
|
|
@@ -361,9 +365,7 @@ function storeAnnotation(prototype, key, annotation) {
|
|
|
361
365
|
assertNotDecorated(prototype, annotation, key); // Ignore override
|
|
362
366
|
|
|
363
367
|
if (!isOverride(annotation)) {
|
|
364
|
-
prototype[storedAnnotationsSymbol][key] =
|
|
365
|
-
isDecorator_: true
|
|
366
|
-
});
|
|
368
|
+
prototype[storedAnnotationsSymbol][key] = annotation;
|
|
367
369
|
}
|
|
368
370
|
}
|
|
369
371
|
|
|
@@ -403,7 +405,7 @@ var Atom = /*#__PURE__*/function () {
|
|
|
403
405
|
*/
|
|
404
406
|
function Atom(name_) {
|
|
405
407
|
if (name_ === void 0) {
|
|
406
|
-
name_ =
|
|
408
|
+
name_ = "Atom@" + getNextId() ;
|
|
407
409
|
}
|
|
408
410
|
|
|
409
411
|
this.name_ = void 0;
|
|
@@ -593,7 +595,7 @@ function createActionAnnotation(name, options) {
|
|
|
593
595
|
}
|
|
594
596
|
|
|
595
597
|
function make_$1(adm, key) {
|
|
596
|
-
var _this$options_$bound, _this$options_;
|
|
598
|
+
var _this$options_$bound, _this$options_, _adm$target_$storedAn;
|
|
597
599
|
|
|
598
600
|
var annotated = false;
|
|
599
601
|
var source = adm.target_;
|
|
@@ -643,7 +645,7 @@ function make_$1(adm, key) {
|
|
|
643
645
|
|
|
644
646
|
if (annotated) {
|
|
645
647
|
recordAnnotationApplied(adm, this, key);
|
|
646
|
-
} else if (!
|
|
648
|
+
} else if (!((_adm$target_$storedAn = adm.target_[storedAnnotationsSymbol]) == null ? void 0 : _adm$target_$storedAn[key])) {
|
|
647
649
|
// Throw on missing key, except for decorators:
|
|
648
650
|
// Decorator annotations are collected from whole prototype chain.
|
|
649
651
|
// When called from super() some props may not exist yet.
|
|
@@ -707,6 +709,8 @@ function createFlowAnnotation(name, options) {
|
|
|
707
709
|
}
|
|
708
710
|
|
|
709
711
|
function make_$2(adm, key) {
|
|
712
|
+
var _adm$target_$storedAn;
|
|
713
|
+
|
|
710
714
|
var annotated = false;
|
|
711
715
|
var source = adm.target_;
|
|
712
716
|
|
|
@@ -744,7 +748,7 @@ function make_$2(adm, key) {
|
|
|
744
748
|
|
|
745
749
|
if (annotated) {
|
|
746
750
|
recordAnnotationApplied(adm, this, key);
|
|
747
|
-
} else if (!
|
|
751
|
+
} else if (!((_adm$target_$storedAn = adm.target_[storedAnnotationsSymbol]) == null ? void 0 : _adm$target_$storedAn[key])) {
|
|
748
752
|
// Throw on missing key, except for decorators:
|
|
749
753
|
// Decorator annotations are collected from whole prototype chain.
|
|
750
754
|
// When called from super() some props may not exist yet.
|
|
@@ -798,6 +802,8 @@ function createComputedAnnotation(name, options) {
|
|
|
798
802
|
}
|
|
799
803
|
|
|
800
804
|
function make_$3(adm, key) {
|
|
805
|
+
var _adm$target_$storedAn;
|
|
806
|
+
|
|
801
807
|
var source = adm.target_;
|
|
802
808
|
|
|
803
809
|
while (source && source !== objectPrototype) {
|
|
@@ -822,7 +828,7 @@ function make_$3(adm, key) {
|
|
|
822
828
|
source = Object.getPrototypeOf(source);
|
|
823
829
|
}
|
|
824
830
|
|
|
825
|
-
if (!
|
|
831
|
+
if (!((_adm$target_$storedAn = adm.target_[storedAnnotationsSymbol]) == null ? void 0 : _adm$target_$storedAn[key])) {
|
|
826
832
|
// Throw on missing key, except for decorators:
|
|
827
833
|
// Decorator annotations are collected from whole prototype chain.
|
|
828
834
|
// When called from super() some props may not exist yet.
|
|
@@ -859,6 +865,8 @@ function createObservableAnnotation(name, options) {
|
|
|
859
865
|
}
|
|
860
866
|
|
|
861
867
|
function make_$4(adm, key) {
|
|
868
|
+
var _adm$target_$storedAn;
|
|
869
|
+
|
|
862
870
|
var source = adm.target_; // Copy props from proto as well, see test:
|
|
863
871
|
// "decorate should work with Object.create"
|
|
864
872
|
|
|
@@ -883,7 +891,7 @@ function make_$4(adm, key) {
|
|
|
883
891
|
source = Object.getPrototypeOf(source);
|
|
884
892
|
}
|
|
885
893
|
|
|
886
|
-
if (!
|
|
894
|
+
if (!((_adm$target_$storedAn = adm.target_[storedAnnotationsSymbol]) == null ? void 0 : _adm$target_$storedAn[key])) {
|
|
887
895
|
// Throw on missing key, except for decorators:
|
|
888
896
|
// Decorator annotations are collected from whole prototype chain.
|
|
889
897
|
// When called from super() some props may not exist yet.
|
|
@@ -967,7 +975,7 @@ function createObservable(v, arg2, arg3) {
|
|
|
967
975
|
|
|
968
976
|
if (typeof v === "object" && v !== null) return v; // anything else
|
|
969
977
|
|
|
970
|
-
return observable.box(v);
|
|
978
|
+
return observable.box(v, arg2);
|
|
971
979
|
}
|
|
972
980
|
|
|
973
981
|
Object.assign(createObservable, observableDecoratorAnnotation);
|
|
@@ -1029,7 +1037,7 @@ var computed = function computed(arg1, arg2) {
|
|
|
1029
1037
|
|
|
1030
1038
|
var opts = isPlainObject(arg2) ? arg2 : {};
|
|
1031
1039
|
opts.get = arg1;
|
|
1032
|
-
opts.name
|
|
1040
|
+
opts.name || (opts.name = arg1.name || "");
|
|
1033
1041
|
/* for generated name */
|
|
1034
1042
|
|
|
1035
1043
|
return new ComputedValue(opts);
|
|
@@ -1177,7 +1185,7 @@ var ObservableValue = /*#__PURE__*/function (_Atom) {
|
|
|
1177
1185
|
var _this;
|
|
1178
1186
|
|
|
1179
1187
|
if (name_ === void 0) {
|
|
1180
|
-
name_ =
|
|
1188
|
+
name_ = "ObservableValue@" + getNextId() ;
|
|
1181
1189
|
}
|
|
1182
1190
|
|
|
1183
1191
|
if (notifySpy === void 0) {
|
|
@@ -1377,7 +1385,6 @@ var ComputedValue = /*#__PURE__*/function () {
|
|
|
1377
1385
|
this.lastAccessedBy_ = 0;
|
|
1378
1386
|
this.lowestObserverState_ = IDerivationState_.UP_TO_DATE_;
|
|
1379
1387
|
this.unboundDepsCount_ = 0;
|
|
1380
|
-
this.mapid_ = "#" + getNextId();
|
|
1381
1388
|
this.value_ = new CaughtException(null);
|
|
1382
1389
|
this.name_ = void 0;
|
|
1383
1390
|
this.triggeredBy_ = void 0;
|
|
@@ -1394,8 +1401,12 @@ var ComputedValue = /*#__PURE__*/function () {
|
|
|
1394
1401
|
this.onBUOL = void 0;
|
|
1395
1402
|
if (!options.get) die(31);
|
|
1396
1403
|
this.derivation = options.get;
|
|
1397
|
-
this.name_ = options.name || "ComputedValue@" + getNextId();
|
|
1398
|
-
|
|
1404
|
+
this.name_ = options.name || ( "ComputedValue@" + getNextId() );
|
|
1405
|
+
|
|
1406
|
+
if (options.set) {
|
|
1407
|
+
this.setter_ = createAction( this.name_ + "-setter" , options.set);
|
|
1408
|
+
}
|
|
1409
|
+
|
|
1399
1410
|
this.equals_ = options.equals || (options.compareStructural || options.struct ? comparer.structural : comparer["default"]);
|
|
1400
1411
|
this.scope_ = options.context;
|
|
1401
1412
|
this.requiresReaction_ = !!options.requiresReaction;
|
|
@@ -2166,7 +2177,7 @@ var Reaction = /*#__PURE__*/function () {
|
|
|
2166
2177
|
// nodes we are looking at. Our value depends on these nodes
|
|
2167
2178
|
function Reaction(name_, onInvalidate_, errorHandler_, requiresObservable_) {
|
|
2168
2179
|
if (name_ === void 0) {
|
|
2169
|
-
name_ =
|
|
2180
|
+
name_ = "Reaction@" + getNextId() ;
|
|
2170
2181
|
}
|
|
2171
2182
|
|
|
2172
2183
|
if (requiresObservable_ === void 0) {
|
|
@@ -2183,7 +2194,6 @@ var Reaction = /*#__PURE__*/function () {
|
|
|
2183
2194
|
this.diffValue_ = 0;
|
|
2184
2195
|
this.runId_ = 0;
|
|
2185
2196
|
this.unboundDepsCount_ = 0;
|
|
2186
|
-
this.mapid_ = "#" + getNextId();
|
|
2187
2197
|
this.isDisposed_ = false;
|
|
2188
2198
|
this.isScheduled_ = false;
|
|
2189
2199
|
this.isTrackPending_ = false;
|
|
@@ -2516,6 +2526,8 @@ function isAction(thing) {
|
|
|
2516
2526
|
*/
|
|
2517
2527
|
|
|
2518
2528
|
function autorun(view, opts) {
|
|
2529
|
+
var _opts$name, _opts;
|
|
2530
|
+
|
|
2519
2531
|
if (opts === void 0) {
|
|
2520
2532
|
opts = EMPTY_OBJECT;
|
|
2521
2533
|
}
|
|
@@ -2525,7 +2537,7 @@ function autorun(view, opts) {
|
|
|
2525
2537
|
if (isAction(view)) die("Autorun does not accept actions since actions are untrackable");
|
|
2526
2538
|
}
|
|
2527
2539
|
|
|
2528
|
-
var name = opts
|
|
2540
|
+
var name = (_opts$name = (_opts = opts) == null ? void 0 : _opts.name) != null ? _opts$name : view.name || "Autorun@" + getNextId() ;
|
|
2529
2541
|
var runSync = !opts.scheduler && !opts.delay;
|
|
2530
2542
|
var reaction;
|
|
2531
2543
|
|
|
@@ -2568,6 +2580,8 @@ function createSchedulerFromOptions(opts) {
|
|
|
2568
2580
|
}
|
|
2569
2581
|
|
|
2570
2582
|
function reaction(expression, effect, opts) {
|
|
2583
|
+
var _opts$name2;
|
|
2584
|
+
|
|
2571
2585
|
if (opts === void 0) {
|
|
2572
2586
|
opts = EMPTY_OBJECT;
|
|
2573
2587
|
}
|
|
@@ -2577,7 +2591,7 @@ function reaction(expression, effect, opts) {
|
|
|
2577
2591
|
if (!isPlainObject(opts)) die("Third argument of reactions should be an object");
|
|
2578
2592
|
}
|
|
2579
2593
|
|
|
2580
|
-
var name = opts.name
|
|
2594
|
+
var name = (_opts$name2 = opts.name) != null ? _opts$name2 : "Reaction@" + getNextId() ;
|
|
2581
2595
|
var effectAction = action(name, opts.onError ? wrapErrorHandler(opts.onError, effect) : effect);
|
|
2582
2596
|
var runSync = !opts.scheduler && !opts.delay;
|
|
2583
2597
|
var scheduler = createSchedulerFromOptions(opts);
|
|
@@ -3214,8 +3228,8 @@ function _when(predicate, effect, opts) {
|
|
|
3214
3228
|
}, opts.timeout);
|
|
3215
3229
|
}
|
|
3216
3230
|
|
|
3217
|
-
opts.name =
|
|
3218
|
-
var effectAction = createAction(opts.name + "-effect", effect); // eslint-disable-next-line
|
|
3231
|
+
opts.name = opts.name || "When@" + getNextId() ;
|
|
3232
|
+
var effectAction = createAction( opts.name + "-effect" , effect); // eslint-disable-next-line
|
|
3219
3233
|
|
|
3220
3234
|
var disposer = autorun(function (r) {
|
|
3221
3235
|
// predicate should not change state
|
|
@@ -3399,9 +3413,20 @@ function makeAutoObservable(target, overrides, options) {
|
|
|
3399
3413
|
startBatch();
|
|
3400
3414
|
|
|
3401
3415
|
try {
|
|
3416
|
+
// Use cached inferred annotations if available (only in classes)
|
|
3402
3417
|
if (target[inferredAnnotationsSymbol]) {
|
|
3403
|
-
|
|
3404
|
-
adm.make_(key,
|
|
3418
|
+
target[inferredAnnotationsSymbol].forEach(function (value, key) {
|
|
3419
|
+
return adm.make_(key, value);
|
|
3420
|
+
}); // Overrides are not cached, unless `true`, see #2832
|
|
3421
|
+
|
|
3422
|
+
if (overrides) {
|
|
3423
|
+
ownKeys(overrides).forEach(function (key) {
|
|
3424
|
+
var annotation = overrides[key];
|
|
3425
|
+
|
|
3426
|
+
if (annotation !== true) {
|
|
3427
|
+
adm.make_(key, annotation);
|
|
3428
|
+
}
|
|
3429
|
+
});
|
|
3405
3430
|
}
|
|
3406
3431
|
} else {
|
|
3407
3432
|
var _ignoreKeys;
|
|
@@ -3472,6 +3497,10 @@ var arrayTraps = {
|
|
|
3472
3497
|
var ObservableArrayAdministration = /*#__PURE__*/function () {
|
|
3473
3498
|
// this is the prop that gets proxied, so can't replace it!
|
|
3474
3499
|
function ObservableArrayAdministration(name, enhancer, owned_, legacyMode_) {
|
|
3500
|
+
if (name === void 0) {
|
|
3501
|
+
name = "ObservableArray@" + getNextId() ;
|
|
3502
|
+
}
|
|
3503
|
+
|
|
3475
3504
|
this.owned_ = void 0;
|
|
3476
3505
|
this.legacyMode_ = void 0;
|
|
3477
3506
|
this.atom_ = void 0;
|
|
@@ -3484,10 +3513,10 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
|
|
|
3484
3513
|
this.lastKnownLength_ = 0;
|
|
3485
3514
|
this.owned_ = owned_;
|
|
3486
3515
|
this.legacyMode_ = legacyMode_;
|
|
3487
|
-
this.atom_ = new Atom(name
|
|
3516
|
+
this.atom_ = new Atom(name);
|
|
3488
3517
|
|
|
3489
3518
|
this.enhancer_ = function (newV, oldV) {
|
|
3490
|
-
return enhancer(newV, oldV,
|
|
3519
|
+
return enhancer(newV, oldV, name + "[..]" );
|
|
3491
3520
|
};
|
|
3492
3521
|
}
|
|
3493
3522
|
|
|
@@ -3702,7 +3731,7 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
|
|
|
3702
3731
|
}();
|
|
3703
3732
|
function createObservableArray(initialValues, enhancer, name, owned) {
|
|
3704
3733
|
if (name === void 0) {
|
|
3705
|
-
name =
|
|
3734
|
+
name = "ObservableArray@" + getNextId() ;
|
|
3706
3735
|
}
|
|
3707
3736
|
|
|
3708
3737
|
if (owned === void 0) {
|
|
@@ -3924,7 +3953,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
3924
3953
|
}
|
|
3925
3954
|
|
|
3926
3955
|
if (name_ === void 0) {
|
|
3927
|
-
name_ =
|
|
3956
|
+
name_ = "ObservableMap@" + getNextId() ;
|
|
3928
3957
|
}
|
|
3929
3958
|
|
|
3930
3959
|
this.enhancer_ = void 0;
|
|
@@ -3943,7 +3972,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
3943
3972
|
die(18);
|
|
3944
3973
|
}
|
|
3945
3974
|
|
|
3946
|
-
this.keysAtom_ = createAtom(this.name_ + ".keys()");
|
|
3975
|
+
this.keysAtom_ = createAtom( this.name_ + ".keys()" );
|
|
3947
3976
|
this.data_ = new Map();
|
|
3948
3977
|
this.hasMap_ = new Map();
|
|
3949
3978
|
this.merge(initialData);
|
|
@@ -3962,7 +3991,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
3962
3991
|
var entry = this.hasMap_.get(key);
|
|
3963
3992
|
|
|
3964
3993
|
if (!entry) {
|
|
3965
|
-
var newEntry = entry = new ObservableValue(this.has_(key), referenceEnhancer,
|
|
3994
|
+
var newEntry = entry = new ObservableValue(this.has_(key), referenceEnhancer, this.name_ + "." + stringifyKey(key) + "?" , false);
|
|
3966
3995
|
this.hasMap_.set(key, newEntry);
|
|
3967
3996
|
onBecomeUnobserved(newEntry, function () {
|
|
3968
3997
|
return _this.hasMap_["delete"](key);
|
|
@@ -4078,7 +4107,7 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4078
4107
|
|
|
4079
4108
|
checkIfStateModificationsAreAllowed(this.keysAtom_);
|
|
4080
4109
|
transaction(function () {
|
|
4081
|
-
var observable = new ObservableValue(newValue, _this3.enhancer_,
|
|
4110
|
+
var observable = new ObservableValue(newValue, _this3.enhancer_, _this3.name_ + "." + stringifyKey(key) , false);
|
|
4082
4111
|
|
|
4083
4112
|
_this3.data_.set(key, observable);
|
|
4084
4113
|
|
|
@@ -4375,7 +4404,7 @@ var ObservableSet = /*#__PURE__*/function () {
|
|
|
4375
4404
|
}
|
|
4376
4405
|
|
|
4377
4406
|
if (name_ === void 0) {
|
|
4378
|
-
name_ =
|
|
4407
|
+
name_ = "ObservableSet@" + getNextId() ;
|
|
4379
4408
|
}
|
|
4380
4409
|
|
|
4381
4410
|
this.name_ = void 0;
|
|
@@ -4659,7 +4688,7 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
4659
4688
|
this.name_ = name_;
|
|
4660
4689
|
this.defaultAnnotation_ = defaultAnnotation_;
|
|
4661
4690
|
this.autoBind_ = autoBind_;
|
|
4662
|
-
this.keysAtom_ = new Atom(name_ + ".keys"); // Optimization: we use this frequently
|
|
4691
|
+
this.keysAtom_ = new Atom( this.name_ + ".keys" ); // Optimization: we use this frequently
|
|
4663
4692
|
|
|
4664
4693
|
this.isPlainObject_ = isPlainObject(this.target_);
|
|
4665
4694
|
|
|
@@ -4786,7 +4815,7 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
4786
4815
|
var entry = this.pendingKeys_.get(key);
|
|
4787
4816
|
|
|
4788
4817
|
if (!entry) {
|
|
4789
|
-
entry = new ObservableValue(key in this.target_, referenceEnhancer,
|
|
4818
|
+
entry = new ObservableValue(key in this.target_, referenceEnhancer, this.name_ + "." + stringifyKey(key) + "?" , false);
|
|
4790
4819
|
this.pendingKeys_.set(key, entry);
|
|
4791
4820
|
}
|
|
4792
4821
|
|
|
@@ -4846,7 +4875,7 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
4846
4875
|
var _this$target_$inferre;
|
|
4847
4876
|
|
|
4848
4877
|
// Inherited is fine - annotation cannot differ in subclass
|
|
4849
|
-
var annotation = (_this$target_$inferre = this.target_[inferredAnnotationsSymbol]) == null ? void 0 : _this$target_$inferre
|
|
4878
|
+
var annotation = (_this$target_$inferre = this.target_[inferredAnnotationsSymbol]) == null ? void 0 : _this$target_$inferre.get(key);
|
|
4850
4879
|
if (annotation) return annotation;
|
|
4851
4880
|
var current = this.target_;
|
|
4852
4881
|
|
|
@@ -4873,10 +4902,10 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
4873
4902
|
var closestProto = Object.getPrototypeOf(this.target_);
|
|
4874
4903
|
|
|
4875
4904
|
if (!hasProp(closestProto, inferredAnnotationsSymbol)) {
|
|
4876
|
-
addHiddenProp(closestProto, inferredAnnotationsSymbol,
|
|
4905
|
+
addHiddenProp(closestProto, inferredAnnotationsSymbol, new Map());
|
|
4877
4906
|
}
|
|
4878
4907
|
|
|
4879
|
-
closestProto[inferredAnnotationsSymbol]
|
|
4908
|
+
closestProto[inferredAnnotationsSymbol].set(key, annotation);
|
|
4880
4909
|
}
|
|
4881
4910
|
|
|
4882
4911
|
return annotation;
|
|
@@ -4984,7 +5013,7 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
4984
5013
|
defineProperty(this.target_, key, descriptor);
|
|
4985
5014
|
}
|
|
4986
5015
|
|
|
4987
|
-
var _observable = new ObservableValue(value, enhancer, this.name_ + "." +
|
|
5016
|
+
var _observable = new ObservableValue(value, enhancer, "development" !== "production" ? this.name_ + "." + key.toString() : "ObservableObject.key", false);
|
|
4988
5017
|
|
|
4989
5018
|
this.values_.set(key, _observable); // Notify (value possibly changed by ObservableValue)
|
|
4990
5019
|
|
|
@@ -5023,7 +5052,7 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
5023
5052
|
if (!change) return null;
|
|
5024
5053
|
}
|
|
5025
5054
|
|
|
5026
|
-
options.name || (options.name = this.name_ + "." +
|
|
5055
|
+
options.name || (options.name = "development" !== "production" ? this.name_ + "." + key.toString() : "ObservableObject.key");
|
|
5027
5056
|
options.context = this.proxy_ || this.target_;
|
|
5028
5057
|
var cachedDescriptor = getCachedObservablePropDescriptor(key);
|
|
5029
5058
|
var descriptor = {
|
|
@@ -5215,10 +5244,17 @@ function asObservableObject(target, options) {
|
|
|
5215
5244
|
die("Options can't be provided for already observable objects.");
|
|
5216
5245
|
}
|
|
5217
5246
|
|
|
5218
|
-
if (hasProp(target, $mobx))
|
|
5247
|
+
if (hasProp(target, $mobx)) {
|
|
5248
|
+
if ( !(getAdministration(target) instanceof ObservableObjectAdministration)) {
|
|
5249
|
+
die("Cannot convert '" + getDebugName(target) + "' into observable object:" + "\nThe target is already observable of different type." + "\nExtending builtins is not supported.");
|
|
5250
|
+
}
|
|
5251
|
+
|
|
5252
|
+
return target;
|
|
5253
|
+
}
|
|
5254
|
+
|
|
5219
5255
|
if ( !Object.isExtensible(target)) die("Cannot make the designated object observable; it is not extensible");
|
|
5220
|
-
var name = (_options$name = options == null ? void 0 : options.name) != null ? _options$name :
|
|
5221
|
-
var adm = new ObservableObjectAdministration(target, new Map(),
|
|
5256
|
+
var name = (_options$name = options == null ? void 0 : options.name) != null ? _options$name : (isPlainObject(target) ? "ObservableObject" : target.constructor.name) + "@" + getNextId() ;
|
|
5257
|
+
var adm = new ObservableObjectAdministration(target, new Map(), String(name), getAnnotationFromOptions(options), options == null ? void 0 : options.autoBind);
|
|
5222
5258
|
addHiddenProp(target, $mobx, adm);
|
|
5223
5259
|
return target;
|
|
5224
5260
|
}
|
|
@@ -5243,14 +5279,14 @@ function isObservableObject(thing) {
|
|
|
5243
5279
|
return false;
|
|
5244
5280
|
}
|
|
5245
5281
|
function recordAnnotationApplied(adm, annotation, key) {
|
|
5282
|
+
var _adm$target_$storedAn;
|
|
5283
|
+
|
|
5246
5284
|
{
|
|
5247
5285
|
adm.appliedAnnotations_[key] = annotation;
|
|
5248
5286
|
} // Remove applied decorator annotation so we don't try to apply it again in subclass constructor
|
|
5249
5287
|
|
|
5250
5288
|
|
|
5251
|
-
|
|
5252
|
-
delete adm.target_[storedAnnotationsSymbol][key];
|
|
5253
|
-
}
|
|
5289
|
+
(_adm$target_$storedAn = adm.target_[storedAnnotationsSymbol]) == null ? true : delete _adm$target_$storedAn[key];
|
|
5254
5290
|
}
|
|
5255
5291
|
|
|
5256
5292
|
function assertAnnotable(adm, annotation, key) {
|
|
@@ -5330,7 +5366,7 @@ var LegacyObservableArray = /*#__PURE__*/function (_StubArray) {
|
|
|
5330
5366
|
var _this;
|
|
5331
5367
|
|
|
5332
5368
|
if (name === void 0) {
|
|
5333
|
-
name =
|
|
5369
|
+
name = "ObservableArray@" + getNextId() ;
|
|
5334
5370
|
}
|
|
5335
5371
|
|
|
5336
5372
|
if (owned === void 0) {
|
|
@@ -5489,7 +5525,17 @@ function getAdministration(thing, property) {
|
|
|
5489
5525
|
}
|
|
5490
5526
|
function getDebugName(thing, property) {
|
|
5491
5527
|
var named;
|
|
5492
|
-
|
|
5528
|
+
|
|
5529
|
+
if (property !== undefined) {
|
|
5530
|
+
named = getAtom(thing, property);
|
|
5531
|
+
} else if (isAction(thing)) {
|
|
5532
|
+
return thing.name;
|
|
5533
|
+
} else if (isObservableObject(thing) || isObservableMap(thing) || isObservableSet(thing)) {
|
|
5534
|
+
named = getAdministration(thing);
|
|
5535
|
+
} else {
|
|
5536
|
+
// valid for arrays as well
|
|
5537
|
+
named = getAtom(thing);
|
|
5538
|
+
}
|
|
5493
5539
|
|
|
5494
5540
|
return named.name_;
|
|
5495
5541
|
}
|