From 09c4e3dea235ea3fb8315ea1e505b48e92f9a155 Mon Sep 17 00:00:00 2001 From: TrickyPi <530257315@qq.com> Date: Sat, 6 May 2023 19:40:04 +0800 Subject: [PATCH] release 1.6.0 --- .gitignore | 1 - dist/xhook.js | 805 ++++++++++++++++++++++++++++++++++++++++++ dist/xhook.js.map | 1 + dist/xhook.min.js | 4 + dist/xhook.min.js.map | 1 + package.json | 2 +- 6 files changed, 812 insertions(+), 2 deletions(-) create mode 100644 dist/xhook.js create mode 100644 dist/xhook.js.map create mode 100644 dist/xhook.min.js create mode 100644 dist/xhook.min.js.map diff --git a/.gitignore b/.gitignore index 410104c..74e2eaa 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,5 @@ bower_components .DS_Store # ouput dir -dist/ lib/ es/ diff --git a/dist/xhook.js b/dist/xhook.js new file mode 100644 index 0000000..1e4cc1d --- /dev/null +++ b/dist/xhook.js @@ -0,0 +1,805 @@ +//XHook - v1.6.0 - https://github.com/jpillora/xhook +//Jaime Pillora - MIT Copyright 2023 +var xhook = (function () { + 'use strict'; + + const slice = (o, n) => Array.prototype.slice.call(o, n); + + let result = null; + + //find global object + if ( + typeof WorkerGlobalScope !== "undefined" && + self instanceof WorkerGlobalScope + ) { + result = self; + } else if (typeof global !== "undefined") { + result = global; + } else if (window) { + result = window; + } + + const windowRef = result; + const documentRef = result.document; + + const UPLOAD_EVENTS = ["load", "loadend", "loadstart"]; + const COMMON_EVENTS = ["progress", "abort", "error", "timeout"]; + + const depricatedProp = p => + ["returnValue", "totalSize", "position"].includes(p); + + const mergeObjects = function (src, dst) { + for (let k in src) { + if (depricatedProp(k)) { + continue; + } + const v = src[k]; + try { + dst[k] = v; + } catch (error) {} + } + return dst; + }; + + //proxy events from one emitter to another + const proxyEvents = function (events, src, dst) { + const p = event => + function (e) { + const clone = {}; + //copies event, with dst emitter inplace of src + for (let k in e) { + if (depricatedProp(k)) { + continue; + } + const val = e[k]; + clone[k] = val === src ? dst : val; + } + //emits out the dst + return dst.dispatchEvent(event, clone); + }; + //dont proxy manual events + for (let event of Array.from(events)) { + if (dst._has(event)) { + src[`on${event}`] = p(event); + } + } + }; + + //create fake event + const fakeEvent = function (type) { + if (documentRef && documentRef.createEventObject != null) { + const msieEventObject = documentRef.createEventObject(); + msieEventObject.type = type; + return msieEventObject; + } + // on some platforms like android 4.1.2 and safari on windows, it appears + // that new Event is not allowed + try { + return new Event(type); + } catch (error) { + return { type }; + } + }; + + //tiny event emitter + const EventEmitter = function (nodeStyle) { + //private + let events = {}; + const listeners = event => events[event] || []; + //public + const emitter = {}; + emitter.addEventListener = function (event, callback, i) { + events[event] = listeners(event); + if (events[event].indexOf(callback) >= 0) { + return; + } + i = i === undefined ? events[event].length : i; + events[event].splice(i, 0, callback); + }; + emitter.removeEventListener = function (event, callback) { + //remove all + if (event === undefined) { + events = {}; + return; + } + //remove all of type event + if (callback === undefined) { + events[event] = []; + } + //remove particular handler + const i = listeners(event).indexOf(callback); + if (i === -1) { + return; + } + listeners(event).splice(i, 1); + }; + emitter.dispatchEvent = function () { + const args = slice(arguments); + const event = args.shift(); + if (!nodeStyle) { + args[0] = mergeObjects(args[0], fakeEvent(event)); + } + const legacylistener = emitter[`on${event}`]; + if (legacylistener) { + legacylistener.apply(emitter, args); + } + const iterable = listeners(event).concat(listeners("*")); + for (let i = 0; i < iterable.length; i++) { + const listener = iterable[i]; + listener.apply(emitter, args); + } + }; + emitter._has = event => !!(events[event] || emitter[`on${event}`]); + //add extra aliases + if (nodeStyle) { + emitter.listeners = event => slice(listeners(event)); + emitter.on = emitter.addEventListener; + emitter.off = emitter.removeEventListener; + emitter.fire = emitter.dispatchEvent; + emitter.once = function (e, fn) { + var fire = function () { + emitter.off(e, fire); + return fn.apply(null, arguments); + }; + return emitter.on(e, fire); + }; + emitter.destroy = () => (events = {}); + } + + return emitter; + }; + + //helper + const CRLF = "\r\n"; + + const objectToString = function (headersObj) { + const entries = Object.entries(headersObj); + + const headers = entries.map(([name, value]) => { + return `${name.toLowerCase()}: ${value}`; + }); + + return headers.join(CRLF); + }; + + const stringToObject = function (headersString, dest) { + const headers = headersString.split(CRLF); + if (dest == null) { + dest = {}; + } + + for (let header of headers) { + if (/([^:]+):\s*(.+)/.test(header)) { + const name = RegExp.$1 != null ? RegExp.$1.toLowerCase() : undefined; + const value = RegExp.$2; + if (dest[name] == null) { + dest[name] = value; + } + } + } + + return dest; + }; + + const convert = function (headers, dest) { + switch (typeof headers) { + case "object": { + return objectToString(headers); + } + case "string": { + return stringToObject(headers, dest); + } + } + + return []; + }; + + var headers = { convert }; + + //global set of hook functions, + //uses event emitter to store hooks + const hooks = EventEmitter(true); + + const nullify = res => (res === undefined ? null : res); + + //browser's XMLHttpRequest + const Native$1 = windowRef.XMLHttpRequest; + + //xhook's XMLHttpRequest + const Xhook$1 = function () { + const ABORTED = -1; + const xhr = new Native$1(); + + //========================== + // Extra state + const request = {}; + let status = null; + let hasError = undefined; + let transiting = undefined; + let response = undefined; + var currentState = 0; + + //========================== + // Private API + + //read results from real xhr into response + const readHead = function () { + // Accessing attributes on an aborted xhr object will + // throw an 'c00c023f error' in IE9 and lower, don't touch it. + response.status = status || xhr.status; + if (status !== ABORTED) { + response.statusText = xhr.statusText; + } + if (status !== ABORTED) { + const object = headers.convert(xhr.getAllResponseHeaders()); + for (let key in object) { + const val = object[key]; + if (!response.headers[key]) { + const name = key.toLowerCase(); + response.headers[name] = val; + } + } + return; + } + }; + + const readBody = function () { + //https://xhr.spec.whatwg.org/ + if (!xhr.responseType || xhr.responseType === "text") { + response.text = xhr.responseText; + response.data = xhr.responseText; + try { + response.xml = xhr.responseXML; + } catch (error) {} + // unable to set responseXML due to response type, we attempt to assign responseXML + // when the type is text even though it's against the spec due to several libraries + // and browser vendors who allow this behavior. causing these requests to fail when + // xhook is installed on a page. + } else if (xhr.responseType === "document") { + response.xml = xhr.responseXML; + response.data = xhr.responseXML; + } else { + response.data = xhr.response; + } + //new in some browsers + if ("responseURL" in xhr) { + response.finalUrl = xhr.responseURL; + } + }; + + //write response into facade xhr + const writeHead = function () { + facade.status = response.status; + facade.statusText = response.statusText; + }; + + const writeBody = function () { + if ("text" in response) { + facade.responseText = response.text; + } + if ("xml" in response) { + facade.responseXML = response.xml; + } + if ("data" in response) { + facade.response = response.data; + } + if ("finalUrl" in response) { + facade.responseURL = response.finalUrl; + } + }; + + const emitFinal = function () { + if (!hasError) { + facade.dispatchEvent("load", {}); + } + facade.dispatchEvent("loadend", {}); + if (hasError) { + facade.readyState = 0; + } + }; + + //ensure ready state 0 through 4 is handled + const emitReadyState = function (n) { + while (n > currentState && currentState < 4) { + facade.readyState = ++currentState; + // make fake events for libraries that actually check the type on + // the event object + if (currentState === 1) { + facade.dispatchEvent("loadstart", {}); + } + if (currentState === 2) { + writeHead(); + } + if (currentState === 4) { + writeHead(); + writeBody(); + } + facade.dispatchEvent("readystatechange", {}); + //delay final events incase of error + if (currentState === 4) { + if (request.async === false) { + emitFinal(); + } else { + setTimeout(emitFinal, 0); + } + } + } + }; + + //control facade ready state + const setReadyState = function (n) { + //emit events until readyState reaches 4 + if (n !== 4) { + emitReadyState(n); + return; + } + //before emitting 4, run all 'after' hooks in sequence + const afterHooks = hooks.listeners("after"); + var process = function () { + if (afterHooks.length > 0) { + //execute each 'before' hook one at a time + const hook = afterHooks.shift(); + if (hook.length === 2) { + hook(request, response); + process(); + } else if (hook.length === 3 && request.async) { + hook(request, response, process); + } else { + process(); + } + } else { + //response ready for reading + emitReadyState(4); + } + return; + }; + process(); + }; + + //========================== + // Facade XHR + var facade = EventEmitter(); + request.xhr = facade; + + // Handle the underlying ready state + xhr.onreadystatechange = function (event) { + //pull status and headers + try { + if (xhr.readyState === 2) { + readHead(); + } + } catch (error) {} + //pull response data + if (xhr.readyState === 4) { + transiting = false; + readHead(); + readBody(); + } + + setReadyState(xhr.readyState); + }; + + //mark this xhr as errored + const hasErrorHandler = function () { + hasError = true; + }; + facade.addEventListener("error", hasErrorHandler); + facade.addEventListener("timeout", hasErrorHandler); + facade.addEventListener("abort", hasErrorHandler); + // progress means we're current downloading... + facade.addEventListener("progress", function (event) { + if (currentState < 3) { + setReadyState(3); + } else if (xhr.readyState <= 3) { + //until ready (4), each progress event is followed by readystatechange... + facade.dispatchEvent("readystatechange", {}); //TODO fake an XHR event + } + }); + + // initialise 'withCredentials' on facade xhr in browsers with it + // or if explicitly told to do so + if ("withCredentials" in xhr) { + facade.withCredentials = false; + } + facade.status = 0; + + // initialise all possible event handlers + for (let event of Array.from(COMMON_EVENTS.concat(UPLOAD_EVENTS))) { + facade[`on${event}`] = null; + } + + facade.open = function (method, url, async, user, pass) { + // Initailize empty XHR facade + currentState = 0; + hasError = false; + transiting = false; + //reset request + request.headers = {}; + request.headerNames = {}; + request.status = 0; + request.method = method; + request.url = url; + request.async = async !== false; + request.user = user; + request.pass = pass; + //reset response + response = {}; + response.headers = {}; + // openned facade xhr (not real xhr) + setReadyState(1); + }; + + facade.send = function (body) { + //read xhr settings before hooking + let k, modk; + for (k of ["type", "timeout", "withCredentials"]) { + modk = k === "type" ? "responseType" : k; + if (modk in facade) { + request[k] = facade[modk]; + } + } + + request.body = body; + const send = function () { + //proxy all events from real xhr to facade + proxyEvents(COMMON_EVENTS, xhr, facade); + //proxy all upload events from the real to the upload facade + if (facade.upload) { + proxyEvents( + COMMON_EVENTS.concat(UPLOAD_EVENTS), + xhr.upload, + facade.upload + ); + } + + //prepare request all at once + transiting = true; + //perform open + xhr.open( + request.method, + request.url, + request.async, + request.user, + request.pass + ); + + //write xhr settings + for (k of ["type", "timeout", "withCredentials"]) { + modk = k === "type" ? "responseType" : k; + if (k in request) { + xhr[modk] = request[k]; + } + } + + //insert headers + for (let header in request.headers) { + const value = request.headers[header]; + if (header) { + xhr.setRequestHeader(header, value); + } + } + //real send! + xhr.send(request.body); + }; + + const beforeHooks = hooks.listeners("before"); + //process beforeHooks sequentially + var process = function () { + if (!beforeHooks.length) { + return send(); + } + //go to next hook OR optionally provide response + const done = function (userResponse) { + //break chain - provide dummy response (readyState 4) + if ( + typeof userResponse === "object" && + (typeof userResponse.status === "number" || + typeof response.status === "number") + ) { + mergeObjects(userResponse, response); + if (!("data" in userResponse)) { + userResponse.data = userResponse.response || userResponse.text; + } + setReadyState(4); + return; + } + //continue processing until no beforeHooks left + process(); + }; + //specifically provide headers (readyState 2) + done.head = function (userResponse) { + mergeObjects(userResponse, response); + setReadyState(2); + }; + //specifically provide partial text (responseText readyState 3) + done.progress = function (userResponse) { + mergeObjects(userResponse, response); + setReadyState(3); + }; + + const hook = beforeHooks.shift(); + //async or sync? + if (hook.length === 1) { + done(hook(request)); + } else if (hook.length === 2 && request.async) { + //async handlers must use an async xhr + hook(request, done); + } else { + //skip async hook on sync requests + done(); + } + return; + }; + //kick off + process(); + }; + + facade.abort = function () { + status = ABORTED; + if (transiting) { + xhr.abort(); //this will emit an 'abort' for us + } else { + facade.dispatchEvent("abort", {}); + } + }; + + facade.setRequestHeader = function (header, value) { + //the first header set is used for all future case-alternatives of 'name' + const lName = header != null ? header.toLowerCase() : undefined; + const name = (request.headerNames[lName] = + request.headerNames[lName] || header); + //append header to any previous values + if (request.headers[name]) { + value = request.headers[name] + ", " + value; + } + request.headers[name] = value; + }; + facade.getResponseHeader = header => + nullify(response.headers[header ? header.toLowerCase() : undefined]); + + facade.getAllResponseHeaders = () => + nullify(headers.convert(response.headers)); + + //proxy call only when supported + if (xhr.overrideMimeType) { + facade.overrideMimeType = function () { + xhr.overrideMimeType.apply(xhr, arguments); + }; + } + + //create emitter when supported + if (xhr.upload) { + let up = EventEmitter(); + facade.upload = up; + request.upload = up; + } + + facade.UNSENT = 0; + facade.OPENED = 1; + facade.HEADERS_RECEIVED = 2; + facade.LOADING = 3; + facade.DONE = 4; + + // fill in default values for an empty XHR object according to the spec + facade.response = ""; + facade.responseText = ""; + facade.responseXML = null; + facade.readyState = 0; + facade.statusText = ""; + + return facade; + }; + + Xhook$1.UNSENT = 0; + Xhook$1.OPENED = 1; + Xhook$1.HEADERS_RECEIVED = 2; + Xhook$1.LOADING = 3; + Xhook$1.DONE = 4; + + //patch interface + var XMLHttpRequest = { + patch() { + if (Native$1) { + windowRef.XMLHttpRequest = Xhook$1; + } + }, + unpatch() { + if (Native$1) { + windowRef.XMLHttpRequest = Native$1; + } + }, + Native: Native$1, + Xhook: Xhook$1, + }; + + /****************************************************************************** + Copyright (c) Microsoft Corporation. + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH + REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, + INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + PERFORMANCE OF THIS SOFTWARE. + ***************************************************************************** */ + + function __rest(s, e) { + var t = {}; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) + t[p] = s[p]; + if (s != null && typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { + if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) + t[p[i]] = s[p[i]]; + } + return t; + } + + //browser's fetch + const Native = windowRef.fetch; + function copyToObjFromRequest(req) { + const copyedKeys = [ + "method", + "headers", + "body", + "mode", + "credentials", + "cache", + "redirect", + "referrer", + "referrerPolicy", + "integrity", + "keepalive", + "signal", + "url", + ]; + let copyedObj = {}; + copyedKeys.forEach(key => (copyedObj[key] = req[key])); + return copyedObj; + } + function covertHeaderToPlainObj(headers) { + if (headers instanceof Headers) { + return covertTDAarryToObj([...headers.entries()]); + } + if (Array.isArray(headers)) { + return covertTDAarryToObj(headers); + } + return headers; + } + function covertTDAarryToObj(input) { + return input.reduce((prev, [key, value]) => { + prev[key] = value; + return prev; + }, {}); + } + /** + * if fetch(hacked by Xhook) accept a Request as a first parameter, it will be destrcuted to a plain object. + * Finally the whole network request was convert to fectch(Request.url, other options) + */ + const Xhook = function (input, init = { headers: {} }) { + let options = Object.assign(Object.assign({}, init), { isFetch: true }); + if (input instanceof Request) { + const requestObj = copyToObjFromRequest(input); + const prevHeaders = Object.assign(Object.assign({}, covertHeaderToPlainObj(requestObj.headers)), covertHeaderToPlainObj(options.headers)); + options = Object.assign(Object.assign(Object.assign({}, requestObj), init), { headers: prevHeaders, acceptedRequest: true }); + } + else { + options.url = input; + } + const beforeHooks = hooks.listeners("before"); + const afterHooks = hooks.listeners("after"); + return new Promise(function (resolve, reject) { + let fullfiled = resolve; + const processAfter = function (response) { + if (!afterHooks.length) { + return fullfiled(response); + } + const hook = afterHooks.shift(); + if (hook.length === 2) { + hook(options, response); + return processAfter(response); + } + else if (hook.length === 3) { + return hook(options, response, processAfter); + } + else { + return processAfter(response); + } + }; + const done = function (userResponse) { + if (userResponse !== undefined) { + const response = new Response(userResponse.body || userResponse.text, userResponse); + resolve(response); + processAfter(response); + return; + } + //continue processing until no hooks left + processBefore(); + }; + const processBefore = function () { + if (!beforeHooks.length) { + send(); + return; + } + const hook = beforeHooks.shift(); + if (hook.length === 1) { + return done(hook(options)); + } + else if (hook.length === 2) { + return hook(options, done); + } + }; + const send = () => { + const { url, isFetch, acceptedRequest } = options, restInit = __rest(options, ["url", "isFetch", "acceptedRequest"]); + Native(url, restInit) + .then(response => processAfter(response)) + .catch(function (err) { + fullfiled = reject; + processAfter(err); + return reject(err); + }); + }; + processBefore(); + }); + }; + //patch interface + var fetch = { + patch() { + if (Native) { + windowRef.fetch = Xhook; + } + }, + unpatch() { + if (Native) { + windowRef.fetch = Native; + } + }, + Native, + Xhook, + }; + + //the global hooks event emitter is also the global xhook object + //(not the best decision in hindsight) + const xhook = hooks; + xhook.EventEmitter = EventEmitter; + //modify hooks + xhook.before = function (handler, i) { + if (handler.length < 1 || handler.length > 2) { + throw "invalid hook"; + } + return xhook.on("before", handler, i); + }; + xhook.after = function (handler, i) { + if (handler.length < 2 || handler.length > 3) { + throw "invalid hook"; + } + return xhook.on("after", handler, i); + }; + + //globally enable/disable + xhook.enable = function () { + XMLHttpRequest.patch(); + fetch.patch(); + }; + xhook.disable = function () { + XMLHttpRequest.unpatch(); + fetch.unpatch(); + }; + //expose native objects + xhook.XMLHttpRequest = XMLHttpRequest.Native; + xhook.fetch = fetch.Native; + + //expose helpers + xhook.headers = headers.convert; + + //enable by default + xhook.enable(); + + return xhook; + +})(); +//# sourceMappingURL=xhook.js.map diff --git a/dist/xhook.js.map b/dist/xhook.js.map new file mode 100644 index 0000000..8e63cad --- /dev/null +++ b/dist/xhook.js.map @@ -0,0 +1 @@ +{"version":3,"file":"xhook.js","sources":["../src/misc/array.js","../src/misc/window.js","../src/misc/events.js","../src/misc/event-emitter.js","../src/misc/headers.js","../src/misc/hooks.js","../src/patch/xmlhttprequest.js","../node_modules/tslib/tslib.es6.js","../src/patch/fetch.ts","../src/main.js"],"sourcesContent":["const slice = (o, n) => Array.prototype.slice.call(o, n);\n\nexport { slice };\n","let result = null;\n\n//find global object\nif (\n typeof WorkerGlobalScope !== \"undefined\" &&\n self instanceof WorkerGlobalScope\n) {\n result = self;\n} else if (typeof global !== \"undefined\") {\n result = global;\n} else if (window) {\n result = window;\n}\n\nexport const windowRef = result;\nexport const documentRef = result.document;\n","import { documentRef } from \"./window\";\n\nexport const UPLOAD_EVENTS = [\"load\", \"loadend\", \"loadstart\"];\nexport const COMMON_EVENTS = [\"progress\", \"abort\", \"error\", \"timeout\"];\n\nconst depricatedProp = p =>\n [\"returnValue\", \"totalSize\", \"position\"].includes(p);\n\nexport const mergeObjects = function (src, dst) {\n for (let k in src) {\n if (depricatedProp(k)) {\n continue;\n }\n const v = src[k];\n try {\n dst[k] = v;\n } catch (error) {}\n }\n return dst;\n};\n\n//proxy events from one emitter to another\nexport const proxyEvents = function (events, src, dst) {\n const p = event =>\n function (e) {\n const clone = {};\n //copies event, with dst emitter inplace of src\n for (let k in e) {\n if (depricatedProp(k)) {\n continue;\n }\n const val = e[k];\n clone[k] = val === src ? dst : val;\n }\n //emits out the dst\n return dst.dispatchEvent(event, clone);\n };\n //dont proxy manual events\n for (let event of Array.from(events)) {\n if (dst._has(event)) {\n src[`on${event}`] = p(event);\n }\n }\n};\n\n//create fake event\nexport const fakeEvent = function (type) {\n if (documentRef && documentRef.createEventObject != null) {\n const msieEventObject = documentRef.createEventObject();\n msieEventObject.type = type;\n return msieEventObject;\n }\n // on some platforms like android 4.1.2 and safari on windows, it appears\n // that new Event is not allowed\n try {\n return new Event(type);\n } catch (error) {\n return { type };\n }\n};\n","import { slice } from \"./array\";\nimport { mergeObjects, fakeEvent } from \"./events\";\n\n//tiny event emitter\nexport const EventEmitter = function (nodeStyle) {\n //private\n let events = {};\n const listeners = event => events[event] || [];\n //public\n const emitter = {};\n emitter.addEventListener = function (event, callback, i) {\n events[event] = listeners(event);\n if (events[event].indexOf(callback) >= 0) {\n return;\n }\n i = i === undefined ? events[event].length : i;\n events[event].splice(i, 0, callback);\n };\n emitter.removeEventListener = function (event, callback) {\n //remove all\n if (event === undefined) {\n events = {};\n return;\n }\n //remove all of type event\n if (callback === undefined) {\n events[event] = [];\n }\n //remove particular handler\n const i = listeners(event).indexOf(callback);\n if (i === -1) {\n return;\n }\n listeners(event).splice(i, 1);\n };\n emitter.dispatchEvent = function () {\n const args = slice(arguments);\n const event = args.shift();\n if (!nodeStyle) {\n args[0] = mergeObjects(args[0], fakeEvent(event));\n }\n const legacylistener = emitter[`on${event}`];\n if (legacylistener) {\n legacylistener.apply(emitter, args);\n }\n const iterable = listeners(event).concat(listeners(\"*\"));\n for (let i = 0; i < iterable.length; i++) {\n const listener = iterable[i];\n listener.apply(emitter, args);\n }\n };\n emitter._has = event => !!(events[event] || emitter[`on${event}`]);\n //add extra aliases\n if (nodeStyle) {\n emitter.listeners = event => slice(listeners(event));\n emitter.on = emitter.addEventListener;\n emitter.off = emitter.removeEventListener;\n emitter.fire = emitter.dispatchEvent;\n emitter.once = function (e, fn) {\n var fire = function () {\n emitter.off(e, fire);\n return fn.apply(null, arguments);\n };\n return emitter.on(e, fire);\n };\n emitter.destroy = () => (events = {});\n }\n\n return emitter;\n};\n","//helper\nconst CRLF = \"\\r\\n\";\n\nconst objectToString = function (headersObj) {\n const entries = Object.entries(headersObj);\n\n const headers = entries.map(([name, value]) => {\n return `${name.toLowerCase()}: ${value}`;\n });\n\n return headers.join(CRLF);\n};\n\nconst stringToObject = function (headersString, dest) {\n const headers = headersString.split(CRLF);\n if (dest == null) {\n dest = {};\n }\n\n for (let header of headers) {\n if (/([^:]+):\\s*(.+)/.test(header)) {\n const name = RegExp.$1 != null ? RegExp.$1.toLowerCase() : undefined;\n const value = RegExp.$2;\n if (dest[name] == null) {\n dest[name] = value;\n }\n }\n }\n\n return dest;\n};\n\nconst convert = function (headers, dest) {\n switch (typeof headers) {\n case \"object\": {\n return objectToString(headers);\n }\n case \"string\": {\n return stringToObject(headers, dest);\n }\n }\n\n return [];\n};\n\nexport default { convert };\n","import { EventEmitter } from \"./event-emitter\";\n\n//global set of hook functions,\n//uses event emitter to store hooks\nconst hooks = EventEmitter(true);\n\nexport default hooks;\n","import { windowRef } from \"../misc/window\";\nimport {\n proxyEvents,\n mergeObjects,\n COMMON_EVENTS,\n UPLOAD_EVENTS,\n} from \"../misc/events\";\nimport { EventEmitter } from \"../misc/event-emitter\";\nimport headers from \"../misc/headers\";\nimport hooks from \"../misc/hooks\";\n\nconst nullify = res => (res === undefined ? null : res);\n\n//browser's XMLHttpRequest\nconst Native = windowRef.XMLHttpRequest;\n\n//xhook's XMLHttpRequest\nconst Xhook = function () {\n const ABORTED = -1;\n const xhr = new Native();\n\n //==========================\n // Extra state\n const request = {};\n let status = null;\n let hasError = undefined;\n let transiting = undefined;\n let response = undefined;\n var currentState = 0;\n\n //==========================\n // Private API\n\n //read results from real xhr into response\n const readHead = function () {\n // Accessing attributes on an aborted xhr object will\n // throw an 'c00c023f error' in IE9 and lower, don't touch it.\n response.status = status || xhr.status;\n if (status !== ABORTED) {\n response.statusText = xhr.statusText;\n }\n if (status !== ABORTED) {\n const object = headers.convert(xhr.getAllResponseHeaders());\n for (let key in object) {\n const val = object[key];\n if (!response.headers[key]) {\n const name = key.toLowerCase();\n response.headers[name] = val;\n }\n }\n return;\n }\n };\n\n const readBody = function () {\n //https://xhr.spec.whatwg.org/\n if (!xhr.responseType || xhr.responseType === \"text\") {\n response.text = xhr.responseText;\n response.data = xhr.responseText;\n try {\n response.xml = xhr.responseXML;\n } catch (error) {}\n // unable to set responseXML due to response type, we attempt to assign responseXML\n // when the type is text even though it's against the spec due to several libraries\n // and browser vendors who allow this behavior. causing these requests to fail when\n // xhook is installed on a page.\n } else if (xhr.responseType === \"document\") {\n response.xml = xhr.responseXML;\n response.data = xhr.responseXML;\n } else {\n response.data = xhr.response;\n }\n //new in some browsers\n if (\"responseURL\" in xhr) {\n response.finalUrl = xhr.responseURL;\n }\n };\n\n //write response into facade xhr\n const writeHead = function () {\n facade.status = response.status;\n facade.statusText = response.statusText;\n };\n\n const writeBody = function () {\n if (\"text\" in response) {\n facade.responseText = response.text;\n }\n if (\"xml\" in response) {\n facade.responseXML = response.xml;\n }\n if (\"data\" in response) {\n facade.response = response.data;\n }\n if (\"finalUrl\" in response) {\n facade.responseURL = response.finalUrl;\n }\n };\n\n const emitFinal = function () {\n if (!hasError) {\n facade.dispatchEvent(\"load\", {});\n }\n facade.dispatchEvent(\"loadend\", {});\n if (hasError) {\n facade.readyState = 0;\n }\n };\n\n //ensure ready state 0 through 4 is handled\n const emitReadyState = function (n) {\n while (n > currentState && currentState < 4) {\n facade.readyState = ++currentState;\n // make fake events for libraries that actually check the type on\n // the event object\n if (currentState === 1) {\n facade.dispatchEvent(\"loadstart\", {});\n }\n if (currentState === 2) {\n writeHead();\n }\n if (currentState === 4) {\n writeHead();\n writeBody();\n }\n facade.dispatchEvent(\"readystatechange\", {});\n //delay final events incase of error\n if (currentState === 4) {\n if (request.async === false) {\n emitFinal();\n } else {\n setTimeout(emitFinal, 0);\n }\n }\n }\n };\n\n //control facade ready state\n const setReadyState = function (n) {\n //emit events until readyState reaches 4\n if (n !== 4) {\n emitReadyState(n);\n return;\n }\n //before emitting 4, run all 'after' hooks in sequence\n const afterHooks = hooks.listeners(\"after\");\n var process = function () {\n if (afterHooks.length > 0) {\n //execute each 'before' hook one at a time\n const hook = afterHooks.shift();\n if (hook.length === 2) {\n hook(request, response);\n process();\n } else if (hook.length === 3 && request.async) {\n hook(request, response, process);\n } else {\n process();\n }\n } else {\n //response ready for reading\n emitReadyState(4);\n }\n return;\n };\n process();\n };\n\n //==========================\n // Facade XHR\n var facade = EventEmitter();\n request.xhr = facade;\n\n // Handle the underlying ready state\n xhr.onreadystatechange = function (event) {\n //pull status and headers\n try {\n if (xhr.readyState === 2) {\n readHead();\n }\n } catch (error) {}\n //pull response data\n if (xhr.readyState === 4) {\n transiting = false;\n readHead();\n readBody();\n }\n\n setReadyState(xhr.readyState);\n };\n\n //mark this xhr as errored\n const hasErrorHandler = function () {\n hasError = true;\n };\n facade.addEventListener(\"error\", hasErrorHandler);\n facade.addEventListener(\"timeout\", hasErrorHandler);\n facade.addEventListener(\"abort\", hasErrorHandler);\n // progress means we're current downloading...\n facade.addEventListener(\"progress\", function (event) {\n if (currentState < 3) {\n setReadyState(3);\n } else if (xhr.readyState <= 3) {\n //until ready (4), each progress event is followed by readystatechange...\n facade.dispatchEvent(\"readystatechange\", {}); //TODO fake an XHR event\n }\n });\n\n // initialise 'withCredentials' on facade xhr in browsers with it\n // or if explicitly told to do so\n if (\"withCredentials\" in xhr) {\n facade.withCredentials = false;\n }\n facade.status = 0;\n\n // initialise all possible event handlers\n for (let event of Array.from(COMMON_EVENTS.concat(UPLOAD_EVENTS))) {\n facade[`on${event}`] = null;\n }\n\n facade.open = function (method, url, async, user, pass) {\n // Initailize empty XHR facade\n currentState = 0;\n hasError = false;\n transiting = false;\n //reset request\n request.headers = {};\n request.headerNames = {};\n request.status = 0;\n request.method = method;\n request.url = url;\n request.async = async !== false;\n request.user = user;\n request.pass = pass;\n //reset response\n response = {};\n response.headers = {};\n // openned facade xhr (not real xhr)\n setReadyState(1);\n };\n\n facade.send = function (body) {\n //read xhr settings before hooking\n let k, modk;\n for (k of [\"type\", \"timeout\", \"withCredentials\"]) {\n modk = k === \"type\" ? \"responseType\" : k;\n if (modk in facade) {\n request[k] = facade[modk];\n }\n }\n\n request.body = body;\n const send = function () {\n //proxy all events from real xhr to facade\n proxyEvents(COMMON_EVENTS, xhr, facade);\n //proxy all upload events from the real to the upload facade\n if (facade.upload) {\n proxyEvents(\n COMMON_EVENTS.concat(UPLOAD_EVENTS),\n xhr.upload,\n facade.upload\n );\n }\n\n //prepare request all at once\n transiting = true;\n //perform open\n xhr.open(\n request.method,\n request.url,\n request.async,\n request.user,\n request.pass\n );\n\n //write xhr settings\n for (k of [\"type\", \"timeout\", \"withCredentials\"]) {\n modk = k === \"type\" ? \"responseType\" : k;\n if (k in request) {\n xhr[modk] = request[k];\n }\n }\n\n //insert headers\n for (let header in request.headers) {\n const value = request.headers[header];\n if (header) {\n xhr.setRequestHeader(header, value);\n }\n }\n //real send!\n xhr.send(request.body);\n };\n\n const beforeHooks = hooks.listeners(\"before\");\n //process beforeHooks sequentially\n var process = function () {\n if (!beforeHooks.length) {\n return send();\n }\n //go to next hook OR optionally provide response\n const done = function (userResponse) {\n //break chain - provide dummy response (readyState 4)\n if (\n typeof userResponse === \"object\" &&\n (typeof userResponse.status === \"number\" ||\n typeof response.status === \"number\")\n ) {\n mergeObjects(userResponse, response);\n if (!(\"data\" in userResponse)) {\n userResponse.data = userResponse.response || userResponse.text;\n }\n setReadyState(4);\n return;\n }\n //continue processing until no beforeHooks left\n process();\n };\n //specifically provide headers (readyState 2)\n done.head = function (userResponse) {\n mergeObjects(userResponse, response);\n setReadyState(2);\n };\n //specifically provide partial text (responseText readyState 3)\n done.progress = function (userResponse) {\n mergeObjects(userResponse, response);\n setReadyState(3);\n };\n\n const hook = beforeHooks.shift();\n //async or sync?\n if (hook.length === 1) {\n done(hook(request));\n } else if (hook.length === 2 && request.async) {\n //async handlers must use an async xhr\n hook(request, done);\n } else {\n //skip async hook on sync requests\n done();\n }\n return;\n };\n //kick off\n process();\n };\n\n facade.abort = function () {\n status = ABORTED;\n if (transiting) {\n xhr.abort(); //this will emit an 'abort' for us\n } else {\n facade.dispatchEvent(\"abort\", {});\n }\n };\n\n facade.setRequestHeader = function (header, value) {\n //the first header set is used for all future case-alternatives of 'name'\n const lName = header != null ? header.toLowerCase() : undefined;\n const name = (request.headerNames[lName] =\n request.headerNames[lName] || header);\n //append header to any previous values\n if (request.headers[name]) {\n value = request.headers[name] + \", \" + value;\n }\n request.headers[name] = value;\n };\n facade.getResponseHeader = header =>\n nullify(response.headers[header ? header.toLowerCase() : undefined]);\n\n facade.getAllResponseHeaders = () =>\n nullify(headers.convert(response.headers));\n\n //proxy call only when supported\n if (xhr.overrideMimeType) {\n facade.overrideMimeType = function () {\n xhr.overrideMimeType.apply(xhr, arguments);\n };\n }\n\n //create emitter when supported\n if (xhr.upload) {\n let up = EventEmitter();\n facade.upload = up;\n request.upload = up;\n }\n\n facade.UNSENT = 0;\n facade.OPENED = 1;\n facade.HEADERS_RECEIVED = 2;\n facade.LOADING = 3;\n facade.DONE = 4;\n\n // fill in default values for an empty XHR object according to the spec\n facade.response = \"\";\n facade.responseText = \"\";\n facade.responseXML = null;\n facade.readyState = 0;\n facade.statusText = \"\";\n\n return facade;\n};\n\nXhook.UNSENT = 0;\nXhook.OPENED = 1;\nXhook.HEADERS_RECEIVED = 2;\nXhook.LOADING = 3;\nXhook.DONE = 4;\n\n//patch interface\nexport default {\n patch() {\n if (Native) {\n windowRef.XMLHttpRequest = Xhook;\n }\n },\n unpatch() {\n if (Native) {\n windowRef.XMLHttpRequest = Native;\n }\n },\n Native,\n Xhook,\n};\n","/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n","import { windowRef } from \"../misc/window\";\nimport hooks from \"../misc/hooks\";\n\ninterface InterceptReqOptions extends Omit {\n url?: URL | string;\n isFetch?: boolean;\n acceptedRequest?: boolean;\n}\n\n//browser's fetch\nconst Native: typeof fetch = windowRef.fetch;\n\nfunction copyToObjFromRequest(req: Request): any {\n const copyedKeys = [\n \"method\",\n \"headers\",\n \"body\",\n \"mode\",\n \"credentials\",\n \"cache\",\n \"redirect\",\n \"referrer\",\n \"referrerPolicy\",\n \"integrity\",\n \"keepalive\",\n \"signal\",\n \"url\",\n ];\n let copyedObj = {};\n copyedKeys.forEach(key => (copyedObj[key] = req[key]));\n return copyedObj;\n}\n\nfunction covertHeaderToPlainObj(headers: RequestInit[\"headers\"]) {\n if (headers instanceof Headers) {\n return covertTDAarryToObj([...headers.entries()]);\n }\n if (Array.isArray(headers)) {\n return covertTDAarryToObj(headers);\n }\n return headers;\n}\n\nfunction covertTDAarryToObj(input: T) {\n return input.reduce((prev, [key, value]) => {\n prev[key] = value;\n return prev;\n }, {});\n}\n\n/**\n * if fetch(hacked by Xhook) accept a Request as a first parameter, it will be destrcuted to a plain object.\n * Finally the whole network request was convert to fectch(Request.url, other options)\n */\nconst Xhook: typeof fetch = function (input, init = { headers: {} }) {\n let options: InterceptReqOptions = { ...init, isFetch: true };\n\n if (input instanceof Request) {\n const requestObj = copyToObjFromRequest(input);\n const prevHeaders = {\n ...covertHeaderToPlainObj(requestObj.headers),\n ...covertHeaderToPlainObj(options.headers),\n };\n options = {\n ...requestObj,\n ...init,\n headers: prevHeaders,\n acceptedRequest: true,\n };\n } else {\n options.url = input;\n }\n\n const beforeHooks = hooks.listeners(\"before\");\n const afterHooks = hooks.listeners(\"after\");\n\n return new Promise(function (resolve, reject) {\n let fullfiled = resolve;\n\n const processAfter = function (response) {\n if (!afterHooks.length) {\n return fullfiled(response);\n }\n\n const hook = afterHooks.shift();\n\n if (hook.length === 2) {\n hook(options, response);\n return processAfter(response);\n } else if (hook.length === 3) {\n return hook(options, response, processAfter);\n } else {\n return processAfter(response);\n }\n };\n\n const done = function (userResponse) {\n if (userResponse !== undefined) {\n const response = new Response(\n userResponse.body || userResponse.text,\n userResponse\n );\n resolve(response);\n processAfter(response);\n return;\n }\n\n //continue processing until no hooks left\n processBefore();\n };\n\n const processBefore = function () {\n if (!beforeHooks.length) {\n send();\n return;\n }\n\n const hook = beforeHooks.shift();\n\n if (hook.length === 1) {\n return done(hook(options));\n } else if (hook.length === 2) {\n return hook(options, done);\n }\n };\n\n const send = () => {\n const { url, isFetch, acceptedRequest, ...restInit } = options;\n Native(url, restInit)\n .then(response => processAfter(response))\n .catch(function (err) {\n fullfiled = reject;\n processAfter(err);\n return reject(err);\n });\n };\n\n processBefore();\n });\n};\n\n//patch interface\nexport default {\n patch() {\n if (Native) {\n windowRef.fetch = Xhook;\n }\n },\n unpatch() {\n if (Native) {\n windowRef.fetch = Native;\n }\n },\n Native,\n Xhook,\n};\n","import { EventEmitter } from \"./misc/event-emitter\";\nimport headers from \"./misc/headers\";\n\n//patchable types\nimport XMLHttpRequest from \"./patch/xmlhttprequest\";\nimport fetch from \"./patch/fetch\";\n\n//global state\nimport hooks from \"./misc/hooks\";\n//the global hooks event emitter is also the global xhook object\n//(not the best decision in hindsight)\nconst xhook = hooks;\nxhook.EventEmitter = EventEmitter;\n//modify hooks\nxhook.before = function (handler, i) {\n if (handler.length < 1 || handler.length > 2) {\n throw \"invalid hook\";\n }\n return xhook.on(\"before\", handler, i);\n};\nxhook.after = function (handler, i) {\n if (handler.length < 2 || handler.length > 3) {\n throw \"invalid hook\";\n }\n return xhook.on(\"after\", handler, i);\n};\n\n//globally enable/disable\nxhook.enable = function () {\n XMLHttpRequest.patch();\n fetch.patch();\n};\nxhook.disable = function () {\n XMLHttpRequest.unpatch();\n fetch.unpatch();\n};\n//expose native objects\nxhook.XMLHttpRequest = XMLHttpRequest.Native;\nxhook.fetch = fetch.Native;\n\n//expose helpers\nxhook.headers = headers.convert;\n\n//enable by default\nxhook.enable();\n\nexport default xhook;\n"],"names":["Native","Xhook"],"mappings":";;;;;EAAA,MAAM,KAAK,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAA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/dist/xhook.min.js b/dist/xhook.min.js new file mode 100644 index 0000000..5237acc --- /dev/null +++ b/dist/xhook.min.js @@ -0,0 +1,4 @@ +//XHook - v1.6.0 - https://github.com/jpillora/xhook +//Jaime Pillora - MIT Copyright 2023 +var xhook=function(){"use strict";const e=(e,t)=>Array.prototype.slice.call(e,t);let t=null;"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?t=self:"undefined"!=typeof global?t=global:window&&(t=window);const n=t,r=t.document,o=["load","loadend","loadstart"],s=["progress","abort","error","timeout"],a=e=>["returnValue","totalSize","position"].includes(e),i=function(e,t){for(let n in e){if(a(n))continue;const r=e[n];try{t[n]=r}catch(e){}}return t},c=function(e,t,n){const r=e=>function(r){const o={};for(let e in r){if(a(e))continue;const s=r[e];o[e]=s===t?n:s}return n.dispatchEvent(e,o)};for(let o of Array.from(e))n._has(o)&&(t[`on${o}`]=r(o))},u=function(e){if(r&&null!=r.createEventObject){const t=r.createEventObject();return t.type=e,t}try{return new Event(e)}catch(t){return{type:e}}},l=function(t){let n={};const r=e=>n[e]||[],o={addEventListener:function(e,t,o){n[e]=r(e),n[e].indexOf(t)>=0||(o=void 0===o?n[e].length:o,n[e].splice(o,0,t))},removeEventListener:function(e,t){if(void 0===e)return void(n={});void 0===t&&(n[e]=[]);const o=r(e).indexOf(t);-1!==o&&r(e).splice(o,1)},dispatchEvent:function(){const n=e(arguments),s=n.shift();t||(n[0]=i(n[0],u(s)));const a=o[`on${s}`];a&&a.apply(o,n);const c=r(s).concat(r("*"));for(let e=0;e!(!n[e]&&!o[`on${e}`])};return t&&(o.listeners=t=>e(r(t)),o.on=o.addEventListener,o.off=o.removeEventListener,o.fire=o.dispatchEvent,o.once=function(e,t){var n=function(){return o.off(e,n),t.apply(null,arguments)};return o.on(e,n)},o.destroy=()=>n={}),o};var f=function(e,t){switch(typeof e){case"object":return n=e,Object.entries(n).map((([e,t])=>`${e.toLowerCase()}: ${t}`)).join("\r\n");case"string":return function(e,t){const n=e.split("\r\n");null==t&&(t={});for(let e of n)if(/([^:]+):\s*(.+)/.test(e)){const e=null!=RegExp.$1?RegExp.$1.toLowerCase():void 0,n=RegExp.$2;null==t[e]&&(t[e]=n)}return t}(e,t)}var n;return[]};const d=l(!0),p=e=>void 0===e?null:e,h=n.XMLHttpRequest,y=function(){const e=new h,t={};let n,r,a,u=null;var y=0;const v=function(){if(a.status=u||e.status,-1!==u&&(a.statusText=e.statusText),-1===u);else{const t=f(e.getAllResponseHeaders());for(let e in t){const n=t[e];if(!a.headers[e]){const t=e.toLowerCase();a.headers[t]=n}}}},g=function(){x.status=a.status,x.statusText=a.statusText},E=function(){n||x.dispatchEvent("load",{}),x.dispatchEvent("loadend",{}),n&&(x.readyState=0)},b=function(e){for(;e>y&&y<4;)x.readyState=++y,1===y&&x.dispatchEvent("loadstart",{}),2===y&&g(),4===y&&(g(),"text"in a&&(x.responseText=a.text),"xml"in a&&(x.responseXML=a.xml),"data"in a&&(x.response=a.data),"finalUrl"in a&&(x.responseURL=a.finalUrl)),x.dispatchEvent("readystatechange",{}),4===y&&(!1===t.async?E():setTimeout(E,0))},m=function(e){if(4!==e)return void b(e);const n=d.listeners("after");var r=function(){if(n.length>0){const e=n.shift();2===e.length?(e(t,a),r()):3===e.length&&t.async?e(t,a,r):r()}else b(4)};r()};var x=l();t.xhr=x,e.onreadystatechange=function(t){try{2===e.readyState&&v()}catch(e){}4===e.readyState&&(r=!1,v(),function(){if(e.responseType&&"text"!==e.responseType)"document"===e.responseType?(a.xml=e.responseXML,a.data=e.responseXML):a.data=e.response;else{a.text=e.responseText,a.data=e.responseText;try{a.xml=e.responseXML}catch(e){}}"responseURL"in e&&(a.finalUrl=e.responseURL)}()),m(e.readyState)};const L=function(){n=!0};x.addEventListener("error",L),x.addEventListener("timeout",L),x.addEventListener("abort",L),x.addEventListener("progress",(function(t){y<3?m(3):e.readyState<=3&&x.dispatchEvent("readystatechange",{})})),"withCredentials"in e&&(x.withCredentials=!1),x.status=0;for(let e of Array.from(s.concat(o)))x[`on${e}`]=null;if(x.open=function(e,o,s,i,c){y=0,n=!1,r=!1,t.headers={},t.headerNames={},t.status=0,t.method=e,t.url=o,t.async=!1!==s,t.user=i,t.pass=c,a={},a.headers={},m(1)},x.send=function(n){let u,l;for(u of["type","timeout","withCredentials"])l="type"===u?"responseType":u,l in x&&(t[u]=x[l]);t.body=n;const f=d.listeners("before");var p=function(){if(!f.length)return function(){for(u of(c(s,e,x),x.upload&&c(s.concat(o),e.upload,x.upload),r=!0,e.open(t.method,t.url,t.async,t.user,t.pass),["type","timeout","withCredentials"]))l="type"===u?"responseType":u,u in t&&(e[l]=t[u]);for(let n in t.headers){const r=t.headers[n];n&&e.setRequestHeader(n,r)}e.send(t.body)}();const n=function(e){if("object"==typeof e&&("number"==typeof e.status||"number"==typeof a.status))return i(e,a),"data"in e||(e.data=e.response||e.text),void m(4);p()};n.head=function(e){i(e,a),m(2)},n.progress=function(e){i(e,a),m(3)};const d=f.shift();1===d.length?n(d(t)):2===d.length&&t.async?d(t,n):n()};p()},x.abort=function(){u=-1,r?e.abort():x.dispatchEvent("abort",{})},x.setRequestHeader=function(e,n){const r=null!=e?e.toLowerCase():void 0,o=t.headerNames[r]=t.headerNames[r]||e;t.headers[o]&&(n=t.headers[o]+", "+n),t.headers[o]=n},x.getResponseHeader=e=>p(a.headers[e?e.toLowerCase():void 0]),x.getAllResponseHeaders=()=>p(f(a.headers)),e.overrideMimeType&&(x.overrideMimeType=function(){e.overrideMimeType.apply(e,arguments)}),e.upload){let e=l();x.upload=e,t.upload=e}return x.UNSENT=0,x.OPENED=1,x.HEADERS_RECEIVED=2,x.LOADING=3,x.DONE=4,x.response="",x.responseText="",x.responseXML=null,x.readyState=0,x.statusText="",x};y.UNSENT=0,y.OPENED=1,y.HEADERS_RECEIVED=2,y.LOADING=3,y.DONE=4;var v={patch(){h&&(n.XMLHttpRequest=y)},unpatch(){h&&(n.XMLHttpRequest=h)},Native:h,Xhook:y};const g=n.fetch;function E(e){return e instanceof Headers?b([...e.entries()]):Array.isArray(e)?b(e):e}function b(e){return e.reduce(((e,[t,n])=>(e[t]=n,e)),{})}const m=function(e,t={headers:{}}){let n=Object.assign(Object.assign({},t),{isFetch:!0});if(e instanceof Request){const r=function(e){let t={};return["method","headers","body","mode","credentials","cache","redirect","referrer","referrerPolicy","integrity","keepalive","signal","url"].forEach((n=>t[n]=e[n])),t}(e),o=Object.assign(Object.assign({},E(r.headers)),E(n.headers));n=Object.assign(Object.assign(Object.assign({},r),t),{headers:o,acceptedRequest:!0})}else n.url=e;const r=d.listeners("before"),o=d.listeners("after");return new Promise((function(e,t){let s=e;const a=function(e){if(!o.length)return s(e);const t=o.shift();return 2===t.length?(t(n,e),a(e)):3===t.length?t(n,e,a):a(e)},i=function(t){if(void 0!==t){const n=new Response(t.body||t.text,t);return e(n),void a(n)}c()},c=function(){if(!r.length)return void u();const e=r.shift();return 1===e.length?i(e(n)):2===e.length?e(n,i):void 0},u=()=>{const{url:e,isFetch:r,acceptedRequest:o}=n,i=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);oa(e))).catch((function(e){return s=t,a(e),t(e)}))};c()}))};var x={patch(){g&&(n.fetch=m)},unpatch(){g&&(n.fetch=g)},Native:g,Xhook:m};const L=d;return L.EventEmitter=l,L.before=function(e,t){if(e.length<1||e.length>2)throw"invalid hook";return L.on("before",e,t)},L.after=function(e,t){if(e.length<2||e.length>3)throw"invalid hook";return L.on("after",e,t)},L.enable=function(){v.patch(),x.patch()},L.disable=function(){v.unpatch(),x.unpatch()},L.XMLHttpRequest=v.Native,L.fetch=x.Native,L.headers=f,L.enable(),L}(); +//# sourceMappingURL=xhook.min.js.map diff --git a/dist/xhook.min.js.map b/dist/xhook.min.js.map new file mode 100644 index 0000000..636e1e8 --- /dev/null +++ b/dist/xhook.min.js.map @@ -0,0 +1 @@ +{"version":3,"file":"xhook.min.js","sources":["../src/misc/array.js","../src/misc/window.js","../src/misc/events.js","../src/misc/event-emitter.js","../src/misc/headers.js","../src/misc/hooks.js","../src/patch/xmlhttprequest.js","../src/patch/fetch.ts","../node_modules/tslib/tslib.es6.js","../src/main.js"],"sourcesContent":["const slice = (o, n) => Array.prototype.slice.call(o, n);\n\nexport { slice };\n","let result = null;\n\n//find global object\nif (\n typeof WorkerGlobalScope !== \"undefined\" &&\n self instanceof WorkerGlobalScope\n) {\n result = self;\n} else if (typeof global !== \"undefined\") {\n result = global;\n} else if (window) {\n result = window;\n}\n\nexport const windowRef = result;\nexport const documentRef = result.document;\n","import { documentRef } from \"./window\";\n\nexport const UPLOAD_EVENTS = [\"load\", \"loadend\", \"loadstart\"];\nexport const COMMON_EVENTS = [\"progress\", \"abort\", \"error\", \"timeout\"];\n\nconst depricatedProp = p =>\n [\"returnValue\", \"totalSize\", \"position\"].includes(p);\n\nexport const mergeObjects = function (src, dst) {\n for (let k in src) {\n if (depricatedProp(k)) {\n continue;\n }\n const v = src[k];\n try {\n dst[k] = v;\n } catch (error) {}\n }\n return dst;\n};\n\n//proxy events from one emitter to another\nexport const proxyEvents = function (events, src, dst) {\n const p = event =>\n function (e) {\n const clone = {};\n //copies event, with dst emitter inplace of src\n for (let k in e) {\n if (depricatedProp(k)) {\n continue;\n }\n const val = e[k];\n clone[k] = val === src ? dst : val;\n }\n //emits out the dst\n return dst.dispatchEvent(event, clone);\n };\n //dont proxy manual events\n for (let event of Array.from(events)) {\n if (dst._has(event)) {\n src[`on${event}`] = p(event);\n }\n }\n};\n\n//create fake event\nexport const fakeEvent = function (type) {\n if (documentRef && documentRef.createEventObject != null) {\n const msieEventObject = documentRef.createEventObject();\n msieEventObject.type = type;\n return msieEventObject;\n }\n // on some platforms like android 4.1.2 and safari on windows, it appears\n // that new Event is not allowed\n try {\n return new Event(type);\n } catch (error) {\n return { type };\n }\n};\n","import { slice } from \"./array\";\nimport { mergeObjects, fakeEvent } from \"./events\";\n\n//tiny event emitter\nexport const EventEmitter = function (nodeStyle) {\n //private\n let events = {};\n const listeners = event => events[event] || [];\n //public\n const emitter = {};\n emitter.addEventListener = function (event, callback, i) {\n events[event] = listeners(event);\n if (events[event].indexOf(callback) >= 0) {\n return;\n }\n i = i === undefined ? events[event].length : i;\n events[event].splice(i, 0, callback);\n };\n emitter.removeEventListener = function (event, callback) {\n //remove all\n if (event === undefined) {\n events = {};\n return;\n }\n //remove all of type event\n if (callback === undefined) {\n events[event] = [];\n }\n //remove particular handler\n const i = listeners(event).indexOf(callback);\n if (i === -1) {\n return;\n }\n listeners(event).splice(i, 1);\n };\n emitter.dispatchEvent = function () {\n const args = slice(arguments);\n const event = args.shift();\n if (!nodeStyle) {\n args[0] = mergeObjects(args[0], fakeEvent(event));\n }\n const legacylistener = emitter[`on${event}`];\n if (legacylistener) {\n legacylistener.apply(emitter, args);\n }\n const iterable = listeners(event).concat(listeners(\"*\"));\n for (let i = 0; i < iterable.length; i++) {\n const listener = iterable[i];\n listener.apply(emitter, args);\n }\n };\n emitter._has = event => !!(events[event] || emitter[`on${event}`]);\n //add extra aliases\n if (nodeStyle) {\n emitter.listeners = event => slice(listeners(event));\n emitter.on = emitter.addEventListener;\n emitter.off = emitter.removeEventListener;\n emitter.fire = emitter.dispatchEvent;\n emitter.once = function (e, fn) {\n var fire = function () {\n emitter.off(e, fire);\n return fn.apply(null, arguments);\n };\n return emitter.on(e, fire);\n };\n emitter.destroy = () => (events = {});\n }\n\n return emitter;\n};\n","//helper\nconst CRLF = \"\\r\\n\";\n\nconst objectToString = function (headersObj) {\n const entries = Object.entries(headersObj);\n\n const headers = entries.map(([name, value]) => {\n return `${name.toLowerCase()}: ${value}`;\n });\n\n return headers.join(CRLF);\n};\n\nconst stringToObject = function (headersString, dest) {\n const headers = headersString.split(CRLF);\n if (dest == null) {\n dest = {};\n }\n\n for (let header of headers) {\n if (/([^:]+):\\s*(.+)/.test(header)) {\n const name = RegExp.$1 != null ? RegExp.$1.toLowerCase() : undefined;\n const value = RegExp.$2;\n if (dest[name] == null) {\n dest[name] = value;\n }\n }\n }\n\n return dest;\n};\n\nconst convert = function (headers, dest) {\n switch (typeof headers) {\n case \"object\": {\n return objectToString(headers);\n }\n case \"string\": {\n return stringToObject(headers, dest);\n }\n }\n\n return [];\n};\n\nexport default { convert };\n","import { EventEmitter } from \"./event-emitter\";\n\n//global set of hook functions,\n//uses event emitter to store hooks\nconst hooks = EventEmitter(true);\n\nexport default hooks;\n","import { windowRef } from \"../misc/window\";\nimport {\n proxyEvents,\n mergeObjects,\n COMMON_EVENTS,\n UPLOAD_EVENTS,\n} from \"../misc/events\";\nimport { EventEmitter } from \"../misc/event-emitter\";\nimport headers from \"../misc/headers\";\nimport hooks from \"../misc/hooks\";\n\nconst nullify = res => (res === undefined ? null : res);\n\n//browser's XMLHttpRequest\nconst Native = windowRef.XMLHttpRequest;\n\n//xhook's XMLHttpRequest\nconst Xhook = function () {\n const ABORTED = -1;\n const xhr = new Native();\n\n //==========================\n // Extra state\n const request = {};\n let status = null;\n let hasError = undefined;\n let transiting = undefined;\n let response = undefined;\n var currentState = 0;\n\n //==========================\n // Private API\n\n //read results from real xhr into response\n const readHead = function () {\n // Accessing attributes on an aborted xhr object will\n // throw an 'c00c023f error' in IE9 and lower, don't touch it.\n response.status = status || xhr.status;\n if (status !== ABORTED) {\n response.statusText = xhr.statusText;\n }\n if (status !== ABORTED) {\n const object = headers.convert(xhr.getAllResponseHeaders());\n for (let key in object) {\n const val = object[key];\n if (!response.headers[key]) {\n const name = key.toLowerCase();\n response.headers[name] = val;\n }\n }\n return;\n }\n };\n\n const readBody = function () {\n //https://xhr.spec.whatwg.org/\n if (!xhr.responseType || xhr.responseType === \"text\") {\n response.text = xhr.responseText;\n response.data = xhr.responseText;\n try {\n response.xml = xhr.responseXML;\n } catch (error) {}\n // unable to set responseXML due to response type, we attempt to assign responseXML\n // when the type is text even though it's against the spec due to several libraries\n // and browser vendors who allow this behavior. causing these requests to fail when\n // xhook is installed on a page.\n } else if (xhr.responseType === \"document\") {\n response.xml = xhr.responseXML;\n response.data = xhr.responseXML;\n } else {\n response.data = xhr.response;\n }\n //new in some browsers\n if (\"responseURL\" in xhr) {\n response.finalUrl = xhr.responseURL;\n }\n };\n\n //write response into facade xhr\n const writeHead = function () {\n facade.status = response.status;\n facade.statusText = response.statusText;\n };\n\n const writeBody = function () {\n if (\"text\" in response) {\n facade.responseText = response.text;\n }\n if (\"xml\" in response) {\n facade.responseXML = response.xml;\n }\n if (\"data\" in response) {\n facade.response = response.data;\n }\n if (\"finalUrl\" in response) {\n facade.responseURL = response.finalUrl;\n }\n };\n\n const emitFinal = function () {\n if (!hasError) {\n facade.dispatchEvent(\"load\", {});\n }\n facade.dispatchEvent(\"loadend\", {});\n if (hasError) {\n facade.readyState = 0;\n }\n };\n\n //ensure ready state 0 through 4 is handled\n const emitReadyState = function (n) {\n while (n > currentState && currentState < 4) {\n facade.readyState = ++currentState;\n // make fake events for libraries that actually check the type on\n // the event object\n if (currentState === 1) {\n facade.dispatchEvent(\"loadstart\", {});\n }\n if (currentState === 2) {\n writeHead();\n }\n if (currentState === 4) {\n writeHead();\n writeBody();\n }\n facade.dispatchEvent(\"readystatechange\", {});\n //delay final events incase of error\n if (currentState === 4) {\n if (request.async === false) {\n emitFinal();\n } else {\n setTimeout(emitFinal, 0);\n }\n }\n }\n };\n\n //control facade ready state\n const setReadyState = function (n) {\n //emit events until readyState reaches 4\n if (n !== 4) {\n emitReadyState(n);\n return;\n }\n //before emitting 4, run all 'after' hooks in sequence\n const afterHooks = hooks.listeners(\"after\");\n var process = function () {\n if (afterHooks.length > 0) {\n //execute each 'before' hook one at a time\n const hook = afterHooks.shift();\n if (hook.length === 2) {\n hook(request, response);\n process();\n } else if (hook.length === 3 && request.async) {\n hook(request, response, process);\n } else {\n process();\n }\n } else {\n //response ready for reading\n emitReadyState(4);\n }\n return;\n };\n process();\n };\n\n //==========================\n // Facade XHR\n var facade = EventEmitter();\n request.xhr = facade;\n\n // Handle the underlying ready state\n xhr.onreadystatechange = function (event) {\n //pull status and headers\n try {\n if (xhr.readyState === 2) {\n readHead();\n }\n } catch (error) {}\n //pull response data\n if (xhr.readyState === 4) {\n transiting = false;\n readHead();\n readBody();\n }\n\n setReadyState(xhr.readyState);\n };\n\n //mark this xhr as errored\n const hasErrorHandler = function () {\n hasError = true;\n };\n facade.addEventListener(\"error\", hasErrorHandler);\n facade.addEventListener(\"timeout\", hasErrorHandler);\n facade.addEventListener(\"abort\", hasErrorHandler);\n // progress means we're current downloading...\n facade.addEventListener(\"progress\", function (event) {\n if (currentState < 3) {\n setReadyState(3);\n } else if (xhr.readyState <= 3) {\n //until ready (4), each progress event is followed by readystatechange...\n facade.dispatchEvent(\"readystatechange\", {}); //TODO fake an XHR event\n }\n });\n\n // initialise 'withCredentials' on facade xhr in browsers with it\n // or if explicitly told to do so\n if (\"withCredentials\" in xhr) {\n facade.withCredentials = false;\n }\n facade.status = 0;\n\n // initialise all possible event handlers\n for (let event of Array.from(COMMON_EVENTS.concat(UPLOAD_EVENTS))) {\n facade[`on${event}`] = null;\n }\n\n facade.open = function (method, url, async, user, pass) {\n // Initailize empty XHR facade\n currentState = 0;\n hasError = false;\n transiting = false;\n //reset request\n request.headers = {};\n request.headerNames = {};\n request.status = 0;\n request.method = method;\n request.url = url;\n request.async = async !== false;\n request.user = user;\n request.pass = pass;\n //reset response\n response = {};\n response.headers = {};\n // openned facade xhr (not real xhr)\n setReadyState(1);\n };\n\n facade.send = function (body) {\n //read xhr settings before hooking\n let k, modk;\n for (k of [\"type\", \"timeout\", \"withCredentials\"]) {\n modk = k === \"type\" ? \"responseType\" : k;\n if (modk in facade) {\n request[k] = facade[modk];\n }\n }\n\n request.body = body;\n const send = function () {\n //proxy all events from real xhr to facade\n proxyEvents(COMMON_EVENTS, xhr, facade);\n //proxy all upload events from the real to the upload facade\n if (facade.upload) {\n proxyEvents(\n COMMON_EVENTS.concat(UPLOAD_EVENTS),\n xhr.upload,\n facade.upload\n );\n }\n\n //prepare request all at once\n transiting = true;\n //perform open\n xhr.open(\n request.method,\n request.url,\n request.async,\n request.user,\n request.pass\n );\n\n //write xhr settings\n for (k of [\"type\", \"timeout\", \"withCredentials\"]) {\n modk = k === \"type\" ? \"responseType\" : k;\n if (k in request) {\n xhr[modk] = request[k];\n }\n }\n\n //insert headers\n for (let header in request.headers) {\n const value = request.headers[header];\n if (header) {\n xhr.setRequestHeader(header, value);\n }\n }\n //real send!\n xhr.send(request.body);\n };\n\n const beforeHooks = hooks.listeners(\"before\");\n //process beforeHooks sequentially\n var process = function () {\n if (!beforeHooks.length) {\n return send();\n }\n //go to next hook OR optionally provide response\n const done = function (userResponse) {\n //break chain - provide dummy response (readyState 4)\n if (\n typeof userResponse === \"object\" &&\n (typeof userResponse.status === \"number\" ||\n typeof response.status === \"number\")\n ) {\n mergeObjects(userResponse, response);\n if (!(\"data\" in userResponse)) {\n userResponse.data = userResponse.response || userResponse.text;\n }\n setReadyState(4);\n return;\n }\n //continue processing until no beforeHooks left\n process();\n };\n //specifically provide headers (readyState 2)\n done.head = function (userResponse) {\n mergeObjects(userResponse, response);\n setReadyState(2);\n };\n //specifically provide partial text (responseText readyState 3)\n done.progress = function (userResponse) {\n mergeObjects(userResponse, response);\n setReadyState(3);\n };\n\n const hook = beforeHooks.shift();\n //async or sync?\n if (hook.length === 1) {\n done(hook(request));\n } else if (hook.length === 2 && request.async) {\n //async handlers must use an async xhr\n hook(request, done);\n } else {\n //skip async hook on sync requests\n done();\n }\n return;\n };\n //kick off\n process();\n };\n\n facade.abort = function () {\n status = ABORTED;\n if (transiting) {\n xhr.abort(); //this will emit an 'abort' for us\n } else {\n facade.dispatchEvent(\"abort\", {});\n }\n };\n\n facade.setRequestHeader = function (header, value) {\n //the first header set is used for all future case-alternatives of 'name'\n const lName = header != null ? header.toLowerCase() : undefined;\n const name = (request.headerNames[lName] =\n request.headerNames[lName] || header);\n //append header to any previous values\n if (request.headers[name]) {\n value = request.headers[name] + \", \" + value;\n }\n request.headers[name] = value;\n };\n facade.getResponseHeader = header =>\n nullify(response.headers[header ? header.toLowerCase() : undefined]);\n\n facade.getAllResponseHeaders = () =>\n nullify(headers.convert(response.headers));\n\n //proxy call only when supported\n if (xhr.overrideMimeType) {\n facade.overrideMimeType = function () {\n xhr.overrideMimeType.apply(xhr, arguments);\n };\n }\n\n //create emitter when supported\n if (xhr.upload) {\n let up = EventEmitter();\n facade.upload = up;\n request.upload = up;\n }\n\n facade.UNSENT = 0;\n facade.OPENED = 1;\n facade.HEADERS_RECEIVED = 2;\n facade.LOADING = 3;\n facade.DONE = 4;\n\n // fill in default values for an empty XHR object according to the spec\n facade.response = \"\";\n facade.responseText = \"\";\n facade.responseXML = null;\n facade.readyState = 0;\n facade.statusText = \"\";\n\n return facade;\n};\n\nXhook.UNSENT = 0;\nXhook.OPENED = 1;\nXhook.HEADERS_RECEIVED = 2;\nXhook.LOADING = 3;\nXhook.DONE = 4;\n\n//patch interface\nexport default {\n patch() {\n if (Native) {\n windowRef.XMLHttpRequest = Xhook;\n }\n },\n unpatch() {\n if (Native) {\n windowRef.XMLHttpRequest = Native;\n }\n },\n Native,\n Xhook,\n};\n","import { windowRef } from \"../misc/window\";\nimport hooks from \"../misc/hooks\";\n\ninterface InterceptReqOptions extends Omit {\n url?: URL | string;\n isFetch?: boolean;\n acceptedRequest?: boolean;\n}\n\n//browser's fetch\nconst Native: typeof fetch = windowRef.fetch;\n\nfunction copyToObjFromRequest(req: Request): any {\n const copyedKeys = [\n \"method\",\n \"headers\",\n \"body\",\n \"mode\",\n \"credentials\",\n \"cache\",\n \"redirect\",\n \"referrer\",\n \"referrerPolicy\",\n \"integrity\",\n \"keepalive\",\n \"signal\",\n \"url\",\n ];\n let copyedObj = {};\n copyedKeys.forEach(key => (copyedObj[key] = req[key]));\n return copyedObj;\n}\n\nfunction covertHeaderToPlainObj(headers: RequestInit[\"headers\"]) {\n if (headers instanceof Headers) {\n return covertTDAarryToObj([...headers.entries()]);\n }\n if (Array.isArray(headers)) {\n return covertTDAarryToObj(headers);\n }\n return headers;\n}\n\nfunction covertTDAarryToObj(input: T) {\n return input.reduce((prev, [key, value]) => {\n prev[key] = value;\n return prev;\n }, {});\n}\n\n/**\n * if fetch(hacked by Xhook) accept a Request as a first parameter, it will be destrcuted to a plain object.\n * Finally the whole network request was convert to fectch(Request.url, other options)\n */\nconst Xhook: typeof fetch = function (input, init = { headers: {} }) {\n let options: InterceptReqOptions = { ...init, isFetch: true };\n\n if (input instanceof Request) {\n const requestObj = copyToObjFromRequest(input);\n const prevHeaders = {\n ...covertHeaderToPlainObj(requestObj.headers),\n ...covertHeaderToPlainObj(options.headers),\n };\n options = {\n ...requestObj,\n ...init,\n headers: prevHeaders,\n acceptedRequest: true,\n };\n } else {\n options.url = input;\n }\n\n const beforeHooks = hooks.listeners(\"before\");\n const afterHooks = hooks.listeners(\"after\");\n\n return new Promise(function (resolve, reject) {\n let fullfiled = resolve;\n\n const processAfter = function (response) {\n if (!afterHooks.length) {\n return fullfiled(response);\n }\n\n const hook = afterHooks.shift();\n\n if (hook.length === 2) {\n hook(options, response);\n return processAfter(response);\n } else if (hook.length === 3) {\n return hook(options, response, processAfter);\n } else {\n return processAfter(response);\n }\n };\n\n const done = function (userResponse) {\n if (userResponse !== undefined) {\n const response = new Response(\n userResponse.body || userResponse.text,\n userResponse\n );\n resolve(response);\n processAfter(response);\n return;\n }\n\n //continue processing until no hooks left\n processBefore();\n };\n\n const processBefore = function () {\n if (!beforeHooks.length) {\n send();\n return;\n }\n\n const hook = beforeHooks.shift();\n\n if (hook.length === 1) {\n return done(hook(options));\n } else if (hook.length === 2) {\n return hook(options, done);\n }\n };\n\n const send = () => {\n const { url, isFetch, acceptedRequest, ...restInit } = options;\n Native(url, restInit)\n .then(response => processAfter(response))\n .catch(function (err) {\n fullfiled = reject;\n processAfter(err);\n return reject(err);\n });\n };\n\n processBefore();\n });\n};\n\n//patch interface\nexport default {\n patch() {\n if (Native) {\n windowRef.fetch = Xhook;\n }\n },\n unpatch() {\n if (Native) {\n windowRef.fetch = Native;\n }\n },\n Native,\n Xhook,\n};\n","/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n","import { EventEmitter } from \"./misc/event-emitter\";\nimport headers from \"./misc/headers\";\n\n//patchable types\nimport XMLHttpRequest from \"./patch/xmlhttprequest\";\nimport fetch from \"./patch/fetch\";\n\n//global state\nimport hooks from \"./misc/hooks\";\n//the global hooks event emitter is also the global xhook object\n//(not the best decision in hindsight)\nconst xhook = hooks;\nxhook.EventEmitter = EventEmitter;\n//modify hooks\nxhook.before = function (handler, i) {\n if (handler.length < 1 || handler.length > 2) {\n throw \"invalid hook\";\n }\n return xhook.on(\"before\", handler, i);\n};\nxhook.after = function (handler, i) {\n if (handler.length < 2 || handler.length > 3) {\n throw \"invalid hook\";\n }\n return xhook.on(\"after\", handler, i);\n};\n\n//globally enable/disable\nxhook.enable = function () {\n XMLHttpRequest.patch();\n fetch.patch();\n};\nxhook.disable = function () {\n XMLHttpRequest.unpatch();\n fetch.unpatch();\n};\n//expose native objects\nxhook.XMLHttpRequest = XMLHttpRequest.Native;\nxhook.fetch = fetch.Native;\n\n//expose helpers\nxhook.headers = headers.convert;\n\n//enable by default\nxhook.enable();\n\nexport default xhook;\n"],"names":["slice","o","n","Array","prototype","call","result","WorkerGlobalScope","self","global","window","windowRef","documentRef","document","UPLOAD_EVENTS","COMMON_EVENTS","depricatedProp","p","includes","mergeObjects","src","dst","k","v","error","proxyEvents","events","event","e","clone","val","dispatchEvent","from","_has","fakeEvent","type","createEventObject","msieEventObject","Event","EventEmitter","nodeStyle","listeners","emitter","callback","i","indexOf","undefined","length","splice","args","arguments","shift","legacylistener","apply","iterable","concat","on","addEventListener","off","removeEventListener","fire","once","fn","destroy","headers","dest","headersObj","Object","entries","map","name","value","toLowerCase","join","headersString","split","header","test","RegExp","$1","$2","stringToObject","hooks","nullify","res","Native","XMLHttpRequest","Xhook","xhr","request","hasError","transiting","response","status","currentState","readHead","statusText","object","getAllResponseHeaders","key","writeHead","facade","emitFinal","readyState","emitReadyState","responseText","text","responseXML","xml","data","responseURL","finalUrl","async","setTimeout","setReadyState","afterHooks","process","hook","onreadystatechange","responseType","readBody","hasErrorHandler","withCredentials","open","method","url","user","pass","headerNames","send","body","modk","beforeHooks","upload","setRequestHeader","done","userResponse","head","progress","abort","lName","getResponseHeader","overrideMimeType","up","UNSENT","OPENED","HEADERS_RECEIVED","LOADING","DONE","patch","unpatch","fetch","covertHeaderToPlainObj","Headers","covertTDAarryToObj","isArray","input","reduce","prev","init","options","isFetch","Request","requestObj","req","copyedObj","forEach","copyToObjFromRequest","prevHeaders","assign","acceptedRequest","Promise","resolve","reject","fullfiled","processAfter","Response","processBefore","restInit","s","t","hasOwnProperty","getOwnPropertySymbols","propertyIsEnumerable","__rest","then","catch","err","xhook","before","handler","after","enable","disable"],"mappings":";;kCAAA,MAAMA,EAAQ,CAACC,EAAGC,IAAMC,MAAMC,UAAUJ,MAAMK,KAAKJ,EAAGC,GCAtD,IAAII,EAAS,KAIkB,oBAAtBC,mBACPC,gBAAgBD,kBAEhBD,EAASE,KACkB,oBAAXC,OAChBH,EAASG,OACAC,SACTJ,EAASI,QAGJ,MAAMC,EAAYL,EACZM,EAAcN,EAAOO,SCbrBC,EAAgB,CAAC,OAAQ,UAAW,aACpCC,EAAgB,CAAC,WAAY,QAAS,QAAS,WAEtDC,EAAiBC,GACrB,CAAC,cAAe,YAAa,YAAYC,SAASD,GAEvCE,EAAe,SAAUC,EAAKC,GACzC,IAAK,IAAIC,KAAKF,EAAK,CACjB,GAAIJ,EAAeM,GACjB,SAEF,MAAMC,EAAIH,EAAIE,GACd,IACED,EAAIC,GAAKC,CACO,CAAhB,MAAOC,GAAS,CACnB,CACD,OAAOH,CACT,EAGaI,EAAc,SAAUC,EAAQN,EAAKC,GAChD,MAAMJ,EAAIU,GACR,SAAUC,GACR,MAAMC,EAAQ,CAAA,EAEd,IAAK,IAAIP,KAAKM,EAAG,CACf,GAAIZ,EAAeM,GACjB,SAEF,MAAMQ,EAAMF,EAAEN,GACdO,EAAMP,GAAKQ,IAAQV,EAAMC,EAAMS,CAChC,CAED,OAAOT,EAAIU,cAAcJ,EAAOE,EACtC,EAEE,IAAK,IAAIF,KAASxB,MAAM6B,KAAKN,GACvBL,EAAIY,KAAKN,KACXP,EAAI,KAAKO,KAAWV,EAAEU,GAG5B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I,CAAAxB,EAAjD,CAAA,MAAA,UAAA,oBACN3E,EAAOwC,EAAKqD,GACTO,MAAK7F,GAAYmF,EAAanF,KAC9B8F,OAAM,SAAUC,GAGf,OAFAb,EAAYD,EACZE,EAAaY,GACNd,EAAOc,EAChB,GAAE,EAGNV,GACF,GACF,EAGe,IAAA1B,EAAA,CACbF,QACMhE,IACF1E,EAAU4I,MAAQhE,EAErB,EACD+D,UACMjE,IACF1E,EAAU4I,MAAQlE,EAErB,EACDA,SACAE,SE/II,MAAAqG,EAAQ1G,SACd0G,EAAMrJ,aAAeA,EAErBqJ,EAAMC,OAAS,SAAUC,EAASlJ,GAChC,GAAIkJ,EAAQ/I,OAAS,GAAK+I,EAAQ/I,OAAS,EACzC,KAAM,eAER,OAAO6I,EAAMpI,GAAG,SAAUsI,EAASlJ,EACrC,EACAgJ,EAAMG,MAAQ,SAAUD,EAASlJ,GAC/B,GAAIkJ,EAAQ/I,OAAS,GAAK+I,EAAQ/I,OAAS,EACzC,KAAM,eAER,OAAO6I,EAAMpI,GAAG,QAASsI,EAASlJ,EACpC,EAGAgJ,EAAMI,OAAS,WACb1G,EAAe+D,QACfE,EAAMF,OACR,EACAuC,EAAMK,QAAU,WACd3G,EAAegE,UACfC,EAAMD,SACR,EAEAsC,EAAMtG,eAAiBA,EAAeD,OACtCuG,EAAMrC,MAAQA,EAAMlE,OAGpBuG,EAAM5H,QAAUA,EAGhB4H,EAAMI"} \ No newline at end of file diff --git a/package.json b/package.json index 7240762..8fbc370 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xhook", - "version": "0.0.0-git-tag", + "version": "1.6.0", "description": "Easily intercept and modify XHR request and response", "main": "lib/main.js", "module": "es/main.js",