diff --git a/.vscodeignore b/.vscodeignore index ad94bb3..262a135 100644 --- a/.vscodeignore +++ b/.vscodeignore @@ -15,4 +15,5 @@ resources/**/*.d.ts resources/**/*.wasm resources/dide-lsp/server tsconfig.json -design \ No newline at end of file +design +lib \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index bd46d3e..0120be1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "version": "0.4.0", "dependencies": { "axios": "^1.7.7", + "bson": "^6.8.0", "chokidar": "^3.5.3", "puppeteer-core": "^19.4.1", "showdown": "^2.1.0", @@ -1108,6 +1109,14 @@ "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" } }, + "node_modules/bson": { + "version": "6.8.0", + "resolved": "https://registry.npmjs.org/bson/-/bson-6.8.0.tgz", + "integrity": "sha512-iOJg8pr7wq2tg/zSlCCHMi3hMm5JTOxLTagf3zxhcenHsFp+c6uOs6K7W5UE7A4QIJGtqh/ZovFNMP4mOPJynQ==", + "engines": { + "node": ">=16.20.1" + } + }, "node_modules/buffer": { "version": "5.7.1", "resolved": "https://registry.npmmirror.com/buffer/-/buffer-5.7.1.tgz", @@ -5424,6 +5433,11 @@ "update-browserslist-db": "^1.0.13" } }, + "bson": { + "version": "6.8.0", + "resolved": "https://registry.npmjs.org/bson/-/bson-6.8.0.tgz", + "integrity": "sha512-iOJg8pr7wq2tg/zSlCCHMi3hMm5JTOxLTagf3zxhcenHsFp+c6uOs6K7W5UE7A4QIJGtqh/ZovFNMP4mOPJynQ==" + }, "buffer": { "version": "5.7.1", "resolved": "https://registry.npmmirror.com/buffer/-/buffer-5.7.1.tgz", diff --git a/package.json b/package.json index cf0a107..a3ba997 100644 --- a/package.json +++ b/package.json @@ -1191,6 +1191,7 @@ }, "dependencies": { "axios": "^1.7.7", + "bson": "^6.8.0", "chokidar": "^3.5.3", "puppeteer-core": "^19.4.1", "showdown": "^2.1.0", diff --git a/src/function/dide-viewer/api.ts b/src/function/dide-viewer/api.ts new file mode 100644 index 0000000..781fd4d --- /dev/null +++ b/src/function/dide-viewer/api.ts @@ -0,0 +1,7 @@ +import * as fs from 'fs'; +import { BSON } from 'bson'; +import { hdlPath } from '../../hdlFs'; + +export async function saveView(file: string, payload: any) { + +} \ No newline at end of file diff --git a/src/function/dide-viewer/index.ts b/src/function/dide-viewer/index.ts index 7efe4b3..b1a999c 100644 --- a/src/function/dide-viewer/index.ts +++ b/src/function/dide-viewer/index.ts @@ -18,6 +18,7 @@ function getWebviewContent(panel?: vscode.WebviewPanel): string | undefined { class WaveViewer { context: vscode.ExtensionContext; + openFileUri?: vscode.Uri; panel?: vscode.WebviewPanel; constructor(context: vscode.ExtensionContext) { this.context = context; @@ -28,6 +29,7 @@ class WaveViewer { } private create(uri: vscode.Uri) { + this.openFileUri = uri; this.panel = vscode.window.createWebviewPanel( 'Wave Viewer', 'Wave Viewer', @@ -64,16 +66,33 @@ class WaveViewer { const iconPath = hdlPath.join(opeParam.extensionPath, 'images', 'icon.svg'); this.panel.iconPath = vscode.Uri.file(iconPath); + this.registerMessageEvent(); } else { WaveViewOutput.report('preview html in is empty', ReportType.Warn); } } + // vscode 前端向 webview 发送消息 public send(uri: vscode.Uri) { this.panel?.webview.postMessage({ }); } + + // vscode 前端接受 webview 的消息 + private registerMessageEvent() { + this.panel?.webview.onDidReceiveMessage(message => { + const { command, data } = message; + + switch (command) { + case 'save-view': + break; + + default: + break; + } + }); + } } async function openWaveViewer(context: vscode.ExtensionContext, uri: vscode.Uri) {