@evolu/sqlite-wasm 2.2.4 → 3.53.4-build1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +55 -218
  3. package/dist/src/CApi.d.ts +2108 -0
  4. package/dist/src/CApi.d.ts.map +1 -0
  5. package/dist/src/CApi.js +1919 -0
  6. package/dist/src/Constants.d.ts +868 -0
  7. package/dist/src/Constants.d.ts.map +1 -0
  8. package/dist/src/Constants.js +602 -0
  9. package/dist/src/Database.d.ts +641 -0
  10. package/dist/src/Database.d.ts.map +1 -0
  11. package/dist/src/Database.js +1177 -0
  12. package/dist/src/Memory.d.ts +119 -0
  13. package/dist/src/Memory.d.ts.map +1 -0
  14. package/dist/src/Memory.js +207 -0
  15. package/dist/src/Pointer.d.ts +100 -0
  16. package/dist/src/Pointer.d.ts.map +1 -0
  17. package/dist/src/Pointer.js +15 -0
  18. package/dist/src/SahPool.d.ts +744 -0
  19. package/dist/src/SahPool.d.ts.map +1 -0
  20. package/dist/src/SahPool.js +1985 -0
  21. package/dist/src/Wasm.d.ts +315 -0
  22. package/dist/src/Wasm.d.ts.map +1 -0
  23. package/dist/src/Wasm.js +756 -0
  24. package/dist/src/WasmUrl.d.ts +21 -0
  25. package/dist/src/WasmUrl.d.ts.map +1 -0
  26. package/dist/src/WasmUrl.js +20 -0
  27. package/dist/src/c-api/index.d.ts +9 -0
  28. package/dist/src/c-api/index.d.ts.map +1 -0
  29. package/dist/src/c-api/index.js +8 -0
  30. package/dist/src/index.d.ts +15 -0
  31. package/dist/src/index.d.ts.map +1 -0
  32. package/dist/src/index.js +13 -0
  33. package/dist/wasm/sqlite3.wasm +0 -0
  34. package/package.json +60 -60
  35. package/src/CApi.test.ts +217 -0
  36. package/src/CApi.ts +3294 -0
  37. package/src/Constants.ts +803 -0
  38. package/src/Database.ts +1714 -0
  39. package/src/Memory.test.ts +319 -0
  40. package/src/Memory.ts +237 -0
  41. package/src/Pointer.ts +121 -0
  42. package/src/SahPool.test.ts +180 -0
  43. package/src/SahPool.ts +2627 -0
  44. package/src/Wasm.test.ts +444 -0
  45. package/src/Wasm.ts +1026 -0
  46. package/src/WasmUrl.ts +26 -0
  47. package/src/c-api/index.ts +9 -0
  48. package/src/index.ts +15 -0
  49. package/bin/index.js +0 -110
  50. package/index.d.ts +0 -8118
  51. package/index.mjs +0 -7
  52. package/node.mjs +0 -3
  53. package/sqlite-wasm/jswasm/sqlite3-bundler-friendly.mjs +0 -13659
  54. package/sqlite-wasm/jswasm/sqlite3-node.mjs +0 -11671
  55. package/sqlite-wasm/jswasm/sqlite3-opfs-async-proxy.js +0 -691
  56. package/sqlite-wasm/jswasm/sqlite3-worker1-bundler-friendly.mjs +0 -35
  57. package/sqlite-wasm/jswasm/sqlite3-worker1-promiser.js +0 -193
  58. package/sqlite-wasm/jswasm/sqlite3-worker1-promiser.mjs +0 -187
  59. package/sqlite-wasm/jswasm/sqlite3-worker1.js +0 -46
  60. package/sqlite-wasm/jswasm/sqlite3.js +0 -13697
  61. package/sqlite-wasm/jswasm/sqlite3.mjs +0 -13661
  62. package/sqlite-wasm/jswasm/sqlite3.wasm +0 -0
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Where the package's wasm binary is.
3
+ *
4
+ * @module
5
+ */
6
+ /**
7
+ * The URL of the wasm binary the package ships, to load with
8
+ * {@link createSqliteWasm}.
9
+ *
10
+ * It is `new URL("../wasm/sqlite3.wasm", import.meta.url)`, which Vite,
11
+ * webpack, Next.js and other bundlers recognize: they emit the binary with the
12
+ * app and give the URL of their copy. In the published package, the binary is
13
+ * `dist/wasm/sqlite3.wasm`, beside the compiled modules in `dist/src`.
14
+ *
15
+ * Vite does not process the URL in a dependency it prebundles, so add
16
+ * `@evolu/sqlite-wasm` to `optimizeDeps.exclude`. Vite emits the binary
17
+ * whenever the app imports `@evolu/sqlite-wasm`, even without this URL, and
18
+ * webpack only when the app uses it.
19
+ */
20
+ export declare const sqliteWasmUrl: URL;
21
+ //# sourceMappingURL=WasmUrl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WasmUrl.d.ts","sourceRoot":"","sources":["../../src/WasmUrl.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,aAAa,EAAE,GAG3B,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Where the package's wasm binary is.
3
+ *
4
+ * @module
5
+ */
6
+ /**
7
+ * The URL of the wasm binary the package ships, to load with
8
+ * {@link createSqliteWasm}.
9
+ *
10
+ * It is `new URL("../wasm/sqlite3.wasm", import.meta.url)`, which Vite,
11
+ * webpack, Next.js and other bundlers recognize: they emit the binary with the
12
+ * app and give the URL of their copy. In the published package, the binary is
13
+ * `dist/wasm/sqlite3.wasm`, beside the compiled modules in `dist/src`.
14
+ *
15
+ * Vite does not process the URL in a dependency it prebundles, so add
16
+ * `@evolu/sqlite-wasm` to `optimizeDeps.exclude`. Vite emits the binary
17
+ * whenever the app imports `@evolu/sqlite-wasm`, even without this URL, and
18
+ * webpack only when the app uses it.
19
+ */
20
+ export const sqliteWasmUrl = /*#__PURE__*/ new URL("../wasm/sqlite3.wasm", import.meta.url);
@@ -0,0 +1,9 @@
1
+ /**
2
+ * SQLite's C API as the wasm exports it: the C-named functions, the SQLITE_*
3
+ * constants, and the struct layouts.
4
+ *
5
+ * @module
6
+ */
7
+ export * from "../CApi.ts";
8
+ export * from "../Constants.ts";
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/c-api/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * SQLite's C API as the wasm exports it: the C-named functions, the SQLITE_*
3
+ * constants, and the struct layouts.
4
+ *
5
+ * @module
6
+ */
7
+ export * from "../CApi.js";
8
+ export * from "../Constants.js";
@@ -0,0 +1,15 @@
1
+ /**
2
+ * SQLite compiled to WebAssembly, with Evolu's own TypeScript layer, which also
3
+ * encrypts databases.
4
+ *
5
+ * @module
6
+ * @mergeModuleWith <project>
7
+ */
8
+ export type { SqlitePrimaryResultCode, SqliteResultCode } from "./Constants.ts";
9
+ export * from "./Database.ts";
10
+ export * from "./Memory.ts";
11
+ export * from "./Pointer.ts";
12
+ export * from "./SahPool.ts";
13
+ export * from "./Wasm.ts";
14
+ export * from "./WasmUrl.ts";
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,YAAY,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAChF,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * SQLite compiled to WebAssembly, with Evolu's own TypeScript layer, which also
3
+ * encrypts databases.
4
+ *
5
+ * @module
6
+ * @mergeModuleWith <project>
7
+ */
8
+ export * from "./Database.js";
9
+ export * from "./Memory.js";
10
+ export * from "./Pointer.js";
11
+ export * from "./SahPool.js";
12
+ export * from "./Wasm.js";
13
+ export * from "./WasmUrl.js";
Binary file
package/package.json CHANGED
@@ -1,76 +1,76 @@
1
1
  {
2
2
  "name": "@evolu/sqlite-wasm",
3
- "version": "2.2.4",
4
- "description": "SQLite Wasm conveniently wrapped as an ES Module. (Multiple Ciphers Support)",
3
+ "version": "3.53.4-build1",
4
+ "description": "SQLite compiled to WebAssembly, with Evolu's own TypeScript layer, which also encrypts databases",
5
5
  "keywords": [
6
- "sqlite",
7
- "sqlite3",
8
- "sqlite-wasm",
9
- "sqlite3-wasm",
10
- "sqlite-wasm-cipher",
11
- "sqlite3-multiple-ciphers",
12
- "webassembly",
13
- "cipher",
14
6
  "evolu",
7
+ "sqlite",
15
8
  "wasm",
16
- "esm",
17
- "opfs",
18
- "origin-private-file-system"
9
+ "opfs"
19
10
  ],
20
- "main": "index.mjs",
21
- "node": "node.mjs",
11
+ "author": "Daniel Steigerwald <daniel@steigerwald.cz>",
12
+ "license": "MIT",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/evoluhq/evolu.git"
16
+ },
17
+ "bugs": {
18
+ "url": "https://github.com/evoluhq/evolu/issues"
19
+ },
20
+ "homepage": "https://evolu.dev",
22
21
  "type": "module",
23
- "files": [
24
- "index.d.ts",
25
- "index.mjs",
26
- "node.mjs",
27
- "sqlite-wasm/"
28
- ],
29
- "types": "index.d.ts",
22
+ "types": "./dist/src/index.d.ts",
30
23
  "exports": {
31
24
  ".": {
32
- "types": "./index.d.ts",
33
- "node": "./node.mjs",
34
- "import": "./index.mjs",
35
- "main": "./index.mjs",
36
- "browser": "./index.mjs"
25
+ "types": "./dist/src/index.d.ts",
26
+ "import": "./dist/src/index.js",
27
+ "browser": "./dist/src/index.js"
37
28
  },
38
- "./package.json": "./package.json",
39
- "./sqlite3.wasm": "./sqlite-wasm/jswasm/sqlite3.wasm"
29
+ "./c-api": {
30
+ "types": "./dist/src/c-api/index.d.ts",
31
+ "import": "./dist/src/c-api/index.js",
32
+ "browser": "./dist/src/c-api/index.js"
33
+ }
40
34
  },
41
- "bin": {
42
- "sqlite-wasm": "bin/index.js"
35
+ "typesVersions": {
36
+ "*": {
37
+ "c-api": [
38
+ "./dist/src/c-api/index.d.ts"
39
+ ]
40
+ }
43
41
  },
44
- "scripts": {
45
- "publint": "npx publint",
46
- "check-types": "tsc",
47
- "clean": "shx rm -rf sqlite-wasm",
48
- "build": "npm run clean && node bin/index.js",
49
- "start": "npx http-server --coop",
50
- "start:node": "cd demo && node node.mjs",
51
- "fix": "npx prettier . --write",
52
- "prepublishOnly": "npm run build && npm run fix && npm run publint && npm run check-types",
53
- "deploy": "npm run prepublishOnly && git add . && git commit -am 'New release' && git push && npm publish --access public"
42
+ "files": [
43
+ "dist/src/**",
44
+ "!dist/**/*.test.*",
45
+ "dist/wasm/sqlite3.wasm",
46
+ "src/**",
47
+ "README.md"
48
+ ],
49
+ "devDependencies": {
50
+ "@evolu/common": "8.19.0",
51
+ "@evolu/typescript-config": "0.1.1",
52
+ "@types/node": "^24.10.9",
53
+ "@typescript/native": "npm:typescript@^7.0.2",
54
+ "prettier": "^3.9.6",
55
+ "typescript": "npm:@typescript/typescript6@^6.0.2",
56
+ "wabt": "1.0.39"
54
57
  },
55
- "repository": {
56
- "type": "git",
57
- "url": "git+https://github.com/evoluhq/sqlite-wasm-cipher.git"
58
+ "peerDependencies": {
59
+ "@evolu/common": "^8.19.0"
58
60
  },
59
- "author": "EvoluHQ",
60
- "license": "Apache-2.0",
61
- "bugs": {
62
- "url": "https://github.com/evoluhq/sqlite-wasm-cipher/issues"
61
+ "publishConfig": {
62
+ "access": "public"
63
63
  },
64
- "homepage": "https://github.com/evoluhq/sqlite-wasm-cipher#readme",
65
- "devDependencies": {
66
- "decompress": "^4.2.1",
67
- "http-server": "github:vapier/http-server",
68
- "module-workers-polyfill": "^0.3.2",
69
- "node-fetch": "^3.3.2",
70
- "prettier": "^3.6.2",
71
- "prettier-plugin-jsdoc": "^1.3.3",
72
- "publint": "^0.3.12",
73
- "shx": "^0.4.0",
74
- "typescript": "^5.9.2"
64
+ "engines": {
65
+ "node": ">=24.20.0"
66
+ },
67
+ "sideEffects": false,
68
+ "dependencies": {
69
+ "@awasm/noble": "0.1.4"
70
+ },
71
+ "scripts": {
72
+ "build": "tsc --build tsconfig.build.json",
73
+ "format": "prettier --write \"src/*.{ts,tsx,md}\"",
74
+ "generate": "node scripts/generate.mts"
75
75
  }
76
- }
76
+ }
@@ -0,0 +1,217 @@
1
+ import { test } from "node:test";
2
+
3
+ import { assertEqual, assertSame, assertTrue, assertType } from "@evolu/common";
4
+ import {
5
+ sqlite3_config,
6
+ sqlite3_db_config,
7
+ type SqliteCExports,
8
+ } from "./CApi.ts";
9
+ import {
10
+ SQLITE_CONFIG_GETMALLOC,
11
+ SQLITE_CONFIG_LOOKASIDE,
12
+ SQLITE_CONFIG_MEMDB_MAXSIZE,
13
+ SQLITE_CONFIG_URI,
14
+ SQLITE_DBCONFIG_ENABLE_FKEY,
15
+ SQLITE_DBCONFIG_FP_DIGITS,
16
+ SQLITE_DBCONFIG_LOOKASIDE,
17
+ SQLITE_DBCONFIG_MAINDBNAME,
18
+ SQLITE_DBCONFIG_MAX,
19
+ SQLITE_MISUSE,
20
+ SQLITE_NOTFOUND,
21
+ SQLITE_OK,
22
+ SQLITE_SERIALIZE_NOCOPY,
23
+ type SqliteResultCode,
24
+ } from "./Constants.ts";
25
+ import type { readCString } from "./Memory.ts";
26
+ import type {
27
+ CStringPtr,
28
+ NullPtr,
29
+ SqliteDbPtr,
30
+ SqliteOwnedCStringPtr,
31
+ SqliteOwnedPtr,
32
+ SqliteOwnedValuePtr,
33
+ SqliteStmtPtr,
34
+ SqliteValuePtr,
35
+ WasmPtr,
36
+ } from "./Pointer.ts";
37
+ import type { SqliteWasmDep } from "./Wasm.ts";
38
+
39
+ // The exports need a loaded binary, so these tests call stubs of their types
40
+ // to prove which calls TypeScript accepts, and fakes of the variadic shims to
41
+ // prove how options are dispatched.
42
+
43
+ const db = 8 as SqliteDbPtr;
44
+ const pStmt = 16 as SqliteStmtPtr;
45
+ const sqlite3_free: SqliteCExports["sqlite3_free"] = () => undefined;
46
+
47
+ test("sqlite3_serialize returns memory sqlite3_free accepts only for mFlags 0", () => {
48
+ const sqlite3_serialize: SqliteCExports["sqlite3_serialize"] = () => 0;
49
+ const piSize = 24 as WasmPtr;
50
+ const mFlags: number = SQLITE_SERIALIZE_NOCOPY;
51
+
52
+ const copy = sqlite3_serialize(db, 0, piSize, 0);
53
+ assertType<typeof copy, SqliteOwnedPtr | NullPtr>();
54
+ sqlite3_free(copy);
55
+
56
+ const buffer = sqlite3_serialize(db, 0, piSize, SQLITE_SERIALIZE_NOCOPY);
57
+ assertType<typeof buffer, WasmPtr | NullPtr>();
58
+ // @ts-expect-error SQLITE_SERIALIZE_NOCOPY can return SQLite's own buffer.
59
+ sqlite3_free(buffer);
60
+
61
+ const unknown = sqlite3_serialize(db, 0, piSize, mFlags);
62
+ // @ts-expect-error Flags not known to be 0 can include SQLITE_SERIALIZE_NOCOPY.
63
+ sqlite3_free(unknown);
64
+ });
65
+
66
+ test("sqlite3_value_free accepts only values sqlite3_value_dup returns", () => {
67
+ const sqlite3_column_value: SqliteCExports["sqlite3_column_value"] = () =>
68
+ 32 as SqliteValuePtr;
69
+ const sqlite3_value_dup: SqliteCExports["sqlite3_value_dup"] = () => 0;
70
+ const sqlite3_value_free: SqliteCExports["sqlite3_value_free"] = () =>
71
+ undefined;
72
+
73
+ const column = sqlite3_column_value(pStmt, 0);
74
+ const copy = sqlite3_value_dup(column);
75
+ assertType<typeof copy, SqliteOwnedValuePtr | NullPtr>();
76
+ sqlite3_value_free(copy);
77
+
78
+ // @ts-expect-error A column value is borrowed from the statement.
79
+ sqlite3_value_free(column);
80
+ // @ts-expect-error A copied value is freed with sqlite3_value_free.
81
+ sqlite3_free(copy);
82
+ });
83
+
84
+ test("sqlite3_expanded_sql returns a C string sqlite3_free accepts", () => {
85
+ const sqlite3_expanded_sql: SqliteCExports["sqlite3_expanded_sql"] = () => 0;
86
+ const read: ReturnType<typeof readCString> = () => "";
87
+
88
+ const sql = sqlite3_expanded_sql(pStmt);
89
+ assertType<typeof sql, SqliteOwnedCStringPtr | NullPtr>();
90
+ if (sql !== 0) read(sql);
91
+ sqlite3_free(sql);
92
+ });
93
+
94
+ /**
95
+ * A fake {@link SqliteWasmDep} whose variadic shims record their calls and
96
+ * return SQLITE_OK.
97
+ */
98
+ const setupFakeShims = () => {
99
+ const calls: Array<ReadonlyArray<unknown>> = [];
100
+ const shim =
101
+ (name: string) =>
102
+ (...args: ReadonlyArray<unknown>): SqliteResultCode => {
103
+ calls.push([name, ...args]);
104
+ return SQLITE_OK;
105
+ };
106
+ const deps: SqliteWasmDep = {
107
+ sqliteWasm: {
108
+ exports: {
109
+ sqlite3__wasm_config_i: shim("sqlite3__wasm_config_i"),
110
+ sqlite3__wasm_config_ii: shim("sqlite3__wasm_config_ii"),
111
+ sqlite3__wasm_config_j: shim("sqlite3__wasm_config_j"),
112
+ sqlite3__wasm_db_config_s: shim("sqlite3__wasm_db_config_s"),
113
+ sqlite3__wasm_db_config_pii: shim("sqlite3__wasm_db_config_pii"),
114
+ sqlite3__wasm_db_config_ip: shim("sqlite3__wasm_db_config_ip"),
115
+ } as unknown as SqliteCExports,
116
+ functionTable: new WebAssembly.Table({ initial: 0, element: "anyfunc" }),
117
+ getHeapU8: () => new Uint8Array(),
118
+ getHeapDataView: () => new DataView(new ArrayBuffer(0)),
119
+ call: (fn) => fn(),
120
+ isBroken: () => false,
121
+ },
122
+ };
123
+ return { deps, calls };
124
+ };
125
+
126
+ test("sqlite3_config passes each option to the shim for its arguments", () => {
127
+ const { deps, calls } = setupFakeShims();
128
+ const config = sqlite3_config(deps);
129
+
130
+ assertEqual(config(SQLITE_CONFIG_URI, 1), SQLITE_OK);
131
+ assertEqual(config(SQLITE_CONFIG_LOOKASIDE, 64, 10), SQLITE_OK);
132
+ assertEqual(config(SQLITE_CONFIG_MEMDB_MAXSIZE, 1024n), SQLITE_OK);
133
+
134
+ assertEqual(calls, [
135
+ ["sqlite3__wasm_config_i", SQLITE_CONFIG_URI, 1],
136
+ ["sqlite3__wasm_config_ii", SQLITE_CONFIG_LOOKASIDE, 64, 10],
137
+ ["sqlite3__wasm_config_j", SQLITE_CONFIG_MEMDB_MAXSIZE, 1024n],
138
+ ]);
139
+ });
140
+
141
+ test("sqlite3_config returns SQLITE_NOTFOUND for any other option without calling wasm", () => {
142
+ const { deps, calls } = setupFakeShims();
143
+
144
+ // @ts-expect-error SQLITE_CONFIG_GETMALLOC takes a pointer the shims do not pass.
145
+ const result = sqlite3_config(deps)(SQLITE_CONFIG_GETMALLOC, 1);
146
+
147
+ assertEqual(result, SQLITE_NOTFOUND);
148
+ assertEqual(calls, []);
149
+ });
150
+
151
+ test("sqlite3_db_config passes each option to the shim for its arguments, and pResult as NULL when omitted", () => {
152
+ const { deps, calls } = setupFakeShims();
153
+ const dbConfig = sqlite3_db_config(deps);
154
+ const zName = 24 as CStringPtr;
155
+ const buf = 32 as WasmPtr;
156
+ const pResult = 40 as WasmPtr;
157
+
158
+ assertEqual(dbConfig(db, SQLITE_DBCONFIG_MAINDBNAME, zName), SQLITE_OK);
159
+ assertEqual(dbConfig(db, SQLITE_DBCONFIG_LOOKASIDE, buf, 64, 10), SQLITE_OK);
160
+ assertEqual(dbConfig(db, SQLITE_DBCONFIG_ENABLE_FKEY, 1, pResult), SQLITE_OK);
161
+ assertEqual(dbConfig(db, SQLITE_DBCONFIG_FP_DIGITS, 5), SQLITE_OK);
162
+
163
+ assertEqual(calls, [
164
+ ["sqlite3__wasm_db_config_s", db, SQLITE_DBCONFIG_MAINDBNAME, zName],
165
+ ["sqlite3__wasm_db_config_pii", db, SQLITE_DBCONFIG_LOOKASIDE, buf, 64, 10],
166
+ ["sqlite3__wasm_db_config_ip", db, SQLITE_DBCONFIG_ENABLE_FKEY, 1, pResult],
167
+ ["sqlite3__wasm_db_config_ip", db, SQLITE_DBCONFIG_FP_DIGITS, 5, 0],
168
+ ]);
169
+ });
170
+
171
+ test("sqlite3_db_config returns SQLITE_MISUSE for any other option without calling wasm", () => {
172
+ const { deps, calls } = setupFakeShims();
173
+
174
+ // @ts-expect-error The value after SQLITE_DBCONFIG_MAX is not an option.
175
+ const result = sqlite3_db_config(deps)(db, SQLITE_DBCONFIG_MAX + 1, 0);
176
+
177
+ assertEqual(result, SQLITE_MISUSE);
178
+ assertEqual(calls, []);
179
+ });
180
+
181
+ test("every generated binding returns the export it names", async () => {
182
+ const exportsByName = new Map<string | symbol, () => void>();
183
+ const exports = new Proxy(
184
+ {},
185
+ {
186
+ get: (_, name) => {
187
+ const fake = exportsByName.get(name) ?? (() => undefined);
188
+ exportsByName.set(name, fake);
189
+ return fake;
190
+ },
191
+ },
192
+ ) as SqliteCExports;
193
+ const deps = { sqliteWasm: { exports } } as SqliteWasmDep;
194
+ // The variadic functions dispatch to shims, tested above, and
195
+ // sqlite3_vtab_config is its shim.
196
+ const exportNames: Readonly<Record<string, string | null>> = {
197
+ sqlite3_config: null,
198
+ sqlite3_db_config: null,
199
+ sqlite3_vtab_config: "sqlite3__wasm_vtab_config",
200
+ };
201
+ const capi = (await import("./CApi.ts")) as unknown as Readonly<
202
+ Record<string, unknown>
203
+ >;
204
+
205
+ let checked = 0;
206
+ for (const [name, binding] of Object.entries(capi)) {
207
+ if (typeof binding !== "function") continue;
208
+ const exportName = name in exportNames ? exportNames[name] : name;
209
+ if (exportName == null) continue;
210
+ assertSame(
211
+ (binding as (deps: SqliteWasmDep) => unknown)(deps),
212
+ exports[exportName as keyof SqliteCExports],
213
+ );
214
+ checked++;
215
+ }
216
+ assertTrue(checked > 154);
217
+ });