22import type * as rta from 'roku-test-automation' ;
33import { RequestType } from 'roku-test-automation/client/dist/types/OnDeviceComponent' ;
44import type { VscodeCommand } from '../../src/commands/VscodeCommand' ;
5- import type { ViewProviderEvent } from '../../src/viewProviders/ViewProviderEvent' ;
5+ import { ViewProviderEvent } from '../../src/viewProviders/ViewProviderEvent' ;
66import { ViewProviderCommand } from '../../src/viewProviders/ViewProviderCommand' ;
7- import type { DeleteEntireRegistrySectionsArgs , DeleteNodeReferencesArgs , DeleteRegistrySectionsArgs , FindNodesAtLocationArgs , GetFocusedNodeArgs , GetNodesInfoArgs , GetNodesWithPropertiesArgs , GetValueArgs , GetValuesArgs , HasFocusArgs , IsInFocusChainArgs , OnFieldChangeOnceArgs , ReadRegistryArgs , RequestOptions , SetValueArgs , StoreNodeReferencesArgs , WriteRegistryArgs , GetVolumeListArgs , GetDirectoryListingArgs , StatPathArgs , RenameFileArgs , DeleteFileArgs , CreateDirectoryArgs , RemoveNodeArgs , RemoveNodeChildrenArgs , FocusNodeArgs } from 'roku-test-automation' ;
7+ import type { DeleteEntireRegistrySectionsArgs , DeleteRegistrySectionsArgs , FindNodesAtLocationArgs , GetFocusedNodeArgs , GetNodesInfoArgs , GetNodesWithPropertiesArgs , GetValueArgs , GetValuesArgs , HasFocusArgs , IsInFocusChainArgs , OnFieldChangeOnceArgs , ReadRegistryArgs , RequestOptions , SetValueArgs , WriteRegistryArgs , GetVolumeListArgs , GetDirectoryListingArgs , StatPathArgs , RenameFileArgs , DeleteFileArgs , CreateDirectoryArgs , RemoveNodeArgs , RemoveNodeChildrenArgs , FocusNodeArgs , AppUIResponse , ConvertKeyPathToSceneKeyPathArgs } from 'roku-test-automation' ;
88
99class ExtensionIntermediary {
1010 private inflightRequests = { } ;
@@ -90,11 +90,23 @@ class ExtensionIntermediary {
9090 } ) ;
9191 }
9292
93- public setVscodeContext ( key : string , value : boolean | number | string ) {
93+ public setVscodeContext ( key : string , value : boolean | number | string , notifyViewIds : string | string [ ] = [ ] ) {
9494 this . postMessage ( this . createCommandMessage ( ViewProviderCommand . setVscodeContext , {
9595 key : key ,
9696 value : value
9797 } ) ) ;
98+
99+ const message = intermediary . createEventMessage ( ViewProviderEvent . onVscodeContextSet , {
100+ key : key ,
101+ value : value
102+ } ) ;
103+ intermediary . sendMessageToWebviews ( notifyViewIds , message ) ;
104+ }
105+
106+ public getVscodeContext ( key : string ) {
107+ return this . sendCommand ( ViewProviderCommand . getVscodeContext , {
108+ key : key
109+ } ) ;
98110 }
99111
100112 public updateWorkspaceState ( key : string , value : any ) {
@@ -111,8 +123,13 @@ class ExtensionIntermediary {
111123 } ) ;
112124 }
113125
114- public async getStoredNodeReferences ( ) {
115- return this . sendCommand < ReturnType < typeof rta . odc . storeNodeReferences > > ( ViewProviderCommand . getStoredNodeReferences ) ;
126+ public async getStoredAppUI ( ) {
127+ return this . sendCommand < AppUIResponse | undefined > ( ViewProviderCommand . getStoredAppUI ) ;
128+ }
129+
130+ public async getAppUI ( ) {
131+ const { response } = await this . sendCommand ( ViewProviderCommand . getAppUI ) ;
132+ return response as AppUIResponse ;
116133 }
117134
118135 public observeEvent ( eventName : string , callback : ObserverCallback ) {
@@ -126,6 +143,10 @@ class ExtensionIntermediary {
126143 }
127144
128145 public sendMessageToWebviews ( viewIds : string | string [ ] , message ) {
146+ if ( ! viewIds || ( Array . isArray ( viewIds ) && viewIds . length === 0 ) ) {
147+ return ;
148+ }
149+
129150 this . postMessage ( this . createCommandMessage ( ViewProviderCommand . sendMessageToWebviews , {
130151 viewIds : viewIds ,
131152 message : message
@@ -201,14 +222,6 @@ class ODCIntermediary {
201222 return this . sendOdcMessage < ReturnType < typeof rta . odc . deleteEntireRegistry > > ( RequestType . deleteEntireRegistry , args , options ) ;
202223 }
203224
204- public async storeNodeReferences ( args ?: StoreNodeReferencesArgs , options ?: RequestOptions ) {
205- return this . sendOdcMessage < ReturnType < typeof rta . odc . storeNodeReferences > > ( RequestType . storeNodeReferences , args , options ) ;
206- }
207-
208- public async deleteNodeReferences ( args : DeleteNodeReferencesArgs , options ?: RequestOptions ) {
209- return this . sendOdcMessage < ReturnType < typeof rta . odc . deleteNodeReferences > > ( RequestType . deleteNodeReferences , args , options ) ;
210- }
211-
212225 public async getNodesWithProperties ( args : GetNodesWithPropertiesArgs , options ?: RequestOptions ) {
213226 return this . sendOdcMessage < ReturnType < typeof rta . odc . getNodesWithProperties > > ( RequestType . getNodesWithProperties , args , options ) ;
214227 }
@@ -256,6 +269,10 @@ class ODCIntermediary {
256269 public async focusNode ( args : FocusNodeArgs , options ?: RequestOptions ) {
257270 return this . sendOdcMessage < ReturnType < typeof rta . odc . focusNode > > ( RequestType . focusNode , args , options ) ;
258271 }
272+
273+ public async convertKeyPathToSceneKeyPath ( args : ConvertKeyPathToSceneKeyPathArgs , options ?: RequestOptions ) {
274+ return this . sendOdcMessage < ReturnType < typeof rta . odc . convertKeyPathToSceneKeyPath > > ( RequestType . convertKeyPathToSceneKeyPath , args , options ) ;
275+ }
259276}
260277
261278type ObserverCallback = ( message ) => void ;
0 commit comments