mobx 6.2.0 → 6.3.3
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 +44 -5
- package/README.md +4 -4
- package/dist/api/autorun.d.ts +3 -3
- package/dist/api/flow.d.ts +1 -0
- package/dist/api/object-api.d.ts +2 -0
- package/dist/errors.d.ts +2 -0
- package/dist/mobx.cjs.development.js +94 -33
- 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 +1 -1
- package/dist/mobx.esm.development.js +93 -34
- package/dist/mobx.esm.development.js.map +1 -1
- package/dist/mobx.esm.js +93 -34
- 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 +94 -33
- 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/package.json +1 -1
- package/src/api/autorun.ts +5 -5
- package/src/api/flow.ts +6 -1
- package/src/api/object-api.ts +14 -0
- package/src/api/observable.ts +4 -4
- package/src/api/tojs.ts +5 -4
- package/src/api/when.ts +1 -1
- package/src/core/computedvalue.ts +8 -6
- package/src/core/derivation.ts +4 -2
- package/src/errors.ts +14 -1
- package/src/mobx.ts +3 -1
- package/src/types/autoannotation.ts +2 -1
- package/src/types/dynamicobject.ts +1 -1
- package/src/types/flowannotation.ts +12 -3
- package/src/utils/comparer.ts +5 -1
package/dist/mobx.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { IObservable, IDepTreeNode, Reaction, IReactionPublic, IReactionDisposer, untracked, IAtom, createAtom, spy, IComputedValue, IEqualsComparer, comparer, IEnhancer, IInterceptable, IInterceptor, IListenable, IObjectWillChange, IObjectDidChange, isObservableObject, IValueDidChange, IValueWillChange, IObservableValue, isObservableValue as isBoxedObservable, IObservableArray, IArrayWillChange, IArrayWillSplice, IArraySplice, IArrayUpdate, IArrayDidChange, isObservableArray, IKeyValueMap, ObservableMap, IMapEntries, IMapEntry, IMapWillChange, IMapDidChange, isObservableMap, IObservableMapInitialValues, ObservableSet, isObservableSet, ISetDidChange, ISetWillChange, IObservableSetInitialValues, transaction, observable, IObservableFactory, CreateObservableOptions, computed, IComputedFactory, isObservable, isObservableProp, isComputed, isComputedProp, extendObservable, observe, intercept, autorun, IAutorunOptions, reaction, IReactionOptions, when, IWhenOptions, action, isAction, runInAction, IActionFactory, keys, values, entries, set, remove, has, get, configure, onBecomeObserved, onBecomeUnobserved, flow, isFlow, flowResult, FlowCancellationError, isFlowCancellationError, toJS, trace, IObserverTree, IDependencyTree, getDependencyTree, getObserverTree, resetGlobalState as _resetGlobalState, getGlobalState as _getGlobalState, getDebugName, getAtom, getAdministration as _getAdministration, allowStateChanges as _allowStateChanges, runInAction as _allowStateChangesInsideComputed, // This has become the default behavior in Mobx 6
|
|
1
|
+
export { IObservable, IDepTreeNode, Reaction, IReactionPublic, IReactionDisposer, untracked, IAtom, createAtom, spy, IComputedValue, IEqualsComparer, comparer, IEnhancer, IInterceptable, IInterceptor, IListenable, IObjectWillChange, IObjectDidChange, isObservableObject, IValueDidChange, IValueWillChange, IObservableValue, isObservableValue as isBoxedObservable, IObservableArray, IArrayWillChange, IArrayWillSplice, IArraySplice, IArrayUpdate, IArrayDidChange, isObservableArray, IKeyValueMap, ObservableMap, IMapEntries, IMapEntry, IMapWillChange, IMapDidChange, isObservableMap, IObservableMapInitialValues, ObservableSet, isObservableSet, ISetDidChange, ISetWillChange, IObservableSetInitialValues, transaction, observable, IObservableFactory, CreateObservableOptions, computed, IComputedFactory, isObservable, isObservableProp, isComputed, isComputedProp, extendObservable, observe, intercept, autorun, IAutorunOptions, reaction, IReactionOptions, when, IWhenOptions, action, isAction, runInAction, IActionFactory, keys, values, entries, set, remove, has, get, apiOwnKeys as ownKeys, apiDefineProperty as defineProperty, configure, onBecomeObserved, onBecomeUnobserved, flow, isFlow, flowResult, FlowCancellationError, isFlowCancellationError, toJS, trace, IObserverTree, IDependencyTree, getDependencyTree, getObserverTree, resetGlobalState as _resetGlobalState, getGlobalState as _getGlobalState, getDebugName, getAtom, getAdministration as _getAdministration, allowStateChanges as _allowStateChanges, runInAction as _allowStateChangesInsideComputed, // This has become the default behavior in Mobx 6
|
|
2
2
|
Lambda, $mobx, isComputingDerivation as _isComputingDerivation, onReactionError, interceptReads as _interceptReads, IComputedValueOptions, IActionRunInfo, _startAction, _endAction, allowStateReadsStart as _allowStateReadsStart, allowStateReadsEnd as _allowStateReadsEnd, makeObservable, makeAutoObservable, autoAction as _autoAction, AnnotationsMap, AnnotationMapEntry, override } from "./internal";
|
|
@@ -3,6 +3,18 @@ var niceErrors = {
|
|
|
3
3
|
1: function _(annotationType, key) {
|
|
4
4
|
return "Cannot apply '" + annotationType + "' to '" + key.toString() + "': Field not found.";
|
|
5
5
|
},
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
2(prop) {
|
|
9
|
+
return `invalid decorator for '${prop.toString()}'`
|
|
10
|
+
},
|
|
11
|
+
3(prop) {
|
|
12
|
+
return `Cannot decorate '${prop.toString()}': action can only be used on properties with a function value.`
|
|
13
|
+
},
|
|
14
|
+
4(prop) {
|
|
15
|
+
return `Cannot decorate '${prop.toString()}': computed can only be used on getter properties.`
|
|
16
|
+
},
|
|
17
|
+
*/
|
|
6
18
|
5: "'keys()' can only be used on observable objects, arrays, sets and maps",
|
|
7
19
|
6: "'values()' can only be used on observable objects, arrays, sets and maps",
|
|
8
20
|
7: "'entries()' can only be used on observable objects, arrays and maps",
|
|
@@ -59,7 +71,9 @@ var niceErrors = {
|
|
|
59
71
|
36: "isolateGlobalState should be called before MobX is running any reactions",
|
|
60
72
|
37: function _(method) {
|
|
61
73
|
return "[mobx] `observableArray." + method + "()` mutates the array in-place, which is not allowed inside a derivation. Use `array.slice()." + method + "()` instead";
|
|
62
|
-
}
|
|
74
|
+
},
|
|
75
|
+
38: "'ownKeys()' can only be used on observable objects",
|
|
76
|
+
39: "'defineProperty()' can only be used on observable objects"
|
|
63
77
|
};
|
|
64
78
|
var errors = niceErrors ;
|
|
65
79
|
function die(error) {
|
|
@@ -496,7 +510,8 @@ function shallowComparer(a, b) {
|
|
|
496
510
|
}
|
|
497
511
|
|
|
498
512
|
function defaultComparer(a, b) {
|
|
499
|
-
return Object.is(a, b);
|
|
513
|
+
if (Object.is) return Object.is(a, b);
|
|
514
|
+
return a === b ? a !== 0 || 1 / a === 1 / b : a !== a && b !== b;
|
|
500
515
|
}
|
|
501
516
|
|
|
502
517
|
var comparer = {
|
|
@@ -694,6 +709,8 @@ function createFlowAnnotation(name, options) {
|
|
|
694
709
|
}
|
|
695
710
|
|
|
696
711
|
function make_$2(adm, key, descriptor, source) {
|
|
712
|
+
var _this$options_;
|
|
713
|
+
|
|
697
714
|
// own
|
|
698
715
|
if (source === adm.target_) {
|
|
699
716
|
return this.extend_(adm, key, descriptor, false) === null ? 0
|
|
@@ -702,8 +719,15 @@ function make_$2(adm, key, descriptor, source) {
|
|
|
702
719
|
/* Continue */
|
|
703
720
|
;
|
|
704
721
|
} // prototype
|
|
722
|
+
// bound - must annotate protos to support super.flow()
|
|
705
723
|
|
|
706
724
|
|
|
725
|
+
if (((_this$options_ = this.options_) == null ? void 0 : _this$options_.bound) && !isFlow(adm.target_[key])) {
|
|
726
|
+
if (this.extend_(adm, key, descriptor, false) === null) return 0
|
|
727
|
+
/* Cancel */
|
|
728
|
+
;
|
|
729
|
+
}
|
|
730
|
+
|
|
707
731
|
if (isFlow(descriptor.value)) {
|
|
708
732
|
// A prototype could have been annotated already by other constructor,
|
|
709
733
|
// rest of the proto chain must be annotated already
|
|
@@ -712,7 +736,7 @@ function make_$2(adm, key, descriptor, source) {
|
|
|
712
736
|
;
|
|
713
737
|
}
|
|
714
738
|
|
|
715
|
-
var flowDescriptor = createFlowDescriptor(adm, this, key, descriptor, false);
|
|
739
|
+
var flowDescriptor = createFlowDescriptor(adm, this, key, descriptor, false, false);
|
|
716
740
|
defineProperty(source, key, flowDescriptor);
|
|
717
741
|
return 2
|
|
718
742
|
/* Continue */
|
|
@@ -720,7 +744,9 @@ function make_$2(adm, key, descriptor, source) {
|
|
|
720
744
|
}
|
|
721
745
|
|
|
722
746
|
function extend_$2(adm, key, descriptor, proxyTrap) {
|
|
723
|
-
var
|
|
747
|
+
var _this$options_2;
|
|
748
|
+
|
|
749
|
+
var flowDescriptor = createFlowDescriptor(adm, this, key, descriptor, (_this$options_2 = this.options_) == null ? void 0 : _this$options_2.bound);
|
|
724
750
|
return adm.defineProperty_(key, flowDescriptor, proxyTrap);
|
|
725
751
|
}
|
|
726
752
|
|
|
@@ -733,15 +759,23 @@ function assertFlowDescriptor(adm, _ref, key, _ref2) {
|
|
|
733
759
|
}
|
|
734
760
|
}
|
|
735
761
|
|
|
736
|
-
function createFlowDescriptor(adm, annotation, key, descriptor, // provides ability to disable safeDescriptors for prototypes
|
|
762
|
+
function createFlowDescriptor(adm, annotation, key, descriptor, bound, // provides ability to disable safeDescriptors for prototypes
|
|
737
763
|
safeDescriptors) {
|
|
738
764
|
if (safeDescriptors === void 0) {
|
|
739
765
|
safeDescriptors = globalState.safeDescriptors;
|
|
740
766
|
}
|
|
741
767
|
|
|
742
768
|
assertFlowDescriptor(adm, annotation, key, descriptor);
|
|
769
|
+
var value = descriptor.value;
|
|
770
|
+
|
|
771
|
+
if (bound) {
|
|
772
|
+
var _adm$proxy_;
|
|
773
|
+
|
|
774
|
+
value = value.bind((_adm$proxy_ = adm.proxy_) != null ? _adm$proxy_ : adm.target_);
|
|
775
|
+
}
|
|
776
|
+
|
|
743
777
|
return {
|
|
744
|
-
value: flow(
|
|
778
|
+
value: flow(value),
|
|
745
779
|
// Non-configurable for classes
|
|
746
780
|
// prevents accidental field redefinition in subclass
|
|
747
781
|
configurable: safeDescriptors ? adm.isPlainObject_ : true,
|
|
@@ -831,7 +865,7 @@ function createAutoAnnotation(options) {
|
|
|
831
865
|
}
|
|
832
866
|
|
|
833
867
|
function make_$5(adm, key, descriptor, source) {
|
|
834
|
-
var _this$
|
|
868
|
+
var _this$options_3, _this$options_4;
|
|
835
869
|
|
|
836
870
|
// getter -> computed
|
|
837
871
|
if (descriptor.get) {
|
|
@@ -866,22 +900,25 @@ function make_$5(adm, key, descriptor, source) {
|
|
|
866
900
|
|
|
867
901
|
|
|
868
902
|
if (source !== adm.target_ && typeof descriptor.value === "function") {
|
|
869
|
-
var _this$
|
|
903
|
+
var _this$options_2;
|
|
870
904
|
|
|
871
905
|
if (isGenerator(descriptor.value)) {
|
|
872
|
-
|
|
906
|
+
var _this$options_;
|
|
907
|
+
|
|
908
|
+
var flowAnnotation = ((_this$options_ = this.options_) == null ? void 0 : _this$options_.autoBind) ? flow.bound : flow;
|
|
909
|
+
return flowAnnotation.make_(adm, key, descriptor, source);
|
|
873
910
|
}
|
|
874
911
|
|
|
875
|
-
var actionAnnotation = ((_this$
|
|
912
|
+
var actionAnnotation = ((_this$options_2 = this.options_) == null ? void 0 : _this$options_2.autoBind) ? autoAction.bound : autoAction;
|
|
876
913
|
return actionAnnotation.make_(adm, key, descriptor, source);
|
|
877
914
|
} // other -> observable
|
|
878
915
|
// Copy props from proto as well, see test:
|
|
879
916
|
// "decorate should work with Object.create"
|
|
880
917
|
|
|
881
918
|
|
|
882
|
-
var observableAnnotation = ((_this$
|
|
919
|
+
var observableAnnotation = ((_this$options_3 = this.options_) == null ? void 0 : _this$options_3.deep) === false ? observable.ref : observable; // if function respect autoBind option
|
|
883
920
|
|
|
884
|
-
if (typeof descriptor.value === "function" && ((_this$
|
|
921
|
+
if (typeof descriptor.value === "function" && ((_this$options_4 = this.options_) == null ? void 0 : _this$options_4.autoBind)) {
|
|
885
922
|
var _adm$proxy_;
|
|
886
923
|
|
|
887
924
|
descriptor.value = descriptor.value.bind((_adm$proxy_ = adm.proxy_) != null ? _adm$proxy_ : adm.target_);
|
|
@@ -891,7 +928,7 @@ function make_$5(adm, key, descriptor, source) {
|
|
|
891
928
|
}
|
|
892
929
|
|
|
893
930
|
function extend_$5(adm, key, descriptor, proxyTrap) {
|
|
894
|
-
var _this$
|
|
931
|
+
var _this$options_5, _this$options_6;
|
|
895
932
|
|
|
896
933
|
// getter -> computed
|
|
897
934
|
if (descriptor.get) {
|
|
@@ -909,16 +946,20 @@ function extend_$5(adm, key, descriptor, proxyTrap) {
|
|
|
909
946
|
// if function respect autoBind option
|
|
910
947
|
|
|
911
948
|
|
|
912
|
-
if (typeof descriptor.value === "function" && ((_this$
|
|
949
|
+
if (typeof descriptor.value === "function" && ((_this$options_5 = this.options_) == null ? void 0 : _this$options_5.autoBind)) {
|
|
913
950
|
var _adm$proxy_2;
|
|
914
951
|
|
|
915
952
|
descriptor.value = descriptor.value.bind((_adm$proxy_2 = adm.proxy_) != null ? _adm$proxy_2 : adm.target_);
|
|
916
953
|
}
|
|
917
954
|
|
|
918
|
-
var observableAnnotation = ((_this$
|
|
955
|
+
var observableAnnotation = ((_this$options_6 = this.options_) == null ? void 0 : _this$options_6.deep) === false ? observable.ref : observable;
|
|
919
956
|
return observableAnnotation.extend_(adm, key, descriptor, proxyTrap);
|
|
920
957
|
}
|
|
921
958
|
|
|
959
|
+
var OBSERVABLE = "observable";
|
|
960
|
+
var OBSERVABLE_REF = "observable.ref";
|
|
961
|
+
var OBSERVABLE_SHALLOW = "observable.shallow";
|
|
962
|
+
var OBSERVABLE_STRUCT = "observable.struct"; // Predefined bags of create observable options, to avoid allocating temporarily option objects
|
|
922
963
|
// in the majority of cases
|
|
923
964
|
|
|
924
965
|
var defaultCreateObservableOptions = {
|
|
@@ -931,14 +972,14 @@ Object.freeze(defaultCreateObservableOptions);
|
|
|
931
972
|
function asCreateObservableOptions(thing) {
|
|
932
973
|
return thing || defaultCreateObservableOptions;
|
|
933
974
|
}
|
|
934
|
-
var observableAnnotation = /*#__PURE__*/createObservableAnnotation(
|
|
935
|
-
var observableRefAnnotation = /*#__PURE__*/createObservableAnnotation(
|
|
975
|
+
var observableAnnotation = /*#__PURE__*/createObservableAnnotation(OBSERVABLE);
|
|
976
|
+
var observableRefAnnotation = /*#__PURE__*/createObservableAnnotation(OBSERVABLE_REF, {
|
|
936
977
|
enhancer: referenceEnhancer
|
|
937
978
|
});
|
|
938
|
-
var observableShallowAnnotation = /*#__PURE__*/createObservableAnnotation(
|
|
979
|
+
var observableShallowAnnotation = /*#__PURE__*/createObservableAnnotation(OBSERVABLE_SHALLOW, {
|
|
939
980
|
enhancer: shallowEnhancer
|
|
940
981
|
});
|
|
941
|
-
var observableStructAnnotation = /*#__PURE__*/createObservableAnnotation(
|
|
982
|
+
var observableStructAnnotation = /*#__PURE__*/createObservableAnnotation(OBSERVABLE_STRUCT, {
|
|
942
983
|
enhancer: refStructEnhancer
|
|
943
984
|
});
|
|
944
985
|
var observableDecoratorAnnotation = /*#__PURE__*/createDecoratorAnnotation(observableAnnotation);
|
|
@@ -1543,6 +1584,10 @@ var ComputedValue = /*#__PURE__*/function () {
|
|
|
1543
1584
|
if (!this.keepAlive_) {
|
|
1544
1585
|
clearObserving(this);
|
|
1545
1586
|
this.value_ = undefined; // don't hold on to computed value!
|
|
1587
|
+
|
|
1588
|
+
if ( this.isTracing_ !== TraceMode.NONE) {
|
|
1589
|
+
console.log("[mobx.trace] Computed value '" + this.name_ + "' was suspended and it will recompute on the next access.");
|
|
1590
|
+
}
|
|
1546
1591
|
}
|
|
1547
1592
|
};
|
|
1548
1593
|
|
|
@@ -1575,16 +1620,12 @@ var ComputedValue = /*#__PURE__*/function () {
|
|
|
1575
1620
|
|
|
1576
1621
|
_proto.warnAboutUntrackedRead_ = function warnAboutUntrackedRead_() {
|
|
1577
1622
|
|
|
1578
|
-
if (this.requiresReaction_ === true) {
|
|
1579
|
-
die("[mobx] Computed value " + this.name_ + " is read outside a reactive context");
|
|
1580
|
-
}
|
|
1581
|
-
|
|
1582
1623
|
if (this.isTracing_ !== TraceMode.NONE) {
|
|
1583
|
-
console.log("[mobx.trace] '" + this.name_ + "' is being read outside a reactive context. Doing a full recompute");
|
|
1624
|
+
console.log("[mobx.trace] Computed value '" + this.name_ + "' is being read outside a reactive context. Doing a full recompute.");
|
|
1584
1625
|
}
|
|
1585
1626
|
|
|
1586
|
-
if (globalState.computedRequiresReaction) {
|
|
1587
|
-
console.warn("[mobx] Computed value " + this.name_ + " is being read outside a reactive context. Doing a full recompute");
|
|
1627
|
+
if (globalState.computedRequiresReaction || this.requiresReaction_) {
|
|
1628
|
+
console.warn("[mobx] Computed value '" + this.name_ + "' is being read outside a reactive context. Doing a full recompute.");
|
|
1588
1629
|
}
|
|
1589
1630
|
};
|
|
1590
1631
|
|
|
@@ -1717,7 +1758,7 @@ function checkIfStateModificationsAreAllowed(atom) {
|
|
|
1717
1758
|
}
|
|
1718
1759
|
function checkIfStateReadsAreAllowed(observable) {
|
|
1719
1760
|
if ( !globalState.allowStateReads && globalState.observableRequiresReaction) {
|
|
1720
|
-
console.warn("[mobx] Observable " + observable.name_ + " being read outside a reactive context");
|
|
1761
|
+
console.warn("[mobx] Observable '" + observable.name_ + "' being read outside a reactive context.");
|
|
1721
1762
|
}
|
|
1722
1763
|
}
|
|
1723
1764
|
/**
|
|
@@ -1761,7 +1802,7 @@ function warnAboutDerivationWithoutDependencies(derivation) {
|
|
|
1761
1802
|
if (derivation.observing_.length !== 0) return;
|
|
1762
1803
|
|
|
1763
1804
|
if (globalState.reactionRequiresObservable || derivation.requiresObservable_) {
|
|
1764
|
-
console.warn("[mobx] Derivation " + derivation.name_ + " is created/updated without reading any observable value");
|
|
1805
|
+
console.warn("[mobx] Derivation '" + derivation.name_ + "' is created/updated without reading any observable value.");
|
|
1765
1806
|
}
|
|
1766
1807
|
}
|
|
1767
1808
|
/**
|
|
@@ -2781,6 +2822,9 @@ function isFlowCancellationError(error) {
|
|
|
2781
2822
|
return error instanceof FlowCancellationError;
|
|
2782
2823
|
}
|
|
2783
2824
|
var flowAnnotation = /*#__PURE__*/createFlowAnnotation("flow");
|
|
2825
|
+
var flowBoundAnnotation = /*#__PURE__*/createFlowAnnotation("flow.bound", {
|
|
2826
|
+
bound: true
|
|
2827
|
+
});
|
|
2784
2828
|
var flow = /*#__PURE__*/Object.assign(function flow(arg1, arg2) {
|
|
2785
2829
|
// @flow
|
|
2786
2830
|
if (isStringish(arg2)) {
|
|
@@ -2866,6 +2910,7 @@ var flow = /*#__PURE__*/Object.assign(function flow(arg1, arg2) {
|
|
|
2866
2910
|
res.isMobXFlow = true;
|
|
2867
2911
|
return res;
|
|
2868
2912
|
}, flowAnnotation);
|
|
2913
|
+
flow.bound = /*#__PURE__*/createDecoratorAnnotation(flowBoundAnnotation);
|
|
2869
2914
|
|
|
2870
2915
|
function cancelPromise(promise) {
|
|
2871
2916
|
if (isFunction(promise.cancel)) promise.cancel();
|
|
@@ -3090,6 +3135,20 @@ function get(obj, key) {
|
|
|
3090
3135
|
|
|
3091
3136
|
die(11);
|
|
3092
3137
|
}
|
|
3138
|
+
function apiDefineProperty(obj, key, descriptor) {
|
|
3139
|
+
if (isObservableObject(obj)) {
|
|
3140
|
+
return obj[$mobx].defineProperty_(key, descriptor);
|
|
3141
|
+
}
|
|
3142
|
+
|
|
3143
|
+
die(39);
|
|
3144
|
+
}
|
|
3145
|
+
function apiOwnKeys(obj) {
|
|
3146
|
+
if (isObservableObject(obj)) {
|
|
3147
|
+
return obj[$mobx].ownKeys_();
|
|
3148
|
+
}
|
|
3149
|
+
|
|
3150
|
+
die(38);
|
|
3151
|
+
}
|
|
3093
3152
|
|
|
3094
3153
|
function observe(thing, propOrCb, cbOrFire, fireImmediately) {
|
|
3095
3154
|
if (isFunction(cbOrFire)) return observeObservableProperty(thing, propOrCb, cbOrFire, fireImmediately);else return observeObservable(thing, propOrCb, cbOrFire);
|
|
@@ -3110,7 +3169,7 @@ function cache(map, key, value) {
|
|
|
3110
3169
|
|
|
3111
3170
|
function toJSHelper(source, __alreadySeen) {
|
|
3112
3171
|
if (source == null || typeof source !== "object" || source instanceof Date || !isObservable(source)) return source;
|
|
3113
|
-
if (isObservableValue(source)) return toJSHelper(source.get(), __alreadySeen);
|
|
3172
|
+
if (isObservableValue(source) || isComputedValue(source)) return toJSHelper(source.get(), __alreadySeen);
|
|
3114
3173
|
|
|
3115
3174
|
if (__alreadySeen.has(source)) {
|
|
3116
3175
|
return __alreadySeen.get(source);
|
|
@@ -3144,7 +3203,7 @@ function toJSHelper(source, __alreadySeen) {
|
|
|
3144
3203
|
// must be observable object
|
|
3145
3204
|
var _res3 = cache(__alreadySeen, source, {});
|
|
3146
3205
|
|
|
3147
|
-
source
|
|
3206
|
+
apiOwnKeys(source).forEach(function (key) {
|
|
3148
3207
|
if (objectPrototype.propertyIsEnumerable.call(source, key)) {
|
|
3149
3208
|
_res3[key] = toJSHelper(source[key], __alreadySeen);
|
|
3150
3209
|
}
|
|
@@ -3227,10 +3286,10 @@ function _when(predicate, effect, opts) {
|
|
|
3227
3286
|
var timeoutHandle;
|
|
3228
3287
|
|
|
3229
3288
|
if (typeof opts.timeout === "number") {
|
|
3289
|
+
var error = new Error("WHEN_TIMEOUT");
|
|
3230
3290
|
timeoutHandle = setTimeout(function () {
|
|
3231
3291
|
if (!disposer[$mobx].isDisposed_) {
|
|
3232
3292
|
disposer();
|
|
3233
|
-
var error = new Error("WHEN_TIMEOUT");
|
|
3234
3293
|
if (opts.onError) opts.onError(error);else throw error;
|
|
3235
3294
|
}
|
|
3236
3295
|
}, opts.timeout);
|
|
@@ -3317,7 +3376,7 @@ var objectProxyTraps = {
|
|
|
3317
3376
|
return (_getAdm$definePropert = getAdm(target).defineProperty_(name, descriptor)) != null ? _getAdm$definePropert : true;
|
|
3318
3377
|
},
|
|
3319
3378
|
ownKeys: function ownKeys(target) {
|
|
3320
|
-
if ( globalState.trackingDerivation) warnAboutProxyRequirement("iterate keys to detect added / removed properties. Use
|
|
3379
|
+
if ( globalState.trackingDerivation) warnAboutProxyRequirement("iterate keys to detect added / removed properties. Use 'keys' from 'mobx' instead.");
|
|
3321
3380
|
return getAdm(target).ownKeys_();
|
|
3322
3381
|
},
|
|
3323
3382
|
preventExtensions: function preventExtensions(target) {
|
|
@@ -5680,7 +5739,7 @@ function isAnnotation(thing) {
|
|
|
5680
5739
|
* - utils/ Utility stuff.
|
|
5681
5740
|
*
|
|
5682
5741
|
*/
|
|
5683
|
-
["Symbol", "Map", "Set"
|
|
5742
|
+
["Symbol", "Map", "Set"].forEach(function (m) {
|
|
5684
5743
|
var g = getGlobal();
|
|
5685
5744
|
|
|
5686
5745
|
if (typeof g[m] === "undefined") {
|
|
@@ -5699,5 +5758,5 @@ if (typeof __MOBX_DEVTOOLS_GLOBAL_HOOK__ === "object") {
|
|
|
5699
5758
|
});
|
|
5700
5759
|
}
|
|
5701
5760
|
|
|
5702
|
-
export { $mobx, FlowCancellationError, ObservableMap, ObservableSet, Reaction, allowStateChanges as _allowStateChanges, runInAction as _allowStateChangesInsideComputed, allowStateReadsEnd as _allowStateReadsEnd, allowStateReadsStart as _allowStateReadsStart, autoAction as _autoAction, _endAction, getAdministration as _getAdministration, getGlobalState as _getGlobalState, interceptReads as _interceptReads, isComputingDerivation as _isComputingDerivation, resetGlobalState as _resetGlobalState, _startAction, action, autorun, comparer, computed, configure, createAtom, entries, extendObservable, flow, flowResult, get, getAtom, getDebugName, getDependencyTree, getObserverTree, has, intercept, isAction, isObservableValue as isBoxedObservable, isComputed, isComputedProp, isFlow, isFlowCancellationError, isObservable, isObservableArray, isObservableMap, isObservableObject, isObservableProp, isObservableSet, keys, makeAutoObservable, makeObservable, observable, observe, onBecomeObserved, onBecomeUnobserved, onReactionError, override, reaction, remove, runInAction, set, spy, toJS, trace, transaction, untracked, values, when };
|
|
5761
|
+
export { $mobx, FlowCancellationError, ObservableMap, ObservableSet, Reaction, allowStateChanges as _allowStateChanges, runInAction as _allowStateChangesInsideComputed, allowStateReadsEnd as _allowStateReadsEnd, allowStateReadsStart as _allowStateReadsStart, autoAction as _autoAction, _endAction, getAdministration as _getAdministration, getGlobalState as _getGlobalState, interceptReads as _interceptReads, isComputingDerivation as _isComputingDerivation, resetGlobalState as _resetGlobalState, _startAction, action, autorun, comparer, computed, configure, createAtom, apiDefineProperty as defineProperty, entries, extendObservable, flow, flowResult, get, getAtom, getDebugName, getDependencyTree, getObserverTree, has, intercept, isAction, isObservableValue as isBoxedObservable, isComputed, isComputedProp, isFlow, isFlowCancellationError, isObservable, isObservableArray, isObservableMap, isObservableObject, isObservableProp, isObservableSet, keys, makeAutoObservable, makeObservable, observable, observe, onBecomeObserved, onBecomeUnobserved, onReactionError, override, apiOwnKeys as ownKeys, reaction, remove, runInAction, set, spy, toJS, trace, transaction, untracked, values, when };
|
|
5703
5762
|
//# sourceMappingURL=mobx.esm.development.js.map
|