@powersync/web 0.0.0-dev-20251119142638 → 0.0.0-dev-20251120085122

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 (27) hide show
  1. package/dist/index.umd.js +21 -6
  2. package/dist/index.umd.js.map +1 -1
  3. package/dist/worker/SharedSyncImplementation.umd.js +14 -6
  4. package/dist/worker/SharedSyncImplementation.umd.js.map +1 -1
  5. package/dist/worker/WASQLiteDB.umd.js +28 -34
  6. package/dist/worker/WASQLiteDB.umd.js.map +1 -1
  7. package/lib/src/db/adapters/AsyncDatabaseConnection.d.ts +13 -0
  8. package/lib/src/db/adapters/WorkerWrappedAsyncDatabaseConnection.d.ts +1 -0
  9. package/lib/src/db/adapters/WorkerWrappedAsyncDatabaseConnection.js +7 -2
  10. package/lib/src/db/adapters/wa-sqlite/WASQLiteConnection.d.ts +5 -0
  11. package/lib/src/db/adapters/wa-sqlite/WASQLiteConnection.js +7 -0
  12. package/lib/src/worker/db/SharedWASQLiteConnection.d.ts +4 -3
  13. package/lib/src/worker/db/SharedWASQLiteConnection.js +17 -17
  14. package/lib/src/worker/db/WASQLiteDB.worker.js +2 -2
  15. package/lib/src/worker/db/WorkerWASQLiteConnection.d.ts +3 -3
  16. package/lib/src/worker/db/WorkerWASQLiteConnection.js +2 -14
  17. package/lib/src/worker/sync/SharedSyncImplementation.d.ts +2 -2
  18. package/lib/src/worker/sync/SharedSyncImplementation.js +7 -4
  19. package/lib/tsconfig.tsbuildinfo +1 -1
  20. package/package.json +1 -1
  21. package/src/db/adapters/AsyncDatabaseConnection.ts +13 -0
  22. package/src/db/adapters/WorkerWrappedAsyncDatabaseConnection.ts +8 -2
  23. package/src/db/adapters/wa-sqlite/WASQLiteConnection.ts +8 -0
  24. package/src/worker/db/SharedWASQLiteConnection.ts +23 -20
  25. package/src/worker/db/WASQLiteDB.worker.ts +2 -2
  26. package/src/worker/db/WorkerWASQLiteConnection.ts +3 -18
  27. package/src/worker/sync/SharedSyncImplementation.ts +15 -12
@@ -15947,6 +15947,13 @@ class WASqliteConnection extends _powersync_common__WEBPACK_IMPORTED_MODULE_1__.
15947
15947
  }
15948
15948
  return this._dbP;
15949
15949
  }
15950
+ /**
15951
+ * Checks if the database connection is in autocommit mode.
15952
+ * @returns true if in autocommit mode, false if in a transaction
15953
+ */
15954
+ async isAutoCommit() {
15955
+ return this.sqliteAPI.get_autocommit(this.dbP) != 0;
15956
+ }
15950
15957
  async markHold() {
15951
15958
  const previousHoldId = this._holdId;
15952
15959
  this._holdId = `${++this._holdCounter}`;
@@ -16238,6 +16245,18 @@ class SharedWASQLiteConnection {
16238
16245
  this.isClosing = false;
16239
16246
  this.activeHoldId = null;
16240
16247
  }
16248
+ get logger() {
16249
+ return this.options.logger;
16250
+ }
16251
+ get dbEntry() {
16252
+ return this.options.dbMap.get(this.options.dbFilename);
16253
+ }
16254
+ get connection() {
16255
+ return this.dbEntry.db;
16256
+ }
16257
+ get clientIds() {
16258
+ return this.dbEntry.clientIds;
16259
+ }
16241
16260
  async init() {
16242
16261
  // No-op since the connection is already initialized when it was created
16243
16262
  }
@@ -16253,17 +16272,8 @@ class SharedWASQLiteConnection {
16253
16272
  this.activeHoldId = null;
16254
16273
  }
16255
16274
  }
16256
- get logger() {
16257
- return this.options.logger;
16258
- }
16259
- get dbEntry() {
16260
- return this.options.dbMap.get(this.options.dbFilename);
16261
- }
16262
- get connection() {
16263
- return this.dbEntry.db;
16264
- }
16265
- get clientIds() {
16266
- return this.dbEntry.clientIds;
16275
+ async isAutoCommit() {
16276
+ return this.connection.isAutoCommit();
16267
16277
  }
16268
16278
  /**
16269
16279
  * Handles closing of a shared connection.
@@ -16277,12 +16287,9 @@ class SharedWASQLiteConnection {
16277
16287
  logger.debug(`Close requested from client ${clientId} of ${[...clientIds]}`);
16278
16288
  clientIds.delete(clientId);
16279
16289
  if (this.activeHoldId) {
16280
- /**
16281
- * The hold hasn't been released, but we're closing now.
16282
- * We can proactively cleanup and release the hold.
16283
- */
16284
- await this.connection.execute('ROLLBACK').catch(() => { });
16285
- await this.connection.releaseHold(this.activeHoldId).catch(() => { });
16290
+ // We can't cleanup here since we're not in a lock context.
16291
+ // The cleanup will occur once a new hold is acquired.
16292
+ this.logger.info(`Hold ${this.activeHoldId} was still active when the connection was closed. Cleanup will occur once a new hold is acquired.`);
16286
16293
  }
16287
16294
  if (clientIds.size == 0) {
16288
16295
  logger.debug(`Closing connection to ${this.options}.`);
@@ -16328,29 +16335,16 @@ class SharedWASQLiteConnection {
16328
16335
  "use strict";
16329
16336
  __webpack_require__.r(__webpack_exports__);
16330
16337
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
16331
- /* harmony export */ WorkerWASQLiteConnection: () => (/* binding */ WorkerWASQLiteConnection),
16332
- /* harmony export */ proxyWASQLiteConnection: () => (/* binding */ proxyWASQLiteConnection)
16338
+ /* harmony export */ WorkerWASQLiteConnection: () => (/* binding */ WorkerWASQLiteConnection)
16333
16339
  /* harmony export */ });
16334
16340
  /* harmony import */ var comlink__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! comlink */ "../../node_modules/comlink/dist/esm/comlink.mjs");
16335
16341
  /* harmony import */ var _db_adapters_wa_sqlite_WASQLiteConnection__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../db/adapters/wa-sqlite/WASQLiteConnection */ "./lib/src/db/adapters/wa-sqlite/WASQLiteConnection.js");
16336
16342
 
16337
16343
 
16338
16344
  /**
16339
- * Fully proxies a WASQLiteConnection to be used as an AsyncDatabaseConnection.
16345
+ * A Small proxy wrapper around the WASqliteConnection.
16346
+ * This ensures that certain return types are properly proxied.
16340
16347
  */
16341
- function proxyWASQLiteConnection(connection) {
16342
- return comlink__WEBPACK_IMPORTED_MODULE_1__.proxy({
16343
- init: comlink__WEBPACK_IMPORTED_MODULE_1__.proxy(() => connection.init()),
16344
- close: comlink__WEBPACK_IMPORTED_MODULE_1__.proxy(() => connection.close()),
16345
- markHold: comlink__WEBPACK_IMPORTED_MODULE_1__.proxy(() => connection.markHold()),
16346
- releaseHold: comlink__WEBPACK_IMPORTED_MODULE_1__.proxy((holdId) => connection.releaseHold(holdId)),
16347
- execute: comlink__WEBPACK_IMPORTED_MODULE_1__.proxy((sql, params) => connection.execute(sql, params)),
16348
- executeRaw: comlink__WEBPACK_IMPORTED_MODULE_1__.proxy((sql, params) => connection.executeRaw(sql, params)),
16349
- executeBatch: comlink__WEBPACK_IMPORTED_MODULE_1__.proxy((sql, params) => connection.executeBatch(sql, params)),
16350
- registerOnTableChange: comlink__WEBPACK_IMPORTED_MODULE_1__.proxy((callback) => connection.registerOnTableChange(callback)),
16351
- getConfig: comlink__WEBPACK_IMPORTED_MODULE_1__.proxy(() => connection.getConfig())
16352
- });
16353
- }
16354
16348
  class WorkerWASQLiteConnection extends _db_adapters_wa_sqlite_WASQLiteConnection__WEBPACK_IMPORTED_MODULE_0__.WASqliteConnection {
16355
16349
  async registerOnTableChange(callback) {
16356
16350
  // Proxy the callback remove function
@@ -16580,7 +16574,7 @@ const openDBShared = async (options) => {
16580
16574
  clientId,
16581
16575
  logger
16582
16576
  });
16583
- return (0,_WorkerWASQLiteConnection__WEBPACK_IMPORTED_MODULE_4__.proxyWASQLiteConnection)(sharedConnection);
16577
+ return comlink__WEBPACK_IMPORTED_MODULE_5__.proxy(sharedConnection);
16584
16578
  });
16585
16579
  };
16586
16580
  // Check if we're in a SharedWorker context