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

Commit4d2cfd6

Browse files
committed
update typings for node processes
1 parent06f1285 commit4d2cfd6

File tree

11 files changed

+129
-55
lines changed

11 files changed

+129
-55
lines changed

‎src/actions/setupActions.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import*asTfrom'typings'
2+
import*asTTfrom'typings/tutorial'
23
import*asvscodefrom'vscode'
34
import*asgitfrom'../services/git'
45
importloadWatchersfrom'./utils/loadWatchers'
@@ -8,7 +9,7 @@ import onError from '../services/sentry/onError'
89

910
constsetupActions=async(
1011
workspaceRoot:vscode.WorkspaceFolder,
11-
actions:T.StepActions,
12+
actions:TT.StepActions,
1213
send:(action:T.Action)=>void,// send messages to client
1314
):Promise<void>=>{
1415
const{ commands, commits, files, watchers}=actions

‎src/actions/solutionActions.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import*asTfrom'typings'
2+
import*asTTfrom'typings/tutorial'
23
import*asvscodefrom'vscode'
34
import*asgitfrom'../services/git'
45
importsetupActionsfrom'./setupActions'
56
importonErrorfrom'../services/sentry/onError'
67

78
constsolutionActions=async(
89
workspaceRoot:vscode.WorkspaceFolder,
9-
stepActions:T.StepActions,
10+
stepActions:TT.StepActions,
1011
send:(action:T.Action)=>void,
1112
):Promise<void>=>{
1213
awaitgit.clear()

‎src/actions/tutorialConfig.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import*asTfrom'typings'
2-
import*asGfrom'typings/graphql'
2+
import*asTTfrom'typings/tutorial'
33
import*asvscodefrom'vscode'
44
import{COMMANDS}from'../editor/commands'
5-
importlanguageMapfrom'../editor/languageMap'
65
import*asgitfrom'../services/git'
76
importonErrorfrom'../services/sentry/onError'
87

98
interfaceTutorialConfigParams{
10-
config:T.TutorialConfig
9+
config:TT.TutorialConfig
1110
alreadyConfigured?:boolean
1211
onComplete?():void
1312
}

‎src/channel/context.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import*asCRfrom'typings'
2-
import*asGfrom'typings/graphql'
2+
import*asTTfrom'typings/tutorial'
33
import*asvscodefrom'vscode'
44
importPositionfrom'./state/Position'
55
importProgressfrom'./state/Progress'
@@ -17,7 +17,7 @@ class Context {
1717
}
1818
publicsetTutorial=async(
1919
workspaceState:vscode.Memento,
20-
tutorial:G.Tutorial,
20+
tutorial:TT.Tutorial,
2121
):Promise<{progress:CR.Progress;position:CR.Position}>=>{
2222
this.tutorial.set(tutorial)
2323
constprogress:CR.Progress=awaitthis.progress.setTutorial(workspaceState,tutorial)

‎src/channel/index.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import*asTfrom'typings'
2-
import*asGfrom'typings/graphql'
2+
import*asTTfrom'typings/tutorial'
33
import*asvscodefrom'vscode'
44
importsaveCommitfrom'../actions/saveCommit'
55
importsetupActionsfrom'../actions/setupActions'
@@ -54,10 +54,10 @@ class Channel implements Channel {
5454
return
5555
// continue from tutorial from local storage
5656
case'EDITOR_TUTORIAL_LOAD':
57-
consttutorial:G.Tutorial|null=this.context.tutorial.get()
57+
consttutorial:TT.Tutorial|null=this.context.tutorial.get()
5858

5959
// new tutorial
60-
if(!tutorial||!tutorial.id||!tutorial.version){
60+
if(!tutorial||!tutorial.id){
6161
this.send({type:'START_NEW_TUTORIAL'})
6262
return
6363
}
@@ -81,23 +81,23 @@ class Channel implements Channel {
8181
return
8282
// configure test runner, language, git
8383
case'EDITOR_TUTORIAL_CONFIG':
84-
consttutorialData:G.Tutorial=action.payload.tutorial
84+
consttutorialData:TT.Tutorial=action.payload.tutorial
8585
// setup tutorial config (save watcher, test runner, etc)
8686
this.context.setTutorial(this.workspaceState,tutorialData)
8787

88-
constdata:G.TutorialData=tutorialData.version.data
88+
constdata:TT.TutorialData=tutorialData.data
8989

9090
awaittutorialConfig({config:data.config},onError)
9191

9292
// report back to the webview that setup is complete
9393
this.send({type:'TUTORIAL_CONFIGURED'})
9494
return
9595
case'EDITOR_TUTORIAL_CONTINUE_CONFIG':
96-
consttutorialContinue:G.Tutorial|null=this.context.tutorial.get()
96+
consttutorialContinue:TT.Tutorial|null=this.context.tutorial.get()
9797
if(!tutorialContinue){
9898
thrownewError('Invalid tutorial to continue')
9999
}
100-
constcontinueConfig:T.TutorialConfig=tutorialContinue.version.data.config
100+
constcontinueConfig:TT.TutorialConfig=tutorialContinue.data.config
101101
awaittutorialConfig(
102102
{
103103
config:continueConfig,
@@ -148,7 +148,7 @@ class Channel implements Channel {
148148
thrownewError('Error with current tutorial')
149149
}
150150
// update local storage stepProgress
151-
constprogress=this.context.progress.setStepComplete(tutorial.version.data,action.payload.stepId)
151+
constprogress=this.context.progress.setStepComplete(tutorial.data,action.payload.stepId)
152152
this.context.position.setPositionFromProgress(tutorial,progress)
153153
saveCommit()
154154
}

‎src/channel/state/Position.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import*asCRfrom'typings'
2-
import*asGfrom'typings/graphql'
2+
import*asTTfrom'typings/tutorial'
33

44
constdefaultValue:CR.Position={
55
levelId:'',
@@ -22,34 +22,34 @@ class Position {
2222
this.value=defaultValue
2323
}
2424
// calculate the current position based on the saved progress
25-
publicsetPositionFromProgress=(tutorial:G.Tutorial,progress:CR.Progress):CR.Position=>{
25+
publicsetPositionFromProgress=(tutorial:TT.Tutorial,progress:CR.Progress):CR.Position=>{
2626
// tutorial already completed
2727
// TODO handle start again?
2828
if(progress.complete){
2929
returnthis.value
3030
}
3131

32-
if(!tutorial||!tutorial.version||!tutorial.version.data||!tutorial.version.data.levels){
32+
if(!tutorial||!tutorial.data||!tutorial.data.levels){
3333
thrownewError('Error setting position from progress')
3434
}
3535

3636
// get level
37-
const{ levels}=tutorial.version.data
38-
constlastLevelIndex:number|undefined=levels.findIndex((l:G.Level)=>!progress.levels[l.id])
37+
const{ levels}=tutorial.data
38+
constlastLevelIndex:number|undefined=levels.findIndex((l:TT.Level)=>!progress.levels[l.id])
3939
if(lastLevelIndex>=levels.length){
4040
thrownewError('Error setting progress level')
4141
}
4242

4343
// get step
44-
constcurrentLevel:G.Level=levels[lastLevelIndex]
44+
constcurrentLevel:TT.Level=levels[lastLevelIndex]
4545
letcurrentStepId:string|null
4646
if(!currentLevel.steps.length){
4747
// no steps available for level
4848
currentStepId=null
4949
}else{
5050
// find current step id
5151
const{ steps}=currentLevel
52-
constlastStepIndex:number|undefined=steps.findIndex((s:G.Step)=>!progress.steps[s.id])
52+
constlastStepIndex:number|undefined=steps.findIndex((s:TT.Step)=>!progress.steps[s.id])
5353
if(lastStepIndex>=steps.length){
5454
thrownewError('Error setting progress step')
5555
}

‎src/channel/state/Progress.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import*asCRfrom'typings'
2-
import*asGfrom'typings/graphql'
2+
import*asTTfrom'typings/tutorial'
33
import*asvscodefrom'vscode'
44
importStoragefrom'../../services/storage'
55

@@ -39,7 +39,7 @@ class Progress {
3939
publicreset=()=>{
4040
this.set(defaultValue)
4141
}
42-
publicsetStepComplete=(tutorialData:G.TutorialData,stepId:string):CR.Progress=>{
42+
publicsetStepComplete=(tutorialData:TT.TutorialData,stepId:string):CR.Progress=>{
4343
constnext=this.value
4444
// mark step complete
4545
next.steps[stepId]=true

‎src/channel/state/Tutorial.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
import*asGfrom'typings/graphql'
1+
import*asTTfrom'typings/tutorial'
22
import*asvscodefrom'vscode'
33
importStoragefrom'../../services/storage'
44

55
// Tutorial
66
classTutorial{
7-
privatestorage:Storage<G.Tutorial|null>
8-
privatevalue:G.Tutorial|null=null
7+
privatestorage:Storage<TT.Tutorial|null>
8+
privatevalue:TT.Tutorial|null=null
99
constructor(workspaceState:vscode.Memento){
10-
this.storage=newStorage<G.Tutorial|null>({
10+
this.storage=newStorage<TT.Tutorial|null>({
1111
key:'coderoad:currentTutorial',
1212
storage:workspaceState,
1313
defaultValue:null,
1414
})
1515
// set value from storage
16-
this.storage.get().then((value:G.Tutorial|null)=>{
16+
this.storage.get().then((value:TT.Tutorial|null)=>{
1717
this.value=value
1818
})
1919
}
2020
publicget=()=>{
2121
returnthis.value
2222
}
23-
publicset=(value:G.Tutorial|null)=>{
23+
publicset=(value:TT.Tutorial|null)=>{
2424
this.value=value
2525
this.storage.set(value)
2626
}

‎src/editor/commands.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import*asTfrom'typings'
1+
import*asTTfrom'typings/tutorial'
22
import*asvscodefrom'vscode'
33
importcreateTestRunner,{Payload}from'../services/testRunner'
44
importcreateWebViewfrom'../webview'
@@ -49,7 +49,7 @@ export const createCommands = ({ extensionPath, workspaceState, workspaceRoot }:
4949
// setup 1x1 horizontal layout
5050
webview.createOrShow()
5151
},
52-
[COMMANDS.CONFIG_TEST_RUNNER]:(config:T.TutorialTestRunner)=>{
52+
[COMMANDS.CONFIG_TEST_RUNNER]:(config:TT.TutorialTestRunner)=>{
5353
testRunner=createTestRunner(config,{
5454
onSuccess:(payload:Payload)=>{
5555
// send test pass message back to client

‎src/editor/languageMap.ts

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
import{storiesOf}from'@storybook/react'
2+
import{action}from'@storybook/addon-actions'
3+
importReactfrom'react'
4+
import{css,jsx}from'@emotion/core'
5+
importSelectWorkspacefrom'../src/containers/Check/SelectWorkspace'
6+
importSideBarDecoratorfrom'./utils/SideBarDecorator'
7+
import{Form,Input,Select}from'@alifd/next'
8+
9+
constFormItem=Form.Item
10+
constOption=Select.Option
11+
12+
conststyles={
13+
container:{
14+
display:'flex'as'flex',
15+
flexDirection:'column'as'column',
16+
},
17+
}
18+
19+
constuseFetch=(url:string,options?:object)=>{
20+
const[data,setData]=React.useState(null)
21+
const[error,setError]=React.useState(null)
22+
const[loading,setLoading]=React.useState(true)
23+
React.useEffect(()=>{
24+
constfetchData=async()=>{
25+
try{
26+
constres=awaitfetch(url,options)
27+
setLoading(false)
28+
constjson=awaitres.json()
29+
setData(json)
30+
}catch(error){
31+
setError(error)
32+
}
33+
}
34+
fetchData()
35+
},[url])
36+
return{ data, error, loading}
37+
}
38+
39+
constGitHubFetch=({ url})=>{
40+
if(!url){
41+
returnnull
42+
}
43+
const{ data, error, loading}=useFetch(url)
44+
if(loading){
45+
return<div>Loading...</div>
46+
}
47+
if(error){
48+
return<div>{JSON.stringify(error)}</div>
49+
}
50+
return<div>{JSON.stringify(data)}</div>
51+
}
52+
53+
consttutorials=[
54+
{
55+
id:'1',
56+
title:'Basic Node & Express',
57+
configUrl:'https://raw.githubusercontent.com/coderoad/fcc-basic-node-and-express/master/coderoad-config.json',
58+
},
59+
{
60+
id:'2',
61+
title:'Learn NPM',
62+
configUrl:'https://raw.githubusercontent.com/coderoad/fcc-learn-npm/master/coderoad-config.json',
63+
},
64+
]
65+
66+
constSelectTutorial=()=>{
67+
const[url,setUrl]=React.useState(null)
68+
consthandleUrlChange=(value)=>{
69+
setUrl(value)
70+
}
71+
return(
72+
<div>
73+
<Formstyle={{maxWidth:'500px'}}>
74+
<FormItemlabel="Select Tutorial:">
75+
<SelectonChange={handleUrlChange}style={{width:'100%'}}>
76+
{tutorials.map((tutorial)=>(
77+
<Optionkey={tutorial.id}value={tutorial.configUrl}>
78+
{tutorial.title}
79+
</Option>
80+
))}
81+
</Select>
82+
</FormItem>
83+
</Form>
84+
<GitHubFetchurl={url}/>
85+
</div>
86+
)
87+
}
88+
89+
storiesOf('GitHub Fetch',module)
90+
.addDecorator(SideBarDecorator)
91+
.add('Request',()=>{
92+
return<GitHubFetchurl={tutorials[0].configUrl}/>
93+
})
94+
.add('Select Tutorial',()=>{
95+
return<SelectTutorial/>
96+
})

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp