mobx 6.3.10 → 6.4.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.
Files changed (64) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/README.md +1 -0
  3. package/dist/api/tojs.d.ts +4 -1
  4. package/dist/errors.d.ts +2 -2
  5. package/dist/mobx.cjs.development.js +995 -304
  6. package/dist/mobx.cjs.development.js.map +1 -1
  7. package/dist/mobx.cjs.production.min.js +1 -1
  8. package/dist/mobx.cjs.production.min.js.map +1 -1
  9. package/dist/mobx.esm.development.js +995 -304
  10. package/dist/mobx.esm.development.js.map +1 -1
  11. package/dist/mobx.esm.js +1010 -307
  12. package/dist/mobx.esm.js.map +1 -1
  13. package/dist/mobx.esm.production.min.js +1 -1
  14. package/dist/mobx.esm.production.min.js.map +1 -1
  15. package/dist/mobx.umd.development.js +995 -304
  16. package/dist/mobx.umd.development.js.map +1 -1
  17. package/dist/mobx.umd.production.min.js +1 -1
  18. package/dist/mobx.umd.production.min.js.map +1 -1
  19. package/dist/types/observablemap.d.ts +2 -2
  20. package/dist/utils/utils.d.ts +1 -1
  21. package/package.json +1 -1
  22. package/src/api/action.ts +8 -3
  23. package/src/api/annotation.ts +1 -2
  24. package/src/api/autorun.ts +22 -8
  25. package/src/api/computed.ts +5 -2
  26. package/src/api/configure.ts +6 -2
  27. package/src/api/extendobservable.ts +11 -5
  28. package/src/api/extras.ts +4 -2
  29. package/src/api/flow.ts +11 -4
  30. package/src/api/intercept-read.ts +4 -2
  31. package/src/api/intercept.ts +5 -2
  32. package/src/api/iscomputed.ts +10 -4
  33. package/src/api/isobservable.ts +10 -4
  34. package/src/api/makeObservable.ts +4 -2
  35. package/src/api/object-api.ts +30 -16
  36. package/src/api/observable.ts +23 -9
  37. package/src/api/observe.ts +4 -2
  38. package/src/api/tojs.ts +11 -4
  39. package/src/api/trace.ts +6 -2
  40. package/src/api/when.ts +12 -5
  41. package/src/core/action.ts +8 -3
  42. package/src/core/computedvalue.ts +29 -9
  43. package/src/core/derivation.ts +25 -9
  44. package/src/core/globalstate.ts +18 -7
  45. package/src/core/observable.ts +14 -5
  46. package/src/core/reaction.ts +15 -6
  47. package/src/core/spy.ts +20 -7
  48. package/src/errors.ts +2 -2
  49. package/src/types/actionannotation.ts +2 -2
  50. package/src/types/dynamicobject.ts +10 -4
  51. package/src/types/flowannotation.ts +14 -4
  52. package/src/types/intercept-utils.ts +9 -3
  53. package/src/types/legacyobservablearray.ts +5 -3
  54. package/src/types/listen-utils.ts +6 -2
  55. package/src/types/modifiers.ts +39 -14
  56. package/src/types/observablearray.ts +78 -30
  57. package/src/types/observablemap.ts +65 -26
  58. package/src/types/observableobject.ts +52 -18
  59. package/src/types/observableset.ts +29 -10
  60. package/src/types/observablevalue.ts +13 -5
  61. package/src/types/type-utils.ts +33 -11
  62. package/src/utils/comparer.ts +4 -4
  63. package/src/utils/eq.ts +45 -15
  64. package/src/utils/utils.ts +42 -20
package/dist/mobx.esm.js CHANGED
@@ -23,9 +23,9 @@ var niceErrors = {
23
23
  10: "'has()' can only be used on observable objects, arrays and maps",
24
24
  11: "'get()' can only be used on observable objects, arrays and maps",
25
25
  12: "Invalid annotation",
26
- 13: "Dynamic observable objects cannot be frozen",
26
+ 13: "Dynamic observable objects cannot be frozen. If you're passing observables to 3rd party component/function that calls Object.freeze, pass copy instead: toJS(observable)",
27
27
  14: "Intercept handlers should return nothing or a change object",
28
- 15: "Observable arrays cannot be frozen",
28
+ 15: "Observable arrays cannot be frozen. If you're passing observables to 3rd party component/function that calls Object.freeze, pass copy instead: toJS(observable)",
29
29
  16: "Modification exception: the internal structure of an observable array was changed.",
30
30
  17: function _(index, length) {
31
31
  return "[mobx.array] Index out of bounds, " + index + " is larger than " + length;
@@ -141,7 +141,10 @@ function getNextId() {
141
141
  function once(func) {
142
142
  var invoked = false;
143
143
  return function () {
144
- if (invoked) return;
144
+ if (invoked) {
145
+ return;
146
+ }
147
+
145
148
  invoked = true;
146
149
  return func.apply(this, arguments);
147
150
  };
@@ -166,17 +169,31 @@ function isObject(value) {
166
169
  return value !== null && typeof value === "object";
167
170
  }
168
171
  function isPlainObject(value) {
169
- if (!isObject(value)) return false;
172
+ if (!isObject(value)) {
173
+ return false;
174
+ }
175
+
170
176
  var proto = Object.getPrototypeOf(value);
171
- if (proto == null) return true;
177
+
178
+ if (proto == null) {
179
+ return true;
180
+ }
181
+
172
182
  var protoConstructor = Object.hasOwnProperty.call(proto, "constructor") && proto.constructor;
173
183
  return typeof protoConstructor === "function" && protoConstructor.toString() === plainObjectString;
174
184
  } // https://stackoverflow.com/a/37865170
175
185
 
176
186
  function isGenerator(obj) {
177
187
  var constructor = obj == null ? void 0 : obj.constructor;
178
- if (!constructor) return false;
179
- if ("GeneratorFunction" === constructor.name || "GeneratorFunction" === constructor.displayName) return true;
188
+
189
+ if (!constructor) {
190
+ return false;
191
+ }
192
+
193
+ if ("GeneratorFunction" === constructor.name || "GeneratorFunction" === constructor.displayName) {
194
+ return true;
195
+ }
196
+
180
197
  return false;
181
198
  }
182
199
  function addHiddenProp(object, propName, value) {
@@ -216,9 +233,16 @@ var hasGetOwnPropertySymbols = typeof Object.getOwnPropertySymbols !== "undefine
216
233
  function getPlainObjectKeys(object) {
217
234
  var keys = Object.keys(object); // Not supported in IE, so there are not going to be symbol props anyway...
218
235
 
219
- if (!hasGetOwnPropertySymbols) return keys;
236
+ if (!hasGetOwnPropertySymbols) {
237
+ return keys;
238
+ }
239
+
220
240
  var symbols = Object.getOwnPropertySymbols(object);
221
- if (!symbols.length) return keys;
241
+
242
+ if (!symbols.length) {
243
+ return keys;
244
+ }
245
+
222
246
  return [].concat(keys, symbols.filter(function (s) {
223
247
  return objectPrototype.propertyIsEnumerable.call(object, s);
224
248
  }));
@@ -231,8 +255,14 @@ var ownKeys = typeof Reflect !== "undefined" && Reflect.ownKeys ? Reflect.ownKey
231
255
  /* istanbul ignore next */
232
256
  Object.getOwnPropertyNames;
233
257
  function stringifyKey(key) {
234
- if (typeof key === "string") return key;
235
- if (typeof key === "symbol") return key.toString();
258
+ if (typeof key === "string") {
259
+ return key;
260
+ }
261
+
262
+ if (typeof key === "symbol") {
263
+ return key.toString();
264
+ }
265
+
236
266
  return new String(key).toString();
237
267
  }
238
268
  function toPrimitive(value) {
@@ -520,7 +550,10 @@ function shallowComparer(a, b) {
520
550
  }
521
551
 
522
552
  function defaultComparer(a, b) {
523
- if (Object.is) return Object.is(a, b);
553
+ if (Object.is) {
554
+ return Object.is(a, b);
555
+ }
556
+
524
557
  return a === b ? a !== 0 || 1 / a === 1 / b : a !== a && b !== b;
525
558
  }
526
559
 
@@ -533,20 +566,34 @@ var comparer = {
533
566
 
534
567
  function deepEnhancer(v, _, name) {
535
568
  // it is an observable already, done
536
- if (isObservable(v)) return v; // something that can be converted and mutated?
569
+ if (isObservable(v)) {
570
+ return v;
571
+ } // something that can be converted and mutated?
537
572
 
538
- if (Array.isArray(v)) return observable.array(v, {
539
- name: name
540
- });
541
- if (isPlainObject(v)) return observable.object(v, undefined, {
542
- name: name
543
- });
544
- if (isES6Map(v)) return observable.map(v, {
545
- name: name
546
- });
547
- if (isES6Set(v)) return observable.set(v, {
548
- name: name
549
- });
573
+
574
+ if (Array.isArray(v)) {
575
+ return observable.array(v, {
576
+ name: name
577
+ });
578
+ }
579
+
580
+ if (isPlainObject(v)) {
581
+ return observable.object(v, undefined, {
582
+ name: name
583
+ });
584
+ }
585
+
586
+ if (isES6Map(v)) {
587
+ return observable.map(v, {
588
+ name: name
589
+ });
590
+ }
591
+
592
+ if (isES6Set(v)) {
593
+ return observable.set(v, {
594
+ name: name
595
+ });
596
+ }
550
597
 
551
598
  if (typeof v === "function" && !isAction(v) && !isFlow(v)) {
552
599
  if (isGenerator(v)) {
@@ -559,33 +606,59 @@ function deepEnhancer(v, _, name) {
559
606
  return v;
560
607
  }
561
608
  function shallowEnhancer(v, _, name) {
562
- if (v === undefined || v === null) return v;
563
- if (isObservableObject(v) || isObservableArray(v) || isObservableMap(v) || isObservableSet(v)) return v;
564
- if (Array.isArray(v)) return observable.array(v, {
565
- name: name,
566
- deep: false
567
- });
568
- if (isPlainObject(v)) return observable.object(v, undefined, {
569
- name: name,
570
- deep: false
571
- });
572
- if (isES6Map(v)) return observable.map(v, {
573
- name: name,
574
- deep: false
575
- });
576
- if (isES6Set(v)) return observable.set(v, {
577
- name: name,
578
- deep: false
579
- });
580
- if (process.env.NODE_ENV !== "production") die("The shallow modifier / decorator can only used in combination with arrays, objects, maps and sets");
609
+ if (v === undefined || v === null) {
610
+ return v;
611
+ }
612
+
613
+ if (isObservableObject(v) || isObservableArray(v) || isObservableMap(v) || isObservableSet(v)) {
614
+ return v;
615
+ }
616
+
617
+ if (Array.isArray(v)) {
618
+ return observable.array(v, {
619
+ name: name,
620
+ deep: false
621
+ });
622
+ }
623
+
624
+ if (isPlainObject(v)) {
625
+ return observable.object(v, undefined, {
626
+ name: name,
627
+ deep: false
628
+ });
629
+ }
630
+
631
+ if (isES6Map(v)) {
632
+ return observable.map(v, {
633
+ name: name,
634
+ deep: false
635
+ });
636
+ }
637
+
638
+ if (isES6Set(v)) {
639
+ return observable.set(v, {
640
+ name: name,
641
+ deep: false
642
+ });
643
+ }
644
+
645
+ if (process.env.NODE_ENV !== "production") {
646
+ die("The shallow modifier / decorator can only used in combination with arrays, objects, maps and sets");
647
+ }
581
648
  }
582
649
  function referenceEnhancer(newValue) {
583
650
  // never turn into an observable
584
651
  return newValue;
585
652
  }
586
653
  function refStructEnhancer(v, oldValue) {
587
- if (process.env.NODE_ENV !== "production" && isObservable(v)) die("observable.struct should not be used with observable values");
588
- if (deepEqual(v, oldValue)) return oldValue;
654
+ if (process.env.NODE_ENV !== "production" && isObservable(v)) {
655
+ die("observable.struct should not be used with observable values");
656
+ }
657
+
658
+ if (deepEqual(v, oldValue)) {
659
+ return oldValue;
660
+ }
661
+
589
662
  return v;
590
663
  }
591
664
 
@@ -733,10 +806,12 @@ function make_$2(adm, key, descriptor, source) {
733
806
  // bound - must annotate protos to support super.flow()
734
807
 
735
808
 
736
- if ((_this$options_ = this.options_) != null && _this$options_.bound && !isFlow(adm.target_[key])) {
737
- if (this.extend_(adm, key, descriptor, false) === null) return 0
738
- /* Cancel */
739
- ;
809
+ if ((_this$options_ = this.options_) != null && _this$options_.bound && (!hasProp(adm.target_, key) || !isFlow(adm.target_[key]))) {
810
+ if (this.extend_(adm, key, descriptor, false) === null) {
811
+ return 0
812
+ /* Cancel */
813
+ ;
814
+ }
740
815
  }
741
816
 
742
817
  if (isFlow(descriptor.value)) {
@@ -777,16 +852,23 @@ safeDescriptors) {
777
852
  }
778
853
 
779
854
  assertFlowDescriptor(adm, annotation, key, descriptor);
780
- var value = descriptor.value;
855
+ var value = descriptor.value; // In case of flow.bound, the descriptor can be from already annotated prototype
856
+
857
+ if (!isFlow(value)) {
858
+ value = flow(value);
859
+ }
781
860
 
782
861
  if (bound) {
783
862
  var _adm$proxy_;
784
863
 
785
- value = value.bind((_adm$proxy_ = adm.proxy_) != null ? _adm$proxy_ : adm.target_);
864
+ // We do not keep original function around, so we bind the existing flow
865
+ value = value.bind((_adm$proxy_ = adm.proxy_) != null ? _adm$proxy_ : adm.target_); // This is normally set by `flow`, but `bind` returns new function...
866
+
867
+ value.isMobXFlow = true;
786
868
  }
787
869
 
788
870
  return {
789
- value: flow(value),
871
+ value: value,
790
872
  // Non-configurable for classes
791
873
  // prevents accidental field redefinition in subclass
792
874
  configurable: safeDescriptors ? adm.isPlainObject_ : true,
@@ -1020,17 +1102,35 @@ function createObservable(v, arg2, arg3) {
1020
1102
  } // already observable - ignore
1021
1103
 
1022
1104
 
1023
- if (isObservable(v)) return v; // plain object
1105
+ if (isObservable(v)) {
1106
+ return v;
1107
+ } // plain object
1024
1108
 
1025
- if (isPlainObject(v)) return observable.object(v, arg2, arg3); // Array
1026
1109
 
1027
- if (Array.isArray(v)) return observable.array(v, arg2); // Map
1110
+ if (isPlainObject(v)) {
1111
+ return observable.object(v, arg2, arg3);
1112
+ } // Array
1028
1113
 
1029
- if (isES6Map(v)) return observable.map(v, arg2); // Set
1030
1114
 
1031
- if (isES6Set(v)) return observable.set(v, arg2); // other object - ignore
1115
+ if (Array.isArray(v)) {
1116
+ return observable.array(v, arg2);
1117
+ } // Map
1118
+
1119
+
1120
+ if (isES6Map(v)) {
1121
+ return observable.map(v, arg2);
1122
+ } // Set
1123
+
1124
+
1125
+ if (isES6Set(v)) {
1126
+ return observable.set(v, arg2);
1127
+ } // other object - ignore
1128
+
1129
+
1130
+ if (typeof v === "object" && v !== null) {
1131
+ return v;
1132
+ } // anything else
1032
1133
 
1033
- if (typeof v === "object" && v !== null) return v; // anything else
1034
1134
 
1035
1135
  return observable.box(v, arg2);
1036
1136
  }
@@ -1088,8 +1188,13 @@ var computed = function computed(arg1, arg2) {
1088
1188
 
1089
1189
 
1090
1190
  if (process.env.NODE_ENV !== "production") {
1091
- if (!isFunction(arg1)) die("First argument to `computed` should be an expression.");
1092
- if (isFunction(arg2)) die("A setter as second argument is no longer supported, use `{ set: fn }` option instead");
1191
+ if (!isFunction(arg1)) {
1192
+ die("First argument to `computed` should be an expression.");
1193
+ }
1194
+
1195
+ if (isFunction(arg2)) {
1196
+ die("A setter as second argument is no longer supported, use `{ set: fn }` option instead");
1197
+ }
1093
1198
  }
1094
1199
 
1095
1200
  var opts = isPlainObject(arg2) ? arg2 : {};
@@ -1121,8 +1226,13 @@ function createAction(actionName, fn, autoAction, ref) {
1121
1226
  }
1122
1227
 
1123
1228
  if (process.env.NODE_ENV !== "production") {
1124
- if (!isFunction(fn)) die("`action` can only be invoked on functions");
1125
- if (typeof actionName !== "string" || !actionName) die("actions should have valid names, got: '" + actionName + "'");
1229
+ if (!isFunction(fn)) {
1230
+ die("`action` can only be invoked on functions");
1231
+ }
1232
+
1233
+ if (typeof actionName !== "string" || !actionName) {
1234
+ die("actions should have valid names, got: '" + actionName + "'");
1235
+ }
1126
1236
  }
1127
1237
 
1128
1238
  function res() {
@@ -1204,7 +1314,10 @@ function _endAction(runInfo) {
1204
1314
  allowStateChangesEnd(runInfo.prevAllowStateChanges_);
1205
1315
  allowStateReadsEnd(runInfo.prevAllowStateReads_);
1206
1316
  endBatch();
1207
- if (runInfo.runAsAction_) untrackedEnd(runInfo.prevDerivation_);
1317
+
1318
+ if (runInfo.runAsAction_) {
1319
+ untrackedEnd(runInfo.prevDerivation_);
1320
+ }
1208
1321
 
1209
1322
  if (process.env.NODE_ENV !== "production" && runInfo.notifySpy_) {
1210
1323
  spyReportEnd({
@@ -1284,7 +1397,10 @@ var ObservableValue = /*#__PURE__*/function (_Atom, _Symbol$toPrimitive2) {
1284
1397
  var _proto = ObservableValue.prototype;
1285
1398
 
1286
1399
  _proto.dehanceValue = function dehanceValue(value) {
1287
- if (this.dehancer !== undefined) return this.dehancer(value);
1400
+ if (this.dehancer !== undefined) {
1401
+ return this.dehancer(value);
1402
+ }
1403
+
1288
1404
  return value;
1289
1405
  };
1290
1406
 
@@ -1307,7 +1423,10 @@ var ObservableValue = /*#__PURE__*/function (_Atom, _Symbol$toPrimitive2) {
1307
1423
  }
1308
1424
 
1309
1425
  this.setNewValue_(newValue);
1310
- if (process.env.NODE_ENV !== "production" && notifySpy) spyReportEnd();
1426
+
1427
+ if (process.env.NODE_ENV !== "production" && notifySpy) {
1428
+ spyReportEnd();
1429
+ }
1311
1430
  }
1312
1431
  };
1313
1432
 
@@ -1320,7 +1439,11 @@ var ObservableValue = /*#__PURE__*/function (_Atom, _Symbol$toPrimitive2) {
1320
1439
  type: UPDATE,
1321
1440
  newValue: newValue
1322
1441
  });
1323
- if (!change) return globalState.UNCHANGED;
1442
+
1443
+ if (!change) {
1444
+ return globalState.UNCHANGED;
1445
+ }
1446
+
1324
1447
  newValue = change.newValue;
1325
1448
  } // apply modifier
1326
1449
 
@@ -1354,14 +1477,17 @@ var ObservableValue = /*#__PURE__*/function (_Atom, _Symbol$toPrimitive2) {
1354
1477
  };
1355
1478
 
1356
1479
  _proto.observe_ = function observe_(listener, fireImmediately) {
1357
- if (fireImmediately) listener({
1358
- observableKind: "value",
1359
- debugObjectName: this.name_,
1360
- object: this,
1361
- type: UPDATE,
1362
- newValue: this.value_,
1363
- oldValue: undefined
1364
- });
1480
+ if (fireImmediately) {
1481
+ listener({
1482
+ observableKind: "value",
1483
+ debugObjectName: this.name_,
1484
+ object: this,
1485
+ type: UPDATE,
1486
+ newValue: this.value_,
1487
+ oldValue: undefined
1488
+ });
1489
+ }
1490
+
1365
1491
  return registerListener(this, listener);
1366
1492
  };
1367
1493
 
@@ -1456,7 +1582,11 @@ var ComputedValue = /*#__PURE__*/function (_Symbol$toPrimitive2) {
1456
1582
  this.keepAlive_ = void 0;
1457
1583
  this.onBOL = void 0;
1458
1584
  this.onBUOL = void 0;
1459
- if (!options.get) die(31);
1585
+
1586
+ if (!options.get) {
1587
+ die(31);
1588
+ }
1589
+
1460
1590
  this.derivation = options.get;
1461
1591
  this.name_ = options.name || (process.env.NODE_ENV !== "production" ? "ComputedValue@" + getNextId() : "ComputedValue");
1462
1592
 
@@ -1498,7 +1628,9 @@ var ComputedValue = /*#__PURE__*/function (_Symbol$toPrimitive2) {
1498
1628
  ;
1499
1629
 
1500
1630
  _proto.get = function get() {
1501
- if (this.isComputing_) die(32, this.name_, this.derivation);
1631
+ if (this.isComputing_) {
1632
+ die(32, this.name_, this.derivation);
1633
+ }
1502
1634
 
1503
1635
  if (globalState.inBatch === 0 && // !globalState.trackingDerivatpion &&
1504
1636
  this.observers_.size === 0 && !this.keepAlive_) {
@@ -1514,20 +1646,34 @@ var ComputedValue = /*#__PURE__*/function (_Symbol$toPrimitive2) {
1514
1646
 
1515
1647
  if (shouldCompute(this)) {
1516
1648
  var prevTrackingContext = globalState.trackingContext;
1517
- if (this.keepAlive_ && !prevTrackingContext) globalState.trackingContext = this;
1518
- if (this.trackAndCompute()) propagateChangeConfirmed(this);
1649
+
1650
+ if (this.keepAlive_ && !prevTrackingContext) {
1651
+ globalState.trackingContext = this;
1652
+ }
1653
+
1654
+ if (this.trackAndCompute()) {
1655
+ propagateChangeConfirmed(this);
1656
+ }
1657
+
1519
1658
  globalState.trackingContext = prevTrackingContext;
1520
1659
  }
1521
1660
  }
1522
1661
 
1523
1662
  var result = this.value_;
1524
- if (isCaughtException(result)) throw result.cause;
1663
+
1664
+ if (isCaughtException(result)) {
1665
+ throw result.cause;
1666
+ }
1667
+
1525
1668
  return result;
1526
1669
  };
1527
1670
 
1528
1671
  _proto.set = function set(value) {
1529
1672
  if (this.setter_) {
1530
- if (this.isRunningSetter_) die(33, this.name_);
1673
+ if (this.isRunningSetter_) {
1674
+ die(33, this.name_);
1675
+ }
1676
+
1531
1677
  this.isRunningSetter_ = true;
1532
1678
 
1533
1679
  try {
@@ -1535,7 +1681,9 @@ var ComputedValue = /*#__PURE__*/function (_Symbol$toPrimitive2) {
1535
1681
  } finally {
1536
1682
  this.isRunningSetter_ = false;
1537
1683
  }
1538
- } else die(34, this.name_);
1684
+ } else {
1685
+ die(34, this.name_);
1686
+ }
1539
1687
  };
1540
1688
 
1541
1689
  _proto.trackAndCompute = function trackAndCompute() {
@@ -1629,7 +1777,9 @@ var ComputedValue = /*#__PURE__*/function (_Symbol$toPrimitive2) {
1629
1777
  };
1630
1778
 
1631
1779
  _proto.warnAboutUntrackedRead_ = function warnAboutUntrackedRead_() {
1632
- if (!(process.env.NODE_ENV !== "production")) return;
1780
+ if (!(process.env.NODE_ENV !== "production")) {
1781
+ return;
1782
+ }
1633
1783
 
1634
1784
  if (this.isTracing_ !== TraceMode.NONE) {
1635
1785
  console.log("[mobx.trace] Computed value '" + this.name_ + "' is being read outside a reactive context. Doing a full recompute.");
@@ -1768,7 +1918,9 @@ function checkIfStateModificationsAreAllowed(atom) {
1768
1918
 
1769
1919
  var hasObservers = atom.observers_.size > 0; // Should not be possible to change observed state outside strict mode, except during initialization, see #563
1770
1920
 
1771
- if (!globalState.allowStateChanges && (hasObservers || globalState.enforceActions === "always")) console.warn("[MobX] " + (globalState.enforceActions ? "Since strict-mode is enabled, changing (observed) observable values without using an action is not allowed. Tried to modify: " : "Side effects like changing state are not allowed at this point. Are you trying to modify state from, for example, a computed value or the render function of a React component? You can wrap side effects in 'runInAction' (or decorate functions with 'action') if needed. Tried to modify: ") + atom.name_);
1921
+ if (!globalState.allowStateChanges && (hasObservers || globalState.enforceActions === "always")) {
1922
+ console.warn("[MobX] " + (globalState.enforceActions ? "Since strict-mode is enabled, changing (observed) observable values without using an action is not allowed. Tried to modify: " : "Side effects like changing state are not allowed at this point. Are you trying to modify state from, for example, a computed value or the render function of a React component? You can wrap side effects in 'runInAction' (or decorate functions with 'action') if needed. Tried to modify: ") + atom.name_);
1923
+ }
1772
1924
  }
1773
1925
  function checkIfStateReadsAreAllowed(observable) {
1774
1926
  if (process.env.NODE_ENV !== "production" && !globalState.allowStateReads && globalState.observableRequiresReaction) {
@@ -1813,8 +1965,13 @@ function trackDerivedFunction(derivation, f, context) {
1813
1965
  }
1814
1966
 
1815
1967
  function warnAboutDerivationWithoutDependencies(derivation) {
1816
- if (!(process.env.NODE_ENV !== "production")) return;
1817
- if (derivation.observing_.length !== 0) return;
1968
+ if (!(process.env.NODE_ENV !== "production")) {
1969
+ return;
1970
+ }
1971
+
1972
+ if (derivation.observing_.length !== 0) {
1973
+ return;
1974
+ }
1818
1975
 
1819
1976
  if (globalState.reactionRequiresObservable || derivation.requiresObservable_) {
1820
1977
  console.warn("[mobx] Derivation '" + derivation.name_ + "' is created/updated without reading any observable value.");
@@ -1843,7 +2000,11 @@ function bindDependencies(derivation) {
1843
2000
 
1844
2001
  if (dep.diffValue_ === 0) {
1845
2002
  dep.diffValue_ = 1;
1846
- if (i0 !== i) observing[i0] = dep;
2003
+
2004
+ if (i0 !== i) {
2005
+ observing[i0] = dep;
2006
+ }
2007
+
1847
2008
  i0++;
1848
2009
  } // Upcast is 'safe' here, because if dep is IObservable, `dependenciesState` will be undefined,
1849
2010
  // not hitting the condition
@@ -1935,7 +2096,10 @@ function allowStateReadsEnd(prev) {
1935
2096
  */
1936
2097
 
1937
2098
  function changeDependenciesStateTo0(derivation) {
1938
- if (derivation.dependenciesState_ === IDerivationState_.UP_TO_DATE_) return;
2099
+ if (derivation.dependenciesState_ === IDerivationState_.UP_TO_DATE_) {
2100
+ return;
2101
+ }
2102
+
1939
2103
  derivation.dependenciesState_ = IDerivationState_.UP_TO_DATE_;
1940
2104
  var obs = derivation.observing_;
1941
2105
  var i = obs.length;
@@ -1979,8 +2143,14 @@ var canMergeGlobalState = true;
1979
2143
  var isolateCalled = false;
1980
2144
  var globalState = /*#__PURE__*/function () {
1981
2145
  var global = /*#__PURE__*/getGlobal();
1982
- if (global.__mobxInstanceCount > 0 && !global.__mobxGlobals) canMergeGlobalState = false;
1983
- if (global.__mobxGlobals && global.__mobxGlobals.version !== new MobXGlobals().version) canMergeGlobalState = false;
2146
+
2147
+ if (global.__mobxInstanceCount > 0 && !global.__mobxGlobals) {
2148
+ canMergeGlobalState = false;
2149
+ }
2150
+
2151
+ if (global.__mobxGlobals && global.__mobxGlobals.version !== new MobXGlobals().version) {
2152
+ canMergeGlobalState = false;
2153
+ }
1984
2154
 
1985
2155
  if (!canMergeGlobalState) {
1986
2156
  // Because this is a IIFE we need to let isolateCalled a chance to change
@@ -1993,7 +2163,11 @@ var globalState = /*#__PURE__*/function () {
1993
2163
  return new MobXGlobals();
1994
2164
  } else if (global.__mobxGlobals) {
1995
2165
  global.__mobxInstanceCount += 1;
1996
- if (!global.__mobxGlobals.UNCHANGED) global.__mobxGlobals.UNCHANGED = {}; // make merge backward compatible
2166
+
2167
+ if (!global.__mobxGlobals.UNCHANGED) {
2168
+ global.__mobxGlobals.UNCHANGED = {};
2169
+ } // make merge backward compatible
2170
+
1997
2171
 
1998
2172
  return global.__mobxGlobals;
1999
2173
  } else {
@@ -2002,12 +2176,19 @@ var globalState = /*#__PURE__*/function () {
2002
2176
  }
2003
2177
  }();
2004
2178
  function isolateGlobalState() {
2005
- if (globalState.pendingReactions.length || globalState.inBatch || globalState.isRunningReactions) die(36);
2179
+ if (globalState.pendingReactions.length || globalState.inBatch || globalState.isRunningReactions) {
2180
+ die(36);
2181
+ }
2182
+
2006
2183
  isolateCalled = true;
2007
2184
 
2008
2185
  if (canMergeGlobalState) {
2009
2186
  var global = getGlobal();
2010
- if (--global.__mobxInstanceCount === 0) global.__mobxGlobals = undefined;
2187
+
2188
+ if (--global.__mobxInstanceCount === 0) {
2189
+ global.__mobxGlobals = undefined;
2190
+ }
2191
+
2011
2192
  globalState = new MobXGlobals();
2012
2193
  }
2013
2194
  }
@@ -2023,7 +2204,9 @@ function resetGlobalState() {
2023
2204
  var defaultGlobals = new MobXGlobals();
2024
2205
 
2025
2206
  for (var key in defaultGlobals) {
2026
- if (persistentKeys.indexOf(key) === -1) globalState[key] = defaultGlobals[key];
2207
+ if (persistentKeys.indexOf(key) === -1) {
2208
+ globalState[key] = defaultGlobals[key];
2209
+ }
2027
2210
  }
2028
2211
 
2029
2212
  globalState.allowStateChanges = !globalState.enforceActions;
@@ -2057,8 +2240,12 @@ function addObserver(observable, node) {
2057
2240
  // invariant(observable._observers.indexOf(node) === -1, "INTERNAL ERROR add already added node");
2058
2241
  // invariantObservers(observable);
2059
2242
  observable.observers_.add(node);
2060
- if (observable.lowestObserverState_ > node.dependenciesState_) observable.lowestObserverState_ = node.dependenciesState_; // invariantObservers(observable);
2243
+
2244
+ if (observable.lowestObserverState_ > node.dependenciesState_) {
2245
+ observable.lowestObserverState_ = node.dependenciesState_;
2246
+ } // invariantObservers(observable);
2061
2247
  // invariant(observable._observers.indexOf(node) !== -1, "INTERNAL ERROR didn't add node");
2248
+
2062
2249
  }
2063
2250
  function removeObserver(observable, node) {
2064
2251
  // invariant(globalState.inBatch > 0, "INTERNAL ERROR, remove should be called only inside batch");
@@ -2169,7 +2356,10 @@ function reportObserved(observable) {
2169
2356
 
2170
2357
  function propagateChanged(observable) {
2171
2358
  // invariantLOS(observable, "changed start");
2172
- if (observable.lowestObserverState_ === IDerivationState_.STALE_) return;
2359
+ if (observable.lowestObserverState_ === IDerivationState_.STALE_) {
2360
+ return;
2361
+ }
2362
+
2173
2363
  observable.lowestObserverState_ = IDerivationState_.STALE_; // Ideally we use for..of here, but the downcompiled version is really slow...
2174
2364
 
2175
2365
  observable.observers_.forEach(function (d) {
@@ -2187,7 +2377,10 @@ function propagateChanged(observable) {
2187
2377
 
2188
2378
  function propagateChangeConfirmed(observable) {
2189
2379
  // invariantLOS(observable, "confirmed start");
2190
- if (observable.lowestObserverState_ === IDerivationState_.STALE_) return;
2380
+ if (observable.lowestObserverState_ === IDerivationState_.STALE_) {
2381
+ return;
2382
+ }
2383
+
2191
2384
  observable.lowestObserverState_ = IDerivationState_.STALE_;
2192
2385
  observable.observers_.forEach(function (d) {
2193
2386
  if (d.dependenciesState_ === IDerivationState_.POSSIBLY_STALE_) {
@@ -2205,7 +2398,10 @@ function propagateChangeConfirmed(observable) {
2205
2398
 
2206
2399
  function propagateMaybeChanged(observable) {
2207
2400
  // invariantLOS(observable, "maybe start");
2208
- if (observable.lowestObserverState_ !== IDerivationState_.UP_TO_DATE_) return;
2401
+ if (observable.lowestObserverState_ !== IDerivationState_.UP_TO_DATE_) {
2402
+ return;
2403
+ }
2404
+
2209
2405
  observable.lowestObserverState_ = IDerivationState_.POSSIBLY_STALE_;
2210
2406
  observable.observers_.forEach(function (d) {
2211
2407
  if (d.dependenciesState_ === IDerivationState_.UP_TO_DATE_) {
@@ -2233,9 +2429,12 @@ function printDepTree(tree, lines, depth) {
2233
2429
  }
2234
2430
 
2235
2431
  lines.push("" + "\t".repeat(depth - 1) + tree.name);
2236
- if (tree.dependencies) tree.dependencies.forEach(function (child) {
2237
- return printDepTree(child, lines, depth + 1);
2238
- });
2432
+
2433
+ if (tree.dependencies) {
2434
+ tree.dependencies.forEach(function (child) {
2435
+ return printDepTree(child, lines, depth + 1);
2436
+ });
2437
+ }
2239
2438
  }
2240
2439
 
2241
2440
  var Reaction = /*#__PURE__*/function () {
@@ -2353,7 +2552,9 @@ var Reaction = /*#__PURE__*/function () {
2353
2552
  clearObserving(this);
2354
2553
  }
2355
2554
 
2356
- if (isCaughtException(result)) this.reportExceptionInDerivation_(result.cause);
2555
+ if (isCaughtException(result)) {
2556
+ this.reportExceptionInDerivation_(result.cause);
2557
+ }
2357
2558
 
2358
2559
  if (process.env.NODE_ENV !== "production" && notify) {
2359
2560
  spyReportEnd({
@@ -2372,13 +2573,18 @@ var Reaction = /*#__PURE__*/function () {
2372
2573
  return;
2373
2574
  }
2374
2575
 
2375
- if (globalState.disableErrorBoundaries) throw error;
2576
+ if (globalState.disableErrorBoundaries) {
2577
+ throw error;
2578
+ }
2579
+
2376
2580
  var message = process.env.NODE_ENV !== "production" ? "[mobx] Encountered an uncaught exception that was thrown by a reaction or observer component, in: '" + this + "'" : "[mobx] uncaught error in '" + this + "'";
2377
2581
 
2378
2582
  if (!globalState.suppressReactionErrors) {
2379
2583
  console.error(message, error);
2380
2584
  /** If debugging brought you here, please, read the above message :-). Tnx! */
2381
- } else if (process.env.NODE_ENV !== "production") console.warn("[mobx] (error in reaction '" + this.name_ + "' suppressed, fix error of causing action below)"); // prettier-ignore
2585
+ } else if (process.env.NODE_ENV !== "production") {
2586
+ console.warn("[mobx] (error in reaction '" + this.name_ + "' suppressed, fix error of causing action below)");
2587
+ } // prettier-ignore
2382
2588
 
2383
2589
 
2384
2590
  if (process.env.NODE_ENV !== "production" && isSpyEnabled()) {
@@ -2432,7 +2638,10 @@ function onReactionError(handler) {
2432
2638
  globalState.globalReactionErrorHandlers.push(handler);
2433
2639
  return function () {
2434
2640
  var idx = globalState.globalReactionErrorHandlers.indexOf(handler);
2435
- if (idx >= 0) globalState.globalReactionErrorHandlers.splice(idx, 1);
2641
+
2642
+ if (idx >= 0) {
2643
+ globalState.globalReactionErrorHandlers.splice(idx, 1);
2644
+ }
2436
2645
  };
2437
2646
  }
2438
2647
  /**
@@ -2449,7 +2658,10 @@ var reactionScheduler = function reactionScheduler(f) {
2449
2658
 
2450
2659
  function runReactions() {
2451
2660
  // Trampolining, if runReactions are already running, new reactions will be picked up
2452
- if (globalState.inBatch > 0 || globalState.isRunningReactions) return;
2661
+ if (globalState.inBatch > 0 || globalState.isRunningReactions) {
2662
+ return;
2663
+ }
2664
+
2453
2665
  reactionScheduler(runReactionsHelper);
2454
2666
  }
2455
2667
 
@@ -2491,9 +2703,15 @@ function isSpyEnabled() {
2491
2703
  return process.env.NODE_ENV !== "production" && !!globalState.spyListeners.length;
2492
2704
  }
2493
2705
  function spyReport(event) {
2494
- if (!(process.env.NODE_ENV !== "production")) return; // dead code elimination can do the rest
2706
+ if (!(process.env.NODE_ENV !== "production")) {
2707
+ return;
2708
+ } // dead code elimination can do the rest
2709
+
2710
+
2711
+ if (!globalState.spyListeners.length) {
2712
+ return;
2713
+ }
2495
2714
 
2496
- if (!globalState.spyListeners.length) return;
2497
2715
  var listeners = globalState.spyListeners;
2498
2716
 
2499
2717
  for (var i = 0, l = listeners.length; i < l; i++) {
@@ -2501,7 +2719,9 @@ function spyReport(event) {
2501
2719
  }
2502
2720
  }
2503
2721
  function spyReportStart(event) {
2504
- if (!(process.env.NODE_ENV !== "production")) return;
2722
+ if (!(process.env.NODE_ENV !== "production")) {
2723
+ return;
2724
+ }
2505
2725
 
2506
2726
  var change = _extends({}, event, {
2507
2727
  spyReportStart: true
@@ -2514,11 +2734,18 @@ var END_EVENT = {
2514
2734
  spyReportEnd: true
2515
2735
  };
2516
2736
  function spyReportEnd(change) {
2517
- if (!(process.env.NODE_ENV !== "production")) return;
2518
- if (change) spyReport(_extends({}, change, {
2519
- type: "report-end",
2520
- spyReportEnd: true
2521
- }));else spyReport(END_EVENT);
2737
+ if (!(process.env.NODE_ENV !== "production")) {
2738
+ return;
2739
+ }
2740
+
2741
+ if (change) {
2742
+ spyReport(_extends({}, change, {
2743
+ type: "report-end",
2744
+ spyReportEnd: true
2745
+ }));
2746
+ } else {
2747
+ spyReport(END_EVENT);
2748
+ }
2522
2749
  }
2523
2750
  function spy(listener) {
2524
2751
  if (!(process.env.NODE_ENV !== "production")) {
@@ -2554,9 +2781,15 @@ var autoActionBoundAnnotation = /*#__PURE__*/createActionAnnotation(AUTOACTION_B
2554
2781
  function createActionFactory(autoAction) {
2555
2782
  var res = function action(arg1, arg2) {
2556
2783
  // action(fn() {})
2557
- if (isFunction(arg1)) return createAction(arg1.name || DEFAULT_ACTION_NAME, arg1, autoAction); // action("name", fn() {})
2784
+ if (isFunction(arg1)) {
2785
+ return createAction(arg1.name || DEFAULT_ACTION_NAME, arg1, autoAction);
2786
+ } // action("name", fn() {})
2787
+
2788
+
2789
+ if (isFunction(arg2)) {
2790
+ return createAction(arg1, arg2, autoAction);
2791
+ } // @action
2558
2792
 
2559
- if (isFunction(arg2)) return createAction(arg1, arg2, autoAction); // @action
2560
2793
 
2561
2794
  if (isStringish(arg2)) {
2562
2795
  return storeAnnotation(arg1, arg2, autoAction ? autoActionAnnotation : actionAnnotation);
@@ -2570,7 +2803,9 @@ function createActionFactory(autoAction) {
2570
2803
  }));
2571
2804
  }
2572
2805
 
2573
- if (process.env.NODE_ENV !== "production") die("Invalid arguments for `action`");
2806
+ if (process.env.NODE_ENV !== "production") {
2807
+ die("Invalid arguments for `action`");
2808
+ }
2574
2809
  };
2575
2810
 
2576
2811
  return res;
@@ -2604,8 +2839,13 @@ function autorun(view, opts) {
2604
2839
  }
2605
2840
 
2606
2841
  if (process.env.NODE_ENV !== "production") {
2607
- if (!isFunction(view)) die("Autorun expects a function as first argument");
2608
- if (isAction(view)) die("Autorun does not accept actions since actions are untrackable");
2842
+ if (!isFunction(view)) {
2843
+ die("Autorun expects a function as first argument");
2844
+ }
2845
+
2846
+ if (isAction(view)) {
2847
+ die("Autorun does not accept actions since actions are untrackable");
2848
+ }
2609
2849
  }
2610
2850
 
2611
2851
  var name = (_opts$name = (_opts = opts) == null ? void 0 : _opts.name) != null ? _opts$name : process.env.NODE_ENV !== "production" ? view.name || "Autorun@" + getNextId() : "Autorun";
@@ -2626,7 +2866,10 @@ function autorun(view, opts) {
2626
2866
  isScheduled = true;
2627
2867
  scheduler(function () {
2628
2868
  isScheduled = false;
2629
- if (!reaction.isDisposed_) reaction.track(reactionRunner);
2869
+
2870
+ if (!reaction.isDisposed_) {
2871
+ reaction.track(reactionRunner);
2872
+ }
2630
2873
  });
2631
2874
  }
2632
2875
  }, opts.onError, opts.requiresObservable);
@@ -2658,8 +2901,13 @@ function reaction(expression, effect, opts) {
2658
2901
  }
2659
2902
 
2660
2903
  if (process.env.NODE_ENV !== "production") {
2661
- if (!isFunction(expression) || !isFunction(effect)) die("First and second argument to reaction should be functions");
2662
- if (!isPlainObject(opts)) die("Third argument of reactions should be an object");
2904
+ if (!isFunction(expression) || !isFunction(effect)) {
2905
+ die("First and second argument to reaction should be functions");
2906
+ }
2907
+
2908
+ if (!isPlainObject(opts)) {
2909
+ die("Third argument of reactions should be an object");
2910
+ }
2663
2911
  }
2664
2912
 
2665
2913
  var name = (_opts$name2 = opts.name) != null ? _opts$name2 : process.env.NODE_ENV !== "production" ? "Reaction@" + getNextId() : "Reaction";
@@ -2682,7 +2930,11 @@ function reaction(expression, effect, opts) {
2682
2930
 
2683
2931
  function reactionRunner() {
2684
2932
  isScheduled = false;
2685
- if (r.isDisposed_) return;
2933
+
2934
+ if (r.isDisposed_) {
2935
+ return;
2936
+ }
2937
+
2686
2938
  var changed = false;
2687
2939
  r.track(function () {
2688
2940
  var nextValue = allowStateChanges(false, function () {
@@ -2692,7 +2944,13 @@ function reaction(expression, effect, opts) {
2692
2944
  oldValue = value;
2693
2945
  value = nextValue;
2694
2946
  });
2695
- if (firstTime && opts.fireImmediately) effectAction(value, oldValue, r);else if (!firstTime && changed) effectAction(value, oldValue, r);
2947
+
2948
+ if (firstTime && opts.fireImmediately) {
2949
+ effectAction(value, oldValue, r);
2950
+ } else if (!firstTime && changed) {
2951
+ effectAction(value, oldValue, r);
2952
+ }
2953
+
2696
2954
  firstTime = false;
2697
2955
  }
2698
2956
 
@@ -2759,7 +3017,9 @@ function configure(options) {
2759
3017
  globalState.useProxies = useProxies === ALWAYS ? true : useProxies === NEVER ? false : typeof Proxy !== "undefined";
2760
3018
  }
2761
3019
 
2762
- if (useProxies === "ifavailable") globalState.verifyProxies = true;
3020
+ if (useProxies === "ifavailable") {
3021
+ globalState.verifyProxies = true;
3022
+ }
2763
3023
 
2764
3024
  if (enforceActions !== undefined) {
2765
3025
  var ea = enforceActions === ALWAYS ? ALWAYS : enforceActions === OBSERVED;
@@ -2767,7 +3027,9 @@ function configure(options) {
2767
3027
  globalState.allowStateChanges = ea === true || ea === ALWAYS ? false : true;
2768
3028
  }
2769
3029
  ["computedRequiresReaction", "reactionRequiresObservable", "observableRequiresReaction", "disableErrorBoundaries", "safeDescriptors"].forEach(function (key) {
2770
- if (key in options) globalState[key] = !!options[key];
3030
+ if (key in options) {
3031
+ globalState[key] = !!options[key];
3032
+ }
2771
3033
  });
2772
3034
  globalState.allowStateReads = !globalState.observableRequiresReaction;
2773
3035
 
@@ -2782,11 +3044,25 @@ function configure(options) {
2782
3044
 
2783
3045
  function extendObservable(target, properties, annotations, options) {
2784
3046
  if (process.env.NODE_ENV !== "production") {
2785
- if (arguments.length > 4) die("'extendObservable' expected 2-4 arguments");
2786
- if (typeof target !== "object") die("'extendObservable' expects an object as first argument");
2787
- if (isObservableMap(target)) die("'extendObservable' should not be used on maps, use map.merge instead");
2788
- if (!isPlainObject(properties)) die("'extendObservable' only accepts plain objects as second argument");
2789
- if (isObservable(properties) || isObservable(annotations)) die("Extending an object with another observable (object) is not supported");
3047
+ if (arguments.length > 4) {
3048
+ die("'extendObservable' expected 2-4 arguments");
3049
+ }
3050
+
3051
+ if (typeof target !== "object") {
3052
+ die("'extendObservable' expects an object as first argument");
3053
+ }
3054
+
3055
+ if (isObservableMap(target)) {
3056
+ die("'extendObservable' should not be used on maps, use map.merge instead");
3057
+ }
3058
+
3059
+ if (!isPlainObject(properties)) {
3060
+ die("'extendObservable' only accepts plain objects as second argument");
3061
+ }
3062
+
3063
+ if (isObservable(properties) || isObservable(annotations)) {
3064
+ die("Extending an object with another observable (object) is not supported");
3065
+ }
2790
3066
  } // Pull descriptors first, so we don't have to deal with props added by administration ($mobx)
2791
3067
 
2792
3068
 
@@ -2814,7 +3090,11 @@ function nodeToDependencyTree(node) {
2814
3090
  var result = {
2815
3091
  name: node.name_
2816
3092
  };
2817
- if (node.observing_ && node.observing_.length > 0) result.dependencies = unique(node.observing_).map(nodeToDependencyTree);
3093
+
3094
+ if (node.observing_ && node.observing_.length > 0) {
3095
+ result.dependencies = unique(node.observing_).map(nodeToDependencyTree);
3096
+ }
3097
+
2818
3098
  return result;
2819
3099
  }
2820
3100
 
@@ -2826,7 +3106,11 @@ function nodeToObserverTree(node) {
2826
3106
  var result = {
2827
3107
  name: node.name_
2828
3108
  };
2829
- if (hasObservers(node)) result.observers = Array.from(getObservers(node)).map(nodeToObserverTree);
3109
+
3110
+ if (hasObservers(node)) {
3111
+ result.observers = Array.from(getObservers(node)).map(nodeToObserverTree);
3112
+ }
3113
+
2830
3114
  return result;
2831
3115
  }
2832
3116
 
@@ -2853,7 +3137,10 @@ var flow = /*#__PURE__*/Object.assign(function flow(arg1, arg2) {
2853
3137
  } // flow(fn)
2854
3138
 
2855
3139
 
2856
- if (process.env.NODE_ENV !== "production" && arguments.length !== 1) die("Flow expects single argument with generator function");
3140
+ if (process.env.NODE_ENV !== "production" && arguments.length !== 1) {
3141
+ die("Flow expects single argument with generator function");
3142
+ }
3143
+
2857
3144
  var generator = arg1;
2858
3145
  var name = generator.name || "<unnamed flow>"; // Implementation based on https://github.com/tj/co/blob/master/index.js
2859
3146
 
@@ -2901,7 +3188,10 @@ var flow = /*#__PURE__*/Object.assign(function flow(arg1, arg2) {
2901
3188
  return;
2902
3189
  }
2903
3190
 
2904
- if (ret.done) return resolve(ret.value);
3191
+ if (ret.done) {
3192
+ return resolve(ret.value);
3193
+ }
3194
+
2905
3195
  pendingPromise = Promise.resolve(ret.value);
2906
3196
  return pendingPromise.then(onFulfilled, onRejected);
2907
3197
  }
@@ -2910,7 +3200,10 @@ var flow = /*#__PURE__*/Object.assign(function flow(arg1, arg2) {
2910
3200
  });
2911
3201
  promise.cancel = action(name + " - runid: " + runId + " - cancel", function () {
2912
3202
  try {
2913
- if (pendingPromise) cancelPromise(pendingPromise); // Finally block can return (or yield) stuff..
3203
+ if (pendingPromise) {
3204
+ cancelPromise(pendingPromise);
3205
+ } // Finally block can return (or yield) stuff..
3206
+
2914
3207
 
2915
3208
  var _res = gen["return"](undefined); // eat anything that promise would do, it's cancelled!
2916
3209
 
@@ -2934,7 +3227,9 @@ var flow = /*#__PURE__*/Object.assign(function flow(arg1, arg2) {
2934
3227
  flow.bound = /*#__PURE__*/createDecoratorAnnotation(flowBoundAnnotation);
2935
3228
 
2936
3229
  function cancelPromise(promise) {
2937
- if (isFunction(promise.cancel)) promise.cancel();
3230
+ if (isFunction(promise.cancel)) {
3231
+ promise.cancel();
3232
+ }
2938
3233
  }
2939
3234
 
2940
3235
  function flowResult(result) {
@@ -2950,13 +3245,19 @@ function interceptReads(thing, propOrHandler, handler) {
2950
3245
  if (isObservableMap(thing) || isObservableArray(thing) || isObservableValue(thing)) {
2951
3246
  target = getAdministration(thing);
2952
3247
  } else if (isObservableObject(thing)) {
2953
- if (process.env.NODE_ENV !== "production" && !isStringish(propOrHandler)) return die("InterceptReads can only be used with a specific property, not with an object in general");
3248
+ if (process.env.NODE_ENV !== "production" && !isStringish(propOrHandler)) {
3249
+ return die("InterceptReads can only be used with a specific property, not with an object in general");
3250
+ }
3251
+
2954
3252
  target = getAdministration(thing, propOrHandler);
2955
3253
  } else if (process.env.NODE_ENV !== "production") {
2956
3254
  return die("Expected observable map, object or array as first array");
2957
3255
  }
2958
3256
 
2959
- if (process.env.NODE_ENV !== "production" && target.dehancer !== undefined) return die("An intercept reader was already established");
3257
+ if (process.env.NODE_ENV !== "production" && target.dehancer !== undefined) {
3258
+ return die("An intercept reader was already established");
3259
+ }
3260
+
2960
3261
  target.dehancer = typeof propOrHandler === "function" ? propOrHandler : handler;
2961
3262
  return function () {
2962
3263
  target.dehancer = undefined;
@@ -2964,7 +3265,11 @@ function interceptReads(thing, propOrHandler, handler) {
2964
3265
  }
2965
3266
 
2966
3267
  function intercept(thing, propOrHandler, handler) {
2967
- if (isFunction(handler)) return interceptProperty(thing, propOrHandler, handler);else return interceptInterceptable(thing, propOrHandler);
3268
+ if (isFunction(handler)) {
3269
+ return interceptProperty(thing, propOrHandler, handler);
3270
+ } else {
3271
+ return interceptInterceptable(thing, propOrHandler);
3272
+ }
2968
3273
  }
2969
3274
 
2970
3275
  function interceptInterceptable(thing, handler) {
@@ -2980,25 +3285,41 @@ function _isComputed(value, property) {
2980
3285
  return isComputedValue(value);
2981
3286
  }
2982
3287
 
2983
- if (isObservableObject(value) === false) return false;
2984
- if (!value[$mobx].values_.has(property)) return false;
3288
+ if (isObservableObject(value) === false) {
3289
+ return false;
3290
+ }
3291
+
3292
+ if (!value[$mobx].values_.has(property)) {
3293
+ return false;
3294
+ }
3295
+
2985
3296
  var atom = getAtom(value, property);
2986
3297
  return isComputedValue(atom);
2987
3298
  }
2988
3299
  function isComputed(value) {
2989
- if (process.env.NODE_ENV !== "production" && arguments.length > 1) return die("isComputed expects only 1 argument. Use isComputedProp to inspect the observability of a property");
3300
+ if (process.env.NODE_ENV !== "production" && arguments.length > 1) {
3301
+ return die("isComputed expects only 1 argument. Use isComputedProp to inspect the observability of a property");
3302
+ }
3303
+
2990
3304
  return _isComputed(value);
2991
3305
  }
2992
3306
  function isComputedProp(value, propName) {
2993
- if (process.env.NODE_ENV !== "production" && !isStringish(propName)) return die("isComputed expected a property name as second argument");
3307
+ if (process.env.NODE_ENV !== "production" && !isStringish(propName)) {
3308
+ return die("isComputed expected a property name as second argument");
3309
+ }
3310
+
2994
3311
  return _isComputed(value, propName);
2995
3312
  }
2996
3313
 
2997
3314
  function _isObservable(value, property) {
2998
- if (!value) return false;
3315
+ if (!value) {
3316
+ return false;
3317
+ }
2999
3318
 
3000
3319
  if (property !== undefined) {
3001
- if (process.env.NODE_ENV !== "production" && (isObservableMap(value) || isObservableArray(value))) return die("isObservable(object, propertyName) is not supported for arrays and maps. Use map.has or array.length instead.");
3320
+ if (process.env.NODE_ENV !== "production" && (isObservableMap(value) || isObservableArray(value))) {
3321
+ return die("isObservable(object, propertyName) is not supported for arrays and maps. Use map.has or array.length instead.");
3322
+ }
3002
3323
 
3003
3324
  if (isObservableObject(value)) {
3004
3325
  return value[$mobx].values_.has(property);
@@ -3012,11 +3333,17 @@ function _isObservable(value, property) {
3012
3333
  }
3013
3334
 
3014
3335
  function isObservable(value) {
3015
- if (process.env.NODE_ENV !== "production" && arguments.length !== 1) die("isObservable expects only 1 argument. Use isObservableProp to inspect the observability of a property");
3336
+ if (process.env.NODE_ENV !== "production" && arguments.length !== 1) {
3337
+ die("isObservable expects only 1 argument. Use isObservableProp to inspect the observability of a property");
3338
+ }
3339
+
3016
3340
  return _isObservable(value);
3017
3341
  }
3018
3342
  function isObservableProp(value, propName) {
3019
- if (process.env.NODE_ENV !== "production" && !isStringish(propName)) return die("expected a property name as second argument");
3343
+ if (process.env.NODE_ENV !== "production" && !isStringish(propName)) {
3344
+ return die("expected a property name as second argument");
3345
+ }
3346
+
3020
3347
  return _isObservable(value, propName);
3021
3348
  }
3022
3349
 
@@ -3108,13 +3435,25 @@ function set(obj, key, value) {
3108
3435
  } else if (isObservableSet(obj)) {
3109
3436
  obj.add(key);
3110
3437
  } else if (isObservableArray(obj)) {
3111
- if (typeof key !== "number") key = parseInt(key, 10);
3112
- if (key < 0) die("Invalid index: '" + key + "'");
3438
+ if (typeof key !== "number") {
3439
+ key = parseInt(key, 10);
3440
+ }
3441
+
3442
+ if (key < 0) {
3443
+ die("Invalid index: '" + key + "'");
3444
+ }
3445
+
3113
3446
  startBatch();
3114
- if (key >= obj.length) obj.length = key + 1;
3447
+
3448
+ if (key >= obj.length) {
3449
+ obj.length = key + 1;
3450
+ }
3451
+
3115
3452
  obj[key] = value;
3116
3453
  endBatch();
3117
- } else die(8);
3454
+ } else {
3455
+ die(8);
3456
+ }
3118
3457
  }
3119
3458
  function remove(obj, key) {
3120
3459
  if (isObservableObject(obj)) {
@@ -3124,7 +3463,10 @@ function remove(obj, key) {
3124
3463
  } else if (isObservableSet(obj)) {
3125
3464
  obj["delete"](key);
3126
3465
  } else if (isObservableArray(obj)) {
3127
- if (typeof key !== "number") key = parseInt(key, 10);
3466
+ if (typeof key !== "number") {
3467
+ key = parseInt(key, 10);
3468
+ }
3469
+
3128
3470
  obj.splice(key, 1);
3129
3471
  } else {
3130
3472
  die(9);
@@ -3144,7 +3486,9 @@ function has(obj, key) {
3144
3486
  die(10);
3145
3487
  }
3146
3488
  function get(obj, key) {
3147
- if (!has(obj, key)) return undefined;
3489
+ if (!has(obj, key)) {
3490
+ return undefined;
3491
+ }
3148
3492
 
3149
3493
  if (isObservableObject(obj)) {
3150
3494
  return obj[$mobx].get_(key);
@@ -3172,7 +3516,11 @@ function apiOwnKeys(obj) {
3172
3516
  }
3173
3517
 
3174
3518
  function observe(thing, propOrCb, cbOrFire, fireImmediately) {
3175
- if (isFunction(cbOrFire)) return observeObservableProperty(thing, propOrCb, cbOrFire, fireImmediately);else return observeObservable(thing, propOrCb, cbOrFire);
3519
+ if (isFunction(cbOrFire)) {
3520
+ return observeObservableProperty(thing, propOrCb, cbOrFire, fireImmediately);
3521
+ } else {
3522
+ return observeObservable(thing, propOrCb, cbOrFire);
3523
+ }
3176
3524
  }
3177
3525
 
3178
3526
  function observeObservable(thing, listener, fireImmediately) {
@@ -3189,8 +3537,13 @@ function cache(map, key, value) {
3189
3537
  }
3190
3538
 
3191
3539
  function toJSHelper(source, __alreadySeen) {
3192
- if (source == null || typeof source !== "object" || source instanceof Date || !isObservable(source)) return source;
3193
- if (isObservableValue(source) || isComputedValue(source)) return toJSHelper(source.get(), __alreadySeen);
3540
+ if (source == null || typeof source !== "object" || source instanceof Date || !isObservable(source)) {
3541
+ return source;
3542
+ }
3543
+
3544
+ if (isObservableValue(source) || isComputedValue(source)) {
3545
+ return toJSHelper(source.get(), __alreadySeen);
3546
+ }
3194
3547
 
3195
3548
  if (__alreadySeen.has(source)) {
3196
3549
  return __alreadySeen.get(source);
@@ -3233,24 +3586,36 @@ function toJSHelper(source, __alreadySeen) {
3233
3586
  }
3234
3587
  }
3235
3588
  /**
3236
- * Basically, a deep clone, so that no reactive property will exist anymore.
3589
+ * Recursively converts an observable to it's non-observable native counterpart.
3590
+ * It does NOT recurse into non-observables, these are left as they are, even if they contain observables.
3591
+ * Computed and other non-enumerable properties are completely ignored.
3592
+ * Complex scenarios require custom solution, eg implementing `toJSON` or using `serializr` lib.
3237
3593
  */
3238
3594
 
3239
3595
 
3240
3596
  function toJS(source, options) {
3241
- if (process.env.NODE_ENV !== "production" && options) die("toJS no longer supports options");
3597
+ if (process.env.NODE_ENV !== "production" && options) {
3598
+ die("toJS no longer supports options");
3599
+ }
3600
+
3242
3601
  return toJSHelper(source, new Map());
3243
3602
  }
3244
3603
 
3245
3604
  function trace() {
3246
- if (!(process.env.NODE_ENV !== "production")) die("trace() is not available in production builds");
3605
+ if (!(process.env.NODE_ENV !== "production")) {
3606
+ die("trace() is not available in production builds");
3607
+ }
3608
+
3247
3609
  var enterBreakPoint = false;
3248
3610
 
3249
3611
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3250
3612
  args[_key] = arguments[_key];
3251
3613
  }
3252
3614
 
3253
- if (typeof args[args.length - 1] === "boolean") enterBreakPoint = args.pop();
3615
+ if (typeof args[args.length - 1] === "boolean") {
3616
+ enterBreakPoint = args.pop();
3617
+ }
3618
+
3254
3619
  var derivation = getAtomFromArgs(args);
3255
3620
 
3256
3621
  if (!derivation) {
@@ -3300,7 +3665,10 @@ function transaction(action, thisArg) {
3300
3665
  }
3301
3666
 
3302
3667
  function when(predicate, arg1, arg2) {
3303
- if (arguments.length === 1 || arg1 && typeof arg1 === "object") return whenPromise(predicate, arg1);
3668
+ if (arguments.length === 1 || arg1 && typeof arg1 === "object") {
3669
+ return whenPromise(predicate, arg1);
3670
+ }
3671
+
3304
3672
  return _when(predicate, arg1, arg2 || {});
3305
3673
  }
3306
3674
 
@@ -3312,7 +3680,12 @@ function _when(predicate, effect, opts) {
3312
3680
  timeoutHandle = setTimeout(function () {
3313
3681
  if (!disposer[$mobx].isDisposed_) {
3314
3682
  disposer();
3315
- if (opts.onError) opts.onError(error);else throw error;
3683
+
3684
+ if (opts.onError) {
3685
+ opts.onError(error);
3686
+ } else {
3687
+ throw error;
3688
+ }
3316
3689
  }
3317
3690
  }, opts.timeout);
3318
3691
  }
@@ -3326,7 +3699,11 @@ function _when(predicate, effect, opts) {
3326
3699
 
3327
3700
  if (cond) {
3328
3701
  r.dispose();
3329
- if (timeoutHandle) clearTimeout(timeoutHandle);
3702
+
3703
+ if (timeoutHandle) {
3704
+ clearTimeout(timeoutHandle);
3705
+ }
3706
+
3330
3707
  effectAction();
3331
3708
  }
3332
3709
  }, opts);
@@ -3334,7 +3711,10 @@ function _when(predicate, effect, opts) {
3334
3711
  }
3335
3712
 
3336
3713
  function whenPromise(predicate, opts) {
3337
- if (process.env.NODE_ENV !== "production" && opts && opts.onError) return die("the options 'onError' and 'promise' cannot be combined");
3714
+ if (process.env.NODE_ENV !== "production" && opts && opts.onError) {
3715
+ return die("the options 'onError' and 'promise' cannot be combined");
3716
+ }
3717
+
3338
3718
  var cancel;
3339
3719
  var res = new Promise(function (resolve, reject) {
3340
3720
  var disposer = _when(predicate, resolve, _extends({}, opts, {
@@ -3358,7 +3738,10 @@ function getAdm(target) {
3358
3738
 
3359
3739
  var objectProxyTraps = {
3360
3740
  has: function has(target, name) {
3361
- if (process.env.NODE_ENV !== "production" && globalState.trackingDerivation) warnAboutProxyRequirement("detect new properties using the 'in' operator. Use 'has' from 'mobx' instead.");
3741
+ if (process.env.NODE_ENV !== "production" && globalState.trackingDerivation) {
3742
+ warnAboutProxyRequirement("detect new properties using the 'in' operator. Use 'has' from 'mobx' instead.");
3743
+ }
3744
+
3362
3745
  return getAdm(target).has_(name);
3363
3746
  },
3364
3747
  get: function get(target, name) {
@@ -3367,7 +3750,9 @@ var objectProxyTraps = {
3367
3750
  set: function set(target, name, value) {
3368
3751
  var _getAdm$set_;
3369
3752
 
3370
- if (!isStringish(name)) return false;
3753
+ if (!isStringish(name)) {
3754
+ return false;
3755
+ }
3371
3756
 
3372
3757
  if (process.env.NODE_ENV !== "production" && !getAdm(target).values_.has(name)) {
3373
3758
  warnAboutProxyRequirement("add a new observable property through direct assignment. Use 'set' from 'mobx' instead.");
@@ -3383,7 +3768,10 @@ var objectProxyTraps = {
3383
3768
  warnAboutProxyRequirement("delete properties from an observable object. Use 'remove' from 'mobx' instead.");
3384
3769
  }
3385
3770
 
3386
- if (!isStringish(name)) return false; // null (intercepted) -> true (success)
3771
+ if (!isStringish(name)) {
3772
+ return false;
3773
+ } // null (intercepted) -> true (success)
3774
+
3387
3775
 
3388
3776
  return (_getAdm$delete_ = getAdm(target).delete_(name, true)) != null ? _getAdm$delete_ : true;
3389
3777
  },
@@ -3398,7 +3786,10 @@ var objectProxyTraps = {
3398
3786
  return (_getAdm$definePropert = getAdm(target).defineProperty_(name, descriptor)) != null ? _getAdm$definePropert : true;
3399
3787
  },
3400
3788
  ownKeys: function ownKeys(target) {
3401
- if (process.env.NODE_ENV !== "production" && globalState.trackingDerivation) warnAboutProxyRequirement("iterate keys to detect added / removed properties. Use 'keys' from 'mobx' instead.");
3789
+ if (process.env.NODE_ENV !== "production" && globalState.trackingDerivation) {
3790
+ warnAboutProxyRequirement("iterate keys to detect added / removed properties. Use 'keys' from 'mobx' instead.");
3791
+ }
3792
+
3402
3793
  return getAdm(target).ownKeys_();
3403
3794
  },
3404
3795
  preventExtensions: function preventExtensions(target) {
@@ -3421,7 +3812,10 @@ function registerInterceptor(interceptable, handler) {
3421
3812
  interceptors.push(handler);
3422
3813
  return once(function () {
3423
3814
  var idx = interceptors.indexOf(handler);
3424
- if (idx !== -1) interceptors.splice(idx, 1);
3815
+
3816
+ if (idx !== -1) {
3817
+ interceptors.splice(idx, 1);
3818
+ }
3425
3819
  });
3426
3820
  }
3427
3821
  function interceptChange(interceptable, change) {
@@ -3433,8 +3827,14 @@ function interceptChange(interceptable, change) {
3433
3827
 
3434
3828
  for (var i = 0, l = interceptors.length; i < l; i++) {
3435
3829
  change = interceptors[i](change);
3436
- if (change && !change.type) die(14);
3437
- if (!change) break;
3830
+
3831
+ if (change && !change.type) {
3832
+ die(14);
3833
+ }
3834
+
3835
+ if (!change) {
3836
+ break;
3837
+ }
3438
3838
  }
3439
3839
 
3440
3840
  return change;
@@ -3451,13 +3851,20 @@ function registerListener(listenable, handler) {
3451
3851
  listeners.push(handler);
3452
3852
  return once(function () {
3453
3853
  var idx = listeners.indexOf(handler);
3454
- if (idx !== -1) listeners.splice(idx, 1);
3854
+
3855
+ if (idx !== -1) {
3856
+ listeners.splice(idx, 1);
3857
+ }
3455
3858
  });
3456
3859
  }
3457
3860
  function notifyListeners(listenable, change) {
3458
3861
  var prevU = untrackedStart();
3459
3862
  var listeners = listenable.changeListeners_;
3460
- if (!listeners) return;
3863
+
3864
+ if (!listeners) {
3865
+ return;
3866
+ }
3867
+
3461
3868
  listeners = listeners.slice();
3462
3869
 
3463
3870
  for (var i = 0, l = listeners.length; i < l; i++) {
@@ -3494,8 +3901,13 @@ function makeObservable(target, annotations, options) {
3494
3901
  var keysSymbol = /*#__PURE__*/Symbol("mobx-keys");
3495
3902
  function makeAutoObservable(target, overrides, options) {
3496
3903
  if (process.env.NODE_ENV !== "production") {
3497
- if (!isPlainObject(target) && !isPlainObject(Object.getPrototypeOf(target))) die("'makeAutoObservable' can only be used for classes that don't have a superclass");
3498
- if (isObservableObject(target)) die("makeAutoObservable can only be used on objects not already made observable");
3904
+ if (!isPlainObject(target) && !isPlainObject(Object.getPrototypeOf(target))) {
3905
+ die("'makeAutoObservable' can only be used for classes that don't have a superclass");
3906
+ }
3907
+
3908
+ if (isObservableObject(target)) {
3909
+ die("makeAutoObservable can only be used on objects not already made observable");
3910
+ }
3499
3911
  } // Optimization: avoid visiting protos
3500
3912
  // Assumes that annotation.make_/.extend_ works the same for plain objects
3501
3913
 
@@ -3536,8 +3948,14 @@ var MAX_SPLICE_SIZE = 10000; // See e.g. https://github.com/mobxjs/mobx/issues/8
3536
3948
  var arrayTraps = {
3537
3949
  get: function get(target, name) {
3538
3950
  var adm = target[$mobx];
3539
- if (name === $mobx) return adm;
3540
- if (name === "length") return adm.getArrayLength_();
3951
+
3952
+ if (name === $mobx) {
3953
+ return adm;
3954
+ }
3955
+
3956
+ if (name === "length") {
3957
+ return adm.getArrayLength_();
3958
+ }
3541
3959
 
3542
3960
  if (typeof name === "string" && !isNaN(name)) {
3543
3961
  return adm.get_(parseInt(name));
@@ -3598,12 +4016,18 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
3598
4016
  var _proto = ObservableArrayAdministration.prototype;
3599
4017
 
3600
4018
  _proto.dehanceValue_ = function dehanceValue_(value) {
3601
- if (this.dehancer !== undefined) return this.dehancer(value);
4019
+ if (this.dehancer !== undefined) {
4020
+ return this.dehancer(value);
4021
+ }
4022
+
3602
4023
  return value;
3603
4024
  };
3604
4025
 
3605
4026
  _proto.dehanceValues_ = function dehanceValues_(values) {
3606
- if (this.dehancer !== undefined && values.length > 0) return values.map(this.dehancer);
4027
+ if (this.dehancer !== undefined && values.length > 0) {
4028
+ return values.map(this.dehancer);
4029
+ }
4030
+
3607
4031
  return values;
3608
4032
  };
3609
4033
 
@@ -3639,9 +4063,15 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
3639
4063
  };
3640
4064
 
3641
4065
  _proto.setArrayLength_ = function setArrayLength_(newLength) {
3642
- if (typeof newLength !== "number" || isNaN(newLength) || newLength < 0) die("Out of range: " + newLength);
4066
+ if (typeof newLength !== "number" || isNaN(newLength) || newLength < 0) {
4067
+ die("Out of range: " + newLength);
4068
+ }
4069
+
3643
4070
  var currentLength = this.values_.length;
3644
- if (newLength === currentLength) return;else if (newLength > currentLength) {
4071
+
4072
+ if (newLength === currentLength) {
4073
+ return;
4074
+ } else if (newLength > currentLength) {
3645
4075
  var newItems = new Array(newLength - currentLength);
3646
4076
 
3647
4077
  for (var i = 0; i < newLength - currentLength; i++) {
@@ -3650,13 +4080,21 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
3650
4080
 
3651
4081
 
3652
4082
  this.spliceWithArray_(currentLength, 0, newItems);
3653
- } else this.spliceWithArray_(newLength, currentLength - newLength);
4083
+ } else {
4084
+ this.spliceWithArray_(newLength, currentLength - newLength);
4085
+ }
3654
4086
  };
3655
4087
 
3656
4088
  _proto.updateArrayLength_ = function updateArrayLength_(oldLength, delta) {
3657
- if (oldLength !== this.lastKnownLength_) die(16);
4089
+ if (oldLength !== this.lastKnownLength_) {
4090
+ die(16);
4091
+ }
4092
+
3658
4093
  this.lastKnownLength_ += delta;
3659
- if (this.legacyMode_ && delta > 0) reserveArrayBuffer(oldLength + delta + 1);
4094
+
4095
+ if (this.legacyMode_ && delta > 0) {
4096
+ reserveArrayBuffer(oldLength + delta + 1);
4097
+ }
3660
4098
  };
3661
4099
 
3662
4100
  _proto.spliceWithArray_ = function spliceWithArray_(index, deleteCount, newItems) {
@@ -3664,9 +4102,26 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
3664
4102
 
3665
4103
  checkIfStateModificationsAreAllowed(this.atom_);
3666
4104
  var length = this.values_.length;
3667
- if (index === undefined) index = 0;else if (index > length) index = length;else if (index < 0) index = Math.max(0, length + index);
3668
- if (arguments.length === 1) deleteCount = length - index;else if (deleteCount === undefined || deleteCount === null) deleteCount = 0;else deleteCount = Math.max(0, Math.min(deleteCount, length - index));
3669
- if (newItems === undefined) newItems = EMPTY_ARRAY;
4105
+
4106
+ if (index === undefined) {
4107
+ index = 0;
4108
+ } else if (index > length) {
4109
+ index = length;
4110
+ } else if (index < 0) {
4111
+ index = Math.max(0, length + index);
4112
+ }
4113
+
4114
+ if (arguments.length === 1) {
4115
+ deleteCount = length - index;
4116
+ } else if (deleteCount === undefined || deleteCount === null) {
4117
+ deleteCount = 0;
4118
+ } else {
4119
+ deleteCount = Math.max(0, Math.min(deleteCount, length - index));
4120
+ }
4121
+
4122
+ if (newItems === undefined) {
4123
+ newItems = EMPTY_ARRAY;
4124
+ }
3670
4125
 
3671
4126
  if (hasInterceptors(this)) {
3672
4127
  var change = interceptChange(this, {
@@ -3676,7 +4131,11 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
3676
4131
  removedCount: deleteCount,
3677
4132
  added: newItems
3678
4133
  });
3679
- if (!change) return EMPTY_ARRAY;
4134
+
4135
+ if (!change) {
4136
+ return EMPTY_ARRAY;
4137
+ }
4138
+
3680
4139
  deleteCount = change.removedCount;
3681
4140
  newItems = change.added;
3682
4141
  }
@@ -3691,7 +4150,11 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
3691
4150
  }
3692
4151
 
3693
4152
  var res = this.spliceItemsIntoValues_(index, deleteCount, newItems);
3694
- if (deleteCount !== 0 || newItems.length !== 0) this.notifyArraySplice_(index, newItems, res);
4153
+
4154
+ if (deleteCount !== 0 || newItems.length !== 0) {
4155
+ this.notifyArraySplice_(index, newItems, res);
4156
+ }
4157
+
3695
4158
  return this.dehanceValues_(res);
3696
4159
  };
3697
4160
 
@@ -3734,10 +4197,19 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
3734
4197
  } : null; // The reason why this is on right hand side here (and not above), is this way the uglifier will drop it, but it won't
3735
4198
  // cause any runtime overhead in development mode without NODE_ENV set, unless spying is enabled
3736
4199
 
3737
- if (process.env.NODE_ENV !== "production" && notifySpy) spyReportStart(change);
4200
+ if (process.env.NODE_ENV !== "production" && notifySpy) {
4201
+ spyReportStart(change);
4202
+ }
4203
+
3738
4204
  this.atom_.reportChanged();
3739
- if (notify) notifyListeners(this, change);
3740
- if (process.env.NODE_ENV !== "production" && notifySpy) spyReportEnd();
4205
+
4206
+ if (notify) {
4207
+ notifyListeners(this, change);
4208
+ }
4209
+
4210
+ if (process.env.NODE_ENV !== "production" && notifySpy) {
4211
+ spyReportEnd();
4212
+ }
3741
4213
  };
3742
4214
 
3743
4215
  _proto.notifyArraySplice_ = function notifyArraySplice_(index, added, removed) {
@@ -3754,11 +4226,20 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
3754
4226
  removedCount: removed.length,
3755
4227
  addedCount: added.length
3756
4228
  } : null;
3757
- if (process.env.NODE_ENV !== "production" && notifySpy) spyReportStart(change);
4229
+
4230
+ if (process.env.NODE_ENV !== "production" && notifySpy) {
4231
+ spyReportStart(change);
4232
+ }
4233
+
3758
4234
  this.atom_.reportChanged(); // conform: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/observe
3759
4235
 
3760
- if (notify) notifyListeners(this, change);
3761
- if (process.env.NODE_ENV !== "production" && notifySpy) spyReportEnd();
4236
+ if (notify) {
4237
+ notifyListeners(this, change);
4238
+ }
4239
+
4240
+ if (process.env.NODE_ENV !== "production" && notifySpy) {
4241
+ spyReportEnd();
4242
+ }
3762
4243
  };
3763
4244
 
3764
4245
  _proto.get_ = function get_(index) {
@@ -3785,7 +4266,11 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
3785
4266
  index: index,
3786
4267
  newValue: newValue
3787
4268
  });
3788
- if (!change) return;
4269
+
4270
+ if (!change) {
4271
+ return;
4272
+ }
4273
+
3789
4274
  newValue = change.newValue;
3790
4275
  }
3791
4276
 
@@ -4026,6 +4511,8 @@ _Symbol$toStringTag = Symbol.toStringTag;
4026
4511
  var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTag2) {
4027
4512
  // hasMap, not hashMap >-).
4028
4513
  function ObservableMap(initialData, enhancer_, name_) {
4514
+ var _this = this;
4515
+
4029
4516
  if (enhancer_ === void 0) {
4030
4517
  enhancer_ = deepEnhancer;
4031
4518
  }
@@ -4053,7 +4540,9 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4053
4540
  this.keysAtom_ = createAtom(process.env.NODE_ENV !== "production" ? this.name_ + ".keys()" : "ObservableMap.keys()");
4054
4541
  this.data_ = new Map();
4055
4542
  this.hasMap_ = new Map();
4056
- this.merge(initialData);
4543
+ allowStateChanges(true, function () {
4544
+ _this.merge(initialData);
4545
+ });
4057
4546
  }
4058
4547
 
4059
4548
  var _proto = ObservableMap.prototype;
@@ -4063,16 +4552,19 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4063
4552
  };
4064
4553
 
4065
4554
  _proto.has = function has(key) {
4066
- var _this = this;
4555
+ var _this2 = this;
4556
+
4557
+ if (!globalState.trackingDerivation) {
4558
+ return this.has_(key);
4559
+ }
4067
4560
 
4068
- if (!globalState.trackingDerivation) return this.has_(key);
4069
4561
  var entry = this.hasMap_.get(key);
4070
4562
 
4071
4563
  if (!entry) {
4072
4564
  var newEntry = entry = new ObservableValue(this.has_(key), referenceEnhancer, process.env.NODE_ENV !== "production" ? this.name_ + "." + stringifyKey(key) + "?" : "ObservableMap.key?", false);
4073
4565
  this.hasMap_.set(key, newEntry);
4074
4566
  onBecomeUnobserved(newEntry, function () {
4075
- return _this.hasMap_["delete"](key);
4567
+ return _this2.hasMap_["delete"](key);
4076
4568
  });
4077
4569
  }
4078
4570
 
@@ -4089,7 +4581,11 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4089
4581
  newValue: value,
4090
4582
  name: key
4091
4583
  });
4092
- if (!change) return this;
4584
+
4585
+ if (!change) {
4586
+ return this;
4587
+ }
4588
+
4093
4589
  value = change.newValue;
4094
4590
  }
4095
4591
 
@@ -4103,7 +4599,7 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4103
4599
  };
4104
4600
 
4105
4601
  _proto["delete"] = function _delete(key) {
4106
- var _this2 = this;
4602
+ var _this3 = this;
4107
4603
 
4108
4604
  checkIfStateModificationsAreAllowed(this.keysAtom_);
4109
4605
 
@@ -4113,7 +4609,10 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4113
4609
  object: this,
4114
4610
  name: key
4115
4611
  });
4116
- if (!change) return false;
4612
+
4613
+ if (!change) {
4614
+ return false;
4615
+ }
4117
4616
  }
4118
4617
 
4119
4618
  if (this.has_(key)) {
@@ -4129,23 +4628,33 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4129
4628
  name: key
4130
4629
  } : null;
4131
4630
 
4132
- if (process.env.NODE_ENV !== "production" && notifySpy) spyReportStart(_change); // TODO fix type
4631
+ if (process.env.NODE_ENV !== "production" && notifySpy) {
4632
+ spyReportStart(_change);
4633
+ } // TODO fix type
4634
+
4133
4635
 
4134
4636
  transaction(function () {
4135
- var _this2$hasMap_$get;
4637
+ var _this3$hasMap_$get;
4136
4638
 
4137
- _this2.keysAtom_.reportChanged();
4639
+ _this3.keysAtom_.reportChanged();
4138
4640
 
4139
- (_this2$hasMap_$get = _this2.hasMap_.get(key)) == null ? void 0 : _this2$hasMap_$get.setNewValue_(false);
4641
+ (_this3$hasMap_$get = _this3.hasMap_.get(key)) == null ? void 0 : _this3$hasMap_$get.setNewValue_(false);
4140
4642
 
4141
- var observable = _this2.data_.get(key);
4643
+ var observable = _this3.data_.get(key);
4142
4644
 
4143
4645
  observable.setNewValue_(undefined);
4144
4646
 
4145
- _this2.data_["delete"](key);
4647
+ _this3.data_["delete"](key);
4146
4648
  });
4147
- if (notify) notifyListeners(this, _change);
4148
- if (process.env.NODE_ENV !== "production" && notifySpy) spyReportEnd();
4649
+
4650
+ if (notify) {
4651
+ notifyListeners(this, _change);
4652
+ }
4653
+
4654
+ if (process.env.NODE_ENV !== "production" && notifySpy) {
4655
+ spyReportEnd();
4656
+ }
4657
+
4149
4658
  return true;
4150
4659
  }
4151
4660
 
@@ -4168,30 +4677,40 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4168
4677
  name: key,
4169
4678
  newValue: newValue
4170
4679
  } : null;
4171
- if (process.env.NODE_ENV !== "production" && notifySpy) spyReportStart(change); // TODO fix type
4680
+
4681
+ if (process.env.NODE_ENV !== "production" && notifySpy) {
4682
+ spyReportStart(change);
4683
+ } // TODO fix type
4684
+
4172
4685
 
4173
4686
  observable.setNewValue_(newValue);
4174
- if (notify) notifyListeners(this, change);
4175
- if (process.env.NODE_ENV !== "production" && notifySpy) spyReportEnd();
4687
+
4688
+ if (notify) {
4689
+ notifyListeners(this, change);
4690
+ }
4691
+
4692
+ if (process.env.NODE_ENV !== "production" && notifySpy) {
4693
+ spyReportEnd();
4694
+ }
4176
4695
  }
4177
4696
  };
4178
4697
 
4179
4698
  _proto.addValue_ = function addValue_(key, newValue) {
4180
- var _this3 = this;
4699
+ var _this4 = this;
4181
4700
 
4182
4701
  checkIfStateModificationsAreAllowed(this.keysAtom_);
4183
4702
  transaction(function () {
4184
- var _this3$hasMap_$get;
4703
+ var _this4$hasMap_$get;
4185
4704
 
4186
- var observable = new ObservableValue(newValue, _this3.enhancer_, process.env.NODE_ENV !== "production" ? _this3.name_ + "." + stringifyKey(key) : "ObservableMap.key", false);
4705
+ var observable = new ObservableValue(newValue, _this4.enhancer_, process.env.NODE_ENV !== "production" ? _this4.name_ + "." + stringifyKey(key) : "ObservableMap.key", false);
4187
4706
 
4188
- _this3.data_.set(key, observable);
4707
+ _this4.data_.set(key, observable);
4189
4708
 
4190
4709
  newValue = observable.value_; // value might have been changed
4191
4710
 
4192
- (_this3$hasMap_$get = _this3.hasMap_.get(key)) == null ? void 0 : _this3$hasMap_$get.setNewValue_(true);
4711
+ (_this4$hasMap_$get = _this4.hasMap_.get(key)) == null ? void 0 : _this4$hasMap_$get.setNewValue_(true);
4193
4712
 
4194
- _this3.keysAtom_.reportChanged();
4713
+ _this4.keysAtom_.reportChanged();
4195
4714
  });
4196
4715
  var notifySpy = isSpyEnabled();
4197
4716
  var notify = hasListeners(this);
@@ -4203,14 +4722,26 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4203
4722
  name: key,
4204
4723
  newValue: newValue
4205
4724
  } : null;
4206
- if (process.env.NODE_ENV !== "production" && notifySpy) spyReportStart(change); // TODO fix type
4207
4725
 
4208
- if (notify) notifyListeners(this, change);
4209
- if (process.env.NODE_ENV !== "production" && notifySpy) spyReportEnd();
4726
+ if (process.env.NODE_ENV !== "production" && notifySpy) {
4727
+ spyReportStart(change);
4728
+ } // TODO fix type
4729
+
4730
+
4731
+ if (notify) {
4732
+ notifyListeners(this, change);
4733
+ }
4734
+
4735
+ if (process.env.NODE_ENV !== "production" && notifySpy) {
4736
+ spyReportEnd();
4737
+ }
4210
4738
  };
4211
4739
 
4212
4740
  _proto.get = function get(key) {
4213
- if (this.has(key)) return this.dehanceValue_(this.data_.get(key).get());
4741
+ if (this.has(key)) {
4742
+ return this.dehanceValue_(this.data_.get(key).get());
4743
+ }
4744
+
4214
4745
  return this.dehanceValue_(undefined);
4215
4746
  };
4216
4747
 
@@ -4277,45 +4808,54 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4277
4808
  ;
4278
4809
 
4279
4810
  _proto.merge = function merge(other) {
4280
- var _this4 = this;
4811
+ var _this5 = this;
4281
4812
 
4282
4813
  if (isObservableMap(other)) {
4283
4814
  other = new Map(other);
4284
4815
  }
4285
4816
 
4286
4817
  transaction(function () {
4287
- if (isPlainObject(other)) getPlainObjectKeys(other).forEach(function (key) {
4288
- return _this4.set(key, other[key]);
4289
- });else if (Array.isArray(other)) other.forEach(function (_ref) {
4290
- var key = _ref[0],
4291
- value = _ref[1];
4292
- return _this4.set(key, value);
4293
- });else if (isES6Map(other)) {
4294
- if (other.constructor !== Map) die(19, other);
4818
+ if (isPlainObject(other)) {
4819
+ getPlainObjectKeys(other).forEach(function (key) {
4820
+ return _this5.set(key, other[key]);
4821
+ });
4822
+ } else if (Array.isArray(other)) {
4823
+ other.forEach(function (_ref) {
4824
+ var key = _ref[0],
4825
+ value = _ref[1];
4826
+ return _this5.set(key, value);
4827
+ });
4828
+ } else if (isES6Map(other)) {
4829
+ if (other.constructor !== Map) {
4830
+ die(19, other);
4831
+ }
4832
+
4295
4833
  other.forEach(function (value, key) {
4296
- return _this4.set(key, value);
4834
+ return _this5.set(key, value);
4297
4835
  });
4298
- } else if (other !== null && other !== undefined) die(20, other);
4836
+ } else if (other !== null && other !== undefined) {
4837
+ die(20, other);
4838
+ }
4299
4839
  });
4300
4840
  return this;
4301
4841
  };
4302
4842
 
4303
4843
  _proto.clear = function clear() {
4304
- var _this5 = this;
4844
+ var _this6 = this;
4305
4845
 
4306
4846
  transaction(function () {
4307
4847
  untracked(function () {
4308
- for (var _iterator2 = _createForOfIteratorHelperLoose(_this5.keys()), _step2; !(_step2 = _iterator2()).done;) {
4848
+ for (var _iterator2 = _createForOfIteratorHelperLoose(_this6.keys()), _step2; !(_step2 = _iterator2()).done;) {
4309
4849
  var key = _step2.value;
4310
4850
 
4311
- _this5["delete"](key);
4851
+ _this6["delete"](key);
4312
4852
  }
4313
4853
  });
4314
4854
  });
4315
4855
  };
4316
4856
 
4317
4857
  _proto.replace = function replace(values) {
4318
- var _this6 = this;
4858
+ var _this7 = this;
4319
4859
 
4320
4860
  // Implementation requirements:
4321
4861
  // - respect ordering of replacement map
@@ -4332,13 +4872,13 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4332
4872
  // if the key deletion is prevented by interceptor
4333
4873
  // add entry at the beginning of the result map
4334
4874
 
4335
- for (var _iterator3 = _createForOfIteratorHelperLoose(_this6.data_.keys()), _step3; !(_step3 = _iterator3()).done;) {
4875
+ for (var _iterator3 = _createForOfIteratorHelperLoose(_this7.data_.keys()), _step3; !(_step3 = _iterator3()).done;) {
4336
4876
  var key = _step3.value;
4337
4877
 
4338
4878
  // Concurrently iterating/deleting keys
4339
4879
  // iterator should handle this correctly
4340
4880
  if (!replacementMap.has(key)) {
4341
- var deleted = _this6["delete"](key); // Was the key removed?
4881
+ var deleted = _this7["delete"](key); // Was the key removed?
4342
4882
 
4343
4883
 
4344
4884
  if (deleted) {
@@ -4346,7 +4886,7 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4346
4886
  keysReportChangedCalled = true;
4347
4887
  } else {
4348
4888
  // Delete prevented by interceptor
4349
- var value = _this6.data_.get(key);
4889
+ var value = _this7.data_.get(key);
4350
4890
 
4351
4891
  orderedData.set(key, value);
4352
4892
  }
@@ -4360,17 +4900,17 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4360
4900
  _value = _step4$value[1];
4361
4901
 
4362
4902
  // We will want to know whether a new key is added
4363
- var keyExisted = _this6.data_.has(_key); // Add or update value
4903
+ var keyExisted = _this7.data_.has(_key); // Add or update value
4364
4904
 
4365
4905
 
4366
- _this6.set(_key, _value); // The addition could have been prevent by interceptor
4906
+ _this7.set(_key, _value); // The addition could have been prevent by interceptor
4367
4907
 
4368
4908
 
4369
- if (_this6.data_.has(_key)) {
4909
+ if (_this7.data_.has(_key)) {
4370
4910
  // The update could have been prevented by interceptor
4371
4911
  // and also we want to preserve existing values
4372
4912
  // so use value from _data map (instead of replacement map)
4373
- var _value2 = _this6.data_.get(_key);
4913
+ var _value2 = _this7.data_.get(_key);
4374
4914
 
4375
4915
  orderedData.set(_key, _value2); // Was a new key added?
4376
4916
 
@@ -4383,11 +4923,11 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4383
4923
 
4384
4924
 
4385
4925
  if (!keysReportChangedCalled) {
4386
- if (_this6.data_.size !== orderedData.size) {
4926
+ if (_this7.data_.size !== orderedData.size) {
4387
4927
  // If size differs, keys are definitely modified
4388
- _this6.keysAtom_.reportChanged();
4928
+ _this7.keysAtom_.reportChanged();
4389
4929
  } else {
4390
- var iter1 = _this6.data_.keys();
4930
+ var iter1 = _this7.data_.keys();
4391
4931
 
4392
4932
  var iter2 = orderedData.keys();
4393
4933
  var next1 = iter1.next();
@@ -4395,7 +4935,7 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4395
4935
 
4396
4936
  while (!next1.done) {
4397
4937
  if (next1.value !== next2.value) {
4398
- _this6.keysAtom_.reportChanged();
4938
+ _this7.keysAtom_.reportChanged();
4399
4939
 
4400
4940
  break;
4401
4941
  }
@@ -4407,7 +4947,7 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4407
4947
  } // Use correctly ordered map
4408
4948
 
4409
4949
 
4410
- _this6.data_ = orderedData;
4950
+ _this7.data_ = orderedData;
4411
4951
  });
4412
4952
  return this;
4413
4953
  };
@@ -4426,7 +4966,10 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4426
4966
  * for callback details
4427
4967
  */
4428
4968
  _proto.observe_ = function observe_(listener, fireImmediately) {
4429
- if (process.env.NODE_ENV !== "production" && fireImmediately === true) die("`observe` doesn't support fireImmediately=true in combination with maps.");
4969
+ if (process.env.NODE_ENV !== "production" && fireImmediately === true) {
4970
+ die("`observe` doesn't support fireImmediately=true in combination with maps.");
4971
+ }
4972
+
4430
4973
  return registerListener(this, listener);
4431
4974
  };
4432
4975
 
@@ -4551,8 +5094,12 @@ var ObservableSet = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4551
5094
  object: this,
4552
5095
  newValue: value
4553
5096
  });
4554
- if (!change) return this; // ideally, value = change.value would be done here, so that values can be
5097
+
5098
+ if (!change) {
5099
+ return this;
5100
+ } // ideally, value = change.value would be done here, so that values can be
4555
5101
  // changed by interceptor. Same applies for other Set and Map api's.
5102
+
4556
5103
  }
4557
5104
 
4558
5105
  if (!this.has(value)) {
@@ -4572,9 +5119,17 @@ var ObservableSet = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4572
5119
  newValue: value
4573
5120
  } : null;
4574
5121
 
4575
- if (notifySpy && process.env.NODE_ENV !== "production") spyReportStart(_change);
4576
- if (notify) notifyListeners(this, _change);
4577
- if (notifySpy && process.env.NODE_ENV !== "production") spyReportEnd();
5122
+ if (notifySpy && process.env.NODE_ENV !== "production") {
5123
+ spyReportStart(_change);
5124
+ }
5125
+
5126
+ if (notify) {
5127
+ notifyListeners(this, _change);
5128
+ }
5129
+
5130
+ if (notifySpy && process.env.NODE_ENV !== "production") {
5131
+ spyReportEnd();
5132
+ }
4578
5133
  }
4579
5134
 
4580
5135
  return this;
@@ -4589,7 +5144,10 @@ var ObservableSet = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4589
5144
  object: this,
4590
5145
  oldValue: value
4591
5146
  });
4592
- if (!change) return false;
5147
+
5148
+ if (!change) {
5149
+ return false;
5150
+ }
4593
5151
  }
4594
5152
 
4595
5153
  if (this.has(value)) {
@@ -4604,14 +5162,24 @@ var ObservableSet = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4604
5162
  oldValue: value
4605
5163
  } : null;
4606
5164
 
4607
- if (notifySpy && process.env.NODE_ENV !== "production") spyReportStart(_change2);
5165
+ if (notifySpy && process.env.NODE_ENV !== "production") {
5166
+ spyReportStart(_change2);
5167
+ }
5168
+
4608
5169
  transaction(function () {
4609
5170
  _this3.atom_.reportChanged();
4610
5171
 
4611
5172
  _this3.data_["delete"](value);
4612
5173
  });
4613
- if (notify) notifyListeners(this, _change2);
4614
- if (notifySpy && process.env.NODE_ENV !== "production") spyReportEnd();
5174
+
5175
+ if (notify) {
5176
+ notifyListeners(this, _change2);
5177
+ }
5178
+
5179
+ if (notifySpy && process.env.NODE_ENV !== "production") {
5180
+ spyReportEnd();
5181
+ }
5182
+
4615
5183
  return true;
4616
5184
  }
4617
5185
 
@@ -4691,7 +5259,10 @@ var ObservableSet = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4691
5259
 
4692
5260
  _proto.observe_ = function observe_(listener, fireImmediately) {
4693
5261
  // ... 'fireImmediately' could also be true?
4694
- if (process.env.NODE_ENV !== "production" && fireImmediately === true) die("`observe` doesn't support fireImmediately=true in combination with sets.");
5262
+ if (process.env.NODE_ENV !== "production" && fireImmediately === true) {
5263
+ die("`observe` doesn't support fireImmediately=true in combination with sets.");
5264
+ }
5265
+
4695
5266
  return registerListener(this, listener);
4696
5267
  };
4697
5268
 
@@ -4793,7 +5364,11 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
4793
5364
  name: key,
4794
5365
  newValue: newValue
4795
5366
  });
4796
- if (!change) return null;
5367
+
5368
+ if (!change) {
5369
+ return null;
5370
+ }
5371
+
4797
5372
  newValue = change.newValue;
4798
5373
  }
4799
5374
 
@@ -4813,10 +5388,18 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
4813
5388
  newValue: newValue
4814
5389
  } : null;
4815
5390
 
4816
- if (process.env.NODE_ENV !== "production" && notifySpy) spyReportStart(_change);
5391
+ if (process.env.NODE_ENV !== "production" && notifySpy) {
5392
+ spyReportStart(_change);
5393
+ }
4817
5394
  observable.setNewValue_(newValue);
4818
- if (notify) notifyListeners(this, _change);
4819
- if (process.env.NODE_ENV !== "production" && notifySpy) spyReportEnd();
5395
+
5396
+ if (notify) {
5397
+ notifyListeners(this, _change);
5398
+ }
5399
+
5400
+ if (process.env.NODE_ENV !== "production" && notifySpy) {
5401
+ spyReportEnd();
5402
+ }
4820
5403
  }
4821
5404
 
4822
5405
  return true;
@@ -4925,12 +5508,18 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
4925
5508
 
4926
5509
  if (descriptor) {
4927
5510
  var outcome = annotation.make_(this, key, descriptor, source);
5511
+
4928
5512
  if (outcome === 0
4929
5513
  /* Cancel */
4930
- ) return;
5514
+ ) {
5515
+ return;
5516
+ }
5517
+
4931
5518
  if (outcome === 1
4932
5519
  /* Break */
4933
- ) break;
5520
+ ) {
5521
+ break;
5522
+ }
4934
5523
  }
4935
5524
 
4936
5525
  source = Object.getPrototypeOf(source);
@@ -5000,7 +5589,11 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
5000
5589
  type: ADD,
5001
5590
  newValue: descriptor.value
5002
5591
  });
5003
- if (!change) return null;
5592
+
5593
+ if (!change) {
5594
+ return null;
5595
+ }
5596
+
5004
5597
  var newValue = change.newValue;
5005
5598
 
5006
5599
  if (descriptor.value !== newValue) {
@@ -5052,7 +5645,11 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
5052
5645
  type: ADD,
5053
5646
  newValue: value
5054
5647
  });
5055
- if (!change) return null;
5648
+
5649
+ if (!change) {
5650
+ return null;
5651
+ }
5652
+
5056
5653
  value = change.newValue;
5057
5654
  }
5058
5655
 
@@ -5107,7 +5704,10 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
5107
5704
  type: ADD,
5108
5705
  newValue: undefined
5109
5706
  });
5110
- if (!change) return null;
5707
+
5708
+ if (!change) {
5709
+ return null;
5710
+ }
5111
5711
  }
5112
5712
 
5113
5713
  options.name || (options.name = process.env.NODE_ENV !== "production" ? this.name_ + "." + key.toString() : "ObservableObject.key");
@@ -5163,7 +5763,9 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
5163
5763
  type: REMOVE
5164
5764
  }); // Cancelled
5165
5765
 
5166
- if (!change) return null;
5766
+ if (!change) {
5767
+ return null;
5768
+ }
5167
5769
  } // Delete
5168
5770
 
5169
5771
 
@@ -5224,9 +5826,18 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
5224
5826
  oldValue: value,
5225
5827
  name: key
5226
5828
  };
5227
- if (process.env.NODE_ENV !== "production" && notifySpy) spyReportStart(_change2);
5228
- if (notify) notifyListeners(this, _change2);
5229
- if (process.env.NODE_ENV !== "production" && notifySpy) spyReportEnd();
5829
+
5830
+ if (process.env.NODE_ENV !== "production" && notifySpy) {
5831
+ spyReportStart(_change2);
5832
+ }
5833
+
5834
+ if (notify) {
5835
+ notifyListeners(this, _change2);
5836
+ }
5837
+
5838
+ if (process.env.NODE_ENV !== "production" && notifySpy) {
5839
+ spyReportEnd();
5840
+ }
5230
5841
  }
5231
5842
  } finally {
5232
5843
  endBatch();
@@ -5242,7 +5853,10 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
5242
5853
  ;
5243
5854
 
5244
5855
  _proto.observe_ = function observe_(callback, fireImmediately) {
5245
- if (process.env.NODE_ENV !== "production" && fireImmediately === true) die("`observe` doesn't support the fire immediately property for observable objects.");
5856
+ if (process.env.NODE_ENV !== "production" && fireImmediately === true) {
5857
+ die("`observe` doesn't support the fire immediately property for observable objects.");
5858
+ }
5859
+
5246
5860
  return registerListener(this, callback);
5247
5861
  };
5248
5862
 
@@ -5265,9 +5879,18 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
5265
5879
  name: key,
5266
5880
  newValue: value
5267
5881
  } : null;
5268
- if (process.env.NODE_ENV !== "production" && notifySpy) spyReportStart(change);
5269
- if (notify) notifyListeners(this, change);
5270
- if (process.env.NODE_ENV !== "production" && notifySpy) spyReportEnd();
5882
+
5883
+ if (process.env.NODE_ENV !== "production" && notifySpy) {
5884
+ spyReportStart(change);
5885
+ }
5886
+
5887
+ if (notify) {
5888
+ notifyListeners(this, change);
5889
+ }
5890
+
5891
+ if (process.env.NODE_ENV !== "production" && notifySpy) {
5892
+ spyReportEnd();
5893
+ }
5271
5894
  }
5272
5895
 
5273
5896
  (_this$pendingKeys_2 = this.pendingKeys_) == null ? void 0 : (_this$pendingKeys_2$g = _this$pendingKeys_2.get(key)) == null ? void 0 : _this$pendingKeys_2$g.set(true); // Notify "keys/entries/values" observers
@@ -5308,7 +5931,10 @@ function asObservableObject(target, options) {
5308
5931
  return target;
5309
5932
  }
5310
5933
 
5311
- if (process.env.NODE_ENV !== "production" && !Object.isExtensible(target)) die("Cannot make the designated object observable; it is not extensible");
5934
+ if (process.env.NODE_ENV !== "production" && !Object.isExtensible(target)) {
5935
+ die("Cannot make the designated object observable; it is not extensible");
5936
+ }
5937
+
5312
5938
  var name = (_options$name = options == null ? void 0 : options.name) != null ? _options$name : process.env.NODE_ENV !== "production" ? (isPlainObject(target) ? "ObservableObject" : target.constructor.name) + "@" + getNextId() : "ObservableObject";
5313
5939
  var adm = new ObservableObjectAdministration(target, new Map(), String(name), getAnnotationFromOptions(options));
5314
5940
  addHiddenProp(target, $mobx, adm);
@@ -5465,7 +6091,6 @@ var LegacyObservableArray = /*#__PURE__*/function (_StubArray, _Symbol$toStringT
5465
6091
  var nextIndex = 0;
5466
6092
  return makeIterable({
5467
6093
  next: function next() {
5468
- // @ts-ignore
5469
6094
  return nextIndex < self.length ? {
5470
6095
  value: self[nextIndex++],
5471
6096
  done: false
@@ -5498,7 +6123,10 @@ var LegacyObservableArray = /*#__PURE__*/function (_StubArray, _Symbol$toStringT
5498
6123
  Object.entries(arrayExtensions).forEach(function (_ref) {
5499
6124
  var prop = _ref[0],
5500
6125
  fn = _ref[1];
5501
- if (prop !== "concat") addHiddenProp(LegacyObservableArray.prototype, prop, fn);
6126
+
6127
+ if (prop !== "concat") {
6128
+ addHiddenProp(LegacyObservableArray.prototype, prop, fn);
6129
+ }
5502
6130
  });
5503
6131
 
5504
6132
  function createArrayEntryDescriptor(index) {
@@ -5535,7 +6163,10 @@ function createLegacyArray(initialValues, enhancer, name) {
5535
6163
  function getAtom(thing, property) {
5536
6164
  if (typeof thing === "object" && thing !== null) {
5537
6165
  if (isObservableArray(thing)) {
5538
- if (property !== undefined) die(23);
6166
+ if (property !== undefined) {
6167
+ die(23);
6168
+ }
6169
+
5539
6170
  return thing[$mobx].atom_;
5540
6171
  }
5541
6172
 
@@ -5544,18 +6175,31 @@ function getAtom(thing, property) {
5544
6175
  }
5545
6176
 
5546
6177
  if (isObservableMap(thing)) {
5547
- if (property === undefined) return thing.keysAtom_;
6178
+ if (property === undefined) {
6179
+ return thing.keysAtom_;
6180
+ }
6181
+
5548
6182
  var observable = thing.data_.get(property) || thing.hasMap_.get(property);
5549
- if (!observable) die(25, property, getDebugName(thing));
6183
+
6184
+ if (!observable) {
6185
+ die(25, property, getDebugName(thing));
6186
+ }
6187
+
5550
6188
  return observable;
5551
6189
  }
5552
6190
 
6191
+
5553
6192
  if (isObservableObject(thing)) {
5554
- if (!property) return die(26);
6193
+ if (!property) {
6194
+ return die(26);
6195
+ }
5555
6196
 
5556
6197
  var _observable = thing[$mobx].values_.get(property);
5557
6198
 
5558
- if (!_observable) die(27, property, getDebugName(thing));
6199
+ if (!_observable) {
6200
+ die(27, property, getDebugName(thing));
6201
+ }
6202
+
5559
6203
  return _observable;
5560
6204
  }
5561
6205
 
@@ -5572,11 +6216,26 @@ function getAtom(thing, property) {
5572
6216
  die(28);
5573
6217
  }
5574
6218
  function getAdministration(thing, property) {
5575
- if (!thing) die(29);
5576
- if (property !== undefined) return getAdministration(getAtom(thing, property));
5577
- if (isAtom(thing) || isComputedValue(thing) || isReaction(thing)) return thing;
5578
- if (isObservableMap(thing) || isObservableSet(thing)) return thing;
5579
- if (thing[$mobx]) return thing[$mobx];
6219
+ if (!thing) {
6220
+ die(29);
6221
+ }
6222
+
6223
+ if (property !== undefined) {
6224
+ return getAdministration(getAtom(thing, property));
6225
+ }
6226
+
6227
+ if (isAtom(thing) || isComputedValue(thing) || isReaction(thing)) {
6228
+ return thing;
6229
+ }
6230
+
6231
+ if (isObservableMap(thing) || isObservableSet(thing)) {
6232
+ return thing;
6233
+ }
6234
+
6235
+ if (thing[$mobx]) {
6236
+ return thing[$mobx];
6237
+ }
6238
+
5580
6239
  die(24, thing);
5581
6240
  }
5582
6241
  function getDebugName(thing, property) {
@@ -5609,17 +6268,33 @@ function deepEqual(a, b, depth) {
5609
6268
  function eq(a, b, depth, aStack, bStack) {
5610
6269
  // Identical objects are equal. `0 === -0`, but they aren't identical.
5611
6270
  // See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal).
5612
- if (a === b) return a !== 0 || 1 / a === 1 / b; // `null` or `undefined` only equal to itself (strict comparison).
6271
+ if (a === b) {
6272
+ return a !== 0 || 1 / a === 1 / b;
6273
+ } // `null` or `undefined` only equal to itself (strict comparison).
6274
+
6275
+
6276
+ if (a == null || b == null) {
6277
+ return false;
6278
+ } // `NaN`s are equivalent, but non-reflexive.
6279
+
5613
6280
 
5614
- if (a == null || b == null) return false; // `NaN`s are equivalent, but non-reflexive.
6281
+ if (a !== a) {
6282
+ return b !== b;
6283
+ } // Exhaust primitive checks
5615
6284
 
5616
- if (a !== a) return b !== b; // Exhaust primitive checks
5617
6285
 
5618
6286
  var type = typeof a;
5619
- if (type !== "function" && type !== "object" && typeof b != "object") return false; // Compare `[[Class]]` names.
6287
+
6288
+ if (type !== "function" && type !== "object" && typeof b != "object") {
6289
+ return false;
6290
+ } // Compare `[[Class]]` names.
6291
+
5620
6292
 
5621
6293
  var className = toString.call(a);
5622
- if (className !== toString.call(b)) return false;
6294
+
6295
+ if (className !== toString.call(b)) {
6296
+ return false;
6297
+ }
5623
6298
 
5624
6299
  switch (className) {
5625
6300
  // Strings, numbers, regular expressions, dates, and booleans are compared by value.
@@ -5633,7 +6308,10 @@ function eq(a, b, depth, aStack, bStack) {
5633
6308
  case "[object Number]":
5634
6309
  // `NaN`s are equivalent, but non-reflexive.
5635
6310
  // Object(NaN) is equivalent to NaN.
5636
- if (+a !== +a) return +b !== +b; // An `egal` comparison is performed for other numeric values.
6311
+ if (+a !== +a) {
6312
+ return +b !== +b;
6313
+ } // An `egal` comparison is performed for other numeric values.
6314
+
5637
6315
 
5638
6316
  return +a === 0 ? 1 / +a === 1 / b : +a === +b;
5639
6317
 
@@ -5664,9 +6342,12 @@ function eq(a, b, depth, aStack, bStack) {
5664
6342
  var areArrays = className === "[object Array]";
5665
6343
 
5666
6344
  if (!areArrays) {
5667
- if (typeof a != "object" || typeof b != "object") return false; // Objects with different constructors are not equivalent, but `Object`s or `Array`s
6345
+ if (typeof a != "object" || typeof b != "object") {
6346
+ return false;
6347
+ } // Objects with different constructors are not equivalent, but `Object`s or `Array`s
5668
6348
  // from different frames are.
5669
6349
 
6350
+
5670
6351
  var aCtor = a.constructor,
5671
6352
  bCtor = b.constructor;
5672
6353
 
@@ -5692,7 +6373,9 @@ function eq(a, b, depth, aStack, bStack) {
5692
6373
  while (length--) {
5693
6374
  // Linear search. Performance is inversely proportional to the number of
5694
6375
  // unique nested structures.
5695
- if (aStack[length] === a) return bStack[length] === b;
6376
+ if (aStack[length] === a) {
6377
+ return bStack[length] === b;
6378
+ }
5696
6379
  } // Add the first object to the stack of traversed objects.
5697
6380
 
5698
6381
 
@@ -5702,10 +6385,16 @@ function eq(a, b, depth, aStack, bStack) {
5702
6385
  if (areArrays) {
5703
6386
  // Compare array lengths to determine if a deep comparison is necessary.
5704
6387
  length = a.length;
5705
- if (length !== b.length) return false; // Deep compare the contents, ignoring non-numeric properties.
6388
+
6389
+ if (length !== b.length) {
6390
+ return false;
6391
+ } // Deep compare the contents, ignoring non-numeric properties.
6392
+
5706
6393
 
5707
6394
  while (length--) {
5708
- if (!eq(a[length], b[length], depth - 1, aStack, bStack)) return false;
6395
+ if (!eq(a[length], b[length], depth - 1, aStack, bStack)) {
6396
+ return false;
6397
+ }
5709
6398
  }
5710
6399
  } else {
5711
6400
  // Deep compare objects.
@@ -5713,12 +6402,17 @@ function eq(a, b, depth, aStack, bStack) {
5713
6402
  var key;
5714
6403
  length = keys.length; // Ensure that both objects contain the same number of properties before comparing deep equality.
5715
6404
 
5716
- if (Object.keys(b).length !== length) return false;
6405
+ if (Object.keys(b).length !== length) {
6406
+ return false;
6407
+ }
5717
6408
 
5718
6409
  while (length--) {
5719
6410
  // Deep compare each member
5720
6411
  key = keys[length];
5721
- if (!(hasProp(b, key) && eq(a[key], b[key], depth - 1, aStack, bStack))) return false;
6412
+
6413
+ if (!(hasProp(b, key) && eq(a[key], b[key], depth - 1, aStack, bStack))) {
6414
+ return false;
6415
+ }
5722
6416
  }
5723
6417
  } // Remove the first object from the stack of traversed objects.
5724
6418
 
@@ -5729,9 +6423,18 @@ function eq(a, b, depth, aStack, bStack) {
5729
6423
  }
5730
6424
 
5731
6425
  function unwrap(a) {
5732
- if (isObservableArray(a)) return a.slice();
5733
- if (isES6Map(a) || isObservableMap(a)) return Array.from(a.entries());
5734
- if (isES6Set(a) || isObservableSet(a)) return Array.from(a.entries());
6426
+ if (isObservableArray(a)) {
6427
+ return a.slice();
6428
+ }
6429
+
6430
+ if (isES6Map(a) || isObservableMap(a)) {
6431
+ return Array.from(a.entries());
6432
+ }
6433
+
6434
+ if (isES6Set(a) || isObservableSet(a)) {
6435
+ return Array.from(a.entries());
6436
+ }
6437
+
5735
6438
  return a;
5736
6439
  }
5737
6440