mobx 6.10.2 → 6.11.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 (88) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +2 -2
  3. package/dist/api/action.d.ts +16 -15
  4. package/dist/api/annotation.d.ts +19 -18
  5. package/dist/api/autorun.d.ts +25 -25
  6. package/dist/api/become-observed.d.ts +5 -5
  7. package/dist/api/computed.d.ts +14 -13
  8. package/dist/api/configure.d.ts +17 -17
  9. package/dist/api/decorators.d.ts +20 -17
  10. package/dist/api/extendobservable.d.ts +2 -2
  11. package/dist/api/extras.d.ts +10 -10
  12. package/dist/api/flow.d.ts +19 -18
  13. package/dist/api/intercept-read.d.ts +8 -8
  14. package/dist/api/intercept.d.ts +8 -8
  15. package/dist/api/iscomputed.d.ts +3 -3
  16. package/dist/api/isobservable.d.ts +2 -2
  17. package/dist/api/makeObservable.d.ts +6 -6
  18. package/dist/api/object-api.d.ts +36 -36
  19. package/dist/api/observable.d.ts +45 -44
  20. package/dist/api/observe.d.ts +8 -8
  21. package/dist/api/tojs.d.ts +7 -7
  22. package/dist/api/trace.d.ts +3 -3
  23. package/dist/api/transaction.d.ts +8 -8
  24. package/dist/api/when.d.ts +11 -11
  25. package/dist/core/action.d.ts +20 -20
  26. package/dist/core/atom.d.ts +37 -37
  27. package/dist/core/computedvalue.d.ts +99 -99
  28. package/dist/core/derivation.d.ts +73 -73
  29. package/dist/core/globalstate.d.ts +121 -121
  30. package/dist/core/observable.d.ts +45 -45
  31. package/dist/core/reaction.d.ts +62 -62
  32. package/dist/core/spy.d.ts +37 -37
  33. package/dist/errors.d.ts +42 -42
  34. package/dist/internal.d.ts +54 -54
  35. package/dist/mobx.cjs.development.js +419 -252
  36. package/dist/mobx.cjs.development.js.map +1 -1
  37. package/dist/mobx.cjs.production.min.js +1 -1
  38. package/dist/mobx.cjs.production.min.js.map +1 -1
  39. package/dist/mobx.d.ts +2 -2
  40. package/dist/mobx.esm.development.js +419 -252
  41. package/dist/mobx.esm.development.js.map +1 -1
  42. package/dist/mobx.esm.js +419 -252
  43. package/dist/mobx.esm.js.map +1 -1
  44. package/dist/mobx.esm.production.min.js +1 -1
  45. package/dist/mobx.esm.production.min.js.map +1 -1
  46. package/dist/mobx.umd.development.js +419 -252
  47. package/dist/mobx.umd.development.js.map +1 -1
  48. package/dist/mobx.umd.production.min.js +1 -1
  49. package/dist/mobx.umd.production.min.js.map +1 -1
  50. package/dist/types/actionannotation.d.ts +8 -8
  51. package/dist/types/autoannotation.d.ts +3 -3
  52. package/dist/types/computedannotation.d.ts +2 -2
  53. package/dist/types/decorator_fills.d.ts +6 -0
  54. package/dist/types/dynamicobject.d.ts +2 -2
  55. package/dist/types/flowannotation.d.ts +2 -2
  56. package/dist/types/generic-abort-signal.d.ts +6 -6
  57. package/dist/types/intercept-utils.d.ts +8 -8
  58. package/dist/types/legacyobservablearray.d.ts +14 -3
  59. package/dist/types/listen-utils.d.ts +7 -7
  60. package/dist/types/modifiers.d.ts +7 -7
  61. package/dist/types/observableannotation.d.ts +2 -2
  62. package/dist/types/observablearray.d.ts +85 -85
  63. package/dist/types/observablemap.d.ts +78 -78
  64. package/dist/types/observableobject.d.ts +98 -98
  65. package/dist/types/observableset.d.ts +53 -53
  66. package/dist/types/observablevalue.d.ts +49 -49
  67. package/dist/types/overrideannotation.d.ts +4 -3
  68. package/dist/types/type-utils.d.ts +11 -11
  69. package/dist/utils/comparer.d.ts +14 -14
  70. package/dist/utils/eq.d.ts +1 -1
  71. package/dist/utils/global.d.ts +1 -1
  72. package/dist/utils/iterable.d.ts +1 -1
  73. package/dist/utils/utils.d.ts +45 -45
  74. package/package.json +1 -1
  75. package/src/api/action.ts +21 -4
  76. package/src/api/annotation.ts +1 -0
  77. package/src/api/computed.ts +11 -4
  78. package/src/api/decorators.ts +33 -8
  79. package/src/api/flow.ts +10 -3
  80. package/src/api/observable.ts +20 -6
  81. package/src/types/actionannotation.ts +48 -2
  82. package/src/types/autoannotation.ts +8 -2
  83. package/src/types/computedannotation.ts +39 -2
  84. package/src/types/decorator_fills.ts +33 -0
  85. package/src/types/flowannotation.ts +28 -2
  86. package/src/types/legacyobservablearray.ts +1 -1
  87. package/src/types/observableannotation.ts +75 -2
  88. package/src/types/overrideannotation.ts +15 -7
@@ -1,98 +1,98 @@
1
- import { CreateObservableOptions, Annotation, ComputedValue, IAtom, IComputedValueOptions, IEnhancer, IInterceptable, IListenable, Lambda, ObservableValue } from "../internal";
2
- export declare type IObjectDidChange<T = any> = {
3
- observableKind: "object";
4
- name: PropertyKey;
5
- object: T;
6
- debugObjectName: string;
7
- } & ({
8
- type: "add";
9
- newValue: any;
10
- } | {
11
- type: "update";
12
- oldValue: any;
13
- newValue: any;
14
- } | {
15
- type: "remove";
16
- oldValue: any;
17
- });
18
- export declare type IObjectWillChange<T = any> = {
19
- object: T;
20
- type: "update" | "add";
21
- name: PropertyKey;
22
- newValue: any;
23
- } | {
24
- object: T;
25
- type: "remove";
26
- name: PropertyKey;
27
- };
28
- export declare class ObservableObjectAdministration implements IInterceptable<IObjectWillChange>, IListenable {
29
- target_: any;
30
- values_: Map<PropertyKey, ObservableValue<any> | ComputedValue<any>>;
31
- name_: string;
32
- defaultAnnotation_: Annotation;
33
- keysAtom_: IAtom;
34
- changeListeners_: any;
35
- interceptors_: any;
36
- proxy_: any;
37
- isPlainObject_: boolean;
38
- appliedAnnotations_?: object;
39
- private pendingKeys_;
40
- constructor(target_: any, values_: Map<PropertyKey, ObservableValue<any> | ComputedValue<any>>, name_: string, defaultAnnotation_?: Annotation);
41
- getObservablePropValue_(key: PropertyKey): any;
42
- setObservablePropValue_(key: PropertyKey, newValue: any): boolean | null;
43
- get_(key: PropertyKey): any;
44
- /**
45
- * @param {PropertyKey} key
46
- * @param {any} value
47
- * @param {Annotation|boolean} annotation true - use default annotation, false - copy as is
48
- * @param {boolean} proxyTrap whether it's called from proxy trap
49
- * @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor
50
- */
51
- set_(key: PropertyKey, value: any, proxyTrap?: boolean): boolean | null;
52
- has_(key: PropertyKey): boolean;
53
- /**
54
- * @param {PropertyKey} key
55
- * @param {Annotation|boolean} annotation true - use default annotation, false - ignore prop
56
- */
57
- make_(key: PropertyKey, annotation: Annotation | boolean): void;
58
- /**
59
- * @param {PropertyKey} key
60
- * @param {PropertyDescriptor} descriptor
61
- * @param {Annotation|boolean} annotation true - use default annotation, false - copy as is
62
- * @param {boolean} proxyTrap whether it's called from proxy trap
63
- * @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor
64
- */
65
- extend_(key: PropertyKey, descriptor: PropertyDescriptor, annotation: Annotation | boolean, proxyTrap?: boolean): boolean | null;
66
- /**
67
- * @param {PropertyKey} key
68
- * @param {PropertyDescriptor} descriptor
69
- * @param {boolean} proxyTrap whether it's called from proxy trap
70
- * @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor
71
- */
72
- defineProperty_(key: PropertyKey, descriptor: PropertyDescriptor, proxyTrap?: boolean): boolean | null;
73
- defineObservableProperty_(key: PropertyKey, value: any, enhancer: IEnhancer<any>, proxyTrap?: boolean): boolean | null;
74
- defineComputedProperty_(key: PropertyKey, options: IComputedValueOptions<any>, proxyTrap?: boolean): boolean | null;
75
- /**
76
- * @param {PropertyKey} key
77
- * @param {PropertyDescriptor} descriptor
78
- * @param {boolean} proxyTrap whether it's called from proxy trap
79
- * @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor
80
- */
81
- delete_(key: PropertyKey, proxyTrap?: boolean): boolean | null;
82
- /**
83
- * Observes this object. Triggers for the events 'add', 'update' and 'delete'.
84
- * See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/observe
85
- * for callback details
86
- */
87
- observe_(callback: (changes: IObjectDidChange) => void, fireImmediately?: boolean): Lambda;
88
- intercept_(handler: any): Lambda;
89
- notifyPropertyAddition_(key: PropertyKey, value: any): void;
90
- ownKeys_(): ArrayLike<string | symbol>;
91
- keys_(): PropertyKey[];
92
- }
93
- export interface IIsObservableObject {
94
- $mobx: ObservableObjectAdministration;
95
- }
96
- export declare function asObservableObject(target: any, options?: CreateObservableOptions): IIsObservableObject;
97
- export declare function isObservableObject(thing: any): boolean;
98
- export declare function recordAnnotationApplied(adm: ObservableObjectAdministration, annotation: Annotation, key: PropertyKey): void;
1
+ import { CreateObservableOptions, Annotation, ComputedValue, IAtom, IComputedValueOptions, IEnhancer, IInterceptable, IListenable, Lambda, ObservableValue } from "../internal";
2
+ export type IObjectDidChange<T = any> = {
3
+ observableKind: "object";
4
+ name: PropertyKey;
5
+ object: T;
6
+ debugObjectName: string;
7
+ } & ({
8
+ type: "add";
9
+ newValue: any;
10
+ } | {
11
+ type: "update";
12
+ oldValue: any;
13
+ newValue: any;
14
+ } | {
15
+ type: "remove";
16
+ oldValue: any;
17
+ });
18
+ export type IObjectWillChange<T = any> = {
19
+ object: T;
20
+ type: "update" | "add";
21
+ name: PropertyKey;
22
+ newValue: any;
23
+ } | {
24
+ object: T;
25
+ type: "remove";
26
+ name: PropertyKey;
27
+ };
28
+ export declare class ObservableObjectAdministration implements IInterceptable<IObjectWillChange>, IListenable {
29
+ target_: any;
30
+ values_: Map<PropertyKey, ObservableValue<any> | ComputedValue<any>>;
31
+ name_: string;
32
+ defaultAnnotation_: Annotation;
33
+ keysAtom_: IAtom;
34
+ changeListeners_: any;
35
+ interceptors_: any;
36
+ proxy_: any;
37
+ isPlainObject_: boolean;
38
+ appliedAnnotations_?: object;
39
+ private pendingKeys_;
40
+ constructor(target_: any, values_: Map<PropertyKey, ObservableValue<any> | ComputedValue<any>>, name_: string, defaultAnnotation_?: Annotation);
41
+ getObservablePropValue_(key: PropertyKey): any;
42
+ setObservablePropValue_(key: PropertyKey, newValue: any): boolean | null;
43
+ get_(key: PropertyKey): any;
44
+ /**
45
+ * @param {PropertyKey} key
46
+ * @param {any} value
47
+ * @param {Annotation|boolean} annotation true - use default annotation, false - copy as is
48
+ * @param {boolean} proxyTrap whether it's called from proxy trap
49
+ * @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor
50
+ */
51
+ set_(key: PropertyKey, value: any, proxyTrap?: boolean): boolean | null;
52
+ has_(key: PropertyKey): boolean;
53
+ /**
54
+ * @param {PropertyKey} key
55
+ * @param {Annotation|boolean} annotation true - use default annotation, false - ignore prop
56
+ */
57
+ make_(key: PropertyKey, annotation: Annotation | boolean): void;
58
+ /**
59
+ * @param {PropertyKey} key
60
+ * @param {PropertyDescriptor} descriptor
61
+ * @param {Annotation|boolean} annotation true - use default annotation, false - copy as is
62
+ * @param {boolean} proxyTrap whether it's called from proxy trap
63
+ * @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor
64
+ */
65
+ extend_(key: PropertyKey, descriptor: PropertyDescriptor, annotation: Annotation | boolean, proxyTrap?: boolean): boolean | null;
66
+ /**
67
+ * @param {PropertyKey} key
68
+ * @param {PropertyDescriptor} descriptor
69
+ * @param {boolean} proxyTrap whether it's called from proxy trap
70
+ * @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor
71
+ */
72
+ defineProperty_(key: PropertyKey, descriptor: PropertyDescriptor, proxyTrap?: boolean): boolean | null;
73
+ defineObservableProperty_(key: PropertyKey, value: any, enhancer: IEnhancer<any>, proxyTrap?: boolean): boolean | null;
74
+ defineComputedProperty_(key: PropertyKey, options: IComputedValueOptions<any>, proxyTrap?: boolean): boolean | null;
75
+ /**
76
+ * @param {PropertyKey} key
77
+ * @param {PropertyDescriptor} descriptor
78
+ * @param {boolean} proxyTrap whether it's called from proxy trap
79
+ * @returns {boolean|null} true on success, false on failure (proxyTrap + non-configurable), null when cancelled by interceptor
80
+ */
81
+ delete_(key: PropertyKey, proxyTrap?: boolean): boolean | null;
82
+ /**
83
+ * Observes this object. Triggers for the events 'add', 'update' and 'delete'.
84
+ * See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/observe
85
+ * for callback details
86
+ */
87
+ observe_(callback: (changes: IObjectDidChange) => void, fireImmediately?: boolean): Lambda;
88
+ intercept_(handler: any): Lambda;
89
+ notifyPropertyAddition_(key: PropertyKey, value: any): void;
90
+ ownKeys_(): ArrayLike<string | symbol>;
91
+ keys_(): PropertyKey[];
92
+ }
93
+ export interface IIsObservableObject {
94
+ $mobx: ObservableObjectAdministration;
95
+ }
96
+ export declare function asObservableObject(target: any, options?: CreateObservableOptions): IIsObservableObject;
97
+ export declare function isObservableObject(thing: any): boolean;
98
+ export declare function recordAnnotationApplied(adm: ObservableObjectAdministration, annotation: Annotation, key: PropertyKey): void;
@@ -1,53 +1,53 @@
1
- import { $mobx, IEnhancer, IListenable, Lambda, IInterceptable, IInterceptor, IAtom } from "../internal";
2
- export declare type IObservableSetInitialValues<T> = Set<T> | readonly T[];
3
- export declare type ISetDidChange<T = any> = {
4
- object: ObservableSet<T>;
5
- observableKind: "set";
6
- debugObjectName: string;
7
- type: "add";
8
- newValue: T;
9
- } | {
10
- object: ObservableSet<T>;
11
- observableKind: "set";
12
- debugObjectName: string;
13
- type: "delete";
14
- oldValue: T;
15
- };
16
- export declare type ISetWillChange<T = any> = {
17
- type: "delete";
18
- object: ObservableSet<T>;
19
- oldValue: T;
20
- } | {
21
- type: "add";
22
- object: ObservableSet<T>;
23
- newValue: T;
24
- };
25
- export declare class ObservableSet<T = any> implements Set<T>, IInterceptable<ISetWillChange>, IListenable {
26
- name_: string;
27
- [$mobx]: {};
28
- private data_;
29
- atom_: IAtom;
30
- changeListeners_: any;
31
- interceptors_: any;
32
- dehancer: any;
33
- enhancer_: (newV: any, oldV: any | undefined) => any;
34
- constructor(initialData?: IObservableSetInitialValues<T>, enhancer?: IEnhancer<T>, name_?: string);
35
- private dehanceValue_;
36
- clear(): void;
37
- forEach(callbackFn: (value: T, value2: T, set: Set<T>) => void, thisArg?: any): void;
38
- get size(): number;
39
- add(value: T): this;
40
- delete(value: T): boolean;
41
- has(value: T): boolean;
42
- entries(): IterableIterator<[T, T]>;
43
- keys(): IterableIterator<T>;
44
- values(): IterableIterator<T>;
45
- replace(other: ObservableSet<T> | IObservableSetInitialValues<T>): ObservableSet<T>;
46
- observe_(listener: (changes: ISetDidChange<T>) => void, fireImmediately?: boolean): Lambda;
47
- intercept_(handler: IInterceptor<ISetWillChange<T>>): Lambda;
48
- toJSON(): T[];
49
- toString(): string;
50
- [Symbol.iterator](): IterableIterator<T>;
51
- get [Symbol.toStringTag](): string;
52
- }
53
- export declare var isObservableSet: (thing: any) => thing is ObservableSet<any>;
1
+ import { $mobx, IEnhancer, IListenable, Lambda, IInterceptable, IInterceptor, IAtom } from "../internal";
2
+ export type IObservableSetInitialValues<T> = Set<T> | readonly T[];
3
+ export type ISetDidChange<T = any> = {
4
+ object: ObservableSet<T>;
5
+ observableKind: "set";
6
+ debugObjectName: string;
7
+ type: "add";
8
+ newValue: T;
9
+ } | {
10
+ object: ObservableSet<T>;
11
+ observableKind: "set";
12
+ debugObjectName: string;
13
+ type: "delete";
14
+ oldValue: T;
15
+ };
16
+ export type ISetWillChange<T = any> = {
17
+ type: "delete";
18
+ object: ObservableSet<T>;
19
+ oldValue: T;
20
+ } | {
21
+ type: "add";
22
+ object: ObservableSet<T>;
23
+ newValue: T;
24
+ };
25
+ export declare class ObservableSet<T = any> implements Set<T>, IInterceptable<ISetWillChange>, IListenable {
26
+ name_: string;
27
+ [$mobx]: {};
28
+ private data_;
29
+ atom_: IAtom;
30
+ changeListeners_: any;
31
+ interceptors_: any;
32
+ dehancer: any;
33
+ enhancer_: (newV: any, oldV: any | undefined) => any;
34
+ constructor(initialData?: IObservableSetInitialValues<T>, enhancer?: IEnhancer<T>, name_?: string);
35
+ private dehanceValue_;
36
+ clear(): void;
37
+ forEach(callbackFn: (value: T, value2: T, set: Set<T>) => void, thisArg?: any): void;
38
+ get size(): number;
39
+ add(value: T): this;
40
+ delete(value: T): boolean;
41
+ has(value: T): boolean;
42
+ entries(): IterableIterator<[T, T]>;
43
+ keys(): IterableIterator<T>;
44
+ values(): IterableIterator<T>;
45
+ replace(other: ObservableSet<T> | IObservableSetInitialValues<T>): ObservableSet<T>;
46
+ observe_(listener: (changes: ISetDidChange<T>) => void, fireImmediately?: boolean): Lambda;
47
+ intercept_(handler: IInterceptor<ISetWillChange<T>>): Lambda;
48
+ toJSON(): T[];
49
+ toString(): string;
50
+ [Symbol.iterator](): IterableIterator<T>;
51
+ get [Symbol.toStringTag](): string;
52
+ }
53
+ export declare var isObservableSet: (thing: any) => thing is ObservableSet<any>;
@@ -1,49 +1,49 @@
1
- import { Atom, IEnhancer, IInterceptable, IEqualsComparer, IInterceptor, IListenable, Lambda } from "../internal";
2
- export interface IValueWillChange<T> {
3
- object: IObservableValue<T>;
4
- type: "update";
5
- newValue: T;
6
- }
7
- export declare type IValueDidChange<T = any> = {
8
- type: "update";
9
- observableKind: "value";
10
- object: IObservableValue<T>;
11
- debugObjectName: string;
12
- newValue: T;
13
- oldValue: T | undefined;
14
- };
15
- export declare type IBoxDidChange<T = any> = {
16
- type: "create";
17
- observableKind: "value";
18
- object: IObservableValue<T>;
19
- debugObjectName: string;
20
- newValue: T;
21
- } | IValueDidChange<T>;
22
- export interface IObservableValue<T> {
23
- get(): T;
24
- set(value: T): void;
25
- }
26
- export declare class ObservableValue<T> extends Atom implements IObservableValue<T>, IInterceptable<IValueWillChange<T>>, IListenable {
27
- enhancer: IEnhancer<T>;
28
- name_: string;
29
- private equals;
30
- hasUnreportedChange_: boolean;
31
- interceptors_: any;
32
- changeListeners_: any;
33
- value_: any;
34
- dehancer: any;
35
- constructor(value: T, enhancer: IEnhancer<T>, name_?: string, notifySpy?: boolean, equals?: IEqualsComparer<any>);
36
- private dehanceValue;
37
- set(newValue: T): void;
38
- private prepareNewValue_;
39
- setNewValue_(newValue: T): void;
40
- get(): T;
41
- intercept_(handler: IInterceptor<IValueWillChange<T>>): Lambda;
42
- observe_(listener: (change: IValueDidChange<T>) => void, fireImmediately?: boolean): Lambda;
43
- raw(): any;
44
- toJSON(): T;
45
- toString(): string;
46
- valueOf(): T;
47
- [Symbol.toPrimitive](): T;
48
- }
49
- export declare const isObservableValue: (x: any) => x is IObservableValue<any>;
1
+ import { Atom, IEnhancer, IInterceptable, IEqualsComparer, IInterceptor, IListenable, Lambda } from "../internal";
2
+ export interface IValueWillChange<T> {
3
+ object: IObservableValue<T>;
4
+ type: "update";
5
+ newValue: T;
6
+ }
7
+ export type IValueDidChange<T = any> = {
8
+ type: "update";
9
+ observableKind: "value";
10
+ object: IObservableValue<T>;
11
+ debugObjectName: string;
12
+ newValue: T;
13
+ oldValue: T | undefined;
14
+ };
15
+ export type IBoxDidChange<T = any> = {
16
+ type: "create";
17
+ observableKind: "value";
18
+ object: IObservableValue<T>;
19
+ debugObjectName: string;
20
+ newValue: T;
21
+ } | IValueDidChange<T>;
22
+ export interface IObservableValue<T> {
23
+ get(): T;
24
+ set(value: T): void;
25
+ }
26
+ export declare class ObservableValue<T> extends Atom implements IObservableValue<T>, IInterceptable<IValueWillChange<T>>, IListenable {
27
+ enhancer: IEnhancer<T>;
28
+ name_: string;
29
+ private equals;
30
+ hasUnreportedChange_: boolean;
31
+ interceptors_: any;
32
+ changeListeners_: any;
33
+ value_: any;
34
+ dehancer: any;
35
+ constructor(value: T, enhancer: IEnhancer<T>, name_?: string, notifySpy?: boolean, equals?: IEqualsComparer<any>);
36
+ private dehanceValue;
37
+ set(newValue: T): void;
38
+ private prepareNewValue_;
39
+ setNewValue_(newValue: T): void;
40
+ get(): T;
41
+ intercept_(handler: IInterceptor<IValueWillChange<T>>): Lambda;
42
+ observe_(listener: (change: IValueDidChange<T>) => void, fireImmediately?: boolean): Lambda;
43
+ raw(): any;
44
+ toJSON(): T;
45
+ toString(): string;
46
+ valueOf(): T;
47
+ [Symbol.toPrimitive](): T;
48
+ }
49
+ export declare const isObservableValue: (x: any) => x is IObservableValue<any>;
@@ -1,3 +1,4 @@
1
- import { Annotation } from "../internal";
2
- export declare const override: Annotation & PropertyDecorator;
3
- export declare function isOverride(annotation: Annotation): boolean;
1
+ import { Annotation } from "../internal";
2
+ import type { ClassMethodDecorator } from "./decorator_fills";
3
+ export declare const override: Annotation & PropertyDecorator & ClassMethodDecorator;
4
+ export declare function isOverride(annotation: Annotation): boolean;
@@ -1,11 +1,11 @@
1
- import { IDepTreeNode } from "../internal";
2
- export declare function getAtom(thing: any, property?: PropertyKey): IDepTreeNode;
3
- export declare function getAdministration(thing: any, property?: string): any;
4
- export declare function getDebugName(thing: any, property?: string): string;
5
- /**
6
- * Helper function for initializing observable structures, it applies:
7
- * 1. allowStateChanges so we don't violate enforceActions.
8
- * 2. untracked so we don't accidentaly subscribe to anything observable accessed during init in case the observable is created inside derivation.
9
- * 3. batch to avoid state version updates
10
- */
11
- export declare function initObservable<T>(cb: () => T): T;
1
+ import { IDepTreeNode } from "../internal";
2
+ export declare function getAtom(thing: any, property?: PropertyKey): IDepTreeNode;
3
+ export declare function getAdministration(thing: any, property?: string): any;
4
+ export declare function getDebugName(thing: any, property?: string): string;
5
+ /**
6
+ * Helper function for initializing observable structures, it applies:
7
+ * 1. allowStateChanges so we don't violate enforceActions.
8
+ * 2. untracked so we don't accidentaly subscribe to anything observable accessed during init in case the observable is created inside derivation.
9
+ * 3. batch to avoid state version updates
10
+ */
11
+ export declare function initObservable<T>(cb: () => T): T;
@@ -1,14 +1,14 @@
1
- export interface IEqualsComparer<T> {
2
- (a: T, b: T): boolean;
3
- }
4
- declare function identityComparer(a: any, b: any): boolean;
5
- declare function structuralComparer(a: any, b: any): boolean;
6
- declare function shallowComparer(a: any, b: any): boolean;
7
- declare function defaultComparer(a: any, b: any): boolean;
8
- export declare const comparer: {
9
- identity: typeof identityComparer;
10
- structural: typeof structuralComparer;
11
- default: typeof defaultComparer;
12
- shallow: typeof shallowComparer;
13
- };
14
- export {};
1
+ export interface IEqualsComparer<T> {
2
+ (a: T, b: T): boolean;
3
+ }
4
+ declare function identityComparer(a: any, b: any): boolean;
5
+ declare function structuralComparer(a: any, b: any): boolean;
6
+ declare function shallowComparer(a: any, b: any): boolean;
7
+ declare function defaultComparer(a: any, b: any): boolean;
8
+ export declare const comparer: {
9
+ identity: typeof identityComparer;
10
+ structural: typeof structuralComparer;
11
+ default: typeof defaultComparer;
12
+ shallow: typeof shallowComparer;
13
+ };
14
+ export {};
@@ -1 +1 @@
1
- export declare function deepEqual(a: any, b: any, depth?: number): boolean;
1
+ export declare function deepEqual(a: any, b: any, depth?: number): boolean;
@@ -1 +1 @@
1
- export declare function getGlobal(): any;
1
+ export declare function getGlobal(): any;
@@ -1 +1 @@
1
- export declare function makeIterable<T>(iterator: Iterator<T>): IterableIterator<T>;
1
+ export declare function makeIterable<T>(iterator: Iterator<T>): IterableIterator<T>;
@@ -1,45 +1,45 @@
1
- export declare const assign: {
2
- <T, U>(target: T, source: U): T & U;
3
- <T_1, U_1, V>(target: T_1, source1: U_1, source2: V): T_1 & U_1 & V;
4
- <T_2, U_2, V_1, W>(target: T_2, source1: U_2, source2: V_1, source3: W): T_2 & U_2 & V_1 & W;
5
- (target: object, ...sources: any[]): any;
6
- };
7
- export declare const getDescriptor: (o: any, p: PropertyKey) => PropertyDescriptor | undefined;
8
- export declare const defineProperty: <T>(o: T, p: PropertyKey, attributes: PropertyDescriptor & ThisType<any>) => T;
9
- export declare const objectPrototype: Object;
10
- export declare const EMPTY_ARRAY: never[];
11
- export declare const EMPTY_OBJECT: {};
12
- export interface Lambda {
13
- (): void;
14
- name?: string;
15
- }
16
- export declare function assertProxies(): void;
17
- export declare function warnAboutProxyRequirement(msg: string): void;
18
- export declare function getNextId(): number;
19
- /**
20
- * Makes sure that the provided function is invoked at most once.
21
- */
22
- export declare function once(func: Lambda): Lambda;
23
- export declare const noop: () => void;
24
- export declare function isFunction(fn: any): fn is Function;
25
- export declare function isString(value: any): value is string;
26
- export declare function isStringish(value: any): value is string | number | symbol;
27
- export declare function isObject(value: any): value is Object;
28
- export declare function isPlainObject(value: any): boolean;
29
- export declare function isGenerator(obj: any): boolean;
30
- export declare function addHiddenProp(object: any, propName: PropertyKey, value: any): void;
31
- export declare function addHiddenFinalProp(object: any, propName: PropertyKey, value: any): void;
32
- export declare function createInstanceofPredicate<T>(name: string, theClass: new (...args: any[]) => T): (x: any) => x is T;
33
- export declare function isES6Map(thing: any): thing is Map<any, any>;
34
- export declare function isES6Set(thing: any): thing is Set<any>;
35
- /**
36
- * Returns the following: own enumerable keys and symbols.
37
- */
38
- export declare function getPlainObjectKeys(object: any): (string | symbol)[];
39
- export declare const ownKeys: (target: any) => Array<string | symbol>;
40
- export declare function stringifyKey(key: any): string;
41
- export declare function toPrimitive(value: any): any;
42
- export declare function hasProp(target: Object, prop: PropertyKey): boolean;
43
- export declare const getOwnPropertyDescriptors: <T>(o: T) => { [P in keyof T]: TypedPropertyDescriptor<T[P]>; } & {
44
- [x: string]: PropertyDescriptor;
45
- };
1
+ export declare const assign: {
2
+ <T extends {}, U>(target: T, source: U): T & U;
3
+ <T_1 extends {}, U_1, V>(target: T_1, source1: U_1, source2: V): T_1 & U_1 & V;
4
+ <T_2 extends {}, U_2, V_1, W>(target: T_2, source1: U_2, source2: V_1, source3: W): T_2 & U_2 & V_1 & W;
5
+ (target: object, ...sources: any[]): any;
6
+ };
7
+ export declare const getDescriptor: (o: any, p: PropertyKey) => PropertyDescriptor | undefined;
8
+ export declare const defineProperty: <T>(o: T, p: PropertyKey, attributes: PropertyDescriptor & ThisType<any>) => T;
9
+ export declare const objectPrototype: Object;
10
+ export declare const EMPTY_ARRAY: never[];
11
+ export declare const EMPTY_OBJECT: {};
12
+ export interface Lambda {
13
+ (): void;
14
+ name?: string;
15
+ }
16
+ export declare function assertProxies(): void;
17
+ export declare function warnAboutProxyRequirement(msg: string): void;
18
+ export declare function getNextId(): number;
19
+ /**
20
+ * Makes sure that the provided function is invoked at most once.
21
+ */
22
+ export declare function once(func: Lambda): Lambda;
23
+ export declare const noop: () => void;
24
+ export declare function isFunction(fn: any): fn is Function;
25
+ export declare function isString(value: any): value is string;
26
+ export declare function isStringish(value: any): value is string | number | symbol;
27
+ export declare function isObject(value: any): value is Object;
28
+ export declare function isPlainObject(value: any): boolean;
29
+ export declare function isGenerator(obj: any): boolean;
30
+ export declare function addHiddenProp(object: any, propName: PropertyKey, value: any): void;
31
+ export declare function addHiddenFinalProp(object: any, propName: PropertyKey, value: any): void;
32
+ export declare function createInstanceofPredicate<T>(name: string, theClass: new (...args: any[]) => T): (x: any) => x is T;
33
+ export declare function isES6Map(thing: any): thing is Map<any, any>;
34
+ export declare function isES6Set(thing: any): thing is Set<any>;
35
+ /**
36
+ * Returns the following: own enumerable keys and symbols.
37
+ */
38
+ export declare function getPlainObjectKeys(object: any): (string | symbol)[];
39
+ export declare const ownKeys: (target: any) => Array<string | symbol>;
40
+ export declare function stringifyKey(key: any): string;
41
+ export declare function toPrimitive(value: any): any;
42
+ export declare function hasProp(target: Object, prop: PropertyKey): boolean;
43
+ export declare const getOwnPropertyDescriptors: <T>(o: T) => { [P in keyof T]: TypedPropertyDescriptor<T[P]>; } & {
44
+ [x: string]: PropertyDescriptor;
45
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobx",
3
- "version": "6.10.2",
3
+ "version": "6.11.0",
4
4
  "description": "Simple, scalable state management.",
5
5
  "source": "src/mobx.ts",
6
6
  "main": "dist/index.js",
package/src/api/action.ts CHANGED
@@ -7,9 +7,12 @@ import {
7
7
  isFunction,
8
8
  isStringish,
9
9
  createDecoratorAnnotation,
10
- createActionAnnotation
10
+ createActionAnnotation,
11
+ is20223Decorator
11
12
  } from "../internal"
12
13
 
14
+ import type { ClassFieldDecorator, ClassMethodDecorator } from "../types/decorator_fills"
15
+
13
16
  export const ACTION = "action"
14
17
  export const ACTION_BOUND = "action.bound"
15
18
  export const AUTOACTION = "autoAction"
@@ -29,17 +32,24 @@ const autoActionBoundAnnotation = createActionAnnotation(AUTOACTION_BOUND, {
29
32
  bound: true
30
33
  })
31
34
 
32
- export interface IActionFactory extends Annotation, PropertyDecorator {
35
+ export interface IActionFactory
36
+ extends Annotation,
37
+ PropertyDecorator,
38
+ ClassMethodDecorator,
39
+ ClassFieldDecorator {
33
40
  // nameless actions
34
41
  <T extends Function | undefined | null>(fn: T): T
35
42
  // named actions
36
43
  <T extends Function | undefined | null>(name: string, fn: T): T
37
44
 
38
45
  // named decorator
39
- (customName: string): PropertyDecorator & Annotation
46
+ (customName: string): PropertyDecorator &
47
+ Annotation &
48
+ ClassMethodDecorator &
49
+ ClassFieldDecorator
40
50
 
41
51
  // decorator (name no longer supported)
42
- bound: Annotation & PropertyDecorator
52
+ bound: Annotation & PropertyDecorator & ClassMethodDecorator & ClassFieldDecorator
43
53
  }
44
54
 
45
55
  function createActionFactory(autoAction: boolean): IActionFactory {
@@ -52,6 +62,13 @@ function createActionFactory(autoAction: boolean): IActionFactory {
52
62
  if (isFunction(arg2)) {
53
63
  return createAction(arg1, arg2, autoAction)
54
64
  }
65
+ // @action (2022.3 Decorators)
66
+ if (is20223Decorator(arg2)) {
67
+ return (autoAction ? autoActionAnnotation : actionAnnotation).decorate_20223_(
68
+ arg1,
69
+ arg2
70
+ )
71
+ }
55
72
  // @action
56
73
  if (isStringish(arg2)) {
57
74
  return storeAnnotation(arg1, arg2, autoAction ? autoActionAnnotation : actionAnnotation)
@@ -20,6 +20,7 @@ export type Annotation = {
20
20
  descriptor: PropertyDescriptor,
21
21
  proxyTrap: boolean
22
22
  ): boolean | null
23
+ decorate_20223_(value: any, context: DecoratorContext)
23
24
  options_?: any
24
25
  }
25
26