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

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.16",
3
+ "version": "1.0.1-dev.18",
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
@@ -249,19 +249,37 @@ export function Factory(Module) {
249
249
  };
250
250
  })();
251
251
 
252
+ const SQLITE_SERIALIZE_NOCOPY = 0x0_01
253
+
252
254
  sqlite3.serialize = (function() {
253
255
  const fname = 'sqlite3_serialize';
254
256
  const f = Module.cwrap(fname, ...decl('nsnn:n'));
255
- return function(db, schema, flags) {
257
+ return function(db, schema) {
256
258
  verifyDatabase(db);
257
259
  const piSize = tmpPtr[0];
258
- const address = f(db, schema, piSize, flags);
260
+ let address = f(db, schema, piSize, 0);
261
+ if (address === 0) {
262
+ address = f(db, schema, piSize, SQLITE_SERIALIZE_NOCOPY);
263
+ }
259
264
  const size = Module.getValue(piSize, '*');
260
265
  const result = Module.HEAPU8.subarray(address, address + size);
261
266
  return result;
262
267
  };
263
268
  })();
264
269
 
270
+ // sqlite3.serialize = (function() {
271
+ // const fname = 'sqlite3_serialize';
272
+ // const f = Module.cwrap(fname, ...decl('nsnn:n'));
273
+ // return function(db, schema, flags) {
274
+ // verifyDatabase(db);
275
+ // const piSize = tmpPtr[0];
276
+ // const address = f(db, schema, piSize, flags);
277
+ // const size = Module.getValue(piSize, '*');
278
+ // const result = Module.HEAPU8.subarray(address, address + size);
279
+ // return result;
280
+ // };
281
+ // })();
282
+
265
283
  sqlite3.clear_bindings = (function() {
266
284
  const fname = 'sqlite3_clear_bindings';
267
285
  const f = Module.cwrap(fname, ...decl('n:n'));
@@ -361,7 +361,7 @@ interface SQLiteAPI {
361
361
  serialize(
362
362
  db: number,
363
363
  zSchema: string,
364
- mFlags: number
364
+ // mFlags: number
365
365
  ): Uint8Array;
366
366
 
367
367
  /**
@@ -1255,6 +1255,7 @@ declare module '@livestore/wa-sqlite/src/examples/AccessHandlePoolVFS.js' {
1255
1255
  import * as VFS from "@livestore/wa-sqlite/src/VFS.js";
1256
1256
  export class AccessHandlePoolVFS extends VFS.Base {
1257
1257
  constructor(name: string, module: any)
1258
+ static create(name: string, module: any): Promise<AccessHandlePoolVFS>;
1258
1259
  }
1259
1260
  }
1260
1261