deno wasm mod

This commit is contained in:
2026-02-14 20:39:48 +08:00
parent 25f35f7b53
commit 4149c0c142

View File

@@ -1,9 +1,32 @@
import {fetchDataWithTimeout} from "https://script.hatter.ink/@49/deno-commons-mod.ts"; import {
args,
execCommandShell,
exit,
fetchFileWithCache,
log,
} from "https://script.hatter.ink/@50/deno-commons-mod.ts";
// JQ WASM URL: // JQ WASM URL:
// https://cdn.hatter.ink/doc/8998_BE8D1CBE6106C77968183F226E2129B5/jq.wasm // https://cdn.hatter.ink/doc/8998_BE8D1CBE6106C77968183F226E2129B5/jq.wasm
async function getCachedWasm(wasmUrl: string): Promise<string> { async function execWasm(
const wasmResponse = await fetchDataWithTimeout(wasmUrl); wasmCommand: string,
return null; wasmUrl: string,
wasmArgs?: string[],
): never {
const wasmCacheFileMeta = await fetchFileWithCache(wasmUrl);
const wasmCommandArgs = [wasmCacheFileMeta.cache_full_path, "--"];
if (wasmArgs) {
wasmCommandArgs.push(...wasmArgs);
}
log.debug(wasmCommandArgs);
exit(await execCommandShell(wasmCommand, wasmCommandArgs));
}
if (import.meta.main) {
await execWasm(
"wasmer",
"https://cdn.hatter.ink/doc/8998_BE8D1CBE6106C77968183F226E2129B5/jq.wasm",
args(),
);
} }