@@ -9,47 +9,36 @@ import * as hooks from './services/hooks'
99
1010interface Channel {
1111 receive ( action : T . Action ) : Promise < void >
12- send ( action : T . Action ) : Promise < void >
13- }
14-
15- interface ChannelProps {
16- postMessage : ( action : T . Action ) => Thenable < boolean >
17- workspaceState : vscode . Memento
1812}
1913
2014class Channel implements Channel {
21- private postMessage : ( action : T . Action ) => Thenable < boolean >
22- private workspaceState : vscode . Memento
23- private context : Context
24- constructor ( { postMessage, workspaceState } : ChannelProps ) {
25- // workspaceState used for local storage
26- this . workspaceState = workspaceState
27- this . postMessage = postMessage
15+ public context : Context
16+ constructor ( workspaceState : vscode . Memento ) {
17+ // workspaceState used for local storages
2818 this . context = new Context ( workspaceState )
2919 }
3020
3121 // receive from webview
3222 public receive = async ( action : T . Action ) : Promise < void > => {
3323 // action may be an object.type or plain string
3424 const actionType : string = typeof action === 'string' ? action : action . type
35- // const onError = (error: T.ErrorMessage) => this.send({ type: 'ERROR', payload: { error } })
3625
3726 logger ( `EXT RECEIVED: "${ actionType } "` )
3827
3928 switch ( actionType ) {
4029 case 'EDITOR_STARTUP' :
41- actions . onStartup ( this . context , this . workspaceState , this . send )
30+ actions . onStartup ( this . context )
4231 return
4332 // clear tutorial local storage
4433 // configure test runner, language, git
4534 case 'EDITOR_TUTORIAL_CONFIG' :
46- actions . onTutorialConfigNew ( action , this . context , this . send )
35+ actions . onTutorialConfigNew ( action , this . context )
4736 return
4837 case 'EDITOR_TUTORIAL_CONTINUE_CONFIG' :
49- actions . onTutorialConfigContinue ( action , this . context , this . send )
38+ actions . onTutorialConfigContinue ( action , this . context )
5039 return
5140 case 'EDITOR_VALIDATE_SETUP' :
52- actions . onValidateSetup ( this . send )
41+ actions . onValidateSetup ( )
5342 return
5443 case 'EDITOR_REQUEST_WORKSPACE' :
5544 openWorkspace ( )
@@ -95,26 +84,6 @@ class Channel implements Channel {
9584 return
9685 }
9786 }
98- // send to webview
99- public send = async ( action : T . Action ) : Promise < void > => {
100- // load error page if error action is triggered
101- actions . onErrorPage ( action )
102- // action may be an object.type or plain string
103- const actionType : string = typeof action === 'string' ? action : action . type
104-
105- logger ( `EXT TO CLIENT: "${ actionType } "` )
106-
107- switch ( actionType ) {
108- case 'TEST_PASS' :
109- actions . onTestPass ( action , this . context )
110- }
111-
112- // send message
113- const sentToClient = await this . postMessage ( action )
114- if ( ! sentToClient ) {
115- throw new Error ( `Message post failure: ${ JSON . stringify ( action ) } ` )
116- }
117- }
11887}
11988
12089export default Channel
0 commit comments