From 61b8f8f3d687f516366660df2c3f68ab4acd636d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=98=99=E2=97=A6=20The=20Tablet=20=E2=9D=80=20GamerGirla?= =?UTF-8?q?ndCo=20=E2=97=A6=E2=9D=A7?= Date: Sun, 21 Jul 2024 20:15:30 -0400 Subject: [PATCH] run formatter --- src/main.ts | 89 ++++++++++++++++++++--------------------- src/sqlite.d.ts | 4 +- src/styles.css | 16 ++++---- src/testthing.worker.ts | 24 ++++++----- 4 files changed, 68 insertions(+), 65 deletions(-) diff --git a/src/main.ts b/src/main.ts index eac7bcf..2d4f7da 100644 --- a/src/main.ts +++ b/src/main.ts @@ -8,9 +8,9 @@ import { PluginSettingTab, Setting, } from "obsidian"; -import TestWorker from "testthing.worker" +import TestWorker from "testthing.worker"; import sqlite3InitModule, { Sqlite3Static } from "@sqlite.org/sqlite-wasm"; -import {sqlite3Worker1Promiser} from "@sqlite.org/sqlite-wasm" +import { sqlite3Worker1Promiser } from "@sqlite.org/sqlite-wasm"; // Remember to rename these classes and interfaces! @@ -29,22 +29,18 @@ export default class MyPlugin extends Plugin { async onload() { await this.loadSettings(); - console.log(import.meta) + console.log(import.meta); // This creates an icon in the left ribbon. await this.initSqlite(); } onunload() { - this.worker.terminate() + this.worker.terminate(); } async loadSettings() { - this.settings = Object.assign( - {}, - DEFAULT_SETTINGS, - await this.loadData() - ); + this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData()); } async saveSettings() { @@ -56,66 +52,69 @@ export default class MyPlugin extends Plugin { new Notice("~LOG~", args.join("\n")); } locateFile(path: string, prefix: string): string { - return this.app.vault.adapter.getResourcePath(`${this.manifest.dir}/${path}`) + return this.app.vault.adapter.getResourcePath( + `${this.manifest.dir}/${path}`, + ); } async initSqlite() { this.worker = new TestWorker(); let w = this.worker; - this.worker.postMessage({type: "init", path: this.locateFile("sqlite3.wasm", "")}) + this.worker.postMessage({ + type: "init", + path: this.locateFile("sqlite3.wasm", ""), + }); this.promiser = await new Promise((resolve) => { - const _promiser = sqlite3Worker1Promiser({ + const _promiser = sqlite3Worker1Promiser({ print: this.printNotice, printErr: console.error, locateFile: this.locateFile.bind(this), - onready: () => { - resolve(_promiser); - }, - worker: () => w - }); - }); - await this.start() + onready: () => { + resolve(_promiser); + }, + worker: () => w, + }); + }); + await this.start(); } async start() { let openRes = await this.promiser("open", { filename: "/test.sqlite2", vfs: "opfs-sahpool", - - }) - const {dbId} = openRes - console.log(openRes) + }); + const { dbId } = openRes; + console.log(openRes); try { - console.log("Creating a table...") + console.log("Creating a table..."); let res = await this.promiser("exec", { dbId, sql: "DROP TABLE IF EXISTS abcdef; CREATE TABLE IF NOT EXISTS abcdef(a,b,c)", - returnValue: "resultRows" - }) - console.log("Result: ", res) + returnValue: "resultRows", + }); + console.log("Result: ", res); console.log("Insert some data using exec()..."); for (let i = 20; i <= 25; ++i) { - let innerRes = await this.promiser("exec", { - dbId, - sql: "INSERT INTO abcdef(a,b,c) VALUES (?,?,69)", - bind: [i, i * 2], - returnValue: "resultRows", - rowMode: "object" - }); - console.log(innerRes) - } - console.log("Query data with exec()..."); - let rowRes = await this.promiser("exec", { + let innerRes = await this.promiser("exec", { dbId, - sql: "SELECT * FROM abcdef ORDER BY a LIMIT 10", + sql: "INSERT INTO abcdef(a,b,c) VALUES (?,?,69)", + bind: [i, i * 2], returnValue: "resultRows", - rowMode: "object" - }) - console.log(rowRes) - - } finally { - await this.promiser("close", {dbId}) + rowMode: "object", + }); + console.log(innerRes); } + console.log("Query data with exec()..."); + let rowRes = await this.promiser("exec", { + dbId, + sql: "SELECT * FROM abcdef ORDER BY a LIMIT 10", + returnValue: "resultRows", + rowMode: "object", + }); + console.log(rowRes); + } finally { + await this.promiser("close", { dbId }); + } // db = new sqlite3.oo1.DB("/test.sqlite3", "ct"); /* if (db) { try { diff --git a/src/sqlite.d.ts b/src/sqlite.d.ts index 057b56f..08766fd 100644 --- a/src/sqlite.d.ts +++ b/src/sqlite.d.ts @@ -1,5 +1,5 @@ -import "@sqlite.org/sqlite-wasm" +import "@sqlite.org/sqlite-wasm"; declare module "@sqlite.org/sqlite-wasm" { - export const sqlite3Worker1Promiser: any + export const sqlite3Worker1Promiser: any; } declare module "@sqlite.org/sqlite-wasm/sqlite-wasm/jswasm/sqlite3-worker1-bundler-friendly"; diff --git a/src/styles.css b/src/styles.css index a52b029..71cc60f 100644 --- a/src/styles.css +++ b/src/styles.css @@ -1,8 +1,8 @@ -/* - -This CSS file will be included with your plugin, and -available in the app when your plugin is enabled. - -If your plugin does not need CSS, delete this file. - -*/ +/* + +This CSS file will be included with your plugin, and +available in the app when your plugin is enabled. + +If your plugin does not need CSS, delete this file. + +*/ diff --git a/src/testthing.worker.ts b/src/testthing.worker.ts index b7dbbfd..8bde4fc 100644 --- a/src/testthing.worker.ts +++ b/src/testthing.worker.ts @@ -1,15 +1,19 @@ -import sqlite3InitModule from "@sqlite.org/sqlite-wasm" -(async()=> { -})() +import sqlite3InitModule from "@sqlite.org/sqlite-wasm"; +(async () => {})(); let sqlite3; onmessage = async (event) => { - console.log(event) - if(event.data.type== "init") { - sqlite3 = await sqlite3InitModule({locateFile: (path, prefix) => event.data.path}) + console.log(event); + if (event.data.type == "init") { + sqlite3 = await sqlite3InitModule({ + locateFile: (path, prefix) => event.data.path, + }); // debugger; console.log(`Running sqlite version: ${sqlite3.version.libVersion}`); - await sqlite3.installOpfsSAHPoolVfs({clearOnInit: false, initialCapacity: 65536}); - sqlite3.initWorker1API() - console.log(sqlite3.capi.sqlite3_vfs_find("opfs")) + await sqlite3.installOpfsSAHPoolVfs({ + clearOnInit: false, + initialCapacity: 65536, + }); + sqlite3.initWorker1API(); + console.log(sqlite3.capi.sqlite3_vfs_find("opfs")); } -} +};