@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.
- package/dist/.tsbuildinfo +1 -1
- package/dist/FacadeVFS.d.ts +0 -3
- package/dist/FacadeVFS.d.ts.map +1 -1
- package/dist/FacadeVFS.js +0 -3
- package/dist/FacadeVFS.js.map +1 -1
- package/dist/browser/mod.d.ts.map +1 -1
- package/dist/browser/mod.js +3 -3
- package/dist/browser/mod.js.map +1 -1
- package/dist/browser/opfs/AccessHandlePoolVFS.d.ts +4 -4
- package/dist/browser/opfs/AccessHandlePoolVFS.d.ts.map +1 -1
- package/dist/browser/opfs/AccessHandlePoolVFS.js +79 -66
- package/dist/browser/opfs/AccessHandlePoolVFS.js.map +1 -1
- package/dist/browser/opfs/index.d.ts.map +1 -1
- package/dist/browser/opfs/index.js +2 -2
- package/dist/browser/opfs/index.js.map +1 -1
- package/dist/cf/CloudflareDurableObjectVFS.d.ts.map +1 -1
- package/dist/cf/CloudflareDurableObjectVFS.js +3 -1
- package/dist/cf/CloudflareDurableObjectVFS.js.map +1 -1
- package/dist/cf/test/async-storage/cloudflare-worker-vfs-advanced.test.js +1 -1
- package/dist/cf/test/async-storage/cloudflare-worker-vfs-advanced.test.js.map +1 -1
- package/dist/cf/test/async-storage/cloudflare-worker-vfs-core.test.js +1 -1
- package/dist/cf/test/async-storage/cloudflare-worker-vfs-core.test.js.map +1 -1
- package/dist/cf/test/async-storage/cloudflare-worker-vfs-integration.test.js +1 -1
- package/dist/cf/test/async-storage/cloudflare-worker-vfs-integration.test.js.map +1 -1
- package/dist/cf/test/async-storage/cloudflare-worker-vfs-reliability.test.js +1 -1
- package/dist/cf/test/async-storage/cloudflare-worker-vfs-reliability.test.js.map +1 -1
- package/dist/cf/test/sql/cloudflare-sql-vfs-core.test.js +1 -1
- package/dist/cf/test/sql/cloudflare-sql-vfs-core.test.js.map +1 -1
- package/dist/make-sqlite-db.d.ts.map +1 -1
- package/dist/make-sqlite-db.js +1 -1
- package/dist/make-sqlite-db.js.map +1 -1
- package/dist/node/NodeFS.js +1 -1
- package/dist/node/NodeFS.js.map +1 -1
- package/dist/node/mod.js +1 -1
- package/dist/node/mod.js.map +1 -1
- package/package.json +13 -22
- package/src/FacadeVFS.ts +0 -4
- package/src/browser/mod.ts +3 -3
- package/src/browser/opfs/AccessHandlePoolVFS.ts +91 -77
- package/src/browser/opfs/index.ts +2 -2
- package/src/cf/CloudflareDurableObjectVFS.ts +3 -4
- package/src/cf/test/README.md +8 -11
- package/src/cf/test/async-storage/cloudflare-worker-vfs-advanced.test.ts +2 -1
- package/src/cf/test/async-storage/cloudflare-worker-vfs-core.test.ts +2 -1
- package/src/cf/test/async-storage/cloudflare-worker-vfs-integration.test.ts +2 -1
- package/src/cf/test/async-storage/cloudflare-worker-vfs-reliability.test.ts +2 -1
- package/src/cf/test/sql/cloudflare-sql-vfs-core.test.ts +6 -3
- package/src/make-sqlite-db.ts +16 -21
- package/src/node/NodeFS.ts +1 -1
- package/src/node/mod.ts +1 -1
package/src/make-sqlite-db.ts
CHANGED
|
@@ -242,28 +242,23 @@ export const makeSqliteDb = <
|
|
|
242
242
|
},
|
|
243
243
|
apply: () => {
|
|
244
244
|
try {
|
|
245
|
-
sqlite3.changeset_apply(
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
(
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
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
|
-
//
|
|
261
|
+
// oxlint-disable-next-line eslint(no-param-reassign)
|
|
267
262
|
data = undefined
|
|
268
263
|
} catch (cause: any) {
|
|
269
264
|
throw new SqliteError({
|
package/src/node/NodeFS.ts
CHANGED
|
@@ -16,7 +16,7 @@ interface NodeFsFile {
|
|
|
16
16
|
|
|
17
17
|
export class NodeFS extends FacadeVFS {
|
|
18
18
|
private mapIdToFile = new Map<number, NodeFsFile>()
|
|
19
|
-
//
|
|
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