halife 0.0.3 → 0.1.1
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.
- package/dist/polyfill/esm/chunk-N6xyN86N.js +5 -0
- package/dist/polyfill/esm/event.polyfill.js +23 -0
- package/dist/polyfill/esm/miniprog.js +1 -0
- package/dist/polyfill/esm/text_decoder.polyfill.js +54 -0
- package/dist/polyfill/esm/text_encoder.polyfill.js +93 -0
- package/dist/polyfill/esm/url.polyfill.js +491 -0
- package/package.json +23 -4
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//#region jspolyfill/event.ts
|
|
2
|
+
var EventTarget = class {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.listeners = /* @__PURE__ */ new Map();
|
|
5
|
+
}
|
|
6
|
+
addEventListener(type, listener, options) {
|
|
7
|
+
if (!this.listeners.has(type)) this.listeners.set(type, /* @__PURE__ */ new Set());
|
|
8
|
+
this.listeners.get(type).add(listener);
|
|
9
|
+
}
|
|
10
|
+
removeEventListener(type, listener, options) {
|
|
11
|
+
this.listeners.get(type)?.delete(listener);
|
|
12
|
+
}
|
|
13
|
+
dispatchEvent(event) {
|
|
14
|
+
const cbs = this.listeners.get(event.type);
|
|
15
|
+
if (!cbs) return true;
|
|
16
|
+
for (const cb of cbs) if (typeof cb === "function") cb(event);
|
|
17
|
+
else if (cb && typeof cb.handleEvent === "function") cb.handleEvent(event);
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
export { EventTarget };
|
|
@@ -0,0 +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)=>()=>(e&&(t=e(e=0)),t),s=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),c=(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},l=(n,r,a)=>(a=n==null?{}:e(i(n)),c(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n)),u=s(((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})),d=s(((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})),f,p=o((()=>{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 m(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}function h(e){try{return decodeURIComponent(e.replace(/\+/g,` `))}catch{return null}}function g(e){try{return encodeURIComponent(e)}catch{return null}}function _(e){for(var t=/([^=?#&]+)=?([^&]*)/g,n={},r;r=t.exec(e);){var i=h(r[1]),a=h(r[2]);i===null||a===null||i in n||(n[i]=a)}return n}function v(e,t){t||=``;var n=[],r,i;for(i in typeof t!=`string`&&(t=`?`),e)if(O.call(e,i)){if(r=e[i],!r&&(r===null||r===k||isNaN(r))&&(r=``),i=g(i),r=g(r),i===null||r===null)continue;n.push(i+`=`+r)}return n.length?t+n.join(`&`):``}function y(e){return(e||``).toString().replace(A,``)}function b(e){var t=y(e),n=t.length;if(n===0)return t;for(;n&&!(t.charCodeAt(n-1)>32);)--n;return t.slice(0,n)}function x(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 T(unescape(e.pathname),{});else if(r===`string`)for(i in n=new T(e,{}),L)delete n[i];else if(r===`object`){for(i in e)i in L||(n[i]=e[i]);n.slashes===void 0&&(n.slashes=M.test(e.href))}return n}function S(e){return e===`file:`||e===`ftp:`||e===`http:`||e===`https:`||e===`ws:`||e===`wss:`}function C(e,t){e=b(e),e=e.replace(j,``),t||={};var n=P.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)):S(r)?s=n[4]:r?i&&(s=s.slice(2)):o>=2&&S(t.protocol)&&(s=n[4]),{protocol:r,slashes:i||S(r),slashesCount:o,rest:s}}function w(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 T(e,t,n){if(!(this instanceof T))return new T(e,t,n);var r,i,a,o,s,c,l=I.slice(),u=typeof t,d=this,f=0;for(u!==`object`&&u!==`string`&&(n=t,t=null),n&&typeof n!=`function`&&(n=_),t=x(t),i=C(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||F.test(e))||!i.slashes&&(i.protocol||i.slashesCount<2||!S(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=w(d.pathname,t.pathname)),d.pathname.charAt(0)!==`/`&&S(d.protocol)&&(d.pathname=`/`+d.pathname),m(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:`&&S(d.protocol)&&d.host?d.protocol+`//`+d.host:`null`,d.href=d.toString()}function E(e,t,n){var r=this;switch(e){case`query`:typeof t==`string`&&t.length&&(t=(n||_)(t)),r[e]=t;break;case`port`:r[e]=t,m(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,N.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<I.length;o++){var s=I[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:`&&S(r.protocol)&&r.host?r.protocol+`//`+r.host:`null`,r.href=r.toString(),r}function D(e){(!e||typeof e!=`function`)&&(e=v);var t,n=this,r=n.host,i=n.protocol;i&&i.charAt(i.length-1)!==`:`&&(i+=`:`);var a=i+(i&&n.slashes||S(i)?`//`:``);return n.username?(a+=n.username,n.password&&(a+=`:`+n.password),a+=`@`):n.password?(a+=`:`+n.password,a+=`@`):i!==`file:`&&S(i)&&!r&&n.pathname!==`/`&&(a+=`@`),(r[r.length-1]===`:`||N.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}var O,k,A,j,M,N,P,F,I,L,R=o((()=>{O=Object.prototype.hasOwnProperty,A=/^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/,j=/[\n\r\t]/g,M=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//,N=/:\d+$/,P=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i,F=/^[a-zA-Z]:/,I=[[`#`,`hash`],[`?`,`query`],function(e,t){return S(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]],L={hash:1,query:1},T.prototype={set:E,toString:D},T.extractProtocol=C,T.location=x,T.trimLeft=y,T.stringify=v,T.parse=_,T.canParse=()=>{},T.createObjectURL=()=>{},T.revokeObjectURL=()=>{}})),z,B=o((()=>{z=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 V(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))}})})}var H=o((()=>{V.preconnect=()=>{}})),U=s((e=>{var t=l(u(),1),n=l(d(),1);p(),R(),B(),H(),e=function(){globalThis.EventTarget=f,globalThis.fetch=V,globalThis.TextEncoder=t.default,globalThis.TextDecoder=n.default,globalThis.URL=T,globalThis.WebSocket=z}}));export default U();
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { t as __commonJSMin } from "./chunk-N6xyN86N.js";
|
|
2
|
+
|
|
3
|
+
//#region jspolyfill/text_decoder.js
|
|
4
|
+
var require_text_decoder = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
5
|
+
let TextDecoderPolyfill;
|
|
6
|
+
if (Object.defineProperty(exports, "__esModule", { value: !0 }), "undefined" == typeof TextDecoder) {
|
|
7
|
+
const e = String.fromCharCode, t = Object.prototype.toString, r = t.call(ArrayBuffer.prototype), o = "undefined" != typeof SharedArrayBuffer ? t.call(SharedArrayBuffer) : "", d = function(t$1) {
|
|
8
|
+
const r$1 = t$1.charCodeAt(0), o$1 = 0 | t$1.length;
|
|
9
|
+
let d$1 = 1114112, c$1 = 0, a$1 = "";
|
|
10
|
+
switch (r$1 >>> 4) {
|
|
11
|
+
case 12:
|
|
12
|
+
case 13:
|
|
13
|
+
d$1 = (31 & r$1) << 6 | 63 & t$1.charCodeAt(1), c$1 = d$1 < 128 ? 0 : 2;
|
|
14
|
+
break;
|
|
15
|
+
case 14:
|
|
16
|
+
d$1 = (15 & r$1) << 12 | (63 & t$1.charCodeAt(1)) << 6 | 63 & t$1.charCodeAt(2), c$1 = d$1 < 2048 ? 0 : 3;
|
|
17
|
+
break;
|
|
18
|
+
case 15: r$1 >>> 3 == 30 && (d$1 = (7 & r$1) << 18 | (63 & t$1.charCodeAt(1)) << 12 | (63 & t$1.charCodeAt(2)) << 6 | t$1.charCodeAt(3), c$1 = d$1 < 65536 ? 0 : 4);
|
|
19
|
+
}
|
|
20
|
+
for (c$1 && (o$1 < c$1 ? c$1 = 0 : d$1 < 65536 ? a$1 = e(d$1) : d$1 < 1114112 ? (d$1 = d$1 - 65664 | 0, a$1 = e(55296 + (d$1 >>> 10) | 0, 56320 + (1023 & d$1) | 0)) : c$1 = 0); c$1 < o$1; c$1 = c$1 + 1 | 0) a$1 += " ";
|
|
21
|
+
return a$1;
|
|
22
|
+
}, c = [
|
|
23
|
+
"utf-8",
|
|
24
|
+
"utf8",
|
|
25
|
+
"unicode-1-1-utf-8"
|
|
26
|
+
];
|
|
27
|
+
class a {
|
|
28
|
+
constructor(e$1, t$1) {
|
|
29
|
+
if (this.encoding = "utf-8", this.fatal = !1, this.ignoreBOM = !1, e$1 && -1 === c.indexOf(e$1.toLowerCase())) throw new RangeError(`Failed to construct 'TextDecoder': The encoding label provided ('${e$1}') is invalid.`);
|
|
30
|
+
if (t$1) {
|
|
31
|
+
if (t$1.fatal) throw new Error("Failed to construct 'TextDecoder': the 'fatal' option is unsupported.");
|
|
32
|
+
if (t$1.ignoreBOM) throw new Error("Failed to construct 'TextDecoder': the 'ignoreBOM' option is unsupported.");
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
decode(c$1, a$1) {
|
|
36
|
+
if (a$1 && a$1.stream) throw new Error("Failed to decode: the 'stream' option is unsupported.");
|
|
37
|
+
const i = c$1 && c$1.buffer || c$1, n = t.call(i);
|
|
38
|
+
if (n !== r && n !== o && void 0 !== c$1) throw TypeError("Failed to execute 'decode' on 'TextDecoder': The provided value is not of type '(ArrayBuffer or ArrayBufferView)'");
|
|
39
|
+
const f = new Uint8Array(i);
|
|
40
|
+
let l = "";
|
|
41
|
+
for (let t$1 = 0, r$1 = 0 | f.length; t$1 < r$1; t$1 = t$1 + 32768 | 0) l += e.apply(0, f.subarray(t$1, t$1 + 32768 | 0));
|
|
42
|
+
return l.replace(/[\xc0-\xff][\x80-\xbf]+|[\x80-\xff]/g, d);
|
|
43
|
+
}
|
|
44
|
+
toString() {
|
|
45
|
+
return "[object TextDecoder]";
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
"undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(a.prototype, Symbol.toStringTag, { value: "TextDecoder" }), TextDecoderPolyfill = a;
|
|
49
|
+
} else TextDecoderPolyfill = TextDecoder;
|
|
50
|
+
exports.default = TextDecoderPolyfill, module.exports = exports.default;
|
|
51
|
+
}));
|
|
52
|
+
|
|
53
|
+
//#endregion
|
|
54
|
+
export default require_text_decoder();
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { t as __commonJSMin } from "./chunk-N6xyN86N.js";
|
|
2
|
+
|
|
3
|
+
//#region jspolyfill/text_encoder.js
|
|
4
|
+
var require_text_encoder = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
5
|
+
let TextEncoderPolyfill;
|
|
6
|
+
if (Object.defineProperty(exports, "__esModule", { value: !0 }), "undefined" != typeof TextEncoder && TextEncoder.prototype.encodeInto) TextEncoderPolyfill = TextEncoder;
|
|
7
|
+
else {
|
|
8
|
+
const e = String.fromCharCode, t = function(t$1) {
|
|
9
|
+
let o$1 = 0 | t$1.charCodeAt(0);
|
|
10
|
+
if (55296 <= o$1) if (o$1 < 56320) {
|
|
11
|
+
const n$1 = 0 | t$1.charCodeAt(1);
|
|
12
|
+
if (56320 <= n$1 && n$1 <= 57343) {
|
|
13
|
+
if (o$1 = (o$1 << 10) + n$1 - 56613888 | 0, o$1 > 65535) return e(240 | o$1 >>> 18, 128 | o$1 >>> 12 & 63, 128 | o$1 >>> 6 & 63, 128 | 63 & o$1);
|
|
14
|
+
} else o$1 = 65533;
|
|
15
|
+
} else o$1 <= 57343 && (o$1 = 65533);
|
|
16
|
+
return o$1 <= 2047 ? e(192 | o$1 >>> 6, 128 | 63 & o$1) : e(224 | o$1 >>> 12, 128 | o$1 >>> 6 & 63, 128 | 63 & o$1);
|
|
17
|
+
}, o = function(e$1) {
|
|
18
|
+
return void 0 === e$1 ? "" : ("" + e$1).replace(/[\x80-\uD7ff\uDC00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]?/g, t);
|
|
19
|
+
};
|
|
20
|
+
class n {
|
|
21
|
+
constructor() {
|
|
22
|
+
this.encoding = "utf-8";
|
|
23
|
+
}
|
|
24
|
+
encode(e$1) {
|
|
25
|
+
const t$1 = o(e$1), n$1 = 0 | t$1.length, r = new Uint8Array(n$1);
|
|
26
|
+
let c = 0;
|
|
27
|
+
for (; c < n$1; c = c + 1 | 0) r[c] = 0 | t$1.charCodeAt(c);
|
|
28
|
+
return r;
|
|
29
|
+
}
|
|
30
|
+
encodeInto(e$1, t$1) {
|
|
31
|
+
const n$1 = o(e$1), r = 0 | t$1.length, c = 0 | e$1.length;
|
|
32
|
+
let d = 0 | n$1.length, l = 0, s = 0, a = 0;
|
|
33
|
+
r < d && (d = r);
|
|
34
|
+
e: for (; l < d; l = l + 1 | 0) {
|
|
35
|
+
switch (s = 0 | n$1.charCodeAt(l), s >>> 4) {
|
|
36
|
+
case 0:
|
|
37
|
+
case 1:
|
|
38
|
+
case 2:
|
|
39
|
+
case 3:
|
|
40
|
+
case 4:
|
|
41
|
+
case 5:
|
|
42
|
+
case 6:
|
|
43
|
+
case 7: a = a + 1 | 0;
|
|
44
|
+
case 8:
|
|
45
|
+
case 9:
|
|
46
|
+
case 10:
|
|
47
|
+
case 11: break;
|
|
48
|
+
case 12:
|
|
49
|
+
case 13: if ((l + 1 | 0) < r) {
|
|
50
|
+
a = a + 1 | 0;
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
case 14: if ((l + 2 | 0) < r) {
|
|
54
|
+
a = a + 1 | 0;
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
case 15: if ((l + 3 | 0) < r) {
|
|
58
|
+
a = a + 1 | 0;
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
default: break e;
|
|
62
|
+
}
|
|
63
|
+
t$1[l] = s;
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
written: l,
|
|
67
|
+
read: c < a ? c : a
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
toString() {
|
|
71
|
+
return "[object TextEncoder]";
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if ("undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(n.prototype, Symbol.toStringTag, { value: "TextEncoder" }), "undefined" == typeof TextEncoder && (TextEncoderPolyfill = n), !TextEncoderPolyfill.prototype.encodeInto) {
|
|
75
|
+
const e$1 = new TextEncoder();
|
|
76
|
+
TextEncoder.prototype.encodeInto = function(t$1, o$1) {
|
|
77
|
+
const r = 0 | t$1.length, c = 0 | o$1.length;
|
|
78
|
+
if (r < (3 + (c >> 1) | 0)) {
|
|
79
|
+
const n$1 = e$1.encode(t$1);
|
|
80
|
+
if ((0 | n$1.length) < c) return o$1.set(n$1), {
|
|
81
|
+
read: r,
|
|
82
|
+
written: 0 | n$1.length
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
return n.prototype.encodeInto(t$1, o$1);
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
exports.default = TextEncoderPolyfill, module.exports = exports.default;
|
|
90
|
+
}));
|
|
91
|
+
|
|
92
|
+
//#endregion
|
|
93
|
+
export default require_text_encoder();
|
|
@@ -0,0 +1,491 @@
|
|
|
1
|
+
//#region jspolyfill/url.js
|
|
2
|
+
/**
|
|
3
|
+
* Check if we're required to add a port number.
|
|
4
|
+
*
|
|
5
|
+
* @see https://url.spec.whatwg.org/#default-port
|
|
6
|
+
* @param {Number|String} port Port number we need to check
|
|
7
|
+
* @param {String} protocol Protocol we need to check against.
|
|
8
|
+
* @returns {Boolean} Is it a default port for the given protocol
|
|
9
|
+
* @api private
|
|
10
|
+
*/
|
|
11
|
+
function required_port(port, protocol) {
|
|
12
|
+
protocol = protocol.split(":")[0];
|
|
13
|
+
port = +port;
|
|
14
|
+
if (!port) return false;
|
|
15
|
+
switch (protocol) {
|
|
16
|
+
case "http":
|
|
17
|
+
case "ws": return port !== 80;
|
|
18
|
+
case "https":
|
|
19
|
+
case "wss": return port !== 443;
|
|
20
|
+
case "ftp": return port !== 21;
|
|
21
|
+
case "gopher": return port !== 70;
|
|
22
|
+
case "file": return false;
|
|
23
|
+
}
|
|
24
|
+
return port !== 0;
|
|
25
|
+
}
|
|
26
|
+
var has = Object.prototype.hasOwnProperty, undef;
|
|
27
|
+
/**
|
|
28
|
+
* Decode a URI encoded string.
|
|
29
|
+
*
|
|
30
|
+
* @param {String} input The URI encoded string.
|
|
31
|
+
* @returns {String|Null} The decoded string.
|
|
32
|
+
* @api private
|
|
33
|
+
*/
|
|
34
|
+
function decode(input) {
|
|
35
|
+
try {
|
|
36
|
+
return decodeURIComponent(input.replace(/\+/g, " "));
|
|
37
|
+
} catch (e) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Attempts to encode a given input.
|
|
43
|
+
*
|
|
44
|
+
* @param {String} input The string that needs to be encoded.
|
|
45
|
+
* @returns {String|Null} The encoded string.
|
|
46
|
+
* @api private
|
|
47
|
+
*/
|
|
48
|
+
function encode(input) {
|
|
49
|
+
try {
|
|
50
|
+
return encodeURIComponent(input);
|
|
51
|
+
} catch (e) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Simple query string parser.
|
|
57
|
+
*
|
|
58
|
+
* @param {String} query The query string that needs to be parsed.
|
|
59
|
+
* @returns {Object}
|
|
60
|
+
* @api public
|
|
61
|
+
*/
|
|
62
|
+
function queryparse(query) {
|
|
63
|
+
var parser = /([^=?#&]+)=?([^&]*)/g, result = {}, part;
|
|
64
|
+
while (part = parser.exec(query)) {
|
|
65
|
+
var key = decode(part[1]), value = decode(part[2]);
|
|
66
|
+
if (key === null || value === null || key in result) continue;
|
|
67
|
+
result[key] = value;
|
|
68
|
+
}
|
|
69
|
+
return result;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Transform a query string to an object.
|
|
73
|
+
*
|
|
74
|
+
* @param {Object} obj Object that should be transformed.
|
|
75
|
+
* @param {String} prefix Optional prefix.
|
|
76
|
+
* @returns {String}
|
|
77
|
+
* @api public
|
|
78
|
+
*/
|
|
79
|
+
function querystringify(obj, prefix) {
|
|
80
|
+
prefix = prefix || "";
|
|
81
|
+
var pairs = [], value, key;
|
|
82
|
+
if ("string" !== typeof prefix) prefix = "?";
|
|
83
|
+
for (key in obj) if (has.call(obj, key)) {
|
|
84
|
+
value = obj[key];
|
|
85
|
+
if (!value && (value === null || value === undef || isNaN(value))) value = "";
|
|
86
|
+
key = encode(key);
|
|
87
|
+
value = encode(value);
|
|
88
|
+
if (key === null || value === null) continue;
|
|
89
|
+
pairs.push(key + "=" + value);
|
|
90
|
+
}
|
|
91
|
+
return pairs.length ? prefix + pairs.join("&") : "";
|
|
92
|
+
}
|
|
93
|
+
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]:/;
|
|
94
|
+
/**
|
|
95
|
+
* Remove control characters and whitespace from the beginning of a string.
|
|
96
|
+
*
|
|
97
|
+
* @param {Object|String} str String to trim.
|
|
98
|
+
* @returns {String} A new string representing `str` stripped of control
|
|
99
|
+
* characters and whitespace from its beginning.
|
|
100
|
+
* @public
|
|
101
|
+
*/
|
|
102
|
+
function trimLeft(str) {
|
|
103
|
+
return (str ? str : "").toString().replace(controlOrWhitespace, "");
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Remove control characters and whitespace from both ends of a string.
|
|
107
|
+
*
|
|
108
|
+
* @param {Object|String} str String to trim.
|
|
109
|
+
* @returns {String} A new string representing `str` stripped of control
|
|
110
|
+
* characters and whitespace from both its beginning and end.
|
|
111
|
+
* @private
|
|
112
|
+
*/
|
|
113
|
+
function trim(str) {
|
|
114
|
+
var trimmed = trimLeft(str);
|
|
115
|
+
var i = trimmed.length;
|
|
116
|
+
if (i === 0) return trimmed;
|
|
117
|
+
while (i) if (trimmed.charCodeAt(i - 1) > 32) break;
|
|
118
|
+
else i = i - 1;
|
|
119
|
+
return trimmed.slice(0, i);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* These are the parse rules for the URL parser, it informs the parser
|
|
123
|
+
* about:
|
|
124
|
+
*
|
|
125
|
+
* 0. The char it Needs to parse, if it's a string it should be done using
|
|
126
|
+
* indexOf, RegExp using exec and NaN means set as current value.
|
|
127
|
+
* 1. The property we should set when parsing this value.
|
|
128
|
+
* 2. Indication if it's backwards or forward parsing, when set as number it's
|
|
129
|
+
* the value of extra chars that should be split off.
|
|
130
|
+
* 3. Inherit from location if non existing in the parser.
|
|
131
|
+
* 4. `toLowerCase` the resulting value.
|
|
132
|
+
*/
|
|
133
|
+
var rules = [
|
|
134
|
+
["#", "hash"],
|
|
135
|
+
["?", "query"],
|
|
136
|
+
function sanitize(address, url) {
|
|
137
|
+
return isSpecial(url.protocol) ? address.replace(/\\/g, "/") : address;
|
|
138
|
+
},
|
|
139
|
+
["/", "pathname"],
|
|
140
|
+
[
|
|
141
|
+
"@",
|
|
142
|
+
"auth",
|
|
143
|
+
1
|
|
144
|
+
],
|
|
145
|
+
[
|
|
146
|
+
NaN,
|
|
147
|
+
"host",
|
|
148
|
+
void 0,
|
|
149
|
+
1,
|
|
150
|
+
1
|
|
151
|
+
],
|
|
152
|
+
[
|
|
153
|
+
/:(\d*)$/,
|
|
154
|
+
"port",
|
|
155
|
+
void 0,
|
|
156
|
+
1
|
|
157
|
+
],
|
|
158
|
+
[
|
|
159
|
+
NaN,
|
|
160
|
+
"hostname",
|
|
161
|
+
void 0,
|
|
162
|
+
1,
|
|
163
|
+
1
|
|
164
|
+
]
|
|
165
|
+
];
|
|
166
|
+
/**
|
|
167
|
+
* These properties should not be copied or inherited from. This is only needed
|
|
168
|
+
* for all non blob URL's as a blob URL does not include a hash, only the
|
|
169
|
+
* origin.
|
|
170
|
+
*
|
|
171
|
+
* @type {Object}
|
|
172
|
+
* @private
|
|
173
|
+
*/
|
|
174
|
+
var ignore = {
|
|
175
|
+
hash: 1,
|
|
176
|
+
query: 1
|
|
177
|
+
};
|
|
178
|
+
/**
|
|
179
|
+
* The location object differs when your code is loaded through a normal page,
|
|
180
|
+
* Worker or through a worker using a blob. And with the blobble begins the
|
|
181
|
+
* trouble as the location object will contain the URL of the blob, not the
|
|
182
|
+
* location of the page where our code is loaded in. The actual origin is
|
|
183
|
+
* encoded in the `pathname` so we can thankfully generate a good "default"
|
|
184
|
+
* location from it so we can generate proper relative URL's again.
|
|
185
|
+
*
|
|
186
|
+
* @param {Object|String} loc Optional default location object.
|
|
187
|
+
* @returns {Object} lolcation object.
|
|
188
|
+
* @public
|
|
189
|
+
*/
|
|
190
|
+
function lolcation(loc) {
|
|
191
|
+
var globalVar;
|
|
192
|
+
if (typeof window !== "undefined") globalVar = window;
|
|
193
|
+
else if (typeof global !== "undefined") globalVar = global;
|
|
194
|
+
else if (typeof self !== "undefined") globalVar = self;
|
|
195
|
+
else globalVar = {};
|
|
196
|
+
var location = globalVar.location || {};
|
|
197
|
+
loc = loc || location;
|
|
198
|
+
var finaldestination = {}, type = typeof loc, key;
|
|
199
|
+
if ("blob:" === loc.protocol) finaldestination = new Url(unescape(loc.pathname), {});
|
|
200
|
+
else if ("string" === type) {
|
|
201
|
+
finaldestination = new Url(loc, {});
|
|
202
|
+
for (key in ignore) delete finaldestination[key];
|
|
203
|
+
} else if ("object" === type) {
|
|
204
|
+
for (key in loc) {
|
|
205
|
+
if (key in ignore) continue;
|
|
206
|
+
finaldestination[key] = loc[key];
|
|
207
|
+
}
|
|
208
|
+
if (finaldestination.slashes === void 0) finaldestination.slashes = slashes.test(loc.href);
|
|
209
|
+
}
|
|
210
|
+
return finaldestination;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Check whether a protocol scheme is special.
|
|
214
|
+
*
|
|
215
|
+
* @param {String} The protocol scheme of the URL
|
|
216
|
+
* @return {Boolean} `true` if the protocol scheme is special, else `false`
|
|
217
|
+
* @private
|
|
218
|
+
*/
|
|
219
|
+
function isSpecial(scheme) {
|
|
220
|
+
return scheme === "file:" || scheme === "ftp:" || scheme === "http:" || scheme === "https:" || scheme === "ws:" || scheme === "wss:";
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* @typedef ProtocolExtract
|
|
224
|
+
* @type Object
|
|
225
|
+
* @property {String} protocol Protocol matched in the URL, in lowercase.
|
|
226
|
+
* @property {Boolean} slashes `true` if protocol is followed by "//", else `false`.
|
|
227
|
+
* @property {String} rest Rest of the URL that is not part of the protocol.
|
|
228
|
+
*/
|
|
229
|
+
/**
|
|
230
|
+
* Extract protocol information from a URL with/without double slash ("//").
|
|
231
|
+
*
|
|
232
|
+
* @param {String} address URL we want to extract from.
|
|
233
|
+
* @param {Object} location
|
|
234
|
+
* @return {ProtocolExtract} Extracted information.
|
|
235
|
+
* @private
|
|
236
|
+
*/
|
|
237
|
+
function extractProtocol(address, location) {
|
|
238
|
+
address = trim(address);
|
|
239
|
+
address = address.replace(CRHTLF, "");
|
|
240
|
+
location = location || {};
|
|
241
|
+
var match = protocolre.exec(address);
|
|
242
|
+
var protocol = match[1] ? match[1].toLowerCase() : "";
|
|
243
|
+
var forwardSlashes = !!match[2];
|
|
244
|
+
var otherSlashes = !!match[3];
|
|
245
|
+
var slashesCount = 0;
|
|
246
|
+
var rest;
|
|
247
|
+
if (forwardSlashes) if (otherSlashes) {
|
|
248
|
+
rest = match[2] + match[3] + match[4];
|
|
249
|
+
slashesCount = match[2].length + match[3].length;
|
|
250
|
+
} else {
|
|
251
|
+
rest = match[2] + match[4];
|
|
252
|
+
slashesCount = match[2].length;
|
|
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]);
|
|
338
|
+
} else {
|
|
339
|
+
url[key] = address.slice(index);
|
|
340
|
+
address = address.slice(0, index);
|
|
341
|
+
}
|
|
342
|
+
} else if (index = parse.exec(address)) {
|
|
343
|
+
url[key] = index[1];
|
|
344
|
+
address = address.slice(0, index.index);
|
|
345
|
+
}
|
|
346
|
+
url[key] = url[key] || (relative && instruction[3] ? location[key] || "" : "");
|
|
347
|
+
if (instruction[4]) url[key] = url[key].toLowerCase();
|
|
348
|
+
}
|
|
349
|
+
if (parser) url.query = parser(url.query);
|
|
350
|
+
if (relative && location.slashes && url.pathname.charAt(0) !== "/" && (url.pathname !== "" || location.pathname !== "")) url.pathname = resolve(url.pathname, location.pathname);
|
|
351
|
+
if (url.pathname.charAt(0) !== "/" && isSpecial(url.protocol)) url.pathname = "/" + url.pathname;
|
|
352
|
+
if (!required_port(url.port, url.protocol)) {
|
|
353
|
+
url.host = url.hostname;
|
|
354
|
+
url.port = "";
|
|
355
|
+
}
|
|
356
|
+
url.username = url.password = "";
|
|
357
|
+
if (url.auth) {
|
|
358
|
+
index = url.auth.indexOf(":");
|
|
359
|
+
if (~index) {
|
|
360
|
+
url.username = url.auth.slice(0, index);
|
|
361
|
+
url.username = encodeURIComponent(decodeURIComponent(url.username));
|
|
362
|
+
url.password = url.auth.slice(index + 1);
|
|
363
|
+
url.password = encodeURIComponent(decodeURIComponent(url.password));
|
|
364
|
+
} else url.username = encodeURIComponent(decodeURIComponent(url.auth));
|
|
365
|
+
url.auth = url.password ? url.username + ":" + url.password : url.username;
|
|
366
|
+
}
|
|
367
|
+
url.origin = url.protocol !== "file:" && isSpecial(url.protocol) && url.host ? url.protocol + "//" + url.host : "null";
|
|
368
|
+
url.href = url.toString();
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* This is convenience method for changing properties in the URL instance to
|
|
372
|
+
* insure that they all propagate correctly.
|
|
373
|
+
*
|
|
374
|
+
* @param {String} part Property we need to adjust.
|
|
375
|
+
* @param {Mixed} value The newly assigned value.
|
|
376
|
+
* @param {Boolean|Function} fn When setting the query, it will be the function
|
|
377
|
+
* used to parse the query.
|
|
378
|
+
* When setting the protocol, double slash will be
|
|
379
|
+
* removed from the final url if it is truthy.
|
|
380
|
+
* When setting the pathname or the hash, a
|
|
381
|
+
* leading / or # will not be automatically added
|
|
382
|
+
* if it is truthy.
|
|
383
|
+
* @returns {URL} URL instance for chaining.
|
|
384
|
+
* @public
|
|
385
|
+
*/
|
|
386
|
+
function set(part, value, fn) {
|
|
387
|
+
var url = this;
|
|
388
|
+
switch (part) {
|
|
389
|
+
case "query":
|
|
390
|
+
if ("string" === typeof value && value.length) value = (fn || queryparse)(value);
|
|
391
|
+
url[part] = value;
|
|
392
|
+
break;
|
|
393
|
+
case "port":
|
|
394
|
+
url[part] = value;
|
|
395
|
+
if (!required_port(value, url.protocol)) {
|
|
396
|
+
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
|
+
url.port = "";
|
|
414
|
+
}
|
|
415
|
+
break;
|
|
416
|
+
case "protocol":
|
|
417
|
+
url.protocol = value.toLowerCase();
|
|
418
|
+
if (url.protocol && url.protocol.charAt(url.protocol.length - 1) !== ":") url.protocol += ":";
|
|
419
|
+
url.slashes = !fn;
|
|
420
|
+
break;
|
|
421
|
+
case "pathname":
|
|
422
|
+
case "hash":
|
|
423
|
+
if (value && !fn) {
|
|
424
|
+
var char = part === "pathname" ? "/" : "#";
|
|
425
|
+
url[part] = value.charAt(0) !== char ? char + value : value;
|
|
426
|
+
} else url[part] = value;
|
|
427
|
+
break;
|
|
428
|
+
case "username":
|
|
429
|
+
case "password":
|
|
430
|
+
url[part] = encodeURIComponent(value);
|
|
431
|
+
break;
|
|
432
|
+
case "auth":
|
|
433
|
+
var index = value.indexOf(":");
|
|
434
|
+
if (~index) {
|
|
435
|
+
url.username = value.slice(0, index);
|
|
436
|
+
url.username = encodeURIComponent(decodeURIComponent(url.username));
|
|
437
|
+
url.password = value.slice(index + 1);
|
|
438
|
+
url.password = encodeURIComponent(decodeURIComponent(url.password));
|
|
439
|
+
} else url.username = encodeURIComponent(decodeURIComponent(value));
|
|
440
|
+
}
|
|
441
|
+
for (var i = 0; i < rules.length; i++) {
|
|
442
|
+
var ins = rules[i];
|
|
443
|
+
if (ins[4]) url[ins[1]] = url[ins[1]].toLowerCase();
|
|
444
|
+
}
|
|
445
|
+
url.auth = url.password ? url.username + ":" + url.password : url.username;
|
|
446
|
+
url.origin = url.protocol !== "file:" && isSpecial(url.protocol) && url.host ? url.protocol + "//" + url.host : "null";
|
|
447
|
+
url.href = url.toString();
|
|
448
|
+
return url;
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* Transform the properties back in to a valid and full URL string.
|
|
452
|
+
*
|
|
453
|
+
* @param {Function} stringify Optional query stringify function.
|
|
454
|
+
* @returns {String} Compiled version of the URL.
|
|
455
|
+
* @public
|
|
456
|
+
*/
|
|
457
|
+
function toString(stringify) {
|
|
458
|
+
if (!stringify || "function" !== typeof stringify) stringify = querystringify;
|
|
459
|
+
var query, url = this, host = url.host, protocol = url.protocol;
|
|
460
|
+
if (protocol && protocol.charAt(protocol.length - 1) !== ":") protocol += ":";
|
|
461
|
+
var result = protocol + (protocol && url.slashes || isSpecial(protocol) ? "//" : "");
|
|
462
|
+
if (url.username) {
|
|
463
|
+
result += url.username;
|
|
464
|
+
if (url.password) result += ":" + url.password;
|
|
465
|
+
result += "@";
|
|
466
|
+
} else if (url.password) {
|
|
467
|
+
result += ":" + url.password;
|
|
468
|
+
result += "@";
|
|
469
|
+
} else if (protocol !== "file:" && isSpecial(protocol) && !host && url.pathname !== "/") result += "@";
|
|
470
|
+
if (host[host.length - 1] === ":" || port.test(url.hostname) && !url.port) host += ":";
|
|
471
|
+
result += host + url.pathname;
|
|
472
|
+
query = "object" === typeof url.query ? stringify(url.query) : url.query;
|
|
473
|
+
if (query) result += "?" !== query.charAt(0) ? "?" + query : query;
|
|
474
|
+
if (url.hash) result += url.hash;
|
|
475
|
+
return result;
|
|
476
|
+
}
|
|
477
|
+
Url.prototype = {
|
|
478
|
+
set,
|
|
479
|
+
toString
|
|
480
|
+
};
|
|
481
|
+
Url.extractProtocol = extractProtocol;
|
|
482
|
+
Url.location = lolcation;
|
|
483
|
+
Url.trimLeft = trimLeft;
|
|
484
|
+
Url.stringify = querystringify;
|
|
485
|
+
Url.parse = queryparse;
|
|
486
|
+
Url.canParse = () => {};
|
|
487
|
+
Url.createObjectURL = () => {};
|
|
488
|
+
Url.revokeObjectURL = () => {};
|
|
489
|
+
|
|
490
|
+
//#endregion
|
|
491
|
+
export { Url };
|
package/package.json
CHANGED
|
@@ -14,11 +14,14 @@
|
|
|
14
14
|
"layout"
|
|
15
15
|
],
|
|
16
16
|
"license": "MIT License",
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build:polyfill": "bun run scripts/build.polyfill.js"
|
|
19
|
+
},
|
|
17
20
|
"repository": {
|
|
18
21
|
"type": "git",
|
|
19
22
|
"url": "https://codeberg.org/y0z0ng/halife.git"
|
|
20
23
|
},
|
|
21
|
-
"version": "0.
|
|
24
|
+
"version": "0.1.1",
|
|
22
25
|
"workspaces": [
|
|
23
26
|
"examples/*"
|
|
24
27
|
],
|
|
@@ -34,16 +37,32 @@
|
|
|
34
37
|
"files": [
|
|
35
38
|
"index.js",
|
|
36
39
|
"package.json",
|
|
37
|
-
"README.md"
|
|
40
|
+
"README.md",
|
|
41
|
+
"dist"
|
|
38
42
|
],
|
|
39
43
|
"packages": {
|
|
40
44
|
"Input": {
|
|
41
45
|
"type": "component",
|
|
42
46
|
"path": "packages/Input.astro"
|
|
43
47
|
},
|
|
44
|
-
"
|
|
48
|
+
"Check": {
|
|
49
|
+
"type": "component",
|
|
50
|
+
"path": "packages/Check.astro"
|
|
51
|
+
},
|
|
52
|
+
"Dialog": {
|
|
53
|
+
"type": "component",
|
|
54
|
+
"path": "packages/Dialog.astro"
|
|
55
|
+
},
|
|
56
|
+
"Switch": {
|
|
57
|
+
"type": "component",
|
|
58
|
+
"path": "packages/Switch.astro"
|
|
59
|
+
},
|
|
60
|
+
"DashboardModern": {
|
|
45
61
|
"type": "layout",
|
|
46
|
-
"path": "packages/
|
|
62
|
+
"path": "packages/DashboardModern.astro"
|
|
47
63
|
}
|
|
64
|
+
},
|
|
65
|
+
"devDependencies": {
|
|
66
|
+
"rolldown": "^1.0.0-beta.60"
|
|
48
67
|
}
|
|
49
68
|
}
|