@powersync/common 0.0.0-dev-20250828085411 → 0.0.0-dev-20250909203539
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/bundle.cjs +2 -2
- package/dist/bundle.mjs +2 -2
- package/dist/index.d.cts +863 -855
- package/lib/client/AbstractPowerSyncDatabase.js +4 -4
- package/lib/client/sync/stream/AbstractRemote.js +3 -0
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js +6 -3
- package/lib/client/triggers/TriggerManager.d.ts +1 -1
- package/lib/client/watched/processors/AbstractQueryProcessor.js +12 -4
- package/lib/client/watched/processors/DifferentialQueryProcessor.js +4 -1
- package/lib/client/watched/processors/OnChangeQueryProcessor.js +4 -1
- package/lib/db/crud/SyncStatus.d.ts +9 -0
- package/lib/db/crud/SyncStatus.js +9 -0
- package/package.json +1 -1
|
@@ -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.
|
|
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.
|
|
229
|
-
if (versionInts[0] != 0 || versionInts[1] <
|
|
230
|
-
throw new Error(`Unsupported powersync extension version. Need >=0.
|
|
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() {
|
|
@@ -382,6 +382,9 @@ export class AbstractRemote {
|
|
|
382
382
|
* Aborting the active fetch request while it is being consumed seems to throw
|
|
383
383
|
* an unhandled exception on the window level.
|
|
384
384
|
*/
|
|
385
|
+
if (abortSignal?.aborted) {
|
|
386
|
+
throw new AbortOperation('Abort request received before making postStreamRaw request');
|
|
387
|
+
}
|
|
385
388
|
const controller = new AbortController();
|
|
386
389
|
let requestResolved = false;
|
|
387
390
|
abortSignal?.addEventListener('abort', () => {
|
|
@@ -439,7 +439,9 @@ The next upload iteration will be delayed.`);
|
|
|
439
439
|
...DEFAULT_STREAM_CONNECTION_OPTIONS,
|
|
440
440
|
...(options ?? {})
|
|
441
441
|
};
|
|
442
|
-
|
|
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 {
|
|
@@ -694,7 +696,7 @@ The next upload iteration will be delayed.`);
|
|
|
694
696
|
let receivingLines = null;
|
|
695
697
|
let hadSyncLine = false;
|
|
696
698
|
if (signal.aborted) {
|
|
697
|
-
|
|
699
|
+
throw new AbortOperation('Connection request has been aborted');
|
|
698
700
|
}
|
|
699
701
|
const abortController = new AbortController();
|
|
700
702
|
signal.addEventListener('abort', () => abortController.abort());
|
|
@@ -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;
|
|
@@ -323,7 +323,7 @@ export interface TriggerManager {
|
|
|
323
323
|
* },
|
|
324
324
|
* onChange: async (context) => {
|
|
325
325
|
* // Fetches the todo records that were inserted during this diff
|
|
326
|
-
* const newTodos = await context.
|
|
326
|
+
* const newTodos = await context.withDiff<Database['todos']>(`
|
|
327
327
|
* SELECT
|
|
328
328
|
* todos.*
|
|
329
329
|
* FROM
|
|
@@ -38,17 +38,25 @@ export class AbstractQueryProcessor extends MetaBaseObserver {
|
|
|
38
38
|
* Updates the underlying query.
|
|
39
39
|
*/
|
|
40
40
|
async updateSettings(settings) {
|
|
41
|
+
// Abort any previous requests
|
|
42
|
+
this.abortController.abort();
|
|
43
|
+
this.options.watchOptions = settings;
|
|
44
|
+
// Keep track of this controller's abort status
|
|
45
|
+
const abortController = new AbortController();
|
|
46
|
+
// Allow this to be aborted externally
|
|
47
|
+
this.abortController = abortController;
|
|
41
48
|
await this.initialized;
|
|
49
|
+
// This may have been aborted while awaiting or if multiple calls to `updateSettings` were made
|
|
50
|
+
if (abortController.signal.aborted) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
42
53
|
if (!this.state.isFetching && this.reportFetching) {
|
|
43
54
|
await this.updateState({
|
|
44
55
|
isFetching: true
|
|
45
56
|
});
|
|
46
57
|
}
|
|
47
|
-
this.options.watchOptions = settings;
|
|
48
|
-
this.abortController.abort();
|
|
49
|
-
this.abortController = new AbortController();
|
|
50
58
|
await this.runWithReporting(() => this.linkQuery({
|
|
51
|
-
abortSignal:
|
|
59
|
+
abortSignal: abortController.signal,
|
|
52
60
|
settings
|
|
53
61
|
}));
|
|
54
62
|
}
|
|
@@ -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
|
*
|