mixapply 1.1.48 → 1.1.49
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/assets/sharedWorker-DVRBPGcK.js +1 -0
- package/mixapply.css +1 -1
- package/mixapply.js +4342 -4277
- package/mixapply.umd.cjs +57 -57
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var O=Object.defineProperty;var E=(o,t,r)=>t in o?O(o,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[t]=r;var u=(o,t,r)=>E(o,typeof t!="symbol"?t+"":t,r);(function(){"use strict";const i=class i{constructor(){u(this,"receivedPings",5)}create_ws(s,e){const{url:l,token:g,sysMode:T}=s,p=new WebSocket(l),P=this;return p.onopen=function(){console.log("WebSocket连接成功");const a={action:"auth_dashbos",token:g};T!=="box"&&p.send(JSON.stringify(a)),I&&clearInterval(I),I=setInterval(()=>{_()},i.PING_TIMEOUT)},p.onmessage=function(a){var b;if(a.data!=="pong")try{const f=JSON.parse(a.data);if(f.code===200)if(f.component_name==="object_alias_map"){const[k]=Object.values(e);k&&k.postMessage(f)}else(b=e[f.actionid])==null||b.postMessage(f)}catch(f){console.error("消息处理错误:",f)}else P.receivedPings=i.PING_INITIAL_COUNT},p.onclose=function(a){P.receivedPings=0,console.log("WebSocket已关闭")},p.onerror=function(a){console.error("WebSocket错误:",a)},new Promise(a=>{a(p)})}send_data(s,e,l,g){l[s.actionid]=g,e.send(JSON.stringify(s))}};u(i,"PING_TIMEOUT",1e4),u(i,"MAX_RETRIES",5),u(i,"PING_INITIAL_COUNT",5);let o=i;const t=new o,r=new Map;let n=null,I=null,S=null,d=null;const v=new Map,y=new Set;self.onconnect=({ports:c})=>{const s=c[0];y.add(s),s.onmessage=function({data:e}){e.type==="open"?M(e):e.type==="send"&&N(e,s)}};function M(c,s){d=JSON.parse(JSON.stringify(c)),console.log("打开WebSocket:",d),n?(I&&clearInterval(I),I=setInterval(()=>{_()},o.PING_TIMEOUT)):t.create_ws(d,r,self).then(e=>{n=e})}function N(c,s){v.has(c.request.actionid)||v.set(c.request.actionid,c);let e=0;if(n){const l=setInterval(()=>{n.readyState===1?(t.send_data(c.request,n,r,s),clearInterval(l)):e>o.MAX_RETRIES&&(console.error("WebSocket连接失败超过最大重试次数,请检查服务端!"),clearInterval(l)),e++},3e3)}else console.error("共享工作者线程中WebSocket对象未初始化")}function _(c,s){t.receivedPings===0?(n==null||n.close(),n=null,console.log("重新连接WebSocket:",d),t.create_ws(d,r,self).then(e=>{n=e;let l=0;clearInterval(S),S=setInterval(()=>{if(n.readyState===1){for(const[g,T]of v)N(T,r.get(g));clearInterval(S)}else l>o.MAX_RETRIES&&(console.error("WebSocket连接失败超过最大重试次数,请检查服务端!"),clearInterval(S));l++},2e3)})):(t.receivedPings--,n==null||n.send("ping"))}})();
|