@sanity/client 6.22.5-beta.0 → 6.22.5-beta.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/index.browser.cjs +7 -4
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +7 -4
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +8 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +8 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/data/listen.ts +11 -9
- package/umd/sanityClient.js +7 -4
- package/umd/sanityClient.min.js +1 -1
package/dist/index.browser.js
CHANGED
|
@@ -867,10 +867,13 @@ function _listen(query, params, opts = {}) {
|
|
|
867
867
|
const { url, token, withCredentials, requestTagPrefix } = this.config(), tag = opts.tag && requestTagPrefix ? [requestTagPrefix, opts.tag].join(".") : opts.tag, options = { ...defaults(opts, defaultOptions), tag }, listenOpts = pick(options, possibleOptions), qs = encodeQueryString({ query, params, options: { tag, ...listenOpts } }), uri = `${url}${_getDataUrl(this, "listen", qs)}`;
|
|
868
868
|
if (uri.length > MAX_URL_LENGTH)
|
|
869
869
|
return new Observable((observer) => observer.error(new Error("Query too large for listener")));
|
|
870
|
-
const listenFor = options.events ? options.events : ["mutation"], shouldEmitReconnect = listenFor.indexOf("reconnect") !== -1
|
|
871
|
-
return
|
|
872
|
-
|
|
873
|
-
|
|
870
|
+
const listenFor = options.events ? options.events : ["mutation"], shouldEmitReconnect = listenFor.indexOf("reconnect") !== -1;
|
|
871
|
+
return new Observable((observer) => {
|
|
872
|
+
const esOptions = {};
|
|
873
|
+
(token || withCredentials) && (esOptions.withCredentials = !0), token && (esOptions.fetch = (esUrl, esInit) => globalThis.fetch(esUrl, {
|
|
874
|
+
...esInit,
|
|
875
|
+
headers: { ...esInit?.headers, Authorization: `Bearer ${token}` }
|
|
876
|
+
}));
|
|
874
877
|
let es, reconnectTimer, stopped = !1, unsubscribed = !1;
|
|
875
878
|
open();
|
|
876
879
|
function onError() {
|