@electric-sql/client 1.5.5 → 1.5.6
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 +24 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.browser.mjs +3 -3
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.legacy-esm.js +24 -1
- package/dist/index.legacy-esm.js.map +1 -1
- package/dist/index.mjs +24 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +12 -1
- package/src/fetch.ts +26 -0
- package/src/shape-stream-state.ts +13 -0
package/dist/cjs/index.cjs
CHANGED
|
@@ -646,6 +646,12 @@ function createFetchWithChunkBuffer(fetchClient, prefetchOptions = ChunkPrefetch
|
|
|
646
646
|
let prefetchQueue;
|
|
647
647
|
const prefetchClient = async (...args) => {
|
|
648
648
|
const url = args[0].toString();
|
|
649
|
+
const method = getRequestMethod(args[0], args[1]);
|
|
650
|
+
if (method !== `GET`) {
|
|
651
|
+
prefetchQueue == null ? void 0 : prefetchQueue.abort();
|
|
652
|
+
prefetchQueue = void 0;
|
|
653
|
+
return fetchClient(...args);
|
|
654
|
+
}
|
|
649
655
|
const prefetchedRequest = prefetchQueue == null ? void 0 : prefetchQueue.consume(...args);
|
|
650
656
|
if (prefetchedRequest) {
|
|
651
657
|
return prefetchedRequest;
|
|
@@ -815,6 +821,15 @@ function chainAborter(aborter, sourceSignal) {
|
|
|
815
821
|
}
|
|
816
822
|
function noop() {
|
|
817
823
|
}
|
|
824
|
+
function getRequestMethod(input, init) {
|
|
825
|
+
if (init == null ? void 0 : init.method) {
|
|
826
|
+
return init.method.toUpperCase();
|
|
827
|
+
}
|
|
828
|
+
if (typeof Request !== `undefined` && input instanceof Request) {
|
|
829
|
+
return input.method.toUpperCase();
|
|
830
|
+
}
|
|
831
|
+
return `GET`;
|
|
832
|
+
}
|
|
818
833
|
|
|
819
834
|
// src/expression-compiler.ts
|
|
820
835
|
function compileExpression(expr, columnMapper) {
|
|
@@ -1491,6 +1506,12 @@ var FetchingState = class extends ActiveState {
|
|
|
1491
1506
|
const staleResult = this.checkStaleResponse(input);
|
|
1492
1507
|
if (staleResult) return staleResult;
|
|
1493
1508
|
const shared = this.parseResponseFields(input);
|
|
1509
|
+
if (input.status === 204) {
|
|
1510
|
+
return {
|
|
1511
|
+
action: `accepted`,
|
|
1512
|
+
state: new LiveState(shared, { sseFallbackToLongPolling: true })
|
|
1513
|
+
};
|
|
1514
|
+
}
|
|
1494
1515
|
return { action: `accepted`, state: new SyncingState(shared) };
|
|
1495
1516
|
}
|
|
1496
1517
|
canEnterReplayMode() {
|
|
@@ -2639,7 +2660,9 @@ requestShapeSSE_fn = async function(opts) {
|
|
|
2639
2660
|
if (requestAbortController.signal.aborted) {
|
|
2640
2661
|
throw new FetchBackoffAbortError();
|
|
2641
2662
|
}
|
|
2642
|
-
|
|
2663
|
+
if (error instanceof FetchError || error instanceof StaleCacheError || error instanceof MissingHeadersError) {
|
|
2664
|
+
throw error;
|
|
2665
|
+
}
|
|
2643
2666
|
} finally {
|
|
2644
2667
|
const connectionDuration = Date.now() - __privateGet(this, _lastSseConnectionStartTime);
|
|
2645
2668
|
const wasAborted = requestAbortController.signal.aborted;
|