@powersync/common 1.51.0 → 1.52.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/bundle.cjs +431 -445
- package/dist/bundle.cjs.map +1 -1
- package/dist/bundle.mjs +432 -444
- package/dist/bundle.mjs.map +1 -1
- package/dist/bundle.node.cjs +429 -445
- package/dist/bundle.node.cjs.map +1 -1
- package/dist/bundle.node.mjs +430 -444
- package/dist/bundle.node.mjs.map +1 -1
- package/dist/index.d.cts +41 -70
- package/lib/client/AbstractPowerSyncDatabase.js +3 -3
- package/lib/client/AbstractPowerSyncDatabase.js.map +1 -1
- package/lib/client/sync/stream/AbstractRemote.d.ts +29 -8
- package/lib/client/sync/stream/AbstractRemote.js +154 -177
- package/lib/client/sync/stream/AbstractRemote.js.map +1 -1
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.d.ts +1 -0
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js +69 -88
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +0 -1
- package/lib/index.js.map +1 -1
- package/lib/utils/async.d.ts +0 -9
- package/lib/utils/async.js +0 -9
- package/lib/utils/async.js.map +1 -1
- package/lib/utils/stream_transform.d.ts +39 -0
- package/lib/utils/stream_transform.js +206 -0
- package/lib/utils/stream_transform.js.map +1 -0
- package/package.json +9 -7
- package/src/client/AbstractPowerSyncDatabase.ts +3 -3
- package/src/client/sync/stream/AbstractRemote.ts +182 -206
- package/src/client/sync/stream/AbstractStreamingSyncImplementation.ts +82 -83
- package/src/index.ts +1 -1
- package/src/utils/async.ts +0 -11
- package/src/utils/stream_transform.ts +252 -0
- package/lib/utils/DataStream.d.ts +0 -62
- package/lib/utils/DataStream.js +0 -169
- package/lib/utils/DataStream.js.map +0 -1
- package/src/utils/DataStream.ts +0 -222
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
export const doneResult = { done: true, value: undefined };
|
|
2
|
+
export function valueResult(value) {
|
|
3
|
+
return { done: false, value };
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* A variant of {@link Array.map} for async iterators.
|
|
7
|
+
*/
|
|
8
|
+
export function map(source, map) {
|
|
9
|
+
return {
|
|
10
|
+
next: async () => {
|
|
11
|
+
const value = await source.next();
|
|
12
|
+
if (value.done) {
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
return { value: map(value.value) };
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Expands a source async iterator by allowing to inject events asynchronously.
|
|
23
|
+
*
|
|
24
|
+
* The resulting iterator will emit all events from its source. Additionally though, events can be injected. These
|
|
25
|
+
* events are dropped once the main iterator completes, but are otherwise forwarded.
|
|
26
|
+
*
|
|
27
|
+
* The iterator completes when its source completes, and it supports backpressure by only calling `next()` on the source
|
|
28
|
+
* in response to a `next()` call from downstream if no pending injected events can be dispatched.
|
|
29
|
+
*/
|
|
30
|
+
export function injectable(source) {
|
|
31
|
+
let sourceIsDone = false;
|
|
32
|
+
let waiter = undefined; // An active, waiting next() call.
|
|
33
|
+
// A pending upstream event that couldn't be dispatched because inject() has been called before it was resolved.
|
|
34
|
+
let pendingSourceEvent = null;
|
|
35
|
+
let pendingInjectedEvents = [];
|
|
36
|
+
const consumeWaiter = () => {
|
|
37
|
+
const pending = waiter;
|
|
38
|
+
waiter = undefined;
|
|
39
|
+
return pending;
|
|
40
|
+
};
|
|
41
|
+
const fetchFromSource = () => {
|
|
42
|
+
const resolveWaiter = (propagate) => {
|
|
43
|
+
const active = consumeWaiter();
|
|
44
|
+
if (active) {
|
|
45
|
+
propagate(active);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
pendingSourceEvent = propagate;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const nextFromSource = source.next();
|
|
52
|
+
nextFromSource.then((value) => {
|
|
53
|
+
sourceIsDone = value.done == true;
|
|
54
|
+
resolveWaiter((w) => w.resolve(value));
|
|
55
|
+
}, (error) => {
|
|
56
|
+
resolveWaiter((w) => w.reject(error));
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
return {
|
|
60
|
+
next: () => {
|
|
61
|
+
return new Promise((resolve, reject) => {
|
|
62
|
+
// First priority: Dispatch ready upstream events.
|
|
63
|
+
if (sourceIsDone) {
|
|
64
|
+
return resolve(doneResult);
|
|
65
|
+
}
|
|
66
|
+
if (pendingSourceEvent) {
|
|
67
|
+
pendingSourceEvent({ resolve, reject });
|
|
68
|
+
pendingSourceEvent = null;
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
// Second priority: Dispatch injected events
|
|
72
|
+
if (pendingInjectedEvents.length) {
|
|
73
|
+
return resolve(valueResult(pendingInjectedEvents.shift()));
|
|
74
|
+
}
|
|
75
|
+
// Nothing pending? Fetch from source
|
|
76
|
+
waiter = { resolve, reject };
|
|
77
|
+
return fetchFromSource();
|
|
78
|
+
});
|
|
79
|
+
},
|
|
80
|
+
inject: (event) => {
|
|
81
|
+
const pending = consumeWaiter();
|
|
82
|
+
if (pending != null) {
|
|
83
|
+
pending.resolve(valueResult(event));
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
pendingInjectedEvents.push(event);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Splits a byte stream at line endings, emitting each line as a string.
|
|
93
|
+
*/
|
|
94
|
+
export function extractJsonLines(source, decoder) {
|
|
95
|
+
let buffer = '';
|
|
96
|
+
const pendingLines = [];
|
|
97
|
+
let isFinalEvent = false;
|
|
98
|
+
return {
|
|
99
|
+
next: async () => {
|
|
100
|
+
while (true) {
|
|
101
|
+
if (isFinalEvent) {
|
|
102
|
+
return doneResult;
|
|
103
|
+
}
|
|
104
|
+
{
|
|
105
|
+
const first = pendingLines.shift();
|
|
106
|
+
if (first) {
|
|
107
|
+
return { done: false, value: first };
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const { done, value } = await source.next();
|
|
111
|
+
if (done) {
|
|
112
|
+
const remaining = buffer.trim();
|
|
113
|
+
if (remaining.length != 0) {
|
|
114
|
+
isFinalEvent = true;
|
|
115
|
+
return { done: false, value: remaining };
|
|
116
|
+
}
|
|
117
|
+
return doneResult;
|
|
118
|
+
}
|
|
119
|
+
const data = decoder.decode(value, { stream: true });
|
|
120
|
+
buffer += data;
|
|
121
|
+
const lines = buffer.split('\n');
|
|
122
|
+
for (let i = 0; i < lines.length - 1; i++) {
|
|
123
|
+
const l = lines[i].trim();
|
|
124
|
+
if (l.length > 0) {
|
|
125
|
+
pendingLines.push(l);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
buffer = lines[lines.length - 1];
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Splits a concatenated stream of BSON objects by emitting individual objects.
|
|
135
|
+
*/
|
|
136
|
+
export function extractBsonObjects(source) {
|
|
137
|
+
// Fully read but not emitted yet.
|
|
138
|
+
const completedObjects = [];
|
|
139
|
+
// Whether source has returned { done: true }. We do the same once completed objects have been emitted.
|
|
140
|
+
let isDone = false;
|
|
141
|
+
const lengthBuffer = new DataView(new ArrayBuffer(4));
|
|
142
|
+
let objectBody = null;
|
|
143
|
+
// If we're parsing the length field, a number between 1 and 4 (inclusive) describing remaining bytes in the header.
|
|
144
|
+
// If we're consuming a document, the bytes remaining.
|
|
145
|
+
let remainingLength = 4;
|
|
146
|
+
return {
|
|
147
|
+
async next() {
|
|
148
|
+
while (true) {
|
|
149
|
+
// Before fetching new data from upstream, return completed objects.
|
|
150
|
+
if (completedObjects.length) {
|
|
151
|
+
return valueResult(completedObjects.shift());
|
|
152
|
+
}
|
|
153
|
+
if (isDone) {
|
|
154
|
+
return doneResult;
|
|
155
|
+
}
|
|
156
|
+
const upstreamEvent = await source.next();
|
|
157
|
+
if (upstreamEvent.done) {
|
|
158
|
+
isDone = true;
|
|
159
|
+
if (objectBody || remainingLength != 4) {
|
|
160
|
+
throw new Error('illegal end of stream in BSON object');
|
|
161
|
+
}
|
|
162
|
+
return doneResult;
|
|
163
|
+
}
|
|
164
|
+
const chunk = upstreamEvent.value;
|
|
165
|
+
for (let i = 0; i < chunk.length;) {
|
|
166
|
+
const availableInData = chunk.length - i;
|
|
167
|
+
if (objectBody) {
|
|
168
|
+
// We're in the middle of reading a BSON document.
|
|
169
|
+
const bytesToRead = Math.min(availableInData, remainingLength);
|
|
170
|
+
const copySource = new Uint8Array(chunk.buffer, chunk.byteOffset + i, bytesToRead);
|
|
171
|
+
objectBody.set(copySource, objectBody.length - remainingLength);
|
|
172
|
+
i += bytesToRead;
|
|
173
|
+
remainingLength -= bytesToRead;
|
|
174
|
+
if (remainingLength == 0) {
|
|
175
|
+
completedObjects.push(objectBody);
|
|
176
|
+
// Prepare to read another document, starting with its length
|
|
177
|
+
objectBody = null;
|
|
178
|
+
remainingLength = 4;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
// Copy up to 4 bytes into lengthBuffer, depending on how many we still need.
|
|
183
|
+
const bytesToRead = Math.min(availableInData, remainingLength);
|
|
184
|
+
for (let j = 0; j < bytesToRead; j++) {
|
|
185
|
+
lengthBuffer.setUint8(4 - remainingLength + j, chunk[i + j]);
|
|
186
|
+
}
|
|
187
|
+
i += bytesToRead;
|
|
188
|
+
remainingLength -= bytesToRead;
|
|
189
|
+
if (remainingLength == 0) {
|
|
190
|
+
// Transition from reading length header to reading document. Subtracting 4 because the length of the
|
|
191
|
+
// header is included in length.
|
|
192
|
+
const length = lengthBuffer.getInt32(0, true /* little endian */);
|
|
193
|
+
remainingLength = length - 4;
|
|
194
|
+
if (remainingLength < 1) {
|
|
195
|
+
throw new Error(`invalid length for bson: ${length}`);
|
|
196
|
+
}
|
|
197
|
+
objectBody = new Uint8Array(length);
|
|
198
|
+
new DataView(objectBody.buffer).setInt32(0, length, true);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
//# sourceMappingURL=stream_transform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream_transform.js","sourceRoot":"","sources":["../../src/utils/stream_transform.ts"],"names":[],"mappings":"AAUA,MAAM,CAAC,MAAM,UAAU,GAA8B,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;AAEtF,MAAM,UAAU,WAAW,CAAI,KAAQ;IACrC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AAChC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,GAAG,CAAS,MAA+B,EAAE,GAAuB;IAClF,OAAO;QACL,IAAI,EAAE,KAAK,IAAI,EAAE;YACf,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;YAClC,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;gBACf,OAAO,KAAK,CAAC;YACf,CAAC;iBAAM,CAAC;gBACN,OAAO,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;YACrC,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC;AAMD;;;;;;;;GAQG;AACH,MAAM,UAAU,UAAU,CAAI,MAA8B;IAG1D,IAAI,YAAY,GAAG,KAAK,CAAC;IACzB,IAAI,MAAM,GAAuB,SAAS,CAAC,CAAC,kCAAkC;IAC9E,gHAAgH;IAChH,IAAI,kBAAkB,GAAiC,IAAI,CAAC;IAE5D,IAAI,qBAAqB,GAAQ,EAAE,CAAC;IAEpC,MAAM,aAAa,GAAG,GAAG,EAAE;QACzB,MAAM,OAAO,GAAG,MAAM,CAAC;QACvB,MA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.org/",
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
8
|
-
"description": "API definitions for
|
|
8
|
+
"description": "API definitions for PowerSync",
|
|
9
9
|
"type": "module",
|
|
10
10
|
"main": "dist/bundle.mjs",
|
|
11
11
|
"module": "dist/bundle.mjs",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
|
-
"author": "
|
|
35
|
+
"author": "PowerSync",
|
|
36
36
|
"license": "Apache-2.0",
|
|
37
37
|
"files": [
|
|
38
38
|
"lib",
|
|
@@ -57,14 +57,16 @@
|
|
|
57
57
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
58
58
|
"@types/node": "^24.0.0",
|
|
59
59
|
"@types/uuid": "^9.0.6",
|
|
60
|
+
"bson": "^6.10.4",
|
|
60
61
|
"buffer": "^6.0.3",
|
|
61
|
-
"rollup": "^4.52.5",
|
|
62
|
-
"rollup-plugin-dts": "^6.2.1",
|
|
63
62
|
"cross-fetch": "^4.1.0",
|
|
63
|
+
"estree-walker": "^3.0.3",
|
|
64
64
|
"js-logger": "^1.6.1",
|
|
65
|
+
"magic-string": "^0.30.21",
|
|
66
|
+
"rollup": "^4.52.5",
|
|
67
|
+
"rollup-plugin-dts": "^6.2.1",
|
|
65
68
|
"rsocket-core": "1.0.0-alpha.3",
|
|
66
|
-
"rsocket-websocket-client": "1.0.0-alpha.3"
|
|
67
|
-
"bson": "^6.10.4"
|
|
69
|
+
"rsocket-websocket-client": "1.0.0-alpha.3"
|
|
68
70
|
},
|
|
69
71
|
"scripts": {
|
|
70
72
|
"build": "tsc -b && rollup -c rollup.config.mjs",
|
|
@@ -13,7 +13,7 @@ import { UploadQueueStats } from '../db/crud/UploadQueueStatus.js';
|
|
|
13
13
|
import { Schema } from '../db/schema/Schema.js';
|
|
14
14
|
import { BaseObserver } from '../utils/BaseObserver.js';
|
|
15
15
|
import { ControlledExecutor } from '../utils/ControlledExecutor.js';
|
|
16
|
-
import {
|
|
16
|
+
import { throttleTrailing } from '../utils/async.js';
|
|
17
17
|
import {
|
|
18
18
|
ConnectionManager,
|
|
19
19
|
CreateSyncImplementationOptions,
|
|
@@ -704,7 +704,7 @@ export abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncDB
|
|
|
704
704
|
* @returns A transaction of CRUD operations to upload, or null if there are none
|
|
705
705
|
*/
|
|
706
706
|
async getNextCrudTransaction(): Promise<CrudTransaction | null> {
|
|
707
|
-
const iterator = this.getCrudTransactions()[
|
|
707
|
+
const iterator = this.getCrudTransactions()[Symbol.asyncIterator]();
|
|
708
708
|
return (await iterator.next()).value;
|
|
709
709
|
}
|
|
710
710
|
|
|
@@ -741,7 +741,7 @@ export abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncDB
|
|
|
741
741
|
*/
|
|
742
742
|
getCrudTransactions(): AsyncIterable<CrudTransaction, null> {
|
|
743
743
|
return {
|
|
744
|
-
[
|
|
744
|
+
[Symbol.asyncIterator]: () => {
|
|
745
745
|
let lastCrudItemId = -1;
|
|
746
746
|
const sql = `
|
|
747
747
|
WITH RECURSIVE crud_entries AS (
|