@livestore/sqlite-wasm 0.4.0 → 0.5.0-dev.0

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.
Files changed (50) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/FacadeVFS.d.ts +0 -3
  3. package/dist/FacadeVFS.d.ts.map +1 -1
  4. package/dist/FacadeVFS.js +0 -3
  5. package/dist/FacadeVFS.js.map +1 -1
  6. package/dist/browser/mod.d.ts.map +1 -1
  7. package/dist/browser/mod.js +3 -3
  8. package/dist/browser/mod.js.map +1 -1
  9. package/dist/browser/opfs/AccessHandlePoolVFS.d.ts +4 -4
  10. package/dist/browser/opfs/AccessHandlePoolVFS.d.ts.map +1 -1
  11. package/dist/browser/opfs/AccessHandlePoolVFS.js +79 -66
  12. package/dist/browser/opfs/AccessHandlePoolVFS.js.map +1 -1
  13. package/dist/browser/opfs/index.d.ts.map +1 -1
  14. package/dist/browser/opfs/index.js +2 -2
  15. package/dist/browser/opfs/index.js.map +1 -1
  16. package/dist/cf/CloudflareDurableObjectVFS.d.ts.map +1 -1
  17. package/dist/cf/CloudflareDurableObjectVFS.js +3 -1
  18. package/dist/cf/CloudflareDurableObjectVFS.js.map +1 -1
  19. package/dist/cf/test/async-storage/cloudflare-worker-vfs-advanced.test.js +1 -1
  20. package/dist/cf/test/async-storage/cloudflare-worker-vfs-advanced.test.js.map +1 -1
  21. package/dist/cf/test/async-storage/cloudflare-worker-vfs-core.test.js +1 -1
  22. package/dist/cf/test/async-storage/cloudflare-worker-vfs-core.test.js.map +1 -1
  23. package/dist/cf/test/async-storage/cloudflare-worker-vfs-integration.test.js +1 -1
  24. package/dist/cf/test/async-storage/cloudflare-worker-vfs-integration.test.js.map +1 -1
  25. package/dist/cf/test/async-storage/cloudflare-worker-vfs-reliability.test.js +1 -1
  26. package/dist/cf/test/async-storage/cloudflare-worker-vfs-reliability.test.js.map +1 -1
  27. package/dist/cf/test/sql/cloudflare-sql-vfs-core.test.js +1 -1
  28. package/dist/cf/test/sql/cloudflare-sql-vfs-core.test.js.map +1 -1
  29. package/dist/make-sqlite-db.d.ts.map +1 -1
  30. package/dist/make-sqlite-db.js +1 -1
  31. package/dist/make-sqlite-db.js.map +1 -1
  32. package/dist/node/NodeFS.js +1 -1
  33. package/dist/node/NodeFS.js.map +1 -1
  34. package/dist/node/mod.js +1 -1
  35. package/dist/node/mod.js.map +1 -1
  36. package/package.json +13 -22
  37. package/src/FacadeVFS.ts +0 -4
  38. package/src/browser/mod.ts +3 -3
  39. package/src/browser/opfs/AccessHandlePoolVFS.ts +91 -77
  40. package/src/browser/opfs/index.ts +2 -2
  41. package/src/cf/CloudflareDurableObjectVFS.ts +3 -4
  42. package/src/cf/test/README.md +8 -11
  43. package/src/cf/test/async-storage/cloudflare-worker-vfs-advanced.test.ts +2 -1
  44. package/src/cf/test/async-storage/cloudflare-worker-vfs-core.test.ts +2 -1
  45. package/src/cf/test/async-storage/cloudflare-worker-vfs-integration.test.ts +2 -1
  46. package/src/cf/test/async-storage/cloudflare-worker-vfs-reliability.test.ts +2 -1
  47. package/src/cf/test/sql/cloudflare-sql-vfs-core.test.ts +6 -3
  48. package/src/make-sqlite-db.ts +16 -21
  49. package/src/node/NodeFS.ts +1 -1
  50. package/src/node/mod.ts +1 -1
@@ -242,28 +242,23 @@ export const makeSqliteDb = <
242
242
  },
243
243
  apply: () => {
244
244
  try {
245
- sqlite3.changeset_apply(
246
- dbPointer,
247
- data,
248
- null,
249
- (eConflict) => {
250
- // During rollback we apply inverted changesets to undo local events
251
- // before replaying them on top of remote state. We want the undo to
252
- // succeed unconditionally: if the row was already changed by another
253
- // tab (DATA) or reinserted (CONFLICT), force-overwrite it. For
254
- // NOTFOUND, CONSTRAINT, and FOREIGN_KEY the row is already gone or
255
- // can't be replaced, so we skip.
256
- if (
257
- eConflict === SqliteConstants.SQLITE_CHANGESET_DATA ||
258
- eConflict === SqliteConstants.SQLITE_CHANGESET_CONFLICT
259
- ) {
260
- return SqliteConstants.SQLITE_CHANGESET_REPLACE
261
- }
262
- return SqliteConstants.SQLITE_CHANGESET_OMIT
263
- },
264
- )
245
+ sqlite3.changeset_apply(dbPointer, data, null, (eConflict) => {
246
+ // During rollback we apply inverted changesets to undo local events
247
+ // before replaying them on top of remote state. We want the undo to
248
+ // succeed unconditionally: if the row was already changed by another
249
+ // tab (DATA) or reinserted (CONFLICT), force-overwrite it. For
250
+ // NOTFOUND, CONSTRAINT, and FOREIGN_KEY the row is already gone or
251
+ // can't be replaced, so we skip.
252
+ if (
253
+ eConflict === SqliteConstants.SQLITE_CHANGESET_DATA ||
254
+ eConflict === SqliteConstants.SQLITE_CHANGESET_CONFLICT
255
+ ) {
256
+ return SqliteConstants.SQLITE_CHANGESET_REPLACE
257
+ }
258
+ return SqliteConstants.SQLITE_CHANGESET_OMIT
259
+ })
265
260
  // @ts-expect-error data should be garbage collected after use
266
- // biome-ignore lint/style/noParameterAssign: ...
261
+ // oxlint-disable-next-line eslint(no-param-reassign)
267
262
  data = undefined
268
263
  } catch (cause: any) {
269
264
  throw new SqliteError({
@@ -16,7 +16,7 @@ interface NodeFsFile {
16
16
 
17
17
  export class NodeFS extends FacadeVFS {
18
18
  private mapIdToFile = new Map<number, NodeFsFile>()
19
- // biome-ignore lint/correctness/noUnusedPrivateClassMembers: for debugging
19
+ // For debugging.
20
20
  private lastError: Error | null = null
21
21
  private readonly directory: string
22
22
  constructor(name: string, sqlite3: WaSqlite.SQLiteAPI, directory: string) {
package/src/node/mod.ts CHANGED
@@ -54,7 +54,7 @@ export const sqliteDbFactory = ({
54
54
  }: {
55
55
  sqlite3: SQLiteAPI
56
56
  }): Effect.Effect<MakeNodeSqliteDb, never, FileSystem.FileSystem> =>
57
- Effect.andThen(
57
+ Effect.map(
58
58
  FileSystem.FileSystem,
59
59
  (fs) => (input) =>
60
60
  Effect.gen(function* () {