@sanity/client 6.17.0 → 6.17.1
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/_chunks-cjs/stegaClean.cjs +7 -7
- package/dist/_chunks-cjs/stegaClean.cjs.map +1 -1
- package/dist/_chunks-es/stegaClean.js +7 -7
- package/dist/_chunks-es/stegaClean.js.map +1 -1
- package/dist/index.browser.cjs +8 -10
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +8 -10
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +9 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +9 -11
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/data/listen.ts +19 -10
- package/umd/sanityClient.js +18 -20
- package/umd/sanityClient.min.js +3 -3
package/dist/index.js
CHANGED
|
@@ -856,13 +856,8 @@ function _listen(query, params, opts = {}) {
|
|
|
856
856
|
return (token || withCredentials) && (esOptions.withCredentials = !0), token && (esOptions.headers = {
|
|
857
857
|
Authorization: `Bearer ${token}`
|
|
858
858
|
}), new Observable((observer) => {
|
|
859
|
-
let es;
|
|
860
|
-
|
|
861
|
-
es = eventSource;
|
|
862
|
-
}).catch((reason) => {
|
|
863
|
-
observer.error(reason), stop();
|
|
864
|
-
});
|
|
865
|
-
let reconnectTimer, stopped = !1;
|
|
859
|
+
let es, reconnectTimer, stopped = !1, unsubscribed = !1;
|
|
860
|
+
open();
|
|
866
861
|
function onError() {
|
|
867
862
|
stopped || (emitReconnect(), !stopped && es.readyState === es.CLOSED && (unsubscribe(), clearTimeout(reconnectTimer), reconnectTimer = setTimeout(open, 100)));
|
|
868
863
|
}
|
|
@@ -883,18 +878,21 @@ function _listen(query, params, opts = {}) {
|
|
|
883
878
|
shouldEmitReconnect && observer.next({ type: "reconnect" });
|
|
884
879
|
}
|
|
885
880
|
async function getEventSource() {
|
|
886
|
-
const { default: EventSource } = await import("@sanity/eventsource")
|
|
881
|
+
const { default: EventSource } = await import("@sanity/eventsource");
|
|
882
|
+
if (unsubscribed)
|
|
883
|
+
return;
|
|
884
|
+
const evs = new EventSource(uri, esOptions);
|
|
887
885
|
return evs.addEventListener("error", onError), evs.addEventListener("channelError", onChannelError), evs.addEventListener("disconnect", onDisconnect), listenFor.forEach((type) => evs.addEventListener(type, onMessage)), evs;
|
|
888
886
|
}
|
|
889
887
|
function open() {
|
|
890
888
|
getEventSource().then((eventSource) => {
|
|
891
|
-
es = eventSource;
|
|
889
|
+
eventSource && (es = eventSource);
|
|
892
890
|
}).catch((reason) => {
|
|
893
891
|
observer.error(reason), stop();
|
|
894
892
|
});
|
|
895
893
|
}
|
|
896
894
|
function stop() {
|
|
897
|
-
stopped = !0, unsubscribe();
|
|
895
|
+
stopped = !0, unsubscribe(), unsubscribed = !0;
|
|
898
896
|
}
|
|
899
897
|
return stop;
|
|
900
898
|
});
|
|
@@ -1415,7 +1413,7 @@ function defineDeprecatedCreateClient(createClient2) {
|
|
|
1415
1413
|
return printNoDefaultExport(), createClient2(config);
|
|
1416
1414
|
};
|
|
1417
1415
|
}
|
|
1418
|
-
var name = "@sanity/client", version = "6.17.
|
|
1416
|
+
var name = "@sanity/client", version = "6.17.1";
|
|
1419
1417
|
const middleware = [
|
|
1420
1418
|
debug({ verbose: !0, namespace: "sanity:client" }),
|
|
1421
1419
|
headers({ "User-Agent": `${name} ${version}` }),
|