@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.
@@ -885,10 +885,13 @@ function _listen(query, params, opts = {}) {
885
885
  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)}`;
886
886
  if (uri.length > MAX_URL_LENGTH)
887
887
  return new rxjs.Observable((observer) => observer.error(new Error("Query too large for listener")));
888
- const listenFor = options.events ? options.events : ["mutation"], shouldEmitReconnect = listenFor.indexOf("reconnect") !== -1, esOptions = {};
889
- return (token || withCredentials) && (esOptions.withCredentials = !0), token && (esOptions.headers = {
890
- Authorization: `Bearer ${token}`
891
- }), new rxjs.Observable((observer) => {
888
+ const listenFor = options.events ? options.events : ["mutation"], shouldEmitReconnect = listenFor.indexOf("reconnect") !== -1;
889
+ return new rxjs.Observable((observer) => {
890
+ const esOptions = {};
891
+ (token || withCredentials) && (esOptions.withCredentials = !0), token && (esOptions.fetch = (esUrl, esInit) => globalThis.fetch(esUrl, {
892
+ ...esInit,
893
+ headers: { ...esInit?.headers, Authorization: `Bearer ${token}` }
894
+ }));
892
895
  let es, reconnectTimer, stopped = !1, unsubscribed = !1;
893
896
  open();
894
897
  function onError() {