@jbrowse/mobx-state-tree 5.7.1 → 5.8.7

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 (253) hide show
  1. package/README.md +0 -10
  2. package/dist/index.d.ts +2135 -2
  3. package/dist/mobx-state-tree.cjs +6894 -0
  4. package/dist/mobx-state-tree.cjs.map +1 -0
  5. package/dist/mobx-state-tree.mjs +6814 -0
  6. package/dist/mobx-state-tree.mjs.map +1 -0
  7. package/package.json +30 -26
  8. package/dist/core/action.d.ts +0 -87
  9. package/dist/core/action.js +0 -228
  10. package/dist/core/action.js.map +0 -1
  11. package/dist/core/actionContext.d.ts +0 -27
  12. package/dist/core/actionContext.js +0 -42
  13. package/dist/core/actionContext.js.map +0 -1
  14. package/dist/core/flow.d.ts +0 -69
  15. package/dist/core/flow.js +0 -180
  16. package/dist/core/flow.js.map +0 -1
  17. package/dist/core/json-patch.d.ts +0 -46
  18. package/dist/core/json-patch.js +0 -133
  19. package/dist/core/json-patch.js.map +0 -1
  20. package/dist/core/mst-operations.d.ts +0 -459
  21. package/dist/core/mst-operations.js +0 -885
  22. package/dist/core/mst-operations.js.map +0 -1
  23. package/dist/core/node/BaseNode.d.ts +0 -62
  24. package/dist/core/node/BaseNode.js +0 -152
  25. package/dist/core/node/BaseNode.js.map +0 -1
  26. package/dist/core/node/Hook.d.ts +0 -17
  27. package/dist/core/node/Hook.js +0 -15
  28. package/dist/core/node/Hook.js.map +0 -1
  29. package/dist/core/node/create-node.d.ts +0 -16
  30. package/dist/core/node/create-node.js +0 -41
  31. package/dist/core/node/create-node.js.map +0 -1
  32. package/dist/core/node/identifier-cache.d.ts +0 -19
  33. package/dist/core/node/identifier-cache.js +0 -115
  34. package/dist/core/node/identifier-cache.js.map +0 -1
  35. package/dist/core/node/livelinessChecking.d.ts +0 -37
  36. package/dist/core/node/livelinessChecking.js +0 -38
  37. package/dist/core/node/livelinessChecking.js.map +0 -1
  38. package/dist/core/node/node-utils.d.ts +0 -83
  39. package/dist/core/node/node-utils.js +0 -165
  40. package/dist/core/node/node-utils.js.map +0 -1
  41. package/dist/core/node/object-node.d.ts +0 -101
  42. package/dist/core/node/object-node.js +0 -546
  43. package/dist/core/node/object-node.js.map +0 -1
  44. package/dist/core/node/scalar-node.d.ts +0 -21
  45. package/dist/core/node/scalar-node.js +0 -90
  46. package/dist/core/node/scalar-node.js.map +0 -1
  47. package/dist/core/process.d.ts +0 -50
  48. package/dist/core/process.js +0 -39
  49. package/dist/core/process.js.map +0 -1
  50. package/dist/core/type/type-checker.d.ts +0 -69
  51. package/dist/core/type/type-checker.js +0 -154
  52. package/dist/core/type/type-checker.js.map +0 -1
  53. package/dist/core/type/type.d.ts +0 -317
  54. package/dist/core/type/type.js +0 -251
  55. package/dist/core/type/type.js.map +0 -1
  56. package/dist/index.js +0 -85
  57. package/dist/index.js.map +0 -1
  58. package/dist/internal.d.ts +0 -39
  59. package/dist/internal.js +0 -60
  60. package/dist/internal.js.map +0 -1
  61. package/dist/middlewares/create-action-tracking-middleware.d.ts +0 -24
  62. package/dist/middlewares/create-action-tracking-middleware.js +0 -81
  63. package/dist/middlewares/create-action-tracking-middleware.js.map +0 -1
  64. package/dist/middlewares/createActionTrackingMiddleware2.d.ts +0 -34
  65. package/dist/middlewares/createActionTrackingMiddleware2.js +0 -133
  66. package/dist/middlewares/createActionTrackingMiddleware2.js.map +0 -1
  67. package/dist/middlewares/on-action.d.ts +0 -87
  68. package/dist/middlewares/on-action.js +0 -215
  69. package/dist/middlewares/on-action.js.map +0 -1
  70. package/dist/package.json +0 -1
  71. package/dist/types/complex-types/array.d.ts +0 -81
  72. package/dist/types/complex-types/array.js +0 -353
  73. package/dist/types/complex-types/array.js.map +0 -1
  74. package/dist/types/complex-types/map.d.ts +0 -111
  75. package/dist/types/complex-types/map.js +0 -362
  76. package/dist/types/complex-types/map.js.map +0 -1
  77. package/dist/types/complex-types/model.d.ts +0 -193
  78. package/dist/types/complex-types/model.js +0 -478
  79. package/dist/types/complex-types/model.js.map +0 -1
  80. package/dist/types/index.d.ts +0 -33
  81. package/dist/types/index.js +0 -38
  82. package/dist/types/index.js.map +0 -1
  83. package/dist/types/primitives.d.ts +0 -125
  84. package/dist/types/primitives.js +0 -183
  85. package/dist/types/primitives.js.map +0 -1
  86. package/dist/types/utility-types/custom.d.ts +0 -75
  87. package/dist/types/utility-types/custom.js +0 -111
  88. package/dist/types/utility-types/custom.js.map +0 -1
  89. package/dist/types/utility-types/enumeration.d.ts +0 -5
  90. package/dist/types/utility-types/enumeration.js +0 -34
  91. package/dist/types/utility-types/enumeration.js.map +0 -1
  92. package/dist/types/utility-types/frozen.d.ts +0 -24
  93. package/dist/types/utility-types/frozen.js +0 -98
  94. package/dist/types/utility-types/frozen.js.map +0 -1
  95. package/dist/types/utility-types/identifier.d.ts +0 -87
  96. package/dist/types/utility-types/identifier.js +0 -130
  97. package/dist/types/utility-types/identifier.js.map +0 -1
  98. package/dist/types/utility-types/late.d.ts +0 -10
  99. package/dist/types/utility-types/late.js +0 -110
  100. package/dist/types/utility-types/late.js.map +0 -1
  101. package/dist/types/utility-types/lazy.d.ts +0 -23
  102. package/dist/types/utility-types/lazy.js +0 -77
  103. package/dist/types/utility-types/lazy.js.map +0 -1
  104. package/dist/types/utility-types/literal.d.ts +0 -38
  105. package/dist/types/utility-types/literal.js +0 -64
  106. package/dist/types/utility-types/literal.js.map +0 -1
  107. package/dist/types/utility-types/maybe.d.ts +0 -26
  108. package/dist/types/utility-types/maybe.js +0 -30
  109. package/dist/types/utility-types/maybe.js.map +0 -1
  110. package/dist/types/utility-types/optional.d.ts +0 -42
  111. package/dist/types/utility-types/optional.js +0 -141
  112. package/dist/types/utility-types/optional.js.map +0 -1
  113. package/dist/types/utility-types/reference.d.ts +0 -90
  114. package/dist/types/utility-types/reference.js +0 -393
  115. package/dist/types/utility-types/reference.js.map +0 -1
  116. package/dist/types/utility-types/refinement.d.ts +0 -10
  117. package/dist/types/utility-types/refinement.js +0 -86
  118. package/dist/types/utility-types/refinement.js.map +0 -1
  119. package/dist/types/utility-types/resilient.d.ts +0 -18
  120. package/dist/types/utility-types/resilient.js +0 -121
  121. package/dist/types/utility-types/resilient.js.map +0 -1
  122. package/dist/types/utility-types/snapshotProcessor.d.ts +0 -63
  123. package/dist/types/utility-types/snapshotProcessor.js +0 -162
  124. package/dist/types/utility-types/snapshotProcessor.js.map +0 -1
  125. package/dist/types/utility-types/union.d.ts +0 -78
  126. package/dist/types/utility-types/union.js +0 -246
  127. package/dist/types/utility-types/union.js.map +0 -1
  128. package/dist/utils.d.ts +0 -230
  129. package/dist/utils.js +0 -483
  130. package/dist/utils.js.map +0 -1
  131. package/esm/core/action.d.ts +0 -87
  132. package/esm/core/action.js +0 -219
  133. package/esm/core/action.js.map +0 -1
  134. package/esm/core/actionContext.d.ts +0 -27
  135. package/esm/core/actionContext.js +0 -37
  136. package/esm/core/actionContext.js.map +0 -1
  137. package/esm/core/flow.d.ts +0 -69
  138. package/esm/core/flow.js +0 -173
  139. package/esm/core/flow.js.map +0 -1
  140. package/esm/core/json-patch.d.ts +0 -46
  141. package/esm/core/json-patch.js +0 -125
  142. package/esm/core/json-patch.js.map +0 -1
  143. package/esm/core/mst-operations.d.ts +0 -459
  144. package/esm/core/mst-operations.js +0 -844
  145. package/esm/core/mst-operations.js.map +0 -1
  146. package/esm/core/node/BaseNode.d.ts +0 -62
  147. package/esm/core/node/BaseNode.js +0 -148
  148. package/esm/core/node/BaseNode.js.map +0 -1
  149. package/esm/core/node/Hook.d.ts +0 -17
  150. package/esm/core/node/Hook.js +0 -12
  151. package/esm/core/node/Hook.js.map +0 -1
  152. package/esm/core/node/create-node.d.ts +0 -16
  153. package/esm/core/node/create-node.js +0 -36
  154. package/esm/core/node/create-node.js.map +0 -1
  155. package/esm/core/node/identifier-cache.d.ts +0 -19
  156. package/esm/core/node/identifier-cache.js +0 -111
  157. package/esm/core/node/identifier-cache.js.map +0 -1
  158. package/esm/core/node/livelinessChecking.d.ts +0 -37
  159. package/esm/core/node/livelinessChecking.js +0 -33
  160. package/esm/core/node/livelinessChecking.js.map +0 -1
  161. package/esm/core/node/node-utils.d.ts +0 -83
  162. package/esm/core/node/node-utils.js +0 -153
  163. package/esm/core/node/node-utils.js.map +0 -1
  164. package/esm/core/node/object-node.d.ts +0 -101
  165. package/esm/core/node/object-node.js +0 -542
  166. package/esm/core/node/object-node.js.map +0 -1
  167. package/esm/core/node/scalar-node.d.ts +0 -21
  168. package/esm/core/node/scalar-node.js +0 -86
  169. package/esm/core/node/scalar-node.js.map +0 -1
  170. package/esm/core/process.d.ts +0 -50
  171. package/esm/core/process.js +0 -35
  172. package/esm/core/process.js.map +0 -1
  173. package/esm/core/type/type-checker.d.ts +0 -69
  174. package/esm/core/type/type-checker.js +0 -144
  175. package/esm/core/type/type-checker.js.map +0 -1
  176. package/esm/core/type/type.d.ts +0 -317
  177. package/esm/core/type/type.js +0 -243
  178. package/esm/core/type/type.js.map +0 -1
  179. package/esm/index.d.ts +0 -2
  180. package/esm/index.js +0 -2
  181. package/esm/index.js.map +0 -1
  182. package/esm/internal.d.ts +0 -39
  183. package/esm/internal.js +0 -44
  184. package/esm/internal.js.map +0 -1
  185. package/esm/middlewares/create-action-tracking-middleware.d.ts +0 -24
  186. package/esm/middlewares/create-action-tracking-middleware.js +0 -78
  187. package/esm/middlewares/create-action-tracking-middleware.js.map +0 -1
  188. package/esm/middlewares/createActionTrackingMiddleware2.d.ts +0 -34
  189. package/esm/middlewares/createActionTrackingMiddleware2.js +0 -130
  190. package/esm/middlewares/createActionTrackingMiddleware2.js.map +0 -1
  191. package/esm/middlewares/on-action.d.ts +0 -87
  192. package/esm/middlewares/on-action.js +0 -210
  193. package/esm/middlewares/on-action.js.map +0 -1
  194. package/esm/types/complex-types/array.d.ts +0 -81
  195. package/esm/types/complex-types/array.js +0 -347
  196. package/esm/types/complex-types/array.js.map +0 -1
  197. package/esm/types/complex-types/map.d.ts +0 -111
  198. package/esm/types/complex-types/map.js +0 -356
  199. package/esm/types/complex-types/map.js.map +0 -1
  200. package/esm/types/complex-types/model.d.ts +0 -193
  201. package/esm/types/complex-types/model.js +0 -471
  202. package/esm/types/complex-types/model.js.map +0 -1
  203. package/esm/types/index.d.ts +0 -33
  204. package/esm/types/index.js +0 -35
  205. package/esm/types/index.js.map +0 -1
  206. package/esm/types/primitives.d.ts +0 -125
  207. package/esm/types/primitives.js +0 -177
  208. package/esm/types/primitives.js.map +0 -1
  209. package/esm/types/utility-types/custom.d.ts +0 -75
  210. package/esm/types/utility-types/custom.js +0 -106
  211. package/esm/types/utility-types/custom.js.map +0 -1
  212. package/esm/types/utility-types/enumeration.d.ts +0 -5
  213. package/esm/types/utility-types/enumeration.js +0 -31
  214. package/esm/types/utility-types/enumeration.js.map +0 -1
  215. package/esm/types/utility-types/frozen.d.ts +0 -24
  216. package/esm/types/utility-types/frozen.js +0 -92
  217. package/esm/types/utility-types/frozen.js.map +0 -1
  218. package/esm/types/utility-types/identifier.d.ts +0 -87
  219. package/esm/types/utility-types/identifier.js +0 -121
  220. package/esm/types/utility-types/identifier.js.map +0 -1
  221. package/esm/types/utility-types/late.d.ts +0 -10
  222. package/esm/types/utility-types/late.js +0 -106
  223. package/esm/types/utility-types/late.js.map +0 -1
  224. package/esm/types/utility-types/lazy.d.ts +0 -23
  225. package/esm/types/utility-types/lazy.js +0 -72
  226. package/esm/types/utility-types/lazy.js.map +0 -1
  227. package/esm/types/utility-types/literal.d.ts +0 -38
  228. package/esm/types/utility-types/literal.js +0 -58
  229. package/esm/types/utility-types/literal.js.map +0 -1
  230. package/esm/types/utility-types/maybe.d.ts +0 -26
  231. package/esm/types/utility-types/maybe.js +0 -26
  232. package/esm/types/utility-types/maybe.js.map +0 -1
  233. package/esm/types/utility-types/optional.d.ts +0 -42
  234. package/esm/types/utility-types/optional.js +0 -135
  235. package/esm/types/utility-types/optional.js.map +0 -1
  236. package/esm/types/utility-types/reference.d.ts +0 -90
  237. package/esm/types/utility-types/reference.js +0 -383
  238. package/esm/types/utility-types/reference.js.map +0 -1
  239. package/esm/types/utility-types/refinement.d.ts +0 -10
  240. package/esm/types/utility-types/refinement.js +0 -82
  241. package/esm/types/utility-types/refinement.js.map +0 -1
  242. package/esm/types/utility-types/resilient.d.ts +0 -18
  243. package/esm/types/utility-types/resilient.js +0 -118
  244. package/esm/types/utility-types/resilient.js.map +0 -1
  245. package/esm/types/utility-types/snapshotProcessor.d.ts +0 -63
  246. package/esm/types/utility-types/snapshotProcessor.js +0 -159
  247. package/esm/types/utility-types/snapshotProcessor.js.map +0 -1
  248. package/esm/types/utility-types/union.d.ts +0 -78
  249. package/esm/types/utility-types/union.js +0 -240
  250. package/esm/types/utility-types/union.js.map +0 -1
  251. package/esm/utils.d.ts +0 -230
  252. package/esm/utils.js +0 -449
  253. package/esm/utils.js.map +0 -1
@@ -1,92 +0,0 @@
1
- import { SimpleType } from "../../core/type/type.js";
2
- import { TypeFlags, createScalarNode, deepFreeze, isSerializable, isType, optional, typeCheckFailure, typeCheckSuccess } from "../../internal.js";
3
- /**
4
- * @internal
5
- * @hidden
6
- */
7
- export class Frozen extends SimpleType {
8
- subType;
9
- flags = TypeFlags.Frozen;
10
- constructor(subType) {
11
- super(subType ? `frozen(${subType.name})` : "frozen");
12
- this.subType = subType;
13
- }
14
- describe() {
15
- return "<any immutable value>";
16
- }
17
- instantiate(parent, subpath, environment, value) {
18
- // create the node
19
- return createScalarNode(this, parent, subpath, environment, deepFreeze(value));
20
- }
21
- isValidSnapshot(value, context) {
22
- if (!isSerializable(value)) {
23
- return typeCheckFailure(context, value, "Value is not serializable and cannot be frozen");
24
- }
25
- if (this.subType) {
26
- return this.subType.validate(value, context);
27
- }
28
- return typeCheckSuccess();
29
- }
30
- }
31
- const untypedFrozenInstance = new Frozen();
32
- /**
33
- * `types.frozen` - Frozen can be used to store any value that is serializable in itself (that is valid JSON).
34
- * Frozen values need to be immutable or treated as if immutable. They need be serializable as well.
35
- * Values stored in frozen will snapshotted as-is by MST, and internal changes will not be tracked.
36
- *
37
- * This is useful to store complex, but immutable values like vectors etc. It can form a powerful bridge to parts of your application that should be immutable, or that assume data to be immutable.
38
- *
39
- * Note: if you want to store free-form state that is mutable, or not serializeable, consider using volatile state instead.
40
- *
41
- * Frozen properties can be defined in three different ways
42
- * 1. `types.frozen(SubType)` - provide a valid MST type and frozen will check if the provided data conforms the snapshot for that type
43
- * 2. `types.frozen({ someDefaultValue: true})` - provide a primitive value, object or array, and MST will infer the type from that object, and also make it the default value for the field
44
- * 3. `types.frozen<TypeScriptType>()` - provide a typescript type, to help in strongly typing the field (design time only)
45
- *
46
- * Example:
47
- * ```ts
48
- * const GameCharacter = types.model({
49
- * name: string,
50
- * location: types.frozen({ x: 0, y: 0})
51
- * })
52
- *
53
- * const hero = GameCharacter.create({
54
- * name: "Mario",
55
- * location: { x: 7, y: 4 }
56
- * })
57
- *
58
- * hero.location = { x: 10, y: 2 } // OK
59
- * hero.location.x = 7 // Not ok!
60
- * ```
61
- *
62
- * ```ts
63
- * type Point = { x: number, y: number }
64
- * const Mouse = types.model({
65
- * loc: types.frozen<Point>()
66
- * })
67
- * ```
68
- *
69
- * @param defaultValueOrType
70
- * @returns
71
- */
72
- export function frozen(arg) {
73
- if (arguments.length === 0) {
74
- return untypedFrozenInstance;
75
- }
76
- else if (isType(arg)) {
77
- return new Frozen(arg);
78
- }
79
- else {
80
- return optional(untypedFrozenInstance, arg);
81
- }
82
- }
83
- /**
84
- * Returns if a given value represents a frozen type.
85
- *
86
- * @param type
87
- * @returns
88
- */
89
- export function isFrozenType(type) {
90
- return isType(type) && (type.flags & TypeFlags.Frozen) > 0;
91
- }
92
- //# sourceMappingURL=frozen.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"frozen.js","sourceRoot":"","sources":["../../../src/types/utility-types/frozen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACpD,OAAO,EAML,SAAS,EACT,gBAAgB,EAChB,UAA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AAG,CAAC,EAAE,CAAC;QACvB,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC,CAAA;IACxB,CAAC;SAAM,CAAC;QACN,OAAO,QAAQ,CAAC,qBAAqB,EAAE,GAAG,CAAC,CAAA;IAC7C,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAC1B,IAAQ;IAER,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;AAC5D,CAAC","sourcesContent":["import { SimpleType } from \"../../core/type/type.ts\"\nimport {\n type AnyObjectNode,\n type IAnyType,\n type IType,\n type IValidationContext,\n type IValidationResult,\n TypeFlags,\n createScalarNode,\n deepFreeze,\n isSerializable,\n isType,\n optional,\n typeCheckFailure,\n typeCheckSuccess\n} from \"../../internal.ts\"\n\n/**\n * @internal\n * @hidden\n */\nexport class Frozen<T> extends SimpleType<T, T, T> {\n flags = TypeFlags.Frozen\n\n constructor(private subType?: IAnyType) {\n super(subType ? `frozen(${subType.name})` : \"frozen\")\n }\n\n describe() {\n return \"<any immutable value>\"\n }\n\n instantiate(\n parent: AnyObjectNode | null,\n subpath: string,\n environment: any,\n value: this[\"C\"]\n ): this[\"N\"] {\n // create the node\n return createScalarNode(\n this,\n parent,\n subpath,\n environment,\n deepFreeze(value)\n )\n }\n\n isValidSnapshot(\n value: this[\"C\"],\n context: IValidationContext\n ): IValidationResult {\n if (!isSerializable(value)) {\n return typeCheckFailure(\n context,\n value,\n \"Value is not serializable and cannot be frozen\"\n )\n }\n if (this.subType) {\n return this.subType.validate(value, context)\n }\n return typeCheckSuccess()\n }\n}\n\nconst untypedFrozenInstance = new Frozen()\n\nexport function frozen<C>(subType: IType<C, any, any>): IType<C, C, C>\nexport function frozen<T>(defaultValue: T): IType<T | undefined | null, T, T>\nexport function frozen<T = any>(): IType<T, T, T> // do not assume undefined by default, let the user specify it if needed\n/**\n * `types.frozen` - Frozen can be used to store any value that is serializable in itself (that is valid JSON).\n * Frozen values need to be immutable or treated as if immutable. They need be serializable as well.\n * Values stored in frozen will snapshotted as-is by MST, and internal changes will not be tracked.\n *\n * This is useful to store complex, but immutable values like vectors etc. It can form a powerful bridge to parts of your application that should be immutable, or that assume data to be immutable.\n *\n * Note: if you want to store free-form state that is mutable, or not serializeable, consider using volatile state instead.\n *\n * Frozen properties can be defined in three different ways\n * 1. `types.frozen(SubType)` - provide a valid MST type and frozen will check if the provided data conforms the snapshot for that type\n * 2. `types.frozen({ someDefaultValue: true})` - provide a primitive value, object or array, and MST will infer the type from that object, and also make it the default value for the field\n * 3. `types.frozen<TypeScriptType>()` - provide a typescript type, to help in strongly typing the field (design time only)\n *\n * Example:\n * ```ts\n * const GameCharacter = types.model({\n * name: string,\n * location: types.frozen({ x: 0, y: 0})\n * })\n *\n * const hero = GameCharacter.create({\n * name: \"Mario\",\n * location: { x: 7, y: 4 }\n * })\n *\n * hero.location = { x: 10, y: 2 } // OK\n * hero.location.x = 7 // Not ok!\n * ```\n *\n * ```ts\n * type Point = { x: number, y: number }\n * const Mouse = types.model({\n * loc: types.frozen<Point>()\n * })\n * ```\n *\n * @param defaultValueOrType\n * @returns\n */\nexport function frozen(arg?: any): any {\n if (arguments.length === 0) {\n return untypedFrozenInstance\n } else if (isType(arg)) {\n return new Frozen(arg)\n } else {\n return optional(untypedFrozenInstance, arg)\n }\n}\n\n/**\n * Returns if a given value represents a frozen type.\n *\n * @param type\n * @returns\n */\nexport function isFrozenType<IT extends IType<T | any, T, T>, T = any>(\n type: IT\n): type is IT {\n return isType(type) && (type.flags & TypeFlags.Frozen) > 0\n}\n"]}
@@ -1,87 +0,0 @@
1
- import { SimpleType } from "../../core/type/type.ts";
2
- import { type AnyObjectNode, type ISimpleType, type IValidationContext, type IValidationResult, type ScalarNode, TypeFlags } from "../../internal.ts";
3
- declare abstract class BaseIdentifierType<T> extends SimpleType<T, T, T> {
4
- private readonly validType;
5
- readonly flags = TypeFlags.Identifier;
6
- constructor(name: string, validType: "string" | "number");
7
- instantiate(parent: AnyObjectNode | null, subpath: string, environment: any, initialValue: this["C"]): this["N"];
8
- reconcile(current: this["N"], newValue: this["C"], parent: AnyObjectNode, subpath: string): this["N"];
9
- isValidSnapshot(value: this["C"], context: IValidationContext): IValidationResult;
10
- }
11
- /**
12
- * @internal
13
- * @hidden
14
- */
15
- export declare class IdentifierType extends BaseIdentifierType<string> {
16
- readonly flags = TypeFlags.Identifier;
17
- constructor();
18
- describe(): string;
19
- }
20
- /**
21
- * @internal
22
- * @hidden
23
- */
24
- export declare class IdentifierNumberType extends BaseIdentifierType<number> {
25
- constructor();
26
- getSnapshot(node: ScalarNode<number, number, number>): number;
27
- describe(): string;
28
- }
29
- /**
30
- * `types.identifier` - Identifiers are used to make references, lifecycle events and reconciling works.
31
- * Inside a state tree, for each type can exist only one instance for each given identifier.
32
- * For example there couldn't be 2 instances of user with id 1. If you need more, consider using references.
33
- * Identifier can be used only as type property of a model.
34
- * This type accepts as parameter the value type of the identifier field that can be either string or number.
35
- *
36
- * Example:
37
- * ```ts
38
- * const Todo = types.model("Todo", {
39
- * id: types.identifier,
40
- * title: types.string
41
- * })
42
- * ```
43
- *
44
- * @returns
45
- */
46
- export declare const identifier: ISimpleType<string>;
47
- /**
48
- * `types.identifierNumber` - Similar to `types.identifier`. This one will serialize from / to a number when applying snapshots
49
- *
50
- * Example:
51
- * ```ts
52
- * const Todo = types.model("Todo", {
53
- * id: types.identifierNumber,
54
- * title: types.string
55
- * })
56
- * ```
57
- *
58
- * @returns
59
- */
60
- export declare const identifierNumber: ISimpleType<number>;
61
- /**
62
- * Returns if a given value represents an identifier type.
63
- *
64
- * @param type
65
- * @returns
66
- */
67
- export declare function isIdentifierType<IT extends typeof identifier | typeof identifierNumber>(type: IT): type is IT;
68
- /**
69
- * Valid types for identifiers.
70
- */
71
- export type ReferenceIdentifier = string | number;
72
- /**
73
- * @internal
74
- * @hidden
75
- */
76
- export declare function normalizeIdentifier(id: ReferenceIdentifier): string;
77
- /**
78
- * @internal
79
- * @hidden
80
- */
81
- export declare function isValidIdentifier(id: any): id is ReferenceIdentifier;
82
- /**
83
- * @internal
84
- * @hidden
85
- */
86
- export declare function assertIsValidIdentifier(id: ReferenceIdentifier, argNumber: number | number[]): void;
87
- export {};
@@ -1,121 +0,0 @@
1
- import { SimpleType } from "../../core/type/type.js";
2
- import { ModelType, TypeFlags, assertArg, createScalarNode, fail, isType, typeCheckFailure, typeCheckSuccess } from "../../internal.js";
3
- class BaseIdentifierType extends SimpleType {
4
- validType;
5
- flags = TypeFlags.Identifier;
6
- constructor(name, validType) {
7
- super(name);
8
- this.validType = validType;
9
- }
10
- instantiate(parent, subpath, environment, initialValue) {
11
- if (!parent || !(parent.type instanceof ModelType)) {
12
- throw fail(`Identifier types can only be instantiated as direct child of a model type`);
13
- }
14
- return createScalarNode(this, parent, subpath, environment, initialValue);
15
- }
16
- reconcile(current, newValue, parent, subpath) {
17
- // we don't consider detaching here since identifier are scalar nodes, and scalar nodes cannot be detached
18
- if (current.storedValue !== newValue) {
19
- throw fail(`Tried to change identifier from '${current.storedValue}' to '${newValue}'. Changing identifiers is not allowed.`);
20
- }
21
- current.setParent(parent, subpath);
22
- return current;
23
- }
24
- isValidSnapshot(value, context) {
25
- if (typeof value !== this.validType) {
26
- return typeCheckFailure(context, value, `Value is not a valid ${this.describe()}, expected a ${this.validType}`);
27
- }
28
- return typeCheckSuccess();
29
- }
30
- }
31
- /**
32
- * @internal
33
- * @hidden
34
- */
35
- export class IdentifierType extends BaseIdentifierType {
36
- flags = TypeFlags.Identifier;
37
- constructor() {
38
- super(`identifier`, "string");
39
- }
40
- describe() {
41
- return `identifier`;
42
- }
43
- }
44
- /**
45
- * @internal
46
- * @hidden
47
- */
48
- export class IdentifierNumberType extends BaseIdentifierType {
49
- constructor() {
50
- super("identifierNumber", "number");
51
- }
52
- getSnapshot(node) {
53
- return node.storedValue;
54
- }
55
- describe() {
56
- return `identifierNumber`;
57
- }
58
- }
59
- /**
60
- * `types.identifier` - Identifiers are used to make references, lifecycle events and reconciling works.
61
- * Inside a state tree, for each type can exist only one instance for each given identifier.
62
- * For example there couldn't be 2 instances of user with id 1. If you need more, consider using references.
63
- * Identifier can be used only as type property of a model.
64
- * This type accepts as parameter the value type of the identifier field that can be either string or number.
65
- *
66
- * Example:
67
- * ```ts
68
- * const Todo = types.model("Todo", {
69
- * id: types.identifier,
70
- * title: types.string
71
- * })
72
- * ```
73
- *
74
- * @returns
75
- */
76
- export const identifier = new IdentifierType();
77
- /**
78
- * `types.identifierNumber` - Similar to `types.identifier`. This one will serialize from / to a number when applying snapshots
79
- *
80
- * Example:
81
- * ```ts
82
- * const Todo = types.model("Todo", {
83
- * id: types.identifierNumber,
84
- * title: types.string
85
- * })
86
- * ```
87
- *
88
- * @returns
89
- */
90
- export const identifierNumber = new IdentifierNumberType();
91
- /**
92
- * Returns if a given value represents an identifier type.
93
- *
94
- * @param type
95
- * @returns
96
- */
97
- export function isIdentifierType(type) {
98
- return isType(type) && (type.flags & TypeFlags.Identifier) > 0;
99
- }
100
- /**
101
- * @internal
102
- * @hidden
103
- */
104
- export function normalizeIdentifier(id) {
105
- return "" + id;
106
- }
107
- /**
108
- * @internal
109
- * @hidden
110
- */
111
- export function isValidIdentifier(id) {
112
- return typeof id === "string" || typeof id === "number";
113
- }
114
- /**
115
- * @internal
116
- * @hidden
117
- */
118
- export function assertIsValidIdentifier(id, argNumber) {
119
- assertArg(id, isValidIdentifier, "string or number (identifier)", argNumber);
120
- }
121
- //# sourceMappingURL=identifier.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"identifier.js","sourceRoot":"","sources":["../../../src/types/utility-types/identifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACpD,OAAO,EAKL,SAAS,EAET,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,IAAI,EACJ,MAAM,EACN,gBAAgB,EAChB,g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AU,CAAA;IAErC;QACE,KAAK,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAA;IAC/B,CAAC;IAED,QAAQ;QACN,OAAO,YAAY,CAAA;IACrB,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,oBAAqB,SAAQ,kBAA0B;IAClE;QACE,KAAK,CAAC,kBAAkB,EAAE,QAAQ,CAAC,CAAA;IACrC,CAAC;IAED,WAAW,CAAC,IAAwC;QAClD,OAAO,IAAI,CAAC,WAAW,CAAA;IACzB,CAAC;IAED,QAAQ;QACN,OAAO,kBAAkB,CAAA;IAC3B,CAAC;CACF;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,UAAU,GAAwB,IAAI,cAAc,EAAE,CAAA;AAEnE;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAwB,IAAI,oBAAoB,EAAE,CAAA;AAE/E;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAE9B,IAAQ;IACR,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;AAChE,CAAC;AAOD;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,EAAuB;IACzD,OAAO,EAAE,GAAG,EAAE,CAAA;AAChB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,EAAO;IACvC,OAAO,OAAO,EAAE,KAAK,QAAQ,IAAI,OAAO,EAAE,KAAK,QAAQ,CAAA;AACzD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CACrC,EAAuB,EACvB,SAA4B;IAE5B,SAAS,CAAC,EAAE,EAAE,iBAAiB,EAAE,+BAA+B,EAAE,SAAS,CAAC,CAAA;AAC9E,CAAC","sourcesContent":["import { SimpleType } from \"../../core/type/type.ts\"\nimport {\n type AnyObjectNode,\n type ISimpleType,\n type IValidationContext,\n type IValidationResult,\n ModelType,\n type ScalarNode,\n TypeFlags,\n assertArg,\n createScalarNode,\n fail,\n isType,\n typeCheckFailure,\n typeCheckSuccess\n} from \"../../internal.ts\"\n\nabstract class BaseIdentifierType<T> extends SimpleType<T, T, T> {\n readonly flags = TypeFlags.Identifier\n\n constructor(\n name: string,\n private readonly validType: \"string\" | \"number\"\n ) {\n super(name)\n }\n\n instantiate(\n parent: AnyObjectNode | null,\n subpath: string,\n environment: any,\n initialValue: this[\"C\"]\n ): this[\"N\"] {\n if (!parent || !(parent.type instanceof ModelType)) {\n throw fail(\n `Identifier types can only be instantiated as direct child of a model type`\n )\n }\n\n return createScalarNode(this, parent, subpath, environment, initialValue)\n }\n\n reconcile(\n current: this[\"N\"],\n newValue: this[\"C\"],\n parent: AnyObjectNode,\n subpath: string\n ) {\n // we don't consider detaching here since identifier are scalar nodes, and scalar nodes cannot be detached\n if (current.storedValue !== newValue) {\n throw fail(\n `Tried to change identifier from '${current.storedValue}' to '${newValue}'. Changing identifiers is not allowed.`\n )\n }\n current.setParent(parent, subpath)\n return current\n }\n\n isValidSnapshot(\n value: this[\"C\"],\n context: IValidationContext\n ): IValidationResult {\n if (typeof value !== this.validType) {\n return typeCheckFailure(\n context,\n value,\n `Value is not a valid ${this.describe()}, expected a ${this.validType}`\n )\n }\n return typeCheckSuccess()\n }\n}\n\n/**\n * @internal\n * @hidden\n */\nexport class IdentifierType extends BaseIdentifierType<string> {\n readonly flags = TypeFlags.Identifier\n\n constructor() {\n super(`identifier`, \"string\")\n }\n\n describe() {\n return `identifier`\n }\n}\n\n/**\n * @internal\n * @hidden\n */\nexport class IdentifierNumberType extends BaseIdentifierType<number> {\n constructor() {\n super(\"identifierNumber\", \"number\")\n }\n\n getSnapshot(node: ScalarNode<number, number, number>): number {\n return node.storedValue\n }\n\n describe() {\n return `identifierNumber`\n }\n}\n\n/**\n * `types.identifier` - Identifiers are used to make references, lifecycle events and reconciling works.\n * Inside a state tree, for each type can exist only one instance for each given identifier.\n * For example there couldn't be 2 instances of user with id 1. If you need more, consider using references.\n * Identifier can be used only as type property of a model.\n * This type accepts as parameter the value type of the identifier field that can be either string or number.\n *\n * Example:\n * ```ts\n * const Todo = types.model(\"Todo\", {\n * id: types.identifier,\n * title: types.string\n * })\n * ```\n *\n * @returns\n */\nexport const identifier: ISimpleType<string> = new IdentifierType()\n\n/**\n * `types.identifierNumber` - Similar to `types.identifier`. This one will serialize from / to a number when applying snapshots\n *\n * Example:\n * ```ts\n * const Todo = types.model(\"Todo\", {\n * id: types.identifierNumber,\n * title: types.string\n * })\n * ```\n *\n * @returns\n */\nexport const identifierNumber: ISimpleType<number> = new IdentifierNumberType()\n\n/**\n * Returns if a given value represents an identifier type.\n *\n * @param type\n * @returns\n */\nexport function isIdentifierType<\n IT extends typeof identifier | typeof identifierNumber\n>(type: IT): type is IT {\n return isType(type) && (type.flags & TypeFlags.Identifier) > 0\n}\n\n/**\n * Valid types for identifiers.\n */\nexport type ReferenceIdentifier = string | number\n\n/**\n * @internal\n * @hidden\n */\nexport function normalizeIdentifier(id: ReferenceIdentifier): string {\n return \"\" + id\n}\n\n/**\n * @internal\n * @hidden\n */\nexport function isValidIdentifier(id: any): id is ReferenceIdentifier {\n return typeof id === \"string\" || typeof id === \"number\"\n}\n\n/**\n * @internal\n * @hidden\n */\nexport function assertIsValidIdentifier(\n id: ReferenceIdentifier,\n argNumber: number | number[]\n) {\n assertArg(id, isValidIdentifier, \"string or number (identifier)\", argNumber)\n}\n"]}
@@ -1,10 +0,0 @@
1
- import { type IAnyType } from "../../internal.ts";
2
- export declare function late<T extends IAnyType>(type: () => T): T;
3
- export declare function late<T extends IAnyType>(name: string, type: () => T): T;
4
- /**
5
- * Returns if a given value represents a late type.
6
- *
7
- * @param type
8
- * @returns
9
- */
10
- export declare function isLateType<IT extends IAnyType>(type: IT): type is IT;
@@ -1,106 +0,0 @@
1
- import { BaseType } from "../../core/type/type.js";
2
- import { TypeFlags, cannotDetermineSubtype, devMode, fail, isType, typeCheckSuccess } from "../../internal.js";
3
- class Late extends BaseType {
4
- _definition;
5
- _subType;
6
- get flags() {
7
- return (this._subType ? this._subType.flags : 0) | TypeFlags.Late;
8
- }
9
- getSubType(mustSucceed) {
10
- if (!this._subType) {
11
- let t = undefined;
12
- try {
13
- t = this._definition();
14
- }
15
- catch (e) {
16
- if (e instanceof ReferenceError) // can happen in strict ES5 code when a definition is self refering
17
- {
18
- t = undefined;
19
- }
20
- else {
21
- throw e;
22
- }
23
- }
24
- if (mustSucceed && t === undefined) {
25
- throw fail("Late type seems to be used too early, the definition (still) returns undefined");
26
- }
27
- if (t) {
28
- if (devMode() && !isType(t)) {
29
- throw fail("Failed to determine subtype, make sure types.late returns a type definition.");
30
- }
31
- this._subType = t;
32
- }
33
- }
34
- return this._subType;
35
- }
36
- constructor(name, _definition) {
37
- super(name);
38
- this._definition = _definition;
39
- }
40
- instantiate(parent, subpath, environment, initialValue) {
41
- return this.getSubType(true).instantiate(parent, subpath, environment, initialValue);
42
- }
43
- reconcile(current, newValue, parent, subpath) {
44
- return this.getSubType(true).reconcile(current, newValue, parent, subpath);
45
- }
46
- describe() {
47
- const t = this.getSubType(false);
48
- return t ? t.name : "<uknown late type>";
49
- }
50
- isValidSnapshot(value, context) {
51
- const t = this.getSubType(false);
52
- if (!t) {
53
- // See #916; the variable the definition closure is pointing to wasn't defined yet, so can't be evaluted yet here
54
- return typeCheckSuccess();
55
- }
56
- return t.validate(value, context);
57
- }
58
- isAssignableFrom(type) {
59
- const t = this.getSubType(false);
60
- return t ? t.isAssignableFrom(type) : false;
61
- }
62
- getSubTypes() {
63
- const subtype = this.getSubType(false);
64
- return subtype ? subtype : cannotDetermineSubtype;
65
- }
66
- }
67
- /**
68
- * `types.late` - Defines a type that gets implemented later. This is useful when you have to deal with circular dependencies.
69
- * Please notice that when defining circular dependencies TypeScript isn't smart enough to inference them.
70
- *
71
- * Example:
72
- * ```ts
73
- * // TypeScript isn't smart enough to infer self referencing types.
74
- * const Node = types.model({
75
- * children: types.array(types.late((): IAnyModelType => Node)) // then typecast each array element to Instance<typeof Node>
76
- * })
77
- * ```
78
- *
79
- * @param name The name to use for the type that will be returned.
80
- * @param type A function that returns the type that will be defined.
81
- * @returns
82
- */
83
- export function late(nameOrType, maybeType) {
84
- const name = typeof nameOrType === "string"
85
- ? nameOrType
86
- : `late(${nameOrType.toString()})`;
87
- const type = typeof nameOrType === "string" ? maybeType : nameOrType;
88
- // checks that the type is actually a late type
89
- if (devMode()) {
90
- if (!(typeof type === "function" && type.length === 0)) {
91
- throw fail("Invalid late type, expected a function with zero arguments that returns a type, got: " +
92
- type);
93
- }
94
- }
95
- return new Late(name, type);
96
- }
97
- /**
98
- * Returns if a given value represents a late type.
99
- *
100
- * @param type
101
- * @returns
102
- */
103
- export function isLateType(type) {
104
- return isType(type) && (type.flags & TypeFlags.Late) > 0;
105
- }
106
- //# sourceMappingURL=late.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"late.js","sourceRoot":"","sources":["../../../src/types/utility-types/late.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAClD,OAAO,EAML,SAAS,EACT,sBAAsB,EACtB,OAAO,EACP,IAAI,EACJ,MAAM,EACN,gBAAgB,EACjB,MAAM,mBAAmB,CAAA;AAE1B,MAAM,IAA0B,SAAQ,QAKvC;IA2CoB;IA1CX,QAAQ,CAAK;IAErB,IAAI,KAAK;QACP,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,IAAI,CAAA;IACnE,CAAC;IAID,UAAU,CAAC,WAAoB;QAC7B,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACnB,IAAI,CAAC,GAAG,SAAS,CAAA;YACjB,IAAI,CAAC;gBACH,CAAC,GAAG,IAAI,CAAC,WAAW,EAAE,CAAA;YACxB,CAAC;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AC,IAAI,EAAE,IAAI,CAAC,CAAA;AAC7B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAsB,IAAQ;IACtD,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAC1D,CAAC","sourcesContent":["import { BaseType } from \"../../core/type/type.ts\"\nimport {\n type AnyObjectNode,\n type ExtractNodeType,\n type IAnyType,\n type IValidationContext,\n type IValidationResult,\n TypeFlags,\n cannotDetermineSubtype,\n devMode,\n fail,\n isType,\n typeCheckSuccess\n} from \"../../internal.ts\"\n\nclass Late<IT extends IAnyType> extends BaseType<\n IT[\"CreationType\"],\n IT[\"SnapshotType\"],\n IT[\"TypeWithoutSTN\"],\n ExtractNodeType<IT>\n> {\n private _subType?: IT\n\n get flags() {\n return (this._subType ? this._subType.flags : 0) | TypeFlags.Late\n }\n\n getSubType(mustSucceed: true): IT\n getSubType(mustSucceed: false): IT | undefined\n getSubType(mustSucceed: boolean): IT | undefined {\n if (!this._subType) {\n let t = undefined\n try {\n t = this._definition()\n } catch (e) {\n if (\n e instanceof ReferenceError\n ) // can happen in strict ES5 code when a definition is self refering\n {\n t = undefined\n } else {\n throw e\n }\n }\n if (mustSucceed && t === undefined) {\n throw fail(\n \"Late type seems to be used too early, the definition (still) returns undefined\"\n )\n }\n if (t) {\n if (devMode() && !isType(t)) {\n throw fail(\n \"Failed to determine subtype, make sure types.late returns a type definition.\"\n )\n }\n this._subType = t\n }\n }\n return this._subType\n }\n\n constructor(\n name: string,\n private readonly _definition: () => IT\n ) {\n super(name)\n }\n\n instantiate(\n parent: AnyObjectNode | null,\n subpath: string,\n environment: any,\n initialValue: this[\"C\"] | this[\"T\"]\n ): this[\"N\"] {\n return this.getSubType(true).instantiate(\n parent,\n subpath,\n environment,\n initialValue\n ) as any\n }\n\n reconcile(\n current: this[\"N\"],\n newValue: this[\"C\"] | this[\"T\"],\n parent: AnyObjectNode,\n subpath: string\n ): this[\"N\"] {\n return this.getSubType(true).reconcile(\n current,\n newValue,\n parent,\n subpath\n ) as any\n }\n\n describe() {\n const t = this.getSubType(false)\n return t ? t.name : \"<uknown late type>\"\n }\n\n isValidSnapshot(\n value: this[\"C\"],\n context: IValidationContext\n ): IValidationResult {\n const t = this.getSubType(false)\n if (!t) {\n // See #916; the variable the definition closure is pointing to wasn't defined yet, so can't be evaluted yet here\n return typeCheckSuccess()\n }\n return t.validate(value, context)\n }\n\n isAssignableFrom(type: IAnyType) {\n const t = this.getSubType(false)\n return t ? t.isAssignableFrom(type) : false\n }\n\n getSubTypes() {\n const subtype = this.getSubType(false)\n return subtype ? subtype : cannotDetermineSubtype\n }\n}\n\nexport function late<T extends IAnyType>(type: () => T): T\nexport function late<T extends IAnyType>(name: string, type: () => T): T\n/**\n * `types.late` - Defines a type that gets implemented later. This is useful when you have to deal with circular dependencies.\n * Please notice that when defining circular dependencies TypeScript isn't smart enough to inference them.\n *\n * Example:\n * ```ts\n * // TypeScript isn't smart enough to infer self referencing types.\n * const Node = types.model({\n * children: types.array(types.late((): IAnyModelType => Node)) // then typecast each array element to Instance<typeof Node>\n * })\n * ```\n *\n * @param name The name to use for the type that will be returned.\n * @param type A function that returns the type that will be defined.\n * @returns\n */\nexport function late(nameOrType: any, maybeType?: () => IAnyType): IAnyType {\n const name =\n typeof nameOrType === \"string\"\n ? nameOrType\n : `late(${nameOrType.toString()})`\n const type = typeof nameOrType === \"string\" ? maybeType : nameOrType\n // checks that the type is actually a late type\n if (devMode()) {\n if (!(typeof type === \"function\" && type.length === 0)) {\n throw fail(\n \"Invalid late type, expected a function with zero arguments that returns a type, got: \" +\n type\n )\n }\n }\n return new Late(name, type)\n}\n\n/**\n * Returns if a given value represents a late type.\n *\n * @param type\n * @returns\n */\nexport function isLateType<IT extends IAnyType>(type: IT): type is IT {\n return isType(type) && (type.flags & TypeFlags.Late) > 0\n}\n"]}
@@ -1,23 +0,0 @@
1
- import { SimpleType } from "../../core/type/type.ts";
2
- import { type AnyObjectNode, type IType, type IValidationContext, type IValidationResult, TypeFlags } from "../../internal.ts";
3
- interface LazyOptions<T extends IType<any, any, any>, U> {
4
- loadType: () => Promise<T>;
5
- shouldLoadPredicate: (parent: U) => boolean;
6
- }
7
- export declare function lazy<T extends IType<any, any, any>, U>(name: string, options: LazyOptions<T, U>): T;
8
- /**
9
- * @internal
10
- * @hidden
11
- */
12
- export declare class Lazy<T extends IType<any, any, any>, U> extends SimpleType<T, T, T> {
13
- private readonly options;
14
- flags: TypeFlags;
15
- private loadedType;
16
- private pendingNodeList;
17
- constructor(name: string, options: LazyOptions<T, U>);
18
- describe(): string;
19
- instantiate(parent: AnyObjectNode | null, subpath: string, environment: any, value: this["C"]): this["N"];
20
- isValidSnapshot(value: this["C"], context: IValidationContext): IValidationResult;
21
- reconcile(current: this["N"], value: T, parent: AnyObjectNode, subpath: string): this["N"];
22
- }
23
- export {};
@@ -1,72 +0,0 @@
1
- import { action, observable, when } from "mobx";
2
- import { SimpleType } from "../../core/type/type.js";
3
- import { TypeFlags, createScalarNode, deepFreeze, isSerializable, typeCheckFailure, typeCheckSuccess } from "../../internal.js";
4
- export function lazy(name, options) {
5
- // TODO: fix this unknown casting to be stricter
6
- return new Lazy(name, options);
7
- }
8
- /**
9
- * @internal
10
- * @hidden
11
- */
12
- export class Lazy extends SimpleType {
13
- options;
14
- flags = TypeFlags.Lazy;
15
- loadedType = null;
16
- pendingNodeList = observable.array();
17
- constructor(name, options) {
18
- super(name);
19
- this.options = options;
20
- when(() => this.pendingNodeList.length > 0 &&
21
- this.pendingNodeList.some(node => node.isAlive &&
22
- this.options.shouldLoadPredicate(node.parent ? node.parent.value : null)), () => {
23
- this.options.loadType().then(action((type) => {
24
- this.loadedType = type;
25
- this.pendingNodeList.forEach(node => {
26
- if (!node.parent) {
27
- return;
28
- }
29
- if (!this.loadedType) {
30
- return;
31
- }
32
- node.parent.applyPatches([
33
- {
34
- op: "replace",
35
- path: `/${node.subpath}`,
36
- value: node.snapshot
37
- }
38
- ]);
39
- });
40
- }));
41
- });
42
- }
43
- describe() {
44
- return `<lazy ${this.name}>`;
45
- }
46
- instantiate(parent, subpath, environment, value) {
47
- if (this.loadedType) {
48
- return this.loadedType.instantiate(parent, subpath, environment, value);
49
- }
50
- const node = createScalarNode(this, parent, subpath, environment, deepFreeze(value));
51
- this.pendingNodeList.push(node);
52
- when(() => !node.isAlive, () => this.pendingNodeList.splice(this.pendingNodeList.indexOf(node), 1));
53
- return node;
54
- }
55
- isValidSnapshot(value, context) {
56
- if (this.loadedType) {
57
- return this.loadedType.validate(value, context);
58
- }
59
- if (!isSerializable(value)) {
60
- return typeCheckFailure(context, value, "Value is not serializable and cannot be lazy");
61
- }
62
- return typeCheckSuccess();
63
- }
64
- reconcile(current, value, parent, subpath) {
65
- if (this.loadedType) {
66
- current.die();
67
- return this.loadedType.instantiate(parent, subpath, parent.environment, value);
68
- }
69
- return super.reconcile(current, value, parent, subpath);
70
- }
71
- }
72
- //# sourceMappingURL=lazy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lazy.js","sourceRoot":"","sources":["../../../src/types/utility-types/lazy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAEtE,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACpD,OAAO,EAML,SAAS,EACT,gBAAgB,EAChB,UAAU,EACV,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,mBAAmB,CAAA;AAO1B,MAAM,UAAU,IAAI,CAClB,IAAY,EACZ,OAA0B;IAE1B,gDAAgD;IAChD,OAAO,IAAI,IAAI,CAAC,IAAI,EAAE,OAAO,CAAiB,CAAA;AAChD,CAAC;AAED;;;GAGG;AACH,MAAM,OAAO,IAAwC,SAAQ,UAI5D;IAQoB;IAPnB,KAAK,GAAG,SAAS,CAAC,IAAI,CAAA;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CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;IACzD,CAAC;CACF","sourcesContent":["import { type IObservableArray, action, observable, when } from \"mobx\"\n\nimport { SimpleType } from \"../../core/type/type.ts\"\nimport {\n type AnyNode,\n type AnyObjectNode,\n type IType,\n type IValidationContext,\n type IValidationResult,\n TypeFlags,\n createScalarNode,\n deepFreeze,\n isSerializable,\n typeCheckFailure,\n typeCheckSuccess\n} from \"../../internal.ts\"\n\ninterface LazyOptions<T extends IType<any, any, any>, U> {\n loadType: () => Promise<T>\n shouldLoadPredicate: (parent: U) => boolean\n}\n\nexport function lazy<T extends IType<any, any, any>, U>(\n name: string,\n options: LazyOptions<T, U>\n): T {\n // TODO: fix this unknown casting to be stricter\n return new Lazy(name, options) as unknown as T\n}\n\n/**\n * @internal\n * @hidden\n */\nexport class Lazy<T extends IType<any, any, any>, U> extends SimpleType<\n T,\n T,\n T\n> {\n flags = TypeFlags.Lazy\n\n private loadedType: T | null = null\n private pendingNodeList: IObservableArray<AnyNode> = observable.array()\n\n constructor(\n name: string,\n private readonly options: LazyOptions<T, U>\n ) {\n super(name)\n\n when(\n () =>\n this.pendingNodeList.length > 0 &&\n this.pendingNodeList.some(\n node =>\n node.isAlive &&\n this.options.shouldLoadPredicate(\n node.parent ? node.parent.value : null\n )\n ),\n () => {\n this.options.loadType().then(\n action((type: T) => {\n this.loadedType = type\n this.pendingNodeList.forEach(node => {\n if (!node.parent) {\n return\n }\n if (!this.loadedType) {\n return\n }\n\n node.parent.applyPatches([\n {\n op: \"replace\",\n path: `/${node.subpath}`,\n value: node.snapshot\n }\n ])\n })\n })\n )\n }\n )\n }\n\n describe() {\n return `<lazy ${this.name}>`\n }\n\n instantiate(\n parent: AnyObjectNode | null,\n subpath: string,\n environment: any,\n value: this[\"C\"]\n ): this[\"N\"] {\n if (this.loadedType) {\n return this.loadedType.instantiate(\n parent,\n subpath,\n environment,\n value\n ) as this[\"N\"]\n }\n\n const node = createScalarNode(\n this,\n parent,\n subpath,\n environment,\n deepFreeze(value)\n )\n this.pendingNodeList.push(node)\n\n when(\n () => !node.isAlive,\n () => this.pendingNodeList.splice(this.pendingNodeList.indexOf(node), 1)\n )\n\n return node\n }\n\n isValidSnapshot(\n value: this[\"C\"],\n context: IValidationContext\n ): IValidationResult {\n if (this.loadedType) {\n return this.loadedType.validate(value, context)\n }\n if (!isSerializable(value)) {\n return typeCheckFailure(\n context,\n value,\n \"Value is not serializable and cannot be lazy\"\n )\n }\n return typeCheckSuccess()\n }\n\n reconcile(\n current: this[\"N\"],\n value: T,\n parent: AnyObjectNode,\n subpath: string\n ): this[\"N\"] {\n if (this.loadedType) {\n current.die()\n return this.loadedType.instantiate(\n parent,\n subpath,\n parent.environment,\n value\n ) as this[\"N\"]\n }\n return super.reconcile(current, value, parent, subpath)\n }\n}\n"]}
@@ -1,38 +0,0 @@
1
- import { SimpleType } from "../../core/type/type.ts";
2
- import { type AnyObjectNode, type ISimpleType, type IValidationContext, type IValidationResult, type Primitives, TypeFlags } from "../../internal.ts";
3
- /**
4
- * @internal
5
- * @hidden
6
- */
7
- export declare class Literal<T> extends SimpleType<T, T, T> {
8
- readonly value: T;
9
- readonly flags = TypeFlags.Literal;
10
- constructor(value: T);
11
- instantiate(parent: AnyObjectNode | null, subpath: string, environment: any, initialValue: this["C"]): this["N"];
12
- describe(): string;
13
- isValidSnapshot(value: this["C"], context: IValidationContext): IValidationResult;
14
- }
15
- /**
16
- * `types.literal` - The literal type will return a type that will match only the exact given type.
17
- * The given value must be a primitive, in order to be serialized to a snapshot correctly.
18
- * You can use literal to match exact strings for example the exact male or female string.
19
- *
20
- * Example:
21
- * ```ts
22
- * const Person = types.model({
23
- * name: types.string,
24
- * gender: types.union(types.literal('male'), types.literal('female'))
25
- * })
26
- * ```
27
- *
28
- * @param value The value to use in the strict equal check
29
- * @returns
30
- */
31
- export declare function literal<S extends Primitives>(value: S): ISimpleType<S>;
32
- /**
33
- * Returns if a given value represents a literal type.
34
- *
35
- * @param type
36
- * @returns
37
- */
38
- export declare function isLiteralType<IT extends ISimpleType<any>>(type: IT): type is IT;