mobx 5.7.0 → 5.9.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 +46 -0
- package/LICENSE +0 -0
- package/README.md +27 -17
- package/lib/api/action.d.ts +1 -1
- package/lib/api/actiondecorator.d.ts +12 -1
- package/lib/api/become-observed.d.ts +3 -3
- package/lib/api/computed.d.ts +1 -1
- package/lib/api/flow.d.ts +8 -13
- package/lib/api/intercept-read.d.ts +2 -1
- package/lib/api/intercept.d.ts +2 -1
- package/lib/api/object-api.d.ts +6 -1
- package/lib/api/observable.d.ts +3 -1
- package/lib/api/observe.d.ts +2 -1
- package/lib/core/action.d.ts +1 -1
- package/lib/core/atom.d.ts +4 -1
- package/lib/core/computedvalue.d.ts +3 -1
- package/lib/core/globalstate.d.ts +1 -0
- package/lib/core/observable.d.ts +3 -1
- package/lib/internal.d.ts +1 -0
- package/lib/mobx.d.ts +1 -1
- package/lib/mobx.es6.js +358 -60
- package/lib/mobx.js +392 -57
- package/lib/mobx.js.flow +2 -2
- package/lib/mobx.min.js +1 -1
- package/lib/mobx.min.js.map +1 -1
- package/lib/mobx.module.js +391 -58
- package/lib/mobx.umd.js +392 -57
- package/lib/mobx.umd.min.js +1 -1
- package/lib/mobx.umd.min.js.map +1 -1
- package/lib/types/observablemap.d.ts +1 -1
- package/lib/types/observableset.d.ts +49 -0
- package/lib/types/observablevalue.d.ts +5 -3
- package/lib/utils/utils.d.ts +1 -0
- package/package.json +9 -3
package/lib/mobx.module.js
CHANGED
|
@@ -185,6 +185,9 @@ function isArrayLike$$1(x) {
|
|
|
185
185
|
function isES6Map$$1(thing) {
|
|
186
186
|
return thing instanceof Map;
|
|
187
187
|
}
|
|
188
|
+
function isES6Set$$1(thing) {
|
|
189
|
+
return thing instanceof Set;
|
|
190
|
+
}
|
|
188
191
|
function getMapLikeKeys$$1(map) {
|
|
189
192
|
if (isPlainObject$$1(map))
|
|
190
193
|
return Object.keys(map);
|
|
@@ -217,11 +220,15 @@ var Atom$$1 = /** @class */ (function () {
|
|
|
217
220
|
this.lastAccessedBy = 0;
|
|
218
221
|
this.lowestObserverState = IDerivationState.NOT_TRACKING;
|
|
219
222
|
}
|
|
220
|
-
Atom$$1.prototype.onBecomeUnobserved = function () {
|
|
221
|
-
// noop
|
|
222
|
-
};
|
|
223
223
|
Atom$$1.prototype.onBecomeObserved = function () {
|
|
224
|
-
|
|
224
|
+
if (this.onBecomeObservedListeners) {
|
|
225
|
+
this.onBecomeObservedListeners.forEach(function (listener) { return listener(); });
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
Atom$$1.prototype.onBecomeUnobserved = function () {
|
|
229
|
+
if (this.onBecomeUnobservedListeners) {
|
|
230
|
+
this.onBecomeUnobservedListeners.forEach(function (listener) { return listener(); });
|
|
231
|
+
}
|
|
225
232
|
};
|
|
226
233
|
/**
|
|
227
234
|
* Invoke this method to notify mobx that your atom has been used somehow.
|
|
@@ -248,8 +255,13 @@ function createAtom$$1(name, onBecomeObservedHandler, onBecomeUnobservedHandler)
|
|
|
248
255
|
if (onBecomeObservedHandler === void 0) { onBecomeObservedHandler = noop$$1; }
|
|
249
256
|
if (onBecomeUnobservedHandler === void 0) { onBecomeUnobservedHandler = noop$$1; }
|
|
250
257
|
var atom = new Atom$$1(name);
|
|
251
|
-
|
|
252
|
-
|
|
258
|
+
// default `noop` listener will not initialize the hook Set
|
|
259
|
+
if (onBecomeObservedHandler !== noop$$1) {
|
|
260
|
+
onBecomeObserved$$1(atom, onBecomeObservedHandler);
|
|
261
|
+
}
|
|
262
|
+
if (onBecomeUnobservedHandler !== noop$$1) {
|
|
263
|
+
onBecomeUnobserved$$1(atom, onBecomeUnobservedHandler);
|
|
264
|
+
}
|
|
253
265
|
return atom;
|
|
254
266
|
}
|
|
255
267
|
|
|
@@ -354,12 +366,14 @@ function deepEnhancer$$1(v, _, name) {
|
|
|
354
366
|
return observable$$1.object(v, undefined, { name: name });
|
|
355
367
|
if (isES6Map$$1(v))
|
|
356
368
|
return observable$$1.map(v, { name: name });
|
|
369
|
+
if (isES6Set$$1(v))
|
|
370
|
+
return observable$$1.set(v, { name: name });
|
|
357
371
|
return v;
|
|
358
372
|
}
|
|
359
373
|
function shallowEnhancer$$1(v, _, name) {
|
|
360
374
|
if (v === undefined || v === null)
|
|
361
375
|
return v;
|
|
362
|
-
if (isObservableObject$$1(v) || isObservableArray$$1(v) || isObservableMap$$1(v))
|
|
376
|
+
if (isObservableObject$$1(v) || isObservableArray$$1(v) || isObservableMap$$1(v) || isObservableSet$$1(v))
|
|
363
377
|
return v;
|
|
364
378
|
if (Array.isArray(v))
|
|
365
379
|
return observable$$1.array(v, { name: name, deep: false });
|
|
@@ -367,8 +381,10 @@ function shallowEnhancer$$1(v, _, name) {
|
|
|
367
381
|
return observable$$1.object(v, undefined, { name: name, deep: false });
|
|
368
382
|
if (isES6Map$$1(v))
|
|
369
383
|
return observable$$1.map(v, { name: name, deep: false });
|
|
384
|
+
if (isES6Set$$1(v))
|
|
385
|
+
return observable$$1.set(v, { name: name, deep: false });
|
|
370
386
|
return fail$$1(process.env.NODE_ENV !== "production" &&
|
|
371
|
-
"The shallow modifier / decorator can only used in combination with arrays, objects and
|
|
387
|
+
"The shallow modifier / decorator can only used in combination with arrays, objects, maps and sets");
|
|
372
388
|
}
|
|
373
389
|
function referenceEnhancer$$1(newValue) {
|
|
374
390
|
// never turn into an observable
|
|
@@ -420,7 +436,7 @@ var defaultCreateObservableOptions$$1 = {
|
|
|
420
436
|
};
|
|
421
437
|
Object.freeze(defaultCreateObservableOptions$$1);
|
|
422
438
|
function assertValidOption(key) {
|
|
423
|
-
if (!/^(deep|name|defaultDecorator|proxy)$/.test(key))
|
|
439
|
+
if (!/^(deep|name|equals|defaultDecorator|proxy)$/.test(key))
|
|
424
440
|
fail$$1("invalid option for (extend)observable: " + key);
|
|
425
441
|
}
|
|
426
442
|
function asCreateObservableOptions$$1(thing) {
|
|
@@ -465,7 +481,9 @@ function createObservable(v, arg2, arg3) {
|
|
|
465
481
|
? observable$$1.array(v, arg2)
|
|
466
482
|
: isES6Map$$1(v)
|
|
467
483
|
? observable$$1.map(v, arg2)
|
|
468
|
-
: v
|
|
484
|
+
: isES6Set$$1(v)
|
|
485
|
+
? observable$$1.set(v, arg2)
|
|
486
|
+
: v;
|
|
469
487
|
// this value could be converted to a new observable data structure, return it
|
|
470
488
|
if (res !== v)
|
|
471
489
|
return res;
|
|
@@ -478,7 +496,7 @@ var observableFactories = {
|
|
|
478
496
|
if (arguments.length > 2)
|
|
479
497
|
incorrectlyUsedAsDecorator("box");
|
|
480
498
|
var o = asCreateObservableOptions$$1(options);
|
|
481
|
-
return new ObservableValue$$1(value, getEnhancerFromOptions(o), o.name);
|
|
499
|
+
return new ObservableValue$$1(value, getEnhancerFromOptions(o), o.name, true, o.equals);
|
|
482
500
|
},
|
|
483
501
|
array: function (initialValues, options) {
|
|
484
502
|
if (arguments.length > 2)
|
|
@@ -492,6 +510,12 @@ var observableFactories = {
|
|
|
492
510
|
var o = asCreateObservableOptions$$1(options);
|
|
493
511
|
return new ObservableMap$$1(initialValues, getEnhancerFromOptions(o), o.name);
|
|
494
512
|
},
|
|
513
|
+
set: function (initialValues, options) {
|
|
514
|
+
if (arguments.length > 2)
|
|
515
|
+
incorrectlyUsedAsDecorator("set");
|
|
516
|
+
var o = asCreateObservableOptions$$1(options);
|
|
517
|
+
return new ObservableSet$$1(initialValues, getEnhancerFromOptions(o), o.name);
|
|
518
|
+
},
|
|
495
519
|
object: function (props, decorators, options) {
|
|
496
520
|
if (typeof arguments[1] === "string")
|
|
497
521
|
incorrectlyUsedAsDecorator("object");
|
|
@@ -557,25 +581,35 @@ var computed$$1 = function computed$$1(arg1, arg2, arg3) {
|
|
|
557
581
|
};
|
|
558
582
|
computed$$1.struct = computedStructDecorator;
|
|
559
583
|
|
|
560
|
-
function createAction$$1(actionName, fn) {
|
|
584
|
+
function createAction$$1(actionName, fn, ref) {
|
|
561
585
|
if (process.env.NODE_ENV !== "production") {
|
|
562
586
|
invariant$$1(typeof fn === "function", "`action` can only be invoked on functions");
|
|
563
587
|
if (typeof actionName !== "string" || !actionName)
|
|
564
588
|
fail$$1("actions should have valid names, got: '" + actionName + "'");
|
|
565
589
|
}
|
|
566
590
|
var res = function () {
|
|
567
|
-
return executeAction$$1(actionName, fn, this, arguments);
|
|
591
|
+
return executeAction$$1(actionName, fn, ref || this, arguments);
|
|
568
592
|
};
|
|
569
593
|
res.isMobxAction = true;
|
|
570
594
|
return res;
|
|
571
595
|
}
|
|
572
596
|
function executeAction$$1(actionName, fn, scope, args) {
|
|
573
597
|
var runInfo = startAction(actionName, fn, scope, args);
|
|
598
|
+
var shouldSupressReactionError = true;
|
|
574
599
|
try {
|
|
575
|
-
|
|
600
|
+
var res = fn.apply(scope, args);
|
|
601
|
+
shouldSupressReactionError = false;
|
|
602
|
+
return res;
|
|
576
603
|
}
|
|
577
604
|
finally {
|
|
578
|
-
|
|
605
|
+
if (shouldSupressReactionError) {
|
|
606
|
+
globalState$$1.suppressReactionErrors = shouldSupressReactionError;
|
|
607
|
+
endAction(runInfo);
|
|
608
|
+
globalState$$1.suppressReactionErrors = false;
|
|
609
|
+
}
|
|
610
|
+
else {
|
|
611
|
+
endAction(runInfo);
|
|
612
|
+
}
|
|
579
613
|
}
|
|
580
614
|
}
|
|
581
615
|
function startAction(actionName, fn, scope, args) {
|
|
@@ -646,11 +680,14 @@ function allowStateChangesInsideComputed$$1(func) {
|
|
|
646
680
|
|
|
647
681
|
var ObservableValue$$1 = /** @class */ (function (_super) {
|
|
648
682
|
__extends(ObservableValue$$1, _super);
|
|
649
|
-
function ObservableValue$$1(value, enhancer, name, notifySpy) {
|
|
683
|
+
function ObservableValue$$1(value, enhancer, name, notifySpy, equals) {
|
|
650
684
|
if (name === void 0) { name = "ObservableValue@" + getNextId$$1(); }
|
|
651
685
|
if (notifySpy === void 0) { notifySpy = true; }
|
|
686
|
+
if (equals === void 0) { equals = comparer$$1.default; }
|
|
652
687
|
var _this = _super.call(this, name) || this;
|
|
653
688
|
_this.enhancer = enhancer;
|
|
689
|
+
_this.name = name;
|
|
690
|
+
_this.equals = equals;
|
|
654
691
|
_this.hasUnreportedChange = false;
|
|
655
692
|
_this.value = enhancer(value, undefined, name);
|
|
656
693
|
if (notifySpy && isSpyEnabled$$1() && process.env.NODE_ENV !== "production") {
|
|
@@ -696,7 +733,7 @@ var ObservableValue$$1 = /** @class */ (function (_super) {
|
|
|
696
733
|
}
|
|
697
734
|
// apply modifier
|
|
698
735
|
newValue = this.enhancer(newValue, this.value, this.name);
|
|
699
|
-
return this.value
|
|
736
|
+
return this.equals(this.value, newValue) ? globalState$$1.UNCHANGED : newValue;
|
|
700
737
|
};
|
|
701
738
|
ObservableValue$$1.prototype.setNewValue = function (newValue) {
|
|
702
739
|
var oldValue = this.value;
|
|
@@ -811,8 +848,16 @@ var ComputedValue$$1 = /** @class */ (function () {
|
|
|
811
848
|
ComputedValue$$1.prototype.onBecomeStale = function () {
|
|
812
849
|
propagateMaybeChanged$$1(this);
|
|
813
850
|
};
|
|
814
|
-
ComputedValue$$1.prototype.
|
|
815
|
-
|
|
851
|
+
ComputedValue$$1.prototype.onBecomeObserved = function () {
|
|
852
|
+
if (this.onBecomeObservedListeners) {
|
|
853
|
+
this.onBecomeObservedListeners.forEach(function (listener) { return listener(); });
|
|
854
|
+
}
|
|
855
|
+
};
|
|
856
|
+
ComputedValue$$1.prototype.onBecomeUnobserved = function () {
|
|
857
|
+
if (this.onBecomeUnobservedListeners) {
|
|
858
|
+
this.onBecomeUnobservedListeners.forEach(function (listener) { return listener(); });
|
|
859
|
+
}
|
|
860
|
+
};
|
|
816
861
|
/**
|
|
817
862
|
* Returns the current value of this computed value.
|
|
818
863
|
* Will evaluate its computation first if needed.
|
|
@@ -1291,6 +1336,11 @@ var MobXGlobals$$1 = /** @class */ (function () {
|
|
|
1291
1336
|
* the stack when an exception occurs while debugging.
|
|
1292
1337
|
*/
|
|
1293
1338
|
this.disableErrorBoundaries = false;
|
|
1339
|
+
/*
|
|
1340
|
+
* If true, we are already handling an exception in an action. Any errors in reactions should be supressed, as
|
|
1341
|
+
* they are not the cause, see: https://github.com/mobxjs/mobx/issues/1836
|
|
1342
|
+
*/
|
|
1343
|
+
this.suppressReactionErrors = false;
|
|
1294
1344
|
}
|
|
1295
1345
|
return MobXGlobals$$1;
|
|
1296
1346
|
}());
|
|
@@ -1535,7 +1585,7 @@ function logTraceInfo(derivation, observable$$1) {
|
|
|
1535
1585
|
var lines = [];
|
|
1536
1586
|
printDepTree(getDependencyTree$$1(derivation), lines, 1);
|
|
1537
1587
|
// prettier-ignore
|
|
1538
|
-
new Function("debugger;\n/*\nTracing '" + derivation.name + "'\n\nYou are entering this break point because derivation '" + derivation.name + "' is being traced and '" + observable$$1.name + "' is now forcing it to update.\nJust follow the stacktrace you should now see in the devtools to see precisely what piece of your code is causing this update\nThe stackframe you are looking for is at least ~6-8 stack-frames up.\n\n" + (derivation instanceof ComputedValue$$1 ? derivation.derivation.toString() : "") + "\n\nThe dependencies for this derivation are:\n\n" + lines.join("\n") + "\n*/\n ")();
|
|
1588
|
+
new Function("debugger;\n/*\nTracing '" + derivation.name + "'\n\nYou are entering this break point because derivation '" + derivation.name + "' is being traced and '" + observable$$1.name + "' is now forcing it to update.\nJust follow the stacktrace you should now see in the devtools to see precisely what piece of your code is causing this update\nThe stackframe you are looking for is at least ~6-8 stack-frames up.\n\n" + (derivation instanceof ComputedValue$$1 ? derivation.derivation.toString().replace(/[*]\//g, "/") : "") + "\n\nThe dependencies for this derivation are:\n\n" + lines.join("\n") + "\n*/\n ")();
|
|
1539
1589
|
}
|
|
1540
1590
|
}
|
|
1541
1591
|
function printDepTree(tree, lines, depth) {
|
|
@@ -1609,6 +1659,9 @@ var Reaction$$1 = /** @class */ (function () {
|
|
|
1609
1659
|
}
|
|
1610
1660
|
};
|
|
1611
1661
|
Reaction$$1.prototype.track = function (fn) {
|
|
1662
|
+
if (this.isDisposed) {
|
|
1663
|
+
fail$$1("Reaction already disposed");
|
|
1664
|
+
}
|
|
1612
1665
|
startBatch$$1();
|
|
1613
1666
|
var notify = isSpyEnabled$$1();
|
|
1614
1667
|
var startTime;
|
|
@@ -1644,9 +1697,14 @@ var Reaction$$1 = /** @class */ (function () {
|
|
|
1644
1697
|
}
|
|
1645
1698
|
if (globalState$$1.disableErrorBoundaries)
|
|
1646
1699
|
throw error;
|
|
1647
|
-
var message = "[mobx] Encountered an uncaught exception that was thrown by a reaction or observer component, in: '" + this;
|
|
1648
|
-
|
|
1649
|
-
|
|
1700
|
+
var message = "[mobx] Encountered an uncaught exception that was thrown by a reaction or observer component, in: '" + this + "'";
|
|
1701
|
+
if (globalState$$1.suppressReactionErrors) {
|
|
1702
|
+
console.warn("[mobx] (error in reaction '" + this.name + "' suppressed, fix error of causing action below)"); // prettier-ignore
|
|
1703
|
+
}
|
|
1704
|
+
else {
|
|
1705
|
+
console.error(message, error);
|
|
1706
|
+
/** If debugging brought you here, please, read the above message :-). Tnx! */
|
|
1707
|
+
}
|
|
1650
1708
|
if (isSpyEnabled$$1()) {
|
|
1651
1709
|
spyReport$$1({
|
|
1652
1710
|
type: "error",
|
|
@@ -1864,7 +1922,7 @@ var action$$1 = function action$$1(arg1, arg2, arg3, arg4) {
|
|
|
1864
1922
|
// @action fn() {}
|
|
1865
1923
|
if (arg4 === true) {
|
|
1866
1924
|
// apply to instance immediately
|
|
1867
|
-
addHiddenProp$$1(arg1, arg2, createAction$$1(arg1.name || arg2, arg3.value));
|
|
1925
|
+
addHiddenProp$$1(arg1, arg2, createAction$$1(arg1.name || arg2, arg3.value, this));
|
|
1868
1926
|
}
|
|
1869
1927
|
else {
|
|
1870
1928
|
return namedActionDecorator$$1(arg2).apply(null, arguments);
|
|
@@ -2003,20 +2061,32 @@ function onBecomeUnobserved$$1(thing, arg2, arg3) {
|
|
|
2003
2061
|
function interceptHook(hook, thing, arg2, arg3) {
|
|
2004
2062
|
var atom = typeof arg2 === "string" ? getAtom$$1(thing, arg2) : getAtom$$1(thing);
|
|
2005
2063
|
var cb = typeof arg2 === "string" ? arg3 : arg2;
|
|
2064
|
+
var listenersKey = hook + "Listeners";
|
|
2065
|
+
if (atom[listenersKey]) {
|
|
2066
|
+
atom[listenersKey].add(cb);
|
|
2067
|
+
}
|
|
2068
|
+
else {
|
|
2069
|
+
atom[listenersKey] = new Set([cb]);
|
|
2070
|
+
}
|
|
2006
2071
|
var orig = atom[hook];
|
|
2007
2072
|
if (typeof orig !== "function")
|
|
2008
2073
|
return fail$$1(process.env.NODE_ENV !== "production" && "Not an atom that can be (un)observed");
|
|
2009
|
-
atom[hook] = function () {
|
|
2010
|
-
orig.call(this);
|
|
2011
|
-
cb.call(this);
|
|
2012
|
-
};
|
|
2013
2074
|
return function () {
|
|
2014
|
-
atom[
|
|
2075
|
+
var hookListeners = atom[listenersKey];
|
|
2076
|
+
if (hookListeners) {
|
|
2077
|
+
hookListeners.delete(cb);
|
|
2078
|
+
if (hookListeners.size === 0) {
|
|
2079
|
+
delete atom[listenersKey];
|
|
2080
|
+
}
|
|
2081
|
+
}
|
|
2015
2082
|
};
|
|
2016
2083
|
}
|
|
2017
2084
|
|
|
2018
2085
|
function configure$$1(options) {
|
|
2019
2086
|
var enforceActions = options.enforceActions, computedRequiresReaction = options.computedRequiresReaction, disableErrorBoundaries = options.disableErrorBoundaries, reactionScheduler = options.reactionScheduler;
|
|
2087
|
+
if (options.isolateGlobalState === true) {
|
|
2088
|
+
isolateGlobalState$$1();
|
|
2089
|
+
}
|
|
2020
2090
|
if (enforceActions !== undefined) {
|
|
2021
2091
|
if (typeof enforceActions === "boolean" || enforceActions === "strict")
|
|
2022
2092
|
deprecated$$1("Deprecated value for 'enforceActions', use 'false' => '\"never\"', 'true' => '\"observed\"', '\"strict\"' => \"'always'\" instead");
|
|
@@ -2043,9 +2113,6 @@ function configure$$1(options) {
|
|
|
2043
2113
|
if (computedRequiresReaction !== undefined) {
|
|
2044
2114
|
globalState$$1.computedRequiresReaction = !!computedRequiresReaction;
|
|
2045
2115
|
}
|
|
2046
|
-
if (options.isolateGlobalState === true) {
|
|
2047
|
-
isolateGlobalState$$1();
|
|
2048
|
-
}
|
|
2049
2116
|
if (disableErrorBoundaries !== undefined) {
|
|
2050
2117
|
if (disableErrorBoundaries === true)
|
|
2051
2118
|
console.warn("WARNING: Debug feature only. MobX will NOT recover from errors when `disableErrorBoundaries` is enabled.");
|
|
@@ -2167,7 +2234,7 @@ function flow$$1(generator) {
|
|
|
2167
2234
|
var gen = action$$1(name + " - runid: " + runId + " - init", generator).apply(ctx, args);
|
|
2168
2235
|
var rejector;
|
|
2169
2236
|
var pendingPromise = undefined;
|
|
2170
|
-
var
|
|
2237
|
+
var promise = new Promise(function (resolve, reject) {
|
|
2171
2238
|
var stepId = 0;
|
|
2172
2239
|
rejector = reject;
|
|
2173
2240
|
function onFulfilled(res) {
|
|
@@ -2205,14 +2272,14 @@ function flow$$1(generator) {
|
|
|
2205
2272
|
}
|
|
2206
2273
|
onFulfilled(undefined); // kick off the process
|
|
2207
2274
|
});
|
|
2208
|
-
|
|
2275
|
+
promise.cancel = action$$1(name + " - runid: " + runId + " - cancel", function () {
|
|
2209
2276
|
try {
|
|
2210
2277
|
if (pendingPromise)
|
|
2211
2278
|
cancelPromise(pendingPromise);
|
|
2212
2279
|
// Finally block can return (or yield) stuff..
|
|
2213
|
-
var
|
|
2280
|
+
var res = gen.return();
|
|
2214
2281
|
// eat anything that promise would do, it's cancelled!
|
|
2215
|
-
var yieldedPromise = Promise.resolve(
|
|
2282
|
+
var yieldedPromise = Promise.resolve(res.value);
|
|
2216
2283
|
yieldedPromise.then(noop$$1, noop$$1);
|
|
2217
2284
|
cancelPromise(yieldedPromise); // maybe it can be cancelled :)
|
|
2218
2285
|
// reject our original promise
|
|
@@ -2222,7 +2289,7 @@ function flow$$1(generator) {
|
|
|
2222
2289
|
rejector(e); // there could be a throwing finally block
|
|
2223
2290
|
}
|
|
2224
2291
|
});
|
|
2225
|
-
return
|
|
2292
|
+
return promise;
|
|
2226
2293
|
};
|
|
2227
2294
|
}
|
|
2228
2295
|
function cancelPromise(promise) {
|
|
@@ -2330,11 +2397,14 @@ function keys$$1(obj) {
|
|
|
2330
2397
|
if (isObservableMap$$1(obj)) {
|
|
2331
2398
|
return Array.from(obj.keys());
|
|
2332
2399
|
}
|
|
2400
|
+
if (isObservableSet$$1(obj)) {
|
|
2401
|
+
return Array.from(obj.keys());
|
|
2402
|
+
}
|
|
2333
2403
|
if (isObservableArray$$1(obj)) {
|
|
2334
2404
|
return obj.map(function (_, index) { return index; });
|
|
2335
2405
|
}
|
|
2336
2406
|
return fail$$1(process.env.NODE_ENV !== "production" &&
|
|
2337
|
-
"'keys()' can only be used on observable objects, arrays and maps");
|
|
2407
|
+
"'keys()' can only be used on observable objects, arrays, sets and maps");
|
|
2338
2408
|
}
|
|
2339
2409
|
function values$$1(obj) {
|
|
2340
2410
|
if (isObservableObject$$1(obj)) {
|
|
@@ -2343,11 +2413,14 @@ function values$$1(obj) {
|
|
|
2343
2413
|
if (isObservableMap$$1(obj)) {
|
|
2344
2414
|
return keys$$1(obj).map(function (key) { return obj.get(key); });
|
|
2345
2415
|
}
|
|
2416
|
+
if (isObservableSet$$1(obj)) {
|
|
2417
|
+
return Array.from(obj.values());
|
|
2418
|
+
}
|
|
2346
2419
|
if (isObservableArray$$1(obj)) {
|
|
2347
2420
|
return obj.slice();
|
|
2348
2421
|
}
|
|
2349
2422
|
return fail$$1(process.env.NODE_ENV !== "production" &&
|
|
2350
|
-
"'values()' can only be used on observable objects, arrays and maps");
|
|
2423
|
+
"'values()' can only be used on observable objects, arrays, sets and maps");
|
|
2351
2424
|
}
|
|
2352
2425
|
function entries$$1(obj) {
|
|
2353
2426
|
if (isObservableObject$$1(obj)) {
|
|
@@ -2356,6 +2429,9 @@ function entries$$1(obj) {
|
|
|
2356
2429
|
if (isObservableMap$$1(obj)) {
|
|
2357
2430
|
return keys$$1(obj).map(function (key) { return [key, obj.get(key)]; });
|
|
2358
2431
|
}
|
|
2432
|
+
if (isObservableSet$$1(obj)) {
|
|
2433
|
+
return Array.from(obj.entries());
|
|
2434
|
+
}
|
|
2359
2435
|
if (isObservableArray$$1(obj)) {
|
|
2360
2436
|
return obj.map(function (key, index) { return [index, key]; });
|
|
2361
2437
|
}
|
|
@@ -2411,6 +2487,9 @@ function remove$$1(obj, key) {
|
|
|
2411
2487
|
else if (isObservableMap$$1(obj)) {
|
|
2412
2488
|
obj.delete(key);
|
|
2413
2489
|
}
|
|
2490
|
+
else if (isObservableSet$$1(obj)) {
|
|
2491
|
+
obj.delete(key);
|
|
2492
|
+
}
|
|
2414
2493
|
else if (isObservableArray$$1(obj)) {
|
|
2415
2494
|
if (typeof key !== "number")
|
|
2416
2495
|
key = parseInt(key, 10);
|
|
@@ -2431,6 +2510,9 @@ function has$$1(obj, key) {
|
|
|
2431
2510
|
else if (isObservableMap$$1(obj)) {
|
|
2432
2511
|
return obj.has(key);
|
|
2433
2512
|
}
|
|
2513
|
+
else if (isObservableSet$$1(obj)) {
|
|
2514
|
+
return obj.has(key);
|
|
2515
|
+
}
|
|
2434
2516
|
else if (isObservableArray$$1(obj)) {
|
|
2435
2517
|
return key >= 0 && key < obj.length;
|
|
2436
2518
|
}
|
|
@@ -2508,20 +2590,36 @@ function toJSHelper(source, options, __alreadySeen) {
|
|
|
2508
2590
|
res_1[i] = toAdd[i];
|
|
2509
2591
|
return res_1;
|
|
2510
2592
|
}
|
|
2593
|
+
if (isObservableSet$$1(source) || Object.getPrototypeOf(source) === Set.prototype) {
|
|
2594
|
+
if (options.exportMapsAsObjects === false) {
|
|
2595
|
+
var res_2 = cache(__alreadySeen, source, new Set(), options);
|
|
2596
|
+
source.forEach(function (value) {
|
|
2597
|
+
res_2.add(toJSHelper(value, options, __alreadySeen));
|
|
2598
|
+
});
|
|
2599
|
+
return res_2;
|
|
2600
|
+
}
|
|
2601
|
+
else {
|
|
2602
|
+
var res_3 = cache(__alreadySeen, source, [], options);
|
|
2603
|
+
source.forEach(function (value) {
|
|
2604
|
+
res_3.push(toJSHelper(value, options, __alreadySeen));
|
|
2605
|
+
});
|
|
2606
|
+
return res_3;
|
|
2607
|
+
}
|
|
2608
|
+
}
|
|
2511
2609
|
if (isObservableMap$$1(source) || Object.getPrototypeOf(source) === Map.prototype) {
|
|
2512
2610
|
if (options.exportMapsAsObjects === false) {
|
|
2513
|
-
var
|
|
2611
|
+
var res_4 = cache(__alreadySeen, source, new Map(), options);
|
|
2514
2612
|
source.forEach(function (value, key) {
|
|
2515
|
-
|
|
2613
|
+
res_4.set(key, toJSHelper(value, options, __alreadySeen));
|
|
2516
2614
|
});
|
|
2517
|
-
return
|
|
2615
|
+
return res_4;
|
|
2518
2616
|
}
|
|
2519
2617
|
else {
|
|
2520
|
-
var
|
|
2618
|
+
var res_5 = cache(__alreadySeen, source, {}, options);
|
|
2521
2619
|
source.forEach(function (value, key) {
|
|
2522
|
-
|
|
2620
|
+
res_5[key] = toJSHelper(value, options, __alreadySeen);
|
|
2523
2621
|
});
|
|
2524
|
-
return
|
|
2622
|
+
return res_5;
|
|
2525
2623
|
}
|
|
2526
2624
|
}
|
|
2527
2625
|
// Fallback to the situation that source is an ObservableObject or a plain object
|
|
@@ -2828,7 +2926,7 @@ var ObservableArrayAdministration = /** @class */ (function () {
|
|
|
2828
2926
|
return value;
|
|
2829
2927
|
};
|
|
2830
2928
|
ObservableArrayAdministration.prototype.dehanceValues = function (values$$1) {
|
|
2831
|
-
if (this.dehancer !== undefined &&
|
|
2929
|
+
if (this.dehancer !== undefined && values$$1.length > 0)
|
|
2832
2930
|
return values$$1.map(this.dehancer);
|
|
2833
2931
|
return values$$1;
|
|
2834
2932
|
};
|
|
@@ -3249,7 +3347,7 @@ var ObservableMap$$1 = /** @class */ (function () {
|
|
|
3249
3347
|
entry.setNewValue(value);
|
|
3250
3348
|
}
|
|
3251
3349
|
else {
|
|
3252
|
-
entry = new ObservableValue$$1(value, referenceEnhancer$$1, this.name + "." + key + "?", false);
|
|
3350
|
+
entry = new ObservableValue$$1(value, referenceEnhancer$$1, this.name + "." + stringifyKey(key) + "?", false);
|
|
3253
3351
|
this._hasMap.set(key, entry);
|
|
3254
3352
|
}
|
|
3255
3353
|
return entry;
|
|
@@ -3282,7 +3380,7 @@ var ObservableMap$$1 = /** @class */ (function () {
|
|
|
3282
3380
|
var _this = this;
|
|
3283
3381
|
checkIfStateModificationsAreAllowed$$1(this._keysAtom);
|
|
3284
3382
|
transaction$$1(function () {
|
|
3285
|
-
var observable$$1 = new ObservableValue$$1(newValue, _this.enhancer, _this.name + "." + key, false);
|
|
3383
|
+
var observable$$1 = new ObservableValue$$1(newValue, _this.enhancer, _this.name + "." + stringifyKey(key), false);
|
|
3286
3384
|
_this._data.set(key, observable$$1);
|
|
3287
3385
|
newValue = observable$$1.value; // value might have been changed
|
|
3288
3386
|
_this._updateHasMapEntry(key, true);
|
|
@@ -3382,8 +3480,11 @@ var ObservableMap$$1 = /** @class */ (function () {
|
|
|
3382
3480
|
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
3383
3481
|
return _this.set(key, value);
|
|
3384
3482
|
});
|
|
3385
|
-
else if (isES6Map$$1(other))
|
|
3483
|
+
else if (isES6Map$$1(other)) {
|
|
3484
|
+
if (other.constructor !== Map)
|
|
3485
|
+
fail$$1("Cannot initialize from classes that inherit from Map: " + other.constructor.name); // prettier-ignore
|
|
3386
3486
|
other.forEach(function (value, key) { return _this.set(key, value); });
|
|
3487
|
+
}
|
|
3387
3488
|
else if (other !== null && other !== undefined)
|
|
3388
3489
|
fail$$1("Cannot initialize map from " + other);
|
|
3389
3490
|
});
|
|
@@ -3443,7 +3544,8 @@ var ObservableMap$$1 = /** @class */ (function () {
|
|
|
3443
3544
|
try {
|
|
3444
3545
|
for (var _b = __values(this), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
3445
3546
|
var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
|
|
3446
|
-
|
|
3547
|
+
// We lie about symbol key types due to https://github.com/Microsoft/TypeScript/issues/1863
|
|
3548
|
+
res[typeof key === "symbol" ? key : stringifyKey(key)] = value;
|
|
3447
3549
|
}
|
|
3448
3550
|
}
|
|
3449
3551
|
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
@@ -3471,7 +3573,7 @@ var ObservableMap$$1 = /** @class */ (function () {
|
|
|
3471
3573
|
return (this.name +
|
|
3472
3574
|
"[{ " +
|
|
3473
3575
|
Array.from(this.keys())
|
|
3474
|
-
.map(function (key) { return key + ": " + ("" + _this.get(key)); })
|
|
3576
|
+
.map(function (key) { return stringifyKey(key) + ": " + ("" + _this.get(key)); })
|
|
3475
3577
|
.join(", ") +
|
|
3476
3578
|
" }]");
|
|
3477
3579
|
};
|
|
@@ -3490,9 +3592,233 @@ var ObservableMap$$1 = /** @class */ (function () {
|
|
|
3490
3592
|
};
|
|
3491
3593
|
return ObservableMap$$1;
|
|
3492
3594
|
}());
|
|
3595
|
+
function stringifyKey(key) {
|
|
3596
|
+
if (key && key.toString)
|
|
3597
|
+
return key.toString();
|
|
3598
|
+
else
|
|
3599
|
+
return new String(key).toString();
|
|
3600
|
+
}
|
|
3493
3601
|
/* 'var' fixes small-build issue */
|
|
3494
3602
|
var isObservableMap$$1 = createInstanceofPredicate$$1("ObservableMap", ObservableMap$$1);
|
|
3495
3603
|
|
|
3604
|
+
var _a$1;
|
|
3605
|
+
var ObservableSetMarker = {};
|
|
3606
|
+
var ObservableSet$$1 = /** @class */ (function () {
|
|
3607
|
+
function ObservableSet$$1(initialData, enhancer, name) {
|
|
3608
|
+
if (enhancer === void 0) { enhancer = deepEnhancer$$1; }
|
|
3609
|
+
if (name === void 0) { name = "ObservableSet@" + getNextId$$1(); }
|
|
3610
|
+
this.name = name;
|
|
3611
|
+
this[_a$1] = ObservableSetMarker;
|
|
3612
|
+
this._data = new Set();
|
|
3613
|
+
this._atom = createAtom$$1(this.name);
|
|
3614
|
+
this[Symbol.toStringTag] = "Set";
|
|
3615
|
+
if (typeof Set !== "function") {
|
|
3616
|
+
throw new Error("mobx.set requires Set polyfill for the current browser. Check babel-polyfill or core-js/es6/set.js");
|
|
3617
|
+
}
|
|
3618
|
+
this.enhancer = function (newV, oldV) { return enhancer(newV, oldV, name); };
|
|
3619
|
+
if (initialData) {
|
|
3620
|
+
this.replace(initialData);
|
|
3621
|
+
}
|
|
3622
|
+
}
|
|
3623
|
+
ObservableSet$$1.prototype.dehanceValue = function (value) {
|
|
3624
|
+
if (this.dehancer !== undefined) {
|
|
3625
|
+
return this.dehancer(value);
|
|
3626
|
+
}
|
|
3627
|
+
return value;
|
|
3628
|
+
};
|
|
3629
|
+
ObservableSet$$1.prototype.clear = function () {
|
|
3630
|
+
var _this = this;
|
|
3631
|
+
transaction$$1(function () {
|
|
3632
|
+
untracked$$1(function () {
|
|
3633
|
+
var e_1, _a;
|
|
3634
|
+
try {
|
|
3635
|
+
for (var _b = __values(_this._data.values()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
3636
|
+
var value = _c.value;
|
|
3637
|
+
_this.delete(value);
|
|
3638
|
+
}
|
|
3639
|
+
}
|
|
3640
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
3641
|
+
finally {
|
|
3642
|
+
try {
|
|
3643
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
3644
|
+
}
|
|
3645
|
+
finally { if (e_1) throw e_1.error; }
|
|
3646
|
+
}
|
|
3647
|
+
});
|
|
3648
|
+
});
|
|
3649
|
+
};
|
|
3650
|
+
ObservableSet$$1.prototype.forEach = function (callbackFn, thisArg) {
|
|
3651
|
+
var e_2, _a;
|
|
3652
|
+
try {
|
|
3653
|
+
for (var _b = __values(this), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
3654
|
+
var value = _c.value;
|
|
3655
|
+
callbackFn.call(thisArg, value, value, this);
|
|
3656
|
+
}
|
|
3657
|
+
}
|
|
3658
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
3659
|
+
finally {
|
|
3660
|
+
try {
|
|
3661
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
3662
|
+
}
|
|
3663
|
+
finally { if (e_2) throw e_2.error; }
|
|
3664
|
+
}
|
|
3665
|
+
};
|
|
3666
|
+
Object.defineProperty(ObservableSet$$1.prototype, "size", {
|
|
3667
|
+
get: function () {
|
|
3668
|
+
this._atom.reportObserved();
|
|
3669
|
+
return this._data.size;
|
|
3670
|
+
},
|
|
3671
|
+
enumerable: true,
|
|
3672
|
+
configurable: true
|
|
3673
|
+
});
|
|
3674
|
+
ObservableSet$$1.prototype.add = function (value) {
|
|
3675
|
+
var _this = this;
|
|
3676
|
+
checkIfStateModificationsAreAllowed$$1(this._atom);
|
|
3677
|
+
if (hasInterceptors$$1(this)) {
|
|
3678
|
+
var change = interceptChange$$1(this, {
|
|
3679
|
+
type: "add",
|
|
3680
|
+
object: this,
|
|
3681
|
+
newValue: value
|
|
3682
|
+
});
|
|
3683
|
+
if (!change)
|
|
3684
|
+
return this;
|
|
3685
|
+
// TODO: ideally, value = change.value would be done here, so that values can be
|
|
3686
|
+
// changed by interceptor. Same applies for other Set and Map api's.
|
|
3687
|
+
}
|
|
3688
|
+
if (!this.has(value)) {
|
|
3689
|
+
transaction$$1(function () {
|
|
3690
|
+
_this._data.add(_this.enhancer(value, undefined));
|
|
3691
|
+
_this._atom.reportChanged();
|
|
3692
|
+
});
|
|
3693
|
+
var notifySpy = isSpyEnabled$$1();
|
|
3694
|
+
var notify = hasListeners$$1(this);
|
|
3695
|
+
var change = notify || notifySpy
|
|
3696
|
+
? {
|
|
3697
|
+
type: "add",
|
|
3698
|
+
object: this,
|
|
3699
|
+
newValue: value
|
|
3700
|
+
}
|
|
3701
|
+
: null;
|
|
3702
|
+
if (notifySpy && process.env.NODE_ENV !== "production")
|
|
3703
|
+
spyReportStart$$1(change);
|
|
3704
|
+
if (notify)
|
|
3705
|
+
notifyListeners$$1(this, change);
|
|
3706
|
+
if (notifySpy && process.env.NODE_ENV !== "production")
|
|
3707
|
+
spyReportEnd$$1();
|
|
3708
|
+
}
|
|
3709
|
+
return this;
|
|
3710
|
+
};
|
|
3711
|
+
ObservableSet$$1.prototype.delete = function (value) {
|
|
3712
|
+
var _this = this;
|
|
3713
|
+
if (hasInterceptors$$1(this)) {
|
|
3714
|
+
var change = interceptChange$$1(this, {
|
|
3715
|
+
type: "delete",
|
|
3716
|
+
object: this,
|
|
3717
|
+
oldValue: value
|
|
3718
|
+
});
|
|
3719
|
+
if (!change)
|
|
3720
|
+
return false;
|
|
3721
|
+
}
|
|
3722
|
+
if (this.has(value)) {
|
|
3723
|
+
var notifySpy = isSpyEnabled$$1();
|
|
3724
|
+
var notify = hasListeners$$1(this);
|
|
3725
|
+
var change = notify || notifySpy
|
|
3726
|
+
? {
|
|
3727
|
+
type: "delete",
|
|
3728
|
+
object: this,
|
|
3729
|
+
oldValue: value
|
|
3730
|
+
}
|
|
3731
|
+
: null;
|
|
3732
|
+
if (notifySpy && process.env.NODE_ENV !== "production")
|
|
3733
|
+
spyReportStart$$1(__assign({}, change, { name: this.name }));
|
|
3734
|
+
transaction$$1(function () {
|
|
3735
|
+
_this._atom.reportChanged();
|
|
3736
|
+
_this._data.delete(value);
|
|
3737
|
+
});
|
|
3738
|
+
if (notify)
|
|
3739
|
+
notifyListeners$$1(this, change);
|
|
3740
|
+
if (notifySpy && process.env.NODE_ENV !== "production")
|
|
3741
|
+
spyReportEnd$$1();
|
|
3742
|
+
return true;
|
|
3743
|
+
}
|
|
3744
|
+
return false;
|
|
3745
|
+
};
|
|
3746
|
+
ObservableSet$$1.prototype.has = function (value) {
|
|
3747
|
+
this._atom.reportObserved();
|
|
3748
|
+
return this._data.has(this.dehanceValue(value));
|
|
3749
|
+
};
|
|
3750
|
+
ObservableSet$$1.prototype.entries = function () {
|
|
3751
|
+
var nextIndex = 0;
|
|
3752
|
+
var keys$$1 = Array.from(this.keys());
|
|
3753
|
+
var values$$1 = Array.from(this.values());
|
|
3754
|
+
return makeIterable({
|
|
3755
|
+
next: function () {
|
|
3756
|
+
var index = nextIndex;
|
|
3757
|
+
nextIndex += 1;
|
|
3758
|
+
return index < values$$1.length
|
|
3759
|
+
? { value: [keys$$1[index], values$$1[index]], done: false }
|
|
3760
|
+
: { done: true };
|
|
3761
|
+
}
|
|
3762
|
+
});
|
|
3763
|
+
};
|
|
3764
|
+
ObservableSet$$1.prototype.keys = function () {
|
|
3765
|
+
return this.values();
|
|
3766
|
+
};
|
|
3767
|
+
ObservableSet$$1.prototype.values = function () {
|
|
3768
|
+
this._atom.reportObserved();
|
|
3769
|
+
var self = this;
|
|
3770
|
+
var nextIndex = 0;
|
|
3771
|
+
var observableValues = Array.from(this._data.values());
|
|
3772
|
+
return makeIterable({
|
|
3773
|
+
next: function () {
|
|
3774
|
+
return nextIndex < observableValues.length
|
|
3775
|
+
? { value: self.dehanceValue(observableValues[nextIndex++]), done: false }
|
|
3776
|
+
: { done: true };
|
|
3777
|
+
}
|
|
3778
|
+
});
|
|
3779
|
+
};
|
|
3780
|
+
ObservableSet$$1.prototype.replace = function (other) {
|
|
3781
|
+
var _this = this;
|
|
3782
|
+
if (isObservableSet$$1(other)) {
|
|
3783
|
+
other = other.toJS();
|
|
3784
|
+
}
|
|
3785
|
+
transaction$$1(function () {
|
|
3786
|
+
if (Array.isArray(other)) {
|
|
3787
|
+
_this.clear();
|
|
3788
|
+
other.forEach(function (value) { return _this.add(value); });
|
|
3789
|
+
}
|
|
3790
|
+
else if (isES6Set$$1(other)) {
|
|
3791
|
+
_this.clear();
|
|
3792
|
+
other.forEach(function (value) { return _this.add(value); });
|
|
3793
|
+
}
|
|
3794
|
+
else if (other !== null && other !== undefined) {
|
|
3795
|
+
fail$$1("Cannot initialize set from " + other);
|
|
3796
|
+
}
|
|
3797
|
+
});
|
|
3798
|
+
return this;
|
|
3799
|
+
};
|
|
3800
|
+
ObservableSet$$1.prototype.observe = function (listener, fireImmediately) {
|
|
3801
|
+
// TODO 'fireImmediately' can be true?
|
|
3802
|
+
process.env.NODE_ENV !== "production" &&
|
|
3803
|
+
invariant$$1(fireImmediately !== true, "`observe` doesn't support fireImmediately=true in combination with sets.");
|
|
3804
|
+
return registerListener$$1(this, listener);
|
|
3805
|
+
};
|
|
3806
|
+
ObservableSet$$1.prototype.intercept = function (handler) {
|
|
3807
|
+
return registerInterceptor$$1(this, handler);
|
|
3808
|
+
};
|
|
3809
|
+
ObservableSet$$1.prototype.toJS = function () {
|
|
3810
|
+
return new Set(this);
|
|
3811
|
+
};
|
|
3812
|
+
ObservableSet$$1.prototype.toString = function () {
|
|
3813
|
+
return this.name + "[ " + Array.from(this).join(", ") + " ]";
|
|
3814
|
+
};
|
|
3815
|
+
ObservableSet$$1.prototype[(_a$1 = $mobx$$1, Symbol.iterator)] = function () {
|
|
3816
|
+
return this.values();
|
|
3817
|
+
};
|
|
3818
|
+
return ObservableSet$$1;
|
|
3819
|
+
}());
|
|
3820
|
+
var isObservableSet$$1 = createInstanceofPredicate$$1("ObservableSet", ObservableSet$$1);
|
|
3821
|
+
|
|
3496
3822
|
var ObservableObjectAdministration$$1 = /** @class */ (function () {
|
|
3497
3823
|
function ObservableObjectAdministration$$1(target, values$$1, name, defaultEnhancer) {
|
|
3498
3824
|
if (values$$1 === void 0) { values$$1 = new Map(); }
|
|
@@ -3764,7 +4090,7 @@ function getAdministrationForComputedPropOwner(owner) {
|
|
|
3764
4090
|
function generateComputedPropConfig$$1(propName) {
|
|
3765
4091
|
return (computedPropertyConfigs[propName] ||
|
|
3766
4092
|
(computedPropertyConfigs[propName] = {
|
|
3767
|
-
configurable:
|
|
4093
|
+
configurable: false,
|
|
3768
4094
|
enumerable: false,
|
|
3769
4095
|
get: function () {
|
|
3770
4096
|
return getAdministrationForComputedPropOwner(this).read(propName);
|
|
@@ -3792,6 +4118,9 @@ function getAtom$$1(thing, property) {
|
|
|
3792
4118
|
"It is not possible to get index atoms from arrays");
|
|
3793
4119
|
return thing[$mobx$$1].atom;
|
|
3794
4120
|
}
|
|
4121
|
+
if (isObservableSet$$1(thing)) {
|
|
4122
|
+
return thing[$mobx$$1];
|
|
4123
|
+
}
|
|
3795
4124
|
if (isObservableMap$$1(thing)) {
|
|
3796
4125
|
var anyThing = thing;
|
|
3797
4126
|
if (property === undefined)
|
|
@@ -3834,7 +4163,7 @@ function getAdministration$$1(thing, property) {
|
|
|
3834
4163
|
return getAdministration$$1(getAtom$$1(thing, property));
|
|
3835
4164
|
if (isAtom$$1(thing) || isComputedValue$$1(thing) || isReaction$$1(thing))
|
|
3836
4165
|
return thing;
|
|
3837
|
-
if (isObservableMap$$1(thing))
|
|
4166
|
+
if (isObservableMap$$1(thing) || isObservableSet$$1(thing))
|
|
3838
4167
|
return thing;
|
|
3839
4168
|
// Initializers run lazily when transpiling to babel, so make sure they are run...
|
|
3840
4169
|
initializeInstance$$1(thing);
|
|
@@ -3846,7 +4175,7 @@ function getDebugName$$1(thing, property) {
|
|
|
3846
4175
|
var named;
|
|
3847
4176
|
if (property !== undefined)
|
|
3848
4177
|
named = getAtom$$1(thing, property);
|
|
3849
|
-
else if (isObservableObject$$1(thing) || isObservableMap$$1(thing))
|
|
4178
|
+
else if (isObservableObject$$1(thing) || isObservableMap$$1(thing) || isObservableSet$$1(thing))
|
|
3850
4179
|
named = getAdministration$$1(thing);
|
|
3851
4180
|
else
|
|
3852
4181
|
named = getAtom$$1(thing); // valid for arrays as well
|
|
@@ -3955,7 +4284,8 @@ function deepEq(a, b, aStack, bStack) {
|
|
|
3955
4284
|
}
|
|
3956
4285
|
else {
|
|
3957
4286
|
// Deep compare objects.
|
|
3958
|
-
var keys$$1 = Object.keys(a)
|
|
4287
|
+
var keys$$1 = Object.keys(a);
|
|
4288
|
+
var key = void 0;
|
|
3959
4289
|
length = keys$$1.length;
|
|
3960
4290
|
// Ensure that both objects contain the same number of properties before comparing deep equality.
|
|
3961
4291
|
if (Object.keys(b).length !== length)
|
|
@@ -3977,6 +4307,8 @@ function unwrap(a) {
|
|
|
3977
4307
|
return a.slice();
|
|
3978
4308
|
if (isES6Map$$1(a) || isObservableMap$$1(a))
|
|
3979
4309
|
return Array.from(a.entries());
|
|
4310
|
+
if (isES6Set$$1(a) || isObservableSet$$1(a))
|
|
4311
|
+
return Array.from(a.entries());
|
|
3980
4312
|
return a;
|
|
3981
4313
|
}
|
|
3982
4314
|
function has$1(a, key) {
|
|
@@ -4017,7 +4349,7 @@ but at least in this file we can magically reorder the imports with trial and er
|
|
|
4017
4349
|
*
|
|
4018
4350
|
*/
|
|
4019
4351
|
if (typeof Proxy === "undefined" || typeof Symbol === "undefined") {
|
|
4020
|
-
throw new Error("[mobx] MobX 5+ requires Proxy and Symbol objects. If your environment doesn't support Proxy objects, please downgrade to MobX 4. For React Native Android, consider upgrading JSCore.");
|
|
4352
|
+
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.");
|
|
4021
4353
|
}
|
|
4022
4354
|
try {
|
|
4023
4355
|
// define process.env if needed
|
|
@@ -4035,7 +4367,8 @@ catch (e) {
|
|
|
4035
4367
|
(function () {
|
|
4036
4368
|
function testCodeMinification() { }
|
|
4037
4369
|
if (testCodeMinification.name !== "testCodeMinification" &&
|
|
4038
|
-
process.env.NODE_ENV !== "production"
|
|
4370
|
+
process.env.NODE_ENV !== "production" &&
|
|
4371
|
+
process.env.IGNORE_MOBX_MINIFY_WARNING !== "true") {
|
|
4039
4372
|
console.warn(
|
|
4040
4373
|
// Template literal(backtick) is used for fix issue with rollup-plugin-commonjs https://github.com/rollup/rollup-plugin-commonjs/issues/344
|
|
4041
4374
|
"[mobx] you are running a minified build, but 'process.env.NODE_ENV' was not set to 'production' in your bundler. This results in an unnecessarily large and slow bundle");
|
|
@@ -4053,4 +4386,4 @@ if (typeof __MOBX_DEVTOOLS_GLOBAL_HOOK__ === "object") {
|
|
|
4053
4386
|
});
|
|
4054
4387
|
}
|
|
4055
4388
|
|
|
4056
|
-
export { Reaction$$1 as Reaction, untracked$$1 as untracked, IDerivationState, createAtom$$1 as createAtom, spy$$1 as spy, comparer$$1 as comparer, isObservableObject$$1 as isObservableObject, isObservableValue$$1 as isBoxedObservable, isObservableArray$$1 as isObservableArray, ObservableMap$$1 as ObservableMap, isObservableMap$$1 as isObservableMap, transaction$$1 as transaction, observable$$1 as observable, computed$$1 as computed, isObservable$$1 as isObservable, isObservableProp$$1 as isObservableProp, isComputed$$1 as isComputed, isComputedProp$$1 as isComputedProp, extendObservable$$1 as extendObservable, observe$$1 as observe, intercept$$1 as intercept, autorun$$1 as autorun, reaction$$1 as reaction, when$$1 as when, action$$1 as action, isAction$$1 as isAction, runInAction$$1 as runInAction, keys$$1 as keys, values$$1 as values, entries$$1 as entries, set$$1 as set, remove$$1 as remove, has$$1 as has, get$$1 as get, decorate$$1 as decorate, configure$$1 as configure, onBecomeObserved$$1 as onBecomeObserved, onBecomeUnobserved$$1 as onBecomeUnobserved, flow$$1 as flow, toJS$$1 as toJS, trace$$1 as trace, getDependencyTree$$1 as getDependencyTree, getObserverTree$$1 as getObserverTree, resetGlobalState$$1 as _resetGlobalState, getGlobalState$$1 as _getGlobalState, getDebugName$$1 as getDebugName, getAtom$$1 as getAtom, getAdministration$$1 as _getAdministration, allowStateChanges$$1 as _allowStateChanges, allowStateChangesInsideComputed$$1 as _allowStateChangesInsideComputed, isArrayLike$$1 as isArrayLike, $mobx$$1 as $mobx, isComputingDerivation$$1 as _isComputingDerivation, onReactionError$$1 as onReactionError, interceptReads$$1 as _interceptReads };
|
|
4389
|
+
export { Reaction$$1 as Reaction, untracked$$1 as untracked, IDerivationState, createAtom$$1 as createAtom, spy$$1 as spy, comparer$$1 as comparer, isObservableObject$$1 as isObservableObject, isObservableValue$$1 as isBoxedObservable, isObservableArray$$1 as isObservableArray, ObservableMap$$1 as ObservableMap, isObservableMap$$1 as isObservableMap, ObservableSet$$1 as ObservableSet, isObservableSet$$1 as isObservableSet, transaction$$1 as transaction, observable$$1 as observable, computed$$1 as computed, isObservable$$1 as isObservable, isObservableProp$$1 as isObservableProp, isComputed$$1 as isComputed, isComputedProp$$1 as isComputedProp, extendObservable$$1 as extendObservable, observe$$1 as observe, intercept$$1 as intercept, autorun$$1 as autorun, reaction$$1 as reaction, when$$1 as when, action$$1 as action, isAction$$1 as isAction, runInAction$$1 as runInAction, keys$$1 as keys, values$$1 as values, entries$$1 as entries, set$$1 as set, remove$$1 as remove, has$$1 as has, get$$1 as get, decorate$$1 as decorate, configure$$1 as configure, onBecomeObserved$$1 as onBecomeObserved, onBecomeUnobserved$$1 as onBecomeUnobserved, flow$$1 as flow, toJS$$1 as toJS, trace$$1 as trace, getDependencyTree$$1 as getDependencyTree, getObserverTree$$1 as getObserverTree, resetGlobalState$$1 as _resetGlobalState, getGlobalState$$1 as _getGlobalState, getDebugName$$1 as getDebugName, getAtom$$1 as getAtom, getAdministration$$1 as _getAdministration, allowStateChanges$$1 as _allowStateChanges, allowStateChangesInsideComputed$$1 as _allowStateChangesInsideComputed, isArrayLike$$1 as isArrayLike, $mobx$$1 as $mobx, isComputingDerivation$$1 as _isComputingDerivation, onReactionError$$1 as onReactionError, interceptReads$$1 as _interceptReads };
|