mobx 6.13.7 → 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,21 @@
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
+
3
19
  ## 6.13.7
4
20
 
5
21
  ### 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() {