@sanity/client 2.24.3-pte.128 → 3.0.2
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/LICENSE +1 -1
- package/README.md +6 -2
- package/lib/assets/assetsClient.js +4 -20
- package/lib/config.js +14 -28
- package/lib/data/dataMethods.js +4 -6
- package/lib/data/listen.js +2 -1
- package/lib/data/patch.js +0 -10
- package/lib/http/request.js +5 -4
- package/lib/sanityClient.js +11 -8
- package/lib/util/observable.js +18 -0
- package/lib/validators.js +1 -1
- package/lib/warnings.js +0 -1
- package/package.json +33 -33
- package/sanityClient.d.ts +2 -21
- package/test/client.test.js +122 -68
- package/umd/sanityClient.js +122 -158
- package/umd/sanityClient.min.js +1 -1
- package/.depcheckignore.json +0 -1
- package/.travis.yml +0 -9
- package/lib/scripts/print-bundle-size.js +0 -52
- package/test/gradientMode.test.js +0 -112
package/umd/sanityClient.js
CHANGED
|
@@ -1,254 +1,218 @@
|
|
|
1
1
|
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.SanityClient = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
|
|
2
|
-
(function (
|
|
3
|
-
!function(t,e){if("function"==typeof define&&define.amd)define([],e);else if("object"==typeof module&&module.exports)module.exports=e();else{if(global.EventSource&&!global._eventSourceImportPrefix)return;t[(t._eventSourceImportPrefix||"")+"EventSource"]=e()}}("undefined"==typeof self?this:self,function(){var t=function(t,e){if(!t||"string"!=typeof t)throw new SyntaxError("Not enough arguments");this.URL=t,this.setOptions(e);var i=this;setTimeout(function(){i.poll()},0)};if(t.prototype={CONNECTING:0,OPEN:1,CLOSED:2,defaultOptions:{loggingEnabled:!1,loggingPrefix:"eventsource",interval:500,bufferSizeLimit:262144,silentTimeout:3e5,getArgs:{evs_buffer_size_limit:262144},xhrHeaders:{Accept:"text/event-stream","Cache-Control":"no-cache","X-Requested-With":"XMLHttpRequest"}},setOptions:function(t){var e,i=this.defaultOptions;for(e in i)i.hasOwnProperty(e)&&(this[e]=i[e]);for(e in t)e in i&&t.hasOwnProperty(e)&&(this[e]=t[e]);this.getArgs&&this.bufferSizeLimit&&(this.getArgs.evs_buffer_size_limit=this.bufferSizeLimit),"undefined"!=typeof console&&void 0!==console.log||(this.loggingEnabled=!1)},log:function(t){this.loggingEnabled&&console.log("["+this.loggingPrefix+"]:"+t)},poll:function(){try{if(this.readyState==this.CLOSED)return;this.cleanup(),this.readyState=this.CONNECTING,this.cursor=0,this.cache="",this._xhr=new this.XHR(this),this.resetNoActivityTimer()}catch(t){this.log("There were errors inside the pool try-catch"),this.dispatchEvent("error",{type:"error",data:t.message})}},pollAgain:function(t){var e=this;e.readyState=e.CONNECTING,e.dispatchEvent("error",{type:"error",data:"Reconnecting "}),this._pollTimer=setTimeout(function(){e.poll()},t||0)},cleanup:function(){this.log("evs cleaning up"),this._pollTimer&&(clearInterval(this._pollTimer),this._pollTimer=null),this._noActivityTimer&&(clearInterval(this._noActivityTimer),this._noActivityTimer=null),this._xhr&&(this._xhr.abort(),this._xhr=null)},resetNoActivityTimer:function(){if(this.silentTimeout){this._noActivityTimer&&clearInterval(this._noActivityTimer);var t=this;this._noActivityTimer=setTimeout(function(){t.log("Timeout! silentTImeout:"+t.silentTimeout),t.pollAgain()},this.silentTimeout)}},close:function(){this.readyState=this.CLOSED,this.log("Closing connection. readyState: "+this.readyState),this.cleanup()},_onxhrdata:function(){var t=this._xhr;if(t.isReady()&&!t.hasError()){this.resetNoActivityTimer(),this.readyState==this.CONNECTING&&(this.readyState=this.OPEN,this.dispatchEvent("open",{type:"open"}));var e=t.getBuffer();e.length>this.bufferSizeLimit&&(this.log("buffer.length > this.bufferSizeLimit"),this.pollAgain()),0==this.cursor&&e.length>0&&"\ufeff"==e.substring(0,1)&&(this.cursor=1);var i=this.lastMessageIndex(e);if(i[0]>=this.cursor){var r=i[1],n=e.substring(this.cursor,r);this.parseStream(n),this.cursor=r}t.isDone()&&(this.log("request.isDone(). reopening the connection"),this.pollAgain(this.interval))}else this.readyState!==this.CLOSED&&(this.log("this.readyState !== this.CLOSED"),this.pollAgain(this.interval))},parseStream:function(t){var e,r,n,s,o,a,l=(t=this.cache+this.normalizeToLF(t)).split("\n\n");for(e=0;e<l.length-1;e++){n="message",s=[];var h=l[e].split("\n");for(r=0;r<h.length;r++)0==(o=this.trimWhiteSpace(h[r])).indexOf("event")?n=o.replace(/event:?\s*/,""):0==o.indexOf("retry")?(a=parseInt(o.replace(/retry:?\s*/,""),10),isNaN(a)||(this.interval=a)):0==o.indexOf("data")?s.push(o.replace(/data:?\s*/,"")):0==o.indexOf("id:")?this.lastEventId=o.replace(/id:?\s*/,""):0==o.indexOf("id")&&(this.lastEventId=null);if(s.length&&this.readyState!=this.CLOSED){var u=new i(n,s.join("\n"),"undefined"!=typeof window&&void 0!==window.location?window.location.origin:null,this.lastEventId);this.dispatchEvent(n,u)}}this.cache=l[l.length-1]},dispatchEvent:function(t,e){var i=this["_"+t+"Handlers"];if(i)for(var r=0;r<i.length;r++)i[r].call(this,e);this["on"+t]&&this["on"+t].call(this,e)},addEventListener:function(t,e){this["_"+t+"Handlers"]||(this["_"+t+"Handlers"]=[]),this["_"+t+"Handlers"].push(e)},removeEventListener:function(t,e){var i=this["_"+t+"Handlers"];if(i)for(var r=i.length-1;r>=0;--r)if(i[r]===e){i.splice(r,1);break}},_pollTimer:null,_noactivityTimer:null,_xhr:null,lastEventId:null,cache:"",cursor:0,onerror:null,onmessage:null,onopen:null,readyState:0,urlWithParams:function(t,e){var i=[];if(e){var r,n,s=encodeURIComponent;for(r in e)e.hasOwnProperty(r)&&(n=s(r)+"="+s(e[r]),i.push(n))}return i.length>0?-1==t.indexOf("?")?t+"?"+i.join("&"):t+"&"+i.join("&"):t},lastMessageIndex:function(t){var e=t.lastIndexOf("\n\n"),i=t.lastIndexOf("\r\r"),r=t.lastIndexOf("\r\n\r\n");return r>Math.max(e,i)?[r,r+4]:[Math.max(e,i),Math.max(e,i)+2]},trimWhiteSpace:function(t){return t.replace(/^(\s|\u00A0)+|(\s|\u00A0)+$/g,"")},normalizeToLF:function(t){return t.replace(/\r\n|\r/g,"\n")}},Boolean("undefined"!=typeof window&&window.XDomainRequest&&window.XMLHttpRequest&&void 0===(new XMLHttpRequest).responseType)){t.isPolyfill="IE_8-9";var e=t.prototype.defaultOptions;e.xhrHeaders=null,e.getArgs.evs_preamble=2056,t.prototype.XHR=function(t){var e=new XDomainRequest;this._request=e,e.onprogress=function(){e._ready=!0,t._onxhrdata()},e.onload=function(){this._loaded=!0,t._onxhrdata()},e.onerror=function(){this._failed=!0,t.readyState=t.CLOSED,t.dispatchEvent("error",{type:"error",data:"XDomainRequest error"})},e.ontimeout=function(){this._failed=!0,t.readyState=t.CLOSED,t.dispatchEvent("error",{type:"error",data:"XDomainRequest timed out"})};var i={};if(t.getArgs){var r=t.getArgs;for(var n in r)r.hasOwnProperty(n)&&(i[n]=r[n]);t.lastEventId&&(i.evs_last_event_id=t.lastEventId)}e.open("GET",t.urlWithParams(t.URL,i)),e.send()},t.prototype.XHR.prototype={useXDomainRequest:!0,_request:null,_ready:!1,_loaded:!1,_failed:!1,isReady:function(){return this._request._ready},isDone:function(){return this._request._loaded},hasError:function(){return this._request._failed},getBuffer:function(){var t="";try{t=this._request.responseText||""}catch(t){}return t},abort:function(){this._request&&this._request.abort()}}}else t.isPolyfill="XHR",t.prototype.XHR=function(t){var e=new XMLHttpRequest;this._request=e,t._xhr=this,e.onreadystatechange=function(){e.readyState>1&&t.readyState!=t.CLOSED&&(200==e.status||e.status>=300&&e.status<400?t._onxhrdata():(e._failed=!0,t.readyState=t.CLOSED,t.dispatchEvent("error",{type:"error",data:"The server responded with "+e.status}),t.close()))},e.onprogress=function(){},e.open("GET",t.urlWithParams(t.URL,t.getArgs),!0);var i=t.xhrHeaders;for(var r in i)i.hasOwnProperty(r)&&e.setRequestHeader(r,i[r]);t.lastEventId&&e.setRequestHeader("Last-Event-Id",t.lastEventId),e.send()},t.prototype.XHR.prototype={useXDomainRequest:!1,_request:null,_failed:!1,isReady:function(){return this._request.readyState>=2},isDone:function(){return 4==this._request.readyState},hasError:function(){return this._failed||this._request.status>=400},getBuffer:function(){var t="";try{t=this._request.responseText||""}catch(t){}return t},abort:function(){this._request&&this._request.abort()}};function i(t,e,i,r){this.bubbles=!1,this.cancelBubble=!1,this.cancelable=!1,this.data=e||null,this.origin=i||"",this.lastEventId=r||"",this.type=t||"message"}return t});
|
|
2
|
+
"use strict";function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray(e,t)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function _iterableToArrayLimit(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,a=[],o=!0,s=!1;try{for(r=r.call(e);!(o=(n=r.next()).done)&&(a.push(n.value),!t||a.length!==t);o=!0);}catch(e){s=!0,i=e}finally{try{o||null==r.return||r.return()}finally{if(s)throw i}}return a}}function _arrayWithHoles(e){if(Array.isArray(e))return e}var assign=require("object-assign"),_require=require("../util/observable"),map=_require.map,filter=_require.filter,queryString=require("../http/queryString"),validators=require("../validators");function AssetsClient(e){this.client=e}function optionsFromFile(e,t){return"undefined"!=typeof window&&t instanceof window.File?assign({filename:!1===e.preserveFilename?void 0:t.name,contentType:t.type},e):e}assign(AssetsClient.prototype,{upload:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};validators.validateAssetType(e);var n=r.extract||void 0;n&&!n.length&&(n=["none"]);var i=validators.hasDataset(this.client.clientConfig),a="image"===e?"images":"files",o=optionsFromFile(r,t),s=o.tag,l=o.label,c=o.title,u=o.description,d=o.creditLine,y=o.filename,f=o.source,p={label:l,title:c,description:u,filename:y,meta:n,creditLine:d};f&&(p.sourceId=f.id,p.sourceName=f.name,p.sourceUrl=f.url);var m=this.client._requestObservable({tag:s,method:"POST",timeout:o.timeout||0,uri:"/assets/".concat(a,"/").concat(i),headers:o.contentType?{"Content-Type":o.contentType}:{},query:p,body:t});return this.client.isPromiseAPI()?m.pipe(filter(function(e){return"response"===e.type}),map(function(e){return e.body.document})).toPromise():m},delete:function(e,t){console.warn("client.assets.delete() is deprecated, please use client.delete(<document-id>)");var r=t||"";return/^(image|file)-/.test(r)?e._id&&(r=e._id):r="".concat(e,"-").concat(r),validators.hasDataset(this.client.clientConfig),this.client.delete(r)},getImageUrl:function(e,t){var r=e._ref||e;if("string"!=typeof r)throw new Error("getImageUrl() needs either an object with a _ref, or a string with an asset document ID");if(!/^image-[A-Za-z0-9_]+-\d+x\d+-[a-z]{1,5}$/.test(r))throw new Error('Unsupported asset ID "'.concat(r,'". URL generation only works for auto-generated IDs.'));var n=_slicedToArray(r.split("-"),4),i=n[1],a=n[2],o=n[3];validators.hasDataset(this.client.clientConfig);var s=this.client.clientConfig,l=s.projectId,c=s.dataset,u=t?queryString(t):"";return"https://cdn.sanity.io/images/".concat(l,"/").concat(c,"/").concat(i,"-").concat(a,".").concat(o).concat(u)}}),module.exports=AssetsClient;
|
|
4
3
|
|
|
5
|
-
}
|
|
6
|
-
},{}
|
|
7
|
-
|
|
4
|
+
},{"../http/queryString":12,"../util/observable":20,"../validators":23,"object-assign":46}],2:[function(require,module,exports){
|
|
5
|
+
"use strict";var assign=require("object-assign");function AuthClient(t){this.client=t}assign(AuthClient.prototype,{getLoginProviders:function(){return this.client.request({uri:"/auth/providers"})},logout:function(){return this.client.request({uri:"/auth/logout",method:"POST"})}}),module.exports=AuthClient;
|
|
6
|
+
|
|
7
|
+
},{"object-assign":46}],3:[function(require,module,exports){
|
|
8
|
+
"use strict";var generateHelpUrl=require("@sanity/generate-help-url"),assign=require("object-assign"),validate=require("./validators"),warnings=require("./warnings"),defaultCdnHost="apicdn.sanity.io",defaultConfig={apiHost:"https://api.sanity.io",apiVersion:"1",useProjectHostname:!0,isPromiseAPI:!0},LOCALHOSTS=["localhost","127.0.0.1","0.0.0.0"],isLocal=function(e){return-1!==LOCALHOSTS.indexOf(e)};exports.defaultConfig=defaultConfig,exports.initConfig=function(e,i){var n=assign({},i,e);n.apiVersion||warnings.printNoApiVersionSpecifiedWarning();var t=assign({},defaultConfig,n),a=t.useProjectHostname;if("undefined"==typeof Promise){var o=generateHelpUrl("js-client-promise-polyfill");throw new Error("No native Promise-implementation found, polyfill needed - see ".concat(o))}if(a&&!t.projectId)throw new Error("Configuration must contain `projectId`");var r="undefined"!=typeof window&&window.location&&window.location.hostname,s=r&&isLocal(window.location.hostname);r&&s&&t.token&&!0!==t.ignoreBrowserTokenWarning?warnings.printBrowserTokenWarning():void 0===t.useCdn&&warnings.printCdnWarning(),a&&validate.projectId(t.projectId),t.dataset&&validate.dataset(t.dataset),"requestTagPrefix"in t&&(t.requestTagPrefix=t.requestTagPrefix?validate.requestTag(t.requestTagPrefix).replace(/\.+$/,""):void 0),t.apiVersion="".concat(t.apiVersion).replace(/^v/,""),t.isDefaultApi=t.apiHost===defaultConfig.apiHost,t.useCdn=Boolean(t.useCdn)&&!t.withCredentials,exports.validateApiVersion(t.apiVersion);var c=t.apiHost.split("://",2),d=c[0],l=c[1],p=t.isDefaultApi?defaultCdnHost:l;return t.useProjectHostname?(t.url="".concat(d,"://").concat(t.projectId,".").concat(l,"/v").concat(t.apiVersion),t.cdnUrl="".concat(d,"://").concat(t.projectId,".").concat(p,"/v").concat(t.apiVersion)):(t.url="".concat(t.apiHost,"/v").concat(t.apiVersion),t.cdnUrl=t.url),t},exports.validateApiVersion=function(e){if("1"!==e&&"X"!==e){var i=new Date(e);if(!(/^\d{4}-\d{2}-\d{2}$/.test(e)&&i instanceof Date&&i.getTime()>0))throw new Error("Invalid API version string, expected `1` or date in format `YYYY-MM-DD`")}};
|
|
9
|
+
|
|
10
|
+
},{"./validators":23,"./warnings":24,"@sanity/generate-help-url":27,"object-assign":46}],4:[function(require,module,exports){
|
|
11
|
+
"use strict";function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var assign=require("object-assign"),_require=require("../util/observable"),map=_require.map,filter=_require.filter,validators=require("../validators"),getSelection=require("../util/getSelection"),encodeQueryString=require("./encodeQueryString"),Transaction=require("./transaction"),Patch=require("./patch"),listen=require("./listen"),excludeFalsey=function(e,t){return!1===e?void 0:void 0===e?t:e},getMutationQuery=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{returnIds:!0,returnDocuments:excludeFalsey(e.returnDocuments,!0),visibility:e.visibility||"sync"}},isResponse=function(e){return"response"===e.type},getBody=function(e){return e.body},indexBy=function(e,t){return e.reduce(function(e,r){return e[t(r)]=r,e},Object.create(null))},toPromise=function(e){return e.toPromise()},getQuerySizeLimit=11264;module.exports={listen:listen,getDataUrl:function(e,t){var r=this.clientConfig,n=validators.hasDataset(r),i="/".concat(e,"/").concat(n),u=t?"".concat(i,"/").concat(t):i;return"/data".concat(u).replace(/\/($|\?)/,"$1")},fetch:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=!1===r.filterResponse?function(e){return e}:function(e){return e.result},i=this._dataRequest("query",{query:e,params:t},r).pipe(map(n));return this.isPromiseAPI()?toPromise(i):i},getDocument:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r={uri:this.getDataUrl("doc",e),json:!0,tag:t.tag},n=this._requestObservable(r).pipe(filter(isResponse),map(function(e){return e.body.documents&&e.body.documents[0]}));return this.isPromiseAPI()?toPromise(n):n},getDocuments:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r={uri:this.getDataUrl("doc",e.join(",")),json:!0,tag:t.tag},n=this._requestObservable(r).pipe(filter(isResponse),map(function(t){var r=indexBy(t.body.documents||[],function(e){return e._id});return e.map(function(e){return r[e]||null})}));return this.isPromiseAPI()?toPromise(n):n},create:function(e,t){return this._create(e,"create",t)},createIfNotExists:function(e,t){return validators.requireDocumentId("createIfNotExists",e),this._create(e,"createIfNotExists",t)},createOrReplace:function(e,t){return validators.requireDocumentId("createOrReplace",e),this._create(e,"createOrReplace",t)},patch:function(e,t){return new Patch(e,t,this)},delete:function(e,t){return this.dataRequest("mutate",{mutations:[{delete:getSelection(e)}]},t)},mutate:function(e,t){var r=e instanceof Patch||e instanceof Transaction?e.serialize():e,n=Array.isArray(r)?r:[r],i=t&&t.transactionId;return this.dataRequest("mutate",{mutations:n,transactionId:i},t)},transaction:function(e){return new Transaction(e,this)},dataRequest:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=this._dataRequest(e,t,r);return this.isPromiseAPI()?toPromise(n):n},_dataRequest:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n="mutate"===e,i="query"===e,u=!n&&encodeQueryString(t),a=!n&&u.length<getQuerySizeLimit,o=a?u:"",s=r.returnFirst,c=r.timeout,d=r.token,l=r.tag,f={method:a?"GET":"POST",uri:this.getDataUrl(e,o),json:!0,body:a?void 0:t,query:n&&getMutationQuery(r),timeout:c,token:d,tag:l,canUseCdn:i};return this._requestObservable(f).pipe(filter(isResponse),map(getBody),map(function(e){if(!n)return e;var t=e.results||[];if(r.returnDocuments)return s?t[0]&&t[0].document:t.map(function(e){return e.document});var i=s?"documentId":"documentIds",u=s?t[0]&&t[0].id:t.map(function(e){return e.id});return _defineProperty({transactionId:e.transactionId,results:t},i,u)}))},_create:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=_defineProperty({},t,e),i=assign({returnFirst:!0,returnDocuments:!0},r);return this.dataRequest("mutate",{mutations:[n]},i)}};
|
|
12
|
+
|
|
13
|
+
},{"../util/getSelection":19,"../util/observable":20,"../validators":23,"./encodeQueryString":5,"./listen":6,"./patch":7,"./transaction":8,"object-assign":46}],5:[function(require,module,exports){
|
|
14
|
+
"use strict";var _excluded=["tag"];function _objectWithoutProperties(e,t){if(null==e)return{};var c,o,n=_objectWithoutPropertiesLoose(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(o=0;o<r.length;o++)c=r[o],t.indexOf(c)>=0||Object.prototype.propertyIsEnumerable.call(e,c)&&(n[c]=e[c])}return n}function _objectWithoutPropertiesLoose(e,t){if(null==e)return{};var c,o,n={},r=Object.keys(e);for(o=0;o<r.length;o++)c=r[o],t.indexOf(c)>=0||(n[c]=e[c]);return n}var enc=encodeURIComponent;module.exports=function(e){var t=e.query,c=e.params,o=void 0===c?{}:c,n=e.options,r=void 0===n?{}:n,u=r.tag,a=_objectWithoutProperties(r,_excluded),i="query=".concat(enc(t)),s=u?"?tag=".concat(enc(u),"&").concat(i):"?".concat(i),l=Object.keys(o).reduce(function(e,t){return"".concat(e,"&").concat(enc("$".concat(t)),"=").concat(enc(JSON.stringify(o[t])))},s);return Object.keys(a).reduce(function(e,t){return r[t]?"".concat(e,"&").concat(enc(t),"=").concat(enc(r[t])):e},l)};
|
|
15
|
+
|
|
16
|
+
},{}],6:[function(require,module,exports){
|
|
17
|
+
"use strict";function ownKeys(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r&&(t=t.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),n.push.apply(n,t)}return n}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(n),!0).forEach(function(r){_defineProperty(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ownKeys(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function _defineProperty(e,r,n){return r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}var assign=require("object-assign"),_require=require("../util/observable"),Observable=_require.Observable,polyfilledEventSource=require("@sanity/eventsource"),generateHelpUrl=require("@sanity/generate-help-url"),pick=require("../util/pick"),once=require("../util/once"),defaults=require("../util/defaults"),encodeQueryString=require("./encodeQueryString"),MAX_URL_LENGTH=14800,tokenWarning=["Using token with listeners is not supported in browsers. ","For more info, see ".concat(generateHelpUrl("js-client-listener-tokens-browser"),".")],printTokenWarning=once(function(){return console.warn(tokenWarning.join(" "))}),isWindowEventSource=Boolean("undefined"!=typeof window&&window.EventSource),EventSource=isWindowEventSource?window.EventSource:polyfilledEventSource,possibleOptions=["includePreviousRevision","includeResult","visibility","effectFormat","tag"],defaultOptions={includeResult:!0};function parseEvent(e){try{var r=e.data&&JSON.parse(e.data)||{};return assign({type:e.type},r)}catch(e){return e}}function cooerceError(e){if(e instanceof Error)return e;var r=parseEvent(e);return r instanceof Error?r:new Error(extractErrorMessage(r))}function extractErrorMessage(e){return e.error?e.error.description?e.error.description:"string"==typeof e.error?e.error:JSON.stringify(e.error,null,2):e.message||"Unknown listener error"}module.exports=function(e,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},t=this.clientConfig,o=t.url,i=t.token,c=t.withCredentials,s=t.requestTagPrefix,u=n.tag&&s?[s,n.tag].join("."):n.tag,a=_objectSpread(_objectSpread({},defaults(n,defaultOptions)),{},{tag:u}),l=pick(a,possibleOptions),f=encodeQueryString({query:e,params:r,options:l,tag:u}),p="".concat(o).concat(this.getDataUrl("listen",f));if(p.length>MAX_URL_LENGTH)return new Observable(function(e){return e.error(new Error("Query too large for listener"))});var d=a.events?a.events:["mutation"],v=-1!==d.indexOf("reconnect");i&&isWindowEventSource&&printTokenWarning();var g={};return(i||c)&&(g.withCredentials=!0),i&&(g.headers={Authorization:"Bearer ".concat(i)}),new Observable(function(e){var r,n=a(),t=!1;function o(){t||(v&&e.next({type:"reconnect"}),t||n.readyState===EventSource.CLOSED&&(u(),clearTimeout(r),r=setTimeout(l,100)))}function i(r){e.error(cooerceError(r))}function c(r){var n=parseEvent(r);return n instanceof Error?e.error(n):e.next(n)}function s(r){t=!0,u(),e.complete()}function u(){n.removeEventListener("error",o,!1),n.removeEventListener("channelError",i,!1),n.removeEventListener("disconnect",s,!1),d.forEach(function(e){return n.removeEventListener(e,c,!1)}),n.close()}function a(){var e=new EventSource(p,g);return e.addEventListener("error",o,!1),e.addEventListener("channelError",i,!1),e.addEventListener("disconnect",s,!1),d.forEach(function(r){return e.addEventListener(r,c,!1)}),e}function l(){n=a()}return function(){t=!0,u()}})};
|
|
18
|
+
|
|
19
|
+
},{"../util/defaults":18,"../util/observable":20,"../util/once":21,"../util/pick":22,"./encodeQueryString":5,"@sanity/eventsource":26,"@sanity/generate-help-url":27,"object-assign":46}],7:[function(require,module,exports){
|
|
20
|
+
"use strict";function _defineProperty(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}var assign=require("object-assign"),getSelection=require("../util/getSelection"),validate=require("../validators"),validateObject=validate.validateObject,validateInsert=validate.validateInsert;function Patch(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.selection=t,this.operations=assign({},e),this.client=i}assign(Patch.prototype,{clone:function(){return new Patch(this.selection,assign({},this.operations),this.client)},set:function(t){return this._assign("set",t)},diffMatchPatch:function(t){return validateObject("diffMatchPatch",t),this._assign("diffMatchPatch",t)},unset:function(t){if(!Array.isArray(t))throw new Error("unset(attrs) takes an array of attributes to unset, non-array given");return this.operations=assign({},this.operations,{unset:t}),this},setIfMissing:function(t){return this._assign("setIfMissing",t)},replace:function(t){return validateObject("replace",t),this._set("set",{$:t})},inc:function(t){return this._assign("inc",t)},dec:function(t){return this._assign("dec",t)},insert:function(t,e,i){var n;return validateInsert(t,e,i),this._assign("insert",(_defineProperty(n={},t,e),_defineProperty(n,"items",i),n))},append:function(t,e){return this.insert("after","".concat(t,"[-1]"),e)},prepend:function(t,e){return this.insert("before","".concat(t,"[0]"),e)},splice:function(t,e,i,n){var s=e<0?e-1:e,r=void 0===i||-1===i?-1:Math.max(0,e+i),a=s<0&&r>=0?"":r,o="".concat(t,"[").concat(s,":").concat(a,"]");return this.insert("replace",o,n||[])},ifRevisionId:function(t){return this.operations.ifRevisionID=t,this},serialize:function(){return assign(getSelection(this.selection),this.operations)},toJSON:function(){return this.serialize()},commit:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this.client)throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");var e="string"==typeof this.selection,i=assign({returnFirst:e,returnDocuments:!0},t);return this.client.mutate({patch:this.serialize()},i)},reset:function(){return this.operations={},this},_set:function(t,e){return this._assign(t,e,!1)},_assign:function(t,e){var i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return validateObject(t,e),this.operations=assign({},this.operations,_defineProperty({},t,assign({},i&&this.operations[t]||{},e))),this}}),module.exports=Patch;
|
|
21
|
+
|
|
22
|
+
},{"../util/getSelection":19,"../validators":23,"object-assign":46}],8:[function(require,module,exports){
|
|
23
|
+
"use strict";function _defineProperty(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}var assign=require("object-assign"),validators=require("../validators"),Patch=require("./patch"),defaultMutateOptions={returnDocuments:!1};function Transaction(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1?arguments[1]:void 0,i=arguments.length>2?arguments[2]:void 0;this.trxId=i,this.operations=t,this.client=e}assign(Transaction.prototype,{clone:function(){return new Transaction(this.operations.slice(0),this.client,this.trxId)},create:function(t){return validators.validateObject("create",t),this._add({create:t})},createIfNotExists:function(t){var e="createIfNotExists";return validators.validateObject(e,t),validators.requireDocumentId(e,t),this._add(_defineProperty({},e,t))},createOrReplace:function(t){var e="createOrReplace";return validators.validateObject(e,t),validators.requireDocumentId(e,t),this._add(_defineProperty({},e,t))},delete:function(t){return validators.validateDocumentId("delete",t),this._add({delete:{id:t}})},patch:function(t,e){var i="function"==typeof e;if(t instanceof Patch)return this._add({patch:t.serialize()});if(i){var r=e(new Patch(t,{},this.client));if(!(r instanceof Patch))throw new Error("function passed to `patch()` must return the patch");return this._add({patch:r.serialize()})}return this._add({patch:assign({id:t},e)})},transactionId:function(t){return t?(this.trxId=t,this):this.trxId},serialize:function(){return this.operations.slice()},toJSON:function(){return this.serialize()},commit:function(t){if(!this.client)throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");return this.client.mutate(this.serialize(),assign({transactionId:this.trxId},defaultMutateOptions,t||{}))},reset:function(){return this.operations=[],this},_add:function(t){return this.operations.push(t),this}}),module.exports=Transaction;
|
|
24
|
+
|
|
25
|
+
},{"../validators":23,"./patch":7,"object-assign":46}],9:[function(require,module,exports){
|
|
26
|
+
"use strict";var assign=require("object-assign"),validate=require("../validators");function DatasetsClient(t){this.request=t.request.bind(t)}assign(DatasetsClient.prototype,{create:function(t,e){return this._modify("PUT",t,e)},edit:function(t,e){return this._modify("PATCH",t,e)},delete:function(t){return this._modify("DELETE",t)},list:function(){return this.request({uri:"/datasets"})},_modify:function(t,e,i){return validate.dataset(e),this.request({method:t,uri:"/datasets/".concat(e),body:i})}}),module.exports=DatasetsClient;
|
|
27
|
+
|
|
28
|
+
},{"../validators":23,"object-assign":46}],10:[function(require,module,exports){
|
|
29
|
+
"use strict";module.exports=[];
|
|
30
|
+
|
|
31
|
+
},{}],11:[function(require,module,exports){
|
|
32
|
+
"use strict";var makeError=require("make-error"),assign=require("object-assign");function ClientError(r){var e=extractErrorProps(r);ClientError.super.call(this,e.message),assign(this,e)}function ServerError(r){var e=extractErrorProps(r);ServerError.super.call(this,e.message),assign(this,e)}function extractErrorProps(r){var e=r.body,s={response:r,statusCode:r.statusCode,responseBody:stringifyBody(e,r)};return e.error&&e.message?(s.message="".concat(e.error," - ").concat(e.message),s):e.error&&e.error.description?(s.message=e.error.description,s.details=e.error,s):(s.message=e.error||e.message||httpErrorMessage(r),s)}function httpErrorMessage(r){var e=r.statusMessage?" ".concat(r.statusMessage):"";return"".concat(r.method,"-request to ").concat(r.url," resulted in HTTP ").concat(r.statusCode).concat(e)}function stringifyBody(r,e){return-1!==(e.headers["content-type"]||"").toLowerCase().indexOf("application/json")?JSON.stringify(r,null,2):r}makeError(ClientError),makeError(ServerError),exports.ClientError=ClientError,exports.ServerError=ServerError;
|
|
33
|
+
|
|
34
|
+
},{"make-error":44,"object-assign":46}],12:[function(require,module,exports){
|
|
35
|
+
"use strict";module.exports=function(n){var o=[];for(var e in n)n.hasOwnProperty(e)&&o.push("".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(n[e])));return o.length>0?"?".concat(o.join("&")):""};
|
|
36
|
+
|
|
37
|
+
},{}],13:[function(require,module,exports){
|
|
38
|
+
"use strict";var getIt=require("get-it"),assign=require("object-assign"),observable=require("get-it/lib/middleware/observable"),jsonRequest=require("get-it/lib/middleware/jsonRequest"),jsonResponse=require("get-it/lib/middleware/jsonResponse"),progress=require("get-it/lib/middleware/progress"),_require=require("../util/observable"),Observable=_require.Observable,_require2=require("./errors"),ClientError=_require2.ClientError,ServerError=_require2.ServerError,httpError={onResponse:function(e){if(e.statusCode>=500)throw new ServerError(e);if(e.statusCode>=400)throw new ClientError(e);return e}},printWarnings={onResponse:function(e){var r=e.headers["x-sanity-warning"];return(Array.isArray(r)?r:[r]).filter(Boolean).forEach(function(e){return console.warn(e)}),e}},envSpecific=require("./nodeMiddleware"),middleware=envSpecific.concat([printWarnings,jsonRequest(),jsonResponse(),progress(),httpError,observable({implementation:Observable})]),request=getIt(middleware);function httpRequest(e){return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:request)(assign({maxRedirects:0},e))}httpRequest.defaultRequester=request,httpRequest.ClientError=ClientError,httpRequest.ServerError=ServerError,module.exports=httpRequest;
|
|
39
|
+
|
|
40
|
+
},{"../util/observable":20,"./errors":11,"./nodeMiddleware":10,"get-it":28,"get-it/lib/middleware/jsonRequest":32,"get-it/lib/middleware/jsonResponse":33,"get-it/lib/middleware/observable":34,"get-it/lib/middleware/progress":36,"object-assign":46}],14:[function(require,module,exports){
|
|
41
|
+
"use strict";var assign=require("object-assign"),projectHeader="X-Sanity-Project-ID";module.exports=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o={},r=t.token||e.token;r&&(o.Authorization="Bearer ".concat(r)),t.useGlobalApi||e.useProjectHostname||!e.projectId||(o[projectHeader]=e.projectId);var i=Boolean(void 0===t.withCredentials?e.token||e.withCredentials:t.withCredentials),a=void 0===t.timeout?e.timeout:t.timeout;return assign({},t,{headers:assign({},o,t.headers||{}),timeout:void 0===a?3e5:a,proxy:t.proxy||e.proxy,json:!0,withCredentials:i})};
|
|
42
|
+
|
|
43
|
+
},{"object-assign":46}],15:[function(require,module,exports){
|
|
44
|
+
"use strict";var assign=require("object-assign");function ProjectsClient(t){this.client=t}assign(ProjectsClient.prototype,{list:function(){return this.client.request({uri:"/projects"})},getById:function(t){return this.client.request({uri:"/projects/".concat(t)})}}),module.exports=ProjectsClient;
|
|
45
|
+
|
|
46
|
+
},{"object-assign":46}],16:[function(require,module,exports){
|
|
47
|
+
"use strict";function ownKeys(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),i.push.apply(i,r)}return i}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(i),!0).forEach(function(t){_defineProperty(e,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):ownKeys(Object(i)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}function _defineProperty(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}var assign=require("object-assign"),_require=require("./util/observable"),Observable=_require.Observable,map=_require.map,filter=_require.filter,Patch=require("./data/patch"),Transaction=require("./data/transaction"),dataMethods=require("./data/dataMethods"),DatasetsClient=require("./datasets/datasetsClient"),ProjectsClient=require("./projects/projectsClient"),AssetsClient=require("./assets/assetsClient"),UsersClient=require("./users/usersClient"),AuthClient=require("./auth/authClient"),httpRequest=require("./http/request"),getRequestOptions=require("./http/requestOptions"),_require2=require("./config"),defaultConfig=_require2.defaultConfig,initConfig=_require2.initConfig,validate=require("./validators"),toPromise=function(e){return e.toPromise()};function SanityClient(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:defaultConfig;if(!(this instanceof SanityClient))return new SanityClient(e);if(this.config(e),this.assets=new AssetsClient(this),this.datasets=new DatasetsClient(this),this.projects=new ProjectsClient(this),this.users=new UsersClient(this),this.auth=new AuthClient(this),this.clientConfig.isPromiseAPI){var t=assign({},this.clientConfig,{isPromiseAPI:!1});this.observable=new SanityClient(t)}}assign(SanityClient.prototype,dataMethods),assign(SanityClient.prototype,{clone:function(){return new SanityClient(this.config())},config:function(e){if(void 0===e)return assign({},this.clientConfig);if(this.observable){var t=assign({},e,{isPromiseAPI:!1});this.observable.config(t)}return this.clientConfig=initConfig(e,this.clientConfig||{}),this},withConfig:function(e){return this.clone().config(e)},getUrl:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1]?this.clientConfig.cdnUrl:this.clientConfig.url;return"".concat(t,"/").concat(e.replace(/^\//,""))},isPromiseAPI:function(){return this.clientConfig.isPromiseAPI},_requestObservable:function(e){var t=this,i=e.url||e.uri,r=void 0===e.canUseCdn?["GET","HEAD"].indexOf(e.method||"GET")>=0&&0===i.indexOf("/data/"):e.canUseCdn,n=this.clientConfig.useCdn&&r,s=e.tag&&this.clientConfig.requestTagPrefix?[this.clientConfig.requestTagPrefix,e.tag].join("."):e.tag||this.clientConfig.requestTagPrefix;s&&(e.query=_objectSpread({tag:validate.requestTag(s)},e.query));var o=getRequestOptions(this.clientConfig,assign({},e,{url:this.getUrl(i,n)}));return new Observable(function(e){return httpRequest(o,t.clientConfig.requester).subscribe(e)})},request:function(e){var t=this._requestObservable(e).pipe(filter(function(e){return"response"===e.type}),map(function(e){return e.body}));return this.isPromiseAPI()?toPromise(t):t}}),SanityClient.Patch=Patch,SanityClient.Transaction=Transaction,SanityClient.ClientError=httpRequest.ClientError,SanityClient.ServerError=httpRequest.ServerError,SanityClient.requester=httpRequest.defaultRequester,module.exports=SanityClient;
|
|
48
|
+
|
|
49
|
+
},{"./assets/assetsClient":1,"./auth/authClient":2,"./config":3,"./data/dataMethods":4,"./data/patch":7,"./data/transaction":8,"./datasets/datasetsClient":9,"./http/request":13,"./http/requestOptions":14,"./projects/projectsClient":15,"./users/usersClient":17,"./util/observable":20,"./validators":23,"object-assign":46}],17:[function(require,module,exports){
|
|
50
|
+
"use strict";var assign=require("object-assign");function UsersClient(e){this.client=e}assign(UsersClient.prototype,{getById:function(e){return this.client.request({uri:"/users/".concat(e)})}}),module.exports=UsersClient;
|
|
51
|
+
|
|
52
|
+
},{"object-assign":46}],18:[function(require,module,exports){
|
|
53
|
+
"use strict";module.exports=function(e,t){return Object.keys(t).concat(Object.keys(e)).reduce(function(c,n){return c[n]=void 0===e[n]?t[n]:e[n],c},{})};
|
|
54
|
+
|
|
55
|
+
},{}],19:[function(require,module,exports){
|
|
56
|
+
"use strict";module.exports=function(r){if("string"==typeof r||Array.isArray(r))return{id:r};if(r&&r.query)return"params"in r?{query:r.query,params:r.params}:{query:r.query};var n=["* Document ID (<docId>)","* Array of document IDs","* Object containing `query`"].join("\n");throw new Error("Unknown selection - must be one of:\n\n".concat(n))};
|
|
57
|
+
|
|
58
|
+
},{}],20:[function(require,module,exports){
|
|
59
|
+
"use strict";var _require=require("rxjs/internal/Observable"),Observable=_require.Observable,_require2=require("rxjs/internal/operators/filter"),filter=_require2.filter,_require3=require("rxjs/internal/operators/map"),map=_require3.map;module.exports={Observable:Observable,filter:filter,map:map};
|
|
60
|
+
|
|
61
|
+
},{"rxjs/internal/Observable":50,"rxjs/internal/operators/filter":55,"rxjs/internal/operators/map":56}],21:[function(require,module,exports){
|
|
62
|
+
"use strict";module.exports=function(r){var t,n=!1;return function(){return n?t:(t=r.apply(void 0,arguments),n=!0,t)}};
|
|
63
|
+
|
|
64
|
+
},{}],22:[function(require,module,exports){
|
|
65
|
+
"use strict";module.exports=function(e,r){return r.reduce(function(r,t){return void 0===e[t]?r:(r[t]=e[t],r)},{})};
|
|
8
66
|
|
|
9
|
-
},{
|
|
10
|
-
|
|
67
|
+
},{}],23:[function(require,module,exports){
|
|
68
|
+
"use strict";function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var VALID_ASSET_TYPES=["image","file"],VALID_INSERT_LOCATIONS=["before","after","replace"];exports.dataset=function(t){if(!/^(~[a-z0-9]{1}[-\w]{0,63}|[a-z0-9]{1}[-\w]{0,63})$/.test(t))throw new Error("Datasets can only contain lowercase characters, numbers, underscores and dashes, and start with tilde, and be maximum 64 characters")},exports.projectId=function(t){if(!/^[-a-z0-9]+$/i.test(t))throw new Error("`projectId` can only contain only a-z, 0-9 and dashes")},exports.validateAssetType=function(t){if(-1===VALID_ASSET_TYPES.indexOf(t))throw new Error("Invalid asset type: ".concat(t,". Must be one of ").concat(VALID_ASSET_TYPES.join(", ")))},exports.validateObject=function(t,e){if(null===e||"object"!==_typeof(e)||Array.isArray(e))throw new Error("".concat(t,"() takes an object of properties"))},exports.requireDocumentId=function(t,e){if(!e._id)throw new Error("".concat(t,'() requires that the document contains an ID ("_id" property)'));exports.validateDocumentId(t,e._id)},exports.validateDocumentId=function(t,e){if("string"!=typeof e||!/^[a-z0-9_.-]+$/i.test(e))throw new Error("".concat(t,'(): "').concat(e,'" is not a valid document ID'))},exports.validateInsert=function(t,e,r){var o="insert(at, selector, items)";if(-1===VALID_INSERT_LOCATIONS.indexOf(t)){var n=VALID_INSERT_LOCATIONS.map(function(t){return'"'.concat(t,'"')}).join(", ");throw new Error("".concat(o,' takes an "at"-argument which is one of: ').concat(n))}if("string"!=typeof e)throw new Error("".concat(o,' takes a "selector"-argument which must be a string'));if(!Array.isArray(r))throw new Error("".concat(o,' takes an "items"-argument which must be an array'))},exports.hasDataset=function(t){if(!t.dataset)throw new Error("`dataset` must be provided to perform queries");return t.dataset||""},exports.requestTag=function(t){if("string"!=typeof t||!/^[a-z0-9._-]{1,75}$/i.test(t))throw new Error("Tag can only contain alphanumeric characters, underscores, dashes and dots, and be between one and 75 characters long.");return t};
|
|
11
69
|
|
|
12
|
-
},{
|
|
13
|
-
|
|
70
|
+
},{}],24:[function(require,module,exports){
|
|
71
|
+
"use strict";var generateHelpUrl=require("@sanity/generate-help-url"),once=require("./util/once"),createWarningPrinter=function(e){return once(function(){for(var n,r=arguments.length,t=new Array(r),i=0;i<r;i++)t[i]=arguments[i];return(n=console).warn.apply(n,[e.join(" ")].concat(t))})};exports.printCdnWarning=createWarningPrinter(["You are not using the Sanity CDN. That means your data is always fresh, but the CDN is faster and","cheaper. Think about it! For more info, see ".concat(generateHelpUrl("js-client-cdn-configuration"),"."),"To hide this warning, please set the `useCdn` option to either `true` or `false` when creating","the client."]),exports.printBrowserTokenWarning=createWarningPrinter(["You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.","See ".concat(generateHelpUrl("js-client-browser-token")," for more information and how to hide this warning.")]),exports.printNoApiVersionSpecifiedWarning=createWarningPrinter(["Using the Sanity client without specifying an API version is deprecated.","See ".concat(generateHelpUrl("js-client-api-version"))]);
|
|
14
72
|
|
|
15
|
-
},{"
|
|
16
|
-
|
|
73
|
+
},{"./util/once":21,"@sanity/generate-help-url":27}],25:[function(require,module,exports){
|
|
74
|
+
(function (global){(function (){
|
|
75
|
+
!function(t,e){if("function"==typeof define&&define.amd)define([],e);else if("object"==typeof module&&module.exports)module.exports=e();else{if(global.EventSource&&!global._eventSourceImportPrefix)return;t[(t._eventSourceImportPrefix||"")+"EventSource"]=e()}}("undefined"==typeof self?this:self,function(){var t=function(t,e){if(!t||"string"!=typeof t)throw new SyntaxError("Not enough arguments");this.URL=t,this.setOptions(e);var i=this;setTimeout(function(){i.poll()},0)};if(t.prototype={CONNECTING:0,OPEN:1,CLOSED:2,defaultOptions:{loggingEnabled:!1,loggingPrefix:"eventsource",interval:500,bufferSizeLimit:262144,silentTimeout:3e5,getArgs:{evs_buffer_size_limit:262144},xhrHeaders:{Accept:"text/event-stream","Cache-Control":"no-cache","X-Requested-With":"XMLHttpRequest"}},setOptions:function(t){var e,i=this.defaultOptions;for(e in i)i.hasOwnProperty(e)&&(this[e]=i[e]);for(e in t)e in i&&t.hasOwnProperty(e)&&(this[e]=t[e]);this.getArgs&&this.bufferSizeLimit&&(this.getArgs.evs_buffer_size_limit=this.bufferSizeLimit),"undefined"!=typeof console&&void 0!==console.log||(this.loggingEnabled=!1)},log:function(t){this.loggingEnabled&&console.log("["+this.loggingPrefix+"]:"+t)},poll:function(){try{if(this.readyState==this.CLOSED)return;this.cleanup(),this.readyState=this.CONNECTING,this.cursor=0,this.cache="",this._xhr=new this.XHR(this),this.resetNoActivityTimer()}catch(t){this.log("There were errors inside the pool try-catch"),this.dispatchEvent("error",{type:"error",data:t.message})}},pollAgain:function(t){var e=this;e.readyState=e.CONNECTING,e.dispatchEvent("error",{type:"error",data:"Reconnecting "}),this._pollTimer=setTimeout(function(){e.poll()},t||0)},cleanup:function(){this.log("evs cleaning up"),this._pollTimer&&(clearInterval(this._pollTimer),this._pollTimer=null),this._noActivityTimer&&(clearInterval(this._noActivityTimer),this._noActivityTimer=null),this._xhr&&(this._xhr.abort(),this._xhr=null)},resetNoActivityTimer:function(){if(this.silentTimeout){this._noActivityTimer&&clearInterval(this._noActivityTimer);var t=this;this._noActivityTimer=setTimeout(function(){t.log("Timeout! silentTImeout:"+t.silentTimeout),t.pollAgain()},this.silentTimeout)}},close:function(){this.readyState=this.CLOSED,this.log("Closing connection. readyState: "+this.readyState),this.cleanup()},_onxhrdata:function(){var t=this._xhr;if(t.isReady()&&!t.hasError()){this.resetNoActivityTimer(),this.readyState==this.CONNECTING&&(this.readyState=this.OPEN,this.dispatchEvent("open",{type:"open"}));var e=t.getBuffer();e.length>this.bufferSizeLimit&&(this.log("buffer.length > this.bufferSizeLimit"),this.pollAgain()),0==this.cursor&&e.length>0&&"\ufeff"==e.substring(0,1)&&(this.cursor=1);var i=this.lastMessageIndex(e);if(i[0]>=this.cursor){var r=i[1],n=e.substring(this.cursor,r);this.parseStream(n),this.cursor=r}t.isDone()&&(this.log("request.isDone(). reopening the connection"),this.pollAgain(this.interval))}else this.readyState!==this.CLOSED&&(this.log("this.readyState !== this.CLOSED"),this.pollAgain(this.interval))},parseStream:function(t){var e,r,n,s,o,a,l=(t=this.cache+this.normalizeToLF(t)).split("\n\n");for(e=0;e<l.length-1;e++){n="message",s=[];var h=l[e].split("\n");for(r=0;r<h.length;r++)0==(o=this.trimWhiteSpace(h[r])).indexOf("event")?n=o.replace(/event:?\s*/,""):0==o.indexOf("retry")?(a=parseInt(o.replace(/retry:?\s*/,""),10),isNaN(a)||(this.interval=a)):0==o.indexOf("data")?s.push(o.replace(/data:?\s*/,"")):0==o.indexOf("id:")?this.lastEventId=o.replace(/id:?\s*/,""):0==o.indexOf("id")&&(this.lastEventId=null);if(s.length&&this.readyState!=this.CLOSED){var u=new i(n,s.join("\n"),"undefined"!=typeof window&&void 0!==window.location?window.location.origin:null,this.lastEventId);this.dispatchEvent(n,u)}}this.cache=l[l.length-1]},dispatchEvent:function(t,e){var i=this["_"+t+"Handlers"];if(i)for(var r=0;r<i.length;r++)i[r].call(this,e);this["on"+t]&&this["on"+t].call(this,e)},addEventListener:function(t,e){this["_"+t+"Handlers"]||(this["_"+t+"Handlers"]=[]),this["_"+t+"Handlers"].push(e)},removeEventListener:function(t,e){var i=this["_"+t+"Handlers"];if(i)for(var r=i.length-1;r>=0;--r)if(i[r]===e){i.splice(r,1);break}},_pollTimer:null,_noactivityTimer:null,_xhr:null,lastEventId:null,cache:"",cursor:0,onerror:null,onmessage:null,onopen:null,readyState:0,urlWithParams:function(t,e){var i=[];if(e){var r,n,s=encodeURIComponent;for(r in e)e.hasOwnProperty(r)&&(n=s(r)+"="+s(e[r]),i.push(n))}return i.length>0?-1==t.indexOf("?")?t+"?"+i.join("&"):t+"&"+i.join("&"):t},lastMessageIndex:function(t){var e=t.lastIndexOf("\n\n"),i=t.lastIndexOf("\r\r"),r=t.lastIndexOf("\r\n\r\n");return r>Math.max(e,i)?[r,r+4]:[Math.max(e,i),Math.max(e,i)+2]},trimWhiteSpace:function(t){return t.replace(/^(\s|\u00A0)+|(\s|\u00A0)+$/g,"")},normalizeToLF:function(t){return t.replace(/\r\n|\r/g,"\n")}},Boolean("undefined"!=typeof window&&window.XDomainRequest&&window.XMLHttpRequest&&void 0===(new XMLHttpRequest).responseType)){t.isPolyfill="IE_8-9";var e=t.prototype.defaultOptions;e.xhrHeaders=null,e.getArgs.evs_preamble=2056,t.prototype.XHR=function(t){var e=new XDomainRequest;this._request=e,e.onprogress=function(){e._ready=!0,t._onxhrdata()},e.onload=function(){this._loaded=!0,t._onxhrdata()},e.onerror=function(){this._failed=!0,t.readyState=t.CLOSED,t.dispatchEvent("error",{type:"error",data:"XDomainRequest error"})},e.ontimeout=function(){this._failed=!0,t.readyState=t.CLOSED,t.dispatchEvent("error",{type:"error",data:"XDomainRequest timed out"})};var i={};if(t.getArgs){var r=t.getArgs;for(var n in r)r.hasOwnProperty(n)&&(i[n]=r[n]);t.lastEventId&&(i.evs_last_event_id=t.lastEventId)}e.open("GET",t.urlWithParams(t.URL,i)),e.send()},t.prototype.XHR.prototype={useXDomainRequest:!0,_request:null,_ready:!1,_loaded:!1,_failed:!1,isReady:function(){return this._request._ready},isDone:function(){return this._request._loaded},hasError:function(){return this._request._failed},getBuffer:function(){var t="";try{t=this._request.responseText||""}catch(t){}return t},abort:function(){this._request&&this._request.abort()}}}else t.isPolyfill="XHR",t.prototype.XHR=function(t){var e=new XMLHttpRequest;this._request=e,t._xhr=this,e.onreadystatechange=function(){e.readyState>1&&t.readyState!=t.CLOSED&&(200==e.status||e.status>=300&&e.status<400?t._onxhrdata():(e._failed=!0,t.readyState=t.CLOSED,t.dispatchEvent("error",{type:"error",data:"The server responded with "+e.status}),t.close()))},e.onprogress=function(){},e.open("GET",t.urlWithParams(t.URL,t.getArgs),!0);var i=t.xhrHeaders;for(var r in i)i.hasOwnProperty(r)&&e.setRequestHeader(r,i[r]);t.lastEventId&&e.setRequestHeader("Last-Event-Id",t.lastEventId),e.send()},t.prototype.XHR.prototype={useXDomainRequest:!1,_request:null,_failed:!1,isReady:function(){return this._request.readyState>=2},isDone:function(){return 4==this._request.readyState},hasError:function(){return this._failed||this._request.status>=400},getBuffer:function(){var t="";try{t=this._request.responseText||""}catch(t){}return t},abort:function(){this._request&&this._request.abort()}};function i(t,e,i,r){this.bubbles=!1,this.cancelBubble=!1,this.cancelable=!1,this.data=e||null,this.origin=i||"",this.lastEventId=r||"",this.type=t||"message"}return t});
|
|
17
76
|
|
|
18
|
-
},
|
|
19
|
-
exports
|
|
77
|
+
}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
78
|
+
},{}],26:[function(require,module,exports){
|
|
79
|
+
var evs=require("@rexxars/eventsource-polyfill");module.exports="undefined"!=typeof window&&window.EventSource?window.EventSource:evs.EventSource;
|
|
20
80
|
|
|
21
|
-
},{"
|
|
22
|
-
|
|
81
|
+
},{"@rexxars/eventsource-polyfill":25}],27:[function(require,module,exports){
|
|
82
|
+
var baseUrl="https://docs.sanity.io/help/";module.exports=function(e){return baseUrl+e};
|
|
23
83
|
|
|
24
|
-
},{
|
|
84
|
+
},{}],28:[function(require,module,exports){
|
|
25
85
|
module.exports=require("./lib-node");
|
|
26
86
|
|
|
27
|
-
},{"./lib-node":
|
|
87
|
+
},{"./lib-node":29}],29:[function(require,module,exports){
|
|
28
88
|
"use strict";var pubsub=require("nano-pubsub"),middlewareReducer=require("./util/middlewareReducer"),processOptions=require("./middleware/defaultOptionsProcessor"),validateOptions=require("./middleware/defaultOptionsValidator"),httpRequester=require("./request"),channelNames=["request","response","progress","error","abort"],middlehooks=["processOptions","validateOptions","interceptRequest","finalizeOptions","onRequest","onResponse","onError","onReturn","onHeaders"];module.exports=function e(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:httpRequester,n=[],o=middlehooks.reduce(function(e,r){return e[r]=e[r]||[],e},{processOptions:[processOptions],validateOptions:[validateOptions]});function s(e){var r=channelNames.reduce(function(e,r){return e[r]=pubsub(),e},{}),n=middlewareReducer(o),s=n("processOptions",e);n("validateOptions",s);var i={options:s,channels:r,applyMiddleware:n},u=null,a=r.request.subscribe(function(e){u=t(e,function(t,o){return function(e,t,o){var s=e,i=t;if(!s)try{i=n("onResponse",t,o)}catch(e){i=null,s=e}(s=s&&n("onError",s,o))?r.error.publish(s):i&&r.response.publish(i)}(t,o,e)})});r.abort.subscribe(function(){a(),u&&u.abort()});var d=n("onReturn",r,i);return d===r&&r.request.publish(i),d}return s.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&&o.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 middlehooks.forEach(function(r){e[r]&&o[r].push(e[r])}),n.push(e),s},s.clone=function(){return e(n)},r.forEach(s.use),s};
|
|
29
89
|
|
|
30
|
-
},{"./middleware/defaultOptionsProcessor":
|
|
90
|
+
},{"./middleware/defaultOptionsProcessor":30,"./middleware/defaultOptionsValidator":31,"./request":39,"./util/middlewareReducer":41,"nano-pubsub":45}],30:[function(require,module,exports){
|
|
31
91
|
"use strict";var objectAssign=require("object-assign"),urlParse=require("url-parse"),isReactNative="undefined"!=typeof navigator&&"ReactNative"===navigator.product,has=Object.prototype.hasOwnProperty,defaultOptions={timeout:isReactNative?6e4:12e4};function stringifyQueryString(e){var t=[];for(var r in e)has.call(e,r)&&n(r,e[r]);return t.length?t.join("&"):"";function n(e,r){Array.isArray(r)?r.forEach(function(t){return n(e,t)}):t.push([e,r].map(encodeURIComponent).join("="))}}function normalizeTimeout(e){if(!1===e||0===e)return!1;if(e.connect||e.socket)return e;var t=Number(e);return isNaN(t)?normalizeTimeout(defaultOptions.timeout):{connect:t,socket:t}}function removeUndefined(e){var t={};for(var r in e)void 0!==e[r]&&(t[r]=e[r]);return t}module.exports=function(e){var t="string"==typeof e?objectAssign({url:e},defaultOptions):objectAssign({},defaultOptions,e),r=urlParse(t.url,{},!0);return t.timeout=normalizeTimeout(t.timeout),t.query&&(r.query=objectAssign({},r.query,removeUndefined(t.query))),t.method=t.body&&!t.method?"POST":(t.method||"GET").toUpperCase(),t.url=r.toString(stringifyQueryString),t};
|
|
32
92
|
|
|
33
|
-
},{"object-assign":
|
|
93
|
+
},{"object-assign":46,"url-parse":70}],31:[function(require,module,exports){
|
|
34
94
|
"use strict";var validUrl=/^https?:\/\//i;module.exports=function(r){if(!validUrl.test(r.url))throw new Error('"'+r.url+'" is not a valid URL')};
|
|
35
95
|
|
|
36
|
-
},{}],
|
|
96
|
+
},{}],32:[function(require,module,exports){
|
|
37
97
|
"use strict";var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},objectAssign=require("object-assign"),isPlainObject=require("is-plain-object"),serializeTypes=["boolean","string","number"],isBuffer=function(o){return!!o.constructor&&"function"==typeof o.constructor.isBuffer&&o.constructor.isBuffer(o)};module.exports=function(){return{processOptions:function(o){var e=o.body;return e&&!("function"==typeof e.pipe)&&!isBuffer(e)&&(-1!==serializeTypes.indexOf(void 0===e?"undefined":_typeof(e))||Array.isArray(e)||isPlainObject(e))?objectAssign({},o,{body:JSON.stringify(o.body),headers:objectAssign({},o.headers,{"Content-Type":"application/json"})}):o}}};
|
|
38
98
|
|
|
39
|
-
},{"is-plain-object":
|
|
99
|
+
},{"is-plain-object":42,"object-assign":46}],33:[function(require,module,exports){
|
|
40
100
|
"use strict";var objectAssign=require("object-assign");function tryParse(e){try{return JSON.parse(e)}catch(e){throw e.message="Failed to parsed response body as JSON: "+e.message,e}}module.exports=function(e){return{onResponse:function(s){var t=s.headers["content-type"]||"",n=e&&e.force||-1!==t.indexOf("application/json");return s.body&&t&&n?objectAssign({},s,{body:tryParse(s.body)}):s},processOptions:function(e){return objectAssign({},e,{headers:objectAssign({Accept:"application/json"},e.headers)})}}};
|
|
41
101
|
|
|
42
|
-
},{"object-assign":
|
|
102
|
+
},{"object-assign":46}],34:[function(require,module,exports){
|
|
43
103
|
"use strict";var global=require("../util/global"),objectAssign=require("object-assign");module.exports=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).implementation||global.Observable;if(!e)throw new Error("`Observable` is not available in global scope, and no implementation was passed");return{onReturn:function(r,n){return new e(function(e){return r.error.subscribe(function(r){return e.error(r)}),r.progress.subscribe(function(r){return e.next(objectAssign({type:"progress"},r))}),r.response.subscribe(function(r){e.next(objectAssign({type:"response"},r)),e.complete()}),r.request.publish(n),function(){return r.abort.publish()}})}}};
|
|
44
104
|
|
|
45
|
-
},{"../util/global":
|
|
105
|
+
},{"../util/global":40,"object-assign":46}],35:[function(require,module,exports){
|
|
46
106
|
"use strict";module.exports=function(){return{onRequest:function(o){if("xhr"===o.adapter){var e=o.request,t=o.context;"upload"in e&&"onprogress"in e.upload&&(e.upload.onprogress=n("upload")),"onprogress"in e&&(e.onprogress=n("download"))}function n(o){return function(e){var n=e.lengthComputable?e.loaded/e.total*100:-1;t.channels.progress.publish({stage:o,percent:n,total:e.total,loaded:e.loaded,lengthComputable:e.lengthComputable})}}}}};
|
|
47
107
|
|
|
48
|
-
},{}],
|
|
108
|
+
},{}],36:[function(require,module,exports){
|
|
49
109
|
"use strict";module.exports=require("./node-progress");
|
|
50
110
|
|
|
51
|
-
},{"./node-progress":
|
|
111
|
+
},{"./node-progress":35}],37:[function(require,module,exports){
|
|
52
112
|
"use strict";var sameOrigin=require("same-origin"),parseHeaders=require("parse-headers"),FetchXhr=require("./browser/fetchXhr"),noop=function(){},win="undefined"==typeof window?void 0:window,adapter=win?"xhr":"fetch",XmlHttpRequest="function"==typeof XMLHttpRequest?XMLHttpRequest:noop,hasXhr2="withCredentials"in new XmlHttpRequest,XDR="undefined"==typeof XDomainRequest?void 0:XDomainRequest,CrossDomainRequest=hasXhr2?XmlHttpRequest:XDR;win||(XmlHttpRequest=FetchXhr,CrossDomainRequest=FetchXhr),module.exports=function(e,t){var r=e.options,n=e.applyMiddleware("finalizeOptions",r),o={},s=win&&win.location&&!sameOrigin(win.location.href,n.url),i=e.applyMiddleware("interceptRequest",void 0,{adapter:adapter,context:e});if(i){var a=setTimeout(t,0,null,i);return{abort:function(){return clearTimeout(a)}}}var u=s?new CrossDomainRequest:new XmlHttpRequest,c=win&&win.XDomainRequest&&u instanceof win.XDomainRequest,d=n.headers,l=n.timeout,p=!1,f=!1,w=!1;if(u.onerror=R,u.ontimeout=R,u.onabort=function(){p=!0},u.onprogress=function(){},u[c?"onload":"onreadystatechange"]=function(){!function(){if(!l)return;q(),o.socket=setTimeout(function(){return m("ESOCKETTIMEDOUT")},l.socket)}(),p||4!==u.readyState&&!c||0!==u.status&&function(){if(p||f||w)return;if(0===u.status)return void R(new Error("Unknown XHR error"));q(),f=!0,t(null,function(){var e=u.status,t=u.statusText;if(c&&void 0===e)e=200;else{if(e>12e3&&e<12156)return R();e=1223===u.status?204:u.status,t=1223===u.status?"No Content":t}return{body:u.response||u.responseText,url:n.url,method:n.method,headers:c?{}:parseHeaders(u.getAllResponseHeaders()),statusCode:e,statusMessage:t}}())}()},u.open(n.method,n.url,!0),u.withCredentials=!!n.withCredentials,d&&u.setRequestHeader)for(var h in d)d.hasOwnProperty(h)&&u.setRequestHeader(h,d[h]);else if(d&&c)throw new Error("Headers cannot be set on an XDomainRequest object");return n.rawBody&&(u.responseType="arraybuffer"),e.applyMiddleware("onRequest",{options:n,adapter:adapter,request:u,context:e}),u.send(n.body||null),l&&(o.connect=setTimeout(function(){return m("ETIMEDOUT")},l.connect)),{abort:function(){p=!0,u&&u.abort()}};function m(t){w=!0,u.abort();var r=new Error("ESOCKETTIMEDOUT"===t?"Socket timed out on request to "+n.url:"Connection timed out on request to "+n.url);r.code=t,e.channels.error.publish(r)}function q(){(p||u.readyState>=2&&o.connect)&&clearTimeout(o.connect),o.socket&&clearTimeout(o.socket)}function R(e){if(!f){q(),f=!0,u=null;var r=e||new Error("Network error while attempting to reach "+n.url);r.isNetworkError=!0,r.request=n,t(r)}}};
|
|
53
113
|
|
|
54
|
-
},{"./browser/fetchXhr":
|
|
114
|
+
},{"./browser/fetchXhr":38,"parse-headers":47,"same-origin":68}],38:[function(require,module,exports){
|
|
55
115
|
"use strict";function FetchXhr(){this.readyState=0}FetchXhr.prototype.open=function(t,e){this._method=t,this._url=e,this._resHeaders="",this.readyState=1,this.onreadystatechange()},FetchXhr.prototype.abort=function(){this._controller&&this._controller.abort()},FetchXhr.prototype.getAllResponseHeaders=function(){return this._resHeaders},FetchXhr.prototype.setRequestHeader=function(t,e){this._headers=this._headers||{},this._headers[t]=e},FetchXhr.prototype.send=function(t){var e=this,r=this._controller="function"==typeof AbortController&&new AbortController,s="arraybuffer"!==this.responseType,o={method:this._method,headers:this._headers,signal:r&&r.signal,body:t};"undefined"!=typeof window&&(o.credentials=this.withCredentials?"include":"omit"),fetch(this._url,o).then(function(t){return t.headers.forEach(function(t,r){e._resHeaders+=r+": "+t+"\r\n"}),e.status=t.status,e.statusText=t.statusText,e.readyState=3,s?t.text():t.arrayBuffer()}).then(function(t){s?e.responseText=t:e.response=t,e.readyState=4,e.onreadystatechange()}).catch(function(t){"AbortError"!==t.name?e.onerror(t):e.onabort()})},module.exports=FetchXhr;
|
|
56
116
|
|
|
57
|
-
},{}],
|
|
117
|
+
},{}],39:[function(require,module,exports){
|
|
58
118
|
"use strict";module.exports=require("./node-request");
|
|
59
119
|
|
|
60
|
-
},{"./node-request":
|
|
120
|
+
},{"./node-request":37}],40:[function(require,module,exports){
|
|
61
121
|
(function (global){(function (){
|
|
62
122
|
"use strict";"undefined"!=typeof window?module.exports=window:"undefined"!=typeof global?module.exports=global:"undefined"!=typeof self?module.exports=self:module.exports={};
|
|
63
123
|
|
|
64
124
|
}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
65
|
-
},{}],
|
|
125
|
+
},{}],41:[function(require,module,exports){
|
|
66
126
|
"use strict";module.exports=function(r){return function(n,o){for(var t=arguments.length,e=Array(t>2?t-2:0),u=2;u<t;u++)e[u-2]=arguments[u];for(var a="onError"===n,c=o,f=0;f<r[n].length&&(c=r[n][f].apply(void 0,[c].concat(e)),!a||c);f++);return c}};
|
|
67
127
|
|
|
68
|
-
},{}],
|
|
69
|
-
module.exports=function(){var n=[];return{subscribe:function(u){return n.push(u),function(){var r=n.indexOf(u);r>-1&&n.splice(r,1)}},publish:function(){for(var u=0;u<n.length;u++)n[u].apply(null,arguments)}}};
|
|
70
|
-
|
|
71
|
-
},{}],23:[function(require,module,exports){
|
|
72
|
-
"use strict";module.exports=function(t){var e=typeof t;return null!==t&&("object"===e||"function"===e)};
|
|
73
|
-
|
|
74
|
-
},{}],24:[function(require,module,exports){
|
|
128
|
+
},{}],42:[function(require,module,exports){
|
|
75
129
|
"use strict";var isObject=require("isobject");function isObjectObject(t){return!0===isObject(t)&&"[object Object]"===Object.prototype.toString.call(t)}module.exports=function(t){var e,c;return!1!==isObjectObject(t)&&("function"==typeof(e=t.constructor)&&(!1!==isObjectObject(c=e.prototype)&&!1!==c.hasOwnProperty("isPrototypeOf")))};
|
|
76
130
|
|
|
77
|
-
},{"isobject":
|
|
131
|
+
},{"isobject":43}],43:[function(require,module,exports){
|
|
78
132
|
"use strict";module.exports=function(r){return null!=r&&"object"==typeof r&&!1===Array.isArray(r)};
|
|
79
133
|
|
|
80
|
-
},{}],
|
|
134
|
+
},{}],44:[function(require,module,exports){
|
|
81
135
|
"use strict";var construct="undefined"!=typeof Reflect?Reflect.construct:void 0,defineProperty=Object.defineProperty,captureStackTrace=Error.captureStackTrace;function BaseError(r){void 0!==r&&defineProperty(this,"message",{configurable:!0,value:r,writable:!0});var e=this.constructor.name;void 0!==e&&e!==this.name&&defineProperty(this,"name",{configurable:!0,value:e,writable:!0}),captureStackTrace(this,this.constructor)}void 0===captureStackTrace&&(captureStackTrace=function(r){var e=new Error;defineProperty(r,"stack",{configurable:!0,get:function(){var r=e.stack;return defineProperty(this,"stack",{configurable:!0,value:r,writable:!0}),r},set:function(e){defineProperty(r,"stack",{configurable:!0,value:e,writable:!0})}})}),BaseError.prototype=Object.create(Error.prototype,{constructor:{configurable:!0,value:BaseError,writable:!0}});var setFunctionName=function(){function r(r,e){return defineProperty(r,"name",{configurable:!0,value:e})}try{var e=function(){};if(r(e,"foo"),"foo"===e.name)return r}catch(r){}}();function makeError(r,e){if(null==e||e===Error)e=BaseError;else if("function"!=typeof e)throw new TypeError("super_ should be a function");var t;if("string"==typeof r)t=r,r=void 0!==construct?function(){return construct(e,arguments,this.constructor)}:function(){e.apply(this,arguments)},void 0!==setFunctionName&&(setFunctionName(r,t),t=void 0);else if("function"!=typeof r)throw new TypeError("constructor should be either a string or a function");r.super_=r.super=e;var o={constructor:{configurable:!0,value:r,writable:!0}};return void 0!==t&&(o.name={configurable:!0,value:t,writable:!0}),r.prototype=Object.create(e.prototype,o),r}exports=module.exports=makeError,exports.BaseError=BaseError;
|
|
82
136
|
|
|
83
|
-
},{}],
|
|
137
|
+
},{}],45:[function(require,module,exports){
|
|
138
|
+
module.exports=function(){var n=[];return{subscribe:function(u){return n.push(u),function(){var r=n.indexOf(u);r>-1&&n.splice(r,1)}},publish:function(){for(var u=0;u<n.length;u++)n[u].apply(null,arguments)}}};
|
|
139
|
+
|
|
140
|
+
},{}],46:[function(require,module,exports){
|
|
84
141
|
"use strict";var getOwnPropertySymbols=Object.getOwnPropertySymbols,hasOwnProperty=Object.prototype.hasOwnProperty,propIsEnumerable=Object.prototype.propertyIsEnumerable;function toObject(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}function shouldUseNative(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var r={},t=0;t<10;t++)r["_"+String.fromCharCode(t)]=t;if("0123456789"!==Object.getOwnPropertyNames(r).map(function(e){return r[e]}).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach(function(e){n[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(e){return!1}}module.exports=shouldUseNative()?Object.assign:function(e,r){for(var t,n,o=toObject(e),a=1;a<arguments.length;a++){for(var s in t=Object(arguments[a]))hasOwnProperty.call(t,s)&&(o[s]=t[s]);if(getOwnPropertySymbols){n=getOwnPropertySymbols(t);for(var c=0;c<n.length;c++)propIsEnumerable.call(t,n[c])&&(o[n[c]]=t[n[c]])}}return o};
|
|
85
142
|
|
|
86
|
-
},{}],
|
|
143
|
+
},{}],47:[function(require,module,exports){
|
|
87
144
|
var trim=function(r){return r.replace(/^\s+|\s+$/g,"")},isArray=function(r){return"[object Array]"===Object.prototype.toString.call(r)};module.exports=function(r){if(!r)return{};for(var t={},e=trim(r).split("\n"),i=0;i<e.length;i++){var n=e[i],o=n.indexOf(":"),s=trim(n.slice(0,o)).toLowerCase(),a=trim(n.slice(o+1));void 0===t[s]?t[s]=a:isArray(t[s])?t[s].push(a):t[s]=[t[s],a]}return t};
|
|
88
145
|
|
|
89
|
-
},{}],
|
|
146
|
+
},{}],48:[function(require,module,exports){
|
|
90
147
|
"use strict";var undef,has=Object.prototype.hasOwnProperty;function decode(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(e){return null}}function encode(e){try{return encodeURIComponent(e)}catch(e){return null}}function querystring(e){for(var n,r=/([^=?#&]+)=?([^&]*)/g,t={};n=r.exec(e);){var o=decode(n[1]),u=decode(n[2]);null===o||null===u||o in t||(t[o]=u)}return t}function querystringify(e,n){n=n||"";var r,t,o=[];for(t in"string"!=typeof n&&(n="?"),e)if(has.call(e,t)){if((r=e[t])||null!==r&&r!==undef&&!isNaN(r)||(r=""),t=encode(t),r=encode(r),null===t||null===r)continue;o.push(t+"="+r)}return o.length?n+o.join("&"):""}exports.stringify=querystringify,exports.parse=querystring;
|
|
91
148
|
|
|
92
|
-
},{}],
|
|
149
|
+
},{}],49:[function(require,module,exports){
|
|
93
150
|
"use strict";module.exports=function(e,t){if(t=t.split(":")[0],!(e=+e))return!1;switch(t){case"http":case"ws":return 80!==e;case"https":case"wss":return 443!==e;case"ftp":return 21!==e;case"gopher":return 70!==e;case"file":return!1}return 0!==e};
|
|
94
151
|
|
|
95
|
-
},{}],
|
|
152
|
+
},{}],50:[function(require,module,exports){
|
|
96
153
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var canReportError_1=require("./util/canReportError"),toSubscriber_1=require("./util/toSubscriber"),observable_1=require("./symbol/observable"),pipe_1=require("./util/pipe"),config_1=require("./config"),Observable=function(){function r(r){this._isScalar=!1,r&&(this._subscribe=r)}return r.prototype.lift=function(e){var o=new r;return o.source=this,o.operator=e,o},r.prototype.subscribe=function(r,e,o){var t=this.operator,n=toSubscriber_1.toSubscriber(r,e,o);if(t?n.add(t.call(n,this.source)):n.add(this.source||config_1.config.useDeprecatedSynchronousErrorHandling&&!n.syncErrorThrowable?this._subscribe(n):this._trySubscribe(n)),config_1.config.useDeprecatedSynchronousErrorHandling&&n.syncErrorThrowable&&(n.syncErrorThrowable=!1,n.syncErrorThrown))throw n.syncErrorValue;return n},r.prototype._trySubscribe=function(r){try{return this._subscribe(r)}catch(e){config_1.config.useDeprecatedSynchronousErrorHandling&&(r.syncErrorThrown=!0,r.syncErrorValue=e),canReportError_1.canReportError(r)?r.error(e):console.warn(e)}},r.prototype.forEach=function(r,e){var o=this;return new(e=getPromiseCtor(e))(function(e,t){var n;n=o.subscribe(function(e){try{r(e)}catch(r){t(r),n&&n.unsubscribe()}},t,e)})},r.prototype._subscribe=function(r){var e=this.source;return e&&e.subscribe(r)},r.prototype[observable_1.observable]=function(){return this},r.prototype.pipe=function(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];return 0===r.length?this:pipe_1.pipeFromArray(r)(this)},r.prototype.toPromise=function(r){var e=this;return new(r=getPromiseCtor(r))(function(r,o){var t;e.subscribe(function(r){return t=r},function(r){return o(r)},function(){return r(t)})})},r.create=function(e){return new r(e)},r}();function getPromiseCtor(r){if(r||(r=config_1.config.Promise||Promise),!r)throw new Error("no Promise impl found");return r}exports.Observable=Observable;
|
|
97
154
|
|
|
98
|
-
},{"./config":
|
|
155
|
+
},{"./config":54,"./symbol/observable":57,"./util/canReportError":60,"./util/pipe":66,"./util/toSubscriber":67}],51:[function(require,module,exports){
|
|
99
156
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var config_1=require("./config"),hostReportError_1=require("./util/hostReportError");exports.empty={closed:!0,next:function(r){},error:function(r){if(config_1.config.useDeprecatedSynchronousErrorHandling)throw r;hostReportError_1.hostReportError(r)},complete:function(){}};
|
|
100
157
|
|
|
101
|
-
},{"./config":
|
|
158
|
+
},{"./config":54,"./util/hostReportError":61}],52:[function(require,module,exports){
|
|
102
159
|
"use strict";var __extends=this&&this.__extends||function(){var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,t){r.__proto__=t}||function(r,t){for(var e in t)t.hasOwnProperty(e)&&(r[e]=t[e])})(t,e)};return function(t,e){function o(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}}();Object.defineProperty(exports,"__esModule",{value:!0});var isFunction_1=require("./util/isFunction"),Observer_1=require("./Observer"),Subscription_1=require("./Subscription"),rxSubscriber_1=require("../internal/symbol/rxSubscriber"),config_1=require("./config"),hostReportError_1=require("./util/hostReportError"),Subscriber=function(r){function t(e,o,n){var s=r.call(this)||this;switch(s.syncErrorValue=null,s.syncErrorThrown=!1,s.syncErrorThrowable=!1,s.isStopped=!1,arguments.length){case 0:s.destination=Observer_1.empty;break;case 1:if(!e){s.destination=Observer_1.empty;break}if("object"==typeof e){e instanceof t?(s.syncErrorThrowable=e.syncErrorThrowable,s.destination=e,e.add(s)):(s.syncErrorThrowable=!0,s.destination=new SafeSubscriber(s,e));break}default:s.syncErrorThrowable=!0,s.destination=new SafeSubscriber(s,e,o,n)}return s}return __extends(t,r),t.prototype[rxSubscriber_1.rxSubscriber]=function(){return this},t.create=function(r,e,o){var n=new t(r,e,o);return n.syncErrorThrowable=!1,n},t.prototype.next=function(r){this.isStopped||this._next(r)},t.prototype.error=function(r){this.isStopped||(this.isStopped=!0,this._error(r))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,r.prototype.unsubscribe.call(this))},t.prototype._next=function(r){this.destination.next(r)},t.prototype._error=function(r){this.destination.error(r),this.unsubscribe()},t.prototype._complete=function(){this.destination.complete(),this.unsubscribe()},t.prototype._unsubscribeAndRecycle=function(){var r=this._parentOrParents;return this._parentOrParents=null,this.unsubscribe(),this.closed=!1,this.isStopped=!1,this._parentOrParents=r,this},t}(Subscription_1.Subscription);exports.Subscriber=Subscriber;var SafeSubscriber=function(r){function t(t,e,o,n){var s,i=r.call(this)||this;i._parentSubscriber=t;var c=i;return isFunction_1.isFunction(e)?s=e:e&&(s=e.next,o=e.error,n=e.complete,e!==Observer_1.empty&&(c=Object.create(e),isFunction_1.isFunction(c.unsubscribe)&&i.add(c.unsubscribe.bind(c)),c.unsubscribe=i.unsubscribe.bind(i))),i._context=c,i._next=s,i._error=o,i._complete=n,i}return __extends(t,r),t.prototype.next=function(r){if(!this.isStopped&&this._next){var t=this._parentSubscriber;config_1.config.useDeprecatedSynchronousErrorHandling&&t.syncErrorThrowable?this.__tryOrSetError(t,this._next,r)&&this.unsubscribe():this.__tryOrUnsub(this._next,r)}},t.prototype.error=function(r){if(!this.isStopped){var t=this._parentSubscriber,e=config_1.config.useDeprecatedSynchronousErrorHandling;if(this._error)e&&t.syncErrorThrowable?(this.__tryOrSetError(t,this._error,r),this.unsubscribe()):(this.__tryOrUnsub(this._error,r),this.unsubscribe());else if(t.syncErrorThrowable)e?(t.syncErrorValue=r,t.syncErrorThrown=!0):hostReportError_1.hostReportError(r),this.unsubscribe();else{if(this.unsubscribe(),e)throw r;hostReportError_1.hostReportError(r)}}},t.prototype.complete=function(){var r=this;if(!this.isStopped){var t=this._parentSubscriber;if(this._complete){var e=function(){return r._complete.call(r._context)};config_1.config.useDeprecatedSynchronousErrorHandling&&t.syncErrorThrowable?(this.__tryOrSetError(t,e),this.unsubscribe()):(this.__tryOrUnsub(e),this.unsubscribe())}else this.unsubscribe()}},t.prototype.__tryOrUnsub=function(r,t){try{r.call(this._context,t)}catch(r){if(this.unsubscribe(),config_1.config.useDeprecatedSynchronousErrorHandling)throw r;hostReportError_1.hostReportError(r)}},t.prototype.__tryOrSetError=function(r,t,e){if(!config_1.config.useDeprecatedSynchronousErrorHandling)throw new Error("bad call");try{t.call(this._context,e)}catch(t){return config_1.config.useDeprecatedSynchronousErrorHandling?(r.syncErrorValue=t,r.syncErrorThrown=!0,!0):(hostReportError_1.hostReportError(t),!0)}return!1},t.prototype._unsubscribe=function(){var r=this._parentSubscriber;this._context=null,this._parentSubscriber=null,r.unsubscribe()},t}(Subscriber);exports.SafeSubscriber=SafeSubscriber;
|
|
103
160
|
|
|
104
|
-
},{"../internal/symbol/rxSubscriber":
|
|
161
|
+
},{"../internal/symbol/rxSubscriber":58,"./Observer":51,"./Subscription":53,"./config":54,"./util/hostReportError":61,"./util/isFunction":64}],53:[function(require,module,exports){
|
|
105
162
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var isArray_1=require("./util/isArray"),isObject_1=require("./util/isObject"),isFunction_1=require("./util/isFunction"),UnsubscriptionError_1=require("./util/UnsubscriptionError"),Subscription=function(){function r(r){this.closed=!1,this._parentOrParents=null,this._subscriptions=null,r&&(this._ctorUnsubscribe=!0,this._unsubscribe=r)}var i;return r.prototype.unsubscribe=function(){var i;if(!this.closed){var s=this._parentOrParents,t=this._ctorUnsubscribe,n=this._unsubscribe,e=this._subscriptions;if(this.closed=!0,this._parentOrParents=null,this._subscriptions=null,s instanceof r)s.remove(this);else if(null!==s)for(var o=0;o<s.length;++o){s[o].remove(this)}if(isFunction_1.isFunction(n)){t&&(this._unsubscribe=void 0);try{n.call(this)}catch(r){i=r instanceof UnsubscriptionError_1.UnsubscriptionError?flattenUnsubscriptionErrors(r.errors):[r]}}if(isArray_1.isArray(e)){o=-1;for(var u=e.length;++o<u;){var c=e[o];if(isObject_1.isObject(c))try{c.unsubscribe()}catch(r){i=i||[],r instanceof UnsubscriptionError_1.UnsubscriptionError?i=i.concat(flattenUnsubscriptionErrors(r.errors)):i.push(r)}}}if(i)throw new UnsubscriptionError_1.UnsubscriptionError(i)}},r.prototype.add=function(i){var s=i;if(!i)return r.EMPTY;switch(typeof i){case"function":s=new r(i);case"object":if(s===this||s.closed||"function"!=typeof s.unsubscribe)return s;if(this.closed)return s.unsubscribe(),s;if(!(s instanceof r)){var t=s;(s=new r)._subscriptions=[t]}break;default:throw new Error("unrecognized teardown "+i+" added to Subscription.")}var n=s._parentOrParents;if(null===n)s._parentOrParents=this;else if(n instanceof r){if(n===this)return s;s._parentOrParents=[n,this]}else{if(-1!==n.indexOf(this))return s;n.push(this)}var e=this._subscriptions;return null===e?this._subscriptions=[s]:e.push(s),s},r.prototype.remove=function(r){var i=this._subscriptions;if(i){var s=i.indexOf(r);-1!==s&&i.splice(s,1)}},r.EMPTY=((i=new r).closed=!0,i),r}();function flattenUnsubscriptionErrors(r){return r.reduce(function(r,i){return r.concat(i instanceof UnsubscriptionError_1.UnsubscriptionError?i.errors:i)},[])}exports.Subscription=Subscription;
|
|
106
163
|
|
|
107
|
-
},{"./util/UnsubscriptionError":
|
|
164
|
+
},{"./util/UnsubscriptionError":59,"./util/isArray":63,"./util/isFunction":64,"./util/isObject":65}],54:[function(require,module,exports){
|
|
108
165
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _enable_super_gross_mode_that_will_cause_bad_things=!1;exports.config={Promise:void 0,set useDeprecatedSynchronousErrorHandling(e){if(e){var r=new Error;console.warn("DEPRECATED! RxJS was set to use deprecated synchronous error handling behavior by code at: \n"+r.stack)}else _enable_super_gross_mode_that_will_cause_bad_things&&console.log("RxJS: Back to a better error behavior. Thank you. <3");_enable_super_gross_mode_that_will_cause_bad_things=e},get useDeprecatedSynchronousErrorHandling(){return _enable_super_gross_mode_that_will_cause_bad_things}};
|
|
109
166
|
|
|
110
|
-
},{}],
|
|
111
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var Observable_1=require("../Observable");function empty(e){return e?emptyScheduled(e):exports.EMPTY}function emptyScheduled(e){return new Observable_1.Observable(function(r){return e.schedule(function(){return r.complete()})})}exports.EMPTY=new Observable_1.Observable(function(e){return e.complete()}),exports.empty=empty;
|
|
112
|
-
|
|
113
|
-
},{"../Observable":31}],37:[function(require,module,exports){
|
|
114
|
-
"use strict";var __extends=this&&this.__extends||function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(e,r)};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(exports,"__esModule",{value:!0});var Subscriber_1=require("../Subscriber");function defaultIfEmpty(t){return void 0===t&&(t=null),function(e){return e.lift(new DefaultIfEmptyOperator(t))}}exports.defaultIfEmpty=defaultIfEmpty;var DefaultIfEmptyOperator=function(){function t(t){this.defaultValue=t}return t.prototype.call=function(t,e){return e.subscribe(new DefaultIfEmptySubscriber(t,this.defaultValue))},t}(),DefaultIfEmptySubscriber=function(t){function e(e,r){var n=t.call(this,e)||this;return n.defaultValue=r,n.isEmpty=!0,n}return __extends(e,t),e.prototype._next=function(t){this.isEmpty=!1,this.destination.next(t)},e.prototype._complete=function(){this.isEmpty&&this.destination.next(this.defaultValue),this.destination.complete()},e}(Subscriber_1.Subscriber);
|
|
115
|
-
|
|
116
|
-
},{"../Subscriber":33}],38:[function(require,module,exports){
|
|
167
|
+
},{}],55:[function(require,module,exports){
|
|
117
168
|
"use strict";var __extends=this&&this.__extends||function(){var t=function(r,e){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var e in r)r.hasOwnProperty(e)&&(t[e]=r[e])})(r,e)};return function(r,e){function i(){this.constructor=r}t(r,e),r.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}}();Object.defineProperty(exports,"__esModule",{value:!0});var Subscriber_1=require("../Subscriber");function filter(t,r){return function(e){return e.lift(new FilterOperator(t,r))}}exports.filter=filter;var FilterOperator=function(){function t(t,r){this.predicate=t,this.thisArg=r}return t.prototype.call=function(t,r){return r.subscribe(new FilterSubscriber(t,this.predicate,this.thisArg))},t}(),FilterSubscriber=function(t){function r(r,e,i){var n=t.call(this,r)||this;return n.predicate=e,n.thisArg=i,n.count=0,n}return __extends(r,t),r.prototype._next=function(t){var r;try{r=this.predicate.call(this.thisArg,t,this.count++)}catch(t){return void this.destination.error(t)}r&&this.destination.next(t)},r}(Subscriber_1.Subscriber);
|
|
118
169
|
|
|
119
|
-
},{"../Subscriber":
|
|
170
|
+
},{"../Subscriber":52}],56:[function(require,module,exports){
|
|
120
171
|
"use strict";var __extends=this&&this.__extends||function(){var t=function(r,e){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var e in r)r.hasOwnProperty(e)&&(t[e]=r[e])})(r,e)};return function(r,e){function n(){this.constructor=r}t(r,e),r.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}();Object.defineProperty(exports,"__esModule",{value:!0});var Subscriber_1=require("../Subscriber");function map(t,r){return function(e){if("function"!=typeof t)throw new TypeError("argument is not a function. Are you looking for `mapTo()`?");return e.lift(new MapOperator(t,r))}}exports.map=map;var MapOperator=function(){function t(t,r){this.project=t,this.thisArg=r}return t.prototype.call=function(t,r){return r.subscribe(new MapSubscriber(t,this.project,this.thisArg))},t}();exports.MapOperator=MapOperator;var MapSubscriber=function(t){function r(r,e,n){var o=t.call(this,r)||this;return o.project=e,o.count=0,o.thisArg=n||o,o}return __extends(r,t),r.prototype._next=function(t){var r;try{r=this.project.call(this.thisArg,t,this.count++)}catch(t){return void this.destination.error(t)}this.destination.next(r)},r}(Subscriber_1.Subscriber);
|
|
121
172
|
|
|
122
|
-
},{"../Subscriber":
|
|
123
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var scan_1=require("./scan"),takeLast_1=require("./takeLast"),defaultIfEmpty_1=require("./defaultIfEmpty"),pipe_1=require("../util/pipe");function reduce(e,t){return arguments.length>=2?function(r){return pipe_1.pipe(scan_1.scan(e,t),takeLast_1.takeLast(1),defaultIfEmpty_1.defaultIfEmpty(t))(r)}:function(t){return pipe_1.pipe(scan_1.scan(function(t,r,a){return e(t,r,a+1)}),takeLast_1.takeLast(1))(t)}}exports.reduce=reduce;
|
|
124
|
-
|
|
125
|
-
},{"../util/pipe":53,"./defaultIfEmpty":37,"./scan":41,"./takeLast":42}],41:[function(require,module,exports){
|
|
126
|
-
"use strict";var __extends=this&&this.__extends||function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(e,r)};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(exports,"__esModule",{value:!0});var Subscriber_1=require("../Subscriber");function scan(t,e){var r=!1;return arguments.length>=2&&(r=!0),function(n){return n.lift(new ScanOperator(t,e,r))}}exports.scan=scan;var ScanOperator=function(){function t(t,e,r){void 0===r&&(r=!1),this.accumulator=t,this.seed=e,this.hasSeed=r}return t.prototype.call=function(t,e){return e.subscribe(new ScanSubscriber(t,this.accumulator,this.seed,this.hasSeed))},t}(),ScanSubscriber=function(t){function e(e,r,n,i){var s=t.call(this,e)||this;return s.accumulator=r,s._seed=n,s.hasSeed=i,s.index=0,s}return __extends(e,t),Object.defineProperty(e.prototype,"seed",{get:function(){return this._seed},set:function(t){this.hasSeed=!0,this._seed=t},enumerable:!0,configurable:!0}),e.prototype._next=function(t){if(this.hasSeed)return this._tryNext(t);this.seed=t,this.destination.next(t)},e.prototype._tryNext=function(t){var e,r=this.index++;try{e=this.accumulator(this.seed,t,r)}catch(t){this.destination.error(t)}this.seed=e,this.destination.next(e)},e}(Subscriber_1.Subscriber);
|
|
127
|
-
|
|
128
|
-
},{"../Subscriber":33}],42:[function(require,module,exports){
|
|
129
|
-
"use strict";var __extends=this&&this.__extends||function(){var t=function(r,e){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var e in r)r.hasOwnProperty(e)&&(t[e]=r[e])})(r,e)};return function(r,e){function n(){this.constructor=r}t(r,e),r.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}}();Object.defineProperty(exports,"__esModule",{value:!0});var Subscriber_1=require("../Subscriber"),ArgumentOutOfRangeError_1=require("../util/ArgumentOutOfRangeError"),empty_1=require("../observable/empty");function takeLast(t){return function(r){return 0===t?empty_1.empty():r.lift(new TakeLastOperator(t))}}exports.takeLast=takeLast;var TakeLastOperator=function(){function t(t){if(this.total=t,this.total<0)throw new ArgumentOutOfRangeError_1.ArgumentOutOfRangeError}return t.prototype.call=function(t,r){return r.subscribe(new TakeLastSubscriber(t,this.total))},t}(),TakeLastSubscriber=function(t){function r(r,e){var n=t.call(this,r)||this;return n.total=e,n.ring=new Array,n.count=0,n}return __extends(r,t),r.prototype._next=function(t){var r=this.ring,e=this.total,n=this.count++;r.length<e?r.push(t):r[n%e]=t},r.prototype._complete=function(){var t=this.destination,r=this.count;if(r>0)for(var e=this.count>=this.total?this.total:this.count,n=this.ring,o=0;o<e;o++){var i=r++%e;t.next(n[i])}t.complete()},r}(Subscriber_1.Subscriber);
|
|
130
|
-
|
|
131
|
-
},{"../Subscriber":33,"../observable/empty":36,"../util/ArgumentOutOfRangeError":45}],43:[function(require,module,exports){
|
|
173
|
+
},{"../Subscriber":52}],57:[function(require,module,exports){
|
|
132
174
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.observable="function"==typeof Symbol&&Symbol.observable||"@@observable";
|
|
133
175
|
|
|
134
|
-
},{}],
|
|
176
|
+
},{}],58:[function(require,module,exports){
|
|
135
177
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.rxSubscriber="function"==typeof Symbol?Symbol("rxSubscriber"):"@@rxSubscriber_"+Math.random(),exports.$$rxSubscriber=exports.rxSubscriber;
|
|
136
178
|
|
|
137
|
-
},{}],
|
|
138
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var ArgumentOutOfRangeErrorImpl=function(){function r(){return Error.call(this),this.message="argument out of range",this.name="ArgumentOutOfRangeError",this}return r.prototype=Object.create(Error.prototype),r}();exports.ArgumentOutOfRangeError=ArgumentOutOfRangeErrorImpl;
|
|
139
|
-
|
|
140
|
-
},{}],46:[function(require,module,exports){
|
|
179
|
+
},{}],59:[function(require,module,exports){
|
|
141
180
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var UnsubscriptionErrorImpl=function(){function r(r){return Error.call(this),this.message=r?r.length+" errors occurred during unsubscription:\n"+r.map(function(r,t){return t+1+") "+r.toString()}).join("\n "):"",this.name="UnsubscriptionError",this.errors=r,this}return r.prototype=Object.create(Error.prototype),r}();exports.UnsubscriptionError=UnsubscriptionErrorImpl;
|
|
142
181
|
|
|
143
|
-
},{}],
|
|
182
|
+
},{}],60:[function(require,module,exports){
|
|
144
183
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var Subscriber_1=require("../Subscriber");function canReportError(r){for(;r;){var e=r,o=e.closed,t=e.destination,i=e.isStopped;if(o||i)return!1;r=t&&t instanceof Subscriber_1.Subscriber?t:null}return!0}exports.canReportError=canReportError;
|
|
145
184
|
|
|
146
|
-
},{"../Subscriber":
|
|
185
|
+
},{"../Subscriber":52}],61:[function(require,module,exports){
|
|
147
186
|
"use strict";function hostReportError(r){setTimeout(function(){throw r},0)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.hostReportError=hostReportError;
|
|
148
187
|
|
|
149
|
-
},{}],
|
|
188
|
+
},{}],62:[function(require,module,exports){
|
|
150
189
|
"use strict";function identity(e){return e}Object.defineProperty(exports,"__esModule",{value:!0}),exports.identity=identity;
|
|
151
190
|
|
|
152
|
-
},{}],
|
|
191
|
+
},{}],63:[function(require,module,exports){
|
|
153
192
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isArray=Array.isArray||function(e){return e&&"number"==typeof e.length};
|
|
154
193
|
|
|
155
|
-
},{}],
|
|
194
|
+
},{}],64:[function(require,module,exports){
|
|
156
195
|
"use strict";function isFunction(t){return"function"==typeof t}Object.defineProperty(exports,"__esModule",{value:!0}),exports.isFunction=isFunction;
|
|
157
196
|
|
|
158
|
-
},{}],
|
|
197
|
+
},{}],65:[function(require,module,exports){
|
|
159
198
|
"use strict";function isObject(e){return null!==e&&"object"==typeof e}Object.defineProperty(exports,"__esModule",{value:!0}),exports.isObject=isObject;
|
|
160
199
|
|
|
161
|
-
},{}],
|
|
200
|
+
},{}],66:[function(require,module,exports){
|
|
162
201
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var identity_1=require("./identity");function pipe(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return pipeFromArray(e)}function pipeFromArray(e){return 0===e.length?identity_1.identity:1===e.length?e[0]:function(r){return e.reduce(function(e,r){return r(e)},r)}}exports.pipe=pipe,exports.pipeFromArray=pipeFromArray;
|
|
163
202
|
|
|
164
|
-
},{"./identity":
|
|
203
|
+
},{"./identity":62}],67:[function(require,module,exports){
|
|
165
204
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var Subscriber_1=require("../Subscriber"),rxSubscriber_1=require("../symbol/rxSubscriber"),Observer_1=require("../Observer");function toSubscriber(r,e,b){if(r){if(r instanceof Subscriber_1.Subscriber)return r;if(r[rxSubscriber_1.rxSubscriber])return r[rxSubscriber_1.rxSubscriber]()}return r||e||b?new Subscriber_1.Subscriber(r,e,b):new Subscriber_1.Subscriber(Observer_1.empty)}exports.toSubscriber=toSubscriber;
|
|
166
205
|
|
|
167
|
-
},{"../Observer":
|
|
206
|
+
},{"../Observer":51,"../Subscriber":52,"../symbol/rxSubscriber":58}],68:[function(require,module,exports){
|
|
168
207
|
"use strict";var url=require("url");module.exports=function(o,r,t){if(o===r)return!0;var p=url.parse(o,!1,!0),e=url.parse(r,!1,!0),s=0|p.port||("https"===p.protocol?443:80),u=0|e.port||("https"===e.protocol?443:80),l={proto:p.protocol===e.protocol,hostname:p.hostname===e.hostname,port:s===u};return l.proto&&l.hostname&&(l.port||t)};
|
|
169
208
|
|
|
170
|
-
},{"url":
|
|
209
|
+
},{"url":69}],69:[function(require,module,exports){
|
|
171
210
|
"use strict";var regex=/^(?:(?:(?:([^:\/#\?]+:)?(?:(?:\/\/)((?:((?:[^:@\/#\?]+)(?:\:(?:[^:@\/#\?]+))?)@)?(([^:\/#\?\]\[]+|\[[^\/\]@#?]+\])(?:\:([0-9]+))?))?)?)?((?:\/?(?:[^\/\?#]+\/+)*)(?:[^\?#]*)))?(\?[^#]+)?)(#.*)?/;module.exports={regex:regex,parse:function(e){var o=regex.exec(e);return o?{protocol:(o[1]||"").toLowerCase()||void 0,hostname:(o[5]||"").toLowerCase()||void 0,port:o[6]||void 0}:{}}};
|
|
172
211
|
|
|
173
|
-
},{}],
|
|
212
|
+
},{}],70:[function(require,module,exports){
|
|
174
213
|
(function (global){(function (){
|
|
175
|
-
"use strict";var required=require("requires-port"),qs=require("querystringify"),slashes=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//,protocolre=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i,windowsDriveLetter=/^[a-zA-Z]:/,whitespace="[\\x09\\x0A\\x0B\\x0C\\x0D\\x20\\xA0\\u1680\\u180E\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200A\\u202F\\u205F\\u3000\\u2028\\u2029\\uFEFF]",left=new RegExp("^"+whitespace+"+");function trimLeft(e){return(e||"").toString().replace(left,"")}var rules=[["#","hash"],["?","query"],function(e,t){return isSpecial(t.protocol)?e.replace(/\\/g,"/"):e},["/","pathname"],["@","auth",1],[NaN,"host",void 0,1,1],[/:(\d+)$/,"port",void 0,1],[NaN,"hostname",void 0,1,1]],ignore={hash:1,query:1};function lolcation(e){var t,o=("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{}).location||{},r={},s=typeof(e=e||o);if("blob:"===e.protocol)r=new Url(unescape(e.pathname),{});else if("string"===s)for(t in r=new Url(e,{}),ignore)delete r[t];else if("object"===s){for(t in e)t in ignore||(r[t]=e[t]);void 0===r.slashes&&(r.slashes=slashes.test(e.href))}return r}function isSpecial(e){return"file:"===e||"ftp:"===e||"http:"===e||"https:"===e||"ws:"===e||"wss:"===e}function extractProtocol(e,t){e=trimLeft(e),t=t||{};var o,r=protocolre.exec(e),s=r[1]?r[1].toLowerCase():"",a=!!r[2],l=!!r[3],
|
|
214
|
+
"use strict";var required=require("requires-port"),qs=require("querystringify"),slashes=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//,protocolre=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i,windowsDriveLetter=/^[a-zA-Z]:/,whitespace="[\\x09\\x0A\\x0B\\x0C\\x0D\\x20\\xA0\\u1680\\u180E\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200A\\u202F\\u205F\\u3000\\u2028\\u2029\\uFEFF]",left=new RegExp("^"+whitespace+"+");function trimLeft(e){return(e||"").toString().replace(left,"")}var rules=[["#","hash"],["?","query"],function(e,t){return isSpecial(t.protocol)?e.replace(/\\/g,"/"):e},["/","pathname"],["@","auth",1],[NaN,"host",void 0,1,1],[/:(\d+)$/,"port",void 0,1],[NaN,"hostname",void 0,1,1]],ignore={hash:1,query:1};function lolcation(e){var t,o=("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{}).location||{},r={},s=typeof(e=e||o);if("blob:"===e.protocol)r=new Url(unescape(e.pathname),{});else if("string"===s)for(t in r=new Url(e,{}),ignore)delete r[t];else if("object"===s){for(t in e)t in ignore||(r[t]=e[t]);void 0===r.slashes&&(r.slashes=slashes.test(e.href))}return r}function isSpecial(e){return"file:"===e||"ftp:"===e||"http:"===e||"https:"===e||"ws:"===e||"wss:"===e}function extractProtocol(e,t){e=trimLeft(e),t=t||{};var o,r=protocolre.exec(e),s=r[1]?r[1].toLowerCase():"",a=!!r[2],l=!!r[3],n=0;return a?l?(o=r[2]+r[3]+r[4],n=r[2].length+r[3].length):(o=r[2]+r[4],n=r[2].length):l?(o=r[3]+r[4],n=r[3].length):o=r[4],"file:"===s?n>=2&&(o=o.slice(2)):isSpecial(s)?o=r[4]:s?a&&(o=o.slice(2)):n>=2&&isSpecial(t.protocol)&&(o=r[4]),{protocol:s,slashes:a||isSpecial(s),slashesCount:n,rest:o}}function resolve(e,t){if(""===e)return t;for(var o=(t||"/").split("/").slice(0,-1).concat(e.split("/")),r=o.length,s=o[r-1],a=!1,l=0;r--;)"."===o[r]?o.splice(r,1):".."===o[r]?(o.splice(r,1),l++):l&&(0===r&&(a=!0),o.splice(r,1),l--);return a&&o.unshift(""),"."!==s&&".."!==s||o.push(""),o.join("/")}function Url(e,t,o){if(e=trimLeft(e),!(this instanceof Url))return new Url(e,t,o);var r,s,a,l,n,i,p=rules.slice(),c=typeof t,h=this,u=0;for("object"!==c&&"string"!==c&&(o=t,t=null),o&&"function"!=typeof o&&(o=qs.parse),r=!(s=extractProtocol(e||"",t=lolcation(t))).protocol&&!s.slashes,h.slashes=s.slashes||r&&t.slashes,h.protocol=s.protocol||t.protocol||"",e=s.rest,("file:"===s.protocol&&(2!==s.slashesCount||windowsDriveLetter.test(e))||!s.slashes&&(s.protocol||s.slashesCount<2||!isSpecial(h.protocol)))&&(p[3]=[/(.*)/,"pathname"]);u<p.length;u++)"function"!=typeof(l=p[u])?(a=l[0],i=l[1],a!=a?h[i]=e:"string"==typeof a?~(n=e.indexOf(a))&&("number"==typeof l[2]?(h[i]=e.slice(0,n),e=e.slice(n+l[2])):(h[i]=e.slice(n),e=e.slice(0,n))):(n=a.exec(e))&&(h[i]=n[1],e=e.slice(0,n.index)),h[i]=h[i]||r&&l[3]&&t[i]||"",l[4]&&(h[i]=h[i].toLowerCase())):e=l(e,h);o&&(h.query=o(h.query)),r&&t.slashes&&"/"!==h.pathname.charAt(0)&&(""!==h.pathname||""!==t.pathname)&&(h.pathname=resolve(h.pathname,t.pathname)),"/"!==h.pathname.charAt(0)&&isSpecial(h.protocol)&&(h.pathname="/"+h.pathname),required(h.port,h.protocol)||(h.host=h.hostname,h.port=""),h.username=h.password="",h.auth&&(l=h.auth.split(":"),h.username=l[0],h.password=l[1]||""),h.origin="file:"!==h.protocol&&isSpecial(h.protocol)&&h.host?h.protocol+"//"+h.host:"null",h.href=h.toString()}function set(e,t,o){var r=this;switch(e){case"query":"string"==typeof t&&t.length&&(t=(o||qs.parse)(t)),r[e]=t;break;case"port":r[e]=t,required(t,r.protocol)?t&&(r.host=r.hostname+":"+t):(r.host=r.hostname,r[e]="");break;case"hostname":r[e]=t,r.port&&(t+=":"+r.port),r.host=t;break;case"host":r[e]=t,/:\d+$/.test(t)?(t=t.split(":"),r.port=t.pop(),r.hostname=t.join(":")):(r.hostname=t,r.port="");break;case"protocol":r.protocol=t.toLowerCase(),r.slashes=!o;break;case"pathname":case"hash":if(t){var s="pathname"===e?"/":"#";r[e]=t.charAt(0)!==s?s+t:t}else r[e]=t;break;case"username":case"password":r[e]=encodeURIComponent(t);break;case"auth":var a=t.split(":");r.username=a[0],r.password=2===a.length?a[1]:""}for(var l=0;l<rules.length;l++){var n=rules[l];n[4]&&(r[n[1]]=r[n[1]].toLowerCase())}return r.auth=r.password?r.username+":"+r.password:r.username,r.origin="file:"!==r.protocol&&isSpecial(r.protocol)&&r.host?r.protocol+"//"+r.host:"null",r.href=r.toString(),r}function toString(e){e&&"function"==typeof e||(e=qs.stringify);var t,o=this,r=o.protocol;r&&":"!==r.charAt(r.length-1)&&(r+=":");var s=r+(o.protocol&&o.slashes||isSpecial(o.protocol)?"//":"");return o.username?(s+=o.username,o.password&&(s+=":"+o.password),s+="@"):o.password&&(s+=":"+o.password,s+="@"),s+=o.host+o.pathname,(t="object"==typeof o.query?e(o.query):o.query)&&(s+="?"!==t.charAt(0)?"?"+t:t),o.hash&&(s+=o.hash),s}Url.prototype={set:set,toString:toString},Url.extractProtocol=extractProtocol,Url.location=lolcation,Url.trimLeft=trimLeft,Url.qs=qs,module.exports=Url;
|
|
176
215
|
|
|
177
216
|
}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
178
|
-
},{"querystringify":
|
|
179
|
-
"use strict";function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray(e,t)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function _iterableToArrayLimit(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,a=[],o=!0,s=!1;try{for(r=r.call(e);!(o=(n=r.next()).done)&&(a.push(n.value),!t||a.length!==t);o=!0);}catch(e){s=!0,i=e}finally{try{o||null==r.return||r.return()}finally{if(s)throw i}}return a}}function _arrayWithHoles(e){if(Array.isArray(e))return e}var assign=require("object-assign"),_require=require("@sanity/observable/operators/map"),map=_require.map,_require2=require("@sanity/observable/operators/filter"),filter=_require2.filter,queryString=require("../http/queryString"),validators=require("../validators");function AssetsClient(e){this.client=e}function toDocument(e){var t=e.document;return Object.defineProperty(t,"document",{enumerable:!1,get:function(){return console.warn("The promise returned from client.asset.upload(...) now resolves with the asset document"),t}}),t}function optionsFromFile(e,t){return"undefined"!=typeof window&&t instanceof window.File?assign({filename:!1===e.preserveFilename?void 0:t.name,contentType:t.type},e):e}assign(AssetsClient.prototype,{upload:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};validators.validateAssetType(e);var n=r.extract||void 0;n&&!n.length&&(n=["none"]);var i=validators.hasDataset(this.client.clientConfig),a="image"===e?"images":"files",o=optionsFromFile(r,t),s=o.tag,l=o.label,c=o.title,u=o.description,d=o.creditLine,f=o.filename,y=o.source,p={label:l,title:c,description:u,filename:f,meta:n,creditLine:d};y&&(p.sourceId=y.id,p.sourceName=y.name,p.sourceUrl=y.url);var m=this.client._requestObservable({tag:s,method:"POST",timeout:o.timeout||0,uri:"/assets/".concat(a,"/").concat(i),headers:o.contentType?{"Content-Type":o.contentType}:{},query:p,body:t});return this.client.isPromiseAPI()?m.pipe(filter(function(e){return"response"===e.type}),map(function(e){return toDocument(e.body)})).toPromise():m},delete:function(e,t){console.warn("client.assets.delete() is deprecated, please use client.delete(<document-id>)");var r=t||"";return/^(image|file)-/.test(r)?e._id&&(r=e._id):r="".concat(e,"-").concat(r),validators.hasDataset(this.client.clientConfig),this.client.delete(r)},getImageUrl:function(e,t){var r=e._ref||e;if("string"!=typeof r)throw new Error("getImageUrl() needs either an object with a _ref, or a string with an asset document ID");if(!/^image-[A-Za-z0-9_]+-\d+x\d+-[a-z]{1,5}$/.test(r))throw new Error('Unsupported asset ID "'.concat(r,'". URL generation only works for auto-generated IDs.'));var n=_slicedToArray(r.split("-"),4),i=n[1],a=n[2],o=n[3];validators.hasDataset(this.client.clientConfig);var s=this.client.clientConfig,l=s.projectId,c=s.dataset,u=t?queryString(t):"";return"https://cdn.sanity.io/images/".concat(l,"/").concat(c,"/").concat(i,"-").concat(a,".").concat(o).concat(u)}}),module.exports=AssetsClient;
|
|
180
|
-
|
|
181
|
-
},{"../http/queryString":69,"../validators":79,"@sanity/observable/operators/filter":4,"@sanity/observable/operators/map":5,"object-assign":27}],59:[function(require,module,exports){
|
|
182
|
-
"use strict";var assign=require("object-assign");function AuthClient(t){this.client=t}assign(AuthClient.prototype,{getLoginProviders:function(){return this.client.request({uri:"/auth/providers"})},logout:function(){return this.client.request({uri:"/auth/logout",method:"POST"})}}),module.exports=AuthClient;
|
|
183
|
-
|
|
184
|
-
},{"object-assign":27}],60:[function(require,module,exports){
|
|
185
|
-
"use strict";var generateHelpUrl=require("@sanity/generate-help-url"),assign=require("object-assign"),validate=require("./validators"),warnings=require("./warnings"),defaultCdnHost="apicdn.sanity.io",defaultConfig={apiHost:"https://api.sanity.io",apiVersion:"1",useProjectHostname:!0,gradientMode:!1,isPromiseAPI:!0},LOCALHOSTS=["localhost","127.0.0.1","0.0.0.0"],isLocal=function(e){return-1!==LOCALHOSTS.indexOf(e)};exports.defaultConfig=defaultConfig,exports.initConfig=function(e,n){var i=assign({},n,e);i.apiVersion||warnings.printNoApiVersionSpecifiedWarning();var t=assign({},defaultConfig,i),a=t.gradientMode,o=!a&&t.useProjectHostname;if("undefined"==typeof Promise){var r=generateHelpUrl("js-client-promise-polyfill");throw new Error("No native Promise-implementation found, polyfill needed - see ".concat(r))}if(a&&!t.namespace)throw new Error("Configuration must contain `namespace` when running in gradient mode");if(o&&!t.projectId)throw new Error("Configuration must contain `projectId`");var s="undefined"!=typeof window&&window.location&&window.location.hostname,d=s&&isLocal(window.location.hostname);if(s&&d&&t.token&&!0!==t.ignoreBrowserTokenWarning?warnings.printBrowserTokenWarning():(!s||d)&&t.useCdn&&t.token?warnings.printCdnTokenWarning():void 0===t.useCdn&&warnings.printCdnWarning(),o&&validate.projectId(t.projectId),!a&&t.dataset&&validate.dataset(t.dataset,t.gradientMode),"requestTagPrefix"in t&&(t.requestTagPrefix=t.requestTagPrefix?validate.requestTag(t.requestTagPrefix).replace(/\.+$/,""):void 0),t.apiVersion="".concat(t.apiVersion).replace(/^v/,""),t.isDefaultApi=t.apiHost===defaultConfig.apiHost,t.useCdn=Boolean(t.useCdn)&&!t.token&&!t.withCredentials,exports.validateApiVersion(t.apiVersion),t.gradientMode)t.url=t.apiHost,t.cdnUrl=t.apiHost;else{var c=t.apiHost.split("://",2),p=c[0],l=c[1],u=t.isDefaultApi?defaultCdnHost:l;t.useProjectHostname?(t.url="".concat(p,"://").concat(t.projectId,".").concat(l,"/v").concat(t.apiVersion),t.cdnUrl="".concat(p,"://").concat(t.projectId,".").concat(u,"/v").concat(t.apiVersion)):(t.url="".concat(t.apiHost,"/v").concat(t.apiVersion),t.cdnUrl=t.url)}return t},exports.validateApiVersion=function(e){if("1"!==e&&"X"!==e){var n=new Date(e);if(!(/^\d{4}-\d{2}-\d{2}$/.test(e)&&n instanceof Date&&n.getTime()>0))throw new Error("Invalid API version string, expected `1` or date in format `YYYY-MM-DD`")}};
|
|
186
|
-
|
|
187
|
-
},{"./validators":79,"./warnings":80,"@sanity/generate-help-url":82,"object-assign":27}],61:[function(require,module,exports){
|
|
188
|
-
"use strict";function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var assign=require("object-assign"),_require=require("@sanity/observable/operators/filter"),filter=_require.filter,_require2=require("@sanity/observable/operators/map"),map=_require2.map,validators=require("../validators"),getSelection=require("../util/getSelection"),encodeQueryString=require("./encodeQueryString"),Transaction=require("./transaction"),Patch=require("./patch"),listen=require("./listen"),excludeFalsey=function(e,t){return!1===e?void 0:void 0===e?t:e},getMutationQuery=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{returnIds:!0,returnDocuments:excludeFalsey(e.returnDocuments,!0),visibility:e.visibility||"sync"}},isResponse=function(e){return"response"===e.type},getBody=function(e){return e.body},indexBy=function(e,t){return e.reduce(function(e,r){return e[t(r)]=r,e},Object.create(null))},toPromise=function(e){return e.toPromise()},getQuerySizeLimit=11264;module.exports={listen:listen,getDataUrl:function(e,t){var r=this.clientConfig,n=r.gradientMode?r.namespace:validators.hasDataset(r),i="/".concat(e,"/").concat(n),a=t?"".concat(i,"/").concat(t):i;return(this.clientConfig.gradientMode?a:"/data".concat(a)).replace(/\/($|\?)/,"$1")},fetch:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=!1===r.filterResponse?function(e){return e}:function(e){return e.result},i=this._dataRequest("query",{query:e,params:t},r).pipe(map(n));return this.isPromiseAPI()?toPromise(i):i},getDocument:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r={uri:this.getDataUrl("doc",e),json:!0,tag:t.tag},n=this._requestObservable(r).pipe(filter(isResponse),map(function(e){return e.body.documents&&e.body.documents[0]}));return this.isPromiseAPI()?toPromise(n):n},getDocuments:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r={uri:this.getDataUrl("doc",e.join(",")),json:!0,tag:t.tag},n=this._requestObservable(r).pipe(filter(isResponse),map(function(t){var r=indexBy(t.body.documents||[],function(e){return e._id});return e.map(function(e){return r[e]||null})}));return this.isPromiseAPI()?toPromise(n):n},create:function(e,t){return this._create(e,"create",t)},createIfNotExists:function(e,t){return validators.requireDocumentId("createIfNotExists",e),this._create(e,"createIfNotExists",t)},createOrReplace:function(e,t){return validators.requireDocumentId("createOrReplace",e),this._create(e,"createOrReplace",t)},patch:function(e,t){return new Patch(e,t,this)},delete:function(e,t){return this.dataRequest("mutate",{mutations:[{delete:getSelection(e)}]},t)},mutate:function(e,t){var r=e instanceof Patch||e instanceof Transaction?e.serialize():e,n=Array.isArray(r)?r:[r],i=t&&t.transactionId;return this.dataRequest("mutate",{mutations:n,transactionId:i},t)},transaction:function(e){return new Transaction(e,this)},dataRequest:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=this._dataRequest(e,t,r);return this.isPromiseAPI()?toPromise(n):n},_dataRequest:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n="mutate"===e,i="query"===e,a=!n&&encodeQueryString(t),u=!n&&a.length<getQuerySizeLimit,o=u?a:"",s=r.returnFirst,c=r.timeout,d=r.token,l=r.tag,f={method:u?"GET":"POST",uri:this.getDataUrl(e,o),json:!0,body:u?void 0:t,query:n&&getMutationQuery(r),timeout:c,token:d,tag:l,canUseCdn:i};return this._requestObservable(f).pipe(filter(isResponse),map(getBody),map(function(e){if(!n)return e;var t=e.results||[];if(r.returnDocuments)return s?t[0]&&t[0].document:t.map(function(e){return e.document});var i=s?"documentId":"documentIds",a=s?t[0]&&t[0].id:t.map(function(e){return e.id});return _defineProperty({transactionId:e.transactionId,results:t},i,a)}))},_create:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=_defineProperty({},t,e),i=assign({returnFirst:!0,returnDocuments:!0},r);return this.dataRequest("mutate",{mutations:[n]},i)}};
|
|
189
|
-
|
|
190
|
-
},{"../util/getSelection":76,"../validators":79,"./encodeQueryString":62,"./listen":63,"./patch":64,"./transaction":65,"@sanity/observable/operators/filter":4,"@sanity/observable/operators/map":5,"object-assign":27}],62:[function(require,module,exports){
|
|
191
|
-
"use strict";var _excluded=["tag"];function _objectWithoutProperties(e,t){if(null==e)return{};var c,o,n=_objectWithoutPropertiesLoose(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(o=0;o<r.length;o++)c=r[o],t.indexOf(c)>=0||Object.prototype.propertyIsEnumerable.call(e,c)&&(n[c]=e[c])}return n}function _objectWithoutPropertiesLoose(e,t){if(null==e)return{};var c,o,n={},r=Object.keys(e);for(o=0;o<r.length;o++)c=r[o],t.indexOf(c)>=0||(n[c]=e[c]);return n}var enc=encodeURIComponent;module.exports=function(e){var t=e.query,c=e.params,o=void 0===c?{}:c,n=e.options,r=void 0===n?{}:n,u=r.tag,a=_objectWithoutProperties(r,_excluded),i="query=".concat(enc(t)),s=u?"?tag=".concat(enc(u),"&").concat(i):"?".concat(i),l=Object.keys(o).reduce(function(e,t){return"".concat(e,"&").concat(enc("$".concat(t)),"=").concat(enc(JSON.stringify(o[t])))},s);return Object.keys(a).reduce(function(e,t){return r[t]?"".concat(e,"&").concat(enc(t),"=").concat(enc(r[t])):e},l)};
|
|
192
|
-
|
|
193
|
-
},{}],63:[function(require,module,exports){
|
|
194
|
-
"use strict";function ownKeys(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r&&(t=t.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),n.push.apply(n,t)}return n}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(n),!0).forEach(function(r){_defineProperty(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ownKeys(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function _defineProperty(e,r,n){return r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}var assign=require("object-assign"),Observable=require("@sanity/observable/minimal"),polyfilledEventSource=require("@sanity/eventsource"),generateHelpUrl=require("@sanity/generate-help-url"),pick=require("../util/pick"),once=require("../util/once"),defaults=require("../util/defaults"),encodeQueryString=require("./encodeQueryString"),MAX_URL_LENGTH=14800,tokenWarning=["Using token with listeners is not supported in browsers. ","For more info, see ".concat(generateHelpUrl("js-client-listener-tokens-browser"),".")],printTokenWarning=once(function(){return console.warn(tokenWarning.join(" "))}),isWindowEventSource=Boolean("undefined"!=typeof window&&window.EventSource),EventSource=isWindowEventSource?window.EventSource:polyfilledEventSource,possibleOptions=["includePreviousRevision","includeResult","visibility","effectFormat","tag"],defaultOptions={includeResult:!0};function parseEvent(e){try{var r=e.data&&JSON.parse(e.data)||{};return assign({type:e.type},r)}catch(e){return e}}function cooerceError(e){if(e instanceof Error)return e;var r=parseEvent(e);return r instanceof Error?r:new Error(extractErrorMessage(r))}function extractErrorMessage(e){return e.error?e.error.description?e.error.description:"string"==typeof e.error?e.error:JSON.stringify(e.error,null,2):e.message||"Unknown listener error"}module.exports=function(e,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},t=this.clientConfig,o=t.url,i=t.token,c=t.withCredentials,s=t.requestTagPrefix,a=n.tag&&s?[s,n.tag].join("."):n.tag,u=_objectSpread(_objectSpread({},defaults(n,defaultOptions)),{},{tag:a}),l=pick(u,possibleOptions),f=encodeQueryString({query:e,params:r,options:l,tag:a}),p="".concat(o).concat(this.getDataUrl("listen",f));if(p.length>MAX_URL_LENGTH)return new Observable(function(e){return e.error(new Error("Query too large for listener"))});var d=u.events?u.events:["mutation"],v=-1!==d.indexOf("reconnect");i&&isWindowEventSource&&printTokenWarning();var g={};return(i||c)&&(g.withCredentials=!0),i&&(g.headers={Authorization:"Bearer ".concat(i)}),new Observable(function(e){var r,n=u(),t=!1;function o(){t||(v&&e.next({type:"reconnect"}),t||n.readyState===EventSource.CLOSED&&(a(),clearTimeout(r),r=setTimeout(l,100)))}function i(r){e.error(cooerceError(r))}function c(r){var n=parseEvent(r);return n instanceof Error?e.error(n):e.next(n)}function s(r){t=!0,a(),e.complete()}function a(){n.removeEventListener("error",o,!1),n.removeEventListener("channelError",i,!1),n.removeEventListener("disconnect",s,!1),d.forEach(function(e){return n.removeEventListener(e,c,!1)}),n.close()}function u(){var e=new EventSource(p,g);return e.addEventListener("error",o,!1),e.addEventListener("channelError",i,!1),e.addEventListener("disconnect",s,!1),d.forEach(function(r){return e.addEventListener(r,c,!1)}),e}function l(){n=u()}return function(){t=!0,a()}})};
|
|
195
|
-
|
|
196
|
-
},{"../util/defaults":75,"../util/once":77,"../util/pick":78,"./encodeQueryString":62,"@sanity/eventsource":81,"@sanity/generate-help-url":82,"@sanity/observable/minimal":3,"object-assign":27}],64:[function(require,module,exports){
|
|
197
|
-
"use strict";function _defineProperty(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}var deepAssign=require("deep-assign"),assign=require("object-assign"),getSelection=require("../util/getSelection"),validate=require("../validators"),validateObject=validate.validateObject,validateInsert=validate.validateInsert;function Patch(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.selection=t,this.operations=assign({},e),this.client=i}assign(Patch.prototype,{clone:function(){return new Patch(this.selection,assign({},this.operations),this.client)},merge:function(t){validateObject("merge",t);var e=(new Error).stack.toString().split("\n").filter(function(t){return t.trim()}).slice(2);return console.warn('The "merge" patch has been deprecated and will be removed in the future\n'.concat(e.join("\n"))),this._assign("merge",deepAssign(this.operations.merge||{},t))},set:function(t){return this._assign("set",t)},diffMatchPatch:function(t){return validateObject("diffMatchPatch",t),this._assign("diffMatchPatch",t)},unset:function(t){if(!Array.isArray(t))throw new Error("unset(attrs) takes an array of attributes to unset, non-array given");return this.operations=assign({},this.operations,{unset:t}),this},setIfMissing:function(t){return this._assign("setIfMissing",t)},replace:function(t){return validateObject("replace",t),this._set("set",{$:t})},inc:function(t){return this._assign("inc",t)},dec:function(t){return this._assign("dec",t)},insert:function(t,e,i){var n;return validateInsert(t,e,i),this._assign("insert",(_defineProperty(n={},t,e),_defineProperty(n,"items",i),n))},append:function(t,e){return this.insert("after","".concat(t,"[-1]"),e)},prepend:function(t,e){return this.insert("before","".concat(t,"[0]"),e)},splice:function(t,e,i,n){var r=e<0?e-1:e,s=void 0===i||-1===i?-1:Math.max(0,e+i),a=r<0&&s>=0?"":s,o="".concat(t,"[").concat(r,":").concat(a,"]");return this.insert("replace",o,n||[])},ifRevisionId:function(t){return this.operations.ifRevisionID=t,this},serialize:function(){return assign(getSelection(this.selection),this.operations)},toJSON:function(){return this.serialize()},commit:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this.client)throw new Error("No `client` passed to patch, either provide one or pass the patch to a clients `mutate()` method");var e="string"==typeof this.selection,i=assign({returnFirst:e,returnDocuments:!0},t);return this.client.mutate({patch:this.serialize()},i)},reset:function(){return this.operations={},this},_set:function(t,e){return this._assign(t,e,!1)},_assign:function(t,e){var i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return validateObject(t,e),this.operations=assign({},this.operations,_defineProperty({},t,assign({},i&&this.operations[t]||{},e))),this}}),module.exports=Patch;
|
|
198
|
-
|
|
199
|
-
},{"../util/getSelection":76,"../validators":79,"deep-assign":7,"object-assign":27}],65:[function(require,module,exports){
|
|
200
|
-
"use strict";function _defineProperty(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}var assign=require("object-assign"),validators=require("../validators"),Patch=require("./patch"),defaultMutateOptions={returnDocuments:!1};function Transaction(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1?arguments[1]:void 0,i=arguments.length>2?arguments[2]:void 0;this.trxId=i,this.operations=t,this.client=e}assign(Transaction.prototype,{clone:function(){return new Transaction(this.operations.slice(0),this.client,this.trxId)},create:function(t){return validators.validateObject("create",t),this._add({create:t})},createIfNotExists:function(t){var e="createIfNotExists";return validators.validateObject(e,t),validators.requireDocumentId(e,t),this._add(_defineProperty({},e,t))},createOrReplace:function(t){var e="createOrReplace";return validators.validateObject(e,t),validators.requireDocumentId(e,t),this._add(_defineProperty({},e,t))},delete:function(t){return validators.validateDocumentId("delete",t),this._add({delete:{id:t}})},patch:function(t,e){var i="function"==typeof e;if(t instanceof Patch)return this._add({patch:t.serialize()});if(i){var r=e(new Patch(t,{},this.client));if(!(r instanceof Patch))throw new Error("function passed to `patch()` must return the patch");return this._add({patch:r.serialize()})}return this._add({patch:assign({id:t},e)})},transactionId:function(t){return t?(this.trxId=t,this):this.trxId},serialize:function(){return this.operations.slice()},toJSON:function(){return this.serialize()},commit:function(t){if(!this.client)throw new Error("No `client` passed to transaction, either provide one or pass the transaction to a clients `mutate()` method");return this.client.mutate(this.serialize(),assign({transactionId:this.trxId},defaultMutateOptions,t||{}))},reset:function(){return this.operations=[],this},_add:function(t){return this.operations.push(t),this}}),module.exports=Transaction;
|
|
201
|
-
|
|
202
|
-
},{"../validators":79,"./patch":64,"object-assign":27}],66:[function(require,module,exports){
|
|
203
|
-
"use strict";var assign=require("object-assign"),validate=require("../validators");function DatasetsClient(t){this.request=t.request.bind(t)}assign(DatasetsClient.prototype,{create:function(t,e){return this._modify("PUT",t,e)},edit:function(t,e){return this._modify("PATCH",t,e)},delete:function(t){return this._modify("DELETE",t)},list:function(){return this.request({uri:"/datasets"})},_modify:function(t,e,i){return validate.dataset(e),this.request({method:t,uri:"/datasets/".concat(e),body:i})}}),module.exports=DatasetsClient;
|
|
204
|
-
|
|
205
|
-
},{"../validators":79,"object-assign":27}],67:[function(require,module,exports){
|
|
206
|
-
"use strict";module.exports=[];
|
|
207
|
-
|
|
208
|
-
},{}],68:[function(require,module,exports){
|
|
209
|
-
"use strict";var makeError=require("make-error"),assign=require("object-assign");function ClientError(r){var e=extractErrorProps(r);ClientError.super.call(this,e.message),assign(this,e)}function ServerError(r){var e=extractErrorProps(r);ServerError.super.call(this,e.message),assign(this,e)}function extractErrorProps(r){var e=r.body,s={response:r,statusCode:r.statusCode,responseBody:stringifyBody(e,r)};return e.error&&e.message?(s.message="".concat(e.error," - ").concat(e.message),s):e.error&&e.error.description?(s.message=e.error.description,s.details=e.error,s):(s.message=e.error||e.message||httpErrorMessage(r),s)}function httpErrorMessage(r){var e=r.statusMessage?" ".concat(r.statusMessage):"";return"".concat(r.method,"-request to ").concat(r.url," resulted in HTTP ").concat(r.statusCode).concat(e)}function stringifyBody(r,e){return-1!==(e.headers["content-type"]||"").toLowerCase().indexOf("application/json")?JSON.stringify(r,null,2):r}makeError(ClientError),makeError(ServerError),exports.ClientError=ClientError,exports.ServerError=ServerError;
|
|
210
|
-
|
|
211
|
-
},{"make-error":26,"object-assign":27}],69:[function(require,module,exports){
|
|
212
|
-
"use strict";module.exports=function(n){var o=[];for(var e in n)n.hasOwnProperty(e)&&o.push("".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(n[e])));return o.length>0?"?".concat(o.join("&")):""};
|
|
213
|
-
|
|
214
|
-
},{}],70:[function(require,module,exports){
|
|
215
|
-
"use strict";var getIt=require("get-it"),assign=require("object-assign"),observable=require("get-it/lib/middleware/observable"),jsonRequest=require("get-it/lib/middleware/jsonRequest"),jsonResponse=require("get-it/lib/middleware/jsonResponse"),progress=require("get-it/lib/middleware/progress"),Observable=require("@sanity/observable/minimal"),_require=require("./errors"),ClientError=_require.ClientError,ServerError=_require.ServerError,httpError={onResponse:function(e){if(e.statusCode>=500)throw new ServerError(e);if(e.statusCode>=400)throw new ClientError(e);return e}},printWarnings={onResponse:function(e){var r=e.headers["x-sanity-warning"];return(Array.isArray(r)?r:[r]).filter(Boolean).forEach(function(e){return console.warn(e)}),e}},envSpecific=require("./nodeMiddleware"),middleware=envSpecific.concat([printWarnings,jsonRequest(),jsonResponse(),progress(),httpError,observable({implementation:Observable})]),request=getIt(middleware);function httpRequest(e){return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:request)(assign({maxRedirects:0},e))}httpRequest.defaultRequester=request,httpRequest.ClientError=ClientError,httpRequest.ServerError=ServerError,module.exports=httpRequest;
|
|
216
|
-
|
|
217
|
-
},{"./errors":68,"./nodeMiddleware":67,"@sanity/observable/minimal":3,"get-it":8,"get-it/lib/middleware/jsonRequest":12,"get-it/lib/middleware/jsonResponse":13,"get-it/lib/middleware/observable":14,"get-it/lib/middleware/progress":16,"object-assign":27}],71:[function(require,module,exports){
|
|
218
|
-
"use strict";var assign=require("object-assign"),projectHeader="X-Sanity-Project-ID";module.exports=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o={},r=t.token||e.token;r&&(o.Authorization="Bearer ".concat(r)),t.useGlobalApi||e.useProjectHostname||!e.projectId||(o[projectHeader]=e.projectId);var i=Boolean(void 0===t.withCredentials?e.token||e.withCredentials:t.withCredentials),a=void 0===t.timeout?e.timeout:t.timeout;return assign({},t,{headers:assign({},o,t.headers||{}),timeout:void 0===a?3e5:a,proxy:t.proxy||e.proxy,json:!0,withCredentials:i})};
|
|
219
|
-
|
|
220
|
-
},{"object-assign":27}],72:[function(require,module,exports){
|
|
221
|
-
"use strict";var assign=require("object-assign");function ProjectsClient(t){this.client=t}assign(ProjectsClient.prototype,{list:function(){return this.client.request({uri:"/projects"})},getById:function(t){return this.client.request({uri:"/projects/".concat(t)})}}),module.exports=ProjectsClient;
|
|
222
|
-
|
|
223
|
-
},{"object-assign":27}],73:[function(require,module,exports){
|
|
224
|
-
"use strict";function ownKeys(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),i.push.apply(i,r)}return i}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(i),!0).forEach(function(t){_defineProperty(e,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):ownKeys(Object(i)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}function _defineProperty(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}var assign=require("object-assign"),_require=require("@sanity/observable/operators/filter"),filter=_require.filter,_require2=require("@sanity/observable/operators/map"),map=_require2.map,Patch=require("./data/patch"),Transaction=require("./data/transaction"),dataMethods=require("./data/dataMethods"),DatasetsClient=require("./datasets/datasetsClient"),ProjectsClient=require("./projects/projectsClient"),AssetsClient=require("./assets/assetsClient"),UsersClient=require("./users/usersClient"),AuthClient=require("./auth/authClient"),httpRequest=require("./http/request"),getRequestOptions=require("./http/requestOptions"),_require3=require("./config"),defaultConfig=_require3.defaultConfig,initConfig=_require3.initConfig,validate=require("./validators"),toPromise=function(e){return e.toPromise()};function SanityClient(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:defaultConfig;if(!(this instanceof SanityClient))return new SanityClient(e);if(this.config(e),this.assets=new AssetsClient(this),this.datasets=new DatasetsClient(this),this.projects=new ProjectsClient(this),this.users=new UsersClient(this),this.auth=new AuthClient(this),this.clientConfig.isPromiseAPI){var t=assign({},this.clientConfig,{isPromiseAPI:!1});this.observable=new SanityClient(t)}}assign(SanityClient.prototype,dataMethods),assign(SanityClient.prototype,{clone:function(){return new SanityClient(this.config())},config:function(e){if(void 0===e)return assign({},this.clientConfig);if(this.observable){var t=assign({},e,{isPromiseAPI:!1});this.observable.config(t)}return this.clientConfig=initConfig(e,this.clientConfig||{}),this},withConfig:function(e){return this.clone().config(e)},getUrl:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1]?this.clientConfig.cdnUrl:this.clientConfig.url;return"".concat(t,"/").concat(e.replace(/^\//,""))},isPromiseAPI:function(){return this.clientConfig.isPromiseAPI},_requestObservable:function(e){var t=e.url||e.uri,i=void 0===e.canUseCdn?["GET","HEAD"].indexOf(e.method||"GET")>=0&&0===t.indexOf("/data/"):e.canUseCdn,r=this.clientConfig.useCdn&&i,n=e.tag&&this.clientConfig.requestTagPrefix?[this.clientConfig.requestTagPrefix,e.tag].join("."):e.tag||this.clientConfig.requestTagPrefix;n&&(e.query=_objectSpread({tag:validate.requestTag(n)},e.query));var s=getRequestOptions(this.clientConfig,assign({},e,{url:this.getUrl(t,r)}));return httpRequest(s,this.clientConfig.requester)},request:function(e){var t=this._requestObservable(e).pipe(filter(function(e){return"response"===e.type}),map(function(e){return e.body}));return this.isPromiseAPI()?toPromise(t):t}}),SanityClient.Patch=Patch,SanityClient.Transaction=Transaction,SanityClient.ClientError=httpRequest.ClientError,SanityClient.ServerError=httpRequest.ServerError,SanityClient.requester=httpRequest.defaultRequester,module.exports=SanityClient;
|
|
225
|
-
|
|
226
|
-
},{"./assets/assetsClient":58,"./auth/authClient":59,"./config":60,"./data/dataMethods":61,"./data/patch":64,"./data/transaction":65,"./datasets/datasetsClient":66,"./http/request":70,"./http/requestOptions":71,"./projects/projectsClient":72,"./users/usersClient":74,"./validators":79,"@sanity/observable/operators/filter":4,"@sanity/observable/operators/map":5,"object-assign":27}],74:[function(require,module,exports){
|
|
227
|
-
"use strict";var assign=require("object-assign");function UsersClient(e){this.client=e}assign(UsersClient.prototype,{getById:function(e){return this.client.request({uri:"/users/".concat(e)})}}),module.exports=UsersClient;
|
|
228
|
-
|
|
229
|
-
},{"object-assign":27}],75:[function(require,module,exports){
|
|
230
|
-
"use strict";module.exports=function(e,t){return Object.keys(t).concat(Object.keys(e)).reduce(function(c,n){return c[n]=void 0===e[n]?t[n]:e[n],c},{})};
|
|
231
|
-
|
|
232
|
-
},{}],76:[function(require,module,exports){
|
|
233
|
-
"use strict";module.exports=function(r){if("string"==typeof r||Array.isArray(r))return{id:r};if(r&&r.query)return"params"in r?{query:r.query,params:r.params}:{query:r.query};var n=["* Document ID (<docId>)","* Array of document IDs","* Object containing `query`"].join("\n");throw new Error("Unknown selection - must be one of:\n\n".concat(n))};
|
|
234
|
-
|
|
235
|
-
},{}],77:[function(require,module,exports){
|
|
236
|
-
"use strict";module.exports=function(r){var t,n=!1;return function(){return n?t:(t=r.apply(void 0,arguments),n=!0,t)}};
|
|
237
|
-
|
|
238
|
-
},{}],78:[function(require,module,exports){
|
|
239
|
-
"use strict";module.exports=function(e,r){return r.reduce(function(r,t){return void 0===e[t]?r:(r[t]=e[t],r)},{})};
|
|
240
|
-
|
|
241
|
-
},{}],79:[function(require,module,exports){
|
|
242
|
-
"use strict";function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var VALID_ASSET_TYPES=["image","file"],VALID_INSERT_LOCATIONS=["before","after","replace"];exports.dataset=function(t){if(!/^(~[a-z0-9]{1}[-\w]{0,63}|[a-z0-9]{1}[-\w]{0,63})$/.test(t))throw new Error("Datasets can only contain lowercase characters, numbers, underscores and dashes, and start with tilde, and be maximum 64 characters")},exports.projectId=function(t){if(!/^[-a-z0-9]+$/i.test(t))throw new Error("`projectId` can only contain only a-z, 0-9 and dashes")},exports.validateAssetType=function(t){if(-1===VALID_ASSET_TYPES.indexOf(t))throw new Error("Invalid asset type: ".concat(t,". Must be one of ").concat(VALID_ASSET_TYPES.join(", ")))},exports.validateObject=function(t,e){if(null===e||"object"!==_typeof(e)||Array.isArray(e))throw new Error("".concat(t,"() takes an object of properties"))},exports.requireDocumentId=function(t,e){if(!e._id)throw new Error("".concat(t,'() requires that the document contains an ID ("_id" property)'));exports.validateDocumentId(t,e._id)},exports.validateDocumentId=function(t,e){if("string"!=typeof e||!/^[a-z0-9_.-]+$/i.test(e))throw new Error("".concat(t,'(): "').concat(e,'" is not a valid document ID'))},exports.validateInsert=function(t,e,r){var o="insert(at, selector, items)";if(-1===VALID_INSERT_LOCATIONS.indexOf(t)){var n=VALID_INSERT_LOCATIONS.map(function(t){return'"'.concat(t,'"')}).join(", ");throw new Error("".concat(o,' takes an "at"-argument which is one of: ').concat(n))}if("string"!=typeof e)throw new Error("".concat(o,' takes a "selector"-argument which must be a string'));if(!Array.isArray(r))throw new Error("".concat(o,' takes an "items"-argument which must be an array'))},exports.hasDataset=function(t){if(!t.gradientMode&&!t.dataset)throw new Error("`dataset` must be provided to perform queries");return t.dataset||""},exports.requestTag=function(t){if("string"!=typeof t||!/^[a-z0-9._-]{1,75}$/i.test(t))throw new Error("Tag can only contain alphanumeric characters, underscores, dashes and dots, and be between one and 75 characters long.");return t};
|
|
243
|
-
|
|
244
|
-
},{}],80:[function(require,module,exports){
|
|
245
|
-
"use strict";var generateHelpUrl=require("@sanity/generate-help-url"),once=require("./util/once"),createWarningPrinter=function(e){return once(function(){for(var n,t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return(n=console).warn.apply(n,[e.join(" ")].concat(r))})};exports.printCdnWarning=createWarningPrinter(["You are not using the Sanity CDN. That means your data is always fresh, but the CDN is faster and","cheaper. Think about it! For more info, see ".concat(generateHelpUrl("js-client-cdn-configuration"),"."),"To hide this warning, please set the `useCdn` option to either `true` or `false` when creating","the client."]),exports.printBrowserTokenWarning=createWarningPrinter(["You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.","See ".concat(generateHelpUrl("js-client-browser-token")," for more information and how to hide this warning.")]),exports.printCdnTokenWarning=createWarningPrinter(["You have set `useCdn` to `true` while also specifying a token. This is usually not what you","want. The CDN cannot be used with an authorization token, since private data cannot be cached.","See ".concat(generateHelpUrl("js-client-usecdn-token")," for more information.")]),exports.printNoApiVersionSpecifiedWarning=createWarningPrinter(["Using the Sanity client without specifying an API version is deprecated.","See ".concat(generateHelpUrl("js-client-api-version"))]);
|
|
246
|
-
|
|
247
|
-
},{"./util/once":77,"@sanity/generate-help-url":82}],81:[function(require,module,exports){
|
|
248
|
-
var evs=require("@rexxars/eventsource-polyfill");module.exports="undefined"!=typeof window&&window.EventSource?window.EventSource:evs.EventSource;
|
|
249
|
-
|
|
250
|
-
},{"@rexxars/eventsource-polyfill":1}],82:[function(require,module,exports){
|
|
251
|
-
var baseUrl="https://docs.sanity.io/help/";module.exports=function(e){return baseUrl+e};
|
|
252
|
-
|
|
253
|
-
},{}]},{},[73])(73)
|
|
217
|
+
},{"querystringify":48,"requires-port":49}]},{},[16])(16)
|
|
254
218
|
});
|