@powersync/web 1.35.0 → 1.36.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powersync/web",
3
- "version": "1.35.0",
3
+ "version": "1.36.0",
4
4
  "description": "PowerSync Web SDK",
5
5
  "main": "lib/src/index.js",
6
6
  "module": "lib/src/index.js",
@@ -56,14 +56,14 @@
56
56
  "license": "Apache-2.0",
57
57
  "peerDependencies": {
58
58
  "@journeyapps/wa-sqlite": "^1.5.0",
59
- "@powersync/common": "^1.48.0"
59
+ "@powersync/common": "^1.49.0"
60
60
  },
61
61
  "dependencies": {
62
62
  "async-mutex": "^0.5.0",
63
63
  "bson": "^6.10.4",
64
64
  "comlink": "^4.4.2",
65
65
  "commander": "^12.1.0",
66
- "@powersync/common": "1.48.0"
66
+ "@powersync/common": "1.49.0"
67
67
  },
68
68
  "devDependencies": {
69
69
  "@journeyapps/wa-sqlite": "^1.5.0",
@@ -7,6 +7,7 @@ import {
7
7
  DBLockOptions,
8
8
  LockContext,
9
9
  QueryResult,
10
+ SqlExecutor,
10
11
  Transaction,
11
12
  createLogger,
12
13
  type ILogger
@@ -90,7 +91,8 @@ export class LockedAsyncDatabaseAdapter
90
91
 
91
92
  this.dbGetHelpers = this.generateDBHelpers({
92
93
  execute: (query, params) => this.acquireLock(() => this._execute(query, params)),
93
- executeRaw: (query, params) => this.acquireLock(() => this._executeRaw(query, params))
94
+ executeRaw: (query, params) => this.acquireLock(() => this._executeRaw(query, params)),
95
+ executeBatch: (query, params) => this.acquireLock(() => this._executeBatch(query, params))
94
96
  });
95
97
  this.initPromise = this._init();
96
98
  }
@@ -269,19 +271,21 @@ export class LockedAsyncDatabaseAdapter
269
271
  }
270
272
 
271
273
  async readLock<T>(fn: (tx: LockContext) => Promise<T>, options?: DBLockOptions | undefined): Promise<T> {
272
- await this.waitForInitialized();
273
- return this.acquireLock(
274
- async () => fn(this.generateDBHelpers({ execute: this._execute, executeRaw: this._executeRaw })),
275
- {
276
- timeoutMs: options?.timeoutMs ?? this.options.defaultLockTimeoutMs
277
- }
278
- );
274
+ // Read and write locks are the same because we only have one underlying connection.
275
+ return this.writeLock(fn, options);
279
276
  }
280
277
 
281
278
  async writeLock<T>(fn: (tx: LockContext) => Promise<T>, options?: DBLockOptions | undefined): Promise<T> {
282
279
  await this.waitForInitialized();
283
280
  return this.acquireLock(
284
- async () => fn(this.generateDBHelpers({ execute: this._execute, executeRaw: this._executeRaw })),
281
+ async () =>
282
+ fn(
283
+ this.generateDBHelpers({
284
+ execute: this._execute,
285
+ executeRaw: this._executeRaw,
286
+ executeBatch: this._executeBatch
287
+ })
288
+ ),
285
289
  {
286
290
  timeoutMs: options?.timeoutMs ?? this.options.defaultLockTimeoutMs
287
291
  }
@@ -370,12 +374,7 @@ export class LockedAsyncDatabaseAdapter
370
374
  return this.writeLock(this.wrapTransaction(fn, true));
371
375
  }
372
376
 
373
- private generateDBHelpers<
374
- T extends {
375
- execute: (sql: string, params?: any[]) => Promise<QueryResult>;
376
- executeRaw: (sql: string, params?: any[]) => Promise<any[][]>;
377
- }
378
- >(tx: T): T & DBGetUtils {
377
+ private generateDBHelpers<T extends SqlExecutor>(tx: T): T & LockContext {
379
378
  return {
380
379
  ...tx,
381
380
  /**