@voidhash/mimic 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (278) hide show
  1. package/.turbo/turbo-build.log +257 -42
  2. package/dist/Document.cjs +152 -0
  3. package/dist/Document.d.cts +67 -0
  4. package/dist/Document.d.cts.map +1 -0
  5. package/dist/Document.d.mts +68 -0
  6. package/dist/Document.d.mts.map +1 -0
  7. package/dist/Document.mjs +147 -0
  8. package/dist/Document.mjs.map +1 -0
  9. package/dist/EffectSchema.cjs +180 -0
  10. package/dist/EffectSchema.d.cts +84 -0
  11. package/dist/EffectSchema.d.cts.map +1 -0
  12. package/dist/EffectSchema.d.mts +84 -0
  13. package/dist/EffectSchema.d.mts.map +1 -0
  14. package/dist/EffectSchema.mjs +176 -0
  15. package/dist/EffectSchema.mjs.map +1 -0
  16. package/dist/FractionalIndex.cjs +365 -0
  17. package/dist/FractionalIndex.mjs +364 -0
  18. package/dist/FractionalIndex.mjs.map +1 -0
  19. package/dist/Operation.cjs +53 -0
  20. package/dist/Operation.d.cts +39 -0
  21. package/dist/Operation.d.cts.map +1 -0
  22. package/dist/Operation.d.mts +39 -0
  23. package/dist/Operation.d.mts.map +1 -0
  24. package/dist/Operation.mjs +46 -0
  25. package/dist/Operation.mjs.map +1 -0
  26. package/dist/OperationDefinition.cjs +13 -0
  27. package/dist/OperationDefinition.d.cts +12 -0
  28. package/dist/OperationDefinition.d.cts.map +1 -0
  29. package/dist/OperationDefinition.d.mts +12 -0
  30. package/dist/OperationDefinition.d.mts.map +1 -0
  31. package/dist/OperationDefinition.mjs +13 -0
  32. package/dist/OperationDefinition.mjs.map +1 -0
  33. package/dist/OperationPath.cjs +148 -0
  34. package/dist/OperationPath.d.cts +60 -0
  35. package/dist/OperationPath.d.cts.map +1 -0
  36. package/dist/OperationPath.d.mts +60 -0
  37. package/dist/OperationPath.d.mts.map +1 -0
  38. package/dist/OperationPath.mjs +138 -0
  39. package/dist/OperationPath.mjs.map +1 -0
  40. package/dist/{Presence-gWrmGBeu.cjs → Presence.cjs} +4 -39
  41. package/dist/{Presence-N8u7Eppr.d.mts → Presence.d.cts} +2 -2
  42. package/dist/Presence.d.cts.map +1 -0
  43. package/dist/{Presence-DKKP4v5X.d.cts → Presence.d.mts} +2 -2
  44. package/dist/Presence.d.mts.map +1 -0
  45. package/dist/{Presence-DdMVKcOv.mjs → Presence.mjs} +3 -28
  46. package/dist/Presence.mjs.map +1 -0
  47. package/dist/Primitive.cjs +52 -0
  48. package/dist/Primitive.d.cts +20 -0
  49. package/dist/Primitive.d.cts.map +1 -0
  50. package/dist/Primitive.d.mts +20 -0
  51. package/dist/Primitive.d.mts.map +1 -0
  52. package/dist/Primitive.mjs +48 -0
  53. package/dist/Primitive.mjs.map +1 -0
  54. package/dist/ProxyEnvironment.cjs +34 -0
  55. package/dist/ProxyEnvironment.d.cts +31 -0
  56. package/dist/ProxyEnvironment.d.cts.map +1 -0
  57. package/dist/ProxyEnvironment.d.mts +31 -0
  58. package/dist/ProxyEnvironment.d.mts.map +1 -0
  59. package/dist/ProxyEnvironment.mjs +29 -0
  60. package/dist/ProxyEnvironment.mjs.map +1 -0
  61. package/dist/Transaction.cjs +66 -0
  62. package/dist/Transaction.d.cts +56 -0
  63. package/dist/Transaction.d.cts.map +1 -0
  64. package/dist/Transaction.d.mts +56 -0
  65. package/dist/Transaction.d.mts.map +1 -0
  66. package/dist/Transaction.mjs +58 -0
  67. package/dist/Transaction.mjs.map +1 -0
  68. package/dist/Transform.cjs +11 -0
  69. package/dist/Transform.d.cts +21 -0
  70. package/dist/Transform.d.cts.map +1 -0
  71. package/dist/Transform.d.mts +21 -0
  72. package/dist/Transform.d.mts.map +1 -0
  73. package/dist/Transform.mjs +6 -0
  74. package/dist/Transform.mjs.map +1 -0
  75. package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/defineProperty.cjs +14 -0
  76. package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/defineProperty.mjs +14 -0
  77. package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/objectSpread2.cjs +27 -0
  78. package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/objectSpread2.mjs +27 -0
  79. package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/toPrimitive.cjs +16 -0
  80. package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/toPrimitive.mjs +16 -0
  81. package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/toPropertyKey.cjs +11 -0
  82. package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/toPropertyKey.mjs +11 -0
  83. package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/typeof.cjs +18 -0
  84. package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/typeof.mjs +12 -0
  85. package/dist/_virtual/rolldown_runtime.cjs +43 -0
  86. package/dist/{chunk-CLMFDpHK.mjs → _virtual/rolldown_runtime.mjs} +1 -1
  87. package/dist/client/ClientDocument.cjs +590 -0
  88. package/dist/client/ClientDocument.d.cts +161 -0
  89. package/dist/client/ClientDocument.d.cts.map +1 -0
  90. package/dist/client/ClientDocument.d.mts +162 -0
  91. package/dist/client/ClientDocument.d.mts.map +1 -0
  92. package/dist/client/ClientDocument.mjs +586 -0
  93. package/dist/client/ClientDocument.mjs.map +1 -0
  94. package/dist/client/Rebase.cjs +204 -0
  95. package/dist/client/Rebase.d.cts +87 -0
  96. package/dist/client/Rebase.d.cts.map +1 -0
  97. package/dist/client/Rebase.d.mts +88 -0
  98. package/dist/client/Rebase.d.mts.map +1 -0
  99. package/dist/client/Rebase.mjs +198 -0
  100. package/dist/client/Rebase.mjs.map +1 -0
  101. package/dist/client/StateMonitor.cjs +133 -0
  102. package/dist/client/StateMonitor.d.cts +122 -0
  103. package/dist/client/StateMonitor.d.cts.map +1 -0
  104. package/dist/client/StateMonitor.d.mts +122 -0
  105. package/dist/client/StateMonitor.d.mts.map +1 -0
  106. package/dist/client/StateMonitor.mjs +129 -0
  107. package/dist/client/StateMonitor.mjs.map +1 -0
  108. package/dist/client/Transport.cjs +11 -0
  109. package/dist/client/Transport.d.cts +237 -0
  110. package/dist/client/Transport.d.cts.map +1 -0
  111. package/dist/client/Transport.d.mts +237 -0
  112. package/dist/client/Transport.d.mts.map +1 -0
  113. package/dist/client/Transport.mjs +6 -0
  114. package/dist/client/Transport.mjs.map +1 -0
  115. package/dist/client/WebSocketTransport.cjs +396 -0
  116. package/dist/client/WebSocketTransport.d.cts +29 -0
  117. package/dist/client/WebSocketTransport.d.cts.map +1 -0
  118. package/dist/client/WebSocketTransport.d.mts +29 -0
  119. package/dist/client/WebSocketTransport.d.mts.map +1 -0
  120. package/dist/client/WebSocketTransport.mjs +392 -0
  121. package/dist/client/WebSocketTransport.mjs.map +1 -0
  122. package/dist/client/errors.cjs +135 -0
  123. package/dist/client/errors.d.cts +87 -0
  124. package/dist/client/errors.d.cts.map +1 -0
  125. package/dist/client/errors.d.mts +87 -0
  126. package/dist/client/errors.d.mts.map +1 -0
  127. package/dist/client/errors.mjs +127 -0
  128. package/dist/client/errors.mjs.map +1 -0
  129. package/dist/client/index.cjs +22 -1424
  130. package/dist/client/index.d.cts +8 -692
  131. package/dist/client/index.d.mts +8 -692
  132. package/dist/client/index.mjs +9 -1413
  133. package/dist/index.cjs +30 -2529
  134. package/dist/index.d.cts +12 -143
  135. package/dist/index.d.mts +12 -143
  136. package/dist/index.mjs +13 -2526
  137. package/dist/primitives/Array.cjs +302 -0
  138. package/dist/primitives/Array.d.cts +95 -0
  139. package/dist/primitives/Array.d.cts.map +1 -0
  140. package/dist/primitives/Array.d.mts +95 -0
  141. package/dist/primitives/Array.d.mts.map +1 -0
  142. package/dist/primitives/Array.mjs +301 -0
  143. package/dist/primitives/Array.mjs.map +1 -0
  144. package/dist/primitives/Boolean.cjs +95 -0
  145. package/dist/primitives/Boolean.d.cts +44 -0
  146. package/dist/primitives/Boolean.d.cts.map +1 -0
  147. package/dist/primitives/Boolean.d.mts +44 -0
  148. package/dist/primitives/Boolean.d.mts.map +1 -0
  149. package/dist/primitives/Boolean.mjs +94 -0
  150. package/dist/primitives/Boolean.mjs.map +1 -0
  151. package/dist/primitives/Either.cjs +200 -0
  152. package/dist/primitives/Either.d.cts +113 -0
  153. package/dist/primitives/Either.d.cts.map +1 -0
  154. package/dist/primitives/Either.d.mts +113 -0
  155. package/dist/primitives/Either.d.mts.map +1 -0
  156. package/dist/primitives/Either.mjs +199 -0
  157. package/dist/primitives/Either.mjs.map +1 -0
  158. package/dist/primitives/Lazy.cjs +46 -0
  159. package/dist/primitives/Lazy.d.cts +46 -0
  160. package/dist/primitives/Lazy.d.cts.map +1 -0
  161. package/dist/primitives/Lazy.d.mts +46 -0
  162. package/dist/primitives/Lazy.d.mts.map +1 -0
  163. package/dist/primitives/Lazy.mjs +46 -0
  164. package/dist/primitives/Lazy.mjs.map +1 -0
  165. package/dist/primitives/Literal.cjs +91 -0
  166. package/dist/primitives/Literal.d.cts +46 -0
  167. package/dist/primitives/Literal.d.cts.map +1 -0
  168. package/dist/primitives/Literal.d.mts +46 -0
  169. package/dist/primitives/Literal.d.mts.map +1 -0
  170. package/dist/primitives/Literal.mjs +90 -0
  171. package/dist/primitives/Literal.mjs.map +1 -0
  172. package/dist/primitives/Number.cjs +115 -0
  173. package/dist/primitives/Number.d.cts +54 -0
  174. package/dist/primitives/Number.d.cts.map +1 -0
  175. package/dist/primitives/Number.d.mts +54 -0
  176. package/dist/primitives/Number.d.mts.map +1 -0
  177. package/dist/primitives/Number.mjs +114 -0
  178. package/dist/primitives/Number.mjs.map +1 -0
  179. package/dist/primitives/String.cjs +127 -0
  180. package/dist/primitives/String.d.cts +56 -0
  181. package/dist/primitives/String.d.cts.map +1 -0
  182. package/dist/primitives/String.d.mts +56 -0
  183. package/dist/primitives/String.d.mts.map +1 -0
  184. package/dist/primitives/String.mjs +126 -0
  185. package/dist/primitives/String.mjs.map +1 -0
  186. package/dist/primitives/Struct.cjs +207 -0
  187. package/dist/primitives/Struct.d.cts +96 -0
  188. package/dist/primitives/Struct.d.cts.map +1 -0
  189. package/dist/primitives/Struct.d.mts +97 -0
  190. package/dist/primitives/Struct.d.mts.map +1 -0
  191. package/dist/primitives/Struct.mjs +206 -0
  192. package/dist/primitives/Struct.mjs.map +1 -0
  193. package/dist/primitives/Tree.cjs +575 -0
  194. package/dist/primitives/Tree.d.cts +185 -0
  195. package/dist/primitives/Tree.d.cts.map +1 -0
  196. package/dist/primitives/Tree.d.mts +185 -0
  197. package/dist/primitives/Tree.d.mts.map +1 -0
  198. package/dist/primitives/Tree.mjs +574 -0
  199. package/dist/primitives/Tree.mjs.map +1 -0
  200. package/dist/primitives/TreeNode.cjs +73 -0
  201. package/dist/primitives/TreeNode.d.cts +92 -0
  202. package/dist/primitives/TreeNode.d.cts.map +1 -0
  203. package/dist/primitives/TreeNode.d.mts +93 -0
  204. package/dist/primitives/TreeNode.d.mts.map +1 -0
  205. package/dist/primitives/TreeNode.mjs +72 -0
  206. package/dist/primitives/TreeNode.mjs.map +1 -0
  207. package/dist/primitives/Union.cjs +170 -0
  208. package/dist/primitives/Union.d.cts +81 -0
  209. package/dist/primitives/Union.d.cts.map +1 -0
  210. package/dist/primitives/Union.d.mts +81 -0
  211. package/dist/primitives/Union.d.mts.map +1 -0
  212. package/dist/primitives/Union.mjs +169 -0
  213. package/dist/primitives/Union.mjs.map +1 -0
  214. package/dist/primitives/shared.cjs +60 -0
  215. package/dist/primitives/shared.d.cts +147 -0
  216. package/dist/primitives/shared.d.cts.map +1 -0
  217. package/dist/primitives/shared.d.mts +147 -0
  218. package/dist/primitives/shared.d.mts.map +1 -0
  219. package/dist/primitives/shared.mjs +58 -0
  220. package/dist/primitives/shared.mjs.map +1 -0
  221. package/dist/server/ServerDocument.cjs +110 -0
  222. package/dist/server/ServerDocument.d.cts +98 -0
  223. package/dist/server/ServerDocument.d.cts.map +1 -0
  224. package/dist/server/ServerDocument.d.mts +99 -0
  225. package/dist/server/ServerDocument.d.mts.map +1 -0
  226. package/dist/server/ServerDocument.mjs +106 -0
  227. package/dist/server/ServerDocument.mjs.map +1 -0
  228. package/dist/server/errors.cjs +85 -0
  229. package/dist/server/errors.d.cts +53 -0
  230. package/dist/server/errors.d.cts.map +1 -0
  231. package/dist/server/errors.d.mts +53 -0
  232. package/dist/server/errors.d.mts.map +1 -0
  233. package/dist/server/errors.mjs +81 -0
  234. package/dist/server/errors.mjs.map +1 -0
  235. package/dist/server/index.cjs +9 -185
  236. package/dist/server/index.d.cts +3 -148
  237. package/dist/server/index.d.mts +3 -148
  238. package/dist/server/index.mjs +3 -181
  239. package/dist/types/index.cjs +16 -0
  240. package/dist/types/index.d.cts +16 -0
  241. package/dist/types/index.d.cts.map +1 -0
  242. package/dist/types/index.d.mts +16 -0
  243. package/dist/types/index.d.mts.map +1 -0
  244. package/dist/types/index.mjs +12 -0
  245. package/dist/types/index.mjs.map +1 -0
  246. package/dist/utils/tree-helpers.cjs +443 -0
  247. package/dist/utils/tree-helpers.d.cts +280 -0
  248. package/dist/utils/tree-helpers.d.cts.map +1 -0
  249. package/dist/utils/tree-helpers.d.mts +280 -0
  250. package/dist/utils/tree-helpers.d.mts.map +1 -0
  251. package/dist/utils/tree-helpers.mjs +439 -0
  252. package/dist/utils/tree-helpers.mjs.map +1 -0
  253. package/package.json +2 -2
  254. package/src/index.ts +2 -0
  255. package/src/primitives/shared.ts +7 -1
  256. package/src/types/index.ts +137 -0
  257. package/src/utils/index.ts +7 -0
  258. package/src/utils/tree-helpers.ts +648 -0
  259. package/tsdown.config.ts +1 -1
  260. package/dist/Document-ChuFrTk1.cjs +0 -571
  261. package/dist/Document-CwiAFTIq.mjs +0 -438
  262. package/dist/Document-CwiAFTIq.mjs.map +0 -1
  263. package/dist/Presence-DKKP4v5X.d.cts.map +0 -1
  264. package/dist/Presence-DdMVKcOv.mjs.map +0 -1
  265. package/dist/Presence-N8u7Eppr.d.mts.map +0 -1
  266. package/dist/Primitive-CvFVxR8_.d.cts +0 -1175
  267. package/dist/Primitive-CvFVxR8_.d.cts.map +0 -1
  268. package/dist/Primitive-lEhQyGVL.d.mts +0 -1175
  269. package/dist/Primitive-lEhQyGVL.d.mts.map +0 -1
  270. package/dist/client/index.d.cts.map +0 -1
  271. package/dist/client/index.d.mts.map +0 -1
  272. package/dist/client/index.mjs.map +0 -1
  273. package/dist/index.d.cts.map +0 -1
  274. package/dist/index.d.mts.map +0 -1
  275. package/dist/index.mjs.map +0 -1
  276. package/dist/server/index.d.cts.map +0 -1
  277. package/dist/server/index.d.mts.map +0 -1
  278. package/dist/server/index.mjs.map +0 -1
package/dist/index.d.cts CHANGED
@@ -1,143 +1,12 @@
1
- import { _ as OperationPath_d_exports, a as InferSetInput, c as InferUpdateInput, d as ProxyEnvironment_d_exports, g as Operation_d_exports, h as Operation, i as InferProxy, m as Transaction_d_exports, n as AnyTreeNodePrimitive, o as InferSnapshot, p as Transaction, r as AnyPrimitive, s as InferState, t as Primitive_d_exports, u as Transform_d_exports, v as __export } from "./Primitive-CvFVxR8_.cjs";
2
- import { i as Presence_d_exports } from "./Presence-DKKP4v5X.cjs";
3
- import { Schema } from "effect";
4
-
5
- //#region src/Document.d.ts
6
- declare namespace Document_d_exports {
7
- export { Document, DocumentOptions, NestedTransactionError, OperationError, make };
8
- }
9
- /**
10
- * Error thrown when attempting to start a nested transaction.
11
- */
12
- declare class NestedTransactionError extends Error {
13
- readonly _tag = "NestedTransactionError";
14
- constructor();
15
- }
16
- /**
17
- * Error thrown when an operation fails to apply.
18
- */
19
- declare class OperationError extends Error {
20
- readonly _tag = "OperationError";
21
- constructor(message: string);
22
- }
23
- /**
24
- * A Document manages state for a primitive-based schema with transaction support.
25
- */
26
- interface Document<TSchema extends AnyPrimitive> {
27
- /** The schema defining this document's structure */
28
- readonly schema: TSchema;
29
- /** Root proxy for accessing and modifying document data */
30
- readonly root: InferProxy<TSchema>;
31
- /** Returns the current document state */
32
- get(): InferState<TSchema> | undefined;
33
- /**
34
- * Returns a readonly snapshot of the entire document state for rendering.
35
- * The snapshot is a type-safe, readonly structure where:
36
- * - Required fields and fields with defaults are guaranteed to be defined
37
- * - Optional fields may be undefined
38
- */
39
- toSnapshot(): InferSnapshot<TSchema>;
40
- /**
41
- * Runs a function within a transaction.
42
- * All operations are collected and applied atomically.
43
- * If the function throws, all changes are rolled back.
44
- * @returns The return value of the function
45
- */
46
- transaction<R>(fn: (root: InferProxy<TSchema>) => R): R;
47
- /**
48
- * Applies external operations (e.g., from server/peers) to the document.
49
- * These operations are NOT added to pending operations.
50
- */
51
- apply(ops: ReadonlyArray<Operation<any, any, any>>): void;
52
- /**
53
- * Returns pending local operations as a Transaction and clears the buffer.
54
- */
55
- flush(): Transaction;
56
- }
57
- interface DocumentOptions<TSchema extends AnyPrimitive> {
58
- /** Initial state for the document */
59
- readonly initial?: InferState<TSchema>;
60
- }
61
- /**
62
- * Creates a new Document for the given schema.
63
- */
64
- declare const make: <TSchema extends AnyPrimitive>(schema: TSchema, options?: DocumentOptions<TSchema>) => Document<TSchema>;
65
- declare namespace EffectSchema_d_exports {
66
- export { ToSetSchema, ToTreeNodeSetSchema, ToTreeNodeUpdateSchema, ToUpdateSchema, TreeNodeStateSchema, toSetSchema, toUpdateSchema };
67
- }
68
- /**
69
- * Infer the Effect.Schema type for a primitive's set input.
70
- */
71
- type ToSetSchema<T extends AnyPrimitive> = Schema.Schema<InferSetInput<T>>;
72
- /**
73
- * Infer the Effect.Schema type for a primitive's update input.
74
- */
75
- type ToUpdateSchema<T extends AnyPrimitive> = Schema.Schema<InferUpdateInput<T>>;
76
- /**
77
- * Type for TreeNode set schema - uses the node's data set input type
78
- */
79
- type ToTreeNodeSetSchema<T extends AnyTreeNodePrimitive> = Schema.Schema<InferSetInput<T["data"]>>;
80
- /**
81
- * Type for TreeNode update schema - uses the node's data update input type
82
- */
83
- type ToTreeNodeUpdateSchema<T extends AnyTreeNodePrimitive> = Schema.Schema<InferUpdateInput<T["data"]>>;
84
- /**
85
- * Schema for a tree node state (flat storage format).
86
- */
87
- declare const TreeNodeStateSchema: Schema.Struct<{
88
- id: typeof Schema.String;
89
- type: typeof Schema.String;
90
- parentId: Schema.NullOr<typeof Schema.String>;
91
- pos: typeof Schema.String;
92
- data: typeof Schema.Unknown;
93
- }>;
94
- /**
95
- * Convert a Mimic primitive to an Effect.Schema for set operations.
96
- *
97
- * The resulting schema:
98
- * - For structs: required fields (required=true, no default) are non-optional, others are optional
99
- * - For arrays: uses the element's set schema
100
- * - For unions: creates a Schema.Union of variant schemas
101
- * - For TreeNode: delegates to the node's data struct schema
102
- * - For Tree: returns Schema.Array of TreeNodeState
103
- *
104
- * @example
105
- * ```typescript
106
- * const UserSchema = Primitive.Struct({
107
- * name: Primitive.String().required(),
108
- * age: Primitive.Number().default(0),
109
- * email: Primitive.String(),
110
- * });
111
- *
112
- * const SetSchema = toSetSchema(UserSchema);
113
- * // { name: string, age?: number, email?: string }
114
- * ```
115
- */
116
- declare function toSetSchema<T extends AnyPrimitive>(primitive: T): ToSetSchema<T>;
117
- declare function toSetSchema<T extends AnyTreeNodePrimitive>(primitive: T): ToTreeNodeSetSchema<T>;
118
- /**
119
- * Convert a Mimic primitive to an Effect.Schema for update operations.
120
- *
121
- * The resulting schema:
122
- * - For structs: all fields are optional (partial updates)
123
- * - For unions: all variant fields are optional
124
- * - For TreeNode: delegates to the node's data struct update schema
125
- * - For simple primitives: same as set schema
126
- *
127
- * @example
128
- * ```typescript
129
- * const UserSchema = Primitive.Struct({
130
- * name: Primitive.String().required(),
131
- * age: Primitive.Number().default(0),
132
- * email: Primitive.String(),
133
- * });
134
- *
135
- * const UpdateSchema = toUpdateSchema(UserSchema);
136
- * // { name?: string, age?: string, email?: string }
137
- * ```
138
- */
139
- declare function toUpdateSchema<T extends AnyPrimitive>(primitive: T): ToUpdateSchema<T>;
140
- declare function toUpdateSchema<T extends AnyTreeNodePrimitive>(primitive: T): ToTreeNodeUpdateSchema<T>;
141
- //#endregion
142
- export { Document_d_exports as Document, EffectSchema_d_exports as EffectSchema, Operation_d_exports as Operation, OperationPath_d_exports as OperationPath, Presence_d_exports as Presence, Primitive_d_exports as Primitive, ProxyEnvironment_d_exports as ProxyEnvironment, Transaction_d_exports as Transaction, Transform_d_exports as Transform };
143
- //# sourceMappingURL=index.d.cts.map
1
+ import { Presence_d_exports } from "./Presence.cjs";
2
+ import { OperationPath_d_exports } from "./OperationPath.cjs";
3
+ import { Operation_d_exports } from "./Operation.cjs";
4
+ import { Transaction_d_exports } from "./Transaction.cjs";
5
+ import { ProxyEnvironment_d_exports } from "./ProxyEnvironment.cjs";
6
+ import { Transform_d_exports } from "./Transform.cjs";
7
+ import { Primitive_d_exports } from "./Primitive.cjs";
8
+ import { Document_d_exports } from "./Document.cjs";
9
+ import { EffectSchema_d_exports } from "./EffectSchema.cjs";
10
+ import { index_d_exports } from "./types/index.cjs";
11
+ import { tree_helpers_d_exports } from "./utils/tree-helpers.cjs";
12
+ export { Document_d_exports as Document, EffectSchema_d_exports as EffectSchema, Operation_d_exports as Operation, OperationPath_d_exports as OperationPath, Presence_d_exports as Presence, Primitive_d_exports as Primitive, ProxyEnvironment_d_exports as ProxyEnvironment, Transaction_d_exports as Transaction, Transform_d_exports as Transform, tree_helpers_d_exports as TreeHelpers, index_d_exports as Types };
package/dist/index.d.mts CHANGED
@@ -1,143 +1,12 @@
1
- import { i as Presence_d_exports } from "./Presence-N8u7Eppr.mjs";
2
- import { _ as OperationPath_d_exports, a as InferSetInput, c as InferUpdateInput, d as ProxyEnvironment_d_exports, g as Operation_d_exports, h as Operation, i as InferProxy, m as Transaction_d_exports, n as AnyTreeNodePrimitive, o as InferSnapshot, p as Transaction, r as AnyPrimitive, s as InferState, t as Primitive_d_exports, u as Transform_d_exports } from "./Primitive-lEhQyGVL.mjs";
3
- import { Schema } from "effect";
4
-
5
- //#region src/Document.d.ts
6
- declare namespace Document_d_exports {
7
- export { Document, DocumentOptions, NestedTransactionError, OperationError, make };
8
- }
9
- /**
10
- * Error thrown when attempting to start a nested transaction.
11
- */
12
- declare class NestedTransactionError extends Error {
13
- readonly _tag = "NestedTransactionError";
14
- constructor();
15
- }
16
- /**
17
- * Error thrown when an operation fails to apply.
18
- */
19
- declare class OperationError extends Error {
20
- readonly _tag = "OperationError";
21
- constructor(message: string);
22
- }
23
- /**
24
- * A Document manages state for a primitive-based schema with transaction support.
25
- */
26
- interface Document<TSchema extends AnyPrimitive> {
27
- /** The schema defining this document's structure */
28
- readonly schema: TSchema;
29
- /** Root proxy for accessing and modifying document data */
30
- readonly root: InferProxy<TSchema>;
31
- /** Returns the current document state */
32
- get(): InferState<TSchema> | undefined;
33
- /**
34
- * Returns a readonly snapshot of the entire document state for rendering.
35
- * The snapshot is a type-safe, readonly structure where:
36
- * - Required fields and fields with defaults are guaranteed to be defined
37
- * - Optional fields may be undefined
38
- */
39
- toSnapshot(): InferSnapshot<TSchema>;
40
- /**
41
- * Runs a function within a transaction.
42
- * All operations are collected and applied atomically.
43
- * If the function throws, all changes are rolled back.
44
- * @returns The return value of the function
45
- */
46
- transaction<R>(fn: (root: InferProxy<TSchema>) => R): R;
47
- /**
48
- * Applies external operations (e.g., from server/peers) to the document.
49
- * These operations are NOT added to pending operations.
50
- */
51
- apply(ops: ReadonlyArray<Operation<any, any, any>>): void;
52
- /**
53
- * Returns pending local operations as a Transaction and clears the buffer.
54
- */
55
- flush(): Transaction;
56
- }
57
- interface DocumentOptions<TSchema extends AnyPrimitive> {
58
- /** Initial state for the document */
59
- readonly initial?: InferState<TSchema>;
60
- }
61
- /**
62
- * Creates a new Document for the given schema.
63
- */
64
- declare const make: <TSchema extends AnyPrimitive>(schema: TSchema, options?: DocumentOptions<TSchema>) => Document<TSchema>;
65
- declare namespace EffectSchema_d_exports {
66
- export { ToSetSchema, ToTreeNodeSetSchema, ToTreeNodeUpdateSchema, ToUpdateSchema, TreeNodeStateSchema, toSetSchema, toUpdateSchema };
67
- }
68
- /**
69
- * Infer the Effect.Schema type for a primitive's set input.
70
- */
71
- type ToSetSchema<T extends AnyPrimitive> = Schema.Schema<InferSetInput<T>>;
72
- /**
73
- * Infer the Effect.Schema type for a primitive's update input.
74
- */
75
- type ToUpdateSchema<T extends AnyPrimitive> = Schema.Schema<InferUpdateInput<T>>;
76
- /**
77
- * Type for TreeNode set schema - uses the node's data set input type
78
- */
79
- type ToTreeNodeSetSchema<T extends AnyTreeNodePrimitive> = Schema.Schema<InferSetInput<T["data"]>>;
80
- /**
81
- * Type for TreeNode update schema - uses the node's data update input type
82
- */
83
- type ToTreeNodeUpdateSchema<T extends AnyTreeNodePrimitive> = Schema.Schema<InferUpdateInput<T["data"]>>;
84
- /**
85
- * Schema for a tree node state (flat storage format).
86
- */
87
- declare const TreeNodeStateSchema: Schema.Struct<{
88
- id: typeof Schema.String;
89
- type: typeof Schema.String;
90
- parentId: Schema.NullOr<typeof Schema.String>;
91
- pos: typeof Schema.String;
92
- data: typeof Schema.Unknown;
93
- }>;
94
- /**
95
- * Convert a Mimic primitive to an Effect.Schema for set operations.
96
- *
97
- * The resulting schema:
98
- * - For structs: required fields (required=true, no default) are non-optional, others are optional
99
- * - For arrays: uses the element's set schema
100
- * - For unions: creates a Schema.Union of variant schemas
101
- * - For TreeNode: delegates to the node's data struct schema
102
- * - For Tree: returns Schema.Array of TreeNodeState
103
- *
104
- * @example
105
- * ```typescript
106
- * const UserSchema = Primitive.Struct({
107
- * name: Primitive.String().required(),
108
- * age: Primitive.Number().default(0),
109
- * email: Primitive.String(),
110
- * });
111
- *
112
- * const SetSchema = toSetSchema(UserSchema);
113
- * // { name: string, age?: number, email?: string }
114
- * ```
115
- */
116
- declare function toSetSchema<T extends AnyPrimitive>(primitive: T): ToSetSchema<T>;
117
- declare function toSetSchema<T extends AnyTreeNodePrimitive>(primitive: T): ToTreeNodeSetSchema<T>;
118
- /**
119
- * Convert a Mimic primitive to an Effect.Schema for update operations.
120
- *
121
- * The resulting schema:
122
- * - For structs: all fields are optional (partial updates)
123
- * - For unions: all variant fields are optional
124
- * - For TreeNode: delegates to the node's data struct update schema
125
- * - For simple primitives: same as set schema
126
- *
127
- * @example
128
- * ```typescript
129
- * const UserSchema = Primitive.Struct({
130
- * name: Primitive.String().required(),
131
- * age: Primitive.Number().default(0),
132
- * email: Primitive.String(),
133
- * });
134
- *
135
- * const UpdateSchema = toUpdateSchema(UserSchema);
136
- * // { name?: string, age?: string, email?: string }
137
- * ```
138
- */
139
- declare function toUpdateSchema<T extends AnyPrimitive>(primitive: T): ToUpdateSchema<T>;
140
- declare function toUpdateSchema<T extends AnyTreeNodePrimitive>(primitive: T): ToTreeNodeUpdateSchema<T>;
141
- //#endregion
142
- export { Document_d_exports as Document, EffectSchema_d_exports as EffectSchema, Operation_d_exports as Operation, OperationPath_d_exports as OperationPath, Presence_d_exports as Presence, Primitive_d_exports as Primitive, ProxyEnvironment_d_exports as ProxyEnvironment, Transaction_d_exports as Transaction, Transform_d_exports as Transform };
143
- //# sourceMappingURL=index.d.mts.map
1
+ import { Presence_d_exports } from "./Presence.mjs";
2
+ import { OperationPath_d_exports } from "./OperationPath.mjs";
3
+ import { Operation_d_exports } from "./Operation.mjs";
4
+ import { Transaction_d_exports } from "./Transaction.mjs";
5
+ import { ProxyEnvironment_d_exports } from "./ProxyEnvironment.mjs";
6
+ import { Transform_d_exports } from "./Transform.mjs";
7
+ import { Primitive_d_exports } from "./Primitive.mjs";
8
+ import { Document_d_exports } from "./Document.mjs";
9
+ import { EffectSchema_d_exports } from "./EffectSchema.mjs";
10
+ import { index_d_exports } from "./types/index.mjs";
11
+ import { tree_helpers_d_exports } from "./utils/tree-helpers.mjs";
12
+ export { Document_d_exports as Document, EffectSchema_d_exports as EffectSchema, Operation_d_exports as Operation, OperationPath_d_exports as OperationPath, Presence_d_exports as Presence, Primitive_d_exports as Primitive, ProxyEnvironment_d_exports as ProxyEnvironment, Transaction_d_exports as Transaction, Transform_d_exports as Transform, tree_helpers_d_exports as TreeHelpers, index_d_exports as Types };