@microlink/mql 0.10.4 → 0.10.10
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/CHANGELOG.md +663 -0
- package/dist/mql.js +19 -5
- package/dist/mql.js.map +1 -1
- package/dist/mql.min.js +2 -2
- package/dist/mql.min.js.map +1 -1
- package/index.d.ts +109 -45
- package/package.json +12 -8
- package/src/factory.js +18 -4
package/dist/mql.min.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mql.min.js","sources":["../node_modules/is-url-http/lightweight.js","../node_modules/flattie/dist/index.js","../node_modules/qss/dist/qss.m.js","../node_modules/mimic-fn/index.js","../node_modules/whoops/lib/helpers.js","../node_modules/whoops/lib/add-error-props.js","../node_modules/whoops/lib/create-extend-error.js","../node_modules/whoops/lib/create-error.js","../node_modules/whoops/lib/index.js","../src/factory.js","../src/ky.js","../src/browser.js"],"sourcesContent":["'use strict'\n\nconst URL = global.window ? window.URL : require('url').URL\nconst REGEX_HTTP_PROTOCOL = /^https?:\\/\\//i\n\nmodule.exports = url => {\n try {\n return REGEX_HTTP_PROTOCOL.test(new URL(url).href)\n } catch (err) {\n return false\n }\n}\n","function iter(output, nullish, sep, val, key) {\n\tvar k, pfx = key ? (key + sep) : key;\n\n\tif (val == null) {\n\t\tif (nullish) output[key] = val;\n\t} else if (typeof val != 'object') {\n\t\toutput[key] = val;\n\t} else if (Array.isArray(val)) {\n\t\tfor (k=0; k < val.length; k++) {\n\t\t\titer(output, nullish, sep, val[k], pfx + k);\n\t\t}\n\t} else {\n\t\tfor (k in val) {\n\t\t\titer(output, nullish, sep, val[k], pfx + k);\n\t\t}\n\t}\n}\n\nfunction flattie(input, glue, toNull) {\n\tvar output = {};\n\tif (typeof input == 'object') {\n\t\titer(output, !!toNull, glue || '.', input, '');\n\t}\n\treturn output;\n}\n\nexports.flattie = flattie;","export function encode(obj, pfx) {\n\tvar k, i, tmp, str='';\n\n\tfor (k in obj) {\n\t\tif ((tmp = obj[k]) !== void 0) {\n\t\t\tif (Array.isArray(tmp)) {\n\t\t\t\tfor (i=0; i < tmp.length; i++) {\n\t\t\t\t\tstr && (str += '&');\n\t\t\t\t\tstr += encodeURIComponent(k) + '=' + encodeURIComponent(tmp[i]);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tstr && (str += '&');\n\t\t\t\tstr += encodeURIComponent(k) + '=' + encodeURIComponent(tmp);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn (pfx || '') + str;\n}\n\nfunction toValue(mix) {\n\tif (!mix) return '';\n\tvar str = decodeURIComponent(mix);\n\tif (str === 'false') return false;\n\tif (str === 'true') return true;\n\treturn (+str * 0 === 0) ? (+str) : str;\n}\n\nexport function decode(str) {\n\tvar tmp, k, out={}, arr=str.split('&');\n\n\twhile (tmp = arr.shift()) {\n\t\ttmp = tmp.split('=');\n\t\tk = tmp.shift();\n\t\tif (out[k] !== void 0) {\n\t\t\tout[k] = [].concat(out[k], toValue(tmp.shift()));\n\t\t} else {\n\t\t\tout[k] = toValue(tmp.shift());\n\t\t}\n\t}\n\n\treturn out;\n}\n","'use strict';\n\nconst copyProperty = (to, from, property, ignoreNonConfigurable) => {\n\t// `Function#length` should reflect the parameters of `to` not `from` since we keep its body.\n\t// `Function#prototype` is non-writable and non-configurable so can never be modified.\n\tif (property === 'length' || property === 'prototype') {\n\t\treturn;\n\t}\n\n\tconst toDescriptor = Object.getOwnPropertyDescriptor(to, property);\n\tconst fromDescriptor = Object.getOwnPropertyDescriptor(from, property);\n\n\tif (!canCopyProperty(toDescriptor, fromDescriptor) && ignoreNonConfigurable) {\n\t\treturn;\n\t}\n\n\tObject.defineProperty(to, property, fromDescriptor);\n};\n\n// `Object.defineProperty()` throws if the property exists, is not configurable and either:\n// - one its descriptors is changed\n// - it is non-writable and its value is changed\nconst canCopyProperty = function (toDescriptor, fromDescriptor) {\n\treturn toDescriptor === undefined || toDescriptor.configurable || (\n\t\ttoDescriptor.writable === fromDescriptor.writable &&\n\t\ttoDescriptor.enumerable === fromDescriptor.enumerable &&\n\t\ttoDescriptor.configurable === fromDescriptor.configurable &&\n\t\t(toDescriptor.writable || toDescriptor.value === fromDescriptor.value)\n\t);\n};\n\nconst changePrototype = (to, from) => {\n\tconst fromPrototype = Object.getPrototypeOf(from);\n\tif (fromPrototype === Object.getPrototypeOf(to)) {\n\t\treturn;\n\t}\n\n\tObject.setPrototypeOf(to, fromPrototype);\n};\n\nconst wrappedToString = (withName, fromBody) => `/* Wrapped ${withName}*/\\n${fromBody}`;\n\nconst toStringDescriptor = Object.getOwnPropertyDescriptor(Function.prototype, 'toString');\nconst toStringName = Object.getOwnPropertyDescriptor(Function.prototype.toString, 'name');\n\n// We call `from.toString()` early (not lazily) to ensure `from` can be garbage collected.\n// We use `bind()` instead of a closure for the same reason.\n// Calling `from.toString()` early also allows caching it in case `to.toString()` is called several times.\nconst changeToString = (to, from, name) => {\n\tconst withName = name === '' ? '' : `with ${name.trim()}() `;\n\tconst newToString = wrappedToString.bind(null, withName, from.toString());\n\t// Ensure `to.toString.toString` is non-enumerable and has the same `same`\n\tObject.defineProperty(newToString, 'name', toStringName);\n\tObject.defineProperty(to, 'toString', {...toStringDescriptor, value: newToString});\n};\n\nconst mimicFn = (to, from, {ignoreNonConfigurable = false} = {}) => {\n\tconst {name} = to;\n\n\tfor (const property of Reflect.ownKeys(from)) {\n\t\tcopyProperty(to, from, property, ignoreNonConfigurable);\n\t}\n\n\tchangePrototype(to, from);\n\tchangeToString(to, from, name);\n\n\treturn to;\n};\n\nmodule.exports = mimicFn;\n","'use strict'\n\nmodule.exports = {\n isFunction: obj => typeof obj === 'function',\n isString: obj => typeof obj === 'string',\n composeErrorMessage: (code, description) => `${code}, ${description}`,\n inherits: (ctor, superCtor) => {\n ctor.super_ = superCtor\n ctor.prototype = Object.create(superCtor.prototype, {\n constructor: {\n value: ctor,\n enumerable: false,\n writable: true,\n configurable: true\n }\n })\n }\n}\n","'use strict'\n\nconst {isFunction, composeErrorMessage} = require('./helpers')\n\nfunction interfaceObject (error, ...props) {\n Object.assign(error, ...props)\n\n error.description = isFunction(error.message) ? error.message(error) : error.message\n\n error.message = error.code\n ? composeErrorMessage(error.code, error.description)\n : error.description\n}\n\nmodule.exports = interfaceObject\n","'use strict'\n\nconst cleanStack = require('clean-stack')\nconst mimicFn = require('mimic-fn')\n\nconst addErrorProps = require('./add-error-props')\nconst {isString} = require('./helpers')\n\nfunction createExtendError (ErrorClass, classProps) {\n function ExtendError (props) {\n const error = new ErrorClass()\n const errorProps = isString(props) ? {message: props} : props\n addErrorProps(error, classProps, errorProps)\n\n error.stack = cleanStack(error.stack)\n return error\n }\n\n ExtendError.prototype = ErrorClass.prototype\n mimicFn(ExtendError, ErrorClass)\n\n return ExtendError\n}\n\nmodule.exports = createExtendError\n","'use strict'\n\nconst {inherits} = require('./helpers')\nconst mimicFn = require('mimic-fn')\n\nconst REGEX_CLASS_NAME = /[^0-9a-zA-Z_$]/\n\nfunction createError (className) {\n if (typeof className !== 'string') {\n throw new TypeError('Expected className to be a string')\n }\n\n if (REGEX_CLASS_NAME.test(className)) {\n throw new Error('className contains invalid characters')\n }\n\n function ErrorClass () {\n Object.defineProperty(this, 'name', {\n configurable: true,\n value: className,\n writable: true\n })\n\n Error.captureStackTrace(this, this.constructor)\n }\n\n inherits(ErrorClass, Error)\n mimicFn(ErrorClass, Error)\n return ErrorClass\n}\n\nmodule.exports = createError\n","'use strict'\n\nconst createExtendError = require('./create-extend-error')\nconst createError = require('./create-error')\n\nconst createErrorClass = ErrorClass => (className, props) => {\n const errorClass = createError(className || ErrorClass.name)\n return createExtendError(errorClass, props)\n}\n\nmodule.exports = createErrorClass(Error)\nmodule.exports.type = createErrorClass(TypeError)\nmodule.exports.range = createErrorClass(RangeError)\nmodule.exports.eval = createErrorClass(EvalError)\nmodule.exports.syntax = createErrorClass(SyntaxError)\nmodule.exports.reference = createErrorClass(ReferenceError)\nmodule.exports.uri = createErrorClass(URIError)\n","const ENDPOINT = {\n FREE: 'https://api.microlink.io',\n PRO: 'https://pro.microlink.io'\n}\n\nconst isObject = input => input !== null && typeof input === 'object'\n\nconst parseBody = (input, error, url) => {\n try {\n return JSON.parse(input)\n } catch (_) {\n const message = input || error.message\n\n return {\n status: 'error',\n data: { url: message },\n more: 'https://microlink.io/efatalclient',\n code: 'EFATALCLIENT',\n message,\n url\n }\n }\n}\n\nconst factory = ({ VERSION, MicrolinkError, isUrlHttp, stringify, got, flatten }) => {\n const assertUrl = (url = '') => {\n if (!isUrlHttp(url)) {\n const message = `The \\`url\\` as \\`${url}\\` is not valid. Ensure it has protocol (http or https) and hostname.`\n throw new MicrolinkError({\n status: 'fail',\n data: { url: message },\n more: 'https://microlink.io/docs/api/api-parameters/url',\n code: 'EINVALURLCLIENT',\n message,\n url\n })\n }\n }\n\n const mapRules = rules => {\n if (!isObject(rules)) return\n const flatRules = flatten(rules)\n return Object.keys(flatRules).reduce(\n (acc, key) => ({ ...acc, [`data.${key}`]: flatRules[key].toString() }),\n {}\n )\n }\n\n const fetchFromApi = async (apiUrl, opts = {}, retryCount = 0) => {\n try {\n const response = await got(apiUrl, opts)\n return opts.responseType === 'buffer'\n ? { body: response.body, response }\n : { ...response.body, response }\n } catch (err) {\n const { response = {} } = err\n const { statusCode, body: rawBody, headers, url: uri = apiUrl } = response\n\n const body =\n isObject(rawBody) && !Buffer.isBuffer(rawBody) ? rawBody : parseBody(rawBody, err, uri)\n\n if (body.code === 'EFATALCLIENT' && retryCount++ < 2) return fetchFromApi(apiUrl, opts, retryCount)\n\n throw MicrolinkError({\n ...body,\n message: body.message,\n url: uri,\n statusCode,\n headers\n })\n }\n }\n\n const getApiUrl = (\n url,\n { data, apiKey, endpoint, retry, cache, ...opts } = {},\n { responseType = 'json', headers: gotHeaders, ...gotOpts } = {}\n ) => {\n const isPro = !!apiKey\n const apiEndpoint = endpoint || ENDPOINT[isPro ? 'PRO' : 'FREE']\n\n const apiUrl = `${apiEndpoint}?${stringify({\n url,\n ...mapRules(data),\n ...flatten(opts)\n })}`\n\n const headers = isPro ? { ...gotHeaders, 'x-api-key': apiKey } : { ...gotHeaders }\n return [apiUrl, { ...gotOpts, responseType, cache, retry, headers }]\n }\n\n const createMql = defaultOpts => async (url, opts, gotOpts) => {\n assertUrl(url)\n const [apiUrl, fetchOpts] = getApiUrl(url, opts, {\n ...defaultOpts,\n ...gotOpts\n })\n return fetchFromApi(apiUrl, fetchOpts)\n }\n\n const mql = createMql()\n mql.MicrolinkError = MicrolinkError\n mql.getApiUrl = getApiUrl\n mql.fetchFromApi = fetchFromApi\n mql.mapRules = mapRules\n mql.version = VERSION\n mql.stream = got.stream\n mql.buffer = createMql({ responseType: 'buffer' })\n\n return mql\n}\n\nmodule.exports = factory\n","(function (global, factory) {\n\ttypeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :\n\ttypeof define === 'function' && define.amd ? define(factory) :\n\t(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.ky = factory());\n}(this, (function () { 'use strict';\n\n\t/*! MIT License © Sindre Sorhus */\n\n\tconst isObject = value => value !== null && typeof value === 'object';\n\tconst supportsAbortController = typeof globalThis.AbortController === 'function';\n\tconst supportsStreams = typeof globalThis.ReadableStream === 'function';\n\tconst supportsFormData = typeof globalThis.FormData === 'function';\n\n\tconst mergeHeaders = (source1, source2) => {\n\t\tconst result = new globalThis.Headers(source1 || {});\n\t\tconst isHeadersInstance = source2 instanceof globalThis.Headers;\n\t\tconst source = new globalThis.Headers(source2 || {});\n\n\t\tfor (const [key, value] of source) {\n\t\t\tif ((isHeadersInstance && value === 'undefined') || value === undefined) {\n\t\t\t\tresult.delete(key);\n\t\t\t} else {\n\t\t\t\tresult.set(key, value);\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t};\n\n\tconst deepMerge = (...sources) => {\n\t\tlet returnValue = {};\n\t\tlet headers = {};\n\n\t\tfor (const source of sources) {\n\t\t\tif (Array.isArray(source)) {\n\t\t\t\tif (!(Array.isArray(returnValue))) {\n\t\t\t\t\treturnValue = [];\n\t\t\t\t}\n\n\t\t\t\treturnValue = [...returnValue, ...source];\n\t\t\t} else if (isObject(source)) {\n\t\t\t\tfor (let [key, value] of Object.entries(source)) {\n\t\t\t\t\tif (isObject(value) && (key in returnValue)) {\n\t\t\t\t\t\tvalue = deepMerge(returnValue[key], value);\n\t\t\t\t\t}\n\n\t\t\t\t\treturnValue = {...returnValue, [key]: value};\n\t\t\t\t}\n\n\t\t\t\tif (isObject(source.headers)) {\n\t\t\t\t\theaders = mergeHeaders(headers, source.headers);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturnValue.headers = headers;\n\t\t}\n\n\t\treturn returnValue;\n\t};\n\n\tconst requestMethods = [\n\t\t'get',\n\t\t'post',\n\t\t'put',\n\t\t'patch',\n\t\t'head',\n\t\t'delete'\n\t];\n\n\tconst responseTypes = {\n\t\tjson: 'application/json',\n\t\ttext: 'text/*',\n\t\tformData: 'multipart/form-data',\n\t\tarrayBuffer: '*/*',\n\t\tblob: '*/*'\n\t};\n\n\tconst retryMethods = [\n\t\t'get',\n\t\t'put',\n\t\t'head',\n\t\t'delete',\n\t\t'options',\n\t\t'trace'\n\t];\n\n\tconst retryStatusCodes = [\n\t\t408,\n\t\t413,\n\t\t429,\n\t\t500,\n\t\t502,\n\t\t503,\n\t\t504\n\t];\n\n\tconst retryAfterStatusCodes = [\n\t\t413,\n\t\t429,\n\t\t503\n\t];\n\n\tconst stop = Symbol('stop');\n\n\tclass HTTPError extends Error {\n\t\tconstructor(response, request, options) {\n\t\t\t// Set the message to the status text, such as Unauthorized,\n\t\t\t// with some fallbacks. This message should never be undefined.\n\t\t\tsuper(\n\t\t\t\tresponse.statusText ||\n\t\t\t\tString(\n\t\t\t\t\t(response.status === 0 || response.status) ?\n\t\t\t\t\t\tresponse.status : 'Unknown response error'\n\t\t\t\t)\n\t\t\t);\n\t\t\tthis.name = 'HTTPError';\n\t\t\tthis.response = response;\n\t\t\tthis.request = request;\n\t\t\tthis.options = options;\n\t\t}\n\t}\n\n\tclass TimeoutError extends Error {\n\t\tconstructor(request) {\n\t\t\tsuper('Request timed out');\n\t\t\tthis.name = 'TimeoutError';\n\t\t\tthis.request = request;\n\t\t}\n\t}\n\n\tconst delay = ms => new Promise(resolve => setTimeout(resolve, ms));\n\n\t// `Promise.race()` workaround (#91)\n\tconst timeout = (request, abortController, options) =>\n\t\tnew Promise((resolve, reject) => {\n\t\t\tconst timeoutID = setTimeout(() => {\n\t\t\t\tif (abortController) {\n\t\t\t\t\tabortController.abort();\n\t\t\t\t}\n\n\t\t\t\treject(new TimeoutError(request));\n\t\t\t}, options.timeout);\n\n\t\t\t/* eslint-disable promise/prefer-await-to-then */\n\t\t\toptions.fetch(request)\n\t\t\t\t.then(resolve)\n\t\t\t\t.catch(reject)\n\t\t\t\t.then(() => {\n\t\t\t\t\tclearTimeout(timeoutID);\n\t\t\t\t});\n\t\t\t/* eslint-enable promise/prefer-await-to-then */\n\t\t});\n\n\tconst normalizeRequestMethod = input => requestMethods.includes(input) ? input.toUpperCase() : input;\n\n\tconst defaultRetryOptions = {\n\t\tlimit: 2,\n\t\tmethods: retryMethods,\n\t\tstatusCodes: retryStatusCodes,\n\t\tafterStatusCodes: retryAfterStatusCodes\n\t};\n\n\tconst normalizeRetryOptions = (retry = {}) => {\n\t\tif (typeof retry === 'number') {\n\t\t\treturn {\n\t\t\t\t...defaultRetryOptions,\n\t\t\t\tlimit: retry\n\t\t\t};\n\t\t}\n\n\t\tif (retry.methods && !Array.isArray(retry.methods)) {\n\t\t\tthrow new Error('retry.methods must be an array');\n\t\t}\n\n\t\tif (retry.statusCodes && !Array.isArray(retry.statusCodes)) {\n\t\t\tthrow new Error('retry.statusCodes must be an array');\n\t\t}\n\n\t\treturn {\n\t\t\t...defaultRetryOptions,\n\t\t\t...retry,\n\t\t\tafterStatusCodes: retryAfterStatusCodes\n\t\t};\n\t};\n\n\t// The maximum value of a 32bit int (see issue #117)\n\tconst maxSafeTimeout = 2147483647;\n\n\tclass Ky {\n\t\tconstructor(input, options = {}) {\n\t\t\tthis._retryCount = 0;\n\t\t\tthis._input = input;\n\t\t\tthis._options = {\n\t\t\t\t// TODO: credentials can be removed when the spec change is implemented in all browsers. Context: https://www.chromestatus.com/feature/4539473312350208\n\t\t\t\tcredentials: this._input.credentials || 'same-origin',\n\t\t\t\t...options,\n\t\t\t\theaders: mergeHeaders(this._input.headers, options.headers),\n\t\t\t\thooks: deepMerge({\n\t\t\t\t\tbeforeRequest: [],\n\t\t\t\t\tbeforeRetry: [],\n\t\t\t\t\tafterResponse: []\n\t\t\t\t}, options.hooks),\n\t\t\t\tmethod: normalizeRequestMethod(options.method || this._input.method),\n\t\t\t\tprefixUrl: String(options.prefixUrl || ''),\n\t\t\t\tretry: normalizeRetryOptions(options.retry),\n\t\t\t\tthrowHttpErrors: options.throwHttpErrors !== false,\n\t\t\t\ttimeout: typeof options.timeout === 'undefined' ? 10000 : options.timeout,\n\t\t\t\tfetch: options.fetch || globalThis.fetch.bind(globalThis)\n\t\t\t};\n\n\t\t\tif (typeof this._input !== 'string' && !(this._input instanceof URL || this._input instanceof globalThis.Request)) {\n\t\t\t\tthrow new TypeError('`input` must be a string, URL, or Request');\n\t\t\t}\n\n\t\t\tif (this._options.prefixUrl && typeof this._input === 'string') {\n\t\t\t\tif (this._input.startsWith('/')) {\n\t\t\t\t\tthrow new Error('`input` must not begin with a slash when using `prefixUrl`');\n\t\t\t\t}\n\n\t\t\t\tif (!this._options.prefixUrl.endsWith('/')) {\n\t\t\t\t\tthis._options.prefixUrl += '/';\n\t\t\t\t}\n\n\t\t\t\tthis._input = this._options.prefixUrl + this._input;\n\t\t\t}\n\n\t\t\tif (supportsAbortController) {\n\t\t\t\tthis.abortController = new globalThis.AbortController();\n\t\t\t\tif (this._options.signal) {\n\t\t\t\t\tthis._options.signal.addEventListener('abort', () => {\n\t\t\t\t\t\tthis.abortController.abort();\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tthis._options.signal = this.abortController.signal;\n\t\t\t}\n\n\t\t\tthis.request = new globalThis.Request(this._input, this._options);\n\n\t\t\tif (this._options.searchParams) {\n\t\t\t\tconst textSearchParams = typeof this._options.searchParams === 'string' ?\n\t\t\t\t\tthis._options.searchParams.replace(/^\\?/, '') :\n\t\t\t\t\tnew URLSearchParams(this._options.searchParams).toString();\n\t\t\t\tconst searchParams = '?' + textSearchParams;\n\t\t\t\tconst url = this.request.url.replace(/(?:\\?.*?)?(?=#|$)/, searchParams);\n\n\t\t\t\t// To provide correct form boundary, Content-Type header should be deleted each time when new Request instantiated from another one\n\t\t\t\tif (((supportsFormData && this._options.body instanceof globalThis.FormData) || this._options.body instanceof URLSearchParams) && !(this._options.headers && this._options.headers['content-type'])) {\n\t\t\t\t\tthis.request.headers.delete('content-type');\n\t\t\t\t}\n\n\t\t\t\tthis.request = new globalThis.Request(new globalThis.Request(url, this.request), this._options);\n\t\t\t}\n\n\t\t\tif (this._options.json !== undefined) {\n\t\t\t\tthis._options.body = JSON.stringify(this._options.json);\n\t\t\t\tthis.request.headers.set('content-type', 'application/json');\n\t\t\t\tthis.request = new globalThis.Request(this.request, {body: this._options.body});\n\t\t\t}\n\n\t\t\tconst fn = async () => {\n\t\t\t\tif (this._options.timeout > maxSafeTimeout) {\n\t\t\t\t\tthrow new RangeError(`The \\`timeout\\` option cannot be greater than ${maxSafeTimeout}`);\n\t\t\t\t}\n\n\t\t\t\tawait delay(1);\n\t\t\t\tlet response = await this._fetch();\n\n\t\t\t\tfor (const hook of this._options.hooks.afterResponse) {\n\t\t\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\t\t\tconst modifiedResponse = await hook(\n\t\t\t\t\t\tthis.request,\n\t\t\t\t\t\tthis._options,\n\t\t\t\t\t\tthis._decorateResponse(response.clone())\n\t\t\t\t\t);\n\n\t\t\t\t\tif (modifiedResponse instanceof globalThis.Response) {\n\t\t\t\t\t\tresponse = modifiedResponse;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tthis._decorateResponse(response);\n\n\t\t\t\tif (!response.ok && this._options.throwHttpErrors) {\n\t\t\t\t\tthrow new HTTPError(response, this.request, this._options);\n\t\t\t\t}\n\n\t\t\t\t// If `onDownloadProgress` is passed, it uses the stream API internally\n\t\t\t\t/* istanbul ignore next */\n\t\t\t\tif (this._options.onDownloadProgress) {\n\t\t\t\t\tif (typeof this._options.onDownloadProgress !== 'function') {\n\t\t\t\t\t\tthrow new TypeError('The `onDownloadProgress` option must be a function');\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!supportsStreams) {\n\t\t\t\t\t\tthrow new Error('Streams are not supported in your environment. `ReadableStream` is missing.');\n\t\t\t\t\t}\n\n\t\t\t\t\treturn this._stream(response.clone(), this._options.onDownloadProgress);\n\t\t\t\t}\n\n\t\t\t\treturn response;\n\t\t\t};\n\n\t\t\tconst isRetriableMethod = this._options.retry.methods.includes(this.request.method.toLowerCase());\n\t\t\tconst result = isRetriableMethod ? this._retry(fn) : fn();\n\n\t\t\tfor (const [type, mimeType] of Object.entries(responseTypes)) {\n\t\t\t\tresult[type] = async () => {\n\t\t\t\t\tthis.request.headers.set('accept', this.request.headers.get('accept') || mimeType);\n\n\t\t\t\t\tconst response = (await result).clone();\n\n\t\t\t\t\tif (type === 'json') {\n\t\t\t\t\t\tif (response.status === 204) {\n\t\t\t\t\t\t\treturn '';\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (options.parseJson) {\n\t\t\t\t\t\t\treturn options.parseJson(await response.text());\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\treturn response[type]();\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn result;\n\t\t}\n\n\t\t_calculateRetryDelay(error) {\n\t\t\tthis._retryCount++;\n\n\t\t\tif (this._retryCount < this._options.retry.limit && !(error instanceof TimeoutError)) {\n\t\t\t\tif (error instanceof HTTPError) {\n\t\t\t\t\tif (!this._options.retry.statusCodes.includes(error.response.status)) {\n\t\t\t\t\t\treturn 0;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst retryAfter = error.response.headers.get('Retry-After');\n\t\t\t\t\tif (retryAfter && this._options.retry.afterStatusCodes.includes(error.response.status)) {\n\t\t\t\t\t\tlet after = Number(retryAfter);\n\t\t\t\t\t\tif (Number.isNaN(after)) {\n\t\t\t\t\t\t\tafter = Date.parse(retryAfter) - Date.now();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tafter *= 1000;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (typeof this._options.retry.maxRetryAfter !== 'undefined' && after > this._options.retry.maxRetryAfter) {\n\t\t\t\t\t\t\treturn 0;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn after;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (error.response.status === 413) {\n\t\t\t\t\t\treturn 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst BACKOFF_FACTOR = 0.3;\n\t\t\t\treturn BACKOFF_FACTOR * (2 ** (this._retryCount - 1)) * 1000;\n\t\t\t}\n\n\t\t\treturn 0;\n\t\t}\n\n\t\t_decorateResponse(response) {\n\t\t\tif (this._options.parseJson) {\n\t\t\t\tresponse.json = async () => {\n\t\t\t\t\treturn this._options.parseJson(await response.text());\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn response;\n\t\t}\n\n\t\tasync _retry(fn) {\n\t\t\ttry {\n\t\t\t\treturn await fn();\n\t\t\t} catch (error) {\n\t\t\t\tconst ms = Math.min(this._calculateRetryDelay(error), maxSafeTimeout);\n\t\t\t\tif (ms !== 0 && this._retryCount > 0) {\n\t\t\t\t\tawait delay(ms);\n\n\t\t\t\t\tfor (const hook of this._options.hooks.beforeRetry) {\n\t\t\t\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\t\t\t\tconst hookResult = await hook({\n\t\t\t\t\t\t\trequest: this.request,\n\t\t\t\t\t\t\toptions: this._options,\n\t\t\t\t\t\t\terror,\n\t\t\t\t\t\t\tretryCount: this._retryCount\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\t// If `stop` is returned from the hook, the retry process is stopped\n\t\t\t\t\t\tif (hookResult === stop) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\treturn this._retry(fn);\n\t\t\t\t}\n\n\t\t\t\tif (this._options.throwHttpErrors) {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tasync _fetch() {\n\t\t\tfor (const hook of this._options.hooks.beforeRequest) {\n\t\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\t\tconst result = await hook(this.request, this._options);\n\n\t\t\t\tif (result instanceof Request) {\n\t\t\t\t\tthis.request = result;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tif (result instanceof Response) {\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (this._options.timeout === false) {\n\t\t\t\treturn this._options.fetch(this.request.clone());\n\t\t\t}\n\n\t\t\treturn timeout(this.request.clone(), this.abortController, this._options);\n\t\t}\n\n\t\t/* istanbul ignore next */\n\t\t_stream(response, onDownloadProgress) {\n\t\t\tconst totalBytes = Number(response.headers.get('content-length')) || 0;\n\t\t\tlet transferredBytes = 0;\n\n\t\t\treturn new globalThis.Response(\n\t\t\t\tnew globalThis.ReadableStream({\n\t\t\t\t\tasync start(controller) {\n\t\t\t\t\t\tconst reader = response.body.getReader();\n\n\t\t\t\t\t\tif (onDownloadProgress) {\n\t\t\t\t\t\t\tonDownloadProgress({percent: 0, transferredBytes: 0, totalBytes}, new Uint8Array());\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tasync function read() {\n\t\t\t\t\t\t\tconst {done, value} = await reader.read();\n\t\t\t\t\t\t\tif (done) {\n\t\t\t\t\t\t\t\tcontroller.close();\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (onDownloadProgress) {\n\t\t\t\t\t\t\t\ttransferredBytes += value.byteLength;\n\t\t\t\t\t\t\t\tconst percent = totalBytes === 0 ? 0 : transferredBytes / totalBytes;\n\t\t\t\t\t\t\t\tonDownloadProgress({percent, transferredBytes, totalBytes}, value);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tcontroller.enqueue(value);\n\t\t\t\t\t\t\tawait read();\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tawait read();\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t);\n\t\t}\n\t}\n\n\tconst validateAndMerge = (...sources) => {\n\t\tfor (const source of sources) {\n\t\t\tif ((!isObject(source) || Array.isArray(source)) && typeof source !== 'undefined') {\n\t\t\t\tthrow new TypeError('The `options` argument must be an object');\n\t\t\t}\n\t\t}\n\n\t\treturn deepMerge({}, ...sources);\n\t};\n\n\tconst createInstance = defaults => {\n\t\tconst ky = (input, options) => new Ky(input, validateAndMerge(defaults, options));\n\n\t\tfor (const method of requestMethods) {\n\t\t\tky[method] = (input, options) => new Ky(input, validateAndMerge(defaults, options, {method}));\n\t\t}\n\n\t\tky.HTTPError = HTTPError;\n\t\tky.TimeoutError = TimeoutError;\n\t\tky.create = newDefaults => createInstance(validateAndMerge(newDefaults));\n\t\tky.extend = newDefaults => createInstance(validateAndMerge(defaults, newDefaults));\n\t\tky.stop = stop;\n\n\t\treturn ky;\n\t};\n\n\tconst ky = createInstance();\n\n\treturn ky;\n\n})));\n","'use strict'\n\nconst isUrlHttp = require('is-url-http/lightweight')\nconst { flattie: flatten } = require('flattie')\nconst { encode: stringify } = require('qss')\nconst whoops = require('whoops')\n\nconst factory = require('./factory')\nconst ky = require('./ky')\n\nconst MicrolinkError = whoops('MicrolinkError')\n\nconst got = async (url, opts) => {\n try {\n if (opts.timeout === undefined) opts.timeout = false\n const response = await ky(url, opts)\n const body = await response.json()\n const { headers, status: statusCode, statusText: statusMessage } = response\n return { url: response.url, body, headers, statusCode, statusMessage }\n } catch (err) {\n if (err.response) {\n const { response } = err\n err.response = {\n ...response,\n headers: [...response.headers.entries()].reduce(\n (acc, [key, value]) => ({ ...acc, [key]: value }),\n {}\n ),\n statusCode: response.status,\n body: await response.text()\n }\n }\n throw err\n }\n}\n\nmodule.exports = factory({\n MicrolinkError,\n isUrlHttp,\n stringify,\n got,\n flatten,\n VERSION: '__MQL_VERSION__'\n})\n"],"names":["URL","global","window","require$$0","REGEX_HTTP_PROTOCOL","iter","output","nullish","sep","val","key","k","pfx","Array","isArray","length","toValue","mix","str","decodeURIComponent","input","glue","toNull","obj","i","tmp","encodeURIComponent","out","arr","split","shift","concat","copyProperty","to","from","property","ignoreNonConfigurable","toDescriptor","Object","getOwnPropertyDescriptor","fromDescriptor","canCopyProperty","defineProperty","undefined","configurable","writable","enumerable","value","wrappedToString","withName","fromBody","toStringDescriptor","Function","prototype","toStringName","toString","mimicFn_1","name","Reflect","ownKeys","fromPrototype","getPrototypeOf","setPrototypeOf","changePrototype","trim","newToString","bind","changeToString","helpers","isFunction","isString","composeErrorMessage","code","description","inherits","ctor","superCtor","super_","create","constructor","cleanStack","mimicFn","require$$1","addErrorProps","error","props","assign","message","require$$3","createExtendError_1","ErrorClass","classProps","ExtendError","errorProps","stack","REGEX_CLASS_NAME","createExtendError","createError","className","TypeError","test","Error","this","captureStackTrace","createErrorClass","errorClass","RangeError","EvalError","SyntaxError","ReferenceError","URIError","ENDPOINT","FREE","PRO","isObject","factory_1","VERSION","MicrolinkError","isUrlHttp","stringify","got","flatten","mapRules","rules","flatRules","keys","reduce","acc","fetchFromApi","async","apiUrl","opts","retryCount","response","responseType","body","err","statusCode","rawBody","headers","url","uri","Buffer","isBuffer","JSON","parse","_","status","data","more","parseBody","getApiUrl","apiKey","endpoint","retry","cache","gotHeaders","gotOpts","isPro","createMql","defaultOpts","assertUrl","fetchOpts","mql","version","stream","buffer","module","supportsAbortController","globalThis","AbortController","supportsStreams","ReadableStream","supportsFormData","FormData","mergeHeaders","source1","source2","result","Headers","isHeadersInstance","source","delete","set","deepMerge","sources","returnValue","entries","requestMethods","responseTypes","json","text","formData","arrayBuffer","blob","retryMethods","retryStatusCodes","retryAfterStatusCodes","stop","Symbol","HTTPError","request","options","super","statusText","String","TimeoutError","delay","ms","Promise","resolve","setTimeout","timeout","abortController","reject","timeoutID","abort","fetch","then","catch","clearTimeout","normalizeRequestMethod","includes","toUpperCase","defaultRetryOptions","limit","methods","statusCodes","afterStatusCodes","normalizeRetryOptions","maxSafeTimeout","Ky","_retryCount","_input","_options","credentials","hooks","beforeRequest","beforeRetry","afterResponse","method","prefixUrl","throwHttpErrors","Request","startsWith","endsWith","signal","addEventListener","searchParams","replace","URLSearchParams","fn","_fetch","hook","modifiedResponse","_decorateResponse","clone","Response","ok","onDownloadProgress","_stream","toLowerCase","_retry","type","mimeType","get","parseJson","_calculateRetryDelay","retryAfter","after","Number","isNaN","Date","now","maxRetryAfter","Math","min","totalBytes","transferredBytes","controller","reader","getReader","read","done","close","byteLength","percent","enqueue","Uint8Array","validateAndMerge","createInstance","defaults","ky","newDefaults","extend","factory","href","flattie","encode","require$$2","whoops","require$$5","require$$4","statusMessage"],"mappings":"svBAEA,MAAMA,EAAMC,EAAOC,OAASA,OAAOF,IAAMG,UAAeH,IAClDI,EAAsB,yBCH5B,SAASC,EAAKC,EAAQC,EAASC,EAAKC,EAAKC,GACxC,IAAIC,EAAGC,EAAMF,EAAOA,EAAMF,EAAOE,EAEjC,GAAW,MAAPD,EACCF,IAASD,EAAOI,GAAOD,QACrB,GAAkB,iBAAPA,EACjBH,EAAOI,GAAOD,OACR,GAAII,MAAMC,QAAQL,GACxB,IAAKE,EAAE,EAAGA,EAAIF,EAAIM,OAAQJ,IACzBN,EAAKC,EAAQC,EAASC,EAAKC,EAAIE,GAAIC,EAAMD,QAG1C,IAAKA,KAAKF,EACTJ,EAAKC,EAAQC,EAASC,EAAKC,EAAIE,GAAIC,EAAMD,GCO5C,SAASK,EAAQC,GAChB,IAAKA,EAAK,MAAO,GACjB,IAA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AIN,EAASM,QAAQgD,WAAW7D,QACvC,CAACC,GAAMrH,EAAKqC,UAAiBgF,EAAKrH,CAACA,GAAMqC,KACzC,IAEF0F,WAAYJ,EAASc,OACrBZ,WAAYF,EAAS0D,QAGzB,MAAMvD,IASRf,QAAAA,EACAL,QAAS"}
|
|
1
|
+
{"version":3,"file":"mql.min.js","sources":["../node_modules/.pnpm/is-url-http@2.2.5/node_modules/is-url-http/lightweight.js","../node_modules/.pnpm/flattie@1.1.0/node_modules/flattie/dist/index.js","../node_modules/.pnpm/qss@2.0.3/node_modules/qss/dist/qss.m.js","../node_modules/.pnpm/mimic-fn@3.0.0/node_modules/mimic-fn/index.js","../node_modules/.pnpm/whoops@4.1.0/node_modules/whoops/lib/helpers.js","../node_modules/.pnpm/whoops@4.1.0/node_modules/whoops/lib/add-error-props.js","../node_modules/.pnpm/whoops@4.1.0/node_modules/whoops/lib/create-extend-error.js","../node_modules/.pnpm/whoops@4.1.0/node_modules/whoops/lib/create-error.js","../node_modules/.pnpm/whoops@4.1.0/node_modules/whoops/lib/index.js","../src/factory.js","../src/ky.js","../src/browser.js"],"sourcesContent":["'use strict'\n\nconst URL = global.window ? window.URL : require('url').URL\nconst REGEX_HTTP_PROTOCOL = /^https?:\\/\\//i\n\nmodule.exports = url => {\n try {\n return REGEX_HTTP_PROTOCOL.test(new URL(url).href)\n } catch (err) {\n return false\n }\n}\n","function iter(output, nullish, sep, val, key) {\n\tvar k, pfx = key ? (key + sep) : key;\n\n\tif (val == null) {\n\t\tif (nullish) output[key] = val;\n\t} else if (typeof val != 'object') {\n\t\toutput[key] = val;\n\t} else if (Array.isArray(val)) {\n\t\tfor (k=0; k < val.length; k++) {\n\t\t\titer(output, nullish, sep, val[k], pfx + k);\n\t\t}\n\t} else {\n\t\tfor (k in val) {\n\t\t\titer(output, nullish, sep, val[k], pfx + k);\n\t\t}\n\t}\n}\n\nfunction flattie(input, glue, toNull) {\n\tvar output = {};\n\tif (typeof input == 'object') {\n\t\titer(output, !!toNull, glue || '.', input, '');\n\t}\n\treturn output;\n}\n\nexports.flattie = flattie;","export function encode(obj, pfx) {\n\tvar k, i, tmp, str='';\n\n\tfor (k in obj) {\n\t\tif ((tmp = obj[k]) !== void 0) {\n\t\t\tif (Array.isArray(tmp)) {\n\t\t\t\tfor (i=0; i < tmp.length; i++) {\n\t\t\t\t\tstr && (str += '&');\n\t\t\t\t\tstr += encodeURIComponent(k) + '=' + encodeURIComponent(tmp[i]);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tstr && (str += '&');\n\t\t\t\tstr += encodeURIComponent(k) + '=' + encodeURIComponent(tmp);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn (pfx || '') + str;\n}\n\nfunction toValue(mix) {\n\tif (!mix) return '';\n\tvar str = decodeURIComponent(mix);\n\tif (str === 'false') return false;\n\tif (str === 'true') return true;\n\treturn (+str * 0 === 0) ? (+str) : str;\n}\n\nexport function decode(str) {\n\tvar tmp, k, out={}, arr=str.split('&');\n\n\twhile (tmp = arr.shift()) {\n\t\ttmp = tmp.split('=');\n\t\tk = tmp.shift();\n\t\tif (out[k] !== void 0) {\n\t\t\tout[k] = [].concat(out[k], toValue(tmp.shift()));\n\t\t} else {\n\t\t\tout[k] = toValue(tmp.shift());\n\t\t}\n\t}\n\n\treturn out;\n}\n","'use strict';\n\nconst copyProperty = (to, from, property, ignoreNonConfigurable) => {\n\t// `Function#length` should reflect the parameters of `to` not `from` since we keep its body.\n\t// `Function#prototype` is non-writable and non-configurable so can never be modified.\n\tif (property === 'length' || property === 'prototype') {\n\t\treturn;\n\t}\n\n\tconst toDescriptor = Object.getOwnPropertyDescriptor(to, property);\n\tconst fromDescriptor = Object.getOwnPropertyDescriptor(from, property);\n\n\tif (!canCopyProperty(toDescriptor, fromDescriptor) && ignoreNonConfigurable) {\n\t\treturn;\n\t}\n\n\tObject.defineProperty(to, property, fromDescriptor);\n};\n\n// `Object.defineProperty()` throws if the property exists, is not configurable and either:\n// - one its descriptors is changed\n// - it is non-writable and its value is changed\nconst canCopyProperty = function (toDescriptor, fromDescriptor) {\n\treturn toDescriptor === undefined || toDescriptor.configurable || (\n\t\ttoDescriptor.writable === fromDescriptor.writable &&\n\t\ttoDescriptor.enumerable === fromDescriptor.enumerable &&\n\t\ttoDescriptor.configurable === fromDescriptor.configurable &&\n\t\t(toDescriptor.writable || toDescriptor.value === fromDescriptor.value)\n\t);\n};\n\nconst changePrototype = (to, from) => {\n\tconst fromPrototype = Object.getPrototypeOf(from);\n\tif (fromPrototype === Object.getPrototypeOf(to)) {\n\t\treturn;\n\t}\n\n\tObject.setPrototypeOf(to, fromPrototype);\n};\n\nconst wrappedToString = (withName, fromBody) => `/* Wrapped ${withName}*/\\n${fromBody}`;\n\nconst toStringDescriptor = Object.getOwnPropertyDescriptor(Function.prototype, 'toString');\nconst toStringName = Object.getOwnPropertyDescriptor(Function.prototype.toString, 'name');\n\n// We call `from.toString()` early (not lazily) to ensure `from` can be garbage collected.\n// We use `bind()` instead of a closure for the same reason.\n// Calling `from.toString()` early also allows caching it in case `to.toString()` is called several times.\nconst changeToString = (to, from, name) => {\n\tconst withName = name === '' ? '' : `with ${name.trim()}() `;\n\tconst newToString = wrappedToString.bind(null, withName, from.toString());\n\t// Ensure `to.toString.toString` is non-enumerable and has the same `same`\n\tObject.defineProperty(newToString, 'name', toStringName);\n\tObject.defineProperty(to, 'toString', {...toStringDescriptor, value: newToString});\n};\n\nconst mimicFn = (to, from, {ignoreNonConfigurable = false} = {}) => {\n\tconst {name} = to;\n\n\tfor (const property of Reflect.ownKeys(from)) {\n\t\tcopyProperty(to, from, property, ignoreNonConfigurable);\n\t}\n\n\tchangePrototype(to, from);\n\tchangeToString(to, from, name);\n\n\treturn to;\n};\n\nmodule.exports = mimicFn;\n","'use strict'\n\nmodule.exports = {\n isFunction: obj => typeof obj === 'function',\n isString: obj => typeof obj === 'string',\n composeErrorMessage: (code, description) => `${code}, ${description}`,\n inherits: (ctor, superCtor) => {\n ctor.super_ = superCtor\n ctor.prototype = Object.create(superCtor.prototype, {\n constructor: {\n value: ctor,\n enumerable: false,\n writable: true,\n configurable: true\n }\n })\n }\n}\n","'use strict'\n\nconst {isFunction, composeErrorMessage} = require('./helpers')\n\nfunction interfaceObject (error, ...props) {\n Object.assign(error, ...props)\n\n error.description = isFunction(error.message) ? error.message(error) : error.message\n\n error.message = error.code\n ? composeErrorMessage(error.code, error.description)\n : error.description\n}\n\nmodule.exports = interfaceObject\n","'use strict'\n\nconst cleanStack = require('clean-stack')\nconst mimicFn = require('mimic-fn')\n\nconst addErrorProps = require('./add-error-props')\nconst {isString} = require('./helpers')\n\nfunction createExtendError (ErrorClass, classProps) {\n function ExtendError (props) {\n const error = new ErrorClass()\n const errorProps = isString(props) ? {message: props} : props\n addErrorProps(error, classProps, errorProps)\n\n error.stack = cleanStack(error.stack)\n return error\n }\n\n ExtendError.prototype = ErrorClass.prototype\n mimicFn(ExtendError, ErrorClass)\n\n return ExtendError\n}\n\nmodule.exports = createExtendError\n","'use strict'\n\nconst {inherits} = require('./helpers')\nconst mimicFn = require('mimic-fn')\n\nconst REGEX_CLASS_NAME = /[^0-9a-zA-Z_$]/\n\nfunction createError (className) {\n if (typeof className !== 'string') {\n throw new TypeError('Expected className to be a string')\n }\n\n if (REGEX_CLASS_NAME.test(className)) {\n throw new Error('className contains invalid characters')\n }\n\n function ErrorClass () {\n Object.defineProperty(this, 'name', {\n configurable: true,\n value: className,\n writable: true\n })\n\n Error.captureStackTrace(this, this.constructor)\n }\n\n inherits(ErrorClass, Error)\n mimicFn(ErrorClass, Error)\n return ErrorClass\n}\n\nmodule.exports = createError\n","'use strict'\n\nconst createExtendError = require('./create-extend-error')\nconst createError = require('./create-error')\n\nconst createErrorClass = ErrorClass => (className, props) => {\n const errorClass = createError(className || ErrorClass.name)\n return createExtendError(errorClass, props)\n}\n\nmodule.exports = createErrorClass(Error)\nmodule.exports.type = createErrorClass(TypeError)\nmodule.exports.range = createErrorClass(RangeError)\nmodule.exports.eval = createErrorClass(EvalError)\nmodule.exports.syntax = createErrorClass(SyntaxError)\nmodule.exports.reference = createErrorClass(ReferenceError)\nmodule.exports.uri = createErrorClass(URIError)\n","const ENDPOINT = {\n FREE: 'https://api.microlink.io',\n PRO: 'https://pro.microlink.io'\n}\n\nconst isObject = input => input !== null && typeof input === 'object'\n\nconst parseBody = (input, error, url) => {\n try {\n return JSON.parse(input)\n } catch (_) {\n const message = input || error.message\n\n return {\n status: 'error',\n data: { url: message },\n more: 'https://microlink.io/efatalclient',\n code: 'EFATALCLIENT',\n message,\n url\n }\n }\n}\n\nconst factory = ({\n VERSION,\n MicrolinkError,\n isUrlHttp,\n stringify,\n got,\n flatten\n}) => {\n const assertUrl = (url = '') => {\n if (!isUrlHttp(url)) {\n const message = `The \\`url\\` as \\`${url}\\` is not valid. Ensure it has protocol (http or https) and hostname.`\n throw new MicrolinkError({\n status: 'fail',\n data: { url: message },\n more: 'https://microlink.io/docs/api/api-parameters/url',\n code: 'EINVALURLCLIENT',\n message,\n url\n })\n }\n }\n\n const mapRules = rules => {\n if (!isObject(rules)) return\n const flatRules = flatten(rules)\n return Object.keys(flatRules).reduce(\n (acc, key) => ({ ...acc, [`data.${key}`]: flatRules[key].toString() }),\n {}\n )\n }\n\n const fetchFromApi = async (apiUrl, opts = {}, retryCount = 0) => {\n try {\n const response = await got(apiUrl, opts)\n return opts.responseType === 'buffer'\n ? { body: response.body, response }\n : { ...response.body, response }\n } catch (err) {\n const { response = {} } = err\n const { statusCode, body: rawBody, headers, url: uri = apiUrl } = response\n const isBuffer = Buffer.isBuffer(rawBody)\n\n const body =\n isObject(rawBody) && !isBuffer\n ? rawBody\n : parseBody(isBuffer ? rawBody.toString() : rawBody, err, uri)\n\n if (body.code === 'EFATALCLIENT' && retryCount++ < 2) {\n return fetchFromApi(apiUrl, opts, retryCount)\n }\n\n throw MicrolinkError({\n ...body,\n message: body.message,\n url: uri,\n statusCode,\n headers\n })\n }\n }\n\n const getApiUrl = (\n url,\n { data, apiKey, endpoint, retry, cache, ...opts } = {},\n { responseType = 'json', headers: gotHeaders, ...gotOpts } = {}\n ) => {\n const isPro = !!apiKey\n const apiEndpoint = endpoint || ENDPOINT[isPro ? 'PRO' : 'FREE']\n\n const apiUrl = `${apiEndpoint}?${stringify({\n url,\n ...mapRules(data),\n ...flatten(opts)\n })}`\n\n const headers = isPro\n ? { ...gotHeaders, 'x-api-key': apiKey }\n : { ...gotHeaders }\n return [apiUrl, { ...gotOpts, responseType, cache, retry, headers }]\n }\n\n const createMql = defaultOpts => async (url, opts, gotOpts) => {\n assertUrl(url)\n const [apiUrl, fetchOpts] = getApiUrl(url, opts, {\n ...defaultOpts,\n ...gotOpts\n })\n return fetchFromApi(apiUrl, fetchOpts)\n }\n\n const mql = createMql()\n mql.MicrolinkError = MicrolinkError\n mql.getApiUrl = getApiUrl\n mql.fetchFromApi = fetchFromApi\n mql.mapRules = mapRules\n mql.version = VERSION\n mql.stream = got.stream\n mql.buffer = createMql({ responseType: 'buffer' })\n\n return mql\n}\n\nmodule.exports = factory\n","(function (global, factory) {\n\ttypeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :\n\ttypeof define === 'function' && define.amd ? define(factory) :\n\t(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.ky = factory());\n}(this, (function () { 'use strict';\n\n\t/*! MIT License © Sindre Sorhus */\n\n\tconst isObject = value => value !== null && typeof value === 'object';\n\tconst supportsAbortController = typeof globalThis.AbortController === 'function';\n\tconst supportsStreams = typeof globalThis.ReadableStream === 'function';\n\tconst supportsFormData = typeof globalThis.FormData === 'function';\n\n\tconst mergeHeaders = (source1, source2) => {\n\t\tconst result = new globalThis.Headers(source1 || {});\n\t\tconst isHeadersInstance = source2 instanceof globalThis.Headers;\n\t\tconst source = new globalThis.Headers(source2 || {});\n\n\t\tfor (const [key, value] of source) {\n\t\t\tif ((isHeadersInstance && value === 'undefined') || value === undefined) {\n\t\t\t\tresult.delete(key);\n\t\t\t} else {\n\t\t\t\tresult.set(key, value);\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t};\n\n\tconst deepMerge = (...sources) => {\n\t\tlet returnValue = {};\n\t\tlet headers = {};\n\n\t\tfor (const source of sources) {\n\t\t\tif (Array.isArray(source)) {\n\t\t\t\tif (!(Array.isArray(returnValue))) {\n\t\t\t\t\treturnValue = [];\n\t\t\t\t}\n\n\t\t\t\treturnValue = [...returnValue, ...source];\n\t\t\t} else if (isObject(source)) {\n\t\t\t\tfor (let [key, value] of Object.entries(source)) {\n\t\t\t\t\tif (isObject(value) && (key in returnValue)) {\n\t\t\t\t\t\tvalue = deepMerge(returnValue[key], value);\n\t\t\t\t\t}\n\n\t\t\t\t\treturnValue = {...returnValue, [key]: value};\n\t\t\t\t}\n\n\t\t\t\tif (isObject(source.headers)) {\n\t\t\t\t\theaders = mergeHeaders(headers, source.headers);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturnValue.headers = headers;\n\t\t}\n\n\t\treturn returnValue;\n\t};\n\n\tconst requestMethods = [\n\t\t'get',\n\t\t'post',\n\t\t'put',\n\t\t'patch',\n\t\t'head',\n\t\t'delete'\n\t];\n\n\tconst responseTypes = {\n\t\tjson: 'application/json',\n\t\ttext: 'text/*',\n\t\tformData: 'multipart/form-data',\n\t\tarrayBuffer: '*/*',\n\t\tblob: '*/*'\n\t};\n\n\tconst retryMethods = [\n\t\t'get',\n\t\t'put',\n\t\t'head',\n\t\t'delete',\n\t\t'options',\n\t\t'trace'\n\t];\n\n\tconst retryStatusCodes = [\n\t\t408,\n\t\t413,\n\t\t429,\n\t\t500,\n\t\t502,\n\t\t503,\n\t\t504\n\t];\n\n\tconst retryAfterStatusCodes = [\n\t\t413,\n\t\t429,\n\t\t503\n\t];\n\n\tconst stop = Symbol('stop');\n\n\tclass HTTPError extends Error {\n\t\tconstructor(response, request, options) {\n\t\t\t// Set the message to the status text, such as Unauthorized,\n\t\t\t// with some fallbacks. This message should never be undefined.\n\t\t\tsuper(\n\t\t\t\tresponse.statusText ||\n\t\t\t\tString(\n\t\t\t\t\t(response.status === 0 || response.status) ?\n\t\t\t\t\t\tresponse.status : 'Unknown response error'\n\t\t\t\t)\n\t\t\t);\n\t\t\tthis.name = 'HTTPError';\n\t\t\tthis.response = response;\n\t\t\tthis.request = request;\n\t\t\tthis.options = options;\n\t\t}\n\t}\n\n\tclass TimeoutError extends Error {\n\t\tconstructor(request) {\n\t\t\tsuper('Request timed out');\n\t\t\tthis.name = 'TimeoutError';\n\t\t\tthis.request = request;\n\t\t}\n\t}\n\n\tconst delay = ms => new Promise(resolve => setTimeout(resolve, ms));\n\n\t// `Promise.race()` workaround (#91)\n\tconst timeout = (request, abortController, options) =>\n\t\tnew Promise((resolve, reject) => {\n\t\t\tconst timeoutID = setTimeout(() => {\n\t\t\t\tif (abortController) {\n\t\t\t\t\tabortController.abort();\n\t\t\t\t}\n\n\t\t\t\treject(new TimeoutError(request));\n\t\t\t}, options.timeout);\n\n\t\t\t/* eslint-disable promise/prefer-await-to-then */\n\t\t\toptions.fetch(request)\n\t\t\t\t.then(resolve)\n\t\t\t\t.catch(reject)\n\t\t\t\t.then(() => {\n\t\t\t\t\tclearTimeout(timeoutID);\n\t\t\t\t});\n\t\t\t/* eslint-enable promise/prefer-await-to-then */\n\t\t});\n\n\tconst normalizeRequestMethod = input => requestMethods.includes(input) ? input.toUpperCase() : input;\n\n\tconst defaultRetryOptions = {\n\t\tlimit: 2,\n\t\tmethods: retryMethods,\n\t\tstatusCodes: retryStatusCodes,\n\t\tafterStatusCodes: retryAfterStatusCodes\n\t};\n\n\tconst normalizeRetryOptions = (retry = {}) => {\n\t\tif (typeof retry === 'number') {\n\t\t\treturn {\n\t\t\t\t...defaultRetryOptions,\n\t\t\t\tlimit: retry\n\t\t\t};\n\t\t}\n\n\t\tif (retry.methods && !Array.isArray(retry.methods)) {\n\t\t\tthrow new Error('retry.methods must be an array');\n\t\t}\n\n\t\tif (retry.statusCodes && !Array.isArray(retry.statusCodes)) {\n\t\t\tthrow new Error('retry.statusCodes must be an array');\n\t\t}\n\n\t\treturn {\n\t\t\t...defaultRetryOptions,\n\t\t\t...retry,\n\t\t\tafterStatusCodes: retryAfterStatusCodes\n\t\t};\n\t};\n\n\t// The maximum value of a 32bit int (see issue #117)\n\tconst maxSafeTimeout = 2147483647;\n\n\tclass Ky {\n\t\tconstructor(input, options = {}) {\n\t\t\tthis._retryCount = 0;\n\t\t\tthis._input = input;\n\t\t\tthis._options = {\n\t\t\t\t// TODO: credentials can be removed when the spec change is implemented in all browsers. Context: https://www.chromestatus.com/feature/4539473312350208\n\t\t\t\tcredentials: this._input.credentials || 'same-origin',\n\t\t\t\t...options,\n\t\t\t\theaders: mergeHeaders(this._input.headers, options.headers),\n\t\t\t\thooks: deepMerge({\n\t\t\t\t\tbeforeRequest: [],\n\t\t\t\t\tbeforeRetry: [],\n\t\t\t\t\tafterResponse: []\n\t\t\t\t}, options.hooks),\n\t\t\t\tmethod: normalizeRequestMethod(options.method || this._input.method),\n\t\t\t\tprefixUrl: String(options.prefixUrl || ''),\n\t\t\t\tretry: normalizeRetryOptions(options.retry),\n\t\t\t\tthrowHttpErrors: options.throwHttpErrors !== false,\n\t\t\t\ttimeout: typeof options.timeout === 'undefined' ? 10000 : options.timeout,\n\t\t\t\tfetch: options.fetch || globalThis.fetch.bind(globalThis)\n\t\t\t};\n\n\t\t\tif (typeof this._input !== 'string' && !(this._input instanceof URL || this._input instanceof globalThis.Request)) {\n\t\t\t\tthrow new TypeError('`input` must be a string, URL, or Request');\n\t\t\t}\n\n\t\t\tif (this._options.prefixUrl && typeof this._input === 'string') {\n\t\t\t\tif (this._input.startsWith('/')) {\n\t\t\t\t\tthrow new Error('`input` must not begin with a slash when using `prefixUrl`');\n\t\t\t\t}\n\n\t\t\t\tif (!this._options.prefixUrl.endsWith('/')) {\n\t\t\t\t\tthis._options.prefixUrl += '/';\n\t\t\t\t}\n\n\t\t\t\tthis._input = this._options.prefixUrl + this._input;\n\t\t\t}\n\n\t\t\tif (supportsAbortController) {\n\t\t\t\tthis.abortController = new globalThis.AbortController();\n\t\t\t\tif (this._options.signal) {\n\t\t\t\t\tthis._options.signal.addEventListener('abort', () => {\n\t\t\t\t\t\tthis.abortController.abort();\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tthis._options.signal = this.abortController.signal;\n\t\t\t}\n\n\t\t\tthis.request = new globalThis.Request(this._input, this._options);\n\n\t\t\tif (this._options.searchParams) {\n\t\t\t\tconst textSearchParams = typeof this._options.searchParams === 'string' ?\n\t\t\t\t\tthis._options.searchParams.replace(/^\\?/, '') :\n\t\t\t\t\tnew URLSearchParams(this._options.searchParams).toString();\n\t\t\t\tconst searchParams = '?' + textSearchParams;\n\t\t\t\tconst url = this.request.url.replace(/(?:\\?.*?)?(?=#|$)/, searchParams);\n\n\t\t\t\t// To provide correct form boundary, Content-Type header should be deleted each time when new Request instantiated from another one\n\t\t\t\tif (((supportsFormData && this._options.body instanceof globalThis.FormData) || this._options.body instanceof URLSearchParams) && !(this._options.headers && this._options.headers['content-type'])) {\n\t\t\t\t\tthis.request.headers.delete('content-type');\n\t\t\t\t}\n\n\t\t\t\tthis.request = new globalThis.Request(new globalThis.Request(url, this.request), this._options);\n\t\t\t}\n\n\t\t\tif (this._options.json !== undefined) {\n\t\t\t\tthis._options.body = JSON.stringify(this._options.json);\n\t\t\t\tthis.request.headers.set('content-type', 'application/json');\n\t\t\t\tthis.request = new globalThis.Request(this.request, {body: this._options.body});\n\t\t\t}\n\n\t\t\tconst fn = async () => {\n\t\t\t\tif (this._options.timeout > maxSafeTimeout) {\n\t\t\t\t\tthrow new RangeError(`The \\`timeout\\` option cannot be greater than ${maxSafeTimeout}`);\n\t\t\t\t}\n\n\t\t\t\tawait delay(1);\n\t\t\t\tlet response = await this._fetch();\n\n\t\t\t\tfor (const hook of this._options.hooks.afterResponse) {\n\t\t\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\t\t\tconst modifiedResponse = await hook(\n\t\t\t\t\t\tthis.request,\n\t\t\t\t\t\tthis._options,\n\t\t\t\t\t\tthis._decorateResponse(response.clone())\n\t\t\t\t\t);\n\n\t\t\t\t\tif (modifiedResponse instanceof globalThis.Response) {\n\t\t\t\t\t\tresponse = modifiedResponse;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tthis._decorateResponse(response);\n\n\t\t\t\tif (!response.ok && this._options.throwHttpErrors) {\n\t\t\t\t\tthrow new HTTPError(response, this.request, this._options);\n\t\t\t\t}\n\n\t\t\t\t// If `onDownloadProgress` is passed, it uses the stream API internally\n\t\t\t\t/* istanbul ignore next */\n\t\t\t\tif (this._options.onDownloadProgress) {\n\t\t\t\t\tif (typeof this._options.onDownloadProgress !== 'function') {\n\t\t\t\t\t\tthrow new TypeError('The `onDownloadProgress` option must be a function');\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!supportsStreams) {\n\t\t\t\t\t\tthrow new Error('Streams are not supported in your environment. `ReadableStream` is missing.');\n\t\t\t\t\t}\n\n\t\t\t\t\treturn this._stream(response.clone(), this._options.onDownloadProgress);\n\t\t\t\t}\n\n\t\t\t\treturn response;\n\t\t\t};\n\n\t\t\tconst isRetriableMethod = this._options.retry.methods.includes(this.request.method.toLowerCase());\n\t\t\tconst result = isRetriableMethod ? this._retry(fn) : fn();\n\n\t\t\tfor (const [type, mimeType] of Object.entries(responseTypes)) {\n\t\t\t\tresult[type] = async () => {\n\t\t\t\t\tthis.request.headers.set('accept', this.request.headers.get('accept') || mimeType);\n\n\t\t\t\t\tconst response = (await result).clone();\n\n\t\t\t\t\tif (type === 'json') {\n\t\t\t\t\t\tif (response.status === 204) {\n\t\t\t\t\t\t\treturn '';\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (options.parseJson) {\n\t\t\t\t\t\t\treturn options.parseJson(await response.text());\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\treturn response[type]();\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn result;\n\t\t}\n\n\t\t_calculateRetryDelay(error) {\n\t\t\tthis._retryCount++;\n\n\t\t\tif (this._retryCount < this._options.retry.limit && !(error instanceof TimeoutError)) {\n\t\t\t\tif (error instanceof HTTPError) {\n\t\t\t\t\tif (!this._options.retry.statusCodes.includes(error.response.status)) {\n\t\t\t\t\t\treturn 0;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst retryAfter = error.response.headers.get('Retry-After');\n\t\t\t\t\tif (retryAfter && this._options.retry.afterStatusCodes.includes(error.response.status)) {\n\t\t\t\t\t\tlet after = Number(retryAfter);\n\t\t\t\t\t\tif (Number.isNaN(after)) {\n\t\t\t\t\t\t\tafter = Date.parse(retryAfter) - Date.now();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tafter *= 1000;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (typeof this._options.retry.maxRetryAfter !== 'undefined' && after > this._options.retry.maxRetryAfter) {\n\t\t\t\t\t\t\treturn 0;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn after;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (error.response.status === 413) {\n\t\t\t\t\t\treturn 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst BACKOFF_FACTOR = 0.3;\n\t\t\t\treturn BACKOFF_FACTOR * (2 ** (this._retryCount - 1)) * 1000;\n\t\t\t}\n\n\t\t\treturn 0;\n\t\t}\n\n\t\t_decorateResponse(response) {\n\t\t\tif (this._options.parseJson) {\n\t\t\t\tresponse.json = async () => {\n\t\t\t\t\treturn this._options.parseJson(await response.text());\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn response;\n\t\t}\n\n\t\tasync _retry(fn) {\n\t\t\ttry {\n\t\t\t\treturn await fn();\n\t\t\t} catch (error) {\n\t\t\t\tconst ms = Math.min(this._calculateRetryDelay(error), maxSafeTimeout);\n\t\t\t\tif (ms !== 0 && this._retryCount > 0) {\n\t\t\t\t\tawait delay(ms);\n\n\t\t\t\t\tfor (const hook of this._options.hooks.beforeRetry) {\n\t\t\t\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\t\t\t\tconst hookResult = await hook({\n\t\t\t\t\t\t\trequest: this.request,\n\t\t\t\t\t\t\toptions: this._options,\n\t\t\t\t\t\t\terror,\n\t\t\t\t\t\t\tretryCount: this._retryCount\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\t// If `stop` is returned from the hook, the retry process is stopped\n\t\t\t\t\t\tif (hookResult === stop) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\treturn this._retry(fn);\n\t\t\t\t}\n\n\t\t\t\tif (this._options.throwHttpErrors) {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tasync _fetch() {\n\t\t\tfor (const hook of this._options.hooks.beforeRequest) {\n\t\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\t\tconst result = await hook(this.request, this._options);\n\n\t\t\t\tif (result instanceof Request) {\n\t\t\t\t\tthis.request = result;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tif (result instanceof Response) {\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (this._options.timeout === false) {\n\t\t\t\treturn this._options.fetch(this.request.clone());\n\t\t\t}\n\n\t\t\treturn timeout(this.request.clone(), this.abortController, this._options);\n\t\t}\n\n\t\t/* istanbul ignore next */\n\t\t_stream(response, onDownloadProgress) {\n\t\t\tconst totalBytes = Number(response.headers.get('content-length')) || 0;\n\t\t\tlet transferredBytes = 0;\n\n\t\t\treturn new globalThis.Response(\n\t\t\t\tnew globalThis.ReadableStream({\n\t\t\t\t\tasync start(controller) {\n\t\t\t\t\t\tconst reader = response.body.getReader();\n\n\t\t\t\t\t\tif (onDownloadProgress) {\n\t\t\t\t\t\t\tonDownloadProgress({percent: 0, transferredBytes: 0, totalBytes}, new Uint8Array());\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tasync function read() {\n\t\t\t\t\t\t\tconst {done, value} = await reader.read();\n\t\t\t\t\t\t\tif (done) {\n\t\t\t\t\t\t\t\tcontroller.close();\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (onDownloadProgress) {\n\t\t\t\t\t\t\t\ttransferredBytes += value.byteLength;\n\t\t\t\t\t\t\t\tconst percent = totalBytes === 0 ? 0 : transferredBytes / totalBytes;\n\t\t\t\t\t\t\t\tonDownloadProgress({percent, transferredBytes, totalBytes}, value);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tcontroller.enqueue(value);\n\t\t\t\t\t\t\tawait read();\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tawait read();\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t);\n\t\t}\n\t}\n\n\tconst validateAndMerge = (...sources) => {\n\t\tfor (const source of sources) {\n\t\t\tif ((!isObject(source) || Array.isArray(source)) && typeof source !== 'undefined') {\n\t\t\t\tthrow new TypeError('The `options` argument must be an object');\n\t\t\t}\n\t\t}\n\n\t\treturn deepMerge({}, ...sources);\n\t};\n\n\tconst createInstance = defaults => {\n\t\tconst ky = (input, options) => new Ky(input, validateAndMerge(defaults, options));\n\n\t\tfor (const method of requestMethods) {\n\t\t\tky[method] = (input, options) => new Ky(input, validateAndMerge(defaults, options, {method}));\n\t\t}\n\n\t\tky.HTTPError = HTTPError;\n\t\tky.TimeoutError = TimeoutError;\n\t\tky.create = newDefaults => createInstance(validateAndMerge(newDefaults));\n\t\tky.extend = newDefaults => createInstance(validateAndMerge(defaults, newDefaults));\n\t\tky.stop = stop;\n\n\t\treturn ky;\n\t};\n\n\tconst ky = createInstance();\n\n\treturn ky;\n\n})));\n","'use strict'\n\nconst isUrlHttp = require('is-url-http/lightweight')\nconst { flattie: flatten } = require('flattie')\nconst { encode: stringify } = require('qss')\nconst whoops = require('whoops')\n\nconst factory = require('./factory')\nconst ky = require('./ky')\n\nconst MicrolinkError = whoops('MicrolinkError')\n\nconst got = async (url, opts) => {\n try {\n if (opts.timeout === undefined) opts.timeout = false\n const response = await ky(url, opts)\n const body = await response.json()\n const { headers, status: statusCode, statusText: statusMessage } = response\n return { url: response.url, body, headers, statusCode, statusMessage }\n } catch (err) {\n if (err.response) {\n const { response } = err\n err.response = {\n ...response,\n headers: [...response.headers.entries()].reduce(\n (acc, [key, value]) => ({ ...acc, [key]: value }),\n {}\n ),\n statusCode: response.status,\n body: await response.text()\n }\n }\n throw err\n }\n}\n\nmodule.exports = factory({\n MicrolinkError,\n isUrlHttp,\n stringify,\n got,\n flatten,\n VERSION: '__MQL_VERSION__'\n})\n"],"names":["URL","global","window","require$$0","REGEX_HTTP_PROTOCOL","iter","output","nullish","sep","val","key","k","pfx","Array","isArray","length","toValue","mix","str","decodeURIComponent","input","glue","toNull","obj","i","tmp","encodeURIComponent","out","arr","split","shift","concat","copyProperty","to","from","property","ignoreNonConfigurable","toDescriptor","Object","getOwnPropertyDescriptor","fromDescriptor","canCopyProperty","defineProperty","undefined","configurable","writable","enumerable","value","wrappedToString","withName","fromBody","toStringDescriptor","Function","prototype","toStringName","toString","mimicFn_1","name","Reflect","ownKeys","fromPrototype","getPrototypeOf","setPrototypeOf","changePrototype","trim","newToString","bind","changeToString","helpers","isFunction","isString","composeErrorMessage","code","description","inherits","ctor","superCtor","super_","create","constructor","cleanStack","mimicFn","require$$1","addErrorProps","error","props","assign","message","require$$3","createExtendError_1","ErrorClass","classProps","ExtendError","errorProps","stack","REGEX_CLASS_NAME","createExtendError","createError","className","TypeError","test","Error","this","captureStackTrace","createErrorClass","errorClass","RangeError","EvalError","SyntaxError","ReferenceError","URIError","ENDPOINT","FREE","PRO","isObject","factory_1","VERSION","MicrolinkError","isUrlHttp","stringify","got","flatten","mapRules","rules","flatRules","keys","reduce","acc","fetchFromApi","async","apiUrl","opts","retryCount","response","responseType","body","err","statusCode","rawBody","headers","url","uri","isBuffer","Buffer","JSON","parse","_","status","data","more","parseBody","getApiUrl","apiKey","endpoint","retry","cache","gotHeaders","gotOpts","isPro","createMql","defaultOpts","assertUrl","fetchOpts","mql","version","stream","buffer","module","supportsAbortController","globalThis","AbortController","supportsStreams","ReadableStream","supportsFormData","FormData","mergeHeaders","source1","source2","result","Headers","isHeadersInstance","source","delete","set","deepMerge","sources","returnValue","entries","requestMethods","responseTypes","json","text","formData","arrayBuffer","blob","retryMethods","retryStatusCodes","retryAfterStatusCodes","stop","Symbol","HTTPError","request","options","super","statusText","String","TimeoutError","delay","ms","Promise","resolve","setTimeout","timeout","abortController","reject","timeoutID","abort","fetch","then","catch","clearTimeout","normalizeRequestMethod","includes","toUpperCase","defaultRetryOptions","limit","methods","statusCodes","afterStatusCodes","normalizeRetryOptions","maxSafeTimeout","Ky","_retryCount","_input","_options","credentials","hooks","beforeRequest","beforeRetry","afterResponse","method","prefixUrl","throwHttpErrors","Request","startsWith","endsWith","signal","addEventListener","searchParams","replace","URLSearchParams","fn","_fetch","hook","modifiedResponse","_decorateResponse","clone","Response","ok","onDownloadProgress","_stream","toLowerCase","_retry","type","mimeType","get","parseJson","_calculateRetryDelay","retryAfter","after","Number","isNaN","Date","now","maxRetryAfter","Math","min","totalBytes","transferredBytes","controller","reader","getReader","read","done","close","byteLength","percent","enqueue","Uint8Array","validateAndMerge","createInstance","defaults","ky","newDefaults","extend","factory","href","flattie","encode","require$$2","whoops","require$$5","require$$4","statusMessage"],"mappings":"svBAEA,MAAMA,EAAMC,EAAOC,OAASA,OAAOF,IAAMG,UAAeH,IAClDI,EAAsB,yBCH5B,SAASC,EAAKC,EAAQC,EAASC,EAAKC,EAAKC,GACxC,IAAIC,EAAGC,EAAMF,EAAOA,EAAMF,EAAOE,EAEjC,GAAW,MAAPD,EACCF,IAASD,EAAOI,GAAOD,QACrB,GAAkB,iBAAPA,EACjBH,EAAOI,GAAOD,OACR,GAAII,MAAMC,QAAQL,GACxB,IAAKE,EAAE,EAAGA,EAAIF,EAAIM,OAAQJ,IACzBN,EAAKC,E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AkB1K,EACnE,MAAO,CAAEO,IAAKP,EAASO,IAAKL,KAAAA,EAAMI,QAAAA,EAASF,WAAAA,EAAYsK,cAAAA,GACvD,MAAOvK,GACP,GAAIA,EAAIH,SAAU,CAChB,MAAMA,SAAEA,GAAaG,EACrBA,EAAIH,SAAW,IACVA,EACHM,QAAS,IAAIN,EAASM,QAAQgD,WAAW7D,QACvC,CAACC,GAAMrH,EAAKqC,UAAiBgF,EAAKrH,CAACA,GAAMqC,KACzC,IAEF0F,WAAYJ,EAASc,OACrBZ,WAAYF,EAAS0D,QAGzB,MAAMvD,IASRf,QAAAA,EACAL,QAAS"}
|
package/index.d.ts
CHANGED
|
@@ -1,29 +1,39 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
|
|
3
3
|
declare module "@microlink/mql" {
|
|
4
|
-
export type WaitUntilEvent =
|
|
5
|
-
| "load"
|
|
6
|
-
| "domcontentloaded"
|
|
7
|
-
| "networkidle0"
|
|
8
|
-
| "networkidle2";
|
|
4
|
+
export type WaitUntilEvent = "load" | "domcontentloaded" | "networkidle0" | "networkidle2";
|
|
9
5
|
|
|
10
|
-
export type
|
|
11
|
-
background: string;
|
|
12
|
-
browser: "light" | "dark";
|
|
6
|
+
export type AssetOptions = Partial<{
|
|
13
7
|
click: string | string[];
|
|
14
|
-
deviceScaleFactor: number;
|
|
15
8
|
disableAnimations: boolean;
|
|
16
|
-
|
|
17
|
-
fullPage: boolean;
|
|
18
|
-
hasTouch: boolean;
|
|
19
|
-
height: number;
|
|
9
|
+
filename: string;
|
|
20
10
|
hide: string | string[];
|
|
21
|
-
isLandscape: boolean;
|
|
22
|
-
isMobile: boolean;
|
|
23
11
|
scrollTo: string;
|
|
24
|
-
|
|
12
|
+
viewport: object;
|
|
25
13
|
waitFor: number | string;
|
|
14
|
+
waitForSelector: string;
|
|
15
|
+
waitForTimeout: number;
|
|
26
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;
|
|
27
37
|
width: number;
|
|
28
38
|
}>;
|
|
29
39
|
|
|
@@ -38,10 +48,12 @@ declare module "@microlink/mql" {
|
|
|
38
48
|
| "image"
|
|
39
49
|
| "ip"
|
|
40
50
|
| "lang"
|
|
51
|
+
| "lang"
|
|
41
52
|
| "logo"
|
|
42
53
|
| "number"
|
|
43
54
|
| "object"
|
|
44
55
|
| "publisher"
|
|
56
|
+
| "publisher"
|
|
45
57
|
| "regexp"
|
|
46
58
|
| "string"
|
|
47
59
|
| "title"
|
|
@@ -50,36 +62,38 @@ declare module "@microlink/mql" {
|
|
|
50
62
|
|
|
51
63
|
export type MqlQueryOptions = Partial<{
|
|
52
64
|
attr: string | string[];
|
|
65
|
+
evaluate: string | (() => string)
|
|
53
66
|
selector: string | string[];
|
|
54
|
-
evaluate: string | function;
|
|
55
67
|
selectorAll: string | string[];
|
|
56
68
|
type: MqlQueryResponseType;
|
|
57
69
|
}>;
|
|
58
70
|
|
|
59
71
|
export interface MqlQuery {
|
|
60
|
-
[field: string]: MqlQueryOptions
|
|
72
|
+
[field: string]: MqlQueryOptions;
|
|
61
73
|
}
|
|
62
74
|
|
|
63
75
|
export type MicrolinkApiOptions = Partial<{
|
|
76
|
+
adblock: boolean;
|
|
64
77
|
animations: boolean;
|
|
65
78
|
audio: boolean;
|
|
66
79
|
click: string | string[];
|
|
67
|
-
colorScheme: "dark" | "light";
|
|
68
80
|
codeScheme: string;
|
|
81
|
+
colorScheme: "dark" | "light";
|
|
69
82
|
data: MqlQuery;
|
|
70
83
|
device: string;
|
|
71
84
|
embed: string;
|
|
72
85
|
filter: string;
|
|
73
86
|
force: boolean;
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
iframe: boolean |
|
|
77
|
-
insights: boolean | object
|
|
87
|
+
function: string;
|
|
88
|
+
headers: Record<string, unknown>;
|
|
89
|
+
iframe: boolean | Record<"maxwidth" | "maxheight", number>;
|
|
90
|
+
insights: boolean | Partial<{ lighthouse: boolean | object, technologies: boolean }>;
|
|
78
91
|
javascript: boolean;
|
|
79
|
-
|
|
92
|
+
mediaType: string;
|
|
80
93
|
meta: boolean;
|
|
81
94
|
modules: string | string[];
|
|
82
95
|
palette: boolean;
|
|
96
|
+
pdf: boolean | PdfOptions;
|
|
83
97
|
ping: boolean | object;
|
|
84
98
|
prerender: boolean | "auto";
|
|
85
99
|
proxy: string;
|
|
@@ -88,15 +102,12 @@ declare module "@microlink/mql" {
|
|
|
88
102
|
screenshot: boolean | ScreenshotOptions;
|
|
89
103
|
scripts: string | string[];
|
|
90
104
|
scroll: string;
|
|
105
|
+
staleTtl: string | number;
|
|
91
106
|
styles: string | string[];
|
|
92
107
|
timeout: number;
|
|
93
108
|
ttl: string | number;
|
|
94
109
|
url: string;
|
|
95
110
|
video: boolean;
|
|
96
|
-
viewport: object;
|
|
97
|
-
waitForSelector: string;
|
|
98
|
-
waitForTimeout: number;
|
|
99
|
-
waitUntil: string | string[];
|
|
100
111
|
}>;
|
|
101
112
|
|
|
102
113
|
export type MqlOptions = Partial<{
|
|
@@ -107,33 +118,83 @@ declare module "@microlink/mql" {
|
|
|
107
118
|
timeout: number;
|
|
108
119
|
}>;
|
|
109
120
|
|
|
110
|
-
export interface
|
|
111
|
-
width: number;
|
|
112
|
-
height: number;
|
|
113
|
-
type: string;
|
|
121
|
+
export interface BaseMediaInfo {
|
|
114
122
|
url: string;
|
|
123
|
+
// file type extension.
|
|
124
|
+
type: string;
|
|
125
|
+
// file size in bytes.
|
|
115
126
|
size: number;
|
|
127
|
+
// file size in a human readable format.
|
|
116
128
|
size_pretty: string;
|
|
117
129
|
}
|
|
118
130
|
|
|
119
|
-
export interface PlayableMediaInfo
|
|
131
|
+
export interface PlayableMediaInfo {
|
|
132
|
+
// source duration in seconds.
|
|
120
133
|
duration: number;
|
|
134
|
+
// source duration in a human readable format.
|
|
121
135
|
duration_pretty: string;
|
|
122
136
|
}
|
|
123
137
|
|
|
138
|
+
export interface VisualMediaInfo {
|
|
139
|
+
// file width in pixels.
|
|
140
|
+
width: number;
|
|
141
|
+
// file height in pixels.
|
|
142
|
+
height: number;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export interface AudioInfo extends BaseMediaInfo, PlayableMediaInfo {
|
|
146
|
+
// TODO make this a complete type
|
|
147
|
+
type: "mp3" | string;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export interface ImageInfo extends BaseMediaInfo, VisualMediaInfo {
|
|
151
|
+
// TODO make this a complete type
|
|
152
|
+
type: "png" | "jpg" | string;
|
|
153
|
+
palette: string[];
|
|
154
|
+
background_color: string;
|
|
155
|
+
color: string;
|
|
156
|
+
alternative_color: string;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export interface VideoInfo extends BaseMediaInfo, PlayableMediaInfo, VisualMediaInfo {
|
|
160
|
+
// TODO make this a complete type
|
|
161
|
+
type: "mp4" | string;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export interface IframeInfo {
|
|
165
|
+
html: string;
|
|
166
|
+
scripts: Record<string, unknown>;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export type MqlFunctionResult = {
|
|
170
|
+
isFulfilled: boolean;
|
|
171
|
+
isRejected: boolean;
|
|
172
|
+
value: any;
|
|
173
|
+
};
|
|
174
|
+
|
|
124
175
|
export type MqlResponseData = Partial<{
|
|
125
|
-
author
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
publisher
|
|
130
|
-
|
|
176
|
+
// A human-readable representation of the author's name.
|
|
177
|
+
author: string | null;
|
|
178
|
+
// An ISO 8601 representation of the date the article was published.
|
|
179
|
+
date: string | null;
|
|
180
|
+
// The publisher's chosen description of the article.
|
|
181
|
+
description: string | null;
|
|
182
|
+
// An ISO 639-1 representation of the url content language.
|
|
183
|
+
lang: string | null;
|
|
184
|
+
// An image URL that best represents the publisher brand.
|
|
185
|
+
logo: ImageInfo | null;
|
|
186
|
+
// A human-readable representation of the publisher's name.
|
|
187
|
+
publisher: string | null;
|
|
188
|
+
// The publisher's chosen title of the article.
|
|
189
|
+
title: string | null;
|
|
190
|
+
// The URL of the article.
|
|
131
191
|
url: string;
|
|
132
|
-
image: ImageInfo;
|
|
133
|
-
screenshot: ImageInfo;
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
192
|
+
image: ImageInfo | null;
|
|
193
|
+
screenshot: ImageInfo | null;
|
|
194
|
+
video: VideoInfo | null;
|
|
195
|
+
audio: AudioInfo | null;
|
|
196
|
+
iframe: IframeInfo | null;
|
|
197
|
+
function: MqlFunctionResult;
|
|
137
198
|
}>;
|
|
138
199
|
|
|
139
200
|
export type MqlStatus = "success" | "fail";
|
|
@@ -146,7 +207,10 @@ declare module "@microlink/mql" {
|
|
|
146
207
|
// import { ServerResponse} from 'http';
|
|
147
208
|
// - Under browser, It will be global `Response`
|
|
148
209
|
response: {
|
|
149
|
-
headers: { [key: string]: string }
|
|
210
|
+
headers: { [key: string]: string };
|
|
211
|
+
body?: {
|
|
212
|
+
statusCode?: number;
|
|
213
|
+
};
|
|
150
214
|
};
|
|
151
215
|
}
|
|
152
216
|
|
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.10",
|
|
6
6
|
"browser": "src/browser.js",
|
|
7
7
|
"main": "src/node.js",
|
|
8
8
|
"author": {
|
|
@@ -18,6 +18,10 @@
|
|
|
18
18
|
{
|
|
19
19
|
"name": "ndom91",
|
|
20
20
|
"email": "yo@ndo.dev"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"name": "Gabe O'Leary",
|
|
24
|
+
"email": "oleary.gabe@gmail.com"
|
|
21
25
|
}
|
|
22
26
|
],
|
|
23
27
|
"repository": {
|
|
@@ -46,6 +50,7 @@
|
|
|
46
50
|
"@commitlint/config-conventional": "latest",
|
|
47
51
|
"@rollup/plugin-commonjs": "latest",
|
|
48
52
|
"@rollup/plugin-node-resolve": "latest",
|
|
53
|
+
"@rollup/plugin-replace": "latest",
|
|
49
54
|
"abort-controller": "latest",
|
|
50
55
|
"ava": "latest",
|
|
51
56
|
"beauty-error": "latest",
|
|
@@ -58,15 +63,14 @@
|
|
|
58
63
|
"git-authors-cli": "latest",
|
|
59
64
|
"git-dirty": "latest",
|
|
60
65
|
"ky": "latest",
|
|
61
|
-
"lint-staged": "latest",
|
|
62
66
|
"meow": "latest",
|
|
67
|
+
"nano-staged": "latest",
|
|
63
68
|
"node-fetch": "2",
|
|
64
69
|
"npm-check-updates": "latest",
|
|
65
70
|
"nyc": "latest",
|
|
66
71
|
"prettier-standard": "latest",
|
|
67
72
|
"rollup": "latest",
|
|
68
73
|
"rollup-plugin-filesize": "latest",
|
|
69
|
-
"rollup-plugin-replace": "latest",
|
|
70
74
|
"rollup-plugin-shim": "latest",
|
|
71
75
|
"rollup-plugin-terser": "latest",
|
|
72
76
|
"rollup-plugin-visualizer": "latest",
|
|
@@ -121,20 +125,20 @@
|
|
|
121
125
|
"@commitlint/config-conventional"
|
|
122
126
|
]
|
|
123
127
|
},
|
|
124
|
-
"
|
|
125
|
-
"package.json": [
|
|
126
|
-
"finepack --sort-ignore-object-at ava"
|
|
127
|
-
],
|
|
128
|
+
"nano-staged": {
|
|
128
129
|
"*.js,!*.min.js,": [
|
|
129
130
|
"prettier-standard"
|
|
130
131
|
],
|
|
131
132
|
"*.md": [
|
|
132
133
|
"standard-markdown"
|
|
134
|
+
],
|
|
135
|
+
"package.json": [
|
|
136
|
+
"finepack --sort-ignore-object-at ava"
|
|
133
137
|
]
|
|
134
138
|
},
|
|
135
139
|
"simple-git-hooks": {
|
|
136
140
|
"commit-msg": "npx commitlint --edit",
|
|
137
|
-
"pre-commit": "npx
|
|
141
|
+
"pre-commit": "npx nano-staged"
|
|
138
142
|
},
|
|
139
143
|
"standard": {
|
|
140
144
|
"ignore": [
|
package/src/factory.js
CHANGED
|
@@ -22,7 +22,14 @@ const parseBody = (input, error, url) => {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
const factory = ({
|
|
25
|
+
const factory = ({
|
|
26
|
+
VERSION,
|
|
27
|
+
MicrolinkError,
|
|
28
|
+
isUrlHttp,
|
|
29
|
+
stringify,
|
|
30
|
+
got,
|
|
31
|
+
flatten
|
|
32
|
+
}) => {
|
|
26
33
|
const assertUrl = (url = '') => {
|
|
27
34
|
if (!isUrlHttp(url)) {
|
|
28
35
|
const message = `The \`url\` as \`${url}\` is not valid. Ensure it has protocol (http or https) and hostname.`
|
|
@@ -55,11 +62,16 @@ const factory = ({ VERSION, MicrolinkError, isUrlHttp, stringify, got, flatten }
|
|
|
55
62
|
} catch (err) {
|
|
56
63
|
const { response = {} } = err
|
|
57
64
|
const { statusCode, body: rawBody, headers, url: uri = apiUrl } = response
|
|
65
|
+
const isBuffer = Buffer.isBuffer(rawBody)
|
|
58
66
|
|
|
59
67
|
const body =
|
|
60
|
-
isObject(rawBody) && !
|
|
68
|
+
isObject(rawBody) && !isBuffer
|
|
69
|
+
? rawBody
|
|
70
|
+
: parseBody(isBuffer ? rawBody.toString() : rawBody, err, uri)
|
|
61
71
|
|
|
62
|
-
if (body.code === 'EFATALCLIENT' && retryCount++ < 2)
|
|
72
|
+
if (body.code === 'EFATALCLIENT' && retryCount++ < 2) {
|
|
73
|
+
return fetchFromApi(apiUrl, opts, retryCount)
|
|
74
|
+
}
|
|
63
75
|
|
|
64
76
|
throw MicrolinkError({
|
|
65
77
|
...body,
|
|
@@ -85,7 +97,9 @@ const factory = ({ VERSION, MicrolinkError, isUrlHttp, stringify, got, flatten }
|
|
|
85
97
|
...flatten(opts)
|
|
86
98
|
})}`
|
|
87
99
|
|
|
88
|
-
const headers = isPro
|
|
100
|
+
const headers = isPro
|
|
101
|
+
? { ...gotHeaders, 'x-api-key': apiKey }
|
|
102
|
+
: { ...gotHeaders }
|
|
89
103
|
return [apiUrl, { ...gotOpts, responseType, cache, retry, headers }]
|
|
90
104
|
}
|
|
91
105
|
|