mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-25 09:55:15 +00:00
1 line
18 KiB
JSON
1 line
18 KiB
JSON
{"ast":null,"code":"'use strict';\n\nvar utils = require('./../utils');\n\nvar settle = require('./../core/settle');\n\nvar cookies = require('./../helpers/cookies');\n\nvar buildURL = require('./../helpers/buildURL');\n\nvar buildFullPath = require('../core/buildFullPath');\n\nvar parseHeaders = require('./../helpers/parseHeaders');\n\nvar isURLSameOrigin = require('./../helpers/isURLSameOrigin');\n\nvar createError = require('../core/createError');\n\nmodule.exports = function xhrAdapter(config) {\n return new Promise(function dispatchXhrRequest(resolve, reject) {\n var requestData = config.data;\n var requestHeaders = config.headers;\n\n if (utils.isFormData(requestData)) {\n delete requestHeaders['Content-Type']; // Let the browser set it\n }\n\n var request = new XMLHttpRequest(); // HTTP basic authentication\n\n if (config.auth) {\n var username = config.auth.username || '';\n var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';\n requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);\n }\n\n var fullPath = buildFullPath(config.baseURL, config.url);\n request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true); // Set the request timeout in MS\n\n request.timeout = config.timeout; // Listen for ready state\n\n request.onreadystatechange = function handleLoad() {\n if (!request || request.readyState !== 4) {\n return;\n } // The request errored out and we didn't get a response, this will be\n // handled by onerror instead\n // With one exception: request that using file: protocol, most browsers\n // will return status as 0 even though it's a successful request\n\n\n if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {\n return;\n } // Prepare the response\n\n\n var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;\n var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;\n var response = {\n data: responseData,\n status: request.status,\n statusText: request.statusText,\n headers: responseHeaders,\n config: config,\n request: request\n };\n settle(resolve, reject, response); // Clean up request\n\n request = null;\n }; // Handle browser request cancellation (as opposed to a manual cancellation)\n\n\n request.onabort = function handleAbort() {\n if (!request) {\n return;\n }\n\n reject(createError('Request aborted', config, 'ECONNABORTED', request)); // Clean up request\n\n request = null;\n }; // Handle low level network errors\n\n\n request.onerror = function handleError() {\n // Real errors are hidden from us by the browser\n // onerror should only fire if it's a network error\n reject(createError('Network Error', config, null, request)); // Clean up request\n\n request = null;\n }; // Handle timeout\n\n\n request.ontimeout = function handleTimeout() {\n var timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded';\n\n if (config.timeoutErrorMessage) {\n timeoutErrorMessage = config.timeoutErrorMessage;\n }\n\n reject(createError(timeoutErrorMessage, config, 'ECONNABORTED', request)); // Clean up request\n\n request = null;\n }; // Add xsrf header\n // This is only done if running in a standard browser environment.\n // Specifically not if we're in a web worker, or react-native.\n\n\n if (utils.isStandardBrowserEnv()) {\n // Add xsrf header\n var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ? cookies.read(config.xsrfCookieName) : undefined;\n\n if (xsrfValue) {\n requestHeaders[config.xsrfHeaderName] = xsrfValue;\n }\n } // Add headers to the request\n\n\n if ('setRequestHeader' in request) {\n utils.forEach(requestHeaders, function setRequestHeader(val, key) {\n if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {\n // Remove Content-Type if data is undefined\n delete requestHeaders[key];\n } else {\n // Otherwise add header to the request\n request.setRequestHeader(key, val);\n }\n });\n } // Add withCredentials to request if needed\n\n\n if (!utils.isUndefined(config.withCredentials)) {\n request.withCredentials = !!config.withCredentials;\n } // Add responseType to request if needed\n\n\n if (config.responseType) {\n try {\n request.responseType = config.responseType;\n } catch (e) {\n // Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2.\n // But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function.\n if (config.responseType !== 'json') {\n throw e;\n }\n }\n } // Handle progress if needed\n\n\n if (typeof config.onDownloadProgress === 'function') {\n request.addEventListener('progress', config.onDownloadProgress);\n } // Not all browsers support upload events\n\n\n if (typeof config.onUploadProgress === 'function' && request.upload) {\n request.upload.addEventListener('progress', config.onUploadProgress);\n }\n\n if (config.cancelToken) {\n // Handle cancellation\n config.cancelToken.promise.then(function onCanceled(cancel) {\n if (!request) {\n return;\n }\n\n request.abort();\n reject(cancel); // Clean up request\n\n request = null;\n });\n }\n\n if (!requestData) {\n requestData = null;\n } // Send the request\n\n\n request.send(requestData);\n });\n};","map":{"version":3,"sources":["/app/node_modules/axios/lib/adapters/xhr.js"],"names":["utils","require","settle","cookies","buildURL","buildFullPath","parseHeaders","isURLSameOrigin","createError","module","exports","xhrAdapter","config","Promise","dispatchXhrRequest","resolve","reject","requestData","data","requestHeaders","headers","isFormData","request","XMLHttpRequest","auth","username","password","unescape","encodeURIComponent","Authorization","btoa","fullPath","baseURL","url","open","method","toUpperCase","params","paramsSerializer","timeout","onreadystatechange","handleLoad","readyState","status","responseURL","indexOf","responseHeaders","getAllResponseHeaders","responseData","responseType","responseText","response","statusText","onabort","handleAbort","onerror","handleError","ontimeout","handleTimeout","timeoutErrorMessage","isStandardBrowserEnv","xsrfValue","withCredentials","xsrfCookieName","read","undefined","xsrfHeaderName","forEach","setRequestHeader","val","key","toLowerCase","isUndefined","e","onDownloadProgress","addEventListener","onUploadProgress","upload","cancelToken","promise","then","onCanceled","cancel","abort","send"],"mappings":"AAAA;;AAEA,IAAIA,KAAK,GAAGC,OAAO,CAAC,YAAD,CAAnB;;AACA,IAAIC,MAAM,GAAGD,OAAO,CAAC,kBAAD,CAApB;;AACA,IAAIE,OAAO,GAAGF,OAAO,CAAC,sBAAD,CAArB;;AACA,IAAIG,QAAQ,GAAGH,OAAO,CAAC,uBAAD,CAAtB;;AACA,IAAII,aAAa,GAAGJ,OAAO,CAAC,uBAAD,CAA3B;;AACA,IAAIK,YAAY,GAAGL,OAAO,CAAC,2BAAD,CAA1B;;AACA,IAAIM,eAAe,GAAGN,OAAO,CAAC,8BAAD,CAA7B;;AACA,IAAIO,WAAW,GAAGP,OAAO,CAAC,qBAAD,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AT,CAAoBC,MAApB,EAA4B;AAC1D,YAAI,CAAC5D,OAAL,EAAc;AACZ;AACD;;AAEDA,QAAAA,OAAO,CAAC6D,KAAR;AACAnE,QAAAA,MAAM,CAACkE,MAAD,CAAN,CAN0D,CAO1D;;AACA5D,QAAAA,OAAO,GAAG,IAAV;AACD,OATD;AAUD;;AAED,QAAI,CAACL,WAAL,EAAkB;AAChBA,MAAAA,WAAW,GAAG,IAAd;AACD,KAjK6D,CAmK9D;;;AACAK,IAAAA,OAAO,CAAC8D,IAAR,CAAanE,WAAb;AACD,GArKM,CAAP;AAsKD,CAvKD","sourcesContent":["'use strict';\n\nvar utils = require('./../utils');\nvar settle = require('./../core/settle');\nvar cookies = require('./../helpers/cookies');\nvar buildURL = require('./../helpers/buildURL');\nvar buildFullPath = require('../core/buildFullPath');\nvar parseHeaders = require('./../helpers/parseHeaders');\nvar isURLSameOrigin = require('./../helpers/isURLSameOrigin');\nvar createError = require('../core/createError');\n\nmodule.exports = function xhrAdapter(config) {\n return new Promise(function dispatchXhrRequest(resolve, reject) {\n var requestData = config.data;\n var requestHeaders = config.headers;\n\n if (utils.isFormData(requestData)) {\n delete requestHeaders['Content-Type']; // Let the browser set it\n }\n\n var request = new XMLHttpRequest();\n\n // HTTP basic authentication\n if (config.auth) {\n var username = config.auth.username || '';\n var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';\n requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);\n }\n\n var fullPath = buildFullPath(config.baseURL, config.url);\n request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);\n\n // Set the request timeout in MS\n request.timeout = config.timeout;\n\n // Listen for ready state\n request.onreadystatechange = function handleLoad() {\n if (!request || request.readyState !== 4) {\n return;\n }\n\n // The request errored out and we didn't get a response, this will be\n // handled by onerror instead\n // With one exception: request that using file: protocol, most browsers\n // will return status as 0 even though it's a successful request\n if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {\n return;\n }\n\n // Prepare the response\n var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;\n var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;\n var response = {\n data: responseData,\n status: request.status,\n statusText: request.statusText,\n headers: responseHeaders,\n config: config,\n request: request\n };\n\n settle(resolve, reject, response);\n\n // Clean up request\n request = null;\n };\n\n // Handle browser request cancellation (as opposed to a manual cancellation)\n request.onabort = function handleAbort() {\n if (!request) {\n return;\n }\n\n reject(createError('Request aborted', config, 'ECONNABORTED', request));\n\n // Clean up request\n request = null;\n };\n\n // Handle low level network errors\n request.onerror = function handleError() {\n // Real errors are hidden from us by the browser\n // onerror should only fire if it's a network error\n reject(createError('Network Error', config, null, request));\n\n // Clean up request\n request = null;\n };\n\n // Handle timeout\n request.ontimeout = function handleTimeout() {\n var timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded';\n if (config.timeoutErrorMessage) {\n timeoutErrorMessage = config.timeoutErrorMessage;\n }\n reject(createError(timeoutErrorMessage, config, 'ECONNABORTED',\n request));\n\n // Clean up request\n request = null;\n };\n\n // Add xsrf header\n // This is only done if running in a standard browser environment.\n // Specifically not if we're in a web worker, or react-native.\n if (utils.isStandardBrowserEnv()) {\n // Add xsrf header\n var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?\n cookies.read(config.xsrfCookieName) :\n undefined;\n\n if (xsrfValue) {\n requestHeaders[config.xsrfHeaderName] = xsrfValue;\n }\n }\n\n // Add headers to the request\n if ('setRequestHeader' in request) {\n utils.forEach(requestHeaders, function setRequestHeader(val, key) {\n if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {\n // Remove Content-Type if data is undefined\n delete requestHeaders[key];\n } else {\n // Otherwise add header to the request\n request.setRequestHeader(key, val);\n }\n });\n }\n\n // Add withCredentials to request if needed\n if (!utils.isUndefined(config.withCredentials)) {\n request.withCredentials = !!config.withCredentials;\n }\n\n // Add responseType to request if needed\n if (config.responseType) {\n try {\n request.responseType = config.responseType;\n } catch (e) {\n // Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2.\n // But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function.\n if (config.responseType !== 'json') {\n throw e;\n }\n }\n }\n\n // Handle progress if needed\n if (typeof config.onDownloadProgress === 'function') {\n request.addEventListener('progress', config.onDownloadProgress);\n }\n\n // Not all browsers support upload events\n if (typeof config.onUploadProgress === 'function' && request.upload) {\n request.upload.addEventListener('progress', config.onUploadProgress);\n }\n\n if (config.cancelToken) {\n // Handle cancellation\n config.cancelToken.promise.then(function onCanceled(cancel) {\n if (!request) {\n return;\n }\n\n request.abort();\n reject(cancel);\n // Clean up request\n request = null;\n });\n }\n\n if (!requestData) {\n requestData = null;\n }\n\n // Send the request\n request.send(requestData);\n });\n};\n"]},"metadata":{},"sourceType":"script"} |