Skip to content

Commit 0a22a1f

Browse files
committed
Merge branch 'main' into chore/promiser-types
# Conflicts: # src/index.d.ts
2 parents b0274ae + 9605fca commit 0a22a1f

12 files changed

Lines changed: 1043 additions & 810 deletions

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
blank_issues_enabled: false
2+
contact_links:
3+
- name: All other issues
4+
url: https://www.sqlite.org/src/wiki?name=Bug+Reports
5+
about: View the SQLite bug filing instructions to find the right place.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: TypeScript types
2+
description: Bug reports and feature requests about TypeScript types.
3+
body:
4+
- type: dropdown
5+
attributes:
6+
label: Type
7+
options:
8+
- Bug Report
9+
- Feature Request
10+
validations:
11+
required: true
12+
- type: textarea
13+
attributes:
14+
label: Description
15+
validations:
16+
required: true

README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ const start = (sqlite3) => {
132132
const initializeSQLite = async () => {
133133
try {
134134
log('Loading and initializing SQLite3 module...');
135-
const sqlite3 = await sqlite3InitModule({ print: log, printErr: error });
135+
const sqlite3 = await sqlite3InitModule();
136136
log('Done initializing. Running demo...');
137137
start(sqlite3);
138138
} catch (err) {
@@ -163,10 +163,7 @@ const start = (sqlite3) => {
163163
const initializeSQLite = async () => {
164164
try {
165165
log('Loading and initializing SQLite3 module...');
166-
const sqlite3 = await sqlite3InitModule({
167-
print: log,
168-
printErr: error,
169-
});
166+
const sqlite3 = await sqlite3InitModule();
170167
log('Done initializing. Running demo...');
171168
start(sqlite3);
172169
} catch (err) {

package-lock.json

Lines changed: 333 additions & 332 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sqlite.org/sqlite-wasm",
3-
"version": "3.51.2-build3",
3+
"version": "3.51.2-build6",
44
"description": "SQLite Wasm conveniently wrapped as an ES Module.",
55
"type": "module",
66
"repository": {
@@ -63,18 +63,18 @@
6363
"node": ">=22"
6464
},
6565
"devDependencies": {
66-
"@types/node": "^25.0.9",
67-
"@vitest/browser": "^4.0.17",
68-
"@vitest/browser-playwright": "^4.0.17",
69-
"happy-dom": "^20.3.4",
66+
"@types/node": "^25.1.0",
67+
"@vitest/browser": "^4.0.18",
68+
"@vitest/browser-playwright": "^4.0.18",
69+
"happy-dom": "^20.4.0",
7070
"http-server": "github:vapier/http-server",
71-
"lefthook": "2.0.15",
72-
"playwright": "^1.57.0",
73-
"prettier": "^3.8.0",
71+
"lefthook": "2.0.16",
72+
"playwright": "^1.58.0",
73+
"prettier": "^3.8.1",
7474
"prettier-plugin-jsdoc": "^1.8.0",
75-
"publint": "^0.3.16",
76-
"tsdown": "^0.20.0-beta.4",
75+
"publint": "^0.3.17",
76+
"tsdown": "^0.20.1",
7777
"typescript": "^5.9.3",
78-
"vitest": "^4.0.17"
78+
"vitest": "^4.0.18"
7979
}
8080
}
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
import { expect, test, describe } from 'vitest';
2+
import sqlite3InitModule from '../bin/sqlite3-bundler-friendly.mjs';
3+
4+
describe('kvvfs', () => {
5+
test('kvvfs basic sanity check (browser)', async () => {
6+
const sqlite3 = await sqlite3InitModule();
7+
const { kvvfs } = sqlite3;
8+
9+
expect(kvvfs).toBeDefined();
10+
expect(kvvfs.exists('.')).toBe(true);
11+
12+
if (typeof window !== 'undefined' && window.localStorage) {
13+
expect(kvvfs.exists('local')).toBe(true);
14+
}
15+
if (typeof window !== 'undefined' && window.sessionStorage) {
16+
expect(kvvfs.exists('session')).toBe(true);
17+
}
18+
19+
const db = new sqlite3.oo1.DB('file:temp?vfs=kvvfs', 'c');
20+
try {
21+
db.exec('CREATE TABLE t(a,b); INSERT INTO t(a,b) VALUES(1,2),(3,4);');
22+
const rows = db.selectArrays('SELECT * FROM t ORDER BY a');
23+
expect(rows).toEqual([
24+
[1, 2],
25+
[3, 4],
26+
]);
27+
28+
const size = kvvfs.estimateSize('temp');
29+
expect(size).toBeGreaterThan(0);
30+
} finally {
31+
db.close();
32+
}
33+
});
34+
35+
test('kvvfs persistence check (session storage)', async () => {
36+
const sqlite3 = await sqlite3InitModule();
37+
const { kvvfs } = sqlite3;
38+
39+
const dbName = 'file:persisTest?vfs=kvvfs';
40+
41+
// Clean up if it already exists
42+
kvvfs.unlink('persisTest');
43+
44+
let db = new sqlite3.oo1.DB(dbName, 'c');
45+
try {
46+
db.exec('CREATE TABLE t(a); INSERT INTO t(a) VALUES(100);');
47+
} finally {
48+
db.close();
49+
}
50+
51+
// Re-open
52+
db = new sqlite3.oo1.DB(dbName, 'c');
53+
try {
54+
const val = db.selectValue('SELECT a FROM t');
55+
expect(val).toBe(100);
56+
} finally {
57+
db.close();
58+
kvvfs.unlink('persisTest');
59+
}
60+
});
61+
62+
test('kvvfs utility methods', async () => {
63+
const sqlite3 = await sqlite3InitModule();
64+
const { kvvfs } = sqlite3;
65+
66+
const name = 'utilTest';
67+
const dbName = `file:${name}?vfs=kvvfs`;
68+
69+
kvvfs.unlink(name);
70+
const db = new sqlite3.oo1.DB(dbName, 'c');
71+
try {
72+
db.exec('CREATE TABLE t(a); INSERT INTO t(a) VALUES(1);');
73+
74+
const size = kvvfs.estimateSize(name);
75+
expect(size).toBeGreaterThan(0);
76+
77+
expect(kvvfs.exists(name)).toBe(true);
78+
} finally {
79+
db.close();
80+
kvvfs.unlink(name);
81+
expect(kvvfs.exists(name)).toBe(false);
82+
}
83+
});
84+
85+
test('repro issue 146: kvvfs xFileControl [TypeError: Cannot read properties of undefined (reading "disablePageSizeChange")]', async () => {
86+
const sqlite3 = await sqlite3InitModule();
87+
const db = new sqlite3.oo1.DB('file:repro146?vfs=kvvfs', 'c');
88+
89+
try {
90+
// Trigger xFileControl with SQLITE_FCNTL_PRAGMA for page_size
91+
db.exec('PRAGMA page_size;');
92+
93+
db.exec('PRAGMA page_size = 4096;');
94+
95+
db.exec('VACUUM;');
96+
97+
// If en error occurred, it would have happened by this point
98+
expect(true).toBeTruthy();
99+
} finally {
100+
db.close();
101+
sqlite3.kvvfs.unlink('repro146');
102+
}
103+
});
104+
});

0 commit comments

Comments
 (0)