storyblok-js-client
Advanced tools
Comparing version 4.3.0 to 4.3.1
@@ -6,2 +6,2 @@ /*! | ||
*/ | ||
var StoryblokClient=function(){"use strict";var e=function(e,t){return function(){for(var r=new Array(arguments.length),n=0;n<r.length;n++)r[n]=arguments[n];return e.apply(t,r)}},t=Object.prototype.toString;function r(e){return"[object Array]"===t.call(e)}function n(e){return void 0===e}function o(e){return null!==e&&"object"==typeof e}function s(e){if("[object Object]"!==t.call(e))return!1;var r=Object.getPrototypeOf(e);return null===r||r===Object.prototype}function i(e){return"[object Function]"===t.call(e)}function a(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),r(e))for(var n=0,o=e.length;n<o;n++)t.call(null,e[n],n,e);else for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.call(null,e[s],s,e)}var c={isArray:r,isArrayBuffer:function(e){return"[object ArrayBuffer]"===t.call(e)},isBuffer:function(e){return null!==e&&!n(e)&&null!==e.constructor&&!n(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){return"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:o,isPlainObject:s,isUndefined:n,isDate:function(e){return"[object Date]"===t.call(e)},isFile:function(e){return"[object File]"===t.call(e)},isBlob:function(e){return"[object Blob]"===t.call(e)},isFunction:i,isStream:function(e){return o(e)&&i(e.pipe)},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:a,merge:function e(){var t={};function n(n,o){s(t[o])&&s(n)?t[o]=e(t[o],n):s(n)?t[o]=e({},n):r(n)?t[o]=n.slice():t[o]=n}for(var o=0,i=arguments.length;o<i;o++)a(arguments[o],n);return t},extend:function(t,r,n){return a(r,(function(r,o){t[o]=n&&"function"==typeof r?e(r,n):r})),t},trim:function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")},stripBOM:function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e}};function u(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var l=function(e,t,r){if(!t)return e;var n;if(r)n=r(t);else if(c.isURLSearchParams(t))n=t.toString();else{var o=[];c.forEach(t,(function(e,t){null!=e&&(c.isArray(e)?t+="[]":e=[e],c.forEach(e,(function(e){c.isDate(e)?e=e.toISOString():c.isObject(e)&&(e=JSON.stringify(e)),o.push(u(t)+"="+u(e))})))})),n=o.join("&")}if(n){var s=e.indexOf("#");-1!==s&&(e=e.slice(0,s)),e+=(-1===e.indexOf("?")?"?":"&")+n}return e};function h(){this.handlers=[]}h.prototype.use=function(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1},h.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},h.prototype.forEach=function(e){c.forEach(this.handlers,(function(t){null!==t&&e(t)}))};var f=h,p=function(e,t){c.forEach(e,(function(r,n){n!==t&&n.toUpperCase()===t.toUpperCase()&&(e[t]=r,delete e[n])}))},d=function(e,t,r,n,o){return e.config=t,r&&(e.code=r),e.request=n,e.response=o,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e},m=function(e,t,r,n,o){var s=new Error(e);return d(s,t,r,n,o)},g=c.isStandardBrowserEnv()?{write:function(e,t,r,n,o,s){var i=[];i.push(e+"="+encodeURIComponent(t)),c.isNumber(r)&&i.push("expires="+new Date(r).toGMTString()),c.isString(n)&&i.push("path="+n),c.isString(o)&&i.push("domain="+o),!0===s&&i.push("secure"),document.cookie=i.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}},y=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"],v=c.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function n(e){var n=e;return t&&(r.setAttribute("href",n),n=r.href),r.setAttribute("href",n),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:"/"===r.pathname.charAt(0)?r.pathname:"/"+r.pathname}}return e=n(window.location.href),function(t){var r=c.isString(t)?n(t):t;return r.protocol===e.protocol&&r.host===e.host}}():function(){return!0},b=function(e){return new Promise((function(t,r){var n=e.data,o=e.headers,s=e.responseType;c.isFormData(n)&&delete o["Content-Type"];var i=new XMLHttpRequest;if(e.auth){var a=e.auth.username||"",u=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.Authorization="Basic "+btoa(a+":"+u)}var h,f,p=(h=e.baseURL,f=e.url,h&&!/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(f)?function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}(h,f):f);function d(){if(i){var n,o,a,u,l,h="getAllResponseHeaders"in i?(n=i.getAllResponseHeaders(),l={},n?(c.forEach(n.split("\n"),(function(e){if(u=e.indexOf(":"),o=c.trim(e.substr(0,u)).toLowerCase(),a=c.trim(e.substr(u+1)),o){if(l[o]&&y.indexOf(o)>=0)return;l[o]="set-cookie"===o?(l[o]?l[o]:[]).concat([a]):l[o]?l[o]+", "+a:a}})),l):l):null,f={data:s&&"text"!==s&&"json"!==s?i.response:i.responseText,status:i.status,statusText:i.statusText,headers:h,config:e,request:i};!function(e,t,r){var n=r.config.validateStatus;r.status&&n&&!n(r.status)?t(m("Request failed with status code "+r.status,r.config,null,r.request,r)):e(r)}(t,r,f),i=null}}if(i.open(e.method.toUpperCase(),l(p,e.params,e.paramsSerializer),!0),i.timeout=e.timeout,"onloadend"in i?i.onloadend=d:i.onreadystatechange=function(){i&&4===i.readyState&&(0!==i.status||i.responseURL&&0===i.responseURL.indexOf("file:"))&&setTimeout(d)},i.onabort=function(){i&&(r(m("Request aborted",e,"ECONNABORTED",i)),i=null)},i.onerror=function(){r(m("Network Error",e,null,i)),i=null},i.ontimeout=function(){var t="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),r(m(t,e,e.transitional&&e.transitional.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",i)),i=null},c.isStandardBrowserEnv()){var b=(e.withCredentials||v(p))&&e.xsrfCookieName?g.read(e.xsrfCookieName):void 0;b&&(o[e.xsrfHeaderName]=b)}"setRequestHeader"in i&&c.forEach(o,(function(e,t){void 0===n&&"content-type"===t.toLowerCase()?delete o[t]:i.setRequestHeader(t,e)})),c.isUndefined(e.withCredentials)||(i.withCredentials=!!e.withCredentials),s&&"json"!==s&&(i.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&i.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&i.upload&&i.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then((function(e){i&&(i.abort(),r(e),i=null)})),n||(n=null),i.send(n)}))},k={"Content-Type":"application/x-www-form-urlencoded"};function w(e,t){!c.isUndefined(e)&&c.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var x,E={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(x=b),x),transformRequest:[function(e,t){return p(t,"Accept"),p(t,"Content-Type"),c.isFormData(e)||c.isArrayBuffer(e)||c.isBuffer(e)||c.isStream(e)||c.isFile(e)||c.isBlob(e)?e:c.isArrayBufferView(e)?e.buffer:c.isURLSearchParams(e)?(w(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):c.isObject(e)||t&&"application/json"===t["Content-Type"]?(w(t,"application/json"),function(e,t,r){if(c.isString(e))try{return(t||JSON.parse)(e),c.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(r||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){var t=this.transitional,r=t&&t.silentJSONParsing,n=t&&t.forcedJSONParsing,o=!r&&"json"===this.responseType;if(o||n&&c.isString(e)&&e.length)try{return JSON.parse(e)}catch(e){if(o){if("SyntaxError"===e.name)throw d(e,this,"E_JSON_PARSE");throw e}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300}};E.headers={common:{Accept:"application/json, text/plain, */*"}},c.forEach(["delete","get","head"],(function(e){E.headers[e]={}})),c.forEach(["post","put","patch"],(function(e){E.headers[e]=c.merge(k)}));var j=E,T=function(e,t,r){var n=this||j;return c.forEach(r,(function(r){e=r.call(n,e,t)})),e},R=function(e){return!(!e||!e.__CANCEL__)};function O(e){e.cancelToken&&e.cancelToken.throwIfRequested()}var S=function(e){return O(e),e.headers=e.headers||{},e.data=T.call(e,e.data,e.headers,e.transformRequest),e.headers=c.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),c.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||j.adapter)(e).then((function(t){return O(e),t.data=T.call(e,t.data,t.headers,e.transformResponse),t}),(function(t){return R(t)||(O(e),t&&t.response&&(t.response.data=T.call(e,t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))},C=function(e,t){t=t||{};var r={},n=["url","method","data"],o=["headers","auth","proxy","params"],s=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],i=["validateStatus"];function a(e,t){return c.isPlainObject(e)&&c.isPlainObject(t)?c.merge(e,t):c.isPlainObject(t)?c.merge({},t):c.isArray(t)?t.slice():t}function u(n){c.isUndefined(t[n])?c.isUndefined(e[n])||(r[n]=a(void 0,e[n])):r[n]=a(e[n],t[n])}c.forEach(n,(function(e){c.isUndefined(t[e])||(r[e]=a(void 0,t[e]))})),c.forEach(o,u),c.forEach(s,(function(n){c.isUndefined(t[n])?c.isUndefined(e[n])||(r[n]=a(void 0,e[n])):r[n]=a(void 0,t[n])})),c.forEach(i,(function(n){n in t?r[n]=a(e[n],t[n]):n in e&&(r[n]=a(void 0,e[n]))}));var l=n.concat(o).concat(s).concat(i),h=Object.keys(e).concat(Object.keys(t)).filter((function(e){return-1===l.indexOf(e)}));return c.forEach(h,u),r},A={name:"axios",version:"0.21.4",description:"Promise based HTTP client for the browser and node.js",main:"index.js",scripts:{test:"grunt test",start:"node ./sandbox/server.js",build:"NODE_ENV=production grunt build",preversion:"npm test",version:"npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json",postversion:"git push && git push --tags",examples:"node ./examples/server.js",coveralls:"cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",fix:"eslint --fix lib/**/*.js"},repository:{type:"git",url:"https://github.com/axios/axios.git"},keywords:["xhr","http","ajax","promise","node"],author:"Matt Zabriskie",license:"MIT",bugs:{url:"https://github.com/axios/axios/issues"},homepage:"https://axios-http.com",devDependencies:{coveralls:"^3.0.0","es6-promise":"^4.2.4",grunt:"^1.3.0","grunt-banner":"^0.6.0","grunt-cli":"^1.2.0","grunt-contrib-clean":"^1.1.0","grunt-contrib-watch":"^1.0.0","grunt-eslint":"^23.0.0","grunt-karma":"^4.0.0","grunt-mocha-test":"^0.13.3","grunt-ts":"^6.0.0-beta.19","grunt-webpack":"^4.0.2","istanbul-instrumenter-loader":"^1.0.0","jasmine-core":"^2.4.1",karma:"^6.3.2","karma-chrome-launcher":"^3.1.0","karma-firefox-launcher":"^2.1.0","karma-jasmine":"^1.1.1","karma-jasmine-ajax":"^0.1.13","karma-safari-launcher":"^1.0.0","karma-sauce-launcher":"^4.3.6","karma-sinon":"^1.0.5","karma-sourcemap-loader":"^0.3.8","karma-webpack":"^4.0.2","load-grunt-tasks":"^3.5.2",minimist:"^1.2.0",mocha:"^8.2.1",sinon:"^4.5.0","terser-webpack-plugin":"^4.2.3",typescript:"^4.0.5","url-search-params":"^0.10.0",webpack:"^4.44.2","webpack-dev-server":"^3.11.0"},browser:{"./lib/adapters/http.js":"./lib/adapters/xhr.js"},jsdelivr:"dist/axios.min.js",unpkg:"dist/axios.min.js",typings:"./index.d.ts",dependencies:{"follow-redirects":"^1.14.0"},bundlesize:[{path:"./dist/axios.min.js",threshold:"5kB"}],_resolved:"https://registry.npmjs.org/axios/-/axios-0.21.4.tgz",_integrity:"sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==",_from:"axios@0.21.4"},N={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){N[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}}));var _={},P=A.version.split(".");function U(e,t){for(var r=t?t.split("."):P,n=e.split("."),o=0;o<3;o++){if(r[o]>n[o])return!0;if(r[o]<n[o])return!1}return!1}N.transitional=function(e,t,r){var n=t&&U(t);function o(e,t){return"[Axios v"+A.version+"] Transitional option '"+e+"'"+t+(r?". "+r:"")}return function(r,s,i){if(!1===e)throw new Error(o(s," has been removed in "+t));return n&&!_[s]&&(_[s]=!0,console.warn(o(s," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(r,s,i)}};var L={isOlderVersion:U,assertOptions:function(e,t,r){if("object"!=typeof e)throw new TypeError("options must be an object");for(var n=Object.keys(e),o=n.length;o-- >0;){var s=n[o],i=t[s];if(i){var a=e[s],c=void 0===a||i(a,s,e);if(!0!==c)throw new TypeError("option "+s+" must be "+c)}else if(!0!==r)throw Error("Unknown option "+s)}},validators:N},$=L.validators;function q(e){this.defaults=e,this.interceptors={request:new f,response:new f}}q.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=C(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=e.transitional;void 0!==t&&L.assertOptions(t,{silentJSONParsing:$.transitional($.boolean,"1.0.0"),forcedJSONParsing:$.transitional($.boolean,"1.0.0"),clarifyTimeoutError:$.transitional($.boolean,"1.0.0")},!1);var r=[],n=!0;this.interceptors.request.forEach((function(t){"function"==typeof t.runWhen&&!1===t.runWhen(e)||(n=n&&t.synchronous,r.unshift(t.fulfilled,t.rejected))}));var o,s=[];if(this.interceptors.response.forEach((function(e){s.push(e.fulfilled,e.rejected)})),!n){var i=[S,void 0];for(Array.prototype.unshift.apply(i,r),i=i.concat(s),o=Promise.resolve(e);i.length;)o=o.then(i.shift(),i.shift());return o}for(var a=e;r.length;){var c=r.shift(),u=r.shift();try{a=c(a)}catch(e){u(e);break}}try{o=S(a)}catch(e){return Promise.reject(e)}for(;s.length;)o=o.then(s.shift(),s.shift());return o},q.prototype.getUri=function(e){return e=C(this.defaults,e),l(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},c.forEach(["delete","get","head","options"],(function(e){q.prototype[e]=function(t,r){return this.request(C(r||{},{method:e,url:t,data:(r||{}).data}))}})),c.forEach(["post","put","patch"],(function(e){q.prototype[e]=function(t,r,n){return this.request(C(n||{},{method:e,url:t,data:r}))}}));var B=q;function M(e){this.message=e}M.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},M.prototype.__CANCEL__=!0;var D=M;function I(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var r=this;e((function(e){r.reason||(r.reason=new D(e),t(r.reason))}))}I.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},I.source=function(){var e;return{token:new I((function(t){e=t})),cancel:e}};var H=I;function z(t){var r=new B(t),n=e(B.prototype.request,r);return c.extend(n,B.prototype,r),c.extend(n,r),n}var J=z(j);J.Axios=B,J.create=function(e){return z(C(J.defaults,e))},J.Cancel=D,J.CancelToken=H,J.isCancel=R,J.all=function(e){return Promise.all(e)},J.spread=function(e){return function(t){return e.apply(null,t)}},J.isAxiosError=function(e){return"object"==typeof e&&!0===e.isAxiosError};var V=J,F=J;V.default=F;var X=V;function G(e){return"number"==typeof e&&(e==e&&e!==1/0&&e!==-1/0)}function W(e,t,r){if(!G(t))throw new TypeError("Expected `limit` to be a finite number");if(!G(r))throw new TypeError("Expected `interval` to be a finite number");var n=[],o=[],s=0,i=function(){s++;var t=setTimeout((function(){s--,n.length>0&&i(),o=o.filter((function(e){return e!==t}))}),r);o.indexOf(t)<0&&o.push(t);var a=n.shift();a.resolve(e.apply(a.self,a.args))},a=function(){var e=arguments,r=this;return new Promise((function(o,a){n.push({resolve:o,reject:a,args:e,self:r}),s<t&&i()}))};return a.abort=function(){o.forEach(clearTimeout),o=[],n.forEach((function(e){e.reject(new throttle.AbortError)})),n.length=0},a}W.AbortError=function(){Error.call(this,"Throttled function aborted"),this.name="AbortError"};const K=function(e,t){if(!e)return null;let r={};for(let n in e){let o=e[n];t.indexOf(n)>-1&&null!==o&&(r[n]=o)}return r};var Q={nodes:{horizontal_rule:e=>({singleTag:"hr"}),blockquote:e=>({tag:"blockquote"}),bullet_list:e=>({tag:"ul"}),code_block:e=>({tag:["pre",{tag:"code",attrs:e.attrs}]}),hard_break:e=>({singleTag:"br"}),heading:e=>({tag:`h${e.attrs.level}`}),image:e=>({singleTag:[{tag:"img",attrs:K(e.attrs,["src","alt","title"])}]}),list_item:e=>({tag:"li"}),ordered_list:e=>({tag:"ol"}),paragraph:e=>({tag:"p"})},marks:{bold:()=>({tag:"b"}),strike:()=>({tag:"strike"}),underline:()=>({tag:"u"}),strong:()=>({tag:"strong"}),code:()=>({tag:"code"}),italic:()=>({tag:"i"}),link(e){const t={...e.attrs},{linktype:r="url"}=e.attrs;return"email"===r&&(t.href=`mailto:${t.href}`),t.anchor&&(t.href=`${t.href}#${t.anchor}`,delete t.anchor),{tag:[{tag:"a",attrs:t}]}},styled:e=>({tag:[{tag:"span",attrs:e.attrs}]})}};class Z{constructor(e){e||(e=Q),this.marks=e.marks||[],this.nodes=e.nodes||[]}addNode(e,t){this.nodes[e]=t}addMark(e,t){this.marks[e]=t}render(e={}){if(e.content&&Array.isArray(e.content)){let t="";return e.content.forEach((e=>{t+=this.renderNode(e)})),t}return console.warn("The render method must receive an object with a content field, which is an array"),""}renderNode(e){let t=[];e.marks&&e.marks.forEach((e=>{const r=this.getMatchingMark(e);r&&t.push(this.renderOpeningTag(r.tag))}));const r=this.getMatchingNode(e);return r&&r.tag&&t.push(this.renderOpeningTag(r.tag)),e.content?e.content.forEach((e=>{t.push(this.renderNode(e))})):e.text?t.push(function(e){const t={"&":"&","<":"<",">":">",'"':""","'":"'"},r=/[&<>"']/g,n=RegExp(r.source);return e&&n.test(e)?e.replace(r,(e=>t[e])):e}(e.text)):r&&r.singleTag?t.push(this.renderTag(r.singleTag," /")):r&&r.html&&t.push(r.html),r&&r.tag&&t.push(this.renderClosingTag(r.tag)),e.marks&&e.marks.slice(0).reverse().forEach((e=>{const r=this.getMatchingMark(e);r&&t.push(this.renderClosingTag(r.tag))})),t.join("")}renderTag(e,t){if(e.constructor===String)return`<${e}${t}>`;return e.map((e=>{if(e.constructor===String)return`<${e}${t}>`;{let r=`<${e.tag}`;if(e.attrs)for(let t in e.attrs){let n=e.attrs[t];null!==n&&(r+=` ${t}="${n}"`)}return`${r}${t}>`}})).join("")}renderOpeningTag(e){return this.renderTag(e,"")}renderClosingTag(e){if(e.constructor===String)return`</${e}>`;return e.slice(0).reverse().map((e=>e.constructor===String?`</${e}>`:`</${e.tag}>`)).join("")}getMatchingNode(e){if("function"==typeof this.nodes[e.type])return this.nodes[e.type](e)}getMatchingMark(e){if("function"==typeof this.marks[e.type])return this.marks[e.type](e)}}const Y=(e=0,t=e)=>{const r=Math.abs(t-e)||0,n=e<t?1:-1;return((e=0,t)=>[...Array(e)].map(t))(r,((t,r)=>r*n+e))},ee=(e,t,r)=>{const n=[];for(const o in e){if(!Object.prototype.hasOwnProperty.call(e,o))continue;const s=e[o],i=r?"":encodeURIComponent(o);let a;a="object"==typeof s?ee(s,t?t+encodeURIComponent("["+i+"]"):i,Array.isArray(s)):(t?t+encodeURIComponent("["+i+"]"):i)+"="+encodeURIComponent(s),n.push(a)}return n.join("&")};let te={},re={};return class{constructor(e,t){if(!t){let r=e.region?`-${e.region}`:"",n=!1===e.https?"http":"https";t=void 0===e.oauthToken?`${n}://api${r}.storyblok.com/v2`:`${n}://api${r}.storyblok.com/v1`}let r=Object.assign({},e.headers),n=5;void 0!==e.oauthToken&&(r.Authorization=e.oauthToken,n=3),void 0!==e.rateLimit&&(n=e.rateLimit),this.richTextResolver=new Z(e.richTextSchema),"function"==typeof e.componentResolver&&this.setComponentResolver(e.componentResolver),this.maxRetries=e.maxRetries||5,this.throttle=W(this.throttledRequest,n,1e3),this.accessToken=e.accessToken,this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.client=X.create({baseURL:t,timeout:e.timeout||0,headers:r,proxy:e.proxy||!1}),e.responseInterceptor&&this.client.interceptors.response.use((t=>e.responseInterceptor(t)))}setComponentResolver(e){this.richTextResolver.addNode("blok",(t=>{let r="";return t.attrs.body.forEach((t=>{r+=e(t.component,t)})),{html:r}}))}parseParams(e={}){return e.version||(e.version="published"),e.token||(e.token=this.getToken()),e.cv||(e.cv=re[e.token]),Array.isArray(e.resolve_relations)&&(e.resolve_relations=e.resolve_relations.join(",")),e}factoryParamOptions(e,t={}){return((e="")=>e.indexOf("/cdn/")>-1)(e)?this.parseParams(t):t}makeRequest(e,t,r,n){const o=this.factoryParamOptions(e,((e={},t=25,r=1)=>({...e,per_page:t,page:r}))(t,r,n));return this.cacheResponse(e,o)}get(e,t){let r=`/${e}`;const n=this.factoryParamOptions(r,t);return this.cacheResponse(r,n)}async getAll(e,t={},r){const n=t.per_page||25,o=`/${e}`,s=o.split("/");r=r||s[s.length-1];const i=await this.makeRequest(o,t,n,1),a=Math.ceil(i.total/n);return((e=[],t)=>e.map(t).reduce(((e,t)=>[...e,...t]),[]))([i,...await(async(e=[],t)=>Promise.all(e.map(t)))(Y(1,a),(async e=>this.makeRequest(o,t,n,e+1)))],(e=>Object.values(e.data[r])))}post(e,t){let r=`/${e}`;return this.throttle("post",r,t)}put(e,t){let r=`/${e}`;return this.throttle("put",r,t)}delete(e,t){let r=`/${e}`;return this.throttle("delete",r,t)}getStories(e){return this.get("cdn/stories",e)}getStory(e,t){return this.get(`cdn/stories/${e}`,t)}setToken(e){this.accessToken=e}getToken(){return this.accessToken}_cleanCopy(e){return JSON.parse(JSON.stringify(e))}_insertLinks(e,t){const r=e[t];r&&"multilink"==r.fieldtype&&"story"==r.linktype&&"string"==typeof r.id&&this.links[r.id]?r.story=this._cleanCopy(this.links[r.id]):r&&"story"===r.linktype&&"string"==typeof r.uuid&&this.links[r.uuid]&&(r.story=this._cleanCopy(this.links[r.uuid]))}_insertRelations(e,t,r){if(r.indexOf(e.component+"."+t)>-1)if("string"==typeof e[t])this.relations[e[t]]&&(e[t]=this._cleanCopy(this.relations[e[t]]));else if(e[t].constructor===Array){let r=[];e[t].forEach((e=>{this.relations[e]&&r.push(this._cleanCopy(this.relations[e]))})),e[t]=r}}iterateTree(e,t){let r=e=>{if(null!=e)if(e.constructor===Array)for(let t=0;t<e.length;t++)r(e[t]);else if(e.constructor===Object){if(e._stopResolving)return;for(let n in e)(e.component&&e._uid||"link"===e.type)&&(this._insertRelations(e,n,t),this._insertLinks(e,n)),r(e[n])}};r(e.content)}async resolveLinks(e,t){let r=[];if(e.link_uuids){const n=e.link_uuids.length;let o=[];const s=50;for(let t=0;t<n;t+=s){const r=Math.min(n,t+s);o.push(e.link_uuids.slice(t,r))}for(let e=0;e<o.length;e++){(await this.getStories({per_page:s,language:t.language,version:t.version,by_uuids:o[e].join(",")})).data.stories.forEach((e=>{r.push(e)}))}}else r=e.links;r.forEach((e=>{this.links[e.uuid]={...e,_stopResolving:!0}}))}async resolveRelations(e,t){let r=[];if(e.rel_uuids){const n=e.rel_uuids.length;let o=[];const s=50;for(let t=0;t<n;t+=s){const r=Math.min(n,t+s);o.push(e.rel_uuids.slice(t,r))}for(let e=0;e<o.length;e++){(await this.getStories({per_page:s,language:t.language,version:t.version,by_uuids:o[e].join(",")})).data.stories.forEach((e=>{r.push(e)}))}}else r=e.rels;r.forEach((e=>{this.relations[e.uuid]={...e,_stopResolving:!0}}))}async resolveStories(e,t){let r=[];void 0!==t.resolve_relations&&t.resolve_relations.length>0&&(r=t.resolve_relations.split(","),await this.resolveRelations(e,t)),["1","story","url"].indexOf(t.resolve_links)>-1&&await this.resolveLinks(e,t);for(const e in this.relations)this.iterateTree(this.relations[e],r);e.story?this.iterateTree(e.story,r):e.stories.forEach((e=>{this.iterateTree(e,r)}))}cacheResponse(e,t,r){return void 0===r&&(r=0),new Promise((async(n,o)=>{let s=ee({url:e,params:t}),i=this.cacheProvider();if("auto"===this.cache.clear&&"draft"===t.version&&await this.flushCache(),"published"===t.version&&"/cdn/spaces/me"!=e){const e=await i.get(s);if(e)return n(e)}try{let r=await this.throttle("get",e,{params:t,paramsSerializer:e=>ee(e)}),a={data:r.data,headers:r.headers};if(r.headers["per-page"]&&(a=Object.assign({},a,{perPage:parseInt(r.headers["per-page"]),total:parseInt(r.headers.total)})),200!=r.status)return o(r);(a.data.story||a.data.stories)&&await this.resolveStories(a.data,t),"published"===t.version&&"/cdn/spaces/me"!=e&&i.set(s,a),a.data.cv&&("draft"==t.version&&re[t.token]!=a.data.cv&&this.flushCache(),re[t.token]=a.data.cv),n(a)}catch(s){if(s.response&&429===s.response.status&&(r+=1)<this.maxRetries)return console.log(`Hit rate limit. Retrying in ${r} seconds.`),await(a=1e3*r,new Promise((e=>setTimeout(e,a)))),this.cacheResponse(e,t,r).then(n).catch(o);o(s)}var a}))}throttledRequest(e,t,r){return this.client[e](t,r)}cacheVersions(){return re}cacheVersion(){return re[this.accessToken]}setCacheVersion(e){this.accessToken&&(re[this.accessToken]=e)}cacheProvider(){return"memory"===this.cache.type?{get:e=>te[e],getAll:()=>te,set(e,t){te[e]=t},flush(){te={}}}:{get(){},getAll(){},set(){},flush(){}}}async flushCache(){return await this.cacheProvider().flush(),this}}}(); | ||
var StoryblokClient=function(){"use strict";var e=function(e,t){return function(){for(var r=new Array(arguments.length),n=0;n<r.length;n++)r[n]=arguments[n];return e.apply(t,r)}},t=Object.prototype.toString;function r(e){return"[object Array]"===t.call(e)}function n(e){return void 0===e}function o(e){return null!==e&&"object"==typeof e}function s(e){if("[object Object]"!==t.call(e))return!1;var r=Object.getPrototypeOf(e);return null===r||r===Object.prototype}function i(e){return"[object Function]"===t.call(e)}function a(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),r(e))for(var n=0,o=e.length;n<o;n++)t.call(null,e[n],n,e);else for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.call(null,e[s],s,e)}var c={isArray:r,isArrayBuffer:function(e){return"[object ArrayBuffer]"===t.call(e)},isBuffer:function(e){return null!==e&&!n(e)&&null!==e.constructor&&!n(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){return"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:o,isPlainObject:s,isUndefined:n,isDate:function(e){return"[object Date]"===t.call(e)},isFile:function(e){return"[object File]"===t.call(e)},isBlob:function(e){return"[object Blob]"===t.call(e)},isFunction:i,isStream:function(e){return o(e)&&i(e.pipe)},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:a,merge:function e(){var t={};function n(n,o){s(t[o])&&s(n)?t[o]=e(t[o],n):s(n)?t[o]=e({},n):r(n)?t[o]=n.slice():t[o]=n}for(var o=0,i=arguments.length;o<i;o++)a(arguments[o],n);return t},extend:function(t,r,n){return a(r,(function(r,o){t[o]=n&&"function"==typeof r?e(r,n):r})),t},trim:function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")},stripBOM:function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e}};function u(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var l=function(e,t,r){if(!t)return e;var n;if(r)n=r(t);else if(c.isURLSearchParams(t))n=t.toString();else{var o=[];c.forEach(t,(function(e,t){null!=e&&(c.isArray(e)?t+="[]":e=[e],c.forEach(e,(function(e){c.isDate(e)?e=e.toISOString():c.isObject(e)&&(e=JSON.stringify(e)),o.push(u(t)+"="+u(e))})))})),n=o.join("&")}if(n){var s=e.indexOf("#");-1!==s&&(e=e.slice(0,s)),e+=(-1===e.indexOf("?")?"?":"&")+n}return e};function h(){this.handlers=[]}h.prototype.use=function(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1},h.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},h.prototype.forEach=function(e){c.forEach(this.handlers,(function(t){null!==t&&e(t)}))};var f=h,p=function(e,t){c.forEach(e,(function(r,n){n!==t&&n.toUpperCase()===t.toUpperCase()&&(e[t]=r,delete e[n])}))},d=function(e,t,r,n,o){return e.config=t,r&&(e.code=r),e.request=n,e.response=o,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e},m=function(e,t,r,n,o){var s=new Error(e);return d(s,t,r,n,o)},g=c.isStandardBrowserEnv()?{write:function(e,t,r,n,o,s){var i=[];i.push(e+"="+encodeURIComponent(t)),c.isNumber(r)&&i.push("expires="+new Date(r).toGMTString()),c.isString(n)&&i.push("path="+n),c.isString(o)&&i.push("domain="+o),!0===s&&i.push("secure"),document.cookie=i.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}},v=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"],y=c.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function n(e){var n=e;return t&&(r.setAttribute("href",n),n=r.href),r.setAttribute("href",n),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:"/"===r.pathname.charAt(0)?r.pathname:"/"+r.pathname}}return e=n(window.location.href),function(t){var r=c.isString(t)?n(t):t;return r.protocol===e.protocol&&r.host===e.host}}():function(){return!0},b=function(e){return new Promise((function(t,r){var n=e.data,o=e.headers,s=e.responseType;c.isFormData(n)&&delete o["Content-Type"];var i=new XMLHttpRequest;if(e.auth){var a=e.auth.username||"",u=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.Authorization="Basic "+btoa(a+":"+u)}var h,f,p=(h=e.baseURL,f=e.url,h&&!/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(f)?function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}(h,f):f);function d(){if(i){var n,o,a,u,l,h="getAllResponseHeaders"in i?(n=i.getAllResponseHeaders(),l={},n?(c.forEach(n.split("\n"),(function(e){if(u=e.indexOf(":"),o=c.trim(e.substr(0,u)).toLowerCase(),a=c.trim(e.substr(u+1)),o){if(l[o]&&v.indexOf(o)>=0)return;l[o]="set-cookie"===o?(l[o]?l[o]:[]).concat([a]):l[o]?l[o]+", "+a:a}})),l):l):null,f={data:s&&"text"!==s&&"json"!==s?i.response:i.responseText,status:i.status,statusText:i.statusText,headers:h,config:e,request:i};!function(e,t,r){var n=r.config.validateStatus;r.status&&n&&!n(r.status)?t(m("Request failed with status code "+r.status,r.config,null,r.request,r)):e(r)}(t,r,f),i=null}}if(i.open(e.method.toUpperCase(),l(p,e.params,e.paramsSerializer),!0),i.timeout=e.timeout,"onloadend"in i?i.onloadend=d:i.onreadystatechange=function(){i&&4===i.readyState&&(0!==i.status||i.responseURL&&0===i.responseURL.indexOf("file:"))&&setTimeout(d)},i.onabort=function(){i&&(r(m("Request aborted",e,"ECONNABORTED",i)),i=null)},i.onerror=function(){r(m("Network Error",e,null,i)),i=null},i.ontimeout=function(){var t="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),r(m(t,e,e.transitional&&e.transitional.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",i)),i=null},c.isStandardBrowserEnv()){var b=(e.withCredentials||y(p))&&e.xsrfCookieName?g.read(e.xsrfCookieName):void 0;b&&(o[e.xsrfHeaderName]=b)}"setRequestHeader"in i&&c.forEach(o,(function(e,t){void 0===n&&"content-type"===t.toLowerCase()?delete o[t]:i.setRequestHeader(t,e)})),c.isUndefined(e.withCredentials)||(i.withCredentials=!!e.withCredentials),s&&"json"!==s&&(i.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&i.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&i.upload&&i.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then((function(e){i&&(i.abort(),r(e),i=null)})),n||(n=null),i.send(n)}))},k={"Content-Type":"application/x-www-form-urlencoded"};function w(e,t){!c.isUndefined(e)&&c.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var x,E={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(x=b),x),transformRequest:[function(e,t){return p(t,"Accept"),p(t,"Content-Type"),c.isFormData(e)||c.isArrayBuffer(e)||c.isBuffer(e)||c.isStream(e)||c.isFile(e)||c.isBlob(e)?e:c.isArrayBufferView(e)?e.buffer:c.isURLSearchParams(e)?(w(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):c.isObject(e)||t&&"application/json"===t["Content-Type"]?(w(t,"application/json"),function(e,t,r){if(c.isString(e))try{return(t||JSON.parse)(e),c.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(r||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){var t=this.transitional,r=t&&t.silentJSONParsing,n=t&&t.forcedJSONParsing,o=!r&&"json"===this.responseType;if(o||n&&c.isString(e)&&e.length)try{return JSON.parse(e)}catch(e){if(o){if("SyntaxError"===e.name)throw d(e,this,"E_JSON_PARSE");throw e}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300}};E.headers={common:{Accept:"application/json, text/plain, */*"}},c.forEach(["delete","get","head"],(function(e){E.headers[e]={}})),c.forEach(["post","put","patch"],(function(e){E.headers[e]=c.merge(k)}));var j=E,T=function(e,t,r){var n=this||j;return c.forEach(r,(function(r){e=r.call(n,e,t)})),e},R=function(e){return!(!e||!e.__CANCEL__)};function O(e){e.cancelToken&&e.cancelToken.throwIfRequested()}var S=function(e){return O(e),e.headers=e.headers||{},e.data=T.call(e,e.data,e.headers,e.transformRequest),e.headers=c.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),c.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||j.adapter)(e).then((function(t){return O(e),t.data=T.call(e,t.data,t.headers,e.transformResponse),t}),(function(t){return R(t)||(O(e),t&&t.response&&(t.response.data=T.call(e,t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))},C=function(e,t){t=t||{};var r={},n=["url","method","data"],o=["headers","auth","proxy","params"],s=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],i=["validateStatus"];function a(e,t){return c.isPlainObject(e)&&c.isPlainObject(t)?c.merge(e,t):c.isPlainObject(t)?c.merge({},t):c.isArray(t)?t.slice():t}function u(n){c.isUndefined(t[n])?c.isUndefined(e[n])||(r[n]=a(void 0,e[n])):r[n]=a(e[n],t[n])}c.forEach(n,(function(e){c.isUndefined(t[e])||(r[e]=a(void 0,t[e]))})),c.forEach(o,u),c.forEach(s,(function(n){c.isUndefined(t[n])?c.isUndefined(e[n])||(r[n]=a(void 0,e[n])):r[n]=a(void 0,t[n])})),c.forEach(i,(function(n){n in t?r[n]=a(e[n],t[n]):n in e&&(r[n]=a(void 0,e[n]))}));var l=n.concat(o).concat(s).concat(i),h=Object.keys(e).concat(Object.keys(t)).filter((function(e){return-1===l.indexOf(e)}));return c.forEach(h,u),r},A={name:"axios",version:"0.21.4",description:"Promise based HTTP client for the browser and node.js",main:"index.js",scripts:{test:"grunt test",start:"node ./sandbox/server.js",build:"NODE_ENV=production grunt build",preversion:"npm test",version:"npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json",postversion:"git push && git push --tags",examples:"node ./examples/server.js",coveralls:"cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",fix:"eslint --fix lib/**/*.js"},repository:{type:"git",url:"https://github.com/axios/axios.git"},keywords:["xhr","http","ajax","promise","node"],author:"Matt Zabriskie",license:"MIT",bugs:{url:"https://github.com/axios/axios/issues"},homepage:"https://axios-http.com",devDependencies:{coveralls:"^3.0.0","es6-promise":"^4.2.4",grunt:"^1.3.0","grunt-banner":"^0.6.0","grunt-cli":"^1.2.0","grunt-contrib-clean":"^1.1.0","grunt-contrib-watch":"^1.0.0","grunt-eslint":"^23.0.0","grunt-karma":"^4.0.0","grunt-mocha-test":"^0.13.3","grunt-ts":"^6.0.0-beta.19","grunt-webpack":"^4.0.2","istanbul-instrumenter-loader":"^1.0.0","jasmine-core":"^2.4.1",karma:"^6.3.2","karma-chrome-launcher":"^3.1.0","karma-firefox-launcher":"^2.1.0","karma-jasmine":"^1.1.1","karma-jasmine-ajax":"^0.1.13","karma-safari-launcher":"^1.0.0","karma-sauce-launcher":"^4.3.6","karma-sinon":"^1.0.5","karma-sourcemap-loader":"^0.3.8","karma-webpack":"^4.0.2","load-grunt-tasks":"^3.5.2",minimist:"^1.2.0",mocha:"^8.2.1",sinon:"^4.5.0","terser-webpack-plugin":"^4.2.3",typescript:"^4.0.5","url-search-params":"^0.10.0",webpack:"^4.44.2","webpack-dev-server":"^3.11.0"},browser:{"./lib/adapters/http.js":"./lib/adapters/xhr.js"},jsdelivr:"dist/axios.min.js",unpkg:"dist/axios.min.js",typings:"./index.d.ts",dependencies:{"follow-redirects":"^1.14.0"},bundlesize:[{path:"./dist/axios.min.js",threshold:"5kB"}],_resolved:"https://registry.npmjs.org/axios/-/axios-0.21.4.tgz",_integrity:"sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==",_from:"axios@0.21.4"},N={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){N[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}}));var _={},P=A.version.split(".");function U(e,t){for(var r=t?t.split("."):P,n=e.split("."),o=0;o<3;o++){if(r[o]>n[o])return!0;if(r[o]<n[o])return!1}return!1}N.transitional=function(e,t,r){var n=t&&U(t);function o(e,t){return"[Axios v"+A.version+"] Transitional option '"+e+"'"+t+(r?". "+r:"")}return function(r,s,i){if(!1===e)throw new Error(o(s," has been removed in "+t));return n&&!_[s]&&(_[s]=!0,console.warn(o(s," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(r,s,i)}};var L={isOlderVersion:U,assertOptions:function(e,t,r){if("object"!=typeof e)throw new TypeError("options must be an object");for(var n=Object.keys(e),o=n.length;o-- >0;){var s=n[o],i=t[s];if(i){var a=e[s],c=void 0===a||i(a,s,e);if(!0!==c)throw new TypeError("option "+s+" must be "+c)}else if(!0!==r)throw Error("Unknown option "+s)}},validators:N},$=L.validators;function q(e){this.defaults=e,this.interceptors={request:new f,response:new f}}q.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=C(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=e.transitional;void 0!==t&&L.assertOptions(t,{silentJSONParsing:$.transitional($.boolean,"1.0.0"),forcedJSONParsing:$.transitional($.boolean,"1.0.0"),clarifyTimeoutError:$.transitional($.boolean,"1.0.0")},!1);var r=[],n=!0;this.interceptors.request.forEach((function(t){"function"==typeof t.runWhen&&!1===t.runWhen(e)||(n=n&&t.synchronous,r.unshift(t.fulfilled,t.rejected))}));var o,s=[];if(this.interceptors.response.forEach((function(e){s.push(e.fulfilled,e.rejected)})),!n){var i=[S,void 0];for(Array.prototype.unshift.apply(i,r),i=i.concat(s),o=Promise.resolve(e);i.length;)o=o.then(i.shift(),i.shift());return o}for(var a=e;r.length;){var c=r.shift(),u=r.shift();try{a=c(a)}catch(e){u(e);break}}try{o=S(a)}catch(e){return Promise.reject(e)}for(;s.length;)o=o.then(s.shift(),s.shift());return o},q.prototype.getUri=function(e){return e=C(this.defaults,e),l(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},c.forEach(["delete","get","head","options"],(function(e){q.prototype[e]=function(t,r){return this.request(C(r||{},{method:e,url:t,data:(r||{}).data}))}})),c.forEach(["post","put","patch"],(function(e){q.prototype[e]=function(t,r,n){return this.request(C(n||{},{method:e,url:t,data:r}))}}));var B=q;function M(e){this.message=e}M.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},M.prototype.__CANCEL__=!0;var D=M;function I(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var r=this;e((function(e){r.reason||(r.reason=new D(e),t(r.reason))}))}I.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},I.source=function(){var e;return{token:new I((function(t){e=t})),cancel:e}};var H=I;function z(t){var r=new B(t),n=e(B.prototype.request,r);return c.extend(n,B.prototype,r),c.extend(n,r),n}var J=z(j);J.Axios=B,J.create=function(e){return z(C(J.defaults,e))},J.Cancel=D,J.CancelToken=H,J.isCancel=R,J.all=function(e){return Promise.all(e)},J.spread=function(e){return function(t){return e.apply(null,t)}},J.isAxiosError=function(e){return"object"==typeof e&&!0===e.isAxiosError};var V=J,F=J;V.default=F;var X=V;function G(e){return"number"==typeof e&&(e==e&&e!==1/0&&e!==-1/0)}function W(e,t,r){if(!G(t))throw new TypeError("Expected `limit` to be a finite number");if(!G(r))throw new TypeError("Expected `interval` to be a finite number");var n=[],o=[],s=0,i=function(){s++;var t=setTimeout((function(){s--,n.length>0&&i(),o=o.filter((function(e){return e!==t}))}),r);o.indexOf(t)<0&&o.push(t);var a=n.shift();a.resolve(e.apply(a.self,a.args))},a=function(){var e=arguments,r=this;return new Promise((function(o,a){n.push({resolve:o,reject:a,args:e,self:r}),s<t&&i()}))};return a.abort=function(){o.forEach(clearTimeout),o=[],n.forEach((function(e){e.reject(new throttle.AbortError)})),n.length=0},a}W.AbortError=function(){Error.call(this,"Throttled function aborted"),this.name="AbortError"};const K=function(e,t){if(!e)return null;let r={};for(let n in e){let o=e[n];t.indexOf(n)>-1&&null!==o&&(r[n]=o)}return r};var Q={nodes:{horizontal_rule:e=>({singleTag:"hr"}),blockquote:e=>({tag:"blockquote"}),bullet_list:e=>({tag:"ul"}),code_block:e=>({tag:["pre",{tag:"code",attrs:e.attrs}]}),hard_break:e=>({singleTag:"br"}),heading:e=>({tag:`h${e.attrs.level}`}),image:e=>({singleTag:[{tag:"img",attrs:K(e.attrs,["src","alt","title"])}]}),list_item:e=>({tag:"li"}),ordered_list:e=>({tag:"ol"}),paragraph:e=>({tag:"p"})},marks:{bold:()=>({tag:"b"}),strike:()=>({tag:"strike"}),underline:()=>({tag:"u"}),strong:()=>({tag:"strong"}),code:()=>({tag:"code"}),italic:()=>({tag:"i"}),link(e){const t={...e.attrs},{linktype:r="url"}=e.attrs;return"email"===r&&(t.href=`mailto:${t.href}`),t.anchor&&(t.href=`${t.href}#${t.anchor}`,delete t.anchor),{tag:[{tag:"a",attrs:t}]}},styled:e=>({tag:[{tag:"span",attrs:e.attrs}]})}};class Z{constructor(e){e||(e=Q),this.marks=e.marks||[],this.nodes=e.nodes||[]}addNode(e,t){this.nodes[e]=t}addMark(e,t){this.marks[e]=t}render(e={}){if(e.content&&Array.isArray(e.content)){let t="";return e.content.forEach((e=>{t+=this.renderNode(e)})),t}return console.warn("The render method must receive an object with a content field, which is an array"),""}renderNode(e){let t=[];e.marks&&e.marks.forEach((e=>{const r=this.getMatchingMark(e);r&&t.push(this.renderOpeningTag(r.tag))}));const r=this.getMatchingNode(e);return r&&r.tag&&t.push(this.renderOpeningTag(r.tag)),e.content?e.content.forEach((e=>{t.push(this.renderNode(e))})):e.text?t.push(function(e){const t={"&":"&","<":"<",">":">",'"':""","'":"'"},r=/[&<>"']/g,n=RegExp(r.source);return e&&n.test(e)?e.replace(r,(e=>t[e])):e}(e.text)):r&&r.singleTag?t.push(this.renderTag(r.singleTag," /")):r&&r.html&&t.push(r.html),r&&r.tag&&t.push(this.renderClosingTag(r.tag)),e.marks&&e.marks.slice(0).reverse().forEach((e=>{const r=this.getMatchingMark(e);r&&t.push(this.renderClosingTag(r.tag))})),t.join("")}renderTag(e,t){if(e.constructor===String)return`<${e}${t}>`;return e.map((e=>{if(e.constructor===String)return`<${e}${t}>`;{let r=`<${e.tag}`;if(e.attrs)for(let t in e.attrs){let n=e.attrs[t];null!==n&&(r+=` ${t}="${n}"`)}return`${r}${t}>`}})).join("")}renderOpeningTag(e){return this.renderTag(e,"")}renderClosingTag(e){if(e.constructor===String)return`</${e}>`;return e.slice(0).reverse().map((e=>e.constructor===String?`</${e}>`:`</${e.tag}>`)).join("")}getMatchingNode(e){if("function"==typeof this.nodes[e.type])return this.nodes[e.type](e)}getMatchingMark(e){if("function"==typeof this.marks[e.type])return this.marks[e.type](e)}}const Y=(e=0,t=e)=>{const r=Math.abs(t-e)||0,n=e<t?1:-1;return((e=0,t)=>[...Array(e)].map(t))(r,((t,r)=>r*n+e))},ee=(e,t,r)=>{const n=[];for(const o in e){if(!Object.prototype.hasOwnProperty.call(e,o))continue;const s=e[o],i=r?"":encodeURIComponent(o);let a;a="object"==typeof s?ee(s,t?t+encodeURIComponent("["+i+"]"):i,Array.isArray(s)):(t?t+encodeURIComponent("["+i+"]"):i)+"="+encodeURIComponent(s),n.push(a)}return n.join("&")};let te={},re={};return class{constructor(e,t){if(!t){let r=e.region?`-${e.region}`:"",n=!1===e.https?"http":"https";t=void 0===e.oauthToken?`${n}://api${r}.storyblok.com/v2`:`${n}://api${r}.storyblok.com/v1`}let r=Object.assign({},e.headers),n=5;void 0!==e.oauthToken&&(r.Authorization=e.oauthToken,n=3),void 0!==e.rateLimit&&(n=e.rateLimit),this.richTextResolver=new Z(e.richTextSchema),"function"==typeof e.componentResolver&&this.setComponentResolver(e.componentResolver),this.maxRetries=e.maxRetries||5,this.throttle=W(this.throttledRequest,n,1e3),this.accessToken=e.accessToken,this.relations={},this.links={},this.cache=e.cache||{clear:"manual"},this.client=X.create({baseURL:t,timeout:e.timeout||0,headers:r,proxy:e.proxy||!1}),e.responseInterceptor&&this.client.interceptors.response.use((t=>e.responseInterceptor(t))),this.resolveNestedRelations=e.resolveNestedRelations||!0}setComponentResolver(e){this.richTextResolver.addNode("blok",(t=>{let r="";return t.attrs.body.forEach((t=>{r+=e(t.component,t)})),{html:r}}))}parseParams(e={}){return e.version||(e.version="published"),e.token||(e.token=this.getToken()),e.cv||(e.cv=re[e.token]),Array.isArray(e.resolve_relations)&&(e.resolve_relations=e.resolve_relations.join(",")),e}factoryParamOptions(e,t={}){return((e="")=>e.indexOf("/cdn/")>-1)(e)?this.parseParams(t):t}makeRequest(e,t,r,n){const o=this.factoryParamOptions(e,((e={},t=25,r=1)=>({...e,per_page:t,page:r}))(t,r,n));return this.cacheResponse(e,o)}get(e,t){let r=`/${e}`;const n=this.factoryParamOptions(r,t);return this.cacheResponse(r,n)}async getAll(e,t={},r){const n=t.per_page||25,o=`/${e}`,s=o.split("/");r=r||s[s.length-1];const i=await this.makeRequest(o,t,n,1),a=Math.ceil(i.total/n);return((e=[],t)=>e.map(t).reduce(((e,t)=>[...e,...t]),[]))([i,...await(async(e=[],t)=>Promise.all(e.map(t)))(Y(1,a),(async e=>this.makeRequest(o,t,n,e+1)))],(e=>Object.values(e.data[r])))}post(e,t){let r=`/${e}`;return this.throttle("post",r,t)}put(e,t){let r=`/${e}`;return this.throttle("put",r,t)}delete(e,t){let r=`/${e}`;return this.throttle("delete",r,t)}getStories(e){return this.get("cdn/stories",e)}getStory(e,t){return this.get(`cdn/stories/${e}`,t)}setToken(e){this.accessToken=e}getToken(){return this.accessToken}_cleanCopy(e){return JSON.parse(JSON.stringify(e))}_insertLinks(e,t){const r=e[t];r&&"multilink"==r.fieldtype&&"story"==r.linktype&&"string"==typeof r.id&&this.links[r.id]?r.story=this._cleanCopy(this.links[r.id]):r&&"story"===r.linktype&&"string"==typeof r.uuid&&this.links[r.uuid]&&(r.story=this._cleanCopy(this.links[r.uuid]))}_insertRelations(e,t,r){if(r.indexOf(e.component+"."+t)>-1)if("string"==typeof e[t])this.relations[e[t]]&&(e[t]=this._cleanCopy(this.relations[e[t]]));else if(e[t].constructor===Array){let r=[];e[t].forEach((e=>{this.relations[e]&&r.push(this._cleanCopy(this.relations[e]))})),e[t]=r}}iterateTree(e,t){let r=e=>{if(null!=e)if(e.constructor===Array)for(let t=0;t<e.length;t++)r(e[t]);else if(e.constructor===Object){if(e._stopResolving)return;for(let n in e)(e.component&&e._uid||"link"===e.type)&&(this._insertRelations(e,n,t),this._insertLinks(e,n)),r(e[n])}};r(e.content)}async resolveLinks(e,t){let r=[];if(e.link_uuids){const n=e.link_uuids.length;let o=[];const s=50;for(let t=0;t<n;t+=s){const r=Math.min(n,t+s);o.push(e.link_uuids.slice(t,r))}for(let e=0;e<o.length;e++){(await this.getStories({per_page:s,language:t.language,version:t.version,by_uuids:o[e].join(",")})).data.stories.forEach((e=>{r.push(e)}))}}else r=e.links;r.forEach((e=>{this.links[e.uuid]={...e,_stopResolving:!0}}))}async resolveRelations(e,t){let r=[];if(e.rel_uuids){const n=e.rel_uuids.length;let o=[];const s=50;for(let t=0;t<n;t+=s){const r=Math.min(n,t+s);o.push(e.rel_uuids.slice(t,r))}for(let e=0;e<o.length;e++){(await this.getStories({per_page:s,language:t.language,version:t.version,by_uuids:o[e].join(",")})).data.stories.forEach((e=>{r.push(e)}))}}else r=e.rels;r.forEach((e=>{this.relations[e.uuid]={...e,_stopResolving:!0}}))}async resolveStories(e,t){let r=[];if(void 0!==t.resolve_relations&&t.resolve_relations.length>0&&(r=t.resolve_relations.split(","),await this.resolveRelations(e,t)),["1","story","url"].indexOf(t.resolve_links)>-1&&await this.resolveLinks(e,t),this.resolveNestedRelations)for(const e in this.relations)this.iterateTree(this.relations[e],r);e.story?this.iterateTree(e.story,r):e.stories.forEach((e=>{this.iterateTree(e,r)}))}cacheResponse(e,t,r){return void 0===r&&(r=0),new Promise((async(n,o)=>{let s=ee({url:e,params:t}),i=this.cacheProvider();if("auto"===this.cache.clear&&"draft"===t.version&&await this.flushCache(),"published"===t.version&&"/cdn/spaces/me"!=e){const e=await i.get(s);if(e)return n(e)}try{let r=await this.throttle("get",e,{params:t,paramsSerializer:e=>ee(e)}),a={data:r.data,headers:r.headers};if(r.headers["per-page"]&&(a=Object.assign({},a,{perPage:parseInt(r.headers["per-page"]),total:parseInt(r.headers.total)})),200!=r.status)return o(r);(a.data.story||a.data.stories)&&await this.resolveStories(a.data,t),"published"===t.version&&"/cdn/spaces/me"!=e&&i.set(s,a),a.data.cv&&("draft"==t.version&&re[t.token]!=a.data.cv&&this.flushCache(),re[t.token]=a.data.cv),n(a)}catch(s){if(s.response&&429===s.response.status&&(r+=1)<this.maxRetries)return console.log(`Hit rate limit. Retrying in ${r} seconds.`),await(a=1e3*r,new Promise((e=>setTimeout(e,a)))),this.cacheResponse(e,t,r).then(n).catch(o);o(s)}var a}))}throttledRequest(e,t,r){return this.client[e](t,r)}cacheVersions(){return re}cacheVersion(){return re[this.accessToken]}setCacheVersion(e){this.accessToken&&(re[this.accessToken]=e)}cacheProvider(){return"memory"===this.cache.type?{get:e=>te[e],getAll:()=>te,set(e,t){te[e]=t},flush(){te={}}}:{get(){},getAll(){},set(){},flush(){}}}async flushCache(){return await this.cacheProvider().flush(),this}}}(); |
{ | ||
"name": "storyblok-js-client", | ||
"type": "module", | ||
"version": "4.3.0", | ||
"version": "4.3.1", | ||
"description": "Universal JavaScript SDK for Storyblok's API", | ||
"types": "./types/index.d.ts", | ||
"main": "./dist/index.js", | ||
"module": "./dist/index.mjs", | ||
"main": "./dist/index.cjs.js", | ||
"module": "./dist/index.es.js", | ||
"unpkg": "./dist/index.standalone.js", | ||
@@ -18,8 +17,2 @@ "jsdelivr": "./dist/index.standalone.js", | ||
], | ||
"exports": { | ||
".": { | ||
"import": "./dist/index.mjs", | ||
"require": "./dist/index.js" | ||
} | ||
}, | ||
"scripts": { | ||
@@ -68,5 +61,3 @@ "clean": "rimraf dist/", | ||
}, | ||
"dependencies": { | ||
"rollup-plugin-mjs-entry": "^0.1.1" | ||
}, | ||
"dependencies": {}, | ||
"release": { | ||
@@ -73,0 +64,0 @@ "branches": [ |
@@ -75,8 +75,8 @@ <div align="center"> | ||
// you should need to use the format when import | ||
// mjs - when you are in EsModules environment (like React, Vue apps, for example) | ||
// es - when you are in NodeJS environment | ||
// es - when you are in EsModules environment (like React, Vue apps, for example) | ||
// cjs - when you are in NodeJS environment | ||
// standalone - when you are in Browser environment directly | ||
import RichTextResolver from 'storyblok-js-client/dist/rich-text-resolver.mjs' | ||
// const RichTextResolver = require('storyblok-js-client/dist/rich-text-resolver.es') | ||
import RichTextResolver from 'storyblok-js-client/dist/rich-text-resolver.es' | ||
// const RichTextResolver = require('storyblok-js-client/dist/rich-text-resolver.cjs') | ||
@@ -116,6 +116,6 @@ const resolver = new RichTextResolver() | ||
// for CommonJS environments (NodeJS) | ||
const StoryblokClient = require('storyblok-js-client/dist/es5/index.js') | ||
const StoryblokClient = require('storyblok-js-client/dist/es5/index.cjs') | ||
// for EsModules environments | ||
import StoryblokClient from 'storyblok-js-client/dist/es5/index.mjs' | ||
import StoryblokClient from 'storyblok-js-client/dist/es5/index.es' | ||
``` | ||
@@ -122,0 +122,0 @@ |
@@ -61,2 +61,3 @@ 'use strict' | ||
} | ||
this.resolveNestedRelations = config.resolveNestedRelations || true | ||
} | ||
@@ -302,4 +303,6 @@ | ||
for (const relUuid in this.relations) { | ||
this.iterateTree(this.relations[relUuid], relationParams) | ||
if (this.resolveNestedRelations) { | ||
for (const relUuid in this.relations) { | ||
this.iterateTree(this.relations[relUuid], relationParams) | ||
} | ||
} | ||
@@ -306,0 +309,0 @@ |
Sorry, the diff of this file is too big to display
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
381632
1
2334
18
4
No
- Removedrollup-plugin-mjs-entry@^0.1.1
- Removedrollup-plugin-mjs-entry@0.1.1(transitive)