@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.
- package/CLAUDE.md +3 -2
- package/dist/client/EditBuffer.d.ts +4 -4
- package/dist/client/EditBuffer.d.ts.map +1 -1
- package/dist/client/EditBuffer.js +26 -25
- package/dist/client/EditBuffer.js.map +1 -1
- package/dist/client/actions.d.ts +3 -3
- package/dist/client/actions.d.ts.map +1 -1
- package/dist/client/actions.js +71 -70
- package/dist/client/actions.js.map +1 -1
- package/dist/client/coalesceGraphOps.d.ts +4 -4
- package/dist/client/coalesceGraphOps.js +4 -4
- package/dist/client/coalesceTextOperations.d.ts.map +1 -1
- package/dist/client/coalesceTextOperations.js +23 -20
- package/dist/client/coalesceTextOperations.js.map +1 -1
- package/dist/client/coalescence/lwwOperations.js +3 -3
- package/dist/client/coalescence/lwwOperations.js.map +1 -1
- package/dist/client/coalescence/numberOperations.js +2 -2
- package/dist/client/coalescence/numberOperations.js.map +1 -1
- package/dist/client/coalescence/registry.d.ts +3 -3
- package/dist/client/coalescence/registry.d.ts.map +1 -1
- package/dist/client/coalescence/registry.js +11 -11
- package/dist/client/coalescence/registry.js.map +1 -1
- package/dist/client/coalescence/textDeletes.d.ts +8 -7
- package/dist/client/coalescence/textDeletes.d.ts.map +1 -1
- package/dist/client/coalescence/textDeletes.js +11 -11
- package/dist/client/coalescence/textDeletes.js.map +1 -1
- package/dist/client/coalescence/textInserts.d.ts +8 -5
- package/dist/client/coalescence/textInserts.d.ts.map +1 -1
- package/dist/client/coalescence/textInserts.js +32 -12
- package/dist/client/coalescence/textInserts.js.map +1 -1
- package/dist/client/coalescence/utils.d.ts +3 -9
- package/dist/client/coalescence/utils.d.ts.map +1 -1
- package/dist/client/coalescence/utils.js +10 -8
- package/dist/client/coalescence/utils.js.map +1 -1
- package/dist/client/coalescence/vector3Operations.js +2 -2
- package/dist/client/coalescence/vector3Operations.js.map +1 -1
- package/dist/client/createGraph.d.ts +2 -2
- package/dist/client/createGraph.js +4 -4
- package/dist/client/createGraph.js.map +1 -1
- package/dist/client/createTextDocument.d.ts +1 -1
- package/dist/client/createTextDocument.js +3 -3
- package/dist/client/createTextDocument.js.map +1 -1
- package/dist/client/hooks.d.ts +3 -3
- package/dist/client/hooks.d.ts.map +1 -1
- package/dist/client/hooks.js +4 -4
- package/dist/client/hooks.js.map +1 -1
- package/dist/client/textActions.d.ts +2 -2
- package/dist/client/textActions.d.ts.map +1 -1
- package/dist/client/textActions.js +47 -47
- package/dist/client/textActions.js.map +1 -1
- package/dist/client/textTypes.d.ts +8 -8
- package/dist/client/textTypes.d.ts.map +1 -1
- package/dist/client/types.d.ts +4 -4
- package/dist/client/types.d.ts.map +1 -1
- package/dist/crdt/GraphTextCRDT.d.ts +2 -2
- package/dist/crdt/GraphTextCRDT.d.ts.map +1 -1
- package/dist/crdt/GraphTextCRDT.js +6 -6
- package/dist/crdt/GraphTextCRDT.js.map +1 -1
- package/dist/crdt/Rope.d.ts +13 -14
- package/dist/crdt/Rope.d.ts.map +1 -1
- package/dist/crdt/Rope.js +130 -59
- package/dist/crdt/Rope.js.map +1 -1
- package/dist/crdt/index.d.ts +1 -1
- package/dist/crdt/index.d.ts.map +1 -1
- package/dist/crdt/index.js +1 -1
- package/dist/crdt/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/operations/OperationTypes.d.ts +45 -48
- package/dist/operations/OperationTypes.d.ts.map +1 -1
- package/dist/operations/OperationValidator.js +11 -11
- package/dist/operations/OperationValidator.js.map +1 -1
- package/dist/operations/apply/node.js +3 -3
- package/dist/operations/apply/node.js.map +1 -1
- package/dist/operations/apply/text.d.ts.map +1 -1
- package/dist/operations/apply/text.js +35 -32
- package/dist/operations/apply/text.js.map +1 -1
- package/dist/operations/apply/types.d.ts +4 -4
- package/dist/operations/apply/types.d.ts.map +1 -1
- package/dist/operations/apply/types.js +8 -8
- package/dist/operations/apply/types.js.map +1 -1
- package/dist/operations/dispatcher.d.ts.map +1 -1
- package/dist/operations/dispatcher.js +52 -13
- package/dist/operations/dispatcher.js.map +1 -1
- package/dist/serdes.d.ts +1 -1
- package/dist/serdes.d.ts.map +1 -1
- package/dist/state/ConflictResolver.d.ts +9 -9
- package/dist/state/ConflictResolver.d.ts.map +1 -1
- package/dist/state/ConflictResolver.js +20 -20
- package/dist/state/ConflictResolver.js.map +1 -1
- package/dist/state/DType.d.ts +2 -2
- package/dist/state/DType.d.ts.map +1 -1
- package/dist/state/DType.js +14 -14
- package/dist/state/DType.js.map +1 -1
- package/dist/state/VectorClock.d.ts +6 -6
- package/dist/state/VectorClock.d.ts.map +1 -1
- package/dist/state/VectorClock.js +14 -14
- package/dist/state/VectorClock.js.map +1 -1
- package/dist/state/index.d.ts +1 -1
- package/dist/state/index.js +1 -1
- package/examples/01-basic-usage.ts +16 -16
- package/examples/02-concurrent-edits.ts +29 -29
- package/examples/03-scene-building.ts +28 -28
- package/examples/04-conflict-resolution.ts +56 -56
- package/examples/05-coalescence-usage.ts +23 -23
- package/examples/README.md +12 -12
- package/package.json +1 -1
- package/src/client/EditBuffer.ts +28 -27
- package/src/client/TEXT_DOCUMENT_API.md +9 -9
- package/src/client/actions.ts +74 -70
- package/src/client/coalesceGraphOps.ts +4 -4
- package/src/client/coalesceTextOperations.ts +26 -22
- package/src/client/coalescence/lwwOperations.ts +3 -3
- package/src/client/coalescence/numberOperations.ts +2 -2
- package/src/client/coalescence/registry.ts +13 -12
- package/src/client/coalescence/textDeletes.ts +22 -18
- package/src/client/coalescence/textInserts.ts +49 -25
- package/src/client/coalescence/utils.ts +14 -11
- package/src/client/coalescence/vector3Operations.ts +2 -2
- package/src/client/createGraph.ts +4 -4
- package/src/client/createTextDocument.ts +3 -3
- package/src/client/hooks.tsx +5 -5
- package/src/client/textActions.ts +47 -47
- package/src/client/textTypes.ts +8 -8
- package/src/client/types.ts +4 -4
- package/src/crdt/GraphTextCRDT.ts +6 -6
- package/src/crdt/Rope.ts +156 -71
- package/src/crdt/index.ts +2 -0
- package/src/index.ts +2 -0
- package/src/operations/OperationTypes.ts +47 -47
- package/src/operations/OperationValidator.ts +11 -11
- package/src/operations/apply/node.ts +3 -3
- package/src/operations/apply/text.ts +38 -32
- package/src/operations/apply/types.ts +11 -11
- package/src/operations/dispatcher.ts +57 -13
- package/src/serdes.ts +1 -1
- package/src/state/ConflictResolver.ts +23 -23
- package/src/state/DType.ts +16 -16
- package/src/state/VectorClock.ts +14 -14
- package/src/state/index.ts +1 -1
- package/tests/client/actions.test.ts +76 -76
- package/tests/client/coalesce-graph-operations.test.ts +84 -84
- package/tests/client/coalesce-text-operations.test.ts +91 -114
- package/tests/client/compaction.test.ts +18 -18
- package/tests/client/delete-coalescence-bug.test.ts +34 -34
- package/tests/client/edit-buffer.test.ts +27 -30
- package/tests/client/graph-coalescence-phase1.test.ts +66 -66
- package/tests/client/graph-coalescence.test.ts +50 -50
- package/tests/client/journal-benchmark.test.ts +5 -5
- package/tests/crdt/graph-text-crdt.test.ts +60 -64
- package/tests/crdt/rope.test.ts +9 -8
- package/tests/crdt/text-operations.test.ts +28 -28
- package/tests/fixtures/array-ops.jsonl +6 -6
- package/tests/fixtures/boolean-ops.jsonl +6 -6
- package/tests/fixtures/color-ops.jsonl +4 -4
- package/tests/fixtures/edit-buffer.jsonl +3 -3
- package/tests/fixtures/node-ops.jsonl +6 -6
- package/tests/fixtures/number-ops.jsonl +7 -7
- package/tests/fixtures/object-ops.jsonl +4 -4
- package/tests/fixtures/operations.jsonl +7 -7
- package/tests/fixtures/string-ops.jsonl +4 -4
- package/tests/fixtures/undo-redo.jsonl +3 -3
- package/tests/fixtures/vector-ops.jsonl +17 -17
- package/tests/operations/collections.test.ts +4 -4
- package/tests/operations/nodes.test.ts +5 -5
- package/tests/operations/operation-ordering.test.ts +406 -0
- package/tests/operations/primitives.test.ts +4 -4
- package/tests/operations/unified-schema.test.ts +27 -27
- package/tests/operations/vectors.test.ts +4 -4
- 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
|
-
|
|
15
|
+
client: 'test-session',
|
|
16
16
|
clock: { 'test-session': lamport },
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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',
|
|
199
|
-
{ key: 'box-2',
|
|
200
|
-
{ key: 'box-1',
|
|
201
|
-
{ key: 'box-2',
|
|
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',
|
|
214
|
-
{ key: 'box-1',
|
|
215
|
-
{ key: 'box-2',
|
|
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
|
-
|
|
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',
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
31
|
+
client: 'test-session',
|
|
32
32
|
clock: { 'test-session': lamport },
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
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
|
-
|
|
15
|
-
|
|
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: {},
|
|
31
|
-
|
|
30
|
+
snapshot: { graph: { nodes: {}, rootKey: '' }, vectorClock: {}, lt: 0, journalIndex: 0 },
|
|
31
|
+
lt: 0,
|
|
32
32
|
vectorClock: {},
|
|
33
|
-
|
|
33
|
+
client: 'test',
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
|