Compare commits

...

5 Commits

3 changed files with 7 additions and 40 deletions

@ -1,28 +1,16 @@
import {
App,
Editor,
MarkdownView,
Modal,
Notice,
Plugin,
PluginSettingTab,
Setting,
} from "obsidian";
import TestWorker from "sqlite3.worker";
import { sqlite3Worker1Promiser } from "@sqlite.org/sqlite-wasm";
// Remember to rename these classes and interfaces!
interface MyPluginSettings {
mySetting: string;
}
const DEFAULT_SETTINGS: MyPluginSettings = {
mySetting: "default",
};
export default class MyPlugin extends Plugin {
settings: MyPluginSettings;
settings: any;
private worker: Worker;
private promiser: (...args: any[]) => any;
@ -30,8 +18,9 @@ export default class MyPlugin extends Plugin {
await this.loadSettings();
console.log(import.meta);
// This creates an icon in the left ribbon.
await this.initSqlite();
await this.start();
(window as any).sqlite3Promiser = this.promiser;
}
onunload() {
@ -39,7 +28,7 @@ export default class MyPlugin extends Plugin {
}
async loadSettings() {
this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData());
this.settings = Object.assign({}, await this.loadData());
}
async saveSettings() {
@ -74,12 +63,11 @@ export default class MyPlugin extends Plugin {
worker: () => w,
});
});
await this.start();
}
async start() {
let openRes = await this.promiser("open", {
filename: "/test.sqlite2",
filename: "/managed-sah/test.sqlite3",
vfs: "opfs-sahpool",
});
const { dbId } = openRes;
@ -114,22 +102,5 @@ export default class MyPlugin extends Plugin {
} finally {
await this.promiser("close", { dbId });
}
// db = new sqlite3.oo1.DB("/test.sqlite3", "ct");
/* if (db) {
try {
console.log("Creating a table...");
db.exec();
console.log("Insert some data using exec()...");
for (let i = 20; i <= 25; ++i) {
db.exec({
sql: "INSERT INTO t(a,b) VALUES (?,?)",
bind: [i, i * 2],
});
}
db.exec();
} finally {
db.close();
}
} */
}
}

@ -12,8 +12,9 @@ onmessage = async (event) => {
await sqlite3.installOpfsSAHPoolVfs({
clearOnInit: false,
initialCapacity: 65536,
directory: "/var/managed-sah"
});
sqlite3.initWorker1API();
console.log(sqlite3.capi.sqlite3_vfs_find("opfs-sah"));
console.log(sqlite3.capi.sqlite3_vfs_find("opfs-sahpool"));
}
};

@ -725,11 +725,6 @@ slash@^3.0.0:
resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634"
integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==
sqlite-wasm-esm@^0.0.30:
version "0.0.30"
resolved "https://registry.yarnpkg.com/sqlite-wasm-esm/-/sqlite-wasm-esm-0.0.30.tgz#b25492775bc9f26d260d683820787b840b466592"
integrity sha512-rLl+STKLfGXyBcpQlH6uEMMh76YXixY3s+qDEMzIiMMsyN7iXLmo4Mk1Su/6GoJFprSWP+cgOCWQsAbLELCEPg==
to-regex-range@^5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4"