@powersync/web 1.28.1 → 1.28.2

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.
@@ -9627,7 +9627,7 @@ function requireDist () {
9627
9627
 
9628
9628
  var distExports = requireDist();
9629
9629
 
9630
- var version = "1.41.1";
9630
+ var version = "1.42.0";
9631
9631
  var PACKAGE = {
9632
9632
  version: version};
9633
9633
 
@@ -10375,9 +10375,11 @@ class AbstractRemote {
10375
10375
  // Create a new stream splitting the response at line endings while also handling cancellations
10376
10376
  // by closing the reader.
10377
10377
  const reader = res.body.getReader();
10378
+ let readerReleased = false;
10378
10379
  // This will close the network request and read stream
10379
10380
  const closeReader = async () => {
10380
10381
  try {
10382
+ readerReleased = true;
10381
10383
  await reader.cancel();
10382
10384
  }
10383
10385
  catch (ex) {
@@ -10385,17 +10387,21 @@ class AbstractRemote {
10385
10387
  }
10386
10388
  reader.releaseLock();
10387
10389
  };
10390
+ const stream = new DataStream({
10391
+ logger: this.logger,
10392
+ mapLine: mapLine
10393
+ });
10388
10394
  abortSignal?.addEventListener('abort', () => {
10389
10395
  closeReader();
10396
+ stream.close();
10390
10397
  });
10391
10398
  const decoder = this.createTextDecoder();
10392
10399
  let buffer = '';
10393
- const stream = new DataStream({
10394
- logger: this.logger,
10395
- mapLine: mapLine
10396
- });
10397
10400
  const l = stream.registerListener({
10398
10401
  lowWater: async () => {
10402
+ if (stream.closed || abortSignal?.aborted || readerReleased) {
10403
+ return;
10404
+ }
10399
10405
  try {
10400
10406
  let didCompleteLine = false;
10401
10407
  while (!didCompleteLine) {
@@ -11555,6 +11561,7 @@ class TriggerManagerImpl {
11555
11561
  await hooks?.beforeCreate?.(tx);
11556
11562
  await tx.execute(/* sql */ `
11557
11563
  CREATE TEMP TABLE ${destination} (
11564
+ operation_id INTEGER PRIMARY KEY AUTOINCREMENT,
11558
11565
  id TEXT,
11559
11566
  operation TEXT,
11560
11567
  timestamp TEXT,
@@ -11665,17 +11672,20 @@ class TriggerManagerImpl {
11665
11672
  const callbackResult = await options.onChange({
11666
11673
  ...tx,
11667
11674
  destinationTable: destination,
11668
- withDiff: async (query, params) => {
11675
+ withDiff: async (query, params, options) => {
11669
11676
  // Wrap the query to expose the destination table
11677
+ const operationIdSelect = options?.castOperationIdAsText
11678
+ ? 'id, operation, CAST(operation_id AS TEXT) as operation_id, timestamp, value, previous_value'
11679
+ : '*';
11670
11680
  const wrappedQuery = /* sql */ `
11671
11681
  WITH
11672
11682
  DIFF AS (
11673
11683
  SELECT
11674
- *
11684
+ ${operationIdSelect}
11675
11685
  FROM
11676
11686
  ${destination}
11677
11687
  ORDER BY
11678
- timestamp ASC
11688
+ operation_id ASC
11679
11689
  ) ${query}
11680
11690
  `;
11681
11691
  return tx.getAll(wrappedQuery, params);
@@ -11689,13 +11699,14 @@ class TriggerManagerImpl {
11689
11699
  id,
11690
11700
  ${contextColumns.length > 0
11691
11701
  ? `${contextColumns.map((col) => `json_extract(value, '$.${col}') as ${col}`).join(', ')},`
11692
- : ''} operation as __operation,
11702
+ : ''} operation_id as __operation_id,
11703
+ operation as __operation,
11693
11704
  timestamp as __timestamp,
11694
11705
  previous_value as __previous_value
11695
11706
  FROM
11696
11707
  ${destination}
11697
11708
  ORDER BY
11698
- __timestamp ASC
11709
+ __operation_id ASC
11699
11710
  ) ${query}
11700
11711
  `;
11701
11712
  return tx.getAll(wrappedQuery, params);