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
@@ -27,9 +27,9 @@ var niceErrors = {
27
27
  10: "'has()' can only be used on observable objects, arrays and maps",
28
28
  11: "'get()' can only be used on observable objects, arrays and maps",
29
29
  12: "Invalid annotation",
30
- 13: "Dynamic observable objects cannot be frozen",
30
+ 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)",
31
31
  14: "Intercept handlers should return nothing or a change object",
32
- 15: "Observable arrays cannot be frozen",
32
+ 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)",
33
33
  16: "Modification exception: the internal structure of an observable array was changed.",
34
34
  17: function _(index, length) {
35
35
  return "[mobx.array] Index out of bounds, " + index + " is larger than " + length;
@@ -143,7 +143,10 @@ function getNextId() {
143
143
  function once(func) {
144
144
  var invoked = false;
145
145
  return function () {
146
- if (invoked) return;
146
+ if (invoked) {
147
+ return;
148
+ }
149
+
147
150
  invoked = true;
148
151
  return func.apply(this, arguments);
149
152
  };
@@ -168,17 +171,31 @@ function isObject(value) {
168
171
  return value !== null && typeof value === "object";
169
172
  }
170
173
  function isPlainObject(value) {
171
- if (!isObject(value)) return false;
174
+ if (!isObject(value)) {
175
+ return false;
176
+ }
177
+
172
178
  var proto = Object.getPrototypeOf(value);
173
- if (proto == null) return true;
179
+
180
+ if (proto == null) {
181
+ return true;
182
+ }
183
+
174
184
  var protoConstructor = Object.hasOwnProperty.call(proto, "constructor") && proto.constructor;
175
185
  return typeof protoConstructor === "function" && protoConstructor.toString() === plainObjectString;
176
186
  } // https://stackoverflow.com/a/37865170
177
187
 
178
188
  function isGenerator(obj) {
179
189
  var constructor = obj == null ? void 0 : obj.constructor;
180
- if (!constructor) return false;
181
- if ("GeneratorFunction" === constructor.name || "GeneratorFunction" === constructor.displayName) return true;
190
+
191
+ if (!constructor) {
192
+ return false;
193
+ }
194
+
195
+ if ("GeneratorFunction" === constructor.name || "GeneratorFunction" === constructor.displayName) {
196
+ return true;
197
+ }
198
+
182
199
  return false;
183
200
  }
184
201
  function addHiddenProp(object, propName, value) {
@@ -218,9 +235,16 @@ var hasGetOwnPropertySymbols = typeof Object.getOwnPropertySymbols !== "undefine
218
235
  function getPlainObjectKeys(object) {
219
236
  var keys = Object.keys(object); // Not supported in IE, so there are not going to be symbol props anyway...
220
237
 
221
- if (!hasGetOwnPropertySymbols) return keys;
238
+ if (!hasGetOwnPropertySymbols) {
239
+ return keys;
240
+ }
241
+
222
242
  var symbols = Object.getOwnPropertySymbols(object);
223
- if (!symbols.length) return keys;
243
+
244
+ if (!symbols.length) {
245
+ return keys;
246
+ }
247
+
224
248
  return [].concat(keys, symbols.filter(function (s) {
225
249
  return objectPrototype.propertyIsEnumerable.call(object, s);
226
250
  }));
@@ -233,8 +257,14 @@ var ownKeys = typeof Reflect !== "undefined" && Reflect.ownKeys ? Reflect.ownKey
233
257
  /* istanbul ignore next */
234
258
  Object.getOwnPropertyNames;
235
259
  function stringifyKey(key) {
236
- if (typeof key === "string") return key;
237
- if (typeof key === "symbol") return key.toString();
260
+ if (typeof key === "string") {
261
+ return key;
262
+ }
263
+
264
+ if (typeof key === "symbol") {
265
+ return key.toString();
266
+ }
267
+
238
268
  return new String(key).toString();
239
269
  }
240
270
  function toPrimitive(value) {
@@ -522,7 +552,10 @@ function shallowComparer(a, b) {
522
552
  }
523
553
 
524
554
  function defaultComparer(a, b) {
525
- if (Object.is) return Object.is(a, b);
555
+ if (Object.is) {
556
+ return Object.is(a, b);
557
+ }
558
+
526
559
  return a === b ? a !== 0 || 1 / a === 1 / b : a !== a && b !== b;
527
560
  }
528
561
 
@@ -535,20 +568,34 @@ var comparer = {
535
568
 
536
569
  function deepEnhancer(v, _, name) {
537
570
  // it is an observable already, done
538
- if (isObservable(v)) return v; // something that can be converted and mutated?
571
+ if (isObservable(v)) {
572
+ return v;
573
+ } // something that can be converted and mutated?
539
574
 
540
- if (Array.isArray(v)) return observable.array(v, {
541
- name: name
542
- });
543
- if (isPlainObject(v)) return observable.object(v, undefined, {
544
- name: name
545
- });
546
- if (isES6Map(v)) return observable.map(v, {
547
- name: name
548
- });
549
- if (isES6Set(v)) return observable.set(v, {
550
- name: name
551
- });
575
+
576
+ if (Array.isArray(v)) {
577
+ return observable.array(v, {
578
+ name: name
579
+ });
580
+ }
581
+
582
+ if (isPlainObject(v)) {
583
+ return observable.object(v, undefined, {
584
+ name: name
585
+ });
586
+ }
587
+
588
+ if (isES6Map(v)) {
589
+ return observable.map(v, {
590
+ name: name
591
+ });
592
+ }
593
+
594
+ if (isES6Set(v)) {
595
+ return observable.set(v, {
596
+ name: name
597
+ });
598
+ }
552
599
 
553
600
  if (typeof v === "function" && !isAction(v) && !isFlow(v)) {
554
601
  if (isGenerator(v)) {
@@ -561,33 +608,59 @@ function deepEnhancer(v, _, name) {
561
608
  return v;
562
609
  }
563
610
  function shallowEnhancer(v, _, name) {
564
- if (v === undefined || v === null) return v;
565
- if (isObservableObject(v) || isObservableArray(v) || isObservableMap(v) || isObservableSet(v)) return v;
566
- if (Array.isArray(v)) return observable.array(v, {
567
- name: name,
568
- deep: false
569
- });
570
- if (isPlainObject(v)) return observable.object(v, undefined, {
571
- name: name,
572
- deep: false
573
- });
574
- if (isES6Map(v)) return observable.map(v, {
575
- name: name,
576
- deep: false
577
- });
578
- if (isES6Set(v)) return observable.set(v, {
579
- name: name,
580
- deep: false
581
- });
582
- die("The shallow modifier / decorator can only used in combination with arrays, objects, maps and sets");
611
+ if (v === undefined || v === null) {
612
+ return v;
613
+ }
614
+
615
+ if (isObservableObject(v) || isObservableArray(v) || isObservableMap(v) || isObservableSet(v)) {
616
+ return v;
617
+ }
618
+
619
+ if (Array.isArray(v)) {
620
+ return observable.array(v, {
621
+ name: name,
622
+ deep: false
623
+ });
624
+ }
625
+
626
+ if (isPlainObject(v)) {
627
+ return observable.object(v, undefined, {
628
+ name: name,
629
+ deep: false
630
+ });
631
+ }
632
+
633
+ if (isES6Map(v)) {
634
+ return observable.map(v, {
635
+ name: name,
636
+ deep: false
637
+ });
638
+ }
639
+
640
+ if (isES6Set(v)) {
641
+ return observable.set(v, {
642
+ name: name,
643
+ deep: false
644
+ });
645
+ }
646
+
647
+ {
648
+ die("The shallow modifier / decorator can only used in combination with arrays, objects, maps and sets");
649
+ }
583
650
  }
584
651
  function referenceEnhancer(newValue) {
585
652
  // never turn into an observable
586
653
  return newValue;
587
654
  }
588
655
  function refStructEnhancer(v, oldValue) {
589
- if ( isObservable(v)) die("observable.struct should not be used with observable values");
590
- if (deepEqual(v, oldValue)) return oldValue;
656
+ if ( isObservable(v)) {
657
+ die("observable.struct should not be used with observable values");
658
+ }
659
+
660
+ if (deepEqual(v, oldValue)) {
661
+ return oldValue;
662
+ }
663
+
591
664
  return v;
592
665
  }
593
666
 
@@ -735,10 +808,12 @@ function make_$2(adm, key, descriptor, source) {
735
808
  // bound - must annotate protos to support super.flow()
736
809
 
737
810
 
738
- if ((_this$options_ = this.options_) != null && _this$options_.bound && !isFlow(adm.target_[key])) {
739
- if (this.extend_(adm, key, descriptor, false) === null) return 0
740
- /* Cancel */
741
- ;
811
+ if ((_this$options_ = this.options_) != null && _this$options_.bound && (!hasProp(adm.target_, key) || !isFlow(adm.target_[key]))) {
812
+ if (this.extend_(adm, key, descriptor, false) === null) {
813
+ return 0
814
+ /* Cancel */
815
+ ;
816
+ }
742
817
  }
743
818
 
744
819
  if (isFlow(descriptor.value)) {
@@ -779,16 +854,23 @@ safeDescriptors) {
779
854
  }
780
855
 
781
856
  assertFlowDescriptor(adm, annotation, key, descriptor);
782
- var value = descriptor.value;
857
+ var value = descriptor.value; // In case of flow.bound, the descriptor can be from already annotated prototype
858
+
859
+ if (!isFlow(value)) {
860
+ value = flow(value);
861
+ }
783
862
 
784
863
  if (bound) {
785
864
  var _adm$proxy_;
786
865
 
787
- value = value.bind((_adm$proxy_ = adm.proxy_) != null ? _adm$proxy_ : adm.target_);
866
+ // We do not keep original function around, so we bind the existing flow
867
+ value = value.bind((_adm$proxy_ = adm.proxy_) != null ? _adm$proxy_ : adm.target_); // This is normally set by `flow`, but `bind` returns new function...
868
+
869
+ value.isMobXFlow = true;
788
870
  }
789
871
 
790
872
  return {
791
- value: flow(value),
873
+ value: value,
792
874
  // Non-configurable for classes
793
875
  // prevents accidental field redefinition in subclass
794
876
  configurable: safeDescriptors ? adm.isPlainObject_ : true,
@@ -1022,17 +1104,35 @@ function createObservable(v, arg2, arg3) {
1022
1104
  } // already observable - ignore
1023
1105
 
1024
1106
 
1025
- if (isObservable(v)) return v; // plain object
1107
+ if (isObservable(v)) {
1108
+ return v;
1109
+ } // plain object
1026
1110
 
1027
- if (isPlainObject(v)) return observable.object(v, arg2, arg3); // Array
1028
1111
 
1029
- if (Array.isArray(v)) return observable.array(v, arg2); // Map
1112
+ if (isPlainObject(v)) {
1113
+ return observable.object(v, arg2, arg3);
1114
+ } // Array
1030
1115
 
1031
- if (isES6Map(v)) return observable.map(v, arg2); // Set
1032
1116
 
1033
- if (isES6Set(v)) return observable.set(v, arg2); // other object - ignore
1117
+ if (Array.isArray(v)) {
1118
+ return observable.array(v, arg2);
1119
+ } // Map
1120
+
1121
+
1122
+ if (isES6Map(v)) {
1123
+ return observable.map(v, arg2);
1124
+ } // Set
1125
+
1126
+
1127
+ if (isES6Set(v)) {
1128
+ return observable.set(v, arg2);
1129
+ } // other object - ignore
1130
+
1131
+
1132
+ if (typeof v === "object" && v !== null) {
1133
+ return v;
1134
+ } // anything else
1034
1135
 
1035
- if (typeof v === "object" && v !== null) return v; // anything else
1036
1136
 
1037
1137
  return observable.box(v, arg2);
1038
1138
  }
@@ -1090,8 +1190,13 @@ var computed = function computed(arg1, arg2) {
1090
1190
 
1091
1191
 
1092
1192
  {
1093
- if (!isFunction(arg1)) die("First argument to `computed` should be an expression.");
1094
- if (isFunction(arg2)) die("A setter as second argument is no longer supported, use `{ set: fn }` option instead");
1193
+ if (!isFunction(arg1)) {
1194
+ die("First argument to `computed` should be an expression.");
1195
+ }
1196
+
1197
+ if (isFunction(arg2)) {
1198
+ die("A setter as second argument is no longer supported, use `{ set: fn }` option instead");
1199
+ }
1095
1200
  }
1096
1201
 
1097
1202
  var opts = isPlainObject(arg2) ? arg2 : {};
@@ -1123,8 +1228,13 @@ function createAction(actionName, fn, autoAction, ref) {
1123
1228
  }
1124
1229
 
1125
1230
  {
1126
- if (!isFunction(fn)) die("`action` can only be invoked on functions");
1127
- if (typeof actionName !== "string" || !actionName) die("actions should have valid names, got: '" + actionName + "'");
1231
+ if (!isFunction(fn)) {
1232
+ die("`action` can only be invoked on functions");
1233
+ }
1234
+
1235
+ if (typeof actionName !== "string" || !actionName) {
1236
+ die("actions should have valid names, got: '" + actionName + "'");
1237
+ }
1128
1238
  }
1129
1239
 
1130
1240
  function res() {
@@ -1206,7 +1316,10 @@ function _endAction(runInfo) {
1206
1316
  allowStateChangesEnd(runInfo.prevAllowStateChanges_);
1207
1317
  allowStateReadsEnd(runInfo.prevAllowStateReads_);
1208
1318
  endBatch();
1209
- if (runInfo.runAsAction_) untrackedEnd(runInfo.prevDerivation_);
1319
+
1320
+ if (runInfo.runAsAction_) {
1321
+ untrackedEnd(runInfo.prevDerivation_);
1322
+ }
1210
1323
 
1211
1324
  if ( runInfo.notifySpy_) {
1212
1325
  spyReportEnd({
@@ -1286,7 +1399,10 @@ var ObservableValue = /*#__PURE__*/function (_Atom, _Symbol$toPrimitive2) {
1286
1399
  var _proto = ObservableValue.prototype;
1287
1400
 
1288
1401
  _proto.dehanceValue = function dehanceValue(value) {
1289
- if (this.dehancer !== undefined) return this.dehancer(value);
1402
+ if (this.dehancer !== undefined) {
1403
+ return this.dehancer(value);
1404
+ }
1405
+
1290
1406
  return value;
1291
1407
  };
1292
1408
 
@@ -1309,7 +1425,10 @@ var ObservableValue = /*#__PURE__*/function (_Atom, _Symbol$toPrimitive2) {
1309
1425
  }
1310
1426
 
1311
1427
  this.setNewValue_(newValue);
1312
- if ( notifySpy) spyReportEnd();
1428
+
1429
+ if ( notifySpy) {
1430
+ spyReportEnd();
1431
+ }
1313
1432
  }
1314
1433
  };
1315
1434
 
@@ -1322,7 +1441,11 @@ var ObservableValue = /*#__PURE__*/function (_Atom, _Symbol$toPrimitive2) {
1322
1441
  type: UPDATE,
1323
1442
  newValue: newValue
1324
1443
  });
1325
- if (!change) return globalState.UNCHANGED;
1444
+
1445
+ if (!change) {
1446
+ return globalState.UNCHANGED;
1447
+ }
1448
+
1326
1449
  newValue = change.newValue;
1327
1450
  } // apply modifier
1328
1451
 
@@ -1356,14 +1479,17 @@ var ObservableValue = /*#__PURE__*/function (_Atom, _Symbol$toPrimitive2) {
1356
1479
  };
1357
1480
 
1358
1481
  _proto.observe_ = function observe_(listener, fireImmediately) {
1359
- if (fireImmediately) listener({
1360
- observableKind: "value",
1361
- debugObjectName: this.name_,
1362
- object: this,
1363
- type: UPDATE,
1364
- newValue: this.value_,
1365
- oldValue: undefined
1366
- });
1482
+ if (fireImmediately) {
1483
+ listener({
1484
+ observableKind: "value",
1485
+ debugObjectName: this.name_,
1486
+ object: this,
1487
+ type: UPDATE,
1488
+ newValue: this.value_,
1489
+ oldValue: undefined
1490
+ });
1491
+ }
1492
+
1367
1493
  return registerListener(this, listener);
1368
1494
  };
1369
1495
 
@@ -1458,7 +1584,11 @@ var ComputedValue = /*#__PURE__*/function (_Symbol$toPrimitive2) {
1458
1584
  this.keepAlive_ = void 0;
1459
1585
  this.onBOL = void 0;
1460
1586
  this.onBUOL = void 0;
1461
- if (!options.get) die(31);
1587
+
1588
+ if (!options.get) {
1589
+ die(31);
1590
+ }
1591
+
1462
1592
  this.derivation = options.get;
1463
1593
  this.name_ = options.name || ( "ComputedValue@" + getNextId() );
1464
1594
 
@@ -1500,7 +1630,9 @@ var ComputedValue = /*#__PURE__*/function (_Symbol$toPrimitive2) {
1500
1630
  ;
1501
1631
 
1502
1632
  _proto.get = function get() {
1503
- if (this.isComputing_) die(32, this.name_, this.derivation);
1633
+ if (this.isComputing_) {
1634
+ die(32, this.name_, this.derivation);
1635
+ }
1504
1636
 
1505
1637
  if (globalState.inBatch === 0 && // !globalState.trackingDerivatpion &&
1506
1638
  this.observers_.size === 0 && !this.keepAlive_) {
@@ -1516,20 +1648,34 @@ var ComputedValue = /*#__PURE__*/function (_Symbol$toPrimitive2) {
1516
1648
 
1517
1649
  if (shouldCompute(this)) {
1518
1650
  var prevTrackingContext = globalState.trackingContext;
1519
- if (this.keepAlive_ && !prevTrackingContext) globalState.trackingContext = this;
1520
- if (this.trackAndCompute()) propagateChangeConfirmed(this);
1651
+
1652
+ if (this.keepAlive_ && !prevTrackingContext) {
1653
+ globalState.trackingContext = this;
1654
+ }
1655
+
1656
+ if (this.trackAndCompute()) {
1657
+ propagateChangeConfirmed(this);
1658
+ }
1659
+
1521
1660
  globalState.trackingContext = prevTrackingContext;
1522
1661
  }
1523
1662
  }
1524
1663
 
1525
1664
  var result = this.value_;
1526
- if (isCaughtException(result)) throw result.cause;
1665
+
1666
+ if (isCaughtException(result)) {
1667
+ throw result.cause;
1668
+ }
1669
+
1527
1670
  return result;
1528
1671
  };
1529
1672
 
1530
1673
  _proto.set = function set(value) {
1531
1674
  if (this.setter_) {
1532
- if (this.isRunningSetter_) die(33, this.name_);
1675
+ if (this.isRunningSetter_) {
1676
+ die(33, this.name_);
1677
+ }
1678
+
1533
1679
  this.isRunningSetter_ = true;
1534
1680
 
1535
1681
  try {
@@ -1537,7 +1683,9 @@ var ComputedValue = /*#__PURE__*/function (_Symbol$toPrimitive2) {
1537
1683
  } finally {
1538
1684
  this.isRunningSetter_ = false;
1539
1685
  }
1540
- } else die(34, this.name_);
1686
+ } else {
1687
+ die(34, this.name_);
1688
+ }
1541
1689
  };
1542
1690
 
1543
1691
  _proto.trackAndCompute = function trackAndCompute() {
@@ -1766,7 +1914,9 @@ function checkIfStateModificationsAreAllowed(atom) {
1766
1914
 
1767
1915
  var hasObservers = atom.observers_.size > 0; // Should not be possible to change observed state outside strict mode, except during initialization, see #563
1768
1916
 
1769
- 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_);
1917
+ if (!globalState.allowStateChanges && (hasObservers || globalState.enforceActions === "always")) {
1918
+ 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_);
1919
+ }
1770
1920
  }
1771
1921
  function checkIfStateReadsAreAllowed(observable) {
1772
1922
  if ( !globalState.allowStateReads && globalState.observableRequiresReaction) {
@@ -1811,7 +1961,10 @@ function trackDerivedFunction(derivation, f, context) {
1811
1961
  }
1812
1962
 
1813
1963
  function warnAboutDerivationWithoutDependencies(derivation) {
1814
- if (derivation.observing_.length !== 0) return;
1964
+
1965
+ if (derivation.observing_.length !== 0) {
1966
+ return;
1967
+ }
1815
1968
 
1816
1969
  if (globalState.reactionRequiresObservable || derivation.requiresObservable_) {
1817
1970
  console.warn("[mobx] Derivation '" + derivation.name_ + "' is created/updated without reading any observable value.");
@@ -1840,7 +1993,11 @@ function bindDependencies(derivation) {
1840
1993
 
1841
1994
  if (dep.diffValue_ === 0) {
1842
1995
  dep.diffValue_ = 1;
1843
- if (i0 !== i) observing[i0] = dep;
1996
+
1997
+ if (i0 !== i) {
1998
+ observing[i0] = dep;
1999
+ }
2000
+
1844
2001
  i0++;
1845
2002
  } // Upcast is 'safe' here, because if dep is IObservable, `dependenciesState` will be undefined,
1846
2003
  // not hitting the condition
@@ -1932,7 +2089,10 @@ function allowStateReadsEnd(prev) {
1932
2089
  */
1933
2090
 
1934
2091
  function changeDependenciesStateTo0(derivation) {
1935
- if (derivation.dependenciesState_ === IDerivationState_.UP_TO_DATE_) return;
2092
+ if (derivation.dependenciesState_ === IDerivationState_.UP_TO_DATE_) {
2093
+ return;
2094
+ }
2095
+
1936
2096
  derivation.dependenciesState_ = IDerivationState_.UP_TO_DATE_;
1937
2097
  var obs = derivation.observing_;
1938
2098
  var i = obs.length;
@@ -1976,8 +2136,14 @@ var canMergeGlobalState = true;
1976
2136
  var isolateCalled = false;
1977
2137
  var globalState = /*#__PURE__*/function () {
1978
2138
  var global = /*#__PURE__*/getGlobal();
1979
- if (global.__mobxInstanceCount > 0 && !global.__mobxGlobals) canMergeGlobalState = false;
1980
- if (global.__mobxGlobals && global.__mobxGlobals.version !== new MobXGlobals().version) canMergeGlobalState = false;
2139
+
2140
+ if (global.__mobxInstanceCount > 0 && !global.__mobxGlobals) {
2141
+ canMergeGlobalState = false;
2142
+ }
2143
+
2144
+ if (global.__mobxGlobals && global.__mobxGlobals.version !== new MobXGlobals().version) {
2145
+ canMergeGlobalState = false;
2146
+ }
1981
2147
 
1982
2148
  if (!canMergeGlobalState) {
1983
2149
  // Because this is a IIFE we need to let isolateCalled a chance to change
@@ -1990,7 +2156,11 @@ var globalState = /*#__PURE__*/function () {
1990
2156
  return new MobXGlobals();
1991
2157
  } else if (global.__mobxGlobals) {
1992
2158
  global.__mobxInstanceCount += 1;
1993
- if (!global.__mobxGlobals.UNCHANGED) global.__mobxGlobals.UNCHANGED = {}; // make merge backward compatible
2159
+
2160
+ if (!global.__mobxGlobals.UNCHANGED) {
2161
+ global.__mobxGlobals.UNCHANGED = {};
2162
+ } // make merge backward compatible
2163
+
1994
2164
 
1995
2165
  return global.__mobxGlobals;
1996
2166
  } else {
@@ -1999,12 +2169,19 @@ var globalState = /*#__PURE__*/function () {
1999
2169
  }
2000
2170
  }();
2001
2171
  function isolateGlobalState() {
2002
- if (globalState.pendingReactions.length || globalState.inBatch || globalState.isRunningReactions) die(36);
2172
+ if (globalState.pendingReactions.length || globalState.inBatch || globalState.isRunningReactions) {
2173
+ die(36);
2174
+ }
2175
+
2003
2176
  isolateCalled = true;
2004
2177
 
2005
2178
  if (canMergeGlobalState) {
2006
2179
  var global = getGlobal();
2007
- if (--global.__mobxInstanceCount === 0) global.__mobxGlobals = undefined;
2180
+
2181
+ if (--global.__mobxInstanceCount === 0) {
2182
+ global.__mobxGlobals = undefined;
2183
+ }
2184
+
2008
2185
  globalState = new MobXGlobals();
2009
2186
  }
2010
2187
  }
@@ -2020,7 +2197,9 @@ function resetGlobalState() {
2020
2197
  var defaultGlobals = new MobXGlobals();
2021
2198
 
2022
2199
  for (var key in defaultGlobals) {
2023
- if (persistentKeys.indexOf(key) === -1) globalState[key] = defaultGlobals[key];
2200
+ if (persistentKeys.indexOf(key) === -1) {
2201
+ globalState[key] = defaultGlobals[key];
2202
+ }
2024
2203
  }
2025
2204
 
2026
2205
  globalState.allowStateChanges = !globalState.enforceActions;
@@ -2054,8 +2233,12 @@ function addObserver(observable, node) {
2054
2233
  // invariant(observable._observers.indexOf(node) === -1, "INTERNAL ERROR add already added node");
2055
2234
  // invariantObservers(observable);
2056
2235
  observable.observers_.add(node);
2057
- if (observable.lowestObserverState_ > node.dependenciesState_) observable.lowestObserverState_ = node.dependenciesState_; // invariantObservers(observable);
2236
+
2237
+ if (observable.lowestObserverState_ > node.dependenciesState_) {
2238
+ observable.lowestObserverState_ = node.dependenciesState_;
2239
+ } // invariantObservers(observable);
2058
2240
  // invariant(observable._observers.indexOf(node) !== -1, "INTERNAL ERROR didn't add node");
2241
+
2059
2242
  }
2060
2243
  function removeObserver(observable, node) {
2061
2244
  // invariant(globalState.inBatch > 0, "INTERNAL ERROR, remove should be called only inside batch");
@@ -2166,7 +2349,10 @@ function reportObserved(observable) {
2166
2349
 
2167
2350
  function propagateChanged(observable) {
2168
2351
  // invariantLOS(observable, "changed start");
2169
- if (observable.lowestObserverState_ === IDerivationState_.STALE_) return;
2352
+ if (observable.lowestObserverState_ === IDerivationState_.STALE_) {
2353
+ return;
2354
+ }
2355
+
2170
2356
  observable.lowestObserverState_ = IDerivationState_.STALE_; // Ideally we use for..of here, but the downcompiled version is really slow...
2171
2357
 
2172
2358
  observable.observers_.forEach(function (d) {
@@ -2184,7 +2370,10 @@ function propagateChanged(observable) {
2184
2370
 
2185
2371
  function propagateChangeConfirmed(observable) {
2186
2372
  // invariantLOS(observable, "confirmed start");
2187
- if (observable.lowestObserverState_ === IDerivationState_.STALE_) return;
2373
+ if (observable.lowestObserverState_ === IDerivationState_.STALE_) {
2374
+ return;
2375
+ }
2376
+
2188
2377
  observable.lowestObserverState_ = IDerivationState_.STALE_;
2189
2378
  observable.observers_.forEach(function (d) {
2190
2379
  if (d.dependenciesState_ === IDerivationState_.POSSIBLY_STALE_) {
@@ -2202,7 +2391,10 @@ function propagateChangeConfirmed(observable) {
2202
2391
 
2203
2392
  function propagateMaybeChanged(observable) {
2204
2393
  // invariantLOS(observable, "maybe start");
2205
- if (observable.lowestObserverState_ !== IDerivationState_.UP_TO_DATE_) return;
2394
+ if (observable.lowestObserverState_ !== IDerivationState_.UP_TO_DATE_) {
2395
+ return;
2396
+ }
2397
+
2206
2398
  observable.lowestObserverState_ = IDerivationState_.POSSIBLY_STALE_;
2207
2399
  observable.observers_.forEach(function (d) {
2208
2400
  if (d.dependenciesState_ === IDerivationState_.UP_TO_DATE_) {
@@ -2230,9 +2422,12 @@ function printDepTree(tree, lines, depth) {
2230
2422
  }
2231
2423
 
2232
2424
  lines.push("" + "\t".repeat(depth - 1) + tree.name);
2233
- if (tree.dependencies) tree.dependencies.forEach(function (child) {
2234
- return printDepTree(child, lines, depth + 1);
2235
- });
2425
+
2426
+ if (tree.dependencies) {
2427
+ tree.dependencies.forEach(function (child) {
2428
+ return printDepTree(child, lines, depth + 1);
2429
+ });
2430
+ }
2236
2431
  }
2237
2432
 
2238
2433
  var Reaction = /*#__PURE__*/function () {
@@ -2350,7 +2545,9 @@ var Reaction = /*#__PURE__*/function () {
2350
2545
  clearObserving(this);
2351
2546
  }
2352
2547
 
2353
- if (isCaughtException(result)) this.reportExceptionInDerivation_(result.cause);
2548
+ if (isCaughtException(result)) {
2549
+ this.reportExceptionInDerivation_(result.cause);
2550
+ }
2354
2551
 
2355
2552
  if ( notify) {
2356
2553
  spyReportEnd({
@@ -2369,13 +2566,18 @@ var Reaction = /*#__PURE__*/function () {
2369
2566
  return;
2370
2567
  }
2371
2568
 
2372
- if (globalState.disableErrorBoundaries) throw error;
2569
+ if (globalState.disableErrorBoundaries) {
2570
+ throw error;
2571
+ }
2572
+
2373
2573
  var message = "[mobx] Encountered an uncaught exception that was thrown by a reaction or observer component, in: '" + this + "'" ;
2374
2574
 
2375
2575
  if (!globalState.suppressReactionErrors) {
2376
2576
  console.error(message, error);
2377
2577
  /** If debugging brought you here, please, read the above message :-). Tnx! */
2378
- } else console.warn("[mobx] (error in reaction '" + this.name_ + "' suppressed, fix error of causing action below)"); // prettier-ignore
2578
+ } else {
2579
+ console.warn("[mobx] (error in reaction '" + this.name_ + "' suppressed, fix error of causing action below)");
2580
+ } // prettier-ignore
2379
2581
 
2380
2582
 
2381
2583
  if ( isSpyEnabled()) {
@@ -2429,7 +2631,10 @@ function onReactionError(handler) {
2429
2631
  globalState.globalReactionErrorHandlers.push(handler);
2430
2632
  return function () {
2431
2633
  var idx = globalState.globalReactionErrorHandlers.indexOf(handler);
2432
- if (idx >= 0) globalState.globalReactionErrorHandlers.splice(idx, 1);
2634
+
2635
+ if (idx >= 0) {
2636
+ globalState.globalReactionErrorHandlers.splice(idx, 1);
2637
+ }
2433
2638
  };
2434
2639
  }
2435
2640
  /**
@@ -2446,7 +2651,10 @@ var reactionScheduler = function reactionScheduler(f) {
2446
2651
 
2447
2652
  function runReactions() {
2448
2653
  // Trampolining, if runReactions are already running, new reactions will be picked up
2449
- if (globalState.inBatch > 0 || globalState.isRunningReactions) return;
2654
+ if (globalState.inBatch > 0 || globalState.isRunningReactions) {
2655
+ return;
2656
+ }
2657
+
2450
2658
  reactionScheduler(runReactionsHelper);
2451
2659
  }
2452
2660
 
@@ -2489,7 +2697,11 @@ function isSpyEnabled() {
2489
2697
  }
2490
2698
  function spyReport(event) {
2491
2699
 
2492
- if (!globalState.spyListeners.length) return;
2700
+
2701
+ if (!globalState.spyListeners.length) {
2702
+ return;
2703
+ }
2704
+
2493
2705
  var listeners = globalState.spyListeners;
2494
2706
 
2495
2707
  for (var i = 0, l = listeners.length; i < l; i++) {
@@ -2509,10 +2721,15 @@ var END_EVENT = {
2509
2721
  spyReportEnd: true
2510
2722
  };
2511
2723
  function spyReportEnd(change) {
2512
- if (change) spyReport(_extends({}, change, {
2513
- type: "report-end",
2514
- spyReportEnd: true
2515
- }));else spyReport(END_EVENT);
2724
+
2725
+ if (change) {
2726
+ spyReport(_extends({}, change, {
2727
+ type: "report-end",
2728
+ spyReportEnd: true
2729
+ }));
2730
+ } else {
2731
+ spyReport(END_EVENT);
2732
+ }
2516
2733
  }
2517
2734
  function spy(listener) {
2518
2735
  {
@@ -2545,9 +2762,15 @@ var autoActionBoundAnnotation = /*#__PURE__*/createActionAnnotation(AUTOACTION_B
2545
2762
  function createActionFactory(autoAction) {
2546
2763
  var res = function action(arg1, arg2) {
2547
2764
  // action(fn() {})
2548
- if (isFunction(arg1)) return createAction(arg1.name || DEFAULT_ACTION_NAME, arg1, autoAction); // action("name", fn() {})
2765
+ if (isFunction(arg1)) {
2766
+ return createAction(arg1.name || DEFAULT_ACTION_NAME, arg1, autoAction);
2767
+ } // action("name", fn() {})
2768
+
2769
+
2770
+ if (isFunction(arg2)) {
2771
+ return createAction(arg1, arg2, autoAction);
2772
+ } // @action
2549
2773
 
2550
- if (isFunction(arg2)) return createAction(arg1, arg2, autoAction); // @action
2551
2774
 
2552
2775
  if (isStringish(arg2)) {
2553
2776
  return storeAnnotation(arg1, arg2, autoAction ? autoActionAnnotation : actionAnnotation);
@@ -2561,7 +2784,9 @@ function createActionFactory(autoAction) {
2561
2784
  }));
2562
2785
  }
2563
2786
 
2564
- die("Invalid arguments for `action`");
2787
+ {
2788
+ die("Invalid arguments for `action`");
2789
+ }
2565
2790
  };
2566
2791
 
2567
2792
  return res;
@@ -2595,8 +2820,13 @@ function autorun(view, opts) {
2595
2820
  }
2596
2821
 
2597
2822
  {
2598
- if (!isFunction(view)) die("Autorun expects a function as first argument");
2599
- if (isAction(view)) die("Autorun does not accept actions since actions are untrackable");
2823
+ if (!isFunction(view)) {
2824
+ die("Autorun expects a function as first argument");
2825
+ }
2826
+
2827
+ if (isAction(view)) {
2828
+ die("Autorun does not accept actions since actions are untrackable");
2829
+ }
2600
2830
  }
2601
2831
 
2602
2832
  var name = (_opts$name = (_opts = opts) == null ? void 0 : _opts.name) != null ? _opts$name : view.name || "Autorun@" + getNextId() ;
@@ -2617,7 +2847,10 @@ function autorun(view, opts) {
2617
2847
  isScheduled = true;
2618
2848
  scheduler(function () {
2619
2849
  isScheduled = false;
2620
- if (!reaction.isDisposed_) reaction.track(reactionRunner);
2850
+
2851
+ if (!reaction.isDisposed_) {
2852
+ reaction.track(reactionRunner);
2853
+ }
2621
2854
  });
2622
2855
  }
2623
2856
  }, opts.onError, opts.requiresObservable);
@@ -2649,8 +2882,13 @@ function reaction(expression, effect, opts) {
2649
2882
  }
2650
2883
 
2651
2884
  {
2652
- if (!isFunction(expression) || !isFunction(effect)) die("First and second argument to reaction should be functions");
2653
- if (!isPlainObject(opts)) die("Third argument of reactions should be an object");
2885
+ if (!isFunction(expression) || !isFunction(effect)) {
2886
+ die("First and second argument to reaction should be functions");
2887
+ }
2888
+
2889
+ if (!isPlainObject(opts)) {
2890
+ die("Third argument of reactions should be an object");
2891
+ }
2654
2892
  }
2655
2893
 
2656
2894
  var name = (_opts$name2 = opts.name) != null ? _opts$name2 : "Reaction@" + getNextId() ;
@@ -2673,7 +2911,11 @@ function reaction(expression, effect, opts) {
2673
2911
 
2674
2912
  function reactionRunner() {
2675
2913
  isScheduled = false;
2676
- if (r.isDisposed_) return;
2914
+
2915
+ if (r.isDisposed_) {
2916
+ return;
2917
+ }
2918
+
2677
2919
  var changed = false;
2678
2920
  r.track(function () {
2679
2921
  var nextValue = allowStateChanges(false, function () {
@@ -2683,7 +2925,13 @@ function reaction(expression, effect, opts) {
2683
2925
  oldValue = value;
2684
2926
  value = nextValue;
2685
2927
  });
2686
- if (firstTime && opts.fireImmediately) effectAction(value, oldValue, r);else if (!firstTime && changed) effectAction(value, oldValue, r);
2928
+
2929
+ if (firstTime && opts.fireImmediately) {
2930
+ effectAction(value, oldValue, r);
2931
+ } else if (!firstTime && changed) {
2932
+ effectAction(value, oldValue, r);
2933
+ }
2934
+
2687
2935
  firstTime = false;
2688
2936
  }
2689
2937
 
@@ -2750,7 +2998,9 @@ function configure(options) {
2750
2998
  globalState.useProxies = useProxies === ALWAYS ? true : useProxies === NEVER ? false : typeof Proxy !== "undefined";
2751
2999
  }
2752
3000
 
2753
- if (useProxies === "ifavailable") globalState.verifyProxies = true;
3001
+ if (useProxies === "ifavailable") {
3002
+ globalState.verifyProxies = true;
3003
+ }
2754
3004
 
2755
3005
  if (enforceActions !== undefined) {
2756
3006
  var ea = enforceActions === ALWAYS ? ALWAYS : enforceActions === OBSERVED;
@@ -2758,7 +3008,9 @@ function configure(options) {
2758
3008
  globalState.allowStateChanges = ea === true || ea === ALWAYS ? false : true;
2759
3009
  }
2760
3010
  ["computedRequiresReaction", "reactionRequiresObservable", "observableRequiresReaction", "disableErrorBoundaries", "safeDescriptors"].forEach(function (key) {
2761
- if (key in options) globalState[key] = !!options[key];
3011
+ if (key in options) {
3012
+ globalState[key] = !!options[key];
3013
+ }
2762
3014
  });
2763
3015
  globalState.allowStateReads = !globalState.observableRequiresReaction;
2764
3016
 
@@ -2773,11 +3025,25 @@ function configure(options) {
2773
3025
 
2774
3026
  function extendObservable(target, properties, annotations, options) {
2775
3027
  {
2776
- if (arguments.length > 4) die("'extendObservable' expected 2-4 arguments");
2777
- if (typeof target !== "object") die("'extendObservable' expects an object as first argument");
2778
- if (isObservableMap(target)) die("'extendObservable' should not be used on maps, use map.merge instead");
2779
- if (!isPlainObject(properties)) die("'extendObservable' only accepts plain objects as second argument");
2780
- if (isObservable(properties) || isObservable(annotations)) die("Extending an object with another observable (object) is not supported");
3028
+ if (arguments.length > 4) {
3029
+ die("'extendObservable' expected 2-4 arguments");
3030
+ }
3031
+
3032
+ if (typeof target !== "object") {
3033
+ die("'extendObservable' expects an object as first argument");
3034
+ }
3035
+
3036
+ if (isObservableMap(target)) {
3037
+ die("'extendObservable' should not be used on maps, use map.merge instead");
3038
+ }
3039
+
3040
+ if (!isPlainObject(properties)) {
3041
+ die("'extendObservable' only accepts plain objects as second argument");
3042
+ }
3043
+
3044
+ if (isObservable(properties) || isObservable(annotations)) {
3045
+ die("Extending an object with another observable (object) is not supported");
3046
+ }
2781
3047
  } // Pull descriptors first, so we don't have to deal with props added by administration ($mobx)
2782
3048
 
2783
3049
 
@@ -2805,7 +3071,11 @@ function nodeToDependencyTree(node) {
2805
3071
  var result = {
2806
3072
  name: node.name_
2807
3073
  };
2808
- if (node.observing_ && node.observing_.length > 0) result.dependencies = unique(node.observing_).map(nodeToDependencyTree);
3074
+
3075
+ if (node.observing_ && node.observing_.length > 0) {
3076
+ result.dependencies = unique(node.observing_).map(nodeToDependencyTree);
3077
+ }
3078
+
2809
3079
  return result;
2810
3080
  }
2811
3081
 
@@ -2817,7 +3087,11 @@ function nodeToObserverTree(node) {
2817
3087
  var result = {
2818
3088
  name: node.name_
2819
3089
  };
2820
- if (hasObservers(node)) result.observers = Array.from(getObservers(node)).map(nodeToObserverTree);
3090
+
3091
+ if (hasObservers(node)) {
3092
+ result.observers = Array.from(getObservers(node)).map(nodeToObserverTree);
3093
+ }
3094
+
2821
3095
  return result;
2822
3096
  }
2823
3097
 
@@ -2844,7 +3118,10 @@ var flow = /*#__PURE__*/Object.assign(function flow(arg1, arg2) {
2844
3118
  } // flow(fn)
2845
3119
 
2846
3120
 
2847
- if ( arguments.length !== 1) die("Flow expects single argument with generator function");
3121
+ if ( arguments.length !== 1) {
3122
+ die("Flow expects single argument with generator function");
3123
+ }
3124
+
2848
3125
  var generator = arg1;
2849
3126
  var name = generator.name || "<unnamed flow>"; // Implementation based on https://github.com/tj/co/blob/master/index.js
2850
3127
 
@@ -2892,7 +3169,10 @@ var flow = /*#__PURE__*/Object.assign(function flow(arg1, arg2) {
2892
3169
  return;
2893
3170
  }
2894
3171
 
2895
- if (ret.done) return resolve(ret.value);
3172
+ if (ret.done) {
3173
+ return resolve(ret.value);
3174
+ }
3175
+
2896
3176
  pendingPromise = Promise.resolve(ret.value);
2897
3177
  return pendingPromise.then(onFulfilled, onRejected);
2898
3178
  }
@@ -2901,7 +3181,10 @@ var flow = /*#__PURE__*/Object.assign(function flow(arg1, arg2) {
2901
3181
  });
2902
3182
  promise.cancel = action(name + " - runid: " + runId + " - cancel", function () {
2903
3183
  try {
2904
- if (pendingPromise) cancelPromise(pendingPromise); // Finally block can return (or yield) stuff..
3184
+ if (pendingPromise) {
3185
+ cancelPromise(pendingPromise);
3186
+ } // Finally block can return (or yield) stuff..
3187
+
2905
3188
 
2906
3189
  var _res = gen["return"](undefined); // eat anything that promise would do, it's cancelled!
2907
3190
 
@@ -2925,7 +3208,9 @@ var flow = /*#__PURE__*/Object.assign(function flow(arg1, arg2) {
2925
3208
  flow.bound = /*#__PURE__*/createDecoratorAnnotation(flowBoundAnnotation);
2926
3209
 
2927
3210
  function cancelPromise(promise) {
2928
- if (isFunction(promise.cancel)) promise.cancel();
3211
+ if (isFunction(promise.cancel)) {
3212
+ promise.cancel();
3213
+ }
2929
3214
  }
2930
3215
 
2931
3216
  function flowResult(result) {
@@ -2941,13 +3226,19 @@ function interceptReads(thing, propOrHandler, handler) {
2941
3226
  if (isObservableMap(thing) || isObservableArray(thing) || isObservableValue(thing)) {
2942
3227
  target = getAdministration(thing);
2943
3228
  } else if (isObservableObject(thing)) {
2944
- if ( !isStringish(propOrHandler)) return die("InterceptReads can only be used with a specific property, not with an object in general");
3229
+ if ( !isStringish(propOrHandler)) {
3230
+ return die("InterceptReads can only be used with a specific property, not with an object in general");
3231
+ }
3232
+
2945
3233
  target = getAdministration(thing, propOrHandler);
2946
3234
  } else {
2947
3235
  return die("Expected observable map, object or array as first array");
2948
3236
  }
2949
3237
 
2950
- if ( target.dehancer !== undefined) return die("An intercept reader was already established");
3238
+ if ( target.dehancer !== undefined) {
3239
+ return die("An intercept reader was already established");
3240
+ }
3241
+
2951
3242
  target.dehancer = typeof propOrHandler === "function" ? propOrHandler : handler;
2952
3243
  return function () {
2953
3244
  target.dehancer = undefined;
@@ -2955,7 +3246,11 @@ function interceptReads(thing, propOrHandler, handler) {
2955
3246
  }
2956
3247
 
2957
3248
  function intercept(thing, propOrHandler, handler) {
2958
- if (isFunction(handler)) return interceptProperty(thing, propOrHandler, handler);else return interceptInterceptable(thing, propOrHandler);
3249
+ if (isFunction(handler)) {
3250
+ return interceptProperty(thing, propOrHandler, handler);
3251
+ } else {
3252
+ return interceptInterceptable(thing, propOrHandler);
3253
+ }
2959
3254
  }
2960
3255
 
2961
3256
  function interceptInterceptable(thing, handler) {
@@ -2971,25 +3266,41 @@ function _isComputed(value, property) {
2971
3266
  return isComputedValue(value);
2972
3267
  }
2973
3268
 
2974
- if (isObservableObject(value) === false) return false;
2975
- if (!value[$mobx].values_.has(property)) return false;
3269
+ if (isObservableObject(value) === false) {
3270
+ return false;
3271
+ }
3272
+
3273
+ if (!value[$mobx].values_.has(property)) {
3274
+ return false;
3275
+ }
3276
+
2976
3277
  var atom = getAtom(value, property);
2977
3278
  return isComputedValue(atom);
2978
3279
  }
2979
3280
  function isComputed(value) {
2980
- if ( arguments.length > 1) return die("isComputed expects only 1 argument. Use isComputedProp to inspect the observability of a property");
3281
+ if ( arguments.length > 1) {
3282
+ return die("isComputed expects only 1 argument. Use isComputedProp to inspect the observability of a property");
3283
+ }
3284
+
2981
3285
  return _isComputed(value);
2982
3286
  }
2983
3287
  function isComputedProp(value, propName) {
2984
- if ( !isStringish(propName)) return die("isComputed expected a property name as second argument");
3288
+ if ( !isStringish(propName)) {
3289
+ return die("isComputed expected a property name as second argument");
3290
+ }
3291
+
2985
3292
  return _isComputed(value, propName);
2986
3293
  }
2987
3294
 
2988
3295
  function _isObservable(value, property) {
2989
- if (!value) return false;
3296
+ if (!value) {
3297
+ return false;
3298
+ }
2990
3299
 
2991
3300
  if (property !== undefined) {
2992
- if ( (isObservableMap(value) || isObservableArray(value))) return die("isObservable(object, propertyName) is not supported for arrays and maps. Use map.has or array.length instead.");
3301
+ if ( (isObservableMap(value) || isObservableArray(value))) {
3302
+ return die("isObservable(object, propertyName) is not supported for arrays and maps. Use map.has or array.length instead.");
3303
+ }
2993
3304
 
2994
3305
  if (isObservableObject(value)) {
2995
3306
  return value[$mobx].values_.has(property);
@@ -3003,11 +3314,17 @@ function _isObservable(value, property) {
3003
3314
  }
3004
3315
 
3005
3316
  function isObservable(value) {
3006
- if ( arguments.length !== 1) die("isObservable expects only 1 argument. Use isObservableProp to inspect the observability of a property");
3317
+ if ( arguments.length !== 1) {
3318
+ die("isObservable expects only 1 argument. Use isObservableProp to inspect the observability of a property");
3319
+ }
3320
+
3007
3321
  return _isObservable(value);
3008
3322
  }
3009
3323
  function isObservableProp(value, propName) {
3010
- if ( !isStringish(propName)) return die("expected a property name as second argument");
3324
+ if ( !isStringish(propName)) {
3325
+ return die("expected a property name as second argument");
3326
+ }
3327
+
3011
3328
  return _isObservable(value, propName);
3012
3329
  }
3013
3330
 
@@ -3099,13 +3416,25 @@ function set(obj, key, value) {
3099
3416
  } else if (isObservableSet(obj)) {
3100
3417
  obj.add(key);
3101
3418
  } else if (isObservableArray(obj)) {
3102
- if (typeof key !== "number") key = parseInt(key, 10);
3103
- if (key < 0) die("Invalid index: '" + key + "'");
3104
- startBatch();
3105
- if (key >= obj.length) obj.length = key + 1;
3106
- obj[key] = value;
3107
- endBatch();
3108
- } else die(8);
3419
+ if (typeof key !== "number") {
3420
+ key = parseInt(key, 10);
3421
+ }
3422
+
3423
+ if (key < 0) {
3424
+ die("Invalid index: '" + key + "'");
3425
+ }
3426
+
3427
+ startBatch();
3428
+
3429
+ if (key >= obj.length) {
3430
+ obj.length = key + 1;
3431
+ }
3432
+
3433
+ obj[key] = value;
3434
+ endBatch();
3435
+ } else {
3436
+ die(8);
3437
+ }
3109
3438
  }
3110
3439
  function remove(obj, key) {
3111
3440
  if (isObservableObject(obj)) {
@@ -3115,7 +3444,10 @@ function remove(obj, key) {
3115
3444
  } else if (isObservableSet(obj)) {
3116
3445
  obj["delete"](key);
3117
3446
  } else if (isObservableArray(obj)) {
3118
- if (typeof key !== "number") key = parseInt(key, 10);
3447
+ if (typeof key !== "number") {
3448
+ key = parseInt(key, 10);
3449
+ }
3450
+
3119
3451
  obj.splice(key, 1);
3120
3452
  } else {
3121
3453
  die(9);
@@ -3135,7 +3467,9 @@ function has(obj, key) {
3135
3467
  die(10);
3136
3468
  }
3137
3469
  function get(obj, key) {
3138
- if (!has(obj, key)) return undefined;
3470
+ if (!has(obj, key)) {
3471
+ return undefined;
3472
+ }
3139
3473
 
3140
3474
  if (isObservableObject(obj)) {
3141
3475
  return obj[$mobx].get_(key);
@@ -3163,7 +3497,11 @@ function apiOwnKeys(obj) {
3163
3497
  }
3164
3498
 
3165
3499
  function observe(thing, propOrCb, cbOrFire, fireImmediately) {
3166
- if (isFunction(cbOrFire)) return observeObservableProperty(thing, propOrCb, cbOrFire, fireImmediately);else return observeObservable(thing, propOrCb, cbOrFire);
3500
+ if (isFunction(cbOrFire)) {
3501
+ return observeObservableProperty(thing, propOrCb, cbOrFire, fireImmediately);
3502
+ } else {
3503
+ return observeObservable(thing, propOrCb, cbOrFire);
3504
+ }
3167
3505
  }
3168
3506
 
3169
3507
  function observeObservable(thing, listener, fireImmediately) {
@@ -3180,8 +3518,13 @@ function cache(map, key, value) {
3180
3518
  }
3181
3519
 
3182
3520
  function toJSHelper(source, __alreadySeen) {
3183
- if (source == null || typeof source !== "object" || source instanceof Date || !isObservable(source)) return source;
3184
- if (isObservableValue(source) || isComputedValue(source)) return toJSHelper(source.get(), __alreadySeen);
3521
+ if (source == null || typeof source !== "object" || source instanceof Date || !isObservable(source)) {
3522
+ return source;
3523
+ }
3524
+
3525
+ if (isObservableValue(source) || isComputedValue(source)) {
3526
+ return toJSHelper(source.get(), __alreadySeen);
3527
+ }
3185
3528
 
3186
3529
  if (__alreadySeen.has(source)) {
3187
3530
  return __alreadySeen.get(source);
@@ -3224,23 +3567,33 @@ function toJSHelper(source, __alreadySeen) {
3224
3567
  }
3225
3568
  }
3226
3569
  /**
3227
- * Basically, a deep clone, so that no reactive property will exist anymore.
3570
+ * Recursively converts an observable to it's non-observable native counterpart.
3571
+ * It does NOT recurse into non-observables, these are left as they are, even if they contain observables.
3572
+ * Computed and other non-enumerable properties are completely ignored.
3573
+ * Complex scenarios require custom solution, eg implementing `toJSON` or using `serializr` lib.
3228
3574
  */
3229
3575
 
3230
3576
 
3231
3577
  function toJS(source, options) {
3232
- if ( options) die("toJS no longer supports options");
3578
+ if ( options) {
3579
+ die("toJS no longer supports options");
3580
+ }
3581
+
3233
3582
  return toJSHelper(source, new Map());
3234
3583
  }
3235
3584
 
3236
3585
  function trace() {
3586
+
3237
3587
  var enterBreakPoint = false;
3238
3588
 
3239
3589
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3240
3590
  args[_key] = arguments[_key];
3241
3591
  }
3242
3592
 
3243
- if (typeof args[args.length - 1] === "boolean") enterBreakPoint = args.pop();
3593
+ if (typeof args[args.length - 1] === "boolean") {
3594
+ enterBreakPoint = args.pop();
3595
+ }
3596
+
3244
3597
  var derivation = getAtomFromArgs(args);
3245
3598
 
3246
3599
  if (!derivation) {
@@ -3290,7 +3643,10 @@ function transaction(action, thisArg) {
3290
3643
  }
3291
3644
 
3292
3645
  function when(predicate, arg1, arg2) {
3293
- if (arguments.length === 1 || arg1 && typeof arg1 === "object") return whenPromise(predicate, arg1);
3646
+ if (arguments.length === 1 || arg1 && typeof arg1 === "object") {
3647
+ return whenPromise(predicate, arg1);
3648
+ }
3649
+
3294
3650
  return _when(predicate, arg1, arg2 || {});
3295
3651
  }
3296
3652
 
@@ -3302,7 +3658,12 @@ function _when(predicate, effect, opts) {
3302
3658
  timeoutHandle = setTimeout(function () {
3303
3659
  if (!disposer[$mobx].isDisposed_) {
3304
3660
  disposer();
3305
- if (opts.onError) opts.onError(error);else throw error;
3661
+
3662
+ if (opts.onError) {
3663
+ opts.onError(error);
3664
+ } else {
3665
+ throw error;
3666
+ }
3306
3667
  }
3307
3668
  }, opts.timeout);
3308
3669
  }
@@ -3316,7 +3677,11 @@ function _when(predicate, effect, opts) {
3316
3677
 
3317
3678
  if (cond) {
3318
3679
  r.dispose();
3319
- if (timeoutHandle) clearTimeout(timeoutHandle);
3680
+
3681
+ if (timeoutHandle) {
3682
+ clearTimeout(timeoutHandle);
3683
+ }
3684
+
3320
3685
  effectAction();
3321
3686
  }
3322
3687
  }, opts);
@@ -3324,7 +3689,10 @@ function _when(predicate, effect, opts) {
3324
3689
  }
3325
3690
 
3326
3691
  function whenPromise(predicate, opts) {
3327
- if ( opts && opts.onError) return die("the options 'onError' and 'promise' cannot be combined");
3692
+ if ( opts && opts.onError) {
3693
+ return die("the options 'onError' and 'promise' cannot be combined");
3694
+ }
3695
+
3328
3696
  var cancel;
3329
3697
  var res = new Promise(function (resolve, reject) {
3330
3698
  var disposer = _when(predicate, resolve, _extends({}, opts, {
@@ -3348,7 +3716,10 @@ function getAdm(target) {
3348
3716
 
3349
3717
  var objectProxyTraps = {
3350
3718
  has: function has(target, name) {
3351
- if ( globalState.trackingDerivation) warnAboutProxyRequirement("detect new properties using the 'in' operator. Use 'has' from 'mobx' instead.");
3719
+ if ( globalState.trackingDerivation) {
3720
+ warnAboutProxyRequirement("detect new properties using the 'in' operator. Use 'has' from 'mobx' instead.");
3721
+ }
3722
+
3352
3723
  return getAdm(target).has_(name);
3353
3724
  },
3354
3725
  get: function get(target, name) {
@@ -3357,7 +3728,9 @@ var objectProxyTraps = {
3357
3728
  set: function set(target, name, value) {
3358
3729
  var _getAdm$set_;
3359
3730
 
3360
- if (!isStringish(name)) return false;
3731
+ if (!isStringish(name)) {
3732
+ return false;
3733
+ }
3361
3734
 
3362
3735
  if ( !getAdm(target).values_.has(name)) {
3363
3736
  warnAboutProxyRequirement("add a new observable property through direct assignment. Use 'set' from 'mobx' instead.");
@@ -3373,7 +3746,10 @@ var objectProxyTraps = {
3373
3746
  warnAboutProxyRequirement("delete properties from an observable object. Use 'remove' from 'mobx' instead.");
3374
3747
  }
3375
3748
 
3376
- if (!isStringish(name)) return false; // null (intercepted) -> true (success)
3749
+ if (!isStringish(name)) {
3750
+ return false;
3751
+ } // null (intercepted) -> true (success)
3752
+
3377
3753
 
3378
3754
  return (_getAdm$delete_ = getAdm(target).delete_(name, true)) != null ? _getAdm$delete_ : true;
3379
3755
  },
@@ -3388,7 +3764,10 @@ var objectProxyTraps = {
3388
3764
  return (_getAdm$definePropert = getAdm(target).defineProperty_(name, descriptor)) != null ? _getAdm$definePropert : true;
3389
3765
  },
3390
3766
  ownKeys: function ownKeys(target) {
3391
- if ( globalState.trackingDerivation) warnAboutProxyRequirement("iterate keys to detect added / removed properties. Use 'keys' from 'mobx' instead.");
3767
+ if ( globalState.trackingDerivation) {
3768
+ warnAboutProxyRequirement("iterate keys to detect added / removed properties. Use 'keys' from 'mobx' instead.");
3769
+ }
3770
+
3392
3771
  return getAdm(target).ownKeys_();
3393
3772
  },
3394
3773
  preventExtensions: function preventExtensions(target) {
@@ -3411,7 +3790,10 @@ function registerInterceptor(interceptable, handler) {
3411
3790
  interceptors.push(handler);
3412
3791
  return once(function () {
3413
3792
  var idx = interceptors.indexOf(handler);
3414
- if (idx !== -1) interceptors.splice(idx, 1);
3793
+
3794
+ if (idx !== -1) {
3795
+ interceptors.splice(idx, 1);
3796
+ }
3415
3797
  });
3416
3798
  }
3417
3799
  function interceptChange(interceptable, change) {
@@ -3423,8 +3805,14 @@ function interceptChange(interceptable, change) {
3423
3805
 
3424
3806
  for (var i = 0, l = interceptors.length; i < l; i++) {
3425
3807
  change = interceptors[i](change);
3426
- if (change && !change.type) die(14);
3427
- if (!change) break;
3808
+
3809
+ if (change && !change.type) {
3810
+ die(14);
3811
+ }
3812
+
3813
+ if (!change) {
3814
+ break;
3815
+ }
3428
3816
  }
3429
3817
 
3430
3818
  return change;
@@ -3441,13 +3829,20 @@ function registerListener(listenable, handler) {
3441
3829
  listeners.push(handler);
3442
3830
  return once(function () {
3443
3831
  var idx = listeners.indexOf(handler);
3444
- if (idx !== -1) listeners.splice(idx, 1);
3832
+
3833
+ if (idx !== -1) {
3834
+ listeners.splice(idx, 1);
3835
+ }
3445
3836
  });
3446
3837
  }
3447
3838
  function notifyListeners(listenable, change) {
3448
3839
  var prevU = untrackedStart();
3449
3840
  var listeners = listenable.changeListeners_;
3450
- if (!listeners) return;
3841
+
3842
+ if (!listeners) {
3843
+ return;
3844
+ }
3845
+
3451
3846
  listeners = listeners.slice();
3452
3847
 
3453
3848
  for (var i = 0, l = listeners.length; i < l; i++) {
@@ -3484,8 +3879,13 @@ function makeObservable(target, annotations, options) {
3484
3879
  var keysSymbol = /*#__PURE__*/Symbol("mobx-keys");
3485
3880
  function makeAutoObservable(target, overrides, options) {
3486
3881
  {
3487
- if (!isPlainObject(target) && !isPlainObject(Object.getPrototypeOf(target))) die("'makeAutoObservable' can only be used for classes that don't have a superclass");
3488
- if (isObservableObject(target)) die("makeAutoObservable can only be used on objects not already made observable");
3882
+ if (!isPlainObject(target) && !isPlainObject(Object.getPrototypeOf(target))) {
3883
+ die("'makeAutoObservable' can only be used for classes that don't have a superclass");
3884
+ }
3885
+
3886
+ if (isObservableObject(target)) {
3887
+ die("makeAutoObservable can only be used on objects not already made observable");
3888
+ }
3489
3889
  } // Optimization: avoid visiting protos
3490
3890
  // Assumes that annotation.make_/.extend_ works the same for plain objects
3491
3891
 
@@ -3526,8 +3926,14 @@ var MAX_SPLICE_SIZE = 10000; // See e.g. https://github.com/mobxjs/mobx/issues/8
3526
3926
  var arrayTraps = {
3527
3927
  get: function get(target, name) {
3528
3928
  var adm = target[$mobx];
3529
- if (name === $mobx) return adm;
3530
- if (name === "length") return adm.getArrayLength_();
3929
+
3930
+ if (name === $mobx) {
3931
+ return adm;
3932
+ }
3933
+
3934
+ if (name === "length") {
3935
+ return adm.getArrayLength_();
3936
+ }
3531
3937
 
3532
3938
  if (typeof name === "string" && !isNaN(name)) {
3533
3939
  return adm.get_(parseInt(name));
@@ -3588,12 +3994,18 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
3588
3994
  var _proto = ObservableArrayAdministration.prototype;
3589
3995
 
3590
3996
  _proto.dehanceValue_ = function dehanceValue_(value) {
3591
- if (this.dehancer !== undefined) return this.dehancer(value);
3997
+ if (this.dehancer !== undefined) {
3998
+ return this.dehancer(value);
3999
+ }
4000
+
3592
4001
  return value;
3593
4002
  };
3594
4003
 
3595
4004
  _proto.dehanceValues_ = function dehanceValues_(values) {
3596
- if (this.dehancer !== undefined && values.length > 0) return values.map(this.dehancer);
4005
+ if (this.dehancer !== undefined && values.length > 0) {
4006
+ return values.map(this.dehancer);
4007
+ }
4008
+
3597
4009
  return values;
3598
4010
  };
3599
4011
 
@@ -3629,9 +4041,15 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
3629
4041
  };
3630
4042
 
3631
4043
  _proto.setArrayLength_ = function setArrayLength_(newLength) {
3632
- if (typeof newLength !== "number" || isNaN(newLength) || newLength < 0) die("Out of range: " + newLength);
4044
+ if (typeof newLength !== "number" || isNaN(newLength) || newLength < 0) {
4045
+ die("Out of range: " + newLength);
4046
+ }
4047
+
3633
4048
  var currentLength = this.values_.length;
3634
- if (newLength === currentLength) return;else if (newLength > currentLength) {
4049
+
4050
+ if (newLength === currentLength) {
4051
+ return;
4052
+ } else if (newLength > currentLength) {
3635
4053
  var newItems = new Array(newLength - currentLength);
3636
4054
 
3637
4055
  for (var i = 0; i < newLength - currentLength; i++) {
@@ -3640,13 +4058,21 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
3640
4058
 
3641
4059
 
3642
4060
  this.spliceWithArray_(currentLength, 0, newItems);
3643
- } else this.spliceWithArray_(newLength, currentLength - newLength);
4061
+ } else {
4062
+ this.spliceWithArray_(newLength, currentLength - newLength);
4063
+ }
3644
4064
  };
3645
4065
 
3646
4066
  _proto.updateArrayLength_ = function updateArrayLength_(oldLength, delta) {
3647
- if (oldLength !== this.lastKnownLength_) die(16);
4067
+ if (oldLength !== this.lastKnownLength_) {
4068
+ die(16);
4069
+ }
4070
+
3648
4071
  this.lastKnownLength_ += delta;
3649
- if (this.legacyMode_ && delta > 0) reserveArrayBuffer(oldLength + delta + 1);
4072
+
4073
+ if (this.legacyMode_ && delta > 0) {
4074
+ reserveArrayBuffer(oldLength + delta + 1);
4075
+ }
3650
4076
  };
3651
4077
 
3652
4078
  _proto.spliceWithArray_ = function spliceWithArray_(index, deleteCount, newItems) {
@@ -3654,9 +4080,26 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
3654
4080
 
3655
4081
  checkIfStateModificationsAreAllowed(this.atom_);
3656
4082
  var length = this.values_.length;
3657
- if (index === undefined) index = 0;else if (index > length) index = length;else if (index < 0) index = Math.max(0, length + index);
3658
- 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));
3659
- if (newItems === undefined) newItems = EMPTY_ARRAY;
4083
+
4084
+ if (index === undefined) {
4085
+ index = 0;
4086
+ } else if (index > length) {
4087
+ index = length;
4088
+ } else if (index < 0) {
4089
+ index = Math.max(0, length + index);
4090
+ }
4091
+
4092
+ if (arguments.length === 1) {
4093
+ deleteCount = length - index;
4094
+ } else if (deleteCount === undefined || deleteCount === null) {
4095
+ deleteCount = 0;
4096
+ } else {
4097
+ deleteCount = Math.max(0, Math.min(deleteCount, length - index));
4098
+ }
4099
+
4100
+ if (newItems === undefined) {
4101
+ newItems = EMPTY_ARRAY;
4102
+ }
3660
4103
 
3661
4104
  if (hasInterceptors(this)) {
3662
4105
  var change = interceptChange(this, {
@@ -3666,7 +4109,11 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
3666
4109
  removedCount: deleteCount,
3667
4110
  added: newItems
3668
4111
  });
3669
- if (!change) return EMPTY_ARRAY;
4112
+
4113
+ if (!change) {
4114
+ return EMPTY_ARRAY;
4115
+ }
4116
+
3670
4117
  deleteCount = change.removedCount;
3671
4118
  newItems = change.added;
3672
4119
  }
@@ -3681,7 +4128,11 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
3681
4128
  }
3682
4129
 
3683
4130
  var res = this.spliceItemsIntoValues_(index, deleteCount, newItems);
3684
- if (deleteCount !== 0 || newItems.length !== 0) this.notifyArraySplice_(index, newItems, res);
4131
+
4132
+ if (deleteCount !== 0 || newItems.length !== 0) {
4133
+ this.notifyArraySplice_(index, newItems, res);
4134
+ }
4135
+
3685
4136
  return this.dehanceValues_(res);
3686
4137
  };
3687
4138
 
@@ -3724,10 +4175,19 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
3724
4175
  } : 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
3725
4176
  // cause any runtime overhead in development mode without NODE_ENV set, unless spying is enabled
3726
4177
 
3727
- if ( notifySpy) spyReportStart(change);
4178
+ if ( notifySpy) {
4179
+ spyReportStart(change);
4180
+ }
4181
+
3728
4182
  this.atom_.reportChanged();
3729
- if (notify) notifyListeners(this, change);
3730
- if ( notifySpy) spyReportEnd();
4183
+
4184
+ if (notify) {
4185
+ notifyListeners(this, change);
4186
+ }
4187
+
4188
+ if ( notifySpy) {
4189
+ spyReportEnd();
4190
+ }
3731
4191
  };
3732
4192
 
3733
4193
  _proto.notifyArraySplice_ = function notifyArraySplice_(index, added, removed) {
@@ -3744,11 +4204,20 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
3744
4204
  removedCount: removed.length,
3745
4205
  addedCount: added.length
3746
4206
  } : null;
3747
- if ( notifySpy) spyReportStart(change);
4207
+
4208
+ if ( notifySpy) {
4209
+ spyReportStart(change);
4210
+ }
4211
+
3748
4212
  this.atom_.reportChanged(); // conform: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/observe
3749
4213
 
3750
- if (notify) notifyListeners(this, change);
3751
- if ( notifySpy) spyReportEnd();
4214
+ if (notify) {
4215
+ notifyListeners(this, change);
4216
+ }
4217
+
4218
+ if ( notifySpy) {
4219
+ spyReportEnd();
4220
+ }
3752
4221
  };
3753
4222
 
3754
4223
  _proto.get_ = function get_(index) {
@@ -3775,7 +4244,11 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
3775
4244
  index: index,
3776
4245
  newValue: newValue
3777
4246
  });
3778
- if (!change) return;
4247
+
4248
+ if (!change) {
4249
+ return;
4250
+ }
4251
+
3779
4252
  newValue = change.newValue;
3780
4253
  }
3781
4254
 
@@ -4016,6 +4489,8 @@ _Symbol$toStringTag = Symbol.toStringTag;
4016
4489
  var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTag2) {
4017
4490
  // hasMap, not hashMap >-).
4018
4491
  function ObservableMap(initialData, enhancer_, name_) {
4492
+ var _this = this;
4493
+
4019
4494
  if (enhancer_ === void 0) {
4020
4495
  enhancer_ = deepEnhancer;
4021
4496
  }
@@ -4043,7 +4518,9 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4043
4518
  this.keysAtom_ = createAtom( this.name_ + ".keys()" );
4044
4519
  this.data_ = new Map();
4045
4520
  this.hasMap_ = new Map();
4046
- this.merge(initialData);
4521
+ allowStateChanges(true, function () {
4522
+ _this.merge(initialData);
4523
+ });
4047
4524
  }
4048
4525
 
4049
4526
  var _proto = ObservableMap.prototype;
@@ -4053,16 +4530,19 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4053
4530
  };
4054
4531
 
4055
4532
  _proto.has = function has(key) {
4056
- var _this = this;
4533
+ var _this2 = this;
4534
+
4535
+ if (!globalState.trackingDerivation) {
4536
+ return this.has_(key);
4537
+ }
4057
4538
 
4058
- if (!globalState.trackingDerivation) return this.has_(key);
4059
4539
  var entry = this.hasMap_.get(key);
4060
4540
 
4061
4541
  if (!entry) {
4062
4542
  var newEntry = entry = new ObservableValue(this.has_(key), referenceEnhancer, this.name_ + "." + stringifyKey(key) + "?" , false);
4063
4543
  this.hasMap_.set(key, newEntry);
4064
4544
  onBecomeUnobserved(newEntry, function () {
4065
- return _this.hasMap_["delete"](key);
4545
+ return _this2.hasMap_["delete"](key);
4066
4546
  });
4067
4547
  }
4068
4548
 
@@ -4079,7 +4559,11 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4079
4559
  newValue: value,
4080
4560
  name: key
4081
4561
  });
4082
- if (!change) return this;
4562
+
4563
+ if (!change) {
4564
+ return this;
4565
+ }
4566
+
4083
4567
  value = change.newValue;
4084
4568
  }
4085
4569
 
@@ -4093,7 +4577,7 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4093
4577
  };
4094
4578
 
4095
4579
  _proto["delete"] = function _delete(key) {
4096
- var _this2 = this;
4580
+ var _this3 = this;
4097
4581
 
4098
4582
  checkIfStateModificationsAreAllowed(this.keysAtom_);
4099
4583
 
@@ -4103,7 +4587,10 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4103
4587
  object: this,
4104
4588
  name: key
4105
4589
  });
4106
- if (!change) return false;
4590
+
4591
+ if (!change) {
4592
+ return false;
4593
+ }
4107
4594
  }
4108
4595
 
4109
4596
  if (this.has_(key)) {
@@ -4119,23 +4606,33 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4119
4606
  name: key
4120
4607
  } : null;
4121
4608
 
4122
- if ( notifySpy) spyReportStart(_change); // TODO fix type
4609
+ if ( notifySpy) {
4610
+ spyReportStart(_change);
4611
+ } // TODO fix type
4612
+
4123
4613
 
4124
4614
  transaction(function () {
4125
- var _this2$hasMap_$get;
4615
+ var _this3$hasMap_$get;
4126
4616
 
4127
- _this2.keysAtom_.reportChanged();
4617
+ _this3.keysAtom_.reportChanged();
4128
4618
 
4129
- (_this2$hasMap_$get = _this2.hasMap_.get(key)) == null ? void 0 : _this2$hasMap_$get.setNewValue_(false);
4619
+ (_this3$hasMap_$get = _this3.hasMap_.get(key)) == null ? void 0 : _this3$hasMap_$get.setNewValue_(false);
4130
4620
 
4131
- var observable = _this2.data_.get(key);
4621
+ var observable = _this3.data_.get(key);
4132
4622
 
4133
4623
  observable.setNewValue_(undefined);
4134
4624
 
4135
- _this2.data_["delete"](key);
4625
+ _this3.data_["delete"](key);
4136
4626
  });
4137
- if (notify) notifyListeners(this, _change);
4138
- if ( notifySpy) spyReportEnd();
4627
+
4628
+ if (notify) {
4629
+ notifyListeners(this, _change);
4630
+ }
4631
+
4632
+ if ( notifySpy) {
4633
+ spyReportEnd();
4634
+ }
4635
+
4139
4636
  return true;
4140
4637
  }
4141
4638
 
@@ -4158,30 +4655,40 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4158
4655
  name: key,
4159
4656
  newValue: newValue
4160
4657
  } : null;
4161
- if ( notifySpy) spyReportStart(change); // TODO fix type
4658
+
4659
+ if ( notifySpy) {
4660
+ spyReportStart(change);
4661
+ } // TODO fix type
4662
+
4162
4663
 
4163
4664
  observable.setNewValue_(newValue);
4164
- if (notify) notifyListeners(this, change);
4165
- if ( notifySpy) spyReportEnd();
4665
+
4666
+ if (notify) {
4667
+ notifyListeners(this, change);
4668
+ }
4669
+
4670
+ if ( notifySpy) {
4671
+ spyReportEnd();
4672
+ }
4166
4673
  }
4167
4674
  };
4168
4675
 
4169
4676
  _proto.addValue_ = function addValue_(key, newValue) {
4170
- var _this3 = this;
4677
+ var _this4 = this;
4171
4678
 
4172
4679
  checkIfStateModificationsAreAllowed(this.keysAtom_);
4173
4680
  transaction(function () {
4174
- var _this3$hasMap_$get;
4681
+ var _this4$hasMap_$get;
4175
4682
 
4176
- var observable = new ObservableValue(newValue, _this3.enhancer_, _this3.name_ + "." + stringifyKey(key) , false);
4683
+ var observable = new ObservableValue(newValue, _this4.enhancer_, _this4.name_ + "." + stringifyKey(key) , false);
4177
4684
 
4178
- _this3.data_.set(key, observable);
4685
+ _this4.data_.set(key, observable);
4179
4686
 
4180
4687
  newValue = observable.value_; // value might have been changed
4181
4688
 
4182
- (_this3$hasMap_$get = _this3.hasMap_.get(key)) == null ? void 0 : _this3$hasMap_$get.setNewValue_(true);
4689
+ (_this4$hasMap_$get = _this4.hasMap_.get(key)) == null ? void 0 : _this4$hasMap_$get.setNewValue_(true);
4183
4690
 
4184
- _this3.keysAtom_.reportChanged();
4691
+ _this4.keysAtom_.reportChanged();
4185
4692
  });
4186
4693
  var notifySpy = isSpyEnabled();
4187
4694
  var notify = hasListeners(this);
@@ -4193,14 +4700,26 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4193
4700
  name: key,
4194
4701
  newValue: newValue
4195
4702
  } : null;
4196
- if ( notifySpy) spyReportStart(change); // TODO fix type
4197
4703
 
4198
- if (notify) notifyListeners(this, change);
4199
- if ( notifySpy) spyReportEnd();
4704
+ if ( notifySpy) {
4705
+ spyReportStart(change);
4706
+ } // TODO fix type
4707
+
4708
+
4709
+ if (notify) {
4710
+ notifyListeners(this, change);
4711
+ }
4712
+
4713
+ if ( notifySpy) {
4714
+ spyReportEnd();
4715
+ }
4200
4716
  };
4201
4717
 
4202
4718
  _proto.get = function get(key) {
4203
- if (this.has(key)) return this.dehanceValue_(this.data_.get(key).get());
4719
+ if (this.has(key)) {
4720
+ return this.dehanceValue_(this.data_.get(key).get());
4721
+ }
4722
+
4204
4723
  return this.dehanceValue_(undefined);
4205
4724
  };
4206
4725
 
@@ -4267,45 +4786,54 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4267
4786
  ;
4268
4787
 
4269
4788
  _proto.merge = function merge(other) {
4270
- var _this4 = this;
4789
+ var _this5 = this;
4271
4790
 
4272
4791
  if (isObservableMap(other)) {
4273
4792
  other = new Map(other);
4274
4793
  }
4275
4794
 
4276
4795
  transaction(function () {
4277
- if (isPlainObject(other)) getPlainObjectKeys(other).forEach(function (key) {
4278
- return _this4.set(key, other[key]);
4279
- });else if (Array.isArray(other)) other.forEach(function (_ref) {
4280
- var key = _ref[0],
4281
- value = _ref[1];
4282
- return _this4.set(key, value);
4283
- });else if (isES6Map(other)) {
4284
- if (other.constructor !== Map) die(19, other);
4796
+ if (isPlainObject(other)) {
4797
+ getPlainObjectKeys(other).forEach(function (key) {
4798
+ return _this5.set(key, other[key]);
4799
+ });
4800
+ } else if (Array.isArray(other)) {
4801
+ other.forEach(function (_ref) {
4802
+ var key = _ref[0],
4803
+ value = _ref[1];
4804
+ return _this5.set(key, value);
4805
+ });
4806
+ } else if (isES6Map(other)) {
4807
+ if (other.constructor !== Map) {
4808
+ die(19, other);
4809
+ }
4810
+
4285
4811
  other.forEach(function (value, key) {
4286
- return _this4.set(key, value);
4812
+ return _this5.set(key, value);
4287
4813
  });
4288
- } else if (other !== null && other !== undefined) die(20, other);
4814
+ } else if (other !== null && other !== undefined) {
4815
+ die(20, other);
4816
+ }
4289
4817
  });
4290
4818
  return this;
4291
4819
  };
4292
4820
 
4293
4821
  _proto.clear = function clear() {
4294
- var _this5 = this;
4822
+ var _this6 = this;
4295
4823
 
4296
4824
  transaction(function () {
4297
4825
  untracked(function () {
4298
- for (var _iterator2 = _createForOfIteratorHelperLoose(_this5.keys()), _step2; !(_step2 = _iterator2()).done;) {
4826
+ for (var _iterator2 = _createForOfIteratorHelperLoose(_this6.keys()), _step2; !(_step2 = _iterator2()).done;) {
4299
4827
  var key = _step2.value;
4300
4828
 
4301
- _this5["delete"](key);
4829
+ _this6["delete"](key);
4302
4830
  }
4303
4831
  });
4304
4832
  });
4305
4833
  };
4306
4834
 
4307
4835
  _proto.replace = function replace(values) {
4308
- var _this6 = this;
4836
+ var _this7 = this;
4309
4837
 
4310
4838
  // Implementation requirements:
4311
4839
  // - respect ordering of replacement map
@@ -4322,13 +4850,13 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4322
4850
  // if the key deletion is prevented by interceptor
4323
4851
  // add entry at the beginning of the result map
4324
4852
 
4325
- for (var _iterator3 = _createForOfIteratorHelperLoose(_this6.data_.keys()), _step3; !(_step3 = _iterator3()).done;) {
4853
+ for (var _iterator3 = _createForOfIteratorHelperLoose(_this7.data_.keys()), _step3; !(_step3 = _iterator3()).done;) {
4326
4854
  var key = _step3.value;
4327
4855
 
4328
4856
  // Concurrently iterating/deleting keys
4329
4857
  // iterator should handle this correctly
4330
4858
  if (!replacementMap.has(key)) {
4331
- var deleted = _this6["delete"](key); // Was the key removed?
4859
+ var deleted = _this7["delete"](key); // Was the key removed?
4332
4860
 
4333
4861
 
4334
4862
  if (deleted) {
@@ -4336,7 +4864,7 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4336
4864
  keysReportChangedCalled = true;
4337
4865
  } else {
4338
4866
  // Delete prevented by interceptor
4339
- var value = _this6.data_.get(key);
4867
+ var value = _this7.data_.get(key);
4340
4868
 
4341
4869
  orderedData.set(key, value);
4342
4870
  }
@@ -4350,17 +4878,17 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4350
4878
  _value = _step4$value[1];
4351
4879
 
4352
4880
  // We will want to know whether a new key is added
4353
- var keyExisted = _this6.data_.has(_key); // Add or update value
4881
+ var keyExisted = _this7.data_.has(_key); // Add or update value
4354
4882
 
4355
4883
 
4356
- _this6.set(_key, _value); // The addition could have been prevent by interceptor
4884
+ _this7.set(_key, _value); // The addition could have been prevent by interceptor
4357
4885
 
4358
4886
 
4359
- if (_this6.data_.has(_key)) {
4887
+ if (_this7.data_.has(_key)) {
4360
4888
  // The update could have been prevented by interceptor
4361
4889
  // and also we want to preserve existing values
4362
4890
  // so use value from _data map (instead of replacement map)
4363
- var _value2 = _this6.data_.get(_key);
4891
+ var _value2 = _this7.data_.get(_key);
4364
4892
 
4365
4893
  orderedData.set(_key, _value2); // Was a new key added?
4366
4894
 
@@ -4373,11 +4901,11 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4373
4901
 
4374
4902
 
4375
4903
  if (!keysReportChangedCalled) {
4376
- if (_this6.data_.size !== orderedData.size) {
4904
+ if (_this7.data_.size !== orderedData.size) {
4377
4905
  // If size differs, keys are definitely modified
4378
- _this6.keysAtom_.reportChanged();
4906
+ _this7.keysAtom_.reportChanged();
4379
4907
  } else {
4380
- var iter1 = _this6.data_.keys();
4908
+ var iter1 = _this7.data_.keys();
4381
4909
 
4382
4910
  var iter2 = orderedData.keys();
4383
4911
  var next1 = iter1.next();
@@ -4385,7 +4913,7 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4385
4913
 
4386
4914
  while (!next1.done) {
4387
4915
  if (next1.value !== next2.value) {
4388
- _this6.keysAtom_.reportChanged();
4916
+ _this7.keysAtom_.reportChanged();
4389
4917
 
4390
4918
  break;
4391
4919
  }
@@ -4397,7 +4925,7 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4397
4925
  } // Use correctly ordered map
4398
4926
 
4399
4927
 
4400
- _this6.data_ = orderedData;
4928
+ _this7.data_ = orderedData;
4401
4929
  });
4402
4930
  return this;
4403
4931
  };
@@ -4416,7 +4944,10 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4416
4944
  * for callback details
4417
4945
  */
4418
4946
  _proto.observe_ = function observe_(listener, fireImmediately) {
4419
- if ( fireImmediately === true) die("`observe` doesn't support fireImmediately=true in combination with maps.");
4947
+ if ( fireImmediately === true) {
4948
+ die("`observe` doesn't support fireImmediately=true in combination with maps.");
4949
+ }
4950
+
4420
4951
  return registerListener(this, listener);
4421
4952
  };
4422
4953
 
@@ -4541,8 +5072,12 @@ var ObservableSet = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4541
5072
  object: this,
4542
5073
  newValue: value
4543
5074
  });
4544
- if (!change) return this; // ideally, value = change.value would be done here, so that values can be
5075
+
5076
+ if (!change) {
5077
+ return this;
5078
+ } // ideally, value = change.value would be done here, so that values can be
4545
5079
  // changed by interceptor. Same applies for other Set and Map api's.
5080
+
4546
5081
  }
4547
5082
 
4548
5083
  if (!this.has(value)) {
@@ -4562,9 +5097,17 @@ var ObservableSet = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4562
5097
  newValue: value
4563
5098
  } : null;
4564
5099
 
4565
- if (notifySpy && "development" !== "production") spyReportStart(_change);
4566
- if (notify) notifyListeners(this, _change);
4567
- if (notifySpy && "development" !== "production") spyReportEnd();
5100
+ if (notifySpy && "development" !== "production") {
5101
+ spyReportStart(_change);
5102
+ }
5103
+
5104
+ if (notify) {
5105
+ notifyListeners(this, _change);
5106
+ }
5107
+
5108
+ if (notifySpy && "development" !== "production") {
5109
+ spyReportEnd();
5110
+ }
4568
5111
  }
4569
5112
 
4570
5113
  return this;
@@ -4579,7 +5122,10 @@ var ObservableSet = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4579
5122
  object: this,
4580
5123
  oldValue: value
4581
5124
  });
4582
- if (!change) return false;
5125
+
5126
+ if (!change) {
5127
+ return false;
5128
+ }
4583
5129
  }
4584
5130
 
4585
5131
  if (this.has(value)) {
@@ -4594,14 +5140,24 @@ var ObservableSet = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4594
5140
  oldValue: value
4595
5141
  } : null;
4596
5142
 
4597
- if (notifySpy && "development" !== "production") spyReportStart(_change2);
5143
+ if (notifySpy && "development" !== "production") {
5144
+ spyReportStart(_change2);
5145
+ }
5146
+
4598
5147
  transaction(function () {
4599
5148
  _this3.atom_.reportChanged();
4600
5149
 
4601
5150
  _this3.data_["delete"](value);
4602
5151
  });
4603
- if (notify) notifyListeners(this, _change2);
4604
- if (notifySpy && "development" !== "production") spyReportEnd();
5152
+
5153
+ if (notify) {
5154
+ notifyListeners(this, _change2);
5155
+ }
5156
+
5157
+ if (notifySpy && "development" !== "production") {
5158
+ spyReportEnd();
5159
+ }
5160
+
4605
5161
  return true;
4606
5162
  }
4607
5163
 
@@ -4681,7 +5237,10 @@ var ObservableSet = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4681
5237
 
4682
5238
  _proto.observe_ = function observe_(listener, fireImmediately) {
4683
5239
  // ... 'fireImmediately' could also be true?
4684
- if ( fireImmediately === true) die("`observe` doesn't support fireImmediately=true in combination with sets.");
5240
+ if ( fireImmediately === true) {
5241
+ die("`observe` doesn't support fireImmediately=true in combination with sets.");
5242
+ }
5243
+
4685
5244
  return registerListener(this, listener);
4686
5245
  };
4687
5246
 
@@ -4783,7 +5342,11 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
4783
5342
  name: key,
4784
5343
  newValue: newValue
4785
5344
  });
4786
- if (!change) return null;
5345
+
5346
+ if (!change) {
5347
+ return null;
5348
+ }
5349
+
4787
5350
  newValue = change.newValue;
4788
5351
  }
4789
5352
 
@@ -4803,10 +5366,18 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
4803
5366
  newValue: newValue
4804
5367
  } : null;
4805
5368
 
4806
- if ( notifySpy) spyReportStart(_change);
5369
+ if ( notifySpy) {
5370
+ spyReportStart(_change);
5371
+ }
4807
5372
  observable.setNewValue_(newValue);
4808
- if (notify) notifyListeners(this, _change);
4809
- if ( notifySpy) spyReportEnd();
5373
+
5374
+ if (notify) {
5375
+ notifyListeners(this, _change);
5376
+ }
5377
+
5378
+ if ( notifySpy) {
5379
+ spyReportEnd();
5380
+ }
4810
5381
  }
4811
5382
 
4812
5383
  return true;
@@ -4915,12 +5486,18 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
4915
5486
 
4916
5487
  if (descriptor) {
4917
5488
  var outcome = annotation.make_(this, key, descriptor, source);
5489
+
4918
5490
  if (outcome === 0
4919
5491
  /* Cancel */
4920
- ) return;
5492
+ ) {
5493
+ return;
5494
+ }
5495
+
4921
5496
  if (outcome === 1
4922
5497
  /* Break */
4923
- ) break;
5498
+ ) {
5499
+ break;
5500
+ }
4924
5501
  }
4925
5502
 
4926
5503
  source = Object.getPrototypeOf(source);
@@ -4990,7 +5567,11 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
4990
5567
  type: ADD,
4991
5568
  newValue: descriptor.value
4992
5569
  });
4993
- if (!change) return null;
5570
+
5571
+ if (!change) {
5572
+ return null;
5573
+ }
5574
+
4994
5575
  var newValue = change.newValue;
4995
5576
 
4996
5577
  if (descriptor.value !== newValue) {
@@ -5042,7 +5623,11 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
5042
5623
  type: ADD,
5043
5624
  newValue: value
5044
5625
  });
5045
- if (!change) return null;
5626
+
5627
+ if (!change) {
5628
+ return null;
5629
+ }
5630
+
5046
5631
  value = change.newValue;
5047
5632
  }
5048
5633
 
@@ -5097,7 +5682,10 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
5097
5682
  type: ADD,
5098
5683
  newValue: undefined
5099
5684
  });
5100
- if (!change) return null;
5685
+
5686
+ if (!change) {
5687
+ return null;
5688
+ }
5101
5689
  }
5102
5690
 
5103
5691
  options.name || (options.name = "development" !== "production" ? this.name_ + "." + key.toString() : "ObservableObject.key");
@@ -5153,7 +5741,9 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
5153
5741
  type: REMOVE
5154
5742
  }); // Cancelled
5155
5743
 
5156
- if (!change) return null;
5744
+ if (!change) {
5745
+ return null;
5746
+ }
5157
5747
  } // Delete
5158
5748
 
5159
5749
 
@@ -5214,9 +5804,18 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
5214
5804
  oldValue: value,
5215
5805
  name: key
5216
5806
  };
5217
- if ("development" !== "production" && notifySpy) spyReportStart(_change2);
5218
- if (notify) notifyListeners(this, _change2);
5219
- if ("development" !== "production" && notifySpy) spyReportEnd();
5807
+
5808
+ if ("development" !== "production" && notifySpy) {
5809
+ spyReportStart(_change2);
5810
+ }
5811
+
5812
+ if (notify) {
5813
+ notifyListeners(this, _change2);
5814
+ }
5815
+
5816
+ if ("development" !== "production" && notifySpy) {
5817
+ spyReportEnd();
5818
+ }
5220
5819
  }
5221
5820
  } finally {
5222
5821
  endBatch();
@@ -5232,7 +5831,10 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
5232
5831
  ;
5233
5832
 
5234
5833
  _proto.observe_ = function observe_(callback, fireImmediately) {
5235
- if ( fireImmediately === true) die("`observe` doesn't support the fire immediately property for observable objects.");
5834
+ if ( fireImmediately === true) {
5835
+ die("`observe` doesn't support the fire immediately property for observable objects.");
5836
+ }
5837
+
5236
5838
  return registerListener(this, callback);
5237
5839
  };
5238
5840
 
@@ -5255,9 +5857,18 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
5255
5857
  name: key,
5256
5858
  newValue: value
5257
5859
  } : null;
5258
- if ( notifySpy) spyReportStart(change);
5259
- if (notify) notifyListeners(this, change);
5260
- if ( notifySpy) spyReportEnd();
5860
+
5861
+ if ( notifySpy) {
5862
+ spyReportStart(change);
5863
+ }
5864
+
5865
+ if (notify) {
5866
+ notifyListeners(this, change);
5867
+ }
5868
+
5869
+ if ( notifySpy) {
5870
+ spyReportEnd();
5871
+ }
5261
5872
  }
5262
5873
 
5263
5874
  (_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
@@ -5298,7 +5909,10 @@ function asObservableObject(target, options) {
5298
5909
  return target;
5299
5910
  }
5300
5911
 
5301
- if ( !Object.isExtensible(target)) die("Cannot make the designated object observable; it is not extensible");
5912
+ if ( !Object.isExtensible(target)) {
5913
+ die("Cannot make the designated object observable; it is not extensible");
5914
+ }
5915
+
5302
5916
  var name = (_options$name = options == null ? void 0 : options.name) != null ? _options$name : (isPlainObject(target) ? "ObservableObject" : target.constructor.name) + "@" + getNextId() ;
5303
5917
  var adm = new ObservableObjectAdministration(target, new Map(), String(name), getAnnotationFromOptions(options));
5304
5918
  addHiddenProp(target, $mobx, adm);
@@ -5455,7 +6069,6 @@ var LegacyObservableArray = /*#__PURE__*/function (_StubArray, _Symbol$toStringT
5455
6069
  var nextIndex = 0;
5456
6070
  return makeIterable({
5457
6071
  next: function next() {
5458
- // @ts-ignore
5459
6072
  return nextIndex < self.length ? {
5460
6073
  value: self[nextIndex++],
5461
6074
  done: false
@@ -5488,7 +6101,10 @@ var LegacyObservableArray = /*#__PURE__*/function (_StubArray, _Symbol$toStringT
5488
6101
  Object.entries(arrayExtensions).forEach(function (_ref) {
5489
6102
  var prop = _ref[0],
5490
6103
  fn = _ref[1];
5491
- if (prop !== "concat") addHiddenProp(LegacyObservableArray.prototype, prop, fn);
6104
+
6105
+ if (prop !== "concat") {
6106
+ addHiddenProp(LegacyObservableArray.prototype, prop, fn);
6107
+ }
5492
6108
  });
5493
6109
 
5494
6110
  function createArrayEntryDescriptor(index) {
@@ -5525,7 +6141,10 @@ function createLegacyArray(initialValues, enhancer, name) {
5525
6141
  function getAtom(thing, property) {
5526
6142
  if (typeof thing === "object" && thing !== null) {
5527
6143
  if (isObservableArray(thing)) {
5528
- if (property !== undefined) die(23);
6144
+ if (property !== undefined) {
6145
+ die(23);
6146
+ }
6147
+
5529
6148
  return thing[$mobx].atom_;
5530
6149
  }
5531
6150
 
@@ -5534,18 +6153,31 @@ function getAtom(thing, property) {
5534
6153
  }
5535
6154
 
5536
6155
  if (isObservableMap(thing)) {
5537
- if (property === undefined) return thing.keysAtom_;
6156
+ if (property === undefined) {
6157
+ return thing.keysAtom_;
6158
+ }
6159
+
5538
6160
  var observable = thing.data_.get(property) || thing.hasMap_.get(property);
5539
- if (!observable) die(25, property, getDebugName(thing));
6161
+
6162
+ if (!observable) {
6163
+ die(25, property, getDebugName(thing));
6164
+ }
6165
+
5540
6166
  return observable;
5541
6167
  }
5542
6168
 
6169
+
5543
6170
  if (isObservableObject(thing)) {
5544
- if (!property) return die(26);
6171
+ if (!property) {
6172
+ return die(26);
6173
+ }
5545
6174
 
5546
6175
  var _observable = thing[$mobx].values_.get(property);
5547
6176
 
5548
- if (!_observable) die(27, property, getDebugName(thing));
6177
+ if (!_observable) {
6178
+ die(27, property, getDebugName(thing));
6179
+ }
6180
+
5549
6181
  return _observable;
5550
6182
  }
5551
6183
 
@@ -5562,11 +6194,26 @@ function getAtom(thing, property) {
5562
6194
  die(28);
5563
6195
  }
5564
6196
  function getAdministration(thing, property) {
5565
- if (!thing) die(29);
5566
- if (property !== undefined) return getAdministration(getAtom(thing, property));
5567
- if (isAtom(thing) || isComputedValue(thing) || isReaction(thing)) return thing;
5568
- if (isObservableMap(thing) || isObservableSet(thing)) return thing;
5569
- if (thing[$mobx]) return thing[$mobx];
6197
+ if (!thing) {
6198
+ die(29);
6199
+ }
6200
+
6201
+ if (property !== undefined) {
6202
+ return getAdministration(getAtom(thing, property));
6203
+ }
6204
+
6205
+ if (isAtom(thing) || isComputedValue(thing) || isReaction(thing)) {
6206
+ return thing;
6207
+ }
6208
+
6209
+ if (isObservableMap(thing) || isObservableSet(thing)) {
6210
+ return thing;
6211
+ }
6212
+
6213
+ if (thing[$mobx]) {
6214
+ return thing[$mobx];
6215
+ }
6216
+
5570
6217
  die(24, thing);
5571
6218
  }
5572
6219
  function getDebugName(thing, property) {
@@ -5599,17 +6246,33 @@ function deepEqual(a, b, depth) {
5599
6246
  function eq(a, b, depth, aStack, bStack) {
5600
6247
  // Identical objects are equal. `0 === -0`, but they aren't identical.
5601
6248
  // See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal).
5602
- if (a === b) return a !== 0 || 1 / a === 1 / b; // `null` or `undefined` only equal to itself (strict comparison).
6249
+ if (a === b) {
6250
+ return a !== 0 || 1 / a === 1 / b;
6251
+ } // `null` or `undefined` only equal to itself (strict comparison).
5603
6252
 
5604
- if (a == null || b == null) return false; // `NaN`s are equivalent, but non-reflexive.
5605
6253
 
5606
- if (a !== a) return b !== b; // Exhaust primitive checks
6254
+ if (a == null || b == null) {
6255
+ return false;
6256
+ } // `NaN`s are equivalent, but non-reflexive.
6257
+
6258
+
6259
+ if (a !== a) {
6260
+ return b !== b;
6261
+ } // Exhaust primitive checks
6262
+
5607
6263
 
5608
6264
  var type = typeof a;
5609
- if (type !== "function" && type !== "object" && typeof b != "object") return false; // Compare `[[Class]]` names.
6265
+
6266
+ if (type !== "function" && type !== "object" && typeof b != "object") {
6267
+ return false;
6268
+ } // Compare `[[Class]]` names.
6269
+
5610
6270
 
5611
6271
  var className = toString.call(a);
5612
- if (className !== toString.call(b)) return false;
6272
+
6273
+ if (className !== toString.call(b)) {
6274
+ return false;
6275
+ }
5613
6276
 
5614
6277
  switch (className) {
5615
6278
  // Strings, numbers, regular expressions, dates, and booleans are compared by value.
@@ -5623,7 +6286,10 @@ function eq(a, b, depth, aStack, bStack) {
5623
6286
  case "[object Number]":
5624
6287
  // `NaN`s are equivalent, but non-reflexive.
5625
6288
  // Object(NaN) is equivalent to NaN.
5626
- if (+a !== +a) return +b !== +b; // An `egal` comparison is performed for other numeric values.
6289
+ if (+a !== +a) {
6290
+ return +b !== +b;
6291
+ } // An `egal` comparison is performed for other numeric values.
6292
+
5627
6293
 
5628
6294
  return +a === 0 ? 1 / +a === 1 / b : +a === +b;
5629
6295
 
@@ -5654,9 +6320,12 @@ function eq(a, b, depth, aStack, bStack) {
5654
6320
  var areArrays = className === "[object Array]";
5655
6321
 
5656
6322
  if (!areArrays) {
5657
- if (typeof a != "object" || typeof b != "object") return false; // Objects with different constructors are not equivalent, but `Object`s or `Array`s
6323
+ if (typeof a != "object" || typeof b != "object") {
6324
+ return false;
6325
+ } // Objects with different constructors are not equivalent, but `Object`s or `Array`s
5658
6326
  // from different frames are.
5659
6327
 
6328
+
5660
6329
  var aCtor = a.constructor,
5661
6330
  bCtor = b.constructor;
5662
6331
 
@@ -5682,7 +6351,9 @@ function eq(a, b, depth, aStack, bStack) {
5682
6351
  while (length--) {
5683
6352
  // Linear search. Performance is inversely proportional to the number of
5684
6353
  // unique nested structures.
5685
- if (aStack[length] === a) return bStack[length] === b;
6354
+ if (aStack[length] === a) {
6355
+ return bStack[length] === b;
6356
+ }
5686
6357
  } // Add the first object to the stack of traversed objects.
5687
6358
 
5688
6359
 
@@ -5692,10 +6363,16 @@ function eq(a, b, depth, aStack, bStack) {
5692
6363
  if (areArrays) {
5693
6364
  // Compare array lengths to determine if a deep comparison is necessary.
5694
6365
  length = a.length;
5695
- if (length !== b.length) return false; // Deep compare the contents, ignoring non-numeric properties.
6366
+
6367
+ if (length !== b.length) {
6368
+ return false;
6369
+ } // Deep compare the contents, ignoring non-numeric properties.
6370
+
5696
6371
 
5697
6372
  while (length--) {
5698
- if (!eq(a[length], b[length], depth - 1, aStack, bStack)) return false;
6373
+ if (!eq(a[length], b[length], depth - 1, aStack, bStack)) {
6374
+ return false;
6375
+ }
5699
6376
  }
5700
6377
  } else {
5701
6378
  // Deep compare objects.
@@ -5703,12 +6380,17 @@ function eq(a, b, depth, aStack, bStack) {
5703
6380
  var key;
5704
6381
  length = keys.length; // Ensure that both objects contain the same number of properties before comparing deep equality.
5705
6382
 
5706
- if (Object.keys(b).length !== length) return false;
6383
+ if (Object.keys(b).length !== length) {
6384
+ return false;
6385
+ }
5707
6386
 
5708
6387
  while (length--) {
5709
6388
  // Deep compare each member
5710
6389
  key = keys[length];
5711
- if (!(hasProp(b, key) && eq(a[key], b[key], depth - 1, aStack, bStack))) return false;
6390
+
6391
+ if (!(hasProp(b, key) && eq(a[key], b[key], depth - 1, aStack, bStack))) {
6392
+ return false;
6393
+ }
5712
6394
  }
5713
6395
  } // Remove the first object from the stack of traversed objects.
5714
6396
 
@@ -5719,9 +6401,18 @@ function eq(a, b, depth, aStack, bStack) {
5719
6401
  }
5720
6402
 
5721
6403
  function unwrap(a) {
5722
- if (isObservableArray(a)) return a.slice();
5723
- if (isES6Map(a) || isObservableMap(a)) return Array.from(a.entries());
5724
- if (isES6Set(a) || isObservableSet(a)) return Array.from(a.entries());
6404
+ if (isObservableArray(a)) {
6405
+ return a.slice();
6406
+ }
6407
+
6408
+ if (isES6Map(a) || isObservableMap(a)) {
6409
+ return Array.from(a.entries());
6410
+ }
6411
+
6412
+ if (isES6Set(a) || isObservableSet(a)) {
6413
+ return Array.from(a.entries());
6414
+ }
6415
+
5725
6416
  return a;
5726
6417
  }
5727
6418