Icard/angular-clarity-master(work.../node_modules/get-css-data/dist/get-css-data.esm.min.js.map

1 line
27 KiB
Plaintext
Raw Normal View History

2024-07-16 14:55:36 +00:00
{"version":3,"file":"get-css-data.esm.min.js","sources":["../src/get-urls.js","../src/get-css.js"],"sourcesContent":["/*global XDomainRequest*/\n\n// Functions\n// =============================================================================\n/**\n * Requests one-or-more URLs and returns array of data in order specified.\n * Provides callbacks error and success callbacks for each XMLHttpRequest.\n *\n * @param {array|string} url Single URL or array of URLs to request\n * @param {object} [options] Options object\n * @param {string} [options.mimeType] Overrides MIME type returned by\n * server\n * @param {function} [options.onBeforeSend] Callback before each request is\n * sent. Passes 1) the xhr object, 2) the URL, and 3) the\n * URL index as arguments.\n * @param {function} [options.onSuccess] Callback on xhr success. Passes 1)\n * xhr response text, 2) the URL, and 3) the URL index as\n * arguments.\n * @param {function} [options.onError] Callback on xhr error. Passes 1) the\n * xhr object, 2) the URL, 3) the URL index as arguments.\n * @param {function} [options.onComplete] Callback after all requests have\n * completed. Passes 1) an array of response text for each\n * URL in order provided as an argument.\n */\nfunction getUrls(urls, options = {}) {\n const settings = {\n mimeType : options.mimeType || null,\n onBeforeSend: options.onBeforeSend || Function.prototype,\n onSuccess : options.onSuccess || Function.prototype,\n onError : options.onError || Function.prototype,\n onComplete : options.onComplete || Function.prototype\n };\n const urlArray = Array.isArray(urls) ? urls : [urls];\n const urlQueue = Array.apply(null, Array(urlArray.length)).map(x => null);\n\n // Functions (Private)\n // -------------------------------------------------------------------------\n function isValidCss(text) {\n const isString = typeof text === 'string';\n const isHTML = isString && text.trim().charAt(0) === '<';\n\n return isString && !isHTML;\n }\n\n function onError(xhr, urlIndex) {\n settings.onError(xhr, urlArray[urlIndex], urlIndex);\n }\n\n function onSuccess(responseText, urlIndex) {\n const returnVal = settings.onSuccess(responseText, urlArray[urlIndex], urlIndex);\n\n responseText = returnVal === false ? '' : returnVal || responseText;\n urlQueue[urlIndex] = responseText;\n\n // Complete\n if (urlQueue.indexOf(null) === -1) {\n settings.onComplete(urlQueue);\n }\n }\n\n // Main\n // -------------------------------------------------------------------------\n const parser = document.createElement('a');\n\n urlArray.forEach((url, i) => {\n parser.setAttribute('href', url);\n parser.href = String(parser.href);\n\n const isIElte9 = Boolean(document.all && !window.atob);\n const isIElte9CORS = isIElte9 && parser.host.split(':')[0] !== location.host.split(':')[0];\n\n // IE 9 CORS\n if (isIElte9CORS) {\n const isSameProtocol = parser.protocol === location.protocol;\n\n if (isSameProtocol) {\n const xdr = new XDomainRequest();\n\n // Event handlers must be assigned AFTER xdr.open\n xdr.open('GET', url);\n\n xdr.timeout = 0; // Prevent aborts/timeouts\n xdr.onprogress = Function.prototype; // Prevent aborts/timeouts\n xdr.ontimeout = Function.prototype; // Prevent aborts/timeouts\n xdr.onload = function() {\n const text = xdr.responseText;\n\n if (isValidCss(text)) {\n onSuccess(text, i);\n }\n else {\n onError(xdr, i);\n }\n };\n