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
|
@@ -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",
|
|
@@ -127,8 +127,8 @@ function warnAboutProxyRequirement(msg) {
|
|
|
127
127
|
function getNextId() {
|
|
128
128
|
return ++globalState.mobxGuid;
|
|
129
129
|
}
|
|
130
|
-
/**
|
|
131
|
-
* Makes sure that the provided function is invoked at most once.
|
|
130
|
+
/**
|
|
131
|
+
* Makes sure that the provided function is invoked at most once.
|
|
132
132
|
*/
|
|
133
133
|
function once(func) {
|
|
134
134
|
var invoked = false;
|
|
@@ -209,8 +209,8 @@ function isES6Set(thing) {
|
|
|
209
209
|
return thing instanceof Set;
|
|
210
210
|
}
|
|
211
211
|
var hasGetOwnPropertySymbols = typeof Object.getOwnPropertySymbols !== "undefined";
|
|
212
|
-
/**
|
|
213
|
-
* Returns the following: own enumerable keys and symbols.
|
|
212
|
+
/**
|
|
213
|
+
* Returns the following: own enumerable keys and symbols.
|
|
214
214
|
*/
|
|
215
215
|
function getPlainObjectKeys(object) {
|
|
216
216
|
var keys = Object.keys(object);
|
|
@@ -353,20 +353,24 @@ function _toPropertyKey(arg) {
|
|
|
353
353
|
}
|
|
354
354
|
|
|
355
355
|
var storedAnnotationsSymbol = /*#__PURE__*/Symbol("mobx-stored-annotations");
|
|
356
|
-
/**
|
|
357
|
-
* Creates a function that acts as
|
|
358
|
-
* - decorator
|
|
359
|
-
* - annotation object
|
|
356
|
+
/**
|
|
357
|
+
* Creates a function that acts as
|
|
358
|
+
* - decorator
|
|
359
|
+
* - annotation object
|
|
360
360
|
*/
|
|
361
361
|
function createDecoratorAnnotation(annotation) {
|
|
362
362
|
function decorator(target, property) {
|
|
363
|
-
|
|
363
|
+
if (is20223Decorator(property)) {
|
|
364
|
+
return annotation.decorate_20223_(target, property);
|
|
365
|
+
} else {
|
|
366
|
+
storeAnnotation(target, property, annotation);
|
|
367
|
+
}
|
|
364
368
|
}
|
|
365
369
|
return Object.assign(decorator, annotation);
|
|
366
370
|
}
|
|
367
|
-
/**
|
|
368
|
-
* Stores annotation to prototype,
|
|
369
|
-
* so it can be inspected later by `makeObservable` called from constructor
|
|
371
|
+
/**
|
|
372
|
+
* Stores annotation to prototype,
|
|
373
|
+
* so it can be inspected later by `makeObservable` called from constructor
|
|
370
374
|
*/
|
|
371
375
|
function storeAnnotation(prototype, key, annotation) {
|
|
372
376
|
if (!hasProp(prototype, storedAnnotationsSymbol)) {
|
|
@@ -392,27 +396,37 @@ function assertNotDecorated(prototype, annotation, key) {
|
|
|
392
396
|
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.");
|
|
393
397
|
}
|
|
394
398
|
}
|
|
395
|
-
/**
|
|
396
|
-
* Collects annotations from prototypes and stores them on target (instance)
|
|
399
|
+
/**
|
|
400
|
+
* Collects annotations from prototypes and stores them on target (instance)
|
|
397
401
|
*/
|
|
398
402
|
function collectStoredAnnotations(target) {
|
|
399
403
|
if (!hasProp(target, storedAnnotationsSymbol)) {
|
|
400
|
-
if ( !target[storedAnnotationsSymbol]) {
|
|
401
|
-
|
|
402
|
-
|
|
404
|
+
// if (__DEV__ && !target[storedAnnotationsSymbol]) {
|
|
405
|
+
// die(
|
|
406
|
+
// `No annotations were passed to makeObservable, but no decorated members have been found either`
|
|
407
|
+
// )
|
|
408
|
+
// }
|
|
403
409
|
// We need a copy as we will remove annotation from the list once it's applied.
|
|
404
410
|
addHiddenProp(target, storedAnnotationsSymbol, _extends({}, target[storedAnnotationsSymbol]));
|
|
405
411
|
}
|
|
406
412
|
return target[storedAnnotationsSymbol];
|
|
407
413
|
}
|
|
414
|
+
function is20223Decorator(context) {
|
|
415
|
+
return typeof context == "object" && typeof context["kind"] == "string";
|
|
416
|
+
}
|
|
417
|
+
function assert20223DecoratorType(context, types) {
|
|
418
|
+
if ( !types.includes(context.kind)) {
|
|
419
|
+
die("The decorator applied to '" + String(context.name) + "' cannot be used on a " + context.kind + " element");
|
|
420
|
+
}
|
|
421
|
+
}
|
|
408
422
|
|
|
409
423
|
var $mobx = /*#__PURE__*/Symbol("mobx administration");
|
|
410
424
|
var Atom = /*#__PURE__*/function () {
|
|
411
425
|
// for effective unobserving. BaseAtom has true, for extra optimization, so its onBecomeUnobserved never gets called, because it's not needed
|
|
412
426
|
|
|
413
|
-
/**
|
|
414
|
-
* Create a new atom. For debugging purposes it is recommended to give it a name.
|
|
415
|
-
* The onBecomeObserved and onBecomeUnobserved callbacks can be used for resource management.
|
|
427
|
+
/**
|
|
428
|
+
* Create a new atom. For debugging purposes it is recommended to give it a name.
|
|
429
|
+
* The onBecomeObserved and onBecomeUnobserved callbacks can be used for resource management.
|
|
416
430
|
*/
|
|
417
431
|
function Atom(name_) {
|
|
418
432
|
if (name_ === void 0) {
|
|
@@ -447,15 +461,15 @@ var Atom = /*#__PURE__*/function () {
|
|
|
447
461
|
});
|
|
448
462
|
}
|
|
449
463
|
}
|
|
450
|
-
/**
|
|
451
|
-
* Invoke this method to notify mobx that your atom has been used somehow.
|
|
452
|
-
* Returns true if there is currently a reactive context.
|
|
464
|
+
/**
|
|
465
|
+
* Invoke this method to notify mobx that your atom has been used somehow.
|
|
466
|
+
* Returns true if there is currently a reactive context.
|
|
453
467
|
*/;
|
|
454
468
|
_proto.reportObserved = function reportObserved$1() {
|
|
455
469
|
return reportObserved(this);
|
|
456
470
|
}
|
|
457
|
-
/**
|
|
458
|
-
* Invoke this method _after_ this method has changed to signal mobx that all its observers should invalidate.
|
|
471
|
+
/**
|
|
472
|
+
* Invoke this method _after_ this method has changed to signal mobx that all its observers should invalidate.
|
|
459
473
|
*/;
|
|
460
474
|
_proto.reportChanged = function reportChanged() {
|
|
461
475
|
if (!globalState.inBatch || this.batchId_ !== globalState.batchId) {
|
|
@@ -603,7 +617,8 @@ var OVERRIDE = "override";
|
|
|
603
617
|
var override = /*#__PURE__*/createDecoratorAnnotation({
|
|
604
618
|
annotationType_: OVERRIDE,
|
|
605
619
|
make_: make_,
|
|
606
|
-
extend_: extend_
|
|
620
|
+
extend_: extend_,
|
|
621
|
+
decorate_20223_: decorate_20223_
|
|
607
622
|
});
|
|
608
623
|
function isOverride(annotation) {
|
|
609
624
|
return annotation.annotationType_ === OVERRIDE;
|
|
@@ -617,47 +632,87 @@ function make_(adm, key) {
|
|
|
617
632
|
if ( !hasProp(adm.appliedAnnotations_, key)) {
|
|
618
633
|
die("'" + adm.name_ + "." + key.toString() + "' is annotated with '" + this.annotationType_ + "', " + "but no such annotated member was found on prototype.");
|
|
619
634
|
}
|
|
620
|
-
return 0 /* Cancel */;
|
|
635
|
+
return 0 /* MakeResult.Cancel */;
|
|
621
636
|
}
|
|
622
637
|
|
|
623
638
|
function extend_(adm, key, descriptor, proxyTrap) {
|
|
624
639
|
die("'" + this.annotationType_ + "' can only be used with 'makeObservable'");
|
|
625
640
|
}
|
|
641
|
+
function decorate_20223_(desc, context) {
|
|
642
|
+
console.warn("'" + this.annotationType_ + "' cannot be used with decorators - this is a no-op");
|
|
643
|
+
}
|
|
626
644
|
|
|
627
645
|
function createActionAnnotation(name, options) {
|
|
628
646
|
return {
|
|
629
647
|
annotationType_: name,
|
|
630
648
|
options_: options,
|
|
631
649
|
make_: make_$1,
|
|
632
|
-
extend_: extend_$1
|
|
650
|
+
extend_: extend_$1,
|
|
651
|
+
decorate_20223_: decorate_20223_$1
|
|
633
652
|
};
|
|
634
653
|
}
|
|
635
654
|
function make_$1(adm, key, descriptor, source) {
|
|
636
655
|
var _this$options_;
|
|
637
656
|
// bound
|
|
638
657
|
if ((_this$options_ = this.options_) != null && _this$options_.bound) {
|
|
639
|
-
return this.extend_(adm, key, descriptor, false) === null ? 0 /* Cancel */ : 1 /* Break */;
|
|
658
|
+
return this.extend_(adm, key, descriptor, false) === null ? 0 /* MakeResult.Cancel */ : 1 /* MakeResult.Break */;
|
|
640
659
|
}
|
|
641
660
|
// own
|
|
642
661
|
if (source === adm.target_) {
|
|
643
|
-
return this.extend_(adm, key, descriptor, false) === null ? 0 /* Cancel */ : 2 /* Continue */;
|
|
662
|
+
return this.extend_(adm, key, descriptor, false) === null ? 0 /* MakeResult.Cancel */ : 2 /* MakeResult.Continue */;
|
|
644
663
|
}
|
|
645
664
|
// prototype
|
|
646
665
|
if (isAction(descriptor.value)) {
|
|
647
666
|
// A prototype could have been annotated already by other constructor,
|
|
648
667
|
// rest of the proto chain must be annotated already
|
|
649
|
-
return 1 /* Break */;
|
|
668
|
+
return 1 /* MakeResult.Break */;
|
|
650
669
|
}
|
|
651
670
|
|
|
652
671
|
var actionDescriptor = createActionDescriptor(adm, this, key, descriptor, false);
|
|
653
672
|
defineProperty(source, key, actionDescriptor);
|
|
654
|
-
return 2 /* Continue */;
|
|
673
|
+
return 2 /* MakeResult.Continue */;
|
|
655
674
|
}
|
|
656
675
|
|
|
657
676
|
function extend_$1(adm, key, descriptor, proxyTrap) {
|
|
658
677
|
var actionDescriptor = createActionDescriptor(adm, this, key, descriptor);
|
|
659
678
|
return adm.defineProperty_(key, actionDescriptor, proxyTrap);
|
|
660
679
|
}
|
|
680
|
+
function decorate_20223_$1(mthd, context) {
|
|
681
|
+
{
|
|
682
|
+
assert20223DecoratorType(context, ["method", "field"]);
|
|
683
|
+
}
|
|
684
|
+
var kind = context.kind,
|
|
685
|
+
name = context.name,
|
|
686
|
+
addInitializer = context.addInitializer;
|
|
687
|
+
var ann = this;
|
|
688
|
+
var _createAction = function _createAction(m) {
|
|
689
|
+
var _ann$options_$name, _ann$options_, _ann$options_$autoAct, _ann$options_2;
|
|
690
|
+
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);
|
|
691
|
+
};
|
|
692
|
+
// Backwards/Legacy behavior, expects makeObservable(this)
|
|
693
|
+
if (kind == "field") {
|
|
694
|
+
addInitializer(function () {
|
|
695
|
+
storeAnnotation(this, name, ann);
|
|
696
|
+
});
|
|
697
|
+
return;
|
|
698
|
+
}
|
|
699
|
+
if (kind == "method") {
|
|
700
|
+
var _this$options_2;
|
|
701
|
+
if (!isAction(mthd)) {
|
|
702
|
+
mthd = _createAction(mthd);
|
|
703
|
+
}
|
|
704
|
+
if ((_this$options_2 = this.options_) != null && _this$options_2.bound) {
|
|
705
|
+
addInitializer(function () {
|
|
706
|
+
var self = this;
|
|
707
|
+
var bound = self[name].bind(self);
|
|
708
|
+
bound.isMobxAction = true;
|
|
709
|
+
self[name] = bound;
|
|
710
|
+
});
|
|
711
|
+
}
|
|
712
|
+
return mthd;
|
|
713
|
+
}
|
|
714
|
+
die("Cannot apply '" + ann.annotationType_ + "' to '" + String(name) + "' (kind: " + kind + "):" + ("\n'" + ann.annotationType_ + "' can only be used on properties with a function value."));
|
|
715
|
+
}
|
|
661
716
|
function assertActionDescriptor(adm, _ref, key, _ref2) {
|
|
662
717
|
var annotationType_ = _ref.annotationType_;
|
|
663
718
|
var value = _ref2.value;
|
|
@@ -698,32 +753,33 @@ function createFlowAnnotation(name, options) {
|
|
|
698
753
|
annotationType_: name,
|
|
699
754
|
options_: options,
|
|
700
755
|
make_: make_$2,
|
|
701
|
-
extend_: extend_$2
|
|
756
|
+
extend_: extend_$2,
|
|
757
|
+
decorate_20223_: decorate_20223_$2
|
|
702
758
|
};
|
|
703
759
|
}
|
|
704
760
|
function make_$2(adm, key, descriptor, source) {
|
|
705
761
|
var _this$options_;
|
|
706
762
|
// own
|
|
707
763
|
if (source === adm.target_) {
|
|
708
|
-
return this.extend_(adm, key, descriptor, false) === null ? 0 /* Cancel */ : 2 /* Continue */;
|
|
764
|
+
return this.extend_(adm, key, descriptor, false) === null ? 0 /* MakeResult.Cancel */ : 2 /* MakeResult.Continue */;
|
|
709
765
|
}
|
|
710
766
|
// prototype
|
|
711
767
|
// bound - must annotate protos to support super.flow()
|
|
712
768
|
if ((_this$options_ = this.options_) != null && _this$options_.bound && (!hasProp(adm.target_, key) || !isFlow(adm.target_[key]))) {
|
|
713
769
|
if (this.extend_(adm, key, descriptor, false) === null) {
|
|
714
|
-
return 0 /* Cancel */;
|
|
770
|
+
return 0 /* MakeResult.Cancel */;
|
|
715
771
|
}
|
|
716
772
|
}
|
|
717
773
|
|
|
718
774
|
if (isFlow(descriptor.value)) {
|
|
719
775
|
// A prototype could have been annotated already by other constructor,
|
|
720
776
|
// rest of the proto chain must be annotated already
|
|
721
|
-
return 1 /* Break */;
|
|
777
|
+
return 1 /* MakeResult.Break */;
|
|
722
778
|
}
|
|
723
779
|
|
|
724
780
|
var flowDescriptor = createFlowDescriptor(adm, this, key, descriptor, false, false);
|
|
725
781
|
defineProperty(source, key, flowDescriptor);
|
|
726
|
-
return 2 /* Continue */;
|
|
782
|
+
return 2 /* MakeResult.Continue */;
|
|
727
783
|
}
|
|
728
784
|
|
|
729
785
|
function extend_$2(adm, key, descriptor, proxyTrap) {
|
|
@@ -731,6 +787,26 @@ function extend_$2(adm, key, descriptor, proxyTrap) {
|
|
|
731
787
|
var flowDescriptor = createFlowDescriptor(adm, this, key, descriptor, (_this$options_2 = this.options_) == null ? void 0 : _this$options_2.bound);
|
|
732
788
|
return adm.defineProperty_(key, flowDescriptor, proxyTrap);
|
|
733
789
|
}
|
|
790
|
+
function decorate_20223_$2(mthd, context) {
|
|
791
|
+
var _this$options_3;
|
|
792
|
+
{
|
|
793
|
+
assert20223DecoratorType(context, ["method"]);
|
|
794
|
+
}
|
|
795
|
+
var name = context.name,
|
|
796
|
+
addInitializer = context.addInitializer;
|
|
797
|
+
if (!isFlow(mthd)) {
|
|
798
|
+
mthd = flow(mthd);
|
|
799
|
+
}
|
|
800
|
+
if ((_this$options_3 = this.options_) != null && _this$options_3.bound) {
|
|
801
|
+
addInitializer(function () {
|
|
802
|
+
var self = this;
|
|
803
|
+
var bound = self[name].bind(self);
|
|
804
|
+
bound.isMobXFlow = true;
|
|
805
|
+
self[name] = bound;
|
|
806
|
+
});
|
|
807
|
+
}
|
|
808
|
+
return mthd;
|
|
809
|
+
}
|
|
734
810
|
function assertFlowDescriptor(adm, _ref, key, _ref2) {
|
|
735
811
|
var annotationType_ = _ref.annotationType_;
|
|
736
812
|
var value = _ref2.value;
|
|
@@ -775,11 +851,12 @@ function createComputedAnnotation(name, options) {
|
|
|
775
851
|
annotationType_: name,
|
|
776
852
|
options_: options,
|
|
777
853
|
make_: make_$3,
|
|
778
|
-
extend_: extend_$3
|
|
854
|
+
extend_: extend_$3,
|
|
855
|
+
decorate_20223_: decorate_20223_$3
|
|
779
856
|
};
|
|
780
857
|
}
|
|
781
858
|
function make_$3(adm, key, descriptor) {
|
|
782
|
-
return this.extend_(adm, key, descriptor, false) === null ? 0 /* Cancel */ : 1 /* Break */;
|
|
859
|
+
return this.extend_(adm, key, descriptor, false) === null ? 0 /* MakeResult.Cancel */ : 1 /* MakeResult.Break */;
|
|
783
860
|
}
|
|
784
861
|
|
|
785
862
|
function extend_$3(adm, key, descriptor, proxyTrap) {
|
|
@@ -789,6 +866,26 @@ function extend_$3(adm, key, descriptor, proxyTrap) {
|
|
|
789
866
|
set: descriptor.set
|
|
790
867
|
}), proxyTrap);
|
|
791
868
|
}
|
|
869
|
+
function decorate_20223_$3(get, context) {
|
|
870
|
+
{
|
|
871
|
+
assert20223DecoratorType(context, ["getter"]);
|
|
872
|
+
}
|
|
873
|
+
var ann = this;
|
|
874
|
+
var key = context.name,
|
|
875
|
+
addInitializer = context.addInitializer;
|
|
876
|
+
addInitializer(function () {
|
|
877
|
+
var adm = asObservableObject(this)[$mobx];
|
|
878
|
+
var options = _extends({}, ann.options_, {
|
|
879
|
+
get: get,
|
|
880
|
+
context: this
|
|
881
|
+
});
|
|
882
|
+
options.name || (options.name = adm.name_ + "." + key.toString() );
|
|
883
|
+
adm.values_.set(key, new ComputedValue(options));
|
|
884
|
+
});
|
|
885
|
+
return function () {
|
|
886
|
+
return this[$mobx].getObservablePropValue_(key);
|
|
887
|
+
};
|
|
888
|
+
}
|
|
792
889
|
function assertComputedDescriptor(adm, _ref, key, _ref2) {
|
|
793
890
|
var annotationType_ = _ref.annotationType_;
|
|
794
891
|
var get = _ref2.get;
|
|
@@ -802,11 +899,12 @@ function createObservableAnnotation(name, options) {
|
|
|
802
899
|
annotationType_: name,
|
|
803
900
|
options_: options,
|
|
804
901
|
make_: make_$4,
|
|
805
|
-
extend_: extend_$4
|
|
902
|
+
extend_: extend_$4,
|
|
903
|
+
decorate_20223_: decorate_20223_$4
|
|
806
904
|
};
|
|
807
905
|
}
|
|
808
906
|
function make_$4(adm, key, descriptor) {
|
|
809
|
-
return this.extend_(adm, key, descriptor, false) === null ? 0 /* Cancel */ : 1 /* Break */;
|
|
907
|
+
return this.extend_(adm, key, descriptor, false) === null ? 0 /* MakeResult.Cancel */ : 1 /* MakeResult.Break */;
|
|
810
908
|
}
|
|
811
909
|
|
|
812
910
|
function extend_$4(adm, key, descriptor, proxyTrap) {
|
|
@@ -814,6 +912,55 @@ function extend_$4(adm, key, descriptor, proxyTrap) {
|
|
|
814
912
|
assertObservableDescriptor(adm, this, key, descriptor);
|
|
815
913
|
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);
|
|
816
914
|
}
|
|
915
|
+
function decorate_20223_$4(desc, context) {
|
|
916
|
+
{
|
|
917
|
+
if (context.kind === "field") {
|
|
918
|
+
throw die("Please use `@observable accessor " + String(context.name) + "` instead of `@observable " + String(context.name) + "`");
|
|
919
|
+
}
|
|
920
|
+
assert20223DecoratorType(context, ["accessor"]);
|
|
921
|
+
}
|
|
922
|
+
var ann = this;
|
|
923
|
+
var kind = context.kind,
|
|
924
|
+
name = context.name;
|
|
925
|
+
// The laziness here is not ideal... It's a workaround to how 2022.3 Decorators are implemented:
|
|
926
|
+
// `addInitializer` callbacks are executed _before_ any accessors are defined (instead of the ideal-for-us right after each).
|
|
927
|
+
// This means that, if we were to do our stuff in an `addInitializer`, we'd attempt to read a private slot
|
|
928
|
+
// before it has been initialized. The runtime doesn't like that and throws a `Cannot read private member
|
|
929
|
+
// from an object whose class did not declare it` error.
|
|
930
|
+
// TODO: it seems that this will not be required anymore in the final version of the spec
|
|
931
|
+
// See TODO: link
|
|
932
|
+
var initializedObjects = new WeakSet();
|
|
933
|
+
function initializeObservable(target, value) {
|
|
934
|
+
var _ann$options_$enhance, _ann$options_;
|
|
935
|
+
var adm = asObservableObject(target)[$mobx];
|
|
936
|
+
var observable = new ObservableValue(value, (_ann$options_$enhance = (_ann$options_ = ann.options_) == null ? void 0 : _ann$options_.enhancer) != null ? _ann$options_$enhance : deepEnhancer, adm.name_ + "." + name.toString() , false);
|
|
937
|
+
adm.values_.set(name, observable);
|
|
938
|
+
initializedObjects.add(target);
|
|
939
|
+
}
|
|
940
|
+
if (kind == "accessor") {
|
|
941
|
+
return {
|
|
942
|
+
get: function get() {
|
|
943
|
+
if (!initializedObjects.has(this)) {
|
|
944
|
+
initializeObservable(this, desc.get.call(this));
|
|
945
|
+
}
|
|
946
|
+
return this[$mobx].getObservablePropValue_(name);
|
|
947
|
+
},
|
|
948
|
+
set: function set(value) {
|
|
949
|
+
if (!initializedObjects.has(this)) {
|
|
950
|
+
initializeObservable(this, value);
|
|
951
|
+
}
|
|
952
|
+
return this[$mobx].setObservablePropValue_(name, value);
|
|
953
|
+
},
|
|
954
|
+
init: function init(value) {
|
|
955
|
+
if (!initializedObjects.has(this)) {
|
|
956
|
+
initializeObservable(this, value);
|
|
957
|
+
}
|
|
958
|
+
return value;
|
|
959
|
+
}
|
|
960
|
+
};
|
|
961
|
+
}
|
|
962
|
+
return;
|
|
963
|
+
}
|
|
817
964
|
function assertObservableDescriptor(adm, _ref, key, descriptor) {
|
|
818
965
|
var annotationType_ = _ref.annotationType_;
|
|
819
966
|
if ( !("value" in descriptor)) {
|
|
@@ -828,7 +975,8 @@ function createAutoAnnotation(options) {
|
|
|
828
975
|
annotationType_: AUTO,
|
|
829
976
|
options_: options,
|
|
830
977
|
make_: make_$5,
|
|
831
|
-
extend_: extend_$5
|
|
978
|
+
extend_: extend_$5,
|
|
979
|
+
decorate_20223_: decorate_20223_$5
|
|
832
980
|
};
|
|
833
981
|
}
|
|
834
982
|
function make_$5(adm, key, descriptor, source) {
|
|
@@ -846,14 +994,14 @@ function make_$5(adm, key, descriptor, source) {
|
|
|
846
994
|
return adm.defineProperty_(key, {
|
|
847
995
|
configurable: globalState.safeDescriptors ? adm.isPlainObject_ : true,
|
|
848
996
|
set: set
|
|
849
|
-
}) === null ? 0 /* Cancel */ : 2 /* Continue */;
|
|
997
|
+
}) === null ? 0 /* MakeResult.Cancel */ : 2 /* MakeResult.Continue */;
|
|
850
998
|
}
|
|
851
999
|
// proto
|
|
852
1000
|
defineProperty(source, key, {
|
|
853
1001
|
configurable: true,
|
|
854
1002
|
set: set
|
|
855
1003
|
});
|
|
856
|
-
return 2 /* Continue */;
|
|
1004
|
+
return 2 /* MakeResult.Continue */;
|
|
857
1005
|
}
|
|
858
1006
|
// function on proto -> autoAction/flow
|
|
859
1007
|
if (source !== adm.target_ && typeof descriptor.value === "function") {
|
|
@@ -900,6 +1048,9 @@ function extend_$5(adm, key, descriptor, proxyTrap) {
|
|
|
900
1048
|
var observableAnnotation = ((_this$options_6 = this.options_) == null ? void 0 : _this$options_6.deep) === false ? observable.ref : observable;
|
|
901
1049
|
return observableAnnotation.extend_(adm, key, descriptor, proxyTrap);
|
|
902
1050
|
}
|
|
1051
|
+
function decorate_20223_$5(desc, context) {
|
|
1052
|
+
die("'" + this.annotationType_ + "' cannot be used as a decorator");
|
|
1053
|
+
}
|
|
903
1054
|
|
|
904
1055
|
var OBSERVABLE = "observable";
|
|
905
1056
|
var OBSERVABLE_REF = "observable.ref";
|
|
@@ -939,11 +1090,15 @@ function getEnhancerFromAnnotation(annotation) {
|
|
|
939
1090
|
var _annotation$options_$, _annotation$options_;
|
|
940
1091
|
return !annotation ? deepEnhancer : (_annotation$options_$ = (_annotation$options_ = annotation.options_) == null ? void 0 : _annotation$options_.enhancer) != null ? _annotation$options_$ : deepEnhancer;
|
|
941
1092
|
}
|
|
942
|
-
/**
|
|
943
|
-
* Turns an object, array or function into a reactive structure.
|
|
944
|
-
* @param v the value which should become observable.
|
|
1093
|
+
/**
|
|
1094
|
+
* Turns an object, array or function into a reactive structure.
|
|
1095
|
+
* @param v the value which should become observable.
|
|
945
1096
|
*/
|
|
946
1097
|
function createObservable(v, arg2, arg3) {
|
|
1098
|
+
// @observable someProp; (2022.3 Decorators)
|
|
1099
|
+
if (is20223Decorator(arg2)) {
|
|
1100
|
+
return observableAnnotation.decorate_20223_(v, arg2);
|
|
1101
|
+
}
|
|
947
1102
|
// @observable someProp;
|
|
948
1103
|
if (isStringish(arg2)) {
|
|
949
1104
|
storeAnnotation(v, arg2, observableAnnotation);
|
|
@@ -1013,11 +1168,15 @@ var computedAnnotation = /*#__PURE__*/createComputedAnnotation(COMPUTED);
|
|
|
1013
1168
|
var computedStructAnnotation = /*#__PURE__*/createComputedAnnotation(COMPUTED_STRUCT, {
|
|
1014
1169
|
equals: comparer.structural
|
|
1015
1170
|
});
|
|
1016
|
-
/**
|
|
1017
|
-
* Decorator for class properties: @computed get value() { return expr; }.
|
|
1018
|
-
* For legacy purposes also invokable as ES5 observable created: `computed(() => expr)`;
|
|
1171
|
+
/**
|
|
1172
|
+
* Decorator for class properties: @computed get value() { return expr; }.
|
|
1173
|
+
* For legacy purposes also invokable as ES5 observable created: `computed(() => expr)`;
|
|
1019
1174
|
*/
|
|
1020
1175
|
var computed = function computed(arg1, arg2) {
|
|
1176
|
+
if (is20223Decorator(arg2)) {
|
|
1177
|
+
// @computed (2022.3 Decorators)
|
|
1178
|
+
return computedAnnotation.decorate_20223_(arg1, arg2);
|
|
1179
|
+
}
|
|
1021
1180
|
if (isStringish(arg2)) {
|
|
1022
1181
|
// @computed
|
|
1023
1182
|
return storeAnnotation(arg1, arg2, computedAnnotation);
|
|
@@ -1304,24 +1463,24 @@ var ObservableValue = /*#__PURE__*/function (_Atom) {
|
|
|
1304
1463
|
var isObservableValue = /*#__PURE__*/createInstanceofPredicate("ObservableValue", ObservableValue);
|
|
1305
1464
|
|
|
1306
1465
|
var _Symbol$toPrimitive$1;
|
|
1307
|
-
/**
|
|
1308
|
-
* A node in the state dependency root that observes other nodes, and can be observed itself.
|
|
1309
|
-
*
|
|
1310
|
-
* ComputedValue will remember the result of the computation for the duration of the batch, or
|
|
1311
|
-
* while being observed.
|
|
1312
|
-
*
|
|
1313
|
-
* During this time it will recompute only when one of its direct dependencies changed,
|
|
1314
|
-
* but only when it is being accessed with `ComputedValue.get()`.
|
|
1315
|
-
*
|
|
1316
|
-
* Implementation description:
|
|
1317
|
-
* 1. First time it's being accessed it will compute and remember result
|
|
1318
|
-
* give back remembered result until 2. happens
|
|
1319
|
-
* 2. First time any deep dependency change, propagate POSSIBLY_STALE to all observers, wait for 3.
|
|
1320
|
-
* 3. When it's being accessed, recompute if any shallow dependency changed.
|
|
1321
|
-
* if result changed: propagate STALE to all observers, that were POSSIBLY_STALE from the last step.
|
|
1322
|
-
* go to step 2. either way
|
|
1323
|
-
*
|
|
1324
|
-
* If at any point it's outside batch and it isn't observed: reset everything and go to 1.
|
|
1466
|
+
/**
|
|
1467
|
+
* A node in the state dependency root that observes other nodes, and can be observed itself.
|
|
1468
|
+
*
|
|
1469
|
+
* ComputedValue will remember the result of the computation for the duration of the batch, or
|
|
1470
|
+
* while being observed.
|
|
1471
|
+
*
|
|
1472
|
+
* During this time it will recompute only when one of its direct dependencies changed,
|
|
1473
|
+
* but only when it is being accessed with `ComputedValue.get()`.
|
|
1474
|
+
*
|
|
1475
|
+
* Implementation description:
|
|
1476
|
+
* 1. First time it's being accessed it will compute and remember result
|
|
1477
|
+
* give back remembered result until 2. happens
|
|
1478
|
+
* 2. First time any deep dependency change, propagate POSSIBLY_STALE to all observers, wait for 3.
|
|
1479
|
+
* 3. When it's being accessed, recompute if any shallow dependency changed.
|
|
1480
|
+
* if result changed: propagate STALE to all observers, that were POSSIBLY_STALE from the last step.
|
|
1481
|
+
* go to step 2. either way
|
|
1482
|
+
*
|
|
1483
|
+
* If at any point it's outside batch and it isn't observed: reset everything and go to 1.
|
|
1325
1484
|
*/
|
|
1326
1485
|
_Symbol$toPrimitive$1 = Symbol.toPrimitive;
|
|
1327
1486
|
var ComputedValue = /*#__PURE__*/function () {
|
|
@@ -1332,17 +1491,17 @@ var ComputedValue = /*#__PURE__*/function () {
|
|
|
1332
1491
|
|
|
1333
1492
|
// N.B: unminified as it is used by MST
|
|
1334
1493
|
|
|
1335
|
-
/**
|
|
1336
|
-
* Create a new computed value based on a function expression.
|
|
1337
|
-
*
|
|
1338
|
-
* The `name` property is for debug purposes only.
|
|
1339
|
-
*
|
|
1340
|
-
* The `equals` property specifies the comparer function to use to determine if a newly produced
|
|
1341
|
-
* value differs from the previous value. Two comparers are provided in the library; `defaultComparer`
|
|
1342
|
-
* compares based on identity comparison (===), and `structuralComparer` deeply compares the structure.
|
|
1343
|
-
* Structural comparison can be convenient if you always produce a new aggregated object and
|
|
1344
|
-
* don't want to notify observers if it is structurally the same.
|
|
1345
|
-
* This is useful for working with vectors, mouse coordinates etc.
|
|
1494
|
+
/**
|
|
1495
|
+
* Create a new computed value based on a function expression.
|
|
1496
|
+
*
|
|
1497
|
+
* The `name` property is for debug purposes only.
|
|
1498
|
+
*
|
|
1499
|
+
* The `equals` property specifies the comparer function to use to determine if a newly produced
|
|
1500
|
+
* value differs from the previous value. Two comparers are provided in the library; `defaultComparer`
|
|
1501
|
+
* compares based on identity comparison (===), and `structuralComparer` deeply compares the structure.
|
|
1502
|
+
* Structural comparison can be convenient if you always produce a new aggregated object and
|
|
1503
|
+
* don't want to notify observers if it is structurally the same.
|
|
1504
|
+
* This is useful for working with vectors, mouse coordinates etc.
|
|
1346
1505
|
*/
|
|
1347
1506
|
function ComputedValue(options) {
|
|
1348
1507
|
this.dependenciesState_ = IDerivationState_.NOT_TRACKING_;
|
|
@@ -1401,9 +1560,9 @@ var ComputedValue = /*#__PURE__*/function () {
|
|
|
1401
1560
|
});
|
|
1402
1561
|
}
|
|
1403
1562
|
}
|
|
1404
|
-
/**
|
|
1405
|
-
* Returns the current value of this computed value.
|
|
1406
|
-
* Will evaluate its computation first if needed.
|
|
1563
|
+
/**
|
|
1564
|
+
* Returns the current value of this computed value.
|
|
1565
|
+
* Will evaluate its computation first if needed.
|
|
1407
1566
|
*/;
|
|
1408
1567
|
_proto.get = function get() {
|
|
1409
1568
|
if (this.isComputing_) {
|
|
@@ -1583,16 +1742,16 @@ var CaughtException = function CaughtException(cause) {
|
|
|
1583
1742
|
function isCaughtException(e) {
|
|
1584
1743
|
return e instanceof CaughtException;
|
|
1585
1744
|
}
|
|
1586
|
-
/**
|
|
1587
|
-
* Finds out whether any dependency of the derivation has actually changed.
|
|
1588
|
-
* If dependenciesState is 1 then it will recalculate dependencies,
|
|
1589
|
-
* if any dependency changed it will propagate it by changing dependenciesState to 2.
|
|
1590
|
-
*
|
|
1591
|
-
* By iterating over the dependencies in the same order that they were reported and
|
|
1592
|
-
* stopping on the first change, all the recalculations are only called for ComputedValues
|
|
1593
|
-
* that will be tracked by derivation. That is because we assume that if the first x
|
|
1594
|
-
* dependencies of the derivation doesn't change then the derivation should run the same way
|
|
1595
|
-
* up until accessing x-th dependency.
|
|
1745
|
+
/**
|
|
1746
|
+
* Finds out whether any dependency of the derivation has actually changed.
|
|
1747
|
+
* If dependenciesState is 1 then it will recalculate dependencies,
|
|
1748
|
+
* if any dependency changed it will propagate it by changing dependenciesState to 2.
|
|
1749
|
+
*
|
|
1750
|
+
* By iterating over the dependencies in the same order that they were reported and
|
|
1751
|
+
* stopping on the first change, all the recalculations are only called for ComputedValues
|
|
1752
|
+
* that will be tracked by derivation. That is because we assume that if the first x
|
|
1753
|
+
* dependencies of the derivation doesn't change then the derivation should run the same way
|
|
1754
|
+
* up until accessing x-th dependency.
|
|
1596
1755
|
*/
|
|
1597
1756
|
function shouldCompute(derivation) {
|
|
1598
1757
|
switch (derivation.dependenciesState_) {
|
|
@@ -1656,10 +1815,10 @@ function checkIfStateReadsAreAllowed(observable) {
|
|
|
1656
1815
|
console.warn("[mobx] Observable '" + observable.name_ + "' being read outside a reactive context.");
|
|
1657
1816
|
}
|
|
1658
1817
|
}
|
|
1659
|
-
/**
|
|
1660
|
-
* Executes the provided function `f` and tracks which observables are being accessed.
|
|
1661
|
-
* The tracking information is stored on the `derivation` object and the derivation is registered
|
|
1662
|
-
* as observer of any of the accessed observables.
|
|
1818
|
+
/**
|
|
1819
|
+
* Executes the provided function `f` and tracks which observables are being accessed.
|
|
1820
|
+
* The tracking information is stored on the `derivation` object and the derivation is registered
|
|
1821
|
+
* as observer of any of the accessed observables.
|
|
1663
1822
|
*/
|
|
1664
1823
|
function trackDerivedFunction(derivation, f, context) {
|
|
1665
1824
|
var prevAllowStateReads = allowStateReadsStart(true);
|
|
@@ -1697,10 +1856,10 @@ function warnAboutDerivationWithoutDependencies(derivation) {
|
|
|
1697
1856
|
console.warn("[mobx] Derivation '" + derivation.name_ + "' is created/updated without reading any observable value.");
|
|
1698
1857
|
}
|
|
1699
1858
|
}
|
|
1700
|
-
/**
|
|
1701
|
-
* diffs newObserving with observing.
|
|
1702
|
-
* update observing to be newObserving with unique observables
|
|
1703
|
-
* notify observers that become observed/unobserved
|
|
1859
|
+
/**
|
|
1860
|
+
* diffs newObserving with observing.
|
|
1861
|
+
* update observing to be newObserving with unique observables
|
|
1862
|
+
* notify observers that become observed/unobserved
|
|
1704
1863
|
*/
|
|
1705
1864
|
function bindDependencies(derivation) {
|
|
1706
1865
|
// invariant(derivation.dependenciesState !== IDerivationState.NOT_TRACKING, "INTERNAL ERROR bindDependencies expects derivation.dependenciesState !== -1");
|
|
@@ -1791,9 +1950,9 @@ function allowStateReadsStart(allowStateReads) {
|
|
|
1791
1950
|
function allowStateReadsEnd(prev) {
|
|
1792
1951
|
globalState.allowStateReads = prev;
|
|
1793
1952
|
}
|
|
1794
|
-
/**
|
|
1795
|
-
* needed to keep `lowestObserverState` correct. when changing from (2 or 1) to 0
|
|
1796
|
-
*
|
|
1953
|
+
/**
|
|
1954
|
+
* needed to keep `lowestObserverState` correct. when changing from (2 or 1) to 0
|
|
1955
|
+
*
|
|
1797
1956
|
*/
|
|
1798
1957
|
function changeDependenciesStateTo0(derivation) {
|
|
1799
1958
|
if (derivation.dependenciesState_ === IDerivationState_.UP_TO_DATE_) {
|
|
@@ -1807,8 +1966,8 @@ function changeDependenciesStateTo0(derivation) {
|
|
|
1807
1966
|
}
|
|
1808
1967
|
}
|
|
1809
1968
|
|
|
1810
|
-
/**
|
|
1811
|
-
* These values will persist if global state is reset
|
|
1969
|
+
/**
|
|
1970
|
+
* These values will persist if global state is reset
|
|
1812
1971
|
*/
|
|
1813
1972
|
var persistentKeys = ["mobxGuid", "spyListeners", "enforceActions", "computedRequiresReaction", "reactionRequiresObservable", "observableRequiresReaction", "allowStateReads", "disableErrorBoundaries", "runId", "UNCHANGED", "useProxies"];
|
|
1814
1973
|
var MobXGlobals = function MobXGlobals() {
|
|
@@ -1884,9 +2043,9 @@ function isolateGlobalState() {
|
|
|
1884
2043
|
function getGlobalState() {
|
|
1885
2044
|
return globalState;
|
|
1886
2045
|
}
|
|
1887
|
-
/**
|
|
1888
|
-
* For testing purposes only; this will break the internal state of existing observables,
|
|
1889
|
-
* but can be used to get back at a stable state after throwing errors
|
|
2046
|
+
/**
|
|
2047
|
+
* For testing purposes only; this will break the internal state of existing observables,
|
|
2048
|
+
* but can be used to get back at a stable state after throwing errors
|
|
1890
2049
|
*/
|
|
1891
2050
|
function resetGlobalState() {
|
|
1892
2051
|
var defaultGlobals = new MobXGlobals();
|
|
@@ -1953,10 +2112,10 @@ function queueForUnobservation(observable) {
|
|
|
1953
2112
|
globalState.pendingUnobservations.push(observable);
|
|
1954
2113
|
}
|
|
1955
2114
|
}
|
|
1956
|
-
/**
|
|
1957
|
-
* Batch starts a transaction, at least for purposes of memoizing ComputedValues when nothing else does.
|
|
1958
|
-
* During a batch `onBecomeUnobserved` will be called at most once per observable.
|
|
1959
|
-
* Avoids unnecessary recalculations.
|
|
2115
|
+
/**
|
|
2116
|
+
* Batch starts a transaction, at least for purposes of memoizing ComputedValues when nothing else does.
|
|
2117
|
+
* During a batch `onBecomeUnobserved` will be called at most once per observable.
|
|
2118
|
+
* Avoids unnecessary recalculations.
|
|
1960
2119
|
*/
|
|
1961
2120
|
function startBatch() {
|
|
1962
2121
|
if (globalState.inBatch === 0) {
|
|
@@ -1992,10 +2151,10 @@ function reportObserved(observable) {
|
|
|
1992
2151
|
checkIfStateReadsAreAllowed(observable);
|
|
1993
2152
|
var derivation = globalState.trackingDerivation;
|
|
1994
2153
|
if (derivation !== null) {
|
|
1995
|
-
/**
|
|
1996
|
-
* Simple optimization, give each derivation run an unique id (runId)
|
|
1997
|
-
* Check if last time this observable was accessed the same runId is used
|
|
1998
|
-
* if this is the case, the relation is already known
|
|
2154
|
+
/**
|
|
2155
|
+
* Simple optimization, give each derivation run an unique id (runId)
|
|
2156
|
+
* Check if last time this observable was accessed the same runId is used
|
|
2157
|
+
* if this is the case, the relation is already known
|
|
1999
2158
|
*/
|
|
2000
2159
|
if (derivation.runId_ !== observable.lastAccessedBy_) {
|
|
2001
2160
|
observable.lastAccessedBy_ = derivation.runId_;
|
|
@@ -2025,12 +2184,12 @@ function reportObserved(observable) {
|
|
|
2025
2184
|
// observable.lowestObserverState
|
|
2026
2185
|
// )
|
|
2027
2186
|
// }
|
|
2028
|
-
/**
|
|
2029
|
-
* NOTE: current propagation mechanism will in case of self reruning autoruns behave unexpectedly
|
|
2030
|
-
* It will propagate changes to observers from previous run
|
|
2031
|
-
* It's hard or maybe impossible (with reasonable perf) to get it right with current approach
|
|
2032
|
-
* Hopefully self reruning autoruns aren't a feature people should depend on
|
|
2033
|
-
* Also most basic use cases should be ok
|
|
2187
|
+
/**
|
|
2188
|
+
* NOTE: current propagation mechanism will in case of self reruning autoruns behave unexpectedly
|
|
2189
|
+
* It will propagate changes to observers from previous run
|
|
2190
|
+
* It's hard or maybe impossible (with reasonable perf) to get it right with current approach
|
|
2191
|
+
* Hopefully self reruning autoruns aren't a feature people should depend on
|
|
2192
|
+
* Also most basic use cases should be ok
|
|
2034
2193
|
*/
|
|
2035
2194
|
// Called by Atom when its value changes
|
|
2036
2195
|
function propagateChanged(observable) {
|
|
@@ -2150,8 +2309,8 @@ var Reaction = /*#__PURE__*/function () {
|
|
|
2150
2309
|
_proto.isScheduled = function isScheduled() {
|
|
2151
2310
|
return this.isScheduled_;
|
|
2152
2311
|
}
|
|
2153
|
-
/**
|
|
2154
|
-
* internal, use schedule() if you intend to kick off a reaction
|
|
2312
|
+
/**
|
|
2313
|
+
* internal, use schedule() if you intend to kick off a reaction
|
|
2155
2314
|
*/;
|
|
2156
2315
|
_proto.runReaction_ = function runReaction_() {
|
|
2157
2316
|
if (!this.isDisposed_) {
|
|
@@ -2284,10 +2443,10 @@ function onReactionError(handler) {
|
|
|
2284
2443
|
}
|
|
2285
2444
|
};
|
|
2286
2445
|
}
|
|
2287
|
-
/**
|
|
2288
|
-
* Magic number alert!
|
|
2289
|
-
* Defines within how many times a reaction is allowed to re-trigger itself
|
|
2290
|
-
* until it is assumed that this is gonna be a never ending loop...
|
|
2446
|
+
/**
|
|
2447
|
+
* Magic number alert!
|
|
2448
|
+
* Defines within how many times a reaction is allowed to re-trigger itself
|
|
2449
|
+
* until it is assumed that this is gonna be a never ending loop...
|
|
2291
2450
|
*/
|
|
2292
2451
|
var MAX_REACTION_ITERATIONS = 100;
|
|
2293
2452
|
var reactionScheduler = function reactionScheduler(f) {
|
|
@@ -2399,6 +2558,10 @@ function createActionFactory(autoAction) {
|
|
|
2399
2558
|
if (isFunction(arg2)) {
|
|
2400
2559
|
return createAction(arg1, arg2, autoAction);
|
|
2401
2560
|
}
|
|
2561
|
+
// @action (2022.3 Decorators)
|
|
2562
|
+
if (is20223Decorator(arg2)) {
|
|
2563
|
+
return (autoAction ? autoActionAnnotation : actionAnnotation).decorate_20223_(arg1, arg2);
|
|
2564
|
+
}
|
|
2402
2565
|
// @action
|
|
2403
2566
|
if (isStringish(arg2)) {
|
|
2404
2567
|
return storeAnnotation(arg1, arg2, autoAction ? autoActionAnnotation : actionAnnotation);
|
|
@@ -2429,11 +2592,11 @@ function isAction(thing) {
|
|
|
2429
2592
|
return isFunction(thing) && thing.isMobxAction === true;
|
|
2430
2593
|
}
|
|
2431
2594
|
|
|
2432
|
-
/**
|
|
2433
|
-
* Creates a named reactive view and keeps it alive, so that the view is always
|
|
2434
|
-
* updated if one of the dependencies changes, even when the view is not further used by something else.
|
|
2435
|
-
* @param view The reactive view
|
|
2436
|
-
* @returns disposer function, which can be used to stop the view from being updated in the future.
|
|
2595
|
+
/**
|
|
2596
|
+
* Creates a named reactive view and keeps it alive, so that the view is always
|
|
2597
|
+
* updated if one of the dependencies changes, even when the view is not further used by something else.
|
|
2598
|
+
* @param view The reactive view
|
|
2599
|
+
* @returns disposer function, which can be used to stop the view from being updated in the future.
|
|
2437
2600
|
*/
|
|
2438
2601
|
function autorun(view, opts) {
|
|
2439
2602
|
var _opts$name, _opts, _opts2, _opts2$signal, _opts3;
|
|
@@ -2689,6 +2852,10 @@ var flowBoundAnnotation = /*#__PURE__*/createFlowAnnotation("flow.bound", {
|
|
|
2689
2852
|
bound: true
|
|
2690
2853
|
});
|
|
2691
2854
|
var flow = /*#__PURE__*/Object.assign(function flow(arg1, arg2) {
|
|
2855
|
+
// @flow (2022.3 Decorators)
|
|
2856
|
+
if (is20223Decorator(arg2)) {
|
|
2857
|
+
return flowAnnotation.decorate_20223_(arg1, arg2);
|
|
2858
|
+
}
|
|
2692
2859
|
// @flow
|
|
2693
2860
|
if (isStringish(arg2)) {
|
|
2694
2861
|
return storeAnnotation(arg1, arg2, flowAnnotation);
|
|
@@ -3075,11 +3242,11 @@ function toJSHelper(source, __alreadySeen) {
|
|
|
3075
3242
|
return _res3;
|
|
3076
3243
|
}
|
|
3077
3244
|
}
|
|
3078
|
-
/**
|
|
3079
|
-
* Recursively converts an observable to it's non-observable native counterpart.
|
|
3080
|
-
* It does NOT recurse into non-observables, these are left as they are, even if they contain observables.
|
|
3081
|
-
* Computed and other non-enumerable properties are completely ignored.
|
|
3082
|
-
* Complex scenarios require custom solution, eg implementing `toJSON` or using `serializr` lib.
|
|
3245
|
+
/**
|
|
3246
|
+
* Recursively converts an observable to it's non-observable native counterpart.
|
|
3247
|
+
* It does NOT recurse into non-observables, these are left as they are, even if they contain observables.
|
|
3248
|
+
* Computed and other non-enumerable properties are completely ignored.
|
|
3249
|
+
* Complex scenarios require custom solution, eg implementing `toJSON` or using `serializr` lib.
|
|
3083
3250
|
*/
|
|
3084
3251
|
function toJS(source, options) {
|
|
3085
3252
|
if ( options) {
|
|
@@ -3116,12 +3283,12 @@ function getAtomFromArgs(args) {
|
|
|
3116
3283
|
}
|
|
3117
3284
|
}
|
|
3118
3285
|
|
|
3119
|
-
/**
|
|
3120
|
-
* During a transaction no views are updated until the end of the transaction.
|
|
3121
|
-
* The transaction will be run synchronously nonetheless.
|
|
3122
|
-
*
|
|
3123
|
-
* @param action a function that updates some reactive state
|
|
3124
|
-
* @returns any value that was returned by the 'action' parameter.
|
|
3286
|
+
/**
|
|
3287
|
+
* During a transaction no views are updated until the end of the transaction.
|
|
3288
|
+
* The transaction will be run synchronously nonetheless.
|
|
3289
|
+
*
|
|
3290
|
+
* @param action a function that updates some reactive state
|
|
3291
|
+
* @returns any value that was returned by the 'action' parameter.
|
|
3125
3292
|
*/
|
|
3126
3293
|
function transaction(action, thisArg) {
|
|
3127
3294
|
if (thisArg === void 0) {
|
|
@@ -3709,11 +3876,11 @@ var arrayExtensions = {
|
|
|
3709
3876
|
toJSON: function toJSON() {
|
|
3710
3877
|
return this.slice();
|
|
3711
3878
|
},
|
|
3712
|
-
/*
|
|
3713
|
-
* functions that do alter the internal structure of the array, (based on lib.es6.d.ts)
|
|
3714
|
-
* since these functions alter the inner structure of the array, the have side effects.
|
|
3715
|
-
* Because the have side effects, they should not be used in computed function,
|
|
3716
|
-
* and for that reason the do not call dependencyState.notifyObserved
|
|
3879
|
+
/*
|
|
3880
|
+
* functions that do alter the internal structure of the array, (based on lib.es6.d.ts)
|
|
3881
|
+
* since these functions alter the inner structure of the array, the have side effects.
|
|
3882
|
+
* Because the have side effects, they should not be used in computed function,
|
|
3883
|
+
* and for that reason the do not call dependencyState.notifyObserved
|
|
3717
3884
|
*/
|
|
3718
3885
|
splice: function splice(index, deleteCount) {
|
|
3719
3886
|
for (var _len = arguments.length, newItems = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
@@ -3785,10 +3952,10 @@ var arrayExtensions = {
|
|
|
3785
3952
|
return false;
|
|
3786
3953
|
}
|
|
3787
3954
|
};
|
|
3788
|
-
/**
|
|
3789
|
-
* Wrap function from prototype
|
|
3790
|
-
* Without this, everything works as well, but this works
|
|
3791
|
-
* faster as everything works on unproxied values
|
|
3955
|
+
/**
|
|
3956
|
+
* Wrap function from prototype
|
|
3957
|
+
* Without this, everything works as well, but this works
|
|
3958
|
+
* faster as everything works on unproxied values
|
|
3792
3959
|
*/
|
|
3793
3960
|
addArrayExtension("concat", simpleFunc);
|
|
3794
3961
|
addArrayExtension("flat", simpleFunc);
|
|
@@ -4228,10 +4395,10 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4228
4395
|
_proto.toJSON = function toJSON() {
|
|
4229
4396
|
return Array.from(this);
|
|
4230
4397
|
};
|
|
4231
|
-
/**
|
|
4232
|
-
* Observes this object. Triggers for the events 'add', 'update' and 'delete'.
|
|
4233
|
-
* See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/observe
|
|
4234
|
-
* for callback details
|
|
4398
|
+
/**
|
|
4399
|
+
* Observes this object. Triggers for the events 'add', 'update' and 'delete'.
|
|
4400
|
+
* See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/observe
|
|
4401
|
+
* for callback details
|
|
4235
4402
|
*/
|
|
4236
4403
|
_proto.observe_ = function observe_(listener, fireImmediately) {
|
|
4237
4404
|
if ( fireImmediately === true) {
|
|
@@ -4607,12 +4774,12 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
4607
4774
|
}
|
|
4608
4775
|
return this.target_[key];
|
|
4609
4776
|
}
|
|
4610
|
-
/**
|
|
4611
|
-
* @param {PropertyKey} key
|
|
4612
|
-
* @param {any} value
|
|
4613
|
-
* @param {Annotation|boolean} annotation true - use default annotation, false - copy as is
|
|
4614
|
-
* @param {boolean} proxyTrap whether it's called from proxy trap
|
|
4615
|
-
* @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor
|
|
4777
|
+
/**
|
|
4778
|
+
* @param {PropertyKey} key
|
|
4779
|
+
* @param {any} value
|
|
4780
|
+
* @param {Annotation|boolean} annotation true - use default annotation, false - copy as is
|
|
4781
|
+
* @param {boolean} proxyTrap whether it's called from proxy trap
|
|
4782
|
+
* @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor
|
|
4616
4783
|
*/;
|
|
4617
4784
|
_proto.set_ = function set_(key, value, proxyTrap) {
|
|
4618
4785
|
if (proxyTrap === void 0) {
|
|
@@ -4657,9 +4824,9 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
4657
4824
|
}
|
|
4658
4825
|
return entry.get();
|
|
4659
4826
|
}
|
|
4660
|
-
/**
|
|
4661
|
-
* @param {PropertyKey} key
|
|
4662
|
-
* @param {Annotation|boolean} annotation true - use default annotation, false - ignore prop
|
|
4827
|
+
/**
|
|
4828
|
+
* @param {PropertyKey} key
|
|
4829
|
+
* @param {Annotation|boolean} annotation true - use default annotation, false - ignore prop
|
|
4663
4830
|
*/;
|
|
4664
4831
|
_proto.make_ = function make_(key, annotation) {
|
|
4665
4832
|
if (annotation === true) {
|
|
@@ -4687,10 +4854,10 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
4687
4854
|
var descriptor = getDescriptor(source, key);
|
|
4688
4855
|
if (descriptor) {
|
|
4689
4856
|
var outcome = annotation.make_(this, key, descriptor, source);
|
|
4690
|
-
if (outcome === 0 /* Cancel */) {
|
|
4857
|
+
if (outcome === 0 /* MakeResult.Cancel */) {
|
|
4691
4858
|
return;
|
|
4692
4859
|
}
|
|
4693
|
-
if (outcome === 1 /* Break */) {
|
|
4860
|
+
if (outcome === 1 /* MakeResult.Break */) {
|
|
4694
4861
|
break;
|
|
4695
4862
|
}
|
|
4696
4863
|
}
|
|
@@ -4698,12 +4865,12 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
4698
4865
|
}
|
|
4699
4866
|
recordAnnotationApplied(this, annotation, key);
|
|
4700
4867
|
}
|
|
4701
|
-
/**
|
|
4702
|
-
* @param {PropertyKey} key
|
|
4703
|
-
* @param {PropertyDescriptor} descriptor
|
|
4704
|
-
* @param {Annotation|boolean} annotation true - use default annotation, false - copy as is
|
|
4705
|
-
* @param {boolean} proxyTrap whether it's called from proxy trap
|
|
4706
|
-
* @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor
|
|
4868
|
+
/**
|
|
4869
|
+
* @param {PropertyKey} key
|
|
4870
|
+
* @param {PropertyDescriptor} descriptor
|
|
4871
|
+
* @param {Annotation|boolean} annotation true - use default annotation, false - copy as is
|
|
4872
|
+
* @param {boolean} proxyTrap whether it's called from proxy trap
|
|
4873
|
+
* @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor
|
|
4707
4874
|
*/;
|
|
4708
4875
|
_proto.extend_ = function extend_(key, descriptor, annotation, proxyTrap) {
|
|
4709
4876
|
if (proxyTrap === void 0) {
|
|
@@ -4722,11 +4889,11 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
4722
4889
|
}
|
|
4723
4890
|
return outcome;
|
|
4724
4891
|
}
|
|
4725
|
-
/**
|
|
4726
|
-
* @param {PropertyKey} key
|
|
4727
|
-
* @param {PropertyDescriptor} descriptor
|
|
4728
|
-
* @param {boolean} proxyTrap whether it's called from proxy trap
|
|
4729
|
-
* @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor
|
|
4892
|
+
/**
|
|
4893
|
+
* @param {PropertyKey} key
|
|
4894
|
+
* @param {PropertyDescriptor} descriptor
|
|
4895
|
+
* @param {boolean} proxyTrap whether it's called from proxy trap
|
|
4896
|
+
* @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor
|
|
4730
4897
|
*/;
|
|
4731
4898
|
_proto.defineProperty_ = function defineProperty_(key, descriptor, proxyTrap) {
|
|
4732
4899
|
if (proxyTrap === void 0) {
|
|
@@ -4878,11 +5045,11 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
4878
5045
|
}
|
|
4879
5046
|
return true;
|
|
4880
5047
|
}
|
|
4881
|
-
/**
|
|
4882
|
-
* @param {PropertyKey} key
|
|
4883
|
-
* @param {PropertyDescriptor} descriptor
|
|
4884
|
-
* @param {boolean} proxyTrap whether it's called from proxy trap
|
|
4885
|
-
* @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor
|
|
5048
|
+
/**
|
|
5049
|
+
* @param {PropertyKey} key
|
|
5050
|
+
* @param {PropertyDescriptor} descriptor
|
|
5051
|
+
* @param {boolean} proxyTrap whether it's called from proxy trap
|
|
5052
|
+
* @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor
|
|
4886
5053
|
*/;
|
|
4887
5054
|
_proto.delete_ = function delete_(key, proxyTrap) {
|
|
4888
5055
|
if (proxyTrap === void 0) {
|
|
@@ -4971,10 +5138,10 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
4971
5138
|
}
|
|
4972
5139
|
return true;
|
|
4973
5140
|
}
|
|
4974
|
-
/**
|
|
4975
|
-
* Observes this object. Triggers for the events 'add', 'update' and 'delete'.
|
|
4976
|
-
* See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/observe
|
|
4977
|
-
* for callback details
|
|
5141
|
+
/**
|
|
5142
|
+
* Observes this object. Triggers for the events 'add', 'update' and 'delete'.
|
|
5143
|
+
* See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/observe
|
|
5144
|
+
* for callback details
|
|
4978
5145
|
*/;
|
|
4979
5146
|
_proto.observe_ = function observe_(callback, fireImmediately) {
|
|
4980
5147
|
if ( fireImmediately === true) {
|
|
@@ -5077,35 +5244,35 @@ function assertAnnotable(adm, annotation, key) {
|
|
|
5077
5244
|
if ( !isAnnotation(annotation)) {
|
|
5078
5245
|
die("Cannot annotate '" + adm.name_ + "." + key.toString() + "': Invalid annotation.");
|
|
5079
5246
|
}
|
|
5080
|
-
/*
|
|
5081
|
-
// Configurable, not sealed, not frozen
|
|
5082
|
-
// Possibly not needed, just a little better error then the one thrown by engine.
|
|
5083
|
-
// Cases where this would be useful the most (subclass field initializer) are not interceptable by this.
|
|
5084
|
-
if (__DEV__) {
|
|
5085
|
-
const configurable = getDescriptor(adm.target_, key)?.configurable
|
|
5086
|
-
const frozen = Object.isFrozen(adm.target_)
|
|
5087
|
-
const sealed = Object.isSealed(adm.target_)
|
|
5088
|
-
if (!configurable || frozen || sealed) {
|
|
5089
|
-
const fieldName = `${adm.name_}.${key.toString()}`
|
|
5090
|
-
const requestedAnnotationType = annotation.annotationType_
|
|
5091
|
-
let error = `Cannot apply '${requestedAnnotationType}' to '${fieldName}':`
|
|
5092
|
-
if (frozen) {
|
|
5093
|
-
error += `\nObject is frozen.`
|
|
5094
|
-
}
|
|
5095
|
-
if (sealed) {
|
|
5096
|
-
error += `\nObject is sealed.`
|
|
5097
|
-
}
|
|
5098
|
-
if (!configurable) {
|
|
5099
|
-
error += `\nproperty is not configurable.`
|
|
5100
|
-
// Mention only if caused by us to avoid confusion
|
|
5101
|
-
if (hasProp(adm.appliedAnnotations!, key)) {
|
|
5102
|
-
error += `\nTo prevent accidental re-definition of a field by a subclass, `
|
|
5103
|
-
error += `all annotated fields of non-plain objects (classes) are not configurable.`
|
|
5104
|
-
}
|
|
5105
|
-
}
|
|
5106
|
-
die(error)
|
|
5107
|
-
}
|
|
5108
|
-
}
|
|
5247
|
+
/*
|
|
5248
|
+
// Configurable, not sealed, not frozen
|
|
5249
|
+
// Possibly not needed, just a little better error then the one thrown by engine.
|
|
5250
|
+
// Cases where this would be useful the most (subclass field initializer) are not interceptable by this.
|
|
5251
|
+
if (__DEV__) {
|
|
5252
|
+
const configurable = getDescriptor(adm.target_, key)?.configurable
|
|
5253
|
+
const frozen = Object.isFrozen(adm.target_)
|
|
5254
|
+
const sealed = Object.isSealed(adm.target_)
|
|
5255
|
+
if (!configurable || frozen || sealed) {
|
|
5256
|
+
const fieldName = `${adm.name_}.${key.toString()}`
|
|
5257
|
+
const requestedAnnotationType = annotation.annotationType_
|
|
5258
|
+
let error = `Cannot apply '${requestedAnnotationType}' to '${fieldName}':`
|
|
5259
|
+
if (frozen) {
|
|
5260
|
+
error += `\nObject is frozen.`
|
|
5261
|
+
}
|
|
5262
|
+
if (sealed) {
|
|
5263
|
+
error += `\nObject is sealed.`
|
|
5264
|
+
}
|
|
5265
|
+
if (!configurable) {
|
|
5266
|
+
error += `\nproperty is not configurable.`
|
|
5267
|
+
// Mention only if caused by us to avoid confusion
|
|
5268
|
+
if (hasProp(adm.appliedAnnotations!, key)) {
|
|
5269
|
+
error += `\nTo prevent accidental re-definition of a field by a subclass, `
|
|
5270
|
+
error += `all annotated fields of non-plain objects (classes) are not configurable.`
|
|
5271
|
+
}
|
|
5272
|
+
}
|
|
5273
|
+
die(error)
|
|
5274
|
+
}
|
|
5275
|
+
}
|
|
5109
5276
|
*/
|
|
5110
5277
|
// Not annotated
|
|
5111
5278
|
if ( !isOverride(annotation) && hasProp(adm.appliedAnnotations_, key)) {
|
|
@@ -5129,10 +5296,10 @@ var safariPrototypeSetterInheritanceBug = /*#__PURE__*/function () {
|
|
|
5129
5296
|
/*#__PURE__*/Object.create(p)["0"] = 1;
|
|
5130
5297
|
return v === false;
|
|
5131
5298
|
}();
|
|
5132
|
-
/**
|
|
5133
|
-
* This array buffer contains two lists of properties, so that all arrays
|
|
5134
|
-
* can recycle their property definitions, which significantly improves performance of creating
|
|
5135
|
-
* properties on the fly.
|
|
5299
|
+
/**
|
|
5300
|
+
* This array buffer contains two lists of properties, so that all arrays
|
|
5301
|
+
* can recycle their property definitions, which significantly improves performance of creating
|
|
5302
|
+
* properties on the fly.
|
|
5136
5303
|
*/
|
|
5137
5304
|
var OBSERVABLE_ARRAY_BUFFER_SIZE = 0;
|
|
5138
5305
|
// Typescript workaround to make sure ObservableArray extends Array
|
|
@@ -5329,11 +5496,11 @@ function getDebugName(thing, property) {
|
|
|
5329
5496
|
}
|
|
5330
5497
|
return named.name_;
|
|
5331
5498
|
}
|
|
5332
|
-
/**
|
|
5333
|
-
* Helper function for initializing observable structures, it applies:
|
|
5334
|
-
* 1. allowStateChanges so we don't violate enforceActions.
|
|
5335
|
-
* 2. untracked so we don't accidentaly subscribe to anything observable accessed during init in case the observable is created inside derivation.
|
|
5336
|
-
* 3. batch to avoid state version updates
|
|
5499
|
+
/**
|
|
5500
|
+
* Helper function for initializing observable structures, it applies:
|
|
5501
|
+
* 1. allowStateChanges so we don't violate enforceActions.
|
|
5502
|
+
* 2. untracked so we don't accidentaly subscribe to anything observable accessed during init in case the observable is created inside derivation.
|
|
5503
|
+
* 3. batch to avoid state version updates
|
|
5337
5504
|
*/
|
|
5338
5505
|
function initObservable(cb) {
|
|
5339
5506
|
var derivation = untrackedStart();
|
|
@@ -5515,22 +5682,22 @@ function isAnnotation(thing) {
|
|
|
5515
5682
|
);
|
|
5516
5683
|
}
|
|
5517
5684
|
|
|
5518
|
-
/**
|
|
5519
|
-
* (c) Michel Weststrate 2015 - 2020
|
|
5520
|
-
* MIT Licensed
|
|
5521
|
-
*
|
|
5522
|
-
* Welcome to the mobx sources! To get a global overview of how MobX internally works,
|
|
5523
|
-
* this is a good place to start:
|
|
5524
|
-
* https://medium.com/@mweststrate/becoming-fully-reactive-an-in-depth-explanation-of-mobservable-55995262a254#.xvbh6qd74
|
|
5525
|
-
*
|
|
5526
|
-
* Source folders:
|
|
5527
|
-
* ===============
|
|
5528
|
-
*
|
|
5529
|
-
* - api/ Most of the public static methods exposed by the module can be found here.
|
|
5530
|
-
* - core/ Implementation of the MobX algorithm; atoms, derivations, reactions, dependency trees, optimizations. Cool stuff can be found here.
|
|
5531
|
-
* - types/ All the magic that is need to have observable objects, arrays and values is in this folder. Including the modifiers like `asFlat`.
|
|
5532
|
-
* - utils/ Utility stuff.
|
|
5533
|
-
*
|
|
5685
|
+
/**
|
|
5686
|
+
* (c) Michel Weststrate 2015 - 2020
|
|
5687
|
+
* MIT Licensed
|
|
5688
|
+
*
|
|
5689
|
+
* Welcome to the mobx sources! To get a global overview of how MobX internally works,
|
|
5690
|
+
* this is a good place to start:
|
|
5691
|
+
* https://medium.com/@mweststrate/becoming-fully-reactive-an-in-depth-explanation-of-mobservable-55995262a254#.xvbh6qd74
|
|
5692
|
+
*
|
|
5693
|
+
* Source folders:
|
|
5694
|
+
* ===============
|
|
5695
|
+
*
|
|
5696
|
+
* - api/ Most of the public static methods exposed by the module can be found here.
|
|
5697
|
+
* - core/ Implementation of the MobX algorithm; atoms, derivations, reactions, dependency trees, optimizations. Cool stuff can be found here.
|
|
5698
|
+
* - types/ All the magic that is need to have observable objects, arrays and values is in this folder. Including the modifiers like `asFlat`.
|
|
5699
|
+
* - utils/ Utility stuff.
|
|
5700
|
+
*
|
|
5534
5701
|
*/
|
|
5535
5702
|
["Symbol", "Map", "Set"].forEach(function (m) {
|
|
5536
5703
|
var g = getGlobal();
|