@sanity/client 6.22.4 → 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/_chunks-cjs/resolveEditInfo.cjs +1 -2
- package/dist/_chunks-cjs/resolveEditInfo.cjs.map +1 -1
- package/dist/_chunks-cjs/stegaClean.cjs +1 -2
- package/dist/_chunks-cjs/stegaClean.cjs.map +1 -1
- package/dist/_chunks-cjs/stegaEncodeSourceMap.cjs +1 -2
- package/dist/_chunks-cjs/stegaEncodeSourceMap.cjs.map +1 -1
- package/dist/_chunks-es/resolveEditInfo.js +1 -2
- package/dist/_chunks-es/resolveEditInfo.js.map +1 -1
- package/dist/_chunks-es/stegaClean.js +1 -2
- package/dist/_chunks-es/stegaClean.js.map +1 -1
- package/dist/_chunks-es/stegaEncodeSourceMap.js +1 -2
- package/dist/_chunks-es/stegaEncodeSourceMap.js.map +1 -1
- package/dist/csm.cjs +1 -2
- package/dist/csm.cjs.map +1 -1
- package/dist/csm.js +1 -2
- package/dist/csm.js.map +1 -1
- package/dist/index.browser.cjs +10 -8
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +10 -8
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +11 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +11 -9
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/data/listen.ts +14 -12
- package/src/data/live.ts +1 -1
- package/umd/sanityClient.js +326 -1091
- package/umd/sanityClient.min.js +1 -6
package/dist/index.js
CHANGED
|
@@ -100,8 +100,7 @@ function defineHttpRequest(envMiddleware) {
|
|
|
100
100
|
]);
|
|
101
101
|
}
|
|
102
102
|
function shouldRetry(err, attempt, options) {
|
|
103
|
-
if (options.maxRetries === 0)
|
|
104
|
-
return !1;
|
|
103
|
+
if (options.maxRetries === 0) return !1;
|
|
105
104
|
const isSafe = options.method === "GET" || options.method === "HEAD", isQuery = (options.uri || options.url).startsWith("/data/query"), isRetriableResponse = err.response && (err.response.statusCode === 429 || err.response.statusCode === 502 || err.response.statusCode === 503);
|
|
106
105
|
return (isSafe || isQuery) && isRetriableResponse ? !0 : retry.shouldRetry(err, attempt, options);
|
|
107
106
|
}
|
|
@@ -868,10 +867,13 @@ function _listen(query, params, opts = {}) {
|
|
|
868
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)}`;
|
|
869
868
|
if (uri.length > MAX_URL_LENGTH)
|
|
870
869
|
return new Observable((observer) => observer.error(new Error("Query too large for listener")));
|
|
871
|
-
const listenFor = options.events ? options.events : ["mutation"], shouldEmitReconnect = listenFor.indexOf("reconnect") !== -1
|
|
872
|
-
return
|
|
873
|
-
|
|
874
|
-
|
|
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
|
+
}));
|
|
875
877
|
let es, reconnectTimer, stopped = !1, unsubscribed = !1;
|
|
876
878
|
open();
|
|
877
879
|
function onError() {
|
|
@@ -894,7 +896,7 @@ function _listen(query, params, opts = {}) {
|
|
|
894
896
|
shouldEmitReconnect && observer.next({ type: "reconnect" });
|
|
895
897
|
}
|
|
896
898
|
async function getEventSource() {
|
|
897
|
-
const {
|
|
899
|
+
const { EventSource: EventSource2 } = await import("eventsource");
|
|
898
900
|
if (unsubscribed)
|
|
899
901
|
return;
|
|
900
902
|
const evs = new EventSource2(uri, esOptions);
|
|
@@ -992,7 +994,7 @@ class LiveClient {
|
|
|
992
994
|
}
|
|
993
995
|
}
|
|
994
996
|
async function getEventSource() {
|
|
995
|
-
const EventSourceImplementation = typeof EventSource > "u" || esOptions.headers || esOptions.withCredentials ? (await import("
|
|
997
|
+
const EventSourceImplementation = typeof EventSource > "u" || esOptions.headers || esOptions.withCredentials ? (await import("eventsource")).EventSource : EventSource;
|
|
996
998
|
if (unsubscribed)
|
|
997
999
|
return;
|
|
998
1000
|
try {
|
|
@@ -1550,7 +1552,7 @@ function defineDeprecatedCreateClient(createClient2) {
|
|
|
1550
1552
|
return printNoDefaultExport(), createClient2(config);
|
|
1551
1553
|
};
|
|
1552
1554
|
}
|
|
1553
|
-
var name = "@sanity/client", version = "6.22.
|
|
1555
|
+
var name = "@sanity/client", version = "6.22.5-beta.1";
|
|
1554
1556
|
const middleware = [
|
|
1555
1557
|
debug({ verbose: !0, namespace: "sanity:client" }),
|
|
1556
1558
|
headers({ "User-Agent": `${name} ${version}` }),
|