mobx 6.10.1 → 6.11.0-pre
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 +6 -0
- package/dist/api/action.d.ts +16 -15
- package/dist/api/annotation.d.ts +19 -18
- package/dist/api/autorun.d.ts +25 -25
- package/dist/api/become-observed.d.ts +5 -5
- package/dist/api/computed.d.ts +14 -13
- package/dist/api/configure.d.ts +17 -17
- package/dist/api/decorators.d.ts +20 -17
- package/dist/api/extendobservable.d.ts +2 -2
- package/dist/api/extras.d.ts +10 -10
- package/dist/api/flow.d.ts +19 -18
- package/dist/api/intercept-read.d.ts +8 -8
- package/dist/api/intercept.d.ts +8 -8
- package/dist/api/iscomputed.d.ts +3 -3
- package/dist/api/isobservable.d.ts +2 -2
- package/dist/api/makeObservable.d.ts +6 -6
- package/dist/api/object-api.d.ts +36 -36
- package/dist/api/observable.d.ts +45 -44
- package/dist/api/observe.d.ts +8 -8
- package/dist/api/tojs.d.ts +7 -7
- package/dist/api/trace.d.ts +3 -3
- package/dist/api/transaction.d.ts +8 -8
- package/dist/api/when.d.ts +11 -11
- package/dist/core/action.d.ts +20 -20
- package/dist/core/atom.d.ts +37 -37
- package/dist/core/computedvalue.d.ts +99 -99
- package/dist/core/derivation.d.ts +73 -73
- package/dist/core/globalstate.d.ts +121 -121
- package/dist/core/observable.d.ts +45 -45
- package/dist/core/reaction.d.ts +62 -62
- package/dist/core/spy.d.ts +37 -37
- package/dist/errors.d.ts +42 -42
- package/dist/internal.d.ts +54 -54
- package/dist/mobx.cjs.development.js +428 -260
- 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.d.ts +2 -2
- package/dist/mobx.esm.development.js +428 -260
- package/dist/mobx.esm.development.js.map +1 -1
- package/dist/mobx.esm.js +428 -260
- 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 +428 -260
- 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/actionannotation.d.ts +8 -8
- package/dist/types/autoannotation.d.ts +3 -3
- package/dist/types/computedannotation.d.ts +2 -2
- package/dist/types/decorator_fills.d.ts +6 -0
- package/dist/types/dynamicobject.d.ts +2 -2
- package/dist/types/flowannotation.d.ts +2 -2
- package/dist/types/generic-abort-signal.d.ts +6 -6
- package/dist/types/intercept-utils.d.ts +8 -8
- package/dist/types/legacyobservablearray.d.ts +14 -3
- package/dist/types/listen-utils.d.ts +7 -7
- package/dist/types/modifiers.d.ts +7 -7
- package/dist/types/observableannotation.d.ts +2 -2
- package/dist/types/observablearray.d.ts +85 -85
- package/dist/types/observablemap.d.ts +78 -78
- package/dist/types/observableobject.d.ts +99 -98
- package/dist/types/observableset.d.ts +53 -53
- package/dist/types/observablevalue.d.ts +49 -49
- package/dist/types/overrideannotation.d.ts +4 -3
- package/dist/types/type-utils.d.ts +11 -11
- package/dist/utils/comparer.d.ts +14 -14
- package/dist/utils/eq.d.ts +1 -1
- package/dist/utils/global.d.ts +1 -1
- package/dist/utils/iterable.d.ts +1 -1
- package/dist/utils/utils.d.ts +45 -45
- package/package.json +1 -1
- package/src/api/action.ts +21 -4
- package/src/api/annotation.ts +1 -0
- package/src/api/computed.ts +11 -4
- package/src/api/decorators.ts +29 -8
- package/src/api/flow.ts +10 -3
- package/src/api/observable.ts +19 -6
- package/src/core/atom.ts +9 -11
- package/src/types/actionannotation.ts +48 -2
- package/src/types/autoannotation.ts +8 -2
- package/src/types/computedannotation.ts +39 -2
- package/src/types/decorator_fills.ts +33 -0
- package/src/types/flowannotation.ts +28 -2
- package/src/types/legacyobservablearray.ts +1 -1
- package/src/types/observableannotation.ts +75 -2
- package/src/types/observableobject.ts +16 -0
- package/src/types/overrideannotation.ts +15 -7
package/dist/mobx.esm.js
CHANGED
|
@@ -3,16 +3,16 @@ var niceErrors = {
|
|
|
3
3
|
1: function _(annotationType, key) {
|
|
4
4
|
return "Cannot apply '" + annotationType + "' to '" + key.toString() + "': Field not found.";
|
|
5
5
|
},
|
|
6
|
-
/*
|
|
7
|
-
2(prop) {
|
|
8
|
-
return `invalid decorator for '${prop.toString()}'`
|
|
9
|
-
},
|
|
10
|
-
3(prop) {
|
|
11
|
-
return `Cannot decorate '${prop.toString()}': action can only be used on properties with a function value.`
|
|
12
|
-
},
|
|
13
|
-
4(prop) {
|
|
14
|
-
return `Cannot decorate '${prop.toString()}': computed can only be used on getter properties.`
|
|
15
|
-
},
|
|
6
|
+
/*
|
|
7
|
+
2(prop) {
|
|
8
|
+
return `invalid decorator for '${prop.toString()}'`
|
|
9
|
+
},
|
|
10
|
+
3(prop) {
|
|
11
|
+
return `Cannot decorate '${prop.toString()}': action can only be used on properties with a function value.`
|
|
12
|
+
},
|
|
13
|
+
4(prop) {
|
|
14
|
+
return `Cannot decorate '${prop.toString()}': computed can only be used on getter properties.`
|
|
15
|
+
},
|
|
16
16
|
*/
|
|
17
17
|
5: "'keys()' can only be used on observable objects, arrays, sets and maps",
|
|
18
18
|
6: "'values()' can only be used on observable objects, arrays, sets and maps",
|
|
@@ -128,8 +128,8 @@ function warnAboutProxyRequirement(msg) {
|
|
|
128
128
|
function getNextId() {
|
|
129
129
|
return ++globalState.mobxGuid;
|
|
130
130
|
}
|
|
131
|
-
/**
|
|
132
|
-
* Makes sure that the provided function is invoked at most once.
|
|
131
|
+
/**
|
|
132
|
+
* Makes sure that the provided function is invoked at most once.
|
|
133
133
|
*/
|
|
134
134
|
function once(func) {
|
|
135
135
|
var invoked = false;
|
|
@@ -210,8 +210,8 @@ function isES6Set(thing) {
|
|
|
210
210
|
return thing instanceof Set;
|
|
211
211
|
}
|
|
212
212
|
var hasGetOwnPropertySymbols = typeof Object.getOwnPropertySymbols !== "undefined";
|
|
213
|
-
/**
|
|
214
|
-
* Returns the following: own enumerable keys and symbols.
|
|
213
|
+
/**
|
|
214
|
+
* Returns the following: own enumerable keys and symbols.
|
|
215
215
|
*/
|
|
216
216
|
function getPlainObjectKeys(object) {
|
|
217
217
|
var keys = Object.keys(object);
|
|
@@ -354,20 +354,24 @@ function _toPropertyKey(arg) {
|
|
|
354
354
|
}
|
|
355
355
|
|
|
356
356
|
var storedAnnotationsSymbol = /*#__PURE__*/Symbol("mobx-stored-annotations");
|
|
357
|
-
/**
|
|
358
|
-
* Creates a function that acts as
|
|
359
|
-
* - decorator
|
|
360
|
-
* - annotation object
|
|
357
|
+
/**
|
|
358
|
+
* Creates a function that acts as
|
|
359
|
+
* - decorator
|
|
360
|
+
* - annotation object
|
|
361
361
|
*/
|
|
362
362
|
function createDecoratorAnnotation(annotation) {
|
|
363
363
|
function decorator(target, property) {
|
|
364
|
-
|
|
364
|
+
if (is20223Decorator(property)) {
|
|
365
|
+
return annotation.decorate_20223_(target, property);
|
|
366
|
+
} else {
|
|
367
|
+
storeAnnotation(target, property, annotation);
|
|
368
|
+
}
|
|
365
369
|
}
|
|
366
370
|
return Object.assign(decorator, annotation);
|
|
367
371
|
}
|
|
368
|
-
/**
|
|
369
|
-
* Stores annotation to prototype,
|
|
370
|
-
* so it can be inspected later by `makeObservable` called from constructor
|
|
372
|
+
/**
|
|
373
|
+
* Stores annotation to prototype,
|
|
374
|
+
* so it can be inspected later by `makeObservable` called from constructor
|
|
371
375
|
*/
|
|
372
376
|
function storeAnnotation(prototype, key, annotation) {
|
|
373
377
|
if (!hasProp(prototype, storedAnnotationsSymbol)) {
|
|
@@ -393,27 +397,37 @@ function assertNotDecorated(prototype, annotation, key) {
|
|
|
393
397
|
die("Cannot apply '@" + requestedAnnotationType + "' to '" + fieldName + "':" + ("\nThe field is already decorated with '@" + currentAnnotationType + "'.") + "\nRe-decorating fields is not allowed." + "\nUse '@override' decorator for methods overridden by subclass.");
|
|
394
398
|
}
|
|
395
399
|
}
|
|
396
|
-
/**
|
|
397
|
-
* Collects annotations from prototypes and stores them on target (instance)
|
|
400
|
+
/**
|
|
401
|
+
* Collects annotations from prototypes and stores them on target (instance)
|
|
398
402
|
*/
|
|
399
403
|
function collectStoredAnnotations(target) {
|
|
400
404
|
if (!hasProp(target, storedAnnotationsSymbol)) {
|
|
401
|
-
if (
|
|
402
|
-
|
|
403
|
-
|
|
405
|
+
// if (__DEV__ && !target[storedAnnotationsSymbol]) {
|
|
406
|
+
// die(
|
|
407
|
+
// `No annotations were passed to makeObservable, but no decorated members have been found either`
|
|
408
|
+
// )
|
|
409
|
+
// }
|
|
404
410
|
// We need a copy as we will remove annotation from the list once it's applied.
|
|
405
411
|
addHiddenProp(target, storedAnnotationsSymbol, _extends({}, target[storedAnnotationsSymbol]));
|
|
406
412
|
}
|
|
407
413
|
return target[storedAnnotationsSymbol];
|
|
408
414
|
}
|
|
415
|
+
function is20223Decorator(context) {
|
|
416
|
+
return typeof context == "object" && typeof context["kind"] == "string";
|
|
417
|
+
}
|
|
418
|
+
function assert20223DecoratorType(context, types) {
|
|
419
|
+
if (process.env.NODE_ENV !== "production" && !types.includes(context.kind)) {
|
|
420
|
+
die("Decorator may not be used like this");
|
|
421
|
+
}
|
|
422
|
+
}
|
|
409
423
|
|
|
410
424
|
var $mobx = /*#__PURE__*/Symbol("mobx administration");
|
|
411
425
|
var Atom = /*#__PURE__*/function () {
|
|
412
426
|
// for effective unobserving. BaseAtom has true, for extra optimization, so its onBecomeUnobserved never gets called, because it's not needed
|
|
413
427
|
|
|
414
|
-
/**
|
|
415
|
-
* Create a new atom. For debugging purposes it is recommended to give it a name.
|
|
416
|
-
* The onBecomeObserved and onBecomeUnobserved callbacks can be used for resource management.
|
|
428
|
+
/**
|
|
429
|
+
* Create a new atom. For debugging purposes it is recommended to give it a name.
|
|
430
|
+
* The onBecomeObserved and onBecomeUnobserved callbacks can be used for resource management.
|
|
417
431
|
*/
|
|
418
432
|
function Atom(name_) {
|
|
419
433
|
if (name_ === void 0) {
|
|
@@ -448,28 +462,26 @@ var Atom = /*#__PURE__*/function () {
|
|
|
448
462
|
});
|
|
449
463
|
}
|
|
450
464
|
}
|
|
451
|
-
/**
|
|
452
|
-
* Invoke this method to notify mobx that your atom has been used somehow.
|
|
453
|
-
* Returns true if there is currently a reactive context.
|
|
465
|
+
/**
|
|
466
|
+
* Invoke this method to notify mobx that your atom has been used somehow.
|
|
467
|
+
* Returns true if there is currently a reactive context.
|
|
454
468
|
*/;
|
|
455
469
|
_proto.reportObserved = function reportObserved$1() {
|
|
456
470
|
return reportObserved(this);
|
|
457
471
|
}
|
|
458
|
-
/**
|
|
459
|
-
* Invoke this method _after_ this method has changed to signal mobx that all its observers should invalidate.
|
|
472
|
+
/**
|
|
473
|
+
* Invoke this method _after_ this method has changed to signal mobx that all its observers should invalidate.
|
|
460
474
|
*/;
|
|
461
475
|
_proto.reportChanged = function reportChanged() {
|
|
462
|
-
if (globalState.inBatch
|
|
463
|
-
//
|
|
464
|
-
|
|
476
|
+
if (!globalState.inBatch || this.batchId_ !== globalState.batchId) {
|
|
477
|
+
// We could update state version only at the end of batch,
|
|
478
|
+
// but we would still have to switch some global flag here to signal a change.
|
|
479
|
+
globalState.stateVersion = globalState.stateVersion < Number.MAX_SAFE_INTEGER ? globalState.stateVersion + 1 : Number.MIN_SAFE_INTEGER;
|
|
480
|
+
// Avoids the possibility of hitting the same globalState.batchId when it cycled through all integers (necessary?)
|
|
481
|
+
this.batchId_ = NaN;
|
|
465
482
|
}
|
|
466
|
-
// Avoids the possibility of hitting the same globalState.batchId when it cycled through all integers (necessary?)
|
|
467
|
-
this.batchId_ = NaN;
|
|
468
483
|
startBatch();
|
|
469
484
|
propagateChanged(this);
|
|
470
|
-
// We could update state version only at the end of batch,
|
|
471
|
-
// but we would still have to switch some global flag here to signal a change.
|
|
472
|
-
globalState.stateVersion = globalState.stateVersion < Number.MAX_SAFE_INTEGER ? globalState.stateVersion + 1 : Number.MIN_SAFE_INTEGER;
|
|
473
485
|
endBatch();
|
|
474
486
|
};
|
|
475
487
|
_proto.toString = function toString() {
|
|
@@ -606,7 +618,8 @@ var OVERRIDE = "override";
|
|
|
606
618
|
var override = /*#__PURE__*/createDecoratorAnnotation({
|
|
607
619
|
annotationType_: OVERRIDE,
|
|
608
620
|
make_: make_,
|
|
609
|
-
extend_: extend_
|
|
621
|
+
extend_: extend_,
|
|
622
|
+
decorate_20223_: decorate_20223_
|
|
610
623
|
});
|
|
611
624
|
function isOverride(annotation) {
|
|
612
625
|
return annotation.annotationType_ === OVERRIDE;
|
|
@@ -620,47 +633,87 @@ function make_(adm, key) {
|
|
|
620
633
|
if (process.env.NODE_ENV !== "production" && !hasProp(adm.appliedAnnotations_, key)) {
|
|
621
634
|
die("'" + adm.name_ + "." + key.toString() + "' is annotated with '" + this.annotationType_ + "', " + "but no such annotated member was found on prototype.");
|
|
622
635
|
}
|
|
623
|
-
return 0 /* Cancel */;
|
|
636
|
+
return 0 /* MakeResult.Cancel */;
|
|
624
637
|
}
|
|
625
638
|
|
|
626
639
|
function extend_(adm, key, descriptor, proxyTrap) {
|
|
627
640
|
die("'" + this.annotationType_ + "' can only be used with 'makeObservable'");
|
|
628
641
|
}
|
|
642
|
+
function decorate_20223_(desc, context) {
|
|
643
|
+
console.warn("'" + this.annotationType_ + "' cannot be used with decorators - this is a no-op");
|
|
644
|
+
}
|
|
629
645
|
|
|
630
646
|
function createActionAnnotation(name, options) {
|
|
631
647
|
return {
|
|
632
648
|
annotationType_: name,
|
|
633
649
|
options_: options,
|
|
634
650
|
make_: make_$1,
|
|
635
|
-
extend_: extend_$1
|
|
651
|
+
extend_: extend_$1,
|
|
652
|
+
decorate_20223_: decorate_20223_$1
|
|
636
653
|
};
|
|
637
654
|
}
|
|
638
655
|
function make_$1(adm, key, descriptor, source) {
|
|
639
656
|
var _this$options_;
|
|
640
657
|
// bound
|
|
641
658
|
if ((_this$options_ = this.options_) != null && _this$options_.bound) {
|
|
642
|
-
return this.extend_(adm, key, descriptor, false) === null ? 0 /* Cancel */ : 1 /* Break */;
|
|
659
|
+
return this.extend_(adm, key, descriptor, false) === null ? 0 /* MakeResult.Cancel */ : 1 /* MakeResult.Break */;
|
|
643
660
|
}
|
|
644
661
|
// own
|
|
645
662
|
if (source === adm.target_) {
|
|
646
|
-
return this.extend_(adm, key, descriptor, false) === null ? 0 /* Cancel */ : 2 /* Continue */;
|
|
663
|
+
return this.extend_(adm, key, descriptor, false) === null ? 0 /* MakeResult.Cancel */ : 2 /* MakeResult.Continue */;
|
|
647
664
|
}
|
|
648
665
|
// prototype
|
|
649
666
|
if (isAction(descriptor.value)) {
|
|
650
667
|
// A prototype could have been annotated already by other constructor,
|
|
651
668
|
// rest of the proto chain must be annotated already
|
|
652
|
-
return 1 /* Break */;
|
|
669
|
+
return 1 /* MakeResult.Break */;
|
|
653
670
|
}
|
|
654
671
|
|
|
655
672
|
var actionDescriptor = createActionDescriptor(adm, this, key, descriptor, false);
|
|
656
673
|
defineProperty(source, key, actionDescriptor);
|
|
657
|
-
return 2 /* Continue */;
|
|
674
|
+
return 2 /* MakeResult.Continue */;
|
|
658
675
|
}
|
|
659
676
|
|
|
660
677
|
function extend_$1(adm, key, descriptor, proxyTrap) {
|
|
661
678
|
var actionDescriptor = createActionDescriptor(adm, this, key, descriptor);
|
|
662
679
|
return adm.defineProperty_(key, actionDescriptor, proxyTrap);
|
|
663
680
|
}
|
|
681
|
+
function decorate_20223_$1(mthd, context) {
|
|
682
|
+
if (process.env.NODE_ENV !== "production") {
|
|
683
|
+
assert20223DecoratorType(context, ["method", "field"]);
|
|
684
|
+
}
|
|
685
|
+
var kind = context.kind,
|
|
686
|
+
name = context.name,
|
|
687
|
+
addInitializer = context.addInitializer;
|
|
688
|
+
var ann = this;
|
|
689
|
+
var _createAction = function _createAction(m) {
|
|
690
|
+
var _ann$options_$name, _ann$options_, _ann$options_$autoAct, _ann$options_2;
|
|
691
|
+
return createAction((_ann$options_$name = (_ann$options_ = ann.options_) == null ? void 0 : _ann$options_.name) != null ? _ann$options_$name : name.toString(), m, (_ann$options_$autoAct = (_ann$options_2 = ann.options_) == null ? void 0 : _ann$options_2.autoAction) != null ? _ann$options_$autoAct : false);
|
|
692
|
+
};
|
|
693
|
+
// Backwards/Legacy behavior, expects makeObservable(this)
|
|
694
|
+
if (kind == "field") {
|
|
695
|
+
addInitializer(function () {
|
|
696
|
+
storeAnnotation(this, name, ann);
|
|
697
|
+
});
|
|
698
|
+
return;
|
|
699
|
+
}
|
|
700
|
+
if (kind == "method") {
|
|
701
|
+
var _this$options_2;
|
|
702
|
+
if (!isAction(mthd)) {
|
|
703
|
+
mthd = _createAction(mthd);
|
|
704
|
+
}
|
|
705
|
+
if ((_this$options_2 = this.options_) != null && _this$options_2.bound) {
|
|
706
|
+
addInitializer(function () {
|
|
707
|
+
var self = this;
|
|
708
|
+
var bound = self[name].bind(self);
|
|
709
|
+
bound.isMobxAction = true;
|
|
710
|
+
self[name] = bound;
|
|
711
|
+
});
|
|
712
|
+
}
|
|
713
|
+
return mthd;
|
|
714
|
+
}
|
|
715
|
+
die("Cannot apply '" + ann.annotationType_ + "' to '" + String(name) + "' (kind: " + kind + "):" + ("\n'" + ann.annotationType_ + "' can only be used on properties with a function value."));
|
|
716
|
+
}
|
|
664
717
|
function assertActionDescriptor(adm, _ref, key, _ref2) {
|
|
665
718
|
var annotationType_ = _ref.annotationType_;
|
|
666
719
|
var value = _ref2.value;
|
|
@@ -701,32 +754,33 @@ function createFlowAnnotation(name, options) {
|
|
|
701
754
|
annotationType_: name,
|
|
702
755
|
options_: options,
|
|
703
756
|
make_: make_$2,
|
|
704
|
-
extend_: extend_$2
|
|
757
|
+
extend_: extend_$2,
|
|
758
|
+
decorate_20223_: decorate_20223_$2
|
|
705
759
|
};
|
|
706
760
|
}
|
|
707
761
|
function make_$2(adm, key, descriptor, source) {
|
|
708
762
|
var _this$options_;
|
|
709
763
|
// own
|
|
710
764
|
if (source === adm.target_) {
|
|
711
|
-
return this.extend_(adm, key, descriptor, false) === null ? 0 /* Cancel */ : 2 /* Continue */;
|
|
765
|
+
return this.extend_(adm, key, descriptor, false) === null ? 0 /* MakeResult.Cancel */ : 2 /* MakeResult.Continue */;
|
|
712
766
|
}
|
|
713
767
|
// prototype
|
|
714
768
|
// bound - must annotate protos to support super.flow()
|
|
715
769
|
if ((_this$options_ = this.options_) != null && _this$options_.bound && (!hasProp(adm.target_, key) || !isFlow(adm.target_[key]))) {
|
|
716
770
|
if (this.extend_(adm, key, descriptor, false) === null) {
|
|
717
|
-
return 0 /* Cancel */;
|
|
771
|
+
return 0 /* MakeResult.Cancel */;
|
|
718
772
|
}
|
|
719
773
|
}
|
|
720
774
|
|
|
721
775
|
if (isFlow(descriptor.value)) {
|
|
722
776
|
// A prototype could have been annotated already by other constructor,
|
|
723
777
|
// rest of the proto chain must be annotated already
|
|
724
|
-
return 1 /* Break */;
|
|
778
|
+
return 1 /* MakeResult.Break */;
|
|
725
779
|
}
|
|
726
780
|
|
|
727
781
|
var flowDescriptor = createFlowDescriptor(adm, this, key, descriptor, false, false);
|
|
728
782
|
defineProperty(source, key, flowDescriptor);
|
|
729
|
-
return 2 /* Continue */;
|
|
783
|
+
return 2 /* MakeResult.Continue */;
|
|
730
784
|
}
|
|
731
785
|
|
|
732
786
|
function extend_$2(adm, key, descriptor, proxyTrap) {
|
|
@@ -734,6 +788,26 @@ function extend_$2(adm, key, descriptor, proxyTrap) {
|
|
|
734
788
|
var flowDescriptor = createFlowDescriptor(adm, this, key, descriptor, (_this$options_2 = this.options_) == null ? void 0 : _this$options_2.bound);
|
|
735
789
|
return adm.defineProperty_(key, flowDescriptor, proxyTrap);
|
|
736
790
|
}
|
|
791
|
+
function decorate_20223_$2(mthd, context) {
|
|
792
|
+
var _this$options_3;
|
|
793
|
+
if (process.env.NODE_ENV !== "production") {
|
|
794
|
+
assert20223DecoratorType(context, ["method"]);
|
|
795
|
+
}
|
|
796
|
+
var name = context.name,
|
|
797
|
+
addInitializer = context.addInitializer;
|
|
798
|
+
if (!isFlow(mthd)) {
|
|
799
|
+
mthd = flow(mthd);
|
|
800
|
+
}
|
|
801
|
+
if ((_this$options_3 = this.options_) != null && _this$options_3.bound) {
|
|
802
|
+
addInitializer(function () {
|
|
803
|
+
var self = this;
|
|
804
|
+
var bound = self[name].bind(self);
|
|
805
|
+
bound.isMobXFlow = true;
|
|
806
|
+
self[name] = bound;
|
|
807
|
+
});
|
|
808
|
+
}
|
|
809
|
+
return mthd;
|
|
810
|
+
}
|
|
737
811
|
function assertFlowDescriptor(adm, _ref, key, _ref2) {
|
|
738
812
|
var annotationType_ = _ref.annotationType_;
|
|
739
813
|
var value = _ref2.value;
|
|
@@ -778,11 +852,12 @@ function createComputedAnnotation(name, options) {
|
|
|
778
852
|
annotationType_: name,
|
|
779
853
|
options_: options,
|
|
780
854
|
make_: make_$3,
|
|
781
|
-
extend_: extend_$3
|
|
855
|
+
extend_: extend_$3,
|
|
856
|
+
decorate_20223_: decorate_20223_$3
|
|
782
857
|
};
|
|
783
858
|
}
|
|
784
859
|
function make_$3(adm, key, descriptor) {
|
|
785
|
-
return this.extend_(adm, key, descriptor, false) === null ? 0 /* Cancel */ : 1 /* Break */;
|
|
860
|
+
return this.extend_(adm, key, descriptor, false) === null ? 0 /* MakeResult.Cancel */ : 1 /* MakeResult.Break */;
|
|
786
861
|
}
|
|
787
862
|
|
|
788
863
|
function extend_$3(adm, key, descriptor, proxyTrap) {
|
|
@@ -792,6 +867,26 @@ function extend_$3(adm, key, descriptor, proxyTrap) {
|
|
|
792
867
|
set: descriptor.set
|
|
793
868
|
}), proxyTrap);
|
|
794
869
|
}
|
|
870
|
+
function decorate_20223_$3(get, context) {
|
|
871
|
+
if (process.env.NODE_ENV !== "production") {
|
|
872
|
+
assert20223DecoratorType(context, ["getter"]);
|
|
873
|
+
}
|
|
874
|
+
var ann = this;
|
|
875
|
+
var key = context.name,
|
|
876
|
+
addInitializer = context.addInitializer;
|
|
877
|
+
addInitializer(function () {
|
|
878
|
+
var adm = asObservableObject(this)[$mobx];
|
|
879
|
+
var options = _extends({}, ann.options_, {
|
|
880
|
+
get: get,
|
|
881
|
+
context: this
|
|
882
|
+
});
|
|
883
|
+
options.name || (options.name = process.env.NODE_ENV !== "production" ? adm.name_ + "." + key.toString() : "ObservableObject." + key.toString());
|
|
884
|
+
adm.values_.set(key, new ComputedValue(options));
|
|
885
|
+
});
|
|
886
|
+
return function () {
|
|
887
|
+
return this[$mobx].getObservablePropValue_(key);
|
|
888
|
+
};
|
|
889
|
+
}
|
|
795
890
|
function assertComputedDescriptor(adm, _ref, key, _ref2) {
|
|
796
891
|
var annotationType_ = _ref.annotationType_;
|
|
797
892
|
var get = _ref2.get;
|
|
@@ -805,11 +900,12 @@ function createObservableAnnotation(name, options) {
|
|
|
805
900
|
annotationType_: name,
|
|
806
901
|
options_: options,
|
|
807
902
|
make_: make_$4,
|
|
808
|
-
extend_: extend_$4
|
|
903
|
+
extend_: extend_$4,
|
|
904
|
+
decorate_20223_: decorate_20223_$4
|
|
809
905
|
};
|
|
810
906
|
}
|
|
811
907
|
function make_$4(adm, key, descriptor) {
|
|
812
|
-
return this.extend_(adm, key, descriptor, false) === null ? 0 /* Cancel */ : 1 /* Break */;
|
|
908
|
+
return this.extend_(adm, key, descriptor, false) === null ? 0 /* MakeResult.Cancel */ : 1 /* MakeResult.Break */;
|
|
813
909
|
}
|
|
814
910
|
|
|
815
911
|
function extend_$4(adm, key, descriptor, proxyTrap) {
|
|
@@ -817,6 +913,58 @@ function extend_$4(adm, key, descriptor, proxyTrap) {
|
|
|
817
913
|
assertObservableDescriptor(adm, this, key, descriptor);
|
|
818
914
|
return adm.defineObservableProperty_(key, descriptor.value, (_this$options_$enhanc = (_this$options_ = this.options_) == null ? void 0 : _this$options_.enhancer) != null ? _this$options_$enhanc : deepEnhancer, proxyTrap);
|
|
819
915
|
}
|
|
916
|
+
function decorate_20223_$4(desc, context) {
|
|
917
|
+
if (process.env.NODE_ENV !== "production") {
|
|
918
|
+
assert20223DecoratorType(context, ["accessor", "field"]);
|
|
919
|
+
}
|
|
920
|
+
var ann = this;
|
|
921
|
+
var kind = context.kind,
|
|
922
|
+
name = context.name,
|
|
923
|
+
addInitializer = context.addInitializer;
|
|
924
|
+
// Backwards/Legacy behavior, expects makeObservable(this)
|
|
925
|
+
if (kind == "field") {
|
|
926
|
+
addInitializer(function () {
|
|
927
|
+
storeAnnotation(this, name, ann);
|
|
928
|
+
});
|
|
929
|
+
return;
|
|
930
|
+
}
|
|
931
|
+
// The laziness here is not ideal... It's a workaround to how 2022.3 Decorators are implemented:
|
|
932
|
+
// `addInitializer` callbacks are executed _before_ any accessors are defined (instead of the ideal-for-us right after each).
|
|
933
|
+
// This means that, if we were to do our stuff in an `addInitializer`, we'd attempt to read a private slot
|
|
934
|
+
// before it has been initialized. The runtime doesn't like that and throws a `Cannot read private member
|
|
935
|
+
// from an object whose class did not declare it` error.
|
|
936
|
+
var initializedObjects = new WeakSet();
|
|
937
|
+
function initializeObservable(target, value) {
|
|
938
|
+
var _ann$options_$enhance, _ann$options_;
|
|
939
|
+
var adm = asObservableObject(target)[$mobx];
|
|
940
|
+
var observable = new ObservableValue(value, (_ann$options_$enhance = (_ann$options_ = ann.options_) == null ? void 0 : _ann$options_.enhancer) != null ? _ann$options_$enhance : deepEnhancer, process.env.NODE_ENV !== "production" ? adm.name_ + "." + name.toString() : "ObservableObject." + name.toString(), false);
|
|
941
|
+
adm.values_.set(name, observable);
|
|
942
|
+
initializedObjects.add(target);
|
|
943
|
+
}
|
|
944
|
+
if (kind == "accessor") {
|
|
945
|
+
return {
|
|
946
|
+
get: function get() {
|
|
947
|
+
if (!initializedObjects.has(this)) {
|
|
948
|
+
initializeObservable(this, desc.get.call(this));
|
|
949
|
+
}
|
|
950
|
+
return this[$mobx].getObservablePropValue_(name);
|
|
951
|
+
},
|
|
952
|
+
set: function set(value) {
|
|
953
|
+
if (!initializedObjects.has(this)) {
|
|
954
|
+
initializeObservable(this, value);
|
|
955
|
+
}
|
|
956
|
+
return this[$mobx].setObservablePropValue_(name, value);
|
|
957
|
+
},
|
|
958
|
+
init: function init(value) {
|
|
959
|
+
if (!initializedObjects.has(this)) {
|
|
960
|
+
initializeObservable(this, value);
|
|
961
|
+
}
|
|
962
|
+
return value;
|
|
963
|
+
}
|
|
964
|
+
};
|
|
965
|
+
}
|
|
966
|
+
return;
|
|
967
|
+
}
|
|
820
968
|
function assertObservableDescriptor(adm, _ref, key, descriptor) {
|
|
821
969
|
var annotationType_ = _ref.annotationType_;
|
|
822
970
|
if (process.env.NODE_ENV !== "production" && !("value" in descriptor)) {
|
|
@@ -831,7 +979,8 @@ function createAutoAnnotation(options) {
|
|
|
831
979
|
annotationType_: AUTO,
|
|
832
980
|
options_: options,
|
|
833
981
|
make_: make_$5,
|
|
834
|
-
extend_: extend_$5
|
|
982
|
+
extend_: extend_$5,
|
|
983
|
+
decorate_20223_: decorate_20223_$5
|
|
835
984
|
};
|
|
836
985
|
}
|
|
837
986
|
function make_$5(adm, key, descriptor, source) {
|
|
@@ -849,14 +998,14 @@ function make_$5(adm, key, descriptor, source) {
|
|
|
849
998
|
return adm.defineProperty_(key, {
|
|
850
999
|
configurable: globalState.safeDescriptors ? adm.isPlainObject_ : true,
|
|
851
1000
|
set: set
|
|
852
|
-
}) === null ? 0 /* Cancel */ : 2 /* Continue */;
|
|
1001
|
+
}) === null ? 0 /* MakeResult.Cancel */ : 2 /* MakeResult.Continue */;
|
|
853
1002
|
}
|
|
854
1003
|
// proto
|
|
855
1004
|
defineProperty(source, key, {
|
|
856
1005
|
configurable: true,
|
|
857
1006
|
set: set
|
|
858
1007
|
});
|
|
859
|
-
return 2 /* Continue */;
|
|
1008
|
+
return 2 /* MakeResult.Continue */;
|
|
860
1009
|
}
|
|
861
1010
|
// function on proto -> autoAction/flow
|
|
862
1011
|
if (source !== adm.target_ && typeof descriptor.value === "function") {
|
|
@@ -903,6 +1052,9 @@ function extend_$5(adm, key, descriptor, proxyTrap) {
|
|
|
903
1052
|
var observableAnnotation = ((_this$options_6 = this.options_) == null ? void 0 : _this$options_6.deep) === false ? observable.ref : observable;
|
|
904
1053
|
return observableAnnotation.extend_(adm, key, descriptor, proxyTrap);
|
|
905
1054
|
}
|
|
1055
|
+
function decorate_20223_$5(desc, context) {
|
|
1056
|
+
die("'" + this.annotationType_ + "' cannot be used as a decorator");
|
|
1057
|
+
}
|
|
906
1058
|
|
|
907
1059
|
var OBSERVABLE = "observable";
|
|
908
1060
|
var OBSERVABLE_REF = "observable.ref";
|
|
@@ -942,11 +1094,15 @@ function getEnhancerFromAnnotation(annotation) {
|
|
|
942
1094
|
var _annotation$options_$, _annotation$options_;
|
|
943
1095
|
return !annotation ? deepEnhancer : (_annotation$options_$ = (_annotation$options_ = annotation.options_) == null ? void 0 : _annotation$options_.enhancer) != null ? _annotation$options_$ : deepEnhancer;
|
|
944
1096
|
}
|
|
945
|
-
/**
|
|
946
|
-
* Turns an object, array or function into a reactive structure.
|
|
947
|
-
* @param v the value which should become observable.
|
|
1097
|
+
/**
|
|
1098
|
+
* Turns an object, array or function into a reactive structure.
|
|
1099
|
+
* @param v the value which should become observable.
|
|
948
1100
|
*/
|
|
949
1101
|
function createObservable(v, arg2, arg3) {
|
|
1102
|
+
// @observable someProp; (2022.3 Decorators)
|
|
1103
|
+
if (is20223Decorator(arg2)) {
|
|
1104
|
+
return observableAnnotation.decorate_20223_(v, arg2);
|
|
1105
|
+
}
|
|
950
1106
|
// @observable someProp;
|
|
951
1107
|
if (isStringish(arg2)) {
|
|
952
1108
|
storeAnnotation(v, arg2, observableAnnotation);
|
|
@@ -1016,11 +1172,15 @@ var computedAnnotation = /*#__PURE__*/createComputedAnnotation(COMPUTED);
|
|
|
1016
1172
|
var computedStructAnnotation = /*#__PURE__*/createComputedAnnotation(COMPUTED_STRUCT, {
|
|
1017
1173
|
equals: comparer.structural
|
|
1018
1174
|
});
|
|
1019
|
-
/**
|
|
1020
|
-
* Decorator for class properties: @computed get value() { return expr; }.
|
|
1021
|
-
* For legacy purposes also invokable as ES5 observable created: `computed(() => expr)`;
|
|
1175
|
+
/**
|
|
1176
|
+
* Decorator for class properties: @computed get value() { return expr; }.
|
|
1177
|
+
* For legacy purposes also invokable as ES5 observable created: `computed(() => expr)`;
|
|
1022
1178
|
*/
|
|
1023
1179
|
var computed = function computed(arg1, arg2) {
|
|
1180
|
+
if (is20223Decorator(arg2)) {
|
|
1181
|
+
// @computed (2022.3 Decorators)
|
|
1182
|
+
return computedAnnotation.decorate_20223_(arg1, arg2);
|
|
1183
|
+
}
|
|
1024
1184
|
if (isStringish(arg2)) {
|
|
1025
1185
|
// @computed
|
|
1026
1186
|
return storeAnnotation(arg1, arg2, computedAnnotation);
|
|
@@ -1307,24 +1467,24 @@ var ObservableValue = /*#__PURE__*/function (_Atom) {
|
|
|
1307
1467
|
var isObservableValue = /*#__PURE__*/createInstanceofPredicate("ObservableValue", ObservableValue);
|
|
1308
1468
|
|
|
1309
1469
|
var _Symbol$toPrimitive$1;
|
|
1310
|
-
/**
|
|
1311
|
-
* A node in the state dependency root that observes other nodes, and can be observed itself.
|
|
1312
|
-
*
|
|
1313
|
-
* ComputedValue will remember the result of the computation for the duration of the batch, or
|
|
1314
|
-
* while being observed.
|
|
1315
|
-
*
|
|
1316
|
-
* During this time it will recompute only when one of its direct dependencies changed,
|
|
1317
|
-
* but only when it is being accessed with `ComputedValue.get()`.
|
|
1318
|
-
*
|
|
1319
|
-
* Implementation description:
|
|
1320
|
-
* 1. First time it's being accessed it will compute and remember result
|
|
1321
|
-
* give back remembered result until 2. happens
|
|
1322
|
-
* 2. First time any deep dependency change, propagate POSSIBLY_STALE to all observers, wait for 3.
|
|
1323
|
-
* 3. When it's being accessed, recompute if any shallow dependency changed.
|
|
1324
|
-
* if result changed: propagate STALE to all observers, that were POSSIBLY_STALE from the last step.
|
|
1325
|
-
* go to step 2. either way
|
|
1326
|
-
*
|
|
1327
|
-
* If at any point it's outside batch and it isn't observed: reset everything and go to 1.
|
|
1470
|
+
/**
|
|
1471
|
+
* A node in the state dependency root that observes other nodes, and can be observed itself.
|
|
1472
|
+
*
|
|
1473
|
+
* ComputedValue will remember the result of the computation for the duration of the batch, or
|
|
1474
|
+
* while being observed.
|
|
1475
|
+
*
|
|
1476
|
+
* During this time it will recompute only when one of its direct dependencies changed,
|
|
1477
|
+
* but only when it is being accessed with `ComputedValue.get()`.
|
|
1478
|
+
*
|
|
1479
|
+
* Implementation description:
|
|
1480
|
+
* 1. First time it's being accessed it will compute and remember result
|
|
1481
|
+
* give back remembered result until 2. happens
|
|
1482
|
+
* 2. First time any deep dependency change, propagate POSSIBLY_STALE to all observers, wait for 3.
|
|
1483
|
+
* 3. When it's being accessed, recompute if any shallow dependency changed.
|
|
1484
|
+
* if result changed: propagate STALE to all observers, that were POSSIBLY_STALE from the last step.
|
|
1485
|
+
* go to step 2. either way
|
|
1486
|
+
*
|
|
1487
|
+
* If at any point it's outside batch and it isn't observed: reset everything and go to 1.
|
|
1328
1488
|
*/
|
|
1329
1489
|
_Symbol$toPrimitive$1 = Symbol.toPrimitive;
|
|
1330
1490
|
var ComputedValue = /*#__PURE__*/function () {
|
|
@@ -1335,17 +1495,17 @@ var ComputedValue = /*#__PURE__*/function () {
|
|
|
1335
1495
|
|
|
1336
1496
|
// N.B: unminified as it is used by MST
|
|
1337
1497
|
|
|
1338
|
-
/**
|
|
1339
|
-
* Create a new computed value based on a function expression.
|
|
1340
|
-
*
|
|
1341
|
-
* The `name` property is for debug purposes only.
|
|
1342
|
-
*
|
|
1343
|
-
* The `equals` property specifies the comparer function to use to determine if a newly produced
|
|
1344
|
-
* value differs from the previous value. Two comparers are provided in the library; `defaultComparer`
|
|
1345
|
-
* compares based on identity comparison (===), and `structuralComparer` deeply compares the structure.
|
|
1346
|
-
* Structural comparison can be convenient if you always produce a new aggregated object and
|
|
1347
|
-
* don't want to notify observers if it is structurally the same.
|
|
1348
|
-
* This is useful for working with vectors, mouse coordinates etc.
|
|
1498
|
+
/**
|
|
1499
|
+
* Create a new computed value based on a function expression.
|
|
1500
|
+
*
|
|
1501
|
+
* The `name` property is for debug purposes only.
|
|
1502
|
+
*
|
|
1503
|
+
* The `equals` property specifies the comparer function to use to determine if a newly produced
|
|
1504
|
+
* value differs from the previous value. Two comparers are provided in the library; `defaultComparer`
|
|
1505
|
+
* compares based on identity comparison (===), and `structuralComparer` deeply compares the structure.
|
|
1506
|
+
* Structural comparison can be convenient if you always produce a new aggregated object and
|
|
1507
|
+
* don't want to notify observers if it is structurally the same.
|
|
1508
|
+
* This is useful for working with vectors, mouse coordinates etc.
|
|
1349
1509
|
*/
|
|
1350
1510
|
function ComputedValue(options) {
|
|
1351
1511
|
this.dependenciesState_ = IDerivationState_.NOT_TRACKING_;
|
|
@@ -1404,9 +1564,9 @@ var ComputedValue = /*#__PURE__*/function () {
|
|
|
1404
1564
|
});
|
|
1405
1565
|
}
|
|
1406
1566
|
}
|
|
1407
|
-
/**
|
|
1408
|
-
* Returns the current value of this computed value.
|
|
1409
|
-
* Will evaluate its computation first if needed.
|
|
1567
|
+
/**
|
|
1568
|
+
* Returns the current value of this computed value.
|
|
1569
|
+
* Will evaluate its computation first if needed.
|
|
1410
1570
|
*/;
|
|
1411
1571
|
_proto.get = function get() {
|
|
1412
1572
|
if (this.isComputing_) {
|
|
@@ -1589,16 +1749,16 @@ var CaughtException = function CaughtException(cause) {
|
|
|
1589
1749
|
function isCaughtException(e) {
|
|
1590
1750
|
return e instanceof CaughtException;
|
|
1591
1751
|
}
|
|
1592
|
-
/**
|
|
1593
|
-
* Finds out whether any dependency of the derivation has actually changed.
|
|
1594
|
-
* If dependenciesState is 1 then it will recalculate dependencies,
|
|
1595
|
-
* if any dependency changed it will propagate it by changing dependenciesState to 2.
|
|
1596
|
-
*
|
|
1597
|
-
* By iterating over the dependencies in the same order that they were reported and
|
|
1598
|
-
* stopping on the first change, all the recalculations are only called for ComputedValues
|
|
1599
|
-
* that will be tracked by derivation. That is because we assume that if the first x
|
|
1600
|
-
* dependencies of the derivation doesn't change then the derivation should run the same way
|
|
1601
|
-
* up until accessing x-th dependency.
|
|
1752
|
+
/**
|
|
1753
|
+
* Finds out whether any dependency of the derivation has actually changed.
|
|
1754
|
+
* If dependenciesState is 1 then it will recalculate dependencies,
|
|
1755
|
+
* if any dependency changed it will propagate it by changing dependenciesState to 2.
|
|
1756
|
+
*
|
|
1757
|
+
* By iterating over the dependencies in the same order that they were reported and
|
|
1758
|
+
* stopping on the first change, all the recalculations are only called for ComputedValues
|
|
1759
|
+
* that will be tracked by derivation. That is because we assume that if the first x
|
|
1760
|
+
* dependencies of the derivation doesn't change then the derivation should run the same way
|
|
1761
|
+
* up until accessing x-th dependency.
|
|
1602
1762
|
*/
|
|
1603
1763
|
function shouldCompute(derivation) {
|
|
1604
1764
|
switch (derivation.dependenciesState_) {
|
|
@@ -1665,10 +1825,10 @@ function checkIfStateReadsAreAllowed(observable) {
|
|
|
1665
1825
|
console.warn("[mobx] Observable '" + observable.name_ + "' being read outside a reactive context.");
|
|
1666
1826
|
}
|
|
1667
1827
|
}
|
|
1668
|
-
/**
|
|
1669
|
-
* Executes the provided function `f` and tracks which observables are being accessed.
|
|
1670
|
-
* The tracking information is stored on the `derivation` object and the derivation is registered
|
|
1671
|
-
* as observer of any of the accessed observables.
|
|
1828
|
+
/**
|
|
1829
|
+
* Executes the provided function `f` and tracks which observables are being accessed.
|
|
1830
|
+
* The tracking information is stored on the `derivation` object and the derivation is registered
|
|
1831
|
+
* as observer of any of the accessed observables.
|
|
1672
1832
|
*/
|
|
1673
1833
|
function trackDerivedFunction(derivation, f, context) {
|
|
1674
1834
|
var prevAllowStateReads = allowStateReadsStart(true);
|
|
@@ -1709,10 +1869,10 @@ function warnAboutDerivationWithoutDependencies(derivation) {
|
|
|
1709
1869
|
console.warn("[mobx] Derivation '" + derivation.name_ + "' is created/updated without reading any observable value.");
|
|
1710
1870
|
}
|
|
1711
1871
|
}
|
|
1712
|
-
/**
|
|
1713
|
-
* diffs newObserving with observing.
|
|
1714
|
-
* update observing to be newObserving with unique observables
|
|
1715
|
-
* notify observers that become observed/unobserved
|
|
1872
|
+
/**
|
|
1873
|
+
* diffs newObserving with observing.
|
|
1874
|
+
* update observing to be newObserving with unique observables
|
|
1875
|
+
* notify observers that become observed/unobserved
|
|
1716
1876
|
*/
|
|
1717
1877
|
function bindDependencies(derivation) {
|
|
1718
1878
|
// invariant(derivation.dependenciesState !== IDerivationState.NOT_TRACKING, "INTERNAL ERROR bindDependencies expects derivation.dependenciesState !== -1");
|
|
@@ -1803,9 +1963,9 @@ function allowStateReadsStart(allowStateReads) {
|
|
|
1803
1963
|
function allowStateReadsEnd(prev) {
|
|
1804
1964
|
globalState.allowStateReads = prev;
|
|
1805
1965
|
}
|
|
1806
|
-
/**
|
|
1807
|
-
* needed to keep `lowestObserverState` correct. when changing from (2 or 1) to 0
|
|
1808
|
-
*
|
|
1966
|
+
/**
|
|
1967
|
+
* needed to keep `lowestObserverState` correct. when changing from (2 or 1) to 0
|
|
1968
|
+
*
|
|
1809
1969
|
*/
|
|
1810
1970
|
function changeDependenciesStateTo0(derivation) {
|
|
1811
1971
|
if (derivation.dependenciesState_ === IDerivationState_.UP_TO_DATE_) {
|
|
@@ -1819,8 +1979,8 @@ function changeDependenciesStateTo0(derivation) {
|
|
|
1819
1979
|
}
|
|
1820
1980
|
}
|
|
1821
1981
|
|
|
1822
|
-
/**
|
|
1823
|
-
* These values will persist if global state is reset
|
|
1982
|
+
/**
|
|
1983
|
+
* These values will persist if global state is reset
|
|
1824
1984
|
*/
|
|
1825
1985
|
var persistentKeys = ["mobxGuid", "spyListeners", "enforceActions", "computedRequiresReaction", "reactionRequiresObservable", "observableRequiresReaction", "allowStateReads", "disableErrorBoundaries", "runId", "UNCHANGED", "useProxies"];
|
|
1826
1986
|
var MobXGlobals = function MobXGlobals() {
|
|
@@ -1896,9 +2056,9 @@ function isolateGlobalState() {
|
|
|
1896
2056
|
function getGlobalState() {
|
|
1897
2057
|
return globalState;
|
|
1898
2058
|
}
|
|
1899
|
-
/**
|
|
1900
|
-
* For testing purposes only; this will break the internal state of existing observables,
|
|
1901
|
-
* but can be used to get back at a stable state after throwing errors
|
|
2059
|
+
/**
|
|
2060
|
+
* For testing purposes only; this will break the internal state of existing observables,
|
|
2061
|
+
* but can be used to get back at a stable state after throwing errors
|
|
1902
2062
|
*/
|
|
1903
2063
|
function resetGlobalState() {
|
|
1904
2064
|
var defaultGlobals = new MobXGlobals();
|
|
@@ -1965,10 +2125,10 @@ function queueForUnobservation(observable) {
|
|
|
1965
2125
|
globalState.pendingUnobservations.push(observable);
|
|
1966
2126
|
}
|
|
1967
2127
|
}
|
|
1968
|
-
/**
|
|
1969
|
-
* Batch starts a transaction, at least for purposes of memoizing ComputedValues when nothing else does.
|
|
1970
|
-
* During a batch `onBecomeUnobserved` will be called at most once per observable.
|
|
1971
|
-
* Avoids unnecessary recalculations.
|
|
2128
|
+
/**
|
|
2129
|
+
* Batch starts a transaction, at least for purposes of memoizing ComputedValues when nothing else does.
|
|
2130
|
+
* During a batch `onBecomeUnobserved` will be called at most once per observable.
|
|
2131
|
+
* Avoids unnecessary recalculations.
|
|
1972
2132
|
*/
|
|
1973
2133
|
function startBatch() {
|
|
1974
2134
|
if (globalState.inBatch === 0) {
|
|
@@ -2004,10 +2164,10 @@ function reportObserved(observable) {
|
|
|
2004
2164
|
checkIfStateReadsAreAllowed(observable);
|
|
2005
2165
|
var derivation = globalState.trackingDerivation;
|
|
2006
2166
|
if (derivation !== null) {
|
|
2007
|
-
/**
|
|
2008
|
-
* Simple optimization, give each derivation run an unique id (runId)
|
|
2009
|
-
* Check if last time this observable was accessed the same runId is used
|
|
2010
|
-
* if this is the case, the relation is already known
|
|
2167
|
+
/**
|
|
2168
|
+
* Simple optimization, give each derivation run an unique id (runId)
|
|
2169
|
+
* Check if last time this observable was accessed the same runId is used
|
|
2170
|
+
* if this is the case, the relation is already known
|
|
2011
2171
|
*/
|
|
2012
2172
|
if (derivation.runId_ !== observable.lastAccessedBy_) {
|
|
2013
2173
|
observable.lastAccessedBy_ = derivation.runId_;
|
|
@@ -2037,12 +2197,12 @@ function reportObserved(observable) {
|
|
|
2037
2197
|
// observable.lowestObserverState
|
|
2038
2198
|
// )
|
|
2039
2199
|
// }
|
|
2040
|
-
/**
|
|
2041
|
-
* NOTE: current propagation mechanism will in case of self reruning autoruns behave unexpectedly
|
|
2042
|
-
* It will propagate changes to observers from previous run
|
|
2043
|
-
* It's hard or maybe impossible (with reasonable perf) to get it right with current approach
|
|
2044
|
-
* Hopefully self reruning autoruns aren't a feature people should depend on
|
|
2045
|
-
* Also most basic use cases should be ok
|
|
2200
|
+
/**
|
|
2201
|
+
* NOTE: current propagation mechanism will in case of self reruning autoruns behave unexpectedly
|
|
2202
|
+
* It will propagate changes to observers from previous run
|
|
2203
|
+
* It's hard or maybe impossible (with reasonable perf) to get it right with current approach
|
|
2204
|
+
* Hopefully self reruning autoruns aren't a feature people should depend on
|
|
2205
|
+
* Also most basic use cases should be ok
|
|
2046
2206
|
*/
|
|
2047
2207
|
// Called by Atom when its value changes
|
|
2048
2208
|
function propagateChanged(observable) {
|
|
@@ -2162,8 +2322,8 @@ var Reaction = /*#__PURE__*/function () {
|
|
|
2162
2322
|
_proto.isScheduled = function isScheduled() {
|
|
2163
2323
|
return this.isScheduled_;
|
|
2164
2324
|
}
|
|
2165
|
-
/**
|
|
2166
|
-
* internal, use schedule() if you intend to kick off a reaction
|
|
2325
|
+
/**
|
|
2326
|
+
* internal, use schedule() if you intend to kick off a reaction
|
|
2167
2327
|
*/;
|
|
2168
2328
|
_proto.runReaction_ = function runReaction_() {
|
|
2169
2329
|
if (!this.isDisposed_) {
|
|
@@ -2296,10 +2456,10 @@ function onReactionError(handler) {
|
|
|
2296
2456
|
}
|
|
2297
2457
|
};
|
|
2298
2458
|
}
|
|
2299
|
-
/**
|
|
2300
|
-
* Magic number alert!
|
|
2301
|
-
* Defines within how many times a reaction is allowed to re-trigger itself
|
|
2302
|
-
* until it is assumed that this is gonna be a never ending loop...
|
|
2459
|
+
/**
|
|
2460
|
+
* Magic number alert!
|
|
2461
|
+
* Defines within how many times a reaction is allowed to re-trigger itself
|
|
2462
|
+
* until it is assumed that this is gonna be a never ending loop...
|
|
2303
2463
|
*/
|
|
2304
2464
|
var MAX_REACTION_ITERATIONS = 100;
|
|
2305
2465
|
var reactionScheduler = function reactionScheduler(f) {
|
|
@@ -2423,6 +2583,10 @@ function createActionFactory(autoAction) {
|
|
|
2423
2583
|
if (isFunction(arg2)) {
|
|
2424
2584
|
return createAction(arg1, arg2, autoAction);
|
|
2425
2585
|
}
|
|
2586
|
+
// @action (2022.3 Decorators)
|
|
2587
|
+
if (is20223Decorator(arg2)) {
|
|
2588
|
+
return (autoAction ? autoActionAnnotation : actionAnnotation).decorate_20223_(arg1, arg2);
|
|
2589
|
+
}
|
|
2426
2590
|
// @action
|
|
2427
2591
|
if (isStringish(arg2)) {
|
|
2428
2592
|
return storeAnnotation(arg1, arg2, autoAction ? autoActionAnnotation : actionAnnotation);
|
|
@@ -2453,11 +2617,11 @@ function isAction(thing) {
|
|
|
2453
2617
|
return isFunction(thing) && thing.isMobxAction === true;
|
|
2454
2618
|
}
|
|
2455
2619
|
|
|
2456
|
-
/**
|
|
2457
|
-
* Creates a named reactive view and keeps it alive, so that the view is always
|
|
2458
|
-
* updated if one of the dependencies changes, even when the view is not further used by something else.
|
|
2459
|
-
* @param view The reactive view
|
|
2460
|
-
* @returns disposer function, which can be used to stop the view from being updated in the future.
|
|
2620
|
+
/**
|
|
2621
|
+
* Creates a named reactive view and keeps it alive, so that the view is always
|
|
2622
|
+
* updated if one of the dependencies changes, even when the view is not further used by something else.
|
|
2623
|
+
* @param view The reactive view
|
|
2624
|
+
* @returns disposer function, which can be used to stop the view from being updated in the future.
|
|
2461
2625
|
*/
|
|
2462
2626
|
function autorun(view, opts) {
|
|
2463
2627
|
var _opts$name, _opts, _opts2, _opts2$signal, _opts3;
|
|
@@ -2713,6 +2877,10 @@ var flowBoundAnnotation = /*#__PURE__*/createFlowAnnotation("flow.bound", {
|
|
|
2713
2877
|
bound: true
|
|
2714
2878
|
});
|
|
2715
2879
|
var flow = /*#__PURE__*/Object.assign(function flow(arg1, arg2) {
|
|
2880
|
+
// @flow (2022.3 Decorators)
|
|
2881
|
+
if (is20223Decorator(arg2)) {
|
|
2882
|
+
return flowAnnotation.decorate_20223_(arg1, arg2);
|
|
2883
|
+
}
|
|
2716
2884
|
// @flow
|
|
2717
2885
|
if (isStringish(arg2)) {
|
|
2718
2886
|
return storeAnnotation(arg1, arg2, flowAnnotation);
|
|
@@ -3099,11 +3267,11 @@ function toJSHelper(source, __alreadySeen) {
|
|
|
3099
3267
|
return _res3;
|
|
3100
3268
|
}
|
|
3101
3269
|
}
|
|
3102
|
-
/**
|
|
3103
|
-
* Recursively converts an observable to it's non-observable native counterpart.
|
|
3104
|
-
* It does NOT recurse into non-observables, these are left as they are, even if they contain observables.
|
|
3105
|
-
* Computed and other non-enumerable properties are completely ignored.
|
|
3106
|
-
* Complex scenarios require custom solution, eg implementing `toJSON` or using `serializr` lib.
|
|
3270
|
+
/**
|
|
3271
|
+
* Recursively converts an observable to it's non-observable native counterpart.
|
|
3272
|
+
* It does NOT recurse into non-observables, these are left as they are, even if they contain observables.
|
|
3273
|
+
* Computed and other non-enumerable properties are completely ignored.
|
|
3274
|
+
* Complex scenarios require custom solution, eg implementing `toJSON` or using `serializr` lib.
|
|
3107
3275
|
*/
|
|
3108
3276
|
function toJS(source, options) {
|
|
3109
3277
|
if (process.env.NODE_ENV !== "production" && options) {
|
|
@@ -3143,12 +3311,12 @@ function getAtomFromArgs(args) {
|
|
|
3143
3311
|
}
|
|
3144
3312
|
}
|
|
3145
3313
|
|
|
3146
|
-
/**
|
|
3147
|
-
* During a transaction no views are updated until the end of the transaction.
|
|
3148
|
-
* The transaction will be run synchronously nonetheless.
|
|
3149
|
-
*
|
|
3150
|
-
* @param action a function that updates some reactive state
|
|
3151
|
-
* @returns any value that was returned by the 'action' parameter.
|
|
3314
|
+
/**
|
|
3315
|
+
* During a transaction no views are updated until the end of the transaction.
|
|
3316
|
+
* The transaction will be run synchronously nonetheless.
|
|
3317
|
+
*
|
|
3318
|
+
* @param action a function that updates some reactive state
|
|
3319
|
+
* @returns any value that was returned by the 'action' parameter.
|
|
3152
3320
|
*/
|
|
3153
3321
|
function transaction(action, thisArg) {
|
|
3154
3322
|
if (thisArg === void 0) {
|
|
@@ -3736,11 +3904,11 @@ var arrayExtensions = {
|
|
|
3736
3904
|
toJSON: function toJSON() {
|
|
3737
3905
|
return this.slice();
|
|
3738
3906
|
},
|
|
3739
|
-
/*
|
|
3740
|
-
* functions that do alter the internal structure of the array, (based on lib.es6.d.ts)
|
|
3741
|
-
* since these functions alter the inner structure of the array, the have side effects.
|
|
3742
|
-
* Because the have side effects, they should not be used in computed function,
|
|
3743
|
-
* and for that reason the do not call dependencyState.notifyObserved
|
|
3907
|
+
/*
|
|
3908
|
+
* functions that do alter the internal structure of the array, (based on lib.es6.d.ts)
|
|
3909
|
+
* since these functions alter the inner structure of the array, the have side effects.
|
|
3910
|
+
* Because the have side effects, they should not be used in computed function,
|
|
3911
|
+
* and for that reason the do not call dependencyState.notifyObserved
|
|
3744
3912
|
*/
|
|
3745
3913
|
splice: function splice(index, deleteCount) {
|
|
3746
3914
|
for (var _len = arguments.length, newItems = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
@@ -3812,10 +3980,10 @@ var arrayExtensions = {
|
|
|
3812
3980
|
return false;
|
|
3813
3981
|
}
|
|
3814
3982
|
};
|
|
3815
|
-
/**
|
|
3816
|
-
* Wrap function from prototype
|
|
3817
|
-
* Without this, everything works as well, but this works
|
|
3818
|
-
* faster as everything works on unproxied values
|
|
3983
|
+
/**
|
|
3984
|
+
* Wrap function from prototype
|
|
3985
|
+
* Without this, everything works as well, but this works
|
|
3986
|
+
* faster as everything works on unproxied values
|
|
3819
3987
|
*/
|
|
3820
3988
|
addArrayExtension("concat", simpleFunc);
|
|
3821
3989
|
addArrayExtension("flat", simpleFunc);
|
|
@@ -4255,10 +4423,10 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4255
4423
|
_proto.toJSON = function toJSON() {
|
|
4256
4424
|
return Array.from(this);
|
|
4257
4425
|
};
|
|
4258
|
-
/**
|
|
4259
|
-
* Observes this object. Triggers for the events 'add', 'update' and 'delete'.
|
|
4260
|
-
* See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/observe
|
|
4261
|
-
* for callback details
|
|
4426
|
+
/**
|
|
4427
|
+
* Observes this object. Triggers for the events 'add', 'update' and 'delete'.
|
|
4428
|
+
* See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/observe
|
|
4429
|
+
* for callback details
|
|
4262
4430
|
*/
|
|
4263
4431
|
_proto.observe_ = function observe_(listener, fireImmediately) {
|
|
4264
4432
|
if (process.env.NODE_ENV !== "production" && fireImmediately === true) {
|
|
@@ -4634,12 +4802,12 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
4634
4802
|
}
|
|
4635
4803
|
return this.target_[key];
|
|
4636
4804
|
}
|
|
4637
|
-
/**
|
|
4638
|
-
* @param {PropertyKey} key
|
|
4639
|
-
* @param {any} value
|
|
4640
|
-
* @param {Annotation|boolean} annotation true - use default annotation, false - copy as is
|
|
4641
|
-
* @param {boolean} proxyTrap whether it's called from proxy trap
|
|
4642
|
-
* @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor
|
|
4805
|
+
/**
|
|
4806
|
+
* @param {PropertyKey} key
|
|
4807
|
+
* @param {any} value
|
|
4808
|
+
* @param {Annotation|boolean} annotation true - use default annotation, false - copy as is
|
|
4809
|
+
* @param {boolean} proxyTrap whether it's called from proxy trap
|
|
4810
|
+
* @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor
|
|
4643
4811
|
*/;
|
|
4644
4812
|
_proto.set_ = function set_(key, value, proxyTrap) {
|
|
4645
4813
|
if (proxyTrap === void 0) {
|
|
@@ -4684,9 +4852,9 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
4684
4852
|
}
|
|
4685
4853
|
return entry.get();
|
|
4686
4854
|
}
|
|
4687
|
-
/**
|
|
4688
|
-
* @param {PropertyKey} key
|
|
4689
|
-
* @param {Annotation|boolean} annotation true - use default annotation, false - ignore prop
|
|
4855
|
+
/**
|
|
4856
|
+
* @param {PropertyKey} key
|
|
4857
|
+
* @param {Annotation|boolean} annotation true - use default annotation, false - ignore prop
|
|
4690
4858
|
*/;
|
|
4691
4859
|
_proto.make_ = function make_(key, annotation) {
|
|
4692
4860
|
if (annotation === true) {
|
|
@@ -4714,10 +4882,10 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
4714
4882
|
var descriptor = getDescriptor(source, key);
|
|
4715
4883
|
if (descriptor) {
|
|
4716
4884
|
var outcome = annotation.make_(this, key, descriptor, source);
|
|
4717
|
-
if (outcome === 0 /* Cancel */) {
|
|
4885
|
+
if (outcome === 0 /* MakeResult.Cancel */) {
|
|
4718
4886
|
return;
|
|
4719
4887
|
}
|
|
4720
|
-
if (outcome === 1 /* Break */) {
|
|
4888
|
+
if (outcome === 1 /* MakeResult.Break */) {
|
|
4721
4889
|
break;
|
|
4722
4890
|
}
|
|
4723
4891
|
}
|
|
@@ -4725,12 +4893,12 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
4725
4893
|
}
|
|
4726
4894
|
recordAnnotationApplied(this, annotation, key);
|
|
4727
4895
|
}
|
|
4728
|
-
/**
|
|
4729
|
-
* @param {PropertyKey} key
|
|
4730
|
-
* @param {PropertyDescriptor} descriptor
|
|
4731
|
-
* @param {Annotation|boolean} annotation true - use default annotation, false - copy as is
|
|
4732
|
-
* @param {boolean} proxyTrap whether it's called from proxy trap
|
|
4733
|
-
* @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor
|
|
4896
|
+
/**
|
|
4897
|
+
* @param {PropertyKey} key
|
|
4898
|
+
* @param {PropertyDescriptor} descriptor
|
|
4899
|
+
* @param {Annotation|boolean} annotation true - use default annotation, false - copy as is
|
|
4900
|
+
* @param {boolean} proxyTrap whether it's called from proxy trap
|
|
4901
|
+
* @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor
|
|
4734
4902
|
*/;
|
|
4735
4903
|
_proto.extend_ = function extend_(key, descriptor, annotation, proxyTrap) {
|
|
4736
4904
|
if (proxyTrap === void 0) {
|
|
@@ -4749,11 +4917,11 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
4749
4917
|
}
|
|
4750
4918
|
return outcome;
|
|
4751
4919
|
}
|
|
4752
|
-
/**
|
|
4753
|
-
* @param {PropertyKey} key
|
|
4754
|
-
* @param {PropertyDescriptor} descriptor
|
|
4755
|
-
* @param {boolean} proxyTrap whether it's called from proxy trap
|
|
4756
|
-
* @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor
|
|
4920
|
+
/**
|
|
4921
|
+
* @param {PropertyKey} key
|
|
4922
|
+
* @param {PropertyDescriptor} descriptor
|
|
4923
|
+
* @param {boolean} proxyTrap whether it's called from proxy trap
|
|
4924
|
+
* @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor
|
|
4757
4925
|
*/;
|
|
4758
4926
|
_proto.defineProperty_ = function defineProperty_(key, descriptor, proxyTrap) {
|
|
4759
4927
|
if (proxyTrap === void 0) {
|
|
@@ -4905,11 +5073,11 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
4905
5073
|
}
|
|
4906
5074
|
return true;
|
|
4907
5075
|
}
|
|
4908
|
-
/**
|
|
4909
|
-
* @param {PropertyKey} key
|
|
4910
|
-
* @param {PropertyDescriptor} descriptor
|
|
4911
|
-
* @param {boolean} proxyTrap whether it's called from proxy trap
|
|
4912
|
-
* @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor
|
|
5076
|
+
/**
|
|
5077
|
+
* @param {PropertyKey} key
|
|
5078
|
+
* @param {PropertyDescriptor} descriptor
|
|
5079
|
+
* @param {boolean} proxyTrap whether it's called from proxy trap
|
|
5080
|
+
* @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor
|
|
4913
5081
|
*/;
|
|
4914
5082
|
_proto.delete_ = function delete_(key, proxyTrap) {
|
|
4915
5083
|
if (proxyTrap === void 0) {
|
|
@@ -4998,10 +5166,10 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
4998
5166
|
}
|
|
4999
5167
|
return true;
|
|
5000
5168
|
}
|
|
5001
|
-
/**
|
|
5002
|
-
* Observes this object. Triggers for the events 'add', 'update' and 'delete'.
|
|
5003
|
-
* See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/observe
|
|
5004
|
-
* for callback details
|
|
5169
|
+
/**
|
|
5170
|
+
* Observes this object. Triggers for the events 'add', 'update' and 'delete'.
|
|
5171
|
+
* See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/observe
|
|
5172
|
+
* for callback details
|
|
5005
5173
|
*/;
|
|
5006
5174
|
_proto.observe_ = function observe_(callback, fireImmediately) {
|
|
5007
5175
|
if (process.env.NODE_ENV !== "production" && fireImmediately === true) {
|
|
@@ -5104,35 +5272,35 @@ function assertAnnotable(adm, annotation, key) {
|
|
|
5104
5272
|
if (process.env.NODE_ENV !== "production" && !isAnnotation(annotation)) {
|
|
5105
5273
|
die("Cannot annotate '" + adm.name_ + "." + key.toString() + "': Invalid annotation.");
|
|
5106
5274
|
}
|
|
5107
|
-
/*
|
|
5108
|
-
// Configurable, not sealed, not frozen
|
|
5109
|
-
// Possibly not needed, just a little better error then the one thrown by engine.
|
|
5110
|
-
// Cases where this would be useful the most (subclass field initializer) are not interceptable by this.
|
|
5111
|
-
if (__DEV__) {
|
|
5112
|
-
const configurable = getDescriptor(adm.target_, key)?.configurable
|
|
5113
|
-
const frozen = Object.isFrozen(adm.target_)
|
|
5114
|
-
const sealed = Object.isSealed(adm.target_)
|
|
5115
|
-
if (!configurable || frozen || sealed) {
|
|
5116
|
-
const fieldName = `${adm.name_}.${key.toString()}`
|
|
5117
|
-
const requestedAnnotationType = annotation.annotationType_
|
|
5118
|
-
let error = `Cannot apply '${requestedAnnotationType}' to '${fieldName}':`
|
|
5119
|
-
if (frozen) {
|
|
5120
|
-
error += `\nObject is frozen.`
|
|
5121
|
-
}
|
|
5122
|
-
if (sealed) {
|
|
5123
|
-
error += `\nObject is sealed.`
|
|
5124
|
-
}
|
|
5125
|
-
if (!configurable) {
|
|
5126
|
-
error += `\nproperty is not configurable.`
|
|
5127
|
-
// Mention only if caused by us to avoid confusion
|
|
5128
|
-
if (hasProp(adm.appliedAnnotations!, key)) {
|
|
5129
|
-
error += `\nTo prevent accidental re-definition of a field by a subclass, `
|
|
5130
|
-
error += `all annotated fields of non-plain objects (classes) are not configurable.`
|
|
5131
|
-
}
|
|
5132
|
-
}
|
|
5133
|
-
die(error)
|
|
5134
|
-
}
|
|
5135
|
-
}
|
|
5275
|
+
/*
|
|
5276
|
+
// Configurable, not sealed, not frozen
|
|
5277
|
+
// Possibly not needed, just a little better error then the one thrown by engine.
|
|
5278
|
+
// Cases where this would be useful the most (subclass field initializer) are not interceptable by this.
|
|
5279
|
+
if (__DEV__) {
|
|
5280
|
+
const configurable = getDescriptor(adm.target_, key)?.configurable
|
|
5281
|
+
const frozen = Object.isFrozen(adm.target_)
|
|
5282
|
+
const sealed = Object.isSealed(adm.target_)
|
|
5283
|
+
if (!configurable || frozen || sealed) {
|
|
5284
|
+
const fieldName = `${adm.name_}.${key.toString()}`
|
|
5285
|
+
const requestedAnnotationType = annotation.annotationType_
|
|
5286
|
+
let error = `Cannot apply '${requestedAnnotationType}' to '${fieldName}':`
|
|
5287
|
+
if (frozen) {
|
|
5288
|
+
error += `\nObject is frozen.`
|
|
5289
|
+
}
|
|
5290
|
+
if (sealed) {
|
|
5291
|
+
error += `\nObject is sealed.`
|
|
5292
|
+
}
|
|
5293
|
+
if (!configurable) {
|
|
5294
|
+
error += `\nproperty is not configurable.`
|
|
5295
|
+
// Mention only if caused by us to avoid confusion
|
|
5296
|
+
if (hasProp(adm.appliedAnnotations!, key)) {
|
|
5297
|
+
error += `\nTo prevent accidental re-definition of a field by a subclass, `
|
|
5298
|
+
error += `all annotated fields of non-plain objects (classes) are not configurable.`
|
|
5299
|
+
}
|
|
5300
|
+
}
|
|
5301
|
+
die(error)
|
|
5302
|
+
}
|
|
5303
|
+
}
|
|
5136
5304
|
*/
|
|
5137
5305
|
// Not annotated
|
|
5138
5306
|
if (process.env.NODE_ENV !== "production" && !isOverride(annotation) && hasProp(adm.appliedAnnotations_, key)) {
|
|
@@ -5156,10 +5324,10 @@ var safariPrototypeSetterInheritanceBug = /*#__PURE__*/function () {
|
|
|
5156
5324
|
/*#__PURE__*/Object.create(p)["0"] = 1;
|
|
5157
5325
|
return v === false;
|
|
5158
5326
|
}();
|
|
5159
|
-
/**
|
|
5160
|
-
* This array buffer contains two lists of properties, so that all arrays
|
|
5161
|
-
* can recycle their property definitions, which significantly improves performance of creating
|
|
5162
|
-
* properties on the fly.
|
|
5327
|
+
/**
|
|
5328
|
+
* This array buffer contains two lists of properties, so that all arrays
|
|
5329
|
+
* can recycle their property definitions, which significantly improves performance of creating
|
|
5330
|
+
* properties on the fly.
|
|
5163
5331
|
*/
|
|
5164
5332
|
var OBSERVABLE_ARRAY_BUFFER_SIZE = 0;
|
|
5165
5333
|
// Typescript workaround to make sure ObservableArray extends Array
|
|
@@ -5356,11 +5524,11 @@ function getDebugName(thing, property) {
|
|
|
5356
5524
|
}
|
|
5357
5525
|
return named.name_;
|
|
5358
5526
|
}
|
|
5359
|
-
/**
|
|
5360
|
-
* Helper function for initializing observable structures, it applies:
|
|
5361
|
-
* 1. allowStateChanges so we don't violate enforceActions.
|
|
5362
|
-
* 2. untracked so we don't accidentaly subscribe to anything observable accessed during init in case the observable is created inside derivation.
|
|
5363
|
-
* 3. batch to avoid state version updates
|
|
5527
|
+
/**
|
|
5528
|
+
* Helper function for initializing observable structures, it applies:
|
|
5529
|
+
* 1. allowStateChanges so we don't violate enforceActions.
|
|
5530
|
+
* 2. untracked so we don't accidentaly subscribe to anything observable accessed during init in case the observable is created inside derivation.
|
|
5531
|
+
* 3. batch to avoid state version updates
|
|
5364
5532
|
*/
|
|
5365
5533
|
function initObservable(cb) {
|
|
5366
5534
|
var derivation = untrackedStart();
|
|
@@ -5542,22 +5710,22 @@ function isAnnotation(thing) {
|
|
|
5542
5710
|
);
|
|
5543
5711
|
}
|
|
5544
5712
|
|
|
5545
|
-
/**
|
|
5546
|
-
* (c) Michel Weststrate 2015 - 2020
|
|
5547
|
-
* MIT Licensed
|
|
5548
|
-
*
|
|
5549
|
-
* Welcome to the mobx sources! To get a global overview of how MobX internally works,
|
|
5550
|
-
* this is a good place to start:
|
|
5551
|
-
* https://medium.com/@mweststrate/becoming-fully-reactive-an-in-depth-explanation-of-mobservable-55995262a254#.xvbh6qd74
|
|
5552
|
-
*
|
|
5553
|
-
* Source folders:
|
|
5554
|
-
* ===============
|
|
5555
|
-
*
|
|
5556
|
-
* - api/ Most of the public static methods exposed by the module can be found here.
|
|
5557
|
-
* - core/ Implementation of the MobX algorithm; atoms, derivations, reactions, dependency trees, optimizations. Cool stuff can be found here.
|
|
5558
|
-
* - types/ All the magic that is need to have observable objects, arrays and values is in this folder. Including the modifiers like `asFlat`.
|
|
5559
|
-
* - utils/ Utility stuff.
|
|
5560
|
-
*
|
|
5713
|
+
/**
|
|
5714
|
+
* (c) Michel Weststrate 2015 - 2020
|
|
5715
|
+
* MIT Licensed
|
|
5716
|
+
*
|
|
5717
|
+
* Welcome to the mobx sources! To get a global overview of how MobX internally works,
|
|
5718
|
+
* this is a good place to start:
|
|
5719
|
+
* https://medium.com/@mweststrate/becoming-fully-reactive-an-in-depth-explanation-of-mobservable-55995262a254#.xvbh6qd74
|
|
5720
|
+
*
|
|
5721
|
+
* Source folders:
|
|
5722
|
+
* ===============
|
|
5723
|
+
*
|
|
5724
|
+
* - api/ Most of the public static methods exposed by the module can be found here.
|
|
5725
|
+
* - core/ Implementation of the MobX algorithm; atoms, derivations, reactions, dependency trees, optimizations. Cool stuff can be found here.
|
|
5726
|
+
* - types/ All the magic that is need to have observable objects, arrays and values is in this folder. Including the modifiers like `asFlat`.
|
|
5727
|
+
* - utils/ Utility stuff.
|
|
5728
|
+
*
|
|
5561
5729
|
*/
|
|
5562
5730
|
["Symbol", "Map", "Set"].forEach(function (m) {
|
|
5563
5731
|
var g = getGlobal();
|