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

Setup#3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ShMcK merged 23 commits intomasterfromxstate
Jun 8, 2019
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
23 commits
Select commitHold shift + click to select a range
820097a
setup level/stage tree
ShMcKMay 27, 2019
32edbcf
setup xstate machine as core
ShMcKJun 2, 2019
4be011f
setup start w/ continue or new
ShMcKJun 2, 2019
6993147
add machine loadTutorial
ShMcKJun 2, 2019
04653e2
setup tutorial initialization
ShMcKJun 2, 2019
b51dd2f
refactor files
ShMcKJun 2, 2019
89045a3
refactor files
ShMcKJun 2, 2019
9bcf64c
refactor storage into editor
ShMcKJun 2, 2019
cc176e6
update deps
ShMcKJun 2, 2019
e88651e
setup xstate with interpreter
ShMcKJun 2, 2019
f8c527e
cleanup start
ShMcKJun 2, 2019
634a6d4
Merge pull request #2 from ShMcK/feature/treeview
Jun 2, 2019
9241fef
add createWebview logic
ShMcKJun 2, 2019
563874f
initialize webview
ShMcKJun 2, 2019
54e06de
setup web-app
ShMcKJun 4, 2019
81a1041
setup react liniting & tsconfig
ShMcKJun 4, 2019
aa1a8b8
refactor out path to build
ShMcKJun 4, 2019
69b7e81
working react in vscode
ShMcKJun 8, 2019
c4a05ca
cleanup inline script
ShMcKJun 8, 2019
826f2e7
update deps
ShMcKJun 8, 2019
97cf2a1
setup storybook & components
ShMcKJun 8, 2019
567c6a6
setup concurrent build script
ShMcKJun 8, 2019
01d2669
resolve alifd/next style issues
ShMcKJun 8, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
add machine loadTutorial
  • Loading branch information
@ShMcK
ShMcK committedJun 2, 2019
commit6993147a0c124a894979c835635f060ef17b1181
44 changes: 42 additions & 2 deletionssrc/state/actions/index.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
import { send } from "xstate";
import { assign, send } from 'xstate'
import * as CR from 'typings'
import * as storage from '../../services/storage'
import * as git from '../../services/git'

let initialTutorial: CR.Tutorial | undefined
let initialProgress: CR.Progress = {
levels: {},
stages: {},
steps: {},
complete: false,
}

export default {
start: async () => {
const [tutorial, progress, hasGit, hasGitRemote] = await Promise.all([
Expand All@@ -10,7 +19,38 @@ export default {
git.gitVersion(),
git.gitCheckRemoteExists(),
])
initialTutorial = tutorial
initialProgress = progress
const canContinue = !!(tutorial && progress && hasGit && hasGitRemote)
send(canContinue ? 'CONTINUE' : 'NEW')
}
},
loadTutorial: assign({
// load initial data, progress & position
data(): CR.TutorialData {
if (!initialTutorial) {
throw new Error('No Tutorial loaded')
}
return initialTutorial.data

},
progress(): CR.Progress { return initialProgress },
position() {
if (!initialTutorial) {
throw new Error('No Tutorial loaded')
}
const { data } = initialTutorial

const levelId = data.summary.levelList[0]
const stageId = data.levels[levelId].stageList[0]
const stepId = data.stages[stageId].stepList[0]

const position = {
levelId,
stageId,
stepId,
}

return position
}
}),
}
204 changes: 114 additions & 90 deletionssrc/state/machine.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,120 +15,144 @@ export const tutorialMachine = Machine<
{
id: 'tutorial',
context: initialContext,
initial: 'initial',
initial: 'Start',
states: {
initial: {
onEntry: 'start',
on: {
CONTINUE: 'continue',
NEW: 'new',
},
},
new: {
on: {
TUTORIAL_START: 'loading',
},
},
continue: {
on: {
TUTORIAL_START: 'loading',
},
},
loading: {
on: {
TUTORIAL_LOADED: [
{
target: 'summary',
cond: 'hasNoProgress',
},
{
target: 'level',
cond: 'hasNoLevelProgress',
},
{
target: 'stage',
},
],
},
},
summary: {
on: {
NEXT: 'level',
},
},
level: {
onEntry: ['loadLevel'],
on: {
NEXT: 'stage',
BACK: 'summary',
},
},
stage: {
onEntry: ['loadStage'],
initial: 'stageNormal',
Start: {
states: {
stageNormal: {
Initial: {
onEntry: 'start',
on: {
TEST_RUN: 'testRunning',
STEP_SOLUTION_LOAD: {
actions: ['callSolution'],
},
CONTINUE: 'ContinueTutorial',
NEW: 'NewTutorial',
},
},
testRunning: {
on: {
TEST_SUCCESS: [
{
target: 'complete',
cond: 'tasksComplete',
NewTutorial: {
initial: 'SelectTutorial',
states: {
SelectTutorial: {
on: {
TUTORIAL_START: 'InitializeTutorial',
},
{
target: 'testPass',
},
],
TEST_FAILURE: 'testFail',
},
},
InitializeTutorial: {
on: {
TUTORIAL_LOADED: 'Tutorial'
}
},
}

},
ContinueTutorial: {
onEntry: 'loadTutorial',
on: {
TUTORIAL_START: {
target: 'Tutorial',
}
}
},
testPass: {
onEntry: ['stepComplete'],
}
},
Tutorial: {
initial: 'Initialize',
states: {
Initialize: {
on: {
NEXT: [
TUTORIAL_LOADED: [
{
target: 'Summary',
cond: 'hasNoProgress',
},
{
target: 'stageNormal',
cond: 'hasNextStep',
target: 'Level',
cond: 'hasNoLevelProgress',
},
{
target: 'stageComplete',
target: 'Stage',
},
],
},
},
testFail: {

Summary: {
on: {
RETURN: 'stageNormal',
NEXT: 'Level',
},
},
stageComplete: {
Level: {
onEntry: ['loadLevel'],
on: {
NEXT: [
{
target: 'stage',
cond: 'hasNextStage',
NEXT: 'Stage',
BACK: 'Summary',
},
},
Stage: {
onEntry: ['loadStage'],
initial: 'StageNormal',
states: {
StageNormal: {
on: {
TEST_RUN: 'TestRunning',
STEP_SOLUTION_LOAD: {
actions: ['callSolution'],
},
},
{
target: 'level',
cond: 'hasNextLevel',
},
TestRunning: {
on: {
TEST_SUCCESS: [
{
target: 'StageComplete',
cond: 'tasksComplete',
},
{
target: 'TestPass',
},
],
TEST_FAILURE: 'TestFail',
},
{
target: 'complete',
},
TestPass: {
onEntry: ['stepComplete'],
on: {
NEXT: [
{
target: 'StageNormal',
cond: 'hasNextStep',
},
{
target: 'StageComplete',
},
],
},
],
},
TestFail: {
on: {
RETURN: 'StageNormal',
},
},
StageComplete: {
on: {
NEXT: [
{
target: 'Stage',
cond: 'hasNextStage',
},
{
target: 'Level',
cond: 'hasNextLevel',
},
{
target: 'EndTutorial',
},
],
},
},
},
},
},
},
complete: {},
},
EndTutorial: {},
}
}
}
},
{
actions,
Expand Down
39 changes: 26 additions & 13 deletionssrc/typings/index.d.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -129,21 +129,34 @@ export interface MachineEvent {

export interface MachineStateSchema {
states: {
initial: {}
new: {}
continue: {}
loading: {}
summary: {}
level: {}
stage: {
Start: {
states: {
stageNormal: {}
testRunning: {}
testPass: {}
testFail: {}
stageComplete: {}
Initial: {}
NewTutorial: {
states: {
SelectTutorial: {}
InitializeTutorial: {}
}
}
ContinueTutorial: {}
}
}
Tutorial: {
states: {
Initialize: {}
Summary: {}
Level: {}
Stage: {
states: {
StageNormal: {}
TestRunning: {}
TestPass: {}
TestFail: {}
StageComplete: {}
}
}
EndTutorial: {}
}
}
complete: {}
}
}

[8]ページ先頭

©2009-2025 Movatter.jp