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

Commite062d66

Browse files
committed
cleanup editor - experimental
1 parent50cad58 commite062d66

File tree

22 files changed

+83
-267
lines changed

22 files changed

+83
-267
lines changed

‎src/editor/commands/index.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ const COMMANDS = {
2222

2323
interfaceCreateCommandProps{
2424
vscodeExt:vscode.ExtensionContext
25-
machine:CR.StateMachine
2625
}
2726

2827
constresetLayout=()=>{
@@ -32,7 +31,7 @@ const resetLayout = () => {
3231
})
3332
}
3433

35-
exportconstcreateCommands=({vscodeExt, machine}:CreateCommandProps)=>{
34+
exportconstcreateCommands=({vscodeExt}:CreateCommandProps)=>{
3635
// React panel webview
3736
letwebview:any
3837

@@ -59,7 +58,7 @@ export const createCommands = ({vscodeExt, machine}: CreateCommandProps) => {
5958
// activate machine
6059
webview=newReactWebView(vscodeExt.extensionPath)
6160
if(webviewState==='INITIALIZING'){
62-
machine.activate()
61+
//machine.activate()
6362
}elseif(webviewState==='RESTARTING'){
6463
setTimeout(()=>{
6564
// timeout hack to make data update on new windows
@@ -73,7 +72,7 @@ export const createCommands = ({vscodeExt, machine}: CreateCommandProps) => {
7372
// setup 1x1 horizontal layout
7473
resetLayout()
7574
constcallback=()=>{
76-
machine.send('WEBVIEW_INITIALIZED')
75+
//machine.send('WEBVIEW_INITIALIZED')
7776
}
7877
webview.createOrShow(column,callback)
7978
},
@@ -87,7 +86,7 @@ export const createCommands = ({vscodeExt, machine}: CreateCommandProps) => {
8786
console.log('save document',document)
8887
if(document.uri.scheme==='file'&&codingLanguage===document.languageId){
8988
// do work
90-
machine.send('TEST_RUN')
89+
//machine.send('TEST_RUN')
9190
}
9291
})
9392
},
@@ -119,13 +118,13 @@ export const createCommands = ({vscodeExt, machine}: CreateCommandProps) => {
119118
[COMMANDS.RECEIVE_MACHINE_ACTION]:(action:string|CR.Action)=>{
120119
// send received actions from web-app into state machine
121120
console.log('receive action',action)
122-
machine.send(action)
121+
//machine.send(action)
123122
},
124123
[COMMANDS.RUN_TEST]:()=>{
125-
runTest({
126-
onSuccess:()=>machine.send('TEST_PASS'),
127-
onFail:()=>machine.send('TEST_FAIL'),
128-
})
124+
//runTest({
125+
//onSuccess: () => machine.send('TEST_PASS'),
126+
//onFail: () => machine.send('TEST_FAIL'),
127+
//})
129128
},
130129
[COMMANDS.TEST_PASS]:()=>{
131130
vscode.window.showInformationMessage('PASS')

‎src/editor/index.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,13 @@
11
import*asvscodefrom'vscode'
2-
import*asCRfrom'typings'
2+
import{setWorkspaceRoot}from'./services/node'
33
import{createCommands}from'./commands'
44

5-
interfaceProps{
6-
machine:CR.StateMachine
7-
setWorkspaceRoot(rootPath:string):void
8-
}
9-
105
classEditor{
116
// extension context set on activation
127
//@ts-ignore
138
privatevscodeExt:vscode.ExtensionContext
14-
privatemachine:CR.StateMachine
159

16-
constructor({machine, setWorkspaceRoot}:Props){
17-
this.machine=machine
10+
constructor(){
1811

1912
// set workspace root for node executions
2013
const{workspace}=vscode
@@ -40,7 +33,6 @@ class Editor {
4033
}
4134
// shut down state machine
4235
console.log('deactivate machine')
43-
this.machine.deactivate()
4436
}
4537

4638
// execute vscode command
@@ -51,7 +43,6 @@ class Editor {
5143
privateactivateCommands=():void=>{
5244
constcommands=createCommands({
5345
vscodeExt:this.vscodeExt,
54-
machine:this.machine,
5546
})
5647
for(constcmdincommands){
5748
constcommand:vscode.Disposable=vscode.commands.registerCommand(cmd,commands[cmd])

‎src/extension.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
11
import*asvscodefrom'vscode'
2-
import{setWorkspaceRoot}from'./services/node'
32
importTutorial,{TutorialModel}from'./services/tutorial'
4-
importStateMachinefrom'./state'
53
importEditorfrom'./editor'
64

75
exportconsttutorialModel:TutorialModel=newTutorial(vscode.commands.executeCommand)
8-
// state machine that governs application logic
9-
exportconstmachine=newStateMachine(tutorialModel,vscode.commands.executeCommand)
106

117
// vscode editor
12-
exportconsteditor=newEditor({
13-
machine,
14-
setWorkspaceRoot,
15-
})
8+
exportconsteditor=newEditor()
169

1710
// activate run on vscode extension initialization
1811
exportconstactivate=editor.activate

‎src/services/api/gql/getTutorial.ts

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

‎src/services/api/index.ts

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

‎src/services/tutorial/index.ts

Lines changed: 9 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import * as CR from 'typings'
33
import*asgitfrom'../../services/git'
44
import{machine}from'../../extension'
55
import*asstoragefrom'../storage'
6-
importapifrom'../api'
7-
importtutorialQueryfrom'../../services/api/gql/getTutorial'
86

97
interfaceTutorialConfig{
108
codingLanguage:G.EnumCodingLanguage
@@ -17,15 +15,12 @@ export interface TutorialModel {
1715
version:G.TutorialVersion
1816
position:CR.Position
1917
progress:CR.Progress
20-
launch(tutorialId:string):void
21-
level(levelId?:string):G.Level
22-
stage(stageId?:string):G.Stage
23-
step(stepId?:string):G.Step
18+
launch(tutorial:G.Tutorial):void
2419
updateProgress():void
2520
nextPosition():CR.Position
2621
hasExisting():Promise<boolean>
2722
syncClient():void
28-
triggerCurrent(type:'STEP'|'STAGE'|'LEVEL'):void
23+
triggerCurrent(stepActions:G.StepActions):void
2924
}
3025

3126
classTutorialimplementsTutorialModel{
@@ -51,40 +46,27 @@ class Tutorial implements TutorialModel {
5146
position:this.position,
5247
})
5348
this.openFile=(file:string)=>editorDispatch('coderoad.open_file',file)
54-
// Promise.all([
55-
// storage.getTutorial(),
56-
// storage.getProgress(),
57-
// ]).then((data) => {
58-
// const [tutorial, progress] = data
59-
// console.log('load continue tutorial')
60-
// console.log(tutorial, progress)
61-
// })
62-
6349
}
64-
publiclaunch=async(tutorialId:string)=>{
50+
publiclaunch=async(tutorial:G.Tutorial)=>{
6551
console.log('launch tutorial')
6652
machine.send('TUTORIAL_START')
6753

68-
const{tutorial}:{tutorial:G.Tutorial|null}=awaitapi.request(tutorialQuery,{
69-
tutorialId,// TODO: add selection of tutorial id
70-
})
71-
7254
console.log('tutorial',tutorial)
7355

74-
if(!tutorial){
75-
thrownewError(`Tutorial${tutorialId} not found`)
76-
}
77-
7856
this.repo=tutorial.repo
7957

8058
if(!this.repo||!this.repo.uri){
8159
thrownewError('Tutorial repo uri not found')
8260
}
8361

62+
awaitgit.gitInitIfNotExists()
63+
awaitgit.gitSetupRemote(this.repo.uri)
64+
8465
this.config={
8566
codingLanguage:tutorial.codingLanguage,
8667
testRunner:tutorial.testRunner,
8768
}
69+
8870
// version containing level data
8971
this.version=tutorial.version
9072
console.log('version',this.version)
@@ -104,10 +86,7 @@ class Tutorial implements TutorialModel {
10486
}
10587

10688
// setup git, git remote
107-
awaitgit.gitInitIfNotExists()
108-
awaitgit.gitSetupRemote(this.repo.uri)
10989

110-
console.log('this.position',JSON.stringify(this.position))
11190

11291
awaitthis.syncClient()
11392

@@ -140,49 +119,8 @@ class Tutorial implements TutorialModel {
140119

141120
returncanContinue
142121
}
143-
publiclevel=(levelId?:string):G.Level=>{
144-
constlevel:G.Level|undefined=this.version.levels.find((l:G.Level)=>l.id===levelId||this.position.levelId)
145-
if(!level){
146-
thrownewError('Level not found')
147-
}
148-
returnlevel
149-
}
150-
publicstage=(stageId?:string):G.Stage=>{
151-
constlevel:G.Level=this.level(this.position.levelId)
152-
conststage:G.Stage|undefined=level.stages.find((s:G.Stage)=>s.id===stageId||this.position.stageId)
153-
if(!stage){
154-
thrownewError('Stage not found')
155-
}
156-
returnstage
157-
}
158-
publicstep=(stepId?:string):G.Step=>{
159-
conststage:G.Stage=this.stage(this.position.stageId)
160-
conststep:G.Step|undefined=stage.steps.find((s:G.Step)=>s.id===stepId||this.position.stepId)
161-
if(!step){
162-
thrownewError('Step not found')
163-
}
164-
returnstep
165-
}
166-
publictriggerCurrent=(type:'STEP'|'STAGE'|'LEVEL')=>{
167-
lettarget:G.Step|G.Stage|G.Level|null=null
168-
switch(type){
169-
case'STEP':
170-
target=this.step()
171-
break
172-
case'STAGE':
173-
target=this.stage()
174-
break
175-
case'LEVEL':
176-
target=this.level()
177-
break
178-
default:
179-
thrownewError(`Type${type} not found`)
180-
}
181-
if(!target||!target.setup){
182-
// no stepAction
183-
return
184-
}
185-
git.gitLoadCommits(target.setup,this.openFile)
122+
publictriggerCurrent=(stepActions:G.StepActions)=>{
123+
git.gitLoadCommits(stepActions,this.openFile)
186124
}
187125
publicupdateProgress=()=>{
188126
const{levelId, stageId, stepId}=this.position

‎web-app/src/App.tsx

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import*asReactfrom'react'
2-
import{ApolloProvider,useMutation}from'@apollo/react-hooks'
2+
import{ApolloProvider}from'@apollo/react-hooks'
33
import*asCRfrom'typings'
44

55
importclientfrom'./services/apollo'
6-
import{SET_STATUS}from'./services/apollo/mutations'
76
importcurrentTutorialfrom'./services/current'
87
importDebuggerfrom'./components/Debugger'
98
importRoutesfrom'./Routes'
@@ -22,10 +21,6 @@ const App = () => {
2221
progress:{levels:{},stages:{},steps:{},complete:false},
2322
position:{levelId:'',stageId:'',stepId:''},
2423
})
25-
26-
// update level/stage/step status based on user progress & position
27-
// TODO: model server more efficiently
28-
const[setStatus]=useMutation(SET_STATUS)
2924

3025
// event bus listener
3126
React.useEffect(()=>{
@@ -40,16 +35,15 @@ const App = () => {
4035

4136
}elseif(message.type==='SET_DATA'){
4237
// SET_DATA - set state machine context
43-
console.log('DATA')
38+
console.log('SET_DATA updated')
4439
const{ progress, position}=message.payload
4540
if(process.env.REACT_APP_DEBUG){
4641
console.log(`Position:${position.levelId}/${position.stageId}/${position.stepId}`)
4742
setDebuggerInfo({ progress, position})
4843
}
4944
console.log('set currentTutorial')
50-
currentTutorial.set({ position})
51-
console.log('setStatus')
52-
setStatus({variables:{ progress, position}})
45+
currentTutorial.set({ position, progress})
46+
5347
}
5448
}
5549

‎web-app/src/containers/Continue/index.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { useQuery } from '@apollo/react-hooks'
33
import{Button,Card}from'@alifd/next'
44
import*asTfrom'typings/graphql'
55

6+
importcurrentTutorialfrom'../../services/current'
67
import{send}from'../../utils/vscode'
78
importLoadingPagefrom'../LoadingPage'
89
importqueryTutorialfrom'./queryTutorial'
@@ -29,11 +30,12 @@ export const ContinuePage = (props: Props) => (
2930
constLoading=()=><LoadingPagetext="Loading tutorials"/>
3031

3132
constContinuePageContainer=()=>{
32-
// TODO: load specific tutorialId
33+
// TODO: load specific tutorialId
34+
const{ tutorialId, version}=currentTutorial.get()
3335
const{ data, loading, error}=useQuery(queryTutorial,{
3436
variables:{
35-
tutorialId:1,
36-
version:'0.1.0',
37+
tutorialId,
38+
version,
3739
},
3840
})
3941

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp