@@ -3,7 +3,7 @@ import type { SharedState } from '@vitejs/devtools-kit/utils/shared-state'
33import { createSharedState } from '@vitejs/devtools-kit/utils/shared-state'
44import { createDebug } from 'obug'
55
6- const debug = createDebug ( 'vite:devtools:rpc:shared- state' )
6+ const debug = createDebug ( 'vite:devtools:rpc:state:changed ' )
77
88export function createRpcSharedStateServerHost (
99 rpc : RpcFunctionsHost ,
@@ -14,21 +14,21 @@ export function createRpcSharedStateServerHost(
1414 const offs : ( ( ) => void ) [ ] = [ ]
1515
1616 offs . push (
17- state . on ( 'updated' , ( _fullState , patches , syncId ) => {
17+ state . on ( 'updated' , ( fullState , patches , syncId ) => {
1818 if ( patches ) {
1919 debug ( 'patch' , { key, syncId } )
2020 rpc . broadcast ( {
2121 method : 'vite:internal:rpc:client-state:patch' ,
2222 args : [ key , patches , syncId ] ,
23- // TODO: filter: broadcast to clients only subscribed to its
23+ filter : client => client . $meta . subscribedStates . has ( key ) ,
2424 } )
2525 }
2626 else {
2727 debug ( 'updated' , { key, syncId } )
2828 rpc . broadcast ( {
2929 method : 'vite:internal:rpc:client-state:updated' ,
30- args : [ key , syncId ] ,
31- // TODO: filter: broadcast to clients only subscribed to its
30+ args : [ key , fullState , syncId ] ,
31+ filter : client => client . $meta . subscribedStates . has ( key ) ,
3232 } )
3333 }
3434 } ) ,
0 commit comments