@sanity/client 6.24.2 → 6.24.4
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/csm.d.cts +99 -34
- package/dist/csm.d.ts +99 -34
- package/dist/index.browser.cjs +188 -128
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +112 -4
- package/dist/index.browser.d.ts +112 -4
- package/dist/index.browser.js +189 -129
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +189 -129
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +112 -4
- package/dist/index.d.ts +112 -4
- package/dist/index.js +190 -130
- package/dist/index.js.map +1 -1
- package/dist/stega.browser.d.cts +3419 -96
- package/dist/stega.browser.d.ts +3419 -96
- package/dist/stega.d.cts +3419 -96
- package/dist/stega.d.ts +3419 -96
- package/package.json +4 -4
- package/src/data/eventsource.ts +255 -0
- package/src/data/eventsourcePolyfill.ts +7 -0
- package/src/data/listen.ts +31 -142
- package/src/data/live.ts +60 -120
- package/src/data/reconnectOnConnectionFailure.ts +30 -0
- package/src/data/transaction.ts +26 -1
- package/src/defineCreateClient.ts +11 -0
- package/src/types.ts +10 -0
- package/umd/sanityClient.js +988 -144
- package/umd/sanityClient.min.js +2 -2
package/umd/sanityClient.js
CHANGED
|
@@ -4,11 +4,26 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.SanityClient = {}));
|
|
5
5
|
})(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
|
+
function _mergeNamespaces(n, m) {
|
|
8
|
+
m.forEach(function (e) {
|
|
9
|
+
e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
|
|
10
|
+
if (k !== 'default' && !(k in n)) {
|
|
11
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
12
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () { return e[k]; }
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
return Object.freeze(n);
|
|
20
|
+
}
|
|
21
|
+
|
|
7
22
|
const e=!(typeof navigator>"u")&&"ReactNative"===navigator.product,t={timeout:e?6e4:12e4},r=function(r){const a={...t,..."string"==typeof r?{url:r}:r};if(a.timeout=n$1(a.timeout),a.query){const{url:t,searchParams:r}=function(t){const r=t.indexOf("?");if(-1===r)return {url:t,searchParams:new URLSearchParams};const n=t.slice(0,r),a=t.slice(r+1);if(!e)return {url:n,searchParams:new URLSearchParams(a)};if("function"!=typeof decodeURIComponent)throw new Error("Broken `URLSearchParams` implementation, and `decodeURIComponent` is not defined");const s=new URLSearchParams;for(const e of a.split("&")){const[t,r]=e.split("=");t&&s.append(o$1(t),o$1(r||""));}return {url:n,searchParams:s}}(a.url);for(const[e,o]of Object.entries(a.query)){if(undefined!==o)if(Array.isArray(o))for(const t of o)r.append(e,t);else r.append(e,o);const n=r.toString();n&&(a.url=`${t}?${n}`);}}return a.method=a.body&&!a.method?"POST":(a.method||"GET").toUpperCase(),a};function o$1(e){return decodeURIComponent(e.replace(/\+/g," "))}function n$1(e){if(false===e||0===e)return false;if(e.connect||e.socket)return e;const r=Number(e);return isNaN(r)?n$1(t.timeout):{connect:r,socket:r}}const a$2=/^https?:\/\//i,s$2=function(e){if(!a$2.test(e.url))throw new Error(`"${e.url}" is not a valid URL`)};function c$3(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}
|
|
8
23
|
|
|
9
|
-
const o=["request","response","progress","error","abort"],s$1=["processOptions","validateOptions","interceptRequest","finalizeOptions","onRequest","onResponse","onError","onReturn","onHeaders"];function n(r$1,a){const i=[],u=s$1.reduce(((e,t)=>(e[t]=e[t]||[],e)),{processOptions:[r],validateOptions:[s$2]});function l(e){const t=o.reduce(((e,t)=>(e[t]=function(){const e
|
|
24
|
+
const o=["request","response","progress","error","abort"],s$1=["processOptions","validateOptions","interceptRequest","finalizeOptions","onRequest","onResponse","onError","onReturn","onHeaders"];function n(r$1,a){const i=[],u=s$1.reduce(((e,t)=>(e[t]=e[t]||[],e)),{processOptions:[r],validateOptions:[s$2]});function l(e){const t=o.reduce(((e,t)=>(e[t]=function(){const e=/* @__PURE__ */Object.create(null);let t=0;return {publish:function(t){for(const r in e)e[r](t);},subscribe:function(r){const o=t++;return e[o]=r,function(){delete e[o];}}}}(),e)),{}),r=(e=>function(t,r,...o){const s="onError"===t;let n=r;for(let r=0;r<e[t].length&&(n=(0, e[t][r])(n,...o),!s||n);r++);return n})(u),s=r("processOptions",e);r("validateOptions",s);const n={options:s,channels:t,applyMiddleware:r};let i;const l=t.request.subscribe((e=>{i=a(e,((o,s)=>((e,o,s)=>{let n=e,a=o;if(!n)try{a=r("onResponse",o,s);}catch(e){a=null,n=e;}n=n&&r("onError",n,s),n?t.error.publish(n):a&&t.response.publish(a);})(o,s,e)));}));t.abort.subscribe((()=>{l(),i&&i.abort();}));const c=r("onReturn",t,n);return c===t&&t.request.publish(n),c}return l.use=function(e){if(!e)throw new Error("Tried to add middleware that resolved to falsey value");if("function"==typeof e)throw new Error("Tried to add middleware that was a function. It probably expects you to pass options to it.");if(e.onReturn&&u.onReturn.length>0)throw new Error("Tried to add new middleware with `onReturn` handler, but another handler has already been registered for this event");return s$1.forEach((t=>{e[t]&&u[t].push(e[t]);})),i.push(e),l},l.clone=()=>n(i,a),r$1.forEach(l.use),l}var a$1,i,u$2=/* @__PURE__ */c$3(function(){if(i)return a$1;i=1;var e=function(e){return e.replace(/^\s+|\s+$/g,"")};return a$1=function(t){if(!t)return {};for(var r={},o=e(t).split("\n"),s=0;s<o.length;s++){var n=o[s],a=n.indexOf(":"),i=e(n.slice(0,a)).toLowerCase(),u=e(n.slice(a+1));typeof r[i]>"u"?r[i]=u:(l=r[i],"[object Array]"===Object.prototype.toString.call(l)?r[i].push(u):r[i]=[r[i],u]);}var l;return r}}());let l$1 = class l{onabort;onerror;onreadystatechange;ontimeout;readyState=0;response;responseText="";responseType="";status;statusText;withCredentials;#e;#t;#r;#o={};#s;#n={};#a;open(e,t,r){this.#e=e,this.#t=t,this.#r="",this.readyState=1,this.onreadystatechange?.(),this.#s=undefined;}abort(){this.#s&&this.#s.abort();}getAllResponseHeaders(){return this.#r}setRequestHeader(e,t){this.#o[e]=t;}setInit(e,t=true){this.#n=e,this.#a=t;}send(e){const t="arraybuffer"!==this.responseType,r={...this.#n,method:this.#e,headers:this.#o,body:e};"function"==typeof AbortController&&this.#a&&(this.#s=new AbortController,typeof EventTarget<"u"&&this.#s.signal instanceof EventTarget&&(r.signal=this.#s.signal)),typeof document<"u"&&(r.credentials=this.withCredentials?"include":"omit"),fetch(this.#t,r).then((e=>(e.headers.forEach(((e,t)=>{this.#r+=`${t}: ${e}\r\n`;})),this.status=e.status,this.statusText=e.statusText,this.readyState=3,this.onreadystatechange?.(),t?e.text():e.arrayBuffer()))).then((e=>{"string"==typeof e?this.responseText=e:this.response=e,this.readyState=4,this.onreadystatechange?.();})).catch((e=>{"AbortError"!==e.name?this.onerror?.(e):this.onabort?.();}));}};const c$2="function"==typeof XMLHttpRequest?"xhr":"fetch",h="xhr"===c$2?XMLHttpRequest:l$1,d$1=(e,t)=>{const r=e.options,o=e.applyMiddleware("finalizeOptions",r),s={},n=e.applyMiddleware("interceptRequest",undefined,{adapter:c$2,context:e});if(n){const e=setTimeout(t,0,null,n);return {abort:()=>clearTimeout(e)}}let a=new h;a instanceof l$1&&"object"==typeof o.fetch&&a.setInit(o.fetch,o.useAbortSignal??true);const i=o.headers,d=o.timeout;let p=false,f=false,b=false;if(a.onerror=e=>{m(a instanceof l$1?e instanceof Error?e:new Error(`Request error while attempting to reach is ${o.url}`,{cause:e}):new Error(`Request error while attempting to reach is ${o.url}${e.lengthComputable?`(${e.loaded} of ${e.total} bytes transferred)`:""}`));},a.ontimeout=e=>{m(new Error(`Request timeout while attempting to reach ${o.url}${e.lengthComputable?`(${e.loaded} of ${e.total} bytes transferred)`:""}`));},a.onabort=()=>{w(true),p=true;},a.onreadystatechange=()=>{d&&(w(),s.socket=setTimeout((()=>y("ESOCKETTIMEDOUT")),d.socket)),!p&&4===a.readyState&&0!==a.status&&function(){if(!(p||f||b)){if(0===a.status)return void m(new Error("Unknown XHR error"));w(),f=true,t(null,{body:a.response||(""===a.responseType||"text"===a.responseType?a.responseText:""),url:o.url,method:o.method,headers:u$2(a.getAllResponseHeaders()),statusCode:a.status,statusMessage:a.statusText});}}();},a.open(o.method,o.url,true),a.withCredentials=!!o.withCredentials,i&&a.setRequestHeader)for(const e in i)i.hasOwnProperty(e)&&a.setRequestHeader(e,i[e]);return o.rawBody&&(a.responseType="arraybuffer"),e.applyMiddleware("onRequest",{options:o,adapter:c$2,request:a,context:e}),a.send(o.body||null),d&&(s.connect=setTimeout((()=>y("ETIMEDOUT")),d.connect)),{abort:function(){p=true,a&&a.abort();}};function y(t){b=true,a.abort();const r=new Error("ESOCKETTIMEDOUT"===t?`Socket timed out on request to ${o.url}`:`Connection timed out on request to ${o.url}`);r.code=t,e.channels.error.publish(r);}function w(e){(e||p||a.readyState>=2&&s.connect)&&clearTimeout(s.connect),s.socket&&clearTimeout(s.socket);}function m(e){if(f)return;w(true),f=true,a=null;const r=e||new Error(`Network error while attempting to reach ${o.url}`);r.isNetworkError=true,r.request=o,t(r);}},p$1=(e=[],t=d$1)=>n(e,t),f$1="browser";
|
|
10
25
|
|
|
11
|
-
var a,c$1,u$1={exports:{}}
|
|
26
|
+
var a,c$1,u$1,l,p,d={exports:{}};/* @__PURE__ */c$3((p||(p=1,function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const s="color: "+this.color;t.splice(1,0,s,"color: inherit");let n=0,r=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(n++,"%c"===e&&(r=n));})),t.splice(r,0,s);},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug");}catch{}},t.load=function(){let e;try{e=t.storage.getItem("debug");}catch{}return !e&&typeof process<"u"&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){return !(!(typeof window<"u"&&window.process)||"renderer"!==window.process.type&&!window.process.__nwjs)||!(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&(typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},t.storage=function(){try{return localStorage}catch{}}(),t.destroy=/* @__PURE__ */(()=>{let e=false;return ()=>{e||(e=true,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."));}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=(l?u$1:(l=1,u$1=function(e){function t(e){let n,r,o,i=null;function a(...e){if(!a.enabled)return;const s=a,r=Number(/* @__PURE__ */new Date),o=r-(n||r);s.diff=o,s.prev=n,s.curr=r,n=r,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,r)=>{if("%%"===n)return "%";i++;const o=t.formatters[r];if("function"==typeof o){const t=e[i];n=o.call(s,t),e.splice(i,1),i--;}return n})),t.formatArgs.call(s,e),(s.log||t.log).apply(s,e);}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=s,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:true,configurable:false,get:()=>null!==i?i:(r!==t.namespaces&&(r=t.namespaces,o=t.enabled(e)),o),set:e=>{i=e;}}),"function"==typeof t.init&&t.init(a),a}function s(e,s){const n=t(this.namespace+(typeof s>"u"?":":s)+e);return n.log=this.log,n}function n(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names.map(n),...t.skips.map(n).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let s;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"==typeof e?e:"").split(/[\s,]+/),r=n.length;for(s=0;s<r;s++)n[s]&&("-"===(e=n[s].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.slice(1)+"$")):t.names.push(new RegExp("^"+e+"$")));},t.enabled=function(e){if("*"===e[e.length-1])return true;let s,n;for(s=0,n=t.skips.length;s<n;s++)if(t.skips[s].test(e))return false;for(s=0,n=t.names.length;s<n;s++)if(t.names[s].test(e))return true;return false},t.humanize=function(){if(c$1)return a;c$1=1;var e=1e3,t=60*e,s=60*t,n=24*s,r=7*n;function o(e,t,s,n){var r=t>=1.5*s;return Math.round(e/s)+" "+n+(r?"s":"")}return a=function(i,a){a=a||{};var c,u,l=typeof i;if("string"===l&&i.length>0)return function(o){if(!((o=String(o)).length>100)){var i=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(o);if(i){var a=parseFloat(i[1]);switch((i[2]||"ms").toLowerCase()){case "years":case "year":case "yrs":case "yr":case "y":return 315576e5*a;case "weeks":case "week":case "w":return a*r;case "days":case "day":case "d":return a*n;case "hours":case "hour":case "hrs":case "hr":case "h":return a*s;case "minutes":case "minute":case "mins":case "min":case "m":return a*t;case "seconds":case "second":case "secs":case "sec":case "s":return a*e;case "milliseconds":case "millisecond":case "msecs":case "msec":case "ms":return a;default:return}}}}(i);if("number"===l&&isFinite(i))return a.long?(c=i,(u=Math.abs(c))>=n?o(c,u,n,"day"):u>=s?o(c,u,s,"hour"):u>=t?o(c,u,t,"minute"):u>=e?o(c,u,e,"second"):c+" ms"):function(r){var o=Math.abs(r);return o>=n?Math.round(r/n)+"d":o>=s?Math.round(r/s)+"h":o>=t?Math.round(r/t)+"m":o>=e?Math.round(r/e)+"s":r+"ms"}(i);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(i))}}(),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");},Object.keys(e).forEach((s=>{t[s]=e[s];})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let s=0;for(let t=0;t<e.length;t++)s=(s<<5)-s+e.charCodeAt(t),s|=0;return t.colors[Math.abs(s)%t.colors.length]},t.enable(t.load()),t}))(t);const{formatters:s}=e.exports;s.j=function(e){try{return JSON.stringify(e)}catch(e){return "[UnexpectedJSONParseError]: "+e.message}};}(d,d.exports)),d.exports));const F=typeof Buffer>"u"?()=>false:e=>Buffer.isBuffer(e);function O$1(e){return "[object Object]"===Object.prototype.toString.call(e)}function j(e){if(false===O$1(e))return false;const t=e.constructor;if(undefined===t)return true;const s=t.prototype;return !(false===O$1(s)||false===s.hasOwnProperty("isPrototypeOf"))}const v=["boolean","string","number"];function x(){return {processOptions:e=>{const t=e.body;return !t||"function"==typeof t.pipe||F(t)||-1===v.indexOf(typeof t)&&!Array.isArray(t)&&!j(t)?e:Object.assign({},e,{body:JSON.stringify(e.body),headers:Object.assign({},e.headers,{"Content-Type":"application/json"})})}}}function E$1(e){return {onResponse:s=>{const n=s.headers["content-type"]||"",r=e&&e.force||-1!==n.indexOf("application/json");return s.body&&n&&r?Object.assign({},s,{body:t(s.body)}):s},processOptions:e=>Object.assign({},e,{headers:Object.assign({Accept:"application/json"},e.headers)})};function t(e){try{return JSON.parse(e)}catch(e){throw e.message=`Failed to parsed response body as JSON: ${e.message}`,e}}}let k={};typeof globalThis<"u"?k=globalThis:typeof window<"u"?k=window:typeof global<"u"?k=global:typeof self<"u"&&(k=self);var q=k;function A(e={}){const t=e.implementation||q.Observable;if(!t)throw new Error("`Observable` is not available in global scope, and no implementation was passed");return {onReturn:(e,s)=>new t((t=>(e.error.subscribe((e=>t.error(e))),e.progress.subscribe((e=>t.next(Object.assign({type:"progress"},e)))),e.response.subscribe((e=>{t.next(Object.assign({type:"response"},e)),t.complete();})),e.request.publish(s),()=>e.abort.publish())))}}function S$1(){return {onRequest:e=>{if("xhr"!==e.adapter)return;const t=e.request,s=e.context;function n(e){return t=>{const n=t.lengthComputable?t.loaded/t.total*100:-1;s.channels.progress.publish({stage:e,percent:n,total:t.total,loaded:t.loaded,lengthComputable:t.lengthComputable});}}"upload"in t&&"onprogress"in t.upload&&(t.upload.onprogress=n("upload")),"onprogress"in t&&(t.onprogress=n("download"));}}}var M=(e,t,s)=>("GET"===s.method||"HEAD"===s.method)&&(e.isNetworkError||false);function _$1(e){return 100*Math.pow(2,e)+100*Math.random()}const P=(e={})=>(e=>{const t=e.maxRetries||5,s=e.retryDelay||_$1,n=e.shouldRetry;return {onError:(e,r)=>{const o=r.options,i=o.maxRetries||t,a=o.retryDelay||s,c=o.shouldRetry||n,u=o.attemptNumber||0;if(null!==(l=o.body)&&"object"==typeof l&&"function"==typeof l.pipe||!c(e,u,o)||u>=i)return e;var l;const p=Object.assign({},r,{options:Object.assign({},o,{attemptNumber:u+1})});return setTimeout((()=>r.channels.request.publish(p)),a(u)),null}}})({shouldRetry:M,...e});P.shouldRetry=M;
|
|
12
27
|
|
|
13
28
|
/******************************************************************************
|
|
14
29
|
Copyright (c) Microsoft Corporation.
|
|
@@ -305,7 +320,7 @@
|
|
|
305
320
|
})();
|
|
306
321
|
return Subscription;
|
|
307
322
|
}());
|
|
308
|
-
Subscription.EMPTY;
|
|
323
|
+
var EMPTY_SUBSCRIPTION = Subscription.EMPTY;
|
|
309
324
|
function isSubscription(value) {
|
|
310
325
|
return (value instanceof Subscription ||
|
|
311
326
|
(value && 'closed' in value && isFunction(value.remove) && isFunction(value.add) && isFunction(value.unsubscribe)));
|
|
@@ -700,12 +715,404 @@
|
|
|
700
715
|
return OperatorSubscriber;
|
|
701
716
|
}(Subscriber));
|
|
702
717
|
|
|
718
|
+
var ObjectUnsubscribedError = createErrorClass(function (_super) {
|
|
719
|
+
return function ObjectUnsubscribedErrorImpl() {
|
|
720
|
+
_super(this);
|
|
721
|
+
this.name = 'ObjectUnsubscribedError';
|
|
722
|
+
this.message = 'object unsubscribed';
|
|
723
|
+
};
|
|
724
|
+
});
|
|
725
|
+
|
|
726
|
+
var Subject = (function (_super) {
|
|
727
|
+
__extends(Subject, _super);
|
|
728
|
+
function Subject() {
|
|
729
|
+
var _this = _super.call(this) || this;
|
|
730
|
+
_this.closed = false;
|
|
731
|
+
_this.currentObservers = null;
|
|
732
|
+
_this.observers = [];
|
|
733
|
+
_this.isStopped = false;
|
|
734
|
+
_this.hasError = false;
|
|
735
|
+
_this.thrownError = null;
|
|
736
|
+
return _this;
|
|
737
|
+
}
|
|
738
|
+
Subject.prototype.lift = function (operator) {
|
|
739
|
+
var subject = new AnonymousSubject(this, this);
|
|
740
|
+
subject.operator = operator;
|
|
741
|
+
return subject;
|
|
742
|
+
};
|
|
743
|
+
Subject.prototype._throwIfClosed = function () {
|
|
744
|
+
if (this.closed) {
|
|
745
|
+
throw new ObjectUnsubscribedError();
|
|
746
|
+
}
|
|
747
|
+
};
|
|
748
|
+
Subject.prototype.next = function (value) {
|
|
749
|
+
var _this = this;
|
|
750
|
+
errorContext(function () {
|
|
751
|
+
var e_1, _a;
|
|
752
|
+
_this._throwIfClosed();
|
|
753
|
+
if (!_this.isStopped) {
|
|
754
|
+
if (!_this.currentObservers) {
|
|
755
|
+
_this.currentObservers = Array.from(_this.observers);
|
|
756
|
+
}
|
|
757
|
+
try {
|
|
758
|
+
for (var _b = __values(_this.currentObservers), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
759
|
+
var observer = _c.value;
|
|
760
|
+
observer.next(value);
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
764
|
+
finally {
|
|
765
|
+
try {
|
|
766
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
767
|
+
}
|
|
768
|
+
finally { if (e_1) throw e_1.error; }
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
});
|
|
772
|
+
};
|
|
773
|
+
Subject.prototype.error = function (err) {
|
|
774
|
+
var _this = this;
|
|
775
|
+
errorContext(function () {
|
|
776
|
+
_this._throwIfClosed();
|
|
777
|
+
if (!_this.isStopped) {
|
|
778
|
+
_this.hasError = _this.isStopped = true;
|
|
779
|
+
_this.thrownError = err;
|
|
780
|
+
var observers = _this.observers;
|
|
781
|
+
while (observers.length) {
|
|
782
|
+
observers.shift().error(err);
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
});
|
|
786
|
+
};
|
|
787
|
+
Subject.prototype.complete = function () {
|
|
788
|
+
var _this = this;
|
|
789
|
+
errorContext(function () {
|
|
790
|
+
_this._throwIfClosed();
|
|
791
|
+
if (!_this.isStopped) {
|
|
792
|
+
_this.isStopped = true;
|
|
793
|
+
var observers = _this.observers;
|
|
794
|
+
while (observers.length) {
|
|
795
|
+
observers.shift().complete();
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
});
|
|
799
|
+
};
|
|
800
|
+
Subject.prototype.unsubscribe = function () {
|
|
801
|
+
this.isStopped = this.closed = true;
|
|
802
|
+
this.observers = this.currentObservers = null;
|
|
803
|
+
};
|
|
804
|
+
Object.defineProperty(Subject.prototype, "observed", {
|
|
805
|
+
get: function () {
|
|
806
|
+
var _a;
|
|
807
|
+
return ((_a = this.observers) === null || _a === undefined ? undefined : _a.length) > 0;
|
|
808
|
+
},
|
|
809
|
+
enumerable: false,
|
|
810
|
+
configurable: true
|
|
811
|
+
});
|
|
812
|
+
Subject.prototype._trySubscribe = function (subscriber) {
|
|
813
|
+
this._throwIfClosed();
|
|
814
|
+
return _super.prototype._trySubscribe.call(this, subscriber);
|
|
815
|
+
};
|
|
816
|
+
Subject.prototype._subscribe = function (subscriber) {
|
|
817
|
+
this._throwIfClosed();
|
|
818
|
+
this._checkFinalizedStatuses(subscriber);
|
|
819
|
+
return this._innerSubscribe(subscriber);
|
|
820
|
+
};
|
|
821
|
+
Subject.prototype._innerSubscribe = function (subscriber) {
|
|
822
|
+
var _this = this;
|
|
823
|
+
var _a = this, hasError = _a.hasError, isStopped = _a.isStopped, observers = _a.observers;
|
|
824
|
+
if (hasError || isStopped) {
|
|
825
|
+
return EMPTY_SUBSCRIPTION;
|
|
826
|
+
}
|
|
827
|
+
this.currentObservers = null;
|
|
828
|
+
observers.push(subscriber);
|
|
829
|
+
return new Subscription(function () {
|
|
830
|
+
_this.currentObservers = null;
|
|
831
|
+
arrRemove(observers, subscriber);
|
|
832
|
+
});
|
|
833
|
+
};
|
|
834
|
+
Subject.prototype._checkFinalizedStatuses = function (subscriber) {
|
|
835
|
+
var _a = this, hasError = _a.hasError, thrownError = _a.thrownError, isStopped = _a.isStopped;
|
|
836
|
+
if (hasError) {
|
|
837
|
+
subscriber.error(thrownError);
|
|
838
|
+
}
|
|
839
|
+
else if (isStopped) {
|
|
840
|
+
subscriber.complete();
|
|
841
|
+
}
|
|
842
|
+
};
|
|
843
|
+
Subject.prototype.asObservable = function () {
|
|
844
|
+
var observable = new Observable();
|
|
845
|
+
observable.source = this;
|
|
846
|
+
return observable;
|
|
847
|
+
};
|
|
848
|
+
Subject.create = function (destination, source) {
|
|
849
|
+
return new AnonymousSubject(destination, source);
|
|
850
|
+
};
|
|
851
|
+
return Subject;
|
|
852
|
+
}(Observable));
|
|
853
|
+
var AnonymousSubject = (function (_super) {
|
|
854
|
+
__extends(AnonymousSubject, _super);
|
|
855
|
+
function AnonymousSubject(destination, source) {
|
|
856
|
+
var _this = _super.call(this) || this;
|
|
857
|
+
_this.destination = destination;
|
|
858
|
+
_this.source = source;
|
|
859
|
+
return _this;
|
|
860
|
+
}
|
|
861
|
+
AnonymousSubject.prototype.next = function (value) {
|
|
862
|
+
var _a, _b;
|
|
863
|
+
(_b = (_a = this.destination) === null || _a === undefined ? undefined : _a.next) === null || _b === undefined ? undefined : _b.call(_a, value);
|
|
864
|
+
};
|
|
865
|
+
AnonymousSubject.prototype.error = function (err) {
|
|
866
|
+
var _a, _b;
|
|
867
|
+
(_b = (_a = this.destination) === null || _a === undefined ? undefined : _a.error) === null || _b === undefined ? undefined : _b.call(_a, err);
|
|
868
|
+
};
|
|
869
|
+
AnonymousSubject.prototype.complete = function () {
|
|
870
|
+
var _a, _b;
|
|
871
|
+
(_b = (_a = this.destination) === null || _a === undefined ? undefined : _a.complete) === null || _b === undefined ? undefined : _b.call(_a);
|
|
872
|
+
};
|
|
873
|
+
AnonymousSubject.prototype._subscribe = function (subscriber) {
|
|
874
|
+
var _a, _b;
|
|
875
|
+
return (_b = (_a = this.source) === null || _a === undefined ? undefined : _a.subscribe(subscriber)) !== null && _b !== undefined ? _b : EMPTY_SUBSCRIPTION;
|
|
876
|
+
};
|
|
877
|
+
return AnonymousSubject;
|
|
878
|
+
}(Subject));
|
|
879
|
+
|
|
880
|
+
var dateTimestampProvider = {
|
|
881
|
+
now: function () {
|
|
882
|
+
return (dateTimestampProvider.delegate || Date).now();
|
|
883
|
+
},
|
|
884
|
+
delegate: undefined,
|
|
885
|
+
};
|
|
886
|
+
|
|
887
|
+
var ReplaySubject = (function (_super) {
|
|
888
|
+
__extends(ReplaySubject, _super);
|
|
889
|
+
function ReplaySubject(_bufferSize, _windowTime, _timestampProvider) {
|
|
890
|
+
if (_bufferSize === undefined) { _bufferSize = Infinity; }
|
|
891
|
+
if (_windowTime === undefined) { _windowTime = Infinity; }
|
|
892
|
+
if (_timestampProvider === undefined) { _timestampProvider = dateTimestampProvider; }
|
|
893
|
+
var _this = _super.call(this) || this;
|
|
894
|
+
_this._bufferSize = _bufferSize;
|
|
895
|
+
_this._windowTime = _windowTime;
|
|
896
|
+
_this._timestampProvider = _timestampProvider;
|
|
897
|
+
_this._buffer = [];
|
|
898
|
+
_this._infiniteTimeWindow = true;
|
|
899
|
+
_this._infiniteTimeWindow = _windowTime === Infinity;
|
|
900
|
+
_this._bufferSize = Math.max(1, _bufferSize);
|
|
901
|
+
_this._windowTime = Math.max(1, _windowTime);
|
|
902
|
+
return _this;
|
|
903
|
+
}
|
|
904
|
+
ReplaySubject.prototype.next = function (value) {
|
|
905
|
+
var _a = this, isStopped = _a.isStopped, _buffer = _a._buffer, _infiniteTimeWindow = _a._infiniteTimeWindow, _timestampProvider = _a._timestampProvider, _windowTime = _a._windowTime;
|
|
906
|
+
if (!isStopped) {
|
|
907
|
+
_buffer.push(value);
|
|
908
|
+
!_infiniteTimeWindow && _buffer.push(_timestampProvider.now() + _windowTime);
|
|
909
|
+
}
|
|
910
|
+
this._trimBuffer();
|
|
911
|
+
_super.prototype.next.call(this, value);
|
|
912
|
+
};
|
|
913
|
+
ReplaySubject.prototype._subscribe = function (subscriber) {
|
|
914
|
+
this._throwIfClosed();
|
|
915
|
+
this._trimBuffer();
|
|
916
|
+
var subscription = this._innerSubscribe(subscriber);
|
|
917
|
+
var _a = this, _infiniteTimeWindow = _a._infiniteTimeWindow, _buffer = _a._buffer;
|
|
918
|
+
var copy = _buffer.slice();
|
|
919
|
+
for (var i = 0; i < copy.length && !subscriber.closed; i += _infiniteTimeWindow ? 1 : 2) {
|
|
920
|
+
subscriber.next(copy[i]);
|
|
921
|
+
}
|
|
922
|
+
this._checkFinalizedStatuses(subscriber);
|
|
923
|
+
return subscription;
|
|
924
|
+
};
|
|
925
|
+
ReplaySubject.prototype._trimBuffer = function () {
|
|
926
|
+
var _a = this, _bufferSize = _a._bufferSize, _timestampProvider = _a._timestampProvider, _buffer = _a._buffer, _infiniteTimeWindow = _a._infiniteTimeWindow;
|
|
927
|
+
var adjustedBufferSize = (_infiniteTimeWindow ? 1 : 2) * _bufferSize;
|
|
928
|
+
_bufferSize < Infinity && adjustedBufferSize < _buffer.length && _buffer.splice(0, _buffer.length - adjustedBufferSize);
|
|
929
|
+
if (!_infiniteTimeWindow) {
|
|
930
|
+
var now = _timestampProvider.now();
|
|
931
|
+
var last = 0;
|
|
932
|
+
for (var i = 1; i < _buffer.length && _buffer[i] <= now; i += 2) {
|
|
933
|
+
last = i;
|
|
934
|
+
}
|
|
935
|
+
last && _buffer.splice(0, last + 1);
|
|
936
|
+
}
|
|
937
|
+
};
|
|
938
|
+
return ReplaySubject;
|
|
939
|
+
}(Subject));
|
|
940
|
+
|
|
941
|
+
var Action = (function (_super) {
|
|
942
|
+
__extends(Action, _super);
|
|
943
|
+
function Action(scheduler, work) {
|
|
944
|
+
return _super.call(this) || this;
|
|
945
|
+
}
|
|
946
|
+
Action.prototype.schedule = function (state, delay) {
|
|
947
|
+
return this;
|
|
948
|
+
};
|
|
949
|
+
return Action;
|
|
950
|
+
}(Subscription));
|
|
951
|
+
|
|
952
|
+
var intervalProvider = {
|
|
953
|
+
setInterval: function (handler, timeout) {
|
|
954
|
+
var args = [];
|
|
955
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
956
|
+
args[_i - 2] = arguments[_i];
|
|
957
|
+
}
|
|
958
|
+
return setInterval.apply(undefined, __spreadArray([handler, timeout], __read(args)));
|
|
959
|
+
},
|
|
960
|
+
clearInterval: function (handle) {
|
|
961
|
+
return (clearInterval)(handle);
|
|
962
|
+
},
|
|
963
|
+
delegate: undefined,
|
|
964
|
+
};
|
|
965
|
+
|
|
966
|
+
var AsyncAction = (function (_super) {
|
|
967
|
+
__extends(AsyncAction, _super);
|
|
968
|
+
function AsyncAction(scheduler, work) {
|
|
969
|
+
var _this = _super.call(this, scheduler, work) || this;
|
|
970
|
+
_this.scheduler = scheduler;
|
|
971
|
+
_this.work = work;
|
|
972
|
+
_this.pending = false;
|
|
973
|
+
return _this;
|
|
974
|
+
}
|
|
975
|
+
AsyncAction.prototype.schedule = function (state, delay) {
|
|
976
|
+
var _a;
|
|
977
|
+
if (delay === undefined) { delay = 0; }
|
|
978
|
+
if (this.closed) {
|
|
979
|
+
return this;
|
|
980
|
+
}
|
|
981
|
+
this.state = state;
|
|
982
|
+
var id = this.id;
|
|
983
|
+
var scheduler = this.scheduler;
|
|
984
|
+
if (id != null) {
|
|
985
|
+
this.id = this.recycleAsyncId(scheduler, id, delay);
|
|
986
|
+
}
|
|
987
|
+
this.pending = true;
|
|
988
|
+
this.delay = delay;
|
|
989
|
+
this.id = (_a = this.id) !== null && _a !== undefined ? _a : this.requestAsyncId(scheduler, this.id, delay);
|
|
990
|
+
return this;
|
|
991
|
+
};
|
|
992
|
+
AsyncAction.prototype.requestAsyncId = function (scheduler, _id, delay) {
|
|
993
|
+
if (delay === undefined) { delay = 0; }
|
|
994
|
+
return intervalProvider.setInterval(scheduler.flush.bind(scheduler, this), delay);
|
|
995
|
+
};
|
|
996
|
+
AsyncAction.prototype.recycleAsyncId = function (_scheduler, id, delay) {
|
|
997
|
+
if (delay === undefined) { delay = 0; }
|
|
998
|
+
if (delay != null && this.delay === delay && this.pending === false) {
|
|
999
|
+
return id;
|
|
1000
|
+
}
|
|
1001
|
+
if (id != null) {
|
|
1002
|
+
intervalProvider.clearInterval(id);
|
|
1003
|
+
}
|
|
1004
|
+
return undefined;
|
|
1005
|
+
};
|
|
1006
|
+
AsyncAction.prototype.execute = function (state, delay) {
|
|
1007
|
+
if (this.closed) {
|
|
1008
|
+
return new Error('executing a cancelled action');
|
|
1009
|
+
}
|
|
1010
|
+
this.pending = false;
|
|
1011
|
+
var error = this._execute(state, delay);
|
|
1012
|
+
if (error) {
|
|
1013
|
+
return error;
|
|
1014
|
+
}
|
|
1015
|
+
else if (this.pending === false && this.id != null) {
|
|
1016
|
+
this.id = this.recycleAsyncId(this.scheduler, this.id, null);
|
|
1017
|
+
}
|
|
1018
|
+
};
|
|
1019
|
+
AsyncAction.prototype._execute = function (state, _delay) {
|
|
1020
|
+
var errored = false;
|
|
1021
|
+
var errorValue;
|
|
1022
|
+
try {
|
|
1023
|
+
this.work(state);
|
|
1024
|
+
}
|
|
1025
|
+
catch (e) {
|
|
1026
|
+
errored = true;
|
|
1027
|
+
errorValue = e ? e : new Error('Scheduled action threw falsy error');
|
|
1028
|
+
}
|
|
1029
|
+
if (errored) {
|
|
1030
|
+
this.unsubscribe();
|
|
1031
|
+
return errorValue;
|
|
1032
|
+
}
|
|
1033
|
+
};
|
|
1034
|
+
AsyncAction.prototype.unsubscribe = function () {
|
|
1035
|
+
if (!this.closed) {
|
|
1036
|
+
var _a = this, id = _a.id, scheduler = _a.scheduler;
|
|
1037
|
+
var actions = scheduler.actions;
|
|
1038
|
+
this.work = this.state = this.scheduler = null;
|
|
1039
|
+
this.pending = false;
|
|
1040
|
+
arrRemove(actions, this);
|
|
1041
|
+
if (id != null) {
|
|
1042
|
+
this.id = this.recycleAsyncId(scheduler, id, null);
|
|
1043
|
+
}
|
|
1044
|
+
this.delay = null;
|
|
1045
|
+
_super.prototype.unsubscribe.call(this);
|
|
1046
|
+
}
|
|
1047
|
+
};
|
|
1048
|
+
return AsyncAction;
|
|
1049
|
+
}(Action));
|
|
1050
|
+
|
|
1051
|
+
var Scheduler = (function () {
|
|
1052
|
+
function Scheduler(schedulerActionCtor, now) {
|
|
1053
|
+
if (now === undefined) { now = Scheduler.now; }
|
|
1054
|
+
this.schedulerActionCtor = schedulerActionCtor;
|
|
1055
|
+
this.now = now;
|
|
1056
|
+
}
|
|
1057
|
+
Scheduler.prototype.schedule = function (work, delay, state) {
|
|
1058
|
+
if (delay === undefined) { delay = 0; }
|
|
1059
|
+
return new this.schedulerActionCtor(this, work).schedule(state, delay);
|
|
1060
|
+
};
|
|
1061
|
+
Scheduler.now = dateTimestampProvider.now;
|
|
1062
|
+
return Scheduler;
|
|
1063
|
+
}());
|
|
1064
|
+
|
|
1065
|
+
var AsyncScheduler = (function (_super) {
|
|
1066
|
+
__extends(AsyncScheduler, _super);
|
|
1067
|
+
function AsyncScheduler(SchedulerAction, now) {
|
|
1068
|
+
if (now === undefined) { now = Scheduler.now; }
|
|
1069
|
+
var _this = _super.call(this, SchedulerAction, now) || this;
|
|
1070
|
+
_this.actions = [];
|
|
1071
|
+
_this._active = false;
|
|
1072
|
+
return _this;
|
|
1073
|
+
}
|
|
1074
|
+
AsyncScheduler.prototype.flush = function (action) {
|
|
1075
|
+
var actions = this.actions;
|
|
1076
|
+
if (this._active) {
|
|
1077
|
+
actions.push(action);
|
|
1078
|
+
return;
|
|
1079
|
+
}
|
|
1080
|
+
var error;
|
|
1081
|
+
this._active = true;
|
|
1082
|
+
do {
|
|
1083
|
+
if ((error = action.execute(action.state, action.delay))) {
|
|
1084
|
+
break;
|
|
1085
|
+
}
|
|
1086
|
+
} while ((action = actions.shift()));
|
|
1087
|
+
this._active = false;
|
|
1088
|
+
if (error) {
|
|
1089
|
+
while ((action = actions.shift())) {
|
|
1090
|
+
action.unsubscribe();
|
|
1091
|
+
}
|
|
1092
|
+
throw error;
|
|
1093
|
+
}
|
|
1094
|
+
};
|
|
1095
|
+
return AsyncScheduler;
|
|
1096
|
+
}(Scheduler));
|
|
1097
|
+
|
|
1098
|
+
var asyncScheduler = new AsyncScheduler(AsyncAction);
|
|
1099
|
+
var async = asyncScheduler;
|
|
1100
|
+
|
|
1101
|
+
var EMPTY = new Observable(function (subscriber) { return subscriber.complete(); });
|
|
1102
|
+
|
|
1103
|
+
function isScheduler(value) {
|
|
1104
|
+
return value && isFunction(value.schedule);
|
|
1105
|
+
}
|
|
1106
|
+
|
|
703
1107
|
function last(arr) {
|
|
704
1108
|
return arr[arr.length - 1];
|
|
705
1109
|
}
|
|
706
1110
|
function popResultSelector(args) {
|
|
707
1111
|
return isFunction(last(args)) ? args.pop() : undefined;
|
|
708
1112
|
}
|
|
1113
|
+
function popScheduler(args) {
|
|
1114
|
+
return isScheduler(last(args)) ? args.pop() : undefined;
|
|
1115
|
+
}
|
|
709
1116
|
|
|
710
1117
|
var isArrayLike = (function (x) { return x && typeof x.length === 'number' && typeof x !== 'function'; });
|
|
711
1118
|
|
|
@@ -904,8 +1311,161 @@
|
|
|
904
1311
|
});
|
|
905
1312
|
}
|
|
906
1313
|
|
|
1314
|
+
function executeSchedule(parentSubscription, scheduler, work, delay, repeat) {
|
|
1315
|
+
if (delay === undefined) { delay = 0; }
|
|
1316
|
+
if (repeat === undefined) { repeat = false; }
|
|
1317
|
+
var scheduleSubscription = scheduler.schedule(function () {
|
|
1318
|
+
work();
|
|
1319
|
+
if (repeat) {
|
|
1320
|
+
parentSubscription.add(this.schedule(null, delay));
|
|
1321
|
+
}
|
|
1322
|
+
else {
|
|
1323
|
+
this.unsubscribe();
|
|
1324
|
+
}
|
|
1325
|
+
}, delay);
|
|
1326
|
+
parentSubscription.add(scheduleSubscription);
|
|
1327
|
+
if (!repeat) {
|
|
1328
|
+
return scheduleSubscription;
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1332
|
+
function observeOn(scheduler, delay) {
|
|
1333
|
+
if (delay === undefined) { delay = 0; }
|
|
1334
|
+
return operate(function (source, subscriber) {
|
|
1335
|
+
source.subscribe(createOperatorSubscriber(subscriber, function (value) { return executeSchedule(subscriber, scheduler, function () { return subscriber.next(value); }, delay); }, function () { return executeSchedule(subscriber, scheduler, function () { return subscriber.complete(); }, delay); }, function (err) { return executeSchedule(subscriber, scheduler, function () { return subscriber.error(err); }, delay); }));
|
|
1336
|
+
});
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1339
|
+
function subscribeOn(scheduler, delay) {
|
|
1340
|
+
if (delay === undefined) { delay = 0; }
|
|
1341
|
+
return operate(function (source, subscriber) {
|
|
1342
|
+
subscriber.add(scheduler.schedule(function () { return source.subscribe(subscriber); }, delay));
|
|
1343
|
+
});
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1346
|
+
function scheduleObservable(input, scheduler) {
|
|
1347
|
+
return innerFrom(input).pipe(subscribeOn(scheduler), observeOn(scheduler));
|
|
1348
|
+
}
|
|
1349
|
+
|
|
1350
|
+
function schedulePromise(input, scheduler) {
|
|
1351
|
+
return innerFrom(input).pipe(subscribeOn(scheduler), observeOn(scheduler));
|
|
1352
|
+
}
|
|
1353
|
+
|
|
1354
|
+
function scheduleArray(input, scheduler) {
|
|
1355
|
+
return new Observable(function (subscriber) {
|
|
1356
|
+
var i = 0;
|
|
1357
|
+
return scheduler.schedule(function () {
|
|
1358
|
+
if (i === input.length) {
|
|
1359
|
+
subscriber.complete();
|
|
1360
|
+
}
|
|
1361
|
+
else {
|
|
1362
|
+
subscriber.next(input[i++]);
|
|
1363
|
+
if (!subscriber.closed) {
|
|
1364
|
+
this.schedule();
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
});
|
|
1368
|
+
});
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1371
|
+
function scheduleIterable(input, scheduler) {
|
|
1372
|
+
return new Observable(function (subscriber) {
|
|
1373
|
+
var iterator$1;
|
|
1374
|
+
executeSchedule(subscriber, scheduler, function () {
|
|
1375
|
+
iterator$1 = input[iterator]();
|
|
1376
|
+
executeSchedule(subscriber, scheduler, function () {
|
|
1377
|
+
var _a;
|
|
1378
|
+
var value;
|
|
1379
|
+
var done;
|
|
1380
|
+
try {
|
|
1381
|
+
(_a = iterator$1.next(), value = _a.value, done = _a.done);
|
|
1382
|
+
}
|
|
1383
|
+
catch (err) {
|
|
1384
|
+
subscriber.error(err);
|
|
1385
|
+
return;
|
|
1386
|
+
}
|
|
1387
|
+
if (done) {
|
|
1388
|
+
subscriber.complete();
|
|
1389
|
+
}
|
|
1390
|
+
else {
|
|
1391
|
+
subscriber.next(value);
|
|
1392
|
+
}
|
|
1393
|
+
}, 0, true);
|
|
1394
|
+
});
|
|
1395
|
+
return function () { return isFunction(iterator$1 === null || iterator$1 === undefined ? undefined : iterator$1.return) && iterator$1.return(); };
|
|
1396
|
+
});
|
|
1397
|
+
}
|
|
1398
|
+
|
|
1399
|
+
function scheduleAsyncIterable(input, scheduler) {
|
|
1400
|
+
if (!input) {
|
|
1401
|
+
throw new Error('Iterable cannot be null');
|
|
1402
|
+
}
|
|
1403
|
+
return new Observable(function (subscriber) {
|
|
1404
|
+
executeSchedule(subscriber, scheduler, function () {
|
|
1405
|
+
var iterator = input[Symbol.asyncIterator]();
|
|
1406
|
+
executeSchedule(subscriber, scheduler, function () {
|
|
1407
|
+
iterator.next().then(function (result) {
|
|
1408
|
+
if (result.done) {
|
|
1409
|
+
subscriber.complete();
|
|
1410
|
+
}
|
|
1411
|
+
else {
|
|
1412
|
+
subscriber.next(result.value);
|
|
1413
|
+
}
|
|
1414
|
+
});
|
|
1415
|
+
}, 0, true);
|
|
1416
|
+
});
|
|
1417
|
+
});
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
function scheduleReadableStreamLike(input, scheduler) {
|
|
1421
|
+
return scheduleAsyncIterable(readableStreamLikeToAsyncGenerator(input), scheduler);
|
|
1422
|
+
}
|
|
1423
|
+
|
|
1424
|
+
function scheduled(input, scheduler) {
|
|
1425
|
+
if (input != null) {
|
|
1426
|
+
if (isInteropObservable(input)) {
|
|
1427
|
+
return scheduleObservable(input, scheduler);
|
|
1428
|
+
}
|
|
1429
|
+
if (isArrayLike(input)) {
|
|
1430
|
+
return scheduleArray(input, scheduler);
|
|
1431
|
+
}
|
|
1432
|
+
if (isPromise(input)) {
|
|
1433
|
+
return schedulePromise(input, scheduler);
|
|
1434
|
+
}
|
|
1435
|
+
if (isAsyncIterable(input)) {
|
|
1436
|
+
return scheduleAsyncIterable(input, scheduler);
|
|
1437
|
+
}
|
|
1438
|
+
if (isIterable(input)) {
|
|
1439
|
+
return scheduleIterable(input, scheduler);
|
|
1440
|
+
}
|
|
1441
|
+
if (isReadableStreamLike(input)) {
|
|
1442
|
+
return scheduleReadableStreamLike(input, scheduler);
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1445
|
+
throw createInvalidObservableTypeError(input);
|
|
1446
|
+
}
|
|
1447
|
+
|
|
907
1448
|
function from(input, scheduler) {
|
|
908
|
-
return innerFrom(input);
|
|
1449
|
+
return scheduler ? scheduled(input, scheduler) : innerFrom(input);
|
|
1450
|
+
}
|
|
1451
|
+
|
|
1452
|
+
function of() {
|
|
1453
|
+
var args = [];
|
|
1454
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1455
|
+
args[_i] = arguments[_i];
|
|
1456
|
+
}
|
|
1457
|
+
var scheduler = popScheduler(args);
|
|
1458
|
+
return from(args, scheduler);
|
|
1459
|
+
}
|
|
1460
|
+
|
|
1461
|
+
function throwError(errorOrErrorFactory, scheduler) {
|
|
1462
|
+
var errorFactory = isFunction(errorOrErrorFactory) ? errorOrErrorFactory : function () { return errorOrErrorFactory; };
|
|
1463
|
+
var init = function (subscriber) { return subscriber.error(errorFactory()); };
|
|
1464
|
+
return new Observable(init);
|
|
1465
|
+
}
|
|
1466
|
+
|
|
1467
|
+
function isObservable(obj) {
|
|
1468
|
+
return !!obj && (obj instanceof Observable || (isFunction(obj.lift) && isFunction(obj.subscribe)));
|
|
909
1469
|
}
|
|
910
1470
|
|
|
911
1471
|
var EmptyError = createErrorClass(function (_super) { return function EmptyErrorImpl() {
|
|
@@ -936,6 +1496,10 @@
|
|
|
936
1496
|
});
|
|
937
1497
|
}
|
|
938
1498
|
|
|
1499
|
+
function isValidDate$1(value) {
|
|
1500
|
+
return value instanceof Date && !isNaN(value);
|
|
1501
|
+
}
|
|
1502
|
+
|
|
939
1503
|
function map(project, thisArg) {
|
|
940
1504
|
return operate(function (source, subscriber) {
|
|
941
1505
|
var index = 0;
|
|
@@ -963,7 +1527,7 @@
|
|
|
963
1527
|
var remainingFirstValues = length;
|
|
964
1528
|
var _loop_1 = function (i) {
|
|
965
1529
|
maybeSchedule(scheduler, function () {
|
|
966
|
-
var source = from(observables[i]);
|
|
1530
|
+
var source = from(observables[i], scheduler);
|
|
967
1531
|
var hasFirstValue = false;
|
|
968
1532
|
source.subscribe(createOperatorSubscriber(subscriber, function (value) {
|
|
969
1533
|
values[i] = value;
|
|
@@ -993,6 +1557,108 @@
|
|
|
993
1557
|
}
|
|
994
1558
|
}
|
|
995
1559
|
|
|
1560
|
+
function mergeInternals(source, subscriber, project, concurrent, onBeforeNext, expand, innerSubScheduler, additionalFinalizer) {
|
|
1561
|
+
var buffer = [];
|
|
1562
|
+
var active = 0;
|
|
1563
|
+
var index = 0;
|
|
1564
|
+
var isComplete = false;
|
|
1565
|
+
var checkComplete = function () {
|
|
1566
|
+
if (isComplete && !buffer.length && !active) {
|
|
1567
|
+
subscriber.complete();
|
|
1568
|
+
}
|
|
1569
|
+
};
|
|
1570
|
+
var outerNext = function (value) { return (active < concurrent ? doInnerSub(value) : buffer.push(value)); };
|
|
1571
|
+
var doInnerSub = function (value) {
|
|
1572
|
+
active++;
|
|
1573
|
+
var innerComplete = false;
|
|
1574
|
+
innerFrom(project(value, index++)).subscribe(createOperatorSubscriber(subscriber, function (innerValue) {
|
|
1575
|
+
{
|
|
1576
|
+
subscriber.next(innerValue);
|
|
1577
|
+
}
|
|
1578
|
+
}, function () {
|
|
1579
|
+
innerComplete = true;
|
|
1580
|
+
}, undefined, function () {
|
|
1581
|
+
if (innerComplete) {
|
|
1582
|
+
try {
|
|
1583
|
+
active--;
|
|
1584
|
+
var _loop_1 = function () {
|
|
1585
|
+
var bufferedValue = buffer.shift();
|
|
1586
|
+
if (innerSubScheduler) ;
|
|
1587
|
+
else {
|
|
1588
|
+
doInnerSub(bufferedValue);
|
|
1589
|
+
}
|
|
1590
|
+
};
|
|
1591
|
+
while (buffer.length && active < concurrent) {
|
|
1592
|
+
_loop_1();
|
|
1593
|
+
}
|
|
1594
|
+
checkComplete();
|
|
1595
|
+
}
|
|
1596
|
+
catch (err) {
|
|
1597
|
+
subscriber.error(err);
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1600
|
+
}));
|
|
1601
|
+
};
|
|
1602
|
+
source.subscribe(createOperatorSubscriber(subscriber, outerNext, function () {
|
|
1603
|
+
isComplete = true;
|
|
1604
|
+
checkComplete();
|
|
1605
|
+
}));
|
|
1606
|
+
return function () {
|
|
1607
|
+
};
|
|
1608
|
+
}
|
|
1609
|
+
|
|
1610
|
+
function mergeMap(project, resultSelector, concurrent) {
|
|
1611
|
+
if (concurrent === undefined) { concurrent = Infinity; }
|
|
1612
|
+
if (isFunction(resultSelector)) {
|
|
1613
|
+
return mergeMap(function (a, i) { return map(function (b, ii) { return resultSelector(a, b, i, ii); })(innerFrom(project(a, i))); }, concurrent);
|
|
1614
|
+
}
|
|
1615
|
+
else if (typeof resultSelector === 'number') {
|
|
1616
|
+
concurrent = resultSelector;
|
|
1617
|
+
}
|
|
1618
|
+
return operate(function (source, subscriber) { return mergeInternals(source, subscriber, project, concurrent); });
|
|
1619
|
+
}
|
|
1620
|
+
|
|
1621
|
+
function mergeAll(concurrent) {
|
|
1622
|
+
return mergeMap(identity, concurrent);
|
|
1623
|
+
}
|
|
1624
|
+
|
|
1625
|
+
function concatAll() {
|
|
1626
|
+
return mergeAll(1);
|
|
1627
|
+
}
|
|
1628
|
+
|
|
1629
|
+
function concat() {
|
|
1630
|
+
var args = [];
|
|
1631
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1632
|
+
args[_i] = arguments[_i];
|
|
1633
|
+
}
|
|
1634
|
+
return concatAll()(from(args, popScheduler(args)));
|
|
1635
|
+
}
|
|
1636
|
+
|
|
1637
|
+
function defer(observableFactory) {
|
|
1638
|
+
return new Observable(function (subscriber) {
|
|
1639
|
+
innerFrom(observableFactory()).subscribe(subscriber);
|
|
1640
|
+
});
|
|
1641
|
+
}
|
|
1642
|
+
|
|
1643
|
+
function timer(dueTime, intervalOrScheduler, scheduler) {
|
|
1644
|
+
if (scheduler === undefined) { scheduler = async; }
|
|
1645
|
+
return new Observable(function (subscriber) {
|
|
1646
|
+
var due = isValidDate$1(dueTime) ? 1e3 - scheduler.now() : dueTime;
|
|
1647
|
+
if (due < 0) {
|
|
1648
|
+
due = 0;
|
|
1649
|
+
}
|
|
1650
|
+
var n = 0;
|
|
1651
|
+
return scheduler.schedule(function () {
|
|
1652
|
+
if (!subscriber.closed) {
|
|
1653
|
+
subscriber.next(n++);
|
|
1654
|
+
{
|
|
1655
|
+
subscriber.complete();
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
}, due);
|
|
1659
|
+
});
|
|
1660
|
+
}
|
|
1661
|
+
|
|
996
1662
|
var isArray$1 = Array.isArray;
|
|
997
1663
|
function argsOrArgArray(args) {
|
|
998
1664
|
return args.length === 1 && isArray$1(args[0]) ? args[0] : args;
|
|
@@ -1005,6 +1671,30 @@
|
|
|
1005
1671
|
});
|
|
1006
1672
|
}
|
|
1007
1673
|
|
|
1674
|
+
function catchError(selector) {
|
|
1675
|
+
return operate(function (source, subscriber) {
|
|
1676
|
+
var innerSub = null;
|
|
1677
|
+
var syncUnsub = false;
|
|
1678
|
+
var handledResult;
|
|
1679
|
+
innerSub = source.subscribe(createOperatorSubscriber(subscriber, undefined, undefined, function (err) {
|
|
1680
|
+
handledResult = innerFrom(selector(err, catchError(selector)(source)));
|
|
1681
|
+
if (innerSub) {
|
|
1682
|
+
innerSub.unsubscribe();
|
|
1683
|
+
innerSub = null;
|
|
1684
|
+
handledResult.subscribe(subscriber);
|
|
1685
|
+
}
|
|
1686
|
+
else {
|
|
1687
|
+
syncUnsub = true;
|
|
1688
|
+
}
|
|
1689
|
+
}));
|
|
1690
|
+
if (syncUnsub) {
|
|
1691
|
+
innerSub.unsubscribe();
|
|
1692
|
+
innerSub = null;
|
|
1693
|
+
handledResult.subscribe(subscriber);
|
|
1694
|
+
}
|
|
1695
|
+
});
|
|
1696
|
+
}
|
|
1697
|
+
|
|
1008
1698
|
function combineLatest() {
|
|
1009
1699
|
var args = [];
|
|
1010
1700
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
@@ -1026,6 +1716,100 @@
|
|
|
1026
1716
|
return combineLatest.apply(undefined, __spreadArray([], __read(otherSources)));
|
|
1027
1717
|
}
|
|
1028
1718
|
|
|
1719
|
+
function share(options) {
|
|
1720
|
+
if (options === undefined) { options = {}; }
|
|
1721
|
+
var _a = options.connector, connector = _a === undefined ? function () { return new Subject(); } : _a, _b = options.resetOnError, resetOnError = _b === undefined ? true : _b, _c = options.resetOnComplete, resetOnComplete = _c === undefined ? true : _c, _d = options.resetOnRefCountZero, resetOnRefCountZero = _d === undefined ? true : _d;
|
|
1722
|
+
return function (wrapperSource) {
|
|
1723
|
+
var connection;
|
|
1724
|
+
var resetConnection;
|
|
1725
|
+
var subject;
|
|
1726
|
+
var refCount = 0;
|
|
1727
|
+
var hasCompleted = false;
|
|
1728
|
+
var hasErrored = false;
|
|
1729
|
+
var cancelReset = function () {
|
|
1730
|
+
resetConnection === null || resetConnection === undefined ? undefined : resetConnection.unsubscribe();
|
|
1731
|
+
resetConnection = undefined;
|
|
1732
|
+
};
|
|
1733
|
+
var reset = function () {
|
|
1734
|
+
cancelReset();
|
|
1735
|
+
connection = subject = undefined;
|
|
1736
|
+
hasCompleted = hasErrored = false;
|
|
1737
|
+
};
|
|
1738
|
+
var resetAndUnsubscribe = function () {
|
|
1739
|
+
var conn = connection;
|
|
1740
|
+
reset();
|
|
1741
|
+
conn === null || conn === undefined ? undefined : conn.unsubscribe();
|
|
1742
|
+
};
|
|
1743
|
+
return operate(function (source, subscriber) {
|
|
1744
|
+
refCount++;
|
|
1745
|
+
if (!hasErrored && !hasCompleted) {
|
|
1746
|
+
cancelReset();
|
|
1747
|
+
}
|
|
1748
|
+
var dest = (subject = subject !== null && subject !== void 0 ? subject : connector());
|
|
1749
|
+
subscriber.add(function () {
|
|
1750
|
+
refCount--;
|
|
1751
|
+
if (refCount === 0 && !hasErrored && !hasCompleted) {
|
|
1752
|
+
resetConnection = handleReset(resetAndUnsubscribe, resetOnRefCountZero);
|
|
1753
|
+
}
|
|
1754
|
+
});
|
|
1755
|
+
dest.subscribe(subscriber);
|
|
1756
|
+
if (!connection &&
|
|
1757
|
+
refCount > 0) {
|
|
1758
|
+
connection = new SafeSubscriber({
|
|
1759
|
+
next: function (value) { return dest.next(value); },
|
|
1760
|
+
error: function (err) {
|
|
1761
|
+
hasErrored = true;
|
|
1762
|
+
cancelReset();
|
|
1763
|
+
resetConnection = handleReset(reset, resetOnError, err);
|
|
1764
|
+
dest.error(err);
|
|
1765
|
+
},
|
|
1766
|
+
complete: function () {
|
|
1767
|
+
hasCompleted = true;
|
|
1768
|
+
cancelReset();
|
|
1769
|
+
resetConnection = handleReset(reset, resetOnComplete);
|
|
1770
|
+
dest.complete();
|
|
1771
|
+
},
|
|
1772
|
+
});
|
|
1773
|
+
innerFrom(source).subscribe(connection);
|
|
1774
|
+
}
|
|
1775
|
+
})(wrapperSource);
|
|
1776
|
+
};
|
|
1777
|
+
}
|
|
1778
|
+
function handleReset(reset, on) {
|
|
1779
|
+
var args = [];
|
|
1780
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
1781
|
+
args[_i - 2] = arguments[_i];
|
|
1782
|
+
}
|
|
1783
|
+
if (on === true) {
|
|
1784
|
+
reset();
|
|
1785
|
+
return;
|
|
1786
|
+
}
|
|
1787
|
+
if (on === false) {
|
|
1788
|
+
return;
|
|
1789
|
+
}
|
|
1790
|
+
var onSubscriber = new SafeSubscriber({
|
|
1791
|
+
next: function () {
|
|
1792
|
+
onSubscriber.unsubscribe();
|
|
1793
|
+
reset();
|
|
1794
|
+
},
|
|
1795
|
+
});
|
|
1796
|
+
return innerFrom(on.apply(undefined, __spreadArray([], __read(args)))).subscribe(onSubscriber);
|
|
1797
|
+
}
|
|
1798
|
+
|
|
1799
|
+
function shareReplay(configOrBufferSize, windowTime, scheduler) {
|
|
1800
|
+
var bufferSize;
|
|
1801
|
+
var refCount = false;
|
|
1802
|
+
{
|
|
1803
|
+
bufferSize = (configOrBufferSize );
|
|
1804
|
+
}
|
|
1805
|
+
return share({
|
|
1806
|
+
connector: function () { return new ReplaySubject(bufferSize, windowTime, scheduler); },
|
|
1807
|
+
resetOnError: true,
|
|
1808
|
+
resetOnComplete: false,
|
|
1809
|
+
resetOnRefCountZero: refCount,
|
|
1810
|
+
});
|
|
1811
|
+
}
|
|
1812
|
+
|
|
1029
1813
|
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("");
|
|
1030
1814
|
function E(t) {
|
|
1031
1815
|
let e = JSON.stringify(t);
|
|
@@ -1147,21 +1931,21 @@
|
|
|
1147
1931
|
}
|
|
1148
1932
|
};
|
|
1149
1933
|
function defineHttpRequest(envMiddleware2) {
|
|
1150
|
-
return
|
|
1151
|
-
|
|
1934
|
+
return p$1([
|
|
1935
|
+
P({ shouldRetry }),
|
|
1152
1936
|
...envMiddleware2,
|
|
1153
1937
|
printWarnings,
|
|
1154
|
-
v(),
|
|
1155
1938
|
x(),
|
|
1156
|
-
|
|
1939
|
+
E$1(),
|
|
1940
|
+
S$1(),
|
|
1157
1941
|
httpError,
|
|
1158
|
-
|
|
1942
|
+
A({ implementation: Observable })
|
|
1159
1943
|
]);
|
|
1160
1944
|
}
|
|
1161
1945
|
function shouldRetry(err, attempt, options) {
|
|
1162
1946
|
if (options.maxRetries === 0) return false;
|
|
1163
1947
|
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);
|
|
1164
|
-
return (isSafe || isQuery) && isRetriableResponse ? true :
|
|
1948
|
+
return (isSafe || isQuery) && isRetriableResponse ? true : P.shouldRetry(err, attempt, options);
|
|
1165
1949
|
}
|
|
1166
1950
|
const BASE_URL = "https://www.sanity.io/help/";
|
|
1167
1951
|
function generateHelpUrl(slug) {
|
|
@@ -1311,6 +2095,112 @@
|
|
|
1311
2095
|
const hostParts = newConfig.apiHost.split("://", 2), protocol = hostParts[0], host = hostParts[1], cdnHost = newConfig.isDefaultApi ? defaultCdnHost : host;
|
|
1312
2096
|
return newConfig.useProjectHostname ? (newConfig.url = `${protocol}://${newConfig.projectId}.${host}/v${newConfig.apiVersion}`, newConfig.cdnUrl = `${protocol}://${newConfig.projectId}.${cdnHost}/v${newConfig.apiVersion}`) : (newConfig.url = `${newConfig.apiHost}/v${newConfig.apiVersion}`, newConfig.cdnUrl = newConfig.url), newConfig;
|
|
1313
2097
|
};
|
|
2098
|
+
class ConnectionFailedError extends Error {
|
|
2099
|
+
name = "ConnectionFailedError";
|
|
2100
|
+
}
|
|
2101
|
+
class DisconnectError extends Error {
|
|
2102
|
+
name = "DisconnectError";
|
|
2103
|
+
reason;
|
|
2104
|
+
constructor(message, reason, options = {}) {
|
|
2105
|
+
super(message, options), this.reason = reason;
|
|
2106
|
+
}
|
|
2107
|
+
}
|
|
2108
|
+
class ChannelError extends Error {
|
|
2109
|
+
name = "ChannelError";
|
|
2110
|
+
data;
|
|
2111
|
+
constructor(message, data) {
|
|
2112
|
+
super(message), this.data = data;
|
|
2113
|
+
}
|
|
2114
|
+
}
|
|
2115
|
+
class MessageError extends Error {
|
|
2116
|
+
name = "MessageError";
|
|
2117
|
+
data;
|
|
2118
|
+
constructor(message, data, options = {}) {
|
|
2119
|
+
super(message, options), this.data = data;
|
|
2120
|
+
}
|
|
2121
|
+
}
|
|
2122
|
+
class MessageParseError extends Error {
|
|
2123
|
+
name = "MessageParseError";
|
|
2124
|
+
}
|
|
2125
|
+
const REQUIRED_EVENTS = ["channelError", "disconnect"];
|
|
2126
|
+
function connectEventSource(initEventSource, events) {
|
|
2127
|
+
return defer(() => {
|
|
2128
|
+
const es = initEventSource();
|
|
2129
|
+
return isObservable(es) ? es : of(es);
|
|
2130
|
+
}).pipe(mergeMap((es) => connectWithESInstance(es, events)));
|
|
2131
|
+
}
|
|
2132
|
+
function connectWithESInstance(es, events) {
|
|
2133
|
+
return new Observable((observer) => {
|
|
2134
|
+
const emitOpen = events.includes("open"), emitReconnect = events.includes("reconnect");
|
|
2135
|
+
function onError(evt) {
|
|
2136
|
+
if ("data" in evt) {
|
|
2137
|
+
const [parseError, event] = parseEvent(evt);
|
|
2138
|
+
observer.error(
|
|
2139
|
+
parseError ? new MessageParseError("Unable to parse EventSource error message", { cause: event }) : new MessageError((event?.data).message, event)
|
|
2140
|
+
);
|
|
2141
|
+
return;
|
|
2142
|
+
}
|
|
2143
|
+
es.readyState === es.CLOSED ? observer.error(new ConnectionFailedError("EventSource connection failed")) : emitReconnect && observer.next({ type: "reconnect" });
|
|
2144
|
+
}
|
|
2145
|
+
function onOpen() {
|
|
2146
|
+
observer.next({ type: "open" });
|
|
2147
|
+
}
|
|
2148
|
+
function onMessage(message) {
|
|
2149
|
+
const [parseError, event] = parseEvent(message);
|
|
2150
|
+
if (parseError) {
|
|
2151
|
+
observer.error(
|
|
2152
|
+
new MessageParseError("Unable to parse EventSource message", { cause: parseError })
|
|
2153
|
+
);
|
|
2154
|
+
return;
|
|
2155
|
+
}
|
|
2156
|
+
if (message.type === "channelError") {
|
|
2157
|
+
observer.error(new ChannelError(extractErrorMessage(event?.data), event.data));
|
|
2158
|
+
return;
|
|
2159
|
+
}
|
|
2160
|
+
if (message.type === "disconnect") {
|
|
2161
|
+
observer.error(
|
|
2162
|
+
new DisconnectError(
|
|
2163
|
+
`Server disconnected client: ${event.data?.reason || "unknown error"}`
|
|
2164
|
+
)
|
|
2165
|
+
);
|
|
2166
|
+
return;
|
|
2167
|
+
}
|
|
2168
|
+
observer.next({
|
|
2169
|
+
type: message.type,
|
|
2170
|
+
id: message.lastEventId,
|
|
2171
|
+
...event.data ? { data: event.data } : {}
|
|
2172
|
+
});
|
|
2173
|
+
}
|
|
2174
|
+
es.addEventListener("error", onError), emitOpen && es.addEventListener("open", onOpen);
|
|
2175
|
+
const cleanedEvents = [.../* @__PURE__ */ new Set([...REQUIRED_EVENTS, ...events])].filter((type) => type !== "error" && type !== "open" && type !== "reconnect");
|
|
2176
|
+
return cleanedEvents.forEach((type) => es.addEventListener(type, onMessage)), () => {
|
|
2177
|
+
es.removeEventListener("error", onError), emitOpen && es.removeEventListener("open", onOpen), cleanedEvents.forEach((type) => es.removeEventListener(type, onMessage)), es.close();
|
|
2178
|
+
};
|
|
2179
|
+
});
|
|
2180
|
+
}
|
|
2181
|
+
function parseEvent(message) {
|
|
2182
|
+
try {
|
|
2183
|
+
const data = typeof message.data == "string" && JSON.parse(message.data);
|
|
2184
|
+
return [
|
|
2185
|
+
null,
|
|
2186
|
+
{
|
|
2187
|
+
type: message.type,
|
|
2188
|
+
id: message.lastEventId,
|
|
2189
|
+
...isEmptyObject(data) ? {} : { data }
|
|
2190
|
+
}
|
|
2191
|
+
];
|
|
2192
|
+
} catch (err) {
|
|
2193
|
+
return [err, null];
|
|
2194
|
+
}
|
|
2195
|
+
}
|
|
2196
|
+
function extractErrorMessage(err) {
|
|
2197
|
+
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";
|
|
2198
|
+
}
|
|
2199
|
+
function isEmptyObject(data) {
|
|
2200
|
+
for (const _ in data)
|
|
2201
|
+
return false;
|
|
2202
|
+
return true;
|
|
2203
|
+
}
|
|
1314
2204
|
function getSelection(sel) {
|
|
1315
2205
|
if (typeof sel == "string")
|
|
1316
2206
|
return { id: sel };
|
|
@@ -1595,8 +2485,8 @@ ${selectionOpts}`);
|
|
|
1595
2485
|
);
|
|
1596
2486
|
}
|
|
1597
2487
|
patch(patchOrDocumentId, patchOps) {
|
|
1598
|
-
const isBuilder = typeof patchOps == "function";
|
|
1599
|
-
if (
|
|
2488
|
+
const isBuilder = typeof patchOps == "function", isPatch = typeof patchOrDocumentId != "string" && patchOrDocumentId instanceof Patch, isMutationSelection = typeof patchOrDocumentId == "object" && ("query" in patchOrDocumentId || "id" in patchOrDocumentId);
|
|
2489
|
+
if (isPatch)
|
|
1600
2490
|
return this._add({ patch: patchOrDocumentId.serialize() });
|
|
1601
2491
|
if (isBuilder) {
|
|
1602
2492
|
const patch = patchOps(new Patch(patchOrDocumentId, {}, this.#client));
|
|
@@ -1604,6 +2494,10 @@ ${selectionOpts}`);
|
|
|
1604
2494
|
throw new Error("function passed to `patch()` must return the patch");
|
|
1605
2495
|
return this._add({ patch: patch.serialize() });
|
|
1606
2496
|
}
|
|
2497
|
+
if (isMutationSelection) {
|
|
2498
|
+
const patch = new Patch(patchOrDocumentId, patchOps || {}, this.#client);
|
|
2499
|
+
return this._add({ patch: patch.serialize() });
|
|
2500
|
+
}
|
|
1607
2501
|
return this._add({ patch: { id: patchOrDocumentId, ...patchOps } });
|
|
1608
2502
|
}
|
|
1609
2503
|
}
|
|
@@ -1927,7 +2821,18 @@ ${selectionOpts}`);
|
|
|
1927
2821
|
);
|
|
1928
2822
|
}
|
|
1929
2823
|
var defaults = (obj, defaults2) => Object.keys(defaults2).concat(Object.keys(obj)).reduce((target, prop) => (target[prop] = typeof obj[prop] > "u" ? defaults2[prop] : obj[prop], target), {});
|
|
1930
|
-
const pick = (obj, props) => props.reduce((selection, prop) => (typeof obj[prop] > "u" || (selection[prop] = obj[prop]), selection), {}),
|
|
2824
|
+
const pick = (obj, props) => props.reduce((selection, prop) => (typeof obj[prop] > "u" || (selection[prop] = obj[prop]), selection), {}), eventSourcePolyfill = defer(() => Promise.resolve().then(function () { return browser$1; })).pipe(
|
|
2825
|
+
map(({ default: EventSource2 }) => EventSource2),
|
|
2826
|
+
shareReplay(1)
|
|
2827
|
+
);
|
|
2828
|
+
function reconnectOnConnectionFailure() {
|
|
2829
|
+
return function(source) {
|
|
2830
|
+
return source.pipe(
|
|
2831
|
+
catchError((err, caught) => err instanceof ConnectionFailedError ? concat(of({ type: "reconnect" }), timer(1e3).pipe(mergeMap(() => caught))) : throwError(() => err))
|
|
2832
|
+
);
|
|
2833
|
+
};
|
|
2834
|
+
}
|
|
2835
|
+
const MAX_URL_LENGTH = 14800, possibleOptions = [
|
|
1931
2836
|
"includePreviousRevision",
|
|
1932
2837
|
"includeResult",
|
|
1933
2838
|
"includeMutations",
|
|
@@ -1940,68 +2845,23 @@ ${selectionOpts}`);
|
|
|
1940
2845
|
function _listen(query, params, opts = {}) {
|
|
1941
2846
|
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)}`;
|
|
1942
2847
|
if (uri.length > MAX_URL_LENGTH)
|
|
1943
|
-
return
|
|
1944
|
-
const listenFor = options.events ? options.events : ["mutation"],
|
|
2848
|
+
return throwError(() => new Error("Query too large for listener"));
|
|
2849
|
+
const listenFor = options.events ? options.events : ["mutation"], esOptions = {};
|
|
1945
2850
|
return (token || withCredentials) && (esOptions.withCredentials = true), token && (esOptions.headers = {
|
|
1946
2851
|
Authorization: `Bearer ${token}`
|
|
1947
|
-
}),
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
function onDisconnect() {
|
|
1961
|
-
stopped = true, unsubscribe(), observer.complete();
|
|
1962
|
-
}
|
|
1963
|
-
function unsubscribe() {
|
|
1964
|
-
es && (es.removeEventListener("error", onError), es.removeEventListener("channelError", onChannelError), es.removeEventListener("disconnect", onDisconnect), listenFor.forEach((type) => es.removeEventListener(type, onMessage)), es.close());
|
|
1965
|
-
}
|
|
1966
|
-
function emitReconnect() {
|
|
1967
|
-
shouldEmitReconnect && observer.next({ type: "reconnect" });
|
|
1968
|
-
}
|
|
1969
|
-
async function getEventSource() {
|
|
1970
|
-
const { default: EventSource2 } = await Promise.resolve().then(function () { return browser$1; });
|
|
1971
|
-
if (unsubscribed)
|
|
1972
|
-
return;
|
|
1973
|
-
const evs = new EventSource2(uri, esOptions);
|
|
1974
|
-
return evs.addEventListener("error", onError), evs.addEventListener("channelError", onChannelError), evs.addEventListener("disconnect", onDisconnect), listenFor.forEach((type) => evs.addEventListener(type, onMessage)), evs;
|
|
1975
|
-
}
|
|
1976
|
-
function open() {
|
|
1977
|
-
getEventSource().then((eventSource) => {
|
|
1978
|
-
eventSource && (es = eventSource, unsubscribed && unsubscribe());
|
|
1979
|
-
}).catch((reason) => {
|
|
1980
|
-
observer.error(reason), stop();
|
|
1981
|
-
});
|
|
1982
|
-
}
|
|
1983
|
-
function stop() {
|
|
1984
|
-
stopped = true, unsubscribe(), unsubscribed = true;
|
|
1985
|
-
}
|
|
1986
|
-
return stop;
|
|
1987
|
-
});
|
|
1988
|
-
}
|
|
1989
|
-
function parseEvent$1(event) {
|
|
1990
|
-
try {
|
|
1991
|
-
const data = event.data && JSON.parse(event.data) || {};
|
|
1992
|
-
return Object.assign({ type: event.type }, data);
|
|
1993
|
-
} catch (err) {
|
|
1994
|
-
return err;
|
|
1995
|
-
}
|
|
1996
|
-
}
|
|
1997
|
-
function cooerceError(err) {
|
|
1998
|
-
if (err instanceof Error)
|
|
1999
|
-
return err;
|
|
2000
|
-
const evt = parseEvent$1(err);
|
|
2001
|
-
return evt instanceof Error ? evt : new Error(extractErrorMessage(evt));
|
|
2002
|
-
}
|
|
2003
|
-
function extractErrorMessage(err) {
|
|
2004
|
-
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";
|
|
2852
|
+
}), connectEventSource(() => (
|
|
2853
|
+
// use polyfill if there is no global EventSource or if we need to set headers
|
|
2854
|
+
(typeof EventSource > "u" || esOptions.headers ? eventSourcePolyfill : of(EventSource)).pipe(map((EventSource2) => new EventSource2(uri, esOptions)))
|
|
2855
|
+
), listenFor).pipe(
|
|
2856
|
+
reconnectOnConnectionFailure(),
|
|
2857
|
+
filter((event) => listenFor.includes(event.type)),
|
|
2858
|
+
map(
|
|
2859
|
+
(event) => ({
|
|
2860
|
+
type: event.type,
|
|
2861
|
+
..."data" in event ? event.data : {}
|
|
2862
|
+
})
|
|
2863
|
+
)
|
|
2864
|
+
);
|
|
2005
2865
|
}
|
|
2006
2866
|
const requiredApiVersion = "2021-03-26";
|
|
2007
2867
|
class LiveClient {
|
|
@@ -2037,75 +2897,53 @@ ${selectionOpts}`);
|
|
|
2037
2897
|
);
|
|
2038
2898
|
const path = _getDataUrl(this.#client, "live/events"), url = new URL(this.#client.getUrl(path, false)), tag = _tag && requestTagPrefix ? [requestTagPrefix, _tag].join(".") : _tag;
|
|
2039
2899
|
tag && url.searchParams.set("tag", tag), includeDrafts && url.searchParams.set("includeDrafts", "true");
|
|
2040
|
-
const
|
|
2041
|
-
|
|
2900
|
+
const esOptions = {};
|
|
2901
|
+
includeDrafts && token && (esOptions.headers = {
|
|
2042
2902
|
Authorization: `Bearer ${token}`
|
|
2043
|
-
}), includeDrafts && withCredentials && (esOptions.withCredentials = true)
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
}
|
|
2059
|
-
function unsubscribe() {
|
|
2060
|
-
if (es) {
|
|
2061
|
-
es.removeEventListener("error", onError);
|
|
2062
|
-
for (const type of listenFor)
|
|
2063
|
-
es.removeEventListener(type, onMessage);
|
|
2064
|
-
es.close();
|
|
2903
|
+
}), includeDrafts && withCredentials && (esOptions.withCredentials = true);
|
|
2904
|
+
const events = connectEventSource(() => (
|
|
2905
|
+
// use polyfill if there is no global EventSource or if we need to set headers
|
|
2906
|
+
(typeof EventSource > "u" || esOptions.headers ? eventSourcePolyfill : of(EventSource)).pipe(map((EventSource2) => new EventSource2(url.href, esOptions)))
|
|
2907
|
+
), [
|
|
2908
|
+
"message",
|
|
2909
|
+
"restart",
|
|
2910
|
+
"welcome",
|
|
2911
|
+
"reconnect"
|
|
2912
|
+
]).pipe(
|
|
2913
|
+
reconnectOnConnectionFailure(),
|
|
2914
|
+
map((event) => {
|
|
2915
|
+
if (event.type === "message") {
|
|
2916
|
+
const { data, ...rest } = event;
|
|
2917
|
+
return { ...rest, tags: data.tags };
|
|
2065
2918
|
}
|
|
2919
|
+
return event;
|
|
2920
|
+
})
|
|
2921
|
+
), checkCors = fetchObservable(url, {
|
|
2922
|
+
method: "OPTIONS",
|
|
2923
|
+
mode: "cors",
|
|
2924
|
+
credentials: esOptions.withCredentials ? "include" : "omit",
|
|
2925
|
+
headers: esOptions.headers
|
|
2926
|
+
}).pipe(
|
|
2927
|
+
mergeMap(() => EMPTY),
|
|
2928
|
+
catchError(() => {
|
|
2929
|
+
throw new CorsOriginError({ projectId: projectId2 });
|
|
2930
|
+
})
|
|
2931
|
+
);
|
|
2932
|
+
return concat(checkCors, events);
|
|
2933
|
+
}
|
|
2934
|
+
}
|
|
2935
|
+
function fetchObservable(url, init) {
|
|
2936
|
+
return new Observable((observer) => {
|
|
2937
|
+
const controller = new AbortController(), signal = controller.signal;
|
|
2938
|
+
return fetch(url, { ...init, signal: controller.signal }).then(
|
|
2939
|
+
(response) => {
|
|
2940
|
+
observer.next(response), observer.complete();
|
|
2941
|
+
},
|
|
2942
|
+
(err) => {
|
|
2943
|
+
signal.aborted || observer.error(err);
|
|
2066
2944
|
}
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
if (unsubscribed)
|
|
2070
|
-
return;
|
|
2071
|
-
try {
|
|
2072
|
-
if (await fetch(url, {
|
|
2073
|
-
method: "OPTIONS",
|
|
2074
|
-
mode: "cors",
|
|
2075
|
-
credentials: esOptions.withCredentials ? "include" : "omit",
|
|
2076
|
-
headers: esOptions.headers
|
|
2077
|
-
}), unsubscribed)
|
|
2078
|
-
return;
|
|
2079
|
-
} catch {
|
|
2080
|
-
throw new CorsOriginError({ projectId: projectId2 });
|
|
2081
|
-
}
|
|
2082
|
-
const evs = new EventSourceImplementation(url.toString(), esOptions);
|
|
2083
|
-
evs.addEventListener("error", onError);
|
|
2084
|
-
for (const type of listenFor)
|
|
2085
|
-
evs.addEventListener(type, onMessage);
|
|
2086
|
-
return evs;
|
|
2087
|
-
}
|
|
2088
|
-
function open() {
|
|
2089
|
-
getEventSource().then((eventSource) => {
|
|
2090
|
-
eventSource && (es = eventSource, unsubscribed && unsubscribe());
|
|
2091
|
-
}).catch((reason) => {
|
|
2092
|
-
observer.error(reason), stop();
|
|
2093
|
-
});
|
|
2094
|
-
}
|
|
2095
|
-
function stop() {
|
|
2096
|
-
stopped = true, unsubscribe(), unsubscribed = true;
|
|
2097
|
-
}
|
|
2098
|
-
return stop;
|
|
2099
|
-
});
|
|
2100
|
-
}
|
|
2101
|
-
}
|
|
2102
|
-
function parseEvent(event) {
|
|
2103
|
-
try {
|
|
2104
|
-
const data = event.data && JSON.parse(event.data) || {};
|
|
2105
|
-
return { type: event.type, id: event.lastEventId, ...data };
|
|
2106
|
-
} catch (err) {
|
|
2107
|
-
return err;
|
|
2108
|
-
}
|
|
2945
|
+
), () => controller.abort();
|
|
2946
|
+
});
|
|
2109
2947
|
}
|
|
2110
2948
|
class ObservableDatasetsClient {
|
|
2111
2949
|
#client;
|
|
@@ -4038,15 +4876,20 @@ ${selectionOpts}`);
|
|
|
4038
4876
|
var browserExports = /*@__PURE__*/ requireBrowser();
|
|
4039
4877
|
var browser = /*@__PURE__*/getDefaultExportFromCjs(browserExports);
|
|
4040
4878
|
|
|
4041
|
-
var browser$1 = /*#__PURE__*/
|
|
4879
|
+
var browser$1 = /*#__PURE__*/_mergeNamespaces({
|
|
4042
4880
|
__proto__: null,
|
|
4043
4881
|
default: browser
|
|
4044
|
-
});
|
|
4882
|
+
}, [browserExports]);
|
|
4045
4883
|
|
|
4046
4884
|
exports.BasePatch = BasePatch;
|
|
4047
4885
|
exports.BaseTransaction = BaseTransaction;
|
|
4886
|
+
exports.ChannelError = ChannelError;
|
|
4048
4887
|
exports.ClientError = ClientError;
|
|
4888
|
+
exports.ConnectionFailedError = ConnectionFailedError;
|
|
4049
4889
|
exports.CorsOriginError = CorsOriginError;
|
|
4890
|
+
exports.DisconnectError = DisconnectError;
|
|
4891
|
+
exports.MessageError = MessageError;
|
|
4892
|
+
exports.MessageParseError = MessageParseError;
|
|
4050
4893
|
exports.ObservablePatch = ObservablePatch;
|
|
4051
4894
|
exports.ObservableSanityClient = ObservableSanityClient;
|
|
4052
4895
|
exports.ObservableTransaction = ObservableTransaction;
|
|
@@ -4054,11 +4897,12 @@ ${selectionOpts}`);
|
|
|
4054
4897
|
exports.SanityClient = SanityClient;
|
|
4055
4898
|
exports.ServerError = ServerError;
|
|
4056
4899
|
exports.Transaction = Transaction;
|
|
4900
|
+
exports.connectEventSource = connectEventSource;
|
|
4057
4901
|
exports.createClient = createClient;
|
|
4058
4902
|
exports.default = deprecatedCreateClient;
|
|
4059
4903
|
exports.requester = requester;
|
|
4060
|
-
exports.unstable__adapter =
|
|
4061
|
-
exports.unstable__environment =
|
|
4904
|
+
exports.unstable__adapter = c$2;
|
|
4905
|
+
exports.unstable__environment = f$1;
|
|
4062
4906
|
exports.validateApiPerspective = validateApiPerspective;
|
|
4063
4907
|
|
|
4064
4908
|
Object.defineProperty(exports, '__esModule', { value: true });
|