Wasm working again for node

needs testing in browser
This commit is contained in:
Felix Kaspar
2023-11-15 00:24:04 +01:00
parent 063acc6bbf
commit 997f0f349d
6 changed files with 903 additions and 21 deletions

View File

@@ -1,8 +1,7 @@
import { WasmFs } from '@wasmer/wasmfs';
import path from "path";
let webWasmLocation = "/wasm/";
let nodeWasmLocation = "./public/wasm/";
let nodeWasmLocation = "../shared-operations/src/wasm/pdfcpu/";
let fs;
const wasmfs = new WasmFs();
@@ -22,7 +21,7 @@ async function configureFs() {
}
async function loadWasm() {
global.crypto = (await import("crypto")).webcrypto; // wasm dependecy
// global.crypto = (await import("crypto")).webcrypto; // wasm dependecy
await import("./wasm_exec.js");
}

View File

@@ -201,14 +201,14 @@
}
}
if (!global.crypto && global.require) {
const nodeCrypto = require("crypto");
global.crypto = {
getRandomValues(b) {
nodeCrypto.randomFillSync(b);
},
};
}
// if (!global.crypto && global.require) {
// const nodeCrypto = require("crypto");
// global.crypto = {
// getRandomValues(b) {
// nodeCrypto.randomFillSync(b);
// },
// };
// }
if (!global.crypto) {
throw new Error("global.crypto is not available, polyfill required (getRandomValues only)");
}