@vuer-ai/vuer-rtc 0.7.0 → 0.8.2

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 (172) hide show
  1. package/CLAUDE.md +3 -2
  2. package/dist/client/EditBuffer.d.ts +4 -4
  3. package/dist/client/EditBuffer.d.ts.map +1 -1
  4. package/dist/client/EditBuffer.js +26 -25
  5. package/dist/client/EditBuffer.js.map +1 -1
  6. package/dist/client/actions.d.ts +3 -3
  7. package/dist/client/actions.d.ts.map +1 -1
  8. package/dist/client/actions.js +71 -70
  9. package/dist/client/actions.js.map +1 -1
  10. package/dist/client/coalesceGraphOps.d.ts +4 -4
  11. package/dist/client/coalesceGraphOps.js +4 -4
  12. package/dist/client/coalesceTextOperations.d.ts.map +1 -1
  13. package/dist/client/coalesceTextOperations.js +23 -20
  14. package/dist/client/coalesceTextOperations.js.map +1 -1
  15. package/dist/client/coalescence/lwwOperations.js +3 -3
  16. package/dist/client/coalescence/lwwOperations.js.map +1 -1
  17. package/dist/client/coalescence/numberOperations.js +2 -2
  18. package/dist/client/coalescence/numberOperations.js.map +1 -1
  19. package/dist/client/coalescence/registry.d.ts +3 -3
  20. package/dist/client/coalescence/registry.d.ts.map +1 -1
  21. package/dist/client/coalescence/registry.js +11 -11
  22. package/dist/client/coalescence/registry.js.map +1 -1
  23. package/dist/client/coalescence/textDeletes.d.ts +8 -7
  24. package/dist/client/coalescence/textDeletes.d.ts.map +1 -1
  25. package/dist/client/coalescence/textDeletes.js +11 -11
  26. package/dist/client/coalescence/textDeletes.js.map +1 -1
  27. package/dist/client/coalescence/textInserts.d.ts +8 -5
  28. package/dist/client/coalescence/textInserts.d.ts.map +1 -1
  29. package/dist/client/coalescence/textInserts.js +32 -12
  30. package/dist/client/coalescence/textInserts.js.map +1 -1
  31. package/dist/client/coalescence/utils.d.ts +3 -9
  32. package/dist/client/coalescence/utils.d.ts.map +1 -1
  33. package/dist/client/coalescence/utils.js +10 -8
  34. package/dist/client/coalescence/utils.js.map +1 -1
  35. package/dist/client/coalescence/vector3Operations.js +2 -2
  36. package/dist/client/coalescence/vector3Operations.js.map +1 -1
  37. package/dist/client/createGraph.d.ts +2 -2
  38. package/dist/client/createGraph.js +4 -4
  39. package/dist/client/createGraph.js.map +1 -1
  40. package/dist/client/createTextDocument.d.ts +1 -1
  41. package/dist/client/createTextDocument.js +3 -3
  42. package/dist/client/createTextDocument.js.map +1 -1
  43. package/dist/client/hooks.d.ts +3 -3
  44. package/dist/client/hooks.d.ts.map +1 -1
  45. package/dist/client/hooks.js +4 -4
  46. package/dist/client/hooks.js.map +1 -1
  47. package/dist/client/textActions.d.ts +2 -2
  48. package/dist/client/textActions.d.ts.map +1 -1
  49. package/dist/client/textActions.js +47 -47
  50. package/dist/client/textActions.js.map +1 -1
  51. package/dist/client/textTypes.d.ts +8 -8
  52. package/dist/client/textTypes.d.ts.map +1 -1
  53. package/dist/client/types.d.ts +4 -4
  54. package/dist/client/types.d.ts.map +1 -1
  55. package/dist/crdt/GraphTextCRDT.d.ts +2 -2
  56. package/dist/crdt/GraphTextCRDT.d.ts.map +1 -1
  57. package/dist/crdt/GraphTextCRDT.js +6 -6
  58. package/dist/crdt/GraphTextCRDT.js.map +1 -1
  59. package/dist/crdt/Rope.d.ts +13 -14
  60. package/dist/crdt/Rope.d.ts.map +1 -1
  61. package/dist/crdt/Rope.js +130 -59
  62. package/dist/crdt/Rope.js.map +1 -1
  63. package/dist/crdt/index.d.ts +1 -1
  64. package/dist/crdt/index.d.ts.map +1 -1
  65. package/dist/crdt/index.js +1 -1
  66. package/dist/crdt/index.js.map +1 -1
  67. package/dist/index.d.ts +1 -1
  68. package/dist/index.d.ts.map +1 -1
  69. package/dist/index.js +1 -1
  70. package/dist/index.js.map +1 -1
  71. package/dist/operations/OperationTypes.d.ts +45 -48
  72. package/dist/operations/OperationTypes.d.ts.map +1 -1
  73. package/dist/operations/OperationValidator.js +11 -11
  74. package/dist/operations/OperationValidator.js.map +1 -1
  75. package/dist/operations/apply/node.js +3 -3
  76. package/dist/operations/apply/node.js.map +1 -1
  77. package/dist/operations/apply/text.d.ts.map +1 -1
  78. package/dist/operations/apply/text.js +35 -32
  79. package/dist/operations/apply/text.js.map +1 -1
  80. package/dist/operations/apply/types.d.ts +4 -4
  81. package/dist/operations/apply/types.d.ts.map +1 -1
  82. package/dist/operations/apply/types.js +8 -8
  83. package/dist/operations/apply/types.js.map +1 -1
  84. package/dist/operations/dispatcher.d.ts.map +1 -1
  85. package/dist/operations/dispatcher.js +52 -13
  86. package/dist/operations/dispatcher.js.map +1 -1
  87. package/dist/serdes.d.ts +1 -1
  88. package/dist/serdes.d.ts.map +1 -1
  89. package/dist/state/ConflictResolver.d.ts +9 -9
  90. package/dist/state/ConflictResolver.d.ts.map +1 -1
  91. package/dist/state/ConflictResolver.js +20 -20
  92. package/dist/state/ConflictResolver.js.map +1 -1
  93. package/dist/state/DType.d.ts +2 -2
  94. package/dist/state/DType.d.ts.map +1 -1
  95. package/dist/state/DType.js +14 -14
  96. package/dist/state/DType.js.map +1 -1
  97. package/dist/state/VectorClock.d.ts +6 -6
  98. package/dist/state/VectorClock.d.ts.map +1 -1
  99. package/dist/state/VectorClock.js +14 -14
  100. package/dist/state/VectorClock.js.map +1 -1
  101. package/dist/state/index.d.ts +1 -1
  102. package/dist/state/index.js +1 -1
  103. package/examples/01-basic-usage.ts +16 -16
  104. package/examples/02-concurrent-edits.ts +29 -29
  105. package/examples/03-scene-building.ts +28 -28
  106. package/examples/04-conflict-resolution.ts +56 -56
  107. package/examples/05-coalescence-usage.ts +23 -23
  108. package/examples/README.md +12 -12
  109. package/package.json +1 -1
  110. package/src/client/EditBuffer.ts +28 -27
  111. package/src/client/TEXT_DOCUMENT_API.md +9 -9
  112. package/src/client/actions.ts +74 -70
  113. package/src/client/coalesceGraphOps.ts +4 -4
  114. package/src/client/coalesceTextOperations.ts +26 -22
  115. package/src/client/coalescence/lwwOperations.ts +3 -3
  116. package/src/client/coalescence/numberOperations.ts +2 -2
  117. package/src/client/coalescence/registry.ts +13 -12
  118. package/src/client/coalescence/textDeletes.ts +22 -18
  119. package/src/client/coalescence/textInserts.ts +49 -25
  120. package/src/client/coalescence/utils.ts +14 -11
  121. package/src/client/coalescence/vector3Operations.ts +2 -2
  122. package/src/client/createGraph.ts +4 -4
  123. package/src/client/createTextDocument.ts +3 -3
  124. package/src/client/hooks.tsx +5 -5
  125. package/src/client/textActions.ts +47 -47
  126. package/src/client/textTypes.ts +8 -8
  127. package/src/client/types.ts +4 -4
  128. package/src/crdt/GraphTextCRDT.ts +6 -6
  129. package/src/crdt/Rope.ts +156 -71
  130. package/src/crdt/index.ts +2 -0
  131. package/src/index.ts +2 -0
  132. package/src/operations/OperationTypes.ts +47 -47
  133. package/src/operations/OperationValidator.ts +11 -11
  134. package/src/operations/apply/node.ts +3 -3
  135. package/src/operations/apply/text.ts +38 -32
  136. package/src/operations/apply/types.ts +11 -11
  137. package/src/operations/dispatcher.ts +57 -13
  138. package/src/serdes.ts +1 -1
  139. package/src/state/ConflictResolver.ts +23 -23
  140. package/src/state/DType.ts +16 -16
  141. package/src/state/VectorClock.ts +14 -14
  142. package/src/state/index.ts +1 -1
  143. package/tests/client/actions.test.ts +76 -76
  144. package/tests/client/coalesce-graph-operations.test.ts +84 -84
  145. package/tests/client/coalesce-text-operations.test.ts +91 -114
  146. package/tests/client/compaction.test.ts +18 -18
  147. package/tests/client/delete-coalescence-bug.test.ts +34 -34
  148. package/tests/client/edit-buffer.test.ts +27 -30
  149. package/tests/client/graph-coalescence-phase1.test.ts +66 -66
  150. package/tests/client/graph-coalescence.test.ts +50 -50
  151. package/tests/client/journal-benchmark.test.ts +5 -5
  152. package/tests/crdt/graph-text-crdt.test.ts +60 -64
  153. package/tests/crdt/rope.test.ts +9 -8
  154. package/tests/crdt/text-operations.test.ts +28 -28
  155. package/tests/fixtures/array-ops.jsonl +6 -6
  156. package/tests/fixtures/boolean-ops.jsonl +6 -6
  157. package/tests/fixtures/color-ops.jsonl +4 -4
  158. package/tests/fixtures/edit-buffer.jsonl +3 -3
  159. package/tests/fixtures/node-ops.jsonl +6 -6
  160. package/tests/fixtures/number-ops.jsonl +7 -7
  161. package/tests/fixtures/object-ops.jsonl +4 -4
  162. package/tests/fixtures/operations.jsonl +7 -7
  163. package/tests/fixtures/string-ops.jsonl +4 -4
  164. package/tests/fixtures/undo-redo.jsonl +3 -3
  165. package/tests/fixtures/vector-ops.jsonl +17 -17
  166. package/tests/operations/collections.test.ts +4 -4
  167. package/tests/operations/nodes.test.ts +5 -5
  168. package/tests/operations/operation-ordering.test.ts +406 -0
  169. package/tests/operations/primitives.test.ts +4 -4
  170. package/tests/operations/unified-schema.test.ts +27 -27
  171. package/tests/operations/vectors.test.ts +4 -4
  172. package/tests/sync/digest.test.ts +5 -5
@@ -12,10 +12,10 @@ import type { SceneGraph, CRDTMessage, Operation } from '../../src/operations/Op
12
12
  function createMsg(ops: Operation | Operation[], lamport = 1): CRDTMessage {
13
13
  return {
14
14
  id: `msg-${Math.random().toString(36).slice(2)}`,
15
- sessionId: 'test-session',
15
+ client: 'test-session',
16
16
  clock: { 'test-session': lamport },
17
- lamportTime: lamport,
18
- timestamp: Date.now() / 1000,
17
+ lt: lamport,
18
+ ts: Date.now() / 1000,
19
19
  ops: Array.isArray(ops) ? ops : [ops],
20
20
  };
21
21
  }
@@ -28,7 +28,7 @@ function setupGraph(): SceneGraph {
28
28
  graph,
29
29
  createMsg({
30
30
  key: '',
31
- otype: 'node.insert',
31
+ ot: 'node.insert',
32
32
  path: 'children',
33
33
  value: { key: 'scene', tag: 'Scene', name: 'Root Scene' },
34
34
  }, 1)
@@ -39,7 +39,7 @@ function setupGraph(): SceneGraph {
39
39
  graph,
40
40
  createMsg({
41
41
  key: 'scene',
42
- otype: 'node.insert',
42
+ ot: 'node.insert',
43
43
  path: 'children',
44
44
  value: {
45
45
  key: 'box-1',
@@ -56,7 +56,7 @@ function setupGraph(): SceneGraph {
56
56
  graph,
57
57
  createMsg({
58
58
  key: 'scene',
59
- otype: 'node.insert',
59
+ ot: 'node.insert',
60
60
  path: 'children',
61
61
  value: {
62
62
  key: 'box-2',
@@ -82,7 +82,7 @@ describe('Unified Schema: Key Field', () => {
82
82
  it('should target specific node with key', () => {
83
83
  const op: Operation = {
84
84
  key: 'box-1',
85
- otype: 'vector3.set',
85
+ ot: 'vector3.set',
86
86
  path: 'position',
87
87
  value: [10, 20, 30],
88
88
  };
@@ -97,7 +97,7 @@ describe('Unified Schema: Key Field', () => {
97
97
  const newGraph = createEmptyGraph();
98
98
  const op: Operation = {
99
99
  key: '',
100
- otype: 'node.insert',
100
+ ot: 'node.insert',
101
101
  path: 'children',
102
102
  value: { key: 'new-root', tag: 'Scene', name: 'New Root' },
103
103
  };
@@ -113,7 +113,7 @@ describe('Unified Schema: Key Field', () => {
113
113
  graph,
114
114
  createMsg({
115
115
  key: 'box-1',
116
- otype: 'vector3.add',
116
+ ot: 'vector3.add',
117
117
  path: 'position',
118
118
  value: [0, 5, 0],
119
119
  }, 4)
@@ -124,7 +124,7 @@ describe('Unified Schema: Key Field', () => {
124
124
  graph,
125
125
  createMsg({
126
126
  key: 'box-2',
127
- otype: 'vector3.add',
127
+ ot: 'vector3.add',
128
128
  path: 'position',
129
129
  value: [5, 0, 0],
130
130
  }, 5)
@@ -145,7 +145,7 @@ describe('Unified Schema: Path Field', () => {
145
145
  it('should merge at node root with path: "."', () => {
146
146
  const op: Operation = {
147
147
  key: 'box-1',
148
- otype: 'object.merge',
148
+ ot: 'object.merge',
149
149
  path: '.',
150
150
  value: { castShadow: true, receiveShadow: true },
151
151
  };
@@ -160,7 +160,7 @@ describe('Unified Schema: Path Field', () => {
160
160
  it('should set nested property with dot path', () => {
161
161
  const op: Operation = {
162
162
  key: 'box-1',
163
- otype: 'object.merge',
163
+ ot: 'object.merge',
164
164
  path: 'metadata',
165
165
  value: { version: 2, modified: true },
166
166
  };
@@ -176,7 +176,7 @@ describe('Unified Schema: Path Field', () => {
176
176
  it('should set property directly with path', () => {
177
177
  const op: Operation = {
178
178
  key: 'box-1',
179
- otype: 'boolean.set',
179
+ ot: 'boolean.set',
180
180
  path: 'visible',
181
181
  value: false,
182
182
  };
@@ -195,10 +195,10 @@ describe('Unified Schema: Batch Operations', () => {
195
195
 
196
196
  it('should apply multiple operations in single message', () => {
197
197
  const ops: Operation[] = [
198
- { key: 'box-1', otype: 'vector3.set', path: 'position', value: [1, 1, 1] },
199
- { key: 'box-2', otype: 'vector3.set', path: 'position', value: [2, 2, 2] },
200
- { key: 'box-1', otype: 'boolean.set', path: 'visible', value: false },
201
- { key: 'box-2', otype: 'boolean.set', path: 'visible', value: true },
198
+ { key: 'box-1', ot: 'vector3.set', path: 'position', value: [1, 1, 1] },
199
+ { key: 'box-2', ot: 'vector3.set', path: 'position', value: [2, 2, 2] },
200
+ { key: 'box-1', ot: 'boolean.set', path: 'visible', value: false },
201
+ { key: 'box-2', ot: 'boolean.set', path: 'visible', value: true },
202
202
  ];
203
203
  const result = applyMessage(graph, createMsg(ops, 4));
204
204
 
@@ -210,9 +210,9 @@ describe('Unified Schema: Batch Operations', () => {
210
210
 
211
211
  it('should apply additive operations across nodes', () => {
212
212
  const ops: Operation[] = [
213
- { key: 'box-1', otype: 'vector3.add', path: 'position', value: [1, 0, 0] },
214
- { key: 'box-1', otype: 'vector3.add', path: 'position', value: [0, 1, 0] },
215
- { key: 'box-2', otype: 'vector3.add', path: 'position', value: [0, 0, 1] },
213
+ { key: 'box-1', ot: 'vector3.add', path: 'position', value: [1, 0, 0] },
214
+ { key: 'box-1', ot: 'vector3.add', path: 'position', value: [0, 1, 0] },
215
+ { key: 'box-2', ot: 'vector3.add', path: 'position', value: [0, 0, 1] },
216
216
  ];
217
217
  const result = applyMessage(graph, createMsg(ops, 4));
218
218
 
@@ -224,11 +224,11 @@ describe('Unified Schema: Batch Operations', () => {
224
224
  const ops: Operation[] = [
225
225
  {
226
226
  key: 'scene',
227
- otype: 'node.insert',
227
+ ot: 'node.insert',
228
228
  path: 'children',
229
229
  value: { key: 'box-3', tag: 'Mesh', name: 'Box 3', position: [0, 0, 0] },
230
230
  },
231
- { key: 'box-3', otype: 'vector3.set', path: 'position', value: [10, 10, 10] },
231
+ { key: 'box-3', ot: 'vector3.set', path: 'position', value: [10, 10, 10] },
232
232
  ];
233
233
  const result = applyMessage(graph, createMsg(ops, 4));
234
234
 
@@ -250,7 +250,7 @@ describe('Unified Schema: Type-specific Operations on Nodes', () => {
250
250
  graph,
251
251
  createMsg({
252
252
  key: 'box-1',
253
- otype: 'object.merge',
253
+ ot: 'object.merge',
254
254
  path: '.',
255
255
  value: { opacity: 1.0 },
256
256
  }, 4)
@@ -258,7 +258,7 @@ describe('Unified Schema: Type-specific Operations on Nodes', () => {
258
258
 
259
259
  const op: Operation = {
260
260
  key: 'box-1',
261
- otype: 'number.multiply',
261
+ ot: 'number.multiply',
262
262
  path: 'opacity',
263
263
  value: 0.5,
264
264
  };
@@ -270,7 +270,7 @@ describe('Unified Schema: Type-specific Operations on Nodes', () => {
270
270
  it('should apply string operations to node properties', () => {
271
271
  const op: Operation = {
272
272
  key: 'box-1',
273
- otype: 'string.concat',
273
+ ot: 'string.concat',
274
274
  path: 'name',
275
275
  value: ' (modified)',
276
276
  };
@@ -285,7 +285,7 @@ describe('Unified Schema: Type-specific Operations on Nodes', () => {
285
285
  graph,
286
286
  createMsg({
287
287
  key: 'box-1',
288
- otype: 'array.set',
288
+ ot: 'array.set',
289
289
  path: 'tags',
290
290
  value: ['mesh'],
291
291
  }, 10)
@@ -293,7 +293,7 @@ describe('Unified Schema: Type-specific Operations on Nodes', () => {
293
293
 
294
294
  const op: Operation = {
295
295
  key: 'box-1',
296
- otype: 'array.push',
296
+ ot: 'array.push',
297
297
  path: 'tags',
298
298
  value: 'selectable',
299
299
  };
@@ -28,10 +28,10 @@ function loadOps(filename: string): OpFixture[] {
28
28
  function createMsg(op: Operation, lamport = 1): CRDTMessage {
29
29
  return {
30
30
  id: `msg-${Math.random().toString(36).slice(2)}`,
31
- sessionId: 'test-session',
31
+ client: 'test-session',
32
32
  clock: { 'test-session': lamport },
33
- lamportTime: lamport,
34
- timestamp: Date.now() / 1000,
33
+ lt: lamport,
34
+ ts: Date.now() / 1000,
35
35
  ops: [op],
36
36
  };
37
37
  }
@@ -43,7 +43,7 @@ function createNodeWithProps(
43
43
  ): SceneGraph {
44
44
  const nodeOp: Operation = {
45
45
  key: '',
46
- otype: 'node.insert',
46
+ ot: 'node.insert',
47
47
  path: 'children',
48
48
  value: {
49
49
  key,
@@ -11,8 +11,8 @@ import type { CRDTMessage } from '../../src/operations/OperationTypes.js';
11
11
  function makeMsg(id: string): CRDTMessage {
12
12
  return {
13
13
  id,
14
- sessionId: 'test',
15
- lamportTime: 1,
14
+ client: 'test',
15
+ lt: 1,
16
16
  vectorClock: {},
17
17
  ops: [],
18
18
  };
@@ -27,10 +27,10 @@ function makeState(msgIds: string[]): ClientState {
27
27
  graph: { nodes: {}, rootKey: '' },
28
28
  journal,
29
29
  edits: { ops: [], baseGraph: null },
30
- snapshot: { graph: { nodes: {}, rootKey: '' }, vectorClock: {}, lamportTime: 0, journalIndex: 0 },
31
- lamportTime: 0,
30
+ snapshot: { graph: { nodes: {}, rootKey: '' }, vectorClock: {}, lt: 0, journalIndex: 0 },
31
+ lt: 0,
32
32
  vectorClock: {},
33
- sessionId: 'test',
33
+ client: 'test',
34
34
  };
35
35
  }
36
36