@@ -16,6 +16,15 @@ class DbDevtoolsRegistryImpl implements DbDevtoolsRegistry {
16
16
}
17
17
18
18
registerCollection = ( collection : any ) : void => {
19
+ console . log ( 'Registry: Registering collection' , {
20
+ id : collection . id ,
21
+ type : this . detectCollectionType ( collection ) ,
22
+ status : collection . status ,
23
+ size : collection . size ,
24
+ hasTransactions : collection . transactions . size > 0 ,
25
+ registrySize : this . collections . size
26
+ } )
27
+
19
28
const metadata : CollectionMetadata = {
20
29
id : collection . id ,
21
30
type : this . detectCollectionType ( collection ) ,
@@ -40,6 +49,12 @@ class DbDevtoolsRegistryImpl implements DbDevtoolsRegistry {
40
49
}
41
50
42
51
this . collections . set ( collection . id , entry )
52
+
53
+ console . log ( 'Registry: Collection registered successfully' , {
54
+ id : collection . id ,
55
+ totalCollections : this . collections . size ,
56
+ allCollectionIds : Array . from ( this . collections . keys ( ) )
57
+ } )
43
58
44
59
// Track performance for live queries
45
60
if ( this . isLiveQuery ( collection ) ) {
@@ -76,9 +91,11 @@ class DbDevtoolsRegistryImpl implements DbDevtoolsRegistry {
76
91
}
77
92
78
93
getAllCollectionMetadata = ( ) : Array < CollectionMetadata > => {
94
+ console . log ( 'Registry: getAllCollectionMetadata called, total collections:' , this . collections . size )
95
+
79
96
const results : Array < CollectionMetadata > = [ ]
80
97
81
- for ( const [ _id , entry ] of this . collections ) {
98
+ for ( const [ id , entry ] of this . collections ) {
82
99
const collection = entry . weakRef . deref ( )
83
100
if ( collection ) {
84
101
// Collection is still alive, update metadata
@@ -88,14 +105,22 @@ class DbDevtoolsRegistryImpl implements DbDevtoolsRegistry {
88
105
entry . metadata . transactionCount = collection . transactions . size
89
106
entry . metadata . lastUpdated = new Date ( )
90
107
results . push ( { ...entry . metadata } )
108
+ console . log ( 'Registry: Found live collection:' , {
109
+ id,
110
+ status : collection . status ,
111
+ size : collection . size ,
112
+ type : entry . metadata . type
113
+ } )
91
114
} else {
92
115
// Collection was garbage collected, mark it
93
116
entry . metadata . status = `cleaned-up`
94
117
entry . metadata . lastUpdated = new Date ( )
95
118
results . push ( { ...entry . metadata } )
119
+ console . log ( 'Registry: Found GC\'d collection:' , id )
96
120
}
97
121
}
98
122
123
+ console . log ( 'Registry: Returning metadata for' , results . length , 'collections' )
99
124
return results
100
125
}
101
126
@@ -310,23 +335,4 @@ export function initializeDevtoolsRegistry(): DbDevtoolsRegistry {
310
335
return ( window as any ) . __TANSTACK_DB_DEVTOOLS__ as DbDevtoolsRegistry
311
336
}
312
337
313
- // Initialize devtools and set up automatic collection registration
314
- export function initializeDbDevtools ( ) : void {
315
- // SSR safety check
316
- if ( typeof window === 'undefined' ) {
317
- return
318
- }
319
-
320
- // Initialize the registry
321
- const registry = initializeDevtoolsRegistry ( )
322
338
323
- // Set up global registration function that collections can call
324
- ; ( window as any ) . __TANSTACK_DB_DEVTOOLS_REGISTER__ = ( collection : any ) => {
325
- registry . registerCollection ( collection )
326
- }
327
-
328
- // Set up global unregistration function
329
- ; ( window as any ) . __TANSTACK_DB_DEVTOOLS_UNREGISTER__ = ( id : string ) => {
330
- registry . unregisterCollection ( id )
331
- }
332
- }
0 commit comments