@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.
- package/LICENSE +21 -0
- package/README.md +55 -218
- package/dist/src/CApi.d.ts +2108 -0
- package/dist/src/CApi.d.ts.map +1 -0
- package/dist/src/CApi.js +1919 -0
- package/dist/src/Constants.d.ts +868 -0
- package/dist/src/Constants.d.ts.map +1 -0
- package/dist/src/Constants.js +602 -0
- package/dist/src/Database.d.ts +641 -0
- package/dist/src/Database.d.ts.map +1 -0
- package/dist/src/Database.js +1177 -0
- package/dist/src/Memory.d.ts +119 -0
- package/dist/src/Memory.d.ts.map +1 -0
- package/dist/src/Memory.js +207 -0
- package/dist/src/Pointer.d.ts +100 -0
- package/dist/src/Pointer.d.ts.map +1 -0
- package/dist/src/Pointer.js +15 -0
- package/dist/src/SahPool.d.ts +744 -0
- package/dist/src/SahPool.d.ts.map +1 -0
- package/dist/src/SahPool.js +1985 -0
- package/dist/src/Wasm.d.ts +315 -0
- package/dist/src/Wasm.d.ts.map +1 -0
- package/dist/src/Wasm.js +756 -0
- package/dist/src/WasmUrl.d.ts +21 -0
- package/dist/src/WasmUrl.d.ts.map +1 -0
- package/dist/src/WasmUrl.js +20 -0
- package/dist/src/c-api/index.d.ts +9 -0
- package/dist/src/c-api/index.d.ts.map +1 -0
- package/dist/src/c-api/index.js +8 -0
- package/dist/src/index.d.ts +15 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +13 -0
- package/dist/wasm/sqlite3.wasm +0 -0
- package/package.json +60 -60
- package/src/CApi.test.ts +217 -0
- package/src/CApi.ts +3294 -0
- package/src/Constants.ts +803 -0
- package/src/Database.ts +1714 -0
- package/src/Memory.test.ts +319 -0
- package/src/Memory.ts +237 -0
- package/src/Pointer.ts +121 -0
- package/src/SahPool.test.ts +180 -0
- package/src/SahPool.ts +2627 -0
- package/src/Wasm.test.ts +444 -0
- package/src/Wasm.ts +1026 -0
- package/src/WasmUrl.ts +26 -0
- package/src/c-api/index.ts +9 -0
- package/src/index.ts +15 -0
- package/bin/index.js +0 -110
- package/index.d.ts +0 -8118
- package/index.mjs +0 -7
- package/node.mjs +0 -3
- package/sqlite-wasm/jswasm/sqlite3-bundler-friendly.mjs +0 -13659
- package/sqlite-wasm/jswasm/sqlite3-node.mjs +0 -11671
- package/sqlite-wasm/jswasm/sqlite3-opfs-async-proxy.js +0 -691
- package/sqlite-wasm/jswasm/sqlite3-worker1-bundler-friendly.mjs +0 -35
- package/sqlite-wasm/jswasm/sqlite3-worker1-promiser.js +0 -193
- package/sqlite-wasm/jswasm/sqlite3-worker1-promiser.mjs +0 -187
- package/sqlite-wasm/jswasm/sqlite3-worker1.js +0 -46
- package/sqlite-wasm/jswasm/sqlite3.js +0 -13697
- package/sqlite-wasm/jswasm/sqlite3.mjs +0 -13661
- 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
|
+
);
|
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();
|