Browse Source

try to insert wa-sqlite but fail with: WebAssembly.instantiate(): expected magic word 00 61 73 6d, found 3c 21 44 4f @+0)

sql-wa-sqlite
Trent Larson 1 month ago
parent
commit
753d178fc3
  1. 1
      package.json
  2. 28
      src/db-sql/index.ts
  3. 3
      src/views/AccountViewView.vue

1
package.json

@ -123,6 +123,7 @@
"vue-picture-cropper": "^0.7.0",
"vue-qrcode-reader": "^5.5.3",
"vue-router": "^4.5.0",
"wa-sqlite": "github:rhashimoto/wa-sqlite",
"web-did-resolver": "^2.0.27",
"zod": "^3.24.2"
},

28
src/db-sql/index.ts

@ -0,0 +1,28 @@
// Started with https://rhashimoto.github.io/wa-sqlite/docs/interfaces/SQLiteAPI.html
// and then https://github.com/rhashimoto/wa-sqlite/blob/master/demo/demo-worker.js
import SQLiteESMFactory from 'wa-sqlite/dist/wa-sqlite.mjs';
import * as SQLite from 'wa-sqlite';
const IDBBatchAtomicVFS = await import('wa-sqlite/src/examples/IDBBatchAtomicVFS.js');
let db: any;
export async function sql() {
if (!db) {
const module = await SQLiteESMFactory();
// Use the module to build the API instance.
const sqlite3 = SQLite.Factory(module);
const vfs = new IDBBatchAtomicVFS.create("IDBBatchAtomicVFS", module, { lockPolicy: 'shared+hint' });
sqlite3.vfs_register(vfs, true);
// Use the API to open and access a database.
const db = await sqlite3.open_v2("myDB");
console.log("----- sqlite3 db", db);
sqlite3.close(db);
}
return db;
}

3
src/views/AccountViewView.vue

@ -996,6 +996,7 @@ import {
retrieveSettingsForActiveAccount,
updateAccountSettings,
} from "../db/index";
import { sql } from "../db-sql/index";
import { Account } from "../db/tables/accounts";
import { Contact } from "../db/tables/contacts";
import {
@ -1202,6 +1203,8 @@ export default class AccountViewView extends Vue {
);
}
this.passkeyExpirationDescription = tokenExpiryTimeDescription();
const db = await sql();
console.log("----- db", db);
}
beforeUnmount() {

Loading…
Cancel
Save