@microlink/mql 0.10.5 → 0.10.6
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 +1 -1
- package/dist/mql.min.js +1 -1
- package/index.d.ts +40 -27
- package/package.json +7 -7
package/dist/mql.js
CHANGED
package/dist/mql.min.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("url")):"function"==typeof define&&define.amd?define(["url"],e):(t="undefined"!=typeof globalThis?globalThis:t||self).mql=e(t.require$$0$1)}(this,(function(t){"use strict";function e(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var r=e(t),o="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function s(t){if(t.__esModule)return t;var e=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(t).forEach((function(r){var o=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,o.get?o:{enumerable:!0,get:function(){return t[r]}})})),e}const n=o.window?window.URL:r.default.URL,i=/^https?:\/\//i;var a={};function u(t,e,r,o,s){var n,i=s?s+r:s;if(null==o)e&&(t[s]=o);else if("object"!=typeof o)t[s]=o;else if(Array.isArray(o))for(n=0;n<o.length;n++)u(t,e,r,o[n],i+n);else for(n in o)u(t,e,r,o[n],i+n)}function c(t){if(!t)return"";var e=decodeURIComponent(t);return"false"!==e&&("true"===e||(0*+e==0?+e:e))}a.flattie=function(t,e,r){var o={};return"object"==typeof t&&u(o,!!r,e||".",t,""),o};var p=s(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],c(e.shift())):o[r]=c(e.shift());return o}})),h={exports:{}},f=s(Object.freeze({__proto__:null,default:t=>t}));const l=(t,e,r,o)=>{if("length"===r||"prototype"===r)return;const s=Object.getOwnPropertyDescriptor(t,r),n=Object.getOwnPropertyDescriptor(e,r);!d(s,n)&&o||Object.defineProperty(t,r,n)},d=function(t,e){return void 0===t||t.configurable||t.writable===e.writable&&t.enumerable===e.enumerable&&t.configurable===e.configurable&&(t.writable||t.value===e.value)},y=(t,e)=>`/* Wrapped ${t}*/\n${e}`,b=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),m=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name");var g=(t,e,{ignoreNonConfigurable:r=!1}={})=>{const{name:o}=t;for(const o of Reflect.ownKeys(e))l(t,e,o,r);return((t,e)=>{const r=Object.getPrototypeOf(e);r!==Object.getPrototypeOf(t)&&Object.setPrototypeOf(t,r)})(t,e),((t,e,r)=>{const o=""===r?"":`with ${r.trim()}() `,s=y.bind(null,o,e.toString());Object.defineProperty(s,"name",m),Object.defineProperty(t,"toString",{...b,value:s})})(t,e,o),t},w={isFunction:t=>"function"==typeof t,isString:t=>"string"==typeof t,composeErrorMessage:(t,e)=>`${t}, ${e}`,inherits:(t,e)=>{t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}};const{isFunction:_,composeErrorMessage:E}=w;const R=f,T=g,j=function(t,...e){Object.assign(t,...e),t.description=_(t.message)?t.message(t):t.message,t.message=t.code?E(t.code,t.description):t.description},{isString:x}=w;var v=function(t,e){function r(r){const o=new t,s=x(r)?{message:r}:r;return j(o,e,s),o.stack=R(o.stack),o}return r.prototype=t.prototype,T(r,t),r};const{inherits:C}=w,O=g,q=/[^0-9a-zA-Z_$]/;const P=v,A=function(t){if("string"!=typeof t)throw new TypeError("Expected className to be a string");if(q.test(t))throw new Error("className contains invalid characters");function e(){Object.defineProperty(this,"name",{configurable:!0,value:t,writable:!0}),Error.captureStackTrace(this,this.constructor)}return C(e,Error),O(e,Error),e},S=t=>(e,r)=>{const o=A(e||t.name);return P(o,r)};h.exports=S(Error),h.exports.type=S(TypeError),h.exports.range=S(RangeError),h.exports.eval=S(EvalError),h.exports.syntax=S(SyntaxError),h.exports.reference=S(ReferenceError),h.exports.uri=S(URIError);const U={FREE:"https://api.microlink.io",PRO:"https://pro.microlink.io"},k=t=>null!==t&&"object"==typeof t;var D=({VERSION:t,MicrolinkError:e,isUrlHttp:r,stringify:o,got:s,flatten:n})=>{const i=t=>{if(!k(t))return;const e=n(t);return Object.keys(e).reduce(((t,r)=>({...t,[`data.${r}`]:e[r].toString()})),{})},a=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:n={}}=s,{statusCode:i,body:u,headers:c,url:p=t}=n,h=k(u)&&!Buffer.isBuffer(u)?u:((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}}})(u,s,p);if("EFATALCLIENT"===h.code&&o++<2)return a(t,r,o);throw e({...h,message:h.message,url:p,statusCode:i,headers:c})}},u=(t,{data:e,apiKey:r,endpoint:s,retry:a,cache:u,...c}={},{responseType:p="json",headers:h,...f}={})=>{const l=!!r;return[`${s||U[l?"PRO":"FREE"]}?${o({url:t,...i(e),...n(c)})}`,{...f,responseType:p,cache:u,retry:a,headers:l?{...h,"x-api-key":r}:{...h}}]},c=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,c]=u(o,s,{...t,...n});return a(i,c)},p=c();return p.MicrolinkError=e,p.getApiUrl=u,p.fetchFromApi=a,p.mapRules=i,p.version=t,p.stream=s.stream,p.buffer=c({responseType:"buffer"}),p},L={exports:{}};!function(t,e){t.exports=function(){
|
|
2
2
|
/*! MIT License © Sindre Sorhus */
|
|
3
|
-
const t=t=>null!==t&&"object"==typeof t,e="function"==typeof globalThis.AbortController,r="function"==typeof globalThis.ReadableStream,o="function"==typeof globalThis.FormData,s=(t,e)=>{const r=new globalThis.Headers(t||{}),o=e instanceof globalThis.Headers,s=new globalThis.Headers(e||{});for(const[t,e]of s)o&&"undefined"===e||void 0===e?r.delete(t):r.set(t,e);return r},n=(...e)=>{let r={},o={};for(const i of e){if(Array.isArray(i))Array.isArray(r)||(r=[]),r=[...r,...i];else if(t(i)){for(let[e,o]of Object.entries(i))t(o)&&e in r&&(o=n(r[e],o)),r={...r,[e]:o};t(i.headers)&&(o=s(o,i.headers))}r.headers=o}return r},i=["get","post","put","patch","head","delete"],a={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},u=["get","put","head","delete","options","trace"],c=[408,413,429,500,502,503,504],p=[413,429,503],h=Symbol("stop");class f extends Error{constructor(t,e,r){super(t.statusText||String(0===t.status||t.status?t.status:"Unknown response error")),this.name="HTTPError",this.response=t,this.request=e,this.options=r}}class l extends Error{constructor(t){super("Request timed out"),this.name="TimeoutError",this.request=t}}const d=t=>new Promise((e=>setTimeout(e,t))),y=(t,e,r)=>new Promise(((o,s)=>{const n=setTimeout((()=>{e&&e.abort(),s(new l(t))}),r.timeout);r.fetch(t).then(o).catch(s).then((()=>{clearTimeout(n)}))})),b=t=>i.includes(t)?t.toUpperCase():t,m={limit:2,methods:u,statusCodes:c,afterStatusCodes:p},g=(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:p}},w=2147483647;class _{constructor(t,i={}){if(this._retryCount=0,this._input=t,this._options={credentials:this._input.credentials||"same-origin",...i,headers:s(this._input.headers,i.headers),hooks:n({beforeRequest:[],beforeRetry:[],afterResponse:[]},i.hooks),method:b(i.method||this._input.method),prefixUrl:String(i.prefixUrl||""),retry:g(i.retry),throwHttpErrors:!1!==i.throwHttpErrors,timeout:void 0===i.timeout?1e4:i.timeout,fetch:i.fetch||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(e&&(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);!(o&&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","application/json"),this.request=new globalThis.Request(this.request,{body:this._options.body}));const u=async()=>{if(this._options.timeout>w)throw new RangeError(`The \`timeout\` option cannot be greater than ${w}`);await d(1);let t=await this._fetch();for(const e of this._options.hooks.afterResponse){const r=await e(this.request,this._options,this._decorateResponse(t.clone()));r instanceof globalThis.Response&&(t=r)}if(this._decorateResponse(t),!t.ok&&this._options.throwHttpErrors)throw new f(t,this.request,this._options);if(this._options.onDownloadProgress){if("function"!=typeof this._options.onDownloadProgress)throw new TypeError("The `onDownloadProgress` option must be a function");if(!r)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return this._stream(t.clone(),this._options.onDownloadProgress)}return t},c=this._options.retry.methods.includes(this.request.method.toLowerCase())?this._retry(u):u();for(const[t,e]of Object.entries(a))c[t]=async()=>{this.request.headers.set("accept",this.request.headers.get("accept")||e);const r=(await c).clone();if("json"===t){if(204===r.status)return"";if(i.parseJson)return i.parseJson(await r.text())}return r[t]()};return c}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount<this._options.retry.limit&&!(t instanceof l)){if(t instanceof f){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),w);if(0!==r&&this._retryCount>0){await d(r);for(const t of this._options.hooks.beforeRetry)if(await t({request:this.request,options:this._options,error:e,retryCount:this._retryCount})===h)return;return this._retry(t)}if(this._options.throwHttpErrors)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()):y(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()}}))}}const E=(...e)=>{for(const r of e)if((!t(r)||Array.isArray(r))&&void 0!==r)throw new TypeError("The `options` argument must be an object");return n({},...e)},R=t=>{const e=(e,r)=>new _(e,E(t,r));for(const r of i)e[r]=(e,o)=>new _(e,E(t,o,{method:r}));return e.HTTPError=f,e.TimeoutError=l,e.create=t=>R(E(t)),e.extend=e=>R(E(t,e)),e.stop=h,e};return R()}()}(L);const N=t=>{try{return i.test(new n(t).href)}catch(t){return!1}},{flattie:$}=a,{encode:I}=p,F=h.exports,H=L.exports;return D({MicrolinkError:F("MicrolinkError"),isUrlHttp:N,stringify:I,got:async(t,e)=>{try{void 0===e.timeout&&(e.timeout=!1);const r=await H(t,e),o=await r.json(),{headers:s,status:n,statusText:i}=r;return{url:r.url,body:o,headers:s,statusCode:n,statusMessage:i}}catch(t){if(t.response){const{response:e}=t;t.response={...e,headers:[...e.headers.entries()].reduce(((t,[e,r])=>({...t,[e]:r})),{}),statusCode:e.status,body:await e.text()}}throw t}},flatten:$,VERSION:"0.10.
|
|
3
|
+
const t=t=>null!==t&&"object"==typeof t,e="function"==typeof globalThis.AbortController,r="function"==typeof globalThis.ReadableStream,o="function"==typeof globalThis.FormData,s=(t,e)=>{const r=new globalThis.Headers(t||{}),o=e instanceof globalThis.Headers,s=new globalThis.Headers(e||{});for(const[t,e]of s)o&&"undefined"===e||void 0===e?r.delete(t):r.set(t,e);return r},n=(...e)=>{let r={},o={};for(const i of e){if(Array.isArray(i))Array.isArray(r)||(r=[]),r=[...r,...i];else if(t(i)){for(let[e,o]of Object.entries(i))t(o)&&e in r&&(o=n(r[e],o)),r={...r,[e]:o};t(i.headers)&&(o=s(o,i.headers))}r.headers=o}return r},i=["get","post","put","patch","head","delete"],a={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},u=["get","put","head","delete","options","trace"],c=[408,413,429,500,502,503,504],p=[413,429,503],h=Symbol("stop");class f extends Error{constructor(t,e,r){super(t.statusText||String(0===t.status||t.status?t.status:"Unknown response error")),this.name="HTTPError",this.response=t,this.request=e,this.options=r}}class l extends Error{constructor(t){super("Request timed out"),this.name="TimeoutError",this.request=t}}const d=t=>new Promise((e=>setTimeout(e,t))),y=(t,e,r)=>new Promise(((o,s)=>{const n=setTimeout((()=>{e&&e.abort(),s(new l(t))}),r.timeout);r.fetch(t).then(o).catch(s).then((()=>{clearTimeout(n)}))})),b=t=>i.includes(t)?t.toUpperCase():t,m={limit:2,methods:u,statusCodes:c,afterStatusCodes:p},g=(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:p}},w=2147483647;class _{constructor(t,i={}){if(this._retryCount=0,this._input=t,this._options={credentials:this._input.credentials||"same-origin",...i,headers:s(this._input.headers,i.headers),hooks:n({beforeRequest:[],beforeRetry:[],afterResponse:[]},i.hooks),method:b(i.method||this._input.method),prefixUrl:String(i.prefixUrl||""),retry:g(i.retry),throwHttpErrors:!1!==i.throwHttpErrors,timeout:void 0===i.timeout?1e4:i.timeout,fetch:i.fetch||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(e&&(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);!(o&&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","application/json"),this.request=new globalThis.Request(this.request,{body:this._options.body}));const u=async()=>{if(this._options.timeout>w)throw new RangeError(`The \`timeout\` option cannot be greater than ${w}`);await d(1);let t=await this._fetch();for(const e of this._options.hooks.afterResponse){const r=await e(this.request,this._options,this._decorateResponse(t.clone()));r instanceof globalThis.Response&&(t=r)}if(this._decorateResponse(t),!t.ok&&this._options.throwHttpErrors)throw new f(t,this.request,this._options);if(this._options.onDownloadProgress){if("function"!=typeof this._options.onDownloadProgress)throw new TypeError("The `onDownloadProgress` option must be a function");if(!r)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return this._stream(t.clone(),this._options.onDownloadProgress)}return t},c=this._options.retry.methods.includes(this.request.method.toLowerCase())?this._retry(u):u();for(const[t,e]of Object.entries(a))c[t]=async()=>{this.request.headers.set("accept",this.request.headers.get("accept")||e);const r=(await c).clone();if("json"===t){if(204===r.status)return"";if(i.parseJson)return i.parseJson(await r.text())}return r[t]()};return c}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount<this._options.retry.limit&&!(t instanceof l)){if(t instanceof f){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),w);if(0!==r&&this._retryCount>0){await d(r);for(const t of this._options.hooks.beforeRetry)if(await t({request:this.request,options:this._options,error:e,retryCount:this._retryCount})===h)return;return this._retry(t)}if(this._options.throwHttpErrors)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()):y(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()}}))}}const E=(...e)=>{for(const r of e)if((!t(r)||Array.isArray(r))&&void 0!==r)throw new TypeError("The `options` argument must be an object");return n({},...e)},R=t=>{const e=(e,r)=>new _(e,E(t,r));for(const r of i)e[r]=(e,o)=>new _(e,E(t,o,{method:r}));return e.HTTPError=f,e.TimeoutError=l,e.create=t=>R(E(t)),e.extend=e=>R(E(t,e)),e.stop=h,e};return R()}()}(L);const N=t=>{try{return i.test(new n(t).href)}catch(t){return!1}},{flattie:$}=a,{encode:I}=p,F=h.exports,H=L.exports;return D({MicrolinkError:F("MicrolinkError"),isUrlHttp:N,stringify:I,got:async(t,e)=>{try{void 0===e.timeout&&(e.timeout=!1);const r=await H(t,e),o=await r.json(),{headers:s,status:n,statusText:i}=r;return{url:r.url,body:o,headers:s,statusCode:n,statusMessage:i}}catch(t){if(t.response){const{response:e}=t;t.response={...e,headers:[...e.headers.entries()].reduce(((t,[e,r])=>({...t,[e]:r})),{}),statusCode:e.status,body:await e.text()}}throw t}},flatten:$,VERSION:"0.10.6"})}));
|
|
4
4
|
//# sourceMappingURL=mql.min.js.map
|
package/index.d.ts
CHANGED
|
@@ -3,23 +3,37 @@
|
|
|
3
3
|
declare module "@microlink/mql" {
|
|
4
4
|
export type WaitUntilEvent = "load" | "domcontentloaded" | "networkidle0" | "networkidle2";
|
|
5
5
|
|
|
6
|
-
export type
|
|
7
|
-
background: string;
|
|
8
|
-
browser: "light" | "dark";
|
|
6
|
+
export type AssetOptions = Partial<{
|
|
9
7
|
click: string | string[];
|
|
10
|
-
deviceScaleFactor: number;
|
|
11
8
|
disableAnimations: boolean;
|
|
12
|
-
|
|
13
|
-
fullPage: boolean;
|
|
14
|
-
hasTouch: boolean;
|
|
15
|
-
height: number;
|
|
9
|
+
filename: string;
|
|
16
10
|
hide: string | string[];
|
|
17
|
-
isLandscape: boolean;
|
|
18
|
-
isMobile: boolean;
|
|
19
11
|
scrollTo: string;
|
|
20
|
-
|
|
12
|
+
viewport: object;
|
|
21
13
|
waitFor: number | string;
|
|
14
|
+
waitForSelector: string;
|
|
15
|
+
waitForTimeout: number;
|
|
22
16
|
waitUntil: WaitUntilEvent | WaitUntilEvent[];
|
|
17
|
+
}>;
|
|
18
|
+
|
|
19
|
+
export type ScreenshotOptions = AssetOptions & Partial<{
|
|
20
|
+
background: string;
|
|
21
|
+
browser: "light" | "dark";
|
|
22
|
+
element: string;
|
|
23
|
+
fullPage: boolean;
|
|
24
|
+
omitBackground: object;
|
|
25
|
+
overlay: object;
|
|
26
|
+
type: "jpeg" | "png";
|
|
27
|
+
}>;
|
|
28
|
+
|
|
29
|
+
export type PdfOptions = AssetOptions & Partial<{
|
|
30
|
+
format: string;
|
|
31
|
+
height: number;
|
|
32
|
+
hide: string | string[];
|
|
33
|
+
landscape: string;
|
|
34
|
+
margin: string | object;
|
|
35
|
+
pageRanges: string;
|
|
36
|
+
scale: number;
|
|
23
37
|
width: number;
|
|
24
38
|
}>;
|
|
25
39
|
|
|
@@ -48,8 +62,8 @@ declare module "@microlink/mql" {
|
|
|
48
62
|
|
|
49
63
|
export type MqlQueryOptions = Partial<{
|
|
50
64
|
attr: string | string[];
|
|
65
|
+
evaluate: string | (() => string)
|
|
51
66
|
selector: string | string[];
|
|
52
|
-
evaluate: string | function;
|
|
53
67
|
selectorAll: string | string[];
|
|
54
68
|
type: MqlQueryResponseType;
|
|
55
69
|
}>;
|
|
@@ -59,6 +73,7 @@ declare module "@microlink/mql" {
|
|
|
59
73
|
}
|
|
60
74
|
|
|
61
75
|
export type MicrolinkApiOptions = Partial<{
|
|
76
|
+
adblock: boolean;
|
|
62
77
|
animations: boolean;
|
|
63
78
|
audio: boolean;
|
|
64
79
|
click: string | string[];
|
|
@@ -72,13 +87,14 @@ declare module "@microlink/mql" {
|
|
|
72
87
|
function: string;
|
|
73
88
|
headers: Record<string, unknown>;
|
|
74
89
|
iframe: boolean | Record<"maxwidth" | "maxheight", number>;
|
|
75
|
-
insights: boolean | object
|
|
90
|
+
insights: boolean | Partial<{ lighthouse: boolean | object, technologies: boolean }>;
|
|
76
91
|
javascript: boolean;
|
|
77
|
-
|
|
92
|
+
mediaType: string;
|
|
78
93
|
meta: boolean;
|
|
79
94
|
modules: string | string[];
|
|
80
95
|
palette: boolean;
|
|
81
|
-
|
|
96
|
+
pdf: boolean | PdfOptions;
|
|
97
|
+
ping: boolean | object;
|
|
82
98
|
prerender: boolean | "auto";
|
|
83
99
|
proxy: string;
|
|
84
100
|
remove: string | string[];
|
|
@@ -86,15 +102,12 @@ declare module "@microlink/mql" {
|
|
|
86
102
|
screenshot: boolean | ScreenshotOptions;
|
|
87
103
|
scripts: string | string[];
|
|
88
104
|
scroll: string;
|
|
105
|
+
staleTtl: string | number;
|
|
89
106
|
styles: string | string[];
|
|
90
107
|
timeout: number;
|
|
91
108
|
ttl: string | number;
|
|
92
109
|
url: string;
|
|
93
110
|
video: boolean;
|
|
94
|
-
viewport: object;
|
|
95
|
-
waitForSelector: string;
|
|
96
|
-
waitForTimeout: number;
|
|
97
|
-
waitUntil: string | string[];
|
|
98
111
|
}>;
|
|
99
112
|
|
|
100
113
|
export type MqlOptions = Partial<{
|
|
@@ -161,23 +174,23 @@ declare module "@microlink/mql" {
|
|
|
161
174
|
|
|
162
175
|
export type MqlResponseData = Partial<{
|
|
163
176
|
// A human-readable representation of the author's name.
|
|
164
|
-
author: string;
|
|
177
|
+
author: string | null;
|
|
165
178
|
// An ISO 8601 representation of the date the article was published.
|
|
166
|
-
date: string;
|
|
179
|
+
date: string | null;
|
|
167
180
|
// The publisher's chosen description of the article.
|
|
168
|
-
description: string;
|
|
181
|
+
description: string | null;
|
|
169
182
|
// An ISO 639-1 representation of the url content language.
|
|
170
|
-
lang: string;
|
|
183
|
+
lang: string | null;
|
|
171
184
|
// An image URL that best represents the publisher brand.
|
|
172
|
-
logo: ImageInfo;
|
|
185
|
+
logo: ImageInfo | null;
|
|
173
186
|
// A human-readable representation of the publisher's name.
|
|
174
|
-
publisher: string;
|
|
187
|
+
publisher: string | null;
|
|
175
188
|
// The publisher's chosen title of the article.
|
|
176
|
-
title: string;
|
|
189
|
+
title: string | null;
|
|
177
190
|
// The URL of the article.
|
|
178
|
-
|
|
179
191
|
url: string;
|
|
180
192
|
image: ImageInfo | null;
|
|
193
|
+
screenshot: ImageInfo | null;
|
|
181
194
|
video: VideoInfo | null;
|
|
182
195
|
audio: AudioInfo | null;
|
|
183
196
|
iframe: IframeInfo | null;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
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.
|
|
5
|
+
"version": "0.10.6",
|
|
6
6
|
"browser": "src/browser.js",
|
|
7
7
|
"main": "src/node.js",
|
|
8
8
|
"author": {
|
|
@@ -62,8 +62,8 @@
|
|
|
62
62
|
"git-authors-cli": "latest",
|
|
63
63
|
"git-dirty": "latest",
|
|
64
64
|
"ky": "latest",
|
|
65
|
-
"lint-staged": "latest",
|
|
66
65
|
"meow": "latest",
|
|
66
|
+
"nano-staged": "latest",
|
|
67
67
|
"node-fetch": "2",
|
|
68
68
|
"npm-check-updates": "latest",
|
|
69
69
|
"nyc": "latest",
|
|
@@ -125,20 +125,20 @@
|
|
|
125
125
|
"@commitlint/config-conventional"
|
|
126
126
|
]
|
|
127
127
|
},
|
|
128
|
-
"
|
|
129
|
-
"package.json": [
|
|
130
|
-
"finepack --sort-ignore-object-at ava"
|
|
131
|
-
],
|
|
128
|
+
"nano-staged": {
|
|
132
129
|
"*.js,!*.min.js,": [
|
|
133
130
|
"prettier-standard"
|
|
134
131
|
],
|
|
135
132
|
"*.md": [
|
|
136
133
|
"standard-markdown"
|
|
134
|
+
],
|
|
135
|
+
"package.json": [
|
|
136
|
+
"finepack --sort-ignore-object-at ava"
|
|
137
137
|
]
|
|
138
138
|
},
|
|
139
139
|
"simple-git-hooks": {
|
|
140
140
|
"commit-msg": "npx commitlint --edit",
|
|
141
|
-
"pre-commit": "npx
|
|
141
|
+
"pre-commit": "npx nano-staged"
|
|
142
142
|
},
|
|
143
143
|
"standard": {
|
|
144
144
|
"ignore": [
|