@zyzgroup/core-web 0.1.83 → 0.1.85
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/zyzgroup_core_web.iife.js +1 -1
- package/dist/zyzgroup_core_web.iife.js.map +1 -1
- package/dist/zyzgroup_core_web.js +24 -22
- package/dist/zyzgroup_core_web.js.map +1 -1
- package/dist/zyzgroup_core_web.umd.cjs +1 -1
- package/dist/zyzgroup_core_web.umd.cjs.map +1 -1
- package/package.json +1 -1
- package/types/WebSocketClient.d.ts +3 -3
- package/types/WebSocketClient.d.ts.map +1 -1
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
}
|
|
45
45
|
${t}
|
|
46
46
|
return output;
|
|
47
|
-
})`}}function tl(s,t,e){return new WebSocket(s)}function Dw(s){return`${s}eventbus/${on(3,"number")}/${on(8)}/websocket`}class oe{static CONNECTING=WebSocket.CONNECTING;static OPEN=WebSocket.OPEN;static CLOSING=WebSocket.CLOSING;static CLOSED=WebSocket.CLOSED;url;socketCreatorProtocols;socketCreatorOptions;socketCreator;socket;state=oe.CONNECTING;messageQueue=[];pingInterval;pingTimerID;reconnect;reconnectAttempts=0;maxReconnectAttempts;reconnectTimerID;onopen;onclose;onerror;requestid=0;waitings={};listeners={};constructor(t="",e){this.url=t,this.socketCreatorProtocols=e?.socketCreatorProtocols,this.socketCreatorOptions=e?.socketCreatorOptions||{},this.socketCreator=e?.socketCreator||tl,this.pingInterval=e?.pingInterval||5e3,this.onopen=e?.onopen,this.onclose=e?.onclose,this.onerror=e?.onerror,this.reconnect=typeof e?.reconnect=="boolean"?e.reconnect:!0,this.maxReconnectAttempts=typeof e?.maxReconnectAttempts=="number"?e.maxReconnectAttempts:1/0,this._connect()}open(){this.reconnectAttempts=0,this._connect()}close(){this.state=oe.CLOSING,this.socket?.close()}_connect(){this.socket?.readyState===oe.CONNECTING||this.socket?.readyState===oe.OPEN||(this.state=oe.CONNECTING,this.socket=this.socketCreator(this.url,this.socketCreatorProtocols,this.socketCreatorOptions),this.socket.onopen=()=>{ie(`ws(${this.url}) onopen`),this.state=oe.OPEN,this.ping(),this.pingTimerID=setInterval(this.ping.bind(this),this.pingInterval),this.reconnectTimerID&&(clearTimeout(this.reconnectTimerID),this.reconnectTimerID=void 0);const t=this.messageQueue.slice();this.messageQueue=[],t.forEach(this._send.bind(this)),this.onopen?.()},this.socket.onclose=t=>{const{code:e,reason:n,wasClean:i}=t;ie(`ws(${this.url}) onclose: code(${e}) reason(${n}) wasClean(${i})`),this.state=oe.CLOSED,this.pingTimerID&&(clearInterval(this.pingTimerID),this.pingTimerID=void 0),this.onclose?.(t),this.reconnect&&this.reconnectAttempts<this.maxReconnectAttempts&&(this.socket=void 0,this.reconnectTimerID=setTimeout(this._connect.bind(this),Ea(this.reconnectAttempts++)))},this.socket.onerror=t=>{ie(`ws(${this.url}) onerror: ${t.type} ${t}`),this.onerror?.(t)},this.socket.onmessage=t=>{if(ie(`ws(${this.url}) onmessage: { type: ${t.type}, data: ${t.data} }`),typeof t.data=="string"){let e;try{e=JSON.parse(t.data.substring(1))}catch(n){e=[JSON.stringify({type:"err",failureType:n.toString(),message:t.data})]}e.forEach(n=>{const i=JSON.parse(n);if(i.body&&Object.prototype.hasOwnProperty.call(i.body,"requestid")){const r=this.waitings[i.body.requestid];r?r.resolve?.(i.body):ms(`ws(${this.url}) onmessage: found no associated request, already timed out`)}else if(this.listeners[i.address]){const r=this.listeners[i.address];for(let o=0;o<r.length;o++)i.type==="err"?r[o]({failureCode:i.failureCode,failureType:i.failureType,message:i.message}):r[o](null,i.body)}else this.onunhandled(i)})}else t.data instanceof ArrayBuffer?ms(`ws(${this.url}) onmessage: unhandle ArrayBuffer`):t.data instanceof Blob&&ms(`ws(${this.url}) onmessage: unhandle Blob`)})}onunhandled(t){try{t.type==="err"?this.onerror?.(t):t.event?console.warn("No handler found for event: %o. Message: %O",t.event,t):console.warn("No handler found for message: ",t)}catch{}}_send(t){this.socket?.readyState===oe.OPEN?this.socket.send(JSON.stringify([JSON.stringify(t)])):(this.messageQueue.push(t),this._connect())}ping(){this._send({type:"ping"})}register(t,e,n={}){this.listeners[t]||(this.listeners[t]=[],this._send({type:"register",address:t,headers:Pn(n,this.socketCreatorOptions.headers)})),this.listeners[t].push(e)}unregister(t,e,n={}){const i=this.listeners[t];if(i){const r=i.indexOf(e);r!=-1&&(i.splice(r,1),i.length===0&&(this._send({type:"unregister",address:t,headers:Pn(n,this.socketCreatorOptions.headers)}),delete this.listeners[t]))}}publish(t,e,n={}){this._send({type:"publish",address:t,headers:Pn(n,this.socketCreatorOptions.headers),body:e})}async send(t,e,n={},i=3e4){this.requestid++;const r=this.waitings[this.requestid]={requestid:this.requestid},o=await new Promise((a,h)=>{r.resolve=a,this._send({type:"send",address:t,headers:Pn(n,this.socketCreatorOptions.headers),body:{requestid:r.requestid,...e}}),setTimeout(()=>{h(`ws(${this.url}) send(${r.requestid}: ${an(e)}) Timeout!`)},i)});return delete this.waitings[r.requestid],o}}function Lw(s){const t=document.documentElement,e=window.top===window.self?window.devicePixelRatio:1;t.dataset.dpr=e;let n=100;const i=function(){const r=Math.min(t.clientWidth,s);t.dataset.width=r,t.dataset.rem=n=Math.round(100*(r/s)),t.style.fontSize=n+"px"};i(),window.rem2px=function(r){return r=parseFloat(r),r*n},window.px2rem=function(r){return r=parseFloat(r),r/n},window.addEventListener&&window.addEventListener("orientationchange"in window?"orientationchange":"resize",i,!1)}function ri(s=window.location.href){try{return new URL(s)}catch{const e="(?<protocol>https?:)",n="(?<host>(?<hostname>[^/#?:]+)(?::(?<port>\\d+))?)",i="(?<pathname>(?:\\/[^/#?]+)*\\/?)",r="(?<search>(?:\\?[^#]*)?)",o="(?<hash>(?:#.*)?)",h=new RegExp(`^${e}//${n}${i}${r}${o}$`).exec(s);return{href:s,protocol:h?.groups?.protocol??"",host:h?.groups?.host??"",hostname:h?.groups?.hostname??"",port:h?.groups?.port??"",pathname:h?.groups?.pathname??"",search:h?.groups?.search??"",hash:h?.groups?.hash??""}}}function Rw(s){const t=ri(s);return t.protocol==="http:"||t.protocol==="https:"}function el(s=window.location.href){const t=ri(s),e=t.href.indexOf(t.hash);return t.hash&&e>=0?t.href.substring(0,e):t.href}function Ow(s=ri().search){s=decodeURIComponent(s).replace(/^[#?&]/,"");const t={};if(!s)return t;const e=/(?:^|&)([^&=]*)=?([^&]*?)(?=&|$)/y;let n=e.exec(s);for(;n;)t[n[1]]=n[2],n=e.exec(s);return t}const zw=(s=window.location.href)=>JSON.parse('{"'+decodeURI(s.split("?")[1]).replace(/"/g,'\\"').replace(/&/g,'","').replace(/=/g,'":"')+'"}');function oi(s){return"?"+Object.entries(s).map(([t,e])=>`${encodeURIComponent(t)}=${encodeURIComponent(e)}`).join("&")}function nl(s){return"?"+[...s.entries()].map(t=>encodeURIComponent(t[0])+"="+encodeURIComponent(t[1]instanceof File?t[1].name:t[1])).join("&")}function sl(s,t){return s.replace(/(?:\?.*)?$/,t.replace(/^[&?]/,"?"))}function Nw(s,t){return sl(s,oi(t))}function Ho(s,t){return s+t.replace(/^[&?]/,s.indexOf("?")>=0?"&":"?")}function Bw(s,t){return Ho(s,oi(t))}class Fw{worker;cbs={};constructor(t){if(Yc)try{this.worker=new Worker(URL.createObjectURL(new Blob([t])))}catch(e){throw typeof console!==void 0&&typeof console.warn=="function"&&console.warn("🎊 Could not load worker",e),e}else throw new Error("Your environment do not support Worker !")}postMessage(t,e=[]){this.worker.postMessage(t,e)}onmessage(t){this.worker.addEventListener("message",t)}offmessage(t){this.worker.removeEventListener("message",t)}onmessageerror(t){this.worker.addEventListener("messageerror",t)}offmessageerror(t){this.worker.removeEventListener("messageerror",t)}postCanvas(t){const e=t.transferControlToOffscreen();this.worker.postMessage({canvas:e},[e])}postPort(t){this.worker.postMessage({port:t},[t])}postReset(){this.worker.postMessage({reset:!0});for(const t in this.cbs)this.cbs[t](),delete this.cbs[t]}fire(t,e){return new Promise(n=>{if(e){const i=Math.random().toString(36).slice(2),r=o=>{o.data.id===i&&(this.worker.removeEventListener("message",r),delete this.cbs[i],e(),n())};this.cbs[i]=r.bind(this,{data:{id:i}}),this.worker.addEventListener("message",r),this.worker.postMessage({...t,id:i})}else this.worker.postMessage(t),n()})}}class Yw{port1;port2;port1MessageCbs=[];port2MessageCbs=[];port1MessageErrorCbs=[];port2MessageErrorCbs=[];constructor(){const{port1:t,port2:e}=new MessageChannel;this.port1=t,this.port2=e,this.port1.addEventListener("message",n=>{this.port1MessageCbs.forEach(i=>i(this.port1,n))}),this.port1.addEventListener("messageerror",n=>{this.port1MessageErrorCbs.forEach(i=>i(this.port1,n))}),this.port1.start(),this.port2.addEventListener("message",n=>{this.port2MessageCbs.forEach(i=>i(this.port2,n))}),this.port2.addEventListener("messageerror",n=>{this.port2MessageErrorCbs.forEach(i=>i(this.port2,n))}),this.port2.start()}close(){this.port1.close(),this.port2.close()}onPort1Message(t){this.port1MessageCbs.push(t)}onPort1MessageError(t){this.port1MessageErrorCbs.push(t)}offPort1Message(t){Ne(this.port1MessageCbs,t)}offPort1MessageError(t){Ne(this.port1MessageErrorCbs,t)}onPort2Message(t){this.port2MessageCbs.push(t)}onPort2MessageError(t){this.port2MessageErrorCbs.push(t)}offPort2Message(t){Ne(this.port2MessageCbs,t)}offPort2MessageError(t){Ne(this.port2MessageErrorCbs,t)}}function il(){let s=null;if(window.ActiveXObject){const t=["Microsoft.XMLHTTP","MSXML6.XMLHTTP","MSXML5.XMLHTTP","MSXML4.XMLHTTP","MSXML3.XMLHTTP","MSXML2.XMLHTTP","MSXML.XMLHTTP"];for(let e=0,n=t.length;e<n;e++)try{s=new window.ActiveXObject(t[e]);break}catch{continue}}else s=new XMLHttpRequest;return s}function $w(s,t){return new Promise((e,n)=>{const{method:i="GET",data:r={},multipartFormDataString:o="",boundary:a="",headers:h={},withCredentials:c=!1,responseType:u="json",timeout:l=3e4}=t||{},m=il();m.timeout=l,m.responseType=u,m.onreadystatechange=function(_){m.readyState===4&&(m.status===200?e(m.response):n(m.statusText))},m.ontimeout=()=>{n(`${s} is timed out for ${l}ms.`)},m.addEventListener("load",_=>t?.load?.(_,m),!1),m.addEventListener("loadstart",_=>t?.loadstart?.(_,m),!1),m.addEventListener("loadend",_=>t?.loadend?.(_,m),!1),m.addEventListener("progress",_=>{if(_.lengthComputable){const x=Math.round(_.loaded*100/_.total);t?.progress?.(_,m,x)}},!1),m.addEventListener("error",_=>t?.error?.(_,m),!1),m.addEventListener("abort",_=>t?.abort?.(_,m),!1);const f=i.toUpperCase();Object.assign(h,{Accept:"*/*"});let p=!1,y=!1,v=!1;function w(){c&&(m.withCredentials=!0);for(const _ in h)xt(_).toLowerCase()=="content-type"&&h[_].toLowerCase()=="multipart/form-data"?(p=!0,m.setRequestHeader("Content-Type","multipart/form-data; boundary="+a)):(xt(_).toLowerCase()=="content-type"&&(h[_].toLowerCase().indexOf("text/plain")>=0?y=!0:h[_].toLowerCase().indexOf("application/json")>=0&&(v=!0)),m.setRequestHeader(_,h[_]))}switch(f){case"GET":let _="";r instanceof FormData?_=nl(r):_=oi(r),m.open("GET",Ho(s,_),!0),w(),m.send(null);break;default:m.open(f,s,!0),w(),p?m.sendAsBinary(o):v?m.send(JSON.stringify(r)):y?m.send(Object.entries(r).map(([x,b])=>`${x}=${b}`).join(`\r
|
|
47
|
+
})`}}function tl(s,t,e){return new WebSocket(s)}function Dw(s){return`${s}eventbus/${on(3,"number")}/${on(8)}/websocket`}class oe{static CONNECTING=WebSocket.CONNECTING;static OPEN=WebSocket.OPEN;static CLOSING=WebSocket.CLOSING;static CLOSED=WebSocket.CLOSED;url;socketCreatorProtocols;socketCreatorOptions;socketCreator;socket;state=oe.CONNECTING;messageQueue=[];pingInterval;pingTimerID;reconnect;reconnectAttempts=0;maxReconnectAttempts;reconnectTimerID;onopen;onclose;onerror;requestid=0;waitings={};listeners={};constructor(t="",e){this.url=t,this.socketCreatorProtocols=e?.socketCreatorProtocols,this.socketCreatorOptions=e?.socketCreatorOptions||{},this.socketCreator=e?.socketCreator||tl,this.pingInterval=e?.pingInterval||5e3,this.onopen=e?.onopen,this.onclose=e?.onclose,this.onerror=e?.onerror,this.reconnect=typeof e?.reconnect=="boolean"?e.reconnect:!0,this.maxReconnectAttempts=typeof e?.maxReconnectAttempts=="number"?e.maxReconnectAttempts:1/0,this._connect()}open(){this.reconnectAttempts=0,this._connect()}close(){this.state=oe.CLOSING,this.socket?.close()}_connect(){this.socket?.readyState===oe.CONNECTING||this.socket?.readyState===oe.OPEN||(this.state=oe.CONNECTING,this.socket=this.socketCreator(this.url,this.socketCreatorProtocols,this.socketCreatorOptions),this.socket.onopen=()=>{ie(`ws(${this.url}) onopen`),this.state=oe.OPEN,this.reconnectTimerID&&(clearTimeout(this.reconnectTimerID),this.reconnectTimerID=void 0);const t=this.messageQueue.slice();this.messageQueue=[],t.forEach(this._send.bind(this)),this.ping(),this.pingTimerID=setInterval(this.ping.bind(this),this.pingInterval),this.onopen?.()},this.socket.onclose=t=>{const{code:e,reason:n,wasClean:i}=t;ie(`ws(${this.url}) onclose: code(${e}) reason(${n}) wasClean(${i})`),this.state=oe.CLOSED,this.socket=void 0,this.pingTimerID&&(clearInterval(this.pingTimerID),this.pingTimerID=void 0),this.onclose?.(t),this.reconnect&&this.reconnectAttempts<this.maxReconnectAttempts&&(this.reconnectTimerID=setTimeout(this._connect.bind(this),Ea(this.reconnectAttempts++)))},this.socket.onerror=t=>{ie(`ws(${this.url}) onerror: ${t}`),this.onerror?.(t)},this.socket.onmessage=t=>{if(ie(`ws(${this.url}) onmessage: { type: ${t.type}, data: ${t.data} }`),typeof t.data=="string"){let e;const n=t.data.substring(1);try{e=JSON.parse(n)}catch(i){e=[JSON.stringify({type:"err",failureCode:"fe-json-parse-error",failureType:i.toString(),message:n})]}e.forEach(i=>{const r=JSON.parse(i);if(r.body&&Object.prototype.hasOwnProperty.call(r.body,"requestid")){const o=this.waitings[r.body.requestid];o?o.resolve?.(r.body):ms(`ws(${this.url}) onmessage: found no associated request, already timed out`)}else if(this.listeners[r.address]){const o=this.listeners[r.address];for(let a=0;a<o.length;a++)r.type==="err"?o[a]({failureCode:r.failureCode,failureType:r.failureType,message:r.message}):o[a](null,r.body)}else this.onunhandled(r)})}else t.data instanceof ArrayBuffer?ms(`ws(${this.url}) onmessage: unhandle ArrayBuffer`):t.data instanceof Blob&&ms(`ws(${this.url}) onmessage: unhandle Blob`)})}onunhandled(t){try{t.type==="err"?this.onerror?.(t):t.event?console.warn("No handler found for event: %o. Message: %O",t.event,t):console.warn("No handler found for message: ",t)}catch{}}_send(t){this.socket?.readyState===oe.OPEN?this.socket.send(JSON.stringify([JSON.stringify(t)])):(this.messageQueue.push(t),this._connect())}ping(){this._send({type:"ping"})}register(t,e,n={}){this.listeners[t]||(this.listeners[t]=[],this._send({type:"register",address:t,headers:Pn(n,this.socketCreatorOptions.headers)})),this.listeners[t].push(e)}unregister(t,e,n={}){const i=this.listeners[t];if(i){const r=i.indexOf(e);r!=-1&&(i.splice(r,1),i.length===0&&(this._send({type:"unregister",address:t,headers:Pn(n,this.socketCreatorOptions.headers)}),delete this.listeners[t]))}}publish(t,e,n={}){this._send({type:"publish",address:t,headers:Pn(n,this.socketCreatorOptions.headers),body:e})}async send(t,e,n={},i=3e4){this.requestid++;const r=this.waitings[this.requestid]={requestid:this.requestid},o=await new Promise((a,h)=>{r.resolve=a,this._send({type:"send",address:t,headers:Pn(n,this.socketCreatorOptions.headers),body:{requestid:r.requestid,...e}}),setTimeout(()=>{h(`ws(${this.url}) send(${r.requestid}: ${an(e)}) Timeout!`)},i)});return delete this.waitings[r.requestid],o}}function Lw(s){const t=document.documentElement,e=window.top===window.self?window.devicePixelRatio:1;t.dataset.dpr=e;let n=100;const i=function(){const r=Math.min(t.clientWidth,s);t.dataset.width=r,t.dataset.rem=n=Math.round(100*(r/s)),t.style.fontSize=n+"px"};i(),window.rem2px=function(r){return r=parseFloat(r),r*n},window.px2rem=function(r){return r=parseFloat(r),r/n},window.addEventListener&&window.addEventListener("orientationchange"in window?"orientationchange":"resize",i,!1)}function ri(s=window.location.href){try{return new URL(s)}catch{const e="(?<protocol>https?:)",n="(?<host>(?<hostname>[^/#?:]+)(?::(?<port>\\d+))?)",i="(?<pathname>(?:\\/[^/#?]+)*\\/?)",r="(?<search>(?:\\?[^#]*)?)",o="(?<hash>(?:#.*)?)",h=new RegExp(`^${e}//${n}${i}${r}${o}$`).exec(s);return{href:s,protocol:h?.groups?.protocol??"",host:h?.groups?.host??"",hostname:h?.groups?.hostname??"",port:h?.groups?.port??"",pathname:h?.groups?.pathname??"",search:h?.groups?.search??"",hash:h?.groups?.hash??""}}}function Rw(s){const t=ri(s);return t.protocol==="http:"||t.protocol==="https:"}function el(s=window.location.href){const t=ri(s),e=t.href.indexOf(t.hash);return t.hash&&e>=0?t.href.substring(0,e):t.href}function Ow(s=ri().search){s=decodeURIComponent(s).replace(/^[#?&]/,"");const t={};if(!s)return t;const e=/(?:^|&)([^&=]*)=?([^&]*?)(?=&|$)/y;let n=e.exec(s);for(;n;)t[n[1]]=n[2],n=e.exec(s);return t}const zw=(s=window.location.href)=>JSON.parse('{"'+decodeURI(s.split("?")[1]).replace(/"/g,'\\"').replace(/&/g,'","').replace(/=/g,'":"')+'"}');function oi(s){return"?"+Object.entries(s).map(([t,e])=>`${encodeURIComponent(t)}=${encodeURIComponent(e)}`).join("&")}function nl(s){return"?"+[...s.entries()].map(t=>encodeURIComponent(t[0])+"="+encodeURIComponent(t[1]instanceof File?t[1].name:t[1])).join("&")}function sl(s,t){return s.replace(/(?:\?.*)?$/,t.replace(/^[&?]/,"?"))}function Nw(s,t){return sl(s,oi(t))}function Ho(s,t){return s+t.replace(/^[&?]/,s.indexOf("?")>=0?"&":"?")}function Bw(s,t){return Ho(s,oi(t))}class Fw{worker;cbs={};constructor(t){if(Yc)try{this.worker=new Worker(URL.createObjectURL(new Blob([t])))}catch(e){throw typeof console!==void 0&&typeof console.warn=="function"&&console.warn("🎊 Could not load worker",e),e}else throw new Error("Your environment do not support Worker !")}postMessage(t,e=[]){this.worker.postMessage(t,e)}onmessage(t){this.worker.addEventListener("message",t)}offmessage(t){this.worker.removeEventListener("message",t)}onmessageerror(t){this.worker.addEventListener("messageerror",t)}offmessageerror(t){this.worker.removeEventListener("messageerror",t)}postCanvas(t){const e=t.transferControlToOffscreen();this.worker.postMessage({canvas:e},[e])}postPort(t){this.worker.postMessage({port:t},[t])}postReset(){this.worker.postMessage({reset:!0});for(const t in this.cbs)this.cbs[t](),delete this.cbs[t]}fire(t,e){return new Promise(n=>{if(e){const i=Math.random().toString(36).slice(2),r=o=>{o.data.id===i&&(this.worker.removeEventListener("message",r),delete this.cbs[i],e(),n())};this.cbs[i]=r.bind(this,{data:{id:i}}),this.worker.addEventListener("message",r),this.worker.postMessage({...t,id:i})}else this.worker.postMessage(t),n()})}}class Yw{port1;port2;port1MessageCbs=[];port2MessageCbs=[];port1MessageErrorCbs=[];port2MessageErrorCbs=[];constructor(){const{port1:t,port2:e}=new MessageChannel;this.port1=t,this.port2=e,this.port1.addEventListener("message",n=>{this.port1MessageCbs.forEach(i=>i(this.port1,n))}),this.port1.addEventListener("messageerror",n=>{this.port1MessageErrorCbs.forEach(i=>i(this.port1,n))}),this.port1.start(),this.port2.addEventListener("message",n=>{this.port2MessageCbs.forEach(i=>i(this.port2,n))}),this.port2.addEventListener("messageerror",n=>{this.port2MessageErrorCbs.forEach(i=>i(this.port2,n))}),this.port2.start()}close(){this.port1.close(),this.port2.close()}onPort1Message(t){this.port1MessageCbs.push(t)}onPort1MessageError(t){this.port1MessageErrorCbs.push(t)}offPort1Message(t){Ne(this.port1MessageCbs,t)}offPort1MessageError(t){Ne(this.port1MessageErrorCbs,t)}onPort2Message(t){this.port2MessageCbs.push(t)}onPort2MessageError(t){this.port2MessageErrorCbs.push(t)}offPort2Message(t){Ne(this.port2MessageCbs,t)}offPort2MessageError(t){Ne(this.port2MessageErrorCbs,t)}}function il(){let s=null;if(window.ActiveXObject){const t=["Microsoft.XMLHTTP","MSXML6.XMLHTTP","MSXML5.XMLHTTP","MSXML4.XMLHTTP","MSXML3.XMLHTTP","MSXML2.XMLHTTP","MSXML.XMLHTTP"];for(let e=0,n=t.length;e<n;e++)try{s=new window.ActiveXObject(t[e]);break}catch{continue}}else s=new XMLHttpRequest;return s}function $w(s,t){return new Promise((e,n)=>{const{method:i="GET",data:r={},multipartFormDataString:o="",boundary:a="",headers:h={},withCredentials:c=!1,responseType:u="json",timeout:l=3e4}=t||{},m=il();m.timeout=l,m.responseType=u,m.onreadystatechange=function(_){m.readyState===4&&(m.status===200?e(m.response):n(m.statusText))},m.ontimeout=()=>{n(`${s} is timed out for ${l}ms.`)},m.addEventListener("load",_=>t?.load?.(_,m),!1),m.addEventListener("loadstart",_=>t?.loadstart?.(_,m),!1),m.addEventListener("loadend",_=>t?.loadend?.(_,m),!1),m.addEventListener("progress",_=>{if(_.lengthComputable){const x=Math.round(_.loaded*100/_.total);t?.progress?.(_,m,x)}},!1),m.addEventListener("error",_=>t?.error?.(_,m),!1),m.addEventListener("abort",_=>t?.abort?.(_,m),!1);const f=i.toUpperCase();Object.assign(h,{Accept:"*/*"});let p=!1,y=!1,v=!1;function w(){c&&(m.withCredentials=!0);for(const _ in h)xt(_).toLowerCase()=="content-type"&&h[_].toLowerCase()=="multipart/form-data"?(p=!0,m.setRequestHeader("Content-Type","multipart/form-data; boundary="+a)):(xt(_).toLowerCase()=="content-type"&&(h[_].toLowerCase().indexOf("text/plain")>=0?y=!0:h[_].toLowerCase().indexOf("application/json")>=0&&(v=!0)),m.setRequestHeader(_,h[_]))}switch(f){case"GET":let _="";r instanceof FormData?_=nl(r):_=oi(r),m.open("GET",Ho(s,_),!0),w(),m.send(null);break;default:m.open(f,s,!0),w(),p?m.sendAsBinary(o):v?m.send(JSON.stringify(r)):y?m.send(Object.entries(r).map(([x,b])=>`${x}=${b}`).join(`\r
|
|
48
48
|
`)):m.send(Object.entries(r).map(([x,b])=>`${encodeURIComponent(x)}=${encodeURIComponent(b)}`).join("&"));break}})}async function Xw(s){const t={url:s.action||"",data:{},contentType:s.method.toLowerCase()==="post"&&s.enctype?s.enctype:"application/x-www-form-urlencoded",multipartFormDataString:"",boundary:"---------------------------"+Date.now().toString(16)},e=[],n=t.contentType=="multipart/form-data";for(let i=0;i<s.elements.length;i++){const r=s.elements[i];if(!r.hasAttribute("name"))continue;const o=r.getAttribute("type");switch(r.nodeName.toUpperCase()==="INPUT"&&o?o.toUpperCase():""){case"FILE":const h=r;if(n)for(let l=0,m=h.files?.length||0;l<m;l++){const f=h.files?.[l];if(f){const p=await Ln(f,$t.binaryString);e.push('Content-Disposition: form-data; name="'+h.name+'"; filename="'+f.name+`"\r
|
|
49
49
|
Content-Type: `+f.type+`\r
|
|
50
50
|
\r
|