@@ -12,12 +12,6 @@ import { applyCanvasOp, restoreVDomElems } from "./model-utils";
1212
1313const dlog = debug ( "wave:vdom" ) ;
1414
15- type AtomContainer = {
16- val : any ;
17- beVal : any ;
18- usedBy : Set < string > ;
19- } ;
20-
2115type RefContainer = {
2216 refFn : ( elem : HTMLElement ) => void ;
2317 vdomRef : VDomRef ;
@@ -86,13 +80,11 @@ export class TsunamiModel {
8680 serverId : string ;
8781 viewRef : React . RefObject < HTMLDivElement > = { current : null } ;
8882 vdomRoot : jotai . PrimitiveAtom < VDomElem > = jotai . atom ( ) ;
89- atoms : Map < string , AtomContainer > = new Map ( ) ; // key is atomname
9083 refs : Map < string , RefContainer > = new Map ( ) ; // key is refid
9184 batchedEvents : VDomEvent [ ] = [ ] ;
9285 messages : VDomMessage [ ] = [ ] ;
9386 needsResync : boolean = true ;
9487 vdomNodeVersion : WeakMap < VDomElem , jotai . PrimitiveAtom < number > > = new WeakMap ( ) ;
95- compoundAtoms : Map < string , jotai . PrimitiveAtom < { [ key : string ] : any } > > = new Map ( ) ;
9688 rootRefId : string = crypto . randomUUID ( ) ;
9789 backendOpts : VDomBackendOpts ;
9890 shouldDispose : boolean ;
@@ -155,13 +147,11 @@ export class TsunamiModel {
155147 this . serverEventSource = null ;
156148 }
157149 getDefaultStore ( ) . set ( this . vdomRoot , null ) ;
158- this . atoms . clear ( ) ;
159150 this . refs . clear ( ) ;
160151 this . batchedEvents = [ ] ;
161152 this . messages = [ ] ;
162153 this . needsResync = true ;
163154 this . vdomNodeVersion = new WeakMap ( ) ;
164- this . compoundAtoms . clear ( ) ;
165155 this . rootRefId = crypto . randomUUID ( ) ;
166156 this . backendOpts = { } ;
167157 this . shouldDispose = false ;
@@ -326,18 +316,6 @@ export class TsunamiModel {
326316 }
327317 }
328318
329- getAtomContainer ( atomName : string ) : AtomContainer {
330- let container = this . atoms . get ( atomName ) ;
331- if ( container == null ) {
332- container = {
333- val : null ,
334- beVal : null ,
335- usedBy : new Set ( ) ,
336- } ;
337- this . atoms . set ( atomName , container ) ;
338- }
339- return container ;
340- }
341319
342320 getOrCreateRefContainer ( vdomRef : VDomRef ) : RefContainer {
343321 let container = this . refs . get ( vdomRef . refid ) ;
@@ -360,19 +338,6 @@ export class TsunamiModel {
360338 return container ;
361339 }
362340
363- tagUseAtoms ( waveId : string , atomNames : Set < string > ) {
364- for ( let atomName of atomNames ) {
365- let container = this . getAtomContainer ( atomName ) ;
366- container . usedBy . add ( waveId ) ;
367- }
368- }
369-
370- tagUnuseAtoms ( waveId : string , atomNames : Set < string > ) {
371- for ( let atomName of atomNames ) {
372- let container = this . getAtomContainer ( atomName ) ;
373- container . usedBy . delete ( waveId ) ;
374- }
375- }
376341
377342 getVDomNodeVersionAtom ( vdom : VDomElem ) {
378343 let atom = this . vdomNodeVersion . get ( vdom ) ;
@@ -469,53 +434,6 @@ export class TsunamiModel {
469434 }
470435 }
471436
472- setAtomValue ( atomName : string , value : any , fromBe : boolean , idMap : Map < string , VDomElem > ) {
473- dlog ( "setAtomValue" , atomName , value , fromBe ) ;
474- let container = this . getAtomContainer ( atomName ) ;
475- if ( container . val === value ) {
476- return ;
477- }
478- container . val = value ;
479- if ( fromBe ) {
480- container . beVal = value ;
481- }
482- for ( let id of container . usedBy ) {
483- this . incVDomNodeVersion ( idMap . get ( id ) ) ;
484- }
485- }
486-
487- handleStateSync ( update : VDomBackendUpdate , idMap : Map < string , VDomElem > ) {
488- if ( update . fullupdate ) {
489- if ( update . statesync == null ) {
490- this . atoms . clear ( ) ;
491- return ;
492- }
493-
494- const sentAtoms = new Set < string > ( ) ;
495- for ( let sync of update . statesync ) {
496- sentAtoms . add ( sync . atom ) ;
497- this . setAtomValue ( sync . atom , sync . value , true , idMap ) ;
498- }
499-
500- const atomsToRemove : string [ ] = [ ] ;
501- for ( let atomName of this . atoms . keys ( ) ) {
502- if ( ! sentAtoms . has ( atomName ) ) {
503- atomsToRemove . push ( atomName ) ;
504- }
505- }
506-
507- for ( let atomName of atomsToRemove ) {
508- this . atoms . delete ( atomName ) ;
509- }
510- } else {
511- if ( update . statesync == null ) {
512- return ;
513- }
514- for ( let sync of update . statesync ) {
515- this . setAtomValue ( sync . atom , sync . value , true , idMap ) ;
516- }
517- }
518- }
519437
520438 getRefElem ( refId : string ) : HTMLElement {
521439 if ( refId == this . rootRefId ) {
@@ -607,7 +525,6 @@ export class TsunamiModel {
607525 }
608526 makeVDomIdMap ( vdomRoot , idMap ) ;
609527 this . handleRenderUpdates ( update , idMap ) ;
610- this . handleStateSync ( update , idMap ) ;
611528 this . handleRefOperations ( update , idMap ) ;
612529 if ( update . messages ) {
613530 for ( let message of update . messages ) {
0 commit comments