@powersync/shared-internals 1.1.1 → 1.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.
- package/dist/websockets.mjs.map +1 -1
- package/dist/websockets.node.mjs.map +1 -1
- package/lib/client/BasePowerSyncDatabase.d.ts +13 -3
- package/lib/client/BasePowerSyncDatabase.js +59 -5
- package/lib/client/BasePowerSyncDatabase.js.map +1 -1
- package/lib/client/ConnectionManager.d.ts +4 -0
- package/lib/client/ConnectionManager.js +19 -1
- package/lib/client/ConnectionManager.js.map +1 -1
- package/lib/client/sync/CheckpointRequestImpl.d.ts +11 -0
- package/lib/client/sync/CheckpointRequestImpl.js +42 -0
- package/lib/client/sync/CheckpointRequestImpl.js.map +1 -0
- package/lib/client/sync/bucket/BucketStorageAdapter.d.ts +1 -0
- package/lib/client/sync/bucket/BucketStorageAdapter.js.map +1 -1
- package/lib/client/sync/bucket/SqliteBucketStorage.d.ts +1 -0
- package/lib/client/sync/bucket/SqliteBucketStorage.js +7 -0
- package/lib/client/sync/bucket/SqliteBucketStorage.js.map +1 -1
- package/lib/client/sync/options.js +2 -1
- package/lib/client/sync/options.js.map +1 -1
- package/lib/client/sync/stream/AbstractRemote.d.ts +12 -6
- package/lib/client/sync/stream/AbstractRemote.js +16 -14
- package/lib/client/sync/stream/AbstractRemote.js.map +1 -1
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.d.ts +29 -4
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js +177 -23
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js.map +1 -1
- package/lib/client/sync/stream/CheckpointState.d.ts +44 -0
- package/lib/client/sync/stream/CheckpointState.js +111 -0
- package/lib/client/sync/stream/CheckpointState.js.map +1 -0
- package/lib/client/sync/stream/core-instruction.d.ts +6 -0
- package/lib/client/sync/stream/core-instruction.js.map +1 -1
- package/lib/utils/stream_transform.d.ts +1 -0
- package/lib/utils/stream_transform.js +18 -2
- package/lib/utils/stream_transform.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +4 -3
- package/src/client/BasePowerSyncDatabase.ts +71 -14
- package/src/client/ConnectionManager.ts +23 -1
- package/src/client/sync/CheckpointRequestImpl.ts +54 -0
- package/src/client/sync/bucket/BucketStorageAdapter.ts +1 -0
- package/src/client/sync/bucket/SqliteBucketStorage.ts +8 -0
- package/src/client/sync/options.ts +2 -1
- package/src/client/sync/stream/AbstractRemote.ts +29 -15
- package/src/client/sync/stream/AbstractStreamingSyncImplementation.ts +217 -28
- package/src/client/sync/stream/CheckpointState.ts +142 -0
- package/src/client/sync/stream/core-instruction.ts +7 -0
- package/src/utils/stream_transform.ts +19 -3
- package/src/version.ts +1 -1
|
@@ -34,6 +34,7 @@ export function map<T1, T2>(source: SimpleAsyncIterator<T1>, map: (source: T1) =
|
|
|
34
34
|
|
|
35
35
|
export interface InjectableIterator<T> extends SimpleAsyncIterator<T> {
|
|
36
36
|
inject(event: T): void;
|
|
37
|
+
injectError(error: unknown): void;
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
/**
|
|
@@ -54,7 +55,7 @@ export function injectable<T>(source: SimpleAsyncIterator<T>): InjectableIterato
|
|
|
54
55
|
let pendingSourceEvent: ((w: Waiter) => void) | null = null;
|
|
55
56
|
let sourceFetchInFlight = false;
|
|
56
57
|
|
|
57
|
-
let pendingInjectedEvents: T[] = [];
|
|
58
|
+
let pendingInjectedEvents: PromiseSettledResult<T>[] = [];
|
|
58
59
|
|
|
59
60
|
const consumeWaiter = () => {
|
|
60
61
|
const pending = waiter;
|
|
@@ -102,7 +103,14 @@ export function injectable<T>(source: SimpleAsyncIterator<T>): InjectableIterato
|
|
|
102
103
|
|
|
103
104
|
// Second priority: Dispatch injected events
|
|
104
105
|
if (pendingInjectedEvents.length) {
|
|
105
|
-
|
|
106
|
+
const event = pendingInjectedEvents.shift()!;
|
|
107
|
+
if (event.status === 'fulfilled') {
|
|
108
|
+
resolve(valueResult(event.value));
|
|
109
|
+
} else {
|
|
110
|
+
reject(event.reason);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return;
|
|
106
114
|
}
|
|
107
115
|
|
|
108
116
|
// Nothing pending? Fetch from source
|
|
@@ -117,7 +125,15 @@ export function injectable<T>(source: SimpleAsyncIterator<T>): InjectableIterato
|
|
|
117
125
|
if (pending != null) {
|
|
118
126
|
pending.resolve(valueResult(event));
|
|
119
127
|
} else {
|
|
120
|
-
pendingInjectedEvents.push(event);
|
|
128
|
+
pendingInjectedEvents.push({ status: 'fulfilled', value: event });
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
injectError(error) {
|
|
132
|
+
const pending = consumeWaiter();
|
|
133
|
+
if (pending != null) {
|
|
134
|
+
pending.reject(error);
|
|
135
|
+
} else {
|
|
136
|
+
pendingInjectedEvents.push({ status: 'rejected', reason: error });
|
|
121
137
|
}
|
|
122
138
|
}
|
|
123
139
|
};
|
package/src/version.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// Note: This file gets updated by tool/update_version.js script as part of the Changesets release workflow.
|
|
2
2
|
// The update happens in the changesets PR, before the package is built.
|
|
3
|
-
export const POWERSYNC_JS_VERSION = '1.
|
|
3
|
+
export const POWERSYNC_JS_VERSION = '1.3.0';
|