@jbrowse/mobx-state-tree 5.7.0 → 5.8.6
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 +0 -10
- package/dist/index.d.ts +2135 -2
- package/dist/mobx-state-tree.cjs +6894 -0
- package/dist/mobx-state-tree.cjs.map +1 -0
- package/dist/mobx-state-tree.mjs +6814 -0
- package/dist/mobx-state-tree.mjs.map +1 -0
- package/package.json +30 -26
- package/dist/core/action.d.ts +0 -87
- package/dist/core/action.js +0 -228
- package/dist/core/action.js.map +0 -1
- package/dist/core/actionContext.d.ts +0 -27
- package/dist/core/actionContext.js +0 -42
- package/dist/core/actionContext.js.map +0 -1
- package/dist/core/flow.d.ts +0 -69
- package/dist/core/flow.js +0 -180
- package/dist/core/flow.js.map +0 -1
- package/dist/core/json-patch.d.ts +0 -46
- package/dist/core/json-patch.js +0 -133
- package/dist/core/json-patch.js.map +0 -1
- package/dist/core/mst-operations.d.ts +0 -459
- package/dist/core/mst-operations.js +0 -885
- package/dist/core/mst-operations.js.map +0 -1
- package/dist/core/node/BaseNode.d.ts +0 -62
- package/dist/core/node/BaseNode.js +0 -152
- package/dist/core/node/BaseNode.js.map +0 -1
- package/dist/core/node/Hook.d.ts +0 -17
- package/dist/core/node/Hook.js +0 -15
- package/dist/core/node/Hook.js.map +0 -1
- package/dist/core/node/create-node.d.ts +0 -16
- package/dist/core/node/create-node.js +0 -41
- package/dist/core/node/create-node.js.map +0 -1
- package/dist/core/node/identifier-cache.d.ts +0 -19
- package/dist/core/node/identifier-cache.js +0 -115
- package/dist/core/node/identifier-cache.js.map +0 -1
- package/dist/core/node/livelinessChecking.d.ts +0 -37
- package/dist/core/node/livelinessChecking.js +0 -38
- package/dist/core/node/livelinessChecking.js.map +0 -1
- package/dist/core/node/node-utils.d.ts +0 -83
- package/dist/core/node/node-utils.js +0 -165
- package/dist/core/node/node-utils.js.map +0 -1
- package/dist/core/node/object-node.d.ts +0 -101
- package/dist/core/node/object-node.js +0 -546
- package/dist/core/node/object-node.js.map +0 -1
- package/dist/core/node/scalar-node.d.ts +0 -21
- package/dist/core/node/scalar-node.js +0 -90
- package/dist/core/node/scalar-node.js.map +0 -1
- package/dist/core/process.d.ts +0 -50
- package/dist/core/process.js +0 -39
- package/dist/core/process.js.map +0 -1
- package/dist/core/type/type-checker.d.ts +0 -69
- package/dist/core/type/type-checker.js +0 -154
- package/dist/core/type/type-checker.js.map +0 -1
- package/dist/core/type/type.d.ts +0 -317
- package/dist/core/type/type.js +0 -251
- package/dist/core/type/type.js.map +0 -1
- package/dist/index.js +0 -85
- package/dist/index.js.map +0 -1
- package/dist/internal.d.ts +0 -39
- package/dist/internal.js +0 -60
- package/dist/internal.js.map +0 -1
- package/dist/middlewares/create-action-tracking-middleware.d.ts +0 -24
- package/dist/middlewares/create-action-tracking-middleware.js +0 -81
- package/dist/middlewares/create-action-tracking-middleware.js.map +0 -1
- package/dist/middlewares/createActionTrackingMiddleware2.d.ts +0 -34
- package/dist/middlewares/createActionTrackingMiddleware2.js +0 -133
- package/dist/middlewares/createActionTrackingMiddleware2.js.map +0 -1
- package/dist/middlewares/on-action.d.ts +0 -87
- package/dist/middlewares/on-action.js +0 -215
- package/dist/middlewares/on-action.js.map +0 -1
- package/dist/package.json +0 -1
- package/dist/types/complex-types/array.d.ts +0 -81
- package/dist/types/complex-types/array.js +0 -353
- package/dist/types/complex-types/array.js.map +0 -1
- package/dist/types/complex-types/map.d.ts +0 -111
- package/dist/types/complex-types/map.js +0 -362
- package/dist/types/complex-types/map.js.map +0 -1
- package/dist/types/complex-types/model.d.ts +0 -193
- package/dist/types/complex-types/model.js +0 -478
- package/dist/types/complex-types/model.js.map +0 -1
- package/dist/types/index.d.ts +0 -33
- package/dist/types/index.js +0 -38
- package/dist/types/index.js.map +0 -1
- package/dist/types/primitives.d.ts +0 -125
- package/dist/types/primitives.js +0 -183
- package/dist/types/primitives.js.map +0 -1
- package/dist/types/utility-types/custom.d.ts +0 -75
- package/dist/types/utility-types/custom.js +0 -111
- package/dist/types/utility-types/custom.js.map +0 -1
- package/dist/types/utility-types/enumeration.d.ts +0 -5
- package/dist/types/utility-types/enumeration.js +0 -34
- package/dist/types/utility-types/enumeration.js.map +0 -1
- package/dist/types/utility-types/frozen.d.ts +0 -24
- package/dist/types/utility-types/frozen.js +0 -98
- package/dist/types/utility-types/frozen.js.map +0 -1
- package/dist/types/utility-types/identifier.d.ts +0 -87
- package/dist/types/utility-types/identifier.js +0 -130
- package/dist/types/utility-types/identifier.js.map +0 -1
- package/dist/types/utility-types/late.d.ts +0 -10
- package/dist/types/utility-types/late.js +0 -110
- package/dist/types/utility-types/late.js.map +0 -1
- package/dist/types/utility-types/lazy.d.ts +0 -23
- package/dist/types/utility-types/lazy.js +0 -77
- package/dist/types/utility-types/lazy.js.map +0 -1
- package/dist/types/utility-types/literal.d.ts +0 -38
- package/dist/types/utility-types/literal.js +0 -64
- package/dist/types/utility-types/literal.js.map +0 -1
- package/dist/types/utility-types/maybe.d.ts +0 -26
- package/dist/types/utility-types/maybe.js +0 -30
- package/dist/types/utility-types/maybe.js.map +0 -1
- package/dist/types/utility-types/optional.d.ts +0 -42
- package/dist/types/utility-types/optional.js +0 -141
- package/dist/types/utility-types/optional.js.map +0 -1
- package/dist/types/utility-types/reference.d.ts +0 -90
- package/dist/types/utility-types/reference.js +0 -393
- package/dist/types/utility-types/reference.js.map +0 -1
- package/dist/types/utility-types/refinement.d.ts +0 -10
- package/dist/types/utility-types/refinement.js +0 -86
- package/dist/types/utility-types/refinement.js.map +0 -1
- package/dist/types/utility-types/resilient.d.ts +0 -18
- package/dist/types/utility-types/resilient.js +0 -121
- package/dist/types/utility-types/resilient.js.map +0 -1
- package/dist/types/utility-types/snapshotProcessor.d.ts +0 -63
- package/dist/types/utility-types/snapshotProcessor.js +0 -162
- package/dist/types/utility-types/snapshotProcessor.js.map +0 -1
- package/dist/types/utility-types/union.d.ts +0 -78
- package/dist/types/utility-types/union.js +0 -246
- package/dist/types/utility-types/union.js.map +0 -1
- package/dist/utils.d.ts +0 -230
- package/dist/utils.js +0 -483
- package/dist/utils.js.map +0 -1
- package/esm/core/action.d.ts +0 -87
- package/esm/core/action.js +0 -219
- package/esm/core/action.js.map +0 -1
- package/esm/core/actionContext.d.ts +0 -27
- package/esm/core/actionContext.js +0 -37
- package/esm/core/actionContext.js.map +0 -1
- package/esm/core/flow.d.ts +0 -69
- package/esm/core/flow.js +0 -173
- package/esm/core/flow.js.map +0 -1
- package/esm/core/json-patch.d.ts +0 -46
- package/esm/core/json-patch.js +0 -125
- package/esm/core/json-patch.js.map +0 -1
- package/esm/core/mst-operations.d.ts +0 -459
- package/esm/core/mst-operations.js +0 -844
- package/esm/core/mst-operations.js.map +0 -1
- package/esm/core/node/BaseNode.d.ts +0 -62
- package/esm/core/node/BaseNode.js +0 -148
- package/esm/core/node/BaseNode.js.map +0 -1
- package/esm/core/node/Hook.d.ts +0 -17
- package/esm/core/node/Hook.js +0 -12
- package/esm/core/node/Hook.js.map +0 -1
- package/esm/core/node/create-node.d.ts +0 -16
- package/esm/core/node/create-node.js +0 -36
- package/esm/core/node/create-node.js.map +0 -1
- package/esm/core/node/identifier-cache.d.ts +0 -19
- package/esm/core/node/identifier-cache.js +0 -111
- package/esm/core/node/identifier-cache.js.map +0 -1
- package/esm/core/node/livelinessChecking.d.ts +0 -37
- package/esm/core/node/livelinessChecking.js +0 -33
- package/esm/core/node/livelinessChecking.js.map +0 -1
- package/esm/core/node/node-utils.d.ts +0 -83
- package/esm/core/node/node-utils.js +0 -153
- package/esm/core/node/node-utils.js.map +0 -1
- package/esm/core/node/object-node.d.ts +0 -101
- package/esm/core/node/object-node.js +0 -542
- package/esm/core/node/object-node.js.map +0 -1
- package/esm/core/node/scalar-node.d.ts +0 -21
- package/esm/core/node/scalar-node.js +0 -86
- package/esm/core/node/scalar-node.js.map +0 -1
- package/esm/core/process.d.ts +0 -50
- package/esm/core/process.js +0 -35
- package/esm/core/process.js.map +0 -1
- package/esm/core/type/type-checker.d.ts +0 -69
- package/esm/core/type/type-checker.js +0 -144
- package/esm/core/type/type-checker.js.map +0 -1
- package/esm/core/type/type.d.ts +0 -317
- package/esm/core/type/type.js +0 -243
- package/esm/core/type/type.js.map +0 -1
- package/esm/index.d.ts +0 -2
- package/esm/index.js +0 -2
- package/esm/index.js.map +0 -1
- package/esm/internal.d.ts +0 -39
- package/esm/internal.js +0 -44
- package/esm/internal.js.map +0 -1
- package/esm/middlewares/create-action-tracking-middleware.d.ts +0 -24
- package/esm/middlewares/create-action-tracking-middleware.js +0 -78
- package/esm/middlewares/create-action-tracking-middleware.js.map +0 -1
- package/esm/middlewares/createActionTrackingMiddleware2.d.ts +0 -34
- package/esm/middlewares/createActionTrackingMiddleware2.js +0 -130
- package/esm/middlewares/createActionTrackingMiddleware2.js.map +0 -1
- package/esm/middlewares/on-action.d.ts +0 -87
- package/esm/middlewares/on-action.js +0 -210
- package/esm/middlewares/on-action.js.map +0 -1
- package/esm/types/complex-types/array.d.ts +0 -81
- package/esm/types/complex-types/array.js +0 -347
- package/esm/types/complex-types/array.js.map +0 -1
- package/esm/types/complex-types/map.d.ts +0 -111
- package/esm/types/complex-types/map.js +0 -356
- package/esm/types/complex-types/map.js.map +0 -1
- package/esm/types/complex-types/model.d.ts +0 -193
- package/esm/types/complex-types/model.js +0 -471
- package/esm/types/complex-types/model.js.map +0 -1
- package/esm/types/index.d.ts +0 -33
- package/esm/types/index.js +0 -35
- package/esm/types/index.js.map +0 -1
- package/esm/types/primitives.d.ts +0 -125
- package/esm/types/primitives.js +0 -177
- package/esm/types/primitives.js.map +0 -1
- package/esm/types/utility-types/custom.d.ts +0 -75
- package/esm/types/utility-types/custom.js +0 -106
- package/esm/types/utility-types/custom.js.map +0 -1
- package/esm/types/utility-types/enumeration.d.ts +0 -5
- package/esm/types/utility-types/enumeration.js +0 -31
- package/esm/types/utility-types/enumeration.js.map +0 -1
- package/esm/types/utility-types/frozen.d.ts +0 -24
- package/esm/types/utility-types/frozen.js +0 -92
- package/esm/types/utility-types/frozen.js.map +0 -1
- package/esm/types/utility-types/identifier.d.ts +0 -87
- package/esm/types/utility-types/identifier.js +0 -121
- package/esm/types/utility-types/identifier.js.map +0 -1
- package/esm/types/utility-types/late.d.ts +0 -10
- package/esm/types/utility-types/late.js +0 -106
- package/esm/types/utility-types/late.js.map +0 -1
- package/esm/types/utility-types/lazy.d.ts +0 -23
- package/esm/types/utility-types/lazy.js +0 -72
- package/esm/types/utility-types/lazy.js.map +0 -1
- package/esm/types/utility-types/literal.d.ts +0 -38
- package/esm/types/utility-types/literal.js +0 -58
- package/esm/types/utility-types/literal.js.map +0 -1
- package/esm/types/utility-types/maybe.d.ts +0 -26
- package/esm/types/utility-types/maybe.js +0 -26
- package/esm/types/utility-types/maybe.js.map +0 -1
- package/esm/types/utility-types/optional.d.ts +0 -42
- package/esm/types/utility-types/optional.js +0 -135
- package/esm/types/utility-types/optional.js.map +0 -1
- package/esm/types/utility-types/reference.d.ts +0 -90
- package/esm/types/utility-types/reference.js +0 -383
- package/esm/types/utility-types/reference.js.map +0 -1
- package/esm/types/utility-types/refinement.d.ts +0 -10
- package/esm/types/utility-types/refinement.js +0 -82
- package/esm/types/utility-types/refinement.js.map +0 -1
- package/esm/types/utility-types/resilient.d.ts +0 -18
- package/esm/types/utility-types/resilient.js +0 -118
- package/esm/types/utility-types/resilient.js.map +0 -1
- package/esm/types/utility-types/snapshotProcessor.d.ts +0 -63
- package/esm/types/utility-types/snapshotProcessor.js +0 -159
- package/esm/types/utility-types/snapshotProcessor.js.map +0 -1
- package/esm/types/utility-types/union.d.ts +0 -78
- package/esm/types/utility-types/union.js +0 -240
- package/esm/types/utility-types/union.js.map +0 -1
- package/esm/utils.d.ts +0 -230
- package/esm/utils.js +0 -449
- package/esm/utils.js.map +0 -1
package/esm/core/type/type.d.ts
DELETED
|
@@ -1,317 +0,0 @@
|
|
|
1
|
-
import { BaseNode } from "../../internal.ts";
|
|
2
|
-
import type { AnyNode, AnyObjectNode, IChildNodesMap, IJsonPatch, IStateTreeNode, IValidationContext, IValidationResult, ModelPrimitive, ObjectNode, ScalarNode } from "../../internal.ts";
|
|
3
|
-
/**
|
|
4
|
-
* @internal
|
|
5
|
-
* @hidden
|
|
6
|
-
*/
|
|
7
|
-
export declare enum TypeFlags {
|
|
8
|
-
String = 1,
|
|
9
|
-
Number = 2,
|
|
10
|
-
Boolean = 4,
|
|
11
|
-
Date = 8,
|
|
12
|
-
Literal = 16,
|
|
13
|
-
Array = 32,
|
|
14
|
-
Map = 64,
|
|
15
|
-
Object = 128,
|
|
16
|
-
Frozen = 256,
|
|
17
|
-
Optional = 512,
|
|
18
|
-
Reference = 1024,
|
|
19
|
-
Identifier = 2048,
|
|
20
|
-
Late = 4096,
|
|
21
|
-
Refinement = 8192,
|
|
22
|
-
Union = 16384,
|
|
23
|
-
Null = 32768,
|
|
24
|
-
Undefined = 65536,
|
|
25
|
-
Integer = 131072,
|
|
26
|
-
Custom = 262144,
|
|
27
|
-
SnapshotProcessor = 524288,
|
|
28
|
-
Lazy = 1048576,
|
|
29
|
-
Finite = 2097152,
|
|
30
|
-
Float = 4194304
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* @internal
|
|
34
|
-
* @hidden
|
|
35
|
-
*/
|
|
36
|
-
export declare const cannotDetermineSubtype = "cannotDetermine";
|
|
37
|
-
/**
|
|
38
|
-
* A state tree node value.
|
|
39
|
-
* @hidden
|
|
40
|
-
*/
|
|
41
|
-
export type STNValue<T, IT extends IAnyType> = T extends object ? T & IStateTreeNode<IT> : T;
|
|
42
|
-
/** @hidden */
|
|
43
|
-
declare const $type: unique symbol;
|
|
44
|
-
/**
|
|
45
|
-
* A type, either complex or simple.
|
|
46
|
-
*/
|
|
47
|
-
export interface IType<C, S, T> {
|
|
48
|
-
/** @hidden */
|
|
49
|
-
readonly [$type]: undefined;
|
|
50
|
-
/**
|
|
51
|
-
* Friendly type name.
|
|
52
|
-
*/
|
|
53
|
-
name: string;
|
|
54
|
-
/**
|
|
55
|
-
* Name of the identifier attribute or null if none.
|
|
56
|
-
*/
|
|
57
|
-
readonly identifierAttribute?: string;
|
|
58
|
-
/**
|
|
59
|
-
* Creates an instance for the type given an snapshot input.
|
|
60
|
-
*
|
|
61
|
-
* @returns An instance of that type.
|
|
62
|
-
*/
|
|
63
|
-
create(snapshot?: C, env?: any): this["Type"];
|
|
64
|
-
/**
|
|
65
|
-
* Checks if a given snapshot / instance is of the given type.
|
|
66
|
-
*
|
|
67
|
-
* @param thing Snapshot or instance to be checked.
|
|
68
|
-
* @returns true if the value is of the current type, false otherwise.
|
|
69
|
-
*/
|
|
70
|
-
is(thing: any): thing is C | this["Type"];
|
|
71
|
-
/**
|
|
72
|
-
* Run's the type's typechecker on the given value with the given validation context.
|
|
73
|
-
*
|
|
74
|
-
* @param thing Value to be checked, either a snapshot or an instance.
|
|
75
|
-
* @param context Validation context, an array of { subpaths, subtypes } that should be validated
|
|
76
|
-
* @returns The validation result, an array with the list of validation errors.
|
|
77
|
-
*/
|
|
78
|
-
validate(thing: C, context: IValidationContext): IValidationResult;
|
|
79
|
-
/**
|
|
80
|
-
* Gets the textual representation of the type as a string.
|
|
81
|
-
*/
|
|
82
|
-
describe(): string;
|
|
83
|
-
/**
|
|
84
|
-
* @deprecated use `Instance<typeof MyType>` instead.
|
|
85
|
-
* @hidden
|
|
86
|
-
*/
|
|
87
|
-
readonly Type: STNValue<T, this>;
|
|
88
|
-
/**
|
|
89
|
-
* @deprecated do not use.
|
|
90
|
-
* @hidden
|
|
91
|
-
*/
|
|
92
|
-
readonly TypeWithoutSTN: T;
|
|
93
|
-
/**
|
|
94
|
-
* @deprecated use `SnapshotOut<typeof MyType>` instead.
|
|
95
|
-
* @hidden
|
|
96
|
-
*/
|
|
97
|
-
readonly SnapshotType: S;
|
|
98
|
-
/**
|
|
99
|
-
* @deprecated use `SnapshotIn<typeof MyType>` instead.
|
|
100
|
-
* @hidden
|
|
101
|
-
*/
|
|
102
|
-
readonly CreationType: C;
|
|
103
|
-
/**
|
|
104
|
-
* @internal
|
|
105
|
-
* @hidden
|
|
106
|
-
*/
|
|
107
|
-
flags: TypeFlags;
|
|
108
|
-
/**
|
|
109
|
-
* @internal
|
|
110
|
-
* @hidden
|
|
111
|
-
*/
|
|
112
|
-
isType: true;
|
|
113
|
-
/**
|
|
114
|
-
* @internal
|
|
115
|
-
* @hidden
|
|
116
|
-
*/
|
|
117
|
-
instantiate(parent: AnyObjectNode | null, subpath: string, environment: any, initialValue: C | T): BaseNode<C, S, T>;
|
|
118
|
-
/**
|
|
119
|
-
* @internal
|
|
120
|
-
* @hidden
|
|
121
|
-
*/
|
|
122
|
-
reconcile(current: BaseNode<C, S, T>, newValue: C | T, parent: AnyObjectNode, subpath: string): BaseNode<C, S, T>;
|
|
123
|
-
/**
|
|
124
|
-
* @internal
|
|
125
|
-
* @hidden
|
|
126
|
-
*/
|
|
127
|
-
getSnapshot(node: BaseNode<C, S, T>, applyPostProcess?: boolean): S;
|
|
128
|
-
/**
|
|
129
|
-
* @internal
|
|
130
|
-
* @hidden
|
|
131
|
-
*/
|
|
132
|
-
isAssignableFrom(type: IAnyType): boolean;
|
|
133
|
-
/**
|
|
134
|
-
* @internal
|
|
135
|
-
* @hidden
|
|
136
|
-
*/
|
|
137
|
-
getSubTypes(): IAnyType[] | IAnyType | null | typeof cannotDetermineSubtype;
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* Any kind of type.
|
|
141
|
-
*/
|
|
142
|
-
export interface IAnyType extends IType<any, any, any> {
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* A simple type, this is, a type where the instance and the snapshot representation are the same.
|
|
146
|
-
*/
|
|
147
|
-
export interface ISimpleType<T> extends IType<T, T, T> {
|
|
148
|
-
}
|
|
149
|
-
/** @hidden */
|
|
150
|
-
export type Primitives = ModelPrimitive | null | undefined;
|
|
151
|
-
/**
|
|
152
|
-
* A complex type.
|
|
153
|
-
* @deprecated just for compatibility with old versions, could be deprecated on the next major version
|
|
154
|
-
* @hidden
|
|
155
|
-
*/
|
|
156
|
-
export interface IComplexType<C, S, T> extends IType<C, S, T & object> {
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Any kind of complex type.
|
|
160
|
-
*/
|
|
161
|
-
export interface IAnyComplexType extends IType<any, any, object> {
|
|
162
|
-
}
|
|
163
|
-
/** @hidden */
|
|
164
|
-
export type ExtractCSTWithoutSTN<IT extends {
|
|
165
|
-
[$type]: undefined;
|
|
166
|
-
CreationType: any;
|
|
167
|
-
SnapshotType: any;
|
|
168
|
-
TypeWithoutSTN: any;
|
|
169
|
-
}> = IT["CreationType"] | IT["SnapshotType"] | IT["TypeWithoutSTN"];
|
|
170
|
-
/** @hidden */
|
|
171
|
-
export type ExtractCSTWithSTN<IT extends {
|
|
172
|
-
[$type]: undefined;
|
|
173
|
-
CreationType: any;
|
|
174
|
-
SnapshotType: any;
|
|
175
|
-
Type: any;
|
|
176
|
-
}> = IT["CreationType"] | IT["SnapshotType"] | IT["Type"];
|
|
177
|
-
/**
|
|
178
|
-
* The instance representation of a given type.
|
|
179
|
-
*/
|
|
180
|
-
export type Instance<T> = T extends {
|
|
181
|
-
[$type]: undefined;
|
|
182
|
-
Type: any;
|
|
183
|
-
} ? T["Type"] : T;
|
|
184
|
-
/**
|
|
185
|
-
* The input (creation) snapshot representation of a given type.
|
|
186
|
-
*/
|
|
187
|
-
export type SnapshotIn<T> = T extends {
|
|
188
|
-
[$type]: undefined;
|
|
189
|
-
CreationType: any;
|
|
190
|
-
} ? T["CreationType"] : T extends IStateTreeNode<infer IT> ? IT["CreationType"] : T;
|
|
191
|
-
/**
|
|
192
|
-
* The output snapshot representation of a given type.
|
|
193
|
-
*/
|
|
194
|
-
export type SnapshotOut<T> = T extends {
|
|
195
|
-
[$type]: undefined;
|
|
196
|
-
SnapshotType: any;
|
|
197
|
-
} ? T["SnapshotType"] : T extends IStateTreeNode<infer IT> ? IT["SnapshotType"] : T;
|
|
198
|
-
/**
|
|
199
|
-
* A type which is equivalent to the union of SnapshotIn and Instance types of a given typeof TYPE or typeof VARIABLE.
|
|
200
|
-
* For primitives it defaults to the primitive itself.
|
|
201
|
-
*
|
|
202
|
-
* For example:
|
|
203
|
-
* - `SnapshotOrInstance<typeof ModelA> = SnapshotIn<typeof ModelA> | Instance<typeof ModelA>`
|
|
204
|
-
* - `SnapshotOrInstance<typeof self.a (where self.a is a ModelA)> = SnapshotIn<typeof ModelA> | Instance<typeof ModelA>`
|
|
205
|
-
*
|
|
206
|
-
* Usually you might want to use this when your model has a setter action that sets a property.
|
|
207
|
-
*
|
|
208
|
-
* Example:
|
|
209
|
-
* ```ts
|
|
210
|
-
* const ModelA = types.model({
|
|
211
|
-
* n: types.number
|
|
212
|
-
* })
|
|
213
|
-
*
|
|
214
|
-
* const ModelB = types.model({
|
|
215
|
-
* innerModel: ModelA
|
|
216
|
-
* }).actions(self => ({
|
|
217
|
-
* // this will accept as property both the snapshot and the instance, whichever is preferred
|
|
218
|
-
* setInnerModel(m: SnapshotOrInstance<typeof self.innerModel>) {
|
|
219
|
-
* self.innerModel = cast(m)
|
|
220
|
-
* }
|
|
221
|
-
* }))
|
|
222
|
-
* ```
|
|
223
|
-
*/
|
|
224
|
-
export type SnapshotOrInstance<T> = SnapshotIn<T> | Instance<T>;
|
|
225
|
-
/**
|
|
226
|
-
* A base type produces a MST node (Node in the state tree)
|
|
227
|
-
*
|
|
228
|
-
* @internal
|
|
229
|
-
* @hidden
|
|
230
|
-
*/
|
|
231
|
-
export declare abstract class BaseType<C, S, T, N extends BaseNode<any, any, any> = BaseNode<C, S, T>> implements IType<C, S, T> {
|
|
232
|
-
[$type]: undefined;
|
|
233
|
-
readonly C: C;
|
|
234
|
-
readonly S: S;
|
|
235
|
-
readonly T: T;
|
|
236
|
-
readonly N: N;
|
|
237
|
-
readonly isType = true;
|
|
238
|
-
readonly name: string;
|
|
239
|
-
constructor(name: string);
|
|
240
|
-
create(snapshot?: C, environment?: any): any;
|
|
241
|
-
getSnapshot(_node: N, _applyPostProcess?: boolean): S;
|
|
242
|
-
abstract reconcile(current: N, newValue: C | T, parent: AnyObjectNode, subpath: string): N;
|
|
243
|
-
abstract instantiate(parent: AnyObjectNode | null, subpath: string, environment: any, initialValue: C | T): N;
|
|
244
|
-
abstract flags: TypeFlags;
|
|
245
|
-
abstract describe(): string;
|
|
246
|
-
abstract isValidSnapshot(value: C, context: IValidationContext): IValidationResult;
|
|
247
|
-
isAssignableFrom(type: IAnyType): boolean;
|
|
248
|
-
validate(value: C | T, context: IValidationContext): IValidationResult;
|
|
249
|
-
is(thing: any): thing is any;
|
|
250
|
-
get Type(): any;
|
|
251
|
-
get TypeWithoutSTN(): any;
|
|
252
|
-
get SnapshotType(): any;
|
|
253
|
-
get CreationType(): any;
|
|
254
|
-
abstract getSubTypes(): IAnyType[] | IAnyType | null | typeof cannotDetermineSubtype;
|
|
255
|
-
}
|
|
256
|
-
/**
|
|
257
|
-
* @internal
|
|
258
|
-
* @hidden
|
|
259
|
-
*/
|
|
260
|
-
export type AnyBaseType = BaseType<any, any, any, any>;
|
|
261
|
-
/**
|
|
262
|
-
* @internal
|
|
263
|
-
* @hidden
|
|
264
|
-
*/
|
|
265
|
-
export type ExtractNodeType<IT extends IAnyType> = IT extends BaseType<any, any, any, infer N> ? N : never;
|
|
266
|
-
/**
|
|
267
|
-
* A complex type produces a MST node (Node in the state tree)
|
|
268
|
-
*
|
|
269
|
-
* @internal
|
|
270
|
-
* @hidden
|
|
271
|
-
*/
|
|
272
|
-
export declare abstract class ComplexType<C, S, T> extends BaseType<C, S, T, ObjectNode<C, S, T>> {
|
|
273
|
-
identifierAttribute?: string;
|
|
274
|
-
constructor(name: string);
|
|
275
|
-
create(snapshot?: C, environment?: any): any;
|
|
276
|
-
getValue(node: this["N"]): T;
|
|
277
|
-
abstract getDefaultSnapshot(): C;
|
|
278
|
-
abstract createNewInstance(childNodes: IChildNodesMap): T;
|
|
279
|
-
abstract finalizeNewInstance(node: this["N"], instance: any): void;
|
|
280
|
-
abstract applySnapshot(node: this["N"], snapshot: C): void;
|
|
281
|
-
abstract applyPatchLocally(node: this["N"], subpath: string, patch: IJsonPatch): void;
|
|
282
|
-
abstract processInitialSnapshot(childNodes: IChildNodesMap, snapshot: C): S;
|
|
283
|
-
abstract getChildren(node: this["N"]): ReadonlyArray<AnyNode>;
|
|
284
|
-
abstract getChildNode(node: this["N"], key: string): AnyNode;
|
|
285
|
-
abstract getChildType(propertyName?: string): IAnyType;
|
|
286
|
-
abstract initializeChildNodes(node: this["N"], snapshot: any): IChildNodesMap;
|
|
287
|
-
abstract removeChild(node: this["N"], subpath: string): void;
|
|
288
|
-
isMatchingSnapshotId(current: this["N"], snapshot: C): boolean;
|
|
289
|
-
private tryToReconcileNode;
|
|
290
|
-
reconcile(current: this["N"], newValue: C | T, parent: AnyObjectNode, subpath: string): this["N"];
|
|
291
|
-
getSubTypes(): null;
|
|
292
|
-
}
|
|
293
|
-
/**
|
|
294
|
-
* @internal
|
|
295
|
-
* @hidden
|
|
296
|
-
*/
|
|
297
|
-
export declare abstract class SimpleType<C, S, T> extends BaseType<C, S, T, ScalarNode<C, S, T>> {
|
|
298
|
-
abstract instantiate(parent: AnyObjectNode | null, subpath: string, environment: any, initialValue: C): this["N"];
|
|
299
|
-
createNewInstance(snapshot: C): T;
|
|
300
|
-
getValue(node: this["N"]): T;
|
|
301
|
-
getSnapshot(node: this["N"]): S;
|
|
302
|
-
reconcile(current: this["N"], newValue: C, parent: AnyObjectNode, subpath: string): this["N"];
|
|
303
|
-
getSubTypes(): null;
|
|
304
|
-
}
|
|
305
|
-
/**
|
|
306
|
-
* Returns if a given value represents a type.
|
|
307
|
-
*
|
|
308
|
-
* @param value Value to check.
|
|
309
|
-
* @returns `true` if the value is a type.
|
|
310
|
-
*/
|
|
311
|
-
export declare function isType(value: any): value is IAnyType;
|
|
312
|
-
/**
|
|
313
|
-
* @internal
|
|
314
|
-
* @hidden
|
|
315
|
-
*/
|
|
316
|
-
export declare function assertIsType(type: IAnyType, argNumber: number | number[]): void;
|
|
317
|
-
export {};
|
package/esm/core/type/type.js
DELETED
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
import { action } from "mobx";
|
|
2
|
-
import { assertArg, fail, getStateTreeNode, getStateTreeNodeSafe, getType, isMutable, isStateTreeNode, normalizeIdentifier, typeCheckFailure, typeCheckSuccess, typecheckInternal } from "../../internal.js";
|
|
3
|
-
// Cache for validation results to avoid re-validating the same object against the same type
|
|
4
|
-
// Uses WeakMap so cached objects can be garbage collected
|
|
5
|
-
const validationCache = new WeakMap();
|
|
6
|
-
/**
|
|
7
|
-
* @internal
|
|
8
|
-
* @hidden
|
|
9
|
-
*/
|
|
10
|
-
export var TypeFlags;
|
|
11
|
-
(function (TypeFlags) {
|
|
12
|
-
TypeFlags[TypeFlags["String"] = 1] = "String";
|
|
13
|
-
TypeFlags[TypeFlags["Number"] = 2] = "Number";
|
|
14
|
-
TypeFlags[TypeFlags["Boolean"] = 4] = "Boolean";
|
|
15
|
-
TypeFlags[TypeFlags["Date"] = 8] = "Date";
|
|
16
|
-
TypeFlags[TypeFlags["Literal"] = 16] = "Literal";
|
|
17
|
-
TypeFlags[TypeFlags["Array"] = 32] = "Array";
|
|
18
|
-
TypeFlags[TypeFlags["Map"] = 64] = "Map";
|
|
19
|
-
TypeFlags[TypeFlags["Object"] = 128] = "Object";
|
|
20
|
-
TypeFlags[TypeFlags["Frozen"] = 256] = "Frozen";
|
|
21
|
-
TypeFlags[TypeFlags["Optional"] = 512] = "Optional";
|
|
22
|
-
TypeFlags[TypeFlags["Reference"] = 1024] = "Reference";
|
|
23
|
-
TypeFlags[TypeFlags["Identifier"] = 2048] = "Identifier";
|
|
24
|
-
TypeFlags[TypeFlags["Late"] = 4096] = "Late";
|
|
25
|
-
TypeFlags[TypeFlags["Refinement"] = 8192] = "Refinement";
|
|
26
|
-
TypeFlags[TypeFlags["Union"] = 16384] = "Union";
|
|
27
|
-
TypeFlags[TypeFlags["Null"] = 32768] = "Null";
|
|
28
|
-
TypeFlags[TypeFlags["Undefined"] = 65536] = "Undefined";
|
|
29
|
-
TypeFlags[TypeFlags["Integer"] = 131072] = "Integer";
|
|
30
|
-
TypeFlags[TypeFlags["Custom"] = 262144] = "Custom";
|
|
31
|
-
TypeFlags[TypeFlags["SnapshotProcessor"] = 524288] = "SnapshotProcessor";
|
|
32
|
-
TypeFlags[TypeFlags["Lazy"] = 1048576] = "Lazy";
|
|
33
|
-
TypeFlags[TypeFlags["Finite"] = 2097152] = "Finite";
|
|
34
|
-
TypeFlags[TypeFlags["Float"] = 4194304] = "Float";
|
|
35
|
-
})(TypeFlags || (TypeFlags = {}));
|
|
36
|
-
/**
|
|
37
|
-
* @internal
|
|
38
|
-
* @hidden
|
|
39
|
-
*/
|
|
40
|
-
export const cannotDetermineSubtype = "cannotDetermine";
|
|
41
|
-
/** @hidden */
|
|
42
|
-
const $type = Symbol("$type");
|
|
43
|
-
/**
|
|
44
|
-
* A base type produces a MST node (Node in the state tree)
|
|
45
|
-
*
|
|
46
|
-
* @internal
|
|
47
|
-
* @hidden
|
|
48
|
-
*/
|
|
49
|
-
export class BaseType {
|
|
50
|
-
[$type];
|
|
51
|
-
// these are just to make inner types avaialable to inherited classes
|
|
52
|
-
C;
|
|
53
|
-
S;
|
|
54
|
-
T;
|
|
55
|
-
N;
|
|
56
|
-
isType = true;
|
|
57
|
-
name;
|
|
58
|
-
constructor(name) {
|
|
59
|
-
this.name = name;
|
|
60
|
-
}
|
|
61
|
-
create(snapshot, environment) {
|
|
62
|
-
typecheckInternal(this, snapshot);
|
|
63
|
-
return this.instantiate(null, "", environment, snapshot).value;
|
|
64
|
-
}
|
|
65
|
-
getSnapshot(_node, _applyPostProcess) {
|
|
66
|
-
// istanbul ignore next
|
|
67
|
-
throw fail("unimplemented method");
|
|
68
|
-
}
|
|
69
|
-
isAssignableFrom(type) {
|
|
70
|
-
return type === this;
|
|
71
|
-
}
|
|
72
|
-
validate(value, context) {
|
|
73
|
-
const node = getStateTreeNodeSafe(value);
|
|
74
|
-
if (node) {
|
|
75
|
-
const valueType = getType(value);
|
|
76
|
-
return this.isAssignableFrom(valueType)
|
|
77
|
-
? typeCheckSuccess()
|
|
78
|
-
: typeCheckFailure(context, value);
|
|
79
|
-
// it is tempting to compare snapshots, but in that case we should always clone on assignments...
|
|
80
|
-
}
|
|
81
|
-
// check cache for object values (only at root level to avoid context mismatches)
|
|
82
|
-
if (typeof value === "object" && value !== null && context.length === 1) {
|
|
83
|
-
const typeCache = validationCache.get(value);
|
|
84
|
-
if (typeCache) {
|
|
85
|
-
const cached = typeCache.get(this);
|
|
86
|
-
if (cached !== undefined) {
|
|
87
|
-
return cached;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
const result = this.isValidSnapshot(value, context);
|
|
92
|
-
// cache result for object values (only at root level)
|
|
93
|
-
if (typeof value === "object" && value !== null && context.length === 1) {
|
|
94
|
-
let typeCache = validationCache.get(value);
|
|
95
|
-
if (!typeCache) {
|
|
96
|
-
typeCache = new WeakMap();
|
|
97
|
-
validationCache.set(value, typeCache);
|
|
98
|
-
}
|
|
99
|
-
typeCache.set(this, result);
|
|
100
|
-
}
|
|
101
|
-
return result;
|
|
102
|
-
}
|
|
103
|
-
is(thing) {
|
|
104
|
-
return this.validate(thing, [{ path: "", type: this }]).length === 0;
|
|
105
|
-
}
|
|
106
|
-
get Type() {
|
|
107
|
-
// istanbul ignore next
|
|
108
|
-
throw fail("Factory.Type should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.Type`");
|
|
109
|
-
}
|
|
110
|
-
get TypeWithoutSTN() {
|
|
111
|
-
// istanbul ignore next
|
|
112
|
-
throw fail("Factory.TypeWithoutSTN should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.TypeWithoutSTN`");
|
|
113
|
-
}
|
|
114
|
-
get SnapshotType() {
|
|
115
|
-
// istanbul ignore next
|
|
116
|
-
throw fail("Factory.SnapshotType should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.SnapshotType`");
|
|
117
|
-
}
|
|
118
|
-
get CreationType() {
|
|
119
|
-
// istanbul ignore next
|
|
120
|
-
throw fail("Factory.CreationType should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.CreationType`");
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
BaseType.prototype.create = action(BaseType.prototype.create);
|
|
124
|
-
/**
|
|
125
|
-
* A complex type produces a MST node (Node in the state tree)
|
|
126
|
-
*
|
|
127
|
-
* @internal
|
|
128
|
-
* @hidden
|
|
129
|
-
*/
|
|
130
|
-
export class ComplexType extends BaseType {
|
|
131
|
-
identifierAttribute;
|
|
132
|
-
constructor(name) {
|
|
133
|
-
super(name);
|
|
134
|
-
}
|
|
135
|
-
create(snapshot = this.getDefaultSnapshot(), environment) {
|
|
136
|
-
return super.create(snapshot, environment);
|
|
137
|
-
}
|
|
138
|
-
getValue(node) {
|
|
139
|
-
node.createObservableInstanceIfNeeded();
|
|
140
|
-
return node.storedValue;
|
|
141
|
-
}
|
|
142
|
-
isMatchingSnapshotId(current, snapshot) {
|
|
143
|
-
return (!current.identifierAttribute ||
|
|
144
|
-
current.identifier ===
|
|
145
|
-
normalizeIdentifier(snapshot[current.identifierAttribute]));
|
|
146
|
-
}
|
|
147
|
-
tryToReconcileNode(current, newValue) {
|
|
148
|
-
if (current.isDetaching) {
|
|
149
|
-
return false;
|
|
150
|
-
}
|
|
151
|
-
if (current.snapshot === newValue) {
|
|
152
|
-
// newValue is the current snapshot of the node, noop
|
|
153
|
-
return true;
|
|
154
|
-
}
|
|
155
|
-
if (isStateTreeNode(newValue) && getStateTreeNode(newValue) === current) {
|
|
156
|
-
// the current node is the same as the new one
|
|
157
|
-
return true;
|
|
158
|
-
}
|
|
159
|
-
if (current.type === this &&
|
|
160
|
-
isMutable(newValue) &&
|
|
161
|
-
!isStateTreeNode(newValue) &&
|
|
162
|
-
this.isMatchingSnapshotId(current, newValue)) {
|
|
163
|
-
// the newValue has no node, so can be treated like a snapshot
|
|
164
|
-
// we can reconcile
|
|
165
|
-
current.applySnapshot(newValue);
|
|
166
|
-
return true;
|
|
167
|
-
}
|
|
168
|
-
return false;
|
|
169
|
-
}
|
|
170
|
-
reconcile(current, newValue, parent, subpath) {
|
|
171
|
-
const nodeReconciled = this.tryToReconcileNode(current, newValue);
|
|
172
|
-
if (nodeReconciled) {
|
|
173
|
-
current.setParent(parent, subpath);
|
|
174
|
-
return current;
|
|
175
|
-
}
|
|
176
|
-
// current node cannot be recycled in any way
|
|
177
|
-
current.die(); // noop if detaching
|
|
178
|
-
// attempt to reuse the new one
|
|
179
|
-
if (isStateTreeNode(newValue) && this.isAssignableFrom(getType(newValue))) {
|
|
180
|
-
// newValue is a Node as well, move it here..
|
|
181
|
-
const newNode = getStateTreeNode(newValue);
|
|
182
|
-
newNode.setParent(parent, subpath);
|
|
183
|
-
return newNode;
|
|
184
|
-
}
|
|
185
|
-
// nothing to do, we have to create a new node
|
|
186
|
-
return this.instantiate(parent, subpath, undefined, newValue);
|
|
187
|
-
}
|
|
188
|
-
getSubTypes() {
|
|
189
|
-
return null;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
ComplexType.prototype.create = action(ComplexType.prototype.create);
|
|
193
|
-
/**
|
|
194
|
-
* @internal
|
|
195
|
-
* @hidden
|
|
196
|
-
*/
|
|
197
|
-
export class SimpleType extends BaseType {
|
|
198
|
-
createNewInstance(snapshot) {
|
|
199
|
-
return snapshot;
|
|
200
|
-
}
|
|
201
|
-
getValue(node) {
|
|
202
|
-
// if we ever find a case where scalar nodes can be accessed without iterating through its parent
|
|
203
|
-
// uncomment this to make sure the parent chain is created when this is accessed
|
|
204
|
-
// if (node.parent) {
|
|
205
|
-
// node.parent.createObservableInstanceIfNeeded()
|
|
206
|
-
// }
|
|
207
|
-
return node.storedValue;
|
|
208
|
-
}
|
|
209
|
-
getSnapshot(node) {
|
|
210
|
-
return node.storedValue;
|
|
211
|
-
}
|
|
212
|
-
reconcile(current, newValue, parent, subpath) {
|
|
213
|
-
// reconcile only if type and value are still the same, and only if the node is not detaching
|
|
214
|
-
if (!current.isDetaching &&
|
|
215
|
-
current.type === this &&
|
|
216
|
-
current.storedValue === newValue) {
|
|
217
|
-
return current;
|
|
218
|
-
}
|
|
219
|
-
const res = this.instantiate(parent, subpath, undefined, newValue);
|
|
220
|
-
current.die(); // noop if detaching
|
|
221
|
-
return res;
|
|
222
|
-
}
|
|
223
|
-
getSubTypes() {
|
|
224
|
-
return null;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
* Returns if a given value represents a type.
|
|
229
|
-
*
|
|
230
|
-
* @param value Value to check.
|
|
231
|
-
* @returns `true` if the value is a type.
|
|
232
|
-
*/
|
|
233
|
-
export function isType(value) {
|
|
234
|
-
return typeof value === "object" && value && value.isType === true;
|
|
235
|
-
}
|
|
236
|
-
/**
|
|
237
|
-
* @internal
|
|
238
|
-
* @hidden
|
|
239
|
-
*/
|
|
240
|
-
export function assertIsType(type, argNumber) {
|
|
241
|
-
assertArg(type, isType, "mobx-state-tree type", argNumber);
|
|
242
|
-
}
|
|
243
|
-
//# sourceMappingURL=type.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../../src/core/type/type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAE7B,OAAO,EAEL,SAAS,EACT,IAAI,EACJ,gBAAgB,EAChB,oBAAoB,EACpB,OAAO,EACP,SAAS,EACT,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,mBAAmB,CAAA;AAE1B,4FAA4F;AAC5F,0DAA0D;AAC1D,MAAM,eAAe,GAAG,IAAI,OAAO,EAGhC,CAAA;AAeH;;;GAGG;AACH,MAAM,CA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AC;IAED,WAAW;QACT,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,UAAU,MAAM,CAAC,KAAU;IAC/B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,IAAI,CAAA;AACpE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,IAAc,EAAE,SAA4B;IACvE,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,sBAAsB,EAAE,SAAS,CAAC,CAAA;AAC5D,CAAC","sourcesContent":["import { action } from \"mobx\"\n\nimport {\n BaseNode,\n assertArg,\n fail,\n getStateTreeNode,\n getStateTreeNodeSafe,\n getType,\n isMutable,\n isStateTreeNode,\n normalizeIdentifier,\n typeCheckFailure,\n typeCheckSuccess,\n typecheckInternal\n} from \"../../internal.ts\"\n\n// Cache for validation results to avoid re-validating the same object against the same type\n// Uses WeakMap so cached objects can be garbage collected\nconst validationCache = new WeakMap<\n object,\n WeakMap<BaseType<any, any, any, any>, IValidationResult>\n>()\n\nimport type {\n AnyNode,\n AnyObjectNode,\n IChildNodesMap,\n IJsonPatch,\n IStateTreeNode,\n IValidationContext,\n IValidationResult,\n ModelPrimitive,\n ObjectNode,\n ScalarNode\n} from \"../../internal.ts\"\n\n/**\n * @internal\n * @hidden\n */\nexport enum TypeFlags {\n String = 1,\n Number = 1 << 1,\n Boolean = 1 << 2,\n Date = 1 << 3,\n Literal = 1 << 4,\n Array = 1 << 5,\n Map = 1 << 6,\n Object = 1 << 7,\n Frozen = 1 << 8,\n Optional = 1 << 9,\n Reference = 1 << 10,\n Identifier = 1 << 11,\n Late = 1 << 12,\n Refinement = 1 << 13,\n Union = 1 << 14,\n Null = 1 << 15,\n Undefined = 1 << 16,\n Integer = 1 << 17,\n Custom = 1 << 18,\n SnapshotProcessor = 1 << 19,\n Lazy = 1 << 20,\n Finite = 1 << 21,\n Float = 1 << 22\n}\n\n/**\n * @internal\n * @hidden\n */\nexport const cannotDetermineSubtype = \"cannotDetermine\"\n\n/**\n * A state tree node value.\n * @hidden\n */\nexport type STNValue<T, IT extends IAnyType> = T extends object\n ? T & IStateTreeNode<IT>\n : T\n\n/** @hidden */\nconst $type: unique symbol = Symbol(\"$type\")\n\n/**\n * A type, either complex or simple.\n */\nexport interface IType<C, S, T> {\n // fake, will never be present, just for typing\n /** @hidden */\n readonly [$type]: undefined\n\n /**\n * Friendly type name.\n */\n name: string\n\n /**\n * Name of the identifier attribute or null if none.\n */\n readonly identifierAttribute?: string\n\n /**\n * Creates an instance for the type given an snapshot input.\n *\n * @returns An instance of that type.\n */\n create(snapshot?: C, env?: any): this[\"Type\"]\n\n /**\n * Checks if a given snapshot / instance is of the given type.\n *\n * @param thing Snapshot or instance to be checked.\n * @returns true if the value is of the current type, false otherwise.\n */\n is(thing: any): thing is C | this[\"Type\"]\n\n /**\n * Run's the type's typechecker on the given value with the given validation context.\n *\n * @param thing Value to be checked, either a snapshot or an instance.\n * @param context Validation context, an array of { subpaths, subtypes } that should be validated\n * @returns The validation result, an array with the list of validation errors.\n */\n validate(thing: C, context: IValidationContext): IValidationResult\n\n /**\n * Gets the textual representation of the type as a string.\n */\n describe(): string\n\n /**\n * @deprecated use `Instance<typeof MyType>` instead.\n * @hidden\n */\n readonly Type: STNValue<T, this>\n\n /**\n * @deprecated do not use.\n * @hidden\n */\n readonly TypeWithoutSTN: T\n\n /**\n * @deprecated use `SnapshotOut<typeof MyType>` instead.\n * @hidden\n */\n readonly SnapshotType: S\n\n /**\n * @deprecated use `SnapshotIn<typeof MyType>` instead.\n * @hidden\n */\n readonly CreationType: C\n\n // Internal api's\n\n /**\n * @internal\n * @hidden\n */\n flags: TypeFlags\n /**\n * @internal\n * @hidden\n */\n isType: true\n /**\n * @internal\n * @hidden\n */\n instantiate(\n parent: AnyObjectNode | null,\n subpath: string,\n environment: any,\n initialValue: C | T\n ): BaseNode<C, S, T>\n /**\n * @internal\n * @hidden\n */\n reconcile(\n current: BaseNode<C, S, T>,\n newValue: C | T,\n parent: AnyObjectNode,\n subpath: string\n ): BaseNode<C, S, T>\n /**\n * @internal\n * @hidden\n */\n getSnapshot(node: BaseNode<C, S, T>, applyPostProcess?: boolean): S\n /**\n * @internal\n * @hidden\n */\n isAssignableFrom(type: IAnyType): boolean\n /**\n * @internal\n * @hidden\n */\n getSubTypes(): IAnyType[] | IAnyType | null | typeof cannotDetermineSubtype\n}\n\n/**\n * Any kind of type.\n */\nexport interface IAnyType extends IType<any, any, any> {}\n\n/**\n * A simple type, this is, a type where the instance and the snapshot representation are the same.\n */\nexport interface ISimpleType<T> extends IType<T, T, T> {}\n\n/** @hidden */\nexport type Primitives = ModelPrimitive | null | undefined\n\n/**\n * A complex type.\n * @deprecated just for compatibility with old versions, could be deprecated on the next major version\n * @hidden\n */\nexport interface IComplexType<C, S, T> extends IType<C, S, T & object> {}\n\n/**\n * Any kind of complex type.\n */\nexport interface IAnyComplexType extends IType<any, any, object> {}\n\n/** @hidden */\nexport type ExtractCSTWithoutSTN<\n IT extends {\n [$type]: undefined\n CreationType: any\n SnapshotType: any\n TypeWithoutSTN: any\n }\n> = IT[\"CreationType\"] | IT[\"SnapshotType\"] | IT[\"TypeWithoutSTN\"]\n/** @hidden */\nexport type ExtractCSTWithSTN<\n IT extends {\n [$type]: undefined\n CreationType: any\n SnapshotType: any\n Type: any\n }\n> = IT[\"CreationType\"] | IT[\"SnapshotType\"] | IT[\"Type\"]\n\n/**\n * The instance representation of a given type.\n */\nexport type Instance<T> = T extends { [$type]: undefined; Type: any }\n ? T[\"Type\"]\n : T\n\n/**\n * The input (creation) snapshot representation of a given type.\n */\nexport type SnapshotIn<T> = T extends { [$type]: undefined; CreationType: any }\n ? T[\"CreationType\"]\n : T extends IStateTreeNode<infer IT>\n ? IT[\"CreationType\"]\n : T\n\n/**\n * The output snapshot representation of a given type.\n */\nexport type SnapshotOut<T> = T extends { [$type]: undefined; SnapshotType: any }\n ? T[\"SnapshotType\"]\n : T extends IStateTreeNode<infer IT>\n ? IT[\"SnapshotType\"]\n : T\n\n/**\n * A type which is equivalent to the union of SnapshotIn and Instance types of a given typeof TYPE or typeof VARIABLE.\n * For primitives it defaults to the primitive itself.\n *\n * For example:\n * - `SnapshotOrInstance<typeof ModelA> = SnapshotIn<typeof ModelA> | Instance<typeof ModelA>`\n * - `SnapshotOrInstance<typeof self.a (where self.a is a ModelA)> = SnapshotIn<typeof ModelA> | Instance<typeof ModelA>`\n *\n * Usually you might want to use this when your model has a setter action that sets a property.\n *\n * Example:\n * ```ts\n * const ModelA = types.model({\n * n: types.number\n * })\n *\n * const ModelB = types.model({\n * innerModel: ModelA\n * }).actions(self => ({\n * // this will accept as property both the snapshot and the instance, whichever is preferred\n * setInnerModel(m: SnapshotOrInstance<typeof self.innerModel>) {\n * self.innerModel = cast(m)\n * }\n * }))\n * ```\n */\nexport type SnapshotOrInstance<T> = SnapshotIn<T> | Instance<T>\n\n/**\n * A base type produces a MST node (Node in the state tree)\n *\n * @internal\n * @hidden\n */\nexport abstract class BaseType<\n C,\n S,\n T,\n N extends BaseNode<any, any, any> = BaseNode<C, S, T>\n> implements IType<C, S, T> {\n [$type]!: undefined\n\n // these are just to make inner types avaialable to inherited classes\n readonly C!: C\n readonly S!: S\n readonly T!: T\n readonly N!: N\n\n readonly isType = true\n readonly name: string\n\n constructor(name: string) {\n this.name = name\n }\n\n create(snapshot?: C, environment?: any) {\n typecheckInternal(this, snapshot)\n return this.instantiate(null, \"\", environment, snapshot!).value\n }\n\n getSnapshot(_node: N, _applyPostProcess?: boolean): S {\n // istanbul ignore next\n throw fail(\"unimplemented method\")\n }\n\n abstract reconcile(\n current: N,\n newValue: C | T,\n parent: AnyObjectNode,\n subpath: string\n ): N\n\n abstract instantiate(\n parent: AnyObjectNode | null,\n subpath: string,\n environment: any,\n initialValue: C | T\n ): N\n\n declare abstract flags: TypeFlags\n abstract describe(): string\n\n abstract isValidSnapshot(\n value: C,\n context: IValidationContext\n ): IValidationResult\n\n isAssignableFrom(type: IAnyType): boolean {\n return type === this\n }\n\n validate(value: C | T, context: IValidationContext): IValidationResult {\n const node = getStateTreeNodeSafe(value)\n if (node) {\n const valueType = getType(value)\n return this.isAssignableFrom(valueType)\n ? typeCheckSuccess()\n : typeCheckFailure(context, value)\n // it is tempting to compare snapshots, but in that case we should always clone on assignments...\n }\n\n // check cache for object values (only at root level to avoid context mismatches)\n if (typeof value === \"object\" && value !== null && context.length === 1) {\n const typeCache = validationCache.get(value)\n if (typeCache) {\n const cached = typeCache.get(this)\n if (cached !== undefined) {\n return cached\n }\n }\n }\n\n const result = this.isValidSnapshot(value as C, context)\n\n // cache result for object values (only at root level)\n if (typeof value === \"object\" && value !== null && context.length === 1) {\n let typeCache = validationCache.get(value)\n if (!typeCache) {\n typeCache = new WeakMap()\n validationCache.set(value, typeCache)\n }\n typeCache.set(this, result)\n }\n\n return result\n }\n\n is(thing: any): thing is any {\n return this.validate(thing, [{ path: \"\", type: this }]).length === 0\n }\n\n get Type(): any {\n // istanbul ignore next\n throw fail(\n \"Factory.Type should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.Type`\"\n )\n }\n get TypeWithoutSTN(): any {\n // istanbul ignore next\n throw fail(\n \"Factory.TypeWithoutSTN should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.TypeWithoutSTN`\"\n )\n }\n get SnapshotType(): any {\n // istanbul ignore next\n throw fail(\n \"Factory.SnapshotType should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.SnapshotType`\"\n )\n }\n get CreationType(): any {\n // istanbul ignore next\n throw fail(\n \"Factory.CreationType should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.CreationType`\"\n )\n }\n\n abstract getSubTypes():\n | IAnyType[]\n | IAnyType\n | null\n | typeof cannotDetermineSubtype\n}\nBaseType.prototype.create = action(BaseType.prototype.create)\n\n/**\n * @internal\n * @hidden\n */\nexport type AnyBaseType = BaseType<any, any, any, any>\n\n/**\n * @internal\n * @hidden\n */\nexport type ExtractNodeType<IT extends IAnyType> =\n IT extends BaseType<any, any, any, infer N> ? N : never\n\n/**\n * A complex type produces a MST node (Node in the state tree)\n *\n * @internal\n * @hidden\n */\nexport abstract class ComplexType<C, S, T> extends BaseType<\n C,\n S,\n T,\n ObjectNode<C, S, T>\n> {\n identifierAttribute?: string\n\n constructor(name: string) {\n super(name)\n }\n\n create(snapshot: C = this.getDefaultSnapshot(), environment?: any) {\n return super.create(snapshot, environment)\n }\n\n getValue(node: this[\"N\"]): T {\n node.createObservableInstanceIfNeeded()\n return node.storedValue\n }\n\n abstract getDefaultSnapshot(): C\n\n abstract createNewInstance(childNodes: IChildNodesMap): T\n abstract finalizeNewInstance(node: this[\"N\"], instance: any): void\n\n abstract applySnapshot(node: this[\"N\"], snapshot: C): void\n abstract applyPatchLocally(\n node: this[\"N\"],\n subpath: string,\n patch: IJsonPatch\n ): void\n abstract processInitialSnapshot(childNodes: IChildNodesMap, snapshot: C): S\n\n abstract getChildren(node: this[\"N\"]): ReadonlyArray<AnyNode>\n abstract getChildNode(node: this[\"N\"], key: string): AnyNode\n abstract getChildType(propertyName?: string): IAnyType\n abstract initializeChildNodes(node: this[\"N\"], snapshot: any): IChildNodesMap\n abstract removeChild(node: this[\"N\"], subpath: string): void\n\n isMatchingSnapshotId(current: this[\"N\"], snapshot: C): boolean {\n return (\n !current.identifierAttribute ||\n current.identifier ===\n normalizeIdentifier((snapshot as any)[current.identifierAttribute])\n )\n }\n\n private tryToReconcileNode(current: this[\"N\"], newValue: C | T) {\n if (current.isDetaching) {\n return false\n }\n if ((current.snapshot as any) === newValue) {\n // newValue is the current snapshot of the node, noop\n return true\n }\n if (isStateTreeNode(newValue) && getStateTreeNode(newValue) === current) {\n // the current node is the same as the new one\n return true\n }\n if (\n current.type === this &&\n isMutable(newValue) &&\n !isStateTreeNode(newValue) &&\n this.isMatchingSnapshotId(current, newValue as any)\n ) {\n // the newValue has no node, so can be treated like a snapshot\n // we can reconcile\n current.applySnapshot(newValue as C)\n return true\n }\n return false\n }\n\n reconcile(\n current: this[\"N\"],\n newValue: C | T,\n parent: AnyObjectNode,\n subpath: string\n ): this[\"N\"] {\n const nodeReconciled = this.tryToReconcileNode(current, newValue)\n if (nodeReconciled) {\n current.setParent(parent, subpath)\n return current\n }\n\n // current node cannot be recycled in any way\n current.die() // noop if detaching\n // attempt to reuse the new one\n if (isStateTreeNode(newValue) && this.isAssignableFrom(getType(newValue))) {\n // newValue is a Node as well, move it here..\n const newNode = getStateTreeNode(newValue)\n newNode.setParent(parent, subpath)\n return newNode\n }\n // nothing to do, we have to create a new node\n return this.instantiate(parent, subpath, undefined, newValue)\n }\n\n getSubTypes() {\n return null\n }\n}\nComplexType.prototype.create = action(ComplexType.prototype.create)\n\n/**\n * @internal\n * @hidden\n */\nexport abstract class SimpleType<C, S, T> extends BaseType<\n C,\n S,\n T,\n ScalarNode<C, S, T>\n> {\n abstract instantiate(\n parent: AnyObjectNode | null,\n subpath: string,\n environment: any,\n initialValue: C\n ): this[\"N\"]\n\n createNewInstance(snapshot: C): T {\n return snapshot as any\n }\n\n getValue(node: this[\"N\"]): T {\n // if we ever find a case where scalar nodes can be accessed without iterating through its parent\n // uncomment this to make sure the parent chain is created when this is accessed\n // if (node.parent) {\n // node.parent.createObservableInstanceIfNeeded()\n // }\n return node.storedValue\n }\n\n getSnapshot(node: this[\"N\"]): S {\n return node.storedValue\n }\n\n reconcile(\n current: this[\"N\"],\n newValue: C,\n parent: AnyObjectNode,\n subpath: string\n ): this[\"N\"] {\n // reconcile only if type and value are still the same, and only if the node is not detaching\n if (\n !current.isDetaching &&\n current.type === this &&\n current.storedValue === newValue\n ) {\n return current\n }\n const res = this.instantiate(parent, subpath, undefined, newValue)\n current.die() // noop if detaching\n return res\n }\n\n getSubTypes() {\n return null\n }\n}\n\n/**\n * Returns if a given value represents a type.\n *\n * @param value Value to check.\n * @returns `true` if the value is a type.\n */\nexport function isType(value: any): value is IAnyType {\n return typeof value === \"object\" && value && value.isType === true\n}\n\n/**\n * @internal\n * @hidden\n */\nexport function assertIsType(type: IAnyType, argNumber: number | number[]) {\n assertArg(type, isType, \"mobx-state-tree type\", argNumber)\n}\n"]}
|
package/esm/index.d.ts
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export type { CustomTypeOptions, IActionContext, IActionRecorder, IActionTrackingMiddleware2Call, IActionTrackingMiddleware2Hooks, IActionTrackingMiddlewareHooks, IAnyComplexType, IAnyModelType, IAnyStateTreeNode, IAnyType, IArrayType, IComplexType, IDisposer, IJsonPatch, IMSTArray, IMSTMap, IMapType, IMaybe, IMaybeIType, IMaybeNull, IMiddlewareEvent, IMiddlewareEventType, IMiddlewareHandler, IModelReflectionData, IModelReflectionPropertiesData, IModelType, IOptionalIType, IPatchRecorder, IReferenceType, IReversibleJsonPatch, ISerializedActionCall, ISimpleType, ISnapshotProcessor, ISnapshotProcessors, IStateTreeNode, IType, ITypeUnion, Instance, LivelinessMode, LivelynessMode, ModelActions, ModelCreationType2, ModelCreationType, ModelInstanceType, ModelInstanceTypeProps, ModelPrimitive, ModelProperties, ModelPropertiesDeclaration, ModelPropertiesDeclarationToProperties, ModelSnapshotType2, ModelSnapshotType, OnReferenceInvalidated, OnReferenceInvalidatedEvent, OptionalDefaultValueOrFunction, ReferenceIdentifier, ReferenceOptions, ReferenceOptionsGetSet, ReferenceOptionsOnInvalidated, SnapshotIn, SnapshotOrInstance, SnapshotOut, TypeOfValue, TypeOrStateTreeNodeToStateTreeNode, UnionOptions, UnionStringArray, ValidOptionalValue, ValidOptionalValues, _CustomCSProcessor, _CustomJoin, _CustomOrOther, _NotCustomized, NonEmptyObject, ExtractCFromProps } from "./internal.ts";
|
|
2
|
-
export { addDisposer, addMiddleware, applyAction, applyPatch, applySnapshot, cast, castFlowReturn, castToReferenceSnapshot, castToSnapshot, clone, createActionTrackingMiddleware2, createActionTrackingMiddleware, decorate, destroy, detach, escapeJsonPath, flow, getChildType, getEnv, getIdentifier, getLivelinessChecking, getMembers, getNodeId, getParent, getParentOfType, getPath, getPathParts, getPropertyMembers, getRelativePath, getRoot, getRunningActionContext, getSnapshot, getType, hasParent, hasParentOfType, isActionContextChildOf, isActionContextThisOrChildOf, isAlive, isArrayType, isFrozenType, isIdentifierType, isLateType, isLiteralType, isMapType, isModelType, isOptionalType, isPrimitiveType, isProtected, isReferenceType, isRefinementType, isRoot, isStateTreeNode, isType, isUnionType, isValidReference, joinJsonPath, onAction, onPatch, onSnapshot, process, protect, recordActions, recordPatches, resolveIdentifier, resolvePath, setLivelinessChecking, setLivelynessChecking, splitJsonPath, toGenerator, toGeneratorFunction, tryReference, tryResolve, typecheck, types, types as t, unescapeJsonPath, unprotect, walk, setDevMode } from "./internal.ts";
|
package/esm/index.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export { addDisposer, addMiddleware, applyAction, applyPatch, applySnapshot, cast, castFlowReturn, castToReferenceSnapshot, castToSnapshot, clone, createActionTrackingMiddleware2, createActionTrackingMiddleware, decorate, destroy, detach, escapeJsonPath, flow, getChildType, getEnv, getIdentifier, getLivelinessChecking, getMembers, getNodeId, getParent, getParentOfType, getPath, getPathParts, getPropertyMembers, getRelativePath, getRoot, getRunningActionContext, getSnapshot, getType, hasParent, hasParentOfType, isActionContextChildOf, isActionContextThisOrChildOf, isAlive, isArrayType, isFrozenType, isIdentifierType, isLateType, isLiteralType, isMapType, isModelType, isOptionalType, isPrimitiveType, isProtected, isReferenceType, isRefinementType, isRoot, isStateTreeNode, isType, isUnionType, isValidReference, joinJsonPath, onAction, onPatch, onSnapshot, process, protect, recordActions, recordPatches, resolveIdentifier, resolvePath, setLivelinessChecking, setLivelynessChecking, splitJsonPath, toGenerator, toGeneratorFunction, tryReference, tryResolve, typecheck, types, types as t, unescapeJsonPath, unprotect, walk, setDevMode } from "./internal.js";
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
package/esm/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA6EA,OAAO,EACL,WAAW,EACX,aAAa,EACb,WAAW,EACX,UAAU,EACV,aAAa,EACb,IAAI,EACJ,cAAc,EACd,uBAAuB,EACvB,cAAc,EACd,KAAK,EACL,+BAA+B,EAC/B,8BAA8B,EAC9B,QAAQ,EACR,OAAO,EACP,MAAM,EACN,cAAc,EACd,IAAI,EACJ,YAAY,EACZ,MAAM,EACN,aAAa,EACb,qBAAqB,EACrB,UAAU,EACV,SAAS,EACT,SAAS,EACT,eAAe,EACf,OAAO,EACP,YAAY,EACZ,kBAAkB,EAClB,eAAe,EACf,OAAO,EACP,uBAAuB,EACvB,WAAW,EACX,OAAO,EACP,SAAS,EACT,eAAe,EACf,sBAAsB,EACtB,4BAA4B,EAC5B,OAAO,EACP,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,UAAU,EACV,aAAa,EACb,SAAS,EACT,WAAW,EACX,cAAc,EACd,eAAe,EACf,WAAW,EACX,eAAe,EACf,gBAAgB,EAChB,MAAM,EACN,eAAe,EACf,MAAM,EACN,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,QAAQ,EACR,OAAO,EACP,UAAU,EACV,OAAO,EACP,OAAO,EACP,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,WAAW,EACX,qBAAqB,EACrB,qBAAqB,EACrB,aAAa,EACb,WAAW,EACX,mBAAmB,EACnB,YAAY,EACZ,UAAU,EACV,SAAS,EACT,KAAK,EACL,KAAK,IAAI,CAAC,EACV,gBAAgB,EAChB,SAAS,EACT,IAAI,EACJ,UAAU,EACX,MAAM,eAAe,CAAA","sourcesContent":["/* all code is initially loaded through internal, to avoid circular dep issues */\nexport type {\n CustomTypeOptions,\n IActionContext,\n IActionRecorder,\n IActionTrackingMiddleware2Call,\n IActionTrackingMiddleware2Hooks,\n IActionTrackingMiddlewareHooks,\n IAnyComplexType,\n IAnyModelType,\n IAnyStateTreeNode,\n IAnyType,\n IArrayType,\n IComplexType,\n IDisposer,\n IJsonPatch,\n IMSTArray,\n IMSTMap,\n IMapType,\n IMaybe,\n IMaybeIType,\n IMaybeNull,\n IMiddlewareEvent,\n IMiddlewareEventType,\n IMiddlewareHandler,\n IModelReflectionData,\n IModelReflectionPropertiesData,\n IModelType,\n IOptionalIType,\n IPatchRecorder,\n IReferenceType,\n IReversibleJsonPatch,\n ISerializedActionCall,\n ISimpleType,\n ISnapshotProcessor,\n ISnapshotProcessors,\n IStateTreeNode,\n IType,\n ITypeUnion,\n Instance,\n LivelinessMode,\n LivelynessMode,\n ModelActions,\n ModelCreationType2,\n ModelCreationType,\n ModelInstanceType,\n ModelInstanceTypeProps,\n ModelPrimitive,\n ModelProperties,\n ModelPropertiesDeclaration,\n ModelPropertiesDeclarationToProperties,\n ModelSnapshotType2,\n ModelSnapshotType,\n OnReferenceInvalidated,\n OnReferenceInvalidatedEvent,\n OptionalDefaultValueOrFunction,\n ReferenceIdentifier,\n ReferenceOptions,\n ReferenceOptionsGetSet,\n ReferenceOptionsOnInvalidated,\n SnapshotIn,\n SnapshotOrInstance,\n SnapshotOut,\n TypeOfValue,\n TypeOrStateTreeNodeToStateTreeNode,\n UnionOptions,\n UnionStringArray,\n ValidOptionalValue,\n ValidOptionalValues,\n _CustomCSProcessor,\n _CustomJoin,\n _CustomOrOther,\n _NotCustomized,\n NonEmptyObject,\n ExtractCFromProps\n} from \"./internal.ts\"\n\nexport {\n addDisposer,\n addMiddleware,\n applyAction,\n applyPatch,\n applySnapshot,\n cast,\n castFlowReturn,\n castToReferenceSnapshot,\n castToSnapshot,\n clone,\n createActionTrackingMiddleware2,\n createActionTrackingMiddleware,\n decorate,\n destroy,\n detach,\n escapeJsonPath,\n flow,\n getChildType,\n getEnv,\n getIdentifier,\n getLivelinessChecking,\n getMembers,\n getNodeId,\n getParent,\n getParentOfType,\n getPath,\n getPathParts,\n getPropertyMembers,\n getRelativePath,\n getRoot,\n getRunningActionContext,\n getSnapshot,\n getType,\n hasParent,\n hasParentOfType,\n isActionContextChildOf,\n isActionContextThisOrChildOf,\n isAlive,\n isArrayType,\n isFrozenType,\n isIdentifierType,\n isLateType,\n isLiteralType,\n isMapType,\n isModelType,\n isOptionalType,\n isPrimitiveType,\n isProtected,\n isReferenceType,\n isRefinementType,\n isRoot,\n isStateTreeNode,\n isType,\n isUnionType,\n isValidReference,\n joinJsonPath,\n onAction,\n onPatch,\n onSnapshot,\n process,\n protect,\n recordActions,\n recordPatches,\n resolveIdentifier,\n resolvePath,\n setLivelinessChecking,\n setLivelynessChecking,\n splitJsonPath,\n toGenerator,\n toGeneratorFunction,\n tryReference,\n tryResolve,\n typecheck,\n types,\n types as t,\n unescapeJsonPath,\n unprotect,\n walk,\n setDevMode\n} from \"./internal.ts\"\n"]}
|
package/esm/internal.d.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
export * from "./core/node/livelinessChecking.ts";
|
|
2
|
-
export * from "./core/node/Hook.ts";
|
|
3
|
-
export * from "./core/mst-operations.ts";
|
|
4
|
-
export * from "./core/node/BaseNode.ts";
|
|
5
|
-
export * from "./core/node/scalar-node.ts";
|
|
6
|
-
export * from "./core/node/object-node.ts";
|
|
7
|
-
export * from "./core/type/type.ts";
|
|
8
|
-
export * from "./middlewares/create-action-tracking-middleware.ts";
|
|
9
|
-
export * from "./middlewares/createActionTrackingMiddleware2.ts";
|
|
10
|
-
export * from "./middlewares/on-action.ts";
|
|
11
|
-
export * from "./core/action.ts";
|
|
12
|
-
export * from "./core/actionContext.ts";
|
|
13
|
-
export * from "./core/type/type-checker.ts";
|
|
14
|
-
export * from "./core/node/identifier-cache.ts";
|
|
15
|
-
export * from "./core/node/create-node.ts";
|
|
16
|
-
export * from "./core/node/node-utils.ts";
|
|
17
|
-
export * from "./core/process.ts";
|
|
18
|
-
export * from "./core/flow.ts";
|
|
19
|
-
export * from "./core/json-patch.ts";
|
|
20
|
-
export * from "./utils.ts";
|
|
21
|
-
export * from "./types/utility-types/snapshotProcessor.ts";
|
|
22
|
-
export * from "./types/complex-types/map.ts";
|
|
23
|
-
export * from "./types/complex-types/array.ts";
|
|
24
|
-
export * from "./types/complex-types/model.ts";
|
|
25
|
-
export * from "./types/primitives.ts";
|
|
26
|
-
export * from "./types/utility-types/literal.ts";
|
|
27
|
-
export * from "./types/utility-types/refinement.ts";
|
|
28
|
-
export * from "./types/utility-types/enumeration.ts";
|
|
29
|
-
export * from "./types/utility-types/union.ts";
|
|
30
|
-
export * from "./types/utility-types/optional.ts";
|
|
31
|
-
export * from "./types/utility-types/maybe.ts";
|
|
32
|
-
export * from "./types/utility-types/late.ts";
|
|
33
|
-
export * from "./types/utility-types/lazy.ts";
|
|
34
|
-
export * from "./types/utility-types/frozen.ts";
|
|
35
|
-
export * from "./types/utility-types/reference.ts";
|
|
36
|
-
export * from "./types/utility-types/identifier.ts";
|
|
37
|
-
export * from "./types/utility-types/custom.ts";
|
|
38
|
-
export * from "./types/utility-types/resilient.ts";
|
|
39
|
-
export * from "./types/index.ts";
|