mobx 6.16.1 → 7.0.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 (98) hide show
  1. package/CHANGELOG.md +72 -0
  2. package/README.md +9 -13
  3. package/dist/api/action.d.ts +6 -4
  4. package/dist/api/annotation.d.ts +0 -1
  5. package/dist/api/computed.d.ts +4 -7
  6. package/dist/api/configure.d.ts +0 -1
  7. package/dist/api/decoratorannotation.d.ts +3 -0
  8. package/dist/api/decorators.d.ts +0 -19
  9. package/dist/api/flow.d.ts +4 -5
  10. package/dist/api/makeObservable.d.ts +2 -3
  11. package/dist/api/observable.d.ts +9 -15
  12. package/dist/core/atom.d.ts +0 -3
  13. package/dist/core/computedvalue.d.ts +4 -32
  14. package/dist/core/derivation.d.ts +1 -7
  15. package/dist/core/globalstate.d.ts +0 -2
  16. package/dist/core/reaction.d.ts +1 -9
  17. package/dist/errors.d.ts +6 -4
  18. package/dist/internal.d.ts +1 -4
  19. package/dist/mobx.cjs.development.js +1630 -2447
  20. package/dist/mobx.cjs.development.js.map +1 -1
  21. package/dist/mobx.cjs.production.min.js +1 -1
  22. package/dist/mobx.cjs.production.min.js.map +1 -1
  23. package/dist/mobx.d.ts +2 -2
  24. package/dist/mobx.esm.development.js +1619 -2446
  25. package/dist/mobx.esm.development.js.map +1 -1
  26. package/dist/mobx.esm.js +1567 -2397
  27. package/dist/mobx.esm.js.map +1 -1
  28. package/dist/mobx.esm.production.min.js +1 -1
  29. package/dist/mobx.esm.production.min.js.map +1 -1
  30. package/dist/mobx.mjs +5271 -0
  31. package/dist/mobx.mjs.map +1 -0
  32. package/dist/mobx.umd.development.js +1633 -2450
  33. package/dist/mobx.umd.development.js.map +1 -1
  34. package/dist/mobx.umd.production.min.js +1 -1
  35. package/dist/mobx.umd.production.min.js.map +1 -1
  36. package/dist/types/actionannotation.d.ts +1 -0
  37. package/dist/types/computedannotation.d.ts +1 -0
  38. package/dist/types/decorator_fills.d.ts +2 -0
  39. package/dist/types/flowannotation.d.ts +1 -0
  40. package/dist/types/observableannotation.d.ts +5 -0
  41. package/dist/types/observablearray.d.ts +2 -5
  42. package/dist/types/observablemap.d.ts +1 -8
  43. package/dist/types/observableobject.d.ts +2 -13
  44. package/dist/types/observableset.d.ts +1 -3
  45. package/dist/types/observablevalue.d.ts +4 -6
  46. package/dist/types/overrideannotation.d.ts +1 -2
  47. package/dist/utils/comparer.d.ts +4 -11
  48. package/dist/utils/utils.d.ts +0 -2
  49. package/package.json +25 -15
  50. package/src/api/action.ts +27 -35
  51. package/src/api/annotation.ts +0 -1
  52. package/src/api/autorun.ts +2 -4
  53. package/src/api/computed.ts +21 -28
  54. package/src/api/configure.ts +1 -15
  55. package/src/api/decoratorannotation.ts +20 -0
  56. package/src/api/decorators.ts +1 -85
  57. package/src/api/extras.ts +1 -1
  58. package/src/api/flow.ts +26 -29
  59. package/src/api/intercept.ts +4 -3
  60. package/src/api/makeObservable.ts +45 -17
  61. package/src/api/object-api.ts +1 -1
  62. package/src/api/observable.ts +34 -67
  63. package/src/api/observe.ts +82 -3
  64. package/src/api/when.ts +4 -3
  65. package/src/core/action.ts +12 -5
  66. package/src/core/atom.ts +14 -13
  67. package/src/core/computedvalue.ts +27 -67
  68. package/src/core/derivation.ts +15 -14
  69. package/src/core/globalstate.ts +8 -13
  70. package/src/core/observable.ts +0 -48
  71. package/src/core/reaction.ts +19 -25
  72. package/src/core/spy.ts +3 -3
  73. package/src/errors.ts +23 -12
  74. package/src/internal.ts +1 -4
  75. package/src/mobx.ts +21 -10
  76. package/src/types/actionannotation.ts +5 -9
  77. package/src/types/autoannotation.ts +8 -11
  78. package/src/types/computedannotation.ts +13 -11
  79. package/src/types/decorator_fills.ts +4 -0
  80. package/src/types/dynamicobject.ts +0 -29
  81. package/src/types/flowannotation.ts +7 -4
  82. package/src/types/observableannotation.ts +6 -7
  83. package/src/types/observablearray.ts +8 -61
  84. package/src/types/observablemap.ts +4 -29
  85. package/src/types/observableobject.ts +5 -70
  86. package/src/types/observableset.ts +5 -28
  87. package/src/types/observablevalue.ts +7 -29
  88. package/src/types/overrideannotation.ts +7 -22
  89. package/src/types/type-utils.ts +4 -2
  90. package/src/utils/comparer.ts +4 -17
  91. package/src/utils/iterable.ts +3 -4
  92. package/src/utils/utils.ts +4 -46
  93. package/dist/api/trace.d.ts +0 -3
  94. package/dist/types/legacyobservablearray.d.ts +0 -14
  95. package/dist/utils/global.d.ts +0 -1
  96. package/src/api/trace.ts +0 -35
  97. package/src/types/legacyobservablearray.ts +0 -155
  98. package/src/utils/global.ts +0 -20
package/CHANGELOG.md CHANGED
@@ -1,5 +1,77 @@
1
1
  # mobx
2
2
 
3
+ ## 7.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - [`1926c69f53168619d688f348aa587e8f3ae579ae`](https://github.com/mobxjs/mobx/commit/1926c69f53168619d688f348aa587e8f3ae579ae) [#4671](https://github.com/mobxjs/mobx/pull/4671) Thanks [@kubk](https://github.com/kubk)! - Release MobX 7, mobx-react-lite 5, and mobx-react 10.
8
+
9
+ Bundle sizes are down: ESM prod 17.02 KiB gzip -> 13.96 KiB gzip; a minimal tree-shaken example is 10.32 KiB gzip now.
10
+
11
+ It removes long-deprecated compatibility paths and keeps the React bindings split between `mobx-react-lite` for function components and `mobx-react` for class-component support.
12
+
13
+ ## MobX 7
14
+
15
+ MobX 7 is a cleanup release focused on the modern runtime and decorator model.
16
+
17
+ - MobX now always uses Proxy-backed observable objects and arrays. The ES5/non-proxy fallback has been removed.
18
+ - `configure({ useProxies: ... })` is no longer supported.
19
+ - `{ proxy: false }` options for `observable`, `observable.object`, and `observable.array` are no longer supported.
20
+ - Legacy decorators are no longer supported.
21
+ - Namespaced annotation and comparer properties now use named exports to reduce bundle size:
22
+
23
+ | Removed API | Replacement |
24
+ | --------------------- | ------------------- |
25
+ | `observable.ref` | `observableRef` |
26
+ | `observable.shallow` | `observableShallow` |
27
+ | `observable.deep` | `observableDeep` |
28
+ | `observable.struct` | `observableStruct` |
29
+ | `computed.struct` | `computedStruct` |
30
+ | `action.bound` | `actionBound` |
31
+ | `flow.bound` | `flowBound` |
32
+ | `comparer.identity` | `compareIdentity` |
33
+ | `comparer.default` | `compareDefault` |
34
+ | `comparer.structural` | `compareStructural` |
35
+ | `comparer.shallow` | `compareShallow` |
36
+
37
+ - The public `trace` API and its related runtime support have been removed. Use `toJS`, `getDependencyTree`, `getObserverTree`, `spy` or `mobx-log` package for debugging.
38
+
39
+ ## mobx-react-lite 5 and mobx-react 10
40
+
41
+ mobx-react-lite 5 and mobx-react 10 require MobX 7 and React 18 or later.
42
+
43
+ `mobx-react-lite` remains the function-component package. `mobx-react` remains a thin wrapper around `mobx-react-lite` that adds class component and Stage 3 `@observer` class decorator support.
44
+
45
+ - Keep function-component imports on `mobx-react-lite` if you do not need class component support.
46
+ - Use `mobx-react` when you need class components or `@observer` class decorators.
47
+ - `mobx-react-lite` supports function components and `forwardRef`; `mobx-react` delegates function components to `mobx-react-lite` and handles classes itself.
48
+ - Remove React batching imports, including the stale React Native batching deep import. React 18+ renderers handle batching.
49
+
50
+ The recommended public React binding surface for both packages is:
51
+
52
+ - `observer`
53
+ - `Observer`
54
+ - `useLocalObservable`
55
+ - `enableStaticRendering`
56
+ - `isUsingStaticRendering`
57
+
58
+ The following APIs have been removed from the React binding packages:
59
+
60
+ - `Provider`, `inject`, and `MobXProviderContext`; use `React.createContext` directly.
61
+ - `disposeOnUnmount`; dispose reactions in `componentWillUnmount` or return cleanup functions from `useEffect`.
62
+ - `PropTypes`; use TypeScript or the regular `prop-types` package.
63
+ - `useObserver`; wrap components with `observer` or use `<Observer>`.
64
+ - `useLocalStore`; use `useLocalObservable`.
65
+ - `useAsObservableSource`; synchronize values from props into local observable state explicitly.
66
+ - `useStaticRendering`; use `enableStaticRendering`.
67
+ - `observerBatching`, `isObserverBatched`, `batchingForReactDom`, `batchingOptOut`, and `batchingForReactNative`; remove these imports because React 18+ renderers handle batching.
68
+ - Deprecated `observer(fn, { forwardRef: true })`; pass an already-created `React.forwardRef(...)` component to `observer` instead.
69
+ - Legacy function-component `contextTypes` handling.
70
+
71
+ ### Patch Changes
72
+
73
+ - [`979d267d569734dc3cb969ed1880ed68bb79f1b5`](https://github.com/mobxjs/mobx/commit/979d267d569734dc3cb969ed1880ed68bb79f1b5) [#4677](https://github.com/mobxjs/mobx/pull/4677) Thanks [@kubk](https://github.com/kubk)! - Shorten minified error URL to reduce production bundle size.
74
+
3
75
  ## 6.16.1
4
76
 
5
77
  ### Patch Changes
package/README.md CHANGED
@@ -114,19 +114,15 @@ import { makeAutoObservable } from "mobx"
114
114
  import { observer } from "mobx-react-lite"
115
115
 
116
116
  // Model the application state.
117
- function createTimer() {
118
- return makeAutoObservable({
119
- secondsPassed: 0,
120
- increase() {
121
- this.secondsPassed += 1
122
- },
123
- reset() {
124
- this.secondsPassed = 0
125
- }
126
- })
127
- }
128
-
129
- const myTimer = createTimer()
117
+ const myTimer = makeAutoObservable({
118
+ secondsPassed: 0,
119
+ increase() {
120
+ this.secondsPassed += 1
121
+ },
122
+ reset() {
123
+ this.secondsPassed = 0
124
+ }
125
+ })
130
126
 
131
127
  // Build a "user interface" that uses the observable state.
132
128
  const TimerView = observer(({ timer }) => (
@@ -1,16 +1,18 @@
1
1
  import { Annotation } from "../internal";
2
- import type { ClassFieldDecorator, ClassMethodDecorator } from "../types/decorator_fills";
2
+ import { type DecoratorAnnotation } from "./decoratorannotation";
3
+ import type { ClassMethodAndFieldDecorator } from "../types/decorator_fills";
3
4
  export declare const ACTION = "action";
4
5
  export declare const ACTION_BOUND = "action.bound";
5
6
  export declare const AUTOACTION = "autoAction";
6
7
  export declare const AUTOACTION_BOUND = "autoAction.bound";
7
- export interface IActionFactory extends Annotation, PropertyDecorator, ClassMethodDecorator, ClassFieldDecorator {
8
+ export interface IActionFactory extends Annotation, ClassMethodAndFieldDecorator {
8
9
  <T extends Function | undefined | null>(fn: T): T;
9
10
  <T extends Function | undefined | null>(name: string, fn: T): T;
10
- (customName: string): PropertyDecorator & Annotation & ClassMethodDecorator & ClassFieldDecorator;
11
- bound: Annotation & PropertyDecorator & ClassMethodDecorator & ClassFieldDecorator;
11
+ (customName: string): DecoratorAnnotation<ClassMethodAndFieldDecorator>;
12
12
  }
13
13
  export declare const action: IActionFactory;
14
14
  export declare const autoAction: IActionFactory;
15
+ export declare const actionBound: DecoratorAnnotation<ClassMethodAndFieldDecorator>;
16
+ export declare const autoActionBound: DecoratorAnnotation<ClassMethodAndFieldDecorator>;
15
17
  export declare function runInAction<T>(fn: () => T): T;
16
18
  export declare function isAction(thing: any): boolean;
@@ -8,7 +8,6 @@ export type Annotation = {
8
8
  annotationType_: string;
9
9
  make_(adm: ObservableObjectAdministration, key: PropertyKey, descriptor: PropertyDescriptor, source: object): MakeResult;
10
10
  extend_(adm: ObservableObjectAdministration, key: PropertyKey, descriptor: PropertyDescriptor, proxyTrap: boolean): boolean | null;
11
- decorate_20223_(value: any, context: DecoratorContext): any;
12
11
  options_?: any;
13
12
  };
14
13
  export type AnnotationMapEntry = Annotation | true | false;
@@ -1,14 +1,11 @@
1
1
  import { IComputedValueOptions, Annotation, IComputedValue } from "../internal";
2
+ import { type DecoratorAnnotation } from "./decoratorannotation";
2
3
  import type { ClassGetterDecorator } from "../types/decorator_fills";
3
4
  export declare const COMPUTED = "computed";
4
5
  export declare const COMPUTED_STRUCT = "computed.struct";
5
- export interface IComputedFactory extends Annotation, PropertyDecorator, ClassGetterDecorator {
6
- <T>(options: IComputedValueOptions<T>): Annotation & PropertyDecorator & ClassGetterDecorator;
6
+ export interface IComputedFactory extends Annotation, ClassGetterDecorator {
7
+ <T>(options: IComputedValueOptions<T>): DecoratorAnnotation<ClassGetterDecorator>;
7
8
  <T>(func: () => T, options?: IComputedValueOptions<T>): IComputedValue<T>;
8
- struct: Annotation & PropertyDecorator & ClassGetterDecorator;
9
9
  }
10
- /**
11
- * Decorator for class properties: @computed get value() { return expr; }.
12
- * For legacy purposes also invokable as ES5 observable created: `computed(() => expr)`;
13
- */
10
+ export declare const computedStruct: DecoratorAnnotation<ClassGetterDecorator>;
14
11
  export declare const computed: IComputedFactory;
@@ -13,5 +13,4 @@ export declare function configure(options: {
13
13
  disableErrorBoundaries?: boolean;
14
14
  safeDescriptors?: boolean;
15
15
  reactionScheduler?: (f: () => void) => void;
16
- useProxies?: "always" | "never" | "ifavailable";
17
16
  }): void;
@@ -0,0 +1,3 @@
1
+ import type { Annotation } from "./annotation";
2
+ export type DecoratorAnnotation<Decorator extends (...args: any[]) => any> = Annotation & Decorator;
3
+ export declare function createDecoratorAnnotation<Decorator extends (...args: any[]) => any>(annotation: Annotation, decorate: (annotation: Annotation, value: any, context: any) => any): DecoratorAnnotation<Decorator>;
@@ -1,20 +1 @@
1
- import { Annotation, AnnotationsMap } from "../internal";
2
- import type { Decorator } from "../types/decorator_fills";
3
- export declare const storedAnnotationsSymbol: unique symbol;
4
- /**
5
- * Creates a function that acts as
6
- * - decorator
7
- * - annotation object
8
- */
9
- export declare function createDecoratorAnnotation<D extends Decorator = Decorator>(annotation: Annotation): PropertyDecorator & Annotation & D;
10
- /**
11
- * Stores annotation to prototype,
12
- * so it can be inspected later by `makeObservable` called from constructor
13
- */
14
- export declare function storeAnnotation(prototype: any, key: PropertyKey, annotation: Annotation): void;
15
- /**
16
- * Collects annotations from prototypes and stores them on target (instance)
17
- */
18
- export declare function collectStoredAnnotations(target: any): AnnotationsMap<any, any>;
19
- export declare function is20223Decorator(context: any): context is DecoratorContext;
20
1
  export declare function assert20223DecoratorType(context: DecoratorContext, types: DecoratorContext["kind"][]): void;
@@ -1,4 +1,5 @@
1
1
  import { Annotation } from "../internal";
2
+ import { type DecoratorAnnotation } from "./decoratorannotation";
2
3
  import type { ClassMethodDecorator } from "../types/decorator_fills";
3
4
  export declare const FLOW = "flow";
4
5
  export declare class FlowCancellationError extends Error {
@@ -9,13 +10,11 @@ export declare function isFlowCancellationError(error: Error): error is FlowCanc
9
10
  export type CancellablePromise<T> = Promise<T> & {
10
11
  cancel(): void;
11
12
  };
12
- type FlowGenerator = (...args: any[]) => Generator<any, any, any> | AsyncGenerator<any, any, any>;
13
- interface Flow extends Annotation, PropertyDecorator {
14
- <This, Value extends FlowGenerator>(value: Value, context: ClassMethodDecoratorContext<This, Value>): Value | void;
15
- <R, Args extends any[]>(generator: (...args: Args) => Generator<any, R, any> | AsyncGenerator<any, R, any>): (...args: Args) => CancellablePromise<R>;
16
- bound: Annotation & PropertyDecorator & ClassMethodDecorator;
13
+ interface Flow extends Annotation, ClassMethodDecorator {
14
+ <R, Args extends any[]>(generator: (...args: Args) => Generator<any, R, any> | AsyncGenerator<any, R, any>, context?: never): (...args: Args) => CancellablePromise<R>;
17
15
  }
18
16
  export declare const flow: Flow;
17
+ export declare const flowBound: DecoratorAnnotation<ClassMethodDecorator>;
19
18
  export declare function flowResult<T>(result: T): T extends Generator<any, infer R, any> ? CancellablePromise<R> : T extends CancellablePromise<any> ? T : never;
20
19
  export declare function isFlow(fn: any): boolean;
21
20
  export {};
@@ -1,6 +1,5 @@
1
1
  import { AnnotationsMap, CreateObservableOptions } from "../internal";
2
2
  type NoInfer<T> = [T][T extends any ? 0 : never];
3
- type MakeObservableOptions = Omit<CreateObservableOptions, "proxy">;
4
- export declare function makeObservable<T extends object, AdditionalKeys extends PropertyKey = never>(target: T, annotations?: AnnotationsMap<T, NoInfer<AdditionalKeys>>, options?: MakeObservableOptions): T;
5
- export declare function makeAutoObservable<T extends object, AdditionalKeys extends PropertyKey = never>(target: T, overrides?: AnnotationsMap<T, NoInfer<AdditionalKeys>>, options?: MakeObservableOptions): T;
3
+ export declare function makeObservable<T extends object, AdditionalKeys extends PropertyKey = never>(target: T, annotations: AnnotationsMap<T, NoInfer<AdditionalKeys>>, options?: CreateObservableOptions): T;
4
+ export declare function makeAutoObservable<T extends object, AdditionalKeys extends PropertyKey = never>(target: T, overrides?: AnnotationsMap<T, NoInfer<AdditionalKeys>>, options?: CreateObservableOptions): T;
6
5
  export {};
@@ -1,5 +1,6 @@
1
1
  import { IEnhancer, IEqualsComparer, IObservableArray, IMapEntries, IReadonlyMapEntries, IKeyValueMap, IObservableSetInitialValues, IObservableValue, ObservableMap, ObservableSet, Annotation, AnnotationsMap } from "../internal";
2
- import type { ClassAccessorDecorator, ClassFieldDecorator } from "../types/decorator_fills";
2
+ import { type DecoratorAnnotation } from "./decoratorannotation";
3
+ import type { ClassAccessorAndFieldDecorator } from "../types/decorator_fills";
3
4
  export declare const OBSERVABLE = "observable";
4
5
  export declare const OBSERVABLE_REF = "observable.ref";
5
6
  export declare const OBSERVABLE_SHALLOW = "observable.shallow";
@@ -9,7 +10,6 @@ export type CreateObservableOptions = {
9
10
  equals?: IEqualsComparer<any>;
10
11
  deep?: boolean;
11
12
  defaultDecorator?: Annotation;
12
- proxy?: boolean;
13
13
  autoBind?: boolean;
14
14
  };
15
15
  export declare const defaultCreateObservableOptions: CreateObservableOptions;
@@ -29,25 +29,19 @@ export interface IObservableMapFactory {
29
29
  <K, V>(initialValues?: Map<K, V>, options?: CreateObservableOptions): ObservableMap<K, V>;
30
30
  <K = any, V = any>(initialValues: undefined, options?: CreateObservableOptions): ObservableMap<K, V>;
31
31
  }
32
- export interface IObservableFactory extends Annotation, PropertyDecorator, ClassAccessorDecorator, ClassFieldDecorator {
32
+ export interface IObservableFactory extends Annotation, ClassAccessorAndFieldDecorator {
33
33
  <T = any>(value: T[], options?: CreateObservableOptions): IObservableArray<T>;
34
34
  <T = any>(value: Set<T>, options?: CreateObservableOptions): ObservableSet<T>;
35
35
  <K = any, V = any>(value: Map<K, V>, options?: CreateObservableOptions): ObservableMap<K, V>;
36
- <T extends object>(value: T, decorators?: AnnotationsMap<T, never>, options?: CreateObservableOptions): T;
36
+ <T extends object>(value: T, annotations?: AnnotationsMap<T, never>, options?: CreateObservableOptions): T;
37
37
  box: IObservableValueFactory;
38
38
  array: <T = any>(initialValues?: T[], options?: CreateObservableOptions) => IObservableArray<T>;
39
39
  set: <T = any>(initialValues?: IObservableSetInitialValues<T>, options?: CreateObservableOptions) => ObservableSet<T>;
40
40
  map: IObservableMapFactory;
41
- object: <T = any>(props: T, decorators?: AnnotationsMap<T, never>, options?: CreateObservableOptions) => T;
42
- /**
43
- * Decorator that creates an observable that only observes the references, but doesn't try to turn the assigned value into an observable.ts.
44
- */
45
- ref: Annotation & PropertyDecorator & ClassAccessorDecorator & ClassFieldDecorator;
46
- /**
47
- * Decorator that creates an observable converts its value (objects, maps or arrays) into a shallow observable structure
48
- */
49
- shallow: Annotation & PropertyDecorator & ClassAccessorDecorator & ClassFieldDecorator;
50
- deep: Annotation & PropertyDecorator & ClassAccessorDecorator & ClassFieldDecorator;
51
- struct: Annotation & PropertyDecorator & ClassAccessorDecorator & ClassFieldDecorator;
41
+ object: <T = any>(props: T, annotations?: AnnotationsMap<T, never>, options?: CreateObservableOptions) => T;
52
42
  }
43
+ export declare const observableRef: DecoratorAnnotation<ClassAccessorAndFieldDecorator>;
44
+ export declare const observableShallow: DecoratorAnnotation<ClassAccessorAndFieldDecorator>;
45
+ export declare const observableDeep: DecoratorAnnotation<ClassAccessorAndFieldDecorator>;
46
+ export declare const observableStruct: DecoratorAnnotation<ClassAccessorAndFieldDecorator>;
53
47
  export declare var observable: IObservableFactory;
@@ -6,9 +6,6 @@ export interface IAtom extends IObservable {
6
6
  }
7
7
  export declare class Atom implements IAtom {
8
8
  name_: string;
9
- private static readonly isBeingObservedMask_;
10
- private static readonly isPendingUnobservationMask_;
11
- private static readonly diffValueMask_;
12
9
  private flags_;
13
10
  observers_: Set<IDerivation>;
14
11
  lastAccessedBy_: number;
@@ -1,4 +1,4 @@
1
- import { CaughtException, IDerivation, IDerivationState_, IEqualsComparer, IObservable, Lambda, TraceMode } from "../internal";
1
+ import { CaughtException, IDerivation, IDerivationState_, IEqualsComparer, IObservable, Lambda } from "../internal";
2
2
  export interface IComputedValue<T> {
3
3
  get(): T;
4
4
  set(value: T): void;
@@ -20,25 +20,6 @@ export type IComputedDidChange<T = any> = {
20
20
  newValue: T;
21
21
  oldValue: T | undefined;
22
22
  };
23
- /**
24
- * A node in the state dependency root that observes other nodes, and can be observed itself.
25
- *
26
- * ComputedValue will remember the result of the computation for the duration of the batch, or
27
- * while being observed.
28
- *
29
- * During this time it will recompute only when one of its direct dependencies changed,
30
- * but only when it is being accessed with `ComputedValue.get()`.
31
- *
32
- * Implementation description:
33
- * 1. First time it's being accessed it will compute and remember result
34
- * give back remembered result until 2. happens
35
- * 2. First time any deep dependency change, propagate POSSIBLY_STALE to all observers, wait for 3.
36
- * 3. When it's being accessed, recompute if any shallow dependency changed.
37
- * if result changed: propagate STALE to all observers, that were POSSIBLY_STALE from the last step.
38
- * go to step 2. either way
39
- *
40
- * If at any point it's outside batch and it isn't observed: reset everything and go to 1.
41
- */
42
23
  export declare class ComputedValue<T> implements IObservable, IComputedValue<T>, IDerivation {
43
24
  dependenciesState_: IDerivationState_;
44
25
  observing_: IObservable[];
@@ -51,15 +32,9 @@ export declare class ComputedValue<T> implements IObservable, IComputedValue<T>,
51
32
  protected value_: T | undefined | CaughtException;
52
33
  name_: string;
53
34
  triggeredBy_?: string;
54
- private static readonly isComputingMask_;
55
- private static readonly isRunningSetterMask_;
56
- private static readonly isBeingObservedMask_;
57
- private static readonly isPendingUnobservationMask_;
58
- private static readonly diffValueMask_;
59
35
  private flags_;
60
36
  derivation: () => T;
61
37
  setter_?: (value: T) => void;
62
- isTracing_: TraceMode;
63
38
  scope_: Object | undefined;
64
39
  private equals_;
65
40
  private requiresReaction_;
@@ -69,11 +44,9 @@ export declare class ComputedValue<T> implements IObservable, IComputedValue<T>,
69
44
  *
70
45
  * The `name` property is for debug purposes only.
71
46
  *
72
- * The `equals` property specifies the comparer function to use to determine if a newly produced
73
- * value differs from the previous value. Two comparers are provided in the library; `defaultComparer`
74
- * compares based on identity comparison (===), and `structuralComparer` deeply compares the structure.
75
- * Structural comparison can be convenient if you always produce a new aggregated object and
76
- * don't want to notify observers if it is structurally the same.
47
+ * The `equals` property specifies the comparer function used to determine if a newly produced
48
+ * value differs from the previous value. Structural comparison can be convenient if you always
49
+ * produce a new aggregated object and don't want to notify observers if it is structurally the same.
77
50
  * This is useful for working with vectors, mouse coordinates etc.
78
51
  */
79
52
  constructor(options: IComputedValueOptions<T>);
@@ -101,7 +74,6 @@ export declare class ComputedValue<T> implements IObservable, IComputedValue<T>,
101
74
  trackAndCompute(): boolean;
102
75
  computeValue_(track: boolean): T | CaughtException;
103
76
  suspend_(): void;
104
- observe_(listener: (change: IComputedDidChange<T>) => void, fireImmediately?: boolean): Lambda;
105
77
  warnAboutUntrackedRead_(): void;
106
78
  toString(): string;
107
79
  valueOf(): T;
@@ -1,15 +1,10 @@
1
1
  import { IAtom, IDepTreeNode, IObservable } from "../internal";
2
- export declare enum IDerivationState_ {
2
+ export declare const enum IDerivationState_ {
3
3
  NOT_TRACKING_ = -1,
4
4
  UP_TO_DATE_ = 0,
5
5
  POSSIBLY_STALE_ = 1,
6
6
  STALE_ = 2
7
7
  }
8
- export declare enum TraceMode {
9
- NONE = 0,
10
- LOG = 1,
11
- BREAK = 2
12
- }
13
8
  /**
14
9
  * A derivation is everything that can be derived from the state (all the atoms) in a pure manner.
15
10
  * See https://medium.com/@mweststrate/becoming-fully-reactive-an-in-depth-explanation-of-mobservable-55995262a254#.xvbh6qd74
@@ -28,7 +23,6 @@ export interface IDerivation extends IDepTreeNode {
28
23
  */
29
24
  unboundDepsCount_: number;
30
25
  onBecomeStale_(): void;
31
- isTracing_: TraceMode;
32
26
  /**
33
27
  * warn if the derivation has no dependencies after creation/update
34
28
  */
@@ -93,8 +93,6 @@ export declare class MobXGlobals {
93
93
  observableRequiresReaction: boolean;
94
94
  disableErrorBoundaries: boolean;
95
95
  suppressReactionErrors: boolean;
96
- useProxies: boolean;
97
- verifyProxies: boolean;
98
96
  /**
99
97
  * False forces all object's descriptors to
100
98
  * writable: true
@@ -1,4 +1,4 @@
1
- import { $mobx, IDerivation, IDerivationState_, IObservable, Lambda, TraceMode, GenericAbortSignal } from "../internal";
1
+ import { $mobx, IDerivation, IDerivationState_, IObservable, Lambda, GenericAbortSignal } from "../internal";
2
2
  /**
3
3
  * Reactions are a special kind of derivations. Several things distinguishes them from normal reactive computations
4
4
  *
@@ -19,7 +19,6 @@ import { $mobx, IDerivation, IDerivationState_, IObservable, Lambda, TraceMode,
19
19
  */
20
20
  export interface IReactionPublic {
21
21
  dispose(): void;
22
- trace(enterBreakPoint?: boolean): void;
23
22
  }
24
23
  export interface IReactionDisposer {
25
24
  (): void;
@@ -35,13 +34,7 @@ export declare class Reaction implements IDerivation, IReactionPublic {
35
34
  dependenciesState_: IDerivationState_;
36
35
  runId_: number;
37
36
  unboundDepsCount_: number;
38
- private static readonly isDisposedMask_;
39
- private static readonly isScheduledMask_;
40
- private static readonly isTrackPendingMask_;
41
- private static readonly isRunningMask_;
42
- private static readonly diffValueMask_;
43
37
  private flags_;
44
- isTracing_: TraceMode;
45
38
  constructor(name_: string | undefined, onInvalidate_: () => void, errorHandler_?: ((error: any, derivation: IDerivation) => void) | undefined, requiresObservable_?: any);
46
39
  get isDisposed(): boolean;
47
40
  set isDisposed(newValue: boolean);
@@ -64,7 +57,6 @@ export declare class Reaction implements IDerivation, IReactionPublic {
64
57
  dispose(): void;
65
58
  getDisposer_(abortSignal?: GenericAbortSignal): IReactionDisposer;
66
59
  toString(): string;
67
- trace(enterBreakPoint?: boolean): void;
68
60
  }
69
61
  export declare function onReactionError(handler: (error: any, derivation: IDerivation) => void): Lambda;
70
62
  export declare function runReactions(): void;
package/dist/errors.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- declare const niceErrors: {
1
+ export declare const niceErrors: {
2
2
  readonly 0: "Invalid value for configuration 'enforceActions', expected 'never', 'always' or 'observed'";
3
3
  readonly 1: (annotationType: any, key: PropertyKey) => string;
4
4
  readonly 5: "'keys()' can only be used on observable objects, arrays, sets and maps";
@@ -13,12 +13,9 @@ declare const niceErrors: {
13
13
  readonly 14: "Intercept handlers should return nothing or a change object";
14
14
  readonly 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)";
15
15
  readonly 16: "Modification exception: the internal structure of an observable array was changed.";
16
- readonly 17: (index: any, length: any) => string;
17
- readonly 18: "mobx.map requires Map polyfill for the current browser. Check babel-polyfill or core-js/es6/map.js";
18
16
  readonly 19: (other: any) => string;
19
17
  readonly 20: (other: any) => string;
20
18
  readonly 21: (dataStructure: any) => string;
21
- readonly 22: "mobx.set requires Set polyfill for the current browser. Check babel-polyfill or core-js/es6/set.js";
22
19
  readonly 23: "It is not possible to get index atoms from arrays";
23
20
  readonly 24: (thing: any) => string;
24
21
  readonly 25: (property: any, name: any) => string;
@@ -36,6 +33,11 @@ declare const niceErrors: {
36
33
  readonly 37: (method: any) => string;
37
34
  readonly 38: "'ownKeys()' can only be used on observable objects";
38
35
  readonly 39: "'defineProperty()' can only be used on observable objects";
36
+ readonly 40: (length: any) => string;
37
+ readonly 41: (other: any) => string;
38
+ readonly 42: (key: any) => string;
39
+ readonly 43: (annotationType: any, name: any, kind: any) => string;
40
+ readonly 44: (annotationType: any) => string;
39
41
  };
40
42
  declare const errors: typeof niceErrors;
41
43
  export declare function die(error: string | keyof typeof errors, ...args: any[]): never;
@@ -1,5 +1,4 @@
1
- export * from "./utils/global";
2
- export * from "./errors";
1
+ export { die } from "./errors";
3
2
  export * from "./utils/utils";
4
3
  export * from "./api/decorators";
5
4
  export * from "./core/atom";
@@ -36,7 +35,6 @@ export * from "./api/isobservable";
36
35
  export * from "./api/object-api";
37
36
  export * from "./api/observe";
38
37
  export * from "./api/tojs";
39
- export * from "./api/trace";
40
38
  export * from "./api/transaction";
41
39
  export * from "./api/when";
42
40
  export * from "./types/dynamicobject";
@@ -47,7 +45,6 @@ export * from "./types/observablearray";
47
45
  export * from "./types/observablemap";
48
46
  export * from "./types/observableset";
49
47
  export * from "./types/observableobject";
50
- export * from "./types/legacyobservablearray";
51
48
  export * from "./types/type-utils";
52
49
  export * from "./utils/eq";
53
50
  export * from "./utils/iterable";