@powersync/web 2.2.0 → 2.3.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 (29) hide show
  1. package/README.md +1 -1
  2. package/dist/index.react_native_web.js +12 -29
  3. package/dist/index.react_native_web.js.map +1 -1
  4. package/dist/worker/worker.js +1 -1
  5. package/dist/worker/worker.js.map +1 -1
  6. package/lib/db/PowerSyncDatabase.d.ts +1 -2
  7. package/lib/db/PowerSyncDatabase.js +3 -13
  8. package/lib/db/PowerSyncDatabase.js.map +1 -1
  9. package/lib/db/sync/SSRWebStreamingSyncImplementation.d.ts +1 -8
  10. package/lib/db/sync/SSRWebStreamingSyncImplementation.js +3 -12
  11. package/lib/db/sync/SSRWebStreamingSyncImplementation.js.map +1 -1
  12. package/lib/db/sync/SharedWebStreamingSyncImplementation.d.ts +2 -1
  13. package/lib/db/sync/SharedWebStreamingSyncImplementation.js +6 -4
  14. package/lib/db/sync/SharedWebStreamingSyncImplementation.js.map +1 -1
  15. package/lib/worker/sync/AbstractSharedSyncClientProvider.d.ts +1 -0
  16. package/lib/worker/sync/AbstractSharedSyncClientProvider.js.map +1 -1
  17. package/lib/worker/sync/SharedSyncImplementation.d.ts +3 -11
  18. package/lib/worker/sync/SharedSyncImplementation.js +32 -64
  19. package/lib/worker/sync/SharedSyncImplementation.js.map +1 -1
  20. package/lib/worker/sync/WorkerClient.d.ts +1 -1
  21. package/lib/worker/sync/WorkerClient.js +3 -3
  22. package/lib/worker/sync/WorkerClient.js.map +1 -1
  23. package/package.json +5 -5
  24. package/src/db/PowerSyncDatabase.ts +2 -13
  25. package/src/db/sync/SSRWebStreamingSyncImplementation.ts +4 -14
  26. package/src/db/sync/SharedWebStreamingSyncImplementation.ts +8 -5
  27. package/src/worker/sync/AbstractSharedSyncClientProvider.ts +1 -0
  28. package/src/worker/sync/SharedSyncImplementation.ts +41 -76
  29. package/src/worker/sync/WorkerClient.ts +4 -4
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  # PowerSync SDK for Web
6
6
 
7
- _[PowerSync](https://www.powersync.com) is a sync engine for building local-first apps with instantly-responsive UI/UX and simplified state transfer. Syncs between SQLite on the client-side and Postgres, MongoDB, MySQL or SQL Server on the server-side._
7
+ _[PowerSync](https://www.powersync.com) keeps a client-side SQLite database in sync with your backend database. Changes appear across users and devices in real-time, user interactions feel instant and your app continues to work even when offline. Supports Postgres, MongoDB, MySQL, and SQL Server. Client SDKs are available for a wide range of environments including web, mobile, desktop, headless and embedded._
8
8
 
9
9
  This package (`packages/web`) is the PowerSync SDK for JavaScript Web clients. It is an extension of `packages/common`.
10
10
 
@@ -1,7 +1,7 @@
1
1
  import { DBAdapter, LockContext, LogLevels, queryResultWithoutRows, BaseObserver } from '@powersync/common';
2
2
  export * from '@powersync/common';
3
3
  import * as Comlink from 'comlink';
4
- import { Mutex, ConnectionClosedError, Semaphore, LockType, AbstractRemote, AbstractStreamingSyncImplementation, BasePowerSyncDatabase, openDatabase, SqliteBucketStorage } from '@powersync/shared-internals';
4
+ import { Mutex, ConnectionClosedError, Semaphore, LockType, AbstractRemote, AbstractStreamingSyncImplementation, BasePowerSyncDatabase, openDatabase } from '@powersync/shared-internals';
5
5
  import { Factory, SQLITE_ROW } from '@journeyapps/wa-sqlite';
6
6
 
7
7
  /**
@@ -1564,18 +1564,6 @@ class SSRStreamingSyncImplementation extends BaseObserver {
1564
1564
  waitUntilStatusMatches(_predicate) {
1565
1565
  return new Promise(() => { });
1566
1566
  }
1567
- /**
1568
- * Returns a placeholder checkpoint. This should not be used.
1569
- */
1570
- async getWriteCheckpoint() {
1571
- return '1';
1572
- }
1573
- /**
1574
- * The SSR mode adapter will never complete syncing.
1575
- */
1576
- async hasCompletedSync() {
1577
- return false;
1578
- }
1579
1567
  /**
1580
1568
  * This is a no-op in SSR mode.
1581
1569
  */
@@ -1588,6 +1576,9 @@ class SSRStreamingSyncImplementation extends BaseObserver {
1588
1576
  * No-op in SSR mode.
1589
1577
  */
1590
1578
  markConnectionMayHaveChanged() { }
1579
+ requestCheckpoint() {
1580
+ throw new Error('Sub sync implementation does not support request checkpoints');
1581
+ }
1591
1582
  }
1592
1583
 
1593
1584
  /**
@@ -1766,6 +1757,9 @@ class SharedSyncClientProvider extends AbstractSharedSyncClientProvider {
1766
1757
  */
1767
1758
  await this.options.uploadCrud();
1768
1759
  }
1760
+ async postCheckpointRequest(clientId, requestId) {
1761
+ return await this.options.postCheckpointRequest(clientId, requestId);
1762
+ }
1769
1763
  get logger() {
1770
1764
  return this.options.logger;
1771
1765
  }
@@ -1865,10 +1859,6 @@ class SharedWebStreamingSyncImplementation extends WebStreamingSyncImplementatio
1865
1859
  await this.waitForReady();
1866
1860
  return this.syncManager.disconnect();
1867
1861
  }
1868
- async getWriteCheckpoint() {
1869
- await this.waitForReady();
1870
- return this.syncManager.getWriteCheckpoint();
1871
- }
1872
1862
  async dispose() {
1873
1863
  await this.waitForReady();
1874
1864
  await new Promise((resolve) => {
@@ -1897,6 +1887,9 @@ class SharedWebStreamingSyncImplementation extends WebStreamingSyncImplementatio
1897
1887
  async waitForReady() {
1898
1888
  return this.isInitialized;
1899
1889
  }
1890
+ requestCheckpoint() {
1891
+ return this.syncManager.requestCheckpoint();
1892
+ }
1900
1893
  updateSubscriptions(subscriptions) {
1901
1894
  this.syncManager.updateSubscriptions(subscriptions);
1902
1895
  }
@@ -2040,9 +2033,6 @@ class WebPowerSyncDatabase extends BasePowerSyncDatabase {
2040
2033
  }
2041
2034
  return super.resolveOfflineSyncStatus();
2042
2035
  }
2043
- generateBucketStorageAdapter() {
2044
- return new SqliteBucketStorage(this.database, this.logger);
2045
- }
2046
2036
  async runExclusive(cb) {
2047
2037
  if (this.resolvedOpenOptions.ssrMode) {
2048
2038
  return WebPowerSyncDatabase.SHARED_MUTEX.runExclusive(cb);
@@ -2053,15 +2043,8 @@ class WebPowerSyncDatabase extends BasePowerSyncDatabase {
2053
2043
  const remote = new WebRemote(connector, this.logger);
2054
2044
  const syncOptions = {
2055
2045
  ...this.options,
2056
- ...options,
2057
- adapter: this.bucketStorageAdapter,
2058
- remote,
2059
- uploadCrud: async () => {
2060
- await this.waitForReady();
2061
- await connector.uploadData(this);
2062
- },
2063
- identifier: this.database.name,
2064
- logger: this.logger
2046
+ ...this.commonSyncOptions(connector, options),
2047
+ remote
2065
2048
  };
2066
2049
  if (this.resolvedOpenOptions.ssrMode) {
2067
2050
  return new SSRStreamingSyncImplementation();