55 lines
83 KiB
JavaScript
55 lines
83 KiB
JavaScript
|
"use strict";var Debug=(()=>{var st=Object.defineProperty;var Rr=Object.getOwnPropertyDescriptor;var $o=Object.getOwnPropertyNames;var Ho=Object.prototype.hasOwnProperty;var Wo=(e,t,r)=>t in e?st(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var Vo=(e,t)=>{for(var r in t)st(e,r,{get:t[r],enumerable:!0})},zo=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of $o(t))!Ho.call(e,i)&&i!==r&&st(e,i,{get:()=>t[i],enumerable:!(o=Rr(t,i))||o.enumerable});return e};var jo=e=>zo(st({},"__esModule",{value:!0}),e),Zt=(e,t,r,o)=>{for(var i=o>1?void 0:o?Rr(t,r):t,a=e.length-1,s;a>=0;a--)(s=e[a])&&(i=(o?s(t,r,i):s(i))||i);return o&&i&&st(t,r,i),i};var D=(e,t,r)=>(Wo(e,typeof t!="symbol"?t+"":t,r),r);var Ji={};Vo(Ji,{Debug:()=>Xt,default:()=>Yi});function kr(){return{name:"StartDebugOptions",required:!1}}function Pr(){return{name:"UpdateDebugOptions",required:!1}}function Ir(){return{name:"StopDebugOptions",required:!1}}var Ur=typeof location=="undefined"?!1:location.protocol==="file:"||location.hostname==="localhost"||location.hostname==="127.0.0.1",er=()=>{let e=window.navigator&&window.navigator.userAgent||"",t=/iPad/i.test(e)||/iPhone/i.test(e),r=/Android/i.test(e);return t||r},qo=()=>{let e=navigator.language;return e=e.substring(0,2),e==="zh"},z=qo(),Y={LOG_BUTTON:z?"\u65E5\u5FD7":"Log",NETWORK_BUTTON:z?"\u7F51\u7EDC":"Network",UPLOAD_BUTTON:z?"\u4E0A\u4F20":"Upload",EXPORT_BUTTON:z?"\u5BFC\u51FA":"Export",HIDE_BUTTON:z?"\u9690\u85CF":"Hide",GO_BOTTOM:z?"\u5E95\u90E8":"goBottom",BACK_TOP:z?"\u9876\u90E8":"backTop",UPLINK:z?"\u4E0A\u884C":"Uplink",Downlink:z?"\u4E0B\u884C":"Downlink",NO_DATA:z?"\u6682\u65E0\u6570\u636E":"No Data",BASIC:z?"\u57FA\u7840":"Basic"},Nr=e=>e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d").replace(">",">").replace(">","<"),te={"play() error: NotAllowedError:":{tips_zh:e=>e.includes("main <video>")||e.includes("main <audio>")?"\u8FDC\u7AEF\u6D41\u81EA\u52A8\u64AD\u653E\u53D7\u9650\u5BFC\u81F4\u64AD\u653E\u5931\u8D25":"\u672C\u5730\u6D41\u51FA\u73B0\u81EA\u52A8\u64AD\u653E\u5931\u8D25\u62A5\u9519\uFF0C\u4E00\u822C\u53EA\u51FA\u73B0\u5728 Android \u5FAE\u4FE1\u8BBE\u5907\uFF0C\u65E0\u9700\u5904\u7406",tips_en:e=>e.includes("main <video>")||e.includes("main <audio>")?"Remote stream auto play is restricted and playback fails":"Local stream playback failure, generally only occurs in Android WeChat devices, no need to handle",color:"red",class:"red"},"updateStream() try to recover local stream":{tips_zh:"\u8BBE\u5907\u91C7\u96C6\u5F02\u5E38\uFF0C\u6B63\u5728\u5C1D\u8BD5\u81EA\u52A8\u6062\u590D\u91C7\u96C6",tips_en:"Device acquisition exception, automatic recovery is in progress"},"updateStream() recover local stream successfully":{tips_zh:"\u8BBE\u5907\u91C7\u96C6\u5F02\u5E38\uFF0C\u81EA\u52A8\u6062\u590D\u91C7\u96C6\u6210\u529F",tips_en:"Device acquisition exception, automatic recovery is successful"},"updateStream() failed to recover local stream":{tips_zh:"\u8BBE\u5907\u91C7\u96C6\u5F02\u5E38\uFF0C\u81EA\u52A8\u6062\u590D\u91C7\u96C6\u5931\u8D25",tips_en:"Device acquisition exception, automatic recovery failed"},"main stream - video track is muted":{tips_zh:"\u8868\u793A\u6536\u5230\u7684\u89C6\u9891\u6570\u636E\u6682\u4E0D\u8DB3\u4EE5\u64AD\u653E\uFF0C\u4E00\u822C\u662F\u7F51\u7EDC\u539F\u56E0\u5F15\u8D77\uFF0C\u5F53\u6536\u5230\u8DB3\u591F\u64AD\u653E\u7684\u6570\u636E\u4F1A\u53D8\u6210 unmuted \u72B6\u6001\u3002",tips_en:"Indicates that the received video data is not enough for playback. This is usually caused by network reasons. When enough data is received for playback, the state will change to unmuted."},"main stream - audio track is muted":{tips_zh:"\u8868\u793A\u6536\u5230\u7684\u97F3\u9891\u6570\u636E\u6682\u4E0D\u8DB3\u4EE5\u64AD\u653E\uFF0C\u4E00\u822C\u662F\u7F51\u7EDC\u539F\u56E0\u5F15\u8D77\uFF0C\u5F53\u6536\u5230\u8DB3\u591F\u64AD\u653E\u7684\u6570\u636E\u4F1A\u53D8\u6210 unmuted \u72B6\u6001\u3002",tips_en:"Indicates that the received audio data is not enough for playback. This is usually caused by network reasons. When enough data is rec
|
||
|
1. \u4E1A\u52A1\u4FA7\u4F20\u5165\u7528\u4E8E\u64AD\u653E\u97F3\u89C6\u9891\u7684 div \u6807\u7B7E\u5BB9\u5668\u88AB\u4E1A\u52A1\u4FA7\u4ECE DOM \u79FB\u9664\u3002
|
||
|
2. \u7528\u6237\u5728 Chrome 70 \u53CA\u4EE5\u4E0B\u7248\u672C\uFF0C\u5F53\u79FB\u52A8 div \u5BB9\u5668\u65F6\uFF0C\u4F1A\u5BFC\u81F4\u64AD\u653E\u6682\u505C\u3002`,tips_en:`The remote stream audio playback is paused, which usually has two possibilities:
|
||
|
1. The business side passes in the div tag container for playing audio and video to be removed by the business side from the DOM.
|
||
|
2. If the user is in Chrome 70 and below, when the div container is moved, the playback will be paused.`,color:"orange",class:"orange",textColor:"#fff"},"main stream - video player is paused":{tips_zh:`\u8FDC\u7AEF\u6D41\u89C6\u9891\u64AD\u653E\u6682\u505C\uFF0C\u4E00\u822C\u6709\u4E24\u79CD\u53EF\u80FD\uFF1A
|
||
|
1. \u4E1A\u52A1\u4FA7\u4F20\u5165\u7528\u4E8E\u64AD\u653E\u97F3\u89C6\u9891\u7684 div \u6807\u7B7E\u5BB9\u5668\u88AB\u4E1A\u52A1\u4FA7\u4ECE DOM \u79FB\u9664\u3002
|
||
|
2. \u7528\u6237\u5728 Chrome 70 \u53CA\u4EE5\u4E0B\u7248\u672C\uFF0C\u5F53\u79FB\u52A8 div \u5BB9\u5668\u65F6\uFF0C\u4F1A\u5BFC\u81F4\u64AD\u653E\u6682\u505C\u3002`,tips_en:`The remote stream video playback is paused, which usually has two possibilities:
|
||
|
1. The business side passes in the div tag container for playing audio and video to be removed by the business side from the DOM.
|
||
|
2. If the user is in Chrome 70 and below, when the div container is moved, the playback will be paused.`,color:"orange",class:"orange",textColor:"#fff"},'"displaySurface":"window"':{tips_zh:"\u5C4F\u5E55\u5206\u4EAB\u91C7\u96C6\u4E86\u5E94\u7528\u7A97\u53E3",tips_en:"Screen sharing captures the application window",color:"blue",class:"blue",textColor:"#fff"},'"displaySurface":"monitor"':{tips_zh:"\u5C4F\u5E55\u5206\u4EAB\u91C7\u96C6\u4E86\u6574\u4E2A\u5C4F\u5E55",tips_en:"Screen sharing captures the entire screen",color:"blue",class:"blue",textColor:"#fff"},'"displaySurface":"browser"':{tips_zh:"\u5C4F\u5E55\u5206\u4EAB\u91C7\u96C6\u4E86\u67D0\u4E2A\u6807\u7B7E\u9875",tips_en:"Screen sharing captures a certain tab page",color:"blue",class:"blue",textColor:"#fff"},updateMediaSettings:{tips_zh:"\u8BE5\u65E5\u5FD7\u4E0B\u7684\u5206\u8FA8\u7387\u3001\u5E27\u7387\u4E3A\u5B9E\u9645\u91C7\u96C6\u51FA\u7684\u5206\u8FA8\u7387\u53CA\u5E27\u7387",tips_en:"The resolution and frame rate below are the actual resolution and frame rate captured",color:"blue",class:"blue",textColor:"#fff"},"main stream start to play with":{tips_zh:"\u8C03\u7528 remoteStream.play \u63A5\u53E3",tips_en:"Call remoteStream.play interface",color:"blue",class:"blue",textColor:"#fff"},"stream start to play with":{tips_zh:"\u8C03\u7528 localStream.play \u63A5\u53E3",tips_en:"Call localStream.play interface",color:"blue",class:"blue",textColor:"#fff"},"main setAudioVolume to 0":{tips_zh:"\u4E1A\u52A1\u4FA7\u8C03\u7528 remoteStream.setAudioVolume(0) \u63A5\u53E3\uFF0C\u5C06\u64AD\u653E\u97F3\u91CF\u8BBE\u7F6E\u4E3A 0\uFF0C\u4F1A\u5BFC\u81F4\u64AD\u653E\u65E0\u58F0",tips_en:"Business side calls remoteStream.setAudioVolume(0) interface to set the playback volume to 0, which will cause the playback to be silent",color:"orange",class:"orange",textColor:"#fff"},"screen sharing was stopped because the video track is ended":{tips_zh:"\u5C4F\u5E55\u5206\u4EAB\u91C7\u96C6\u505C\u6B62\uFF0C\u53EF\u80FD\u539F\u56E0\uFF1A\u7528\u6237\u70B9\u51FB\u505C\u6B62\u91C7\u96C6\u6309\u94AE\u3001\u5206\u4EAB\u7684\u7A97\u53E3/\u9875\u9762\u88AB\u5173\u95ED\u7B49\u3002",tips_en:"Screen sharing capture stopped, possible reasons: user clicks the stop button, the window/page shared by the user is closed, etc.",color:"orange",class:"orange",textColor:"#fff"},"Join() => joining room":{tips_zh:"\u8C03\u7528 client.join \u63A5\u53E3",tips_en:"Call client.join interface",color:"blue",class:"blue",textColor:"#fff"},"publish() => publishing local stream":{tips_zh:"\u8C03\u7528 client.publish \u63A5\u53E3",tips_en:"Call client.publish interface",color:"blue",class:"blue",textColor:"#fff"},"subscribe() => subscribe to":{tips_zh:"\u8C03\u7528 client.subscribe \u63A5\u53E3",tips_en:"Call client.subscribe interface",color:"blue",class:"blue",textColor:"#fff"},"switchRole() => switch role":{tips_zh:"\u8C03\u7528 client.switchRole \u63A5\u53E3",tips_en:"Call client.switchRole interface",color:"blue",class:"blue",textColor:"#fff"}};["enterRoom","exitRoom","switchRole","destroy","startLocalAudio","updateLocalAudio","stopLocalAudio","startLocalVideo","updateLocalVideo","stopLocalVideo","startScreenShare","updateScreenShare","stopScreenShare","startRemoteVideo","updateRemoteVideo","stopRemoteVideo","muteRemoteAudio","setRemoteAudioVolume"].forEach(e=>{te[`${e}()`]={tips_zh:`\u8C03\u7528 trtc.${e}`,tips_en:`Call trtc.${e}`,color:"blue",class:"blue",textColor:"#fff"}});var Mr=Object.keys(te);function Br(e){return function(t,r,o){return o.value=e(o.value,r),o}}var kt=new WeakMap;function tr(e,t){return Br((r,o)=>function(...i){var l,c;let a=(l=kt.get(this))==null?void 0:l.get(t(...i));a&&a>0&&clearTimeout(a);let s=window.setTimeout(()=>{r.apply(this,i)},e);kt.has(this)?(c=kt.get(this))==null||c.set(t(...i),s):kt.set(this,new Map([[t(...i),s]]))})}var M="top",W="bottom",$="right",B="left",Pt="auto",De=[M,W,$,B],ye="start",Pe="end",$r="clippingParents",It="viewport",Xe="popper",Hr="reference",rr=De.reduce(function(e,t){return e.concat([t+"-"+ye,t+"-"+Pe])},[]),Ut=[].concat(De,[Pt]).reduce(function(e,t){return e
|
||
|
\u2191 ${a/1e3} KB/s (${8*a/1e3} Kb/s) <br>
|
||
|
\u2193 ${s/1e3} KB/s (${8*s/1e3} Kb/s) <br>
|
||
|
`;l.innerHTML=c;let d=(x=this._dialogNode)==null?void 0:x.querySelector(`.${Er}`),u="";i.localStatistics.audio.bitrate&&(u=`<li>local audio: ${i.localStatistics.audio.bitrate} Kb/s audioLevel: ${i.localStatistics.audio.audioLevel.toFixed(5)}</li>`),i.localStatistics.video.length>0&&(u+=`${i.localStatistics.video.map(v=>`<li>local ${v.videoType} video: ${v.bitrate} Kb/s ${v.width}*${v.height} ${v.frameRate}fps</li>`).join("")}`),d.innerHTML=u===""?`${Y.NO_DATA}`:u;let b=(m=this._dialogNode)==null?void 0:m.querySelector(`.${Ar}`),h="";i.remoteStatistics.length>0&&i.remoteStatistics.forEach(v=>{let A=`remote ${v.userId}:`;v.audio.bitrate>0&&(A+=`<li>audio: ${v.audio.bitrate} Kb/s audioLevel: ${v.audio.audioLevel.toFixed(5)}</li>`),v.video.length>0&&v.video.forEach(R=>{A+=`<li>${R.videoType} video: ${R.bitrate} Kb/s ${R.width}*${R.height} ${R.frameRate}fps</li>`}),h+=A}),b.innerHTML=h===""?`${Y.NO_DATA}`:h});Cr=!0,this._core=t,this._log=r,this.addStyle(),this.addDialog(),this.synchronizeLog(),this.installEvents()}synchronizeLog(){this._core.loggerManager.getQueue().forEach(r=>{this.updateLog(r)})}addStyle(){this._dialogStyle=document.createElement("style"),this._dialogStyle.innerHTML=`
|
||
|
#${P}
|
||
|
{--DD-BG-0:#ededed;--DD-BG-1:#f7f7f7;--DD-BG-2:#fff;--DD-BODER:rgba(0,0,0,0.1);--DD-ERROR:red;--DD-WARN:#fa9d3b;--DD-INFO:#000;--DD-DEBUG:#10aeff;--DD-WARN-BG:#fff3cc;--DD-ERROR-BG:#ffe6e6;}
|
||
|
#${P} a,.${Vt}{cursor:pointer;}
|
||
|
.${P}{color:black;}
|
||
|
.${Vt}{display:block;position:fixed;right:50px;bottom:150px;border-radius:5px;background-color:#07c160;color:#fff;padding:5px 10px;z-index:10000;}
|
||
|
.${xr}{display:none;position:fixed;left:0;top:0;right:0;bottom:0;z-index:10001;background-color:rgb(0,0,0,0.6);}
|
||
|
.${zt}{background-color:#ededed;display:none;position:fixed;min-height:85%;left:60%;right:0;bottom:0;z-index:10002;border:1px solid var(--DD-BG-0);}
|
||
|
@media (max-width:768px) {.${zt}{left:0;}}
|
||
|
.${Or}{display:flex;height:2rem;border-bottom:1px solid var(--DD-BODER);}
|
||
|
.${jt}{padding:0 20px;border-right:1px solid rgba(0, 0, 0, 0.1);line-height:2rem;color: black;}
|
||
|
.${jt}.${Ae}{background-color:var(--DD-BG-2);}
|
||
|
.${wr}{height:2rem;display:flex;flex-direction:row;}
|
||
|
.${Ve}{width:20%;text-align:center;line-height:2rem;border-right:1px solid var(--DD-BODER);border-bottom:1px solid var(--DD-BODER);color:black;}
|
||
|
.${Ve}.${Ae}{border-bottom:1px solid #1485ee;background-color:var(--DD-BG-2);}
|
||
|
.${Se}{background-color:#fff;position:absolute;left:0;right:0;top:2rem;bottom:6rem;overflow-y:scroll;overflow-x:hidden;}
|
||
|
.${Se}.${qt}{top:4rem;}
|
||
|
.${ze}{display:flex;display:none;}
|
||
|
.${Gt}{text-align:center;background-color:var(--DD-BG-0);border-bottom:1px solid var(--DD-BODER);}
|
||
|
.${Dr},.${Er},.${Ar}{text-align:center;border-bottom:1px solid var(--DD-BODER);}
|
||
|
.${xe}{border-bottom:1px solid var(--DD-BG-0);padding:5px 10px;overflow-wrap: break-word;}
|
||
|
.${Lo}{color:var(--DD-ERROR);background-color:var(--DD-ERROR-BG);}
|
||
|
.${Co}{color:var(--DD-WARN);background-color:var(--DD-WARN-BG);}
|
||
|
.${Ao}{color:var(--DD-INFO);}
|
||
|
.${Eo}{color:var(--DD-DEBUG);}
|
||
|
.${Kt}{position:absolute;left:0;right:0;bottom:2rem;height:4rem;border-bottom:1px solid var(--DD-BODER);display:flex;flex-direction:column;overflow-y:scroll;background-color:var(--DD-BG-1);}
|
||
|
.${wo}{border-bottom:1px solid var(--DD-BODER);padding:5px 10px;overflow-wrap: break-word;}
|
||
|
.${Do}{position:absolute;line-height:2rem;display:flex;flex-direction:row;left:0;right:0;bottom:0;}
|
||
|
.${vt}{flex:1;color:black;text-align:center;background-color:#ededed;border-right:1px solid var(--DD-BODER);}
|
||
|
#${P} .${bt},#${P} .${yt}{position:absolute;height:2rem;width:6rem;right:2rem;border-radius:5px;background-color:rgba(30, 136, 229, 0.8);z-index:10003;cursor:pointer;padding:0 5px;line-height:2rem;color:white;text-align:center;}
|
||
|
.${yt}{bottom:7rem;}
|
||
|
.${bt}{bottom:9.5rem;}
|
||
|
#${P} .${vt}.disable {cursor: not-allowed;background-color: #ededed;color: #999;}
|
||
|
.tippy-box {position: relative;background-color: #333;color: #fff;border-radius: 4px;font-size: 14px;line-height: 1.4; white-space: normal;outline: 0;transition-property: transform, visibility, opacity;}
|
||
|
.tippy-content {position: relative;padding: 5px 9px;}
|
||
|
.tippy-arrow {width: 16px;height: 16px;color: #333;}
|
||
|
.tippy-arrow:before {content: "";position: absolute;border-color: transparent;border-style: solid;}.tippy-box[data-placement^=top]>.tippy-arrow:before {bottom: -7px;left: 0;border-width: 8px 8px 0; border-top-color: initial;transform-origin: center top;}
|
||
|
.tippy-box[data-placement^=top]>.tippy-arrow {bottom: 0;}
|
||
|
`,document.body.appendChild(this._dialogStyle)}addDialog(){this._dialogNode=this.createDiaLog(),document.body.appendChild(this._dialogNode)}createDiaLog(){var s,l,c,d;this._isMobile=er();let t=document.createElement("template");t.innerHTML=`<div id="${P}" class="${P}"><div class="${Vt}">Debug</div><div class="${xr}"></div><div class="${zt}"><a class="${bt}">${Y.BACK_TOP}</a><a class="${yt}">${Y.GO_BOTTOM}</a><div class="${Or}"><a class="${jt} ${Ae}" data-tab="log">${Y.LOG_BUTTON}</a><a class="${jt}" data-tab="network">${Y.NETWORK_BUTTON}</a></div><div class="${wr}"><a class="${Ve} ${Ae}" data-type="all">All</a><a class="${Ve}" data-type="debug">Debug</a><a class="${Ve}" data-type="info">Info</a><a class="${Ve}" data-type="warn">Warn</a><a class="${Ve}" data-type="error">Error</a></div><div class="${Se} ${qt}"><div class="${Oo}"></div><div class="${ze}"><div class="${Gt}">${Y.BASIC}</div><div class="${Dr}">${Y.NO_DATA}</div><div class="${Gt}">${Y.UPLINK}</div><div class="${Er}">${Y.NO_DATA}</div><div class="${Gt}">${Y.Downlink}</div><div class="${Ar}">${Y.NO_DATA}</div></div></div><div class="${Kt}"></div><div class="${Do}"><a id="trtc_upload" class="${vt}">${Y.UPLOAD_BUTTON}</a><a id="trtc_export" class="${vt}">${Y.EXPORT_BUTTON}</a><a id="trtc_hide" class="${vt}">${Y.HIDE_BUTTON}</a></div></div></div>`;let r=t.content.firstChild;this._switchNode=r.querySelector(`.${Vt}`),(s=this._switchNode)==null||s.addEventListener("click",this.onSwitchClick.bind(this)),this.dragable(this._switchNode),this._maskNode=r.querySelector(`.${xr}`),(l=this._maskNode)==null||l.addEventListener("click",this.onMaskClick.bind(this)),this._pannelNode=r.querySelector(`.${zt}`),(c=r.querySelector(`.${bt}`))==null||c.addEventListener("click",this.onBackTopClick.bind(this)),(d=r.querySelector(`.${yt}`))==null||d.addEventListener("click",this.onGoBottomClick.bind(this)),this._logContentNode=r.querySelector(`.${Oo}`),this._networkContentNode=r.querySelector(`.${ze}`),this._tabNodes=Array.from(r.querySelector(`.${Or}`).children),this._tabNodes.forEach(u=>{u.addEventListener("click",this.onTabClick.bind(this))}),this._toptabNodes=Array.from(r.querySelector(`.${wr}`).children),this._toptabNodes.forEach(u=>{u.addEventListener("click",this.onToptabClick.bind(this))}),this._backTopButton=r.querySelector(`.${bt}`),this._goBottomButton=r.querySelector(`.${yt}`);let o=r.querySelector("#trtc_upload");o==null||o.addEventListener("click",this.onUploadClick.bind(this));let i=r.querySelector("#trtc_export");i==null||i.addEventListener("click",this.onExportClick.bind(this));let a=r.querySelector("#trtc_hide");return a==null||a.addEventListener("click",this.onHideClick.bind(this)),r}deleteDialog(){Cr&&(Cr=!1,this.uninstallEvents(),this._dialogNode&&(document.body.removeChild(this._dialogNode),this._dialogNode=null),this._dialogStyle&&(document.body.removeChild(this._dialogStyle),this._dialogStyle=null))}updateLog(t){var o;this._logList.push(t);let r=document.createElement("div");switch(r.classList.add(xe),t.level){case 4:r.classList.add(Lo);break;case 2:r.classList.add(Ao);break;case 3:r.classList.add(Co);break;case 1:r.classList.add(Eo);break;default:break}r.textContent=t.log,this._showLogType!=="all"&&!r.classList.contains(`${xe}_${this._showLogType}`)&&(r.style.display="none"),(o=this._logContentNode)==null||o.appendChild(r),this.addHelper(r)}onSwitchClick(){if(this._hasMove){this._hasMove=!1;return}this._showDialog?this.hideDialog():(this._isMobile&&(this._maskNode.style.display="block"),this._pannelNode.style.display="block",this._switchNode.style.display="none",this._showDialog=!0)}onTabClick(t){var i,a,s,l,c;let r=t.target;(i=this._tabNodes)==null||i.forEach(d=>{d.classList.remove(Ae)}),r.classList.add(Ae);let o=r.getAttribute("data-tab");o==="log"?((s=(a=this._dialogNode)==null?void 0:a.querySelector(`.${Se}`))==null||s.classList.add(qt),this._logContentNode.style.display="block",this._networkContentNode.style.display="none",this._goBottomButton.style.display="block",this._backTopButton.style.display="block"):o==="network"&&((c=(l=this._dialogNode)==null?
|
||
|
`,""),r=new Blob([t],{type:"text/plain"}),o=document.createElement("a"),i=URL.createObjectURL(r);o.href=i;let a=`trtc_${((s=this._core)==null?void 0:s.room.sdkAppId)===void 0?"EmptySdkAppId":(c=(l=this._core)==null?void 0:l.room)==null?void 0:c.sdkAppId}_${((d=this._core)==null?void 0:d.room.userId)===void 0?"EmptyUserId":(u=this._core)==null?void 0:u.room.userId}_${new Date().getTime()}.log`;o.download=a,o.style.display="none",document.body.appendChild(o),o.click(),URL.revokeObjectURL(i),document.body.removeChild(o),this.addInfoToBanner(Ro,z?`\u5BFC\u51FA\u6210\u529F\uFF1A\u65E5\u5FD7\u6587\u4EF6\u540D\u4E3A${a}`:`Export success: The log file name is ${a}`),(b=this._log)==null||b.info("Export success: The log file name is ${fileName}")}addInfoToBanner(t,r){var a;let o=(a=this._dialogNode)==null?void 0:a.querySelector(`.${Kt}`),i=document.createElement("div");i.classList.add(wo),i.innerText=`${t===Ro?"\u{1F7E9}":"\u{1F7E5} "} ${r}`,o.appendChild(i),o.scrollTop=o.scrollHeight}async onUploadClick(){var l,c,d;if(this.isUploading)return;this.isUploading=!0;let t=(l=this._dialogNode)==null?void 0:l.querySelector("#trtc_upload");t.innerText=z?"\u4E0A\u4F20\u4E2D...":"Uploading...",t==null||t.classList.add(".disable");let r=this._logList.reduce((u,b)=>`${u+b.log}
|
||
|
`,""),o=new Blob([r],{type:"text/plain"}),i=new FormData,a="trtc.log";i.append("file",o,a),i.append("sdkAppId",`${((c=this._core)==null?void 0:c.room.sdkAppId)||"EmptySdkAppId"}`),i.append("userId",`${((d=this._core)==null?void 0:d.room.userId)||"EmptyUserId"}`),fetch("https://service.trtc.qcloud.com/api/uploadLogFile",{method:"POST",body:i}).then(u=>u.json()).then(u=>{var b;this.addInfoToBanner(u==null?void 0:u.type,z?u==null?void 0:u.message_zh:u==null?void 0:u.message_en),this.isUploading=!1,(b=this._log)==null||b.info(u==null?void 0:u.message_en)}).catch(()=>{var u;this.addInfoToBanner(Xi,z?"\u4E0A\u4F20\u5931\u8D25\uFF1A\u8BF7\u4F7F\u7528\u672C\u5730\u5BFC\u51FA":"Upload Failed: Please use local export"),(u=this._log)==null||u.info("Upload Failed: Please use local export")}).finally(()=>{t.innerText=z?"\u4E0A\u4F20":"Upload",t==null||t.classList.remove(".disable"),this.isUploading=!1})}onHideClick(){this.hideDialog()}onMaskClick(){this.hideDialog()}hideDialog(){this._isMobile&&(this._maskNode.style.display="none"),this._pannelNode.style.display="none",this._switchNode.style.display="block",this._showDialog=!1}onBackTopClick(){var t,r;(r=(t=this._dialogNode)==null?void 0:t.querySelector(`.${Se}`))==null||r.scrollTo(0,0)}onGoBottomClick(){var r;let t=(r=this._dialogNode)==null?void 0:r.querySelector(`.${Se}`);t==null||t.scrollTo(0,t==null?void 0:t.scrollHeight)}dragable(t){var u,b;let r={x:0,y:0,startX:0,startY:0,endX:0,endY:0,isTouchEnd:!1};r.x=((u=this._switchNode)==null?void 0:u.offsetLeft)||50,r.y=((b=this._switchNode)==null?void 0:b.offsetTop)||150;let o=h=>{h.preventDefault(),r.startX=h.pageX,r.startY=h.pageY,document.addEventListener("mousemove",i),document.addEventListener("mouseup",a)},i=h=>{h.cancelable&&h.preventDefault(),this._hasMove=!0;let f=r.x-(h.pageX-r.startX),y=r.y-(h.pageY-r.startY);[f,y]=d(f,y),this._switchNode.style.right=`${f}px`,this._switchNode.style.bottom=`${y}px`,r.endX=f,r.endY=y},a=()=>{r.startX=0,r.startY=0,r.x=r.endX,r.y=r.endY,document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",a)},s=h=>{r.startX=h.touches[0].pageX,r.startY=h.touches[0].pageY,r.isTouchEnd=!1},l=()=>{r.isTouchEnd&&(r.startX=0,r.startY=0,r.isTouchEnd=!1,r.x=r.endX,r.y=r.endY)},c=h=>{if(h.touches.length<=0)return;let f=h.touches[0].pageX-r.startX,y=h.touches[0].pageY-r.startY,_=Math.floor(r.x-f),S=Math.floor(r.y-y);[_,S]=d(_,S),this._switchNode.style.right=`${_}px`,this._switchNode.style.bottom=`${S}px`,r.endX=_,r.endY=S,r.isTouchEnd=!0,h.cancelable&&h.preventDefault()},d=(h,f)=>{let y=Math.max(document.documentElement.offsetWidth,window.innerWidth),_=Math.max(document.documentElement.offsetHeight,window.innerHeight);return h+this._switchNode.offsetWidth>y&&(h=y-this._switchNode.offsetWidth),f+this._switchNode.offsetHeight>_&&(f=_-this._switchNode.offsetHeight),h<0&&(h=0),f<20&&(f=20),[h,f]};er()?(t.addEventListener("touchstart",s,{passive:!1}),t.addEventListener("touchend",l,{passive:!1}),t.addEventListener("touchmove",c,{passive:!1})):t.addEventListener("mousedown",o)}installEvents(){this._core.innerEmitter.on("264",this.handleLog,this),this._core.room.on("network-quality",this.handleNetworkQuality,this),this._core.room.on("heartbeat-report",this.handleHeartbeatReport,this)}uninstallEvents(){this._core.innerEmitter.off("264",this.handleLog,this),this._core.room.off("network-quality",this.handleNetworkQuality,this),this._core.room.off("heartbeat-report",this.handleHeartbeatReport,this)}handleLog(t){this.updateLog(t.log)}addHelper(t){let r=/((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})(\.((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})){3}/g,o=Mr,i=t.innerText;i=i.split(`
|
||
|
`).map(a=>{if(a=a.replaceAll("<","<").replaceAll(">",">"),a.includes("failed"))return a.includes("on autoplay-failed")?a:`<span class='red' style="background:red; color:#fff;">${a}</span>`;if(a.includes("clientIp:")){let s=a.match(r);return s==null||s.forEach(l=>{a=a.replaceAll(l,`<a href="javascript:void(0);" target=""><span class='ip' style="background:#e1dfdf">${l}</span></a>`)}),a}return a.includes("URL of current page")&&(a=a.replace(/URL of current page: (.+)/,'URL of current page: <a href="$1">$1</a>')),a}).join(`
|
||
|
`),o.forEach(a=>{if(t.innerText.includes(a)){let s=`tooltip-${this.tippyCount}`;i=i.replace(new RegExp(`${Nr(a)}`,"gi"),`<span id="${s}" class='${te[a].class||te[a].color||"gray"}' style="background:${te[a].color||"#e1dfdf"}; color: ${te[a].textColor||"#000"}">${a}</span>`),setTimeout(()=>{let l="";z?l=typeof te[a].tips_zh=="function"?te[a].tips_zh(t.innerText):te[a].tips_zh:l=typeof te[a].tips_en=="function"?te[a].tips_en(t.innerText):te[a].tips_en;let c=document.getElementById(`${s}`);c&&xo(c,{content:l,zIndex:10004,placement:"top"})},500),this.tippyCount+=1}}),t.innerHTML=i}};Zt([tr(300,()=>"export")],_t.prototype,"onExportClick",1),Zt([tr(300,()=>"upload")],_t.prototype,"onUploadClick",1);var ko=_t;var tt=null,Ft=null,Yt=class Yt{constructor(t){this.core=t;D(this,"seq");D(this,"_core");D(this,"log");return Ft||(this._core=t,this.log=t.log.createChild({id:this.getAlias()}),this.log.info("created"),Ft=this,Ft)}getName(){return Yt.Name}getAlias(){return"dm"}getGroup(){return"dm"}getValidateRule(t){switch(t){case"start":return kr();case"update":return Pr();case"stop":return Ir()}}start(){Ur&&(this._openDebugDiaLog(),this.log.warn("if you are in production environment, please use URL param `trtcDebug=ture` to open debug dialog")),new URLSearchParams(location.search).get("trtcDebug")&&this._openDebugDiaLog()}update(){}stop(){this._closeDebugDiaLog()}destroy(){this.log.info("destroyed")}_openDebugDiaLog(){tt||(tt=new ko(this._core,this.log))}_closeDebugDiaLog(){tt==null||tt.deleteDialog(),tt=null}};D(Yt,"Name","Debug");var Xt=Yt;var Yi=Xt;return jo(Ji);})().default;
|