4
4
* Uses Yjs for efficient local state management and future collaboration.
5
5
* CRDT ensures conflict-free operations for both single and multi-user scenarios.
6
6
*/
7
- import log from 'loglevel'
8
7
import { type ComputedRef , type Ref , computed , customRef } from 'vue'
9
8
import * as Y from 'yjs'
10
9
11
- import { ACTOR_CONFIG , DEBUG_CONFIG } from '@/renderer/core/layout/constants'
10
+ import { ACTOR_CONFIG } from '@/renderer/core/layout/constants'
12
11
import type {
13
12
CreateNodeOperation ,
14
13
DeleteNodeOperation ,
@@ -27,13 +26,6 @@ import type {
27
26
} from '@/renderer/core/layout/types'
28
27
import { SpatialIndexManager } from '@/renderer/core/spatial/SpatialIndex'
29
28
30
- // Create logger for layout store
31
- const logger = log . getLogger ( DEBUG_CONFIG . STORE_LOGGER_NAME )
32
- // In dev mode, always show debug logs
33
- if ( import . meta. env . DEV ) {
34
- logger . setLevel ( 'debug' )
35
- }
36
-
37
29
class LayoutStoreImpl implements LayoutStore {
38
30
// Yjs document and shared data structures
39
31
private ydoc = new Y . Doc ( )
@@ -74,25 +66,10 @@ class LayoutStoreImpl implements LayoutStore {
74
66
event . changes . keys . forEach ( ( _change , key ) => {
75
67
const trigger = this . nodeTriggers . get ( key )
76
68
if ( trigger ) {
77
- logger . debug ( `Yjs change detected for node ${ key } , triggering ref` )
78
69
trigger ( )
79
70
}
80
71
} )
81
72
} )
82
-
83
- // Debug: Log layout operations
84
- if ( localStorage . getItem ( DEBUG_CONFIG . LAYOUT_DEBUG_KEY ) === 'true' ) {
85
- this . yoperations . observe ( ( event ) => {
86
- const operations : LayoutOperation [ ] = [ ]
87
- event . changes . added . forEach ( ( item ) => {
88
- const content = item . content . getContent ( )
89
- if ( Array . isArray ( content ) && content . length > 0 ) {
90
- operations . push ( content [ 0 ] as LayoutOperation )
91
- }
92
- } )
93
- console . log ( 'Layout Operation:' , operations )
94
- } )
95
- }
96
73
}
97
74
98
75
/**
@@ -102,8 +79,6 @@ class LayoutStoreImpl implements LayoutStore {
102
79
let nodeRef = this . nodeRefs . get ( nodeId )
103
80
104
81
if ( ! nodeRef ) {
105
- logger . debug ( `Creating new layout ref for node ${ nodeId } ` )
106
-
107
82
nodeRef = customRef < NodeLayout | null > ( ( track , trigger ) => {
108
83
// Store the trigger so we can call it when Yjs changes
109
84
this . nodeTriggers . set ( nodeId , trigger )
@@ -113,11 +88,6 @@ class LayoutStoreImpl implements LayoutStore {
113
88
track ( )
114
89
const ynode = this . ynodes . get ( nodeId )
115
90
const layout = ynode ? this . yNodeToLayout ( ynode ) : null
116
- logger . debug ( `Layout ref GET for node ${ nodeId } :` , {
117
- position : layout ?. position ,
118
- hasYnode : ! ! ynode ,
119
- version : this . version
120
- } )
121
91
return layout
122
92
} ,
123
93
set : ( newLayout : NodeLayout | null ) => {
@@ -192,7 +162,6 @@ class LayoutStoreImpl implements LayoutStore {
192
162
}
193
163
}
194
164
}
195
- logger . debug ( `Layout ref SET triggering for node ${ nodeId } ` )
196
165
trigger ( )
197
166
}
198
167
}
@@ -294,12 +263,6 @@ class LayoutStoreImpl implements LayoutStore {
294
263
* Apply a layout operation using Yjs transactions
295
264
*/
296
265
applyOperation ( operation : LayoutOperation ) : void {
297
- logger . debug ( `applyOperation called:` , {
298
- type : operation . type ,
299
- nodeId : operation . nodeId ,
300
- operation
301
- } )
302
-
303
266
// Create change object outside transaction so we can use it after
304
267
const change : LayoutChange = {
305
268
type : 'update' ,
@@ -360,9 +323,6 @@ class LayoutStoreImpl implements LayoutStore {
360
323
change . nodeIds . forEach ( ( nodeId ) => {
361
324
const trigger = this . nodeTriggers . get ( nodeId )
362
325
if ( trigger ) {
363
- logger . debug (
364
- `Manually triggering ref for node ${ nodeId } after operation`
365
- )
366
326
trigger ( )
367
327
}
368
328
} )
@@ -413,11 +373,6 @@ class LayoutStoreImpl implements LayoutStore {
413
373
initializeFromLiteGraph (
414
374
nodes : Array < { id : string ; pos : [ number , number ] ; size : [ number , number ] } >
415
375
) : void {
416
- logger . debug ( 'Initializing layout store from LiteGraph' , {
417
- nodeCount : nodes . length ,
418
- nodes : nodes . map ( ( n ) => ( { id : n . id , pos : n . pos } ) )
419
- } )
420
-
421
376
this . ydoc . transact ( ( ) => {
422
377
this . ynodes . clear ( )
423
378
this . nodeRefs . clear ( )
@@ -443,17 +398,8 @@ class LayoutStoreImpl implements LayoutStore {
443
398
444
399
// Add to spatial index
445
400
this . spatialIndex . insert ( layout . id , layout . bounds )
446
-
447
- logger . debug (
448
- `Initialized node ${ layout . id } at position:` ,
449
- layout . position
450
- )
451
401
} )
452
402
} , 'initialization' )
453
-
454
- logger . debug ( 'Layout store initialization complete' , {
455
- totalNodes : this . ynodes . size
456
- } )
457
403
}
458
404
459
405
// Operation handlers
@@ -463,12 +409,9 @@ class LayoutStoreImpl implements LayoutStore {
463
409
) : void {
464
410
const ynode = this . ynodes . get ( operation . nodeId )
465
411
if ( ! ynode ) {
466
- logger . warn ( `No ynode found for ${ operation . nodeId } ` )
467
412
return
468
413
}
469
414
470
- logger . debug ( `Moving node ${ operation . nodeId } ` , operation . position )
471
-
472
415
const size = ynode . get ( 'size' ) as { width : number ; height : number }
473
416
ynode . set ( 'position' , operation . position )
474
417
this . updateNodeBounds ( ynode , operation . position , size )
0 commit comments