Skip to content

Commit

Permalink
update sqlite3_wasm.cjs lib
Browse files Browse the repository at this point in the history
  • Loading branch information
pk910 committed Jan 5, 2024
1 parent d4a9d7e commit 8267686
Show file tree
Hide file tree
Showing 4 changed files with 176 additions and 185 deletions.
12 changes: 6 additions & 6 deletions faucet-wasm/sqlite3/build_wasm.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@

const base32768 = require('base32768');
const fs = require('fs');
import { encode } from "base32768";
import fs from "fs";

const base32768WASM = base32768.encode(fs.readFileSync("node_modules/node-sqlite3-wasm/dist/node-sqlite3-wasm.wasm"));
const base32768WASM = encode(fs.readFileSync("node_modules/node-sqlite3-wasm/dist/node-sqlite3-wasm.wasm"));

const wasmWrappperJS = fs.readFileSync("node_modules/node-sqlite3-wasm/dist/node-sqlite3-wasm.js", { encoding: "utf8" });
let wasmWrappperLines = wasmWrappperJS.split("\n");

const customLoaderSrc = [
fs.readFileSync("node_modules/base32768/dist/iife/base32768.js", { encoding: "utf8" }),
fs.readFileSync("node_modules/base32768/src/index.js", { encoding: "utf8" }).replace(/^export .*$/m, ""),
`const base32768WASM = "${base32768WASM}";`,
`Module['wasmBinary'] = base32768.decode(base32768WASM);`
`moduleArg['wasmBinary'] = decode(base32768WASM);`
];

// inject wasm binary
wasmWrappperLines = wasmWrappperLines.map(line => {
if(line.startsWith("function(Module = {}) {")) {
if(line.startsWith("function(moduleArg = {}) {")) {
return line + "\n" + customLoaderSrc.join("\n");
}
return line;
Expand Down
28 changes: 14 additions & 14 deletions faucet-wasm/sqlite3/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions faucet-wasm/sqlite3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
"version": "0.0.0",
"description": "build wasm module into webworker",
"main": "build_wasm.js",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "GPL-3.0-or-later",
"dependencies": {
"base32768": "^2.0.1",
"node-sqlite3-wasm": "^0.6.4"
"base32768": "^3.0.1",
"node-sqlite3-wasm": "^0.8.5"
}
}
316 changes: 153 additions & 163 deletions libs/sqlite3_wasm.cjs

Large diffs are not rendered by default.

0 comments on commit 8267686

Please sign in to comment.