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

Commit8b6499b

Browse files
committed
refactor tutorial paths
1 parentcb9f82e commit8b6499b

File tree

9 files changed

+47
-40
lines changed

9 files changed

+47
-40
lines changed

‎src/editor/commands/index.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import { setStorage } from '../storage'
44
importReactWebViewfrom'../ReactWebView'
55
import{isEmptyWorkspace}from'../workspace'
66
import*asCRfrom'typings'
7-
// TODO: replace with actual tutorial loading later
8-
importtutorialfrom'../../state/context/tutorials/basic'
97

108
constCOMMANDS={
119
START:'coderoad.start',
@@ -46,7 +44,7 @@ export const createCommands = ({ context, machine, storage, git, position }: Cre
4644
},
4745
// launch a new tutorial
4846
// NOTE: may be better to move into action as logic is primarily non-vscode
49-
[COMMANDS.TUTORIAL_LAUNCH]:async()=>{
47+
[COMMANDS.TUTORIAL_LAUNCH]:async(tutorial:CR.Tutorial)=>{
5048
console.log('launch tutorial')
5149

5250
awaitisEmptyWorkspace()

‎src/services/api/fetch.ts

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

‎src/services/api/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import*asCRfrom'typings'
22

33
// temporary tutorials
4-
importbasicTutorialfrom'../../state/context/tutorials/basic'
4+
importbasicTutorialfrom'tutorials/basic'
55

66
interfaceOptions{
77
resource:string

‎src/state/actions/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import{assign}from'xstate'
22
// NOTE: codesmell - importing machine
33
import{machine}from'../../extension'
4+
importapifrom'../../services/api'
45
import*asCRfrom'typings'
56
import*asvscodefrom'vscode'
67
import*asstoragefrom'../../services/storage'
@@ -37,8 +38,10 @@ export default {
3738

3839
machine.send(canContinue ?'CONTINUE' :'NEW')
3940
},
40-
tutorialLaunch(){
41-
vscode.commands.executeCommand('coderoad.tutorial_launch')
41+
asynctutorialLaunch(){
42+
// TODO: add selection of tutorial id
43+
consttutorial:CR.Tutorial=awaitapi({resource:'getTutorial',params:{id:'1'}})
44+
vscode.commands.executeCommand('coderoad.tutorial_launch',tutorial)
4245
},
4346
tutorialContinue:assign({
4447
// load initial data, progress & position

‎src/state/context/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
importbasicTutorialDatafrom'./tutorials/basic'
1+
importbasicTutorialDatafrom'tutorials/basic'
22
import*asCRfrom'typings'
33

44
consttutorialContext:CR.MachineContext={

‎tsconfig.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"dom"
99
],
1010
"sourceMap":true,
11-
"rootDir":"src",
11+
"rootDirs":["src","tutorials"],
1212
"baseUrl":"src",
1313
"strict":true,/* enable all strict type-checking options*/
1414
/* Additional Checks*/
@@ -23,6 +23,9 @@
2323
"emitDecoratorMetadata":true,
2424
"paths": {
2525
"typings": ["../typings/index.d.ts"],
26+
"tutorials/basic": [
27+
"../tutorials/basic.ts"
28+
]
2629
},
2730
},
2831
"exclude": [
File renamed without changes.

‎web-app/src/services/api/index.tsx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import*asCRfrom'typings'
2+
3+
// temporary tutorials
4+
importbasicTutorialfrom'tutorials/basic'
5+
6+
interfaceOptions{
7+
resource:string
8+
params?:any
9+
}
10+
11+
consttutorialsData:{[key:string]:CR.Tutorial}={
12+
tutorialId:basicTutorial,
13+
}
14+
15+
// TODO: replace with fetch resource
16+
exportdefaultasyncfunctionfetch(options:Options):Promise<any>{
17+
console.log('options',options)
18+
switch(options.resource){
19+
case'getTutorialsSummary':
20+
// list of ids with summaries
21+
letdata:{[id:string]:CR.TutorialSummary}={}
22+
for(consttutorialofObject.values(tutorialsData)){
23+
data[tutorial.id]=tutorial.data.summary
24+
}
25+
returndata
26+
case'getTutorial':
27+
// specific tutorial by id
28+
returntutorialsData[options.params.id]
29+
default:
30+
thrownewError('Resource not found')
31+
}
32+
}

‎web-app/tsconfig.paths.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
"typings": [
1010
"../../typings/index.d.ts"
1111
],
12+
"tutorials/basic": [
13+
"../../tutorials/basic.ts"
14+
]
1215
}
1316
},
1417
"exclude": [

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp