mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-18 00:54:19 +01:00
hack imports of wasm due to the issues in Vite and Next.js build systems
This commit is contained in:
23
bindings/javascript/sync/packages/browser/promise-default.ts
Normal file
23
bindings/javascript/sync/packages/browser/promise-default.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { SyncOpts, DatabaseRowMutation, DatabaseRowStatement, DatabaseRowTransformResult } from "@tursodatabase/sync-common";
|
||||
import { SyncEngine, initThreadPool, MainWorker } from "./index-default.js";
|
||||
import { connect as promiseConnect, Database } from "./promise.js";
|
||||
|
||||
/**
|
||||
* Creates a new database connection asynchronously.
|
||||
*
|
||||
* @param {string} path - Path to the database file.
|
||||
* @param {Object} opts - Options for database behavior.
|
||||
* @returns {Promise<Database>} - A promise that resolves to a Database instance.
|
||||
*/
|
||||
async function connect(opts: SyncOpts): Promise<Database> {
|
||||
return await promiseConnect(opts, x => new SyncEngine(x), async () => {
|
||||
await initThreadPool();
|
||||
if (MainWorker == null) {
|
||||
throw new Error("panic: MainWorker is not initialized");
|
||||
}
|
||||
return MainWorker;
|
||||
});
|
||||
}
|
||||
|
||||
export { connect, Database, }
|
||||
export type { DatabaseRowMutation, DatabaseRowStatement, DatabaseRowTransformResult }
|
||||
Reference in New Issue
Block a user