mobx-state-tree 3.12.2 → 3.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/README.md +103 -23
- package/dist/core/action.d.ts +50 -48
- package/dist/core/actionContext.d.ts +27 -0
- package/dist/core/flow.d.ts +14 -30
- package/dist/core/json-patch.d.ts +36 -36
- package/dist/core/mst-operations.d.ts +451 -444
- package/dist/core/node/BaseNode.d.ts +1 -1
- package/dist/core/node/Hook.d.ts +17 -1
- package/dist/core/node/create-node.d.ts +1 -1
- package/dist/core/node/identifier-cache.d.ts +1 -1
- package/dist/core/node/livelinessChecking.d.ts +37 -37
- package/dist/core/node/node-utils.d.ts +28 -28
- package/dist/core/node/object-node.d.ts +1 -1
- package/dist/core/node/scalar-node.d.ts +1 -1
- package/dist/core/process.d.ts +45 -45
- package/dist/core/type/type-checker.d.ts +30 -30
- package/dist/core/type/type.d.ts +162 -177
- package/dist/index.d.ts +3 -3
- package/dist/internal.d.ts +37 -35
- package/dist/middlewares/create-action-tracking-middleware.d.ts +24 -22
- package/dist/middlewares/createActionTrackingMiddleware2.d.ts +34 -0
- package/dist/middlewares/on-action.d.ts +87 -79
- package/dist/mobx-state-tree.js +6285 -5985
- package/dist/mobx-state-tree.min.js +16 -1
- package/dist/mobx-state-tree.module.js +6234 -5938
- package/dist/mobx-state-tree.umd.js +6263 -5985
- package/dist/mobx-state-tree.umd.min.js +16 -1
- package/dist/types/complex-types/array.d.ts +52 -51
- package/dist/types/complex-types/map.d.ts +80 -79
- package/dist/types/complex-types/model.d.ts +133 -125
- package/dist/types/index.d.ts +29 -29
- package/dist/types/primitives.d.ts +81 -81
- package/dist/types/utility-types/custom.d.ts +60 -60
- package/dist/types/utility-types/enumeration.d.ts +5 -5
- package/dist/types/utility-types/frozen.d.ts +11 -11
- package/dist/types/utility-types/identifier.d.ts +44 -44
- package/dist/types/utility-types/late.d.ts +10 -10
- package/dist/types/utility-types/literal.d.ts +25 -25
- package/dist/types/utility-types/maybe.d.ts +26 -26
- package/dist/types/utility-types/optional.d.ts +20 -20
- package/dist/types/utility-types/reference.d.ts +41 -47
- package/dist/types/utility-types/refinement.d.ts +10 -10
- package/dist/types/utility-types/snapshotProcessor.d.ts +61 -61
- package/dist/types/utility-types/union.d.ts +55 -55
- package/dist/utils.d.ts +4 -4
- package/package.json +16 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
package/dist/core/node/Hook.d.ts
CHANGED
|
@@ -1 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @hidden
|
|
3
|
+
*/
|
|
4
|
+
export declare enum Hook {
|
|
5
|
+
afterCreate = "afterCreate",
|
|
6
|
+
afterAttach = "afterAttach",
|
|
7
|
+
afterCreationFinalization = "afterCreationFinalization",
|
|
8
|
+
beforeDetach = "beforeDetach",
|
|
9
|
+
beforeDestroy = "beforeDestroy"
|
|
10
|
+
}
|
|
11
|
+
export interface IHooks {
|
|
12
|
+
[Hook.afterCreate]?: () => void;
|
|
13
|
+
[Hook.afterAttach]?: () => void;
|
|
14
|
+
[Hook.beforeDetach]?: () => void;
|
|
15
|
+
[Hook.beforeDestroy]?: () => void;
|
|
16
|
+
}
|
|
17
|
+
export declare type IHooksGetter<T> = (self: T) => IHooks;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Defines what MST should do when running into reads / writes to objects that have died.
|
|
3
|
-
* - `"warn"`: Print a warning (default).
|
|
4
|
-
* - `"error"`: Throw an exception.
|
|
5
|
-
* - "`ignore`": Do nothing.
|
|
6
|
-
*/
|
|
7
|
-
export declare type LivelinessMode = "warn" | "error" | "ignore";
|
|
8
|
-
/**
|
|
9
|
-
* Defines what MST should do when running into reads / writes to objects that have died.
|
|
10
|
-
* By default it will print a warning.
|
|
11
|
-
* Use the `"error"` option to easy debugging to see where the error was thrown and when the offending read / write took place
|
|
12
|
-
*
|
|
13
|
-
* @param mode `"warn"`, `"error"` or `"ignore"`
|
|
14
|
-
*/
|
|
15
|
-
export declare function setLivelinessChecking(mode: LivelinessMode): void;
|
|
16
|
-
/**
|
|
17
|
-
* Returns the current liveliness checking mode.
|
|
18
|
-
*
|
|
19
|
-
* @returns `"warn"`, `"error"` or `"ignore"`
|
|
20
|
-
*/
|
|
21
|
-
export declare function getLivelinessChecking(): LivelinessMode;
|
|
22
|
-
/**
|
|
23
|
-
* @deprecated use LivelinessMode instead
|
|
24
|
-
* @hidden
|
|
25
|
-
*/
|
|
26
|
-
export declare type LivelynessMode = LivelinessMode;
|
|
27
|
-
/**
|
|
28
|
-
* @deprecated use setLivelinessChecking instead
|
|
29
|
-
* @hidden
|
|
30
|
-
*
|
|
31
|
-
* Defines what MST should do when running into reads / writes to objects that have died.
|
|
32
|
-
* By default it will print a warning.
|
|
33
|
-
* Use the `"error"` option to easy debugging to see where the error was thrown and when the offending read / write took place
|
|
34
|
-
*
|
|
35
|
-
* @param mode `"warn"`, `"error"` or `"ignore"`
|
|
36
|
-
*/
|
|
37
|
-
export declare function setLivelynessChecking(mode: LivelinessMode): void;
|
|
1
|
+
/**
|
|
2
|
+
* Defines what MST should do when running into reads / writes to objects that have died.
|
|
3
|
+
* - `"warn"`: Print a warning (default).
|
|
4
|
+
* - `"error"`: Throw an exception.
|
|
5
|
+
* - "`ignore`": Do nothing.
|
|
6
|
+
*/
|
|
7
|
+
export declare type LivelinessMode = "warn" | "error" | "ignore";
|
|
8
|
+
/**
|
|
9
|
+
* Defines what MST should do when running into reads / writes to objects that have died.
|
|
10
|
+
* By default it will print a warning.
|
|
11
|
+
* Use the `"error"` option to easy debugging to see where the error was thrown and when the offending read / write took place
|
|
12
|
+
*
|
|
13
|
+
* @param mode `"warn"`, `"error"` or `"ignore"`
|
|
14
|
+
*/
|
|
15
|
+
export declare function setLivelinessChecking(mode: LivelinessMode): void;
|
|
16
|
+
/**
|
|
17
|
+
* Returns the current liveliness checking mode.
|
|
18
|
+
*
|
|
19
|
+
* @returns `"warn"`, `"error"` or `"ignore"`
|
|
20
|
+
*/
|
|
21
|
+
export declare function getLivelinessChecking(): LivelinessMode;
|
|
22
|
+
/**
|
|
23
|
+
* @deprecated use LivelinessMode instead
|
|
24
|
+
* @hidden
|
|
25
|
+
*/
|
|
26
|
+
export declare type LivelynessMode = LivelinessMode;
|
|
27
|
+
/**
|
|
28
|
+
* @deprecated use setLivelinessChecking instead
|
|
29
|
+
* @hidden
|
|
30
|
+
*
|
|
31
|
+
* Defines what MST should do when running into reads / writes to objects that have died.
|
|
32
|
+
* By default it will print a warning.
|
|
33
|
+
* Use the `"error"` option to easy debugging to see where the error was thrown and when the offending read / write took place
|
|
34
|
+
*
|
|
35
|
+
* @param mode `"warn"`, `"error"` or `"ignore"`
|
|
36
|
+
*/
|
|
37
|
+
export declare function setLivelynessChecking(mode: LivelinessMode): void;
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { IAnyType } from "../../internal";
|
|
2
|
-
/** @hidden */
|
|
3
|
-
declare const $stateTreeNodeType: unique symbol;
|
|
4
|
-
/**
|
|
5
|
-
* Common interface that represents a node instance.
|
|
6
|
-
* @hidden
|
|
7
|
-
*/
|
|
8
|
-
export interface IStateTreeNode<IT extends IAnyType = IAnyType> {
|
|
9
|
-
readonly [$stateTreeNodeType]?: [IT] | [any];
|
|
10
|
-
}
|
|
11
|
-
/** @hidden */
|
|
12
|
-
export declare type TypeOfValue<T extends IAnyStateTreeNode> = T extends IStateTreeNode<infer IT> ? IT : never;
|
|
13
|
-
/**
|
|
14
|
-
* Represents any state tree node instance.
|
|
15
|
-
* @hidden
|
|
16
|
-
*/
|
|
17
|
-
export interface IAnyStateTreeNode extends
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Returns true if the given value is a node in a state tree.
|
|
21
|
-
* More precisely, that is, if the value is an instance of a
|
|
22
|
-
* `types.model`, `types.array` or `types.map`.
|
|
23
|
-
*
|
|
24
|
-
* @param value
|
|
25
|
-
* @returns true if the value is a state tree node.
|
|
26
|
-
*/
|
|
27
|
-
export declare function isStateTreeNode<IT extends
|
|
28
|
-
export {};
|
|
1
|
+
import { IAnyType, STNValue, Instance, IAnyComplexType } from "../../internal";
|
|
2
|
+
/** @hidden */
|
|
3
|
+
declare const $stateTreeNodeType: unique symbol;
|
|
4
|
+
/**
|
|
5
|
+
* Common interface that represents a node instance.
|
|
6
|
+
* @hidden
|
|
7
|
+
*/
|
|
8
|
+
export interface IStateTreeNode<IT extends IAnyType = IAnyType> {
|
|
9
|
+
readonly [$stateTreeNodeType]?: [IT] | [any];
|
|
10
|
+
}
|
|
11
|
+
/** @hidden */
|
|
12
|
+
export declare type TypeOfValue<T extends IAnyStateTreeNode> = T extends IStateTreeNode<infer IT> ? IT : never;
|
|
13
|
+
/**
|
|
14
|
+
* Represents any state tree node instance.
|
|
15
|
+
* @hidden
|
|
16
|
+
*/
|
|
17
|
+
export interface IAnyStateTreeNode extends STNValue<any, IAnyType> {
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Returns true if the given value is a node in a state tree.
|
|
21
|
+
* More precisely, that is, if the value is an instance of a
|
|
22
|
+
* `types.model`, `types.array` or `types.map`.
|
|
23
|
+
*
|
|
24
|
+
* @param value
|
|
25
|
+
* @returns true if the value is a state tree node.
|
|
26
|
+
*/
|
|
27
|
+
export declare function isStateTreeNode<IT extends IAnyComplexType = IAnyComplexType>(value: any): value is STNValue<Instance<IT>, IT>;
|
|
28
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
package/dist/core/process.d.ts
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @deprecated has been renamed to `flow()`.
|
|
3
|
-
* @hidden
|
|
4
|
-
*/
|
|
5
|
-
export declare function process<R>(generator: () => IterableIterator<any>): () => Promise<R>;
|
|
6
|
-
/**
|
|
7
|
-
* @deprecated has been renamed to `flow()`.
|
|
8
|
-
* @hidden
|
|
9
|
-
*/
|
|
10
|
-
export declare function process<A1>(generator: (a1: A1) => IterableIterator<any>): (a1: A1) => Promise<any>;
|
|
11
|
-
/**
|
|
12
|
-
* @deprecated has been renamed to `flow()`.
|
|
13
|
-
* @hidden
|
|
14
|
-
*/
|
|
15
|
-
export declare function process<A1, A2>(generator: (a1: A1, a2: A2) => IterableIterator<any>): (a1: A1, a2: A2) => Promise<any>;
|
|
16
|
-
/**
|
|
17
|
-
* @deprecated has been renamed to `flow()`.
|
|
18
|
-
* @hidden
|
|
19
|
-
*/
|
|
20
|
-
export declare function process<A1, A2, A3>(generator: (a1: A1, a2: A2, a3: A3) => IterableIterator<any>): (a1: A1, a2: A2, a3: A3) => Promise<any>;
|
|
21
|
-
/**
|
|
22
|
-
* @deprecated has been renamed to `flow()`.
|
|
23
|
-
* @hidden
|
|
24
|
-
*/
|
|
25
|
-
export declare function process<A1, A2, A3, A4>(generator: (a1: A1, a2: A2, a3: A3, a4: A4) => IterableIterator<any>): (a1: A1, a2: A2, a3: A3, a4: A4) => Promise<any>;
|
|
26
|
-
/**
|
|
27
|
-
* @deprecated has been renamed to `flow()`.
|
|
28
|
-
* @hidden
|
|
29
|
-
*/
|
|
30
|
-
export declare function process<A1, A2, A3, A4, A5>(generator: (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5) => IterableIterator<any>): (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5) => Promise<any>;
|
|
31
|
-
/**
|
|
32
|
-
* @deprecated has been renamed to `flow()`.
|
|
33
|
-
* @hidden
|
|
34
|
-
*/
|
|
35
|
-
export declare function process<A1, A2, A3, A4, A5, A6>(generator: (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6) => IterableIterator<any>): (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6) => Promise<any>;
|
|
36
|
-
/**
|
|
37
|
-
* @deprecated has been renamed to `flow()`.
|
|
38
|
-
* @hidden
|
|
39
|
-
*/
|
|
40
|
-
export declare function process<A1, A2, A3, A4, A5, A6, A7>(generator: (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7) => IterableIterator<any>): (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7) => Promise<any>;
|
|
41
|
-
/**
|
|
42
|
-
* @deprecated has been renamed to `flow()`.
|
|
43
|
-
* @hidden
|
|
44
|
-
*/
|
|
45
|
-
export declare function process<A1, A2, A3, A4, A5, A6, A7, A8>(generator: (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8) => IterableIterator<any>): (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8) => Promise<any>;
|
|
1
|
+
/**
|
|
2
|
+
* @deprecated has been renamed to `flow()`.
|
|
3
|
+
* @hidden
|
|
4
|
+
*/
|
|
5
|
+
export declare function process<R>(generator: () => IterableIterator<any>): () => Promise<R>;
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated has been renamed to `flow()`.
|
|
8
|
+
* @hidden
|
|
9
|
+
*/
|
|
10
|
+
export declare function process<A1>(generator: (a1: A1) => IterableIterator<any>): (a1: A1) => Promise<any>;
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated has been renamed to `flow()`.
|
|
13
|
+
* @hidden
|
|
14
|
+
*/
|
|
15
|
+
export declare function process<A1, A2>(generator: (a1: A1, a2: A2) => IterableIterator<any>): (a1: A1, a2: A2) => Promise<any>;
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated has been renamed to `flow()`.
|
|
18
|
+
* @hidden
|
|
19
|
+
*/
|
|
20
|
+
export declare function process<A1, A2, A3>(generator: (a1: A1, a2: A2, a3: A3) => IterableIterator<any>): (a1: A1, a2: A2, a3: A3) => Promise<any>;
|
|
21
|
+
/**
|
|
22
|
+
* @deprecated has been renamed to `flow()`.
|
|
23
|
+
* @hidden
|
|
24
|
+
*/
|
|
25
|
+
export declare function process<A1, A2, A3, A4>(generator: (a1: A1, a2: A2, a3: A3, a4: A4) => IterableIterator<any>): (a1: A1, a2: A2, a3: A3, a4: A4) => Promise<any>;
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated has been renamed to `flow()`.
|
|
28
|
+
* @hidden
|
|
29
|
+
*/
|
|
30
|
+
export declare function process<A1, A2, A3, A4, A5>(generator: (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5) => IterableIterator<any>): (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5) => Promise<any>;
|
|
31
|
+
/**
|
|
32
|
+
* @deprecated has been renamed to `flow()`.
|
|
33
|
+
* @hidden
|
|
34
|
+
*/
|
|
35
|
+
export declare function process<A1, A2, A3, A4, A5, A6>(generator: (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6) => IterableIterator<any>): (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6) => Promise<any>;
|
|
36
|
+
/**
|
|
37
|
+
* @deprecated has been renamed to `flow()`.
|
|
38
|
+
* @hidden
|
|
39
|
+
*/
|
|
40
|
+
export declare function process<A1, A2, A3, A4, A5, A6, A7>(generator: (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7) => IterableIterator<any>): (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7) => Promise<any>;
|
|
41
|
+
/**
|
|
42
|
+
* @deprecated has been renamed to `flow()`.
|
|
43
|
+
* @hidden
|
|
44
|
+
*/
|
|
45
|
+
export declare function process<A1, A2, A3, A4, A5, A6, A7, A8>(generator: (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8) => IterableIterator<any>): (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8) => Promise<any>;
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { IAnyType, ExtractCSTWithSTN } from "../../internal";
|
|
2
|
-
/** Validation context entry, this is, where the validation should run against which type */
|
|
3
|
-
export interface IValidationContextEntry {
|
|
4
|
-
/** Subpath where the validation should be run, or an empty string to validate it all */
|
|
5
|
-
path: string;
|
|
6
|
-
/** Type to validate the subpath against */
|
|
7
|
-
type: IAnyType;
|
|
8
|
-
}
|
|
9
|
-
/** Array of validation context entries */
|
|
10
|
-
export declare type IValidationContext = IValidationContextEntry[];
|
|
11
|
-
/** Type validation error */
|
|
12
|
-
export interface IValidationError {
|
|
13
|
-
/** Validation context */
|
|
14
|
-
context: IValidationContext;
|
|
15
|
-
/** Value that was being validated, either a snapshot or an instance */
|
|
16
|
-
value: any;
|
|
17
|
-
/** Error message */
|
|
18
|
-
message?: string;
|
|
19
|
-
}
|
|
20
|
-
/** Type validation result, which is an array of type validation errors */
|
|
21
|
-
export declare type IValidationResult = IValidationError[];
|
|
22
|
-
/**
|
|
23
|
-
* Run's the typechecker for the given type on the given value, which can be a snapshot or an instance.
|
|
24
|
-
* Throws if the given value is not according the provided type specification.
|
|
25
|
-
* Use this if you need typechecks even in a production build (by default all automatic runtime type checks will be skipped in production builds)
|
|
26
|
-
*
|
|
27
|
-
* @param type Type to check against.
|
|
28
|
-
* @param value Value to be checked, either a snapshot or an instance.
|
|
29
|
-
*/
|
|
30
|
-
export declare function typecheck<IT extends IAnyType>(type: IT, value: ExtractCSTWithSTN<IT>): void;
|
|
1
|
+
import { IAnyType, ExtractCSTWithSTN } from "../../internal";
|
|
2
|
+
/** Validation context entry, this is, where the validation should run against which type */
|
|
3
|
+
export interface IValidationContextEntry {
|
|
4
|
+
/** Subpath where the validation should be run, or an empty string to validate it all */
|
|
5
|
+
path: string;
|
|
6
|
+
/** Type to validate the subpath against */
|
|
7
|
+
type: IAnyType;
|
|
8
|
+
}
|
|
9
|
+
/** Array of validation context entries */
|
|
10
|
+
export declare type IValidationContext = IValidationContextEntry[];
|
|
11
|
+
/** Type validation error */
|
|
12
|
+
export interface IValidationError {
|
|
13
|
+
/** Validation context */
|
|
14
|
+
context: IValidationContext;
|
|
15
|
+
/** Value that was being validated, either a snapshot or an instance */
|
|
16
|
+
value: any;
|
|
17
|
+
/** Error message */
|
|
18
|
+
message?: string;
|
|
19
|
+
}
|
|
20
|
+
/** Type validation result, which is an array of type validation errors */
|
|
21
|
+
export declare type IValidationResult = IValidationError[];
|
|
22
|
+
/**
|
|
23
|
+
* Run's the typechecker for the given type on the given value, which can be a snapshot or an instance.
|
|
24
|
+
* Throws if the given value is not according the provided type specification.
|
|
25
|
+
* Use this if you need typechecks even in a production build (by default all automatic runtime type checks will be skipped in production builds)
|
|
26
|
+
*
|
|
27
|
+
* @param type Type to check against.
|
|
28
|
+
* @param value Value to be checked, either a snapshot or an instance.
|
|
29
|
+
*/
|
|
30
|
+
export declare function typecheck<IT extends IAnyType>(type: IT, value: ExtractCSTWithSTN<IT>): void;
|