halife 0.1.2 → 0.1.4
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 +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();
|
|
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=()=>{};function z(){globalThis.EventTarget=f,globalThis.fetch=R,globalThis.TextEncoder=d.default,globalThis.TextDecoder=u.default,globalThis.URL=P,globalThis.WebSocket=L}export{z as default};
|
package/package.json
CHANGED
|
@@ -15,13 +15,14 @@
|
|
|
15
15
|
],
|
|
16
16
|
"license": "MIT License",
|
|
17
17
|
"scripts": {
|
|
18
|
-
"build:polyfill": "bun run scripts/build.polyfill.js"
|
|
18
|
+
"build:polyfill": "bun run scripts/build.polyfill.js",
|
|
19
|
+
"pb": "bun run build:polyfill && bun publish"
|
|
19
20
|
},
|
|
20
21
|
"repository": {
|
|
21
22
|
"type": "git",
|
|
22
23
|
"url": "https://codeberg.org/y0z0ng/halife.git"
|
|
23
24
|
},
|
|
24
|
-
"version": "0.1.
|
|
25
|
+
"version": "0.1.4",
|
|
25
26
|
"workspaces": [
|
|
26
27
|
"examples/*"
|
|
27
28
|
],
|