@absolutejs/sync 1.18.0 → 1.18.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.
@@ -789,6 +789,7 @@ var createSyncCollection = (options) => {
789
789
  let attempt = 0;
790
790
  let reconnectTimer;
791
791
  let appliedVersion = 0;
792
+ let appliedCursor;
792
793
  const persist = () => {
793
794
  options.storage?.save(pending.map((mutation) => ({
794
795
  mutationId: mutation.mutationId,
@@ -828,6 +829,9 @@ var createSyncCollection = (options) => {
828
829
  if (frame.version !== undefined) {
829
830
  appliedVersion = frame.version;
830
831
  }
832
+ if (frame.cursor !== undefined) {
833
+ appliedCursor = frame.cursor;
834
+ }
831
835
  persistCache();
832
836
  recompute({ status: "ready", error: undefined });
833
837
  } else if (frame.type === "diff") {
@@ -840,6 +844,9 @@ var createSyncCollection = (options) => {
840
844
  for (const row of frame.changed) {
841
845
  confirmed.set(key(row), row);
842
846
  }
847
+ if (frame.cursor !== undefined) {
848
+ appliedCursor = frame.cursor;
849
+ }
843
850
  if (frame.version !== undefined) {
844
851
  appliedVersion = Math.max(appliedVersion, frame.version);
845
852
  }
@@ -890,7 +897,7 @@ var createSyncCollection = (options) => {
890
897
  id: SUBSCRIPTION_ID,
891
898
  collection: options.collection,
892
899
  params: options.params,
893
- since: appliedVersion > 0 ? appliedVersion : undefined
900
+ since: appliedCursor ?? (appliedVersion > 0 ? appliedVersion : undefined)
894
901
  }));
895
902
  for (const mutation of pending) {
896
903
  sendMutate(mutation);
@@ -1267,6 +1274,9 @@ var createSyncClient = (options) => {
1267
1274
  if (frame.version !== undefined) {
1268
1275
  entry.appliedVersion = frame.version;
1269
1276
  }
1277
+ if (frame.cursor !== undefined) {
1278
+ entry.cursor = frame.cursor;
1279
+ }
1270
1280
  recompute(entry, { status: "ready", error: undefined });
1271
1281
  } else if (frame.type === "diff") {
1272
1282
  const entry = entries.get(frame.id);
@@ -1277,6 +1287,9 @@ var createSyncClient = (options) => {
1277
1287
  if (frame.version !== undefined) {
1278
1288
  entry.appliedVersion = Math.max(entry.appliedVersion, frame.version);
1279
1289
  }
1290
+ if (frame.cursor !== undefined) {
1291
+ entry.cursor = frame.cursor;
1292
+ }
1280
1293
  recompute(entry);
1281
1294
  } else if (frame.type === "frame") {
1282
1295
  const affected = new Set;
@@ -1289,6 +1302,9 @@ var createSyncClient = (options) => {
1289
1302
  if (frame.version !== undefined) {
1290
1303
  entry.appliedVersion = Math.max(entry.appliedVersion, frame.version);
1291
1304
  }
1305
+ if (frame.cursor !== undefined) {
1306
+ entry.cursor = frame.cursor;
1307
+ }
1292
1308
  rebuild(entry);
1293
1309
  affected.add(entry);
1294
1310
  }
@@ -1321,12 +1337,13 @@ var createSyncClient = (options) => {
1321
1337
  socket?.send(payload);
1322
1338
  };
1323
1339
  const sendSubscribe = (entry) => {
1340
+ const since = entry.cursor ?? (entry.appliedVersion > 0 ? entry.appliedVersion : undefined);
1324
1341
  wsSend(serializer.encodeClient({
1325
1342
  type: "subscribe",
1326
1343
  id: entry.id,
1327
1344
  collection: entry.collection,
1328
1345
  params: entry.params,
1329
- since: entry.appliedVersion > 0 ? entry.appliedVersion : undefined
1346
+ since
1330
1347
  }));
1331
1348
  };
1332
1349
  const sendMutate = (mutation) => {
@@ -1389,6 +1406,7 @@ var createSyncClient = (options) => {
1389
1406
  state: { data: [], status: "connecting", error: undefined },
1390
1407
  listeners: new Set,
1391
1408
  appliedVersion: 0,
1409
+ cursor: undefined,
1392
1410
  closed: false
1393
1411
  };
1394
1412
  entries.set(entryId, entry);
@@ -1541,6 +1559,7 @@ var syncStore = (options) => {
1541
1559
  let attempt = 0;
1542
1560
  let reconnectTimer;
1543
1561
  let appliedVersion = 0;
1562
+ let appliedCursor;
1544
1563
  const applyFrame = (frame) => {
1545
1564
  if (frame.type === "snapshot") {
1546
1565
  confirmed.clear();
@@ -1550,6 +1569,9 @@ var syncStore = (options) => {
1550
1569
  if (frame.version !== undefined) {
1551
1570
  appliedVersion = frame.version;
1552
1571
  }
1572
+ if (frame.cursor !== undefined) {
1573
+ appliedCursor = frame.cursor;
1574
+ }
1553
1575
  recompute({ status: "ready", error: undefined });
1554
1576
  reconcileSettled();
1555
1577
  } else if (frame.type === "diff") {
@@ -1565,6 +1587,9 @@ var syncStore = (options) => {
1565
1587
  if (frame.version !== undefined) {
1566
1588
  appliedVersion = Math.max(appliedVersion, frame.version);
1567
1589
  }
1590
+ if (frame.cursor !== undefined) {
1591
+ appliedCursor = frame.cursor;
1592
+ }
1568
1593
  recompute();
1569
1594
  reconcileSettled();
1570
1595
  } else if (frame.type === "error") {
@@ -1624,7 +1649,7 @@ var syncStore = (options) => {
1624
1649
  id: SUBSCRIPTION_ID2,
1625
1650
  collection: options.collection,
1626
1651
  params: options.params,
1627
- since: appliedVersion > 0 ? appliedVersion : undefined
1652
+ since: appliedCursor ?? (appliedVersion > 0 ? appliedVersion : undefined)
1628
1653
  }));
1629
1654
  for (const mutation of pending) {
1630
1655
  if (!mutation.settled && !mutation.inFlight) {
@@ -1791,5 +1816,5 @@ export {
1791
1816
  createCollaborativeText
1792
1817
  };
1793
1818
 
1794
- //# debugId=91907A0D295C48AD64756E2164756E21
1819
+ //# debugId=12EB9063154AECE864756E2164756E21
1795
1820
  //# sourceMappingURL=index.js.map