@powersync/common 0.0.0-dev-20260112083235 → 0.0.0-dev-20260120150240
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 +269 -2079
- package/dist/bundle.cjs.map +1 -1
- package/dist/bundle.mjs +269 -2080
- package/dist/bundle.mjs.map +1 -1
- package/dist/bundle.node.cjs +53 -34
- package/dist/bundle.node.cjs.map +1 -1
- package/dist/bundle.node.mjs +53 -35
- package/dist/bundle.node.mjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/lib/client/sync/stream/AbstractRemote.js +41 -32
- package/lib/client/sync/stream/AbstractRemote.js.map +1 -1
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/utils/DataStream.js +11 -2
- package/lib/utils/DataStream.js.map +1 -1
- package/package.json +4 -3
- package/src/client/sync/stream/AbstractRemote.ts +47 -35
- package/src/client/sync/stream/AbstractStreamingSyncImplementation.ts +1 -2
- package/src/index.ts +1 -0
- package/src/utils/DataStream.ts +13 -2
package/dist/bundle.node.mjs
CHANGED
|
@@ -6791,6 +6791,16 @@ class DataStream extends BaseObserver {
|
|
|
6791
6791
|
* @returns a Data payload or Null if the stream closed.
|
|
6792
6792
|
*/
|
|
6793
6793
|
async read() {
|
|
6794
|
+
if (this.closed) {
|
|
6795
|
+
return null;
|
|
6796
|
+
}
|
|
6797
|
+
// Wait for any pending processing to complete first.
|
|
6798
|
+
// This ensures we register our listener before calling processQueue(),
|
|
6799
|
+
// avoiding a race where processQueue() sees no reader and returns early.
|
|
6800
|
+
if (this.processingPromise) {
|
|
6801
|
+
await this.processingPromise;
|
|
6802
|
+
}
|
|
6803
|
+
// Re-check after await - stream may have closed while we were waiting
|
|
6794
6804
|
if (this.closed) {
|
|
6795
6805
|
return null;
|
|
6796
6806
|
}
|
|
@@ -6830,7 +6840,7 @@ class DataStream extends BaseObserver {
|
|
|
6830
6840
|
}
|
|
6831
6841
|
const promise = (this.processingPromise = this._processQueue());
|
|
6832
6842
|
promise.finally(() => {
|
|
6833
|
-
|
|
6843
|
+
this.processingPromise = null;
|
|
6834
6844
|
});
|
|
6835
6845
|
return promise;
|
|
6836
6846
|
}
|
|
@@ -6862,7 +6872,6 @@ class DataStream extends BaseObserver {
|
|
|
6862
6872
|
this.notifyDataAdded = null;
|
|
6863
6873
|
}
|
|
6864
6874
|
if (this.dataQueue.length > 0) {
|
|
6865
|
-
// Next tick
|
|
6866
6875
|
setTimeout(() => this.processQueue());
|
|
6867
6876
|
}
|
|
6868
6877
|
}
|
|
@@ -7482,7 +7491,11 @@ class AbstractRemote {
|
|
|
7482
7491
|
};
|
|
7483
7492
|
const stream = new DataStream({
|
|
7484
7493
|
logger: this.logger,
|
|
7485
|
-
mapLine: mapLine
|
|
7494
|
+
mapLine: mapLine,
|
|
7495
|
+
pressure: {
|
|
7496
|
+
highWaterMark: 20,
|
|
7497
|
+
lowWaterMark: 10
|
|
7498
|
+
}
|
|
7486
7499
|
});
|
|
7487
7500
|
abortSignal?.addEventListener('abort', () => {
|
|
7488
7501
|
closeReader();
|
|
@@ -7490,42 +7503,47 @@ class AbstractRemote {
|
|
|
7490
7503
|
});
|
|
7491
7504
|
const decoder = this.createTextDecoder();
|
|
7492
7505
|
let buffer = '';
|
|
7493
|
-
const
|
|
7494
|
-
|
|
7495
|
-
|
|
7506
|
+
const consumeStream = async () => {
|
|
7507
|
+
while (!stream.closed && !abortSignal?.aborted && !readerReleased) {
|
|
7508
|
+
const { done, value } = await reader.read();
|
|
7509
|
+
if (done) {
|
|
7510
|
+
const remaining = buffer.trim();
|
|
7511
|
+
if (remaining.length != 0) {
|
|
7512
|
+
stream.enqueueData(remaining);
|
|
7513
|
+
}
|
|
7514
|
+
stream.close();
|
|
7515
|
+
await closeReader();
|
|
7496
7516
|
return;
|
|
7497
7517
|
}
|
|
7498
|
-
|
|
7499
|
-
|
|
7500
|
-
|
|
7501
|
-
|
|
7502
|
-
|
|
7503
|
-
|
|
7504
|
-
|
|
7505
|
-
stream.enqueueData(remaining);
|
|
7506
|
-
}
|
|
7507
|
-
stream.close();
|
|
7508
|
-
await closeReader();
|
|
7509
|
-
return;
|
|
7510
|
-
}
|
|
7511
|
-
const data = decoder.decode(value, { stream: true });
|
|
7512
|
-
buffer += data;
|
|
7513
|
-
const lines = buffer.split('\n');
|
|
7514
|
-
for (var i = 0; i < lines.length - 1; i++) {
|
|
7515
|
-
var l = lines[i].trim();
|
|
7516
|
-
if (l.length > 0) {
|
|
7517
|
-
stream.enqueueData(l);
|
|
7518
|
-
didCompleteLine = true;
|
|
7519
|
-
}
|
|
7520
|
-
}
|
|
7521
|
-
buffer = lines[lines.length - 1];
|
|
7518
|
+
const data = decoder.decode(value, { stream: true });
|
|
7519
|
+
buffer += data;
|
|
7520
|
+
const lines = buffer.split('\n');
|
|
7521
|
+
for (var i = 0; i < lines.length - 1; i++) {
|
|
7522
|
+
var l = lines[i].trim();
|
|
7523
|
+
if (l.length > 0) {
|
|
7524
|
+
stream.enqueueData(l);
|
|
7522
7525
|
}
|
|
7523
7526
|
}
|
|
7524
|
-
|
|
7525
|
-
|
|
7526
|
-
|
|
7527
|
+
buffer = lines[lines.length - 1];
|
|
7528
|
+
// Implement backpressure by waiting for the low water mark to be reached
|
|
7529
|
+
if (stream.dataQueue.length > stream.highWatermark) {
|
|
7530
|
+
await new Promise((resolve) => {
|
|
7531
|
+
const dispose = stream.registerListener({
|
|
7532
|
+
lowWater: async () => {
|
|
7533
|
+
resolve();
|
|
7534
|
+
dispose();
|
|
7535
|
+
},
|
|
7536
|
+
closed: () => {
|
|
7537
|
+
resolve();
|
|
7538
|
+
dispose();
|
|
7539
|
+
}
|
|
7540
|
+
});
|
|
7541
|
+
});
|
|
7527
7542
|
}
|
|
7528
|
-
}
|
|
7543
|
+
}
|
|
7544
|
+
};
|
|
7545
|
+
consumeStream().catch(ex => this.logger.error('Error consuming stream', ex));
|
|
7546
|
+
const l = stream.registerListener({
|
|
7529
7547
|
closed: () => {
|
|
7530
7548
|
closeReader();
|
|
7531
7549
|
l?.();
|
|
@@ -10784,5 +10802,5 @@ const parseQuery = (query, parameters) => {
|
|
|
10784
10802
|
return { sqlStatement, parameters: parameters };
|
|
10785
10803
|
};
|
|
10786
10804
|
|
|
10787
|
-
export { AbortOperation, AbstractPowerSyncDatabase, AbstractPowerSyncDatabaseOpenFactory, AbstractQueryProcessor, AbstractRemote, AbstractStreamingSyncImplementation, ArrayComparator, BaseObserver, Column, ColumnType, ConnectionClosedError, ConnectionManager, ControlledExecutor, CrudBatch, CrudEntry, CrudTransaction, DEFAULT_CRUD_BATCH_LIMIT, DEFAULT_CRUD_UPLOAD_THROTTLE_MS, DEFAULT_INDEX_COLUMN_OPTIONS, DEFAULT_INDEX_OPTIONS, DEFAULT_LOCK_TIMEOUT_MS, DEFAULT_POWERSYNC_CLOSE_OPTIONS, DEFAULT_POWERSYNC_DB_OPTIONS, DEFAULT_PRESSURE_LIMITS, DEFAULT_REMOTE_LOGGER, DEFAULT_REMOTE_OPTIONS, DEFAULT_RETRY_DELAY_MS, DEFAULT_ROW_COMPARATOR, DEFAULT_STREAMING_SYNC_OPTIONS, DEFAULT_STREAM_CONNECTION_OPTIONS, DEFAULT_SYNC_CLIENT_IMPLEMENTATION, DEFAULT_TABLE_OPTIONS, DEFAULT_WATCH_QUERY_OPTIONS, DEFAULT_WATCH_THROTTLE_MS, DataStream, DiffTriggerOperation, DifferentialQueryProcessor, EMPTY_DIFFERENTIAL, FalsyComparator, FetchImplementationProvider, FetchStrategy, GetAllQuery, Index, IndexedColumn, InvalidSQLCharacters, LockType, LogLevel, MAX_AMOUNT_OF_COLUMNS, MAX_OP_ID, OnChangeQueryProcessor, OpType, OpTypeEnum, OplogEntry, PSInternalTable, PowerSyncControlCommand, RowUpdateType, Schema, SqliteBucketStorage, SyncClientImplementation, SyncDataBatch, SyncDataBucket, SyncProgress, SyncStatus, SyncStreamConnectionMethod, Table, TableV2, UpdateType, UploadQueueStats, WatchedQueryListenerEvent, column, compilableQueryWatch, createBaseLogger, createLogger, extractTableUpdates, isBatchedUpdateNotification, isContinueCheckpointRequest, isDBAdapter, isPowerSyncDatabaseOptionsWithSettings, isSQLOpenFactory, isSQLOpenOptions, isStreamingKeepalive, isStreamingSyncCheckpoint, isStreamingSyncCheckpointComplete, isStreamingSyncCheckpointDiff, isStreamingSyncCheckpointPartiallyComplete, isStreamingSyncData, isSyncNewCheckpointRequest, parseQuery, runOnSchemaChange, sanitizeSQL, sanitizeUUID };
|
|
10805
|
+
export { AbortOperation, AbstractPowerSyncDatabase, AbstractPowerSyncDatabaseOpenFactory, AbstractQueryProcessor, AbstractRemote, AbstractStreamingSyncImplementation, ArrayComparator, BaseObserver, Column, ColumnType, ConnectionClosedError, ConnectionManager, ControlledExecutor, CrudBatch, CrudEntry, CrudTransaction, DEFAULT_CRUD_BATCH_LIMIT, DEFAULT_CRUD_UPLOAD_THROTTLE_MS, DEFAULT_INDEX_COLUMN_OPTIONS, DEFAULT_INDEX_OPTIONS, DEFAULT_LOCK_TIMEOUT_MS, DEFAULT_POWERSYNC_CLOSE_OPTIONS, DEFAULT_POWERSYNC_DB_OPTIONS, DEFAULT_PRESSURE_LIMITS, DEFAULT_REMOTE_LOGGER, DEFAULT_REMOTE_OPTIONS, DEFAULT_RETRY_DELAY_MS, DEFAULT_ROW_COMPARATOR, DEFAULT_STREAMING_SYNC_OPTIONS, DEFAULT_STREAM_CONNECTION_OPTIONS, DEFAULT_SYNC_CLIENT_IMPLEMENTATION, DEFAULT_TABLE_OPTIONS, DEFAULT_WATCH_QUERY_OPTIONS, DEFAULT_WATCH_THROTTLE_MS, DataStream, DiffTriggerOperation, DifferentialQueryProcessor, EMPTY_DIFFERENTIAL, FalsyComparator, FetchImplementationProvider, FetchStrategy, GetAllQuery, Index, IndexedColumn, InvalidSQLCharacters, LockType, LogLevel, MAX_AMOUNT_OF_COLUMNS, MAX_OP_ID, OnChangeQueryProcessor, OpType, OpTypeEnum, OplogEntry, PSInternalTable, PowerSyncControlCommand, RawTable, RowUpdateType, Schema, SqliteBucketStorage, SyncClientImplementation, SyncDataBatch, SyncDataBucket, SyncProgress, SyncStatus, SyncStreamConnectionMethod, Table, TableV2, UpdateType, UploadQueueStats, WatchedQueryListenerEvent, column, compilableQueryWatch, createBaseLogger, createLogger, extractTableUpdates, isBatchedUpdateNotification, isContinueCheckpointRequest, isDBAdapter, isPowerSyncDatabaseOptionsWithSettings, isSQLOpenFactory, isSQLOpenOptions, isStreamingKeepalive, isStreamingSyncCheckpoint, isStreamingSyncCheckpointComplete, isStreamingSyncCheckpointDiff, isStreamingSyncCheckpointPartiallyComplete, isStreamingSyncData, isSyncNewCheckpointRequest, parseQuery, runOnSchemaChange, sanitizeSQL, sanitizeUUID };
|
|
10788
10806
|
//# sourceMappingURL=bundle.node.mjs.map
|