Get wasm loading in extension

This commit is contained in:
Jonathan Kelley committed 2023-07-08 18:53:43 -07:00
1 parent f59cacb2a0
commit b5312732ba
11 files changed
+2080 -604

No files matched your search

-23
View File
@@ -1,23 +0,0 @@
// build.ts
import('esbuild').then((esbuild) => {
import('esbuild-plugin-wasm').then((wasmLoader) => {
// "build-base": "esbuild ./src/main.ts --bundle --outfile=out/main.js --external:vscode --format=cjs --platform=node --target=node16",
esbuild.build({
entryPoints: ['src/main.ts'],
outfile: 'out/main.js',
bundle: true,
platform: 'node',
target: 'node16',
format: 'esm',
external: ['vscode'],
plugins: [
wasmLoader.wasmLoader({
mode: 'embedded'
})
]
});
});
});
-7
View File
@@ -25,10 +25,3 @@ pub fn translate_rsx(contents: String, component: bool) -> String {
out
}
// rsx! {
// div {}
// div {}
// div {}
// div {} div {}
// }
+4 -20
View File
@@ -1,9 +1,9 @@
import * as vscode from 'vscode';
import { translate_rsx } from 'dioxus-ext';
import init, { translate_rsx } from 'dioxus-ext';
export async function activate(context: vscode.ExtensionContext) {
const wasmSourceCode = await vscode.workspace.fs.readFile(vscode.Uri.joinPath(context.extensionUri, "./pkg/dioxus_ext_bg.wasm"));
const wasmPromise = await init(wasmSourceCode);
context.subscriptions.push(
vscode.commands.registerCommand('extension.htmlToDioxusRsx', () => translate(false)),
@@ -15,6 +15,7 @@ export async function activate(context: vscode.ExtensionContext) {
}
function translate(component: boolean) {
const editor = vscode.window.activeTextEditor;
if (!editor) return;
@@ -32,23 +33,6 @@ function translate(component: boolean) {
} else {
vscode.window.showWarningMessage(`Errors occurred while translating, make sure this block of HTML is valid`);
}
// const params = ["translate"];
// if (component) params.push("--component");
// params.push("--raw", html);
// const child_proc = spawn(serverPath, params);
// let result = '';
// child_proc.stdout?.on('data', data => result += data);
// child_proc.on('close', () => {
// if (result.length > 0) editor.edit(editBuilder => editBuilder.replace(editor.selection, result));
// });
// child_proc.on('error', (err) => {
// vscode.window.showWarningMessage(`Errors occurred while translating. Make sure you have the most recent Dioxus-CLI installed! \n${err}`);
// });
}