@microlink/mql 0.10.30 → 0.10.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/mql.js CHANGED
@@ -722,7 +722,7 @@
722
722
  stringify,
723
723
  got,
724
724
  flatten,
725
- VERSION: '0.10.30'
725
+ VERSION: '0.10.31'
726
726
  });
727
727
 
728
728
  return browser;
package/dist/mql.min.js CHANGED
@@ -1,3 +1,3 @@
1
1
  !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).mql=e()}(this,(function(){"use strict";"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function t(t){var e=t.default;if("function"==typeof e){var r=function(){return e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach((function(e){var o=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(r,e,o.get?o:{enumerable:!0,get:function(){return t[e]}})})),r}const e=globalThis.URL,r=/^https?:\/\//i;var o={};function s(t,e,r,o,n){var i,a=n?n+r:n;if(null==o)e&&(t[n]=o);else if("object"!=typeof o)t[n]=o;else if(Array.isArray(o))for(i=0;i<o.length;i++)s(t,e,r,o[i],a+i);else for(i in o)s(t,e,r,o[i],a+i)}function n(t){if(!t)return"";var e=decodeURIComponent(t);return"false"!==e&&("true"===e||(0*+e==0?+e:e))}o.flattie=function(t,e,r){var o={};return"object"==typeof t&&s(o,!!r,e||".",t,""),o};var i=t(Object.freeze({__proto__:null,encode:function(t,e){var r,o,s,n="";for(r in t)if(void 0!==(s=t[r]))if(Array.isArray(s))for(o=0;o<s.length;o++)n&&(n+="&"),n+=encodeURIComponent(r)+"="+encodeURIComponent(s[o]);else n&&(n+="&"),n+=encodeURIComponent(r)+"="+encodeURIComponent(s);return(e||"")+n},decode:function(t){for(var e,r,o={},s=t.split("&");e=s.shift();)void 0!==o[r=(e=e.split("=")).shift()]?o[r]=[].concat(o[r],n(e.shift())):o[r]=n(e.shift());return o}}));const a={FREE:"https://api.microlink.io",PRO:"https://pro.microlink.io"},u=t=>null!==t&&"object"==typeof t;var h=({VERSION:t,MicrolinkError:e,urlHttp:r,stringify:o,got:s,flatten:n})=>{const i=t=>{if(!u(t))return;const e=n(t);return Object.keys(e).reduce(((t,r)=>(t[`data.${r}`]=e[r].toString(),t)),{})},h=async(t,r={},o=0)=>{try{const e=await s(t,r);return"buffer"===r.responseType?{body:e.body,response:e}:{...e.body,response:e}}catch(s){const{response:i={}}=s,{statusCode:a,body:c,headers:p={},url:l=t}=i,f=null!=(n=c)&&null!=n.constructor&&"function"==typeof n.constructor.isBuffer&&n.constructor.isBuffer(n),d=u(c)&&!f?c:((t,e,r)=>{try{return JSON.parse(t)}catch(o){const s=t||e.message;return{status:"error",data:{url:s},more:"https://microlink.io/efatalclient",code:"EFATALCLIENT",message:s,url:r}}})(f?c.toString():c,s,l);if("EFATALCLIENT"===d.code&&o++<2)return h(t,r,o);throw new e({...d,message:d.message,url:l,statusCode:a,headers:p})}var n},c=(t,{data:e,apiKey:r,endpoint:s,retry:u,cache:h,...c}={},{responseType:p="json",headers:l,...f}={})=>{const d=!!r;return[`${s||a[d?"PRO":"FREE"]}?${o({url:t,...i(e),...n(c)})}`,{...f,responseType:p,cache:h,retry:u,headers:d?{...l,"x-api-key":r}:{...l}}]},p=t=>async(o,s,n)=>{((t="")=>{if(!r(t)){const r=`The \`url\` as \`${t}\` is not valid. Ensure it has protocol (http or https) and hostname.`;throw new e({status:"fail",data:{url:r},more:"https://microlink.io/docs/api/api-parameters/url",code:"EINVALURLCLIENT",message:r,url:t})}})(o);const[i,a]=c(o,s,{...t,...n});return h(i,a)},l=p();return l.MicrolinkError=e,l.getApiUrl=c,l.fetchFromApi=h,l.mapRules=i,l.version=t,l.stream=s.stream,l.buffer=p({responseType:"buffer"}),l},c={exports:{}};!function(t,e){!function(t){class e extends Error{constructor(t,e,r){const o=`${t.status||0===t.status?t.status:""} ${t.statusText||""}`.trim();super("Request failed with "+(o?`status code ${o}`:"an unknown error")),this.name="HTTPError",this.response=t,this.request=e,this.options=r}}class r extends Error{constructor(t){super("Request timed out"),this.name="TimeoutError",this.request=t}}const o=t=>null!==t&&"object"==typeof t,s=(...t)=>{for(const e of t)if((!o(e)||Array.isArray(e))&&void 0!==e)throw new TypeError("The `options` argument must be an object");return i({},...t)},n=(t={},e={})=>{const r=new globalThis.Headers(t),o=e instanceof globalThis.Headers,s=new globalThis.Headers(e);for(const[t,e]of s.entries())o&&"undefined"===e||void 0===e?r.delete(t):r.set(t,e);return r},i=(...t)=>{let e={},r={};for(const s of t)if(Array.isArray(s))Array.isArray(e)||(e=[]),e=[...e,...s];else if(o(s)){for(let[t,r]of Object.entries(s))o(r)&&t in e&&(r=i(e[t],r)),e={...e,[t]:r};o(s.headers)&&(r=n(r,s.headers),e.headers=r)}return e},a="function"==typeof globalThis.AbortController,u="function"==typeof globalThis.ReadableStream,h="function"==typeof globalThis.FormData,c=["get","post","put","patch","head","delete"],p={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},l=2147483647,f=Symbol("stop"),d=t=>c.includes(t)?t.toUpperCase():t,y=[413,429,503],m={limit:2,methods:["get","put","head","delete","options","trace"],statusCodes:[408,413,429,500,502,503,504],afterStatusCodes:y,maxRetryAfter:Number.POSITIVE_INFINITY},b=(t={})=>{if("number"==typeof t)return{...m,limit:t};if(t.methods&&!Array.isArray(t.methods))throw new Error("retry.methods must be an array");if(t.statusCodes&&!Array.isArray(t.statusCodes))throw new Error("retry.statusCodes must be an array");return{...m,...t,afterStatusCodes:y}},_=async(t,e,o)=>new Promise(((s,n)=>{const i=setTimeout((()=>{e&&e.abort(),n(new r(t))}),o.timeout);o.fetch(t).then(s).catch(n).then((()=>{clearTimeout(i)}))})),g=async t=>new Promise((e=>{setTimeout(e,t)}));class w{constructor(t,e={}){var r,o,s;if(this._retryCount=0,this._input=t,this._options={credentials:this._input.credentials||"same-origin",...e,headers:n(this._input.headers,e.headers),hooks:i({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},e.hooks),method:d(null!==(r=e.method)&&void 0!==r?r:this._input.method),prefixUrl:String(e.prefixUrl||""),retry:b(e.retry),throwHttpErrors:!1!==e.throwHttpErrors,timeout:void 0===e.timeout?1e4:e.timeout,fetch:null!==(o=e.fetch)&&void 0!==o?o:globalThis.fetch.bind(globalThis)},"string"!=typeof this._input&&!(this._input instanceof URL||this._input instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this._options.prefixUrl&&"string"==typeof this._input){if(this._input.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this._options.prefixUrl.endsWith("/")||(this._options.prefixUrl+="/"),this._input=this._options.prefixUrl+this._input}if(a&&(this.abortController=new globalThis.AbortController,this._options.signal&&this._options.signal.addEventListener("abort",(()=>{this.abortController.abort()})),this._options.signal=this.abortController.signal),this.request=new globalThis.Request(this._input,this._options),this._options.searchParams){const t="?"+("string"==typeof this._options.searchParams?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString()),e=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,t);!(h&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)||this._options.headers&&this._options.headers["content-type"]||this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(e,this.request),this._options)}void 0!==this._options.json&&(this._options.body=JSON.stringify(this._options.json),this.request.headers.set("content-type",null!==(s=this._options.headers.get("content-type"))&&void 0!==s?s:"application/json"),this.request=new globalThis.Request(this.request,{body:this._options.body}))}static create(t,r){const o=new w(t,r),s=async()=>{if(o._options.timeout>l)throw new RangeError(`The \`timeout\` option cannot be greater than ${l}`);await Promise.resolve();let t=await o._fetch();for(const e of o._options.hooks.afterResponse){const r=await e(o.request,o._options,o._decorateResponse(t.clone()));r instanceof globalThis.Response&&(t=r)}if(o._decorateResponse(t),!t.ok&&o._options.throwHttpErrors){let r=new e(t,o.request,o._options);for(const t of o._options.hooks.beforeError)r=await t(r);throw r}if(o._options.onDownloadProgress){if("function"!=typeof o._options.onDownloadProgress)throw new TypeError("The `onDownloadProgress` option must be a function");if(!u)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return o._stream(t.clone(),o._options.onDownloadProgress)}return t},n=o._options.retry.methods.includes(o.request.method.toLowerCase())?o._retry(s):s();for(const[t,e]of Object.entries(p))n[t]=async()=>{o.request.headers.set("accept",o.request.headers.get("accept")||e);const s=(await n).clone();if("json"===t){if(204===s.status)return"";if(r.parseJson)return r.parseJson(await s.text())}return s[t]()};return n}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount<this._options.retry.limit&&!(t instanceof r)){if(t instanceof e){if(!this._options.retry.statusCodes.includes(t.response.status))return 0;const e=t.response.headers.get("Retry-After");if(e&&this._options.retry.afterStatusCodes.includes(t.response.status)){let t=Number(e);return Number.isNaN(t)?t=Date.parse(e)-Date.now():t*=1e3,void 0!==this._options.retry.maxRetryAfter&&t>this._options.retry.maxRetryAfter?0:t}if(413===t.response.status)return 0}return.3*2**(this._retryCount-1)*1e3}return 0}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(e){const r=Math.min(this._calculateRetryDelay(e),l);if(0!==r&&this._retryCount>0){await g(r);for(const t of this._options.hooks.beforeRetry)if(await t({request:this.request,options:this._options,error:e,retryCount:this._retryCount})===f)return;return this._retry(t)}throw e}}async _fetch(){for(const t of this._options.hooks.beforeRequest){const e=await t(this.request,this._options);if(e instanceof Request){this.request=e;break}if(e instanceof Response)return e}return!1===this._options.timeout?this._options.fetch(this.request.clone()):_(this.request.clone(),this.abortController,this._options)}_stream(t,e){const r=Number(t.headers.get("content-length"))||0;let o=0;return new globalThis.Response(new globalThis.ReadableStream({async start(s){const n=t.body.getReader();async function i(){const{done:t,value:a}=await n.read();t?s.close():(e&&(o+=a.byteLength,e({percent:0===r?0:o/r,transferredBytes:o,totalBytes:r},a)),s.enqueue(a),await i())}e&&e({percent:0,transferredBytes:0,totalBytes:r},new Uint8Array),await i()}}))}}
2
- /*! MIT License © Sindre Sorhus */const T=t=>{const e=(e,r)=>w.create(e,s(t,r));for(const r of c)e[r]=(e,o)=>w.create(e,s(t,o,{method:r}));return e.create=t=>T(s(t)),e.extend=e=>T(s(t,e)),e.stop=f,e},R=T();t.HTTPError=e,t.TimeoutError=r,t.default=R,Object.defineProperty(t,"__esModule",{value:!0})}(e)}(0,c.exports);const p=t=>{try{const{href:o}=new e(t);return r.test(o)&&o}catch(t){return!1}},{flattie:l}=o,{encode:f}=i,d=h,{default:y}=c.exports;class m extends Error{constructor(t){super(),this.name="MicrolinkError",Object.assign(this,t),this.description=this.message,this.message=this.code?`${this.code}, ${this.description}`:this.description}}return d({MicrolinkError:m,urlHttp:p,stringify:f,got:async(t,e)=>{try{void 0===e.timeout&&(e.timeout=!1);const r=await y(t,e),o=await r.json(),{headers:s,status:n}=r;return{url:r.url,body:o,headers:s,statusCode:n}}catch(t){if(t.response){const{response:e}=t;t.response={...e,headers:Array.from(e.headers.entries()).reduce(((t,[e,r])=>(t[e]=r,t)),{}),statusCode:e.status,body:await e.text()}}throw t}},flatten:l,VERSION:"0.10.30"})}));
2
+ /*! MIT License © Sindre Sorhus */const T=t=>{const e=(e,r)=>w.create(e,s(t,r));for(const r of c)e[r]=(e,o)=>w.create(e,s(t,o,{method:r}));return e.create=t=>T(s(t)),e.extend=e=>T(s(t,e)),e.stop=f,e},R=T();t.HTTPError=e,t.TimeoutError=r,t.default=R,Object.defineProperty(t,"__esModule",{value:!0})}(e)}(0,c.exports);const p=t=>{try{const{href:o}=new e(t);return r.test(o)&&o}catch(t){return!1}},{flattie:l}=o,{encode:f}=i,d=h,{default:y}=c.exports;class m extends Error{constructor(t){super(),this.name="MicrolinkError",Object.assign(this,t),this.description=this.message,this.message=this.code?`${this.code}, ${this.description}`:this.description}}return d({MicrolinkError:m,urlHttp:p,stringify:f,got:async(t,e)=>{try{void 0===e.timeout&&(e.timeout=!1);const r=await y(t,e),o=await r.json(),{headers:s,status:n}=r;return{url:r.url,body:o,headers:s,statusCode:n}}catch(t){if(t.response){const{response:e}=t;t.response={...e,headers:Array.from(e.headers.entries()).reduce(((t,[e,r])=>(t[e]=r,t)),{}),statusCode:e.status,body:await e.text()}}throw t}},flatten:l,VERSION:"0.10.31"})}));
3
3
  //# sourceMappingURL=mql.min.js.map
package/dist/mql.min.mjs CHANGED
@@ -1,3 +1,3 @@
1
1
  "undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function t(t){var e=t.default;if("function"==typeof e){var r=function(){return e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach((function(e){var s=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(r,e,s.get?s:{enumerable:!0,get:function(){return t[e]}})})),r}const e=globalThis.URL,r=/^https?:\/\//i;var s={};function o(t,e,r,s,n){var i,a=n?n+r:n;if(null==s)e&&(t[n]=s);else if("object"!=typeof s)t[n]=s;else if(Array.isArray(s))for(i=0;i<s.length;i++)o(t,e,r,s[i],a+i);else for(i in s)o(t,e,r,s[i],a+i)}function n(t){if(!t)return"";var e=decodeURIComponent(t);return"false"!==e&&("true"===e||(0*+e==0?+e:e))}s.flattie=function(t,e,r){var s={};return"object"==typeof t&&o(s,!!r,e||".",t,""),s};var i=t(Object.freeze({__proto__:null,encode:function(t,e){var r,s,o,n="";for(r in t)if(void 0!==(o=t[r]))if(Array.isArray(o))for(s=0;s<o.length;s++)n&&(n+="&"),n+=encodeURIComponent(r)+"="+encodeURIComponent(o[s]);else n&&(n+="&"),n+=encodeURIComponent(r)+"="+encodeURIComponent(o);return(e||"")+n},decode:function(t){for(var e,r,s={},o=t.split("&");e=o.shift();)void 0!==s[r=(e=e.split("=")).shift()]?s[r]=[].concat(s[r],n(e.shift())):s[r]=n(e.shift());return s}}));const a={FREE:"https://api.microlink.io",PRO:"https://pro.microlink.io"},u=t=>null!==t&&"object"==typeof t;var h=({VERSION:t,MicrolinkError:e,urlHttp:r,stringify:s,got:o,flatten:n})=>{const i=t=>{if(!u(t))return;const e=n(t);return Object.keys(e).reduce(((t,r)=>(t[`data.${r}`]=e[r].toString(),t)),{})},h=async(t,r={},s=0)=>{try{const e=await o(t,r);return"buffer"===r.responseType?{body:e.body,response:e}:{...e.body,response:e}}catch(o){const{response:i={}}=o,{statusCode:a,body:c,headers:p={},url:l=t}=i,f=null!=(n=c)&&null!=n.constructor&&"function"==typeof n.constructor.isBuffer&&n.constructor.isBuffer(n),d=u(c)&&!f?c:((t,e,r)=>{try{return JSON.parse(t)}catch(s){const o=t||e.message;return{status:"error",data:{url:o},more:"https://microlink.io/efatalclient",code:"EFATALCLIENT",message:o,url:r}}})(f?c.toString():c,o,l);if("EFATALCLIENT"===d.code&&s++<2)return h(t,r,s);throw new e({...d,message:d.message,url:l,statusCode:a,headers:p})}var n},c=(t,{data:e,apiKey:r,endpoint:o,retry:u,cache:h,...c}={},{responseType:p="json",headers:l,...f}={})=>{const d=!!r;return[`${o||a[d?"PRO":"FREE"]}?${s({url:t,...i(e),...n(c)})}`,{...f,responseType:p,cache:h,retry:u,headers:d?{...l,"x-api-key":r}:{...l}}]},p=t=>async(s,o,n)=>{((t="")=>{if(!r(t)){const r=`The \`url\` as \`${t}\` is not valid. Ensure it has protocol (http or https) and hostname.`;throw new e({status:"fail",data:{url:r},more:"https://microlink.io/docs/api/api-parameters/url",code:"EINVALURLCLIENT",message:r,url:t})}})(s);const[i,a]=c(s,o,{...t,...n});return h(i,a)},l=p();return l.MicrolinkError=e,l.getApiUrl=c,l.fetchFromApi=h,l.mapRules=i,l.version=t,l.stream=o.stream,l.buffer=p({responseType:"buffer"}),l},c={exports:{}};!function(t){class e extends Error{constructor(t,e,r){const s=`${t.status||0===t.status?t.status:""} ${t.statusText||""}`.trim();super("Request failed with "+(s?`status code ${s}`:"an unknown error")),this.name="HTTPError",this.response=t,this.request=e,this.options=r}}class r extends Error{constructor(t){super("Request timed out"),this.name="TimeoutError",this.request=t}}const s=t=>null!==t&&"object"==typeof t,o=(...t)=>{for(const e of t)if((!s(e)||Array.isArray(e))&&void 0!==e)throw new TypeError("The `options` argument must be an object");return i({},...t)},n=(t={},e={})=>{const r=new globalThis.Headers(t),s=e instanceof globalThis.Headers,o=new globalThis.Headers(e);for(const[t,e]of o.entries())s&&"undefined"===e||void 0===e?r.delete(t):r.set(t,e);return r},i=(...t)=>{let e={},r={};for(const o of t)if(Array.isArray(o))Array.isArray(e)||(e=[]),e=[...e,...o];else if(s(o)){for(let[t,r]of Object.entries(o))s(r)&&t in e&&(r=i(e[t],r)),e={...e,[t]:r};s(o.headers)&&(r=n(r,o.headers),e.headers=r)}return e},a="function"==typeof globalThis.AbortController,u="function"==typeof globalThis.ReadableStream,h="function"==typeof globalThis.FormData,c=["get","post","put","patch","head","delete"],p={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},l=2147483647,f=Symbol("stop"),d=t=>c.includes(t)?t.toUpperCase():t,y=[413,429,503],m={limit:2,methods:["get","put","head","delete","options","trace"],statusCodes:[408,413,429,500,502,503,504],afterStatusCodes:y,maxRetryAfter:Number.POSITIVE_INFINITY},b=(t={})=>{if("number"==typeof t)return{...m,limit:t};if(t.methods&&!Array.isArray(t.methods))throw new Error("retry.methods must be an array");if(t.statusCodes&&!Array.isArray(t.statusCodes))throw new Error("retry.statusCodes must be an array");return{...m,...t,afterStatusCodes:y}},_=async(t,e,s)=>new Promise(((o,n)=>{const i=setTimeout((()=>{e&&e.abort(),n(new r(t))}),s.timeout);s.fetch(t).then(o).catch(n).then((()=>{clearTimeout(i)}))})),w=async t=>new Promise((e=>{setTimeout(e,t)}));class g{constructor(t,e={}){var r,s,o;if(this._retryCount=0,this._input=t,this._options={credentials:this._input.credentials||"same-origin",...e,headers:n(this._input.headers,e.headers),hooks:i({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},e.hooks),method:d(null!==(r=e.method)&&void 0!==r?r:this._input.method),prefixUrl:String(e.prefixUrl||""),retry:b(e.retry),throwHttpErrors:!1!==e.throwHttpErrors,timeout:void 0===e.timeout?1e4:e.timeout,fetch:null!==(s=e.fetch)&&void 0!==s?s:globalThis.fetch.bind(globalThis)},"string"!=typeof this._input&&!(this._input instanceof URL||this._input instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this._options.prefixUrl&&"string"==typeof this._input){if(this._input.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this._options.prefixUrl.endsWith("/")||(this._options.prefixUrl+="/"),this._input=this._options.prefixUrl+this._input}if(a&&(this.abortController=new globalThis.AbortController,this._options.signal&&this._options.signal.addEventListener("abort",(()=>{this.abortController.abort()})),this._options.signal=this.abortController.signal),this.request=new globalThis.Request(this._input,this._options),this._options.searchParams){const t="?"+("string"==typeof this._options.searchParams?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString()),e=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,t);!(h&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)||this._options.headers&&this._options.headers["content-type"]||this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(e,this.request),this._options)}void 0!==this._options.json&&(this._options.body=JSON.stringify(this._options.json),this.request.headers.set("content-type",null!==(o=this._options.headers.get("content-type"))&&void 0!==o?o:"application/json"),this.request=new globalThis.Request(this.request,{body:this._options.body}))}static create(t,r){const s=new g(t,r),o=async()=>{if(s._options.timeout>l)throw new RangeError(`The \`timeout\` option cannot be greater than ${l}`);await Promise.resolve();let t=await s._fetch();for(const e of s._options.hooks.afterResponse){const r=await e(s.request,s._options,s._decorateResponse(t.clone()));r instanceof globalThis.Response&&(t=r)}if(s._decorateResponse(t),!t.ok&&s._options.throwHttpErrors){let r=new e(t,s.request,s._options);for(const t of s._options.hooks.beforeError)r=await t(r);throw r}if(s._options.onDownloadProgress){if("function"!=typeof s._options.onDownloadProgress)throw new TypeError("The `onDownloadProgress` option must be a function");if(!u)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return s._stream(t.clone(),s._options.onDownloadProgress)}return t},n=s._options.retry.methods.includes(s.request.method.toLowerCase())?s._retry(o):o();for(const[t,e]of Object.entries(p))n[t]=async()=>{s.request.headers.set("accept",s.request.headers.get("accept")||e);const o=(await n).clone();if("json"===t){if(204===o.status)return"";if(r.parseJson)return r.parseJson(await o.text())}return o[t]()};return n}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount<this._options.retry.limit&&!(t instanceof r)){if(t instanceof e){if(!this._options.retry.statusCodes.includes(t.response.status))return 0;const e=t.response.headers.get("Retry-After");if(e&&this._options.retry.afterStatusCodes.includes(t.response.status)){let t=Number(e);return Number.isNaN(t)?t=Date.parse(e)-Date.now():t*=1e3,void 0!==this._options.retry.maxRetryAfter&&t>this._options.retry.maxRetryAfter?0:t}if(413===t.response.status)return 0}return.3*2**(this._retryCount-1)*1e3}return 0}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(e){const r=Math.min(this._calculateRetryDelay(e),l);if(0!==r&&this._retryCount>0){await w(r);for(const t of this._options.hooks.beforeRetry)if(await t({request:this.request,options:this._options,error:e,retryCount:this._retryCount})===f)return;return this._retry(t)}throw e}}async _fetch(){for(const t of this._options.hooks.beforeRequest){const e=await t(this.request,this._options);if(e instanceof Request){this.request=e;break}if(e instanceof Response)return e}return!1===this._options.timeout?this._options.fetch(this.request.clone()):_(this.request.clone(),this.abortController,this._options)}_stream(t,e){const r=Number(t.headers.get("content-length"))||0;let s=0;return new globalThis.Response(new globalThis.ReadableStream({async start(o){const n=t.body.getReader();async function i(){const{done:t,value:a}=await n.read();t?o.close():(e&&(s+=a.byteLength,e({percent:0===r?0:s/r,transferredBytes:s,totalBytes:r},a)),o.enqueue(a),await i())}e&&e({percent:0,transferredBytes:0,totalBytes:r},new Uint8Array),await i()}}))}}
2
- /*! MIT License © Sindre Sorhus */const R=t=>{const e=(e,r)=>g.create(e,o(t,r));for(const r of c)e[r]=(e,s)=>g.create(e,o(t,s,{method:r}));return e.create=t=>R(o(t)),e.extend=e=>R(o(t,e)),e.stop=f,e},T=R();t.HTTPError=e,t.TimeoutError=r,t.default=T,Object.defineProperty(t,"__esModule",{value:!0})}(c.exports);const p=t=>{try{const{href:s}=new e(t);return r.test(s)&&s}catch(t){return!1}},{flattie:l}=s,{encode:f}=i,d=h,{default:y}=c.exports;class m extends Error{constructor(t){super(),this.name="MicrolinkError",Object.assign(this,t),this.description=this.message,this.message=this.code?`${this.code}, ${this.description}`:this.description}}var b=d({MicrolinkError:m,urlHttp:p,stringify:f,got:async(t,e)=>{try{void 0===e.timeout&&(e.timeout=!1);const r=await y(t,e),s=await r.json(),{headers:o,status:n}=r;return{url:r.url,body:s,headers:o,statusCode:n}}catch(t){if(t.response){const{response:e}=t;t.response={...e,headers:Array.from(e.headers.entries()).reduce(((t,[e,r])=>(t[e]=r,t)),{}),statusCode:e.status,body:await e.text()}}throw t}},flatten:l,VERSION:"0.10.30"});export{b as default};
2
+ /*! MIT License © Sindre Sorhus */const R=t=>{const e=(e,r)=>g.create(e,o(t,r));for(const r of c)e[r]=(e,s)=>g.create(e,o(t,s,{method:r}));return e.create=t=>R(o(t)),e.extend=e=>R(o(t,e)),e.stop=f,e},T=R();t.HTTPError=e,t.TimeoutError=r,t.default=T,Object.defineProperty(t,"__esModule",{value:!0})}(c.exports);const p=t=>{try{const{href:s}=new e(t);return r.test(s)&&s}catch(t){return!1}},{flattie:l}=s,{encode:f}=i,d=h,{default:y}=c.exports;class m extends Error{constructor(t){super(),this.name="MicrolinkError",Object.assign(this,t),this.description=this.message,this.message=this.code?`${this.code}, ${this.description}`:this.description}}var b=d({MicrolinkError:m,urlHttp:p,stringify:f,got:async(t,e)=>{try{void 0===e.timeout&&(e.timeout=!1);const r=await y(t,e),s=await r.json(),{headers:o,status:n}=r;return{url:r.url,body:s,headers:o,statusCode:n}}catch(t){if(t.response){const{response:e}=t;t.response={...e,headers:Array.from(e.headers.entries()).reduce(((t,[e,r])=>(t[e]=r,t)),{}),statusCode:e.status,body:await e.text()}}throw t}},flatten:l,VERSION:"0.10.31"});export{b as default};
3
3
  //# sourceMappingURL=mql.min.mjs.map
package/dist/mql.mjs CHANGED
@@ -716,7 +716,7 @@ var browser = factory({
716
716
  stringify,
717
717
  got,
718
718
  flatten,
719
- VERSION: '0.10.30'
719
+ VERSION: '0.10.31'
720
720
  });
721
721
 
722
722
  export { browser as default };
package/package.json CHANGED
@@ -2,10 +2,9 @@
2
2
  "name": "@microlink/mql",
3
3
  "description": "Microlink Query Language. The official HTTP client to interact with Microlink API for Node.js, browsers & Deno.",
4
4
  "homepage": "https://nicedoc.io/microlinkhq/mql",
5
- "version": "0.10.30",
5
+ "version": "0.10.31",
6
6
  "browser": "src/browser.js",
7
7
  "main": "src/node.js",
8
- "module": "dist/mql.mjs",
9
8
  "author": {
10
9
  "email": "josefrancisco.verdu@gmail.com",
11
10
  "name": "Kiko Beats",