@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.
- package/dist/cjs/index.cjs +35 -4
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.browser.mjs +4 -4
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.legacy-esm.js +35 -4
- package/dist/index.legacy-esm.js.map +1 -1
- package/dist/index.mjs +35 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +4 -1
- package/src/shape-stream-state.ts +72 -35
package/dist/index.legacy-esm.js
CHANGED
|
@@ -1682,7 +1682,7 @@ var PausedState = class _PausedState extends ShapeStreamState {
|
|
|
1682
1682
|
constructor(previousState) {
|
|
1683
1683
|
super();
|
|
1684
1684
|
this.kind = `paused`;
|
|
1685
|
-
this.previousState = previousState;
|
|
1685
|
+
this.previousState = previousState instanceof _PausedState ? previousState.previousState : previousState;
|
|
1686
1686
|
}
|
|
1687
1687
|
get handle() {
|
|
1688
1688
|
return this.previousState.handle;
|
|
@@ -1722,7 +1722,20 @@ var PausedState = class _PausedState extends ShapeStreamState {
|
|
|
1722
1722
|
if (transition.action === `accepted`) {
|
|
1723
1723
|
return { action: `accepted`, state: new _PausedState(transition.state) };
|
|
1724
1724
|
}
|
|
1725
|
-
|
|
1725
|
+
if (transition.action === `ignored`) {
|
|
1726
|
+
return { action: `ignored`, state: this };
|
|
1727
|
+
}
|
|
1728
|
+
if (transition.action === `stale-retry`) {
|
|
1729
|
+
return {
|
|
1730
|
+
action: `stale-retry`,
|
|
1731
|
+
state: new _PausedState(transition.state),
|
|
1732
|
+
exceededMaxRetries: transition.exceededMaxRetries
|
|
1733
|
+
};
|
|
1734
|
+
}
|
|
1735
|
+
const _exhaustive = transition;
|
|
1736
|
+
throw new Error(
|
|
1737
|
+
`PausedState.handleResponseMetadata: unhandled transition action "${_exhaustive.action}"`
|
|
1738
|
+
);
|
|
1726
1739
|
}
|
|
1727
1740
|
withHandle(handle) {
|
|
1728
1741
|
return new _PausedState(this.previousState.withHandle(handle));
|
|
@@ -1741,7 +1754,7 @@ var ErrorState = class _ErrorState extends ShapeStreamState {
|
|
|
1741
1754
|
constructor(previousState, error) {
|
|
1742
1755
|
super();
|
|
1743
1756
|
this.kind = `error`;
|
|
1744
|
-
this.previousState = previousState;
|
|
1757
|
+
this.previousState = previousState instanceof _ErrorState ? previousState.previousState : previousState;
|
|
1745
1758
|
this.error = error;
|
|
1746
1759
|
}
|
|
1747
1760
|
get handle() {
|
|
@@ -1762,6 +1775,21 @@ var ErrorState = class _ErrorState extends ShapeStreamState {
|
|
|
1762
1775
|
get isUpToDate() {
|
|
1763
1776
|
return this.previousState.isUpToDate;
|
|
1764
1777
|
}
|
|
1778
|
+
get staleCacheBuster() {
|
|
1779
|
+
return this.previousState.staleCacheBuster;
|
|
1780
|
+
}
|
|
1781
|
+
get staleCacheRetryCount() {
|
|
1782
|
+
return this.previousState.staleCacheRetryCount;
|
|
1783
|
+
}
|
|
1784
|
+
get sseFallbackToLongPolling() {
|
|
1785
|
+
return this.previousState.sseFallbackToLongPolling;
|
|
1786
|
+
}
|
|
1787
|
+
get consecutiveShortSseConnections() {
|
|
1788
|
+
return this.previousState.consecutiveShortSseConnections;
|
|
1789
|
+
}
|
|
1790
|
+
get replayCursor() {
|
|
1791
|
+
return this.previousState.replayCursor;
|
|
1792
|
+
}
|
|
1765
1793
|
withHandle(handle) {
|
|
1766
1794
|
return new _ErrorState(this.previousState.withHandle(handle), this.error);
|
|
1767
1795
|
}
|
|
@@ -2019,7 +2047,6 @@ var ShapeStream = class {
|
|
|
2019
2047
|
));
|
|
2020
2048
|
__privateSet(this, _fetchClient2, createFetchWithConsumedMessages(__privateGet(this, _sseFetchClient)));
|
|
2021
2049
|
__privateMethod(this, _ShapeStream_instances, subscribeToVisibilityChanges_fn).call(this);
|
|
2022
|
-
__privateMethod(this, _ShapeStream_instances, subscribeToWakeDetection_fn).call(this);
|
|
2023
2050
|
}
|
|
2024
2051
|
get shapeHandle() {
|
|
2025
2052
|
return __privateGet(this, _syncState).handle;
|
|
@@ -2269,6 +2296,7 @@ _fastLoopMaxCount = new WeakMap();
|
|
|
2269
2296
|
start_fn = async function() {
|
|
2270
2297
|
var _a, _b;
|
|
2271
2298
|
__privateSet(this, _started, true);
|
|
2299
|
+
__privateMethod(this, _ShapeStream_instances, subscribeToWakeDetection_fn).call(this);
|
|
2272
2300
|
try {
|
|
2273
2301
|
await __privateMethod(this, _ShapeStream_instances, requestShape_fn).call(this);
|
|
2274
2302
|
} catch (err) {
|
|
@@ -2822,6 +2850,7 @@ subscribeToVisibilityChanges_fn = function() {
|
|
|
2822
2850
|
document.addEventListener(`visibilitychange`, visibilityHandler);
|
|
2823
2851
|
__privateSet(this, _unsubscribeFromVisibilityChanges, () => {
|
|
2824
2852
|
document.removeEventListener(`visibilitychange`, visibilityHandler);
|
|
2853
|
+
__privateSet(this, _unsubscribeFromVisibilityChanges, void 0);
|
|
2825
2854
|
});
|
|
2826
2855
|
}
|
|
2827
2856
|
};
|
|
@@ -2839,6 +2868,7 @@ subscribeToVisibilityChanges_fn = function() {
|
|
|
2839
2868
|
*/
|
|
2840
2869
|
subscribeToWakeDetection_fn = function() {
|
|
2841
2870
|
if (__privateMethod(this, _ShapeStream_instances, hasBrowserVisibilityAPI_fn).call(this)) return;
|
|
2871
|
+
if (__privateGet(this, _unsubscribeFromWakeDetection)) return;
|
|
2842
2872
|
const INTERVAL_MS = 2e3;
|
|
2843
2873
|
const WAKE_THRESHOLD_MS = 4e3;
|
|
2844
2874
|
let lastTickTime = Date.now();
|
|
@@ -2861,6 +2891,7 @@ subscribeToWakeDetection_fn = function() {
|
|
|
2861
2891
|
}
|
|
2862
2892
|
__privateSet(this, _unsubscribeFromWakeDetection, () => {
|
|
2863
2893
|
clearInterval(timer);
|
|
2894
|
+
__privateSet(this, _unsubscribeFromWakeDetection, void 0);
|
|
2864
2895
|
});
|
|
2865
2896
|
};
|
|
2866
2897
|
/**
|