mobx-state-tree 3.15.0 → 3.17.3

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 (47) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +3 -1757
  3. package/dist/core/action.d.ts +50 -50
  4. package/dist/core/actionContext.d.ts +27 -27
  5. package/dist/core/flow.d.ts +63 -14
  6. package/dist/core/json-patch.d.ts +36 -36
  7. package/dist/core/mst-operations.d.ts +451 -451
  8. package/dist/core/node/BaseNode.d.ts +1 -1
  9. package/dist/core/node/Hook.d.ts +17 -17
  10. package/dist/core/node/create-node.d.ts +1 -1
  11. package/dist/core/node/identifier-cache.d.ts +1 -1
  12. package/dist/core/node/livelinessChecking.d.ts +37 -37
  13. package/dist/core/node/node-utils.d.ts +28 -28
  14. package/dist/core/node/object-node.d.ts +1 -1
  15. package/dist/core/node/scalar-node.d.ts +1 -1
  16. package/dist/core/process.d.ts +45 -45
  17. package/dist/core/type/type-checker.d.ts +30 -30
  18. package/dist/core/type/type.d.ts +162 -162
  19. package/dist/index.d.ts +3 -3
  20. package/dist/internal.d.ts +37 -37
  21. package/dist/middlewares/create-action-tracking-middleware.d.ts +24 -24
  22. package/dist/middlewares/createActionTrackingMiddleware2.d.ts +34 -34
  23. package/dist/middlewares/on-action.d.ts +87 -87
  24. package/dist/mobx-state-tree.js +6362 -6237
  25. package/dist/mobx-state-tree.min.js +12 -12
  26. package/dist/mobx-state-tree.module.js +6362 -6239
  27. package/dist/mobx-state-tree.umd.js +6342 -6217
  28. package/dist/mobx-state-tree.umd.min.js +11 -11
  29. package/dist/types/complex-types/array.d.ts +52 -52
  30. package/dist/types/complex-types/map.d.ts +80 -80
  31. package/dist/types/complex-types/model.d.ts +133 -133
  32. package/dist/types/index.d.ts +29 -29
  33. package/dist/types/primitives.d.ts +81 -81
  34. package/dist/types/utility-types/custom.d.ts +60 -60
  35. package/dist/types/utility-types/enumeration.d.ts +5 -5
  36. package/dist/types/utility-types/frozen.d.ts +11 -11
  37. package/dist/types/utility-types/identifier.d.ts +44 -44
  38. package/dist/types/utility-types/late.d.ts +10 -10
  39. package/dist/types/utility-types/literal.d.ts +25 -25
  40. package/dist/types/utility-types/maybe.d.ts +26 -26
  41. package/dist/types/utility-types/optional.d.ts +20 -20
  42. package/dist/types/utility-types/reference.d.ts +41 -41
  43. package/dist/types/utility-types/refinement.d.ts +10 -10
  44. package/dist/types/utility-types/snapshotProcessor.d.ts +61 -61
  45. package/dist/types/utility-types/union.d.ts +55 -55
  46. package/dist/utils.d.ts +4 -4
  47. package/package.json +22 -17
@@ -1,87 +1,87 @@
1
- import { IDisposer, IAnyStateTreeNode, IActionContext } from "../internal";
2
- export interface ISerializedActionCall {
3
- name: string;
4
- path?: string;
5
- args?: any[];
6
- }
7
- export interface IActionRecorder {
8
- actions: ReadonlyArray<ISerializedActionCall>;
9
- readonly recording: boolean;
10
- stop(): void;
11
- resume(): void;
12
- replay(target: IAnyStateTreeNode): void;
13
- }
14
- /**
15
- * Applies an action or a series of actions in a single MobX transaction.
16
- * Does not return any value
17
- * Takes an action description as produced by the `onAction` middleware.
18
- *
19
- * @param target
20
- * @param actions
21
- */
22
- export declare function applyAction(target: IAnyStateTreeNode, actions: ISerializedActionCall | ISerializedActionCall[]): void;
23
- /**
24
- * Small abstraction around `onAction` and `applyAction`, attaches an action listener to a tree and records all the actions emitted.
25
- * Returns an recorder object with the following signature:
26
- *
27
- * Example:
28
- * ```ts
29
- * export interface IActionRecorder {
30
- * // the recorded actions
31
- * actions: ISerializedActionCall[]
32
- * // true if currently recording
33
- * recording: boolean
34
- * // stop recording actions
35
- * stop(): void
36
- * // resume recording actions
37
- * resume(): void
38
- * // apply all the recorded actions on the given object
39
- * replay(target: IAnyStateTreeNode): void
40
- * }
41
- * ```
42
- *
43
- * The optional filter function allows to skip recording certain actions.
44
- *
45
- * @param subject
46
- * @returns
47
- */
48
- export declare function recordActions(subject: IAnyStateTreeNode, filter?: (action: ISerializedActionCall, actionContext: IActionContext | undefined) => boolean): IActionRecorder;
49
- /**
50
- * Registers a function that will be invoked for each action that is called on the provided model instance, or to any of its children.
51
- * See [actions](https://github.com/mobxjs/mobx-state-tree#actions) for more details. onAction events are emitted only for the outermost called action in the stack.
52
- * Action can also be intercepted by middleware using addMiddleware to change the function call before it will be run.
53
- *
54
- * Not all action arguments might be serializable. For unserializable arguments, a struct like `{ $MST_UNSERIALIZABLE: true, type: "someType" }` will be generated.
55
- * MST Nodes are considered non-serializable as well (they could be serialized as there snapshot, but it is uncertain whether an replaying party will be able to handle such a non-instantiated snapshot).
56
- * Rather, when using `onAction` middleware, one should consider in passing arguments which are 1: an id, 2: a (relative) path, or 3: a snapshot. Instead of a real MST node.
57
- *
58
- * Example:
59
- * ```ts
60
- * const Todo = types.model({
61
- * task: types.string
62
- * })
63
- *
64
- * const TodoStore = types.model({
65
- * todos: types.array(Todo)
66
- * }).actions(self => ({
67
- * add(todo) {
68
- * self.todos.push(todo);
69
- * }
70
- * }))
71
- *
72
- * const s = TodoStore.create({ todos: [] })
73
- *
74
- * let disposer = onAction(s, (call) => {
75
- * console.log(call);
76
- * })
77
- *
78
- * s.add({ task: "Grab a coffee" })
79
- * // Logs: { name: "add", path: "", args: [{ task: "Grab a coffee" }] }
80
- * ```
81
- *
82
- * @param target
83
- * @param listener
84
- * @param attachAfter (default false) fires the listener *after* the action has executed instead of before.
85
- * @returns
86
- */
87
- export declare function onAction(target: IAnyStateTreeNode, listener: (call: ISerializedActionCall) => void, attachAfter?: boolean): IDisposer;
1
+ import { IDisposer, IAnyStateTreeNode, IActionContext } from "../internal";
2
+ export interface ISerializedActionCall {
3
+ name: string;
4
+ path?: string;
5
+ args?: any[];
6
+ }
7
+ export interface IActionRecorder {
8
+ actions: ReadonlyArray<ISerializedActionCall>;
9
+ readonly recording: boolean;
10
+ stop(): void;
11
+ resume(): void;
12
+ replay(target: IAnyStateTreeNode): void;
13
+ }
14
+ /**
15
+ * Applies an action or a series of actions in a single MobX transaction.
16
+ * Does not return any value
17
+ * Takes an action description as produced by the `onAction` middleware.
18
+ *
19
+ * @param target
20
+ * @param actions
21
+ */
22
+ export declare function applyAction(target: IAnyStateTreeNode, actions: ISerializedActionCall | ISerializedActionCall[]): void;
23
+ /**
24
+ * Small abstraction around `onAction` and `applyAction`, attaches an action listener to a tree and records all the actions emitted.
25
+ * Returns an recorder object with the following signature:
26
+ *
27
+ * Example:
28
+ * ```ts
29
+ * export interface IActionRecorder {
30
+ * // the recorded actions
31
+ * actions: ISerializedActionCall[]
32
+ * // true if currently recording
33
+ * recording: boolean
34
+ * // stop recording actions
35
+ * stop(): void
36
+ * // resume recording actions
37
+ * resume(): void
38
+ * // apply all the recorded actions on the given object
39
+ * replay(target: IAnyStateTreeNode): void
40
+ * }
41
+ * ```
42
+ *
43
+ * The optional filter function allows to skip recording certain actions.
44
+ *
45
+ * @param subject
46
+ * @returns
47
+ */
48
+ export declare function recordActions(subject: IAnyStateTreeNode, filter?: (action: ISerializedActionCall, actionContext: IActionContext | undefined) => boolean): IActionRecorder;
49
+ /**
50
+ * Registers a function that will be invoked for each action that is called on the provided model instance, or to any of its children.
51
+ * See [actions](https://github.com/mobxjs/mobx-state-tree#actions) for more details. onAction events are emitted only for the outermost called action in the stack.
52
+ * Action can also be intercepted by middleware using addMiddleware to change the function call before it will be run.
53
+ *
54
+ * Not all action arguments might be serializable. For unserializable arguments, a struct like `{ $MST_UNSERIALIZABLE: true, type: "someType" }` will be generated.
55
+ * MST Nodes are considered non-serializable as well (they could be serialized as there snapshot, but it is uncertain whether an replaying party will be able to handle such a non-instantiated snapshot).
56
+ * Rather, when using `onAction` middleware, one should consider in passing arguments which are 1: an id, 2: a (relative) path, or 3: a snapshot. Instead of a real MST node.
57
+ *
58
+ * Example:
59
+ * ```ts
60
+ * const Todo = types.model({
61
+ * task: types.string
62
+ * })
63
+ *
64
+ * const TodoStore = types.model({
65
+ * todos: types.array(Todo)
66
+ * }).actions(self => ({
67
+ * add(todo) {
68
+ * self.todos.push(todo);
69
+ * }
70
+ * }))
71
+ *
72
+ * const s = TodoStore.create({ todos: [] })
73
+ *
74
+ * let disposer = onAction(s, (call) => {
75
+ * console.log(call);
76
+ * })
77
+ *
78
+ * s.add({ task: "Grab a coffee" })
79
+ * // Logs: { name: "add", path: "", args: [{ task: "Grab a coffee" }] }
80
+ * ```
81
+ *
82
+ * @param target
83
+ * @param listener
84
+ * @param attachAfter (default false) fires the listener *after* the action has executed instead of before.
85
+ * @returns
86
+ */
87
+ export declare function onAction(target: IAnyStateTreeNode, listener: (call: ISerializedActionCall) => void, attachAfter?: boolean): IDisposer;