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
setup xstate with interpreter
  • Loading branch information
@ShMcK
ShMcK committedJun 2, 2019
commite88651e2f5ae5cd742dd05e7f84d8a632da8abf6
1 change: 0 additions & 1 deletion.vscode/settings.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,7 +16,6 @@
"source.fixAll": true,
},
"tslint.enable": true,
"tslint.jsEnable": true,
"[javascript]": {
"editor.formatOnSave": true
},
Expand Down
7 changes: 4 additions & 3 deletionspackage.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,20 +11,21 @@
],
"publisher": "Shawn McKay <shawn.j.mckay@gmail.com>",
"activationEvents": [
"onCommand:coderoad.tutorial_load"
"onCommand:coderoad.start"
],
"main": "./out/extension.js",
"contributes": {
"commands": [
{
"command": "coderoad.tutorial_load",
"title": "Load Tutorial",
"command": "coderoad.start",
"title": "Start",
"category": "CodeRoad"
}
]
},
"scripts": {
"vscode:prepublish": "npm run compile",
"machine": "node ./out/state/index.js",
"compile": "tsc -p ./",
"watch": "tsc -watch -p ./",
"postinstall": "node ./node_modules/vscode/bin/install",
Expand Down
9 changes: 5 additions & 4 deletionssrc/editor/commands/index.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
import * as vscode from 'vscode'

// import runTest from './runTest'
importtutorialLoad from './tutorialLoad'
importstart from './start'
// import loadSolution from './loadSolution'
// import quit from './quit'

const COMMANDS = {
// TUTORIAL_SETUP: 'coderoad.tutorial_setup',
TUTORIAL_LOAD: 'coderoad.tutorial_load',
START: 'coderoad.start',
// RUN_TEST: 'coderoad.test_run',
// LOAD_SOLUTION: 'coderoad.solution_load',
// QUIT: 'coderoad.quit',
}

export default (context: vscode.ExtensionContext): void => {
const commands = {
[COMMANDS.TUTORIAL_LOAD](): void {
tutorialLoad(context)
[COMMANDS.START](): void {
console.log('TUTORIAL_START')
start(context)
},
// [COMMANDS.RUN_TEST]: runTest,
// [COMMANDS.LOAD_SOLUTION]: loadSolution,
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
import * as vscode from 'vscode'
import * as CR from 'typings'

import api from '../../services/api'
import tutorialSetup from '../../services/tutorialSetup'
import { loadProgressPosition } from '../../services/position'
import * as storage from '../../services/storage'
import rootSetup from '../../services/rootSetup'
import { isEmptyWorkspace, openReadme } from '../workspace'
import * as git from '../../services/git'
import { setWorkspaceRoot } from '../../services/node'
import { setStorage } from '../../editor/storage'
import createStateMachine from '../../state'

/*
new
if current workspace is empty, use it
if not, open a new folder then start
*/

async function continueTutorial() {
// TODO: verify that tutorial is loaded in workspace
// TODO: verify progress
// TODO: verify setup
await loadProgressPosition()
await openReadme()
}
//async function continueTutorial() {
// // TODO: verify that tutorial is loaded in workspace
// // TODO: verify progress
// // TODO: verify setup
// await loadProgressPosition()
// await openReadme()
//}

async function newTutorial(tutorial: CR.Tutorial) {
// if workspace isn't empty, clear it out if given permission
Expand All@@ -40,23 +38,15 @@ async function newTutorial(tutorial: CR.Tutorial) {
}


async function validateCanContinue(): Promise<boolean> {
// validate tutorial & progress found in local storage
// validate git is setup with a remote
const [tutorial, progress, hasGit, hasGitRemote] = await Promise.all([
storage.getTutorial(),
storage.getProgress(),
git.gitVersion(),
git.gitCheckRemoteExists(),
])
return !!(tutorial && progress && hasGit && hasGitRemote)
}

export default async function tutorialLoad(context: vscode.ExtensionContext): Promise<void> {
console.log(`tutorialLoad ${JSON.stringify(context)}`)
export default async function start(context: vscode.ExtensionContext): Promise<void> {
console.log('start', context)

// setup connection to workspace
await rootSetup(context)
await setWorkspaceRoot()
// set workspace context path
await setStorage(context.workspaceState)
// initiate the state machine
createStateMachine()
return;

// const modes = ['New']
Expand Down
10 changes: 0 additions & 10 deletionssrc/editor/index.ts
View file
Open in desktop

This file was deleted.

33 changes: 33 additions & 0 deletionssrc/editor/init.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
// The module 'vscode' contains the VS Code extensibility API
// Import the module and reference it with the alias vscode in your code below
import * as vscode from 'vscode'

import createCommands from './commands'
import createViews from './views'
import createStateMachine from '../state'

// this method is called when your extension is activated
// your extension is activated the very first time the command is executed
export function activate(context: vscode.ExtensionContext) {
console.log('ACTIVATE!')

// commands
createCommands(context)

// tasks
// add tasks here

// views
createViews(context)


}

// this method is called when your extension is deactivated
export function deactivate(context: vscode.ExtensionContext): void {
// cleanup subscriptions/tasks
console.log('deactivate context', context)
for (const disposable of context.subscriptions) {
disposable.dispose()
}
}
File renamed without changes.
File renamed without changes.
30 changes: 1 addition & 29 deletionssrc/extension.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,2 @@
// The module 'vscode' contains the VS Code extensibility API
// Import the module and reference it with the alias vscode in your code below
import * as vscode from 'vscode'
export { activate, deactivate } from './editor/init'

import createCommands from './editor/commands'
import createViews from './views'

// this method is called when your extension is activated
// your extension is activated the very first time the command is executed
export function activate(context: vscode.ExtensionContext) {
console.log('ACTIVATE!')

// commands
createCommands(context)

// tasks
// add tasks here

// views
createViews(context)
}

// this method is called when your extension is deactivated
export function deactivate(context: vscode.ExtensionContext): void {
// cleanup subscriptions/tasks
console.log('deactivate context', context)
for (const disposable of context.subscriptions) {
disposable.dispose()
}
}
8 changes: 0 additions & 8 deletionssrc/services/rootSetup.ts
View file
Open in desktop

This file was deleted.

4 changes: 4 additions & 0 deletionssrc/state/actions/index.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,6 +13,7 @@ let initialProgress: CR.Progress = {

export default {
start: async () => {
console.log('ACTION: start')
// verify that the user has a tutorial & progress
// verify git is setup with a coderoad remote
const [tutorial, progress, hasGit, hasGitRemote] = await Promise.all([
Expand All@@ -31,16 +32,19 @@ export default {
tutorialLoad: assign({
// load initial data, progress & position
data(): CR.TutorialData {
console.log('ACTION: tutorialLoad.data')
if (!initialTutorial) {
throw new Error('No Tutorial loaded')
}
return initialTutorial.data

},
progress(): CR.Progress {
console.log('ACTION: tutorialLoad.progress')
return initialProgress
},
position() {
console.log('ACTION: tutorialLoad.position')
if (!initialTutorial) {
throw new Error('No Tutorial loaded')
}
Expand Down
1 change: 1 addition & 0 deletionssrc/state/guards/index.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,6 +3,7 @@ import * as CR from 'typings'
export default {
// skip to the stage if the level has already been started
hasNoNextLevelProgress: (context: CR.MachineContext): boolean => {
console.log('GUARD: hasNoNextLevelProgress')
return false
},
}
28 changes: 28 additions & 0 deletionssrc/state/index.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
import { interpret } from 'xstate'
import machine from './machine'


const createStateMachine = () => {
const machineOptions = {
logger: console.log,
devTools: true,
deferEvents: true,
execute: true
}
// machine interpreter
// https://xstate.js.org/docs/guides/interpretation.html
const service = interpret(machine, machineOptions)
// logging
.onTransition(state => {
console.log('state', state)
if (state.changed) {
console.log('transition')
console.log(state.value)
}
})
// initialize
service.start()
return service
}

export default createStateMachine
7 changes: 4 additions & 3 deletionssrc/state/machine.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,9 +5,7 @@ import actions from './actions'
import guards from './guards'
import initialContext from './context'

// TODO: replace with API

export const tutorialMachine = Machine<
export const machine = Machine<
CR.MachineContext,
CR.MachineStateSchema,
CR.MachineEvent
Expand All@@ -18,6 +16,7 @@ export const tutorialMachine = Machine<
initial: 'Start',
states: {
Start: {
initial: 'Initial',
states: {
Initial: {
onEntry: 'start',
Expand DownExpand Up@@ -157,3 +156,5 @@ export const tutorialMachine = Machine<
activities: {},
},
)

export default machine

[8]ページ先頭

©2009-2025 Movatter.jp