mobx 6.13.7 → 6.15.1

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,29 @@
1
1
  # mobx
2
2
 
3
+ ## 6.15.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`df81c144fb148b64140d761aa61f032a7f429e12`](https://github.com/mobxjs/mobx/commit/df81c144fb148b64140d761aa61f032a7f429e12) [#4523](https://github.com/mobxjs/mobx/pull/4523) Thanks [@exzos28](https://github.com/exzos28)! - Make `FlowCancellationError` a proper `Error` instance while preserving its previous string representation.
8
+
9
+ - [`21fc4de6c09a77caf115aedd2fe6df972637412b`](https://github.com/mobxjs/mobx/commit/21fc4de6c09a77caf115aedd2fe6df972637412b) [#4626](https://github.com/mobxjs/mobx/pull/4626) Thanks [@kubk](https://github.com/kubk)! - Export `CancellablePromise` from the public `mobx` entrypoint.
10
+
11
+ ## 6.15.0
12
+
13
+ ### Minor Changes
14
+
15
+ - [`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
16
+
17
+ ### Patch Changes
18
+
19
+ - [`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
20
+
21
+ ## 6.14.0
22
+
23
+ ### Minor Changes
24
+
25
+ - [`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
26
+
3
27
  ## 6.13.7
4
28
 
5
29
  ### Patch Changes
package/README.md CHANGED
@@ -48,7 +48,7 @@ MobX is made possible by the generosity of the sponsors below, and many other [i
48
48
  **🥈 Silver sponsors (\$500+ total contributions):**<br/>
49
49
 
50
50
  <a href="https://mantro.net/jobs/warlock"><img src="https://mobx.js.org/assets/mantro.png" align="center" width="100" title="mantro GmbH" alt="mantro GmbH"></a>
51
- <a href="https://www.xh.com/"><img src="https://mobx.js.org/assets/xh.png" align="center" width="100" title="Extremely Heavy" alt="Extremely Heavy" /></a>
51
+ <a href="https://xh.io/"><img src="https://mobx.js.org/assets/xh.png" align="center" width="100" title="Extremely Heavy Industries" alt="Extremely Heavy Industries" /></a>
52
52
  <a href="https://www.algolia.com/"><img src="https://mobx.js.org/assets/algolia.jpg" align="center" width="100" title="Algolia" alt="Algolia" /></a>
53
53
  <a href="https://space307.com/?utm_source=sponsorship&utm_medium=mobx&utm_campaign=readme"><img src="https://mobx.js.org/assets/space307.png" align="center" width="100" title="Space307" alt="Space307"/></a>
54
54
  <a href="https://blokt.com/"><img src="https://mobx.js.org/assets/blokt.jpg" align="center" width="100" title="Blokt" alt="Blokt"/></a>
@@ -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,11 +1,11 @@
1
1
  import { Annotation } from "../internal";
2
2
  import type { ClassMethodDecorator } from "../types/decorator_fills";
3
3
  export declare const FLOW = "flow";
4
- export declare function FlowCancellationError(): void;
5
- export declare namespace FlowCancellationError {
6
- var prototype: any;
4
+ export declare class FlowCancellationError extends Error {
5
+ constructor();
6
+ toString(): string;
7
7
  }
8
- export declare function isFlowCancellationError(error: Error): boolean;
8
+ export declare function isFlowCancellationError(error: Error): error is FlowCancellationError;
9
9
  export type CancellablePromise<T> = Promise<T> & {
10
10
  cancel(): void;
11
11
  };
@@ -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.
@@ -292,6 +292,13 @@ function _arrayLikeToArray(r, a) {
292
292
  for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
293
293
  return n;
294
294
  }
295
+ function _construct(t, e, r) {
296
+ if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
297
+ var o = [null];
298
+ o.push.apply(o, e);
299
+ var p = new (t.bind.apply(t, o))();
300
+ return r && _setPrototypeOf(p, r.prototype), p;
301
+ }
295
302
  function _defineProperties(e, r) {
296
303
  for (var t = 0; t < r.length; t++) {
297
304
  var o = r[t];
@@ -329,9 +336,29 @@ function _extends() {
329
336
  return n;
330
337
  }, _extends.apply(null, arguments);
331
338
  }
339
+ function _getPrototypeOf(t) {
340
+ return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
341
+ return t.__proto__ || Object.getPrototypeOf(t);
342
+ }, _getPrototypeOf(t);
343
+ }
332
344
  function _inheritsLoose(t, o) {
333
345
  t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o);
334
346
  }
347
+ function _isNativeFunction(t) {
348
+ try {
349
+ return -1 !== Function.toString.call(t).indexOf("[native code]");
350
+ } catch (n) {
351
+ return "function" == typeof t;
352
+ }
353
+ }
354
+ function _isNativeReflectConstruct() {
355
+ try {
356
+ var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
357
+ } catch (t) {}
358
+ return (_isNativeReflectConstruct = function () {
359
+ return !!t;
360
+ })();
361
+ }
335
362
  function _setPrototypeOf(t, e) {
336
363
  return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
337
364
  return t.__proto__ = e, t;
@@ -358,6 +385,28 @@ function _unsupportedIterableToArray(r, a) {
358
385
  return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
359
386
  }
360
387
  }
388
+ function _wrapNativeSuper(t) {
389
+ var r = "function" == typeof Map ? new Map() : void 0;
390
+ return _wrapNativeSuper = function (t) {
391
+ if (null === t || !_isNativeFunction(t)) return t;
392
+ if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function");
393
+ if (void 0 !== r) {
394
+ if (r.has(t)) return r.get(t);
395
+ r.set(t, Wrapper);
396
+ }
397
+ function Wrapper() {
398
+ return _construct(t, arguments, _getPrototypeOf(this).constructor);
399
+ }
400
+ return Wrapper.prototype = Object.create(t.prototype, {
401
+ constructor: {
402
+ value: Wrapper,
403
+ enumerable: !1,
404
+ writable: !0,
405
+ configurable: !0
406
+ }
407
+ }), _setPrototypeOf(Wrapper, t);
408
+ }, _wrapNativeSuper(t);
409
+ }
361
410
 
362
411
  var storedAnnotationsSymbol = /*#__PURE__*/Symbol("mobx-stored-annotations");
363
412
  /**
@@ -1010,7 +1059,8 @@ function make_$5(adm, key, descriptor, source) {
1010
1059
  // lone setter -> action setter
1011
1060
  if (descriptor.set) {
1012
1061
  // TODO make action applicable to setter and delegate to action.make_
1013
- var set = createAction(key.toString(), descriptor.set);
1062
+ var set = isAction(descriptor.set) ? descriptor.set // See #4553
1063
+ : createAction(key.toString(), descriptor.set);
1014
1064
  // own
1015
1065
  if (source === adm.target_) {
1016
1066
  return adm.defineProperty_(key, {
@@ -1375,13 +1425,14 @@ var ObservableValue = /*#__PURE__*/function (_Atom) {
1375
1425
  _this.equals = equals;
1376
1426
  _this.value_ = enhancer(value, undefined, name_);
1377
1427
  if ( notifySpy && isSpyEnabled()) {
1428
+ var _this$value_;
1378
1429
  // only notify spy if this is a stand-alone observable
1379
1430
  spyReport({
1380
1431
  type: CREATE,
1381
1432
  object: _this,
1382
1433
  observableKind: "value",
1383
1434
  debugObjectName: _this.name_,
1384
- newValue: "" + _this.value_
1435
+ newValue: "" + ((_this$value_ = _this.value_) == null ? void 0 : _this$value_.toString())
1385
1436
  });
1386
1437
  }
1387
1438
  return _this;
@@ -1574,7 +1625,7 @@ var ComputedValue = /*#__PURE__*/function () {
1574
1625
  }
1575
1626
  }
1576
1627
  // to check for cycles
1577
- ;
1628
+ ;
1578
1629
  /**
1579
1630
  * Returns the current value of this computed value.
1580
1631
  * Will evaluate its computation first if needed.
@@ -2549,6 +2600,9 @@ var Reaction = /*#__PURE__*/function () {
2549
2600
  };
2550
2601
  abortSignal == null || abortSignal.addEventListener == null || abortSignal.addEventListener("abort", dispose);
2551
2602
  dispose[$mobx] = this;
2603
+ if ("dispose" in Symbol && typeof Symbol.dispose === "symbol") {
2604
+ dispose[Symbol.dispose] = dispose;
2605
+ }
2552
2606
  return dispose;
2553
2607
  };
2554
2608
  _proto.toString = function toString() {
@@ -3011,10 +3065,21 @@ function unique(list) {
3011
3065
  }
3012
3066
 
3013
3067
  var generatorId = 0;
3014
- function FlowCancellationError() {
3015
- this.message = "FLOW_CANCELLED";
3016
- }
3017
- FlowCancellationError.prototype = /*#__PURE__*/Object.create(Error.prototype);
3068
+ var FlowCancellationError = /*#__PURE__*/function (_Error) {
3069
+ function FlowCancellationError() {
3070
+ var _this;
3071
+ _this = _Error.call(this, "FLOW_CANCELLED") || this;
3072
+ Object.setPrototypeOf(_this, (this instanceof FlowCancellationError ? this.constructor : void 0).prototype);
3073
+ _this.name = "FlowCancellationError";
3074
+ return _this;
3075
+ }
3076
+ _inheritsLoose(FlowCancellationError, _Error);
3077
+ var _proto = FlowCancellationError.prototype;
3078
+ _proto.toString = function toString() {
3079
+ return "Error: " + this.message;
3080
+ };
3081
+ return FlowCancellationError;
3082
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
3018
3083
  function isFlowCancellationError(error) {
3019
3084
  return error instanceof FlowCancellationError;
3020
3085
  }
@@ -5026,7 +5091,7 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
5026
5091
  }
5027
5092
  }
5028
5093
  // Trap for "in"
5029
- ;
5094
+ ;
5030
5095
  _proto.has_ = function has_(key) {
5031
5096
  if (!globalState.trackingDerivation) {
5032
5097
  // Skip key subscription outside derivation
@@ -5158,7 +5223,7 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
5158
5223
  return true;
5159
5224
  }
5160
5225
  // If original descriptor becomes relevant, move this to annotation directly
5161
- ;
5226
+ ;
5162
5227
  _proto.defineObservableProperty_ = function defineObservableProperty_(key, value, enhancer, proxyTrap) {
5163
5228
  if (proxyTrap === void 0) {
5164
5229
  proxyTrap = false;
@@ -5210,7 +5275,7 @@ var ObservableObjectAdministration = /*#__PURE__*/function () {
5210
5275
  return true;
5211
5276
  }
5212
5277
  // If original descriptor becomes relevant, move this to annotation directly
5213
- ;
5278
+ ;
5214
5279
  _proto.defineComputedProperty_ = function defineComputedProperty_(key, options, proxyTrap) {
5215
5280
  if (proxyTrap === void 0) {
5216
5281
  proxyTrap = false;