xVASynth / lib /AbortControllerPolyfill.js
Pendrokar's picture
xVASynth v3 code for English
19c8b95
raw history blame
No virus
17.5 kB
/* Polyfill service v3.105.0
* Disable minification (remove `.min` from URL path) for more info */
(function(self, undefined) {!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.WHATWGFetch={})}(this,function(t){"use strict";function e(t){return t&&DataView.prototype.isPrototypeOf(t)}function r(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function o(t){return"string"!=typeof t&&(t=String(t)),t}function n(t){var e={next:function(){var e=t.shift();return{done:e===undefined,value:e}}};return v.iterable&&(e[Symbol.iterator]=function(){return e}),e}function i(t){this.map={},t instanceof i?t.forEach(function(t,e){this.append(e,t)},this):Array.isArray(t)?t.forEach(function(t){this.append(t[0],t[1])},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}function s(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function a(t){return new Promise(function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}})}function f(t){var e=new FileReader,r=a(e);return e.readAsArrayBuffer(t),r}function u(t){var e=new FileReader,r=a(e);return e.readAsText(t),r}function h(t){for(var e=new Uint8Array(t),r=new Array(e.length),o=0;o<e.length;o++)r[o]=String.fromCharCode(e[o]);return r.join("")}function d(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function c(){return this.bodyUsed=!1,this._initBody=function(t){this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:v.blob&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:v.formData&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:v.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():v.arrayBuffer&&v.blob&&e(t)?(this._bodyArrayBuffer=d(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):v.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(t)||A(t))?this._bodyArrayBuffer=d(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):v.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},v.blob&&(this.blob=function(){var t=s(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?s(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(f)}),this.text=function(){var t=s(this);if(t)return t;if(this._bodyBlob)return u(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(h(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},v.formData&&(this.formData=function(){return this.text().then(l)}),this.json=function(){return this.text().then(JSON.parse)},this}function y(t){var e=t.toUpperCase();return _.indexOf(e)>-1?e:t}function p(t,e){e=e||{};var r=e.body;if(t instanceof p){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new i(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,r||null==t._bodyInit||(r=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",!e.headers&&this.headers||(this.headers=new i(e.headers)),this.method=y(e.method||this.method||"GET"),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&r)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(r)}function l(t){var e=new FormData;return t.trim().split("&").forEach(function(t){if(t){var r=t.split("="),o=r.shift().replace(/\+/g," "),n=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(o),decodeURIComponent(n))}}),e}function b(t){var e=new i;return t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(t){var r=t.split(":"),o=r.shift().trim();if(o){var n=r.join(":").trim();e.append(o,n)}}),e}function m(t,e){e||(e={}),this.type="default",this.status=e.status===undefined?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new i(e.headers),this.url=e.url||"",this._initBody(t)}function w(e,r){return new Promise(function(o,n){function i(){a.abort()}var s=new p(e,r);if(s.signal&&s.signal.aborted)return n(new t.DOMException("Aborted","AbortError"));var a=new XMLHttpRequest;a.onload=function(){var t={status:a.status,statusText:a.statusText,headers:b(a.getAllResponseHeaders()||"")};t.url="responseURL"in a?a.responseURL:t.headers.get("X-Request-URL");var e="response"in a?a.response:a.responseText;o(new m(e,t))},a.onerror=function(){n(new TypeError("Network request failed"))},a.ontimeout=function(){n(new TypeError("Network request failed"))},a.onabort=function(){n(new t.DOMException("Aborted","AbortError"))},a.open(s.method,s.url,!0),"include"===s.credentials?a.withCredentials=!0:"omit"===s.credentials&&(a.withCredentials=!1),"responseType"in a&&v.blob&&(a.responseType="blob"),s.headers.forEach(function(t,e){a.setRequestHeader(e,t)}),s.signal&&(s.signal.addEventListener("abort",i),a.onreadystatechange=function(){4===a.readyState&&s.signal.removeEventListener("abort",i)}),a.send("undefined"==typeof s._bodyInit?null:s._bodyInit)})}var v={searchParams:"URLSearchParams"in self,iterable:"Symbol"in self&&"iterator"in Symbol,blob:"FileReader"in self&&"Blob"in self&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in self,arrayBuffer:"ArrayBuffer"in self};if(v.arrayBuffer)var E=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],A=ArrayBuffer.isView||function(t){return t&&E.indexOf(Object.prototype.toString.call(t))>-1};i.prototype.append=function(t,e){t=r(t),e=o(e);var n=this.map[t];this.map[t]=n?n+", "+e:e},i.prototype["delete"]=function(t){delete this.map[r(t)]},i.prototype.get=function(t){return t=r(t),this.has(t)?this.map[t]:null},i.prototype.has=function(t){return this.map.hasOwnProperty(r(t))},i.prototype.set=function(t,e){this.map[r(t)]=o(e)},i.prototype.forEach=function(t,e){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)},i.prototype.keys=function(){var t=[];return this.forEach(function(e,r){t.push(r)}),n(t)},i.prototype.values=function(){var t=[];return this.forEach(function(e){t.push(e)}),n(t)},i.prototype.entries=function(){var t=[];return this.forEach(function(e,r){t.push([r,e])}),n(t)},v.iterable&&(i.prototype[Symbol.iterator]=i.prototype.entries);var _=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];p.prototype.clone=function(){return new p(this,{body:this._bodyInit})},c.call(p.prototype),c.call(m.prototype),m.prototype.clone=function(){return new m(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new i(this.headers),url:this.url})},m.error=function(){var t=new m(null,{status:0,statusText:""});return t.type="error",t};var x=[301,302,303,307,308];m.redirect=function(t,e){if(-1===x.indexOf(e))throw new RangeError("Invalid status code");return new m(null,{status:e,headers:{location:t}})},t.DOMException=self.DOMException;try{new t.DOMException}catch(g){t.DOMException=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}w.polyfill=!0,self.fetch=w,self.Headers=i,self.Request=p,self.Response=m,t.Headers=i,t.Request=p,t.Response=m,t.fetch=w,Object.defineProperty(t,"__esModule",{value:!0})});!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):(e=e||self,t(e.AbortControllerShim={}))}(this,function(e){"use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var n,o=0;o<t.length;o++)n=t[o],n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}function r(e,t,n){return t&&o(e.prototype,t),n&&o(e,n),e}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&c(e,t)}function u(e){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function l(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function f(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?l(e):t}function a(e){var t=C.get(e);return console.assert(null!=t,"'this' is expected an Event object, but got",e),t}function p(e){return null==e.passiveListener?void(!e.event.cancelable||(e.canceled=!0,"function"==typeof e.event.preventDefault&&e.event.preventDefault())):void("undefined"!=typeof console&&"function"==typeof console.error&&console.error("Unable to preventDefault inside passive event listener invocation.",e.passiveListener))}function s(e,t){C.set(this,{eventTarget:e,event:t,eventPhase:2,currentTarget:e,canceled:!1,stopped:!1,immediateStopped:!1,passiveListener:null,timeStamp:t.timeStamp||Date.now()}),Object.defineProperty(this,"isTrusted",{value:!1,enumerable:!0});for(var n,o=Object.keys(t),r=0;r<o.length;++r)(n=o[r])in this||Object.defineProperty(this,n,b(n))}function b(e){return{get:function(){return a(this).event[e]},set:function(t){a(this).event[e]=t},configurable:!0,enumerable:!0}}function y(e){return{value:function(){var t=a(this).event;return t[e].apply(t,arguments)},configurable:!0,enumerable:!0}}function v(e,t){function n(t,n){e.call(this,t,n)}var o=Object.keys(t);if(0===o.length)return e;n.prototype=Object.create(e.prototype,{constructor:{value:n,configurable:!0,writable:!0}});for(var r,i=0;i<o.length;++i)if(!((r=o[i])in e.prototype)){var u=Object.getOwnPropertyDescriptor(t,r),c="function"==typeof u.value;Object.defineProperty(n.prototype,r,c?y(r):b(r))}return n}function d(e){if(null==e||e===Object.prototype)return s;var t=M.get(e);return null==t&&(t=v(d(Object.getPrototypeOf(e)),e),M.set(e,t)),t}function g(e,t){return new(d(Object.getPrototypeOf(t)))(e,t)}function h(e){return a(e).immediateStopped}function j(e,t){a(e).eventPhase=t}function O(e,t){a(e).currentTarget=t}function m(e,t){a(e).passiveListener=t}function w(e){return null!==e&&"object"===t(e)}function P(e){var t=D.get(e);if(null==t)throw new TypeError("'this' is expected an EventTarget object, but got another value.");return t}function T(e){return{get:function(){for(var t=P(this),n=t.get(e);null!=n;){if(3===n.listenerType)return n.listener;n=n.next}return null},set:function(t){"function"==typeof t||w(t)||(t=null);for(var n=P(this),o=null,r=n.get(e);null!=r;)3===r.listenerType?null===o?null===r.next?n["delete"](e):n.set(e,r.next):o.next=r.next:o=r,r=r.next;if(null!==t){var i={listener:t,listenerType:3,passive:!1,once:!1,next:null};null===o?n.set(e,i):o.next=i}},configurable:!0,enumerable:!0}}function x(e,t){Object.defineProperty(e,"on".concat(t),T(t))}function S(e){function t(){E.call(this)}t.prototype=Object.create(E.prototype,{constructor:{value:t,configurable:!0,writable:!0}});for(var n=0;n<e.length;++n)x(t.prototype,e[n]);return t}function E(){if(this instanceof E)return void D.set(this,new Map);if(1===arguments.length&&Array.isArray(arguments[0]))return S(arguments[0]);if(0<arguments.length){for(var e=Array(arguments.length),t=0;t<arguments.length;++t)e[t]=arguments[t];return S(e)}throw new TypeError("Cannot call a class as a function")}function A(){var e=Object.create(L.prototype);return E.call(e),W.set(e,!1),e}function k(e){!1!==W.get(e)||(W.set(e,!0),e.dispatchEvent({type:"abort"}))}function _(e){var n=B.get(e);if(null==n)throw new TypeError("Expected 'this' to be an 'AbortController' object, but got ".concat(null===e?"null":t(e)));return n}var C=new WeakMap,M=new WeakMap;s.prototype={get type(){return a(this).event.type},get target(){return a(this).eventTarget},get currentTarget(){return a(this).currentTarget},composedPath:function(){var e=a(this).currentTarget;return null==e?[]:[e]},get NONE(){return 0},get CAPTURING_PHASE(){return 1},get AT_TARGET(){return 2},get BUBBLING_PHASE(){return 3},get eventPhase(){return a(this).eventPhase},stopPropagation:function(){var e=a(this);e.stopped=!0,"function"==typeof e.event.stopPropagation&&e.event.stopPropagation()},stopImmediatePropagation:function(){var e=a(this);e.stopped=!0,e.immediateStopped=!0,"function"==typeof e.event.stopImmediatePropagation&&e.event.stopImmediatePropagation()},get bubbles(){return!!a(this).event.bubbles},get cancelable(){return!!a(this).event.cancelable},preventDefault:function(){p(a(this))},get defaultPrevented(){return a(this).canceled},get composed(){return!!a(this).event.composed},get timeStamp(){return a(this).timeStamp},get srcElement(){return a(this).eventTarget},get cancelBubble(){return a(this).stopped},set cancelBubble(e){if(e){var t=a(this);t.stopped=!0,"boolean"==typeof t.event.cancelBubble&&(t.event.cancelBubble=!0)}},get returnValue(){return!a(this).canceled},set returnValue(e){e||p(a(this))},initEvent:function(){}},Object.defineProperty(s.prototype,"constructor",{value:s,configurable:!0,writable:!0}),"undefined"!=typeof window&&"undefined"!=typeof window.Event&&(Object.setPrototypeOf(s.prototype,window.Event.prototype),M.set(window.Event.prototype,s));var D=new WeakMap;E.prototype={addEventListener:function(e,t,n){if(null!=t){if("function"!=typeof t&&!w(t))throw new TypeError("'listener' should be a function or an object.");var o=P(this),r=w(n),i=r?!!n.capture:!!n,u=i?1:2,c={listener:t,listenerType:u,passive:r&&!!n.passive,once:r&&!!n.once,next:null},l=o.get(e);if(void 0===l)return void o.set(e,c);for(var f=null;null!=l;){if(l.listener===t&&l.listenerType===u)return;f=l,l=l.next}f.next=c}},removeEventListener:function(e,t,n){if(null!=t)for(var o=P(this),r=w(n)?!!n.capture:!!n,i=r?1:2,u=null,c=o.get(e);null!=c;){if(c.listener===t&&c.listenerType===i)return void(null===u?null===c.next?o["delete"](e):o.set(e,c.next):u.next=c.next);u=c,c=c.next}},dispatchEvent:function(e){if(null==e||"string"!=typeof e.type)throw new TypeError('"event.type" should be a string.');var t=P(this),n=e.type,o=t.get(n);if(null==o)return!0;for(var r=g(this,e),i=null;null!=o;){if(o.once?null===i?null===o.next?t["delete"](n):t.set(n,o.next):i.next=o.next:i=o,m(r,o.passive?o.listener:null),"function"==typeof o.listener)try{o.listener.call(this,r)}catch(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e)}else 3!==o.listenerType&&"function"==typeof o.listener.handleEvent&&o.listener.handleEvent(r);if(h(r))break;o=o.next}return m(r,null),j(r,0),O(r,null),!r.defaultPrevented}},Object.defineProperty(E.prototype,"constructor",{value:E,configurable:!0,writable:!0}),"undefined"!=typeof window&&"undefined"!=typeof window.EventTarget&&Object.setPrototypeOf(E.prototype,window.EventTarget.prototype);var L=function(e){function o(){throw n(this,o),f(this,u(o).call(this)),new TypeError("AbortSignal cannot be constructed directly")}return i(o,e),r(o,[{key:"aborted",get:function(){var e=W.get(this);if("boolean"!=typeof e)throw new TypeError("Expected 'this' to be an 'AbortSignal' object, but got ".concat(null===this?"null":t(this)));return e}}]),o}(E);x(L.prototype,"abort");var W=new WeakMap;Object.defineProperties(L.prototype,{aborted:{enumerable:!0}}),"function"==typeof Symbol&&"symbol"===t(Symbol.toStringTag)&&Object.defineProperty(L.prototype,Symbol.toStringTag,{configurable:!0,value:"AbortSignal"});var I=function(){function e(){n(this,e),B.set(this,A())}return r(e,[{key:"abort",value:function(){k(_(this))}},{key:"signal",get:function(){return _(this)}}]),e}(),B=new WeakMap;if(Object.defineProperties(I.prototype,{signal:{enumerable:!0},abort:{enumerable:!0}}),"function"==typeof Symbol&&"symbol"===t(Symbol.toStringTag)&&Object.defineProperty(I.prototype,Symbol.toStringTag,{configurable:!0,value:"AbortController"}),e.AbortController=I,e.AbortSignal=L,e["default"]=I,Object.defineProperty(e,"__esModule",{value:!0}),"undefined"==typeof module&&"undefined"==typeof define){var F=Function("return this")();"undefined"==typeof F.AbortController&&(F.AbortController=I,F.AbortSignal=L)}});})('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});