forked from cerebral/overmind
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextension.ts
More file actions
72 lines (62 loc) · 1.9 KB
/
Copy pathextension.ts
File metadata and controls
72 lines (62 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import * as vscode from 'vscode'
import { DevtoolsPanel } from './DevtoolsPanel'
import * as path from 'path'
import { log } from './utils/Logger'
class TempStorage {
private storage: any = {}
public get(key: string): Promise<any> {
return new Promise((resolve, reject) => {
resolve(this.storage[key] || undefined)
})
}
public set(key: string, value: any) {
return new Promise((resolve, reject) => {
this.storage[key] = value
resolve()
})
}
public clear() {
return new Promise((resolve, reject) => {
this.storage = {}
resolve()
})
}
}
const storage = new TempStorage()
const DevtoolBackend = require('overmind-devtools-client/DevtoolBackend')
DevtoolBackend.create({
port: 3031,
onRelaunch() {
console.log('relaunch')
},
storage,
})
// 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) {
context.subscriptions.push(
vscode.commands.registerCommand('overmind-devtools.start', () => {
const onDiskPath = vscode.Uri.file(
path.join(context.extensionPath, 'devtoolsDist', 'bundle.js')
)
const scriptFile = onDiskPath.with({ scheme: 'vscode-resource' })
DevtoolsPanel.scriptFile = scriptFile
DevtoolsPanel.createOrShow(context.extensionPath) // refactor to keep local reference to panel
})
)
// TODO: what does this do?
if (vscode.window.registerWebviewPanelSerializer) {
vscode.window.registerWebviewPanelSerializer(DevtoolsPanel.viewType, {
async deserializeWebviewPanel(
webViewPanel: vscode.WebviewPanel,
state: any
) {
DevtoolsPanel.revive(webViewPanel, context.extensionPath)
},
})
}
}
// this method is called when your extension is deactivated
export function deactivate() {
log('Extension deactivated')
}