mobx 5.5.2 → 5.9.0
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 +42 -0
- package/LICENSE +0 -0
- package/README.md +14 -12
- package/lib/api/actiondecorator.d.ts +12 -1
- package/lib/api/become-observed.d.ts +3 -3
- 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/atom.d.ts +4 -1
- package/lib/core/computedvalue.d.ts +3 -2
- package/lib/core/globalstate.d.ts +6 -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 -59
- package/lib/mobx.js +401 -66
- package/lib/mobx.js.flow +7 -10
- package/lib/mobx.min.js +1 -1
- package/lib/mobx.min.js.map +1 -1
- package/lib/mobx.module.js +400 -67
- package/lib/mobx.umd.js +401 -66
- package/lib/mobx.umd.min.js +1 -1
- package/lib/mobx.umd.min.js.map +1 -1
- package/lib/types/observablearray.d.ts +2 -0
- package/lib/types/observableset.d.ts +49 -0
- package/lib/types/observablevalue.d.ts +4 -4
- package/lib/utils/utils.d.ts +1 -0
- package/package.json +7 -2
package/lib/mobx.umd.js
CHANGED
|
@@ -191,6 +191,9 @@ function isArrayLike$$1(x) {
|
|
|
191
191
|
function isES6Map$$1(thing) {
|
|
192
192
|
return thing instanceof Map;
|
|
193
193
|
}
|
|
194
|
+
function isES6Set$$1(thing) {
|
|
195
|
+
return thing instanceof Set;
|
|
196
|
+
}
|
|
194
197
|
function getMapLikeKeys$$1(map) {
|
|
195
198
|
if (isPlainObject$$1(map))
|
|
196
199
|
return Object.keys(map);
|
|
@@ -223,11 +226,15 @@ var Atom$$1 = /** @class */ (function () {
|
|
|
223
226
|
this.lastAccessedBy = 0;
|
|
224
227
|
this.lowestObserverState = exports.IDerivationState.NOT_TRACKING;
|
|
225
228
|
}
|
|
226
|
-
Atom$$1.prototype.onBecomeUnobserved = function () {
|
|
227
|
-
// noop
|
|
228
|
-
};
|
|
229
229
|
Atom$$1.prototype.onBecomeObserved = function () {
|
|
230
|
-
|
|
230
|
+
if (this.onBecomeObservedListeners) {
|
|
231
|
+
this.onBecomeObservedListeners.forEach(function (listener) { return listener(); });
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
Atom$$1.prototype.onBecomeUnobserved = function () {
|
|
235
|
+
if (this.onBecomeUnobservedListeners) {
|
|
236
|
+
this.onBecomeUnobservedListeners.forEach(function (listener) { return listener(); });
|
|
237
|
+
}
|
|
231
238
|
};
|
|
232
239
|
/**
|
|
233
240
|
* Invoke this method to notify mobx that your atom has been used somehow.
|
|
@@ -254,8 +261,13 @@ function createAtom$$1(name, onBecomeObservedHandler, onBecomeUnobservedHandler)
|
|
|
254
261
|
if (onBecomeObservedHandler === void 0) { onBecomeObservedHandler = noop$$1; }
|
|
255
262
|
if (onBecomeUnobservedHandler === void 0) { onBecomeUnobservedHandler = noop$$1; }
|
|
256
263
|
var atom = new Atom$$1(name);
|
|
257
|
-
|
|
258
|
-
|
|
264
|
+
// default `noop` listener will not initialize the hook Set
|
|
265
|
+
if (onBecomeObservedHandler !== noop$$1) {
|
|
266
|
+
onBecomeObserved$$1(atom, onBecomeObservedHandler);
|
|
267
|
+
}
|
|
268
|
+
if (onBecomeUnobservedHandler !== noop$$1) {
|
|
269
|
+
onBecomeUnobserved$$1(atom, onBecomeUnobservedHandler);
|
|
270
|
+
}
|
|
259
271
|
return atom;
|
|
260
272
|
}
|
|
261
273
|
|
|
@@ -360,12 +372,14 @@ function deepEnhancer$$1(v, _, name) {
|
|
|
360
372
|
return observable$$1.object(v, undefined, { name: name });
|
|
361
373
|
if (isES6Map$$1(v))
|
|
362
374
|
return observable$$1.map(v, { name: name });
|
|
375
|
+
if (isES6Set$$1(v))
|
|
376
|
+
return observable$$1.set(v, { name: name });
|
|
363
377
|
return v;
|
|
364
378
|
}
|
|
365
379
|
function shallowEnhancer$$1(v, _, name) {
|
|
366
380
|
if (v === undefined || v === null)
|
|
367
381
|
return v;
|
|
368
|
-
if (isObservableObject$$1(v) || isObservableArray$$1(v) || isObservableMap$$1(v))
|
|
382
|
+
if (isObservableObject$$1(v) || isObservableArray$$1(v) || isObservableMap$$1(v) || isObservableSet$$1(v))
|
|
369
383
|
return v;
|
|
370
384
|
if (Array.isArray(v))
|
|
371
385
|
return observable$$1.array(v, { name: name, deep: false });
|
|
@@ -373,8 +387,10 @@ function shallowEnhancer$$1(v, _, name) {
|
|
|
373
387
|
return observable$$1.object(v, undefined, { name: name, deep: false });
|
|
374
388
|
if (isES6Map$$1(v))
|
|
375
389
|
return observable$$1.map(v, { name: name, deep: false });
|
|
390
|
+
if (isES6Set$$1(v))
|
|
391
|
+
return observable$$1.set(v, { name: name, deep: false });
|
|
376
392
|
return fail$$1(process.env.NODE_ENV !== "production" &&
|
|
377
|
-
"The shallow modifier / decorator can only used in combination with arrays, objects and
|
|
393
|
+
"The shallow modifier / decorator can only used in combination with arrays, objects, maps and sets");
|
|
378
394
|
}
|
|
379
395
|
function referenceEnhancer$$1(newValue) {
|
|
380
396
|
// never turn into an observable
|
|
@@ -426,7 +442,7 @@ var defaultCreateObservableOptions$$1 = {
|
|
|
426
442
|
};
|
|
427
443
|
Object.freeze(defaultCreateObservableOptions$$1);
|
|
428
444
|
function assertValidOption(key) {
|
|
429
|
-
if (!/^(deep|name|defaultDecorator|proxy)$/.test(key))
|
|
445
|
+
if (!/^(deep|name|equals|defaultDecorator|proxy)$/.test(key))
|
|
430
446
|
fail$$1("invalid option for (extend)observable: " + key);
|
|
431
447
|
}
|
|
432
448
|
function asCreateObservableOptions$$1(thing) {
|
|
@@ -471,7 +487,9 @@ function createObservable(v, arg2, arg3) {
|
|
|
471
487
|
? observable$$1.array(v, arg2)
|
|
472
488
|
: isES6Map$$1(v)
|
|
473
489
|
? observable$$1.map(v, arg2)
|
|
474
|
-
: v
|
|
490
|
+
: isES6Set$$1(v)
|
|
491
|
+
? observable$$1.set(v, arg2)
|
|
492
|
+
: v;
|
|
475
493
|
// this value could be converted to a new observable data structure, return it
|
|
476
494
|
if (res !== v)
|
|
477
495
|
return res;
|
|
@@ -484,7 +502,7 @@ var observableFactories = {
|
|
|
484
502
|
if (arguments.length > 2)
|
|
485
503
|
incorrectlyUsedAsDecorator("box");
|
|
486
504
|
var o = asCreateObservableOptions$$1(options);
|
|
487
|
-
return new ObservableValue$$1(value, getEnhancerFromOptions(o), o.name);
|
|
505
|
+
return new ObservableValue$$1(value, getEnhancerFromOptions(o), o.name, true, o.equals);
|
|
488
506
|
},
|
|
489
507
|
array: function (initialValues, options) {
|
|
490
508
|
if (arguments.length > 2)
|
|
@@ -498,6 +516,12 @@ var observableFactories = {
|
|
|
498
516
|
var o = asCreateObservableOptions$$1(options);
|
|
499
517
|
return new ObservableMap$$1(initialValues, getEnhancerFromOptions(o), o.name);
|
|
500
518
|
},
|
|
519
|
+
set: function (initialValues, options) {
|
|
520
|
+
if (arguments.length > 2)
|
|
521
|
+
incorrectlyUsedAsDecorator("set");
|
|
522
|
+
var o = asCreateObservableOptions$$1(options);
|
|
523
|
+
return new ObservableSet$$1(initialValues, getEnhancerFromOptions(o), o.name);
|
|
524
|
+
},
|
|
501
525
|
object: function (props, decorators, options) {
|
|
502
526
|
if (typeof arguments[1] === "string")
|
|
503
527
|
incorrectlyUsedAsDecorator("object");
|
|
@@ -531,8 +555,9 @@ var computedDecorator$$1 = createPropDecorator$$1(false, function (instance, pro
|
|
|
531
555
|
var get$$1 = descriptor.get, set$$1 = descriptor.set; // initialValue is the descriptor for get / set props
|
|
532
556
|
// Optimization: faster on decorator target or instance? Assuming target
|
|
533
557
|
// Optimization: find out if declaring on instance isn't just faster. (also makes the property descriptor simpler). But, more memory usage..
|
|
558
|
+
// Forcing instance now, fixes hot reloadig issues on React Native:
|
|
534
559
|
var options = decoratorArgs[0] || {};
|
|
535
|
-
asObservableObject$$1(instance).addComputedProp(
|
|
560
|
+
asObservableObject$$1(instance).addComputedProp(instance, propertyName, __assign({ get: get$$1,
|
|
536
561
|
set: set$$1, context: instance }, options));
|
|
537
562
|
});
|
|
538
563
|
var computedStructDecorator = computedDecorator$$1({ equals: comparer$$1.structural });
|
|
@@ -576,11 +601,21 @@ function createAction$$1(actionName, fn) {
|
|
|
576
601
|
}
|
|
577
602
|
function executeAction$$1(actionName, fn, scope, args) {
|
|
578
603
|
var runInfo = startAction(actionName, fn, scope, args);
|
|
604
|
+
var shouldSupressReactionError = true;
|
|
579
605
|
try {
|
|
580
|
-
|
|
606
|
+
var res = fn.apply(scope, args);
|
|
607
|
+
shouldSupressReactionError = false;
|
|
608
|
+
return res;
|
|
581
609
|
}
|
|
582
610
|
finally {
|
|
583
|
-
|
|
611
|
+
if (shouldSupressReactionError) {
|
|
612
|
+
globalState$$1.suppressReactionErrors = shouldSupressReactionError;
|
|
613
|
+
endAction(runInfo);
|
|
614
|
+
globalState$$1.suppressReactionErrors = false;
|
|
615
|
+
}
|
|
616
|
+
else {
|
|
617
|
+
endAction(runInfo);
|
|
618
|
+
}
|
|
584
619
|
}
|
|
585
620
|
}
|
|
586
621
|
function startAction(actionName, fn, scope, args) {
|
|
@@ -649,14 +684,16 @@ function allowStateChangesInsideComputed$$1(func) {
|
|
|
649
684
|
return res;
|
|
650
685
|
}
|
|
651
686
|
|
|
652
|
-
var UNCHANGED$$1 = {};
|
|
653
687
|
var ObservableValue$$1 = /** @class */ (function (_super) {
|
|
654
688
|
__extends(ObservableValue$$1, _super);
|
|
655
|
-
function ObservableValue$$1(value, enhancer, name, notifySpy) {
|
|
689
|
+
function ObservableValue$$1(value, enhancer, name, notifySpy, equals) {
|
|
656
690
|
if (name === void 0) { name = "ObservableValue@" + getNextId$$1(); }
|
|
657
691
|
if (notifySpy === void 0) { notifySpy = true; }
|
|
692
|
+
if (equals === void 0) { equals = comparer$$1.default; }
|
|
658
693
|
var _this = _super.call(this, name) || this;
|
|
659
694
|
_this.enhancer = enhancer;
|
|
695
|
+
_this.name = name;
|
|
696
|
+
_this.equals = equals;
|
|
660
697
|
_this.hasUnreportedChange = false;
|
|
661
698
|
_this.value = enhancer(value, undefined, name);
|
|
662
699
|
if (notifySpy && isSpyEnabled$$1() && process.env.NODE_ENV !== "production") {
|
|
@@ -673,7 +710,7 @@ var ObservableValue$$1 = /** @class */ (function (_super) {
|
|
|
673
710
|
ObservableValue$$1.prototype.set = function (newValue) {
|
|
674
711
|
var oldValue = this.value;
|
|
675
712
|
newValue = this.prepareNewValue(newValue);
|
|
676
|
-
if (newValue !==
|
|
713
|
+
if (newValue !== globalState$$1.UNCHANGED) {
|
|
677
714
|
var notifySpy = isSpyEnabled$$1();
|
|
678
715
|
if (notifySpy && process.env.NODE_ENV !== "production") {
|
|
679
716
|
spyReportStart$$1({
|
|
@@ -697,12 +734,12 @@ var ObservableValue$$1 = /** @class */ (function (_super) {
|
|
|
697
734
|
newValue: newValue
|
|
698
735
|
});
|
|
699
736
|
if (!change)
|
|
700
|
-
return
|
|
737
|
+
return globalState$$1.UNCHANGED;
|
|
701
738
|
newValue = change.newValue;
|
|
702
739
|
}
|
|
703
740
|
// apply modifier
|
|
704
741
|
newValue = this.enhancer(newValue, this.value, this.name);
|
|
705
|
-
return this.value
|
|
742
|
+
return this.equals(this.value, newValue) ? globalState$$1.UNCHANGED : newValue;
|
|
706
743
|
};
|
|
707
744
|
ObservableValue$$1.prototype.setNewValue = function (newValue) {
|
|
708
745
|
var oldValue = this.value;
|
|
@@ -799,7 +836,6 @@ var ComputedValue$$1 = /** @class */ (function () {
|
|
|
799
836
|
this.isComputing = false; // to check for cycles
|
|
800
837
|
this.isRunningSetter = false;
|
|
801
838
|
this.isTracing = TraceMode$$1.NONE;
|
|
802
|
-
this.firstGet = true;
|
|
803
839
|
if (process.env.NODE_ENV !== "production" && !options.get)
|
|
804
840
|
throw "[mobx] missing option for computed: get";
|
|
805
841
|
this.derivation = options.get;
|
|
@@ -818,21 +854,24 @@ var ComputedValue$$1 = /** @class */ (function () {
|
|
|
818
854
|
ComputedValue$$1.prototype.onBecomeStale = function () {
|
|
819
855
|
propagateMaybeChanged$$1(this);
|
|
820
856
|
};
|
|
821
|
-
ComputedValue$$1.prototype.
|
|
822
|
-
|
|
857
|
+
ComputedValue$$1.prototype.onBecomeObserved = function () {
|
|
858
|
+
if (this.onBecomeObservedListeners) {
|
|
859
|
+
this.onBecomeObservedListeners.forEach(function (listener) { return listener(); });
|
|
860
|
+
}
|
|
861
|
+
};
|
|
862
|
+
ComputedValue$$1.prototype.onBecomeUnobserved = function () {
|
|
863
|
+
if (this.onBecomeUnobservedListeners) {
|
|
864
|
+
this.onBecomeUnobservedListeners.forEach(function (listener) { return listener(); });
|
|
865
|
+
}
|
|
866
|
+
};
|
|
823
867
|
/**
|
|
824
868
|
* Returns the current value of this computed value.
|
|
825
869
|
* Will evaluate its computation first if needed.
|
|
826
870
|
*/
|
|
827
871
|
ComputedValue$$1.prototype.get = function () {
|
|
828
|
-
var _this = this;
|
|
829
|
-
if (this.keepAlive && this.firstGet) {
|
|
830
|
-
this.firstGet = false;
|
|
831
|
-
autorun$$1(function () { return _this.get(); });
|
|
832
|
-
}
|
|
833
872
|
if (this.isComputing)
|
|
834
873
|
fail$$1("Cycle detected in computation " + this.name + ": " + this.derivation);
|
|
835
|
-
if (globalState$$1.inBatch === 0 && this.observers.size === 0) {
|
|
874
|
+
if (globalState$$1.inBatch === 0 && this.observers.size === 0 && !this.keepAlive) {
|
|
836
875
|
if (shouldCompute$$1(this)) {
|
|
837
876
|
this.warnAboutUntrackedRead();
|
|
838
877
|
startBatch$$1(); // See perf test 'computed memoization'
|
|
@@ -918,8 +957,10 @@ var ComputedValue$$1 = /** @class */ (function () {
|
|
|
918
957
|
return res;
|
|
919
958
|
};
|
|
920
959
|
ComputedValue$$1.prototype.suspend = function () {
|
|
921
|
-
|
|
922
|
-
|
|
960
|
+
if (!this.keepAlive) {
|
|
961
|
+
clearObserving$$1(this);
|
|
962
|
+
this.value = undefined; // don't hold on to computed value!
|
|
963
|
+
}
|
|
923
964
|
};
|
|
924
965
|
ComputedValue$$1.prototype.observe = function (listener, fireImmediately) {
|
|
925
966
|
var _this = this;
|
|
@@ -1220,7 +1261,8 @@ var persistentKeys = [
|
|
|
1220
1261
|
"enforceActions",
|
|
1221
1262
|
"computedRequiresReaction",
|
|
1222
1263
|
"disableErrorBoundaries",
|
|
1223
|
-
"runId"
|
|
1264
|
+
"runId",
|
|
1265
|
+
"UNCHANGED"
|
|
1224
1266
|
];
|
|
1225
1267
|
var MobXGlobals$$1 = /** @class */ (function () {
|
|
1226
1268
|
function MobXGlobals$$1() {
|
|
@@ -1233,6 +1275,10 @@ var MobXGlobals$$1 = /** @class */ (function () {
|
|
|
1233
1275
|
* internal state storage of MobX, and can be the same across many different package versions
|
|
1234
1276
|
*/
|
|
1235
1277
|
this.version = 5;
|
|
1278
|
+
/**
|
|
1279
|
+
* globally unique token to signal unchanged
|
|
1280
|
+
*/
|
|
1281
|
+
this.UNCHANGED = {};
|
|
1236
1282
|
/**
|
|
1237
1283
|
* Currently running derivation
|
|
1238
1284
|
*/
|
|
@@ -1295,6 +1341,11 @@ var MobXGlobals$$1 = /** @class */ (function () {
|
|
|
1295
1341
|
* the stack when an exception occurs while debugging.
|
|
1296
1342
|
*/
|
|
1297
1343
|
this.disableErrorBoundaries = false;
|
|
1344
|
+
/*
|
|
1345
|
+
* If true, we are already handling an exception in an action. Any errors in reactions should be supressed, as
|
|
1346
|
+
* they are not the cause, see: https://github.com/mobxjs/mobx/issues/1836
|
|
1347
|
+
*/
|
|
1348
|
+
this.suppressReactionErrors = false;
|
|
1298
1349
|
}
|
|
1299
1350
|
return MobXGlobals$$1;
|
|
1300
1351
|
}());
|
|
@@ -1316,6 +1367,8 @@ var globalState$$1 = (function () {
|
|
|
1316
1367
|
}
|
|
1317
1368
|
else if (global.__mobxGlobals) {
|
|
1318
1369
|
global.__mobxInstanceCount += 1;
|
|
1370
|
+
if (!global.__mobxGlobals.UNCHANGED)
|
|
1371
|
+
global.__mobxGlobals.UNCHANGED = {}; // make merge backward compatible
|
|
1319
1372
|
return global.__mobxGlobals;
|
|
1320
1373
|
}
|
|
1321
1374
|
else {
|
|
@@ -1537,7 +1590,7 @@ function logTraceInfo(derivation, observable$$1) {
|
|
|
1537
1590
|
var lines = [];
|
|
1538
1591
|
printDepTree(getDependencyTree$$1(derivation), lines, 1);
|
|
1539
1592
|
// prettier-ignore
|
|
1540
|
-
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 ")();
|
|
1593
|
+
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 ")();
|
|
1541
1594
|
}
|
|
1542
1595
|
}
|
|
1543
1596
|
function printDepTree(tree, lines, depth) {
|
|
@@ -1646,9 +1699,14 @@ var Reaction$$1 = /** @class */ (function () {
|
|
|
1646
1699
|
}
|
|
1647
1700
|
if (globalState$$1.disableErrorBoundaries)
|
|
1648
1701
|
throw error;
|
|
1649
|
-
var message = "[mobx] Encountered an uncaught exception that was thrown by a reaction or observer component, in: '" + this;
|
|
1650
|
-
|
|
1651
|
-
|
|
1702
|
+
var message = "[mobx] Encountered an uncaught exception that was thrown by a reaction or observer component, in: '" + this + "'";
|
|
1703
|
+
if (globalState$$1.suppressReactionErrors) {
|
|
1704
|
+
console.warn("[mobx] (error in reaction '" + this.name + "' suppressed, fix error of causing action below)"); // prettier-ignore
|
|
1705
|
+
}
|
|
1706
|
+
else {
|
|
1707
|
+
console.error(message, error);
|
|
1708
|
+
/** If debugging brought you here, please, read the above message :-). Tnx! */
|
|
1709
|
+
}
|
|
1652
1710
|
if (isSpyEnabled$$1()) {
|
|
1653
1711
|
spyReport$$1({
|
|
1654
1712
|
type: "error",
|
|
@@ -2005,20 +2063,32 @@ function onBecomeUnobserved$$1(thing, arg2, arg3) {
|
|
|
2005
2063
|
function interceptHook(hook, thing, arg2, arg3) {
|
|
2006
2064
|
var atom = typeof arg2 === "string" ? getAtom$$1(thing, arg2) : getAtom$$1(thing);
|
|
2007
2065
|
var cb = typeof arg2 === "string" ? arg3 : arg2;
|
|
2066
|
+
var listenersKey = hook + "Listeners";
|
|
2067
|
+
if (atom[listenersKey]) {
|
|
2068
|
+
atom[listenersKey].add(cb);
|
|
2069
|
+
}
|
|
2070
|
+
else {
|
|
2071
|
+
atom[listenersKey] = new Set([cb]);
|
|
2072
|
+
}
|
|
2008
2073
|
var orig = atom[hook];
|
|
2009
2074
|
if (typeof orig !== "function")
|
|
2010
2075
|
return fail$$1(process.env.NODE_ENV !== "production" && "Not an atom that can be (un)observed");
|
|
2011
|
-
atom[hook] = function () {
|
|
2012
|
-
orig.call(this);
|
|
2013
|
-
cb.call(this);
|
|
2014
|
-
};
|
|
2015
2076
|
return function () {
|
|
2016
|
-
atom[
|
|
2077
|
+
var hookListeners = atom[listenersKey];
|
|
2078
|
+
if (hookListeners) {
|
|
2079
|
+
hookListeners.delete(cb);
|
|
2080
|
+
if (hookListeners.size === 0) {
|
|
2081
|
+
delete atom[listenersKey];
|
|
2082
|
+
}
|
|
2083
|
+
}
|
|
2017
2084
|
};
|
|
2018
2085
|
}
|
|
2019
2086
|
|
|
2020
2087
|
function configure$$1(options) {
|
|
2021
2088
|
var enforceActions = options.enforceActions, computedRequiresReaction = options.computedRequiresReaction, disableErrorBoundaries = options.disableErrorBoundaries, reactionScheduler = options.reactionScheduler;
|
|
2089
|
+
if (options.isolateGlobalState === true) {
|
|
2090
|
+
isolateGlobalState$$1();
|
|
2091
|
+
}
|
|
2022
2092
|
if (enforceActions !== undefined) {
|
|
2023
2093
|
if (typeof enforceActions === "boolean" || enforceActions === "strict")
|
|
2024
2094
|
deprecated$$1("Deprecated value for 'enforceActions', use 'false' => '\"never\"', 'true' => '\"observed\"', '\"strict\"' => \"'always'\" instead");
|
|
@@ -2045,9 +2115,6 @@ function configure$$1(options) {
|
|
|
2045
2115
|
if (computedRequiresReaction !== undefined) {
|
|
2046
2116
|
globalState$$1.computedRequiresReaction = !!computedRequiresReaction;
|
|
2047
2117
|
}
|
|
2048
|
-
if (options.isolateGlobalState === true) {
|
|
2049
|
-
isolateGlobalState$$1();
|
|
2050
|
-
}
|
|
2051
2118
|
if (disableErrorBoundaries !== undefined) {
|
|
2052
2119
|
if (disableErrorBoundaries === true)
|
|
2053
2120
|
console.warn("WARNING: Debug feature only. MobX will NOT recover from errors when `disableErrorBoundaries` is enabled.");
|
|
@@ -2169,7 +2236,7 @@ function flow$$1(generator) {
|
|
|
2169
2236
|
var gen = action$$1(name + " - runid: " + runId + " - init", generator).apply(ctx, args);
|
|
2170
2237
|
var rejector;
|
|
2171
2238
|
var pendingPromise = undefined;
|
|
2172
|
-
var
|
|
2239
|
+
var promise = new Promise(function (resolve, reject) {
|
|
2173
2240
|
var stepId = 0;
|
|
2174
2241
|
rejector = reject;
|
|
2175
2242
|
function onFulfilled(res) {
|
|
@@ -2207,14 +2274,14 @@ function flow$$1(generator) {
|
|
|
2207
2274
|
}
|
|
2208
2275
|
onFulfilled(undefined); // kick off the process
|
|
2209
2276
|
});
|
|
2210
|
-
|
|
2277
|
+
promise.cancel = action$$1(name + " - runid: " + runId + " - cancel", function () {
|
|
2211
2278
|
try {
|
|
2212
2279
|
if (pendingPromise)
|
|
2213
2280
|
cancelPromise(pendingPromise);
|
|
2214
2281
|
// Finally block can return (or yield) stuff..
|
|
2215
|
-
var
|
|
2282
|
+
var res = gen.return();
|
|
2216
2283
|
// eat anything that promise would do, it's cancelled!
|
|
2217
|
-
var yieldedPromise = Promise.resolve(
|
|
2284
|
+
var yieldedPromise = Promise.resolve(res.value);
|
|
2218
2285
|
yieldedPromise.then(noop$$1, noop$$1);
|
|
2219
2286
|
cancelPromise(yieldedPromise); // maybe it can be cancelled :)
|
|
2220
2287
|
// reject our original promise
|
|
@@ -2224,7 +2291,7 @@ function flow$$1(generator) {
|
|
|
2224
2291
|
rejector(e); // there could be a throwing finally block
|
|
2225
2292
|
}
|
|
2226
2293
|
});
|
|
2227
|
-
return
|
|
2294
|
+
return promise;
|
|
2228
2295
|
};
|
|
2229
2296
|
}
|
|
2230
2297
|
function cancelPromise(promise) {
|
|
@@ -2332,11 +2399,14 @@ function keys$$1(obj) {
|
|
|
2332
2399
|
if (isObservableMap$$1(obj)) {
|
|
2333
2400
|
return Array.from(obj.keys());
|
|
2334
2401
|
}
|
|
2402
|
+
if (isObservableSet$$1(obj)) {
|
|
2403
|
+
return Array.from(obj.keys());
|
|
2404
|
+
}
|
|
2335
2405
|
if (isObservableArray$$1(obj)) {
|
|
2336
2406
|
return obj.map(function (_, index) { return index; });
|
|
2337
2407
|
}
|
|
2338
2408
|
return fail$$1(process.env.NODE_ENV !== "production" &&
|
|
2339
|
-
"'keys()' can only be used on observable objects, arrays and maps");
|
|
2409
|
+
"'keys()' can only be used on observable objects, arrays, sets and maps");
|
|
2340
2410
|
}
|
|
2341
2411
|
function values$$1(obj) {
|
|
2342
2412
|
if (isObservableObject$$1(obj)) {
|
|
@@ -2345,11 +2415,14 @@ function values$$1(obj) {
|
|
|
2345
2415
|
if (isObservableMap$$1(obj)) {
|
|
2346
2416
|
return keys$$1(obj).map(function (key) { return obj.get(key); });
|
|
2347
2417
|
}
|
|
2418
|
+
if (isObservableSet$$1(obj)) {
|
|
2419
|
+
return Array.from(obj.values());
|
|
2420
|
+
}
|
|
2348
2421
|
if (isObservableArray$$1(obj)) {
|
|
2349
2422
|
return obj.slice();
|
|
2350
2423
|
}
|
|
2351
2424
|
return fail$$1(process.env.NODE_ENV !== "production" &&
|
|
2352
|
-
"'values()' can only be used on observable objects, arrays and maps");
|
|
2425
|
+
"'values()' can only be used on observable objects, arrays, sets and maps");
|
|
2353
2426
|
}
|
|
2354
2427
|
function entries$$1(obj) {
|
|
2355
2428
|
if (isObservableObject$$1(obj)) {
|
|
@@ -2358,6 +2431,9 @@ function entries$$1(obj) {
|
|
|
2358
2431
|
if (isObservableMap$$1(obj)) {
|
|
2359
2432
|
return keys$$1(obj).map(function (key) { return [key, obj.get(key)]; });
|
|
2360
2433
|
}
|
|
2434
|
+
if (isObservableSet$$1(obj)) {
|
|
2435
|
+
return Array.from(obj.entries());
|
|
2436
|
+
}
|
|
2361
2437
|
if (isObservableArray$$1(obj)) {
|
|
2362
2438
|
return obj.map(function (key, index) { return [index, key]; });
|
|
2363
2439
|
}
|
|
@@ -2413,6 +2489,9 @@ function remove$$1(obj, key) {
|
|
|
2413
2489
|
else if (isObservableMap$$1(obj)) {
|
|
2414
2490
|
obj.delete(key);
|
|
2415
2491
|
}
|
|
2492
|
+
else if (isObservableSet$$1(obj)) {
|
|
2493
|
+
obj.delete(key);
|
|
2494
|
+
}
|
|
2416
2495
|
else if (isObservableArray$$1(obj)) {
|
|
2417
2496
|
if (typeof key !== "number")
|
|
2418
2497
|
key = parseInt(key, 10);
|
|
@@ -2433,6 +2512,9 @@ function has$$1(obj, key) {
|
|
|
2433
2512
|
else if (isObservableMap$$1(obj)) {
|
|
2434
2513
|
return obj.has(key);
|
|
2435
2514
|
}
|
|
2515
|
+
else if (isObservableSet$$1(obj)) {
|
|
2516
|
+
return obj.has(key);
|
|
2517
|
+
}
|
|
2436
2518
|
else if (isObservableArray$$1(obj)) {
|
|
2437
2519
|
return key >= 0 && key < obj.length;
|
|
2438
2520
|
}
|
|
@@ -2510,20 +2592,36 @@ function toJSHelper(source, options, __alreadySeen) {
|
|
|
2510
2592
|
res_1[i] = toAdd[i];
|
|
2511
2593
|
return res_1;
|
|
2512
2594
|
}
|
|
2595
|
+
if (isObservableSet$$1(source) || Object.getPrototypeOf(source) === Set.prototype) {
|
|
2596
|
+
if (options.exportMapsAsObjects === false) {
|
|
2597
|
+
var res_2 = cache(__alreadySeen, source, new Set(), options);
|
|
2598
|
+
source.forEach(function (value) {
|
|
2599
|
+
res_2.add(toJSHelper(value, options, __alreadySeen));
|
|
2600
|
+
});
|
|
2601
|
+
return res_2;
|
|
2602
|
+
}
|
|
2603
|
+
else {
|
|
2604
|
+
var res_3 = cache(__alreadySeen, source, [], options);
|
|
2605
|
+
source.forEach(function (value) {
|
|
2606
|
+
res_3.push(toJSHelper(value, options, __alreadySeen));
|
|
2607
|
+
});
|
|
2608
|
+
return res_3;
|
|
2609
|
+
}
|
|
2610
|
+
}
|
|
2513
2611
|
if (isObservableMap$$1(source) || Object.getPrototypeOf(source) === Map.prototype) {
|
|
2514
2612
|
if (options.exportMapsAsObjects === false) {
|
|
2515
|
-
var
|
|
2613
|
+
var res_4 = cache(__alreadySeen, source, new Map(), options);
|
|
2516
2614
|
source.forEach(function (value, key) {
|
|
2517
|
-
|
|
2615
|
+
res_4.set(key, toJSHelper(value, options, __alreadySeen));
|
|
2518
2616
|
});
|
|
2519
|
-
return
|
|
2617
|
+
return res_4;
|
|
2520
2618
|
}
|
|
2521
2619
|
else {
|
|
2522
|
-
var
|
|
2620
|
+
var res_5 = cache(__alreadySeen, source, {}, options);
|
|
2523
2621
|
source.forEach(function (value, key) {
|
|
2524
|
-
|
|
2622
|
+
res_5[key] = toJSHelper(value, options, __alreadySeen);
|
|
2525
2623
|
});
|
|
2526
|
-
return
|
|
2624
|
+
return res_5;
|
|
2527
2625
|
}
|
|
2528
2626
|
}
|
|
2529
2627
|
// Fallback to the situation that source is an ObservableObject or a plain object
|
|
@@ -2664,8 +2762,16 @@ var objectProxyTraps = {
|
|
|
2664
2762
|
return target[name];
|
|
2665
2763
|
var adm = getAdm(target);
|
|
2666
2764
|
var observable$$1 = adm.values.get(name);
|
|
2667
|
-
if (observable$$1 instanceof Atom$$1)
|
|
2668
|
-
|
|
2765
|
+
if (observable$$1 instanceof Atom$$1) {
|
|
2766
|
+
var result = observable$$1.get();
|
|
2767
|
+
if (result === undefined) {
|
|
2768
|
+
// This fixes #1796, because deleting a prop that has an
|
|
2769
|
+
// undefined value won't retrigger a observer (no visible effect),
|
|
2770
|
+
// the autorun wouldn't subscribe to future key changes (see also next comment)
|
|
2771
|
+
adm.has(name);
|
|
2772
|
+
}
|
|
2773
|
+
return result;
|
|
2774
|
+
}
|
|
2669
2775
|
// make sure we start listening to future keys
|
|
2670
2776
|
// note that we only do this here for optimization
|
|
2671
2777
|
if (typeof name === "string")
|
|
@@ -2822,7 +2928,7 @@ var ObservableArrayAdministration = /** @class */ (function () {
|
|
|
2822
2928
|
return value;
|
|
2823
2929
|
};
|
|
2824
2930
|
ObservableArrayAdministration.prototype.dehanceValues = function (values$$1) {
|
|
2825
|
-
if (this.dehancer !== undefined &&
|
|
2931
|
+
if (this.dehancer !== undefined && values$$1.length > 0)
|
|
2826
2932
|
return values$$1.map(this.dehancer);
|
|
2827
2933
|
return values$$1;
|
|
2828
2934
|
};
|
|
@@ -3251,7 +3357,7 @@ var ObservableMap$$1 = /** @class */ (function () {
|
|
|
3251
3357
|
ObservableMap$$1.prototype._updateValue = function (key, newValue) {
|
|
3252
3358
|
var observable$$1 = this._data.get(key);
|
|
3253
3359
|
newValue = observable$$1.prepareNewValue(newValue);
|
|
3254
|
-
if (newValue !==
|
|
3360
|
+
if (newValue !== globalState$$1.UNCHANGED) {
|
|
3255
3361
|
var notifySpy = isSpyEnabled$$1();
|
|
3256
3362
|
var notify = hasListeners$$1(this);
|
|
3257
3363
|
var change = notify || notifySpy
|
|
@@ -3376,8 +3482,11 @@ var ObservableMap$$1 = /** @class */ (function () {
|
|
|
3376
3482
|
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
3377
3483
|
return _this.set(key, value);
|
|
3378
3484
|
});
|
|
3379
|
-
else if (isES6Map$$1(other))
|
|
3485
|
+
else if (isES6Map$$1(other)) {
|
|
3486
|
+
if (other.constructor !== Map)
|
|
3487
|
+
return fail$$1("Cannot initialize from classes that inherit from Map: " + other.constructor.name); // prettier-ignore
|
|
3380
3488
|
other.forEach(function (value, key) { return _this.set(key, value); });
|
|
3489
|
+
}
|
|
3381
3490
|
else if (other !== null && other !== undefined)
|
|
3382
3491
|
fail$$1("Cannot initialize map from " + other);
|
|
3383
3492
|
});
|
|
@@ -3487,6 +3596,224 @@ var ObservableMap$$1 = /** @class */ (function () {
|
|
|
3487
3596
|
/* 'var' fixes small-build issue */
|
|
3488
3597
|
var isObservableMap$$1 = createInstanceofPredicate$$1("ObservableMap", ObservableMap$$1);
|
|
3489
3598
|
|
|
3599
|
+
var _a$1;
|
|
3600
|
+
var ObservableSetMarker = {};
|
|
3601
|
+
var ObservableSet$$1 = /** @class */ (function () {
|
|
3602
|
+
function ObservableSet$$1(initialData, enhancer, name) {
|
|
3603
|
+
if (enhancer === void 0) { enhancer = deepEnhancer$$1; }
|
|
3604
|
+
if (name === void 0) { name = "ObservableSet@" + getNextId$$1(); }
|
|
3605
|
+
this.name = name;
|
|
3606
|
+
this[_a$1] = ObservableSetMarker;
|
|
3607
|
+
this._data = new Set();
|
|
3608
|
+
this._atom = createAtom$$1(this.name);
|
|
3609
|
+
this[Symbol.toStringTag] = "Set";
|
|
3610
|
+
if (typeof Set !== "function") {
|
|
3611
|
+
throw new Error("mobx.set requires Set polyfill for the current browser. Check babel-polyfill or core-js/es6/set.js");
|
|
3612
|
+
}
|
|
3613
|
+
this.enhancer = function (newV, oldV) { return enhancer(newV, oldV, name); };
|
|
3614
|
+
if (initialData) {
|
|
3615
|
+
this.replace(initialData);
|
|
3616
|
+
}
|
|
3617
|
+
}
|
|
3618
|
+
ObservableSet$$1.prototype.dehanceValue = function (value) {
|
|
3619
|
+
if (this.dehancer !== undefined) {
|
|
3620
|
+
return this.dehancer(value);
|
|
3621
|
+
}
|
|
3622
|
+
return value;
|
|
3623
|
+
};
|
|
3624
|
+
ObservableSet$$1.prototype.clear = function () {
|
|
3625
|
+
var _this = this;
|
|
3626
|
+
transaction$$1(function () {
|
|
3627
|
+
untracked$$1(function () {
|
|
3628
|
+
var e_1, _a;
|
|
3629
|
+
try {
|
|
3630
|
+
for (var _b = __values(_this._data.values()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
3631
|
+
var value = _c.value;
|
|
3632
|
+
_this.delete(value);
|
|
3633
|
+
}
|
|
3634
|
+
}
|
|
3635
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
3636
|
+
finally {
|
|
3637
|
+
try {
|
|
3638
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
3639
|
+
}
|
|
3640
|
+
finally { if (e_1) throw e_1.error; }
|
|
3641
|
+
}
|
|
3642
|
+
});
|
|
3643
|
+
});
|
|
3644
|
+
};
|
|
3645
|
+
ObservableSet$$1.prototype.forEach = function (callbackFn, thisArg) {
|
|
3646
|
+
var e_2, _a;
|
|
3647
|
+
try {
|
|
3648
|
+
for (var _b = __values(this), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
3649
|
+
var value = _c.value;
|
|
3650
|
+
callbackFn.call(thisArg, value, value, this);
|
|
3651
|
+
}
|
|
3652
|
+
}
|
|
3653
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
3654
|
+
finally {
|
|
3655
|
+
try {
|
|
3656
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
3657
|
+
}
|
|
3658
|
+
finally { if (e_2) throw e_2.error; }
|
|
3659
|
+
}
|
|
3660
|
+
};
|
|
3661
|
+
Object.defineProperty(ObservableSet$$1.prototype, "size", {
|
|
3662
|
+
get: function () {
|
|
3663
|
+
this._atom.reportObserved();
|
|
3664
|
+
return this._data.size;
|
|
3665
|
+
},
|
|
3666
|
+
enumerable: true,
|
|
3667
|
+
configurable: true
|
|
3668
|
+
});
|
|
3669
|
+
ObservableSet$$1.prototype.add = function (value) {
|
|
3670
|
+
var _this = this;
|
|
3671
|
+
checkIfStateModificationsAreAllowed$$1(this._atom);
|
|
3672
|
+
if (hasInterceptors$$1(this)) {
|
|
3673
|
+
var change = interceptChange$$1(this, {
|
|
3674
|
+
type: "add",
|
|
3675
|
+
object: this,
|
|
3676
|
+
newValue: value
|
|
3677
|
+
});
|
|
3678
|
+
if (!change)
|
|
3679
|
+
return this;
|
|
3680
|
+
// TODO: ideally, value = change.value would be done here, so that values can be
|
|
3681
|
+
// changed by interceptor. Same applies for other Set and Map api's.
|
|
3682
|
+
}
|
|
3683
|
+
if (!this.has(value)) {
|
|
3684
|
+
transaction$$1(function () {
|
|
3685
|
+
_this._data.add(_this.enhancer(value, undefined));
|
|
3686
|
+
_this._atom.reportChanged();
|
|
3687
|
+
});
|
|
3688
|
+
var notifySpy = isSpyEnabled$$1();
|
|
3689
|
+
var notify = hasListeners$$1(this);
|
|
3690
|
+
var change = notify || notifySpy
|
|
3691
|
+
? {
|
|
3692
|
+
type: "add",
|
|
3693
|
+
object: this,
|
|
3694
|
+
newValue: value
|
|
3695
|
+
}
|
|
3696
|
+
: null;
|
|
3697
|
+
if (notifySpy && process.env.NODE_ENV !== "production")
|
|
3698
|
+
spyReportStart$$1(change);
|
|
3699
|
+
if (notify)
|
|
3700
|
+
notifyListeners$$1(this, change);
|
|
3701
|
+
if (notifySpy && process.env.NODE_ENV !== "production")
|
|
3702
|
+
spyReportEnd$$1();
|
|
3703
|
+
}
|
|
3704
|
+
return this;
|
|
3705
|
+
};
|
|
3706
|
+
ObservableSet$$1.prototype.delete = function (value) {
|
|
3707
|
+
var _this = this;
|
|
3708
|
+
if (hasInterceptors$$1(this)) {
|
|
3709
|
+
var change = interceptChange$$1(this, {
|
|
3710
|
+
type: "delete",
|
|
3711
|
+
object: this,
|
|
3712
|
+
oldValue: value
|
|
3713
|
+
});
|
|
3714
|
+
if (!change)
|
|
3715
|
+
return false;
|
|
3716
|
+
}
|
|
3717
|
+
if (this.has(value)) {
|
|
3718
|
+
var notifySpy = isSpyEnabled$$1();
|
|
3719
|
+
var notify = hasListeners$$1(this);
|
|
3720
|
+
var change = notify || notifySpy
|
|
3721
|
+
? {
|
|
3722
|
+
type: "delete",
|
|
3723
|
+
object: this,
|
|
3724
|
+
oldValue: value
|
|
3725
|
+
}
|
|
3726
|
+
: null;
|
|
3727
|
+
if (notifySpy && process.env.NODE_ENV !== "production")
|
|
3728
|
+
spyReportStart$$1(__assign({}, change, { name: this.name }));
|
|
3729
|
+
transaction$$1(function () {
|
|
3730
|
+
_this._atom.reportChanged();
|
|
3731
|
+
_this._data.delete(value);
|
|
3732
|
+
});
|
|
3733
|
+
if (notify)
|
|
3734
|
+
notifyListeners$$1(this, change);
|
|
3735
|
+
if (notifySpy && process.env.NODE_ENV !== "production")
|
|
3736
|
+
spyReportEnd$$1();
|
|
3737
|
+
return true;
|
|
3738
|
+
}
|
|
3739
|
+
return false;
|
|
3740
|
+
};
|
|
3741
|
+
ObservableSet$$1.prototype.has = function (value) {
|
|
3742
|
+
this._atom.reportObserved();
|
|
3743
|
+
return this._data.has(this.dehanceValue(value));
|
|
3744
|
+
};
|
|
3745
|
+
ObservableSet$$1.prototype.entries = function () {
|
|
3746
|
+
var nextIndex = 0;
|
|
3747
|
+
var keys$$1 = Array.from(this.keys());
|
|
3748
|
+
var values$$1 = Array.from(this.values());
|
|
3749
|
+
return makeIterable({
|
|
3750
|
+
next: function () {
|
|
3751
|
+
var index = nextIndex;
|
|
3752
|
+
nextIndex += 1;
|
|
3753
|
+
return index < values$$1.length
|
|
3754
|
+
? { value: [keys$$1[index], values$$1[index]], done: false }
|
|
3755
|
+
: { done: true };
|
|
3756
|
+
}
|
|
3757
|
+
});
|
|
3758
|
+
};
|
|
3759
|
+
ObservableSet$$1.prototype.keys = function () {
|
|
3760
|
+
return this.values();
|
|
3761
|
+
};
|
|
3762
|
+
ObservableSet$$1.prototype.values = function () {
|
|
3763
|
+
this._atom.reportObserved();
|
|
3764
|
+
var self = this;
|
|
3765
|
+
var nextIndex = 0;
|
|
3766
|
+
var observableValues = Array.from(this._data.values());
|
|
3767
|
+
return makeIterable({
|
|
3768
|
+
next: function () {
|
|
3769
|
+
return nextIndex < observableValues.length
|
|
3770
|
+
? { value: self.dehanceValue(observableValues[nextIndex++]), done: false }
|
|
3771
|
+
: { done: true };
|
|
3772
|
+
}
|
|
3773
|
+
});
|
|
3774
|
+
};
|
|
3775
|
+
ObservableSet$$1.prototype.replace = function (other) {
|
|
3776
|
+
var _this = this;
|
|
3777
|
+
if (isObservableSet$$1(other)) {
|
|
3778
|
+
other = other.toJS();
|
|
3779
|
+
}
|
|
3780
|
+
transaction$$1(function () {
|
|
3781
|
+
if (Array.isArray(other)) {
|
|
3782
|
+
_this.clear();
|
|
3783
|
+
other.forEach(function (value) { return _this.add(value); });
|
|
3784
|
+
}
|
|
3785
|
+
else if (isES6Set$$1(other)) {
|
|
3786
|
+
_this.clear();
|
|
3787
|
+
other.forEach(function (value) { return _this.add(value); });
|
|
3788
|
+
}
|
|
3789
|
+
else if (other !== null && other !== undefined) {
|
|
3790
|
+
fail$$1("Cannot initialize set from " + other);
|
|
3791
|
+
}
|
|
3792
|
+
});
|
|
3793
|
+
return this;
|
|
3794
|
+
};
|
|
3795
|
+
ObservableSet$$1.prototype.observe = function (listener, fireImmediately) {
|
|
3796
|
+
// TODO 'fireImmediately' can be true?
|
|
3797
|
+
process.env.NODE_ENV !== "production" &&
|
|
3798
|
+
invariant$$1(fireImmediately !== true, "`observe` doesn't support fireImmediately=true in combination with sets.");
|
|
3799
|
+
return registerListener$$1(this, listener);
|
|
3800
|
+
};
|
|
3801
|
+
ObservableSet$$1.prototype.intercept = function (handler) {
|
|
3802
|
+
return registerInterceptor$$1(this, handler);
|
|
3803
|
+
};
|
|
3804
|
+
ObservableSet$$1.prototype.toJS = function () {
|
|
3805
|
+
return new Set(this);
|
|
3806
|
+
};
|
|
3807
|
+
ObservableSet$$1.prototype.toString = function () {
|
|
3808
|
+
return this.name + "[ " + Array.from(this).join(", ") + " ]";
|
|
3809
|
+
};
|
|
3810
|
+
ObservableSet$$1.prototype[(_a$1 = $mobx$$1, Symbol.iterator)] = function () {
|
|
3811
|
+
return this.values();
|
|
3812
|
+
};
|
|
3813
|
+
return ObservableSet$$1;
|
|
3814
|
+
}());
|
|
3815
|
+
var isObservableSet$$1 = createInstanceofPredicate$$1("ObservableSet", ObservableSet$$1);
|
|
3816
|
+
|
|
3490
3817
|
var ObservableObjectAdministration$$1 = /** @class */ (function () {
|
|
3491
3818
|
function ObservableObjectAdministration$$1(target, values$$1, name, defaultEnhancer) {
|
|
3492
3819
|
if (values$$1 === void 0) { values$$1 = new Map(); }
|
|
@@ -3520,7 +3847,7 @@ var ObservableObjectAdministration$$1 = /** @class */ (function () {
|
|
|
3520
3847
|
}
|
|
3521
3848
|
newValue = observable$$1.prepareNewValue(newValue);
|
|
3522
3849
|
// notify spy & observers
|
|
3523
|
-
if (newValue !==
|
|
3850
|
+
if (newValue !== globalState$$1.UNCHANGED) {
|
|
3524
3851
|
var notify = hasListeners$$1(this);
|
|
3525
3852
|
var notifySpy = isSpyEnabled$$1();
|
|
3526
3853
|
var change = notify || notifySpy
|
|
@@ -3758,7 +4085,7 @@ function getAdministrationForComputedPropOwner(owner) {
|
|
|
3758
4085
|
function generateComputedPropConfig$$1(propName) {
|
|
3759
4086
|
return (computedPropertyConfigs[propName] ||
|
|
3760
4087
|
(computedPropertyConfigs[propName] = {
|
|
3761
|
-
configurable:
|
|
4088
|
+
configurable: false,
|
|
3762
4089
|
enumerable: false,
|
|
3763
4090
|
get: function () {
|
|
3764
4091
|
return getAdministrationForComputedPropOwner(this).read(propName);
|
|
@@ -3786,6 +4113,9 @@ function getAtom$$1(thing, property) {
|
|
|
3786
4113
|
"It is not possible to get index atoms from arrays");
|
|
3787
4114
|
return thing[$mobx$$1].atom;
|
|
3788
4115
|
}
|
|
4116
|
+
if (isObservableSet$$1(thing)) {
|
|
4117
|
+
return thing[$mobx$$1];
|
|
4118
|
+
}
|
|
3789
4119
|
if (isObservableMap$$1(thing)) {
|
|
3790
4120
|
var anyThing = thing;
|
|
3791
4121
|
if (property === undefined)
|
|
@@ -3828,7 +4158,7 @@ function getAdministration$$1(thing, property) {
|
|
|
3828
4158
|
return getAdministration$$1(getAtom$$1(thing, property));
|
|
3829
4159
|
if (isAtom$$1(thing) || isComputedValue$$1(thing) || isReaction$$1(thing))
|
|
3830
4160
|
return thing;
|
|
3831
|
-
if (isObservableMap$$1(thing))
|
|
4161
|
+
if (isObservableMap$$1(thing) || isObservableSet$$1(thing))
|
|
3832
4162
|
return thing;
|
|
3833
4163
|
// Initializers run lazily when transpiling to babel, so make sure they are run...
|
|
3834
4164
|
initializeInstance$$1(thing);
|
|
@@ -3840,7 +4170,7 @@ function getDebugName$$1(thing, property) {
|
|
|
3840
4170
|
var named;
|
|
3841
4171
|
if (property !== undefined)
|
|
3842
4172
|
named = getAtom$$1(thing, property);
|
|
3843
|
-
else if (isObservableObject$$1(thing) || isObservableMap$$1(thing))
|
|
4173
|
+
else if (isObservableObject$$1(thing) || isObservableMap$$1(thing) || isObservableSet$$1(thing))
|
|
3844
4174
|
named = getAdministration$$1(thing);
|
|
3845
4175
|
else
|
|
3846
4176
|
named = getAtom$$1(thing); // valid for arrays as well
|
|
@@ -3971,6 +4301,8 @@ function unwrap(a) {
|
|
|
3971
4301
|
return a.slice();
|
|
3972
4302
|
if (isES6Map$$1(a) || isObservableMap$$1(a))
|
|
3973
4303
|
return Array.from(a.entries());
|
|
4304
|
+
if (isES6Set$$1(a) || isObservableSet$$1(a))
|
|
4305
|
+
return Array.from(a.entries());
|
|
3974
4306
|
return a;
|
|
3975
4307
|
}
|
|
3976
4308
|
function has$1(a, key) {
|
|
@@ -4029,7 +4361,8 @@ catch (e) {
|
|
|
4029
4361
|
(function () {
|
|
4030
4362
|
function testCodeMinification() { }
|
|
4031
4363
|
if (testCodeMinification.name !== "testCodeMinification" &&
|
|
4032
|
-
process.env.NODE_ENV !== "production"
|
|
4364
|
+
process.env.NODE_ENV !== "production" &&
|
|
4365
|
+
process.env.IGNORE_MOBX_MINIFY_WARNING !== "true") {
|
|
4033
4366
|
console.warn(
|
|
4034
4367
|
// Template literal(backtick) is used for fix issue with rollup-plugin-commonjs https://github.com/rollup/rollup-plugin-commonjs/issues/344
|
|
4035
4368
|
"[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");
|
|
@@ -4057,6 +4390,8 @@ exports.isBoxedObservable = isObservableValue$$1;
|
|
|
4057
4390
|
exports.isObservableArray = isObservableArray$$1;
|
|
4058
4391
|
exports.ObservableMap = ObservableMap$$1;
|
|
4059
4392
|
exports.isObservableMap = isObservableMap$$1;
|
|
4393
|
+
exports.ObservableSet = ObservableSet$$1;
|
|
4394
|
+
exports.isObservableSet = isObservableSet$$1;
|
|
4060
4395
|
exports.transaction = transaction$$1;
|
|
4061
4396
|
exports.observable = observable$$1;
|
|
4062
4397
|
exports.computed = computed$$1;
|