@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
package/src/WasmUrl.ts ADDED
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Where the package's wasm binary is.
3
+ *
4
+ * @module
5
+ */
6
+
7
+ import type { createSqliteWasm } from "./Wasm.ts";
8
+
9
+ /**
10
+ * The URL of the wasm binary the package ships, to load with
11
+ * {@link createSqliteWasm}.
12
+ *
13
+ * It is `new URL("../wasm/sqlite3.wasm", import.meta.url)`, which Vite,
14
+ * webpack, Next.js and other bundlers recognize: they emit the binary with the
15
+ * app and give the URL of their copy. In the published package, the binary is
16
+ * `dist/wasm/sqlite3.wasm`, beside the compiled modules in `dist/src`.
17
+ *
18
+ * Vite does not process the URL in a dependency it prebundles, so add
19
+ * `@evolu/sqlite-wasm` to `optimizeDeps.exclude`. Vite emits the binary
20
+ * whenever the app imports `@evolu/sqlite-wasm`, even without this URL, and
21
+ * webpack only when the app uses it.
22
+ */
23
+ export const sqliteWasmUrl: URL = /*#__PURE__*/ new URL(
24
+ "../wasm/sqlite3.wasm",
25
+ import.meta.url,
26
+ );
@@ -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
+
8
+ export * from "../CApi.ts";
9
+ export * from "../Constants.ts";
package/src/index.ts ADDED
@@ -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
+
9
+ export type { SqlitePrimaryResultCode, SqliteResultCode } from "./Constants.ts";
10
+ export * from "./Database.ts";
11
+ export * from "./Memory.ts";
12
+ export * from "./Pointer.ts";
13
+ export * from "./SahPool.ts";
14
+ export * from "./Wasm.ts";
15
+ export * from "./WasmUrl.ts";
package/bin/index.js DELETED
@@ -1,110 +0,0 @@
1
- #!/usr/bin/env node
2
- import fs from 'fs';
3
- import fetch from 'node-fetch';
4
- import decompress from 'decompress';
5
-
6
- async function getSqliteWasmDownloadLink(version = null) {
7
- const response = await fetch(
8
- 'https://api.github.com/repos/utelle/SQLite3MultipleCiphers/releases',
9
- );
10
- const releases = await response.json();
11
- if (!releases || releases.length === 0) {
12
- throw new Error(
13
- 'No releases found for SQLite3MultipleCiphers repository (likely a network error).',
14
- );
15
- }
16
-
17
- let tagName;
18
- let release;
19
-
20
- if (version) {
21
- release = releases.find(
22
- (release) =>
23
- release.tag_name === `v${version}` || release.tag_name === version,
24
- );
25
- if (!release) {
26
- const availableVersions = releases
27
- .slice(0, 5)
28
- .map((r) => r.tag_name)
29
- .join(', ');
30
- throw new Error(
31
- `Version ${version} not found. Available versions (latest 5): ${availableVersions}`,
32
- );
33
- }
34
- tagName = release.tag_name.replace('v', '');
35
- console.log(`Using specified version: ${tagName}`);
36
- } else {
37
- release = releases[0];
38
- tagName = release.tag_name.replace('v', '');
39
- console.log(`Using latest version: ${tagName}`);
40
- }
41
-
42
- const asset = release?.assets?.find((asset) =>
43
- asset.browser_download_url.endsWith('wasm.zip'),
44
- );
45
-
46
- if (!asset) {
47
- throw new Error(
48
- `Unable to find SQLite Wasm download link in release ${tagName}`,
49
- );
50
- }
51
-
52
- await updatePackageVersion(tagName);
53
- return asset.browser_download_url;
54
- }
55
-
56
- async function downloadAndUnzipSqliteWasm(wasmLink) {
57
- if (!wasmLink) {
58
- throw new Error('Unable to find SQLite Wasm download link');
59
- }
60
- console.log('Downloading and unzipping SQLite Wasm...');
61
- const response = await fetch(wasmLink);
62
- if (!response.ok || response.status !== 200) {
63
- throw new Error(`Unable to download SQLite Wasm from ${wasmLink}`);
64
- }
65
- const buffer = await response.arrayBuffer();
66
- fs.writeFileSync('sqlite-wasm.zip', Buffer.from(buffer));
67
- const files = await decompress('sqlite-wasm.zip', 'sqlite-wasm', {
68
- strip: 1,
69
- filter: (file) =>
70
- /jswasm/.test(file.path) && /(\.mjs|\.wasm|\.js)$/.test(file.path),
71
- });
72
- console.log(
73
- `Downloaded and unzipped:\n${files
74
- .map((file) => (/\//.test(file.path) ? '‣ ' + file.path + '\n' : ''))
75
- .join('')}`,
76
- );
77
- fs.rmSync('sqlite-wasm.zip');
78
- }
79
-
80
- async function updatePackageVersion(tagName) {
81
- try {
82
- const pkgPath = './package.json';
83
- const pkgJson = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
84
- pkgJson.version = tagName;
85
- fs.writeFileSync(pkgPath, JSON.stringify(pkgJson, null, 2) + '\n');
86
- console.log(`Updated package.json version to: ${tagName}`);
87
- } catch (err) {
88
- console.error('Failed to update package.json:', err.message);
89
- throw err;
90
- }
91
- }
92
-
93
- async function main() {
94
- try {
95
- const args = process.argv.slice(2);
96
- const index = args.indexOf('--version');
97
- const version =
98
- index !== -1 && index + 1 < args.length ? args[index + 1] : null;
99
- const wasmLink = await getSqliteWasmDownloadLink(version);
100
- await downloadAndUnzipSqliteWasm(wasmLink);
101
- fs.copyFileSync(
102
- './node_modules/module-workers-polyfill/module-workers-polyfill.min.js',
103
- './demo/module-workers-polyfill.min.js',
104
- );
105
- } catch (err) {
106
- console.error(err.name, err.message);
107
- }
108
- }
109
-
110
- main();