mobx 6.10.2 → 6.11.0-pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +422 -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 +422 -252
- package/dist/mobx.esm.development.js.map +1 -1
- package/dist/mobx.esm.js +422 -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 +422 -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 +99 -98
- package/dist/types/observableset.d.ts +53 -53
- package/dist/types/observablevalue.d.ts +49 -49
- package/dist/types/overrideannotation.d.ts +4 -3
- package/dist/types/type-utils.d.ts +11 -11
- package/dist/utils/comparer.d.ts +14 -14
- package/dist/utils/eq.d.ts +1 -1
- package/dist/utils/global.d.ts +1 -1
- package/dist/utils/iterable.d.ts +1 -1
- package/dist/utils/utils.d.ts +45 -45
- package/package.json +1 -1
- package/src/api/action.ts +21 -4
- package/src/api/annotation.ts +1 -0
- package/src/api/computed.ts +11 -4
- package/src/api/decorators.ts +29 -8
- package/src/api/flow.ts +10 -3
- package/src/api/observable.ts +19 -6
- package/src/types/actionannotation.ts +48 -2
- package/src/types/autoannotation.ts +8 -2
- package/src/types/computedannotation.ts +39 -2
- package/src/types/decorator_fills.ts +33 -0
- package/src/types/flowannotation.ts +28 -2
- package/src/types/legacyobservablearray.ts +1 -1
- package/src/types/observableannotation.ts +75 -2
- package/src/types/observableobject.ts +16 -0
- package/src/types/overrideannotation.ts +15 -7
package/dist/mobx.esm.js
CHANGED
|
@@ -3,16 +3,16 @@ var niceErrors = {
|
|
|
3
3
|
1: function _(annotationType, key) {
|
|
4
4
|
return "Cannot apply '" + annotationType + "' to '" + key.toString() + "': Field not found.";
|
|
5
5
|
},
|
|
6
|
-
/*
|
|
7
|
-
2(prop) {
|
|
8
|
-
return `invalid decorator for '${prop.toString()}'`
|
|
9
|
-
},
|
|
10
|
-
3(prop) {
|
|
11
|
-
return `Cannot decorate '${prop.toString()}': action can only be used on properties with a function value.`
|
|
12
|
-
},
|
|
13
|
-
4(prop) {
|
|
14
|
-
return `Cannot decorate '${prop.toString()}': computed can only be used on getter properties.`
|
|
15
|
-
},
|
|
6
|
+
/*
|
|
7
|
+
2(prop) {
|
|
8
|
+
return `invalid decorator for '${prop.toString()}'`
|
|
9
|
+
},
|
|
10
|
+
3(prop) {
|
|
11
|
+
return `Cannot decorate '${prop.toString()}': action can only be used on properties with a function value.`
|
|
12
|
+
},
|
|
13
|
+
4(prop) {
|
|
14
|
+
return `Cannot decorate '${prop.toString()}': computed can only be used on getter properties.`
|
|
15
|
+
},
|
|
16
16
|
*/
|
|
17
17
|
5: "'keys()' can only be used on observable objects, arrays, sets and maps",
|
|
18
18
|
6: "'values()' can only be used on observable objects, arrays, sets and maps",
|
|
@@ -128,8 +128,8 @@ function warnAboutProxyRequirement(msg) {
|
|
|
128
128
|
function getNextId() {
|
|
129
129
|
return ++globalState.mobxGuid;
|
|
130
130
|
}
|
|
131
|
-
/**
|
|
132
|
-
* Makes sure that the provided function is invoked at most once.
|
|
131
|
+
/**
|
|
132
|
+
* Makes sure that the provided function is invoked at most once.
|
|
133
133
|
*/
|
|
134
134
|
function once(func) {
|
|
135
135
|
var invoked = false;
|
|
@@ -210,8 +210,8 @@ function isES6Set(thing) {
|
|
|
210
210
|
return thing instanceof Set;
|
|
211
211
|
}
|
|
212
212
|
var hasGetOwnPropertySymbols = typeof Object.getOwnPropertySymbols !== "undefined";
|
|
213
|
-
/**
|
|
214
|
-
* Returns the following: own enumerable keys and symbols.
|
|
213
|
+
/**
|
|
214
|
+
* Returns the following: own enumerable keys and symbols.
|
|
215
215
|
*/
|
|
216
216
|
function getPlainObjectKeys(object) {
|
|
217
217
|
var keys = Object.keys(object);
|
|
@@ -354,20 +354,24 @@ function _toPropertyKey(arg) {
|
|
|
354
354
|
}
|
|
355
355
|
|
|
356
356
|
var storedAnnotationsSymbol = /*#__PURE__*/Symbol("mobx-stored-annotations");
|
|
357
|
-
/**
|
|
358
|
-
* Creates a function that acts as
|
|
359
|
-
* - decorator
|
|
360
|
-
* - annotation object
|
|
357
|
+
/**
|
|
358
|
+
* Creates a function that acts as
|
|
359
|
+
* - decorator
|
|
360
|
+
* - annotation object
|
|
361
361
|
*/
|
|
362
362
|
function createDecoratorAnnotation(annotation) {
|
|
363
363
|
function decorator(target, property) {
|
|
364
|
-
|
|
364
|
+
if (is20223Decorator(property)) {
|
|
365
|
+
return annotation.decorate_20223_(target, property);
|
|
366
|
+
} else {
|
|
367
|
+
storeAnnotation(target, property, annotation);
|
|
368
|
+
}
|
|
365
369
|
}
|
|
366
370
|
return Object.assign(decorator, annotation);
|
|
367
371
|
}
|
|
368
|
-
/**
|
|
369
|
-
* Stores annotation to prototype,
|
|
370
|
-
* so it can be inspected later by `makeObservable` called from constructor
|
|
372
|
+
/**
|
|
373
|
+
* Stores annotation to prototype,
|
|
374
|
+
* so it can be inspected later by `makeObservable` called from constructor
|
|
371
375
|
*/
|
|
372
376
|
function storeAnnotation(prototype, key, annotation) {
|
|
373
377
|
if (!hasProp(prototype, storedAnnotationsSymbol)) {
|
|
@@ -393,27 +397,37 @@ function assertNotDecorated(prototype, annotation, key) {
|
|
|
393
397
|
die("Cannot apply '@" + requestedAnnotationType + "' to '" + fieldName + "':" + ("\nThe field is already decorated with '@" + currentAnnotationType + "'.") + "\nRe-decorating fields is not allowed." + "\nUse '@override' decorator for methods overridden by subclass.");
|
|
394
398
|
}
|
|
395
399
|
}
|
|
396
|
-
/**
|
|
397
|
-
* Collects annotations from prototypes and stores them on target (instance)
|
|
400
|
+
/**
|
|
401
|
+
* Collects annotations from prototypes and stores them on target (instance)
|
|
398
402
|
*/
|
|
399
403
|
function collectStoredAnnotations(target) {
|
|
400
404
|
if (!hasProp(target, storedAnnotationsSymbol)) {
|
|
401
|
-
if (
|
|
402
|
-
|
|
403
|
-
|
|
405
|
+
// if (__DEV__ && !target[storedAnnotationsSymbol]) {
|
|
406
|
+
// die(
|
|
407
|
+
// `No annotations were passed to makeObservable, but no decorated members have been found either`
|
|
408
|
+
// )
|
|
409
|
+
// }
|
|
404
410
|
// We need a copy as we will remove annotation from the list once it's applied.
|
|
405
411
|
addHiddenProp(target, storedAnnotationsSymbol, _extends({}, target[storedAnnotationsSymbol]));
|
|
406
412
|
}
|
|
407
413
|
return target[storedAnnotationsSymbol];
|
|
408
414
|
}
|
|
415
|
+
function is20223Decorator(context) {
|
|
416
|
+
return typeof context == "object" && typeof context["kind"] == "string";
|
|
417
|
+
}
|
|
418
|
+
function assert20223DecoratorType(context, types) {
|
|
419
|
+
if (process.env.NODE_ENV !== "production" && !types.includes(context.kind)) {
|
|
420
|
+
die("Decorator may not be used like this");
|
|
421
|
+
}
|
|
422
|
+
}
|
|
409
423
|
|
|
410
424
|
var $mobx = /*#__PURE__*/Symbol("mobx administration");
|
|
411
425
|
var Atom = /*#__PURE__*/function () {
|
|
412
426
|
// for effective unobserving. BaseAtom has true, for extra optimization, so its onBecomeUnobserved never gets called, because it's not needed
|
|
413
427
|
|
|
414
|
-
/**
|
|
415
|
-
* Create a new atom. For debugging purposes it is recommended to give it a name.
|
|
416
|
-
* The onBecomeObserved and onBecomeUnobserved callbacks can be used for resource management.
|
|
428
|
+
/**
|
|
429
|
+
* Create a new atom. For debugging purposes it is recommended to give it a name.
|
|
430
|
+
* The onBecomeObserved and onBecomeUnobserved callbacks can be used for resource management.
|
|
417
431
|
*/
|
|
418
432
|
function Atom(name_) {
|
|
419
433
|
if (name_ === void 0) {
|
|
@@ -448,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,58 @@ 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
|
+
assert20223DecoratorType(context, ["accessor", "field"]);
|
|
919
|
+
}
|
|
920
|
+
var ann = this;
|
|
921
|
+
var kind = context.kind,
|
|
922
|
+
name = context.name,
|
|
923
|
+
addInitializer = context.addInitializer;
|
|
924
|
+
// Backwards/Legacy behavior, expects makeObservable(this)
|
|
925
|
+
if (kind == "field") {
|
|
926
|
+
addInitializer(function () {
|
|
927
|
+
storeAnnotation(this, name, ann);
|
|
928
|
+
});
|
|
929
|
+
return;
|
|
930
|
+
}
|
|
931
|
+
// The laziness here is not ideal... It's a workaround to how 2022.3 Decorators are implemented:
|
|
932
|
+
// `addInitializer` callbacks are executed _before_ any accessors are defined (instead of the ideal-for-us right after each).
|
|
933
|
+
// This means that, if we were to do our stuff in an `addInitializer`, we'd attempt to read a private slot
|
|
934
|
+
// before it has been initialized. The runtime doesn't like that and throws a `Cannot read private member
|
|
935
|
+
// from an object whose class did not declare it` error.
|
|
936
|
+
var initializedObjects = new WeakSet();
|
|
937
|
+
function initializeObservable(target, value) {
|
|
938
|
+
var _ann$options_$enhance, _ann$options_;
|
|
939
|
+
var adm = asObservableObject(target)[$mobx];
|
|
940
|
+
var observable = new ObservableValue(value, (_ann$options_$enhance = (_ann$options_ = ann.options_) == null ? void 0 : _ann$options_.enhancer) != null ? _ann$options_$enhance : deepEnhancer, process.env.NODE_ENV !== "production" ? adm.name_ + "." + name.toString() : "ObservableObject." + name.toString(), false);
|
|
941
|
+
adm.values_.set(name, observable);
|
|
942
|
+
initializedObjects.add(target);
|
|
943
|
+
}
|
|
944
|
+
if (kind == "accessor") {
|
|
945
|
+
return {
|
|
946
|
+
get: function get() {
|
|
947
|
+
if (!initializedObjects.has(this)) {
|
|
948
|
+
initializeObservable(this, desc.get.call(this));
|
|
949
|
+
}
|
|
950
|
+
return this[$mobx].getObservablePropValue_(name);
|
|
951
|
+
},
|
|
952
|
+
set: function set(value) {
|
|
953
|
+
if (!initializedObjects.has(this)) {
|
|
954
|
+
initializeObservable(this, value);
|
|
955
|
+
}
|
|
956
|
+
return this[$mobx].setObservablePropValue_(name, value);
|
|
957
|
+
},
|
|
958
|
+
init: function init(value) {
|
|
959
|
+
if (!initializedObjects.has(this)) {
|
|
960
|
+
initializeObservable(this, value);
|
|
961
|
+
}
|
|
962
|
+
return value;
|
|
963
|
+
}
|
|
964
|
+
};
|
|
965
|
+
}
|
|
966
|
+
return;
|
|
967
|
+
}
|
|
818
968
|
function assertObservableDescriptor(adm, _ref, key, descriptor) {
|
|
819
969
|
var annotationType_ = _ref.annotationType_;
|
|
820
970
|
if (process.env.NODE_ENV !== "production" && !("value" in descriptor)) {
|
|
@@ -829,7 +979,8 @@ function createAutoAnnotation(options) {
|
|
|
829
979
|
annotationType_: AUTO,
|
|
830
980
|
options_: options,
|
|
831
981
|
make_: make_$5,
|
|
832
|
-
extend_: extend_$5
|
|
982
|
+
extend_: extend_$5,
|
|
983
|
+
decorate_20223_: decorate_20223_$5
|
|
833
984
|
};
|
|
834
985
|
}
|
|
835
986
|
function make_$5(adm, key, descriptor, source) {
|
|
@@ -847,14 +998,14 @@ function make_$5(adm, key, descriptor, source) {
|
|
|
847
998
|
return adm.defineProperty_(key, {
|
|
848
999
|
configurable: globalState.safeDescriptors ? adm.isPlainObject_ : true,
|
|
849
1000
|
set: set
|
|
850
|
-
}) === null ? 0 /* Cancel */ : 2 /* Continue */;
|
|
1001
|
+
}) === null ? 0 /* MakeResult.Cancel */ : 2 /* MakeResult.Continue */;
|
|
851
1002
|
}
|
|
852
1003
|
// proto
|
|
853
1004
|
defineProperty(source, key, {
|
|
854
1005
|
configurable: true,
|
|
855
1006
|
set: set
|
|
856
1007
|
});
|
|
857
|
-
return 2 /* Continue */;
|
|
1008
|
+
return 2 /* MakeResult.Continue */;
|
|
858
1009
|
}
|
|
859
1010
|
// function on proto -> autoAction/flow
|
|
860
1011
|
if (source !== adm.target_ && typeof descriptor.value === "function") {
|
|
@@ -901,6 +1052,9 @@ function extend_$5(adm, key, descriptor, proxyTrap) {
|
|
|
901
1052
|
var observableAnnotation = ((_this$options_6 = this.options_) == null ? void 0 : _this$options_6.deep) === false ? observable.ref : observable;
|
|
902
1053
|
return observableAnnotation.extend_(adm, key, descriptor, proxyTrap);
|
|
903
1054
|
}
|
|
1055
|
+
function decorate_20223_$5(desc, context) {
|
|
1056
|
+
die("'" + this.annotationType_ + "' cannot be used as a decorator");
|
|
1057
|
+
}
|
|
904
1058
|
|
|
905
1059
|
var OBSERVABLE = "observable";
|
|
906
1060
|
var OBSERVABLE_REF = "observable.ref";
|
|
@@ -940,11 +1094,15 @@ function getEnhancerFromAnnotation(annotation) {
|
|
|
940
1094
|
var _annotation$options_$, _annotation$options_;
|
|
941
1095
|
return !annotation ? deepEnhancer : (_annotation$options_$ = (_annotation$options_ = annotation.options_) == null ? void 0 : _annotation$options_.enhancer) != null ? _annotation$options_$ : deepEnhancer;
|
|
942
1096
|
}
|
|
943
|
-
/**
|
|
944
|
-
* Turns an object, array or function into a reactive structure.
|
|
945
|
-
* @param v the value which should become observable.
|
|
1097
|
+
/**
|
|
1098
|
+
* Turns an object, array or function into a reactive structure.
|
|
1099
|
+
* @param v the value which should become observable.
|
|
946
1100
|
*/
|
|
947
1101
|
function createObservable(v, arg2, arg3) {
|
|
1102
|
+
// @observable someProp; (2022.3 Decorators)
|
|
1103
|
+
if (is20223Decorator(arg2)) {
|
|
1104
|
+
return observableAnnotation.decorate_20223_(v, arg2);
|
|
1105
|
+
}
|
|
948
1106
|
// @observable someProp;
|
|
949
1107
|
if (isStringish(arg2)) {
|
|
950
1108
|
storeAnnotation(v, arg2, observableAnnotation);
|
|
@@ -1014,11 +1172,15 @@ var computedAnnotation = /*#__PURE__*/createComputedAnnotation(COMPUTED);
|
|
|
1014
1172
|
var computedStructAnnotation = /*#__PURE__*/createComputedAnnotation(COMPUTED_STRUCT, {
|
|
1015
1173
|
equals: comparer.structural
|
|
1016
1174
|
});
|
|
1017
|
-
/**
|
|
1018
|
-
* Decorator for class properties: @computed get value() { return expr; }.
|
|
1019
|
-
* For legacy purposes also invokable as ES5 observable created: `computed(() => expr)`;
|
|
1175
|
+
/**
|
|
1176
|
+
* Decorator for class properties: @computed get value() { return expr; }.
|
|
1177
|
+
* For legacy purposes also invokable as ES5 observable created: `computed(() => expr)`;
|
|
1020
1178
|
*/
|
|
1021
1179
|
var computed = function computed(arg1, arg2) {
|
|
1180
|
+
if (is20223Decorator(arg2)) {
|
|
1181
|
+
// @computed (2022.3 Decorators)
|
|
1182
|
+
return computedAnnotation.decorate_20223_(arg1, arg2);
|
|
1183
|
+
}
|
|
1022
1184
|
if (isStringish(arg2)) {
|
|
1023
1185
|
// @computed
|
|
1024
1186
|
return storeAnnotation(arg1, arg2, computedAnnotation);
|
|
@@ -1305,24 +1467,24 @@ var ObservableValue = /*#__PURE__*/function (_Atom) {
|
|
|
1305
1467
|
var isObservableValue = /*#__PURE__*/createInstanceofPredicate("ObservableValue", ObservableValue);
|
|
1306
1468
|
|
|
1307
1469
|
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.
|
|
1470
|
+
/**
|
|
1471
|
+
* A node in the state dependency root that observes other nodes, and can be observed itself.
|
|
1472
|
+
*
|
|
1473
|
+
* ComputedValue will remember the result of the computation for the duration of the batch, or
|
|
1474
|
+
* while being observed.
|
|
1475
|
+
*
|
|
1476
|
+
* During this time it will recompute only when one of its direct dependencies changed,
|
|
1477
|
+
* but only when it is being accessed with `ComputedValue.get()`.
|
|
1478
|
+
*
|
|
1479
|
+
* Implementation description:
|
|
1480
|
+
* 1. First time it's being accessed it will compute and remember result
|
|
1481
|
+
* give back remembered result until 2. happens
|
|
1482
|
+
* 2. First time any deep dependency change, propagate POSSIBLY_STALE to all observers, wait for 3.
|
|
1483
|
+
* 3. When it's being accessed, recompute if any shallow dependency changed.
|
|
1484
|
+
* if result changed: propagate STALE to all observers, that were POSSIBLY_STALE from the last step.
|
|
1485
|
+
* go to step 2. either way
|
|
1486
|
+
*
|
|
1487
|
+
* If at any point it's outside batch and it isn't observed: reset everything and go to 1.
|
|
1326
1488
|
*/
|
|
1327
1489
|
_Symbol$toPrimitive$1 = Symbol.toPrimitive;
|
|
1328
1490
|
var ComputedValue = /*#__PURE__*/function () {
|
|
@@ -1333,17 +1495,17 @@ var ComputedValue = /*#__PURE__*/function () {
|
|
|
1333
1495
|
|
|
1334
1496
|
// N.B: unminified as it is used by MST
|
|
1335
1497
|
|
|
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.
|
|
1498
|
+
/**
|
|
1499
|
+
* Create a new computed value based on a function expression.
|
|
1500
|
+
*
|
|
1501
|
+
* The `name` property is for debug purposes only.
|
|
1502
|
+
*
|
|
1503
|
+
* The `equals` property specifies the comparer function to use to determine if a newly produced
|
|
1504
|
+
* value differs from the previous value. Two comparers are provided in the library; `defaultComparer`
|
|
1505
|
+
* compares based on identity comparison (===), and `structuralComparer` deeply compares the structure.
|
|
1506
|
+
* Structural comparison can be convenient if you always produce a new aggregated object and
|
|
1507
|
+
* don't want to notify observers if it is structurally the same.
|
|
1508
|
+
* This is useful for working with vectors, mouse coordinates etc.
|
|
1347
1509
|
*/
|
|
1348
1510
|
function ComputedValue(options) {
|
|
1349
1511
|
this.dependenciesState_ = IDerivationState_.NOT_TRACKING_;
|
|
@@ -1402,9 +1564,9 @@ var ComputedValue = /*#__PURE__*/function () {
|
|
|
1402
1564
|
});
|
|
1403
1565
|
}
|
|
1404
1566
|
}
|
|
1405
|
-
/**
|
|
1406
|
-
* Returns the current value of this computed value.
|
|
1407
|
-
* Will evaluate its computation first if needed.
|
|
1567
|
+
/**
|
|
1568
|
+
* Returns the current value of this computed value.
|
|
1569
|
+
* Will evaluate its computation first if needed.
|
|
1408
1570
|
*/;
|
|
1409
1571
|
_proto.get = function get() {
|
|
1410
1572
|
if (this.isComputing_) {
|
|
@@ -1587,16 +1749,16 @@ var CaughtException = function CaughtException(cause) {
|
|
|
1587
1749
|
function isCaughtException(e) {
|
|
1588
1750
|
return e instanceof CaughtException;
|
|
1589
1751
|
}
|
|
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.
|
|
1752
|
+
/**
|
|
1753
|
+
* Finds out whether any dependency of the derivation has actually changed.
|
|
1754
|
+
* If dependenciesState is 1 then it will recalculate dependencies,
|
|
1755
|
+
* if any dependency changed it will propagate it by changing dependenciesState to 2.
|
|
1756
|
+
*
|
|
1757
|
+
* By iterating over the dependencies in the same order that they were reported and
|
|
1758
|
+
* stopping on the first change, all the recalculations are only called for ComputedValues
|
|
1759
|
+
* that will be tracked by derivation. That is because we assume that if the first x
|
|
1760
|
+
* dependencies of the derivation doesn't change then the derivation should run the same way
|
|
1761
|
+
* up until accessing x-th dependency.
|
|
1600
1762
|
*/
|
|
1601
1763
|
function shouldCompute(derivation) {
|
|
1602
1764
|
switch (derivation.dependenciesState_) {
|
|
@@ -1663,10 +1825,10 @@ function checkIfStateReadsAreAllowed(observable) {
|
|
|
1663
1825
|
console.warn("[mobx] Observable '" + observable.name_ + "' being read outside a reactive context.");
|
|
1664
1826
|
}
|
|
1665
1827
|
}
|
|
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.
|
|
1828
|
+
/**
|
|
1829
|
+
* Executes the provided function `f` and tracks which observables are being accessed.
|
|
1830
|
+
* The tracking information is stored on the `derivation` object and the derivation is registered
|
|
1831
|
+
* as observer of any of the accessed observables.
|
|
1670
1832
|
*/
|
|
1671
1833
|
function trackDerivedFunction(derivation, f, context) {
|
|
1672
1834
|
var prevAllowStateReads = allowStateReadsStart(true);
|
|
@@ -1707,10 +1869,10 @@ function warnAboutDerivationWithoutDependencies(derivation) {
|
|
|
1707
1869
|
console.warn("[mobx] Derivation '" + derivation.name_ + "' is created/updated without reading any observable value.");
|
|
1708
1870
|
}
|
|
1709
1871
|
}
|
|
1710
|
-
/**
|
|
1711
|
-
* diffs newObserving with observing.
|
|
1712
|
-
* update observing to be newObserving with unique observables
|
|
1713
|
-
* notify observers that become observed/unobserved
|
|
1872
|
+
/**
|
|
1873
|
+
* diffs newObserving with observing.
|
|
1874
|
+
* update observing to be newObserving with unique observables
|
|
1875
|
+
* notify observers that become observed/unobserved
|
|
1714
1876
|
*/
|
|
1715
1877
|
function bindDependencies(derivation) {
|
|
1716
1878
|
// invariant(derivation.dependenciesState !== IDerivationState.NOT_TRACKING, "INTERNAL ERROR bindDependencies expects derivation.dependenciesState !== -1");
|
|
@@ -1801,9 +1963,9 @@ function allowStateReadsStart(allowStateReads) {
|
|
|
1801
1963
|
function allowStateReadsEnd(prev) {
|
|
1802
1964
|
globalState.allowStateReads = prev;
|
|
1803
1965
|
}
|
|
1804
|
-
/**
|
|
1805
|
-
* needed to keep `lowestObserverState` correct. when changing from (2 or 1) to 0
|
|
1806
|
-
*
|
|
1966
|
+
/**
|
|
1967
|
+
* needed to keep `lowestObserverState` correct. when changing from (2 or 1) to 0
|
|
1968
|
+
*
|
|
1807
1969
|
*/
|
|
1808
1970
|
function changeDependenciesStateTo0(derivation) {
|
|
1809
1971
|
if (derivation.dependenciesState_ === IDerivationState_.UP_TO_DATE_) {
|
|
@@ -1817,8 +1979,8 @@ function changeDependenciesStateTo0(derivation) {
|
|
|
1817
1979
|
}
|
|
1818
1980
|
}
|
|
1819
1981
|
|
|
1820
|
-
/**
|
|
1821
|
-
* These values will persist if global state is reset
|
|
1982
|
+
/**
|
|
1983
|
+
* These values will persist if global state is reset
|
|
1822
1984
|
*/
|
|
1823
1985
|
var persistentKeys = ["mobxGuid", "spyListeners", "enforceActions", "computedRequiresReaction", "reactionRequiresObservable", "observableRequiresReaction", "allowStateReads", "disableErrorBoundaries", "runId", "UNCHANGED", "useProxies"];
|
|
1824
1986
|
var MobXGlobals = function MobXGlobals() {
|
|
@@ -1894,9 +2056,9 @@ function isolateGlobalState() {
|
|
|
1894
2056
|
function getGlobalState() {
|
|
1895
2057
|
return globalState;
|
|
1896
2058
|
}
|
|
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
|
|
2059
|
+
/**
|
|
2060
|
+
* For testing purposes only; this will break the internal state of existing observables,
|
|
2061
|
+
* but can be used to get back at a stable state after throwing errors
|
|
1900
2062
|
*/
|
|
1901
2063
|
function resetGlobalState() {
|
|
1902
2064
|
var defaultGlobals = new MobXGlobals();
|
|
@@ -1963,10 +2125,10 @@ function queueForUnobservation(observable) {
|
|
|
1963
2125
|
globalState.pendingUnobservations.push(observable);
|
|
1964
2126
|
}
|
|
1965
2127
|
}
|
|
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.
|
|
2128
|
+
/**
|
|
2129
|
+
* Batch starts a transaction, at least for purposes of memoizing ComputedValues when nothing else does.
|
|
2130
|
+
* During a batch `onBecomeUnobserved` will be called at most once per observable.
|
|
2131
|
+
* Avoids unnecessary recalculations.
|
|
1970
2132
|
*/
|
|
1971
2133
|
function startBatch() {
|
|
1972
2134
|
if (globalState.inBatch === 0) {
|
|
@@ -2002,10 +2164,10 @@ function reportObserved(observable) {
|
|
|
2002
2164
|
checkIfStateReadsAreAllowed(observable);
|
|
2003
2165
|
var derivation = globalState.trackingDerivation;
|
|
2004
2166
|
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
|
|
2167
|
+
/**
|
|
2168
|
+
* Simple optimization, give each derivation run an unique id (runId)
|
|
2169
|
+
* Check if last time this observable was accessed the same runId is used
|
|
2170
|
+
* if this is the case, the relation is already known
|
|
2009
2171
|
*/
|
|
2010
2172
|
if (derivation.runId_ !== observable.lastAccessedBy_) {
|
|
2011
2173
|
observable.lastAccessedBy_ = derivation.runId_;
|
|
@@ -2035,12 +2197,12 @@ function reportObserved(observable) {
|
|
|
2035
2197
|
// observable.lowestObserverState
|
|
2036
2198
|
// )
|
|
2037
2199
|
// }
|
|
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
|
|
2200
|
+
/**
|
|
2201
|
+
* NOTE: current propagation mechanism will in case of self reruning autoruns behave unexpectedly
|
|
2202
|
+
* It will propagate changes to observers from previous run
|
|
2203
|
+
* It's hard or maybe impossible (with reasonable perf) to get it right with current approach
|
|
2204
|
+
* Hopefully self reruning autoruns aren't a feature people should depend on
|
|
2205
|
+
* Also most basic use cases should be ok
|
|
2044
2206
|
*/
|
|
2045
2207
|
// Called by Atom when its value changes
|
|
2046
2208
|
function propagateChanged(observable) {
|
|
@@ -2160,8 +2322,8 @@ var Reaction = /*#__PURE__*/function () {
|
|
|
2160
2322
|
_proto.isScheduled = function isScheduled() {
|
|
2161
2323
|
return this.isScheduled_;
|
|
2162
2324
|
}
|
|
2163
|
-
/**
|
|
2164
|
-
* internal, use schedule() if you intend to kick off a reaction
|
|
2325
|
+
/**
|
|
2326
|
+
* internal, use schedule() if you intend to kick off a reaction
|
|
2165
2327
|
*/;
|
|
2166
2328
|
_proto.runReaction_ = function runReaction_() {
|
|
2167
2329
|
if (!this.isDisposed_) {
|
|
@@ -2294,10 +2456,10 @@ function onReactionError(handler) {
|
|
|
2294
2456
|
}
|
|
2295
2457
|
};
|
|
2296
2458
|
}
|
|
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...
|
|
2459
|
+
/**
|
|
2460
|
+
* Magic number alert!
|
|
2461
|
+
* Defines within how many times a reaction is allowed to re-trigger itself
|
|
2462
|
+
* until it is assumed that this is gonna be a never ending loop...
|
|
2301
2463
|
*/
|
|
2302
2464
|
var MAX_REACTION_ITERATIONS = 100;
|
|
2303
2465
|
var reactionScheduler = function reactionScheduler(f) {
|
|
@@ -2421,6 +2583,10 @@ function createActionFactory(autoAction) {
|
|
|
2421
2583
|
if (isFunction(arg2)) {
|
|
2422
2584
|
return createAction(arg1, arg2, autoAction);
|
|
2423
2585
|
}
|
|
2586
|
+
// @action (2022.3 Decorators)
|
|
2587
|
+
if (is20223Decorator(arg2)) {
|
|
2588
|
+
return (autoAction ? autoActionAnnotation : actionAnnotation).decorate_20223_(arg1, arg2);
|
|
2589
|
+
}
|
|
2424
2590
|
// @action
|
|
2425
2591
|
if (isStringish(arg2)) {
|
|
2426
2592
|
return storeAnnotation(arg1, arg2, autoAction ? autoActionAnnotation : actionAnnotation);
|
|
@@ -2451,11 +2617,11 @@ function isAction(thing) {
|
|
|
2451
2617
|
return isFunction(thing) && thing.isMobxAction === true;
|
|
2452
2618
|
}
|
|
2453
2619
|
|
|
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.
|
|
2620
|
+
/**
|
|
2621
|
+
* Creates a named reactive view and keeps it alive, so that the view is always
|
|
2622
|
+
* updated if one of the dependencies changes, even when the view is not further used by something else.
|
|
2623
|
+
* @param view The reactive view
|
|
2624
|
+
* @returns disposer function, which can be used to stop the view from being updated in the future.
|
|
2459
2625
|
*/
|
|
2460
2626
|
function autorun(view, opts) {
|
|
2461
2627
|
var _opts$name, _opts, _opts2, _opts2$signal, _opts3;
|
|
@@ -2711,6 +2877,10 @@ var flowBoundAnnotation = /*#__PURE__*/createFlowAnnotation("flow.bound", {
|
|
|
2711
2877
|
bound: true
|
|
2712
2878
|
});
|
|
2713
2879
|
var flow = /*#__PURE__*/Object.assign(function flow(arg1, arg2) {
|
|
2880
|
+
// @flow (2022.3 Decorators)
|
|
2881
|
+
if (is20223Decorator(arg2)) {
|
|
2882
|
+
return flowAnnotation.decorate_20223_(arg1, arg2);
|
|
2883
|
+
}
|
|
2714
2884
|
// @flow
|
|
2715
2885
|
if (isStringish(arg2)) {
|
|
2716
2886
|
return storeAnnotation(arg1, arg2, flowAnnotation);
|
|
@@ -3097,11 +3267,11 @@ function toJSHelper(source, __alreadySeen) {
|
|
|
3097
3267
|
return _res3;
|
|
3098
3268
|
}
|
|
3099
3269
|
}
|
|
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.
|
|
3270
|
+
/**
|
|
3271
|
+
* Recursively converts an observable to it's non-observable native counterpart.
|
|
3272
|
+
* It does NOT recurse into non-observables, these are left as they are, even if they contain observables.
|
|
3273
|
+
* Computed and other non-enumerable properties are completely ignored.
|
|
3274
|
+
* Complex scenarios require custom solution, eg implementing `toJSON` or using `serializr` lib.
|
|
3105
3275
|
*/
|
|
3106
3276
|
function toJS(source, options) {
|
|
3107
3277
|
if (process.env.NODE_ENV !== "production" && options) {
|
|
@@ -3141,12 +3311,12 @@ function getAtomFromArgs(args) {
|
|
|
3141
3311
|
}
|
|
3142
3312
|
}
|
|
3143
3313
|
|
|
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.
|
|
3314
|
+
/**
|
|
3315
|
+
* During a transaction no views are updated until the end of the transaction.
|
|
3316
|
+
* The transaction will be run synchronously nonetheless.
|
|
3317
|
+
*
|
|
3318
|
+
* @param action a function that updates some reactive state
|
|
3319
|
+
* @returns any value that was returned by the 'action' parameter.
|
|
3150
3320
|
*/
|
|
3151
3321
|
function transaction(action, thisArg) {
|
|
3152
3322
|
if (thisArg === void 0) {
|
|
@@ -3734,11 +3904,11 @@ var arrayExtensions = {
|
|
|
3734
3904
|
toJSON: function toJSON() {
|
|
3735
3905
|
return this.slice();
|
|
3736
3906
|
},
|
|
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
|
|
3907
|
+
/*
|
|
3908
|
+
* functions that do alter the internal structure of the array, (based on lib.es6.d.ts)
|
|
3909
|
+
* since these functions alter the inner structure of the array, the have side effects.
|
|
3910
|
+
* Because the have side effects, they should not be used in computed function,
|
|
3911
|
+
* and for that reason the do not call dependencyState.notifyObserved
|
|
3742
3912
|
*/
|
|
3743
3913
|
splice: function splice(index, deleteCount) {
|
|
3744
3914
|
for (var _len = arguments.length, newItems = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
@@ -3810,10 +3980,10 @@ var arrayExtensions = {
|
|
|
3810
3980
|
return false;
|
|
3811
3981
|
}
|
|
3812
3982
|
};
|
|
3813
|
-
/**
|
|
3814
|
-
* Wrap function from prototype
|
|
3815
|
-
* Without this, everything works as well, but this works
|
|
3816
|
-
* faster as everything works on unproxied values
|
|
3983
|
+
/**
|
|
3984
|
+
* Wrap function from prototype
|
|
3985
|
+
* Without this, everything works as well, but this works
|
|
3986
|
+
* faster as everything works on unproxied values
|
|
3817
3987
|
*/
|
|
3818
3988
|
addArrayExtension("concat", simpleFunc);
|
|
3819
3989
|
addArrayExtension("flat", simpleFunc);
|
|
@@ -4253,10 +4423,10 @@ var ObservableMap = /*#__PURE__*/function () {
|
|
|
4253
4423
|
_proto.toJSON = function toJSON() {
|
|
4254
4424
|
return Array.from(this);
|
|
4255
4425
|
};
|
|
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
|
|
4426
|
+
/**
|
|
4427
|
+
* Observes this object. Triggers for the events 'add', 'update' and 'delete'.
|
|
4428
|
+
* See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/observe
|
|
4429
|
+
* for callback details
|
|
4260
4430
|
*/
|
|
4261
4431
|
_proto.observe_ = function observe_(listener, fireImmediately) {
|
|
4262
4432
|
if (process.env.NODE_ENV !== "production" && fireImmediately === true) {
|
|
@@ -4632,12 +4802,12 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
4632
4802
|
}
|
|
4633
4803
|
return this.target_[key];
|
|
4634
4804
|
}
|
|
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
|
|
4805
|
+
/**
|
|
4806
|
+
* @param {PropertyKey} key
|
|
4807
|
+
* @param {any} value
|
|
4808
|
+
* @param {Annotation|boolean} annotation true - use default annotation, false - copy as is
|
|
4809
|
+
* @param {boolean} proxyTrap whether it's called from proxy trap
|
|
4810
|
+
* @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor
|
|
4641
4811
|
*/;
|
|
4642
4812
|
_proto.set_ = function set_(key, value, proxyTrap) {
|
|
4643
4813
|
if (proxyTrap === void 0) {
|
|
@@ -4682,9 +4852,9 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
4682
4852
|
}
|
|
4683
4853
|
return entry.get();
|
|
4684
4854
|
}
|
|
4685
|
-
/**
|
|
4686
|
-
* @param {PropertyKey} key
|
|
4687
|
-
* @param {Annotation|boolean} annotation true - use default annotation, false - ignore prop
|
|
4855
|
+
/**
|
|
4856
|
+
* @param {PropertyKey} key
|
|
4857
|
+
* @param {Annotation|boolean} annotation true - use default annotation, false - ignore prop
|
|
4688
4858
|
*/;
|
|
4689
4859
|
_proto.make_ = function make_(key, annotation) {
|
|
4690
4860
|
if (annotation === true) {
|
|
@@ -4712,10 +4882,10 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
4712
4882
|
var descriptor = getDescriptor(source, key);
|
|
4713
4883
|
if (descriptor) {
|
|
4714
4884
|
var outcome = annotation.make_(this, key, descriptor, source);
|
|
4715
|
-
if (outcome === 0 /* Cancel */) {
|
|
4885
|
+
if (outcome === 0 /* MakeResult.Cancel */) {
|
|
4716
4886
|
return;
|
|
4717
4887
|
}
|
|
4718
|
-
if (outcome === 1 /* Break */) {
|
|
4888
|
+
if (outcome === 1 /* MakeResult.Break */) {
|
|
4719
4889
|
break;
|
|
4720
4890
|
}
|
|
4721
4891
|
}
|
|
@@ -4723,12 +4893,12 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
4723
4893
|
}
|
|
4724
4894
|
recordAnnotationApplied(this, annotation, key);
|
|
4725
4895
|
}
|
|
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
|
|
4896
|
+
/**
|
|
4897
|
+
* @param {PropertyKey} key
|
|
4898
|
+
* @param {PropertyDescriptor} descriptor
|
|
4899
|
+
* @param {Annotation|boolean} annotation true - use default annotation, false - copy as is
|
|
4900
|
+
* @param {boolean} proxyTrap whether it's called from proxy trap
|
|
4901
|
+
* @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor
|
|
4732
4902
|
*/;
|
|
4733
4903
|
_proto.extend_ = function extend_(key, descriptor, annotation, proxyTrap) {
|
|
4734
4904
|
if (proxyTrap === void 0) {
|
|
@@ -4747,11 +4917,11 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
4747
4917
|
}
|
|
4748
4918
|
return outcome;
|
|
4749
4919
|
}
|
|
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
|
|
4920
|
+
/**
|
|
4921
|
+
* @param {PropertyKey} key
|
|
4922
|
+
* @param {PropertyDescriptor} descriptor
|
|
4923
|
+
* @param {boolean} proxyTrap whether it's called from proxy trap
|
|
4924
|
+
* @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor
|
|
4755
4925
|
*/;
|
|
4756
4926
|
_proto.defineProperty_ = function defineProperty_(key, descriptor, proxyTrap) {
|
|
4757
4927
|
if (proxyTrap === void 0) {
|
|
@@ -4903,11 +5073,11 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
4903
5073
|
}
|
|
4904
5074
|
return true;
|
|
4905
5075
|
}
|
|
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
|
|
5076
|
+
/**
|
|
5077
|
+
* @param {PropertyKey} key
|
|
5078
|
+
* @param {PropertyDescriptor} descriptor
|
|
5079
|
+
* @param {boolean} proxyTrap whether it's called from proxy trap
|
|
5080
|
+
* @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor
|
|
4911
5081
|
*/;
|
|
4912
5082
|
_proto.delete_ = function delete_(key, proxyTrap) {
|
|
4913
5083
|
if (proxyTrap === void 0) {
|
|
@@ -4996,10 +5166,10 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
|
|
|
4996
5166
|
}
|
|
4997
5167
|
return true;
|
|
4998
5168
|
}
|
|
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
|
|
5169
|
+
/**
|
|
5170
|
+
* Observes this object. Triggers for the events 'add', 'update' and 'delete'.
|
|
5171
|
+
* See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/observe
|
|
5172
|
+
* for callback details
|
|
5003
5173
|
*/;
|
|
5004
5174
|
_proto.observe_ = function observe_(callback, fireImmediately) {
|
|
5005
5175
|
if (process.env.NODE_ENV !== "production" && fireImmediately === true) {
|
|
@@ -5102,35 +5272,35 @@ function assertAnnotable(adm, annotation, key) {
|
|
|
5102
5272
|
if (process.env.NODE_ENV !== "production" && !isAnnotation(annotation)) {
|
|
5103
5273
|
die("Cannot annotate '" + adm.name_ + "." + key.toString() + "': Invalid annotation.");
|
|
5104
5274
|
}
|
|
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
|
-
}
|
|
5275
|
+
/*
|
|
5276
|
+
// Configurable, not sealed, not frozen
|
|
5277
|
+
// Possibly not needed, just a little better error then the one thrown by engine.
|
|
5278
|
+
// Cases where this would be useful the most (subclass field initializer) are not interceptable by this.
|
|
5279
|
+
if (__DEV__) {
|
|
5280
|
+
const configurable = getDescriptor(adm.target_, key)?.configurable
|
|
5281
|
+
const frozen = Object.isFrozen(adm.target_)
|
|
5282
|
+
const sealed = Object.isSealed(adm.target_)
|
|
5283
|
+
if (!configurable || frozen || sealed) {
|
|
5284
|
+
const fieldName = `${adm.name_}.${key.toString()}`
|
|
5285
|
+
const requestedAnnotationType = annotation.annotationType_
|
|
5286
|
+
let error = `Cannot apply '${requestedAnnotationType}' to '${fieldName}':`
|
|
5287
|
+
if (frozen) {
|
|
5288
|
+
error += `\nObject is frozen.`
|
|
5289
|
+
}
|
|
5290
|
+
if (sealed) {
|
|
5291
|
+
error += `\nObject is sealed.`
|
|
5292
|
+
}
|
|
5293
|
+
if (!configurable) {
|
|
5294
|
+
error += `\nproperty is not configurable.`
|
|
5295
|
+
// Mention only if caused by us to avoid confusion
|
|
5296
|
+
if (hasProp(adm.appliedAnnotations!, key)) {
|
|
5297
|
+
error += `\nTo prevent accidental re-definition of a field by a subclass, `
|
|
5298
|
+
error += `all annotated fields of non-plain objects (classes) are not configurable.`
|
|
5299
|
+
}
|
|
5300
|
+
}
|
|
5301
|
+
die(error)
|
|
5302
|
+
}
|
|
5303
|
+
}
|
|
5134
5304
|
*/
|
|
5135
5305
|
// Not annotated
|
|
5136
5306
|
if (process.env.NODE_ENV !== "production" && !isOverride(annotation) && hasProp(adm.appliedAnnotations_, key)) {
|
|
@@ -5154,10 +5324,10 @@ var safariPrototypeSetterInheritanceBug = /*#__PURE__*/function () {
|
|
|
5154
5324
|
/*#__PURE__*/Object.create(p)["0"] = 1;
|
|
5155
5325
|
return v === false;
|
|
5156
5326
|
}();
|
|
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.
|
|
5327
|
+
/**
|
|
5328
|
+
* This array buffer contains two lists of properties, so that all arrays
|
|
5329
|
+
* can recycle their property definitions, which significantly improves performance of creating
|
|
5330
|
+
* properties on the fly.
|
|
5161
5331
|
*/
|
|
5162
5332
|
var OBSERVABLE_ARRAY_BUFFER_SIZE = 0;
|
|
5163
5333
|
// Typescript workaround to make sure ObservableArray extends Array
|
|
@@ -5354,11 +5524,11 @@ function getDebugName(thing, property) {
|
|
|
5354
5524
|
}
|
|
5355
5525
|
return named.name_;
|
|
5356
5526
|
}
|
|
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
|
|
5527
|
+
/**
|
|
5528
|
+
* Helper function for initializing observable structures, it applies:
|
|
5529
|
+
* 1. allowStateChanges so we don't violate enforceActions.
|
|
5530
|
+
* 2. untracked so we don't accidentaly subscribe to anything observable accessed during init in case the observable is created inside derivation.
|
|
5531
|
+
* 3. batch to avoid state version updates
|
|
5362
5532
|
*/
|
|
5363
5533
|
function initObservable(cb) {
|
|
5364
5534
|
var derivation = untrackedStart();
|
|
@@ -5540,22 +5710,22 @@ function isAnnotation(thing) {
|
|
|
5540
5710
|
);
|
|
5541
5711
|
}
|
|
5542
5712
|
|
|
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
|
-
*
|
|
5713
|
+
/**
|
|
5714
|
+
* (c) Michel Weststrate 2015 - 2020
|
|
5715
|
+
* MIT Licensed
|
|
5716
|
+
*
|
|
5717
|
+
* Welcome to the mobx sources! To get a global overview of how MobX internally works,
|
|
5718
|
+
* this is a good place to start:
|
|
5719
|
+
* https://medium.com/@mweststrate/becoming-fully-reactive-an-in-depth-explanation-of-mobservable-55995262a254#.xvbh6qd74
|
|
5720
|
+
*
|
|
5721
|
+
* Source folders:
|
|
5722
|
+
* ===============
|
|
5723
|
+
*
|
|
5724
|
+
* - api/ Most of the public static methods exposed by the module can be found here.
|
|
5725
|
+
* - core/ Implementation of the MobX algorithm; atoms, derivations, reactions, dependency trees, optimizations. Cool stuff can be found here.
|
|
5726
|
+
* - types/ All the magic that is need to have observable objects, arrays and values is in this folder. Including the modifiers like `asFlat`.
|
|
5727
|
+
* - utils/ Utility stuff.
|
|
5728
|
+
*
|
|
5559
5729
|
*/
|
|
5560
5730
|
["Symbol", "Map", "Set"].forEach(function (m) {
|
|
5561
5731
|
var g = getGlobal();
|