halife 0.1.5 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,23 +1,32 @@
|
|
|
1
|
+
import { t as __commonJSMin } from "./chunk-N6xyN86N.js";
|
|
2
|
+
|
|
1
3
|
//#region jspolyfill/event.ts
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
4
|
+
var require_event = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
5
|
+
let EventTargetPolyfill;
|
|
6
|
+
if (Object.defineProperty(exports, "__esModule", { value: !0 }), "undefined" == typeof EventTarget) {
|
|
7
|
+
class CustomEventTarget {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.listeners = /* @__PURE__ */ new Map();
|
|
10
|
+
}
|
|
11
|
+
addEventListener(type, listener, options) {
|
|
12
|
+
if (!this.listeners.has(type)) this.listeners.set(type, /* @__PURE__ */ new Set());
|
|
13
|
+
this.listeners.get(type).add(listener);
|
|
14
|
+
}
|
|
15
|
+
removeEventListener(type, listener, options) {
|
|
16
|
+
this.listeners.get(type)?.delete(listener);
|
|
17
|
+
}
|
|
18
|
+
dispatchEvent(event) {
|
|
19
|
+
const cbs = this.listeners.get(event.type);
|
|
20
|
+
if (!cbs) return true;
|
|
21
|
+
for (const cb of cbs) if (typeof cb === "function") cb(event);
|
|
22
|
+
else if (cb && typeof cb.handleEvent === "function") cb.handleEvent(event);
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
"undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(CustomEventTarget.prototype, Symbol.toStringTag, { value: "EventTarget" }), EventTargetPolyfill = CustomEventTarget;
|
|
27
|
+
} else EventTargetPolyfill = EventTarget;
|
|
28
|
+
exports.default = { EventTargetPolyfill }, module.exports = exports.default;
|
|
29
|
+
}));
|
|
21
30
|
|
|
22
31
|
//#endregion
|
|
23
|
-
export
|
|
32
|
+
export default require_event();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n)),l=o(((e,t)=>{let n;if(Object.defineProperty(e,`__esModule`,{value:!0}),typeof TextEncoder<`u`&&TextEncoder.prototype.encodeInto)n=TextEncoder;else{let e=String.fromCharCode,t=function(t){let n=0|t.charCodeAt(0);if(55296<=n)if(n<56320){let r=0|t.charCodeAt(1);if(56320<=r&&r<=57343){if(n=(n<<10)+r-56613888|0,n>65535)return e(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)}else n=65533}else n<=57343&&(n=65533);return n<=2047?e(192|n>>>6,128|63&n):e(224|n>>>12,128|n>>>6&63,128|63&n)},r=function(e){return e===void 0?``:(``+e).replace(/[\x80-\uD7ff\uDC00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]?/g,t)};class i{constructor(){this.encoding=`utf-8`}encode(e){let t=r(e),n=0|t.length,i=new Uint8Array(n),a=0;for(;a<n;a=a+1|0)i[a]=0|t.charCodeAt(a);return i}encodeInto(e,t){let n=r(e),i=0|t.length,a=0|e.length,o=0|n.length,s=0,c=0,l=0;i<o&&(o=i);e:for(;s<o;s=s+1|0){switch(c=0|n.charCodeAt(s),c>>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:l=l+1|0;case 8:case 9:case 10:case 11:break;case 12:case 13:if((s+1|0)<i){l=l+1|0;break}case 14:if((s+2|0)<i){l=l+1|0;break}case 15:if((s+3|0)<i){l=l+1|0;break}default:break e}t[s]=c}return{written:s,read:a<l?a:l}}toString(){return`[object TextEncoder]`}}if(typeof Symbol<`u`&&Symbol.toStringTag&&Object.defineProperty(i.prototype,Symbol.toStringTag,{value:`TextEncoder`}),typeof TextEncoder>`u`&&(n=i),!n.prototype.encodeInto){let e=new TextEncoder;TextEncoder.prototype.encodeInto=function(t,n){let r=0|t.length,a=0|n.length;if(r<(3+(a>>1)|0)){let i=e.encode(t);if((0|i.length)<a)return n.set(i),{read:r,written:0|i.length}}return i.prototype.encodeInto(t,n)}}}e.default=n,t.exports=e.default})),u=c(o(((e,t)=>{let n;if(Object.defineProperty(e,`__esModule`,{value:!0}),typeof TextDecoder>`u`){let e=String.fromCharCode,t=Object.prototype.toString,r=t.call(ArrayBuffer.prototype),i=typeof SharedArrayBuffer<`u`?t.call(SharedArrayBuffer):``,a=function(t){let n=t.charCodeAt(0),r=0|t.length,i=1114112,a=0,o=``;switch(n>>>4){case 12:case 13:i=(31&n)<<6|63&t.charCodeAt(1),a=i<128?0:2;break;case 14:i=(15&n)<<12|(63&t.charCodeAt(1))<<6|63&t.charCodeAt(2),a=i<2048?0:3;break;case 15:n>>>3==30&&(i=(7&n)<<18|(63&t.charCodeAt(1))<<12|(63&t.charCodeAt(2))<<6|t.charCodeAt(3),a=i<65536?0:4)}for(a&&(r<a?a=0:i<65536?o=e(i):i<1114112?(i=i-65664|0,o=e(55296+(i>>>10)|0,56320+(1023&i)|0)):a=0);a<r;a=a+1|0)o+=` `;return o},o=[`utf-8`,`utf8`,`unicode-1-1-utf-8`];class s{constructor(e,t){if(this.encoding=`utf-8`,this.fatal=!1,this.ignoreBOM=!1,e&&o.indexOf(e.toLowerCase())===-1)throw RangeError(`Failed to construct 'TextDecoder': The encoding label provided ('${e}') is invalid.`);if(t){if(t.fatal)throw Error(`Failed to construct 'TextDecoder': the 'fatal' option is unsupported.`);if(t.ignoreBOM)throw Error(`Failed to construct 'TextDecoder': the 'ignoreBOM' option is unsupported.`)}}decode(n,o){if(o&&o.stream)throw Error(`Failed to decode: the 'stream' option is unsupported.`);let s=n&&n.buffer||n,c=t.call(s);if(c!==r&&c!==i&&n!==void 0)throw TypeError(`Failed to execute 'decode' on 'TextDecoder': The provided value is not of type '(ArrayBuffer or ArrayBufferView)'`);let l=new Uint8Array(s),u=``;for(let t=0,n=0|l.length;t<n;t=t+32768|0)u+=e.apply(0,l.subarray(t,t+32768|0));return u.replace(/[\xc0-\xff][\x80-\xbf]+|[\x80-\xff]/g,a)}toString(){return`[object TextDecoder]`}}typeof Symbol<`u`&&Symbol.toStringTag&&Object.defineProperty(s.prototype,Symbol.toStringTag,{value:`TextDecoder`}),n=s}else n=TextDecoder;e.default=n,t.exports=e.default}))(),1),d=c(l(),1),f=class{constructor(){this.listeners=new Map}addEventListener(e,t,n){this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t)}removeEventListener(e,t,n){this.listeners.get(e)?.delete(t)}dispatchEvent(e){let t=this.listeners.get(e.type);if(!t)return!0;for(let n of t)typeof n==`function`?n(e):n&&typeof n.handleEvent==`function`&&n.handleEvent(e);return!0}};function p(e,t){if(t=t.split(`:`)[0],e=+e,!e)return!1;switch(t){case`http`:case`ws`:return e!==80;case`https`:case`wss`:return e!==443;case`ftp`:return e!==21;case`gopher`:return e!==70;case`file`:return!1}return e!==0}var m=Object.prototype.hasOwnProperty,h;function g(e){try{return decodeURIComponent(e.replace(/\+/g,` `))}catch{return null}}function _(e){try{return encodeURIComponent(e)}catch{return null}}function v(e){for(var t=/([^=?#&]+)=?([^&]*)/g,n={},r;r=t.exec(e);){var i=g(r[1]),a=g(r[2]);i===null||a===null||i in n||(n[i]=a)}return n}function y(e,t){t||=``;var n=[],r,i;for(i in typeof t!=`string`&&(t=`?`),e)if(m.call(e,i)){if(r=e[i],!r&&(r===null||r===h||isNaN(r))&&(r=``),i=_(i),r=_(r),i===null||r===null)continue;n.push(i+`=`+r)}return n.length?t+n.join(`&`):``}var b=/^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/,x=/[\n\r\t]/g,S=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//,C=/:\d+$/,w=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i,T=/^[a-zA-Z]:/;function E(e){return(e||``).toString().replace(b,``)}function D(e){var t=E(e),n=t.length;if(n===0)return t;for(;n&&!(t.charCodeAt(n-1)>32);)--n;return t.slice(0,n)}var O=[[`#`,`hash`],[`?`,`query`],function(e,t){return j(t.protocol)?e.replace(/\\/g,`/`):e},[`/`,`pathname`],[`@`,`auth`,1],[NaN,`host`,void 0,1,1],[/:(\d*)$/,`port`,void 0,1],[NaN,`hostname`,void 0,1,1]],k={hash:1,query:1};function A(e){var t=(typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{}).location||{};e||=t;var n={},r=typeof e,i;if(e.protocol===`blob:`)n=new P(unescape(e.pathname),{});else if(r===`string`)for(i in n=new P(e,{}),k)delete n[i];else if(r===`object`){for(i in e)i in k||(n[i]=e[i]);n.slashes===void 0&&(n.slashes=S.test(e.href))}return n}function j(e){return e===`file:`||e===`ftp:`||e===`http:`||e===`https:`||e===`ws:`||e===`wss:`}function M(e,t){e=D(e),e=e.replace(x,``),t||={};var n=w.exec(e),r=n[1]?n[1].toLowerCase():``,i=!!n[2],a=!!n[3],o=0,s;return i?a?(s=n[2]+n[3]+n[4],o=n[2].length+n[3].length):(s=n[2]+n[4],o=n[2].length):a?(s=n[3]+n[4],o=n[3].length):s=n[4],r===`file:`?o>=2&&(s=s.slice(2)):j(r)?s=n[4]:r?i&&(s=s.slice(2)):o>=2&&j(t.protocol)&&(s=n[4]),{protocol:r,slashes:i||j(r),slashesCount:o,rest:s}}function N(e,t){if(e===``)return t;for(var n=(t||`/`).split(`/`).slice(0,-1).concat(e.split(`/`)),r=n.length,i=n[r-1],a=!1,o=0;r--;)n[r]===`.`?n.splice(r,1):n[r]===`..`?(n.splice(r,1),o++):o&&(r===0&&(a=!0),n.splice(r,1),o--);return a&&n.unshift(``),(i===`.`||i===`..`)&&n.push(``),n.join(`/`)}function P(e,t,n){if(!(this instanceof P))return new P(e,t,n);var r,i,a,o,s,c,l=O.slice(),u=typeof t,d=this,f=0;for(u!==`object`&&u!==`string`&&(n=t,t=null),n&&typeof n!=`function`&&(n=v),t=A(t),i=M(e||``,t),r=!i.protocol&&!i.slashes,d.slashes=i.slashes||r&&t.slashes,d.protocol=i.protocol||t.protocol||``,e=i.rest,(i.protocol===`file:`&&(i.slashesCount!==2||T.test(e))||!i.slashes&&(i.protocol||i.slashesCount<2||!j(d.protocol)))&&(l[3]=[/(.*)/,`pathname`]);f<l.length;f++){if(o=l[f],typeof o==`function`){e=o(e,d);continue}a=o[0],c=o[1],a===a?typeof a==`string`?(s=a===`@`?e.lastIndexOf(a):e.indexOf(a),~s&&(typeof o[2]==`number`?(d[c]=e.slice(0,s),e=e.slice(s+o[2])):(d[c]=e.slice(s),e=e.slice(0,s)))):(s=a.exec(e))&&(d[c]=s[1],e=e.slice(0,s.index)):d[c]=e,d[c]=d[c]||r&&o[3]&&t[c]||``,o[4]&&(d[c]=d[c].toLowerCase())}n&&(d.query=n(d.query)),r&&t.slashes&&d.pathname.charAt(0)!==`/`&&(d.pathname!==``||t.pathname!==``)&&(d.pathname=N(d.pathname,t.pathname)),d.pathname.charAt(0)!==`/`&&j(d.protocol)&&(d.pathname=`/`+d.pathname),p(d.port,d.protocol)||(d.host=d.hostname,d.port=``),d.username=d.password=``,d.auth&&=(s=d.auth.indexOf(`:`),~s?(d.username=d.auth.slice(0,s),d.username=encodeURIComponent(decodeURIComponent(d.username)),d.password=d.auth.slice(s+1),d.password=encodeURIComponent(decodeURIComponent(d.password))):d.username=encodeURIComponent(decodeURIComponent(d.auth)),d.password?d.username+`:`+d.password:d.username),d.origin=d.protocol!==`file:`&&j(d.protocol)&&d.host?d.protocol+`//`+d.host:`null`,d.href=d.toString()}function F(e,t,n){var r=this;switch(e){case`query`:typeof t==`string`&&t.length&&(t=(n||v)(t)),r[e]=t;break;case`port`:r[e]=t,p(t,r.protocol)?t&&(r.host=r.hostname+`:`+t):(r.host=r.hostname,r[e]=``);break;case`hostname`:r[e]=t,r.port&&(t+=`:`+r.port),r.host=t;break;case`host`:r[e]=t,C.test(t)?(t=t.split(`:`),r.port=t.pop(),r.hostname=t.join(`:`)):(r.hostname=t,r.port=``);break;case`protocol`:r.protocol=t.toLowerCase(),r.protocol&&r.protocol.charAt(r.protocol.length-1)!==`:`&&(r.protocol+=`:`),r.slashes=!n;break;case`pathname`:case`hash`:if(t&&!n){var i=e===`pathname`?`/`:`#`;r[e]=t.charAt(0)===i?t:i+t}else r[e]=t;break;case`username`:case`password`:r[e]=encodeURIComponent(t);break;case`auth`:var a=t.indexOf(`:`);~a?(r.username=t.slice(0,a),r.username=encodeURIComponent(decodeURIComponent(r.username)),r.password=t.slice(a+1),r.password=encodeURIComponent(decodeURIComponent(r.password))):r.username=encodeURIComponent(decodeURIComponent(t))}for(var o=0;o<O.length;o++){var s=O[o];s[4]&&(r[s[1]]=r[s[1]].toLowerCase())}return r.auth=r.password?r.username+`:`+r.password:r.username,r.origin=r.protocol!==`file:`&&j(r.protocol)&&r.host?r.protocol+`//`+r.host:`null`,r.href=r.toString(),r}function I(e){(!e||typeof e!=`function`)&&(e=y);var t,n=this,r=n.host,i=n.protocol;i&&i.charAt(i.length-1)!==`:`&&(i+=`:`);var a=i+(i&&n.slashes||j(i)?`//`:``);return n.username?(a+=n.username,n.password&&(a+=`:`+n.password),a+=`@`):n.password?(a+=`:`+n.password,a+=`@`):i!==`file:`&&j(i)&&!r&&n.pathname!==`/`&&(a+=`@`),(r[r.length-1]===`:`||C.test(n.hostname)&&!n.port)&&(r+=`:`),a+=r+n.pathname,t=typeof n.query==`object`?e(n.query):n.query,t&&(a+=t.charAt(0)===`?`?t:`?`+t),n.hash&&(a+=n.hash),a}P.prototype={set:F,toString:I},P.extractProtocol=M,P.location=A,P.trimLeft=E,P.stringify=y,P.parse=v,P.canParse=()=>{},P.createObjectURL=()=>{},P.revokeObjectURL=()=>{};var L=class e extends f{static{this.CONNECTING=0}static{this.OPEN=1}static{this.CLOSING=2}static{this.CLOSED=3}constructor(t,n){if(super(),this.CONNECTING=0,this.OPEN=1,this.CLOSING=2,this.CLOSED=3,this.binaryType=`arraybuffer`,this.readyState=0,this.url=``,this.extensions=``,this.bufferedAmount=0,typeof wx>`u`||!wx.connectSocket)throw Error(`This Function MUST be used in MotherFucker WeChat, you know what I mean?`);if(!(this instanceof e))throw TypeError(`Constructor WebSocket requires 'new'`);this.url=t.toString(),this.protocol=n?.[0]||``,this.readyState=e.CONNECTING;let r=wx.connectSocket({url:this.url,protocols:n,success:()=>{},complete:()=>{},fail:t=>{this.readyState=e.CLOSED,this.dispatchEvent({type:`error`,message:t.errMsg})}});r.onOpen(t=>{this.readyState=e.OPEN,this.extensions=t.header?.[`Sec-WebSocket-Extensions`]||``,this.protocol=t.header?.[`Sec-WebSocket-Protocol`],this.dispatchEvent({type:`open`})}),r.onMessage(e=>{this.dispatchEvent({type:`message`,data:e})}),r.onClose(t=>{this.readyState=e.CLOSED,this.dispatchEvent({type:`close`,detial:t.code,message:t.reason})}),r.onError(t=>{this.readyState=e.CLOSED,this.dispatchEvent({type:`error`,message:t.errMsg}),this.dispatchEvent({type:`close`,message:t.errMsg})})}send(t){if(this.readyState!==e.OPEN)return this.dispatchEvent({type:`error`,message:`Socket is not open`});wx.sendSocketMessage({data:t,success:()=>{},fail:()=>{},complete:()=>{}})}close(t=1e3,n=``){this.readyState!==e.CLOSED&&(this.readyState=e.CLOSING,wx.closeSocket({code:t,reason:n,success:()=>{},fail:()=>{},complete:()=>{}}))}onclose(){}onerror(){}onmessage(){}onopen(){}};function R(e,t){return new Promise((n,r)=>{if(typeof wx>`u`||!wx.request)return r(Error(`This Function MUST be used in MotherFucker WeChat, you know what I mean?`));let{method:i,headers:a,body:o}=t||{},s=e instanceof URL?e.href:e.toString();wx.request({url:s,method:i,header:a,data:o?.buffer,dataType:`other`,responseType:`arraybuffer`,success:e=>{let t={ok:e.statusCode>=200&&e.statusCode<300,status:e.statusCode,statusText:e.errMsg,headers:e.header,arrayBuffer:()=>Promise.resolve(e.data),blob:()=>Promise.resolve(e.data),redirected:!1,url:s,clone:()=>t,type:`default`,body:e.data,bodyUsed:!1,formData:()=>Promise.resolve(e.data),json:()=>Promise.resolve(e.data),text:()=>Promise.resolve(e.data)};n(t)},fail:e=>{r(Error(e.errMsg))}})})}R.preconnect=()=>{},globalThis.EventTarget=f,globalThis.fetch=R,globalThis.TextEncoder=d.default,globalThis.TextDecoder=u.default,globalThis.URL=P,globalThis.WebSocket=L;
|
|
1
|
+
var e=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),t=e(((e,t)=>{let n;if(Object.defineProperty(e,`__esModule`,{value:!0}),typeof TextEncoder<`u`&&TextEncoder.prototype.encodeInto)n=TextEncoder;else{let e=String.fromCharCode,t=function(t){let n=0|t.charCodeAt(0);if(55296<=n)if(n<56320){let r=0|t.charCodeAt(1);if(56320<=r&&r<=57343){if(n=(n<<10)+r-56613888|0,n>65535)return e(240|n>>>18,128|n>>>12&63,128|n>>>6&63,128|63&n)}else n=65533}else n<=57343&&(n=65533);return n<=2047?e(192|n>>>6,128|63&n):e(224|n>>>12,128|n>>>6&63,128|63&n)},r=function(e){return e===void 0?``:(``+e).replace(/[\x80-\uD7ff\uDC00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]?/g,t)};class i{constructor(){this.encoding=`utf-8`}encode(e){let t=r(e),n=0|t.length,i=new Uint8Array(n),a=0;for(;a<n;a=a+1|0)i[a]=0|t.charCodeAt(a);return i}encodeInto(e,t){let n=r(e),i=0|t.length,a=0|e.length,o=0|n.length,s=0,c=0,l=0;i<o&&(o=i);e:for(;s<o;s=s+1|0){switch(c=0|n.charCodeAt(s),c>>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:l=l+1|0;case 8:case 9:case 10:case 11:break;case 12:case 13:if((s+1|0)<i){l=l+1|0;break}case 14:if((s+2|0)<i){l=l+1|0;break}case 15:if((s+3|0)<i){l=l+1|0;break}default:break e}t[s]=c}return{written:s,read:a<l?a:l}}toString(){return`[object TextEncoder]`}}if(typeof Symbol<`u`&&Symbol.toStringTag&&Object.defineProperty(i.prototype,Symbol.toStringTag,{value:`TextEncoder`}),typeof TextEncoder>`u`&&(n=i),!n.prototype.encodeInto){let e=new TextEncoder;TextEncoder.prototype.encodeInto=function(t,n){let r=0|t.length,a=0|n.length;if(r<(3+(a>>1)|0)){let i=e.encode(t);if((0|i.length)<a)return n.set(i),{read:r,written:0|i.length}}return i.prototype.encodeInto(t,n)}}}e.default=n,t.exports=e.default})),n=e(((e,t)=>{let n;if(Object.defineProperty(e,`__esModule`,{value:!0}),typeof TextDecoder>`u`){let e=String.fromCharCode,t=Object.prototype.toString,r=t.call(ArrayBuffer.prototype),i=typeof SharedArrayBuffer<`u`?t.call(SharedArrayBuffer):``,a=function(t){let n=t.charCodeAt(0),r=0|t.length,i=1114112,a=0,o=``;switch(n>>>4){case 12:case 13:i=(31&n)<<6|63&t.charCodeAt(1),a=i<128?0:2;break;case 14:i=(15&n)<<12|(63&t.charCodeAt(1))<<6|63&t.charCodeAt(2),a=i<2048?0:3;break;case 15:n>>>3==30&&(i=(7&n)<<18|(63&t.charCodeAt(1))<<12|(63&t.charCodeAt(2))<<6|t.charCodeAt(3),a=i<65536?0:4)}for(a&&(r<a?a=0:i<65536?o=e(i):i<1114112?(i=i-65664|0,o=e(55296+(i>>>10)|0,56320+(1023&i)|0)):a=0);a<r;a=a+1|0)o+=` `;return o},o=[`utf-8`,`utf8`,`unicode-1-1-utf-8`];class s{constructor(e,t){if(this.encoding=`utf-8`,this.fatal=!1,this.ignoreBOM=!1,e&&o.indexOf(e.toLowerCase())===-1)throw RangeError(`Failed to construct 'TextDecoder': The encoding label provided ('${e}') is invalid.`);if(t){if(t.fatal)throw Error(`Failed to construct 'TextDecoder': the 'fatal' option is unsupported.`);if(t.ignoreBOM)throw Error(`Failed to construct 'TextDecoder': the 'ignoreBOM' option is unsupported.`)}}decode(n,o){if(o&&o.stream)throw Error(`Failed to decode: the 'stream' option is unsupported.`);let s=n&&n.buffer||n,c=t.call(s);if(c!==r&&c!==i&&n!==void 0)throw TypeError(`Failed to execute 'decode' on 'TextDecoder': The provided value is not of type '(ArrayBuffer or ArrayBufferView)'`);let l=new Uint8Array(s),u=``;for(let t=0,n=0|l.length;t<n;t=t+32768|0)u+=e.apply(0,l.subarray(t,t+32768|0));return u.replace(/[\xc0-\xff][\x80-\xbf]+|[\x80-\xff]/g,a)}toString(){return`[object TextDecoder]`}}typeof Symbol<`u`&&Symbol.toStringTag&&Object.defineProperty(s.prototype,Symbol.toStringTag,{value:`TextDecoder`}),n=s}else n=TextDecoder;e.default=n,t.exports=e.default})),r=e(((e,t)=>{let n;if(Object.defineProperty(e,`__esModule`,{value:!0}),typeof EventTarget>`u`){class e{constructor(){this.listeners=new Map}addEventListener(e,t,n){this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t)}removeEventListener(e,t,n){this.listeners.get(e)?.delete(t)}dispatchEvent(e){let t=this.listeners.get(e.type);if(!t)return!0;for(let n of t)typeof n==`function`?n(e):n&&typeof n.handleEvent==`function`&&n.handleEvent(e);return!0}}typeof Symbol<`u`&&Symbol.toStringTag&&Object.defineProperty(e.prototype,Symbol.toStringTag,{value:`EventTarget`}),n=e}else n=EventTarget;e.default={EventTargetPolyfill:n},t.exports=e.default}));e(((e,t)=>{let n;if(Object.defineProperty(e,`__esModule`,{value:!0}),typeof URL>`u`){let e=function(e,t){if(t=t.split(`:`)[0],e=+e,!e)return!1;switch(t){case`http`:case`ws`:return e!==80;case`https`:case`wss`:return e!==443;case`ftp`:return e!==21;case`gopher`:return e!==70;case`file`:return!1}return e!==0};var r=Object.prototype.hasOwnProperty,i;let t=function(e){try{return decodeURIComponent(e.replace(/\+/g,` `))}catch{return null}},p=function(e){try{return encodeURIComponent(e)}catch{return null}},m=function(e){for(var n=/([^=?#&]+)=?([^&]*)/g,r={},i;i=n.exec(e);){var a=t(i[1]),o=t(i[2]);a===null||o===null||a in r||(r[a]=o)}return r},h=function(e,t){t||=``;var n=[],a,o;for(o in typeof t!=`string`&&(t=`?`),e)if(r.call(e,o)){if(a=e[o],!a&&(a===null||a===i||isNaN(a))&&(a=``),o=p(o),a=p(a),o===null||a===null)continue;n.push(o+`=`+a)}return n.length?t+n.join(`&`):``};var a=/^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/,o=/[\n\r\t]/g,s=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//,c=/:\d+$/,l=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i,u=/^[a-zA-Z]:/;let g=function(e){return(e||``).toString().replace(a,``)},_=function(e){var t=g(e),n=t.length;if(n===0)return t;for(;n&&!(t.charCodeAt(n-1)>32);)--n;return t.slice(0,n)};var d=[[`#`,`hash`],[`?`,`query`],function(e,t){return y(t.protocol)?e.replace(/\\/g,`/`):e},[`/`,`pathname`],[`@`,`auth`,1],[NaN,`host`,void 0,1,1],[/:(\d*)$/,`port`,void 0,1],[NaN,`hostname`,void 0,1,1]],f={hash:1,query:1};let v=function(e){var t=(typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{}).location||{};e||=t;var n={},r=typeof e,i;if(e.protocol===`blob:`)n=new S(unescape(e.pathname),{});else if(r===`string`)for(i in n=new S(e,{}),f)delete n[i];else if(r===`object`){for(i in e)i in f||(n[i]=e[i]);n.slashes===void 0&&(n.slashes=s.test(e.href))}return n},y=function(e){return e===`file:`||e===`ftp:`||e===`http:`||e===`https:`||e===`ws:`||e===`wss:`},b=function(e,t){e=_(e),e=e.replace(o,``),t||={};var n=l.exec(e),r=n[1]?n[1].toLowerCase():``,i=!!n[2],a=!!n[3],s=0,c;return i?a?(c=n[2]+n[3]+n[4],s=n[2].length+n[3].length):(c=n[2]+n[4],s=n[2].length):a?(c=n[3]+n[4],s=n[3].length):c=n[4],r===`file:`?s>=2&&(c=c.slice(2)):y(r)?c=n[4]:r?i&&(c=c.slice(2)):s>=2&&y(t.protocol)&&(c=n[4]),{protocol:r,slashes:i||y(r),slashesCount:s,rest:c}},x=function(e,t){if(e===``)return t;for(var n=(t||`/`).split(`/`).slice(0,-1).concat(e.split(`/`)),r=n.length,i=n[r-1],a=!1,o=0;r--;)n[r]===`.`?n.splice(r,1):n[r]===`..`?(n.splice(r,1),o++):o&&(r===0&&(a=!0),n.splice(r,1),o--);return a&&n.unshift(``),(i===`.`||i===`..`)&&n.push(``),n.join(`/`)};function S(t,n,r){if(!(this instanceof S))return new S(t,n,r);var i,a,o,s,c,l,f=d.slice(),p=typeof n,h=this,g=0;for(p!==`object`&&p!==`string`&&(r=n,n=null),r&&typeof r!=`function`&&(r=m),n=v(n),a=b(t||``,n),i=!a.protocol&&!a.slashes,h.slashes=a.slashes||i&&n.slashes,h.protocol=a.protocol||n.protocol||``,t=a.rest,(a.protocol===`file:`&&(a.slashesCount!==2||u.test(t))||!a.slashes&&(a.protocol||a.slashesCount<2||!y(h.protocol)))&&(f[3]=[/(.*)/,`pathname`]);g<f.length;g++){if(s=f[g],typeof s==`function`){t=s(t,h);continue}o=s[0],l=s[1],o===o?typeof o==`string`?(c=o===`@`?t.lastIndexOf(o):t.indexOf(o),~c&&(typeof s[2]==`number`?(h[l]=t.slice(0,c),t=t.slice(c+s[2])):(h[l]=t.slice(c),t=t.slice(0,c)))):(c=o.exec(t))&&(h[l]=c[1],t=t.slice(0,c.index)):h[l]=t,h[l]=h[l]||i&&s[3]&&n[l]||``,s[4]&&(h[l]=h[l].toLowerCase())}r&&(h.query=r(h.query)),i&&n.slashes&&h.pathname.charAt(0)!==`/`&&(h.pathname!==``||n.pathname!==``)&&(h.pathname=x(h.pathname,n.pathname)),h.pathname.charAt(0)!==`/`&&y(h.protocol)&&(h.pathname=`/`+h.pathname),e(h.port,h.protocol)||(h.host=h.hostname,h.port=``),h.username=h.password=``,h.auth&&=(c=h.auth.indexOf(`:`),~c?(h.username=h.auth.slice(0,c),h.username=encodeURIComponent(decodeURIComponent(h.username)),h.password=h.auth.slice(c+1),h.password=encodeURIComponent(decodeURIComponent(h.password))):h.username=encodeURIComponent(decodeURIComponent(h.auth)),h.password?h.username+`:`+h.password:h.username),h.origin=h.protocol!==`file:`&&y(h.protocol)&&h.host?h.protocol+`//`+h.host:`null`,h.href=h.toString()}S.prototype={set:function(t,n,r){var i=this;switch(t){case`query`:typeof n==`string`&&n.length&&(n=(r||m)(n)),i[t]=n;break;case`port`:i[t]=n,e(n,i.protocol)?n&&(i.host=i.hostname+`:`+n):(i.host=i.hostname,i[t]=``);break;case`hostname`:i[t]=n,i.port&&(n+=`:`+i.port),i.host=n;break;case`host`:i[t]=n,c.test(n)?(n=n.split(`:`),i.port=n.pop(),i.hostname=n.join(`:`)):(i.hostname=n,i.port=``);break;case`protocol`:i.protocol=n.toLowerCase(),i.protocol&&i.protocol.charAt(i.protocol.length-1)!==`:`&&(i.protocol+=`:`),i.slashes=!r;break;case`pathname`:case`hash`:if(n&&!r){var a=t===`pathname`?`/`:`#`;i[t]=n.charAt(0)===a?n:a+n}else i[t]=n;break;case`username`:case`password`:i[t]=encodeURIComponent(n);break;case`auth`:var o=n.indexOf(`:`);~o?(i.username=n.slice(0,o),i.username=encodeURIComponent(decodeURIComponent(i.username)),i.password=n.slice(o+1),i.password=encodeURIComponent(decodeURIComponent(i.password))):i.username=encodeURIComponent(decodeURIComponent(n))}for(var s=0;s<d.length;s++){var l=d[s];l[4]&&(i[l[1]]=i[l[1]].toLowerCase())}return i.auth=i.password?i.username+`:`+i.password:i.username,i.origin=i.protocol!==`file:`&&y(i.protocol)&&i.host?i.protocol+`//`+i.host:`null`,i.href=i.toString(),i},toString:function(e){(!e||typeof e!=`function`)&&(e=h);var t,n=this,r=n.host,i=n.protocol;i&&i.charAt(i.length-1)!==`:`&&(i+=`:`);var a=i+(i&&n.slashes||y(i)?`//`:``);return n.username?(a+=n.username,n.password&&(a+=`:`+n.password),a+=`@`):n.password?(a+=`:`+n.password,a+=`@`):i!==`file:`&&y(i)&&!r&&n.pathname!==`/`&&(a+=`@`),(r[r.length-1]===`:`||c.test(n.hostname)&&!n.port)&&(r+=`:`),a+=r+n.pathname,t=typeof n.query==`object`?e(n.query):n.query,t&&(a+=t.charAt(0)===`?`?t:`?`+t),n.hash&&(a+=n.hash),a}},S.extractProtocol=b,S.location=v,S.trimLeft=g,S.stringify=h,S.parse=m,S.canParse=()=>{},S.createObjectURL=()=>{},S.revokeObjectURL=()=>{},typeof Symbol<`u`&&Symbol.toStringTag&&Object.defineProperty(S.prototype,Symbol.toStringTag,{value:`URL`}),n=S}else n=URL;e.default=n,t.exports=e.default}))(),r(),n(),t(),class e extends EventTarget{static{this.CONNECTING=0}static{this.OPEN=1}static{this.CLOSING=2}static{this.CLOSED=3}constructor(t,n){if(super(),this.CONNECTING=0,this.OPEN=1,this.CLOSING=2,this.CLOSED=3,this.binaryType=`arraybuffer`,this.readyState=0,this.url=``,this.extensions=``,this.bufferedAmount=0,typeof wx>`u`||!wx.connectSocket)throw Error(`This Function MUST be used in MotherFucker WeChat, you know what I mean?`);if(!(this instanceof e))throw TypeError(`Constructor WebSocket requires 'new'`);this.url=t.toString(),this.protocol=n?.[0]||``,this.readyState=e.CONNECTING;let r=wx.connectSocket({url:this.url,protocols:n,success:()=>{},complete:()=>{},fail:t=>{this.readyState=e.CLOSED,this.dispatchEvent({type:`error`,message:t.errMsg})}});r.onOpen(t=>{this.readyState=e.OPEN,this.extensions=t.header?.[`Sec-WebSocket-Extensions`]||``,this.protocol=t.header?.[`Sec-WebSocket-Protocol`],this.dispatchEvent({type:`open`})}),r.onMessage(e=>{this.dispatchEvent({type:`message`,data:e})}),r.onClose(t=>{this.readyState=e.CLOSED,this.dispatchEvent({type:`close`,detial:t.code,message:t.reason})}),r.onError(t=>{this.readyState=e.CLOSED,this.dispatchEvent({type:`error`,message:t.errMsg}),this.dispatchEvent({type:`close`,message:t.errMsg})})}send(t){if(this.readyState!==e.OPEN)return this.dispatchEvent({type:`error`,message:`Socket is not open`});wx.sendSocketMessage({data:t,success:()=>{},fail:()=>{},complete:()=>{}})}close(t=1e3,n=``){this.readyState!==e.CLOSED&&(this.readyState=e.CLOSING,wx.closeSocket({code:t,reason:n,success:()=>{},fail:()=>{},complete:()=>{}}))}onclose(){}onerror(){}onmessage(){}onopen(){}};function i(e,t){return new Promise((n,r)=>{if(typeof wx>`u`||!wx.request)return r(Error(`This Function MUST be used in MotherFucker WeChat, you know what I mean?`));let{method:i,headers:a,body:o}=t||{},s=e instanceof URL?e.href:e.toString();wx.request({url:s,method:i,header:a,data:o?.buffer,dataType:`other`,responseType:`arraybuffer`,success:e=>{let t={ok:e.statusCode>=200&&e.statusCode<300,status:e.statusCode,statusText:e.errMsg,headers:e.header,arrayBuffer:()=>Promise.resolve(e.data),blob:()=>Promise.resolve(e.data),redirected:!1,url:s,clone:()=>t,type:`default`,body:e.data,bodyUsed:!1,formData:()=>Promise.resolve(e.data),json:()=>Promise.resolve(e.data),text:()=>Promise.resolve(e.data)};n(t)},fail:e=>{r(Error(e.errMsg))}})})}i.preconnect=()=>{};
|
|
@@ -1,491 +1,500 @@
|
|
|
1
|
+
import { t as __commonJSMin } from "./chunk-N6xyN86N.js";
|
|
2
|
+
|
|
1
3
|
//#region jspolyfill/url.js
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* @
|
|
9
|
-
* @
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* @
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
*
|
|
97
|
-
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
* @
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
* @
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
* location
|
|
183
|
-
*
|
|
184
|
-
* location
|
|
185
|
-
*
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
*
|
|
217
|
-
*
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
* @
|
|
227
|
-
* @
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
*
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
*
|
|
234
|
-
*
|
|
235
|
-
* @
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
}
|
|
254
|
-
else if (otherSlashes) {
|
|
255
|
-
rest = match[3] + match[4];
|
|
256
|
-
slashesCount = match[3].length;
|
|
257
|
-
} else rest = match[4];
|
|
258
|
-
if (protocol === "file:") {
|
|
259
|
-
if (slashesCount >= 2) rest = rest.slice(2);
|
|
260
|
-
} else if (isSpecial(protocol)) rest = match[4];
|
|
261
|
-
else if (protocol) {
|
|
262
|
-
if (forwardSlashes) rest = rest.slice(2);
|
|
263
|
-
} else if (slashesCount >= 2 && isSpecial(location.protocol)) rest = match[4];
|
|
264
|
-
return {
|
|
265
|
-
protocol,
|
|
266
|
-
slashes: forwardSlashes || isSpecial(protocol),
|
|
267
|
-
slashesCount,
|
|
268
|
-
rest
|
|
269
|
-
};
|
|
270
|
-
}
|
|
271
|
-
/**
|
|
272
|
-
* Resolve a relative URL pathname against a base URL pathname.
|
|
273
|
-
*
|
|
274
|
-
* @param {String} relative Pathname of the relative URL.
|
|
275
|
-
* @param {String} base Pathname of the base URL.
|
|
276
|
-
* @return {String} Resolved pathname.
|
|
277
|
-
* @private
|
|
278
|
-
*/
|
|
279
|
-
function resolve(relative, base) {
|
|
280
|
-
if (relative === "") return base;
|
|
281
|
-
var path = (base || "/").split("/").slice(0, -1).concat(relative.split("/")), i = path.length, last = path[i - 1], unshift = false, up = 0;
|
|
282
|
-
while (i--) if (path[i] === ".") path.splice(i, 1);
|
|
283
|
-
else if (path[i] === "..") {
|
|
284
|
-
path.splice(i, 1);
|
|
285
|
-
up++;
|
|
286
|
-
} else if (up) {
|
|
287
|
-
if (i === 0) unshift = true;
|
|
288
|
-
path.splice(i, 1);
|
|
289
|
-
up--;
|
|
290
|
-
}
|
|
291
|
-
if (unshift) path.unshift("");
|
|
292
|
-
if (last === "." || last === "..") path.push("");
|
|
293
|
-
return path.join("/");
|
|
294
|
-
}
|
|
295
|
-
/**
|
|
296
|
-
* The actual URL instance. Instead of returning an object we've opted-in to
|
|
297
|
-
* create an actual constructor as it's much more memory efficient and
|
|
298
|
-
* faster and it pleases my OCD.
|
|
299
|
-
*
|
|
300
|
-
* It is worth noting that we should not use `URL` as class name to prevent
|
|
301
|
-
* clashes with the global URL instance that got introduced in browsers.
|
|
302
|
-
*
|
|
303
|
-
* @constructor
|
|
304
|
-
* @param {String} address URL we want to parse.
|
|
305
|
-
* @param {Object|String} [location] Location defaults for relative paths.
|
|
306
|
-
* @param {Boolean|Function} [parser] Parser for the query string.
|
|
307
|
-
* @private
|
|
308
|
-
*/
|
|
309
|
-
function Url(address, location, parser) {
|
|
310
|
-
if (!(this instanceof Url)) return new Url(address, location, parser);
|
|
311
|
-
var relative, extracted, parse, instruction, index, key, instructions = rules.slice(), type = typeof location, url = this, i = 0;
|
|
312
|
-
if ("object" !== type && "string" !== type) {
|
|
313
|
-
parser = location;
|
|
314
|
-
location = null;
|
|
315
|
-
}
|
|
316
|
-
if (parser && "function" !== typeof parser) parser = queryparse;
|
|
317
|
-
location = lolcation(location);
|
|
318
|
-
extracted = extractProtocol(address || "", location);
|
|
319
|
-
relative = !extracted.protocol && !extracted.slashes;
|
|
320
|
-
url.slashes = extracted.slashes || relative && location.slashes;
|
|
321
|
-
url.protocol = extracted.protocol || location.protocol || "";
|
|
322
|
-
address = extracted.rest;
|
|
323
|
-
if (extracted.protocol === "file:" && (extracted.slashesCount !== 2 || windowsDriveLetter.test(address)) || !extracted.slashes && (extracted.protocol || extracted.slashesCount < 2 || !isSpecial(url.protocol))) instructions[3] = [/(.*)/, "pathname"];
|
|
324
|
-
for (; i < instructions.length; i++) {
|
|
325
|
-
instruction = instructions[i];
|
|
326
|
-
if (typeof instruction === "function") {
|
|
327
|
-
address = instruction(address, url);
|
|
328
|
-
continue;
|
|
329
|
-
}
|
|
330
|
-
parse = instruction[0];
|
|
331
|
-
key = instruction[1];
|
|
332
|
-
if (parse !== parse) url[key] = address;
|
|
333
|
-
else if ("string" === typeof parse) {
|
|
334
|
-
index = parse === "@" ? address.lastIndexOf(parse) : address.indexOf(parse);
|
|
335
|
-
if (~index) if ("number" === typeof instruction[2]) {
|
|
336
|
-
url[key] = address.slice(0, index);
|
|
337
|
-
address = address.slice(index + instruction[2]);
|
|
4
|
+
var require_url = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
5
|
+
let URLPolyfill;
|
|
6
|
+
if (Object.defineProperty(exports, "__esModule", { value: !0 }), "undefined" == typeof URL) {
|
|
7
|
+
/**
|
|
8
|
+
* Check if we're required to add a port number.
|
|
9
|
+
*
|
|
10
|
+
* @see https://url.spec.whatwg.org/#default-port
|
|
11
|
+
* @param {Number|String} port Port number we need to check
|
|
12
|
+
* @param {String} protocol Protocol we need to check against.
|
|
13
|
+
* @returns {Boolean} Is it a default port for the given protocol
|
|
14
|
+
* @api private
|
|
15
|
+
*/
|
|
16
|
+
const required_port = function(port, protocol) {
|
|
17
|
+
protocol = protocol.split(":")[0];
|
|
18
|
+
port = +port;
|
|
19
|
+
if (!port) return false;
|
|
20
|
+
switch (protocol) {
|
|
21
|
+
case "http":
|
|
22
|
+
case "ws": return port !== 80;
|
|
23
|
+
case "https":
|
|
24
|
+
case "wss": return port !== 443;
|
|
25
|
+
case "ftp": return port !== 21;
|
|
26
|
+
case "gopher": return port !== 70;
|
|
27
|
+
case "file": return false;
|
|
28
|
+
}
|
|
29
|
+
return port !== 0;
|
|
30
|
+
};
|
|
31
|
+
var has = Object.prototype.hasOwnProperty, undef;
|
|
32
|
+
/**
|
|
33
|
+
* Decode a URI encoded string.
|
|
34
|
+
*
|
|
35
|
+
* @param {String} input The URI encoded string.
|
|
36
|
+
* @returns {String|Null} The decoded string.
|
|
37
|
+
* @api private
|
|
38
|
+
*/
|
|
39
|
+
const decode = function(input) {
|
|
40
|
+
try {
|
|
41
|
+
return decodeURIComponent(input.replace(/\+/g, " "));
|
|
42
|
+
} catch (e) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Attempts to encode a given input.
|
|
48
|
+
*
|
|
49
|
+
* @param {String} input The string that needs to be encoded.
|
|
50
|
+
* @returns {String|Null} The encoded string.
|
|
51
|
+
* @api private
|
|
52
|
+
*/
|
|
53
|
+
const encode = function(input) {
|
|
54
|
+
try {
|
|
55
|
+
return encodeURIComponent(input);
|
|
56
|
+
} catch (e) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Simple query string parser.
|
|
62
|
+
*
|
|
63
|
+
* @param {String} query The query string that needs to be parsed.
|
|
64
|
+
* @returns {Object}
|
|
65
|
+
* @api public
|
|
66
|
+
*/
|
|
67
|
+
const queryparse = function(query) {
|
|
68
|
+
var parser = /([^=?#&]+)=?([^&]*)/g, result = {}, part;
|
|
69
|
+
while (part = parser.exec(query)) {
|
|
70
|
+
var key = decode(part[1]), value = decode(part[2]);
|
|
71
|
+
if (key === null || value === null || key in result) continue;
|
|
72
|
+
result[key] = value;
|
|
73
|
+
}
|
|
74
|
+
return result;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Transform a query string to an object.
|
|
78
|
+
*
|
|
79
|
+
* @param {Object} obj Object that should be transformed.
|
|
80
|
+
* @param {String} prefix Optional prefix.
|
|
81
|
+
* @returns {String}
|
|
82
|
+
* @api public
|
|
83
|
+
*/
|
|
84
|
+
const querystringify = function(obj, prefix) {
|
|
85
|
+
prefix = prefix || "";
|
|
86
|
+
var pairs = [], value, key;
|
|
87
|
+
if ("string" !== typeof prefix) prefix = "?";
|
|
88
|
+
for (key in obj) if (has.call(obj, key)) {
|
|
89
|
+
value = obj[key];
|
|
90
|
+
if (!value && (value === null || value === undef || isNaN(value))) value = "";
|
|
91
|
+
key = encode(key);
|
|
92
|
+
value = encode(value);
|
|
93
|
+
if (key === null || value === null) continue;
|
|
94
|
+
pairs.push(key + "=" + value);
|
|
95
|
+
}
|
|
96
|
+
return pairs.length ? prefix + pairs.join("&") : "";
|
|
97
|
+
};
|
|
98
|
+
var controlOrWhitespace = /^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/, CRHTLF = /[\n\r\t]/g, slashes = /^[A-Za-z][A-Za-z0-9+-.]*:\/\//, port = /:\d+$/, protocolre = /^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i, windowsDriveLetter = /^[a-zA-Z]:/;
|
|
99
|
+
/**
|
|
100
|
+
* Remove control characters and whitespace from the beginning of a string.
|
|
101
|
+
*
|
|
102
|
+
* @param {Object|String} str String to trim.
|
|
103
|
+
* @returns {String} A new string representing `str` stripped of control
|
|
104
|
+
* characters and whitespace from its beginning.
|
|
105
|
+
* @public
|
|
106
|
+
*/
|
|
107
|
+
const trimLeft = function(str) {
|
|
108
|
+
return (str ? str : "").toString().replace(controlOrWhitespace, "");
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Remove control characters and whitespace from both ends of a string.
|
|
112
|
+
*
|
|
113
|
+
* @param {Object|String} str String to trim.
|
|
114
|
+
* @returns {String} A new string representing `str` stripped of control
|
|
115
|
+
* characters and whitespace from both its beginning and end.
|
|
116
|
+
* @private
|
|
117
|
+
*/
|
|
118
|
+
const trim = function(str) {
|
|
119
|
+
var trimmed = trimLeft(str);
|
|
120
|
+
var i = trimmed.length;
|
|
121
|
+
if (i === 0) return trimmed;
|
|
122
|
+
while (i) if (trimmed.charCodeAt(i - 1) > 32) break;
|
|
123
|
+
else i = i - 1;
|
|
124
|
+
return trimmed.slice(0, i);
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* These are the parse rules for the URL parser, it informs the parser
|
|
128
|
+
* about:
|
|
129
|
+
*
|
|
130
|
+
* 0. The char it Needs to parse, if it's a string it should be done using
|
|
131
|
+
* indexOf, RegExp using exec and NaN means set as current value.
|
|
132
|
+
* 1. The property we should set when parsing this value.
|
|
133
|
+
* 2. Indication if it's backwards or forward parsing, when set as number it's
|
|
134
|
+
* the value of extra chars that should be split off.
|
|
135
|
+
* 3. Inherit from location if non existing in the parser.
|
|
136
|
+
* 4. `toLowerCase` the resulting value.
|
|
137
|
+
*/
|
|
138
|
+
var rules = [
|
|
139
|
+
["#", "hash"],
|
|
140
|
+
["?", "query"],
|
|
141
|
+
function sanitize(address, url) {
|
|
142
|
+
return isSpecial(url.protocol) ? address.replace(/\\/g, "/") : address;
|
|
143
|
+
},
|
|
144
|
+
["/", "pathname"],
|
|
145
|
+
[
|
|
146
|
+
"@",
|
|
147
|
+
"auth",
|
|
148
|
+
1
|
|
149
|
+
],
|
|
150
|
+
[
|
|
151
|
+
NaN,
|
|
152
|
+
"host",
|
|
153
|
+
void 0,
|
|
154
|
+
1,
|
|
155
|
+
1
|
|
156
|
+
],
|
|
157
|
+
[
|
|
158
|
+
/:(\d*)$/,
|
|
159
|
+
"port",
|
|
160
|
+
void 0,
|
|
161
|
+
1
|
|
162
|
+
],
|
|
163
|
+
[
|
|
164
|
+
NaN,
|
|
165
|
+
"hostname",
|
|
166
|
+
void 0,
|
|
167
|
+
1,
|
|
168
|
+
1
|
|
169
|
+
]
|
|
170
|
+
];
|
|
171
|
+
/**
|
|
172
|
+
* These properties should not be copied or inherited from. This is only needed
|
|
173
|
+
* for all non blob URL's as a blob URL does not include a hash, only the
|
|
174
|
+
* origin.
|
|
175
|
+
*
|
|
176
|
+
* @type {Object}
|
|
177
|
+
* @private
|
|
178
|
+
*/
|
|
179
|
+
var ignore = {
|
|
180
|
+
hash: 1,
|
|
181
|
+
query: 1
|
|
182
|
+
};
|
|
183
|
+
/**
|
|
184
|
+
* The location object differs when your code is loaded through a normal page,
|
|
185
|
+
* Worker or through a worker using a blob. And with the blobble begins the
|
|
186
|
+
* trouble as the location object will contain the URL of the blob, not the
|
|
187
|
+
* location of the page where our code is loaded in. The actual origin is
|
|
188
|
+
* encoded in the `pathname` so we can thankfully generate a good "default"
|
|
189
|
+
* location from it so we can generate proper relative URL's again.
|
|
190
|
+
*
|
|
191
|
+
* @param {Object|String} loc Optional default location object.
|
|
192
|
+
* @returns {Object} lolcation object.
|
|
193
|
+
* @public
|
|
194
|
+
*/
|
|
195
|
+
const lolcation = function(loc) {
|
|
196
|
+
var globalVar;
|
|
197
|
+
if (typeof window !== "undefined") globalVar = window;
|
|
198
|
+
else if (typeof global !== "undefined") globalVar = global;
|
|
199
|
+
else if (typeof self !== "undefined") globalVar = self;
|
|
200
|
+
else globalVar = {};
|
|
201
|
+
var location = globalVar.location || {};
|
|
202
|
+
loc = loc || location;
|
|
203
|
+
var finaldestination = {}, type = typeof loc, key;
|
|
204
|
+
if ("blob:" === loc.protocol) finaldestination = new Url(unescape(loc.pathname), {});
|
|
205
|
+
else if ("string" === type) {
|
|
206
|
+
finaldestination = new Url(loc, {});
|
|
207
|
+
for (key in ignore) delete finaldestination[key];
|
|
208
|
+
} else if ("object" === type) {
|
|
209
|
+
for (key in loc) {
|
|
210
|
+
if (key in ignore) continue;
|
|
211
|
+
finaldestination[key] = loc[key];
|
|
212
|
+
}
|
|
213
|
+
if (finaldestination.slashes === void 0) finaldestination.slashes = slashes.test(loc.href);
|
|
214
|
+
}
|
|
215
|
+
return finaldestination;
|
|
216
|
+
};
|
|
217
|
+
/**
|
|
218
|
+
* Check whether a protocol scheme is special.
|
|
219
|
+
*
|
|
220
|
+
* @param {String} The protocol scheme of the URL
|
|
221
|
+
* @return {Boolean} `true` if the protocol scheme is special, else `false`
|
|
222
|
+
* @private
|
|
223
|
+
*/
|
|
224
|
+
const isSpecial = function(scheme) {
|
|
225
|
+
return scheme === "file:" || scheme === "ftp:" || scheme === "http:" || scheme === "https:" || scheme === "ws:" || scheme === "wss:";
|
|
226
|
+
};
|
|
227
|
+
/**
|
|
228
|
+
* @typedef ProtocolExtract
|
|
229
|
+
* @type Object
|
|
230
|
+
* @property {String} protocol Protocol matched in the URL, in lowercase.
|
|
231
|
+
* @property {Boolean} slashes `true` if protocol is followed by "//", else `false`.
|
|
232
|
+
* @property {String} rest Rest of the URL that is not part of the protocol.
|
|
233
|
+
*/
|
|
234
|
+
/**
|
|
235
|
+
* Extract protocol information from a URL with/without double slash ("//").
|
|
236
|
+
*
|
|
237
|
+
* @param {String} address URL we want to extract from.
|
|
238
|
+
* @param {Object} location
|
|
239
|
+
* @return {ProtocolExtract} Extracted information.
|
|
240
|
+
* @private
|
|
241
|
+
*/
|
|
242
|
+
const extractProtocol = function(address, location) {
|
|
243
|
+
address = trim(address);
|
|
244
|
+
address = address.replace(CRHTLF, "");
|
|
245
|
+
location = location || {};
|
|
246
|
+
var match = protocolre.exec(address);
|
|
247
|
+
var protocol = match[1] ? match[1].toLowerCase() : "";
|
|
248
|
+
var forwardSlashes = !!match[2];
|
|
249
|
+
var otherSlashes = !!match[3];
|
|
250
|
+
var slashesCount = 0;
|
|
251
|
+
var rest;
|
|
252
|
+
if (forwardSlashes) if (otherSlashes) {
|
|
253
|
+
rest = match[2] + match[3] + match[4];
|
|
254
|
+
slashesCount = match[2].length + match[3].length;
|
|
338
255
|
} else {
|
|
339
|
-
|
|
340
|
-
|
|
256
|
+
rest = match[2] + match[4];
|
|
257
|
+
slashesCount = match[2].length;
|
|
341
258
|
}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
*
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
259
|
+
else if (otherSlashes) {
|
|
260
|
+
rest = match[3] + match[4];
|
|
261
|
+
slashesCount = match[3].length;
|
|
262
|
+
} else rest = match[4];
|
|
263
|
+
if (protocol === "file:") {
|
|
264
|
+
if (slashesCount >= 2) rest = rest.slice(2);
|
|
265
|
+
} else if (isSpecial(protocol)) rest = match[4];
|
|
266
|
+
else if (protocol) {
|
|
267
|
+
if (forwardSlashes) rest = rest.slice(2);
|
|
268
|
+
} else if (slashesCount >= 2 && isSpecial(location.protocol)) rest = match[4];
|
|
269
|
+
return {
|
|
270
|
+
protocol,
|
|
271
|
+
slashes: forwardSlashes || isSpecial(protocol),
|
|
272
|
+
slashesCount,
|
|
273
|
+
rest
|
|
274
|
+
};
|
|
275
|
+
};
|
|
276
|
+
/**
|
|
277
|
+
* Resolve a relative URL pathname against a base URL pathname.
|
|
278
|
+
*
|
|
279
|
+
* @param {String} relative Pathname of the relative URL.
|
|
280
|
+
* @param {String} base Pathname of the base URL.
|
|
281
|
+
* @return {String} Resolved pathname.
|
|
282
|
+
* @private
|
|
283
|
+
*/
|
|
284
|
+
const resolve = function(relative, base) {
|
|
285
|
+
if (relative === "") return base;
|
|
286
|
+
var path = (base || "/").split("/").slice(0, -1).concat(relative.split("/")), i = path.length, last = path[i - 1], unshift = false, up = 0;
|
|
287
|
+
while (i--) if (path[i] === ".") path.splice(i, 1);
|
|
288
|
+
else if (path[i] === "..") {
|
|
289
|
+
path.splice(i, 1);
|
|
290
|
+
up++;
|
|
291
|
+
} else if (up) {
|
|
292
|
+
if (i === 0) unshift = true;
|
|
293
|
+
path.splice(i, 1);
|
|
294
|
+
up--;
|
|
295
|
+
}
|
|
296
|
+
if (unshift) path.unshift("");
|
|
297
|
+
if (last === "." || last === "..") path.push("");
|
|
298
|
+
return path.join("/");
|
|
299
|
+
};
|
|
300
|
+
/**
|
|
301
|
+
* The actual URL instance. Instead of returning an object we've opted-in to
|
|
302
|
+
* create an actual constructor as it's much more memory efficient and
|
|
303
|
+
* faster and it pleases my OCD.
|
|
304
|
+
*
|
|
305
|
+
* It is worth noting that we should not use `URL` as class name to prevent
|
|
306
|
+
* clashes with the global URL instance that got introduced in browsers.
|
|
307
|
+
*
|
|
308
|
+
* @constructor
|
|
309
|
+
* @param {String} address URL we want to parse.
|
|
310
|
+
* @param {Object|String} [location] Location defaults for relative paths.
|
|
311
|
+
* @param {Boolean|Function} [parser] Parser for the query string.
|
|
312
|
+
* @private
|
|
313
|
+
*/
|
|
314
|
+
function Url(address, location, parser) {
|
|
315
|
+
if (!(this instanceof Url)) return new Url(address, location, parser);
|
|
316
|
+
var relative, extracted, parse, instruction, index, key, instructions = rules.slice(), type = typeof location, url = this, i = 0;
|
|
317
|
+
if ("object" !== type && "string" !== type) {
|
|
318
|
+
parser = location;
|
|
319
|
+
location = null;
|
|
320
|
+
}
|
|
321
|
+
if (parser && "function" !== typeof parser) parser = queryparse;
|
|
322
|
+
location = lolcation(location);
|
|
323
|
+
extracted = extractProtocol(address || "", location);
|
|
324
|
+
relative = !extracted.protocol && !extracted.slashes;
|
|
325
|
+
url.slashes = extracted.slashes || relative && location.slashes;
|
|
326
|
+
url.protocol = extracted.protocol || location.protocol || "";
|
|
327
|
+
address = extracted.rest;
|
|
328
|
+
if (extracted.protocol === "file:" && (extracted.slashesCount !== 2 || windowsDriveLetter.test(address)) || !extracted.slashes && (extracted.protocol || extracted.slashesCount < 2 || !isSpecial(url.protocol))) instructions[3] = [/(.*)/, "pathname"];
|
|
329
|
+
for (; i < instructions.length; i++) {
|
|
330
|
+
instruction = instructions[i];
|
|
331
|
+
if (typeof instruction === "function") {
|
|
332
|
+
address = instruction(address, url);
|
|
333
|
+
continue;
|
|
334
|
+
}
|
|
335
|
+
parse = instruction[0];
|
|
336
|
+
key = instruction[1];
|
|
337
|
+
if (parse !== parse) url[key] = address;
|
|
338
|
+
else if ("string" === typeof parse) {
|
|
339
|
+
index = parse === "@" ? address.lastIndexOf(parse) : address.indexOf(parse);
|
|
340
|
+
if (~index) if ("number" === typeof instruction[2]) {
|
|
341
|
+
url[key] = address.slice(0, index);
|
|
342
|
+
address = address.slice(index + instruction[2]);
|
|
343
|
+
} else {
|
|
344
|
+
url[key] = address.slice(index);
|
|
345
|
+
address = address.slice(0, index);
|
|
346
|
+
}
|
|
347
|
+
} else if (index = parse.exec(address)) {
|
|
348
|
+
url[key] = index[1];
|
|
349
|
+
address = address.slice(0, index.index);
|
|
350
|
+
}
|
|
351
|
+
url[key] = url[key] || (relative && instruction[3] ? location[key] || "" : "");
|
|
352
|
+
if (instruction[4]) url[key] = url[key].toLowerCase();
|
|
353
|
+
}
|
|
354
|
+
if (parser) url.query = parser(url.query);
|
|
355
|
+
if (relative && location.slashes && url.pathname.charAt(0) !== "/" && (url.pathname !== "" || location.pathname !== "")) url.pathname = resolve(url.pathname, location.pathname);
|
|
356
|
+
if (url.pathname.charAt(0) !== "/" && isSpecial(url.protocol)) url.pathname = "/" + url.pathname;
|
|
357
|
+
if (!required_port(url.port, url.protocol)) {
|
|
396
358
|
url.host = url.hostname;
|
|
397
|
-
url[part] = "";
|
|
398
|
-
} else if (value) url.host = url.hostname + ":" + value;
|
|
399
|
-
break;
|
|
400
|
-
case "hostname":
|
|
401
|
-
url[part] = value;
|
|
402
|
-
if (url.port) value += ":" + url.port;
|
|
403
|
-
url.host = value;
|
|
404
|
-
break;
|
|
405
|
-
case "host":
|
|
406
|
-
url[part] = value;
|
|
407
|
-
if (port.test(value)) {
|
|
408
|
-
value = value.split(":");
|
|
409
|
-
url.port = value.pop();
|
|
410
|
-
url.hostname = value.join(":");
|
|
411
|
-
} else {
|
|
412
|
-
url.hostname = value;
|
|
413
359
|
url.port = "";
|
|
414
360
|
}
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
361
|
+
url.username = url.password = "";
|
|
362
|
+
if (url.auth) {
|
|
363
|
+
index = url.auth.indexOf(":");
|
|
364
|
+
if (~index) {
|
|
365
|
+
url.username = url.auth.slice(0, index);
|
|
366
|
+
url.username = encodeURIComponent(decodeURIComponent(url.username));
|
|
367
|
+
url.password = url.auth.slice(index + 1);
|
|
368
|
+
url.password = encodeURIComponent(decodeURIComponent(url.password));
|
|
369
|
+
} else url.username = encodeURIComponent(decodeURIComponent(url.auth));
|
|
370
|
+
url.auth = url.password ? url.username + ":" + url.password : url.username;
|
|
371
|
+
}
|
|
372
|
+
url.origin = url.protocol !== "file:" && isSpecial(url.protocol) && url.host ? url.protocol + "//" + url.host : "null";
|
|
373
|
+
url.href = url.toString();
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* This is convenience method for changing properties in the URL instance to
|
|
377
|
+
* insure that they all propagate correctly.
|
|
378
|
+
*
|
|
379
|
+
* @param {String} part Property we need to adjust.
|
|
380
|
+
* @param {Mixed} value The newly assigned value.
|
|
381
|
+
* @param {Boolean|Function} fn When setting the query, it will be the function
|
|
382
|
+
* used to parse the query.
|
|
383
|
+
* When setting the protocol, double slash will be
|
|
384
|
+
* removed from the final url if it is truthy.
|
|
385
|
+
* When setting the pathname or the hash, a
|
|
386
|
+
* leading / or # will not be automatically added
|
|
387
|
+
* if it is truthy.
|
|
388
|
+
* @returns {URL} URL instance for chaining.
|
|
389
|
+
* @public
|
|
390
|
+
*/
|
|
391
|
+
const set = function(part, value, fn) {
|
|
392
|
+
var url = this;
|
|
393
|
+
switch (part) {
|
|
394
|
+
case "query":
|
|
395
|
+
if ("string" === typeof value && value.length) value = (fn || queryparse)(value);
|
|
396
|
+
url[part] = value;
|
|
397
|
+
break;
|
|
398
|
+
case "port":
|
|
399
|
+
url[part] = value;
|
|
400
|
+
if (!required_port(value, url.protocol)) {
|
|
401
|
+
url.host = url.hostname;
|
|
402
|
+
url[part] = "";
|
|
403
|
+
} else if (value) url.host = url.hostname + ":" + value;
|
|
404
|
+
break;
|
|
405
|
+
case "hostname":
|
|
406
|
+
url[part] = value;
|
|
407
|
+
if (url.port) value += ":" + url.port;
|
|
408
|
+
url.host = value;
|
|
409
|
+
break;
|
|
410
|
+
case "host":
|
|
411
|
+
url[part] = value;
|
|
412
|
+
if (port.test(value)) {
|
|
413
|
+
value = value.split(":");
|
|
414
|
+
url.port = value.pop();
|
|
415
|
+
url.hostname = value.join(":");
|
|
416
|
+
} else {
|
|
417
|
+
url.hostname = value;
|
|
418
|
+
url.port = "";
|
|
419
|
+
}
|
|
420
|
+
break;
|
|
421
|
+
case "protocol":
|
|
422
|
+
url.protocol = value.toLowerCase();
|
|
423
|
+
if (url.protocol && url.protocol.charAt(url.protocol.length - 1) !== ":") url.protocol += ":";
|
|
424
|
+
url.slashes = !fn;
|
|
425
|
+
break;
|
|
426
|
+
case "pathname":
|
|
427
|
+
case "hash":
|
|
428
|
+
if (value && !fn) {
|
|
429
|
+
var char = part === "pathname" ? "/" : "#";
|
|
430
|
+
url[part] = value.charAt(0) !== char ? char + value : value;
|
|
431
|
+
} else url[part] = value;
|
|
432
|
+
break;
|
|
433
|
+
case "username":
|
|
434
|
+
case "password":
|
|
435
|
+
url[part] = encodeURIComponent(value);
|
|
436
|
+
break;
|
|
437
|
+
case "auth":
|
|
438
|
+
var index = value.indexOf(":");
|
|
439
|
+
if (~index) {
|
|
440
|
+
url.username = value.slice(0, index);
|
|
441
|
+
url.username = encodeURIComponent(decodeURIComponent(url.username));
|
|
442
|
+
url.password = value.slice(index + 1);
|
|
443
|
+
url.password = encodeURIComponent(decodeURIComponent(url.password));
|
|
444
|
+
} else url.username = encodeURIComponent(decodeURIComponent(value));
|
|
445
|
+
}
|
|
446
|
+
for (var i = 0; i < rules.length; i++) {
|
|
447
|
+
var ins = rules[i];
|
|
448
|
+
if (ins[4]) url[ins[1]] = url[ins[1]].toLowerCase();
|
|
449
|
+
}
|
|
450
|
+
url.auth = url.password ? url.username + ":" + url.password : url.username;
|
|
451
|
+
url.origin = url.protocol !== "file:" && isSpecial(url.protocol) && url.host ? url.protocol + "//" + url.host : "null";
|
|
452
|
+
url.href = url.toString();
|
|
453
|
+
return url;
|
|
454
|
+
};
|
|
455
|
+
/**
|
|
456
|
+
* Transform the properties back in to a valid and full URL string.
|
|
457
|
+
*
|
|
458
|
+
* @param {Function} stringify Optional query stringify function.
|
|
459
|
+
* @returns {String} Compiled version of the URL.
|
|
460
|
+
* @public
|
|
461
|
+
*/
|
|
462
|
+
const toString = function(stringify) {
|
|
463
|
+
if (!stringify || "function" !== typeof stringify) stringify = querystringify;
|
|
464
|
+
var query, url = this, host = url.host, protocol = url.protocol;
|
|
465
|
+
if (protocol && protocol.charAt(protocol.length - 1) !== ":") protocol += ":";
|
|
466
|
+
var result = protocol + (protocol && url.slashes || isSpecial(protocol) ? "//" : "");
|
|
467
|
+
if (url.username) {
|
|
468
|
+
result += url.username;
|
|
469
|
+
if (url.password) result += ":" + url.password;
|
|
470
|
+
result += "@";
|
|
471
|
+
} else if (url.password) {
|
|
472
|
+
result += ":" + url.password;
|
|
473
|
+
result += "@";
|
|
474
|
+
} else if (protocol !== "file:" && isSpecial(protocol) && !host && url.pathname !== "/") result += "@";
|
|
475
|
+
if (host[host.length - 1] === ":" || port.test(url.hostname) && !url.port) host += ":";
|
|
476
|
+
result += host + url.pathname;
|
|
477
|
+
query = "object" === typeof url.query ? stringify(url.query) : url.query;
|
|
478
|
+
if (query) result += "?" !== query.charAt(0) ? "?" + query : query;
|
|
479
|
+
if (url.hash) result += url.hash;
|
|
480
|
+
return result;
|
|
481
|
+
};
|
|
482
|
+
Url.prototype = {
|
|
483
|
+
set,
|
|
484
|
+
toString
|
|
485
|
+
};
|
|
486
|
+
Url.extractProtocol = extractProtocol;
|
|
487
|
+
Url.location = lolcation;
|
|
488
|
+
Url.trimLeft = trimLeft;
|
|
489
|
+
Url.stringify = querystringify;
|
|
490
|
+
Url.parse = queryparse;
|
|
491
|
+
Url.canParse = () => {};
|
|
492
|
+
Url.createObjectURL = () => {};
|
|
493
|
+
Url.revokeObjectURL = () => {};
|
|
494
|
+
"undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(Url.prototype, Symbol.toStringTag, { value: "URL" }), URLPolyfill = Url;
|
|
495
|
+
} else URLPolyfill = URL;
|
|
496
|
+
exports.default = URLPolyfill, module.exports = exports.default;
|
|
497
|
+
}));
|
|
489
498
|
|
|
490
499
|
//#endregion
|
|
491
|
-
export
|
|
500
|
+
export default require_url();
|