|
1 | 1 | import * as vscode from 'vscode' |
2 | 2 | import { DevtoolsPanel } from './DevtoolsPanel' |
3 | 3 | import * as path from 'path' |
4 | | - |
5 | 4 | import { log } from './utils/Logger' |
6 | 5 |
|
7 | | -class TempStorage { |
8 | | - private storage: any = {} |
9 | | - public get(key: string): Promise<any> { |
10 | | - return new Promise((resolve, reject) => { |
11 | | - resolve(this.storage[key] || undefined) |
12 | | - }) |
13 | | - } |
| 6 | +// this method is called when your extension is activated |
| 7 | +// your extension is activated the very first time the command is executed |
| 8 | +export function activate(context: vscode.ExtensionContext) { |
| 9 | + const storage = { |
| 10 | + get(key:string){ |
| 11 | + return new Promise((resolve) => { |
| 12 | + resolve(context.workspaceState.get(key)) |
| 13 | + }) |
| 14 | + }, |
14 | 15 |
|
15 | | - public set(key: string, value: any) { |
16 | | - return new Promise((resolve, reject) => { |
17 | | - this.storage[key] = value |
18 | | - resolve() |
19 | | - }) |
20 | | - } |
| 16 | + set (key:string, value: any) |
| 17 | + { |
| 18 | + return new Promise((resolve) => { |
| 19 | + context.workspaceState.update(key, value) |
| 20 | + resolve() |
| 21 | + }) |
| 22 | + }, |
21 | 23 |
|
22 | | - public clear() { |
23 | | - return new Promise((resolve, reject) => { |
24 | | - this.storage = {} |
25 | | - resolve() |
26 | | - }) |
| 24 | + clear() |
| 25 | + { |
| 26 | + return new Promise((resolve) => { |
| 27 | + resolve() |
| 28 | + }) |
| 29 | + } |
27 | 30 | } |
28 | | -} |
29 | 31 |
|
30 | | -const storage = new TempStorage() |
| 32 | + const DevtoolBackend = require('overmind-devtools-client/DevtoolBackend') |
| 33 | + DevtoolBackend.create({ |
| 34 | + port: 3031, |
| 35 | + onRelaunch() { |
| 36 | + console.log('relaunch') |
| 37 | + }, |
| 38 | + storage, |
| 39 | + }) |
31 | 40 |
|
32 | | -const DevtoolBackend = require('overmind-devtools-client/DevtoolBackend') |
33 | | -DevtoolBackend.create({ |
34 | | - port: 3031, |
35 | | - onRelaunch() { |
36 | | - console.log('relaunch') |
37 | | - }, |
38 | | - storage, |
39 | | -}) |
40 | 41 |
|
41 | | -// this method is called when your extension is activated |
42 | | -// your extension is activated the very first time the command is executed |
43 | | -export function activate(context: vscode.ExtensionContext) { |
44 | 42 | context.subscriptions.push( |
45 | 43 | vscode.commands.registerCommand('overmind-devtools.start', () => { |
46 | | - const onDiskPath = vscode.Uri.file( |
47 | | - path.join(context.extensionPath, 'devtoolsDist', 'bundle.js') |
48 | | - ) |
49 | | - const scriptFile = onDiskPath.with({ scheme: 'vscode-resource' }) |
| 44 | + // const onDiskPath = vscode.Uri.file( |
| 45 | + // path.join(context.extensionPath, '../overmind-devtools-client/dist/', 'bundle.js') |
| 46 | + // ) |
| 47 | + // const scriptFile = onDiskPath.with({ scheme: 'vscode-resource' }) |
50 | 48 |
|
51 | | - DevtoolsPanel.scriptFile = scriptFile |
| 49 | + // DevtoolsPanel.scriptFile = scriptFile |
52 | 50 | DevtoolsPanel.createOrShow(context.extensionPath) // refactor to keep local reference to panel |
53 | 51 | }) |
54 | 52 | ) |
|
0 commit comments