Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit17e412e

Browse files
committed
working version
1 parent0107b0d commit17e412e

File tree

12 files changed

+48
-138
lines changed

12 files changed

+48
-138
lines changed

‎src/Channel.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ interface Channel {
1212

1313
classChannelimplementsChannel{
1414
privatepostMessage:(action:CR.Action)=>Thenable<boolean>
15-
constructor(webview:vscode.Webview){
16-
this.postMessage=webview.postMessage
15+
constructor(postMessage:(action:CR.Action)=>Thenable<boolean>){
16+
this.postMessage=postMessage
1717
}
1818

1919
// receive from webview

‎src/actions/runTest.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,15 @@ const getOutputChannel = (name: string): vscode.OutputChannel => {
2222
interfaceProps{
2323
onSuccess():void
2424
onFail():void
25+
onRun():void
2526
}
2627

27-
exportdefaultasyncfunctionrunTest({onSuccess, onFail}:Props):Promise<void>{
28+
asyncfunctionrunTest({onSuccess, onFail, onRun}:Props):Promise<void>{
2829
// increment process id
2930
constprocessId=++currentId
3031

32+
onRun()
33+
3134
constoutputChannelName='Test Output'
3235

3336
// TODO: validate test directory from package.json exists
@@ -139,3 +142,5 @@ export default async function runTest({onSuccess, onFail}: Props): Promise<void>
139142
// }
140143
}
141144
}
145+
146+
exportdefaultrunTest

‎src/actions/tutorialConfig.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ const tutorialConfig = async (tutorial: G.Tutorial) => {
1919
vscode.commands.executeCommand('coderoad.run_test')
2020
}
2121
})
22+
23+
console.log('configured')
2224
}
2325

2426
exportdefaulttutorialConfig

‎src/editor/ReactWebView.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import{Action}from'typings'
12
import*aspathfrom'path'
23
import*asvscodefrom'vscode'
34
importChannelfrom'../Channel'
@@ -36,7 +37,9 @@ class ReactWebView {
3637
// This happens when the user closes the panel or when the panel is closed programmatically
3738
this.panel.onDidDispose(this.dispose,this,this.disposables)
3839

39-
this.channel=newChannel(this.panel.webview)
40+
this.channel=newChannel((action:Action):Thenable<boolean>=>{
41+
returnthis.panel.webview.postMessage(action)
42+
})
4043
// Handle messages from the webview
4144
constreceive=this.channel.receive
4245
this.panel.webview.onDidReceiveMessage(receive,null,this.disposables)

‎src/editor/commands.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,6 @@ interface CreateCommandProps {
1313
vscodeExt:vscode.ExtensionContext
1414
}
1515

16-
constresetLayout=()=>{
17-
vscode.commands.executeCommand('vscode.setEditorLayout',{
18-
orientation:0,
19-
groups:[{groups:[{}],size:0.6},{groups:[{}],size:0.4}],
20-
})
21-
}
22-
2316
exportconstcreateCommands=({vscodeExt}:CreateCommandProps)=>{
2417
// React panel webview
2518
letwebview:any
@@ -50,18 +43,31 @@ export const createCommands = ({vscodeExt}: CreateCommandProps) => {
5043
[COMMANDS.OPEN_WEBVIEW]:(column:number=vscode.ViewColumn.Two)=>{
5144
console.log('open webview')
5245
// setup 1x1 horizontal layout
53-
resetLayout()
46+
47+
// reset layout
48+
vscode.commands.executeCommand('vscode.setEditorLayout',{
49+
orientation:0,
50+
groups:[{groups:[{}],size:0.6},{groups:[{}],size:0.4}],
51+
})
52+
5453
webview.createOrShow(column)
5554
},
5655
[COMMANDS.RUN_TEST]:()=>{
56+
console.log('run test webview',Object.keys(webview))
5757
runTest({
5858
onSuccess:()=>{
59-
console.log('TEST_PASS')
59+
console.log('COMMAND TEST_PASS')
60+
webview.send({type:'TEST_PASS'})
6061
vscode.window.showInformationMessage('PASS')
6162
},
6263
onFail:()=>{
63-
console.log('TEST_FAIL')
64+
console.log('COMMAND TEST_FAIL')
65+
webview.send({type:'TEST_FAIL'})
6466
vscode.window.showWarningMessage('FAIL')
67+
},
68+
onRun:()=>{
69+
console.log('COMMAND TEST_RUN')
70+
webview.send({type:'TEST_RUN'})
6571
}
6672
})
6773
},

‎src/extension.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
// import * as vscode from 'vscode'
2-
// import Tutorial, {TutorialModel} from './services/tutorial'
31
importEditorfrom'./editor'
42

5-
// export const tutorialModel: TutorialModel = new Tutorial(vscode.commands.executeCommand)
6-
73
// vscode editor
84
exportconsteditor=newEditor()
95

‎src/services/tutorial/index.ts

Lines changed: 0 additions & 85 deletions
This file was deleted.

‎typings/index.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import{send}from'xstate'
2-
importTutorialModelfrom'../src/services/tutorial'
32
import*asGfrom'./graphql'
43

54
exportinterfaceTutorialLevel{

‎web-app/src/Routes.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import*asReactfrom'react'
2-
// import { editorDispatch } from './services/vscode'
32
import*asCRfrom'typings'
43
importWorkspacefrom'./components/Workspace'
54

‎web-app/src/services/channel/index.ts

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,19 @@ class Channel {
1818
consteditor=acquireVsCodeApi()
1919
this.editorSend=editor.postMessage
2020
}
21-
publicmachineSend=(action:Action|string)=>console.log('machine send')
22-
publiceditorSend=(action:Action)=>console.log('editor send')
21+
publicmachineSend=(action:Action|string)=>{/* */}
22+
publiceditorSend=(action:Action)=>{/* */}
2323

24-
publicsetMachineSend(send:any){
24+
publicsetMachineSend=(send:any)=>{
2525
this.machineSend=send
2626
}
27-
publicreceive(event:ReceivedEvent){
27+
publicreceive=(event:ReceivedEvent)=>{
28+
console.log('CLIENT RECEIVE')
2829
constaction=event.data
2930

3031
//@ts-ignore // ignore browser events from plugins
3132
if(action.source){return}
32-
33+
console.log(`CLIENT RECEIVE:${action.type}`,action)
3334
// messages from core
3435
switch(action.type){
3536
case'TUTORIAL_LOADED':
@@ -38,12 +39,16 @@ class Channel {
3839
console.log('send action to state machine')
3940
return
4041
case'TEST_PASS':
42+
// { type: 'TEST_PASS', payload: { stepId: string }}
4143
this.machineSend(action)
4244
console.log('test passed')
4345
return
4446
case'TEST_FAIL':
4547
this.machineSend(action)
4648
return
49+
case'TEST_RUN':
50+
console.log('TEST_RUN')
51+
return
4752
case'ACTIONS_LOADED':
4853
console.log('ACTIONS_LOADED')
4954
return
@@ -56,29 +61,3 @@ class Channel {
5661
}
5762

5863
exportdefaultnewChannel()
59-
60-
// Send to Editor
61-
// export const send = (action: Action) => {
62-
// return
63-
// }
64-
65-
66-
67-
// // Receive from Editor
68-
// export const receive = (event: ReceivedEvent): void => {
69-
70-
71-
// // if (message.type === 'SET_DATA') {
72-
// // // SET_DATA - set state machine context
73-
// // console.log('SET_DATA updated')
74-
// // const {progress, position} = message.payload
75-
// // if (process.env.REACT_APP_DEBUG) {
76-
// // console.log(`Position: ${position.levelId}/${position.stageId}/${position.stepId}`)
77-
// // // setDebuggerInfo({ progress, position })
78-
// //}
79-
// // console.log('set currentTutorial')
80-
// // // currentTutorial.set({position, progress})
81-
82-
// //}
83-
// }
84-

‎web-app/src/services/state/actions/context.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ export default {
2828
//@ts-ignore
2929
updateStepPosition:assign({
3030
position:(context:CR.MachineContext,event:CR.MachineEvent):CR.Position=>{
31+
32+
// TODO: calculate from progress
33+
3134
const{position}=context
3235
// merge in the updated position
3336
// sent with the test to ensure consistency
@@ -101,9 +104,13 @@ export default {
101104
//@ts-ignore
102105
updateStepProgress:assign({
103106
progress:(context:CR.MachineContext,event:CR.MachineEvent):CR.Progress=>{
107+
104108
// update progress by tracking completed
105109
constcurrentProgress:CR.Progress=context.progress
106-
conststepId=event.payload.stepId
110+
111+
// TODO: should use event id, to verify not multiple successes jumping one
112+
// const stepId = event.payload.stepId
113+
const{stepId}=context.position
107114

108115
currentProgress.steps[stepId]=true
109116

‎web-app/src/services/state/machine.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ export const machine = Machine<CR.MachineContext, CR.MachineStateSchema, CR.Mach
121121
on:{
122122
TEST_PASS:{
123123
target:'TestPass',
124-
// TODO: combine updateStepProgress & updateStepPosition
125124
actions:['updateStepProgress']
126125
},
127126
TEST_FAIL:'TestFail',

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp