@electric-sql/client 1.5.8 → 1.5.10

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.
@@ -1719,7 +1719,7 @@ var PausedState = class _PausedState extends ShapeStreamState {
1719
1719
  constructor(previousState) {
1720
1720
  super();
1721
1721
  this.kind = `paused`;
1722
- this.previousState = previousState;
1722
+ this.previousState = previousState instanceof _PausedState ? previousState.previousState : previousState;
1723
1723
  }
1724
1724
  get handle() {
1725
1725
  return this.previousState.handle;
@@ -1759,7 +1759,20 @@ var PausedState = class _PausedState extends ShapeStreamState {
1759
1759
  if (transition.action === `accepted`) {
1760
1760
  return { action: `accepted`, state: new _PausedState(transition.state) };
1761
1761
  }
1762
- return transition;
1762
+ if (transition.action === `ignored`) {
1763
+ return { action: `ignored`, state: this };
1764
+ }
1765
+ if (transition.action === `stale-retry`) {
1766
+ return {
1767
+ action: `stale-retry`,
1768
+ state: new _PausedState(transition.state),
1769
+ exceededMaxRetries: transition.exceededMaxRetries
1770
+ };
1771
+ }
1772
+ const _exhaustive = transition;
1773
+ throw new Error(
1774
+ `PausedState.handleResponseMetadata: unhandled transition action "${_exhaustive.action}"`
1775
+ );
1763
1776
  }
1764
1777
  withHandle(handle) {
1765
1778
  return new _PausedState(this.previousState.withHandle(handle));
@@ -1778,7 +1791,7 @@ var ErrorState = class _ErrorState extends ShapeStreamState {
1778
1791
  constructor(previousState, error) {
1779
1792
  super();
1780
1793
  this.kind = `error`;
1781
- this.previousState = previousState;
1794
+ this.previousState = previousState instanceof _ErrorState ? previousState.previousState : previousState;
1782
1795
  this.error = error;
1783
1796
  }
1784
1797
  get handle() {
@@ -1799,6 +1812,21 @@ var ErrorState = class _ErrorState extends ShapeStreamState {
1799
1812
  get isUpToDate() {
1800
1813
  return this.previousState.isUpToDate;
1801
1814
  }
1815
+ get staleCacheBuster() {
1816
+ return this.previousState.staleCacheBuster;
1817
+ }
1818
+ get staleCacheRetryCount() {
1819
+ return this.previousState.staleCacheRetryCount;
1820
+ }
1821
+ get sseFallbackToLongPolling() {
1822
+ return this.previousState.sseFallbackToLongPolling;
1823
+ }
1824
+ get consecutiveShortSseConnections() {
1825
+ return this.previousState.consecutiveShortSseConnections;
1826
+ }
1827
+ get replayCursor() {
1828
+ return this.previousState.replayCursor;
1829
+ }
1802
1830
  withHandle(handle) {
1803
1831
  return new _ErrorState(this.previousState.withHandle(handle), this.error);
1804
1832
  }
@@ -2056,7 +2084,6 @@ var ShapeStream = class {
2056
2084
  ));
2057
2085
  __privateSet(this, _fetchClient2, createFetchWithConsumedMessages(__privateGet(this, _sseFetchClient)));
2058
2086
  __privateMethod(this, _ShapeStream_instances, subscribeToVisibilityChanges_fn).call(this);
2059
- __privateMethod(this, _ShapeStream_instances, subscribeToWakeDetection_fn).call(this);
2060
2087
  }
2061
2088
  get shapeHandle() {
2062
2089
  return __privateGet(this, _syncState).handle;
@@ -2306,6 +2333,7 @@ _fastLoopMaxCount = new WeakMap();
2306
2333
  start_fn = async function() {
2307
2334
  var _a, _b;
2308
2335
  __privateSet(this, _started, true);
2336
+ __privateMethod(this, _ShapeStream_instances, subscribeToWakeDetection_fn).call(this);
2309
2337
  try {
2310
2338
  await __privateMethod(this, _ShapeStream_instances, requestShape_fn).call(this);
2311
2339
  } catch (err) {
@@ -2859,6 +2887,7 @@ subscribeToVisibilityChanges_fn = function() {
2859
2887
  document.addEventListener(`visibilitychange`, visibilityHandler);
2860
2888
  __privateSet(this, _unsubscribeFromVisibilityChanges, () => {
2861
2889
  document.removeEventListener(`visibilitychange`, visibilityHandler);
2890
+ __privateSet(this, _unsubscribeFromVisibilityChanges, void 0);
2862
2891
  });
2863
2892
  }
2864
2893
  };
@@ -2876,6 +2905,7 @@ subscribeToVisibilityChanges_fn = function() {
2876
2905
  */
2877
2906
  subscribeToWakeDetection_fn = function() {
2878
2907
  if (__privateMethod(this, _ShapeStream_instances, hasBrowserVisibilityAPI_fn).call(this)) return;
2908
+ if (__privateGet(this, _unsubscribeFromWakeDetection)) return;
2879
2909
  const INTERVAL_MS = 2e3;
2880
2910
  const WAKE_THRESHOLD_MS = 4e3;
2881
2911
  let lastTickTime = Date.now();
@@ -2898,6 +2928,7 @@ subscribeToWakeDetection_fn = function() {
2898
2928
  }
2899
2929
  __privateSet(this, _unsubscribeFromWakeDetection, () => {
2900
2930
  clearInterval(timer);
2931
+ __privateSet(this, _unsubscribeFromWakeDetection, void 0);
2901
2932
  });
2902
2933
  };
2903
2934
  /**