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

Commitf73bfcb

Browse files
committed
clean up typings preventing build
1 parentadb575b commitf73bfcb

File tree

13 files changed

+164
-101
lines changed

13 files changed

+164
-101
lines changed

‎src/editor/commands/index.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,16 @@ export const createCommands = ({vscodeExt}: CreateCommandProps) => {
117117
// machine.send(action)
118118
},
119119
[COMMANDS.RUN_TEST]:()=>{
120-
//runTest({
121-
//onSuccess: () =>machine.send('TEST_PASS'),
122-
// onFail: () => machine.send('TEST_FAIL'),
123-
// })
124-
},
125-
[COMMANDS.TEST_PASS]:()=>{
126-
vscode.window.showInformationMessage('PASS')
127-
},
128-
[COMMANDS.TEST_FAIL]:()=>{
129-
vscode.window.showWarningMessage('FAIL')
120+
runTest({
121+
onSuccess:()=>{
122+
console.log('TEST_PASS')
123+
vscode.window.showInformationMessage('PASS')
124+
},
125+
onFail:()=>{
126+
console.log('TEST_FAIL')
127+
vscode.window.showWarningMessage('FAIL')
128+
}
129+
})
130130
},
131131
}
132132
}

‎src/editor/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import*asvscodefrom'vscode'
2-
import{setWorkspaceRoot}from'./services/node'
2+
import{setWorkspaceRoot}from'../services/node'
33
import{createCommands}from'./commands'
44

55
classEditor{

‎src/services/tutorial/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class Tutorial implements TutorialModel {
3838
}
3939
publiclaunch=async(tutorial:G.Tutorial)=>{
4040
console.log('launch tutorial')
41-
machine.send('TUTORIAL_START')
41+
//machine.send('TUTORIAL_START')
4242

4343
console.log('tutorial',tutorial)
4444

‎typings/index.d.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import{send}from'xstate'
22
importTutorialModelfrom'../src/services/tutorial'
3+
import*asGfrom'./graphql'
34

45
exportinterfaceTutorialLevel{
56
stageList:string[]
@@ -116,8 +117,8 @@ export interface Action {
116117

117118
exportinterfaceMachineContext{
118119
tutorial:G.Tutorial|null,
119-
position:CR.Position,
120-
progress:CR.Progress,
120+
position:Position,
121+
progress:Progress,
121122
}
122123

123124
exportinterfaceMachineEvent{

‎web-app/src/components/Router/index.tsx

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,33 @@ import Route from './Route'
77
importdebuggerWrapperfrom'../Debugger/debuggerWrapper'
88
importchannelfrom'../../services/channel'
99
importmessageBusReceiverfrom'../../services/channel/receiver'
10-
importactionsfrom'../../services/state/actions'
11-
1210

1311
interfaceProps{
1412
children:any
1513
}
1614

1715
interfaceCloneElementProps{
18-
context:CR.MachineContext
19-
send(action:CR.Action):void
16+
context:CR.MachineContext
17+
send(action:CR.Action):void
2018
}
2119

2220
// router finds first state match of <Route path='' />
23-
constRouter=({ children}:Props):React.ReactElement<CloneElementProps>|null=>{
24-
const[state,send]=useMachine(machine,{
25-
actions,
26-
interpreterOptions:{
27-
logger:console.log.bind('XSTATE:')
28-
}
29-
})
21+
constRouter=({ children}:Props):React.ReactElement<CloneElementProps>|null=>{
22+
const[state,send]=useMachine(machine,{
23+
interpreterOptions:{
24+
logger:console.log.bind('XSTATE:'),
25+
},
26+
})
3027

31-
channel.setMachineSend(send)
28+
channel.setMachineSend(send)
3229

33-
// event bus listener
30+
// event bus listener
3431
React.useEffect(messageBusReceiver,[])
3532

3633
constchildArray=React.Children.toArray(children)
3734
for(constchildofchildArray){
3835
if(state.matches(child.props.path)){
39-
constelement=React.cloneElement<CloneElementProps>(child.props.children,{ send,context:state.context})
36+
constelement=React.cloneElement<CloneElementProps>(child.props.children,{ send,context:state.context})
4037
returndebuggerWrapper(element,state)
4138
}
4239
}

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,12 @@ interface ContainerProps {
2727
}
2828

2929
constContinuePageContainer=({ context, send}:ContainerProps)=>{
30-
// TODO: load specific tutorialId
3130
const{ tutorial}=context
3231

32+
if(!tutorial){
33+
thrownewError('Tutorial not found')
34+
}
35+
3336
return<ContinuePagetutorial={tutorial}onContinue={()=>send('TUTORIAL_START')}/>
3437
}
3538

‎web-app/src/containers/Tutorial/LevelPage/index.tsx

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,36 @@ export const LevelSummaryPage = (props: LevelProps) => {
1313
constonNext=():void=>{
1414
props.send('NEXT')
1515
}
16-
return<Levellevel={props.level}onNext={onNext}/>
16+
return<Levellevel={props.level}onNext={onNext}/>
1717
}
1818

1919
interfaceContainerProps{
20-
context:CR.MachineContext
21-
send(action:string):void
20+
context:CR.MachineContext
21+
send(action:string):void
2222
}
2323

2424
constLevelSummaryPageContainer=(props:ContainerProps)=>{
25-
const{ tutorial, position, progress}=props.context
26-
27-
constlevel:G.Level=tutorial.version.levels.find((l:G.Level)=>l.id===position.levelId)
28-
29-
level.stages.forEach((stage:G.Stage)=>{
30-
if(stage.id===position.stageId){
31-
stage.status='ACTIVE'
32-
}elseif(progress.stages[stage.id]){
33-
stage.status='COMPLETE'
34-
}else{
35-
stage.status='INCOMPLETE'
36-
}
37-
})
25+
const{ tutorial, position, progress}=props.context
26+
27+
if(!tutorial){
28+
thrownewError('Tutorial not found in LevelSummaryPageContainer')
29+
}
30+
31+
constlevel:G.Level|undefined=tutorial.version.levels.find((l:G.Level)=>l.id===position.levelId)
32+
33+
if(!level){
34+
thrownewError('Level not found in LevelSummaryPageContainer')
35+
}
36+
37+
level.stages.forEach((stage:G.Stage)=>{
38+
if(stage.id===position.stageId){
39+
stage.status='ACTIVE'
40+
}elseif(progress.stages[stage.id]){
41+
stage.status='COMPLETE'
42+
}else{
43+
stage.status='INCOMPLETE'
44+
}
45+
})
3846

3947
return<LevelSummaryPagelevel={level}send={props.send}/>
4048
}

‎web-app/src/containers/Tutorial/StagePage/index.tsx

Lines changed: 46 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,47 +5,59 @@ import * as G from 'typings/graphql'
55
importStagefrom'./Stage'
66

77
interfacePageProps{
8-
context:CR.MachineContext
8+
context:CR.MachineContext
99
send(action:CR.Action):void
1010
}
1111

1212
constStageSummaryPageContainer=(props:PageProps)=>{
13-
const{ tutorial, position, progress}=props.context
13+
const{ tutorial, position, progress}=props.context
14+
15+
if(!tutorial){
16+
thrownewError('Tutorial not found in StageSummaryPageContainer')
17+
}
18+
19+
constlevel:G.Level|undefined=tutorial.version.levels.find((l:G.Level)=>l.id===position.levelId)
20+
21+
if(!level){
22+
thrownewError('Level not found in StageSummaryPageContainer')
23+
}
24+
25+
conststage:G.Stage|undefined=level.stages.find((s:G.Stage)=>s.id===position.stageId)
26+
27+
if(!stage){
28+
thrownewError('Stage not found in StageSummaryPageContainer')
29+
}
1430

15-
conststage:G.Stage=tutorial.version
16-
.levels.find((l:G.Level)=>l.id===position.levelId)
17-
.stages.find((s:G.Stage)=>s.id===position.stageId)
18-
1931
constonContinue=():void=>{
2032
props.send({
21-
type:'STAGE_NEXT',
22-
payload:{
23-
stageId:position.stageId,
24-
}
25-
})
26-
}
27-
28-
constonSave=():void=>{
29-
props.send({
30-
type:'TEST_RUN',
31-
payload:{
32-
stepId:position.stepId,
33-
}
34-
})
35-
}
36-
37-
stage.steps.forEach((step:G.Step)=>{
38-
if(progress.steps[step.id]){
39-
step.status='COMPLETE'
40-
}elseif(step.id===position.stepId){
41-
step.status='ACTIVE'
42-
}else{
43-
step.status='INCOMPLETE'
44-
}
45-
})
46-
stage.status=progress.stages[position.stageId] ?'COMPLETE' :'ACTIVE'
47-
48-
return<Stagestage={stage}onContinue={onContinue}onSave={onSave}/>
33+
type:'STAGE_NEXT',
34+
payload:{
35+
stageId:position.stageId,
36+
},
37+
})
38+
}
39+
40+
constonSave=():void=>{
41+
props.send({
42+
type:'TEST_RUN',
43+
payload:{
44+
stepId:position.stepId,
45+
},
46+
})
47+
}
48+
49+
stage.steps.forEach((step:G.Step)=>{
50+
if(progress.steps[step.id]){
51+
step.status='COMPLETE'
52+
}elseif(step.id===position.stepId){
53+
step.status='ACTIVE'
54+
}else{
55+
step.status='INCOMPLETE'
56+
}
57+
})
58+
stage.status=progress.stages[position.stageId] ?'COMPLETE' :'ACTIVE'
59+
60+
return<Stagestage={stage}onContinue={onContinue}onSave={onSave}/>
4961
}
5062

5163
exportdefaultStageSummaryPageContainer

‎web-app/src/containers/Tutorial/SummaryPage/index.tsx

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,21 @@ import Summary from './Summary'
77
importErrorViewfrom'../../../components/Error'
88

99
interfacePageProps{
10-
context:CR.MachineContext
11-
send(action:CR.Action):void
10+
context:CR.MachineContext
11+
send(action:CR.Action):void
1212
}
1313

1414
constSummaryPage=(props:PageProps)=>{
15-
const{ tutorial}=props.context
15+
const{ tutorial}=props.context
16+
17+
if(!tutorial){
18+
thrownewError('Tutorial not found in summary page')
19+
}
1620
const{ loading, error, data}=useQuery(queryTutorial,{
17-
fetchPolicy:'network-only',// for debugging purposes
21+
fetchPolicy:'network-only',// for debugging purposes
1822
variables:{
19-
tutorialId:tutorial.id,
20-
version:tutorial.version.version,
23+
tutorialId:tutorial.id,
24+
version:tutorial.version.version,
2125
},
2226
})
2327

@@ -29,14 +33,15 @@ const SummaryPage = (props: PageProps) => {
2933
return<ErrorViewerror={error}/>
3034
}
3135

32-
constonNext=()=>props.send({
33-
type:'LOAD_TUTORIAL',
34-
payload:{
35-
tutorial:data.tutorial,
36-
}
37-
})
36+
constonNext=()=>
37+
props.send({
38+
type:'LOAD_TUTORIAL',
39+
payload:{
40+
tutorial:data.tutorial,
41+
},
42+
})
3843

39-
const{ title, text}=data.tutorial
44+
const{ title, text}=data.tutorial
4045

4146
return<Summarytitle={title}text={text}onNext={onNext}/>
4247
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ class Channel {
4141
this.machineSend(action)
4242
console.log('test passed')
4343
return
44+
case'TEST_FAIL':
45+
this.machineSend(action)
46+
return
47+
case'ACTIONS_LOADED':
48+
console.log('ACTIONS_LOADED')
49+
return
4450
default:
4551
if(action.type){
4652
console.warn(`Unknown received action${action.type}`,action)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp