@livestore/wa-sqlite 1.0.1-dev.18 → 1.0.1-dev.19

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@livestore/wa-sqlite",
3
- "version": "1.0.1-dev.18",
3
+ "version": "1.0.1-dev.19",
4
4
  "type": "module",
5
5
  "main": "src/sqlite-api.js",
6
6
  "types": "src/types/index.d.ts",
package/src/sqlite-api.js CHANGED
@@ -280,6 +280,22 @@ export function Factory(Module) {
280
280
  // };
281
281
  // })();
282
282
 
283
+ sqlite3.backup = (function() {
284
+ const fInit = Module.cwrap('sqlite3_backup_init', ...decl('nsns:n'));
285
+ const fStep = Module.cwrap('sqlite3_backup_step', ...decl('nn:n'));
286
+ const fFinish = Module.cwrap('sqlite3_backup_finish', ...decl('n:n'));
287
+ return function(dest, destName, source, sourceName) {
288
+ verifyDatabase(dest);
289
+ verifyDatabase(source);
290
+ const backup = fInit(dest, destName, source, sourceName);
291
+ if (backup === 0) {
292
+ throw new SQLiteError('backup failed', SQLite.SQLITE_ERROR);
293
+ }
294
+ fStep(backup, -1);
295
+ return fFinish(backup);
296
+ };
297
+ })();
298
+
283
299
  sqlite3.clear_bindings = (function() {
284
300
  const fname = 'sqlite3_clear_bindings';
285
301
  const f = Module.cwrap(fname, ...decl('n:n'));
@@ -364,6 +364,35 @@ interface SQLiteAPI {
364
364
  // mFlags: number
365
365
  ): Uint8Array;
366
366
 
367
+ // sqlite3_backup *sqlite3_backup_init(
368
+ // sqlite3 *pDest, /* Destination database handle */
369
+ // const char *zDestName, /* Destination database name */
370
+ // sqlite3 *pSource, /* Source database handle */
371
+ // const char *zSourceName /* Source database name */
372
+ // );
373
+ // int sqlite3_backup_step(sqlite3_backup *p, int nPage);
374
+ // int sqlite3_backup_finish(sqlite3_backup *p);
375
+ // int sqlite3_backup_remaining(sqlite3_backup *p);
376
+ // int sqlite3_backup_pagecount(sqlite3_backup *p);
377
+
378
+ backup_init(
379
+ pDest: number,
380
+ zDestName: string,
381
+ pSource: number,
382
+ zSourceName: string
383
+ ): number;
384
+
385
+ backup_step(p: number, nPage: number): number;
386
+ backup_finish(p: number): number;
387
+ backup_remaining(p: number): number;
388
+ backup_pagecount(p: number): number;
389
+
390
+ /**
391
+ * Combines the `backup_init`, `backup_step`, and `backup_finish` functions.
392
+ * @returns `SQLITE_OK` (throws exception on error)
393
+ */
394
+ backup(pDest: number, zDestName: string, pSource: number, zSourceName: string): number;
395
+
367
396
  /**
368
397
  * Reset all bindings on a prepared statement.
369
398
  * @see https://www.sqlite.org/c3ref/clear_bindings.html
@@ -1251,6 +1280,12 @@ declare module '@livestore/wa-sqlite/src/VFS.js' {
1251
1280
  }
1252
1281
  }
1253
1282
 
1283
+ /** @ignore */
1284
+ declare module '@livestore/wa-sqlite/src/FacadeVFS.js' {
1285
+ export type FacadeVFS = any
1286
+ }
1287
+
1288
+
1254
1289
  declare module '@livestore/wa-sqlite/src/examples/AccessHandlePoolVFS.js' {
1255
1290
  import * as VFS from "@livestore/wa-sqlite/src/VFS.js";
1256
1291
  export class AccessHandlePoolVFS extends VFS.Base {