mobx 5.15.3 → 5.15.4
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 +4 -0
- package/lib/index.js +7 -0
- package/lib/mobx.es6.js +142 -93
- package/lib/mobx.js +1 -1
- package/lib/mobx.module.js +142 -93
- package/lib/mobx.umd.js +142 -93
- package/package.json +3 -3
package/lib/mobx.umd.js
CHANGED
|
@@ -101,6 +101,8 @@
|
|
|
101
101
|
*/
|
|
102
102
|
var deprecatedMessages = [];
|
|
103
103
|
function deprecated(msg, thing) {
|
|
104
|
+
if (process.env.NODE_ENV === "production")
|
|
105
|
+
return false;
|
|
104
106
|
if (thing) {
|
|
105
107
|
return deprecated("'" + msg + "', use '" + thing + "' instead.");
|
|
106
108
|
}
|
|
@@ -161,7 +163,7 @@
|
|
|
161
163
|
return !descriptor || (descriptor.configurable !== false && descriptor.writable !== false);
|
|
162
164
|
}
|
|
163
165
|
function assertPropertyConfigurable(object, prop) {
|
|
164
|
-
if (!isPropertyConfigurable(object, prop))
|
|
166
|
+
if (process.env.NODE_ENV !== "production" && !isPropertyConfigurable(object, prop))
|
|
165
167
|
fail("Cannot make property '" + prop.toString() + "' observable, it is not configurable and writable in the target object");
|
|
166
168
|
}
|
|
167
169
|
function createInstanceofPredicate(name, clazz) {
|
|
@@ -356,7 +358,7 @@
|
|
|
356
358
|
propertyCreator(target, prop, descriptor, target, decoratorArguments);
|
|
357
359
|
return null;
|
|
358
360
|
}
|
|
359
|
-
if (!quacksLikeADecorator(arguments))
|
|
361
|
+
if (process.env.NODE_ENV !== "production" && !quacksLikeADecorator(arguments))
|
|
360
362
|
fail("This function is a decorator, but it wasn't invoked like a decorator");
|
|
361
363
|
if (!Object.prototype.hasOwnProperty.call(target, mobxPendingDecorators)) {
|
|
362
364
|
var inheritedDecorators = target[mobxPendingDecorators];
|
|
@@ -417,14 +419,15 @@
|
|
|
417
419
|
return observable.map(v, { name: name, deep: false });
|
|
418
420
|
if (isES6Set(v))
|
|
419
421
|
return observable.set(v, { name: name, deep: false });
|
|
420
|
-
return fail(
|
|
422
|
+
return fail(process.env.NODE_ENV !== "production" &&
|
|
423
|
+
"The shallow modifier / decorator can only used in combination with arrays, objects, maps and sets");
|
|
421
424
|
}
|
|
422
425
|
function referenceEnhancer(newValue) {
|
|
423
426
|
// never turn into an observable
|
|
424
427
|
return newValue;
|
|
425
428
|
}
|
|
426
429
|
function refStructEnhancer(v, oldValue, name) {
|
|
427
|
-
if (isObservable(v))
|
|
430
|
+
if (process.env.NODE_ENV !== "production" && isObservable(v))
|
|
428
431
|
throw "observable.struct should not be used with observable values";
|
|
429
432
|
if (deepEqual(v, oldValue))
|
|
430
433
|
return oldValue;
|
|
@@ -434,7 +437,7 @@
|
|
|
434
437
|
function createDecoratorForEnhancer(enhancer) {
|
|
435
438
|
invariant(enhancer);
|
|
436
439
|
var decorator = createPropDecorator(true, function (target, propertyName, descriptor, _decoratorTarget, decoratorArgs) {
|
|
437
|
-
{
|
|
440
|
+
if (process.env.NODE_ENV !== "production") {
|
|
438
441
|
invariant(!descriptor || !descriptor.get, "@observable cannot be used on getter (property \"" + stringifyKey(propertyName) + "\"), use @computed instead.");
|
|
439
442
|
}
|
|
440
443
|
var initialValue = descriptor
|
|
@@ -446,7 +449,7 @@
|
|
|
446
449
|
});
|
|
447
450
|
var res =
|
|
448
451
|
// Extra process checks, as this happens during module initialization
|
|
449
|
-
typeof process !== "undefined" && process.env &&
|
|
452
|
+
typeof process !== "undefined" && process.env && process.env.NODE_ENV !== "production"
|
|
450
453
|
? function observableDecorator() {
|
|
451
454
|
// This wrapper function is just to detect illegal decorator invocations, deprecate in a next version
|
|
452
455
|
// and simply return the created prop decorator
|
|
@@ -477,7 +480,7 @@
|
|
|
477
480
|
return defaultCreateObservableOptions;
|
|
478
481
|
if (typeof thing === "string")
|
|
479
482
|
return { name: thing, deep: true, proxy: true };
|
|
480
|
-
{
|
|
483
|
+
if (process.env.NODE_ENV !== "production") {
|
|
481
484
|
if (typeof thing !== "object")
|
|
482
485
|
return fail("expected options object");
|
|
483
486
|
Object.keys(thing).forEach(assertValidOption);
|
|
@@ -521,7 +524,8 @@
|
|
|
521
524
|
if (res !== v)
|
|
522
525
|
return res;
|
|
523
526
|
// otherwise, just box it
|
|
524
|
-
fail(
|
|
527
|
+
fail(process.env.NODE_ENV !== "production" &&
|
|
528
|
+
"The provided value could not be converted into an observable. If you want just create an observable reference to the object use 'observable.box(value)'");
|
|
525
529
|
}
|
|
526
530
|
var observableFactories = {
|
|
527
531
|
box: function (value, options) {
|
|
@@ -573,7 +577,7 @@
|
|
|
573
577
|
Object.keys(observableFactories).forEach(function (name) { return (observable[name] = observableFactories[name]); });
|
|
574
578
|
function incorrectlyUsedAsDecorator(methodName) {
|
|
575
579
|
fail(
|
|
576
|
-
//
|
|
580
|
+
// process.env.NODE_ENV !== "production" &&
|
|
577
581
|
"Expected one or two arguments to observable." + methodName + ". Did you accidentally try to use observable." + methodName + " as decorator?");
|
|
578
582
|
}
|
|
579
583
|
|
|
@@ -601,7 +605,7 @@
|
|
|
601
605
|
return computedDecorator.apply(null, arguments);
|
|
602
606
|
}
|
|
603
607
|
// computed(expr, options?)
|
|
604
|
-
{
|
|
608
|
+
if (process.env.NODE_ENV !== "production") {
|
|
605
609
|
invariant(typeof arg1 === "function", "First argument to `computed` should be an expression.");
|
|
606
610
|
invariant(arguments.length < 3, "Computed takes one or two arguments if used as function");
|
|
607
611
|
}
|
|
@@ -708,7 +712,7 @@
|
|
|
708
712
|
// function invariantShouldCompute(derivation: IDerivation) {
|
|
709
713
|
// const newDepState = (derivation as any).dependenciesState
|
|
710
714
|
// if (
|
|
711
|
-
//
|
|
715
|
+
// process.env.NODE_ENV === "production" &&
|
|
712
716
|
// (newDepState === IDerivationState.POSSIBLY_STALE ||
|
|
713
717
|
// newDepState === IDerivationState.NOT_TRACKING)
|
|
714
718
|
// )
|
|
@@ -721,16 +725,19 @@
|
|
|
721
725
|
var hasObservers = atom.observers.size > 0;
|
|
722
726
|
// Should never be possible to change an observed observable from inside computed, see #798
|
|
723
727
|
if (globalState.computationDepth > 0 && hasObservers)
|
|
724
|
-
fail(
|
|
728
|
+
fail(process.env.NODE_ENV !== "production" &&
|
|
729
|
+
"Computed values are not allowed to cause side effects by changing observables that are already being observed. Tried to modify: " + atom.name);
|
|
725
730
|
// Should not be possible to change observed state outside strict mode, except during initialization, see #563
|
|
726
731
|
if (!globalState.allowStateChanges && (hasObservers || globalState.enforceActions === "strict"))
|
|
727
|
-
fail(
|
|
732
|
+
fail(process.env.NODE_ENV !== "production" &&
|
|
733
|
+
(globalState.enforceActions
|
|
728
734
|
? "Since strict-mode is enabled, changing observed observable values outside actions is not allowed. Please wrap the code in an `action` if this change is intended. Tried to modify: "
|
|
729
735
|
: "Side effects like changing state are not allowed at this point. Are you trying to modify state from, for example, the render function of a React component? Tried to modify: ") +
|
|
730
736
|
atom.name);
|
|
731
737
|
}
|
|
732
738
|
function checkIfStateReadsAreAllowed(observable) {
|
|
733
|
-
if (
|
|
739
|
+
if (process.env.NODE_ENV !== "production" &&
|
|
740
|
+
!globalState.allowStateReads &&
|
|
734
741
|
globalState.observableRequiresReaction) {
|
|
735
742
|
console.warn("[mobx] Observable " + observable.name + " being read outside a reactive context");
|
|
736
743
|
}
|
|
@@ -769,6 +776,8 @@
|
|
|
769
776
|
return result;
|
|
770
777
|
}
|
|
771
778
|
function warnAboutDerivationWithoutDependencies(derivation) {
|
|
779
|
+
if (process.env.NODE_ENV === "production")
|
|
780
|
+
return;
|
|
772
781
|
if (derivation.observing.length !== 0)
|
|
773
782
|
return;
|
|
774
783
|
if (globalState.reactionRequiresObservable || derivation.requiresObservable) {
|
|
@@ -888,7 +897,7 @@
|
|
|
888
897
|
var functionNameDescriptor = Object.getOwnPropertyDescriptor(function () { }, "name");
|
|
889
898
|
var isFunctionNameConfigurable = functionNameDescriptor && functionNameDescriptor.configurable;
|
|
890
899
|
function createAction(actionName, fn, ref) {
|
|
891
|
-
{
|
|
900
|
+
if (process.env.NODE_ENV !== "production") {
|
|
892
901
|
invariant(typeof fn === "function", "`action` can only be invoked on functions");
|
|
893
902
|
if (typeof actionName !== "string" || !actionName)
|
|
894
903
|
fail("actions should have valid names, got: '" + actionName + "'");
|
|
@@ -897,7 +906,7 @@
|
|
|
897
906
|
return executeAction(actionName, fn, ref || this, arguments);
|
|
898
907
|
};
|
|
899
908
|
res.isMobxAction = true;
|
|
900
|
-
{
|
|
909
|
+
if (process.env.NODE_ENV !== "production") {
|
|
901
910
|
if (isFunctionNameConfigurable) {
|
|
902
911
|
Object.defineProperty(res, "name", { value: actionName });
|
|
903
912
|
}
|
|
@@ -920,7 +929,7 @@
|
|
|
920
929
|
function _startAction(actionName, scope, args) {
|
|
921
930
|
var notifySpy = isSpyEnabled() && !!actionName;
|
|
922
931
|
var startTime = 0;
|
|
923
|
-
if (notifySpy &&
|
|
932
|
+
if (notifySpy && process.env.NODE_ENV !== "production") {
|
|
924
933
|
startTime = Date.now();
|
|
925
934
|
var l = (args && args.length) || 0;
|
|
926
935
|
var flattendArgs = new Array(l);
|
|
@@ -962,7 +971,7 @@
|
|
|
962
971
|
allowStateReadsEnd(runInfo.prevAllowStateReads);
|
|
963
972
|
endBatch();
|
|
964
973
|
untrackedEnd(runInfo.prevDerivation);
|
|
965
|
-
if (runInfo.notifySpy &&
|
|
974
|
+
if (runInfo.notifySpy && process.env.NODE_ENV !== "production") {
|
|
966
975
|
spyReportEnd({ time: Date.now() - runInfo.startTime });
|
|
967
976
|
}
|
|
968
977
|
globalState.suppressReactionErrors = false;
|
|
@@ -1011,7 +1020,7 @@
|
|
|
1011
1020
|
_this.equals = equals;
|
|
1012
1021
|
_this.hasUnreportedChange = false;
|
|
1013
1022
|
_this.value = enhancer(value, undefined, name);
|
|
1014
|
-
if (notifySpy && isSpyEnabled() &&
|
|
1023
|
+
if (notifySpy && isSpyEnabled() && process.env.NODE_ENV !== "production") {
|
|
1015
1024
|
// only notify spy if this is a stand-alone observable
|
|
1016
1025
|
spyReport({ type: "create", name: _this.name, newValue: "" + _this.value });
|
|
1017
1026
|
}
|
|
@@ -1027,7 +1036,7 @@
|
|
|
1027
1036
|
newValue = this.prepareNewValue(newValue);
|
|
1028
1037
|
if (newValue !== globalState.UNCHANGED) {
|
|
1029
1038
|
var notifySpy = isSpyEnabled();
|
|
1030
|
-
if (notifySpy &&
|
|
1039
|
+
if (notifySpy && process.env.NODE_ENV !== "production") {
|
|
1031
1040
|
spyReportStart({
|
|
1032
1041
|
type: "update",
|
|
1033
1042
|
name: this.name,
|
|
@@ -1036,7 +1045,7 @@
|
|
|
1036
1045
|
});
|
|
1037
1046
|
}
|
|
1038
1047
|
this.setNewValue(newValue);
|
|
1039
|
-
if (notifySpy &&
|
|
1048
|
+
if (notifySpy && process.env.NODE_ENV !== "production")
|
|
1040
1049
|
spyReportEnd();
|
|
1041
1050
|
}
|
|
1042
1051
|
};
|
|
@@ -1222,10 +1231,11 @@
|
|
|
1222
1231
|
}
|
|
1223
1232
|
}
|
|
1224
1233
|
else
|
|
1225
|
-
invariant(false,
|
|
1234
|
+
invariant(false, process.env.NODE_ENV !== "production" &&
|
|
1235
|
+
"[ComputedValue '" + this.name + "'] It is not possible to assign a new value to a computed value.");
|
|
1226
1236
|
};
|
|
1227
1237
|
ComputedValue.prototype.trackAndCompute = function () {
|
|
1228
|
-
if (isSpyEnabled() &&
|
|
1238
|
+
if (isSpyEnabled() && process.env.NODE_ENV !== "production") {
|
|
1229
1239
|
spyReport({
|
|
1230
1240
|
object: this.scope,
|
|
1231
1241
|
type: "compute",
|
|
@@ -1296,6 +1306,8 @@
|
|
|
1296
1306
|
});
|
|
1297
1307
|
};
|
|
1298
1308
|
ComputedValue.prototype.warnAboutUntrackedRead = function () {
|
|
1309
|
+
if (process.env.NODE_ENV === "production")
|
|
1310
|
+
return;
|
|
1299
1311
|
if (this.requiresReaction === true) {
|
|
1300
1312
|
fail("[mobx] Computed value " + this.name + " is read outside a reactive context");
|
|
1301
1313
|
}
|
|
@@ -1754,7 +1766,7 @@
|
|
|
1754
1766
|
this.onInvalidate();
|
|
1755
1767
|
if (this._isTrackPending &&
|
|
1756
1768
|
isSpyEnabled() &&
|
|
1757
|
-
|
|
1769
|
+
process.env.NODE_ENV !== "production") {
|
|
1758
1770
|
// onInvalidate didn't trigger track right away..
|
|
1759
1771
|
spyReport({
|
|
1760
1772
|
name: this.name,
|
|
@@ -1777,7 +1789,7 @@
|
|
|
1777
1789
|
startBatch();
|
|
1778
1790
|
var notify = isSpyEnabled();
|
|
1779
1791
|
var startTime;
|
|
1780
|
-
if (notify &&
|
|
1792
|
+
if (notify && process.env.NODE_ENV !== "production") {
|
|
1781
1793
|
startTime = Date.now();
|
|
1782
1794
|
spyReportStart({
|
|
1783
1795
|
name: this.name,
|
|
@@ -1794,7 +1806,7 @@
|
|
|
1794
1806
|
}
|
|
1795
1807
|
if (isCaughtException(result))
|
|
1796
1808
|
this.reportExceptionInDerivation(result.cause);
|
|
1797
|
-
if (notify &&
|
|
1809
|
+
if (notify && process.env.NODE_ENV !== "production") {
|
|
1798
1810
|
spyReportEnd({
|
|
1799
1811
|
time: Date.now() - startTime
|
|
1800
1812
|
});
|
|
@@ -1899,9 +1911,11 @@
|
|
|
1899
1911
|
}
|
|
1900
1912
|
|
|
1901
1913
|
function isSpyEnabled() {
|
|
1902
|
-
return !!globalState.spyListeners.length;
|
|
1914
|
+
return process.env.NODE_ENV !== "production" && !!globalState.spyListeners.length;
|
|
1903
1915
|
}
|
|
1904
1916
|
function spyReport(event) {
|
|
1917
|
+
if (process.env.NODE_ENV === "production")
|
|
1918
|
+
return; // dead code elimination can do the rest
|
|
1905
1919
|
if (!globalState.spyListeners.length)
|
|
1906
1920
|
return;
|
|
1907
1921
|
var listeners = globalState.spyListeners;
|
|
@@ -1909,18 +1923,26 @@
|
|
|
1909
1923
|
listeners[i](event);
|
|
1910
1924
|
}
|
|
1911
1925
|
function spyReportStart(event) {
|
|
1926
|
+
if (process.env.NODE_ENV === "production")
|
|
1927
|
+
return;
|
|
1912
1928
|
var change = __assign(__assign({}, event), { spyReportStart: true });
|
|
1913
1929
|
spyReport(change);
|
|
1914
1930
|
}
|
|
1915
1931
|
var END_EVENT = { spyReportEnd: true };
|
|
1916
1932
|
function spyReportEnd(change) {
|
|
1933
|
+
if (process.env.NODE_ENV === "production")
|
|
1934
|
+
return;
|
|
1917
1935
|
if (change)
|
|
1918
1936
|
spyReport(__assign(__assign({}, change), { spyReportEnd: true }));
|
|
1919
1937
|
else
|
|
1920
1938
|
spyReport(END_EVENT);
|
|
1921
1939
|
}
|
|
1922
1940
|
function spy(listener) {
|
|
1923
|
-
{
|
|
1941
|
+
if (process.env.NODE_ENV === "production") {
|
|
1942
|
+
console.warn("[mobx.spy] Is a no-op in production builds");
|
|
1943
|
+
return function () { };
|
|
1944
|
+
}
|
|
1945
|
+
else {
|
|
1924
1946
|
globalState.spyListeners.push(listener);
|
|
1925
1947
|
return once(function () {
|
|
1926
1948
|
globalState.spyListeners = globalState.spyListeners.filter(function (l) { return l !== listener; });
|
|
@@ -1929,12 +1951,12 @@
|
|
|
1929
1951
|
}
|
|
1930
1952
|
|
|
1931
1953
|
function dontReassignFields() {
|
|
1932
|
-
fail("@action fields are not reassignable");
|
|
1954
|
+
fail(process.env.NODE_ENV !== "production" && "@action fields are not reassignable");
|
|
1933
1955
|
}
|
|
1934
1956
|
function namedActionDecorator(name) {
|
|
1935
1957
|
return function (target, prop, descriptor) {
|
|
1936
1958
|
if (descriptor) {
|
|
1937
|
-
if (descriptor.get !== undefined) {
|
|
1959
|
+
if (process.env.NODE_ENV !== "production" && descriptor.get !== undefined) {
|
|
1938
1960
|
return fail("@action cannot be used with getters");
|
|
1939
1961
|
}
|
|
1940
1962
|
// babel / typescript
|
|
@@ -2034,7 +2056,7 @@
|
|
|
2034
2056
|
function runInAction(arg1, arg2) {
|
|
2035
2057
|
var actionName = typeof arg1 === "string" ? arg1 : arg1.name || "<unnamed action>";
|
|
2036
2058
|
var fn = typeof arg1 === "function" ? arg1 : arg2;
|
|
2037
|
-
{
|
|
2059
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2038
2060
|
invariant(typeof fn === "function" && fn.length === 0, "`runInAction` expects a function without arguments");
|
|
2039
2061
|
if (typeof actionName !== "string" || !actionName)
|
|
2040
2062
|
fail("actions should have valid names, got: '" + actionName + "'");
|
|
@@ -2056,7 +2078,7 @@
|
|
|
2056
2078
|
*/
|
|
2057
2079
|
function autorun(view, opts) {
|
|
2058
2080
|
if (opts === void 0) { opts = EMPTY_OBJECT; }
|
|
2059
|
-
{
|
|
2081
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2060
2082
|
invariant(typeof view === "function", "Autorun expects a function as first argument");
|
|
2061
2083
|
invariant(isAction(view) === false, "Autorun does not accept actions since actions are untrackable");
|
|
2062
2084
|
}
|
|
@@ -2100,7 +2122,7 @@
|
|
|
2100
2122
|
}
|
|
2101
2123
|
function reaction(expression, effect, opts) {
|
|
2102
2124
|
if (opts === void 0) { opts = EMPTY_OBJECT; }
|
|
2103
|
-
{
|
|
2125
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2104
2126
|
invariant(typeof expression === "function", "First argument to reaction should be a function");
|
|
2105
2127
|
invariant(typeof opts === "object", "Third argument of reactions should be an object");
|
|
2106
2128
|
}
|
|
@@ -2172,7 +2194,7 @@
|
|
|
2172
2194
|
}
|
|
2173
2195
|
var orig = atom[hook];
|
|
2174
2196
|
if (typeof orig !== "function")
|
|
2175
|
-
return fail("Not an atom that can be (un)observed");
|
|
2197
|
+
return fail(process.env.NODE_ENV !== "production" && "Not an atom that can be (un)observed");
|
|
2176
2198
|
return function () {
|
|
2177
2199
|
var hookListeners = atom[listenersKey];
|
|
2178
2200
|
if (hookListeners) {
|
|
@@ -2236,14 +2258,16 @@
|
|
|
2236
2258
|
}
|
|
2237
2259
|
|
|
2238
2260
|
function decorate(thing, decorators) {
|
|
2239
|
-
|
|
2261
|
+
process.env.NODE_ENV !== "production" &&
|
|
2262
|
+
invariant(isPlainObject(decorators), "Decorators should be a key value map");
|
|
2240
2263
|
var target = typeof thing === "function" ? thing.prototype : thing;
|
|
2241
2264
|
var _loop_1 = function (prop) {
|
|
2242
2265
|
var propertyDecorators = decorators[prop];
|
|
2243
2266
|
if (!Array.isArray(propertyDecorators)) {
|
|
2244
2267
|
propertyDecorators = [propertyDecorators];
|
|
2245
2268
|
}
|
|
2246
|
-
|
|
2269
|
+
process.env.NODE_ENV !== "production" &&
|
|
2270
|
+
invariant(propertyDecorators.every(function (decorator) { return typeof decorator === "function"; }), "Decorate: expected a decorator function or array of decorator functions for '" + prop + "'");
|
|
2247
2271
|
var descriptor = Object.getOwnPropertyDescriptor(target, prop);
|
|
2248
2272
|
var newDescriptor = propertyDecorators.reduce(function (accDescriptor, decorator) { return decorator(target, prop, accDescriptor); }, descriptor);
|
|
2249
2273
|
if (newDescriptor)
|
|
@@ -2256,7 +2280,7 @@
|
|
|
2256
2280
|
}
|
|
2257
2281
|
|
|
2258
2282
|
function extendObservable(target, properties, decorators, options) {
|
|
2259
|
-
{
|
|
2283
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2260
2284
|
invariant(arguments.length >= 2 && arguments.length <= 4, "'extendObservable' expected 2-4 arguments");
|
|
2261
2285
|
invariant(typeof target === "object", "'extendObservable' expects an object as first argument");
|
|
2262
2286
|
invariant(!isObservableMap(target), "'extendObservable' should not be used on maps, use map.merge instead");
|
|
@@ -2274,7 +2298,7 @@
|
|
|
2274
2298
|
}
|
|
2275
2299
|
function extendObservableObjectWithProperties(target, properties, decorators, defaultDecorator) {
|
|
2276
2300
|
var e_1, _a, e_2, _b;
|
|
2277
|
-
{
|
|
2301
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2278
2302
|
invariant(!isObservable(properties), "Extending an object with another observable (object) is not supported. Please construct an explicit propertymap, using `toJS` if need. See issue #540");
|
|
2279
2303
|
if (decorators) {
|
|
2280
2304
|
var keys = getPlainObjectKeys(decorators);
|
|
@@ -2301,7 +2325,7 @@
|
|
|
2301
2325
|
for (var keys_2 = __values(keys), keys_2_1 = keys_2.next(); !keys_2_1.done; keys_2_1 = keys_2.next()) {
|
|
2302
2326
|
var key = keys_2_1.value;
|
|
2303
2327
|
var descriptor = Object.getOwnPropertyDescriptor(properties, key);
|
|
2304
|
-
{
|
|
2328
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2305
2329
|
if (!isPlainObject(properties))
|
|
2306
2330
|
fail("'extendObservabe' only accepts plain objects as second argument");
|
|
2307
2331
|
if (isComputed(descriptor.value))
|
|
@@ -2312,7 +2336,7 @@
|
|
|
2312
2336
|
: descriptor.get
|
|
2313
2337
|
? computedDecorator
|
|
2314
2338
|
: defaultDecorator;
|
|
2315
|
-
if (typeof decorator !== "function")
|
|
2339
|
+
if (process.env.NODE_ENV !== "production" && typeof decorator !== "function")
|
|
2316
2340
|
fail("Not a valid decorator for '" + stringifyKey(key) + "', got: " + decorator);
|
|
2317
2341
|
var resultDescriptor = decorator(target, key, descriptor, true);
|
|
2318
2342
|
if (resultDescriptor // otherwise, assume already applied, due to `applyToInstance`
|
|
@@ -2366,7 +2390,7 @@
|
|
|
2366
2390
|
}
|
|
2367
2391
|
function flow(generator) {
|
|
2368
2392
|
if (arguments.length !== 1)
|
|
2369
|
-
fail("Flow expects 1 argument and cannot be used as decorator");
|
|
2393
|
+
fail(!!process.env.NODE_ENV && "Flow expects 1 argument and cannot be used as decorator");
|
|
2370
2394
|
var name = generator.name || "<unnamed flow>";
|
|
2371
2395
|
// Implementation based on https://github.com/tj/co/blob/master/index.js
|
|
2372
2396
|
return function () {
|
|
@@ -2446,14 +2470,16 @@
|
|
|
2446
2470
|
}
|
|
2447
2471
|
else if (isObservableObject(thing)) {
|
|
2448
2472
|
if (typeof propOrHandler !== "string")
|
|
2449
|
-
return fail(
|
|
2473
|
+
return fail(process.env.NODE_ENV !== "production" &&
|
|
2474
|
+
"InterceptReads can only be used with a specific property, not with an object in general");
|
|
2450
2475
|
target = getAdministration(thing, propOrHandler);
|
|
2451
2476
|
}
|
|
2452
2477
|
else {
|
|
2453
|
-
return fail(
|
|
2478
|
+
return fail(process.env.NODE_ENV !== "production" &&
|
|
2479
|
+
"Expected observable map, object or array as first array");
|
|
2454
2480
|
}
|
|
2455
2481
|
if (target.dehancer !== undefined)
|
|
2456
|
-
return fail("An intercept reader was already established");
|
|
2482
|
+
return fail(process.env.NODE_ENV !== "production" && "An intercept reader was already established");
|
|
2457
2483
|
target.dehancer = typeof propOrHandler === "function" ? propOrHandler : handler;
|
|
2458
2484
|
return function () {
|
|
2459
2485
|
target.dehancer = undefined;
|
|
@@ -2488,12 +2514,14 @@
|
|
|
2488
2514
|
}
|
|
2489
2515
|
function isComputed(value) {
|
|
2490
2516
|
if (arguments.length > 1)
|
|
2491
|
-
return fail(
|
|
2517
|
+
return fail(process.env.NODE_ENV !== "production" &&
|
|
2518
|
+
"isComputed expects only 1 argument. Use isObservableProp to inspect the observability of a property");
|
|
2492
2519
|
return _isComputed(value);
|
|
2493
2520
|
}
|
|
2494
2521
|
function isComputedProp(value, propName) {
|
|
2495
2522
|
if (typeof propName !== "string")
|
|
2496
|
-
return fail(
|
|
2523
|
+
return fail(process.env.NODE_ENV !== "production" &&
|
|
2524
|
+
"isComputed expected a property name as second argument");
|
|
2497
2525
|
return _isComputed(value, propName);
|
|
2498
2526
|
}
|
|
2499
2527
|
|
|
@@ -2501,7 +2529,8 @@
|
|
|
2501
2529
|
if (value === null || value === undefined)
|
|
2502
2530
|
return false;
|
|
2503
2531
|
if (property !== undefined) {
|
|
2504
|
-
if (
|
|
2532
|
+
if (process.env.NODE_ENV !== "production" &&
|
|
2533
|
+
(isObservableMap(value) || isObservableArray(value)))
|
|
2505
2534
|
return fail("isObservable(object, propertyName) is not supported for arrays and maps. Use map.has or array.length instead.");
|
|
2506
2535
|
if (isObservableObject(value)) {
|
|
2507
2536
|
return value[$mobx].values.has(property);
|
|
@@ -2517,12 +2546,13 @@
|
|
|
2517
2546
|
}
|
|
2518
2547
|
function isObservable(value) {
|
|
2519
2548
|
if (arguments.length !== 1)
|
|
2520
|
-
fail(
|
|
2549
|
+
fail(process.env.NODE_ENV !== "production" &&
|
|
2550
|
+
"isObservable expects only 1 argument. Use isObservableProp to inspect the observability of a property");
|
|
2521
2551
|
return _isObservable(value);
|
|
2522
2552
|
}
|
|
2523
2553
|
function isObservableProp(value, propName) {
|
|
2524
2554
|
if (typeof propName !== "string")
|
|
2525
|
-
return fail("expected a property name as second argument");
|
|
2555
|
+
return fail(process.env.NODE_ENV !== "production" && "expected a property name as second argument");
|
|
2526
2556
|
return _isObservable(value, propName);
|
|
2527
2557
|
}
|
|
2528
2558
|
|
|
@@ -2539,7 +2569,8 @@
|
|
|
2539
2569
|
if (isObservableArray(obj)) {
|
|
2540
2570
|
return obj.map(function (_, index) { return index; });
|
|
2541
2571
|
}
|
|
2542
|
-
return fail(
|
|
2572
|
+
return fail(process.env.NODE_ENV !== "production" &&
|
|
2573
|
+
"'keys()' can only be used on observable objects, arrays, sets and maps");
|
|
2543
2574
|
}
|
|
2544
2575
|
function values(obj) {
|
|
2545
2576
|
if (isObservableObject(obj)) {
|
|
@@ -2554,7 +2585,8 @@
|
|
|
2554
2585
|
if (isObservableArray(obj)) {
|
|
2555
2586
|
return obj.slice();
|
|
2556
2587
|
}
|
|
2557
|
-
return fail(
|
|
2588
|
+
return fail(process.env.NODE_ENV !== "production" &&
|
|
2589
|
+
"'values()' can only be used on observable objects, arrays, sets and maps");
|
|
2558
2590
|
}
|
|
2559
2591
|
function entries(obj) {
|
|
2560
2592
|
if (isObservableObject(obj)) {
|
|
@@ -2569,7 +2601,8 @@
|
|
|
2569
2601
|
if (isObservableArray(obj)) {
|
|
2570
2602
|
return obj.map(function (key, index) { return [index, key]; });
|
|
2571
2603
|
}
|
|
2572
|
-
return fail(
|
|
2604
|
+
return fail(process.env.NODE_ENV !== "production" &&
|
|
2605
|
+
"'entries()' can only be used on observable objects, arrays and maps");
|
|
2573
2606
|
}
|
|
2574
2607
|
function set(obj, key, value) {
|
|
2575
2608
|
if (arguments.length === 2 && !isObservableSet(obj)) {
|
|
@@ -2611,7 +2644,8 @@
|
|
|
2611
2644
|
endBatch();
|
|
2612
2645
|
}
|
|
2613
2646
|
else {
|
|
2614
|
-
return fail(
|
|
2647
|
+
return fail(process.env.NODE_ENV !== "production" &&
|
|
2648
|
+
"'set()' can only be used on observable objects, arrays and maps");
|
|
2615
2649
|
}
|
|
2616
2650
|
}
|
|
2617
2651
|
function remove(obj, key) {
|
|
@@ -2631,7 +2665,8 @@
|
|
|
2631
2665
|
obj.splice(key, 1);
|
|
2632
2666
|
}
|
|
2633
2667
|
else {
|
|
2634
|
-
return fail(
|
|
2668
|
+
return fail(process.env.NODE_ENV !== "production" &&
|
|
2669
|
+
"'remove()' can only be used on observable objects, arrays and maps");
|
|
2635
2670
|
}
|
|
2636
2671
|
}
|
|
2637
2672
|
function has(obj, key) {
|
|
@@ -2650,7 +2685,8 @@
|
|
|
2650
2685
|
return key >= 0 && key < obj.length;
|
|
2651
2686
|
}
|
|
2652
2687
|
else {
|
|
2653
|
-
return fail(
|
|
2688
|
+
return fail(process.env.NODE_ENV !== "production" &&
|
|
2689
|
+
"'has()' can only be used on observable objects, arrays and maps");
|
|
2654
2690
|
}
|
|
2655
2691
|
}
|
|
2656
2692
|
function get(obj, key) {
|
|
@@ -2666,7 +2702,8 @@
|
|
|
2666
2702
|
return obj[key];
|
|
2667
2703
|
}
|
|
2668
2704
|
else {
|
|
2669
|
-
return fail(
|
|
2705
|
+
return fail(process.env.NODE_ENV !== "production" &&
|
|
2706
|
+
"'get()' can only be used on observable objects, arrays and maps");
|
|
2670
2707
|
}
|
|
2671
2708
|
}
|
|
2672
2709
|
|
|
@@ -2786,7 +2823,8 @@
|
|
|
2786
2823
|
enterBreakPoint = args.pop();
|
|
2787
2824
|
var derivation = getAtomFromArgs(args);
|
|
2788
2825
|
if (!derivation) {
|
|
2789
|
-
return fail(
|
|
2826
|
+
return fail(process.env.NODE_ENV !== "production" &&
|
|
2827
|
+
"'trace(break?)' can only be used inside a tracked computed value or a Reaction. Consider passing in the computed value or reaction explicitly");
|
|
2790
2828
|
}
|
|
2791
2829
|
if (derivation.isTracing === TraceMode.NONE) {
|
|
2792
2830
|
console.log("[mobx.trace] '" + derivation.name + "' tracing enabled");
|
|
@@ -2854,7 +2892,7 @@
|
|
|
2854
2892
|
return disposer;
|
|
2855
2893
|
}
|
|
2856
2894
|
function whenPromise(predicate, opts) {
|
|
2857
|
-
if (opts && opts.onError)
|
|
2895
|
+
if (process.env.NODE_ENV !== "production" && opts && opts.onError)
|
|
2858
2896
|
return fail("the options 'onError' and 'promise' cannot be combined");
|
|
2859
2897
|
var cancel;
|
|
2860
2898
|
var res = new Promise(function (resolve, reject) {
|
|
@@ -3138,7 +3176,7 @@
|
|
|
3138
3176
|
newItems = change.added;
|
|
3139
3177
|
}
|
|
3140
3178
|
newItems = newItems.length === 0 ? newItems : newItems.map(function (v) { return _this.enhancer(v, undefined); });
|
|
3141
|
-
{
|
|
3179
|
+
if (process.env.NODE_ENV !== "production") {
|
|
3142
3180
|
var lengthDelta = newItems.length - deleteCount;
|
|
3143
3181
|
this.updateArrayLength(length, lengthDelta); // checks if internal array wasn't modified
|
|
3144
3182
|
}
|
|
@@ -3174,12 +3212,12 @@
|
|
|
3174
3212
|
: null;
|
|
3175
3213
|
// The reason why this is on right hand side here (and not above), is this way the uglifier will drop it, but it won't
|
|
3176
3214
|
// cause any runtime overhead in development mode without NODE_ENV set, unless spying is enabled
|
|
3177
|
-
if (notifySpy &&
|
|
3215
|
+
if (notifySpy && process.env.NODE_ENV !== "production")
|
|
3178
3216
|
spyReportStart(__assign(__assign({}, change), { name: this.atom.name }));
|
|
3179
3217
|
this.atom.reportChanged();
|
|
3180
3218
|
if (notify)
|
|
3181
3219
|
notifyListeners(this, change);
|
|
3182
|
-
if (notifySpy &&
|
|
3220
|
+
if (notifySpy && process.env.NODE_ENV !== "production")
|
|
3183
3221
|
spyReportEnd();
|
|
3184
3222
|
};
|
|
3185
3223
|
ObservableArrayAdministration.prototype.notifyArraySplice = function (index, added, removed) {
|
|
@@ -3196,13 +3234,13 @@
|
|
|
3196
3234
|
addedCount: added.length
|
|
3197
3235
|
}
|
|
3198
3236
|
: null;
|
|
3199
|
-
if (notifySpy &&
|
|
3237
|
+
if (notifySpy && process.env.NODE_ENV !== "production")
|
|
3200
3238
|
spyReportStart(__assign(__assign({}, change), { name: this.atom.name }));
|
|
3201
3239
|
this.atom.reportChanged();
|
|
3202
3240
|
// conform: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/observe
|
|
3203
3241
|
if (notify)
|
|
3204
3242
|
notifyListeners(this, change);
|
|
3205
|
-
if (notifySpy &&
|
|
3243
|
+
if (notifySpy && process.env.NODE_ENV !== "production")
|
|
3206
3244
|
spyReportEnd();
|
|
3207
3245
|
};
|
|
3208
3246
|
return ObservableArrayAdministration;
|
|
@@ -3288,7 +3326,7 @@
|
|
|
3288
3326
|
// reverse by default mutates in place before returning the result
|
|
3289
3327
|
// which makes it both a 'derivation' and a 'mutation'.
|
|
3290
3328
|
// so we deviate from the default and just make it an dervitation
|
|
3291
|
-
{
|
|
3329
|
+
if (process.env.NODE_ENV !== "production") {
|
|
3292
3330
|
console.warn("[mobx] `observableArray.reverse()` will not update the array in place. Use `observableArray.slice().reverse()` to suppress this warning and perform the operation on a copy, or `observableArray.replace(observableArray.slice().reverse())` to reverse & update in place");
|
|
3293
3331
|
}
|
|
3294
3332
|
var clone = this.slice();
|
|
@@ -3297,7 +3335,7 @@
|
|
|
3297
3335
|
sort: function (compareFn) {
|
|
3298
3336
|
// sort by default mutates in place before returning the result
|
|
3299
3337
|
// which goes against all good practices. Let's not change the array in place!
|
|
3300
|
-
{
|
|
3338
|
+
if (process.env.NODE_ENV !== "production") {
|
|
3301
3339
|
console.warn("[mobx] `observableArray.sort()` will not update the array in place. Use `observableArray.slice().sort()` to suppress this warning and perform the operation on a copy, or `observableArray.replace(observableArray.slice().sort())` to sort & update in place");
|
|
3302
3340
|
}
|
|
3303
3341
|
var clone = this.slice();
|
|
@@ -3465,7 +3503,7 @@
|
|
|
3465
3503
|
name: key
|
|
3466
3504
|
}
|
|
3467
3505
|
: null;
|
|
3468
|
-
if (notifySpy &&
|
|
3506
|
+
if (notifySpy && process.env.NODE_ENV !== "production")
|
|
3469
3507
|
spyReportStart(__assign(__assign({}, change), { name: this.name, key: key }));
|
|
3470
3508
|
transaction(function () {
|
|
3471
3509
|
_this._keysAtom.reportChanged();
|
|
@@ -3476,7 +3514,7 @@
|
|
|
3476
3514
|
});
|
|
3477
3515
|
if (notify)
|
|
3478
3516
|
notifyListeners(this, change);
|
|
3479
|
-
if (notifySpy &&
|
|
3517
|
+
if (notifySpy && process.env.NODE_ENV !== "production")
|
|
3480
3518
|
spyReportEnd();
|
|
3481
3519
|
return true;
|
|
3482
3520
|
}
|
|
@@ -3503,12 +3541,12 @@
|
|
|
3503
3541
|
newValue: newValue
|
|
3504
3542
|
}
|
|
3505
3543
|
: null;
|
|
3506
|
-
if (notifySpy &&
|
|
3544
|
+
if (notifySpy && process.env.NODE_ENV !== "production")
|
|
3507
3545
|
spyReportStart(__assign(__assign({}, change), { name: this.name, key: key }));
|
|
3508
3546
|
observable.setNewValue(newValue);
|
|
3509
3547
|
if (notify)
|
|
3510
3548
|
notifyListeners(this, change);
|
|
3511
|
-
if (notifySpy &&
|
|
3549
|
+
if (notifySpy && process.env.NODE_ENV !== "production")
|
|
3512
3550
|
spyReportEnd();
|
|
3513
3551
|
}
|
|
3514
3552
|
};
|
|
@@ -3532,11 +3570,11 @@
|
|
|
3532
3570
|
newValue: newValue
|
|
3533
3571
|
}
|
|
3534
3572
|
: null;
|
|
3535
|
-
if (notifySpy &&
|
|
3573
|
+
if (notifySpy && process.env.NODE_ENV !== "production")
|
|
3536
3574
|
spyReportStart(__assign(__assign({}, change), { name: this.name, key: key }));
|
|
3537
3575
|
if (notify)
|
|
3538
3576
|
notifyListeners(this, change);
|
|
3539
|
-
if (notifySpy &&
|
|
3577
|
+
if (notifySpy && process.env.NODE_ENV !== "production")
|
|
3540
3578
|
spyReportEnd();
|
|
3541
3579
|
};
|
|
3542
3580
|
ObservableMap.prototype.get = function (key) {
|
|
@@ -3719,7 +3757,8 @@
|
|
|
3719
3757
|
* for callback details
|
|
3720
3758
|
*/
|
|
3721
3759
|
ObservableMap.prototype.observe = function (listener, fireImmediately) {
|
|
3722
|
-
|
|
3760
|
+
process.env.NODE_ENV !== "production" &&
|
|
3761
|
+
invariant(fireImmediately !== true, "`observe` doesn't support fireImmediately=true in combination with maps.");
|
|
3723
3762
|
return registerListener(this, listener);
|
|
3724
3763
|
};
|
|
3725
3764
|
ObservableMap.prototype.intercept = function (handler) {
|
|
@@ -3828,11 +3867,11 @@
|
|
|
3828
3867
|
newValue: value
|
|
3829
3868
|
}
|
|
3830
3869
|
: null;
|
|
3831
|
-
if (notifySpy &&
|
|
3870
|
+
if (notifySpy && process.env.NODE_ENV !== "production")
|
|
3832
3871
|
spyReportStart(change);
|
|
3833
3872
|
if (notify)
|
|
3834
3873
|
notifyListeners(this, change);
|
|
3835
|
-
if (notifySpy &&
|
|
3874
|
+
if (notifySpy && process.env.NODE_ENV !== "production")
|
|
3836
3875
|
spyReportEnd();
|
|
3837
3876
|
}
|
|
3838
3877
|
return this;
|
|
@@ -3858,7 +3897,7 @@
|
|
|
3858
3897
|
oldValue: value
|
|
3859
3898
|
}
|
|
3860
3899
|
: null;
|
|
3861
|
-
if (notifySpy &&
|
|
3900
|
+
if (notifySpy && process.env.NODE_ENV !== "production")
|
|
3862
3901
|
spyReportStart(__assign(__assign({}, change), { name: this.name }));
|
|
3863
3902
|
transaction(function () {
|
|
3864
3903
|
_this._atom.reportChanged();
|
|
@@ -3866,7 +3905,7 @@
|
|
|
3866
3905
|
});
|
|
3867
3906
|
if (notify)
|
|
3868
3907
|
notifyListeners(this, change);
|
|
3869
|
-
if (notifySpy &&
|
|
3908
|
+
if (notifySpy && process.env.NODE_ENV !== "production")
|
|
3870
3909
|
spyReportEnd();
|
|
3871
3910
|
return true;
|
|
3872
3911
|
}
|
|
@@ -3928,7 +3967,8 @@
|
|
|
3928
3967
|
};
|
|
3929
3968
|
ObservableSet.prototype.observe = function (listener, fireImmediately) {
|
|
3930
3969
|
// TODO 'fireImmediately' can be true?
|
|
3931
|
-
|
|
3970
|
+
process.env.NODE_ENV !== "production" &&
|
|
3971
|
+
invariant(fireImmediately !== true, "`observe` doesn't support fireImmediately=true in combination with sets.");
|
|
3932
3972
|
return registerListener(this, listener);
|
|
3933
3973
|
};
|
|
3934
3974
|
ObservableSet.prototype.intercept = function (handler) {
|
|
@@ -3992,12 +4032,12 @@
|
|
|
3992
4032
|
newValue: newValue
|
|
3993
4033
|
}
|
|
3994
4034
|
: null;
|
|
3995
|
-
if (notifySpy &&
|
|
4035
|
+
if (notifySpy && process.env.NODE_ENV !== "production")
|
|
3996
4036
|
spyReportStart(__assign(__assign({}, change), { name: this.name, key: key }));
|
|
3997
4037
|
observable.setNewValue(newValue);
|
|
3998
4038
|
if (notify)
|
|
3999
4039
|
notifyListeners(this, change);
|
|
4000
|
-
if (notifySpy &&
|
|
4040
|
+
if (notifySpy && process.env.NODE_ENV !== "production")
|
|
4001
4041
|
spyReportEnd();
|
|
4002
4042
|
}
|
|
4003
4043
|
};
|
|
@@ -4082,11 +4122,11 @@
|
|
|
4082
4122
|
name: key
|
|
4083
4123
|
}
|
|
4084
4124
|
: null;
|
|
4085
|
-
if (notifySpy &&
|
|
4125
|
+
if (notifySpy && process.env.NODE_ENV !== "production")
|
|
4086
4126
|
spyReportStart(__assign(__assign({}, change), { name: this.name, key: key }));
|
|
4087
4127
|
if (notify)
|
|
4088
4128
|
notifyListeners(this, change);
|
|
4089
|
-
if (notifySpy &&
|
|
4129
|
+
if (notifySpy && process.env.NODE_ENV !== "production")
|
|
4090
4130
|
spyReportEnd();
|
|
4091
4131
|
}
|
|
4092
4132
|
finally {
|
|
@@ -4121,7 +4161,8 @@
|
|
|
4121
4161
|
* for callback details
|
|
4122
4162
|
*/
|
|
4123
4163
|
ObservableObjectAdministration.prototype.observe = function (callback, fireImmediately) {
|
|
4124
|
-
|
|
4164
|
+
process.env.NODE_ENV !== "production" &&
|
|
4165
|
+
invariant(fireImmediately !== true, "`observe` doesn't support the fire immediately property for observable objects.");
|
|
4125
4166
|
return registerListener(this, callback);
|
|
4126
4167
|
};
|
|
4127
4168
|
ObservableObjectAdministration.prototype.intercept = function (handler) {
|
|
@@ -4138,11 +4179,11 @@
|
|
|
4138
4179
|
newValue: newValue
|
|
4139
4180
|
}
|
|
4140
4181
|
: null;
|
|
4141
|
-
if (notifySpy &&
|
|
4182
|
+
if (notifySpy && process.env.NODE_ENV !== "production")
|
|
4142
4183
|
spyReportStart(__assign(__assign({}, change), { name: this.name, key: key }));
|
|
4143
4184
|
if (notify)
|
|
4144
4185
|
notifyListeners(this, change);
|
|
4145
|
-
if (notifySpy &&
|
|
4186
|
+
if (notifySpy && process.env.NODE_ENV !== "production")
|
|
4146
4187
|
spyReportEnd();
|
|
4147
4188
|
if (this.pendingKeys) {
|
|
4148
4189
|
var entry = this.pendingKeys.get(key);
|
|
@@ -4179,7 +4220,8 @@
|
|
|
4179
4220
|
if (defaultEnhancer === void 0) { defaultEnhancer = deepEnhancer; }
|
|
4180
4221
|
if (Object.prototype.hasOwnProperty.call(target, $mobx))
|
|
4181
4222
|
return target[$mobx];
|
|
4182
|
-
|
|
4223
|
+
process.env.NODE_ENV !== "production" &&
|
|
4224
|
+
invariant(Object.isExtensible(target), "Cannot make the designated object observable; it is not extensible");
|
|
4183
4225
|
if (!isPlainObject(target))
|
|
4184
4226
|
name = (target.constructor.name || "ObservableObject") + "@" + getNextId();
|
|
4185
4227
|
if (!name)
|
|
@@ -4240,7 +4282,8 @@
|
|
|
4240
4282
|
if (typeof thing === "object" && thing !== null) {
|
|
4241
4283
|
if (isObservableArray(thing)) {
|
|
4242
4284
|
if (property !== undefined)
|
|
4243
|
-
fail(
|
|
4285
|
+
fail(process.env.NODE_ENV !== "production" &&
|
|
4286
|
+
"It is not possible to get index atoms from arrays");
|
|
4244
4287
|
return thing[$mobx].atom;
|
|
4245
4288
|
}
|
|
4246
4289
|
if (isObservableSet(thing)) {
|
|
@@ -4252,7 +4295,8 @@
|
|
|
4252
4295
|
return anyThing._keysAtom;
|
|
4253
4296
|
var observable = anyThing._data.get(property) || anyThing._hasMap.get(property);
|
|
4254
4297
|
if (!observable)
|
|
4255
|
-
fail(
|
|
4298
|
+
fail(process.env.NODE_ENV !== "production" &&
|
|
4299
|
+
"the entry '" + property + "' does not exist in the observable map '" + getDebugName(thing) + "'");
|
|
4256
4300
|
return observable;
|
|
4257
4301
|
}
|
|
4258
4302
|
// Initializers run lazily when transpiling to babel, so make sure they are run...
|
|
@@ -4261,10 +4305,11 @@
|
|
|
4261
4305
|
thing[property]; // See #1072
|
|
4262
4306
|
if (isObservableObject(thing)) {
|
|
4263
4307
|
if (!property)
|
|
4264
|
-
return fail("please specify a property");
|
|
4308
|
+
return fail(process.env.NODE_ENV !== "production" && "please specify a property");
|
|
4265
4309
|
var observable = thing[$mobx].values.get(property);
|
|
4266
4310
|
if (!observable)
|
|
4267
|
-
fail(
|
|
4311
|
+
fail(process.env.NODE_ENV !== "production" &&
|
|
4312
|
+
"no observable property '" + property + "' found on the observable object '" + getDebugName(thing) + "'");
|
|
4268
4313
|
return observable;
|
|
4269
4314
|
}
|
|
4270
4315
|
if (isAtom(thing) || isComputedValue(thing) || isReaction(thing)) {
|
|
@@ -4277,7 +4322,7 @@
|
|
|
4277
4322
|
return thing[$mobx];
|
|
4278
4323
|
}
|
|
4279
4324
|
}
|
|
4280
|
-
return fail("Cannot obtain atom from " + thing);
|
|
4325
|
+
return fail(process.env.NODE_ENV !== "production" && "Cannot obtain atom from " + thing);
|
|
4281
4326
|
}
|
|
4282
4327
|
function getAdministration(thing, property) {
|
|
4283
4328
|
if (!thing)
|
|
@@ -4292,7 +4337,7 @@
|
|
|
4292
4337
|
initializeInstance(thing);
|
|
4293
4338
|
if (thing[$mobx])
|
|
4294
4339
|
return thing[$mobx];
|
|
4295
|
-
fail("Cannot obtain administration from " + thing);
|
|
4340
|
+
fail(process.env.NODE_ENV !== "production" && "Cannot obtain administration from " + thing);
|
|
4296
4341
|
}
|
|
4297
4342
|
function getDebugName(thing, property) {
|
|
4298
4343
|
var named;
|
|
@@ -4486,6 +4531,10 @@
|
|
|
4486
4531
|
throw new Error("[mobx] MobX 5+ requires Proxy and Symbol objects. If your environment doesn't support Symbol or Proxy objects, please downgrade to MobX 4. For React Native Android, consider upgrading JSCore.");
|
|
4487
4532
|
}
|
|
4488
4533
|
try {
|
|
4534
|
+
// define process.env if needed
|
|
4535
|
+
// if this is not a production build in the first place
|
|
4536
|
+
// (in which case the expression below would be substituted with 'production')
|
|
4537
|
+
process.env.NODE_ENV;
|
|
4489
4538
|
}
|
|
4490
4539
|
catch (e) {
|
|
4491
4540
|
var g = getGlobal();
|
|
@@ -4496,8 +4545,8 @@
|
|
|
4496
4545
|
(function () {
|
|
4497
4546
|
function testCodeMinification() { }
|
|
4498
4547
|
if (testCodeMinification.name !== "testCodeMinification" &&
|
|
4499
|
-
|
|
4500
|
-
process.env.IGNORE_MOBX_MINIFY_WARNING !== "true") {
|
|
4548
|
+
process.env.NODE_ENV !== "production" &&
|
|
4549
|
+
typeof process !== 'undefined' && process.env.IGNORE_MOBX_MINIFY_WARNING !== "true") {
|
|
4501
4550
|
// trick so it doesn't get replaced
|
|
4502
4551
|
var varName = ["process", "env", "NODE_ENV"].join(".");
|
|
4503
4552
|
console.warn("[mobx] you are running a minified build, but '" + varName + "' was not set to 'production' in your bundler. This results in an unnecessarily large and slow bundle");
|