@nota/nativescript-webview-ext
Version:
Extended WebView for NativeScript which adds 'x-local' scheme for local-files. events between WebView and native-layer, javascript execution, injecting CSS and JS-files.
1 lines • 8.48 kB
JavaScript
(function(e,t){typeof exports==="object"&&typeof module!=="undefined"?t(exports):typeof define==="function"&&define.amd?define(["exports"],t):t(e.WHATWGFetch={})})(this,function(a){"use strict";var f={searchParams:"URLSearchParams"in self,iterable:"Symbol"in self&&"iterator"in Symbol,blob:"FileReader"in self&&"Blob"in self&&function(){try{new Blob;return true}catch(e){return false}}(),formData:"FormData"in self,arrayBuffer:"ArrayBuffer"in self};function t(e){return e&&DataView.prototype.isPrototypeOf(e)}if(f.arrayBuffer){var r=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"];var o=ArrayBuffer.isView||function(e){return e&&r.indexOf(Object.prototype.toString.call(e))>-1}}function n(e){if(typeof e!=="string"){e=String(e)}if(/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(e)){throw new TypeError("Invalid character in header field name")}return e.toLowerCase()}function i(e){if(typeof e!=="string"){e=String(e)}return e}function e(t){var e={next:function(){var e=t.shift();return{done:e===undefined,value:e}}};if(f.iterable){e[Symbol.iterator]=function(){return e}}return e}function s(t){this.map={};if(t instanceof s){t.forEach(function(e,t){this.append(t,e)},this)}else if(Array.isArray(t)){t.forEach(function(e){this.append(e[0],e[1])},this)}else if(t){Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}}s.prototype.append=function(e,t){e=n(e);t=i(t);var r=this.map[e];this.map[e]=r?r+", "+t:t};s.prototype["delete"]=function(e){delete this.map[n(e)]};s.prototype.get=function(e){e=n(e);return this.has(e)?this.map[e]:null};s.prototype.has=function(e){return this.map.hasOwnProperty(n(e))};s.prototype.set=function(e,t){this.map[n(e)]=i(t)};s.prototype.forEach=function(e,t){for(var r in this.map){if(this.map.hasOwnProperty(r)){e.call(t,this.map[r],r,this)}}};s.prototype.keys=function(){var r=[];this.forEach(function(e,t){r.push(t)});return e(r)};s.prototype.values=function(){var t=[];this.forEach(function(e){t.push(e)});return e(t)};s.prototype.entries=function(){var r=[];this.forEach(function(e,t){r.push([t,e])});return e(r)};if(f.iterable){s.prototype[Symbol.iterator]=s.prototype.entries}function u(e){if(e.bodyUsed){return Promise.reject(new TypeError("Already read"))}e.bodyUsed=true}function h(r){return new Promise(function(e,t){r.onload=function(){e(r.result)};r.onerror=function(){t(r.error)}})}function l(e){var t=new FileReader;var r=h(t);t.readAsArrayBuffer(e);return r}function d(e){var t=new FileReader;var r=h(t);t.readAsText(e);return r}function c(e){var t=new Uint8Array(e);var r=new Array(t.length);for(var o=0;o<t.length;o++){r[o]=String.fromCharCode(t[o])}return r.join("")}function y(e){if(e.slice){return e.slice(0)}else{var t=new Uint8Array(e.byteLength);t.set(new Uint8Array(e));return t.buffer}}function p(){this.bodyUsed=false;this._initBody=function(e){this._bodyInit=e;if(!e){this._bodyText=""}else if(typeof e==="string"){this._bodyText=e}else if(f.blob&&Blob.prototype.isPrototypeOf(e)){this._bodyBlob=e}else if(f.formData&&FormData.prototype.isPrototypeOf(e)){this._bodyFormData=e}else if(f.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)){this._bodyText=e.toString()}else if(f.arrayBuffer&&f.blob&&t(e)){this._bodyArrayBuffer=y(e.buffer);this._bodyInit=new Blob([this._bodyArrayBuffer])}else if(f.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(e)||o(e))){this._bodyArrayBuffer=y(e)}else{this._bodyText=e=Object.prototype.toString.call(e)}if(!this.headers.get("content-type")){if(typeof e==="string"){this.headers.set("content-type","text/plain;charset=UTF-8")}else if(this._bodyBlob&&this._bodyBlob.type){this.headers.set("content-type",this._bodyBlob.type)}else if(f.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)){this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8")}}};if(f.blob){this.blob=function(){var e=u(this);if(e){return e}if(this._bodyBlob){return Promise.resolve(this._bodyBlob)}else if(this._bodyArrayBuffer){return Promise.resolve(new Blob([this._bodyArrayBuffer]))}else if(this._bodyFormData){throw new Error("could not read FormData body as blob")}else{return Promise.resolve(new Blob([this._bodyText]))}};this.arrayBuffer=function(){if(this._bodyArrayBuffer){return u(this)||Promise.resolve(this._bodyArrayBuffer)}else{return this.blob().then(l)}}}this.text=function(){var e=u(this);if(e){return e}if(this._bodyBlob){return d(this._bodyBlob)}else if(this._bodyArrayBuffer){return Promise.resolve(c(this._bodyArrayBuffer))}else if(this._bodyFormData){throw new Error("could not read FormData body as text")}else{return Promise.resolve(this._bodyText)}};if(f.formData){this.formData=function(){return this.text().then(v)}}this.json=function(){return this.text().then(JSON.parse)};return this}var b=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function m(e){var t=e.toUpperCase();return b.indexOf(t)>-1?t:e}function w(e,t){t=t||{};var r=t.body;if(e instanceof w){if(e.bodyUsed){throw new TypeError("Already read")}this.url=e.url;this.credentials=e.credentials;if(!t.headers){this.headers=new s(e.headers)}this.method=e.method;this.mode=e.mode;this.signal=e.signal;if(!r&&e._bodyInit!=null){r=e._bodyInit;e.bodyUsed=true}}else{this.url=String(e)}this.credentials=t.credentials||this.credentials||"same-origin";if(t.headers||!this.headers){this.headers=new s(t.headers)}this.method=m(t.method||this.method||"GET");this.mode=t.mode||this.mode||null;this.signal=t.signal||this.signal;this.referrer=null;if((this.method==="GET"||this.method==="HEAD")&&r){throw new TypeError("Body not allowed for GET or HEAD requests")}this._initBody(r)}w.prototype.clone=function(){return new w(this,{body:this._bodyInit})};function v(e){var n=new FormData;e.trim().split("&").forEach(function(e){if(e){var t=e.split("=");var r=t.shift().replace(/\+/g," ");var o=t.join("=").replace(/\+/g," ");n.append(decodeURIComponent(r),decodeURIComponent(o))}});return n}function E(e){var n=new s;var t=e.replace(/\r?\n[\t ]+/g," ");t.split(/\r?\n/).forEach(function(e){var t=e.split(":");var r=t.shift().trim();if(r){var o=t.join(":").trim();n.append(r,o)}});return n}p.call(w.prototype);function A(e,t){if(!t){t={}}this.type="default";this.status=t.status===undefined?200:t.status;this.ok=this.status>=200&&this.status<300;this.statusText="statusText"in t?t.statusText:"OK";this.headers=new s(t.headers);this.url=t.url||"";this._initBody(e)}p.call(A.prototype);A.prototype.clone=function(){return new A(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new s(this.headers),url:this.url})};A.error=function(){var e=new A(null,{status:0,statusText:""});e.type="error";return e};var _=[301,302,303,307,308];A.redirect=function(e,t){if(_.indexOf(t)===-1){throw new RangeError("Invalid status code")}return new A(null,{status:t,headers:{location:e}})};a.DOMException=self.DOMException;try{new a.DOMException}catch(e){a.DOMException=function(e,t){this.message=e;this.name=t;var r=Error(e);this.stack=r.stack};a.DOMException.prototype=Object.create(Error.prototype);a.DOMException.prototype.constructor=a.DOMException}function x(i,s){return new Promise(function(r,e){var t=new w(i,s);if(t.signal&&t.signal.aborted){return e(new a.DOMException("Aborted","AbortError"))}var o=new XMLHttpRequest;function n(){o.abort()}o.onload=function(){var e={status:o.status,statusText:o.statusText,headers:E(o.getAllResponseHeaders()||"")};e.url="responseURL"in o?o.responseURL:e.headers.get("X-Request-URL");var t="response"in o?o.response:o.responseText;r(new A(t,e))};o.onerror=function(){e(new TypeError("Network request failed"))};o.ontimeout=function(){e(new TypeError("Network request failed"))};o.onabort=function(){e(new a.DOMException("Aborted","AbortError"))};o.open(t.method,t.url,true);if(t.credentials==="include"){o.withCredentials=true}else if(t.credentials==="omit"){o.withCredentials=false}if("responseType"in o&&f.blob){o.responseType="blob"}t.headers.forEach(function(e,t){o.setRequestHeader(t,e)});if(t.signal){t.signal.addEventListener("abort",n);o.onreadystatechange=function(){if(o.readyState===4){t.signal.removeEventListener("abort",n)}}}o.send(typeof t._bodyInit==="undefined"?null:t._bodyInit)})}x.polyfill=true;if(!self.fetch){self.fetch=x;self.Headers=s;self.Request=w;self.Response=A}a.Headers=s;a.Request=w;a.Response=A;a.fetch=x;Object.defineProperty(a,"__esModule",{value:true})});