Skip to content

Commit 3b0a76d

Browse files
committed
Add wa-sqlite implementation.
1 parent 6672b66 commit 3b0a76d

File tree

12 files changed

+2647
-235
lines changed

12 files changed

+2647
-235
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"ts-node": "^10.9.2",
1919
"tsx": "^4.16.2",
2020
"typescript": "^5.4.5",
21-
"vitest": "^1.5.0"
21+
"vitest": "^2.0.5"
2222
},
2323
"packageManager": "[email protected]+sha512.38dc6fba8dba35b39340b9700112c2fe1e12f10b17134715a4aa98ccf7bb035e76fd981cf0bb384dfa98f8d6af5481c2bef2f4266a24bfa20c34eb7147ce0b5e"
2424
}

packages/api/src/impl.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -303,12 +303,12 @@ export class ConnectionImpl implements SqliteConnection {
303303
}
304304

305305
async begin(options?: TransactionOptions): Promise<SqliteBeginTransaction> {
306-
await this.init();
306+
this.init();
307307

308308
if ((options?.type ?? 'exclusive') == 'exclusive') {
309-
await this._beginExclusive!.select();
309+
await this._beginExclusive!.run();
310310
} else {
311-
await this._begin!.select();
311+
await this._begin!.run();
312312
}
313313

314314
return new BeginTransactionImpl(this);
@@ -321,18 +321,18 @@ export class ConnectionImpl implements SqliteConnection {
321321
this.init();
322322

323323
if ((options?.type ?? 'exclusive') == 'exclusive') {
324-
await this._beginExclusive!.select();
324+
await this._beginExclusive!.run();
325325
} else {
326-
await this._begin!.select();
326+
await this._begin!.run();
327327
}
328328
try {
329329
const tx = new TransactionImpl(this);
330330
const result = await callback(tx);
331331

332-
await this.commit!.select();
332+
await this.commit!.run();
333333
return result;
334334
} catch (e) {
335-
await this.rollback!.select();
335+
await this.rollback!.run();
336336
throw e;
337337
}
338338
}

packages/api/test/src/impl-tests.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ export function describeImplTests(
1212
let dbPath: string;
1313

1414
const open = async () => {
15-
const dir = path.dirname(dbPath);
16-
try {
17-
await fs.mkdir(dir);
18-
} catch (e) {}
19-
try {
20-
await fs.rm(dbPath);
21-
} catch (e) {}
15+
// const dir = path.dirname(dbPath);
16+
// try {
17+
// await fs.mkdir(dir);
18+
// } catch (e) {}
19+
// try {
20+
// await fs.rm(dbPath);
21+
// } catch (e) {}
2222
return factory(dbPath);
2323
};
2424

packages/driver-tests/src/driver-tests.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ export function describeDriverTests(
1919
let dbPath: string;
2020

2121
const open = async () => {
22-
const dir = path.dirname(dbPath);
23-
try {
24-
await fs.mkdir(dir);
25-
} catch (e) {}
26-
try {
27-
await fs.rm(dbPath);
28-
} catch (e) {}
22+
// const dir = path.dirname(dbPath);
23+
// try {
24+
// await fs.mkdir(dir);
25+
// } catch (e) {}
26+
// try {
27+
// await fs.rm(dbPath);
28+
// } catch (e) {}
2929
const db = factory(dbPath);
3030
return db;
3131
};

packages/driver-tests/src/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export interface TestContext {
55
fullName: string;
66
}
77

8-
export const isVitest = process.env.VITEST == 'true';
8+
export const isVitest = true || process.env.VITEST == 'true';
99
export const isMocha = !isVitest;
1010

1111
let testImpl, describeImpl, beforeEachImpl;
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"name": "@sqlite-js/wa-sqlite-driver",
3+
"version": "0.0.1",
4+
"description": "",
5+
"type": "module",
6+
"scripts": {
7+
"build": "tsc -b",
8+
"test": "pnpm build && vitest",
9+
"clean": "tsc -b --clean && tsc -b ./test/tsconfig.json --clean && rm -rf lib test/lib"
10+
},
11+
"exports": {
12+
".": "./lib/index.js"
13+
},
14+
"keywords": [],
15+
"author": "",
16+
"license": "MIT",
17+
"dependencies": {
18+
"@journeyapps/wa-sqlite": "^0.3.0",
19+
"@sqlite-js/driver": "workspace:^",
20+
"async-mutex": "^0.5.0"
21+
},
22+
"devDependencies": {
23+
"vite-plugin-top-level-await": "^1.4.2",
24+
"vite-plugin-wasm": "^3.3.0",
25+
"@sqlite-js/driver-tests": "workspace:^",
26+
"@types/node": "^22.3.0",
27+
"typescript": "^5.5.4",
28+
"@vitest/browser": "^2.0.5",
29+
"vitest": "^2.0.5",
30+
"playwright": "^1.45.3",
31+
"webdriverio": "^8.39.1"
32+
}
33+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './wa-sqlite-driver.js';

0 commit comments

Comments
 (0)