8000 refactor order of launches · benjaminthedev/coderoad-vscode@3261c33 · GitHub
[go: up one dir, main page]

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

Appearance settings

Commit 3261c33

Browse files
committed
refactor order of launches
1 parent d00a485 commit 3261c33

File tree

5 files changed

+93
-93
lines changed

5 files changed

+93
-93
lines changed

src/editor/ReactWebView.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,7 @@ class ReactWebView {
3434
this.onReceive = onReceive
3535
}
3636

37-
public async createOrShow(extensionPath: string, column: number = vscode.ViewColumn.One): Promise<void> {
38-
const hasActiveEditor = vscode.window.activeTextEditor
39-
40-
if (!hasActiveEditor) {
41-
throw new Error('Should have an open file on launch')
42-
}
43-
37+
public async createOrShow(column: number = vscode.ViewColumn.One): Promise<void> {
4438
// If we already have a panel, show it.
4539
// Otherwise, create a new panel.
4640
if (ReactWebView.currentPanel && ReactWebView.currentPanel.panel) {

src/editor/commands/index.ts

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
1-
import * as vscode from 'vscode'
2-
import start from './start'
3-
import ReactPanel from '../views/createWebview'
1+
// import * as vscode from 'vscode'
2+
// import start from './start'
3+
// // import ReactPanel from '../views/createWebview'
44

5-
import runTest from './runTest'
6-
// import loadSolution from './loadSolution'
7-
// import quit from './quit'
5+
// import runTest from './runTest'
6+
// // import loadSolution from './loadSolution'
7+
// // import quit from './quit'
88

9-
const COMMANDS = {
10-
// TUTORIAL_SETUP: 'coderoad.tutorial_setup',
11-
START: 'coderoad.start',
12-
OPEN_WEBVIEW: 'coderoad.open_webview',
13-
RUN_TEST: 'coderoad.test_run',
14-
// LOAD_SOLUTION: 'coderoad.solution_load',
15-
// QUIT: 'coderoad.quit',
16-
}
9+
// const COMMANDS = {
10+
// // TUTORIAL_SETUP: 'coderoad.tutorial_setup',
11+
// START: 'coderoad.start',
12+
// OPEN_WEBVIEW: 'coderoad.open_webview',
13+
// RUN_TEST: 'coderoad.test_run',
14+
// // LOAD_SOLUTION: 'coderoad.solution_load',
15+
// // QUIT: 'coderoad.quit',
16+
// }
1717

1818

19-
export default (context: vscode.ExtensionContext): void => {
20-
const commands = {
21-
[COMMANDS.START]: () => {
22-
start(context)
23-
},
24-
[COMMANDS.OPEN_WEBVIEW]: () => {
25-
ReactPanel.createOrShow(context.extensionPath);
26-
},
27-
[COMMANDS.RUN_TEST]: () => {
28-
runTest()
29-
},
30-
// [COMMANDS.LOAD_SOLUTION]: loadSolution,
31-
// [COMMANDS.QUIT]: () => quit(context.subscriptions),
32-
}
19+
// export default (context: vscode.ExtensionContext): void => {
20+
// const commands = {
21+
// [COMMANDS.START]: () => {
22+
// start(context)
23+
// },
24+
// [COMMANDS.OPEN_WEBVIEW]: () => {
25+
// // ReactPanel.createOrShow(context.extensionPath);
26+
// },
27+
// [COMMANDS.RUN_TEST]: () => {
28+
// runTest()
29+
// },
30+
// // [COMMANDS.LOAD_SOLUTION]: loadSolution,
31+
// // [COMMANDS.QUIT]: () => quit(context.subscriptions),
32+
// }
3333

34-
for (const cmd in commands) {
35-
const command: vscode.Disposable = vscode.commands.registerCommand(cmd, commands[cmd])
36-
context.subscriptions.push(command)
37-
}
38-
}
34+
// for (const cmd in commands) {
35+
// const command: vscode.Disposable = vscode.commands.registerCommand(cmd, commands[cmd])
36+
// context.subscriptions.push(command)
37+
// }
38+
// }

src/editor/commands/start.ts

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,45 @@
1-
import * as vscode from 'vscode'
2-
import { setWorkspaceRoot } from '../../services/node'
3-
import { setStorage } from '../../editor/storage'
4-
import { activate as activateMachine, default as machine } from '../../state'
5-
import * as storage from '../../services/storage'
6-
import * as git from '../../services/git'
7-
import * as CR from 'typings'
1+
// import * as vscode from 'vscode'
2+
// import { setWorkspaceRoot } from '../../services/node'
3+
// import { setStorage } from '../../editor/storage'
4+
// import { activate as activateMachine, default as machine } from '../../state'
5+
// import * as storage from '../../services/storage'
6+
// import * as git from '../../services/git'
7+
// import * as CR from 'typings'
88

9-
let initialTutorial: CR.Tutorial | undefined
10-
let initialProgress: CR.Progress = {
11-
levels: {},
12-
stages: {},
13-
steps: {},
14-
complete: false,
15-
}
9+
// let initialTutorial: CR.Tutorial | undefined
10+
// let initialProgress: CR.Progress = {
11+
// levels: {},
12+
// stages: {},
13+
// steps: {},
14+
// complete: false,
15+
// }
1616

17-
export default async function start(context: vscode.ExtensionContext): Promise<void> {
18-
console.log('TUTORIAL_START')
17+
// export default async function start(context: vscode.ExtensionContext): Promise<void> {
18+
// console.log('TUTORIAL_START')
1919

20-
// setup connection to workspace
21-
// await setWorkspaceRoot()
22-
// set workspace context path
23-
// await setStorage(context.workspaceState)
20+
// // setup connection to workspace
21+
// // await setWorkspaceRoot()
22+
// // set workspace context path
23+
// // await setStorage(context.workspaceState)
2424

25-
// initialize state machine
26-
activateMachine()
25+
// // initialize state machine
26+
// activateMachine()
2727

28-
console.log('ACTION: start')
28+
// console.log('ACTION: start')
2929

30-
// verify that the user has a tutorial & progress
31-
// verify git is setup with a coderoad remote
32-
const [tutorial, progress, hasGit, hasGitRemote] = await Promise.all([
33-
storage.getTutorial(),
34-
storage.getProgress(),
35-
git.gitVersion(),
36-
git.gitCheckRemoteExists(),
37-
])
38-
initialTutorial = tutorial
39-
initialProgress = progress
40-
const canContinue = !!(tutorial && progress && hasGit && hasGitRemote)
41-
console.log('canContinue', canContinue)
42-
// if a tutorial exists, "CONTINUE"
43-
// otherwise start from "NEW"
44-
machine.send(canContinue ? 'CONTINUE' : 'NEW')
45-
}
30+
// // verify that the user has a tutorial & progress
31+
// // verify git is setup with a coderoad remote
32+
// const [tutorial, progress, hasGit, hasGitRemote] = await Promise.all([
33+
// storage.getTutorial(),
34+
// storage.getProgress(),
35+
// git.gitVersion(),
36+
// git.gitCheckRemoteExists(),
37+
// ])
38+
// initialTutorial = tutorial
39+
// initialProgress = progress
40+
// const canContinue = !!(tutorial && progress && hasGit && hasGitRemote)
41+
// console.log('canContinue', canContinue)
42+
// // if a tutorial exists, "CONTINUE"
43+
// // otherwise start from "NEW"
44+
// machine.send(canContinue ? 'CONTINUE' : 'NEW')
45+
// }

src/editor/index.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Editor {
2121
this.machine = machine
2222
}
2323

24-
private commandStart() {
24+
private commandStart = (): void => {
2525
// set workspace root
2626
const { rootPath } = vscode.workspace
2727
if (!rootPath) {
@@ -33,26 +33,32 @@ class Editor {
3333
setStorage(this.context.workspaceState)
3434

3535
// activate machine
36-
this.machine.activate()
3736
this.webview = new ReactWebView(this.context.extensionPath, this.machine.onReceive)
37+
this.machine.activate()
38+
39+
console.log('command start webview')
40+
console.log(this.webview)
3841
}
3942

40-
private activateCommands() {
41-
const { COMMANDS } = this
43+
private activateCommands = (): void => {
44+
console.log('this.COMMANDS', this.COMMANDS)
4245
const commands = {
43-
[COMMANDS.START]: () => {
46+
[this.COMMANDS.START]: () => {
47+
console.log('start')
4448
this.commandStart()
4549
},
46-
[COMMANDS.OPEN_WEBVIEW]: () => {
47-
this.webview.createOrShow(this.context.extensionPath);
50+
[this.COMMANDS.OPEN_WEBVIEW]: () => {
51+
console.log('open webview')
52+
console.log(this.webview)
53+
this.webview.createOrShow();
4854
},
4955
}
5056
for (const cmd in commands) {
5157
const command: vscode.Disposable = vscode.commands.registerCommand(cmd, commands[cmd])
5258
this.context.subscriptions.push(command)
5359
}
5460
}
55-
public activate(context: vscode.ExtensionContext): void {
61+
public activate = (context: vscode.ExtensionContext): void => {
5662
console.log('ACTIVATE!')
5763
this.context = context
5864
// commands
@@ -61,7 +67,7 @@ class Editor {
6167
// setup tasks or views here
6268

6369
}
64-
public deactivate(): void {
70+
public deactivate = (): void => {
6571
console.log('DEACTIVATE!')
6672
// cleanup subscriptions/tasks
6773
for (const disposable of this.context.subscriptions) {

src/state/message.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import panel from '../views/Panel'
1+
// import panel from '../views/Panel'
22
import * as CR from '../typings'
33

44
export const onSend = (action: CR.Action) => {
5-
if (!panel || !panel.currentPanel) {
6-
throw new Error('No valid panel available')
7-
}
8-
panel.currentPanel.postMessage(action)
5+
// if (!panel || !panel.currentPanel) {
6+
// throw new Error('No valid panel available')
7+
// }
8+
// panel.currentPanel.postMessage(action)
99
}
1010

1111
export const onReceive = (action: CR.Action) => {

0 commit comments

Comments
 (0)
0