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
@@ -23,9 +23,9 @@ var niceErrors = {
23
23
  10: "'has()' can only be used on observable objects, arrays and maps",
24
24
  11: "'get()' can only be used on observable objects, arrays and maps",
25
25
  12: "Invalid annotation",
26
- 13: "Dynamic observable objects cannot be frozen",
26
+ 13: "Dynamic observable objects cannot be frozen. If you're passing observables to 3rd party component/function that calls Object.freeze, pass copy instead: toJS(observable)",
27
27
  14: "Intercept handlers should return nothing or a change object",
28
- 15: "Observable arrays cannot be frozen",
28
+ 15: "Observable arrays cannot be frozen. If you're passing observables to 3rd party component/function that calls Object.freeze, pass copy instead: toJS(observable)",
29
29
  16: "Modification exception: the internal structure of an observable array was changed.",
30
30
  17: function _(index, length) {
31
31
  return "[mobx.array] Index out of bounds, " + index + " is larger than " + length;
@@ -139,7 +139,10 @@ function getNextId() {
139
139
  function once(func) {
140
140
  var invoked = false;
141
141
  return function () {
142
- if (invoked) return;
142
+ if (invoked) {
143
+ return;
144
+ }
145
+
143
146
  invoked = true;
144
147
  return func.apply(this, arguments);
145
148
  };
@@ -164,17 +167,31 @@ function isObject(value) {
164
167
  return value !== null && typeof value === "object";
165
168
  }
166
169
  function isPlainObject(value) {
167
- if (!isObject(value)) return false;
170
+ if (!isObject(value)) {
171
+ return false;
172
+ }
173
+
168
174
  var proto = Object.getPrototypeOf(value);
169
- if (proto == null) return true;
175
+
176
+ if (proto == null) {
177
+ return true;
178
+ }
179
+
170
180
  var protoConstructor = Object.hasOwnProperty.call(proto, "constructor") && proto.constructor;
171
181
  return typeof protoConstructor === "function" && protoConstructor.toString() === plainObjectString;
172
182
  } // https://stackoverflow.com/a/37865170
173
183
 
174
184
  function isGenerator(obj) {
175
185
  var constructor = obj == null ? void 0 : obj.constructor;
176
- if (!constructor) return false;
177
- if ("GeneratorFunction" === constructor.name || "GeneratorFunction" === constructor.displayName) return true;
186
+
187
+ if (!constructor) {
188
+ return false;
189
+ }
190
+
191
+ if ("GeneratorFunction" === constructor.name || "GeneratorFunction" === constructor.displayName) {
192
+ return true;
193
+ }
194
+
178
195
  return false;
179
196
  }
180
197
  function addHiddenProp(object, propName, value) {
@@ -214,9 +231,16 @@ var hasGetOwnPropertySymbols = typeof Object.getOwnPropertySymbols !== "undefine
214
231
  function getPlainObjectKeys(object) {
215
232
  var keys = Object.keys(object); // Not supported in IE, so there are not going to be symbol props anyway...
216
233
 
217
- if (!hasGetOwnPropertySymbols) return keys;
234
+ if (!hasGetOwnPropertySymbols) {
235
+ return keys;
236
+ }
237
+
218
238
  var symbols = Object.getOwnPropertySymbols(object);
219
- if (!symbols.length) return keys;
239
+
240
+ if (!symbols.length) {
241
+ return keys;
242
+ }
243
+
220
244
  return [].concat(keys, symbols.filter(function (s) {
221
245
  return objectPrototype.propertyIsEnumerable.call(object, s);
222
246
  }));
@@ -229,8 +253,14 @@ var ownKeys = typeof Reflect !== "undefined" && Reflect.ownKeys ? Reflect.ownKey
229
253
  /* istanbul ignore next */
230
254
  Object.getOwnPropertyNames;
231
255
  function stringifyKey(key) {
232
- if (typeof key === "string") return key;
233
- if (typeof key === "symbol") return key.toString();
256
+ if (typeof key === "string") {
257
+ return key;
258
+ }
259
+
260
+ if (typeof key === "symbol") {
261
+ return key.toString();
262
+ }
263
+
234
264
  return new String(key).toString();
235
265
  }
236
266
  function toPrimitive(value) {
@@ -518,7 +548,10 @@ function shallowComparer(a, b) {
518
548
  }
519
549
 
520
550
  function defaultComparer(a, b) {
521
- if (Object.is) return Object.is(a, b);
551
+ if (Object.is) {
552
+ return Object.is(a, b);
553
+ }
554
+
522
555
  return a === b ? a !== 0 || 1 / a === 1 / b : a !== a && b !== b;
523
556
  }
524
557
 
@@ -531,20 +564,34 @@ var comparer = {
531
564
 
532
565
  function deepEnhancer(v, _, name) {
533
566
  // it is an observable already, done
534
- if (isObservable(v)) return v; // something that can be converted and mutated?
567
+ if (isObservable(v)) {
568
+ return v;
569
+ } // something that can be converted and mutated?
535
570
 
536
- if (Array.isArray(v)) return observable.array(v, {
537
- name: name
538
- });
539
- if (isPlainObject(v)) return observable.object(v, undefined, {
540
- name: name
541
- });
542
- if (isES6Map(v)) return observable.map(v, {
543
- name: name
544
- });
545
- if (isES6Set(v)) return observable.set(v, {
546
- name: name
547
- });
571
+
572
+ if (Array.isArray(v)) {
573
+ return observable.array(v, {
574
+ name: name
575
+ });
576
+ }
577
+
578
+ if (isPlainObject(v)) {
579
+ return observable.object(v, undefined, {
580
+ name: name
581
+ });
582
+ }
583
+
584
+ if (isES6Map(v)) {
585
+ return observable.map(v, {
586
+ name: name
587
+ });
588
+ }
589
+
590
+ if (isES6Set(v)) {
591
+ return observable.set(v, {
592
+ name: name
593
+ });
594
+ }
548
595
 
549
596
  if (typeof v === "function" && !isAction(v) && !isFlow(v)) {
550
597
  if (isGenerator(v)) {
@@ -557,33 +604,59 @@ function deepEnhancer(v, _, name) {
557
604
  return v;
558
605
  }
559
606
  function shallowEnhancer(v, _, name) {
560
- if (v === undefined || v === null) return v;
561
- if (isObservableObject(v) || isObservableArray(v) || isObservableMap(v) || isObservableSet(v)) return v;
562
- if (Array.isArray(v)) return observable.array(v, {
563
- name: name,
564
- deep: false
565
- });
566
- if (isPlainObject(v)) return observable.object(v, undefined, {
567
- name: name,
568
- deep: false
569
- });
570
- if (isES6Map(v)) return observable.map(v, {
571
- name: name,
572
- deep: false
573
- });
574
- if (isES6Set(v)) return observable.set(v, {
575
- name: name,
576
- deep: false
577
- });
578
- die("The shallow modifier / decorator can only used in combination with arrays, objects, maps and sets");
607
+ if (v === undefined || v === null) {
608
+ return v;
609
+ }
610
+
611
+ if (isObservableObject(v) || isObservableArray(v) || isObservableMap(v) || isObservableSet(v)) {
612
+ return v;
613
+ }
614
+
615
+ if (Array.isArray(v)) {
616
+ return observable.array(v, {
617
+ name: name,
618
+ deep: false
619
+ });
620
+ }
621
+
622
+ if (isPlainObject(v)) {
623
+ return observable.object(v, undefined, {
624
+ name: name,
625
+ deep: false
626
+ });
627
+ }
628
+
629
+ if (isES6Map(v)) {
630
+ return observable.map(v, {
631
+ name: name,
632
+ deep: false
633
+ });
634
+ }
635
+
636
+ if (isES6Set(v)) {
637
+ return observable.set(v, {
638
+ name: name,
639
+ deep: false
640
+ });
641
+ }
642
+
643
+ {
644
+ die("The shallow modifier / decorator can only used in combination with arrays, objects, maps and sets");
645
+ }
579
646
  }
580
647
  function referenceEnhancer(newValue) {
581
648
  // never turn into an observable
582
649
  return newValue;
583
650
  }
584
651
  function refStructEnhancer(v, oldValue) {
585
- if ( isObservable(v)) die("observable.struct should not be used with observable values");
586
- if (deepEqual(v, oldValue)) return oldValue;
652
+ if ( isObservable(v)) {
653
+ die("observable.struct should not be used with observable values");
654
+ }
655
+
656
+ if (deepEqual(v, oldValue)) {
657
+ return oldValue;
658
+ }
659
+
587
660
  return v;
588
661
  }
589
662
 
@@ -731,10 +804,12 @@ function make_$2(adm, key, descriptor, source) {
731
804
  // bound - must annotate protos to support super.flow()
732
805
 
733
806
 
734
- if ((_this$options_ = this.options_) != null && _this$options_.bound && !isFlow(adm.target_[key])) {
735
- if (this.extend_(adm, key, descriptor, false) === null) return 0
736
- /* Cancel */
737
- ;
807
+ if ((_this$options_ = this.options_) != null && _this$options_.bound && (!hasProp(adm.target_, key) || !isFlow(adm.target_[key]))) {
808
+ if (this.extend_(adm, key, descriptor, false) === null) {
809
+ return 0
810
+ /* Cancel */
811
+ ;
812
+ }
738
813
  }
739
814
 
740
815
  if (isFlow(descriptor.value)) {
@@ -775,16 +850,23 @@ safeDescriptors) {
775
850
  }
776
851
 
777
852
  assertFlowDescriptor(adm, annotation, key, descriptor);
778
- var value = descriptor.value;
853
+ var value = descriptor.value; // In case of flow.bound, the descriptor can be from already annotated prototype
854
+
855
+ if (!isFlow(value)) {
856
+ value = flow(value);
857
+ }
779
858
 
780
859
  if (bound) {
781
860
  var _adm$proxy_;
782
861
 
783
- value = value.bind((_adm$proxy_ = adm.proxy_) != null ? _adm$proxy_ : adm.target_);
862
+ // We do not keep original function around, so we bind the existing flow
863
+ value = value.bind((_adm$proxy_ = adm.proxy_) != null ? _adm$proxy_ : adm.target_); // This is normally set by `flow`, but `bind` returns new function...
864
+
865
+ value.isMobXFlow = true;
784
866
  }
785
867
 
786
868
  return {
787
- value: flow(value),
869
+ value: value,
788
870
  // Non-configurable for classes
789
871
  // prevents accidental field redefinition in subclass
790
872
  configurable: safeDescriptors ? adm.isPlainObject_ : true,
@@ -1018,17 +1100,35 @@ function createObservable(v, arg2, arg3) {
1018
1100
  } // already observable - ignore
1019
1101
 
1020
1102
 
1021
- if (isObservable(v)) return v; // plain object
1103
+ if (isObservable(v)) {
1104
+ return v;
1105
+ } // plain object
1022
1106
 
1023
- if (isPlainObject(v)) return observable.object(v, arg2, arg3); // Array
1024
1107
 
1025
- if (Array.isArray(v)) return observable.array(v, arg2); // Map
1108
+ if (isPlainObject(v)) {
1109
+ return observable.object(v, arg2, arg3);
1110
+ } // Array
1026
1111
 
1027
- if (isES6Map(v)) return observable.map(v, arg2); // Set
1028
1112
 
1029
- if (isES6Set(v)) return observable.set(v, arg2); // other object - ignore
1113
+ if (Array.isArray(v)) {
1114
+ return observable.array(v, arg2);
1115
+ } // Map
1116
+
1117
+
1118
+ if (isES6Map(v)) {
1119
+ return observable.map(v, arg2);
1120
+ } // Set
1121
+
1122
+
1123
+ if (isES6Set(v)) {
1124
+ return observable.set(v, arg2);
1125
+ } // other object - ignore
1126
+
1127
+
1128
+ if (typeof v === "object" && v !== null) {
1129
+ return v;
1130
+ } // anything else
1030
1131
 
1031
- if (typeof v === "object" && v !== null) return v; // anything else
1032
1132
 
1033
1133
  return observable.box(v, arg2);
1034
1134
  }
@@ -1086,8 +1186,13 @@ var computed = function computed(arg1, arg2) {
1086
1186
 
1087
1187
 
1088
1188
  {
1089
- if (!isFunction(arg1)) die("First argument to `computed` should be an expression.");
1090
- if (isFunction(arg2)) die("A setter as second argument is no longer supported, use `{ set: fn }` option instead");
1189
+ if (!isFunction(arg1)) {
1190
+ die("First argument to `computed` should be an expression.");
1191
+ }
1192
+
1193
+ if (isFunction(arg2)) {
1194
+ die("A setter as second argument is no longer supported, use `{ set: fn }` option instead");
1195
+ }
1091
1196
  }
1092
1197
 
1093
1198
  var opts = isPlainObject(arg2) ? arg2 : {};
@@ -1119,8 +1224,13 @@ function createAction(actionName, fn, autoAction, ref) {
1119
1224
  }
1120
1225
 
1121
1226
  {
1122
- if (!isFunction(fn)) die("`action` can only be invoked on functions");
1123
- if (typeof actionName !== "string" || !actionName) die("actions should have valid names, got: '" + actionName + "'");
1227
+ if (!isFunction(fn)) {
1228
+ die("`action` can only be invoked on functions");
1229
+ }
1230
+
1231
+ if (typeof actionName !== "string" || !actionName) {
1232
+ die("actions should have valid names, got: '" + actionName + "'");
1233
+ }
1124
1234
  }
1125
1235
 
1126
1236
  function res() {
@@ -1202,7 +1312,10 @@ function _endAction(runInfo) {
1202
1312
  allowStateChangesEnd(runInfo.prevAllowStateChanges_);
1203
1313
  allowStateReadsEnd(runInfo.prevAllowStateReads_);
1204
1314
  endBatch();
1205
- if (runInfo.runAsAction_) untrackedEnd(runInfo.prevDerivation_);
1315
+
1316
+ if (runInfo.runAsAction_) {
1317
+ untrackedEnd(runInfo.prevDerivation_);
1318
+ }
1206
1319
 
1207
1320
  if ( runInfo.notifySpy_) {
1208
1321
  spyReportEnd({
@@ -1282,7 +1395,10 @@ var ObservableValue = /*#__PURE__*/function (_Atom, _Symbol$toPrimitive2) {
1282
1395
  var _proto = ObservableValue.prototype;
1283
1396
 
1284
1397
  _proto.dehanceValue = function dehanceValue(value) {
1285
- if (this.dehancer !== undefined) return this.dehancer(value);
1398
+ if (this.dehancer !== undefined) {
1399
+ return this.dehancer(value);
1400
+ }
1401
+
1286
1402
  return value;
1287
1403
  };
1288
1404
 
@@ -1305,7 +1421,10 @@ var ObservableValue = /*#__PURE__*/function (_Atom, _Symbol$toPrimitive2) {
1305
1421
  }
1306
1422
 
1307
1423
  this.setNewValue_(newValue);
1308
- if ( notifySpy) spyReportEnd();
1424
+
1425
+ if ( notifySpy) {
1426
+ spyReportEnd();
1427
+ }
1309
1428
  }
1310
1429
  };
1311
1430
 
@@ -1318,7 +1437,11 @@ var ObservableValue = /*#__PURE__*/function (_Atom, _Symbol$toPrimitive2) {
1318
1437
  type: UPDATE,
1319
1438
  newValue: newValue
1320
1439
  });
1321
- if (!change) return globalState.UNCHANGED;
1440
+
1441
+ if (!change) {
1442
+ return globalState.UNCHANGED;
1443
+ }
1444
+
1322
1445
  newValue = change.newValue;
1323
1446
  } // apply modifier
1324
1447
 
@@ -1352,14 +1475,17 @@ var ObservableValue = /*#__PURE__*/function (_Atom, _Symbol$toPrimitive2) {
1352
1475
  };
1353
1476
 
1354
1477
  _proto.observe_ = function observe_(listener, fireImmediately) {
1355
- if (fireImmediately) listener({
1356
- observableKind: "value",
1357
- debugObjectName: this.name_,
1358
- object: this,
1359
- type: UPDATE,
1360
- newValue: this.value_,
1361
- oldValue: undefined
1362
- });
1478
+ if (fireImmediately) {
1479
+ listener({
1480
+ observableKind: "value",
1481
+ debugObjectName: this.name_,
1482
+ object: this,
1483
+ type: UPDATE,
1484
+ newValue: this.value_,
1485
+ oldValue: undefined
1486
+ });
1487
+ }
1488
+
1363
1489
  return registerListener(this, listener);
1364
1490
  };
1365
1491
 
@@ -1454,7 +1580,11 @@ var ComputedValue = /*#__PURE__*/function (_Symbol$toPrimitive2) {
1454
1580
  this.keepAlive_ = void 0;
1455
1581
  this.onBOL = void 0;
1456
1582
  this.onBUOL = void 0;
1457
- if (!options.get) die(31);
1583
+
1584
+ if (!options.get) {
1585
+ die(31);
1586
+ }
1587
+
1458
1588
  this.derivation = options.get;
1459
1589
  this.name_ = options.name || ( "ComputedValue@" + getNextId() );
1460
1590
 
@@ -1496,7 +1626,9 @@ var ComputedValue = /*#__PURE__*/function (_Symbol$toPrimitive2) {
1496
1626
  ;
1497
1627
 
1498
1628
  _proto.get = function get() {
1499
- if (this.isComputing_) die(32, this.name_, this.derivation);
1629
+ if (this.isComputing_) {
1630
+ die(32, this.name_, this.derivation);
1631
+ }
1500
1632
 
1501
1633
  if (globalState.inBatch === 0 && // !globalState.trackingDerivatpion &&
1502
1634
  this.observers_.size === 0 && !this.keepAlive_) {
@@ -1512,20 +1644,34 @@ var ComputedValue = /*#__PURE__*/function (_Symbol$toPrimitive2) {
1512
1644
 
1513
1645
  if (shouldCompute(this)) {
1514
1646
  var prevTrackingContext = globalState.trackingContext;
1515
- if (this.keepAlive_ && !prevTrackingContext) globalState.trackingContext = this;
1516
- if (this.trackAndCompute()) propagateChangeConfirmed(this);
1647
+
1648
+ if (this.keepAlive_ && !prevTrackingContext) {
1649
+ globalState.trackingContext = this;
1650
+ }
1651
+
1652
+ if (this.trackAndCompute()) {
1653
+ propagateChangeConfirmed(this);
1654
+ }
1655
+
1517
1656
  globalState.trackingContext = prevTrackingContext;
1518
1657
  }
1519
1658
  }
1520
1659
 
1521
1660
  var result = this.value_;
1522
- if (isCaughtException(result)) throw result.cause;
1661
+
1662
+ if (isCaughtException(result)) {
1663
+ throw result.cause;
1664
+ }
1665
+
1523
1666
  return result;
1524
1667
  };
1525
1668
 
1526
1669
  _proto.set = function set(value) {
1527
1670
  if (this.setter_) {
1528
- if (this.isRunningSetter_) die(33, this.name_);
1671
+ if (this.isRunningSetter_) {
1672
+ die(33, this.name_);
1673
+ }
1674
+
1529
1675
  this.isRunningSetter_ = true;
1530
1676
 
1531
1677
  try {
@@ -1533,7 +1679,9 @@ var ComputedValue = /*#__PURE__*/function (_Symbol$toPrimitive2) {
1533
1679
  } finally {
1534
1680
  this.isRunningSetter_ = false;
1535
1681
  }
1536
- } else die(34, this.name_);
1682
+ } else {
1683
+ die(34, this.name_);
1684
+ }
1537
1685
  };
1538
1686
 
1539
1687
  _proto.trackAndCompute = function trackAndCompute() {
@@ -1762,7 +1910,9 @@ function checkIfStateModificationsAreAllowed(atom) {
1762
1910
 
1763
1911
  var hasObservers = atom.observers_.size > 0; // Should not be possible to change observed state outside strict mode, except during initialization, see #563
1764
1912
 
1765
- 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_);
1913
+ if (!globalState.allowStateChanges && (hasObservers || globalState.enforceActions === "always")) {
1914
+ 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_);
1915
+ }
1766
1916
  }
1767
1917
  function checkIfStateReadsAreAllowed(observable) {
1768
1918
  if ( !globalState.allowStateReads && globalState.observableRequiresReaction) {
@@ -1807,7 +1957,10 @@ function trackDerivedFunction(derivation, f, context) {
1807
1957
  }
1808
1958
 
1809
1959
  function warnAboutDerivationWithoutDependencies(derivation) {
1810
- if (derivation.observing_.length !== 0) return;
1960
+
1961
+ if (derivation.observing_.length !== 0) {
1962
+ return;
1963
+ }
1811
1964
 
1812
1965
  if (globalState.reactionRequiresObservable || derivation.requiresObservable_) {
1813
1966
  console.warn("[mobx] Derivation '" + derivation.name_ + "' is created/updated without reading any observable value.");
@@ -1836,7 +1989,11 @@ function bindDependencies(derivation) {
1836
1989
 
1837
1990
  if (dep.diffValue_ === 0) {
1838
1991
  dep.diffValue_ = 1;
1839
- if (i0 !== i) observing[i0] = dep;
1992
+
1993
+ if (i0 !== i) {
1994
+ observing[i0] = dep;
1995
+ }
1996
+
1840
1997
  i0++;
1841
1998
  } // Upcast is 'safe' here, because if dep is IObservable, `dependenciesState` will be undefined,
1842
1999
  // not hitting the condition
@@ -1928,7 +2085,10 @@ function allowStateReadsEnd(prev) {
1928
2085
  */
1929
2086
 
1930
2087
  function changeDependenciesStateTo0(derivation) {
1931
- if (derivation.dependenciesState_ === IDerivationState_.UP_TO_DATE_) return;
2088
+ if (derivation.dependenciesState_ === IDerivationState_.UP_TO_DATE_) {
2089
+ return;
2090
+ }
2091
+
1932
2092
  derivation.dependenciesState_ = IDerivationState_.UP_TO_DATE_;
1933
2093
  var obs = derivation.observing_;
1934
2094
  var i = obs.length;
@@ -1972,8 +2132,14 @@ var canMergeGlobalState = true;
1972
2132
  var isolateCalled = false;
1973
2133
  var globalState = /*#__PURE__*/function () {
1974
2134
  var global = /*#__PURE__*/getGlobal();
1975
- if (global.__mobxInstanceCount > 0 && !global.__mobxGlobals) canMergeGlobalState = false;
1976
- if (global.__mobxGlobals && global.__mobxGlobals.version !== new MobXGlobals().version) canMergeGlobalState = false;
2135
+
2136
+ if (global.__mobxInstanceCount > 0 && !global.__mobxGlobals) {
2137
+ canMergeGlobalState = false;
2138
+ }
2139
+
2140
+ if (global.__mobxGlobals && global.__mobxGlobals.version !== new MobXGlobals().version) {
2141
+ canMergeGlobalState = false;
2142
+ }
1977
2143
 
1978
2144
  if (!canMergeGlobalState) {
1979
2145
  // Because this is a IIFE we need to let isolateCalled a chance to change
@@ -1986,7 +2152,11 @@ var globalState = /*#__PURE__*/function () {
1986
2152
  return new MobXGlobals();
1987
2153
  } else if (global.__mobxGlobals) {
1988
2154
  global.__mobxInstanceCount += 1;
1989
- if (!global.__mobxGlobals.UNCHANGED) global.__mobxGlobals.UNCHANGED = {}; // make merge backward compatible
2155
+
2156
+ if (!global.__mobxGlobals.UNCHANGED) {
2157
+ global.__mobxGlobals.UNCHANGED = {};
2158
+ } // make merge backward compatible
2159
+
1990
2160
 
1991
2161
  return global.__mobxGlobals;
1992
2162
  } else {
@@ -1995,12 +2165,19 @@ var globalState = /*#__PURE__*/function () {
1995
2165
  }
1996
2166
  }();
1997
2167
  function isolateGlobalState() {
1998
- if (globalState.pendingReactions.length || globalState.inBatch || globalState.isRunningReactions) die(36);
2168
+ if (globalState.pendingReactions.length || globalState.inBatch || globalState.isRunningReactions) {
2169
+ die(36);
2170
+ }
2171
+
1999
2172
  isolateCalled = true;
2000
2173
 
2001
2174
  if (canMergeGlobalState) {
2002
2175
  var global = getGlobal();
2003
- if (--global.__mobxInstanceCount === 0) global.__mobxGlobals = undefined;
2176
+
2177
+ if (--global.__mobxInstanceCount === 0) {
2178
+ global.__mobxGlobals = undefined;
2179
+ }
2180
+
2004
2181
  globalState = new MobXGlobals();
2005
2182
  }
2006
2183
  }
@@ -2016,7 +2193,9 @@ function resetGlobalState() {
2016
2193
  var defaultGlobals = new MobXGlobals();
2017
2194
 
2018
2195
  for (var key in defaultGlobals) {
2019
- if (persistentKeys.indexOf(key) === -1) globalState[key] = defaultGlobals[key];
2196
+ if (persistentKeys.indexOf(key) === -1) {
2197
+ globalState[key] = defaultGlobals[key];
2198
+ }
2020
2199
  }
2021
2200
 
2022
2201
  globalState.allowStateChanges = !globalState.enforceActions;
@@ -2050,8 +2229,12 @@ function addObserver(observable, node) {
2050
2229
  // invariant(observable._observers.indexOf(node) === -1, "INTERNAL ERROR add already added node");
2051
2230
  // invariantObservers(observable);
2052
2231
  observable.observers_.add(node);
2053
- if (observable.lowestObserverState_ > node.dependenciesState_) observable.lowestObserverState_ = node.dependenciesState_; // invariantObservers(observable);
2232
+
2233
+ if (observable.lowestObserverState_ > node.dependenciesState_) {
2234
+ observable.lowestObserverState_ = node.dependenciesState_;
2235
+ } // invariantObservers(observable);
2054
2236
  // invariant(observable._observers.indexOf(node) !== -1, "INTERNAL ERROR didn't add node");
2237
+
2055
2238
  }
2056
2239
  function removeObserver(observable, node) {
2057
2240
  // invariant(globalState.inBatch > 0, "INTERNAL ERROR, remove should be called only inside batch");
@@ -2162,7 +2345,10 @@ function reportObserved(observable) {
2162
2345
 
2163
2346
  function propagateChanged(observable) {
2164
2347
  // invariantLOS(observable, "changed start");
2165
- if (observable.lowestObserverState_ === IDerivationState_.STALE_) return;
2348
+ if (observable.lowestObserverState_ === IDerivationState_.STALE_) {
2349
+ return;
2350
+ }
2351
+
2166
2352
  observable.lowestObserverState_ = IDerivationState_.STALE_; // Ideally we use for..of here, but the downcompiled version is really slow...
2167
2353
 
2168
2354
  observable.observers_.forEach(function (d) {
@@ -2180,7 +2366,10 @@ function propagateChanged(observable) {
2180
2366
 
2181
2367
  function propagateChangeConfirmed(observable) {
2182
2368
  // invariantLOS(observable, "confirmed start");
2183
- if (observable.lowestObserverState_ === IDerivationState_.STALE_) return;
2369
+ if (observable.lowestObserverState_ === IDerivationState_.STALE_) {
2370
+ return;
2371
+ }
2372
+
2184
2373
  observable.lowestObserverState_ = IDerivationState_.STALE_;
2185
2374
  observable.observers_.forEach(function (d) {
2186
2375
  if (d.dependenciesState_ === IDerivationState_.POSSIBLY_STALE_) {
@@ -2198,7 +2387,10 @@ function propagateChangeConfirmed(observable) {
2198
2387
 
2199
2388
  function propagateMaybeChanged(observable) {
2200
2389
  // invariantLOS(observable, "maybe start");
2201
- if (observable.lowestObserverState_ !== IDerivationState_.UP_TO_DATE_) return;
2390
+ if (observable.lowestObserverState_ !== IDerivationState_.UP_TO_DATE_) {
2391
+ return;
2392
+ }
2393
+
2202
2394
  observable.lowestObserverState_ = IDerivationState_.POSSIBLY_STALE_;
2203
2395
  observable.observers_.forEach(function (d) {
2204
2396
  if (d.dependenciesState_ === IDerivationState_.UP_TO_DATE_) {
@@ -2226,9 +2418,12 @@ function printDepTree(tree, lines, depth) {
2226
2418
  }
2227
2419
 
2228
2420
  lines.push("" + "\t".repeat(depth - 1) + tree.name);
2229
- if (tree.dependencies) tree.dependencies.forEach(function (child) {
2230
- return printDepTree(child, lines, depth + 1);
2231
- });
2421
+
2422
+ if (tree.dependencies) {
2423
+ tree.dependencies.forEach(function (child) {
2424
+ return printDepTree(child, lines, depth + 1);
2425
+ });
2426
+ }
2232
2427
  }
2233
2428
 
2234
2429
  var Reaction = /*#__PURE__*/function () {
@@ -2346,7 +2541,9 @@ var Reaction = /*#__PURE__*/function () {
2346
2541
  clearObserving(this);
2347
2542
  }
2348
2543
 
2349
- if (isCaughtException(result)) this.reportExceptionInDerivation_(result.cause);
2544
+ if (isCaughtException(result)) {
2545
+ this.reportExceptionInDerivation_(result.cause);
2546
+ }
2350
2547
 
2351
2548
  if ( notify) {
2352
2549
  spyReportEnd({
@@ -2365,13 +2562,18 @@ var Reaction = /*#__PURE__*/function () {
2365
2562
  return;
2366
2563
  }
2367
2564
 
2368
- if (globalState.disableErrorBoundaries) throw error;
2565
+ if (globalState.disableErrorBoundaries) {
2566
+ throw error;
2567
+ }
2568
+
2369
2569
  var message = "[mobx] Encountered an uncaught exception that was thrown by a reaction or observer component, in: '" + this + "'" ;
2370
2570
 
2371
2571
  if (!globalState.suppressReactionErrors) {
2372
2572
  console.error(message, error);
2373
2573
  /** If debugging brought you here, please, read the above message :-). Tnx! */
2374
- } else console.warn("[mobx] (error in reaction '" + this.name_ + "' suppressed, fix error of causing action below)"); // prettier-ignore
2574
+ } else {
2575
+ console.warn("[mobx] (error in reaction '" + this.name_ + "' suppressed, fix error of causing action below)");
2576
+ } // prettier-ignore
2375
2577
 
2376
2578
 
2377
2579
  if ( isSpyEnabled()) {
@@ -2425,7 +2627,10 @@ function onReactionError(handler) {
2425
2627
  globalState.globalReactionErrorHandlers.push(handler);
2426
2628
  return function () {
2427
2629
  var idx = globalState.globalReactionErrorHandlers.indexOf(handler);
2428
- if (idx >= 0) globalState.globalReactionErrorHandlers.splice(idx, 1);
2630
+
2631
+ if (idx >= 0) {
2632
+ globalState.globalReactionErrorHandlers.splice(idx, 1);
2633
+ }
2429
2634
  };
2430
2635
  }
2431
2636
  /**
@@ -2442,7 +2647,10 @@ var reactionScheduler = function reactionScheduler(f) {
2442
2647
 
2443
2648
  function runReactions() {
2444
2649
  // Trampolining, if runReactions are already running, new reactions will be picked up
2445
- if (globalState.inBatch > 0 || globalState.isRunningReactions) return;
2650
+ if (globalState.inBatch > 0 || globalState.isRunningReactions) {
2651
+ return;
2652
+ }
2653
+
2446
2654
  reactionScheduler(runReactionsHelper);
2447
2655
  }
2448
2656
 
@@ -2485,7 +2693,11 @@ function isSpyEnabled() {
2485
2693
  }
2486
2694
  function spyReport(event) {
2487
2695
 
2488
- if (!globalState.spyListeners.length) return;
2696
+
2697
+ if (!globalState.spyListeners.length) {
2698
+ return;
2699
+ }
2700
+
2489
2701
  var listeners = globalState.spyListeners;
2490
2702
 
2491
2703
  for (var i = 0, l = listeners.length; i < l; i++) {
@@ -2505,10 +2717,15 @@ var END_EVENT = {
2505
2717
  spyReportEnd: true
2506
2718
  };
2507
2719
  function spyReportEnd(change) {
2508
- if (change) spyReport(_extends({}, change, {
2509
- type: "report-end",
2510
- spyReportEnd: true
2511
- }));else spyReport(END_EVENT);
2720
+
2721
+ if (change) {
2722
+ spyReport(_extends({}, change, {
2723
+ type: "report-end",
2724
+ spyReportEnd: true
2725
+ }));
2726
+ } else {
2727
+ spyReport(END_EVENT);
2728
+ }
2512
2729
  }
2513
2730
  function spy(listener) {
2514
2731
  {
@@ -2541,9 +2758,15 @@ var autoActionBoundAnnotation = /*#__PURE__*/createActionAnnotation(AUTOACTION_B
2541
2758
  function createActionFactory(autoAction) {
2542
2759
  var res = function action(arg1, arg2) {
2543
2760
  // action(fn() {})
2544
- if (isFunction(arg1)) return createAction(arg1.name || DEFAULT_ACTION_NAME, arg1, autoAction); // action("name", fn() {})
2761
+ if (isFunction(arg1)) {
2762
+ return createAction(arg1.name || DEFAULT_ACTION_NAME, arg1, autoAction);
2763
+ } // action("name", fn() {})
2764
+
2765
+
2766
+ if (isFunction(arg2)) {
2767
+ return createAction(arg1, arg2, autoAction);
2768
+ } // @action
2545
2769
 
2546
- if (isFunction(arg2)) return createAction(arg1, arg2, autoAction); // @action
2547
2770
 
2548
2771
  if (isStringish(arg2)) {
2549
2772
  return storeAnnotation(arg1, arg2, autoAction ? autoActionAnnotation : actionAnnotation);
@@ -2557,7 +2780,9 @@ function createActionFactory(autoAction) {
2557
2780
  }));
2558
2781
  }
2559
2782
 
2560
- die("Invalid arguments for `action`");
2783
+ {
2784
+ die("Invalid arguments for `action`");
2785
+ }
2561
2786
  };
2562
2787
 
2563
2788
  return res;
@@ -2591,8 +2816,13 @@ function autorun(view, opts) {
2591
2816
  }
2592
2817
 
2593
2818
  {
2594
- if (!isFunction(view)) die("Autorun expects a function as first argument");
2595
- if (isAction(view)) die("Autorun does not accept actions since actions are untrackable");
2819
+ if (!isFunction(view)) {
2820
+ die("Autorun expects a function as first argument");
2821
+ }
2822
+
2823
+ if (isAction(view)) {
2824
+ die("Autorun does not accept actions since actions are untrackable");
2825
+ }
2596
2826
  }
2597
2827
 
2598
2828
  var name = (_opts$name = (_opts = opts) == null ? void 0 : _opts.name) != null ? _opts$name : view.name || "Autorun@" + getNextId() ;
@@ -2613,7 +2843,10 @@ function autorun(view, opts) {
2613
2843
  isScheduled = true;
2614
2844
  scheduler(function () {
2615
2845
  isScheduled = false;
2616
- if (!reaction.isDisposed_) reaction.track(reactionRunner);
2846
+
2847
+ if (!reaction.isDisposed_) {
2848
+ reaction.track(reactionRunner);
2849
+ }
2617
2850
  });
2618
2851
  }
2619
2852
  }, opts.onError, opts.requiresObservable);
@@ -2645,8 +2878,13 @@ function reaction(expression, effect, opts) {
2645
2878
  }
2646
2879
 
2647
2880
  {
2648
- if (!isFunction(expression) || !isFunction(effect)) die("First and second argument to reaction should be functions");
2649
- if (!isPlainObject(opts)) die("Third argument of reactions should be an object");
2881
+ if (!isFunction(expression) || !isFunction(effect)) {
2882
+ die("First and second argument to reaction should be functions");
2883
+ }
2884
+
2885
+ if (!isPlainObject(opts)) {
2886
+ die("Third argument of reactions should be an object");
2887
+ }
2650
2888
  }
2651
2889
 
2652
2890
  var name = (_opts$name2 = opts.name) != null ? _opts$name2 : "Reaction@" + getNextId() ;
@@ -2669,7 +2907,11 @@ function reaction(expression, effect, opts) {
2669
2907
 
2670
2908
  function reactionRunner() {
2671
2909
  isScheduled = false;
2672
- if (r.isDisposed_) return;
2910
+
2911
+ if (r.isDisposed_) {
2912
+ return;
2913
+ }
2914
+
2673
2915
  var changed = false;
2674
2916
  r.track(function () {
2675
2917
  var nextValue = allowStateChanges(false, function () {
@@ -2679,7 +2921,13 @@ function reaction(expression, effect, opts) {
2679
2921
  oldValue = value;
2680
2922
  value = nextValue;
2681
2923
  });
2682
- if (firstTime && opts.fireImmediately) effectAction(value, oldValue, r);else if (!firstTime && changed) effectAction(value, oldValue, r);
2924
+
2925
+ if (firstTime && opts.fireImmediately) {
2926
+ effectAction(value, oldValue, r);
2927
+ } else if (!firstTime && changed) {
2928
+ effectAction(value, oldValue, r);
2929
+ }
2930
+
2683
2931
  firstTime = false;
2684
2932
  }
2685
2933
 
@@ -2746,7 +2994,9 @@ function configure(options) {
2746
2994
  globalState.useProxies = useProxies === ALWAYS ? true : useProxies === NEVER ? false : typeof Proxy !== "undefined";
2747
2995
  }
2748
2996
 
2749
- if (useProxies === "ifavailable") globalState.verifyProxies = true;
2997
+ if (useProxies === "ifavailable") {
2998
+ globalState.verifyProxies = true;
2999
+ }
2750
3000
 
2751
3001
  if (enforceActions !== undefined) {
2752
3002
  var ea = enforceActions === ALWAYS ? ALWAYS : enforceActions === OBSERVED;
@@ -2754,7 +3004,9 @@ function configure(options) {
2754
3004
  globalState.allowStateChanges = ea === true || ea === ALWAYS ? false : true;
2755
3005
  }
2756
3006
  ["computedRequiresReaction", "reactionRequiresObservable", "observableRequiresReaction", "disableErrorBoundaries", "safeDescriptors"].forEach(function (key) {
2757
- if (key in options) globalState[key] = !!options[key];
3007
+ if (key in options) {
3008
+ globalState[key] = !!options[key];
3009
+ }
2758
3010
  });
2759
3011
  globalState.allowStateReads = !globalState.observableRequiresReaction;
2760
3012
 
@@ -2769,11 +3021,25 @@ function configure(options) {
2769
3021
 
2770
3022
  function extendObservable(target, properties, annotations, options) {
2771
3023
  {
2772
- if (arguments.length > 4) die("'extendObservable' expected 2-4 arguments");
2773
- if (typeof target !== "object") die("'extendObservable' expects an object as first argument");
2774
- if (isObservableMap(target)) die("'extendObservable' should not be used on maps, use map.merge instead");
2775
- if (!isPlainObject(properties)) die("'extendObservable' only accepts plain objects as second argument");
2776
- if (isObservable(properties) || isObservable(annotations)) die("Extending an object with another observable (object) is not supported");
3024
+ if (arguments.length > 4) {
3025
+ die("'extendObservable' expected 2-4 arguments");
3026
+ }
3027
+
3028
+ if (typeof target !== "object") {
3029
+ die("'extendObservable' expects an object as first argument");
3030
+ }
3031
+
3032
+ if (isObservableMap(target)) {
3033
+ die("'extendObservable' should not be used on maps, use map.merge instead");
3034
+ }
3035
+
3036
+ if (!isPlainObject(properties)) {
3037
+ die("'extendObservable' only accepts plain objects as second argument");
3038
+ }
3039
+
3040
+ if (isObservable(properties) || isObservable(annotations)) {
3041
+ die("Extending an object with another observable (object) is not supported");
3042
+ }
2777
3043
  } // Pull descriptors first, so we don't have to deal with props added by administration ($mobx)
2778
3044
 
2779
3045
 
@@ -2801,7 +3067,11 @@ function nodeToDependencyTree(node) {
2801
3067
  var result = {
2802
3068
  name: node.name_
2803
3069
  };
2804
- if (node.observing_ && node.observing_.length > 0) result.dependencies = unique(node.observing_).map(nodeToDependencyTree);
3070
+
3071
+ if (node.observing_ && node.observing_.length > 0) {
3072
+ result.dependencies = unique(node.observing_).map(nodeToDependencyTree);
3073
+ }
3074
+
2805
3075
  return result;
2806
3076
  }
2807
3077
 
@@ -2813,7 +3083,11 @@ function nodeToObserverTree(node) {
2813
3083
  var result = {
2814
3084
  name: node.name_
2815
3085
  };
2816
- if (hasObservers(node)) result.observers = Array.from(getObservers(node)).map(nodeToObserverTree);
3086
+
3087
+ if (hasObservers(node)) {
3088
+ result.observers = Array.from(getObservers(node)).map(nodeToObserverTree);
3089
+ }
3090
+
2817
3091
  return result;
2818
3092
  }
2819
3093
 
@@ -2840,7 +3114,10 @@ var flow = /*#__PURE__*/Object.assign(function flow(arg1, arg2) {
2840
3114
  } // flow(fn)
2841
3115
 
2842
3116
 
2843
- if ( arguments.length !== 1) die("Flow expects single argument with generator function");
3117
+ if ( arguments.length !== 1) {
3118
+ die("Flow expects single argument with generator function");
3119
+ }
3120
+
2844
3121
  var generator = arg1;
2845
3122
  var name = generator.name || "<unnamed flow>"; // Implementation based on https://github.com/tj/co/blob/master/index.js
2846
3123
 
@@ -2888,7 +3165,10 @@ var flow = /*#__PURE__*/Object.assign(function flow(arg1, arg2) {
2888
3165
  return;
2889
3166
  }
2890
3167
 
2891
- if (ret.done) return resolve(ret.value);
3168
+ if (ret.done) {
3169
+ return resolve(ret.value);
3170
+ }
3171
+
2892
3172
  pendingPromise = Promise.resolve(ret.value);
2893
3173
  return pendingPromise.then(onFulfilled, onRejected);
2894
3174
  }
@@ -2897,7 +3177,10 @@ var flow = /*#__PURE__*/Object.assign(function flow(arg1, arg2) {
2897
3177
  });
2898
3178
  promise.cancel = action(name + " - runid: " + runId + " - cancel", function () {
2899
3179
  try {
2900
- if (pendingPromise) cancelPromise(pendingPromise); // Finally block can return (or yield) stuff..
3180
+ if (pendingPromise) {
3181
+ cancelPromise(pendingPromise);
3182
+ } // Finally block can return (or yield) stuff..
3183
+
2901
3184
 
2902
3185
  var _res = gen["return"](undefined); // eat anything that promise would do, it's cancelled!
2903
3186
 
@@ -2921,7 +3204,9 @@ var flow = /*#__PURE__*/Object.assign(function flow(arg1, arg2) {
2921
3204
  flow.bound = /*#__PURE__*/createDecoratorAnnotation(flowBoundAnnotation);
2922
3205
 
2923
3206
  function cancelPromise(promise) {
2924
- if (isFunction(promise.cancel)) promise.cancel();
3207
+ if (isFunction(promise.cancel)) {
3208
+ promise.cancel();
3209
+ }
2925
3210
  }
2926
3211
 
2927
3212
  function flowResult(result) {
@@ -2937,13 +3222,19 @@ function interceptReads(thing, propOrHandler, handler) {
2937
3222
  if (isObservableMap(thing) || isObservableArray(thing) || isObservableValue(thing)) {
2938
3223
  target = getAdministration(thing);
2939
3224
  } else if (isObservableObject(thing)) {
2940
- if ( !isStringish(propOrHandler)) return die("InterceptReads can only be used with a specific property, not with an object in general");
3225
+ if ( !isStringish(propOrHandler)) {
3226
+ return die("InterceptReads can only be used with a specific property, not with an object in general");
3227
+ }
3228
+
2941
3229
  target = getAdministration(thing, propOrHandler);
2942
3230
  } else {
2943
3231
  return die("Expected observable map, object or array as first array");
2944
3232
  }
2945
3233
 
2946
- if ( target.dehancer !== undefined) return die("An intercept reader was already established");
3234
+ if ( target.dehancer !== undefined) {
3235
+ return die("An intercept reader was already established");
3236
+ }
3237
+
2947
3238
  target.dehancer = typeof propOrHandler === "function" ? propOrHandler : handler;
2948
3239
  return function () {
2949
3240
  target.dehancer = undefined;
@@ -2951,7 +3242,11 @@ function interceptReads(thing, propOrHandler, handler) {
2951
3242
  }
2952
3243
 
2953
3244
  function intercept(thing, propOrHandler, handler) {
2954
- if (isFunction(handler)) return interceptProperty(thing, propOrHandler, handler);else return interceptInterceptable(thing, propOrHandler);
3245
+ if (isFunction(handler)) {
3246
+ return interceptProperty(thing, propOrHandler, handler);
3247
+ } else {
3248
+ return interceptInterceptable(thing, propOrHandler);
3249
+ }
2955
3250
  }
2956
3251
 
2957
3252
  function interceptInterceptable(thing, handler) {
@@ -2967,25 +3262,41 @@ function _isComputed(value, property) {
2967
3262
  return isComputedValue(value);
2968
3263
  }
2969
3264
 
2970
- if (isObservableObject(value) === false) return false;
2971
- if (!value[$mobx].values_.has(property)) return false;
3265
+ if (isObservableObject(value) === false) {
3266
+ return false;
3267
+ }
3268
+
3269
+ if (!value[$mobx].values_.has(property)) {
3270
+ return false;
3271
+ }
3272
+
2972
3273
  var atom = getAtom(value, property);
2973
3274
  return isComputedValue(atom);
2974
3275
  }
2975
3276
  function isComputed(value) {
2976
- if ( arguments.length > 1) return die("isComputed expects only 1 argument. Use isComputedProp to inspect the observability of a property");
3277
+ if ( arguments.length > 1) {
3278
+ return die("isComputed expects only 1 argument. Use isComputedProp to inspect the observability of a property");
3279
+ }
3280
+
2977
3281
  return _isComputed(value);
2978
3282
  }
2979
3283
  function isComputedProp(value, propName) {
2980
- if ( !isStringish(propName)) return die("isComputed expected a property name as second argument");
3284
+ if ( !isStringish(propName)) {
3285
+ return die("isComputed expected a property name as second argument");
3286
+ }
3287
+
2981
3288
  return _isComputed(value, propName);
2982
3289
  }
2983
3290
 
2984
3291
  function _isObservable(value, property) {
2985
- if (!value) return false;
3292
+ if (!value) {
3293
+ return false;
3294
+ }
2986
3295
 
2987
3296
  if (property !== undefined) {
2988
- if ( (isObservableMap(value) || isObservableArray(value))) return die("isObservable(object, propertyName) is not supported for arrays and maps. Use map.has or array.length instead.");
3297
+ if ( (isObservableMap(value) || isObservableArray(value))) {
3298
+ return die("isObservable(object, propertyName) is not supported for arrays and maps. Use map.has or array.length instead.");
3299
+ }
2989
3300
 
2990
3301
  if (isObservableObject(value)) {
2991
3302
  return value[$mobx].values_.has(property);
@@ -2999,11 +3310,17 @@ function _isObservable(value, property) {
2999
3310
  }
3000
3311
 
3001
3312
  function isObservable(value) {
3002
- if ( arguments.length !== 1) die("isObservable expects only 1 argument. Use isObservableProp to inspect the observability of a property");
3313
+ if ( arguments.length !== 1) {
3314
+ die("isObservable expects only 1 argument. Use isObservableProp to inspect the observability of a property");
3315
+ }
3316
+
3003
3317
  return _isObservable(value);
3004
3318
  }
3005
3319
  function isObservableProp(value, propName) {
3006
- if ( !isStringish(propName)) return die("expected a property name as second argument");
3320
+ if ( !isStringish(propName)) {
3321
+ return die("expected a property name as second argument");
3322
+ }
3323
+
3007
3324
  return _isObservable(value, propName);
3008
3325
  }
3009
3326
 
@@ -3095,13 +3412,25 @@ function set(obj, key, value) {
3095
3412
  } else if (isObservableSet(obj)) {
3096
3413
  obj.add(key);
3097
3414
  } else if (isObservableArray(obj)) {
3098
- if (typeof key !== "number") key = parseInt(key, 10);
3099
- if (key < 0) die("Invalid index: '" + key + "'");
3100
- startBatch();
3101
- if (key >= obj.length) obj.length = key + 1;
3102
- obj[key] = value;
3103
- endBatch();
3104
- } else die(8);
3415
+ if (typeof key !== "number") {
3416
+ key = parseInt(key, 10);
3417
+ }
3418
+
3419
+ if (key < 0) {
3420
+ die("Invalid index: '" + key + "'");
3421
+ }
3422
+
3423
+ startBatch();
3424
+
3425
+ if (key >= obj.length) {
3426
+ obj.length = key + 1;
3427
+ }
3428
+
3429
+ obj[key] = value;
3430
+ endBatch();
3431
+ } else {
3432
+ die(8);
3433
+ }
3105
3434
  }
3106
3435
  function remove(obj, key) {
3107
3436
  if (isObservableObject(obj)) {
@@ -3111,7 +3440,10 @@ function remove(obj, key) {
3111
3440
  } else if (isObservableSet(obj)) {
3112
3441
  obj["delete"](key);
3113
3442
  } else if (isObservableArray(obj)) {
3114
- if (typeof key !== "number") key = parseInt(key, 10);
3443
+ if (typeof key !== "number") {
3444
+ key = parseInt(key, 10);
3445
+ }
3446
+
3115
3447
  obj.splice(key, 1);
3116
3448
  } else {
3117
3449
  die(9);
@@ -3131,7 +3463,9 @@ function has(obj, key) {
3131
3463
  die(10);
3132
3464
  }
3133
3465
  function get(obj, key) {
3134
- if (!has(obj, key)) return undefined;
3466
+ if (!has(obj, key)) {
3467
+ return undefined;
3468
+ }
3135
3469
 
3136
3470
  if (isObservableObject(obj)) {
3137
3471
  return obj[$mobx].get_(key);
@@ -3159,7 +3493,11 @@ function apiOwnKeys(obj) {
3159
3493
  }
3160
3494
 
3161
3495
  function observe(thing, propOrCb, cbOrFire, fireImmediately) {
3162
- if (isFunction(cbOrFire)) return observeObservableProperty(thing, propOrCb, cbOrFire, fireImmediately);else return observeObservable(thing, propOrCb, cbOrFire);
3496
+ if (isFunction(cbOrFire)) {
3497
+ return observeObservableProperty(thing, propOrCb, cbOrFire, fireImmediately);
3498
+ } else {
3499
+ return observeObservable(thing, propOrCb, cbOrFire);
3500
+ }
3163
3501
  }
3164
3502
 
3165
3503
  function observeObservable(thing, listener, fireImmediately) {
@@ -3176,8 +3514,13 @@ function cache(map, key, value) {
3176
3514
  }
3177
3515
 
3178
3516
  function toJSHelper(source, __alreadySeen) {
3179
- if (source == null || typeof source !== "object" || source instanceof Date || !isObservable(source)) return source;
3180
- if (isObservableValue(source) || isComputedValue(source)) return toJSHelper(source.get(), __alreadySeen);
3517
+ if (source == null || typeof source !== "object" || source instanceof Date || !isObservable(source)) {
3518
+ return source;
3519
+ }
3520
+
3521
+ if (isObservableValue(source) || isComputedValue(source)) {
3522
+ return toJSHelper(source.get(), __alreadySeen);
3523
+ }
3181
3524
 
3182
3525
  if (__alreadySeen.has(source)) {
3183
3526
  return __alreadySeen.get(source);
@@ -3220,23 +3563,33 @@ function toJSHelper(source, __alreadySeen) {
3220
3563
  }
3221
3564
  }
3222
3565
  /**
3223
- * Basically, a deep clone, so that no reactive property will exist anymore.
3566
+ * Recursively converts an observable to it's non-observable native counterpart.
3567
+ * It does NOT recurse into non-observables, these are left as they are, even if they contain observables.
3568
+ * Computed and other non-enumerable properties are completely ignored.
3569
+ * Complex scenarios require custom solution, eg implementing `toJSON` or using `serializr` lib.
3224
3570
  */
3225
3571
 
3226
3572
 
3227
3573
  function toJS(source, options) {
3228
- if ( options) die("toJS no longer supports options");
3574
+ if ( options) {
3575
+ die("toJS no longer supports options");
3576
+ }
3577
+
3229
3578
  return toJSHelper(source, new Map());
3230
3579
  }
3231
3580
 
3232
3581
  function trace() {
3582
+
3233
3583
  var enterBreakPoint = false;
3234
3584
 
3235
3585
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3236
3586
  args[_key] = arguments[_key];
3237
3587
  }
3238
3588
 
3239
- if (typeof args[args.length - 1] === "boolean") enterBreakPoint = args.pop();
3589
+ if (typeof args[args.length - 1] === "boolean") {
3590
+ enterBreakPoint = args.pop();
3591
+ }
3592
+
3240
3593
  var derivation = getAtomFromArgs(args);
3241
3594
 
3242
3595
  if (!derivation) {
@@ -3286,7 +3639,10 @@ function transaction(action, thisArg) {
3286
3639
  }
3287
3640
 
3288
3641
  function when(predicate, arg1, arg2) {
3289
- if (arguments.length === 1 || arg1 && typeof arg1 === "object") return whenPromise(predicate, arg1);
3642
+ if (arguments.length === 1 || arg1 && typeof arg1 === "object") {
3643
+ return whenPromise(predicate, arg1);
3644
+ }
3645
+
3290
3646
  return _when(predicate, arg1, arg2 || {});
3291
3647
  }
3292
3648
 
@@ -3298,7 +3654,12 @@ function _when(predicate, effect, opts) {
3298
3654
  timeoutHandle = setTimeout(function () {
3299
3655
  if (!disposer[$mobx].isDisposed_) {
3300
3656
  disposer();
3301
- if (opts.onError) opts.onError(error);else throw error;
3657
+
3658
+ if (opts.onError) {
3659
+ opts.onError(error);
3660
+ } else {
3661
+ throw error;
3662
+ }
3302
3663
  }
3303
3664
  }, opts.timeout);
3304
3665
  }
@@ -3312,7 +3673,11 @@ function _when(predicate, effect, opts) {
3312
3673
 
3313
3674
  if (cond) {
3314
3675
  r.dispose();
3315
- if (timeoutHandle) clearTimeout(timeoutHandle);
3676
+
3677
+ if (timeoutHandle) {
3678
+ clearTimeout(timeoutHandle);
3679
+ }
3680
+
3316
3681
  effectAction();
3317
3682
  }
3318
3683
  }, opts);
@@ -3320,7 +3685,10 @@ function _when(predicate, effect, opts) {
3320
3685
  }
3321
3686
 
3322
3687
  function whenPromise(predicate, opts) {
3323
- if ( opts && opts.onError) return die("the options 'onError' and 'promise' cannot be combined");
3688
+ if ( opts && opts.onError) {
3689
+ return die("the options 'onError' and 'promise' cannot be combined");
3690
+ }
3691
+
3324
3692
  var cancel;
3325
3693
  var res = new Promise(function (resolve, reject) {
3326
3694
  var disposer = _when(predicate, resolve, _extends({}, opts, {
@@ -3344,7 +3712,10 @@ function getAdm(target) {
3344
3712
 
3345
3713
  var objectProxyTraps = {
3346
3714
  has: function has(target, name) {
3347
- if ( globalState.trackingDerivation) warnAboutProxyRequirement("detect new properties using the 'in' operator. Use 'has' from 'mobx' instead.");
3715
+ if ( globalState.trackingDerivation) {
3716
+ warnAboutProxyRequirement("detect new properties using the 'in' operator. Use 'has' from 'mobx' instead.");
3717
+ }
3718
+
3348
3719
  return getAdm(target).has_(name);
3349
3720
  },
3350
3721
  get: function get(target, name) {
@@ -3353,7 +3724,9 @@ var objectProxyTraps = {
3353
3724
  set: function set(target, name, value) {
3354
3725
  var _getAdm$set_;
3355
3726
 
3356
- if (!isStringish(name)) return false;
3727
+ if (!isStringish(name)) {
3728
+ return false;
3729
+ }
3357
3730
 
3358
3731
  if ( !getAdm(target).values_.has(name)) {
3359
3732
  warnAboutProxyRequirement("add a new observable property through direct assignment. Use 'set' from 'mobx' instead.");
@@ -3369,7 +3742,10 @@ var objectProxyTraps = {
3369
3742
  warnAboutProxyRequirement("delete properties from an observable object. Use 'remove' from 'mobx' instead.");
3370
3743
  }
3371
3744
 
3372
- if (!isStringish(name)) return false; // null (intercepted) -> true (success)
3745
+ if (!isStringish(name)) {
3746
+ return false;
3747
+ } // null (intercepted) -> true (success)
3748
+
3373
3749
 
3374
3750
  return (_getAdm$delete_ = getAdm(target).delete_(name, true)) != null ? _getAdm$delete_ : true;
3375
3751
  },
@@ -3384,7 +3760,10 @@ var objectProxyTraps = {
3384
3760
  return (_getAdm$definePropert = getAdm(target).defineProperty_(name, descriptor)) != null ? _getAdm$definePropert : true;
3385
3761
  },
3386
3762
  ownKeys: function ownKeys(target) {
3387
- if ( globalState.trackingDerivation) warnAboutProxyRequirement("iterate keys to detect added / removed properties. Use 'keys' from 'mobx' instead.");
3763
+ if ( globalState.trackingDerivation) {
3764
+ warnAboutProxyRequirement("iterate keys to detect added / removed properties. Use 'keys' from 'mobx' instead.");
3765
+ }
3766
+
3388
3767
  return getAdm(target).ownKeys_();
3389
3768
  },
3390
3769
  preventExtensions: function preventExtensions(target) {
@@ -3407,7 +3786,10 @@ function registerInterceptor(interceptable, handler) {
3407
3786
  interceptors.push(handler);
3408
3787
  return once(function () {
3409
3788
  var idx = interceptors.indexOf(handler);
3410
- if (idx !== -1) interceptors.splice(idx, 1);
3789
+
3790
+ if (idx !== -1) {
3791
+ interceptors.splice(idx, 1);
3792
+ }
3411
3793
  });
3412
3794
  }
3413
3795
  function interceptChange(interceptable, change) {
@@ -3419,8 +3801,14 @@ function interceptChange(interceptable, change) {
3419
3801
 
3420
3802
  for (var i = 0, l = interceptors.length; i < l; i++) {
3421
3803
  change = interceptors[i](change);
3422
- if (change && !change.type) die(14);
3423
- if (!change) break;
3804
+
3805
+ if (change && !change.type) {
3806
+ die(14);
3807
+ }
3808
+
3809
+ if (!change) {
3810
+ break;
3811
+ }
3424
3812
  }
3425
3813
 
3426
3814
  return change;
@@ -3437,13 +3825,20 @@ function registerListener(listenable, handler) {
3437
3825
  listeners.push(handler);
3438
3826
  return once(function () {
3439
3827
  var idx = listeners.indexOf(handler);
3440
- if (idx !== -1) listeners.splice(idx, 1);
3828
+
3829
+ if (idx !== -1) {
3830
+ listeners.splice(idx, 1);
3831
+ }
3441
3832
  });
3442
3833
  }
3443
3834
  function notifyListeners(listenable, change) {
3444
3835
  var prevU = untrackedStart();
3445
3836
  var listeners = listenable.changeListeners_;
3446
- if (!listeners) return;
3837
+
3838
+ if (!listeners) {
3839
+ return;
3840
+ }
3841
+
3447
3842
  listeners = listeners.slice();
3448
3843
 
3449
3844
  for (var i = 0, l = listeners.length; i < l; i++) {
@@ -3480,8 +3875,13 @@ function makeObservable(target, annotations, options) {
3480
3875
  var keysSymbol = /*#__PURE__*/Symbol("mobx-keys");
3481
3876
  function makeAutoObservable(target, overrides, options) {
3482
3877
  {
3483
- if (!isPlainObject(target) && !isPlainObject(Object.getPrototypeOf(target))) die("'makeAutoObservable' can only be used for classes that don't have a superclass");
3484
- if (isObservableObject(target)) die("makeAutoObservable can only be used on objects not already made observable");
3878
+ if (!isPlainObject(target) && !isPlainObject(Object.getPrototypeOf(target))) {
3879
+ die("'makeAutoObservable' can only be used for classes that don't have a superclass");
3880
+ }
3881
+
3882
+ if (isObservableObject(target)) {
3883
+ die("makeAutoObservable can only be used on objects not already made observable");
3884
+ }
3485
3885
  } // Optimization: avoid visiting protos
3486
3886
  // Assumes that annotation.make_/.extend_ works the same for plain objects
3487
3887
 
@@ -3522,8 +3922,14 @@ var MAX_SPLICE_SIZE = 10000; // See e.g. https://github.com/mobxjs/mobx/issues/8
3522
3922
  var arrayTraps = {
3523
3923
  get: function get(target, name) {
3524
3924
  var adm = target[$mobx];
3525
- if (name === $mobx) return adm;
3526
- if (name === "length") return adm.getArrayLength_();
3925
+
3926
+ if (name === $mobx) {
3927
+ return adm;
3928
+ }
3929
+
3930
+ if (name === "length") {
3931
+ return adm.getArrayLength_();
3932
+ }
3527
3933
 
3528
3934
  if (typeof name === "string" && !isNaN(name)) {
3529
3935
  return adm.get_(parseInt(name));
@@ -3584,12 +3990,18 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
3584
3990
  var _proto = ObservableArrayAdministration.prototype;
3585
3991
 
3586
3992
  _proto.dehanceValue_ = function dehanceValue_(value) {
3587
- if (this.dehancer !== undefined) return this.dehancer(value);
3993
+ if (this.dehancer !== undefined) {
3994
+ return this.dehancer(value);
3995
+ }
3996
+
3588
3997
  return value;
3589
3998
  };
3590
3999
 
3591
4000
  _proto.dehanceValues_ = function dehanceValues_(values) {
3592
- if (this.dehancer !== undefined && values.length > 0) return values.map(this.dehancer);
4001
+ if (this.dehancer !== undefined && values.length > 0) {
4002
+ return values.map(this.dehancer);
4003
+ }
4004
+
3593
4005
  return values;
3594
4006
  };
3595
4007
 
@@ -3625,9 +4037,15 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
3625
4037
  };
3626
4038
 
3627
4039
  _proto.setArrayLength_ = function setArrayLength_(newLength) {
3628
- if (typeof newLength !== "number" || isNaN(newLength) || newLength < 0) die("Out of range: " + newLength);
4040
+ if (typeof newLength !== "number" || isNaN(newLength) || newLength < 0) {
4041
+ die("Out of range: " + newLength);
4042
+ }
4043
+
3629
4044
  var currentLength = this.values_.length;
3630
- if (newLength === currentLength) return;else if (newLength > currentLength) {
4045
+
4046
+ if (newLength === currentLength) {
4047
+ return;
4048
+ } else if (newLength > currentLength) {
3631
4049
  var newItems = new Array(newLength - currentLength);
3632
4050
 
3633
4051
  for (var i = 0; i < newLength - currentLength; i++) {
@@ -3636,13 +4054,21 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
3636
4054
 
3637
4055
 
3638
4056
  this.spliceWithArray_(currentLength, 0, newItems);
3639
- } else this.spliceWithArray_(newLength, currentLength - newLength);
4057
+ } else {
4058
+ this.spliceWithArray_(newLength, currentLength - newLength);
4059
+ }
3640
4060
  };
3641
4061
 
3642
4062
  _proto.updateArrayLength_ = function updateArrayLength_(oldLength, delta) {
3643
- if (oldLength !== this.lastKnownLength_) die(16);
4063
+ if (oldLength !== this.lastKnownLength_) {
4064
+ die(16);
4065
+ }
4066
+
3644
4067
  this.lastKnownLength_ += delta;
3645
- if (this.legacyMode_ && delta > 0) reserveArrayBuffer(oldLength + delta + 1);
4068
+
4069
+ if (this.legacyMode_ && delta > 0) {
4070
+ reserveArrayBuffer(oldLength + delta + 1);
4071
+ }
3646
4072
  };
3647
4073
 
3648
4074
  _proto.spliceWithArray_ = function spliceWithArray_(index, deleteCount, newItems) {
@@ -3650,9 +4076,26 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
3650
4076
 
3651
4077
  checkIfStateModificationsAreAllowed(this.atom_);
3652
4078
  var length = this.values_.length;
3653
- if (index === undefined) index = 0;else if (index > length) index = length;else if (index < 0) index = Math.max(0, length + index);
3654
- 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));
3655
- if (newItems === undefined) newItems = EMPTY_ARRAY;
4079
+
4080
+ if (index === undefined) {
4081
+ index = 0;
4082
+ } else if (index > length) {
4083
+ index = length;
4084
+ } else if (index < 0) {
4085
+ index = Math.max(0, length + index);
4086
+ }
4087
+
4088
+ if (arguments.length === 1) {
4089
+ deleteCount = length - index;
4090
+ } else if (deleteCount === undefined || deleteCount === null) {
4091
+ deleteCount = 0;
4092
+ } else {
4093
+ deleteCount = Math.max(0, Math.min(deleteCount, length - index));
4094
+ }
4095
+
4096
+ if (newItems === undefined) {
4097
+ newItems = EMPTY_ARRAY;
4098
+ }
3656
4099
 
3657
4100
  if (hasInterceptors(this)) {
3658
4101
  var change = interceptChange(this, {
@@ -3662,7 +4105,11 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
3662
4105
  removedCount: deleteCount,
3663
4106
  added: newItems
3664
4107
  });
3665
- if (!change) return EMPTY_ARRAY;
4108
+
4109
+ if (!change) {
4110
+ return EMPTY_ARRAY;
4111
+ }
4112
+
3666
4113
  deleteCount = change.removedCount;
3667
4114
  newItems = change.added;
3668
4115
  }
@@ -3677,7 +4124,11 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
3677
4124
  }
3678
4125
 
3679
4126
  var res = this.spliceItemsIntoValues_(index, deleteCount, newItems);
3680
- if (deleteCount !== 0 || newItems.length !== 0) this.notifyArraySplice_(index, newItems, res);
4127
+
4128
+ if (deleteCount !== 0 || newItems.length !== 0) {
4129
+ this.notifyArraySplice_(index, newItems, res);
4130
+ }
4131
+
3681
4132
  return this.dehanceValues_(res);
3682
4133
  };
3683
4134
 
@@ -3720,10 +4171,19 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
3720
4171
  } : 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
3721
4172
  // cause any runtime overhead in development mode without NODE_ENV set, unless spying is enabled
3722
4173
 
3723
- if ( notifySpy) spyReportStart(change);
4174
+ if ( notifySpy) {
4175
+ spyReportStart(change);
4176
+ }
4177
+
3724
4178
  this.atom_.reportChanged();
3725
- if (notify) notifyListeners(this, change);
3726
- if ( notifySpy) spyReportEnd();
4179
+
4180
+ if (notify) {
4181
+ notifyListeners(this, change);
4182
+ }
4183
+
4184
+ if ( notifySpy) {
4185
+ spyReportEnd();
4186
+ }
3727
4187
  };
3728
4188
 
3729
4189
  _proto.notifyArraySplice_ = function notifyArraySplice_(index, added, removed) {
@@ -3740,11 +4200,20 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
3740
4200
  removedCount: removed.length,
3741
4201
  addedCount: added.length
3742
4202
  } : null;
3743
- if ( notifySpy) spyReportStart(change);
4203
+
4204
+ if ( notifySpy) {
4205
+ spyReportStart(change);
4206
+ }
4207
+
3744
4208
  this.atom_.reportChanged(); // conform: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/observe
3745
4209
 
3746
- if (notify) notifyListeners(this, change);
3747
- if ( notifySpy) spyReportEnd();
4210
+ if (notify) {
4211
+ notifyListeners(this, change);
4212
+ }
4213
+
4214
+ if ( notifySpy) {
4215
+ spyReportEnd();
4216
+ }
3748
4217
  };
3749
4218
 
3750
4219
  _proto.get_ = function get_(index) {
@@ -3771,7 +4240,11 @@ var ObservableArrayAdministration = /*#__PURE__*/function () {
3771
4240
  index: index,
3772
4241
  newValue: newValue
3773
4242
  });
3774
- if (!change) return;
4243
+
4244
+ if (!change) {
4245
+ return;
4246
+ }
4247
+
3775
4248
  newValue = change.newValue;
3776
4249
  }
3777
4250
 
@@ -4012,6 +4485,8 @@ _Symbol$toStringTag = Symbol.toStringTag;
4012
4485
  var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTag2) {
4013
4486
  // hasMap, not hashMap >-).
4014
4487
  function ObservableMap(initialData, enhancer_, name_) {
4488
+ var _this = this;
4489
+
4015
4490
  if (enhancer_ === void 0) {
4016
4491
  enhancer_ = deepEnhancer;
4017
4492
  }
@@ -4039,7 +4514,9 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4039
4514
  this.keysAtom_ = createAtom( this.name_ + ".keys()" );
4040
4515
  this.data_ = new Map();
4041
4516
  this.hasMap_ = new Map();
4042
- this.merge(initialData);
4517
+ allowStateChanges(true, function () {
4518
+ _this.merge(initialData);
4519
+ });
4043
4520
  }
4044
4521
 
4045
4522
  var _proto = ObservableMap.prototype;
@@ -4049,16 +4526,19 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4049
4526
  };
4050
4527
 
4051
4528
  _proto.has = function has(key) {
4052
- var _this = this;
4529
+ var _this2 = this;
4530
+
4531
+ if (!globalState.trackingDerivation) {
4532
+ return this.has_(key);
4533
+ }
4053
4534
 
4054
- if (!globalState.trackingDerivation) return this.has_(key);
4055
4535
  var entry = this.hasMap_.get(key);
4056
4536
 
4057
4537
  if (!entry) {
4058
4538
  var newEntry = entry = new ObservableValue(this.has_(key), referenceEnhancer, this.name_ + "." + stringifyKey(key) + "?" , false);
4059
4539
  this.hasMap_.set(key, newEntry);
4060
4540
  onBecomeUnobserved(newEntry, function () {
4061
- return _this.hasMap_["delete"](key);
4541
+ return _this2.hasMap_["delete"](key);
4062
4542
  });
4063
4543
  }
4064
4544
 
@@ -4075,7 +4555,11 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4075
4555
  newValue: value,
4076
4556
  name: key
4077
4557
  });
4078
- if (!change) return this;
4558
+
4559
+ if (!change) {
4560
+ return this;
4561
+ }
4562
+
4079
4563
  value = change.newValue;
4080
4564
  }
4081
4565
 
@@ -4089,7 +4573,7 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4089
4573
  };
4090
4574
 
4091
4575
  _proto["delete"] = function _delete(key) {
4092
- var _this2 = this;
4576
+ var _this3 = this;
4093
4577
 
4094
4578
  checkIfStateModificationsAreAllowed(this.keysAtom_);
4095
4579
 
@@ -4099,7 +4583,10 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4099
4583
  object: this,
4100
4584
  name: key
4101
4585
  });
4102
- if (!change) return false;
4586
+
4587
+ if (!change) {
4588
+ return false;
4589
+ }
4103
4590
  }
4104
4591
 
4105
4592
  if (this.has_(key)) {
@@ -4115,23 +4602,33 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4115
4602
  name: key
4116
4603
  } : null;
4117
4604
 
4118
- if ( notifySpy) spyReportStart(_change); // TODO fix type
4605
+ if ( notifySpy) {
4606
+ spyReportStart(_change);
4607
+ } // TODO fix type
4608
+
4119
4609
 
4120
4610
  transaction(function () {
4121
- var _this2$hasMap_$get;
4611
+ var _this3$hasMap_$get;
4122
4612
 
4123
- _this2.keysAtom_.reportChanged();
4613
+ _this3.keysAtom_.reportChanged();
4124
4614
 
4125
- (_this2$hasMap_$get = _this2.hasMap_.get(key)) == null ? void 0 : _this2$hasMap_$get.setNewValue_(false);
4615
+ (_this3$hasMap_$get = _this3.hasMap_.get(key)) == null ? void 0 : _this3$hasMap_$get.setNewValue_(false);
4126
4616
 
4127
- var observable = _this2.data_.get(key);
4617
+ var observable = _this3.data_.get(key);
4128
4618
 
4129
4619
  observable.setNewValue_(undefined);
4130
4620
 
4131
- _this2.data_["delete"](key);
4621
+ _this3.data_["delete"](key);
4132
4622
  });
4133
- if (notify) notifyListeners(this, _change);
4134
- if ( notifySpy) spyReportEnd();
4623
+
4624
+ if (notify) {
4625
+ notifyListeners(this, _change);
4626
+ }
4627
+
4628
+ if ( notifySpy) {
4629
+ spyReportEnd();
4630
+ }
4631
+
4135
4632
  return true;
4136
4633
  }
4137
4634
 
@@ -4154,30 +4651,40 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4154
4651
  name: key,
4155
4652
  newValue: newValue
4156
4653
  } : null;
4157
- if ( notifySpy) spyReportStart(change); // TODO fix type
4654
+
4655
+ if ( notifySpy) {
4656
+ spyReportStart(change);
4657
+ } // TODO fix type
4658
+
4158
4659
 
4159
4660
  observable.setNewValue_(newValue);
4160
- if (notify) notifyListeners(this, change);
4161
- if ( notifySpy) spyReportEnd();
4661
+
4662
+ if (notify) {
4663
+ notifyListeners(this, change);
4664
+ }
4665
+
4666
+ if ( notifySpy) {
4667
+ spyReportEnd();
4668
+ }
4162
4669
  }
4163
4670
  };
4164
4671
 
4165
4672
  _proto.addValue_ = function addValue_(key, newValue) {
4166
- var _this3 = this;
4673
+ var _this4 = this;
4167
4674
 
4168
4675
  checkIfStateModificationsAreAllowed(this.keysAtom_);
4169
4676
  transaction(function () {
4170
- var _this3$hasMap_$get;
4677
+ var _this4$hasMap_$get;
4171
4678
 
4172
- var observable = new ObservableValue(newValue, _this3.enhancer_, _this3.name_ + "." + stringifyKey(key) , false);
4679
+ var observable = new ObservableValue(newValue, _this4.enhancer_, _this4.name_ + "." + stringifyKey(key) , false);
4173
4680
 
4174
- _this3.data_.set(key, observable);
4681
+ _this4.data_.set(key, observable);
4175
4682
 
4176
4683
  newValue = observable.value_; // value might have been changed
4177
4684
 
4178
- (_this3$hasMap_$get = _this3.hasMap_.get(key)) == null ? void 0 : _this3$hasMap_$get.setNewValue_(true);
4685
+ (_this4$hasMap_$get = _this4.hasMap_.get(key)) == null ? void 0 : _this4$hasMap_$get.setNewValue_(true);
4179
4686
 
4180
- _this3.keysAtom_.reportChanged();
4687
+ _this4.keysAtom_.reportChanged();
4181
4688
  });
4182
4689
  var notifySpy = isSpyEnabled();
4183
4690
  var notify = hasListeners(this);
@@ -4189,14 +4696,26 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4189
4696
  name: key,
4190
4697
  newValue: newValue
4191
4698
  } : null;
4192
- if ( notifySpy) spyReportStart(change); // TODO fix type
4193
4699
 
4194
- if (notify) notifyListeners(this, change);
4195
- if ( notifySpy) spyReportEnd();
4700
+ if ( notifySpy) {
4701
+ spyReportStart(change);
4702
+ } // TODO fix type
4703
+
4704
+
4705
+ if (notify) {
4706
+ notifyListeners(this, change);
4707
+ }
4708
+
4709
+ if ( notifySpy) {
4710
+ spyReportEnd();
4711
+ }
4196
4712
  };
4197
4713
 
4198
4714
  _proto.get = function get(key) {
4199
- if (this.has(key)) return this.dehanceValue_(this.data_.get(key).get());
4715
+ if (this.has(key)) {
4716
+ return this.dehanceValue_(this.data_.get(key).get());
4717
+ }
4718
+
4200
4719
  return this.dehanceValue_(undefined);
4201
4720
  };
4202
4721
 
@@ -4263,45 +4782,54 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4263
4782
  ;
4264
4783
 
4265
4784
  _proto.merge = function merge(other) {
4266
- var _this4 = this;
4785
+ var _this5 = this;
4267
4786
 
4268
4787
  if (isObservableMap(other)) {
4269
4788
  other = new Map(other);
4270
4789
  }
4271
4790
 
4272
4791
  transaction(function () {
4273
- if (isPlainObject(other)) getPlainObjectKeys(other).forEach(function (key) {
4274
- return _this4.set(key, other[key]);
4275
- });else if (Array.isArray(other)) other.forEach(function (_ref) {
4276
- var key = _ref[0],
4277
- value = _ref[1];
4278
- return _this4.set(key, value);
4279
- });else if (isES6Map(other)) {
4280
- if (other.constructor !== Map) die(19, other);
4792
+ if (isPlainObject(other)) {
4793
+ getPlainObjectKeys(other).forEach(function (key) {
4794
+ return _this5.set(key, other[key]);
4795
+ });
4796
+ } else if (Array.isArray(other)) {
4797
+ other.forEach(function (_ref) {
4798
+ var key = _ref[0],
4799
+ value = _ref[1];
4800
+ return _this5.set(key, value);
4801
+ });
4802
+ } else if (isES6Map(other)) {
4803
+ if (other.constructor !== Map) {
4804
+ die(19, other);
4805
+ }
4806
+
4281
4807
  other.forEach(function (value, key) {
4282
- return _this4.set(key, value);
4808
+ return _this5.set(key, value);
4283
4809
  });
4284
- } else if (other !== null && other !== undefined) die(20, other);
4810
+ } else if (other !== null && other !== undefined) {
4811
+ die(20, other);
4812
+ }
4285
4813
  });
4286
4814
  return this;
4287
4815
  };
4288
4816
 
4289
4817
  _proto.clear = function clear() {
4290
- var _this5 = this;
4818
+ var _this6 = this;
4291
4819
 
4292
4820
  transaction(function () {
4293
4821
  untracked(function () {
4294
- for (var _iterator2 = _createForOfIteratorHelperLoose(_this5.keys()), _step2; !(_step2 = _iterator2()).done;) {
4822
+ for (var _iterator2 = _createForOfIteratorHelperLoose(_this6.keys()), _step2; !(_step2 = _iterator2()).done;) {
4295
4823
  var key = _step2.value;
4296
4824
 
4297
- _this5["delete"](key);
4825
+ _this6["delete"](key);
4298
4826
  }
4299
4827
  });
4300
4828
  });
4301
4829
  };
4302
4830
 
4303
4831
  _proto.replace = function replace(values) {
4304
- var _this6 = this;
4832
+ var _this7 = this;
4305
4833
 
4306
4834
  // Implementation requirements:
4307
4835
  // - respect ordering of replacement map
@@ -4318,13 +4846,13 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4318
4846
  // if the key deletion is prevented by interceptor
4319
4847
  // add entry at the beginning of the result map
4320
4848
 
4321
- for (var _iterator3 = _createForOfIteratorHelperLoose(_this6.data_.keys()), _step3; !(_step3 = _iterator3()).done;) {
4849
+ for (var _iterator3 = _createForOfIteratorHelperLoose(_this7.data_.keys()), _step3; !(_step3 = _iterator3()).done;) {
4322
4850
  var key = _step3.value;
4323
4851
 
4324
4852
  // Concurrently iterating/deleting keys
4325
4853
  // iterator should handle this correctly
4326
4854
  if (!replacementMap.has(key)) {
4327
- var deleted = _this6["delete"](key); // Was the key removed?
4855
+ var deleted = _this7["delete"](key); // Was the key removed?
4328
4856
 
4329
4857
 
4330
4858
  if (deleted) {
@@ -4332,7 +4860,7 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4332
4860
  keysReportChangedCalled = true;
4333
4861
  } else {
4334
4862
  // Delete prevented by interceptor
4335
- var value = _this6.data_.get(key);
4863
+ var value = _this7.data_.get(key);
4336
4864
 
4337
4865
  orderedData.set(key, value);
4338
4866
  }
@@ -4346,17 +4874,17 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4346
4874
  _value = _step4$value[1];
4347
4875
 
4348
4876
  // We will want to know whether a new key is added
4349
- var keyExisted = _this6.data_.has(_key); // Add or update value
4877
+ var keyExisted = _this7.data_.has(_key); // Add or update value
4350
4878
 
4351
4879
 
4352
- _this6.set(_key, _value); // The addition could have been prevent by interceptor
4880
+ _this7.set(_key, _value); // The addition could have been prevent by interceptor
4353
4881
 
4354
4882
 
4355
- if (_this6.data_.has(_key)) {
4883
+ if (_this7.data_.has(_key)) {
4356
4884
  // The update could have been prevented by interceptor
4357
4885
  // and also we want to preserve existing values
4358
4886
  // so use value from _data map (instead of replacement map)
4359
- var _value2 = _this6.data_.get(_key);
4887
+ var _value2 = _this7.data_.get(_key);
4360
4888
 
4361
4889
  orderedData.set(_key, _value2); // Was a new key added?
4362
4890
 
@@ -4369,11 +4897,11 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4369
4897
 
4370
4898
 
4371
4899
  if (!keysReportChangedCalled) {
4372
- if (_this6.data_.size !== orderedData.size) {
4900
+ if (_this7.data_.size !== orderedData.size) {
4373
4901
  // If size differs, keys are definitely modified
4374
- _this6.keysAtom_.reportChanged();
4902
+ _this7.keysAtom_.reportChanged();
4375
4903
  } else {
4376
- var iter1 = _this6.data_.keys();
4904
+ var iter1 = _this7.data_.keys();
4377
4905
 
4378
4906
  var iter2 = orderedData.keys();
4379
4907
  var next1 = iter1.next();
@@ -4381,7 +4909,7 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4381
4909
 
4382
4910
  while (!next1.done) {
4383
4911
  if (next1.value !== next2.value) {
4384
- _this6.keysAtom_.reportChanged();
4912
+ _this7.keysAtom_.reportChanged();
4385
4913
 
4386
4914
  break;
4387
4915
  }
@@ -4393,7 +4921,7 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4393
4921
  } // Use correctly ordered map
4394
4922
 
4395
4923
 
4396
- _this6.data_ = orderedData;
4924
+ _this7.data_ = orderedData;
4397
4925
  });
4398
4926
  return this;
4399
4927
  };
@@ -4412,7 +4940,10 @@ var ObservableMap = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4412
4940
  * for callback details
4413
4941
  */
4414
4942
  _proto.observe_ = function observe_(listener, fireImmediately) {
4415
- if ( fireImmediately === true) die("`observe` doesn't support fireImmediately=true in combination with maps.");
4943
+ if ( fireImmediately === true) {
4944
+ die("`observe` doesn't support fireImmediately=true in combination with maps.");
4945
+ }
4946
+
4416
4947
  return registerListener(this, listener);
4417
4948
  };
4418
4949
 
@@ -4537,8 +5068,12 @@ var ObservableSet = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4537
5068
  object: this,
4538
5069
  newValue: value
4539
5070
  });
4540
- if (!change) return this; // ideally, value = change.value would be done here, so that values can be
5071
+
5072
+ if (!change) {
5073
+ return this;
5074
+ } // ideally, value = change.value would be done here, so that values can be
4541
5075
  // changed by interceptor. Same applies for other Set and Map api's.
5076
+
4542
5077
  }
4543
5078
 
4544
5079
  if (!this.has(value)) {
@@ -4558,9 +5093,17 @@ var ObservableSet = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4558
5093
  newValue: value
4559
5094
  } : null;
4560
5095
 
4561
- if (notifySpy && "development" !== "production") spyReportStart(_change);
4562
- if (notify) notifyListeners(this, _change);
4563
- if (notifySpy && "development" !== "production") spyReportEnd();
5096
+ if (notifySpy && "development" !== "production") {
5097
+ spyReportStart(_change);
5098
+ }
5099
+
5100
+ if (notify) {
5101
+ notifyListeners(this, _change);
5102
+ }
5103
+
5104
+ if (notifySpy && "development" !== "production") {
5105
+ spyReportEnd();
5106
+ }
4564
5107
  }
4565
5108
 
4566
5109
  return this;
@@ -4575,7 +5118,10 @@ var ObservableSet = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4575
5118
  object: this,
4576
5119
  oldValue: value
4577
5120
  });
4578
- if (!change) return false;
5121
+
5122
+ if (!change) {
5123
+ return false;
5124
+ }
4579
5125
  }
4580
5126
 
4581
5127
  if (this.has(value)) {
@@ -4590,14 +5136,24 @@ var ObservableSet = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4590
5136
  oldValue: value
4591
5137
  } : null;
4592
5138
 
4593
- if (notifySpy && "development" !== "production") spyReportStart(_change2);
5139
+ if (notifySpy && "development" !== "production") {
5140
+ spyReportStart(_change2);
5141
+ }
5142
+
4594
5143
  transaction(function () {
4595
5144
  _this3.atom_.reportChanged();
4596
5145
 
4597
5146
  _this3.data_["delete"](value);
4598
5147
  });
4599
- if (notify) notifyListeners(this, _change2);
4600
- if (notifySpy && "development" !== "production") spyReportEnd();
5148
+
5149
+ if (notify) {
5150
+ notifyListeners(this, _change2);
5151
+ }
5152
+
5153
+ if (notifySpy && "development" !== "production") {
5154
+ spyReportEnd();
5155
+ }
5156
+
4601
5157
  return true;
4602
5158
  }
4603
5159
 
@@ -4677,7 +5233,10 @@ var ObservableSet = /*#__PURE__*/function (_Symbol$iterator2, _Symbol$toStringTa
4677
5233
 
4678
5234
  _proto.observe_ = function observe_(listener, fireImmediately) {
4679
5235
  // ... 'fireImmediately' could also be true?
4680
- if ( fireImmediately === true) die("`observe` doesn't support fireImmediately=true in combination with sets.");
5236
+ if ( fireImmediately === true) {
5237
+ die("`observe` doesn't support fireImmediately=true in combination with sets.");
5238
+ }
5239
+
4681
5240
  return registerListener(this, listener);
4682
5241
  };
4683
5242
 
@@ -4779,7 +5338,11 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
4779
5338
  name: key,
4780
5339
  newValue: newValue
4781
5340
  });
4782
- if (!change) return null;
5341
+
5342
+ if (!change) {
5343
+ return null;
5344
+ }
5345
+
4783
5346
  newValue = change.newValue;
4784
5347
  }
4785
5348
 
@@ -4799,10 +5362,18 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
4799
5362
  newValue: newValue
4800
5363
  } : null;
4801
5364
 
4802
- if ( notifySpy) spyReportStart(_change);
5365
+ if ( notifySpy) {
5366
+ spyReportStart(_change);
5367
+ }
4803
5368
  observable.setNewValue_(newValue);
4804
- if (notify) notifyListeners(this, _change);
4805
- if ( notifySpy) spyReportEnd();
5369
+
5370
+ if (notify) {
5371
+ notifyListeners(this, _change);
5372
+ }
5373
+
5374
+ if ( notifySpy) {
5375
+ spyReportEnd();
5376
+ }
4806
5377
  }
4807
5378
 
4808
5379
  return true;
@@ -4911,12 +5482,18 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
4911
5482
 
4912
5483
  if (descriptor) {
4913
5484
  var outcome = annotation.make_(this, key, descriptor, source);
5485
+
4914
5486
  if (outcome === 0
4915
5487
  /* Cancel */
4916
- ) return;
5488
+ ) {
5489
+ return;
5490
+ }
5491
+
4917
5492
  if (outcome === 1
4918
5493
  /* Break */
4919
- ) break;
5494
+ ) {
5495
+ break;
5496
+ }
4920
5497
  }
4921
5498
 
4922
5499
  source = Object.getPrototypeOf(source);
@@ -4986,7 +5563,11 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
4986
5563
  type: ADD,
4987
5564
  newValue: descriptor.value
4988
5565
  });
4989
- if (!change) return null;
5566
+
5567
+ if (!change) {
5568
+ return null;
5569
+ }
5570
+
4990
5571
  var newValue = change.newValue;
4991
5572
 
4992
5573
  if (descriptor.value !== newValue) {
@@ -5038,7 +5619,11 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
5038
5619
  type: ADD,
5039
5620
  newValue: value
5040
5621
  });
5041
- if (!change) return null;
5622
+
5623
+ if (!change) {
5624
+ return null;
5625
+ }
5626
+
5042
5627
  value = change.newValue;
5043
5628
  }
5044
5629
 
@@ -5093,7 +5678,10 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
5093
5678
  type: ADD,
5094
5679
  newValue: undefined
5095
5680
  });
5096
- if (!change) return null;
5681
+
5682
+ if (!change) {
5683
+ return null;
5684
+ }
5097
5685
  }
5098
5686
 
5099
5687
  options.name || (options.name = "development" !== "production" ? this.name_ + "." + key.toString() : "ObservableObject.key");
@@ -5149,7 +5737,9 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
5149
5737
  type: REMOVE
5150
5738
  }); // Cancelled
5151
5739
 
5152
- if (!change) return null;
5740
+ if (!change) {
5741
+ return null;
5742
+ }
5153
5743
  } // Delete
5154
5744
 
5155
5745
 
@@ -5210,9 +5800,18 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
5210
5800
  oldValue: value,
5211
5801
  name: key
5212
5802
  };
5213
- if ("development" !== "production" && notifySpy) spyReportStart(_change2);
5214
- if (notify) notifyListeners(this, _change2);
5215
- if ("development" !== "production" && notifySpy) spyReportEnd();
5803
+
5804
+ if ("development" !== "production" && notifySpy) {
5805
+ spyReportStart(_change2);
5806
+ }
5807
+
5808
+ if (notify) {
5809
+ notifyListeners(this, _change2);
5810
+ }
5811
+
5812
+ if ("development" !== "production" && notifySpy) {
5813
+ spyReportEnd();
5814
+ }
5216
5815
  }
5217
5816
  } finally {
5218
5817
  endBatch();
@@ -5228,7 +5827,10 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
5228
5827
  ;
5229
5828
 
5230
5829
  _proto.observe_ = function observe_(callback, fireImmediately) {
5231
- if ( fireImmediately === true) die("`observe` doesn't support the fire immediately property for observable objects.");
5830
+ if ( fireImmediately === true) {
5831
+ die("`observe` doesn't support the fire immediately property for observable objects.");
5832
+ }
5833
+
5232
5834
  return registerListener(this, callback);
5233
5835
  };
5234
5836
 
@@ -5251,9 +5853,18 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
5251
5853
  name: key,
5252
5854
  newValue: value
5253
5855
  } : null;
5254
- if ( notifySpy) spyReportStart(change);
5255
- if (notify) notifyListeners(this, change);
5256
- if ( notifySpy) spyReportEnd();
5856
+
5857
+ if ( notifySpy) {
5858
+ spyReportStart(change);
5859
+ }
5860
+
5861
+ if (notify) {
5862
+ notifyListeners(this, change);
5863
+ }
5864
+
5865
+ if ( notifySpy) {
5866
+ spyReportEnd();
5867
+ }
5257
5868
  }
5258
5869
 
5259
5870
  (_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
@@ -5294,7 +5905,10 @@ function asObservableObject(target, options) {
5294
5905
  return target;
5295
5906
  }
5296
5907
 
5297
- if ( !Object.isExtensible(target)) die("Cannot make the designated object observable; it is not extensible");
5908
+ if ( !Object.isExtensible(target)) {
5909
+ die("Cannot make the designated object observable; it is not extensible");
5910
+ }
5911
+
5298
5912
  var name = (_options$name = options == null ? void 0 : options.name) != null ? _options$name : (isPlainObject(target) ? "ObservableObject" : target.constructor.name) + "@" + getNextId() ;
5299
5913
  var adm = new ObservableObjectAdministration(target, new Map(), String(name), getAnnotationFromOptions(options));
5300
5914
  addHiddenProp(target, $mobx, adm);
@@ -5451,7 +6065,6 @@ var LegacyObservableArray = /*#__PURE__*/function (_StubArray, _Symbol$toStringT
5451
6065
  var nextIndex = 0;
5452
6066
  return makeIterable({
5453
6067
  next: function next() {
5454
- // @ts-ignore
5455
6068
  return nextIndex < self.length ? {
5456
6069
  value: self[nextIndex++],
5457
6070
  done: false
@@ -5484,7 +6097,10 @@ var LegacyObservableArray = /*#__PURE__*/function (_StubArray, _Symbol$toStringT
5484
6097
  Object.entries(arrayExtensions).forEach(function (_ref) {
5485
6098
  var prop = _ref[0],
5486
6099
  fn = _ref[1];
5487
- if (prop !== "concat") addHiddenProp(LegacyObservableArray.prototype, prop, fn);
6100
+
6101
+ if (prop !== "concat") {
6102
+ addHiddenProp(LegacyObservableArray.prototype, prop, fn);
6103
+ }
5488
6104
  });
5489
6105
 
5490
6106
  function createArrayEntryDescriptor(index) {
@@ -5521,7 +6137,10 @@ function createLegacyArray(initialValues, enhancer, name) {
5521
6137
  function getAtom(thing, property) {
5522
6138
  if (typeof thing === "object" && thing !== null) {
5523
6139
  if (isObservableArray(thing)) {
5524
- if (property !== undefined) die(23);
6140
+ if (property !== undefined) {
6141
+ die(23);
6142
+ }
6143
+
5525
6144
  return thing[$mobx].atom_;
5526
6145
  }
5527
6146
 
@@ -5530,18 +6149,31 @@ function getAtom(thing, property) {
5530
6149
  }
5531
6150
 
5532
6151
  if (isObservableMap(thing)) {
5533
- if (property === undefined) return thing.keysAtom_;
6152
+ if (property === undefined) {
6153
+ return thing.keysAtom_;
6154
+ }
6155
+
5534
6156
  var observable = thing.data_.get(property) || thing.hasMap_.get(property);
5535
- if (!observable) die(25, property, getDebugName(thing));
6157
+
6158
+ if (!observable) {
6159
+ die(25, property, getDebugName(thing));
6160
+ }
6161
+
5536
6162
  return observable;
5537
6163
  }
5538
6164
 
6165
+
5539
6166
  if (isObservableObject(thing)) {
5540
- if (!property) return die(26);
6167
+ if (!property) {
6168
+ return die(26);
6169
+ }
5541
6170
 
5542
6171
  var _observable = thing[$mobx].values_.get(property);
5543
6172
 
5544
- if (!_observable) die(27, property, getDebugName(thing));
6173
+ if (!_observable) {
6174
+ die(27, property, getDebugName(thing));
6175
+ }
6176
+
5545
6177
  return _observable;
5546
6178
  }
5547
6179
 
@@ -5558,11 +6190,26 @@ function getAtom(thing, property) {
5558
6190
  die(28);
5559
6191
  }
5560
6192
  function getAdministration(thing, property) {
5561
- if (!thing) die(29);
5562
- if (property !== undefined) return getAdministration(getAtom(thing, property));
5563
- if (isAtom(thing) || isComputedValue(thing) || isReaction(thing)) return thing;
5564
- if (isObservableMap(thing) || isObservableSet(thing)) return thing;
5565
- if (thing[$mobx]) return thing[$mobx];
6193
+ if (!thing) {
6194
+ die(29);
6195
+ }
6196
+
6197
+ if (property !== undefined) {
6198
+ return getAdministration(getAtom(thing, property));
6199
+ }
6200
+
6201
+ if (isAtom(thing) || isComputedValue(thing) || isReaction(thing)) {
6202
+ return thing;
6203
+ }
6204
+
6205
+ if (isObservableMap(thing) || isObservableSet(thing)) {
6206
+ return thing;
6207
+ }
6208
+
6209
+ if (thing[$mobx]) {
6210
+ return thing[$mobx];
6211
+ }
6212
+
5566
6213
  die(24, thing);
5567
6214
  }
5568
6215
  function getDebugName(thing, property) {
@@ -5595,17 +6242,33 @@ function deepEqual(a, b, depth) {
5595
6242
  function eq(a, b, depth, aStack, bStack) {
5596
6243
  // Identical objects are equal. `0 === -0`, but they aren't identical.
5597
6244
  // See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal).
5598
- if (a === b) return a !== 0 || 1 / a === 1 / b; // `null` or `undefined` only equal to itself (strict comparison).
6245
+ if (a === b) {
6246
+ return a !== 0 || 1 / a === 1 / b;
6247
+ } // `null` or `undefined` only equal to itself (strict comparison).
5599
6248
 
5600
- if (a == null || b == null) return false; // `NaN`s are equivalent, but non-reflexive.
5601
6249
 
5602
- if (a !== a) return b !== b; // Exhaust primitive checks
6250
+ if (a == null || b == null) {
6251
+ return false;
6252
+ } // `NaN`s are equivalent, but non-reflexive.
6253
+
6254
+
6255
+ if (a !== a) {
6256
+ return b !== b;
6257
+ } // Exhaust primitive checks
6258
+
5603
6259
 
5604
6260
  var type = typeof a;
5605
- if (type !== "function" && type !== "object" && typeof b != "object") return false; // Compare `[[Class]]` names.
6261
+
6262
+ if (type !== "function" && type !== "object" && typeof b != "object") {
6263
+ return false;
6264
+ } // Compare `[[Class]]` names.
6265
+
5606
6266
 
5607
6267
  var className = toString.call(a);
5608
- if (className !== toString.call(b)) return false;
6268
+
6269
+ if (className !== toString.call(b)) {
6270
+ return false;
6271
+ }
5609
6272
 
5610
6273
  switch (className) {
5611
6274
  // Strings, numbers, regular expressions, dates, and booleans are compared by value.
@@ -5619,7 +6282,10 @@ function eq(a, b, depth, aStack, bStack) {
5619
6282
  case "[object Number]":
5620
6283
  // `NaN`s are equivalent, but non-reflexive.
5621
6284
  // Object(NaN) is equivalent to NaN.
5622
- if (+a !== +a) return +b !== +b; // An `egal` comparison is performed for other numeric values.
6285
+ if (+a !== +a) {
6286
+ return +b !== +b;
6287
+ } // An `egal` comparison is performed for other numeric values.
6288
+
5623
6289
 
5624
6290
  return +a === 0 ? 1 / +a === 1 / b : +a === +b;
5625
6291
 
@@ -5650,9 +6316,12 @@ function eq(a, b, depth, aStack, bStack) {
5650
6316
  var areArrays = className === "[object Array]";
5651
6317
 
5652
6318
  if (!areArrays) {
5653
- if (typeof a != "object" || typeof b != "object") return false; // Objects with different constructors are not equivalent, but `Object`s or `Array`s
6319
+ if (typeof a != "object" || typeof b != "object") {
6320
+ return false;
6321
+ } // Objects with different constructors are not equivalent, but `Object`s or `Array`s
5654
6322
  // from different frames are.
5655
6323
 
6324
+
5656
6325
  var aCtor = a.constructor,
5657
6326
  bCtor = b.constructor;
5658
6327
 
@@ -5678,7 +6347,9 @@ function eq(a, b, depth, aStack, bStack) {
5678
6347
  while (length--) {
5679
6348
  // Linear search. Performance is inversely proportional to the number of
5680
6349
  // unique nested structures.
5681
- if (aStack[length] === a) return bStack[length] === b;
6350
+ if (aStack[length] === a) {
6351
+ return bStack[length] === b;
6352
+ }
5682
6353
  } // Add the first object to the stack of traversed objects.
5683
6354
 
5684
6355
 
@@ -5688,10 +6359,16 @@ function eq(a, b, depth, aStack, bStack) {
5688
6359
  if (areArrays) {
5689
6360
  // Compare array lengths to determine if a deep comparison is necessary.
5690
6361
  length = a.length;
5691
- if (length !== b.length) return false; // Deep compare the contents, ignoring non-numeric properties.
6362
+
6363
+ if (length !== b.length) {
6364
+ return false;
6365
+ } // Deep compare the contents, ignoring non-numeric properties.
6366
+
5692
6367
 
5693
6368
  while (length--) {
5694
- if (!eq(a[length], b[length], depth - 1, aStack, bStack)) return false;
6369
+ if (!eq(a[length], b[length], depth - 1, aStack, bStack)) {
6370
+ return false;
6371
+ }
5695
6372
  }
5696
6373
  } else {
5697
6374
  // Deep compare objects.
@@ -5699,12 +6376,17 @@ function eq(a, b, depth, aStack, bStack) {
5699
6376
  var key;
5700
6377
  length = keys.length; // Ensure that both objects contain the same number of properties before comparing deep equality.
5701
6378
 
5702
- if (Object.keys(b).length !== length) return false;
6379
+ if (Object.keys(b).length !== length) {
6380
+ return false;
6381
+ }
5703
6382
 
5704
6383
  while (length--) {
5705
6384
  // Deep compare each member
5706
6385
  key = keys[length];
5707
- if (!(hasProp(b, key) && eq(a[key], b[key], depth - 1, aStack, bStack))) return false;
6386
+
6387
+ if (!(hasProp(b, key) && eq(a[key], b[key], depth - 1, aStack, bStack))) {
6388
+ return false;
6389
+ }
5708
6390
  }
5709
6391
  } // Remove the first object from the stack of traversed objects.
5710
6392
 
@@ -5715,9 +6397,18 @@ function eq(a, b, depth, aStack, bStack) {
5715
6397
  }
5716
6398
 
5717
6399
  function unwrap(a) {
5718
- if (isObservableArray(a)) return a.slice();
5719
- if (isES6Map(a) || isObservableMap(a)) return Array.from(a.entries());
5720
- if (isES6Set(a) || isObservableSet(a)) return Array.from(a.entries());
6400
+ if (isObservableArray(a)) {
6401
+ return a.slice();
6402
+ }
6403
+
6404
+ if (isES6Map(a) || isObservableMap(a)) {
6405
+ return Array.from(a.entries());
6406
+ }
6407
+
6408
+ if (isES6Set(a) || isObservableSet(a)) {
6409
+ return Array.from(a.entries());
6410
+ }
6411
+
5721
6412
  return a;
5722
6413
  }
5723
6414