@livestore/wa-sqlite 1.0.1-dev.4 → 1.0.1-dev.6
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/package.json +1 -1
- package/src/sqlite-api.js +13 -0
- package/src/types/index.d.ts +23 -4
package/package.json
CHANGED
package/src/sqlite-api.js
CHANGED
|
@@ -249,6 +249,19 @@ export function Factory(Module) {
|
|
|
249
249
|
};
|
|
250
250
|
})();
|
|
251
251
|
|
|
252
|
+
sqlite3.serialize = (function() {
|
|
253
|
+
const fname = 'sqlite3_serialize';
|
|
254
|
+
const f = Module.cwrap(fname, ...decl('nsnn:n'));
|
|
255
|
+
return function(db, schema, piSize, flags) {
|
|
256
|
+
verifyDatabase(db);
|
|
257
|
+
// TODO alloc + free memory for result?
|
|
258
|
+
const address = f(db, schema, piSize, flags);
|
|
259
|
+
const result = Module.HEAPU8.subarray(address, address + piSize);
|
|
260
|
+
|
|
261
|
+
return result;
|
|
262
|
+
};
|
|
263
|
+
})();
|
|
264
|
+
|
|
252
265
|
sqlite3.clear_bindings = (function() {
|
|
253
266
|
const fname = 'sqlite3_clear_bindings';
|
|
254
267
|
const f = Module.cwrap(fname, ...decl('n:n'));
|
package/src/types/index.d.ts
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* each element converted to a byte); SQLite always returns blob data as
|
|
16
16
|
* `Uint8Array`
|
|
17
17
|
*/
|
|
18
|
-
|
|
18
|
+
type SQLiteCompatibleType = number|string|Uint8Array|Array<number>|bigint|null;
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* SQLite Virtual File System object
|
|
@@ -33,7 +33,7 @@ export type SQLiteCompatibleType = number|string|Uint8Array|Array<number>|bigint
|
|
|
33
33
|
* @see https://sqlite.org/vfs.html
|
|
34
34
|
* @see https://sqlite.org/c3ref/io_methods.html
|
|
35
35
|
*/
|
|
36
|
-
|
|
36
|
+
interface SQLiteVFS {
|
|
37
37
|
/** Maximum length of a file path in UTF-8 bytes (default 64) */
|
|
38
38
|
mxPathName?: number;
|
|
39
39
|
|
|
@@ -178,7 +178,7 @@ declare interface SQLitePrepareOptions {
|
|
|
178
178
|
*
|
|
179
179
|
* @see https://sqlite.org/c3ref/funclist.html
|
|
180
180
|
*/
|
|
181
|
-
|
|
181
|
+
interface SQLiteAPI {
|
|
182
182
|
/**
|
|
183
183
|
* Bind a collection of values to a statement
|
|
184
184
|
*
|
|
@@ -341,7 +341,6 @@ export interface SQLiteAPI {
|
|
|
341
341
|
* unsigned mFlags Zero or more SQLITE_DESERIALIZE_* flags
|
|
342
342
|
* );
|
|
343
343
|
*/
|
|
344
|
-
|
|
345
344
|
deserialize(
|
|
346
345
|
db: number,
|
|
347
346
|
zSchema: string,
|
|
@@ -351,6 +350,21 @@ export interface SQLiteAPI {
|
|
|
351
350
|
mFlags: number
|
|
352
351
|
): number;
|
|
353
352
|
|
|
353
|
+
/**
|
|
354
|
+
* unsigned char *sqlite3_serialize(
|
|
355
|
+
* sqlite3 *db, The database connection
|
|
356
|
+
* const char *zSchema, Which DB to serialize. ex: "main", "temp", ...
|
|
357
|
+
* sqlite3_int64 *piSize, Write size of the DB here, if not NULL
|
|
358
|
+
* unsigned int mFlags Zero or more SQLITE_SERIALIZE_* flags
|
|
359
|
+
* );
|
|
360
|
+
*/
|
|
361
|
+
serialize(
|
|
362
|
+
db: number,
|
|
363
|
+
zSchema: string,
|
|
364
|
+
piSize: number,
|
|
365
|
+
mFlags: number
|
|
366
|
+
): Uint8Array;
|
|
367
|
+
|
|
354
368
|
/**
|
|
355
369
|
* Reset all bindings on a prepared statement.
|
|
356
370
|
* @see https://www.sqlite.org/c3ref/clear_bindings.html
|
|
@@ -843,6 +857,11 @@ export interface SQLiteAPI {
|
|
|
843
857
|
vfs_register(vfs: SQLiteVFS, makeDefault?: boolean): number;
|
|
844
858
|
}
|
|
845
859
|
|
|
860
|
+
declare module '@livestore/wa-sqlite' {
|
|
861
|
+
export type SQLiteAPI_ = SQLiteAPI;
|
|
862
|
+
export type SQLiteVFS_ = SQLiteVFS;
|
|
863
|
+
}
|
|
864
|
+
|
|
846
865
|
/** @ignore */
|
|
847
866
|
declare module '@livestore/wa-sqlite/src/sqlite-constants.js' {
|
|
848
867
|
export const SQLITE_OK: 0;
|