@sanity/client 6.17.1-canary.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 +10 -63
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +0 -32
- package/dist/index.browser.d.ts +0 -32
- package/dist/index.browser.js +10 -63
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +11 -64
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +0 -32
- package/dist/index.d.ts +0 -32
- package/dist/index.js +11 -64
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/SanityClient.ts +0 -4
- package/src/data/listen.ts +19 -10
- package/src/types.ts +0 -21
- package/umd/sanityClient.js +20 -73
- package/umd/sanityClient.min.js +3 -3
- package/src/data/syncTags.ts +0 -88
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var s = { 0: 8203, 1: 8204, 2: 8205, 3: 8290, 4: 8291, 5: 8288, 6: 65279, 7: 8289, 8: 119155, 9: 119156, a: 119157, b: 119158, c: 119159, d: 119160, e: 119161, f: 119162 }, c = { 0: 8203, 1: 8204, 2: 8205, 3: 65279 },
|
|
2
|
+
var s = { 0: 8203, 1: 8204, 2: 8205, 3: 8290, 4: 8291, 5: 8288, 6: 65279, 7: 8289, 8: 119155, 9: 119156, a: 119157, b: 119158, c: 119159, d: 119160, e: 119161, f: 119162 }, c = { 0: 8203, 1: 8204, 2: 8205, 3: 65279 }, u = new Array(4).fill(String.fromCodePoint(c[0])).join("");
|
|
3
3
|
function E(t) {
|
|
4
4
|
let e = JSON.stringify(t);
|
|
5
|
-
return `${
|
|
5
|
+
return `${u}${Array.from(e).map((r) => {
|
|
6
6
|
let n = r.charCodeAt(0);
|
|
7
7
|
if (n > 255)
|
|
8
8
|
throw new Error(`Only ASCII edit info can be encoded. Error attempting to encode ${e} on character ${r} (${n})`);
|
|
@@ -10,9 +10,9 @@ function E(t) {
|
|
|
10
10
|
}).join("")}`;
|
|
11
11
|
}
|
|
12
12
|
function I(t) {
|
|
13
|
-
return Number.isNaN(Number(t)) ? !!Date.parse(t)
|
|
13
|
+
return !Number.isNaN(Number(t)) || /[a-z]/i.test(t) && !/\d+(?:[-:\/]\d+){2}(?:T\d+(?:[-:\/]\d+){1,2}(\.\d+)?Z?)?/.test(t) ? !1 : !!Date.parse(t);
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function T(t) {
|
|
16
16
|
try {
|
|
17
17
|
new URL(t, t.startsWith("/") ? "https://acme.com" : void 0);
|
|
18
18
|
} catch {
|
|
@@ -21,17 +21,17 @@ function x(t) {
|
|
|
21
21
|
return !0;
|
|
22
22
|
}
|
|
23
23
|
function C(t, e, r = "auto") {
|
|
24
|
-
return r === !0 || r === "auto" && (I(t) ||
|
|
24
|
+
return r === !0 || r === "auto" && (I(t) || T(t)) ? t : `${t}${E(e)}`;
|
|
25
25
|
}
|
|
26
26
|
Object.fromEntries(Object.entries(c).map((t) => t.reverse()));
|
|
27
27
|
Object.fromEntries(Object.entries(s).map((t) => t.reverse()));
|
|
28
|
-
var
|
|
28
|
+
var S = `${Object.values(s).map((t) => `\\u{${t.toString(16)}}`).join("")}`, f = new RegExp(`[${S}]{4,}`, "gu");
|
|
29
29
|
function _(t) {
|
|
30
30
|
var e;
|
|
31
31
|
return { cleaned: t.replace(f, ""), encoded: ((e = t.match(f)) == null ? void 0 : e[0]) || "" };
|
|
32
32
|
}
|
|
33
33
|
function O(t) {
|
|
34
|
-
return JSON.parse(_(JSON.stringify(t)).cleaned);
|
|
34
|
+
return t && JSON.parse(_(JSON.stringify(t)).cleaned);
|
|
35
35
|
}
|
|
36
36
|
function stegaClean(result) {
|
|
37
37
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stegaClean.cjs","sources":["../../node_modules/@vercel/stega/dist/index.mjs","../../src/stega/stegaClean.ts"],"sourcesContent":["var s={0:8203,1:8204,2:8205,3:8290,4:8291,5:8288,6:65279,7:8289,8:119155,9:119156,a:119157,b:119158,c:119159,d:119160,e:119161,f:119162},c={0:8203,1:8204,2:8205,3:65279},
|
|
1
|
+
{"version":3,"file":"stegaClean.cjs","sources":["../../node_modules/@vercel/stega/dist/index.mjs","../../src/stega/stegaClean.ts"],"sourcesContent":["var s={0:8203,1:8204,2:8205,3:8290,4:8291,5:8288,6:65279,7:8289,8:119155,9:119156,a:119157,b:119158,c:119159,d:119160,e:119161,f:119162},c={0:8203,1:8204,2:8205,3:65279},u=new Array(4).fill(String.fromCodePoint(c[0])).join(\"\"),m=String.fromCharCode(0);function E(t){let e=JSON.stringify(t);return`${u}${Array.from(e).map(r=>{let n=r.charCodeAt(0);if(n>255)throw new Error(`Only ASCII edit info can be encoded. Error attempting to encode ${e} on character ${r} (${n})`);return Array.from(n.toString(4).padStart(4,\"0\")).map(o=>String.fromCodePoint(c[o])).join(\"\")}).join(\"\")}`}function y(t){let e=JSON.stringify(t);return Array.from(e).map(r=>{let n=r.charCodeAt(0);if(n>255)throw new Error(`Only ASCII edit info can be encoded. Error attempting to encode ${e} on character ${r} (${n})`);return Array.from(n.toString(16).padStart(2,\"0\")).map(o=>String.fromCodePoint(s[o])).join(\"\")}).join(\"\")}function I(t){return!Number.isNaN(Number(t))||/[a-z]/i.test(t)&&!/\\d+(?:[-:\\/]\\d+){2}(?:T\\d+(?:[-:\\/]\\d+){1,2}(\\.\\d+)?Z?)?/.test(t)?!1:Boolean(Date.parse(t))}function T(t){try{new URL(t,t.startsWith(\"/\")?\"https://acme.com\":void 0)}catch{return!1}return!0}function C(t,e,r=\"auto\"){return r===!0||r===\"auto\"&&(I(t)||T(t))?t:`${t}${E(e)}`}var x=Object.fromEntries(Object.entries(c).map(t=>t.reverse())),g=Object.fromEntries(Object.entries(s).map(t=>t.reverse())),S=`${Object.values(s).map(t=>`\\\\u{${t.toString(16)}}`).join(\"\")}`,f=new RegExp(`[${S}]{4,}`,\"gu\");function G(t){let e=t.match(f);if(!!e)return h(e[0],!0)[0]}function $(t){let e=t.match(f);if(!!e)return e.map(r=>h(r)).flat()}function h(t,e=!1){let r=Array.from(t);if(r.length%2===0){if(r.length%4||!t.startsWith(u))return A(r,e)}else throw new Error(\"Encoded data has invalid length\");let n=[];for(let o=r.length*.25;o--;){let p=r.slice(o*4,o*4+4).map(d=>x[d.codePointAt(0)]).join(\"\");n.unshift(String.fromCharCode(parseInt(p,4)))}if(e){n.shift();let o=n.indexOf(m);return o===-1&&(o=n.length),[JSON.parse(n.slice(0,o).join(\"\"))]}return n.join(\"\").split(m).filter(Boolean).map(o=>JSON.parse(o))}function A(t,e){var d;let r=[];for(let i=t.length*.5;i--;){let a=`${g[t[i*2].codePointAt(0)]}${g[t[i*2+1].codePointAt(0)]}`;r.unshift(String.fromCharCode(parseInt(a,16)))}let n=[],o=[r.join(\"\")],p=10;for(;o.length;){let i=o.shift();try{if(n.push(JSON.parse(i)),e)return n}catch(a){if(!p--)throw a;let l=+((d=a.message.match(/\\sposition\\s(\\d+)$/))==null?void 0:d[1]);if(!l)throw a;o.unshift(i.substring(0,l),i.substring(l))}}return n}function _(t){var e;return{cleaned:t.replace(f,\"\"),encoded:((e=t.match(f))==null?void 0:e[0])||\"\"}}function O(t){return t&&JSON.parse(_(JSON.stringify(t)).cleaned)}export{f as VERCEL_STEGA_REGEX,y as legacyStegaEncode,O as vercelStegaClean,C as vercelStegaCombine,G as vercelStegaDecode,$ as vercelStegaDecodeAll,E as vercelStegaEncode,_ as vercelStegaSplit};\n","import {vercelStegaClean} from '@vercel/stega'\n\n/**\n * Can take a `result` JSON from a `const {result} = client.fetch(query, params, {filterResponse: false})`\n * and remove all stega-encoded data from it.\n * @public\n */\nexport function stegaClean<Result = unknown>(result: Result): Result {\n try {\n return vercelStegaClean<Result>(result)\n } catch {\n return result\n }\n}\n\n/**\n * Can take a `result` JSON from a `const {result} = client.fetch(query, params, {filterResponse: false})`\n * and remove all stega-encoded data from it.\n * @alpha\n * @deprecated Use `stegaClean` instead\n */\nexport const vercelStegaCleanAll = stegaClean\n"],"names":["vercelStegaClean"],"mappings":";AAAG,IAAC,IAAE,EAAC,GAAE,MAAK,GAAE,MAAK,GAAE,MAAK,GAAE,MAAK,GAAE,MAAK,GAAE,MAAK,GAAE,OAAM,GAAE,MAAK,GAAE,QAAO,GAAE,QAAO,GAAE,QAAO,GAAE,QAAO,GAAE,QAAO,GAAE,QAAO,GAAE,QAAO,GAAE,OAAM,GAAE,IAAE,EAAC,GAAE,MAAK,GAAE,MAAK,GAAE,MAAK,GAAE,MAAK,GAAE,IAAE,IAAI,MAAM,CAAC,EAAE,KAAK,OAAO,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE;AAA2B,SAAS,EAAE,GAAE;AAAC,MAAI,IAAE,KAAK,UAAU,CAAC;AAAE,SAAM,GAAG,CAAC,GAAG,MAAM,KAAK,CAAC,EAAE,IAAI,OAAG;AAAC,QAAI,IAAE,EAAE,WAAW,CAAC;AAAE,QAAG,IAAE;AAAI,YAAM,IAAI,MAAM,mEAAmE,CAAC,iBAAiB,CAAC,KAAK,CAAC,GAAG;AAAE,WAAO,MAAM,KAAK,EAAE,SAAS,CAAC,EAAE,SAAS,GAAE,GAAG,CAAC,EAAE,IAAI,OAAG,OAAO,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE;AAAA,EAAC,CAAC,EAAE,KAAK,EAAE,CAAC;AAAE;AAA6T,SAAS,EAAE,GAAE;AAAC,SAAM,CAAC,OAAO,MAAM,OAAO,CAAC,CAAC,KAAG,SAAS,KAAK,CAAC,KAAG,CAAC,2DAA2D,KAAK,CAAC,IAAE,KAAG,EAAQ,KAAK,MAAM,CAAC;AAAE;AAAC,SAAS,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: 119162 }, c = { 0: 8203, 1: 8204, 2: 8205, 3: 65279 },
|
|
1
|
+
var s = { 0: 8203, 1: 8204, 2: 8205, 3: 8290, 4: 8291, 5: 8288, 6: 65279, 7: 8289, 8: 119155, 9: 119156, a: 119157, b: 119158, c: 119159, d: 119160, e: 119161, f: 119162 }, c = { 0: 8203, 1: 8204, 2: 8205, 3: 65279 }, u = new Array(4).fill(String.fromCodePoint(c[0])).join("");
|
|
2
2
|
function E(t) {
|
|
3
3
|
let e = JSON.stringify(t);
|
|
4
|
-
return `${
|
|
4
|
+
return `${u}${Array.from(e).map((r) => {
|
|
5
5
|
let n = r.charCodeAt(0);
|
|
6
6
|
if (n > 255)
|
|
7
7
|
throw new Error(`Only ASCII edit info can be encoded. Error attempting to encode ${e} on character ${r} (${n})`);
|
|
@@ -9,9 +9,9 @@ function E(t) {
|
|
|
9
9
|
}).join("")}`;
|
|
10
10
|
}
|
|
11
11
|
function I(t) {
|
|
12
|
-
return Number.isNaN(Number(t)) ? !!Date.parse(t)
|
|
12
|
+
return !Number.isNaN(Number(t)) || /[a-z]/i.test(t) && !/\d+(?:[-:\/]\d+){2}(?:T\d+(?:[-:\/]\d+){1,2}(\.\d+)?Z?)?/.test(t) ? !1 : !!Date.parse(t);
|
|
13
13
|
}
|
|
14
|
-
function
|
|
14
|
+
function T(t) {
|
|
15
15
|
try {
|
|
16
16
|
new URL(t, t.startsWith("/") ? "https://acme.com" : void 0);
|
|
17
17
|
} catch {
|
|
@@ -20,17 +20,17 @@ function x(t) {
|
|
|
20
20
|
return !0;
|
|
21
21
|
}
|
|
22
22
|
function C(t, e, r = "auto") {
|
|
23
|
-
return r === !0 || r === "auto" && (I(t) ||
|
|
23
|
+
return r === !0 || r === "auto" && (I(t) || T(t)) ? t : `${t}${E(e)}`;
|
|
24
24
|
}
|
|
25
25
|
Object.fromEntries(Object.entries(c).map((t) => t.reverse()));
|
|
26
26
|
Object.fromEntries(Object.entries(s).map((t) => t.reverse()));
|
|
27
|
-
var
|
|
27
|
+
var S = `${Object.values(s).map((t) => `\\u{${t.toString(16)}}`).join("")}`, f = new RegExp(`[${S}]{4,}`, "gu");
|
|
28
28
|
function _(t) {
|
|
29
29
|
var e;
|
|
30
30
|
return { cleaned: t.replace(f, ""), encoded: ((e = t.match(f)) == null ? void 0 : e[0]) || "" };
|
|
31
31
|
}
|
|
32
32
|
function O(t) {
|
|
33
|
-
return JSON.parse(_(JSON.stringify(t)).cleaned);
|
|
33
|
+
return t && JSON.parse(_(JSON.stringify(t)).cleaned);
|
|
34
34
|
}
|
|
35
35
|
function stegaClean(result) {
|
|
36
36
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stegaClean.js","sources":["../../node_modules/@vercel/stega/dist/index.mjs","../../src/stega/stegaClean.ts"],"sourcesContent":["var s={0:8203,1:8204,2:8205,3:8290,4:8291,5:8288,6:65279,7:8289,8:119155,9:119156,a:119157,b:119158,c:119159,d:119160,e:119161,f:119162},c={0:8203,1:8204,2:8205,3:65279},
|
|
1
|
+
{"version":3,"file":"stegaClean.js","sources":["../../node_modules/@vercel/stega/dist/index.mjs","../../src/stega/stegaClean.ts"],"sourcesContent":["var s={0:8203,1:8204,2:8205,3:8290,4:8291,5:8288,6:65279,7:8289,8:119155,9:119156,a:119157,b:119158,c:119159,d:119160,e:119161,f:119162},c={0:8203,1:8204,2:8205,3:65279},u=new Array(4).fill(String.fromCodePoint(c[0])).join(\"\"),m=String.fromCharCode(0);function E(t){let e=JSON.stringify(t);return`${u}${Array.from(e).map(r=>{let n=r.charCodeAt(0);if(n>255)throw new Error(`Only ASCII edit info can be encoded. Error attempting to encode ${e} on character ${r} (${n})`);return Array.from(n.toString(4).padStart(4,\"0\")).map(o=>String.fromCodePoint(c[o])).join(\"\")}).join(\"\")}`}function y(t){let e=JSON.stringify(t);return Array.from(e).map(r=>{let n=r.charCodeAt(0);if(n>255)throw new Error(`Only ASCII edit info can be encoded. Error attempting to encode ${e} on character ${r} (${n})`);return Array.from(n.toString(16).padStart(2,\"0\")).map(o=>String.fromCodePoint(s[o])).join(\"\")}).join(\"\")}function I(t){return!Number.isNaN(Number(t))||/[a-z]/i.test(t)&&!/\\d+(?:[-:\\/]\\d+){2}(?:T\\d+(?:[-:\\/]\\d+){1,2}(\\.\\d+)?Z?)?/.test(t)?!1:Boolean(Date.parse(t))}function T(t){try{new URL(t,t.startsWith(\"/\")?\"https://acme.com\":void 0)}catch{return!1}return!0}function C(t,e,r=\"auto\"){return r===!0||r===\"auto\"&&(I(t)||T(t))?t:`${t}${E(e)}`}var x=Object.fromEntries(Object.entries(c).map(t=>t.reverse())),g=Object.fromEntries(Object.entries(s).map(t=>t.reverse())),S=`${Object.values(s).map(t=>`\\\\u{${t.toString(16)}}`).join(\"\")}`,f=new RegExp(`[${S}]{4,}`,\"gu\");function G(t){let e=t.match(f);if(!!e)return h(e[0],!0)[0]}function $(t){let e=t.match(f);if(!!e)return e.map(r=>h(r)).flat()}function h(t,e=!1){let r=Array.from(t);if(r.length%2===0){if(r.length%4||!t.startsWith(u))return A(r,e)}else throw new Error(\"Encoded data has invalid length\");let n=[];for(let o=r.length*.25;o--;){let p=r.slice(o*4,o*4+4).map(d=>x[d.codePointAt(0)]).join(\"\");n.unshift(String.fromCharCode(parseInt(p,4)))}if(e){n.shift();let o=n.indexOf(m);return o===-1&&(o=n.length),[JSON.parse(n.slice(0,o).join(\"\"))]}return n.join(\"\").split(m).filter(Boolean).map(o=>JSON.parse(o))}function A(t,e){var d;let r=[];for(let i=t.length*.5;i--;){let a=`${g[t[i*2].codePointAt(0)]}${g[t[i*2+1].codePointAt(0)]}`;r.unshift(String.fromCharCode(parseInt(a,16)))}let n=[],o=[r.join(\"\")],p=10;for(;o.length;){let i=o.shift();try{if(n.push(JSON.parse(i)),e)return n}catch(a){if(!p--)throw a;let l=+((d=a.message.match(/\\sposition\\s(\\d+)$/))==null?void 0:d[1]);if(!l)throw a;o.unshift(i.substring(0,l),i.substring(l))}}return n}function _(t){var e;return{cleaned:t.replace(f,\"\"),encoded:((e=t.match(f))==null?void 0:e[0])||\"\"}}function O(t){return t&&JSON.parse(_(JSON.stringify(t)).cleaned)}export{f as VERCEL_STEGA_REGEX,y as legacyStegaEncode,O as vercelStegaClean,C as vercelStegaCombine,G as vercelStegaDecode,$ as vercelStegaDecodeAll,E as vercelStegaEncode,_ as vercelStegaSplit};\n","import {vercelStegaClean} from '@vercel/stega'\n\n/**\n * Can take a `result` JSON from a `const {result} = client.fetch(query, params, {filterResponse: false})`\n * and remove all stega-encoded data from it.\n * @public\n */\nexport function stegaClean<Result = unknown>(result: Result): Result {\n try {\n return vercelStegaClean<Result>(result)\n } catch {\n return result\n }\n}\n\n/**\n * Can take a `result` JSON from a `const {result} = client.fetch(query, params, {filterResponse: false})`\n * and remove all stega-encoded data from it.\n * @alpha\n * @deprecated Use `stegaClean` instead\n */\nexport const vercelStegaCleanAll = stegaClean\n"],"names":["vercelStegaClean"],"mappings":"AAAG,IAAC,IAAE,EAAC,GAAE,MAAK,GAAE,MAAK,GAAE,MAAK,GAAE,MAAK,GAAE,MAAK,GAAE,MAAK,GAAE,OAAM,GAAE,MAAK,GAAE,QAAO,GAAE,QAAO,GAAE,QAAO,GAAE,QAAO,GAAE,QAAO,GAAE,QAAO,GAAE,QAAO,GAAE,OAAM,GAAE,IAAE,EAAC,GAAE,MAAK,GAAE,MAAK,GAAE,MAAK,GAAE,MAAK,GAAE,IAAE,IAAI,MAAM,CAAC,EAAE,KAAK,OAAO,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE;AAA2B,SAAS,EAAE,GAAE;AAAC,MAAI,IAAE,KAAK,UAAU,CAAC;AAAE,SAAM,GAAG,CAAC,GAAG,MAAM,KAAK,CAAC,EAAE,IAAI,OAAG;AAAC,QAAI,IAAE,EAAE,WAAW,CAAC;AAAE,QAAG,IAAE;AAAI,YAAM,IAAI,MAAM,mEAAmE,CAAC,iBAAiB,CAAC,KAAK,CAAC,GAAG;AAAE,W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M,EAAE,KAAK,UAAU,CAAC,CAAC,EAAE,OAAO;AAAC;ACO1kF,SAAS,WAA6B,QAAwB;AAC/D,MAAA;AACF,WAAOA,EAAyB,MAAM;AAAA,EAAA,QAChC;AACC,WAAA;AAAA,EACT;AACF;AAQO,MAAM,sBAAsB;","x_google_ignoreList":[0]}
|
package/dist/index.browser.cjs
CHANGED
|
@@ -873,13 +873,8 @@ function _listen(query, params, opts = {}) {
|
|
|
873
873
|
return (token || withCredentials) && (esOptions.withCredentials = !0), token && (esOptions.headers = {
|
|
874
874
|
Authorization: `Bearer ${token}`
|
|
875
875
|
}), new rxjs.Observable((observer) => {
|
|
876
|
-
let es;
|
|
877
|
-
|
|
878
|
-
es = eventSource;
|
|
879
|
-
}).catch((reason) => {
|
|
880
|
-
observer.error(reason), stop();
|
|
881
|
-
});
|
|
882
|
-
let reconnectTimer, stopped = !1;
|
|
876
|
+
let es, reconnectTimer, stopped = !1, unsubscribed = !1;
|
|
877
|
+
open();
|
|
883
878
|
function onError() {
|
|
884
879
|
stopped || (emitReconnect(), !stopped && es.readyState === es.CLOSED && (unsubscribe(), clearTimeout(reconnectTimer), reconnectTimer = setTimeout(open, 100)));
|
|
885
880
|
}
|
|
@@ -900,18 +895,21 @@ function _listen(query, params, opts = {}) {
|
|
|
900
895
|
shouldEmitReconnect && observer.next({ type: "reconnect" });
|
|
901
896
|
}
|
|
902
897
|
async function getEventSource() {
|
|
903
|
-
const { default: EventSource } = await import("@sanity/eventsource")
|
|
898
|
+
const { default: EventSource } = await import("@sanity/eventsource");
|
|
899
|
+
if (unsubscribed)
|
|
900
|
+
return;
|
|
901
|
+
const evs = new EventSource(uri, esOptions);
|
|
904
902
|
return evs.addEventListener("error", onError), evs.addEventListener("channelError", onChannelError), evs.addEventListener("disconnect", onDisconnect), listenFor.forEach((type) => evs.addEventListener(type, onMessage)), evs;
|
|
905
903
|
}
|
|
906
904
|
function open() {
|
|
907
905
|
getEventSource().then((eventSource) => {
|
|
908
|
-
es = eventSource;
|
|
906
|
+
eventSource && (es = eventSource);
|
|
909
907
|
}).catch((reason) => {
|
|
910
908
|
observer.error(reason), stop();
|
|
911
909
|
});
|
|
912
910
|
}
|
|
913
911
|
function stop() {
|
|
914
|
-
stopped = !0, unsubscribe();
|
|
912
|
+
stopped = !0, unsubscribe(), unsubscribed = !0;
|
|
915
913
|
}
|
|
916
914
|
return stop;
|
|
917
915
|
});
|
|
@@ -933,57 +931,6 @@ function cooerceError(err) {
|
|
|
933
931
|
function extractErrorMessage(err) {
|
|
934
932
|
return err.error ? err.error.description ? err.error.description : typeof err.error == "string" ? err.error : JSON.stringify(err.error, null, 2) : err.message || "Unknown listener error";
|
|
935
933
|
}
|
|
936
|
-
function _syncTags(opts = {}) {
|
|
937
|
-
const path = _getDataUrl(this, "sync-tags"), url = new URL(this.getUrl(path, !0));
|
|
938
|
-
return opts.pos && url.searchParams.append("start", opts.pos), new rxjs.Observable((observer) => {
|
|
939
|
-
const controller = new AbortController(), { signal } = controller;
|
|
940
|
-
return fetch(url, { signal }).then(async (res) => {
|
|
941
|
-
if (!res.body)
|
|
942
|
-
throw new TypeError("Response body is not readable");
|
|
943
|
-
const reader = res.body.pipeThrough(new TextDecoderStream()).pipeThrough(splitStream(`
|
|
944
|
-
`)).pipeThrough(parseJSON()).getReader(), results = {
|
|
945
|
-
[Symbol.asyncIterator]() {
|
|
946
|
-
return {
|
|
947
|
-
next: () => reader.read()
|
|
948
|
-
};
|
|
949
|
-
}
|
|
950
|
-
};
|
|
951
|
-
for await (const chunk of results) {
|
|
952
|
-
if (signal.aborted)
|
|
953
|
-
break;
|
|
954
|
-
if (chunk.type === "error") {
|
|
955
|
-
observer.error(chunk);
|
|
956
|
-
break;
|
|
957
|
-
}
|
|
958
|
-
observer.next(chunk);
|
|
959
|
-
}
|
|
960
|
-
}).catch((err) => {
|
|
961
|
-
(err == null ? void 0 : err.name) !== "TimeoutError" && (err == null ? void 0 : err.name) !== "AbortError" && observer.error(err);
|
|
962
|
-
}), () => {
|
|
963
|
-
controller.abort();
|
|
964
|
-
};
|
|
965
|
-
});
|
|
966
|
-
}
|
|
967
|
-
function splitStream(splitOn) {
|
|
968
|
-
let buffer = "";
|
|
969
|
-
return new TransformStream({
|
|
970
|
-
transform(chunk, controller) {
|
|
971
|
-
buffer += chunk;
|
|
972
|
-
const parts = buffer.split(splitOn);
|
|
973
|
-
parts.slice(0, -1).forEach((part) => controller.enqueue(part)), buffer = parts[parts.length - 1];
|
|
974
|
-
},
|
|
975
|
-
flush(controller) {
|
|
976
|
-
buffer && controller.enqueue(buffer);
|
|
977
|
-
}
|
|
978
|
-
});
|
|
979
|
-
}
|
|
980
|
-
function parseJSON() {
|
|
981
|
-
return new TransformStream({
|
|
982
|
-
transform(chunk, controller) {
|
|
983
|
-
chunk && controller.enqueue(JSON.parse(chunk));
|
|
984
|
-
}
|
|
985
|
-
});
|
|
986
|
-
}
|
|
987
934
|
var __accessCheck$3 = (obj, member, msg) => {
|
|
988
935
|
if (!member.has(obj))
|
|
989
936
|
throw TypeError("Cannot " + msg);
|
|
@@ -1188,7 +1135,7 @@ var __defProp2 = Object.defineProperty, __defNormalProp = (obj, key, value) => k
|
|
|
1188
1135
|
}, __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value), _clientConfig, _httpRequest;
|
|
1189
1136
|
const _ObservableSanityClient = class _ObservableSanityClient2 {
|
|
1190
1137
|
constructor(httpRequest, config = defaultConfig) {
|
|
1191
|
-
__publicField(this, "assets"), __publicField(this, "datasets"), __publicField(this, "projects"), __publicField(this, "users"), __privateAdd(this, _clientConfig, void 0), __privateAdd(this, _httpRequest, void 0), __publicField(this, "listen", _listen),
|
|
1138
|
+
__publicField(this, "assets"), __publicField(this, "datasets"), __publicField(this, "projects"), __publicField(this, "users"), __privateAdd(this, _clientConfig, void 0), __privateAdd(this, _httpRequest, void 0), __publicField(this, "listen", _listen), this.config(config), __privateSet(this, _httpRequest, httpRequest), this.assets = new ObservableAssetsClient(this, __privateGet(this, _httpRequest)), this.datasets = new ObservableDatasetsClient(this, __privateGet(this, _httpRequest)), this.projects = new ObservableProjectsClient(this, __privateGet(this, _httpRequest)), this.users = new ObservableUsersClient(this, __privateGet(this, _httpRequest));
|
|
1192
1139
|
}
|
|
1193
1140
|
/**
|
|
1194
1141
|
* Clone the client - returns a new instance
|
|
@@ -1317,7 +1264,7 @@ let ObservableSanityClient = _ObservableSanityClient;
|
|
|
1317
1264
|
var _clientConfig2, _httpRequest2;
|
|
1318
1265
|
const _SanityClient = class _SanityClient2 {
|
|
1319
1266
|
constructor(httpRequest, config = defaultConfig) {
|
|
1320
|
-
__publicField(this, "assets"), __publicField(this, "datasets"), __publicField(this, "projects"), __publicField(this, "users"), __publicField(this, "observable"), __privateAdd(this, _clientConfig2, void 0), __privateAdd(this, _httpRequest2, void 0), __publicField(this, "listen", _listen),
|
|
1267
|
+
__publicField(this, "assets"), __publicField(this, "datasets"), __publicField(this, "projects"), __publicField(this, "users"), __publicField(this, "observable"), __privateAdd(this, _clientConfig2, void 0), __privateAdd(this, _httpRequest2, void 0), __publicField(this, "listen", _listen), this.config(config), __privateSet(this, _httpRequest2, httpRequest), this.assets = new AssetsClient(this, __privateGet(this, _httpRequest2)), this.datasets = new DatasetsClient(this, __privateGet(this, _httpRequest2)), this.projects = new ProjectsClient(this, __privateGet(this, _httpRequest2)), this.users = new UsersClient(this, __privateGet(this, _httpRequest2)), this.observable = new ObservableSanityClient(httpRequest, config);
|
|
1321
1268
|
}
|
|
1322
1269
|
/**
|
|
1323
1270
|
* Clone the client - returns a new instance
|