@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.
@@ -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, esOptions = {};
871
- return (token || withCredentials) && (esOptions.withCredentials = !0), token && (esOptions.headers = {
872
- Authorization: `Bearer ${token}`
873
- }), new Observable((observer) => {
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() {