feat: support auto decompiling with cfr

This commit is contained in:
ReaJason
2026-08-30 12:30:58 +08:00
parent f239dfb6df
commit 3c91ba50e9
19 changed files with 692 additions and 29 deletions
+19
View File
@@ -0,0 +1,19 @@
const isNode =
typeof process !== "undefined" &&
process?.versions?.node != null;
const wasmPath = async () => {
const url = new URL("./cfr.wasm", import.meta.url).href;
return isNode ? await import("node:url").then((mod) => mod.fileURLToPath(url)) : url;
};
let decompileFunc = null;
export const decompile = async (name, options) => {
if (!decompileFunc) {
const { load } = await import("./cfr.wasm-runtime.js");
const { exports } = await load(await wasmPath(), { noAutoImports: true });
decompileFunc = exports.decompile;
}
return decompileFunc(name, options);
};