@powersync/common 1.37.0 → 1.38.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.
@@ -223,11 +223,11 @@ export class AbstractPowerSyncDatabase extends BaseObserver {
223
223
  .map((n) => parseInt(n));
224
224
  }
225
225
  catch (e) {
226
- throw new Error(`Unsupported powersync extension version. Need >=0.3.11 <1.0.0, got: ${this.sdkVersion}. Details: ${e.message}`);
226
+ throw new Error(`Unsupported powersync extension version. Need >=0.4.5 <1.0.0, got: ${this.sdkVersion}. Details: ${e.message}`);
227
227
  }
228
- // Validate >=0.3.11 <1.0.0
229
- if (versionInts[0] != 0 || versionInts[1] < 3 || (versionInts[1] == 3 && versionInts[2] < 11)) {
230
- throw new Error(`Unsupported powersync extension version. Need >=0.3.11 <1.0.0, got: ${this.sdkVersion}`);
228
+ // Validate >=0.4.5 <1.0.0
229
+ if (versionInts[0] != 0 || versionInts[1] < 4 || (versionInts[1] == 4 && versionInts[2] < 5)) {
230
+ throw new Error(`Unsupported powersync extension version. Need >=0.4.5 <1.0.0, got: ${this.sdkVersion}`);
231
231
  }
232
232
  }
233
233
  async updateHasSynced() {
@@ -439,7 +439,9 @@ The next upload iteration will be delayed.`);
439
439
  ...DEFAULT_STREAM_CONNECTION_OPTIONS,
440
440
  ...(options ?? {})
441
441
  };
442
- if (resolvedOptions.clientImplementation == SyncClientImplementation.JAVASCRIPT) {
442
+ const clientImplementation = resolvedOptions.clientImplementation;
443
+ this.updateSyncStatus({ clientImplementation });
444
+ if (clientImplementation == SyncClientImplementation.JAVASCRIPT) {
443
445
  await this.legacyStreamingSyncIteration(signal, resolvedOptions);
444
446
  }
445
447
  else {
@@ -937,7 +939,8 @@ The next upload iteration will be delayed.`);
937
939
  ...this.syncStatus.dataFlowStatus,
938
940
  ...options.dataFlow
939
941
  },
940
- priorityStatusEntries: options.priorityStatusEntries ?? this.syncStatus.priorityStatusEntries
942
+ priorityStatusEntries: options.priorityStatusEntries ?? this.syncStatus.priorityStatusEntries,
943
+ clientImplementation: options.clientImplementation ?? this.syncStatus.clientImplementation
941
944
  });
942
945
  if (!this.syncStatus.isEqual(updatedStatus)) {
943
946
  this.syncStatus = updatedStatus;
@@ -38,6 +38,7 @@ export class AbstractQueryProcessor extends MetaBaseObserver {
38
38
  * Updates the underlying query.
39
39
  */
40
40
  async updateSettings(settings) {
41
+ this.abortController.abort();
41
42
  await this.initialized;
42
43
  if (!this.state.isFetching && this.reportFetching) {
43
44
  await this.updateState({
@@ -45,7 +46,6 @@ export class AbstractQueryProcessor extends MetaBaseObserver {
45
46
  });
46
47
  }
47
48
  this.options.watchOptions = settings;
48
- this.abortController.abort();
49
49
  this.abortController = new AbortController();
50
50
  await this.runWithReporting(() => this.linkQuery({
51
51
  abortSignal: this.abortController.signal,
@@ -113,7 +113,7 @@ export class DifferentialQueryProcessor extends AbstractQueryProcessor {
113
113
  });
114
114
  db.onChangeWithCallback({
115
115
  onChange: async () => {
116
- if (this.closed) {
116
+ if (this.closed || abortSignal.aborted) {
117
117
  return;
118
118
  }
119
119
  // This fires for each change of the relevant tables
@@ -130,6 +130,9 @@ export class DifferentialQueryProcessor extends AbstractQueryProcessor {
130
130
  parameters: [...compiledQuery.parameters],
131
131
  db: this.options.db
132
132
  });
133
+ if (abortSignal.aborted) {
134
+ return;
135
+ }
133
136
  if (this.reportFetching) {
134
137
  partialStateUpdate.isFetching = false;
135
138
  }
@@ -26,7 +26,7 @@ export class OnChangeQueryProcessor extends AbstractQueryProcessor {
26
26
  });
27
27
  db.onChangeWithCallback({
28
28
  onChange: async () => {
29
- if (this.closed) {
29
+ if (this.closed || abortSignal.aborted) {
30
30
  return;
31
31
  }
32
32
  // This fires for each change of the relevant tables
@@ -43,6 +43,9 @@ export class OnChangeQueryProcessor extends AbstractQueryProcessor {
43
43
  parameters: [...compiledQuery.parameters],
44
44
  db: this.options.db
45
45
  });
46
+ if (abortSignal.aborted) {
47
+ return;
48
+ }
46
49
  if (this.reportFetching) {
47
50
  partialStateUpdate.isFetching = false;
48
51
  }
@@ -1,3 +1,4 @@
1
+ import { SyncClientImplementation } from '../../client/sync/stream/AbstractStreamingSyncImplementation.js';
1
2
  import { InternalProgressInformation, SyncProgress } from './SyncProgress.js';
2
3
  export type SyncDataFlowStatus = Partial<{
3
4
  downloading: boolean;
@@ -32,10 +33,18 @@ export type SyncStatusOptions = {
32
33
  lastSyncedAt?: Date;
33
34
  hasSynced?: boolean;
34
35
  priorityStatusEntries?: SyncPriorityStatus[];
36
+ clientImplementation?: SyncClientImplementation;
35
37
  };
36
38
  export declare class SyncStatus {
37
39
  protected options: SyncStatusOptions;
38
40
  constructor(options: SyncStatusOptions);
41
+ /**
42
+ * Returns the used sync client implementation (either the one implemented in JavaScript or the newer Rust-based
43
+ * implementation).
44
+ *
45
+ * This information is only available after a connection has been requested.
46
+ */
47
+ get clientImplementation(): SyncClientImplementation | undefined;
39
48
  /**
40
49
  * Indicates if the client is currently connected to the PowerSync service.
41
50
  *
@@ -4,6 +4,15 @@ export class SyncStatus {
4
4
  constructor(options) {
5
5
  this.options = options;
6
6
  }
7
+ /**
8
+ * Returns the used sync client implementation (either the one implemented in JavaScript or the newer Rust-based
9
+ * implementation).
10
+ *
11
+ * This information is only available after a connection has been requested.
12
+ */
13
+ get clientImplementation() {
14
+ return this.options.clientImplementation;
15
+ }
7
16
  /**
8
17
  * Indicates if the client is currently connected to the PowerSync service.
9
18
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powersync/common",
3
- "version": "1.37.0",
3
+ "version": "1.38.0",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"