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.es6.js
CHANGED
|
@@ -103,6 +103,9 @@ function isArrayLike$$1(x) {
|
|
|
103
103
|
function isES6Map$$1(thing) {
|
|
104
104
|
return thing instanceof Map;
|
|
105
105
|
}
|
|
106
|
+
function isES6Set$$1(thing) {
|
|
107
|
+
return thing instanceof Set;
|
|
108
|
+
}
|
|
106
109
|
function getMapLikeKeys$$1(map) {
|
|
107
110
|
if (isPlainObject$$1(map))
|
|
108
111
|
return Object.keys(map);
|
|
@@ -131,11 +134,15 @@ class Atom$$1 {
|
|
|
131
134
|
this.lastAccessedBy = 0;
|
|
132
135
|
this.lowestObserverState = IDerivationState.NOT_TRACKING;
|
|
133
136
|
}
|
|
134
|
-
onBecomeUnobserved() {
|
|
135
|
-
// noop
|
|
136
|
-
}
|
|
137
137
|
onBecomeObserved() {
|
|
138
|
-
|
|
138
|
+
if (this.onBecomeObservedListeners) {
|
|
139
|
+
this.onBecomeObservedListeners.forEach(listener => listener());
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
onBecomeUnobserved() {
|
|
143
|
+
if (this.onBecomeUnobservedListeners) {
|
|
144
|
+
this.onBecomeUnobservedListeners.forEach(listener => listener());
|
|
145
|
+
}
|
|
139
146
|
}
|
|
140
147
|
/**
|
|
141
148
|
* Invoke this method to notify mobx that your atom has been used somehow.
|
|
@@ -159,8 +166,13 @@ class Atom$$1 {
|
|
|
159
166
|
const isAtom$$1 = createInstanceofPredicate$$1("Atom", Atom$$1);
|
|
160
167
|
function createAtom$$1(name, onBecomeObservedHandler = noop$$1, onBecomeUnobservedHandler = noop$$1) {
|
|
161
168
|
const atom = new Atom$$1(name);
|
|
162
|
-
|
|
163
|
-
|
|
169
|
+
// default `noop` listener will not initialize the hook Set
|
|
170
|
+
if (onBecomeObservedHandler !== noop$$1) {
|
|
171
|
+
onBecomeObserved$$1(atom, onBecomeObservedHandler);
|
|
172
|
+
}
|
|
173
|
+
if (onBecomeUnobservedHandler !== noop$$1) {
|
|
174
|
+
onBecomeUnobserved$$1(atom, onBecomeUnobservedHandler);
|
|
175
|
+
}
|
|
164
176
|
return atom;
|
|
165
177
|
}
|
|
166
178
|
|
|
@@ -265,12 +277,14 @@ function deepEnhancer$$1(v, _, name) {
|
|
|
265
277
|
return observable$$1.object(v, undefined, { name });
|
|
266
278
|
if (isES6Map$$1(v))
|
|
267
279
|
return observable$$1.map(v, { name });
|
|
280
|
+
if (isES6Set$$1(v))
|
|
281
|
+
return observable$$1.set(v, { name });
|
|
268
282
|
return v;
|
|
269
283
|
}
|
|
270
284
|
function shallowEnhancer$$1(v, _, name) {
|
|
271
285
|
if (v === undefined || v === null)
|
|
272
286
|
return v;
|
|
273
|
-
if (isObservableObject$$1(v) || isObservableArray$$1(v) || isObservableMap$$1(v))
|
|
287
|
+
if (isObservableObject$$1(v) || isObservableArray$$1(v) || isObservableMap$$1(v) || isObservableSet$$1(v))
|
|
274
288
|
return v;
|
|
275
289
|
if (Array.isArray(v))
|
|
276
290
|
return observable$$1.array(v, { name, deep: false });
|
|
@@ -278,8 +292,10 @@ function shallowEnhancer$$1(v, _, name) {
|
|
|
278
292
|
return observable$$1.object(v, undefined, { name, deep: false });
|
|
279
293
|
if (isES6Map$$1(v))
|
|
280
294
|
return observable$$1.map(v, { name, deep: false });
|
|
295
|
+
if (isES6Set$$1(v))
|
|
296
|
+
return observable$$1.set(v, { name, deep: false });
|
|
281
297
|
return fail$$1(process.env.NODE_ENV !== "production" &&
|
|
282
|
-
"The shallow modifier / decorator can only used in combination with arrays, objects and
|
|
298
|
+
"The shallow modifier / decorator can only used in combination with arrays, objects, maps and sets");
|
|
283
299
|
}
|
|
284
300
|
function referenceEnhancer$$1(newValue) {
|
|
285
301
|
// never turn into an observable
|
|
@@ -331,7 +347,7 @@ const defaultCreateObservableOptions$$1 = {
|
|
|
331
347
|
};
|
|
332
348
|
Object.freeze(defaultCreateObservableOptions$$1);
|
|
333
349
|
function assertValidOption(key) {
|
|
334
|
-
if (!/^(deep|name|defaultDecorator|proxy)$/.test(key))
|
|
350
|
+
if (!/^(deep|name|equals|defaultDecorator|proxy)$/.test(key))
|
|
335
351
|
fail$$1(`invalid option for (extend)observable: ${key}`);
|
|
336
352
|
}
|
|
337
353
|
function asCreateObservableOptions$$1(thing) {
|
|
@@ -376,7 +392,9 @@ function createObservable(v, arg2, arg3) {
|
|
|
376
392
|
? observable$$1.array(v, arg2)
|
|
377
393
|
: isES6Map$$1(v)
|
|
378
394
|
? observable$$1.map(v, arg2)
|
|
379
|
-
: v
|
|
395
|
+
: isES6Set$$1(v)
|
|
396
|
+
? observable$$1.set(v, arg2)
|
|
397
|
+
: v;
|
|
380
398
|
// this value could be converted to a new observable data structure, return it
|
|
381
399
|
if (res !== v)
|
|
382
400
|
return res;
|
|
@@ -389,7 +407,7 @@ const observableFactories = {
|
|
|
389
407
|
if (arguments.length > 2)
|
|
390
408
|
incorrectlyUsedAsDecorator("box");
|
|
391
409
|
const o = asCreateObservableOptions$$1(options);
|
|
392
|
-
return new ObservableValue$$1(value, getEnhancerFromOptions(o), o.name);
|
|
410
|
+
return new ObservableValue$$1(value, getEnhancerFromOptions(o), o.name, true, o.equals);
|
|
393
411
|
},
|
|
394
412
|
array(initialValues, options) {
|
|
395
413
|
if (arguments.length > 2)
|
|
@@ -403,6 +421,12 @@ const observableFactories = {
|
|
|
403
421
|
const o = asCreateObservableOptions$$1(options);
|
|
404
422
|
return new ObservableMap$$1(initialValues, getEnhancerFromOptions(o), o.name);
|
|
405
423
|
},
|
|
424
|
+
set(initialValues, options) {
|
|
425
|
+
if (arguments.length > 2)
|
|
426
|
+
incorrectlyUsedAsDecorator("set");
|
|
427
|
+
const o = asCreateObservableOptions$$1(options);
|
|
428
|
+
return new ObservableSet$$1(initialValues, getEnhancerFromOptions(o), o.name);
|
|
429
|
+
},
|
|
406
430
|
object(props, decorators, options) {
|
|
407
431
|
if (typeof arguments[1] === "string")
|
|
408
432
|
incorrectlyUsedAsDecorator("object");
|
|
@@ -446,7 +470,7 @@ const computedStructDecorator = computedDecorator$$1({ equals: comparer$$1.struc
|
|
|
446
470
|
* Decorator for class properties: @computed get value() { return expr; }.
|
|
447
471
|
* For legacy purposes also invokable as ES5 observable created: `computed(() => expr)`;
|
|
448
472
|
*/
|
|
449
|
-
|
|
473
|
+
const computed$$1 = function computed$$1(arg1, arg2, arg3) {
|
|
450
474
|
if (typeof arg2 === "string") {
|
|
451
475
|
// @computed
|
|
452
476
|
return computedDecorator$$1.apply(null, arguments);
|
|
@@ -468,25 +492,35 @@ var computed$$1 = function computed$$1(arg1, arg2, arg3) {
|
|
|
468
492
|
};
|
|
469
493
|
computed$$1.struct = computedStructDecorator;
|
|
470
494
|
|
|
471
|
-
function createAction$$1(actionName, fn) {
|
|
495
|
+
function createAction$$1(actionName, fn, ref) {
|
|
472
496
|
if (process.env.NODE_ENV !== "production") {
|
|
473
497
|
invariant$$1(typeof fn === "function", "`action` can only be invoked on functions");
|
|
474
498
|
if (typeof actionName !== "string" || !actionName)
|
|
475
499
|
fail$$1(`actions should have valid names, got: '${actionName}'`);
|
|
476
500
|
}
|
|
477
501
|
const res = function () {
|
|
478
|
-
return executeAction$$1(actionName, fn, this, arguments);
|
|
502
|
+
return executeAction$$1(actionName, fn, ref || this, arguments);
|
|
479
503
|
};
|
|
480
504
|
res.isMobxAction = true;
|
|
481
505
|
return res;
|
|
482
506
|
}
|
|
483
507
|
function executeAction$$1(actionName, fn, scope, args) {
|
|
484
508
|
const runInfo = startAction(actionName, fn, scope, args);
|
|
509
|
+
let shouldSupressReactionError = true;
|
|
485
510
|
try {
|
|
486
|
-
|
|
511
|
+
const res = fn.apply(scope, args);
|
|
512
|
+
shouldSupressReactionError = false;
|
|
513
|
+
return res;
|
|
487
514
|
}
|
|
488
515
|
finally {
|
|
489
|
-
|
|
516
|
+
if (shouldSupressReactionError) {
|
|
517
|
+
globalState$$1.suppressReactionErrors = shouldSupressReactionError;
|
|
518
|
+
endAction(runInfo);
|
|
519
|
+
globalState$$1.suppressReactionErrors = false;
|
|
520
|
+
}
|
|
521
|
+
else {
|
|
522
|
+
endAction(runInfo);
|
|
523
|
+
}
|
|
490
524
|
}
|
|
491
525
|
}
|
|
492
526
|
function startAction(actionName, fn, scope, args) {
|
|
@@ -556,9 +590,11 @@ function allowStateChangesInsideComputed$$1(func) {
|
|
|
556
590
|
}
|
|
557
591
|
|
|
558
592
|
class ObservableValue$$1 extends Atom$$1 {
|
|
559
|
-
constructor(value, enhancer, name = "ObservableValue@" + getNextId$$1(), notifySpy = true) {
|
|
593
|
+
constructor(value, enhancer, name = "ObservableValue@" + getNextId$$1(), notifySpy = true, equals = comparer$$1.default) {
|
|
560
594
|
super(name);
|
|
561
595
|
this.enhancer = enhancer;
|
|
596
|
+
this.name = name;
|
|
597
|
+
this.equals = equals;
|
|
562
598
|
this.hasUnreportedChange = false;
|
|
563
599
|
this.value = enhancer(value, undefined, name);
|
|
564
600
|
if (notifySpy && isSpyEnabled$$1() && process.env.NODE_ENV !== "production") {
|
|
@@ -603,7 +639,7 @@ class ObservableValue$$1 extends Atom$$1 {
|
|
|
603
639
|
}
|
|
604
640
|
// apply modifier
|
|
605
641
|
newValue = this.enhancer(newValue, this.value, this.name);
|
|
606
|
-
return this.value
|
|
642
|
+
return this.equals(this.value, newValue) ? globalState$$1.UNCHANGED : newValue;
|
|
607
643
|
}
|
|
608
644
|
setNewValue(newValue) {
|
|
609
645
|
const oldValue = this.value;
|
|
@@ -648,7 +684,7 @@ class ObservableValue$$1 extends Atom$$1 {
|
|
|
648
684
|
return this.valueOf();
|
|
649
685
|
}
|
|
650
686
|
}
|
|
651
|
-
|
|
687
|
+
const isObservableValue$$1 = createInstanceofPredicate$$1("ObservableValue", ObservableValue$$1);
|
|
652
688
|
|
|
653
689
|
/**
|
|
654
690
|
* A node in the state dependency root that observes other nodes, and can be observed itself.
|
|
@@ -717,8 +753,16 @@ class ComputedValue$$1 {
|
|
|
717
753
|
onBecomeStale() {
|
|
718
754
|
propagateMaybeChanged$$1(this);
|
|
719
755
|
}
|
|
720
|
-
|
|
721
|
-
|
|
756
|
+
onBecomeObserved() {
|
|
757
|
+
if (this.onBecomeObservedListeners) {
|
|
758
|
+
this.onBecomeObservedListeners.forEach(listener => listener());
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
onBecomeUnobserved() {
|
|
762
|
+
if (this.onBecomeUnobservedListeners) {
|
|
763
|
+
this.onBecomeUnobservedListeners.forEach(listener => listener());
|
|
764
|
+
}
|
|
765
|
+
}
|
|
722
766
|
/**
|
|
723
767
|
* Returns the current value of this computed value.
|
|
724
768
|
* Will evaluate its computation first if needed.
|
|
@@ -1194,6 +1238,11 @@ class MobXGlobals$$1 {
|
|
|
1194
1238
|
* the stack when an exception occurs while debugging.
|
|
1195
1239
|
*/
|
|
1196
1240
|
this.disableErrorBoundaries = false;
|
|
1241
|
+
/*
|
|
1242
|
+
* If true, we are already handling an exception in an action. Any errors in reactions should be supressed, as
|
|
1243
|
+
* they are not the cause, see: https://github.com/mobxjs/mobx/issues/1836
|
|
1244
|
+
*/
|
|
1245
|
+
this.suppressReactionErrors = false;
|
|
1197
1246
|
}
|
|
1198
1247
|
}
|
|
1199
1248
|
let canMergeGlobalState = true;
|
|
@@ -1445,7 +1494,7 @@ You are entering this break point because derivation '${derivation.name}' is bei
|
|
|
1445
1494
|
Just follow the stacktrace you should now see in the devtools to see precisely what piece of your code is causing this update
|
|
1446
1495
|
The stackframe you are looking for is at least ~6-8 stack-frames up.
|
|
1447
1496
|
|
|
1448
|
-
${derivation instanceof ComputedValue$$1 ? derivation.derivation.toString() : ""}
|
|
1497
|
+
${derivation instanceof ComputedValue$$1 ? derivation.derivation.toString().replace(/[*]\//g, "/") : ""}
|
|
1449
1498
|
|
|
1450
1499
|
The dependencies for this derivation are:
|
|
1451
1500
|
|
|
@@ -1524,6 +1573,9 @@ class Reaction$$1 {
|
|
|
1524
1573
|
}
|
|
1525
1574
|
}
|
|
1526
1575
|
track(fn) {
|
|
1576
|
+
if (this.isDisposed) {
|
|
1577
|
+
fail$$1("Reaction already disposed");
|
|
1578
|
+
}
|
|
1527
1579
|
startBatch$$1();
|
|
1528
1580
|
const notify = isSpyEnabled$$1();
|
|
1529
1581
|
let startTime;
|
|
@@ -1558,9 +1610,14 @@ class Reaction$$1 {
|
|
|
1558
1610
|
}
|
|
1559
1611
|
if (globalState$$1.disableErrorBoundaries)
|
|
1560
1612
|
throw error;
|
|
1561
|
-
const message = `[mobx] Encountered an uncaught exception that was thrown by a reaction or observer component, in: '${this}`;
|
|
1562
|
-
|
|
1563
|
-
|
|
1613
|
+
const message = `[mobx] Encountered an uncaught exception that was thrown by a reaction or observer component, in: '${this}'`;
|
|
1614
|
+
if (globalState$$1.suppressReactionErrors) {
|
|
1615
|
+
console.warn(`[mobx] (error in reaction '${this.name}' suppressed, fix error of causing action below)`); // prettier-ignore
|
|
1616
|
+
}
|
|
1617
|
+
else {
|
|
1618
|
+
console.error(message, error);
|
|
1619
|
+
/** If debugging brought you here, please, read the above message :-). Tnx! */
|
|
1620
|
+
}
|
|
1564
1621
|
if (isSpyEnabled$$1()) {
|
|
1565
1622
|
spyReport$$1({
|
|
1566
1623
|
type: "error",
|
|
@@ -1763,7 +1820,7 @@ function boundActionDecorator$$1(target, propertyName, descriptor, applyToInstan
|
|
|
1763
1820
|
};
|
|
1764
1821
|
}
|
|
1765
1822
|
|
|
1766
|
-
|
|
1823
|
+
const action$$1 = function action$$1(arg1, arg2, arg3, arg4) {
|
|
1767
1824
|
// action(fn() {})
|
|
1768
1825
|
if (arguments.length === 1 && typeof arg1 === "function")
|
|
1769
1826
|
return createAction$$1(arg1.name || "<unnamed action>", arg1);
|
|
@@ -1776,7 +1833,7 @@ var action$$1 = function action$$1(arg1, arg2, arg3, arg4) {
|
|
|
1776
1833
|
// @action fn() {}
|
|
1777
1834
|
if (arg4 === true) {
|
|
1778
1835
|
// apply to instance immediately
|
|
1779
|
-
addHiddenProp$$1(arg1, arg2, createAction$$1(arg1.name || arg2, arg3.value));
|
|
1836
|
+
addHiddenProp$$1(arg1, arg2, createAction$$1(arg1.name || arg2, arg3.value, this));
|
|
1780
1837
|
}
|
|
1781
1838
|
else {
|
|
1782
1839
|
return namedActionDecorator$$1(arg2).apply(null, arguments);
|
|
@@ -1913,20 +1970,32 @@ function onBecomeUnobserved$$1(thing, arg2, arg3) {
|
|
|
1913
1970
|
function interceptHook(hook, thing, arg2, arg3) {
|
|
1914
1971
|
const atom = typeof arg2 === "string" ? getAtom$$1(thing, arg2) : getAtom$$1(thing);
|
|
1915
1972
|
const cb = typeof arg2 === "string" ? arg3 : arg2;
|
|
1973
|
+
const listenersKey = `${hook}Listeners`;
|
|
1974
|
+
if (atom[listenersKey]) {
|
|
1975
|
+
atom[listenersKey].add(cb);
|
|
1976
|
+
}
|
|
1977
|
+
else {
|
|
1978
|
+
atom[listenersKey] = new Set([cb]);
|
|
1979
|
+
}
|
|
1916
1980
|
const orig = atom[hook];
|
|
1917
1981
|
if (typeof orig !== "function")
|
|
1918
1982
|
return fail$$1(process.env.NODE_ENV !== "production" && "Not an atom that can be (un)observed");
|
|
1919
|
-
atom[hook] = function () {
|
|
1920
|
-
orig.call(this);
|
|
1921
|
-
cb.call(this);
|
|
1922
|
-
};
|
|
1923
1983
|
return function () {
|
|
1924
|
-
atom[
|
|
1984
|
+
const hookListeners = atom[listenersKey];
|
|
1985
|
+
if (hookListeners) {
|
|
1986
|
+
hookListeners.delete(cb);
|
|
1987
|
+
if (hookListeners.size === 0) {
|
|
1988
|
+
delete atom[listenersKey];
|
|
1989
|
+
}
|
|
1990
|
+
}
|
|
1925
1991
|
};
|
|
1926
1992
|
}
|
|
1927
1993
|
|
|
1928
1994
|
function configure$$1(options) {
|
|
1929
1995
|
const { enforceActions, computedRequiresReaction, disableErrorBoundaries, reactionScheduler } = options;
|
|
1996
|
+
if (options.isolateGlobalState === true) {
|
|
1997
|
+
isolateGlobalState$$1();
|
|
1998
|
+
}
|
|
1930
1999
|
if (enforceActions !== undefined) {
|
|
1931
2000
|
if (typeof enforceActions === "boolean" || enforceActions === "strict")
|
|
1932
2001
|
deprecated$$1(`Deprecated value for 'enforceActions', use 'false' => '"never"', 'true' => '"observed"', '"strict"' => "'always'" instead`);
|
|
@@ -1953,9 +2022,6 @@ function configure$$1(options) {
|
|
|
1953
2022
|
if (computedRequiresReaction !== undefined) {
|
|
1954
2023
|
globalState$$1.computedRequiresReaction = !!computedRequiresReaction;
|
|
1955
2024
|
}
|
|
1956
|
-
if (options.isolateGlobalState === true) {
|
|
1957
|
-
isolateGlobalState$$1();
|
|
1958
|
-
}
|
|
1959
2025
|
if (disableErrorBoundaries !== undefined) {
|
|
1960
2026
|
if (disableErrorBoundaries === true)
|
|
1961
2027
|
console.warn("WARNING: Debug feature only. MobX will NOT recover from errors when `disableErrorBoundaries` is enabled.");
|
|
@@ -2074,7 +2140,7 @@ function flow$$1(generator) {
|
|
|
2074
2140
|
const gen = action$$1(`${name} - runid: ${runId} - init`, generator).apply(ctx, args);
|
|
2075
2141
|
let rejector;
|
|
2076
2142
|
let pendingPromise = undefined;
|
|
2077
|
-
const
|
|
2143
|
+
const promise = new Promise(function (resolve, reject) {
|
|
2078
2144
|
let stepId = 0;
|
|
2079
2145
|
rejector = reject;
|
|
2080
2146
|
function onFulfilled(res) {
|
|
@@ -2112,7 +2178,7 @@ function flow$$1(generator) {
|
|
|
2112
2178
|
}
|
|
2113
2179
|
onFulfilled(undefined); // kick off the process
|
|
2114
2180
|
});
|
|
2115
|
-
|
|
2181
|
+
promise.cancel = action$$1(`${name} - runid: ${runId} - cancel`, function () {
|
|
2116
2182
|
try {
|
|
2117
2183
|
if (pendingPromise)
|
|
2118
2184
|
cancelPromise(pendingPromise);
|
|
@@ -2129,7 +2195,7 @@ function flow$$1(generator) {
|
|
|
2129
2195
|
rejector(e); // there could be a throwing finally block
|
|
2130
2196
|
}
|
|
2131
2197
|
});
|
|
2132
|
-
return
|
|
2198
|
+
return promise;
|
|
2133
2199
|
};
|
|
2134
2200
|
}
|
|
2135
2201
|
function cancelPromise(promise) {
|
|
@@ -2237,11 +2303,14 @@ function keys$$1(obj) {
|
|
|
2237
2303
|
if (isObservableMap$$1(obj)) {
|
|
2238
2304
|
return Array.from(obj.keys());
|
|
2239
2305
|
}
|
|
2306
|
+
if (isObservableSet$$1(obj)) {
|
|
2307
|
+
return Array.from(obj.keys());
|
|
2308
|
+
}
|
|
2240
2309
|
if (isObservableArray$$1(obj)) {
|
|
2241
2310
|
return obj.map((_, index) => index);
|
|
2242
2311
|
}
|
|
2243
2312
|
return fail$$1(process.env.NODE_ENV !== "production" &&
|
|
2244
|
-
"'keys()' can only be used on observable objects, arrays and maps");
|
|
2313
|
+
"'keys()' can only be used on observable objects, arrays, sets and maps");
|
|
2245
2314
|
}
|
|
2246
2315
|
function values$$1(obj) {
|
|
2247
2316
|
if (isObservableObject$$1(obj)) {
|
|
@@ -2250,11 +2319,14 @@ function values$$1(obj) {
|
|
|
2250
2319
|
if (isObservableMap$$1(obj)) {
|
|
2251
2320
|
return keys$$1(obj).map(key => obj.get(key));
|
|
2252
2321
|
}
|
|
2322
|
+
if (isObservableSet$$1(obj)) {
|
|
2323
|
+
return Array.from(obj.values());
|
|
2324
|
+
}
|
|
2253
2325
|
if (isObservableArray$$1(obj)) {
|
|
2254
2326
|
return obj.slice();
|
|
2255
2327
|
}
|
|
2256
2328
|
return fail$$1(process.env.NODE_ENV !== "production" &&
|
|
2257
|
-
"'values()' can only be used on observable objects, arrays and maps");
|
|
2329
|
+
"'values()' can only be used on observable objects, arrays, sets and maps");
|
|
2258
2330
|
}
|
|
2259
2331
|
function entries$$1(obj) {
|
|
2260
2332
|
if (isObservableObject$$1(obj)) {
|
|
@@ -2263,6 +2335,9 @@ function entries$$1(obj) {
|
|
|
2263
2335
|
if (isObservableMap$$1(obj)) {
|
|
2264
2336
|
return keys$$1(obj).map(key => [key, obj.get(key)]);
|
|
2265
2337
|
}
|
|
2338
|
+
if (isObservableSet$$1(obj)) {
|
|
2339
|
+
return Array.from(obj.entries());
|
|
2340
|
+
}
|
|
2266
2341
|
if (isObservableArray$$1(obj)) {
|
|
2267
2342
|
return obj.map((key, index) => [index, key]);
|
|
2268
2343
|
}
|
|
@@ -2318,6 +2393,9 @@ function remove$$1(obj, key) {
|
|
|
2318
2393
|
else if (isObservableMap$$1(obj)) {
|
|
2319
2394
|
obj.delete(key);
|
|
2320
2395
|
}
|
|
2396
|
+
else if (isObservableSet$$1(obj)) {
|
|
2397
|
+
obj.delete(key);
|
|
2398
|
+
}
|
|
2321
2399
|
else if (isObservableArray$$1(obj)) {
|
|
2322
2400
|
if (typeof key !== "number")
|
|
2323
2401
|
key = parseInt(key, 10);
|
|
@@ -2338,6 +2416,9 @@ function has$$1(obj, key) {
|
|
|
2338
2416
|
else if (isObservableMap$$1(obj)) {
|
|
2339
2417
|
return obj.has(key);
|
|
2340
2418
|
}
|
|
2419
|
+
else if (isObservableSet$$1(obj)) {
|
|
2420
|
+
return obj.has(key);
|
|
2421
|
+
}
|
|
2341
2422
|
else if (isObservableArray$$1(obj)) {
|
|
2342
2423
|
return key >= 0 && key < obj.length;
|
|
2343
2424
|
}
|
|
@@ -2415,6 +2496,22 @@ function toJSHelper(source, options, __alreadySeen) {
|
|
|
2415
2496
|
res[i] = toAdd[i];
|
|
2416
2497
|
return res;
|
|
2417
2498
|
}
|
|
2499
|
+
if (isObservableSet$$1(source) || Object.getPrototypeOf(source) === Set.prototype) {
|
|
2500
|
+
if (options.exportMapsAsObjects === false) {
|
|
2501
|
+
const res = cache(__alreadySeen, source, new Set(), options);
|
|
2502
|
+
source.forEach(value => {
|
|
2503
|
+
res.add(toJSHelper(value, options, __alreadySeen));
|
|
2504
|
+
});
|
|
2505
|
+
return res;
|
|
2506
|
+
}
|
|
2507
|
+
else {
|
|
2508
|
+
const res = cache(__alreadySeen, source, [], options);
|
|
2509
|
+
source.forEach(value => {
|
|
2510
|
+
res.push(toJSHelper(value, options, __alreadySeen));
|
|
2511
|
+
});
|
|
2512
|
+
return res;
|
|
2513
|
+
}
|
|
2514
|
+
}
|
|
2418
2515
|
if (isObservableMap$$1(source) || Object.getPrototypeOf(source) === Map.prototype) {
|
|
2419
2516
|
if (options.exportMapsAsObjects === false) {
|
|
2420
2517
|
const res = cache(__alreadySeen, source, new Map(), options);
|
|
@@ -2728,7 +2825,7 @@ class ObservableArrayAdministration {
|
|
|
2728
2825
|
return value;
|
|
2729
2826
|
}
|
|
2730
2827
|
dehanceValues(values$$1) {
|
|
2731
|
-
if (this.dehancer !== undefined &&
|
|
2828
|
+
if (this.dehancer !== undefined && values$$1.length > 0)
|
|
2732
2829
|
return values$$1.map(this.dehancer);
|
|
2733
2830
|
return values$$1;
|
|
2734
2831
|
}
|
|
@@ -3129,7 +3226,7 @@ class ObservableMap$$1 {
|
|
|
3129
3226
|
entry.setNewValue(value);
|
|
3130
3227
|
}
|
|
3131
3228
|
else {
|
|
3132
|
-
entry = new ObservableValue$$1(value, referenceEnhancer$$1, `${this.name}.${key}?`, false);
|
|
3229
|
+
entry = new ObservableValue$$1(value, referenceEnhancer$$1, `${this.name}.${stringifyKey(key)}?`, false);
|
|
3133
3230
|
this._hasMap.set(key, entry);
|
|
3134
3231
|
}
|
|
3135
3232
|
return entry;
|
|
@@ -3161,7 +3258,7 @@ class ObservableMap$$1 {
|
|
|
3161
3258
|
_addValue(key, newValue) {
|
|
3162
3259
|
checkIfStateModificationsAreAllowed$$1(this._keysAtom);
|
|
3163
3260
|
transaction$$1(() => {
|
|
3164
|
-
const observable$$1 = new ObservableValue$$1(newValue, this.enhancer, `${this.name}.${key}`, false);
|
|
3261
|
+
const observable$$1 = new ObservableValue$$1(newValue, this.enhancer, `${this.name}.${stringifyKey(key)}`, false);
|
|
3165
3262
|
this._data.set(key, observable$$1);
|
|
3166
3263
|
newValue = observable$$1.value; // value might have been changed
|
|
3167
3264
|
this._updateHasMapEntry(key, true);
|
|
@@ -3245,8 +3342,11 @@ class ObservableMap$$1 {
|
|
|
3245
3342
|
Object.keys(other).forEach(key => this.set(key, other[key]));
|
|
3246
3343
|
else if (Array.isArray(other))
|
|
3247
3344
|
other.forEach(([key, value]) => this.set(key, value));
|
|
3248
|
-
else if (isES6Map$$1(other))
|
|
3345
|
+
else if (isES6Map$$1(other)) {
|
|
3346
|
+
if (other.constructor !== Map)
|
|
3347
|
+
fail$$1("Cannot initialize from classes that inherit from Map: " + other.constructor.name); // prettier-ignore
|
|
3249
3348
|
other.forEach((value, key) => this.set(key, value));
|
|
3349
|
+
}
|
|
3250
3350
|
else if (other !== null && other !== undefined)
|
|
3251
3351
|
fail$$1("Cannot initialize map from " + other);
|
|
3252
3352
|
});
|
|
@@ -3285,7 +3385,8 @@ class ObservableMap$$1 {
|
|
|
3285
3385
|
toPOJO() {
|
|
3286
3386
|
const res = {};
|
|
3287
3387
|
for (const [key, value] of this) {
|
|
3288
|
-
|
|
3388
|
+
// We lie about symbol key types due to https://github.com/Microsoft/TypeScript/issues/1863
|
|
3389
|
+
res[typeof key === "symbol" ? key : stringifyKey(key)] = value;
|
|
3289
3390
|
}
|
|
3290
3391
|
return res;
|
|
3291
3392
|
}
|
|
@@ -3304,7 +3405,7 @@ class ObservableMap$$1 {
|
|
|
3304
3405
|
return (this.name +
|
|
3305
3406
|
"[{ " +
|
|
3306
3407
|
Array.from(this.keys())
|
|
3307
|
-
.map(key => `${key}: ${"" + this.get(key)}`)
|
|
3408
|
+
.map(key => `${stringifyKey(key)}: ${"" + this.get(key)}`)
|
|
3308
3409
|
.join(", ") +
|
|
3309
3410
|
" }]");
|
|
3310
3411
|
}
|
|
@@ -3322,8 +3423,198 @@ class ObservableMap$$1 {
|
|
|
3322
3423
|
return registerInterceptor$$1(this, handler);
|
|
3323
3424
|
}
|
|
3324
3425
|
}
|
|
3426
|
+
function stringifyKey(key) {
|
|
3427
|
+
if (key && key.toString)
|
|
3428
|
+
return key.toString();
|
|
3429
|
+
else
|
|
3430
|
+
return new String(key).toString();
|
|
3431
|
+
}
|
|
3325
3432
|
/* 'var' fixes small-build issue */
|
|
3326
|
-
|
|
3433
|
+
const isObservableMap$$1 = createInstanceofPredicate$$1("ObservableMap", ObservableMap$$1);
|
|
3434
|
+
|
|
3435
|
+
var _a$1;
|
|
3436
|
+
const ObservableSetMarker = {};
|
|
3437
|
+
class ObservableSet$$1 {
|
|
3438
|
+
constructor(initialData, enhancer = deepEnhancer$$1, name = "ObservableSet@" + getNextId$$1()) {
|
|
3439
|
+
this.name = name;
|
|
3440
|
+
this[_a$1] = ObservableSetMarker;
|
|
3441
|
+
this._data = new Set();
|
|
3442
|
+
this._atom = createAtom$$1(this.name);
|
|
3443
|
+
this[Symbol.toStringTag] = "Set";
|
|
3444
|
+
if (typeof Set !== "function") {
|
|
3445
|
+
throw new Error("mobx.set requires Set polyfill for the current browser. Check babel-polyfill or core-js/es6/set.js");
|
|
3446
|
+
}
|
|
3447
|
+
this.enhancer = (newV, oldV) => enhancer(newV, oldV, name);
|
|
3448
|
+
if (initialData) {
|
|
3449
|
+
this.replace(initialData);
|
|
3450
|
+
}
|
|
3451
|
+
}
|
|
3452
|
+
dehanceValue(value) {
|
|
3453
|
+
if (this.dehancer !== undefined) {
|
|
3454
|
+
return this.dehancer(value);
|
|
3455
|
+
}
|
|
3456
|
+
return value;
|
|
3457
|
+
}
|
|
3458
|
+
clear() {
|
|
3459
|
+
transaction$$1(() => {
|
|
3460
|
+
untracked$$1(() => {
|
|
3461
|
+
for (const value of this._data.values())
|
|
3462
|
+
this.delete(value);
|
|
3463
|
+
});
|
|
3464
|
+
});
|
|
3465
|
+
}
|
|
3466
|
+
forEach(callbackFn, thisArg) {
|
|
3467
|
+
for (const value of this) {
|
|
3468
|
+
callbackFn.call(thisArg, value, value, this);
|
|
3469
|
+
}
|
|
3470
|
+
}
|
|
3471
|
+
get size() {
|
|
3472
|
+
this._atom.reportObserved();
|
|
3473
|
+
return this._data.size;
|
|
3474
|
+
}
|
|
3475
|
+
add(value) {
|
|
3476
|
+
checkIfStateModificationsAreAllowed$$1(this._atom);
|
|
3477
|
+
if (hasInterceptors$$1(this)) {
|
|
3478
|
+
const change = interceptChange$$1(this, {
|
|
3479
|
+
type: "add",
|
|
3480
|
+
object: this,
|
|
3481
|
+
newValue: value
|
|
3482
|
+
});
|
|
3483
|
+
if (!change)
|
|
3484
|
+
return this;
|
|
3485
|
+
// TODO: ideally, value = change.value would be done here, so that values can be
|
|
3486
|
+
// changed by interceptor. Same applies for other Set and Map api's.
|
|
3487
|
+
}
|
|
3488
|
+
if (!this.has(value)) {
|
|
3489
|
+
transaction$$1(() => {
|
|
3490
|
+
this._data.add(this.enhancer(value, undefined));
|
|
3491
|
+
this._atom.reportChanged();
|
|
3492
|
+
});
|
|
3493
|
+
const notifySpy = isSpyEnabled$$1();
|
|
3494
|
+
const notify = hasListeners$$1(this);
|
|
3495
|
+
const change = notify || notifySpy
|
|
3496
|
+
? {
|
|
3497
|
+
type: "add",
|
|
3498
|
+
object: this,
|
|
3499
|
+
newValue: value
|
|
3500
|
+
}
|
|
3501
|
+
: null;
|
|
3502
|
+
if (notifySpy && process.env.NODE_ENV !== "production")
|
|
3503
|
+
spyReportStart$$1(change);
|
|
3504
|
+
if (notify)
|
|
3505
|
+
notifyListeners$$1(this, change);
|
|
3506
|
+
if (notifySpy && process.env.NODE_ENV !== "production")
|
|
3507
|
+
spyReportEnd$$1();
|
|
3508
|
+
}
|
|
3509
|
+
return this;
|
|
3510
|
+
}
|
|
3511
|
+
delete(value) {
|
|
3512
|
+
if (hasInterceptors$$1(this)) {
|
|
3513
|
+
const change = interceptChange$$1(this, {
|
|
3514
|
+
type: "delete",
|
|
3515
|
+
object: this,
|
|
3516
|
+
oldValue: value
|
|
3517
|
+
});
|
|
3518
|
+
if (!change)
|
|
3519
|
+
return false;
|
|
3520
|
+
}
|
|
3521
|
+
if (this.has(value)) {
|
|
3522
|
+
const notifySpy = isSpyEnabled$$1();
|
|
3523
|
+
const notify = hasListeners$$1(this);
|
|
3524
|
+
const change = notify || notifySpy
|
|
3525
|
+
? {
|
|
3526
|
+
type: "delete",
|
|
3527
|
+
object: this,
|
|
3528
|
+
oldValue: value
|
|
3529
|
+
}
|
|
3530
|
+
: null;
|
|
3531
|
+
if (notifySpy && process.env.NODE_ENV !== "production")
|
|
3532
|
+
spyReportStart$$1(Object.assign({}, change, { name: this.name }));
|
|
3533
|
+
transaction$$1(() => {
|
|
3534
|
+
this._atom.reportChanged();
|
|
3535
|
+
this._data.delete(value);
|
|
3536
|
+
});
|
|
3537
|
+
if (notify)
|
|
3538
|
+
notifyListeners$$1(this, change);
|
|
3539
|
+
if (notifySpy && process.env.NODE_ENV !== "production")
|
|
3540
|
+
spyReportEnd$$1();
|
|
3541
|
+
return true;
|
|
3542
|
+
}
|
|
3543
|
+
return false;
|
|
3544
|
+
}
|
|
3545
|
+
has(value) {
|
|
3546
|
+
this._atom.reportObserved();
|
|
3547
|
+
return this._data.has(this.dehanceValue(value));
|
|
3548
|
+
}
|
|
3549
|
+
entries() {
|
|
3550
|
+
let nextIndex = 0;
|
|
3551
|
+
const keys$$1 = Array.from(this.keys());
|
|
3552
|
+
const values$$1 = Array.from(this.values());
|
|
3553
|
+
return makeIterable({
|
|
3554
|
+
next() {
|
|
3555
|
+
const index = nextIndex;
|
|
3556
|
+
nextIndex += 1;
|
|
3557
|
+
return index < values$$1.length
|
|
3558
|
+
? { value: [keys$$1[index], values$$1[index]], done: false }
|
|
3559
|
+
: { done: true };
|
|
3560
|
+
}
|
|
3561
|
+
});
|
|
3562
|
+
}
|
|
3563
|
+
keys() {
|
|
3564
|
+
return this.values();
|
|
3565
|
+
}
|
|
3566
|
+
values() {
|
|
3567
|
+
this._atom.reportObserved();
|
|
3568
|
+
const self = this;
|
|
3569
|
+
let nextIndex = 0;
|
|
3570
|
+
const observableValues = Array.from(this._data.values());
|
|
3571
|
+
return makeIterable({
|
|
3572
|
+
next() {
|
|
3573
|
+
return nextIndex < observableValues.length
|
|
3574
|
+
? { value: self.dehanceValue(observableValues[nextIndex++]), done: false }
|
|
3575
|
+
: { done: true };
|
|
3576
|
+
}
|
|
3577
|
+
});
|
|
3578
|
+
}
|
|
3579
|
+
replace(other) {
|
|
3580
|
+
if (isObservableSet$$1(other)) {
|
|
3581
|
+
other = other.toJS();
|
|
3582
|
+
}
|
|
3583
|
+
transaction$$1(() => {
|
|
3584
|
+
if (Array.isArray(other)) {
|
|
3585
|
+
this.clear();
|
|
3586
|
+
other.forEach(value => this.add(value));
|
|
3587
|
+
}
|
|
3588
|
+
else if (isES6Set$$1(other)) {
|
|
3589
|
+
this.clear();
|
|
3590
|
+
other.forEach(value => this.add(value));
|
|
3591
|
+
}
|
|
3592
|
+
else if (other !== null && other !== undefined) {
|
|
3593
|
+
fail$$1("Cannot initialize set from " + other);
|
|
3594
|
+
}
|
|
3595
|
+
});
|
|
3596
|
+
return this;
|
|
3597
|
+
}
|
|
3598
|
+
observe(listener, fireImmediately) {
|
|
3599
|
+
// TODO 'fireImmediately' can be true?
|
|
3600
|
+
process.env.NODE_ENV !== "production" &&
|
|
3601
|
+
invariant$$1(fireImmediately !== true, "`observe` doesn't support fireImmediately=true in combination with sets.");
|
|
3602
|
+
return registerListener$$1(this, listener);
|
|
3603
|
+
}
|
|
3604
|
+
intercept(handler) {
|
|
3605
|
+
return registerInterceptor$$1(this, handler);
|
|
3606
|
+
}
|
|
3607
|
+
toJS() {
|
|
3608
|
+
return new Set(this);
|
|
3609
|
+
}
|
|
3610
|
+
toString() {
|
|
3611
|
+
return this.name + "[ " + Array.from(this).join(", ") + " ]";
|
|
3612
|
+
}
|
|
3613
|
+
[(_a$1 = $mobx$$1, Symbol.iterator)]() {
|
|
3614
|
+
return this.values();
|
|
3615
|
+
}
|
|
3616
|
+
}
|
|
3617
|
+
const isObservableSet$$1 = createInstanceofPredicate$$1("ObservableSet", ObservableSet$$1);
|
|
3327
3618
|
|
|
3328
3619
|
class ObservableObjectAdministration$$1 {
|
|
3329
3620
|
constructor(target, values$$1 = new Map(), name, defaultEnhancer) {
|
|
@@ -3579,7 +3870,7 @@ function getAdministrationForComputedPropOwner(owner) {
|
|
|
3579
3870
|
function generateComputedPropConfig$$1(propName) {
|
|
3580
3871
|
return (computedPropertyConfigs[propName] ||
|
|
3581
3872
|
(computedPropertyConfigs[propName] = {
|
|
3582
|
-
configurable:
|
|
3873
|
+
configurable: false,
|
|
3583
3874
|
enumerable: false,
|
|
3584
3875
|
get() {
|
|
3585
3876
|
return getAdministrationForComputedPropOwner(this).read(propName);
|
|
@@ -3607,6 +3898,9 @@ function getAtom$$1(thing, property) {
|
|
|
3607
3898
|
"It is not possible to get index atoms from arrays");
|
|
3608
3899
|
return thing[$mobx$$1].atom;
|
|
3609
3900
|
}
|
|
3901
|
+
if (isObservableSet$$1(thing)) {
|
|
3902
|
+
return thing[$mobx$$1];
|
|
3903
|
+
}
|
|
3610
3904
|
if (isObservableMap$$1(thing)) {
|
|
3611
3905
|
const anyThing = thing;
|
|
3612
3906
|
if (property === undefined)
|
|
@@ -3649,7 +3943,7 @@ function getAdministration$$1(thing, property) {
|
|
|
3649
3943
|
return getAdministration$$1(getAtom$$1(thing, property));
|
|
3650
3944
|
if (isAtom$$1(thing) || isComputedValue$$1(thing) || isReaction$$1(thing))
|
|
3651
3945
|
return thing;
|
|
3652
|
-
if (isObservableMap$$1(thing))
|
|
3946
|
+
if (isObservableMap$$1(thing) || isObservableSet$$1(thing))
|
|
3653
3947
|
return thing;
|
|
3654
3948
|
// Initializers run lazily when transpiling to babel, so make sure they are run...
|
|
3655
3949
|
initializeInstance$$1(thing);
|
|
@@ -3661,7 +3955,7 @@ function getDebugName$$1(thing, property) {
|
|
|
3661
3955
|
let named;
|
|
3662
3956
|
if (property !== undefined)
|
|
3663
3957
|
named = getAtom$$1(thing, property);
|
|
3664
|
-
else if (isObservableObject$$1(thing) || isObservableMap$$1(thing))
|
|
3958
|
+
else if (isObservableObject$$1(thing) || isObservableMap$$1(thing) || isObservableSet$$1(thing))
|
|
3665
3959
|
named = getAdministration$$1(thing);
|
|
3666
3960
|
else
|
|
3667
3961
|
named = getAtom$$1(thing); // valid for arrays as well
|
|
@@ -3686,7 +3980,7 @@ function eq(a, b, aStack, bStack) {
|
|
|
3686
3980
|
if (a !== a)
|
|
3687
3981
|
return b !== b;
|
|
3688
3982
|
// Exhaust primitive checks
|
|
3689
|
-
|
|
3983
|
+
const type = typeof a;
|
|
3690
3984
|
if (type !== "function" && type !== "object" && typeof b != "object")
|
|
3691
3985
|
return false;
|
|
3692
3986
|
return deepEq(a, b, aStack, bStack);
|
|
@@ -3697,7 +3991,7 @@ function deepEq(a, b, aStack, bStack) {
|
|
|
3697
3991
|
a = unwrap(a);
|
|
3698
3992
|
b = unwrap(b);
|
|
3699
3993
|
// Compare `[[Class]]` names.
|
|
3700
|
-
|
|
3994
|
+
const className = toString.call(a);
|
|
3701
3995
|
if (className !== toString.call(b))
|
|
3702
3996
|
return false;
|
|
3703
3997
|
switch (className) {
|
|
@@ -3724,13 +4018,13 @@ function deepEq(a, b, aStack, bStack) {
|
|
|
3724
4018
|
case "[object Symbol]":
|
|
3725
4019
|
return (typeof Symbol !== "undefined" && Symbol.valueOf.call(a) === Symbol.valueOf.call(b));
|
|
3726
4020
|
}
|
|
3727
|
-
|
|
4021
|
+
const areArrays = className === "[object Array]";
|
|
3728
4022
|
if (!areArrays) {
|
|
3729
4023
|
if (typeof a != "object" || typeof b != "object")
|
|
3730
4024
|
return false;
|
|
3731
4025
|
// Objects with different constructors are not equivalent, but `Object`s or `Array`s
|
|
3732
4026
|
// from different frames are.
|
|
3733
|
-
|
|
4027
|
+
const aCtor = a.constructor, bCtor = b.constructor;
|
|
3734
4028
|
if (aCtor !== bCtor &&
|
|
3735
4029
|
!(typeof aCtor === "function" &&
|
|
3736
4030
|
aCtor instanceof aCtor &&
|
|
@@ -3746,7 +4040,7 @@ function deepEq(a, b, aStack, bStack) {
|
|
|
3746
4040
|
// It's done here since we only need them for objects and arrays comparison.
|
|
3747
4041
|
aStack = aStack || [];
|
|
3748
4042
|
bStack = bStack || [];
|
|
3749
|
-
|
|
4043
|
+
let length = aStack.length;
|
|
3750
4044
|
while (length--) {
|
|
3751
4045
|
// Linear search. Performance is inversely proportional to the number of
|
|
3752
4046
|
// unique nested structures.
|
|
@@ -3770,7 +4064,8 @@ function deepEq(a, b, aStack, bStack) {
|
|
|
3770
4064
|
}
|
|
3771
4065
|
else {
|
|
3772
4066
|
// Deep compare objects.
|
|
3773
|
-
|
|
4067
|
+
const keys$$1 = Object.keys(a);
|
|
4068
|
+
let key;
|
|
3774
4069
|
length = keys$$1.length;
|
|
3775
4070
|
// Ensure that both objects contain the same number of properties before comparing deep equality.
|
|
3776
4071
|
if (Object.keys(b).length !== length)
|
|
@@ -3792,6 +4087,8 @@ function unwrap(a) {
|
|
|
3792
4087
|
return a.slice();
|
|
3793
4088
|
if (isES6Map$$1(a) || isObservableMap$$1(a))
|
|
3794
4089
|
return Array.from(a.entries());
|
|
4090
|
+
if (isES6Set$$1(a) || isObservableSet$$1(a))
|
|
4091
|
+
return Array.from(a.entries());
|
|
3795
4092
|
return a;
|
|
3796
4093
|
}
|
|
3797
4094
|
function has$1(a, key) {
|
|
@@ -3832,7 +4129,7 @@ but at least in this file we can magically reorder the imports with trial and er
|
|
|
3832
4129
|
*
|
|
3833
4130
|
*/
|
|
3834
4131
|
if (typeof Proxy === "undefined" || typeof Symbol === "undefined") {
|
|
3835
|
-
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.");
|
|
4132
|
+
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.");
|
|
3836
4133
|
}
|
|
3837
4134
|
try {
|
|
3838
4135
|
// define process.env if needed
|
|
@@ -3841,7 +4138,7 @@ try {
|
|
|
3841
4138
|
process.env.NODE_ENV;
|
|
3842
4139
|
}
|
|
3843
4140
|
catch (e) {
|
|
3844
|
-
|
|
4141
|
+
const g = typeof window !== "undefined" ? window : global;
|
|
3845
4142
|
if (typeof process === "undefined")
|
|
3846
4143
|
g.process = {};
|
|
3847
4144
|
g.process.env = {};
|
|
@@ -3850,7 +4147,8 @@ catch (e) {
|
|
|
3850
4147
|
(() => {
|
|
3851
4148
|
function testCodeMinification() { }
|
|
3852
4149
|
if (testCodeMinification.name !== "testCodeMinification" &&
|
|
3853
|
-
process.env.NODE_ENV !== "production"
|
|
4150
|
+
process.env.NODE_ENV !== "production" &&
|
|
4151
|
+
process.env.IGNORE_MOBX_MINIFY_WARNING !== "true") {
|
|
3854
4152
|
console.warn(
|
|
3855
4153
|
// Template literal(backtick) is used for fix issue with rollup-plugin-commonjs https://github.com/rollup/rollup-plugin-commonjs/issues/344
|
|
3856
4154
|
`[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`);
|
|
@@ -3868,4 +4166,4 @@ if (typeof __MOBX_DEVTOOLS_GLOBAL_HOOK__ === "object") {
|
|
|
3868
4166
|
});
|
|
3869
4167
|
}
|
|
3870
4168
|
|
|
3871
|
-
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 };
|
|
4169
|
+
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 };
|