@livestore/wa-sqlite 1.0.1-dev.21 → 1.0.1-dev.22

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.21",
3
+ "version": "1.0.1-dev.22",
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
@@ -262,11 +262,13 @@ export function Factory(Module) {
262
262
  address = f(db, schema, piSize, SQLITE_SERIALIZE_NOCOPY);
263
263
  const size = Module.getValue(piSize, '*');
264
264
  const result = Module.HEAPU8.subarray(address, address + size);
265
+ // NOTE Given that the memory is owned by SQLite, we must copy it.
265
266
  return new Uint8Array(result.slice());
266
267
  } else {
267
268
  const size = Module.getValue(piSize, '*');
268
269
  const result = Module.HEAPU8.subarray(address, address + size);
269
- return result;
270
+ // Here we're getting a copy of the memory, so we can return it directly.
271
+ return new Uint8Array(result);
270
272
  }
271
273
  };
272
274
  })();