mobx 6.10.2 → 6.11.0
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 +9 -0
- package/README.md +2 -2
- 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 +419 -252
- 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 +419 -252
- package/dist/mobx.esm.development.js.map +1 -1
- package/dist/mobx.esm.js +419 -252
- 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 +419 -252
- 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 +98 -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 +33 -8
- package/src/api/flow.ts +10 -3
- package/src/api/observable.ts +20 -6
- 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/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("The decorator applied to '" + String(context.name) + "' cannot be used on a " + context.kind + " element");
|
|
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,15 +462,15 @@ 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
476
|
if (!globalState.inBatch || this.batchId_ !== globalState.batchId) {
|
|
@@ -604,7 +618,8 @@ var OVERRIDE = "override";
|
|
|
604
618
|
var override = /*#__PURE__*/createDecoratorAnnotation({
|
|
605
619
|
annotationType_: OVERRIDE,
|
|
606
620
|
make_: make_,
|
|
607
|
-
extend_: extend_
|
|
621
|
+
extend_: extend_,
|
|
622
|
+
decorate_20223_: decorate_20223_
|
|
608
623
|
});
|
|
609
624
|
function isOverride(annotation) {
|
|
610
625
|
return annotation.annotationType_ === OVERRIDE;
|
|
@@ -618,47 +633,87 @@ function make_(adm, key) {
|
|
|
618
633
|
if (process.env.NODE_ENV !== "production" && !hasProp(adm.appliedAnnotations_, key)) {
|
|
619
634
|
die("'" + adm.name_ + "." + key.toString() + "' is annotated with '" + this.annotationType_ + "', " + "but no such annotated member was found on prototype.");
|
|
620
635
|
}
|
|
621
|
-
return 0 /* Cancel */;
|
|
636
|
+
return 0 /* MakeResult.Cancel */;
|
|
622
637
|
}
|
|
623
638
|
|
|
624
639
|
function extend_(adm, key, descriptor, proxyTrap) {
|
|
625
640
|
die("'" + this.annotationType_ + "' can only be used with 'makeObservable'");
|
|
626
641
|
}
|
|
642
|
+
function decorate_20223_(desc, context) {
|
|
643
|
+
console.warn("'" + this.annotationType_ + "' cannot be used with decorators - this is a no-op");
|
|
644
|
+
}
|
|
627
645
|
|
|
628
646
|
function createActionAnnotation(name, options) {
|
|
629
647
|
return {
|
|
630
648
|
annotationType_: name,
|
|
631
649
|
options_: options,
|
|
632
650
|
make_: make_$1,
|
|
633
|
-
extend_: extend_$1
|
|
651
|
+
extend_: extend_$1,
|
|
652
|
+
decorate_20223_: decorate_20223_$1
|
|
634
653
|
};
|
|
635
654
|
}
|
|
636
655
|
function make_$1(adm, key, descriptor, source) {
|
|
637
656
|
var _this$options_;
|
|
638
657
|
// bound
|
|
639
658
|
if ((_this$options_ = this.options_) != null && _this$options_.bound) {
|
|
640
|
-
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 */;
|
|
641
660
|
}
|
|
642
661
|
// own
|
|
643
662
|
if (source === adm.target_) {
|
|
644
|
-
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 */;
|
|
645
664
|
}
|
|
646
665
|
// prototype
|
|
647
666
|
if (isAction(descriptor.value)) {
|
|
648
667
|
// A prototype could have been annotated already by other constructor,
|
|
649
668
|
// rest of the proto chain must be annotated already
|
|
650
|
-
return 1 /* Break */;
|
|
669
|
+
return 1 /* MakeResult.Break */;
|
|
651
670
|
}
|
|
652
671
|
|
|
653
672
|
var actionDescriptor = createActionDescriptor(adm, this, key, descriptor, false);
|
|
654
673
|
defineProperty(source, key, actionDescriptor);
|
|
655
|
-
return 2 /* Continue */;
|
|
674
|
+
return 2 /* MakeResult.Continue */;
|
|
656
675
|
}
|
|
657
676
|
|
|
658
677
|
function extend_$1(adm, key, descriptor, proxyTrap) {
|
|
659
678
|
var actionDescriptor = createActionDescriptor(adm, this, key, descriptor);
|
|
660
679
|
return adm.defineProperty_(key, actionDescriptor, proxyTrap);
|
|
661
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
|
+
}
|
|
662
717
|
function assertActionDescriptor(adm, _ref, key, _ref2) {
|
|
663
718
|
var annotationType_ = _ref.annotationType_;
|
|
664
719
|
var value = _ref2.value;
|
|
@@ -699,32 +754,33 @@ function createFlowAnnotation(name, options) {
|
|
|
699
754
|
annotationType_: name,
|
|
700
755
|
options_: options,
|
|
701
756
|
make_: make_$2,
|
|
702
|
-
extend_: extend_$2
|
|
757
|
+
extend_: extend_$2,
|
|
758
|
+
decorate_20223_: decorate_20223_$2
|
|
703
759
|
};
|
|
704
760
|
}
|
|
705
761
|
function make_$2(adm, key, descriptor, source) {
|
|
706
762
|
var _this$options_;
|
|
707
763
|
// own
|
|
708
764
|
if (source === adm.target_) {
|
|
709
|
-
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 */;
|
|
710
766
|
}
|
|
711
767
|
// prototype
|
|
712
768
|
// bound - must annotate protos to support super.flow()
|
|
713
769
|
if ((_this$options_ = this.options_) != null && _this$options_.bound && (!hasProp(adm.target_, key) || !isFlow(adm.target_[key]))) {
|
|
714
770
|
if (this.extend_(adm, key, descriptor, false) === null) {
|
|
715
|
-
return 0 /* Cancel */;
|
|
771
|
+
return 0 /* MakeResult.Cancel */;
|
|
716
772
|
}
|
|
717
773
|
}
|
|
718
774
|
|
|
719
775
|
if (isFlow(descriptor.value)) {
|
|
720
776
|
// A prototype could have been annotated already by other constructor,
|
|
721
777
|
// rest of the proto chain must be annotated already
|
|
722
|
-
return 1 /* Break */;
|
|
778
|
+
return 1 /* MakeResult.Break */;
|
|
723
779
|
}
|
|
724
780
|
|
|
725
781
|
var flowDescriptor = createFlowDescriptor(adm, this, key, descriptor, false, false);
|
|
726
782
|
defineProperty(source, key, flowDescriptor);
|
|
727
|
-
return 2 /* Continue */;
|
|
783
|
+
return 2 /* MakeResult.Continue */;
|
|
728
784
|
}
|
|
729
785
|
|
|
730
786
|
function extend_$2(adm, key, descriptor, proxyTrap) {
|
|
@@ -732,6 +788,26 @@ function extend_$2(adm, key, descriptor, proxyTrap) {
|
|
|
732
788
|
var flowDescriptor = createFlowDescriptor(adm, this, key, descriptor, (_this$options_2 = this.options_) == null ? void 0 : _this$options_2.bound);
|
|
733
789
|
return adm.defineProperty_(key, flowDescriptor, proxyTrap);
|
|
734
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
|
+
}
|
|
735
811
|
function assertFlowDescriptor(adm, _ref, key, _ref2) {
|
|
736
812
|
var annotationType_ = _ref.annotationType_;
|
|
737
813
|
var value = _ref2.value;
|
|
@@ -776,11 +852,12 @@ function createComputedAnnotation(name, options) {
|
|
|
776
852
|
annotationType_: name,
|
|
777
853
|
options_: options,
|
|
778
854
|
make_: make_$3,
|
|
779
|
-
extend_: extend_$3
|
|
855
|
+
extend_: extend_$3,
|
|
856
|
+
decorate_20223_: decorate_20223_$3
|
|
780
857
|
};
|
|
781
858
|
}
|
|
782
859
|
function make_$3(adm, key, descriptor) {
|
|
783
|
-
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 */;
|
|
784
861
|
}
|
|
785
862
|
|
|
786
863
|
function extend_$3(adm, key, descriptor, proxyTrap) {
|
|
@@ -790,6 +867,26 @@ function extend_$3(adm, key, descriptor, proxyTrap) {
|
|
|
790
867
|
set: descriptor.set
|
|
791
868
|
}), proxyTrap);
|
|
792
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
|
+
}
|
|
793
890
|
function assertComputedDescriptor(adm, _ref, key, _ref2) {
|
|
794
891
|
var annotationType_ = _ref.annotationType_;
|
|
795
892
|
var get = _ref2.get;
|
|
@@ -803,11 +900,12 @@ function createObservableAnnotation(name, options) {
|
|
|
803
900
|
annotationType_: name,
|
|
804
901
|
options_: options,
|
|
805
902
|
make_: make_$4,
|
|
806
|
-
extend_: extend_$4
|
|
903
|
+
extend_: extend_$4,
|
|
904
|
+
decorate_20223_: decorate_20223_$4
|
|
807
905
|
};
|
|
808
906
|
}
|
|
809
907
|
function make_$4(adm, key, descriptor) {
|
|
810
|
-
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 */;
|
|
811
909
|
}
|
|
812
910
|
|
|
813
911
|
function extend_$4(adm, key, descriptor, proxyTrap) {
|
|
@@ -815,6 +913,55 @@ function extend_$4(adm, key, descriptor, proxyTrap) {
|
|
|
815
913
|
assertObservableDescriptor(adm, this, key, descriptor);
|
|
816
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);
|
|
817
915
|
}
|
|
916
|
+
function decorate_20223_$4(desc, context) {
|
|
917
|
+
if (process.env.NODE_ENV !== "production") {
|
|
918
|
+
if (context.kind === "field") {
|
|
919
|
+
throw die("Please use `@observable accessor " + String(context.name) + "` instead of `@observable " + String(context.name) + "`");
|
|
920
|
+
}
|
|
921
|
+
assert20223DecoratorType(context, ["accessor"]);
|
|
922
|
+
}
|
|
923
|
+
var ann = this;
|
|
924
|
+
var kind = context.kind,
|
|
925
|
+
name = context.name;
|
|
926
|
+
// The laziness here is not ideal... It's a workaround to how 2022.3 Decorators are implemented:
|
|
927
|
+
// `addInitializer` callbacks are executed _before_ any accessors are defined (instead of the ideal-for-us right after each).
|
|
928
|
+
// This means that, if we were to do our stuff in an `addInitializer`, we'd attempt to read a private slot
|
|
929
|
+
// before it has been initialized. The runtime doesn't like that and throws a `Cannot read private member
|
|
930
|
+
// from an object whose class did not declare it` error.
|
|
931
|
+
// TODO: it seems that this will not be required anymore in the final version of the spec
|
|
932
|
+
// See TODO: link
|
|
933
|
+
var initializedObjects = new WeakSet();
|
|
934
|
+
function initializeObservable(target, value) {
|
|
935
|
+
var _ann$options_$enhance, _ann$options_;
|
|
936
|
+
var adm = asObservableObject(target)[$mobx];
|
|
937
|
+
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);
|
|
938
|
+
adm.values_.set(name, observable);
|
|
939
|
+
initializedObjects.add(target);
|
|
940
|
+
}
|
|
941
|
+
if (kind == "accessor") {
|
|
942
|
+
return {
|
|
943
|
+
get: function get() {
|
|
944
|
+
if (!initializedObjects.has(this)) {
|
|
945
|
+
initializeObservable(this, desc.get.call(this));
|
|
946
|
+
}
|
|
947
|
+
return this[$mobx].getObservablePropValue_(name);
|
|
948
|
+
},
|
|
949
|
+
set: function set(value) {
|
|
950
|
+
if (!initializedObjects.has(this)) {
|
|
951
|
+
initializeObservable(this, value);
|
|
952
|
+
}
|
|
953
|
+
return this[$mobx].setObservablePropValue_(name, value);
|
|
954
|
+
},
|
|
955
|
+
init: function init(value) {
|
|
956
|
+
if (!initializedObjects.has(this)) {
|
|
957
|
+
initializeObservable(this, value);
|
|
958
|
+
}
|
|
959
|
+
return value;
|
|
960
|
+
}
|
|
961
|
+
};
|
|
962
|
+
}
|
|
963
|
+
return;
|
|
964
|
+
}
|
|
818
965
|
function assertObservableDescriptor(adm, _ref, key, descriptor) {
|
|
819
966
|
var annotationType_ = _ref.annotationType_;
|
|
820
967
|
if (process.env.NODE_ENV !== "production" && !("value" in descriptor)) {
|
|
@@ -829,7 +976,8 @@ function createAutoAnnotation(options) {
|
|
|
829
976
|
annotationType_: AUTO,
|
|
830
977
|
options_: options,
|
|
831
978
|
make_: make_$5,
|
|
832
|
-
extend_: extend_$5
|
|
979
|
+
extend_: extend_$5,
|
|
980
|
+
decorate_20223_: decorate_20223_$5
|
|
833
981
|
};
|
|
834
982
|
}
|
|
835
983
|
function make_$5(adm, key, descriptor, source) {
|
|
@@ -847,14 +995,14 @@ function make_$5(adm, key, descriptor, source) {
|
|
|
847
995
|
return adm.defineProperty_(key, {
|
|
848
996
|
configurable: globalState.safeDescriptors ? adm.isPlainObject_ : true,
|
|
849
997
|
set: set
|
|
850
|
-
}) === null ? 0 /* Cancel */ : 2 /* Continue */;
|
|
998
|
+
}) === null ? 0 /* MakeResult.Cancel */ : 2 /* MakeResult.Continue */;
|
|
851
999
|
}
|
|
852
1000
|
// proto
|
|
853
1001
|
defineProperty(source, key, {
|
|
854
1002
|
configurable: true,
|
|
855
1003
|
set: set
|
|
856
1004
|
});
|
|
857
|
-
return 2 /* Continue */;
|
|
1005
|
+
return 2 /* MakeResult.Continue */;
|
|
858
1006
|
}
|
|
859
1007
|
// function on proto -> autoAction/flow
|
|
860
1008
|
if (source !== adm.target_ && typeof descriptor.value === "function") {
|
|
@@ -901,6 +1049,9 @@ function extend_$5(adm, key, descriptor, proxyTrap) {
|
|
|
901
1049
|
var observableAnnotation = ((_this$options_6 = this.options_) == null ? void 0 : _this$options_6.deep) === false ? observable.ref : observable;
|
|
902
1050
|
return observableAnnotation.extend_(adm, key, descriptor, proxyTrap);
|
|
903
1051
|
}
|
|
1052
|
+
function decorate_20223_$5(desc, context) {
|
|
1053
|
+
die("'" + this.annotationType_ + "' cannot be used as a decorator");
|
|
1054
|
+
}
|
|
904
1055
|
|
|
905
1056
|
var OBSERVABLE = "observable";
|
|
906
1057
|
var OBSERVABLE_REF = "observable.ref";
|
|
@@ -940,11 +1091,15 @@ function getEnhancerFromAnnotation(annotation) {
|
|
|
940
1091
|
var _annotation$options_$, _annotation$options_;
|
|
941
1092
|
return !annotation ? deepEnhancer : (_annotation$options_$ = (_annotation$options_ = annotation.options_) == null ? void 0 : _annotation$options_.enhancer) != null ? _annotation$options_$ : deepEnhancer;
|
|
942
1093
|
}
|
|
943
|
-
/**
|
|
944
|
-
* Turns an object, array or function into a reactive structure.
|
|
945
|
-
* @param v the value which should become observable.
|
|
1094
|
+
/**
|
|
1095
|
+
* Turns an object, array or function into a reactive structure.
|
|
1096
|
+
* @param v the value which should become observable.
|
|
946
1097
|
*/
|
|
947
1098
|
function createObservable(v, arg2, arg3) {
|
|
1099
|
+
// @observable someProp; (2022.3 Decorators)
|
|
1100
|
+
if (is20223Decorator(arg2)) {
|
|
1101
|
+
return observableAnnotation.decorate_20223_(v, arg2);
|
|
1102
|
+
}
|
|
948
1103
|
// @observable someProp;
|
|
949
1104
|
if (isStringish(arg2)) {
|
|
950
1105
|
storeAnnotation(v, arg2, observableAnnotation);
|
|
@@ -1014,11 +1169,15 @@ var computedAnnotation = /*#__PURE__*/createComputedAnnotation(COMPUTED);
|
|
|
1014
1169
|
var computedStructAnnotation = /*#__PURE__*/createComputedAnnotation(COMPUTED_STRUCT, {
|
|
1015
1170
|
equals: comparer.structural
|
|
1016
1171
|
});
|
|
1017
|
-
/**
|
|
1018
|
-
* Decorator for class properties: @computed get value() { return expr; }.
|
|
1019
|
-
* For legacy purposes also invokable as ES5 observable created: `computed(() => expr)`;
|
|
1172
|
+
/**
|
|
1173
|
+
* Decorator for class properties: @computed get value() { return expr; }.
|
|
1174
|
+
* For legacy purposes also invokable as ES5 observable created: `computed(() => expr)`;
|
|
1020
1175
|
*/
|
|
1021
1176
|
var computed = function computed(arg1, arg2) {
|
|
1177
|
+
if (is20223Decorator(arg2)) {
|
|
1178
|
+
// @computed (2022.3 Decorators)
|
|
1179
|
+
return computedAnnotation.decorate_20223_(arg1, arg2);
|
|
1180
|
+
}
|
|
1022
1181
|
if (isStringish(arg2)) {
|
|
1023
1182
|
// @computed
|
|
1024
1183
|
return storeAnnotation(arg1, arg2, computedAnnotation);
|
|
@@ -1305,24 +1464,24 @@ var ObservableValue = /*#__PURE__*/function (_Atom) {
|
|
|
1305
1464
|
var isObservableValue = /*#__PURE__*/createInstanceofPredicate("ObservableValue", ObservableValue);
|
|
1306
1465
|
|
|
1307
1466
|
var _Symbol$toPrimitive$1;
|
|
1308
|
-
/**
|
|
1309
|
-
* A node in the state dependency root that observes other nodes, and can be observed itself.
|
|
1310
|
-
*
|
|
1311
|
-
* ComputedValue will remember the result of the computation for the duration of the batch, or
|
|
1312
|
-
* while being observed.
|
|
1313
|
-
*
|
|
1314
|
-
* During this time it will recompute only when one of its direct dependencies changed,
|
|
1315
|
-
* but only when it is being accessed with `ComputedValue.get()`.
|
|
1316
|
-
*
|
|
1317
|
-
* Implementation description:
|
|
1318
|
-
* 1. First time it's being accessed it will compute and remember result
|
|
1319
|
-
* give back remembered result until 2. happens
|
|
1320
|
-
* 2. First time any deep dependency change, propagate POSSIBLY_STALE to all observers, wait for 3.
|
|
1321
|
-
* 3. When it's being accessed, recompute if any shallow dependency changed.
|
|
1322
|
-
* if result changed: propagate STALE to all observers, that were POSSIBLY_STALE from the last step.
|
|
1323
|
-
* go to step 2. either way
|
|
1324
|
-
*
|
|
1325
|
-
* If at any point it's outside batch and it isn't observed: reset everything and go to 1.
|
|
1467
|
+
/**
|
|
1468
|
+
* A node in the state dependency root that observes other nodes, and can be observed itself.
|
|
1469
|
+
*
|
|
1470
|
+
* ComputedValue will remember the result of the computation for the duration of the batch, or
|
|
1471
|
+
* while being observed.
|
|
1472
|
+
*
|
|
1473
|
+
* During this time it will recompute only when one of its direct dependencies changed,
|
|
1474
|
+
* but only when it is being accessed with `ComputedValue.get()`.
|
|
1475
|
+
*
|
|
1476
|
+
* Implementation description:
|
|
1477
|
+
* 1. First time it's being accessed it will compute and remember result
|
|
1478
|
+
* give back remembered result until 2. happens
|
|
1479
|
+
* 2. First time any deep dependency change, propagate POSSIBLY_STALE to all observers, wait for 3.
|
|
1480
|
+
* 3. When it's being accessed, recompute if any shallow dependency changed.
|
|
1481
|
+
* if result changed: propagate STALE to all observers, that were POSSIBLY_STALE from the last step.
|
|
1482
|
+
* go to step 2. either way
|
|
1483
|
+
*
|
|
1484
|
+
* If at any point it's outside batch and it isn't observed: reset everything and go to 1.
|
|
1326
1485
|
*/
|
|
1327
1486
|
_Symbol$toPrimitive$1 = Symbol.toPrimitive;
|
|
1328
1487
|
var ComputedValue = /*#__PURE__*/function () {
|
|
@@ -1333,17 +1492,17 @@ var ComputedValue = /*#__PURE__*/function () {
|
|
|
1333
1492
|
|
|
1334
1493
|
// N.B: unminified as it is used by MST
|
|
1335
1494
|
|
|
1336
|
-
/**
|
|
1337
|
-
* Create a new computed value based on a function expression.
|
|
1338
|
-
*
|
|
1339
|
-
* The `name` property is for debug purposes only.
|
|
1340
|
-
*
|
|
1341
|
-
* The `equals` property specifies the comparer function to use to determine if a newly produced
|
|
1342
|
-
* value differs from the previous value. Two comparers are provided in the library; `defaultComparer`
|
|
1343
|
-
* compares based on identity comparison (===), and `structuralComparer` deeply compares the structure.
|
|
1344
|
-
* Structural comparison can be convenient if you always produce a new aggregated object and
|
|
1345
|
-
* don't want to notify observers if it is structurally the same.
|
|
1346
|
-
* This is useful for working with vectors, mouse coordinates etc.
|
|
1495
|
+
/**
|
|
1496
|
+
* Create a new computed value based on a function expression.
|
|
1497
|
+
*
|
|
1498
|
+
* The `name` property is for debug purposes only.
|
|
1499
|
+
*
|
|
1500
|
+
* The `equals` property specifies the comparer function to use to determine if a newly produced
|
|
1501
|
+
* value differs from the previous value. Two comparers are provided in the library; `defaultComparer`
|
|
1502
|
+
* compares based on identity comparison (===), and `structuralComparer` deeply compares the structure.
|
|
1503
|
+
* Structural comparison can be convenient if you always produce a new aggregated object and
|
|
1504
|
+
* don't want to notify observers if it is structurally the same.
|
|
1505
|
+
* This is useful for working with vectors, mouse coordinates etc.
|
|
1347
1506
|
*/
|
|
1348
1507
|
function ComputedValue(options) {
|
|
1349
1508
|
this.dependenciesState_ = IDerivationState_.NOT_TRACKING_;
|
|
@@ -1402,9 +1561,9 @@ var ComputedValue = /*#__PURE__*/function () {
|
|
|
1402
1561
|
});
|
|
1403
1562
|
}
|
|
1404
1563
|
}
|
|
1405
|
-
/**
|
|
1406
|
-
* Returns the current value of this computed value.
|
|
1407
|
-
* Will evaluate its computation first if needed.
|
|
1564
|
+
/**
|
|
1565
|
+
* Returns the current value of this computed value.
|
|
1566
|
+
* Will evaluate its computation first if needed.
|
|
1408
1567
|
*/;
|
|
1409
1568
|
_proto.get = function get() {
|
|
1410
1569
|
if (this.isComputing_) {
|
|
@@ -1587,16 +1746,16 @@ var CaughtException = function CaughtException(cause) {
|
|
|
1587
1746
|
function isCaughtException(e) {
|
|
1588
1747
|
return e instanceof CaughtException;
|
|
1589
1748
|
}
|
|
1590
|
-
/**
|
|
1591
|
-
* Finds out whether any dependency of the derivation has actually changed.
|
|
1592
|
-
* If dependenciesState is 1 then it will recalculate dependencies,
|
|
1593
|
-
* if any dependency changed it will propagate it by changing dependenciesState to 2.
|
|
1594
|
-
*
|
|
1595
|
-
* By iterating over the dependencies in the same order that they were reported and
|
|
1596
|
-
* stopping on the first change, all the recalculations are only called for ComputedValues
|
|
1597
|
-
* that will be tracked by derivation. That is because we assume that if the first x
|
|
1598
|
-
* dependencies of the derivation doesn't change then the derivation should run the same way
|
|
1599
|
-
* up until accessing x-th dependency.
|
|
1749
|
+
/**
|
|
1750
|
+
* Finds out whether any dependency of the derivation has actually changed.
|
|
1751
|
+
* If dependenciesState is 1 then it will recalculate dependencies,
|
|
1752
|
+
* if any dependency changed it will propagate it by changing dependenciesState to 2.
|
|
1753
|
+
*
|
|
1754
|
+
* By iterating over the dependencies in the same order that they were reported and
|
|
1755
|
+
* stopping on the first change, all the recalculations are only called for ComputedValues
|
|
1756
|
+
* that will be tracked by derivation. That is because we assume that if the first x
|
|
1757
|
+
* dependencies of the derivation doesn't change then the derivation should run the same way
|
|
1758
|
+
* up until accessing x-th dependency.
|
|
1600
1759
|
*/
|
|
1601
1760
|
function shouldCompute(derivation) {
|
|
1602
1761
|
switch (derivation.dependenciesState_) {
|
|
@@ -1663,10 +1822,10 @@ function checkIfStateReadsAreAllowed(observable) {
|
|
|
1663
1822
|
console.warn("[mobx] Observable '" + observable.name_ + "' being read outside a reactive context.");
|
|
1664
1823
|
}
|
|
1665
1824
|
}
|
|
1666
|
-
/**
|
|
1667
|
-
* Executes the provided function `f` and tracks which observables are being accessed.
|
|
1668
|
-
* The tracking information is stored on the `derivation` object and the derivation is registered
|
|
1669
|
-
* as observer of any of the accessed observables.
|
|
1825
|
+
/**
|
|
1826
|
+
* Executes the provided function `f` and tracks which observables are being accessed.
|
|
1827
|
+
* The tracking information is stored on the `derivation` object and the derivation is registered
|
|
1828
|
+
* as observer of any of the accessed observables.
|
|
1670
1829
|
*/
|
|
1671
1830
|
function trackDerivedFunction(derivation, f, context) {
|
|
1672
1831
|
var prevAllowStateReads = allowStateReadsStart(true);
|
|
@@ -1707,10 +1866,10 @@ function warnAboutDerivationWithoutDependencies(derivation) {
|
|
|
1707
1866
|
console.warn("[mobx] Derivation '" + derivation.name_ + "' is created/updated without reading any observable value.");
|
|
1708
1867
|
}
|
|
1709
1868
|
}
|
|
1710
|
-
/**
|
|
1711
|
-
* diffs newObserving with observing.
|
|
1712
|
-
* update observing to be newObserving with unique observables
|
|
1713
|
-
* notify observers that become observed/unobserved
|
|
1869
|
+
/**
|
|
1870
|
+
* diffs newObserving with observing.
|
|
1871
|
+
* update observing to be newObserving with unique observables
|
|
1872
|
+
* notify observers that become observed/unobserved
|
|
1714
1873
|
*/
|
|
1715
1874
|
function bindDependencies(derivation) {
|
|
1716
1875
|
// invariant(derivation.dependenciesState !== IDerivationState.NOT_TRACKING, "INTERNAL ERROR bindDependencies expects derivation.dependenciesState !== -1");
|
|
@@ -1801,9 +1960,9 @@ function allowStateReadsStart(allowStateReads) {
|
|
|
1801
1960
|
function allowStateReadsEnd(prev) {
|
|
1802
1961
|
globalState.allowStateReads = prev;
|
|
1803
1962
|
}
|
|
1804
|
-
/**
|
|
1805
|
-
* needed to keep `lowestObserverState` correct. when changing from (2 or 1) to 0
|
|
1806
|
-
*
|
|
1963
|
+
/**
|
|
1964
|
+
* needed to keep `lowestObserverState` correct. when changing from (2 or 1) to 0
|
|
1965
|
+
*
|
|
1807
1966
|
*/
|
|
1808
1967
|
function changeDependenciesStateTo0(derivation) {
|
|
1809
1968
|
if (derivation.dependenciesState_ === IDerivationState_.UP_TO_DATE_) {
|
|
@@ -1817,8 +1976,8 @@ function changeDependenciesStateTo0(derivation) {
|
|
|
1817
1976
|
}
|
|
1818
1977
|
}
|
|
1819
1978
|
|
|
1820
|
-
/**
|
|
1821
|
-
* These values will persist if global state is reset
|
|
1979
|
+
/**
|
|
1980
|
+
* These values will persist if global state is reset
|
|
1822
1981
|
*/
|
|
1823
1982
|
var persistentKeys = ["mobxGuid", "spyListeners", "enforceActions", "computedRequiresReaction", "reactionRequiresObservable", "observableRequiresReaction", "allowStateReads", "disableErrorBoundaries", "runId", "UNCHANGED", "useProxies"];
|
|
1824
1983
|
var MobXGlobals = function MobXGlobals() {
|
|
@@ -1894,9 +2053,9 @@ function isolateGlobalState() {
|
|
|
1894
2053
|
function getGlobalState() {
|
|
1895
2054
|
return globalState;
|
|
1896
2055
|
}
|
|
1897
|
-
/**
|
|
1898
|
-
* For testing purposes only; this will break the internal state of existing observables,
|
|
1899
|
-
* but can be used to get back at a stable state after throwing errors
|
|
2056
|
+
/**
|
|
2057
|
+
* For testing purposes only; this will break the internal state of existing observables,
|
|
2058
|
+
* but can be used to get back at a stable state after throwing errors
|
|
1900
2059
|
*/
|
|
1901
2060
|
function resetGlobalState() {
|
|
1902
2061
|
var defaultGlobals = new MobXGlobals();
|
|
@@ -1963,10 +2122,10 @@ function queueForUnobservation(observable) {
|
|
|
1963
2122
|
globalState.pendingUnobservations.push(observable);
|
|
1964
2123
|
}
|
|
1965
2124
|
}
|
|
1966
|
-
/**
|
|
1967
|
-
* Batch starts a transaction, at least for purposes of memoizing ComputedValues when nothing else does.
|
|
1968
|
-
* During a batch `onBecomeUnobserved` will be called at most once per observable.
|
|
1969
|
-
* Avoids unnecessary recalculations.
|
|
2125
|
+
/**
|
|
2126
|
+
* Batch starts a transaction, at least for purposes of memoizing ComputedValues when nothing else does.
|
|
2127
|
+
* During a batch `onBecomeUnobserved` will be called at most once per observable.
|
|
2128
|
+
* Avoids unnecessary recalculations.
|
|
1970
2129
|
*/
|
|
1971
2130
|
function startBatch() {
|
|
1972
2131
|
if (globalState.inBatch === 0) {
|
|
@@ -2002,10 +2161,10 @@ function reportObserved(observable) {
|
|
|
2002
2161
|
checkIfStateReadsAreAllowed(observable);
|
|
2003
2162
|
var derivation = globalState.trackingDerivation;
|
|
2004
2163
|
if (derivation !== null) {
|
|
2005
|
-
/**
|
|
2006
|
-
* Simple optimization, give each derivation run an unique id (runId)
|
|
2007
|
-
* Check if last time this observable was accessed the same runId is used
|
|
2008
|
-
* if this is the case, the relation is already known
|
|
2164
|
+
/**
|
|
2165
|
+
* Simple optimization, give each derivation run an unique id (runId)
|
|
2166
|
+
* Check if last time this observable was accessed the same runId is used
|
|
2167
|
+
* if this is the case, the relation is already known
|
|
2009
2168
|
*/
|
|
2010
2169
|
if (derivation.runId_ !== observable.lastAccessedBy_) {
|
|
2011
2170
|
observable.lastAccessedBy_ = derivation.runId_;
|
|
@@ -2035,12 +2194,12 @@ function reportObserved(observable) {
|
|
|
2035
2194
|
// observable.lowestObserverState
|
|
2036
2195
|
// )
|
|
2037
2196
|
// }
|
|
2038
|
-
/**
|
|
2039
|
-
* NOTE: current propagation mechanism will in case of self reruning autoruns behave unexpectedly
|
|
2040
|
-
* It will propagate changes to observers from previous run
|
|
2041
|
-
* It's hard or maybe impossible (with reasonable perf) to get it right with current approach
|
|
2042
|
-
* Hopefully self reruning autoruns aren't a feature people should depend on
|
|
2043
|
-
* Also most basic use cases should be ok
|
|
2197
|
+
/**
|
|
2198
|
+
* NOTE: current propagation mechanism will in case of self reruning autoruns behave unexpectedly
|
|
2199
|
+
* It will propagate changes to observers from previous run
|
|
2200
|
+
* It's hard or maybe impossible (with reasonable perf) to get it right with current approach
|
|
2201
|
+
* Hopefully self reruning autoruns aren't a feature people should depend on
|
|
2202
|
+
* Also most basic use cases should be ok
|
|
2044
2203
|
*/
|
|
2045
2204
|
// Called by Atom when its value changes
|
|
2046
2205
|
function propagateChanged(observable) {
|
|
@@ -2160,8 +2319,8 @@ var Reaction = /*#__PURE__*/function () {
|
|
|
2160
2319
|
_proto.isScheduled = function isScheduled() {
|
|
2161
2320
|
return this.isScheduled_;
|
|
2162
2321
|
}
|
|
2163
|
-
/**
|
|
2164
|
-
* internal, use schedule() if you intend to kick off a reaction
|
|
2322
|
+
/**
|
|
2323
|
+
* internal, use schedule() if you intend to kick off a reaction
|
|
2165
2324
|
*/;
|
|
2166
2325
|
_proto.runReaction_ = function runReaction_() {
|
|
2167
2326
|
if (!this.isDisposed_) {
|
|
@@ -2294,10 +2453,10 @@ function onReactionError(handler) {
|
|
|
2294
2453
|
}
|
|
2295
2454
|
};
|
|
2296
2455
|
}
|
|
2297
|
-
/**
|
|
2298
|
-
* Magic number alert!
|
|
2299
|
-
* Defines within how many times a reaction is allowed to re-trigger itself
|
|
2300
|
-
* until it is assumed that this is gonna be a never ending loop...
|
|
2456
|
+
/**
|
|
2457
|
+
* Magic number alert!
|
|
2458
|
+
* Defines within how many times a reaction is allowed to re-trigger itself
|
|
2459
|
+
* until it is assumed that this is gonna be a never ending loop...
|
|
2301
2460
|
*/
|
|
2302
2461
|
var MAX_REACTION_ITERATIONS = 100;
|
|
2303
2462
|
var reactionScheduler = function reactionScheduler(f) {
|
|
@@ -2421,6 +2580,10 @@ function createActionFactory(autoAction) {
|
|
|
2421
2580
|
if (isFunction(arg2)) {
|
|
2422
2581
|
return createAction(arg1, arg2, autoAction);
|
|
2423
2582
|
}
|
|
2583
|
+
// @action (2022.3 Decorators)
|
|
2584
|
+
if (is20223Decorator(arg2)) {
|
|
2585
|
+
return (autoAction ? autoActionAnnotation : actionAnnotation).decorate_20223_(arg1, arg2);
|
|
2586
|
+
}
|
|
2424
2587
|
// @action
|
|
2425
2588
|
if (isStringish(arg2)) {
|
|
2426
2589
|
return storeAnnotation(arg1, arg2, autoAction ? autoActionAnnotation : actionAnnotation);
|
|
@@ -2451,11 +2614,11 @@ function isAction(thing) {
|
|
|
2451
2614
|
return isFunction(thing) && thing.isMobxAction === true;
|
|
2452
2615
|
}
|
|
2453
2616
|
|
|
2454
|
-
/**
|
|
2455
|
-
* Creates a named reactive view and keeps it alive, so that the view is always
|
|
2456
|
-
* updated if one of the dependencies changes, even when the view is not further used by something else.
|
|
2457
|
-
* @param view The reactive view
|
|
2458
|
-
* @returns disposer function, which can be used to stop the view from being updated in the future.
|
|
2617
|
+
/**
|
|
2618
|
+
* Creates a named reactive view and keeps it alive, so that the view is always
|
|
2619
|
+
* updated if one of the dependencies changes, even when the view is not further used by something else.
|
|
2620
|
+
* @param view The reactive view
|
|
2621
|
+
* @returns disposer function, which can be used to stop the view from being updated in the future.
|
|
2459
2622
|
*/
|
|
2460
2623
|
function autorun(view, opts) {
|
|
2461
2624
|
var _opts$name, _opts, _opts2, _opts2$signal, _opts3;
|
|
@@ -2711,6 +2874,10 @@ var flowBoundAnnotation = /*#__PURE__*/createFlowAnnotation("flow.bound", {
|
|
|
2711
2874
|
bound: true
|
|
2712
2875
|
});
|
|
2713
2876
|
var flow = /*#__PURE__*/Object.assign(function flow(arg1, arg2) {
|
|
2877
|
+
// @flow (2022.3 Decorators)
|
|
2878
|
+
if (is20223Decorator(arg2)) {
|
|
2879
|
+
return flowAnnotation.decorate_20223_(arg1, arg2);
|
|
2880
|
+
}
|
|
2714
2881
|
// @flow
|
|
2715
2882
|
if (isStringish(arg2)) {
|
|
2716
2883
|
return storeAnnotation(arg1, arg2, flowAnnotation);
|
|
@@ -3097,11 +3264,11 @@ function toJSHelper(source, __alreadySeen) {
|
|
|
3097
3264
|
return _res3;
|
|
3098
3265
|
}
|
|
3099
3266
|
}
|
|
3100
|
-
/**
|
|
3101
|
-
* Recursively converts an observable to it's non-observable native counterpart.
|
|
3102
|
-
* It does NOT recurse into non-observables, these are left as they are, even if they contain observables.
|
|
3103
|
-
* Computed and other non-enumerable properties are completely ignored.
|
|
3104
|
-
* Complex scenarios require custom solution, eg implementing `toJSON` or using `serializr` lib.
|
|
3267
|
+
/**
|
|
3268
|
+
* Recursively converts an observable to it's non-observable native counterpart.
|
|
3269
|
+
* It does NOT recurse into non-observables, these are left as they are, even if they contain observables.
|
|
3270
|
+
* Computed and other non-enumerable properties are completely ignored.
|
|
3271
|
+
* Complex scenarios require custom solution, eg implementing `toJSON` or using `serializr` lib.
|
|
3105
3272
|
*/
|
|
3106
3273
|
function toJS(source, options) {
|
|
3107
3274
|
if (process.env.NODE_ENV !== "production" && options) {
|
|
@@ -3141,12 +3308,12 @@ function getAtomFromArgs(args) {
|
|
|
3141
3308
|
}
|
|
3142
3309
|
}
|
|
3143
3310
|
|
|
3144
|
-
/**
|
|
3145
|
-
* During a transaction no views are updated until the end of the transaction.
|
|
3146
|
-
* The transaction will be run synchronously nonetheless.
|
|
3147
|
-
*
|
|
3148
|
-
* @param action a function that updates some reactive state
|
|
3149
|
-
* @returns any value that was returned by the 'action' parameter.
|
|
3311
|
+
/**
|
|
3312
|
+
* During a transaction no views are updated until the end of the transaction.
|
|
3313
|
+
* The transaction will be run synchronously nonetheless.
|
|
3314
|
+
*
|
|
3315
|
+
* @param action a function that updates some reactive state
|
|
3316
|
+
* @returns any value that was returned by the 'action' parameter.
|
|
3150
3317
|
*/
|
|
3151
3318
|
function transaction(action, thisArg) {
|
|
3152
3319
|
if (thisArg === void 0) {
|
|
@@ -3734,11 +3901,11 @@ var arrayExtensions = {
|
|
|
3734
3901
|
toJSON: function toJSON() {
|
|
3735
3902
|
return this.slice();
|
|
3736
3903
|
},
|
|
3737
|
-
/*
|
|
3738
|
-
* functions that do alter the internal structure of the array, (based on lib.es6.d.ts)
|
|
3739
|
-
* since these functions alter the inner structure of the array, the have side effects.
|
|
3740
|
-
* Because the have side effects, they should not be used in computed function,
|
|
3741
|
-
* and for that reason the do not call dependencyState.notifyObserved
|
|
3904
|
+
/*
|
|
3905
|
+
* functions that do alter the internal structure of the array, (based on lib.es6.d.ts)
|
|
3906
|
+
* since these functions alter the inner structure of the array, the have side effects.
|
|
3907
|
+
* Because the have side effects, they should not be used in computed function,
|
|
3908
|
+
* and for that reason the do not call dependencyState.notifyObserved
|
|
3742
3909
|
*/
|
|
3743
3910
|
splice: function splice(index, deleteCount) {
|
|
3744
3911
|
for (var _len = arguments.length, newItems = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
@@ -3810,10 +3977,10 @@ var arrayExtensions = {
|
|
|
3810
3977
|
return false;
|
|
3811
3978
|
}
|
|
3812
3979
|
};
|
|
3813
|
-
/**
|
|
3814
|
-
* Wrap function from prototype
|
|
3815
|
-
* Without this, everything works as well, but this works
|
|
3816
|
-
* faster as everything works on unproxied values
|
|
3980
|
+
/**
|
|
3981
|
+
* Wrap function from prototype
|
|
3982
|
+
* Without this, everything works as well, but this works
|
|
3983
|
+
* faster as everything works on unproxied values
|
|
3817
3984
|
*/
|
|
3818
3985
|
addArrayExtension("concat", simpleFunc);
|
|
3819
3986
|
addArrayExtension("flat", simpleFunc);
|
|
@@ -4253,10 +4420,10 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4253
4420
|
_proto.toJSON = function toJSON() {
|
|
4254
4421
|
return Array.from(this);
|
|
4255
4422
|
};
|
|
4256
|
-
/**
|
|
4257
|
-
* Observes this object. Triggers for the events 'add', 'update' and 'delete'.
|
|
4258
|
-
* See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/observe
|
|
4259
|
-
* for callback details
|
|
4423
|
+
/**
|
|
4424
|
+
* Observes this object. Triggers for the events 'add', 'update' and 'delete'.
|
|
4425
|
+
* See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/observe
|
|
4426
|
+
* for callback details
|
|
4260
4427
|
*/
|
|
4261
4428
|
_proto.observe_ = function observe_(listener, fireImmediately) {
|
|
4262
4429
|
if (process.env.NODE_ENV !== "production" && fireImmediately === true) {
|
|
@@ -4632,12 +4799,12 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
4632
4799
|
}
|
|
4633
4800
|
return this.target_[key];
|
|
4634
4801
|
}
|
|
4635
|
-
/**
|
|
4636
|
-
* @param {PropertyKey} key
|
|
4637
|
-
* @param {any} value
|
|
4638
|
-
* @param {Annotation|boolean} annotation true - use default annotation, false - copy as is
|
|
4639
|
-
* @param {boolean} proxyTrap whether it's called from proxy trap
|
|
4640
|
-
* @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor
|
|
4802
|
+
/**
|
|
4803
|
+
* @param {PropertyKey} key
|
|
4804
|
+
* @param {any} value
|
|
4805
|
+
* @param {Annotation|boolean} annotation true - use default annotation, false - copy as is
|
|
4806
|
+
* @param {boolean} proxyTrap whether it's called from proxy trap
|
|
4807
|
+
* @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor
|
|
4641
4808
|
*/;
|
|
4642
4809
|
_proto.set_ = function set_(key, value, proxyTrap) {
|
|
4643
4810
|
if (proxyTrap === void 0) {
|
|
@@ -4682,9 +4849,9 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
4682
4849
|
}
|
|
4683
4850
|
return entry.get();
|
|
4684
4851
|
}
|
|
4685
|
-
/**
|
|
4686
|
-
* @param {PropertyKey} key
|
|
4687
|
-
* @param {Annotation|boolean} annotation true - use default annotation, false - ignore prop
|
|
4852
|
+
/**
|
|
4853
|
+
* @param {PropertyKey} key
|
|
4854
|
+
* @param {Annotation|boolean} annotation true - use default annotation, false - ignore prop
|
|
4688
4855
|
*/;
|
|
4689
4856
|
_proto.make_ = function make_(key, annotation) {
|
|
4690
4857
|
if (annotation === true) {
|
|
@@ -4712,10 +4879,10 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
4712
4879
|
var descriptor = getDescriptor(source, key);
|
|
4713
4880
|
if (descriptor) {
|
|
4714
4881
|
var outcome = annotation.make_(this, key, descriptor, source);
|
|
4715
|
-
if (outcome === 0 /* Cancel */) {
|
|
4882
|
+
if (outcome === 0 /* MakeResult.Cancel */) {
|
|
4716
4883
|
return;
|
|
4717
4884
|
}
|
|
4718
|
-
if (outcome === 1 /* Break */) {
|
|
4885
|
+
if (outcome === 1 /* MakeResult.Break */) {
|
|
4719
4886
|
break;
|
|
4720
4887
|
}
|
|
4721
4888
|
}
|
|
@@ -4723,12 +4890,12 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
4723
4890
|
}
|
|
4724
4891
|
recordAnnotationApplied(this, annotation, key);
|
|
4725
4892
|
}
|
|
4726
|
-
/**
|
|
4727
|
-
* @param {PropertyKey} key
|
|
4728
|
-
* @param {PropertyDescriptor} descriptor
|
|
4729
|
-
* @param {Annotation|boolean} annotation true - use default annotation, false - copy as is
|
|
4730
|
-
* @param {boolean} proxyTrap whether it's called from proxy trap
|
|
4731
|
-
* @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor
|
|
4893
|
+
/**
|
|
4894
|
+
* @param {PropertyKey} key
|
|
4895
|
+
* @param {PropertyDescriptor} descriptor
|
|
4896
|
+
* @param {Annotation|boolean} annotation true - use default annotation, false - copy as is
|
|
4897
|
+
* @param {boolean} proxyTrap whether it's called from proxy trap
|
|
4898
|
+
* @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor
|
|
4732
4899
|
*/;
|
|
4733
4900
|
_proto.extend_ = function extend_(key, descriptor, annotation, proxyTrap) {
|
|
4734
4901
|
if (proxyTrap === void 0) {
|
|
@@ -4747,11 +4914,11 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
4747
4914
|
}
|
|
4748
4915
|
return outcome;
|
|
4749
4916
|
}
|
|
4750
|
-
/**
|
|
4751
|
-
* @param {PropertyKey} key
|
|
4752
|
-
* @param {PropertyDescriptor} descriptor
|
|
4753
|
-
* @param {boolean} proxyTrap whether it's called from proxy trap
|
|
4754
|
-
* @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor
|
|
4917
|
+
/**
|
|
4918
|
+
* @param {PropertyKey} key
|
|
4919
|
+
* @param {PropertyDescriptor} descriptor
|
|
4920
|
+
* @param {boolean} proxyTrap whether it's called from proxy trap
|
|
4921
|
+
* @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor
|
|
4755
4922
|
*/;
|
|
4756
4923
|
_proto.defineProperty_ = function defineProperty_(key, descriptor, proxyTrap) {
|
|
4757
4924
|
if (proxyTrap === void 0) {
|
|
@@ -4903,11 +5070,11 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
4903
5070
|
}
|
|
4904
5071
|
return true;
|
|
4905
5072
|
}
|
|
4906
|
-
/**
|
|
4907
|
-
* @param {PropertyKey} key
|
|
4908
|
-
* @param {PropertyDescriptor} descriptor
|
|
4909
|
-
* @param {boolean} proxyTrap whether it's called from proxy trap
|
|
4910
|
-
* @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor
|
|
5073
|
+
/**
|
|
5074
|
+
* @param {PropertyKey} key
|
|
5075
|
+
* @param {PropertyDescriptor} descriptor
|
|
5076
|
+
* @param {boolean} proxyTrap whether it's called from proxy trap
|
|
5077
|
+
* @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor
|
|
4911
5078
|
*/;
|
|
4912
5079
|
_proto.delete_ = function delete_(key, proxyTrap) {
|
|
4913
5080
|
if (proxyTrap === void 0) {
|
|
@@ -4996,10 +5163,10 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
4996
5163
|
}
|
|
4997
5164
|
return true;
|
|
4998
5165
|
}
|
|
4999
|
-
/**
|
|
5000
|
-
* Observes this object. Triggers for the events 'add', 'update' and 'delete'.
|
|
5001
|
-
* See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/observe
|
|
5002
|
-
* for callback details
|
|
5166
|
+
/**
|
|
5167
|
+
* Observes this object. Triggers for the events 'add', 'update' and 'delete'.
|
|
5168
|
+
* See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/observe
|
|
5169
|
+
* for callback details
|
|
5003
5170
|
*/;
|
|
5004
5171
|
_proto.observe_ = function observe_(callback, fireImmediately) {
|
|
5005
5172
|
if (process.env.NODE_ENV !== "production" && fireImmediately === true) {
|
|
@@ -5102,35 +5269,35 @@ function assertAnnotable(adm, annotation, key) {
|
|
|
5102
5269
|
if (process.env.NODE_ENV !== "production" && !isAnnotation(annotation)) {
|
|
5103
5270
|
die("Cannot annotate '" + adm.name_ + "." + key.toString() + "': Invalid annotation.");
|
|
5104
5271
|
}
|
|
5105
|
-
/*
|
|
5106
|
-
// Configurable, not sealed, not frozen
|
|
5107
|
-
// Possibly not needed, just a little better error then the one thrown by engine.
|
|
5108
|
-
// Cases where this would be useful the most (subclass field initializer) are not interceptable by this.
|
|
5109
|
-
if (__DEV__) {
|
|
5110
|
-
const configurable = getDescriptor(adm.target_, key)?.configurable
|
|
5111
|
-
const frozen = Object.isFrozen(adm.target_)
|
|
5112
|
-
const sealed = Object.isSealed(adm.target_)
|
|
5113
|
-
if (!configurable || frozen || sealed) {
|
|
5114
|
-
const fieldName = `${adm.name_}.${key.toString()}`
|
|
5115
|
-
const requestedAnnotationType = annotation.annotationType_
|
|
5116
|
-
let error = `Cannot apply '${requestedAnnotationType}' to '${fieldName}':`
|
|
5117
|
-
if (frozen) {
|
|
5118
|
-
error += `\nObject is frozen.`
|
|
5119
|
-
}
|
|
5120
|
-
if (sealed) {
|
|
5121
|
-
error += `\nObject is sealed.`
|
|
5122
|
-
}
|
|
5123
|
-
if (!configurable) {
|
|
5124
|
-
error += `\nproperty is not configurable.`
|
|
5125
|
-
// Mention only if caused by us to avoid confusion
|
|
5126
|
-
if (hasProp(adm.appliedAnnotations!, key)) {
|
|
5127
|
-
error += `\nTo prevent accidental re-definition of a field by a subclass, `
|
|
5128
|
-
error += `all annotated fields of non-plain objects (classes) are not configurable.`
|
|
5129
|
-
}
|
|
5130
|
-
}
|
|
5131
|
-
die(error)
|
|
5132
|
-
}
|
|
5133
|
-
}
|
|
5272
|
+
/*
|
|
5273
|
+
// Configurable, not sealed, not frozen
|
|
5274
|
+
// Possibly not needed, just a little better error then the one thrown by engine.
|
|
5275
|
+
// Cases where this would be useful the most (subclass field initializer) are not interceptable by this.
|
|
5276
|
+
if (__DEV__) {
|
|
5277
|
+
const configurable = getDescriptor(adm.target_, key)?.configurable
|
|
5278
|
+
const frozen = Object.isFrozen(adm.target_)
|
|
5279
|
+
const sealed = Object.isSealed(adm.target_)
|
|
5280
|
+
if (!configurable || frozen || sealed) {
|
|
5281
|
+
const fieldName = `${adm.name_}.${key.toString()}`
|
|
5282
|
+
const requestedAnnotationType = annotation.annotationType_
|
|
5283
|
+
let error = `Cannot apply '${requestedAnnotationType}' to '${fieldName}':`
|
|
5284
|
+
if (frozen) {
|
|
5285
|
+
error += `\nObject is frozen.`
|
|
5286
|
+
}
|
|
5287
|
+
if (sealed) {
|
|
5288
|
+
error += `\nObject is sealed.`
|
|
5289
|
+
}
|
|
5290
|
+
if (!configurable) {
|
|
5291
|
+
error += `\nproperty is not configurable.`
|
|
5292
|
+
// Mention only if caused by us to avoid confusion
|
|
5293
|
+
if (hasProp(adm.appliedAnnotations!, key)) {
|
|
5294
|
+
error += `\nTo prevent accidental re-definition of a field by a subclass, `
|
|
5295
|
+
error += `all annotated fields of non-plain objects (classes) are not configurable.`
|
|
5296
|
+
}
|
|
5297
|
+
}
|
|
5298
|
+
die(error)
|
|
5299
|
+
}
|
|
5300
|
+
}
|
|
5134
5301
|
*/
|
|
5135
5302
|
// Not annotated
|
|
5136
5303
|
if (process.env.NODE_ENV !== "production" && !isOverride(annotation) && hasProp(adm.appliedAnnotations_, key)) {
|
|
@@ -5154,10 +5321,10 @@ var safariPrototypeSetterInheritanceBug = /*#__PURE__*/function () {
|
|
|
5154
5321
|
/*#__PURE__*/Object.create(p)["0"] = 1;
|
|
5155
5322
|
return v === false;
|
|
5156
5323
|
}();
|
|
5157
|
-
/**
|
|
5158
|
-
* This array buffer contains two lists of properties, so that all arrays
|
|
5159
|
-
* can recycle their property definitions, which significantly improves performance of creating
|
|
5160
|
-
* properties on the fly.
|
|
5324
|
+
/**
|
|
5325
|
+
* This array buffer contains two lists of properties, so that all arrays
|
|
5326
|
+
* can recycle their property definitions, which significantly improves performance of creating
|
|
5327
|
+
* properties on the fly.
|
|
5161
5328
|
*/
|
|
5162
5329
|
var OBSERVABLE_ARRAY_BUFFER_SIZE = 0;
|
|
5163
5330
|
// Typescript workaround to make sure ObservableArray extends Array
|
|
@@ -5354,11 +5521,11 @@ function getDebugName(thing, property) {
|
|
|
5354
5521
|
}
|
|
5355
5522
|
return named.name_;
|
|
5356
5523
|
}
|
|
5357
|
-
/**
|
|
5358
|
-
* Helper function for initializing observable structures, it applies:
|
|
5359
|
-
* 1. allowStateChanges so we don't violate enforceActions.
|
|
5360
|
-
* 2. untracked so we don't accidentaly subscribe to anything observable accessed during init in case the observable is created inside derivation.
|
|
5361
|
-
* 3. batch to avoid state version updates
|
|
5524
|
+
/**
|
|
5525
|
+
* Helper function for initializing observable structures, it applies:
|
|
5526
|
+
* 1. allowStateChanges so we don't violate enforceActions.
|
|
5527
|
+
* 2. untracked so we don't accidentaly subscribe to anything observable accessed during init in case the observable is created inside derivation.
|
|
5528
|
+
* 3. batch to avoid state version updates
|
|
5362
5529
|
*/
|
|
5363
5530
|
function initObservable(cb) {
|
|
5364
5531
|
var derivation = untrackedStart();
|
|
@@ -5540,22 +5707,22 @@ function isAnnotation(thing) {
|
|
|
5540
5707
|
);
|
|
5541
5708
|
}
|
|
5542
5709
|
|
|
5543
|
-
/**
|
|
5544
|
-
* (c) Michel Weststrate 2015 - 2020
|
|
5545
|
-
* MIT Licensed
|
|
5546
|
-
*
|
|
5547
|
-
* Welcome to the mobx sources! To get a global overview of how MobX internally works,
|
|
5548
|
-
* this is a good place to start:
|
|
5549
|
-
* https://medium.com/@mweststrate/becoming-fully-reactive-an-in-depth-explanation-of-mobservable-55995262a254#.xvbh6qd74
|
|
5550
|
-
*
|
|
5551
|
-
* Source folders:
|
|
5552
|
-
* ===============
|
|
5553
|
-
*
|
|
5554
|
-
* - api/ Most of the public static methods exposed by the module can be found here.
|
|
5555
|
-
* - core/ Implementation of the MobX algorithm; atoms, derivations, reactions, dependency trees, optimizations. Cool stuff can be found here.
|
|
5556
|
-
* - types/ All the magic that is need to have observable objects, arrays and values is in this folder. Including the modifiers like `asFlat`.
|
|
5557
|
-
* - utils/ Utility stuff.
|
|
5558
|
-
*
|
|
5710
|
+
/**
|
|
5711
|
+
* (c) Michel Weststrate 2015 - 2020
|
|
5712
|
+
* MIT Licensed
|
|
5713
|
+
*
|
|
5714
|
+
* Welcome to the mobx sources! To get a global overview of how MobX internally works,
|
|
5715
|
+
* this is a good place to start:
|
|
5716
|
+
* https://medium.com/@mweststrate/becoming-fully-reactive-an-in-depth-explanation-of-mobservable-55995262a254#.xvbh6qd74
|
|
5717
|
+
*
|
|
5718
|
+
* Source folders:
|
|
5719
|
+
* ===============
|
|
5720
|
+
*
|
|
5721
|
+
* - api/ Most of the public static methods exposed by the module can be found here.
|
|
5722
|
+
* - core/ Implementation of the MobX algorithm; atoms, derivations, reactions, dependency trees, optimizations. Cool stuff can be found here.
|
|
5723
|
+
* - types/ All the magic that is need to have observable objects, arrays and values is in this folder. Including the modifiers like `asFlat`.
|
|
5724
|
+
* - utils/ Utility stuff.
|
|
5725
|
+
*
|
|
5559
5726
|
*/
|
|
5560
5727
|
["Symbol", "Map", "Set"].forEach(function (m) {
|
|
5561
5728
|
var g = getGlobal();
|