mobx 6.13.6 → 6.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # mobx
2
2
 
3
+ ## 6.15.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`2e703388eda4ba3eefed2bf1f5ca3958980978c3`](https://github.com/mobxjs/mobx/commit/2e703388eda4ba3eefed2bf1f5ca3958980978c3) [#4584](https://github.com/mobxjs/mobx/pull/4584) Thanks [@mweststrate](https://github.com/mweststrate)! - Fix #4753: Wrong inferred type of observable.map in TS 5.9+, by @mbest in #578
8
+
9
+ ### Patch Changes
10
+
11
+ - [`61d6cf39764f28c6c2e0d2b3912364889739c619`](https://github.com/mobxjs/mobx/commit/61d6cf39764f28c6c2e0d2b3912364889739c619) [#4563](https://github.com/mobxjs/mobx/pull/4563) Thanks [@mweststrate](https://github.com/mweststrate)! - Fixed memory leak where makeAutoObservable would keep wrapping setters defined on the prototype. Fixes #4553
12
+
13
+ ## 6.14.0
14
+
15
+ ### Minor Changes
16
+
17
+ - [`fe1d3f45cfd0d21189e963579e5c9d764329fea9`](https://github.com/mobxjs/mobx/commit/fe1d3f45cfd0d21189e963579e5c9d764329fea9) [#4558](https://github.com/mobxjs/mobx/pull/4558) Thanks [@vkrol](https://github.com/vkrol)! - Add Explicit Resource Management support in reactions
18
+
19
+ ## 6.13.7
20
+
21
+ ### Patch Changes
22
+
23
+ - [`54e3f71ca02f09b3107290f18d8484b70a6e2f0b`](https://github.com/mobxjs/mobx/commit/54e3f71ca02f09b3107290f18d8484b70a6e2f0b) [#4528](https://github.com/mobxjs/mobx/pull/4528) Thanks [@k-g-a](https://github.com/k-g-a)! - Fix observable.set not respecting the new value from interceptors
24
+
3
25
  ## 6.13.6
4
26
 
5
27
  ### Patch Changes
package/README.md CHANGED
@@ -57,6 +57,7 @@ MobX is made possible by the generosity of the sponsors below, and many other [i
57
57
  <a href="https://talentplot.com/"><img src="https://mobx.js.org/assets/talentplot.png" align="center" width="100" title="talentplot" alt="talentplot"></a>
58
58
  <a href="https://www.easeus.com/?utm_source=github_mobxjs_sponsorship&utm_medium=readme&utm_campaign=sponsorship"><img src="https://mobx.js.org/assets/easeus.png" align="center" width="100" title="EaseUS" alt="EaseUS"/></a>
59
59
  <a href="https://route4me.com/"><img src="https://mobx.js.org/assets/route4me.png" align="center" width="100" title="Route Planner and Route Optimizer" alt="Route Planner and Route Optimizer"/></a>
60
+ <a href="https://handsontable.com/docs/react-data-grid/?utm_source=Mobx_homepage&utm_medium=sponsorship&utm_campaign=library_sponsorship"><img src="https://mobx.js.org/assets/handsontable.png" align="center" width="100" title="Handsontable" alt="Handsontable"/></a>
60
61
 
61
62
  ## Introduction
62
63
 
@@ -1,4 +1,4 @@
1
- import { IEnhancer, IEqualsComparer, IObservableArray, IObservableMapInitialValues, IObservableSetInitialValues, IObservableValue, ObservableMap, ObservableSet, Annotation, AnnotationsMap } from "../internal";
1
+ import { IEnhancer, IEqualsComparer, IObservableArray, IMapEntries, IReadonlyMapEntries, IKeyValueMap, IObservableSetInitialValues, IObservableValue, ObservableMap, ObservableSet, Annotation, AnnotationsMap } from "../internal";
2
2
  import type { ClassAccessorDecorator, ClassFieldDecorator } from "../types/decorator_fills";
3
3
  export declare const OBSERVABLE = "observable";
4
4
  export declare const OBSERVABLE_REF = "observable.ref";
@@ -21,6 +21,14 @@ export interface IObservableValueFactory {
21
21
  <T>(value: T, options?: CreateObservableOptions): IObservableValue<T>;
22
22
  <T>(value?: T, options?: CreateObservableOptions): IObservableValue<T | undefined>;
23
23
  }
24
+ export interface IObservableMapFactory {
25
+ <K = any, V = any>(): ObservableMap<K, V>;
26
+ <K, V>(initialValues?: IMapEntries<K, V>, options?: CreateObservableOptions): ObservableMap<K, V>;
27
+ <K, V>(initialValues?: IReadonlyMapEntries<K, V>, options?: CreateObservableOptions): ObservableMap<K, V>;
28
+ <K, V>(initialValues?: IKeyValueMap<V>, options?: CreateObservableOptions): ObservableMap<K, V>;
29
+ <K, V>(initialValues?: Map<K, V>, options?: CreateObservableOptions): ObservableMap<K, V>;
30
+ <K = any, V = any>(initialValues: undefined, options?: CreateObservableOptions): ObservableMap<K, V>;
31
+ }
24
32
  export interface IObservableFactory extends Annotation, PropertyDecorator, ClassAccessorDecorator, ClassFieldDecorator {
25
33
  <T = any>(value: T[], options?: CreateObservableOptions): IObservableArray<T>;
26
34
  <T = any>(value: Set<T>, options?: CreateObservableOptions): ObservableSet<T>;
@@ -29,7 +37,7 @@ export interface IObservableFactory extends Annotation, PropertyDecorator, Class
29
37
  box: IObservableValueFactory;
30
38
  array: <T = any>(initialValues?: T[], options?: CreateObservableOptions) => IObservableArray<T>;
31
39
  set: <T = any>(initialValues?: IObservableSetInitialValues<T>, options?: CreateObservableOptions) => ObservableSet<T>;
32
- map: <K = any, V = any>(initialValues?: IObservableMapInitialValues<K, V>, options?: CreateObservableOptions) => ObservableMap<K, V>;
40
+ map: IObservableMapFactory;
33
41
  object: <T = any>(props: T, decorators?: AnnotationsMap<T, never>, options?: CreateObservableOptions) => T;
34
42
  /**
35
43
  * Decorator that creates an observable that only observes the references, but doesn't try to turn the assigned value into an observable.ts.
@@ -1010,7 +1010,8 @@ function make_$5(adm, key, descriptor, source) {
1010
1010
  // lone setter -> action setter
1011
1011
  if (descriptor.set) {
1012
1012
  // TODO make action applicable to setter and delegate to action.make_
1013
- var set = createAction(key.toString(), descriptor.set);
1013
+ var set = isAction(descriptor.set) ? descriptor.set // See #4553
1014
+ : createAction(key.toString(), descriptor.set);
1014
1015
  // own
1015
1016
  if (source === adm.target_) {
1016
1017
  return adm.defineProperty_(key, {
@@ -1375,13 +1376,14 @@ var ObservableValue = /*#__PURE__*/function (_Atom) {
1375
1376
  _this.equals = equals;
1376
1377
  _this.value_ = enhancer(value, undefined, name_);
1377
1378
  if ( notifySpy && isSpyEnabled()) {
1379
+ var _this$value_;
1378
1380
  // only notify spy if this is a stand-alone observable
1379
1381
  spyReport({
1380
1382
  type: CREATE,
1381
1383
  object: _this,
1382
1384
  observableKind: "value",
1383
1385
  debugObjectName: _this.name_,
1384
- newValue: "" + _this.value_
1386
+ newValue: "" + ((_this$value_ = _this.value_) == null ? void 0 : _this$value_.toString())
1385
1387
  });
1386
1388
  }
1387
1389
  return _this;
@@ -2549,6 +2551,9 @@ var Reaction = /*#__PURE__*/function () {
2549
2551
  };
2550
2552
  abortSignal == null || abortSignal.addEventListener == null || abortSignal.addEventListener("abort", dispose);
2551
2553
  dispose[$mobx] = this;
2554
+ if ("dispose" in Symbol && typeof Symbol.dispose === "symbol") {
2555
+ dispose[Symbol.dispose] = dispose;
2556
+ }
2552
2557
  return dispose;
2553
2558
  };
2554
2559
  _proto.toString = function toString() {
@@ -4682,8 +4687,8 @@ var ObservableSet = /*#__PURE__*/function () {
4682
4687
  if (!change) {
4683
4688
  return this;
4684
4689
  }
4685
- // ideally, value = change.value would be done here, so that values can be
4686
- // changed by interceptor. Same applies for other Set and Map api's.
4690
+ // implemented reassignment same as it's done for ObservableMap
4691
+ value = change.newValue;
4687
4692
  }
4688
4693
  if (!this.has(value)) {
4689
4694
  transaction(function () {
@@ -5738,6 +5743,8 @@ function deepEqual(a, b, depth) {
5738
5743
  return eq(a, b, depth);
5739
5744
  }
5740
5745
  // Copied from https://github.com/jashkenas/underscore/blob/5c237a7c682fb68fd5378203f0bf22dce1624854/underscore.js#L1186-L1289
5746
+ // Modified: "Deep compare objects" part to iterate over keys in forward order instead of reverse order.
5747
+ //
5741
5748
  // Internal recursive comparison function for `isEqual`.
5742
5749
  function eq(a, b, depth, aStack, bStack) {
5743
5750
  // Identical objects are equal. `0 === -0`, but they aren't identical.
@@ -5850,15 +5857,14 @@ function eq(a, b, depth, aStack, bStack) {
5850
5857
  } else {
5851
5858
  // Deep compare objects.
5852
5859
  var keys = Object.keys(a);
5853
- var key;
5854
- length = keys.length;
5860
+ var _length = keys.length;
5855
5861
  // Ensure that both objects contain the same number of properties before comparing deep equality.
5856
- if (Object.keys(b).length !== length) {
5862
+ if (Object.keys(b).length !== _length) {
5857
5863
  return false;
5858
5864
  }
5859
- while (length--) {
5865
+ for (var i = 0; i < _length; i++) {
5860
5866
  // Deep compare each member
5861
- key = keys[length];
5867
+ var key = keys[i];
5862
5868
  if (!(hasProp(b, key) && eq(a[key], b[key], depth - 1, aStack, bStack))) {
5863
5869
  return false;
5864
5870
  }