@livestore/wa-sqlite 1.0.3-dev.3 → 1.0.3-dev.5

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.3-dev.3",
3
+ "version": "1.0.3-dev.5",
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
@@ -343,8 +343,11 @@ export function Factory(Module) {
343
343
  verifyStatement(stmt);
344
344
  const nBytes = sqlite3.column_bytes(stmt, iCol);
345
345
  const address = f(stmt, iCol);
346
+ if (address === 0) {
347
+ return null; // Handle NULL BLOBs
348
+ }
346
349
  const result = Module.HEAPU8.subarray(address, address + nBytes);
347
- return result;
350
+ return new Uint8Array(result); // Ensure a copy is returned
348
351
  };
349
352
  })();
350
353
 
@@ -940,7 +943,11 @@ export function Factory(Module) {
940
943
 
941
944
  // Ensure the pointer is valid before accessing memory
942
945
  if (changesetPtr === 0) {
943
- throw new SQLiteError('Failed to retrieve changeset pointer', SQLite.SQLITE_ERROR);
946
+ return {
947
+ result: result,
948
+ size: 0,
949
+ changeset: null
950
+ }
944
951
  }
945
952
 
946
953
  // Copy the changeset data