@besovideo/webrtc-player 0.3.0 → 0.3.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.
- package/dist/main.browser.css +1 -1
- package/dist/main.browser.js +9 -9
- package/dist/main.es.css +1 -1
- package/dist/main.es.js +9 -9
- package/dist/types/app.d.ts +2 -4
- package/dist/types/components/puPlayer.d.ts +1 -1
- package/dist/types/core/customElement.d.ts +4 -0
- package/dist/types/core/dom.d.ts +24 -0
- package/dist/types/core/events.d.ts +15 -5
- package/dist/types/core/field.d.ts +4 -0
- package/dist/types/core/index.d.ts +21 -3
- package/dist/types/core/jsx.d.ts +8 -0
- package/dist/types/core/style.d.ts +10 -0
- package/dist/types/core/types.d.ts +7 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/main.d.ts +1 -1
- package/dist/types/plugins/controller/button.d.ts +13 -0
- package/dist/types/plugins/controller/event.d.ts +13 -0
- package/dist/types/plugins/controller/index.d.ts +27 -0
- package/dist/types/plugins/decorators.d.ts +2 -0
- package/dist/types/plugins/mixins/visible.d.ts +13 -0
- package/dist/types/plugins/modal.d.ts +33 -0
- package/dist/types/plugins/player/event.d.ts +11 -6
- package/dist/types/plugins/player/index.d.ts +17 -5
- package/dist/types/plugins/player/infoList.d.ts +14 -0
- package/dist/types/plugins/player/panel.d.ts +15 -0
- package/dist/types/plugins/player/reducers/types.d.ts +36 -0
- package/dist/types/plugins/slider.d.ts +21 -0
- package/dist/types/plugins/types.d.ts +13 -14
- package/dist/types/plugins/video.d.ts +14 -2
- package/dist/types/templates/button.d.ts +8 -0
- package/dist/types/templates/icons.d.ts +18 -0
- package/dist/types/templates/type.d.ts +0 -0
- package/dist/types/utils/dev.d.ts +4 -0
- package/dist/types/utils/lang.d.ts +11 -0
- package/dist/types/utils/logger.d.ts +2 -0
- package/dist/types/utils/util.d.ts +3 -2
- package/dist/types/z_test/puPlayer.d.ts +1 -1
- package/dist/types/z_unuse/index.d.ts +5 -0
- package/package.json +69 -58
- package/dist/types/core/classes.d.ts +0 -2
package/dist/main.es.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
var
|
|
1
|
+
var Kt=Object.defineProperty,Gt=Object.defineProperties;var Xt=Object.getOwnPropertyDescriptors;var tt=Object.getOwnPropertySymbols;var qt=Object.prototype.hasOwnProperty,Qt=Object.prototype.propertyIsEnumerable;var nt=(t,e,n)=>e in t?Kt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,R=(t,e)=>{for(var n in e||(e={}))qt.call(e,n)&&nt(t,n,e[n]);if(tt)for(var n of tt(e))Qt.call(e,n)&&nt(t,n,e[n]);return t},U=(t,e)=>Gt(t,Xt(e));var p=(t,e,n)=>new Promise((o,i)=>{var s=l=>{try{m(n.next(l))}catch(g){i(g)}},c=l=>{try{m(n.throw(l))}catch(g){i(g)}},m=l=>l.done?o(l.value):Promise.resolve(l.value).then(s,c);m((n=n.apply(t,e)).next())});var Zt="production",Yt="@besovideo/webrtc-player",jt="0.3.4",d={NODE_ENV:Zt,SH_LIB_NAME:Yt,SH_LIB_VERSION:jt};var en=Object.defineProperty,tn=Object.defineProperties,nn=Object.getOwnPropertyDescriptors,ot=Object.getOwnPropertySymbols,on=Object.prototype.hasOwnProperty,rn=Object.prototype.propertyIsEnumerable,rt=(t,e,n)=>e in t?en(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,X=(t,e)=>{for(var n in e||(e={}))on.call(e,n)&&rt(t,n,e[n]);if(ot)for(var n of ot(e))rn.call(e,n)&&rt(t,n,e[n]);return t},sn=(t,e)=>tn(t,nn(e)),T;(function(t){t.red="#e72528",t.blue="#2a79af",t.weakBlue="#6eb6f4",t.geekblue="#85a5ff",t.gold="#ffd666",t.orange="#ffa940",t.cyan="#13c2c2",t.green="#52c41a",t.volcano="#fa541c",t.lime="#389e0d",t.pink="#eb2f96",t.purple="#722ed1",t.darkPurple="#292F4C",t.gray="#8c8c8c"})(T||(T={}));var it=class{constructor(){this.colors=T,this.shapes={slider:new st}}},st=class{constructor(){}title(t=""){return q`
|
|
2
2
|
color: ${t};
|
|
3
3
|
border-left: 3px solid ${t};
|
|
4
4
|
padding: 2px;
|
|
5
5
|
font-weight: 600;
|
|
6
|
-
`}message(t=""){return
|
|
6
|
+
`}message(t=""){return q`
|
|
7
7
|
color: ${t};
|
|
8
|
-
`}message_button(t="#eee",e=
|
|
8
|
+
`}message_button(t="#eee",e=T.darkPurple,n="#fff"){return q`
|
|
9
9
|
background-color: ${e};
|
|
10
10
|
color: ${t};
|
|
11
11
|
padding: 2px 5px;
|
|
12
12
|
border-radius: 3px;
|
|
13
13
|
text-shadow: 0 0 2px ${n};
|
|
14
|
-
`}}
|
|
15
|
-
`,...e)},this.key=(t,...e)=>{let n=
|
|
14
|
+
`}},q=(t,...e)=>{if(e.length===0)return t[0];let n="";return e.forEach((o,i)=>{n+=t[i]+o}),n+=t[t.length-1],n},J;(function(t){t[t.title=1]="title",t[t.message=2]="message",t[t.message_button=3]="message_button"})(J||(J={}));var ie=({color:t},e=new st,n)=>{switch(n){case 1:return e.title(t);case 2:return e.message(t);case 3:return e.message_button();default:return""}},an=class{constructor(t){let e={log:window.console.log,enable:!0};this._option=sn(X({},e),{enable:typeof(t==null?void 0:t.enable)=="boolean"?t.enable:e.enable,log:(t==null?void 0:t.log)||e.log})}log(...t){let{enable:e,log:n}=this._option;e&&n&&n(...t)}set baseOption(t){this._option=t}get baseOption(){return this._option}setEnable(t){this._option.enable=!!t}},at=class{constructor(t){let e={enable:!0,log:window.console.log,level:39,shape:new it().shapes.slider};this.enable=t&&typeof t.enable=="boolean"?t.enable:e.enable,this.log=t&&t.log||e.log,this.level=t&&typeof t.level=="number"?t.level:e.level,this.shape=t&&t.shape?t.shape:e.shape}},ln=class extends an{constructor(t){super(t||new at);this.loggerOption=X(X({},new at),t)}setLoggerOption(t){let e=X(X({},this.loggerOption),t);this.loggerOption=e,super.baseOption={enable:e.enable,log:e.log}}getLoggerOption(){return this.loggerOption}setLevel(t){typeof t=="number"&&(this.loggerOption.level=t)}formatLog(t,e,n,o,i,...s){!this.loggerOption.level&&this.loggerOption.level!==0||this.loggerOption.level<t||super.log(`%c${e}%c${n}`,o,i,...s)}},lt;(function(t){t[t.log=0]="log",t[t.version=0]="version",t[t.error=0]="error",t[t.key=0]="key",t[t.warn=1]="warn",t[t.interval=1]="interval",t[t.service=2]="service",t[t.api=3]="api",t[t.http=3]="http",t[t.debug=3]="debug"})(lt||(lt={}));var H={debug:{name:"debug",title:" Debug :",color:T.lime,level:3},http:{name:"http",title:" Http :",color:T.weakBlue,level:3},api:{name:"api",title:" Api :",color:T.cyan,level:3},service:{name:"service",title:" Service :",color:T.purple,level:2},interval:{name:"interval",title:" Interval :",color:T.pink,level:1},warn:{name:"warn",title:" WARN :",color:T.orange,level:1},error:{name:"error",title:" ERR :",color:T.red,level:0},key:{name:"key",title:" Key :",color:T.darkPurple,level:0}},Ie=class extends ln{constructor(){super(...arguments);this.error=(t,...e)=>{this.formatShapeLog(H.error,`${t instanceof Error?t.stack:t}
|
|
15
|
+
`,...e)},this.key=(t,...e)=>{let n=H.key;this.formatLog(n.level,n.title,t.toUpperCase(),ie({color:n.color},this.getLoggerOption().shape,J.title),ie({},this.getLoggerOption().shape,J.message_button),...e)},this.version=(t="",e,...n)=>{this.formatLog(0,t.toUpperCase(),e,q`
|
|
16
16
|
background: linear-gradient(to right, #009fff, #ec2f4b);
|
|
17
17
|
color: white;
|
|
18
18
|
padding: 2px 5px;
|
|
19
19
|
border-top-left-radius: 3px;
|
|
20
20
|
border-bottom-left-radius: 3px;
|
|
21
|
-
|
|
22
|
-
background-color: ${
|
|
21
|
+
`,q`
|
|
22
|
+
background-color: ${T.darkPurple};
|
|
23
23
|
color: white;
|
|
24
24
|
padding: 2px 5px;
|
|
25
|
-
`,...n)}}formatLogWrapper(t,e,...n){!t||this.formatLog(t.level,t.title,e,q({color:t.color},this.getLoggerOption().shape,B.title),q({color:t.color},this.getLoggerOption().shape,B.message),...n)}debug(t,...e){this.formatLogWrapper(L.debug,t,...e)}http(t,...e){this.formatLogWrapper(L.http,t,...e)}api(t,...e){this.formatLogWrapper(L.api,t,...e)}service(t,...e){this.formatLogWrapper(L.service,t,...e)}interval(t,...e){this.formatLogWrapper(L.interval,t,...e)}warn(t,...e){this.formatLogWrapper(L.warn,t,...e)}},ce=new Pe,ft=new le,ht=ft,k=ht;var _e=class extends le{constructor(){super(...arguments);this.test=(e,...n)=>{let r=4;this.formatLog(r," Test ",e,ce.shapes.slider.title("#3f6600"),ce.shapes.slider.message("#999"),...n)}}},de=new _e;de.debug("player-core env:",u);de.version(u.SH_LIB_NAME,u.SH_LIB_VERSION||"");var s=de;var we=(t,e,n)=>{let r={value:e,expire:n},o=JSON.stringify(r);return localStorage.setItem(t,o),r},bt=(t,e,n)=>{let o=ae.getUTCSecond()+n;return we(t,e,o)},yt=(t,e=!1)=>{let n=localStorage.getItem(t);if(!n)return null;try{let r=JSON.parse(n);return e?r:r.expire?ae.compare(r.expire)?r.value:null:r.value}catch(r){s.error(r,n,"Storage\u8BFB\u53D6\u6570\u636E\u65F6\uFF0C JSON\u89E3\u6790\u51FA\u9519")}},vt=t=>localStorage.removeItem(t),It={set:we,setTimeout:bt,get:yt,remove:vt},T=It;var z;(function(n){n.GET="GET",n.POST="POST"})(z||(z={}));var Fe=(t,e)=>a(void 0,null,function*(){let n=new AbortController;if(e.signal&&e.signal.addEventListener("abort",()=>{n.abort()}),e.timeout){let l=setTimeout(()=>{n.abort()},e.timeout);n.signal.addEventListener("abort",()=>{clearTimeout(l)})}let r=e.bodyData,o=r&&(typeof r=="object"?JSON.stringify(r):r),i={credentials:"same-origin",method:e.method,headers:new Headers(O({},e.headers)),signal:n.signal};o&&(i.body=o),s.http("\u53D1\u9001\u8BF7\u6C42\uFF1A",t,V(O({},i),{body:r}));try{let l=yield fetch(t,i);if(s.http("\u8BF7\u6C42\u54CD\u5E94\uFF1A",t,l,yield l.clone().text()),l.ok||l.status>=200&&l.status<300){let g=l.headers.get("content-type")||"";if(/application\/json/i.test(g))return yield l.json()}else throw new Error(`${l.status} ${l.statusText}`)}catch(l){if(l.name==="AbortError"){s.http("\u8BF7\u6C42\u53D6\u6D88\uFF1A",i);return}throw l}}),Pt=(t,e,n)=>a(void 0,null,function*(){let r=e?e.toString():"";return yield Fe(t+r,{method:z.GET,headers:n==null?void 0:n.headers})}),Ct=(t,e,n)=>a(void 0,null,function*(){return yield Fe(t,{method:z.POST,headers:O({"Content-Type":"application/json;charset=UTF-8"},n==null?void 0:n.headers),bodyData:e})}),xt={get:Pt,post:Ct},J=xt;function Se(t){return t!==t}function Et(t,e=[]){let n=-1,r=t.length;for(e||(e=Array(r));++n<r;)e[n]=t[n];return e}function _t(t,e,n){let r=n-1,o=t.length;for(;++r<o;)if(t[r]===e)return r;return-1}function wt(t,e,n,r=!1){let o=t.length,i=n+(r?1:-1);for(;r?i--:++i<o;)if(e(t[i],i,t))return i;return-1}function Ft(t,e,n){return e===e?_t(t,e,n):wt(t,Se,n)}function St(t,e){let n=-1,r=e.length,o=t;for(t===e&&(e=Et(e));++n<r;){let i=0,l=e[n],g=l;for(;(i=Ft(o,g,i))>-1;)o!==t&&[].splice.call(o,i,1),[].splice.call(t,i,1)}return t}var Rt=(t,e)=>!t||!t.length||!e||!e.length?t:St(t,e),Ot={pullAll:Rt,baseIsNaN:Se},Re=Ot;var Oe={BVCSP_V1:{path:"/bvcsp/v1",prefix:""}},pe=t=>{let e=Oe[t];return e.prefix+e.path},kt=(t,e)=>{let n=Oe[t];return n.prefix=e||"",pe(t)},U={setApiPrefix:kt,getApiURL:pe,bvscpV1:()=>pe("BVCSP_V1")},K=t=>{U.setApiPrefix("BVCSP_V1",t)};var Tt=t=>{if(!t)return null;if(t.nodeType===Node.DOCUMENT_NODE)return t.documentElement;if(t.nodeType===Node.ELEMENT_NODE){let e=t;return e.hasChildNodes()&&e.childNodes.forEach(n=>{let r=n;r.className&&new RegExp(".*bvplayer-core-player.*").test(r.className)&&e.removeChild(r)}),t}return null},Dt=(t,e,n)=>{if(!t)return;let r=document.createDocumentFragment();r.appendChild(t);let o=Tt(e);!o||(o.appendChild(r),n==null||n())},ke=Dt;var Te=(...t)=>{let e=[];for(let n=0;n<t.length;n++){let r=t[n];if(!r)continue;let o=typeof r;if(o==="string"||o==="number")e.push(r);else if(Array.isArray(r)){if(r.length){let i=Te(...r);i&&e.push(i)}}else if(o==="object")if(r.toString==={}.toString)for(let i in r)({}).hasOwnProperty.call(r,i)&&r[i]&&e.push(i);else e.push(r.toString())}return e.join(" ")},X=Te;var Mt={render:ke,cls:X},De=u.SH_CSS_CLASS_PREFIX,Me=u.SH_STORAGE_FIELD_PREFIX,I=Mt;var W=`${Me}DialogIds`,Lt=(t,e)=>a(void 0,null,function*(){var l;let n={Authorization:e||""},r={id:t.id,index:t.index,sdp:t.sdp},o=yield J.post(`${U.bvscpV1()}/dialog/device/webrtc`,r,{headers:n});if(s.api("\u8BBE\u5907\u97F3\u89C6\u9891\u6D41 webrtc\u65B9\u5F0F\u6253\u5F00dialog: ",{params:r,resData:o}),!o||o.code!==0||!((l=o.data)==null?void 0:l.dialogid))throw new Error(`\u6253\u5F00\u4F20\u8F93\u901A\u9053\u5931\u8D25\uFF0C ${o.msg}`);let{data:i}=o;if(i.dialogid){let g=T.get(W)||[];g.push(i.dialogid),T.set(W,g)}return{dialogId:i.dialogid,sdp:i.sdp}}),Wt=(t,e)=>a(void 0,null,function*(){var g;let n={Authorization:e||""},r={id:t.id,index:t.index,sdp:t.sdp},o=yield J.post(`${U.bvscpV1()}/dialog/conference/webrtc`,r,{headers:n});if(s.api("\u4F1A\u8BAE\u97F3\u89C6\u9891\u6D41 webrtc\u65B9\u5F0F\u6253\u5F00dialog: ",{params:r,resData:o}),!o||o.code!==0||!((g=o.data)==null?void 0:g.dialogid))throw new Error(`\u6253\u5F00\u4F20\u8F93\u901A\u9053\u5931\u8D25\uFF0C ${o==null?void 0:o.msg}`);let{data:i}=o,l=T.get(W)||[];return l.push(i.dialogid),T.set(W,l),{dialogId:i.dialogid,sdp:i.sdp}}),At=(t,e)=>a(void 0,null,function*(){if(!t)return;let n={Authorization:e||""};return s.api("\u5173\u95EDdialog\uFF1A",t),yield J.post(`${U.bvscpV1()}/dialog/close/${t}`,{},{headers:n})}),Le=(t,e)=>a(void 0,null,function*(){let n=T.get(W)||[];Re.pullAll(n,t),T.set(W,n,0);let o=(yield Promise.allSettled(t.map(i=>At(i,e)))).filter(i=>i.status==="rejected");o&&o.length>0&&s.error(new Error(`"\u5173\u95ED\u5B58\u50A8\u7684dialog\u65F6\u5931\u8D25\uFF1A", ${o}`))}),Vt=t=>a(void 0,null,function*(){let e=T.get(W);!e||e.length<1||(T.remove(W),yield Le(e,t))}),Nt={getDeviceWebrtc:Lt,getConferenceWebrtc:Wt,closeDialogs:Le,closeAllStorageDialog:Vt},F=Nt;var We=class{constructor(){this._map=new Map}findExecutor(e,n){let r=this._map.get(e);return{index:r?r.findIndex(i=>Object.is(n,i)):-1,que:r}}publish(e,n){let r=this._map.get(e)||[],o=r.length;for(let i=0;i<o;i++){let l=r[i];l&&l(n)}}subscribe(e,n){let{index:r,que:o=[]}=this.findExecutor(e,n);return r>=0?o[r]=n:o.push(n),this._map.set(e,o),{unSubscribe:()=>{this.unSubscribe(e,n)}}}unSubscribe(e,n){let{index:r,que:o=[]}=this.findExecutor(e,n);r<0||(o.splice(r,1),this._map.set(e,o))}},G=class{constructor(){this._notifier=new We}addEventListener(e,n){this._notifier.subscribe(e,n)}removeEventListener(e,n){this._notifier.unSubscribe(e,n)}dispatch(e,n){this._notifier.publish(e,n)}};var D=class extends G{constructor(e,n){super();let r=document.createElement(e);r.className=De+n.trim(),this.el=r}unmount(){var e,n,r,o;return s.debug("unmount",this.el,(e=this.el)==null?void 0:e.parentNode),(r=(n=this.el)==null?void 0:n.parentNode)==null||r.removeChild(this.el),(o=this.el)==null?void 0:o.parentNode}destroy(){this.beforeDestroy(),this.unmount(),s.debug("destroy",this.el),this.el=null,this.dispatch("destroy")}getEl(){return this.el}};var Ae=class extends D{constructor(e){super("div",I.cls("mask"));this._visible=!!(e==null?void 0:e.visible),this._text=e==null?void 0:e.text,this._textEl=document.createElement("span"),this._textEl.className=X("text")}set visible(e){this._visible=e,this.el.style.display=this._visible?"grid":"none"}set text(e){this._text=e,this._textEl.textContent=e}beforeDestroy(){}init(){s.debug("mask visible: ",this._visible);let e=this.el;e.style.display=this._visible?"block":"none";let n=document.createDocumentFragment();return this._textEl.textContent=this._text||"",n.appendChild(this._textEl),e.appendChild(n),e}},Ve=Ae;var Ne=class extends D{constructor(e){super("div",I.cls("spinner"));this._spin=!!(e==null?void 0:e.spin)}set spin(e){this._spin=e,this.el.style.display=this._spin?"block":"none"}beforeDestroy(){}init(){s.debug("spinner spin: ",this._spin);let e=this.el;e.style.display=this._spin?"block":"none";let n=document.createDocumentFragment(),r=document.createElement("span");return r.style.backgroundColor="#FFF",n.appendChild(r),e.appendChild(n),e}},Be=Ne;var He={contain:"contain",fill:"fill"},je=class extends D{constructor(e){super("video",I.cls("video"));this._url=e==null?void 0:e.url,this._srcObject=(e==null?void 0:e.srcObject)||null,this._fit=(e==null?void 0:e.fit)||He.contain,this._autoPlay=!!(e==null?void 0:e.autoPlay),this._muted=!!(e==null?void 0:e.muted)}set url(e){typeof this._url!="undefined"&&(this.el.src=this._url),this._url=e}set srcObject(e){this._srcObject=e||null,this.el.srcObject=this._srcObject}set muted(e){if(e===this._muted)return;let n=this.el;this._muted=e,n.muted=e}set autoPlay(e){if(!e!==this._autoPlay)return;this._autoPlay=e,this.muted=e;let n=this.el;n.autoplay=this._autoPlay}set fit(e){this._fit=He[e],this.el.style.objectFit=this._fit}getVideoFit(){return this._fit}init(){s.debug("\u6E32\u67D3VideoPlugin\u89C6\u9891\u5BF9\u8C61",this,this.el);let e=this.el;return typeof this._url!="undefined"&&(e.src=this._url),e.srcObject=this._srcObject,e.autoplay=this._autoPlay,e.muted=this._muted,e.style.objectFit=this._fit,e.playsInline=!0,e}play(){return a(this,null,function*(){let e=this.el;try{s.debug("video \u5C1D\u8BD5\u64AD\u653E"),yield e.play()}catch(n){s.error(n,"video \u64AD\u653E \u5931\u8D25")}})}beforeDestroy(){}},$e=je;var Bt=(t,e)=>{k.debug(`webrtc my ICE candidate:
|
|
26
|
-
${e.candidate?e.candidate.candidate:"(null)"}`)},Ht=(t,e,n)=>{k.debug("webrtc ICE state change event: ",e),k.debug(`webrtc my ICE state: ${t==null?void 0:t.iceConnectionState}`),t&&t.iceConnectionState==="disconnected"&&n&&n()},jt=(t,e)=>{k.debug("webrtc Connection state change, \u5F53\u524D\u8FDE\u63A5\u72B6\u6001: ",t,t.connectionState)},$t=(t,e,n)=>{k.debug("webrtc \u5F53\u524D\u7684 stream: ",e.streams[0]);let r=e.streams[0];n(r)},Ut=(t,e)=>a(void 0,null,function*(){let{offerParam:n,productRemoteSdp:r,customerRTCPeerConnection:o,onConnected:i,onConnectedFailed:l,onIceDisconnected:g,onPcEventAdded:f,onLocalDescriptionReady:b}=t,C=!!o&&o instanceof RTCPeerConnection,y={},m=C?o:new RTCPeerConnection(y);if(m.addEventListener("icecandidate",d=>Bt(m,d)),m.addEventListener("iceconnectionstatechange",d=>Ht(m,d,g)),m.addEventListener("connectionstatechange",d=>jt(m,d)),m.addEventListener("track",d=>$t(m,d,e)),f&&(yield f(m)),C)return{pc:m};try{let d=yield m.createOffer(n);k.debug("\u521B\u5EFAoffer\uFF0C\u53C2\u6570\uFF1A",n,"\uFF0C \u7ED3\u679C\uFF1A",d),yield m.setLocalDescription(d),b&&b(m);let h=yield r(new RTCSessionDescription(d));k.debug("webrtc recv open answer",h);let w=new RTCSessionDescription({type:"answer",sdp:h});yield m.setRemoteDescription(w),k.debug("getTransceivers",m.getTransceivers()),i&&i(m)}catch(d){throw l&&l(m),k.error(new Error(`webrtc Failed to create session description: ${d.toString()}`)),m.close(),d}return{pc:m}}),Kt=t=>{if(!t)return;let{pc:e}=t;e.close()},Gt={connect:Ut,disconnect:Kt},ue=Gt;var S;(function(r){r.DIRECT="direct",r.PLUGIN="plugin",r.REJECT="reject"})(S||(S={}));var Q;(function(i){i.MP4="mp4",i.FLAC="flac",i.OGG="Ogg",i.WEBM="webm",i.AUTO="auto"})(Q||(Q={}));var me;(function(e){e.WEBRTC="webrtc"})(me||(me={}));var Ue;(function(n){n[n.DIRECT_SUPORT_TYPES=0]="DIRECT_SUPORT_TYPES",n[n.PLUGIN_SUPORT_TYPES=1]="PLUGIN_SUPORT_TYPES"})(Ue||(Ue={}));var Ke=class extends D{constructor(e){super("div",I.cls("player"));this._video=new $e,this._spinner=new Be({spin:!1}),this._mask=new Ve({visible:!1}),this._videoOption=e==null?void 0:e.video,this._pluginOption=e==null?void 0:e.pluginOption,this._playerConfig=e==null?void 0:e.playerConfig,this._mode=this._restrictPlayerMode(e==null?void 0:e.video,e==null?void 0:e.pluginOption)}justifyVideoType(e,n){return(e==null?void 0:e.url)&&!e.type?Q.AUTO:(e==null?void 0:e.type)||Object.keys(n||{})[0]}_restrictPlayerMode(e,n){let r=this.justifyVideoType(e,n);if(!r&&!(e==null?void 0:e.url))return S.REJECT;if(!r)return S.DIRECT;let o=Object.values(Q),i=Object.values(me);return o.includes(r)?S.DIRECT:i.includes(r)?S.PLUGIN:S.DIRECT}init(){var i;s.debug("\u6E32\u67D3PlayerPlugin",this.el),this.prepare();let e=document.createDocumentFragment(),n=this._video.init(),r=this._spinner.init(),o=this._mask.init();return e.appendChild(n),e.appendChild(r),e.appendChild(o),(i=this.el)==null||i.appendChild(e),this.dispatch("init",{mode:this._mode}),this.el}get video(){return this._video}get spinner(){return this._spinner}get mask(){return this._mask}play(e){return a(this,null,function*(){this.mute(!0),yield this._video.play(),this.mute(e)})}mute(e){var n;this._video.muted=!!e,s.debug("player mute: ",(n=this._video.getEl())==null?void 0:n.muted)}setProductRemoteSdp(e){!this._pluginOption||!this._pluginOption.webrtc||(this._pluginOption.webrtc.productRemoteSdp=e)}prepareWebrtc(){return a(this,null,function*(){var n;if(this._mode!==S.PLUGIN)return;s.debug("PuPlayer Plugin prepareWebrtc");let e=(n=this._pluginOption)==null?void 0:n.webrtc;!e||(this._video.autoPlay=!0,this._spinner.spin=!0,this._webrtcConnect=yield ue.connect(e,r=>{var i;if(!r)return;(i=this.video.getEl())==null||i.addEventListener("canplay",()=>{console.log("Video canplay"),this.video.play()}),this._video.srcObject=r;let o=r.getTracks()[0];o.onended=l=>{console.log("\u6D41\u89C6\u9891\u8F68\u9053\u5DF2\u7ECF\u7EC8\u6B62",l)},o.onmute=l=>{console.log("\u6D41\u89C6\u9891\u8F68\u9053\u6682\u65F6\u65E0\u6CD5\u63D0\u4F9B\u5A92\u4F53",l),this.onMuted()},o.onunmute=l=>{console.log("\u6D41\u89C6\u9891\u8F68\u9053\u63D0\u4F9B\u5A92\u4F53",l),this.onUnMuted()}}))})}close(){this.closeWebrtc()}beforeDestroy(){this.close()}onMuted(){}onUnMuted(){}loadPlayerConfig(){var e,n,r;this.video.autoPlay=!!((e=this._playerConfig)==null?void 0:e.autoPlay),(n=this.video.getEl())==null||n.addEventListener("canplay",()=>{console.log("Video canplay"),this._spinner.spin=!1,this._mask.visible=!1}),(r=this.video.getEl())==null||r.addEventListener("waiting",()=>{console.log("Video is waiting for more data."),this._spinner.spin=!0})}prepare(){if(s.debug("PlayerPlugin mode: ",this._mode),this.loadPlayerConfig(),this._mode===S.REJECT){s.error(new Error("\u4E0D\u652F\u6301\u7684\u89C6\u9891\u7C7B\u578B"),this._mode,this._videoOption);return}if(this._mode===S.DIRECT){this.prepareDirect();return}if(this._mode===S.PLUGIN){switch(this.justifyVideoType(this._videoOption,this._pluginOption)){case"webrtc":break;default:break}return}}prepareDirect(){var e;this._video.url=((e=this._videoOption)==null?void 0:e.url)||"",setTimeout(()=>{this.play()},300)}closeWebrtc(){var e;ue.disconnect(this._webrtcConnect),this.dispatch("closeWebrtc",{peerConnection:(e=this._webrtcConnect)==null?void 0:e.pc}),this._webrtcConnect=null,this._video.srcObject=null}},Z=Ke;var H=document.documentElement,Y="requestFullscreen",ee="exitFullscreen",te="fullscreenElement",ne="onfullscreenchange";if("webkitRequestFullScreen"in H)Y="webkitRequestFullScreen",ee="webkitExitFullscreen",te="webkitFullscreenElement",ne="onwebkitfullscreenchange";else if("msRequestFullscreen"in H)Y="msRequestFullscreen",ee="msExitFullscreen",te="msFullscreenElement",ne="MSFullscreenChange";else if("mozRequestFullScreen"in H)Y="mozRequestFullScreen",ee="mozCancelFullScreen",te="mozFullScreenElement",ne="onmozfullscreenchange";else if(!("requestFullscreen"in H))throw"\u5F53\u524D\u6D4F\u89C8\u5668\u4E0D\u652F\u6301Fullscreen API !";function qt(t=H,e){return t[Y](e)}function zt(){return document[ee]()}function Ge(t){return t===document[te]}function Jt(t=H,e){return Ge(t)?zt():qt(t,e)}function Xt(t,e){let n=()=>{t.onfullscreenchange=null},r=o=>{o.target!==null&&e(Ge(o.target))};return t[ne]=r,{cancel:n}}var Qt={toggle:Jt,watch:Xt},qe=Qt;var Zt=(t,e,n)=>r=>a(void 0,null,function*(){if(r.type==="offer"){s.debug("\u8BF7\u6C42\u8FDC\u7AEFsdp\uFF0C \u8BBE\u5907\u914D\u7F6E\u4FE1\u606F\uFF1A",t,"token: ",e),s.debug("\u672C\u5730sdp",r);try{let{id:o,index:i}=t||{},l=yield F.getDeviceWebrtc({id:o,index:i,sdp:r.sdp},e);return n&&n(l.dialogId),l.sdp}catch(o){throw s.error(o,"\u8BF7\u6C42\u8FDC\u7AEFsdp\u65F6\u51FA\u9519"),new Error(`PUPlayer open \u5931\u8D25 , ${o.message}`)}}}),Yt=t=>{let{container:e,token:n,puOption:r,defaultMediaOption:o={audio:!0,video:!0},testUrl:i,videoFit:l="fill",muted:g,apiPrefix:f,onConnected:b,onConnectedFailed:C,onDisConnected:y,fullScreenOnDblclick:m=!0}=t||{},d,h=n,w=r,R=e,x=typeof g=="boolean"?g:!o.audio;K(f);let v=()=>a(void 0,null,function*(){if(!!d&&(s.debug("PuPlayer close",d),c.mask.visible=!0,c.mask.text="Video Closed",c.close(),d))try{yield F.closeDialogs([d],h)}catch(p){throw s.error(p,"PuPlayer close \u5931\u8D25"),new Error(`PuPlayer close \u5931\u8D25 , ${p.message}`)}}),c=new Z({video:{url:i},pluginOption:{webrtc:{offerParam:{offerToReceiveAudio:o.audio,offerToReceiveVideo:o.video},productRemoteSdp:p=>a(void 0,null,function*(){return Zt(w,h,A=>{d=A})(p)}),onIceDisconnected:()=>{c.mask.visible=!0,c.mask.text="lost connection",c.close(),y&&y()},onConnected:()=>{b&&b()},onConnectedFailed:()=>{C&&C()}}},playerConfig:{autoPlay:!0}});c.addEventListener("init",p=>{s.debug("\u76D1\u542C\u5230\u4E86 player\u5DF2\u7ECF\u521D\u59CB\u5316",p)}),c.mute(x),c.video.fit=l;let P=c.init();m&&(P==null||P.addEventListener("dblclick",()=>{s.debug("\u53CC\u51FBplayer\uFF1A",P),qe.toggle(P)}));let M={instance:{getVideoElement:()=>c.video.getEl(),getPlayerElement:()=>c.getEl(),open:(p=!1)=>a(void 0,null,function*(){s.debug("PuPlayer open"),yield v(),c.mask.visible=!1,c.mask.text="connecting",c.mute(!!p);try{yield c.prepareWebrtc()}catch(E){throw c.mask.visible=!0,c.mask.text="connect failed",E}if(typeof p=="boolean"&&p){let E=()=>{s.debug("\u76D1\u542C\u5230\u7528\u6237\u6709click tap\u4EA4\u4E92\uFF0C \u6539\u53D8\u9759\u97F3\uFF0C muted\uFF1A",x),s.debug("\u6B64\u90E8\u5206\u67E5\u770B\uFF1Ahttps://developers.google.com/web/updates/2017/09/autoplay-policy-changes"),c.mute(x),document.removeEventListener("click",E),document.removeEventListener("touchend",E)};document.addEventListener("click",E),document.addEventListener("touchend",E)}}),play:()=>a(void 0,null,function*(){yield c.play(x)}),mute:(p=!1)=>{x=p,c.mute(p)},hidden:p=>a(void 0,null,function*(){let E=P,A=c.video.getEl();E.style.display="none",document.body.appendChild(E),A.muted=!0;try{typeof p!="undefined"&&(x=p),yield c.play(x)}catch(pn){s.debug("player.play() \u64AD\u653E\u672A\u6210\u529F")}s.debug("\u6DFB\u52A0\u5230body\u5E76\u9690\u85CF\uFF0C \u8C03\u7528play\u540E\u7684\u6682\u505C\u72B6\u6001\uFF1A",A.paused)}),display:p=>a(void 0,null,function*(){let E=P,A=c.video.getEl();I.render(E,R,()=>a(void 0,null,function*(){E.style.display="block",typeof p!="undefined"&&(x=p),yield c.play(x)})),s.debug("\u663E\u793A\u5230\u5F53\u524D\u5BB9\u5668\uFF0C \u8C03\u7528play\u540E\u7684\u6682\u505C\u72B6\u6001\uFF1A",A.paused)}),moveTo:p=>{s.debug("\u79FB\u52A8\u81F3\uFF1A",p),R=p,I.render(P,R,()=>a(void 0,null,function*(){}))},getCurrentContainer:()=>R,setPuOption:p=>{w=p},setVideoFit:p=>{s.debug("PuPlayer setVideoFit",p),c.video.fit=p},setToken:p=>{s.debug("PuPlayer setToken",p),h=p},setApiPrefix:K,close:v,render:c.init,destroy:()=>a(void 0,null,function*(){s.debug("PuPlayer destroy"),yield v(),c.destroy()})},element:P};return R&&(I.render(P,R),M.element=null),M},en=Yt;var ge=class extends G{constructor(e,n){super();this._plugin=e,this._el=this._plugin.init(),this._currentContainer=n}moveTo(e,n){s.debug("\u79FB\u52A8\u81F3\uFF1A",e),this._currentContainer=e,I.render(this._el,this._currentContainer,n)}getCurrentContainer(){return this._currentContainer}render(){return this._plugin.init()}destroy(){s.debug("destroy",this._plugin),this._plugin.destroy(),this.dispatch("destroy")}};var re=class{constructor(e,n,r,o){this.token="";this.fetchSdpFunc=e,this.token=n||"",this.param=r,this.prefix=o}fetch(e){return a(this,null,function*(){s.debug("RemoteSdpFetcher fetch \u8BF7\u6C42\u8FDC\u7AEFsdp\uFF0C param\uFF1A",this.param,"token: ",this.token);let n=yield this.fetchSdpFunc(e,this.param,this.token,this.prefix),{sdp:r,dialogId:o}=n||{};return this.dialogId=o,s.debug(`RemoteSdpFetcher fetch \u83B7\u5F97\u7684remoteSdp ${r}, dialogId: ${o}`),r})}close(){return a(this,null,function*(){s.debug(`remoteSdpFetcher close\uFF0C \u68C0\u67E5dialogId: ${this.dialogId}`),this.dialogId&&(yield F.closeDialogs([this.dialogId]))})}},fe=class extends ge{constructor(e,n,r,o,i){super(e,i);this._muted=!1;this._videoFit="contain";this.setRemoteSdpFetcher(o),this.setVideoFit(n),this.setMuted(r)}get player(){return this._plugin}getPlayerElement(){return this.player.getEl()}getVideoElement(){return console.log(this._plugin),console.log(this.player),this.player.video.getEl()}setRemoteSdpFetcher(e){this._remoteSdpFetcher=e,this._plugin.setProductRemoteSdp(n=>a(this,null,function*(){var r;return(r=this._remoteSdpFetcher)==null?void 0:r.fetch(n)}))}getRemoteSdpFetcher(){return this._remoteSdpFetcher}setVideoFit(e){s.debug("BvWebrtcInstance setVideoFit",e),this._videoFit=e,this.player.video.fit=e}getVideoFit(){return this._videoFit}setMuted(e=!1){this._muted=e,this.player.mute(e)}getMuted(){return this._muted}mute(e=!1){return this.setMuted(e)}open(e=!1){return a(this,null,function*(){s.debug("PuPlayer open"),yield this.close(),this.player.mask.visible=!1,this.player.mask.text="connecting",this.player.mute(!!e);try{yield this.player.prepareWebrtc()}catch(n){throw this.player.mask.visible=!0,this.player.mask.text="connect failed",n}if(e){let n=()=>{s.debug("\u76D1\u542C\u5230\u7528\u6237\u6709click tap\u4EA4\u4E92\uFF0C \u6539\u53D8\u9759\u97F3\uFF0C muted\uFF1A",this._muted),s.debug("\u6B64\u90E8\u5206\u67E5\u770B\uFF1Ahttps://developers.google.com/web/updates/2017/09/autoplay-policy-changes"),this.player.mute(this._muted),document.removeEventListener("click",n),document.removeEventListener("touchend",n)};document.addEventListener("click",n),document.addEventListener("touchend",n)}})}play(){return a(this,null,function*(){yield this.player.play(this._muted)})}hidden(e){return a(this,null,function*(){let n=this._el,r=this.player.video.getEl();n.style.display="none",document.body.appendChild(n),r.muted=!0;try{typeof e!="undefined"&&(this._muted=e),yield this.player.play(this._muted)}catch(o){s.debug("player.play() \u64AD\u653E\u672A\u6210\u529F")}s.debug("\u6DFB\u52A0\u5230body\u5E76\u9690\u85CF\uFF0C \u8C03\u7528play\u540E\u7684\u6682\u505C\u72B6\u6001\uFF1A",r.paused)})}display(e){return a(this,null,function*(){let n=this._el,r=this.player.video.getEl();I.render(n,this._currentContainer,()=>a(this,null,function*(){n.style.display="block",typeof e!="undefined"&&(this._muted=e),yield this.player.play(this._muted)})),s.debug("\u663E\u793A\u5230\u5F53\u524D\u5BB9\u5668\uFF0C \u8C03\u7528play\u540E\u7684\u6682\u505C\u72B6\u6001\uFF1A",r.paused)})}close(){return a(this,null,function*(){if(s.debug("BvWebrtcInstance close",`_dialogId: ${this._dialogId}`),this.player.mask.visible=!0,this.player.mask.text="Video Closed",this.player.close(),s.debug("BvWebrtcInstance close\uFF0C player closed\uFF0C\u68C0\u67E5 remoteSdpFetcher: ",this._remoteSdpFetcher),this.dispatch("close"),this._remoteSdpFetcher)try{yield this._remoteSdpFetcher.close()}catch(e){throw s.error(e,"BvWebrtcInstance close \u5931\u8D25"),new Error(`BvWebrtcInstance close \u5931\u8D25 , ${e.message}`)}})}destroy(){s.debug("PuPlayer destroy"),this.close(),this.player.destroy()}};var tn=t=>{let{container:e,sdpFetcher:n,offerParam:r,videoFit:o,muted:i,autoPlay:l,onConnected:g,onClose:f,onDestroy:b,onConnectedFailed:C,onDisConnected:y,onPcEventAdded:m}=t,d=new Z({pluginOption:{webrtc:{offerParam:r,productRemoteSdp:()=>a(void 0,null,function*(){return""}),onIceDisconnected:()=>{d.mask.visible=!0,d.mask.text="lost connection",d.close(),y&&y()},onPcEventAdded:m,onConnected:()=>{d.mask.visible=!1,d.mask.text="connected",g&&g()},onConnectedFailed:()=>{C&&C()}}},playerConfig:{autoPlay:l}}),h=new fe(d,o,i,n,e);h.addEventListener("close",()=>{f&&f()}),h.addEventListener("destroy",()=>{b&&b()});let w={open:()=>a(void 0,null,function*(){s.debug("BvWebrtc open"),yield h.open()}),setOption:v=>{s.debug("BvWebrtc setOption");let c=h.getRemoteSdpFetcher();c&&(c.param=v)},setToken:v=>{s.debug("BvWebrtc setToken",v);let c=h.getRemoteSdpFetcher();c&&(c.token=v)},setApiPrefix:v=>{s.debug("BvWebrtc setApiPrefix",v);let c=h.getRemoteSdpFetcher();c&&(c.prefix=v)},getRemoteSdpFetcher:()=>h.getRemoteSdpFetcher(),close:()=>a(void 0,null,function*(){s.debug("BvWebrtc close"),yield h.close()}),render:()=>(s.debug("BvWebrtc render"),h.render()),destroy:()=>{s.debug("BvWebrtc destroy"),h.destroy()}},R=h.render(),x={instance:w,element:R};return e&&(I.render(R,e),x.element=null),x},ze=tn;var nn=()=>a(void 0,null,function*(){s.debug("\u8BF7\u6C42\u9EA6\u514B\u98CE...");let t=yield navigator.mediaDevices.getUserMedia({audio:!0,video:!1}),e=t.getAudioTracks();return s.debug("\u9EA6\u514B\u98CE \u97F3\u9891\u8F68\u9053\uFF1A",e),t}),rn=t=>{let{container:e,token:n,getRemoteSdpParam:r,apiPrefix:o,getRemoteSdpResult:i,onConnected:l,onClose:g,onDestroy:f,onConnectedFailed:b,onDisConnected:C,onGetUserMediaFailed:y}=t||{},m=(v,c,P,ie)=>a(void 0,null,function*(){if(s.debug("audioPlayer productRemoteSdp",{param:{localDescription:v,param:c,token:P,prefix:ie}}),v.type==="offer"&&(K(ie),s.debug("\u672C\u5730sdp",v),!!i))try{let{sdp:M,dialogId:p}=yield i(v.sdp,P,c);return{sdp:M,dialogId:p}}catch(M){throw s.error(M,"\u8BF7\u6C42\u8FDC\u7AEFsdp\u65F6\u51FA\u9519"),new Error(`productRemoteSdp \u5931\u8D25 , ${M.message}`)}}),d=new re(m,n,r,o),{instance:h,element:w}=ze({container:e,sdpFetcher:d,offerParam:{offerToReceiveAudio:!0},videoFit:"contain",muted:!1,autoPlay:!0,onConnected:l,onClose:g,onDestroy:f,onConnectedFailed:b,onDisConnected:C,onPcEventAdded:v=>a(void 0,null,function*(){try{let c=yield nn();c.getTracks().forEach(P=>v.addTrack(P,c))}catch(c){y&&y()}})});return{instance:O({},h),element:w}},oe=rn;var on=(t,e,n)=>a(void 0,null,function*(){let{id:r,index:o}=n||{};return yield F.getDeviceWebrtc({id:r,index:o,sdp:t},e)}),sn=t=>{let{container:e,token:n,puOption:r,apiPrefix:o,onConnected:i,onClose:l,onDestroy:g,onConnectedFailed:f,onDisConnected:b,onGetUserMediaFailed:C}=t||{},{instance:y,element:m}=oe({container:e,token:n,getRemoteSdpParam:r,getRemoteSdpResult:on,apiPrefix:o,onConnected:i,onClose:l,onDestroy:g,onConnectedFailed:f,onDisConnected:b,onGetUserMediaFailed:C}),d=V(O({},y),{setPuOption:w=>y.setOption&&y.setOption(w)});return delete d.setOption,{instance:d,element:m}},an=sn;var ln=(t,e,n)=>a(void 0,null,function*(){let{id:r,index:o}=n||{};return yield F.getConferenceWebrtc({id:r,index:o,sdp:t},e)}),cn=t=>{let{container:e,token:n,confOption:r,apiPrefix:o,onConnected:i,onClose:l,onDestroy:g,onConnectedFailed:f,onDisConnected:b,onGetUserMediaFailed:C}=t||{},{instance:y,element:m}=oe({container:e,token:n,getRemoteSdpParam:r,getRemoteSdpResult:ln,apiPrefix:o,onConnected:i,onClose:l,onDestroy:g,onConnectedFailed:f,onDisConnected:b,onGetUserMediaFailed:C}),d=V(O({},y),{setConfOption:w=>y.setOption&&y.setOption(w)});return delete d.setOption,{instance:d,element:m}},dn=cn;var ho=F.closeAllStorageDialog;export{dn as Conference,an as Intercom,en as PuPlayer,re as RemoteSdpFetcher,ho as clearAllDialog};
|
|
25
|
+
`,...n)}}formatShapeLog({level:t,title:e,color:n},o,...i){this.formatLog(t,e,o,ie({color:n},this.getLoggerOption().shape,J.title),ie({color:n},this.getLoggerOption().shape,J.message),...i)}debug(t,...e){this.formatShapeLog(H.debug,t,...e)}http(t,...e){this.formatShapeLog(H.http,t,...e)}api(t,...e){this.formatShapeLog(H.api,t,...e)}service(t,...e){this.formatShapeLog(H.service,t,...e)}interval(t,...e){this.formatShapeLog(H.interval,t,...e)}warn(t,...e){this.formatShapeLog(H.warn,t,...e)}},rr=new it,cn=new Ie,dn=cn,V=dn;var ct=class extends Ie{constructor(){super(...arguments);this.test=(e,...n)=>{let o=4;this.formatShapeLog({level:o,title:" Test ",color:"#3f6600"},e,...n)};this.libWarn=(e,...n)=>{this.warn("bvplayer-core ",e,...n),console.warn(new Error().stack)};this.libError=(e,...n)=>{this.error(new Error(`bvplayer-core ${e}`),...n)}}},Ce=new ct;Ce.debug("player-core env:",d);Ce.version(d.SH_LIB_NAME,d.SH_LIB_VERSION||"");var a=Ce;var un=Array.isArray,pn=t=>t!==t,dt=t=>typeof t=="number",ut=t=>typeof t=="string",mn=t=>dt(t)||ut(t),fn=t=>typeof t=="function",gn=t=>typeof t=="undefined",hn=t=>t?!1:!!(t!=null?t:!0),vn={isArr:un,baseIsNaN:pn,isString:ut,isNumber:dt,isText:mn,isFn:fn,isUndefined:gn,isNullOrUndefined:hn},L=vn;function yn(t,e=[]){let n=-1,o=t.length;for(e||(e=Array(o));++n<o;)e[n]=t[n];return e}function bn(t,e,n){let o=n-1,i=t.length;for(;++o<i;)if(t[o]===e)return o;return-1}function In(t,e,n,o=!1){let i=t.length,s=n+(o?1:-1);for(;o?s--:++s<i;)if(e(t[s],s,t))return s;return-1}function Cn(t,e,n){return e===e?bn(t,e,n):In(t,L.baseIsNaN,n)}function Pn(t,e){let n=-1,o=e.length,i=t;for(t===e&&(e=yn(e));++n<o;){let s=0,c=e[n],m=c;for(;(s=Cn(i,m,s))>-1;)i!==t&&[].splice.call(i,s,1),[].splice.call(t,s,1)}return t}var wn=t=>t?L.isArr(t)?t:[t]:[],En=(t,e)=>!t||!t.length||!e||!e.length?t:Pn(t,e),_n=(t,e="")=>{let n=document.createElement("canvas");n.width=t.videoWidth,n.height=t.videoHeight,n.getContext("2d").drawImage(t,0,0,n.width,n.height),n.toBlob(o=>{if(!o){a.libError("util screenshot canvas\u7684\u8F93\u51FA\u4E3A\u7A7A\u503C");return}let i=URL.createObjectURL(o),s=document.createElement("a");s.href=i,s.download=`${e}.png`,s.style.display="none",document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(i)})},Sn=(t,e,n)=>Math.max(Math.min(t,n),e),xn={pullAll:En,toArray:wn,screenshot:_n,restrict:Sn},D=xn;function Tn(t){return t!=null&&t!==!0&&t!==!1}function pt(t,e=[]){return t.forEach(n=>{L.isArr(n)?pt(n,e):Tn(n)&&e.push(L.isText(n)?Rn(n):n)}),e}function Mn(t={},e){if(!e)return;Object.keys(t).forEach(o=>{if(o==="children")return;let i=t[o];L.isNullOrUndefined(i)||(o.startsWith("on")?e.addEventListener(o.substring(2).toLowerCase(),i):e instanceof Element?e.setAttribute(o==="className"?"class":o,i):e[o]=i)})}function Rn(t){return{type:"",props:{nodeValue:String(t)+""}}}function Ln(t,e){return t===""?document.createTextNode(""):e?document.createElementNS(e,t):document.createElement(t)}function Q(t,e,n){let o=e?e(t):t;if(!o)return null;if(L.isArr(o)){let c=document.createDocumentFragment();return o.forEach(m=>{let l=Q(m,e);l&&c.appendChild(l)}),c}let{props:i,type:s}=o;if(!i)return o instanceof Node||o instanceof Text?(a.libWarn("jsx grow","\u63D0\u793A",o,"\u5E76\u4E0D\u662F\u6709\u6548\u7684jsx element \u5DF2\u7ECF\u539F\u6837\u8F93\u51FA\uFF0C\u4E0D\u5F71\u54CDui \u4F46\u5C3D\u91CF\u5C11\u6DF7\u7528jsx\u548Cdom"),o):(a.libWarn("jsx grow","\u672A\u89E3\u6790",o,"\u56E0\u4E3A\u5B83\u4E0D\u662F\u6709\u6548\u7684jsx element\uFF0C\u5E76\u4E14\u4E5F\u4E0D\u662FRenderTarget\u7C7B\u578B"),null);if(L.isString(s)){let c=Ln(s,i.xmlns||n);return Mn(i,c),(i.children||[]).forEach(l=>{let g=Q(l,e,i.xmlns);!g||c.appendChild(g)}),c}if(L.isFn(s)){let c=s(i);return Q(c,e)}return null}function kn(t,e,...n){return e=e||{},n=pt(D.toArray(e.children||n)),e.children=n,{type:t,props:e}}var Fn=t=>t.children,Nn={h:kn,Fragment:Fn},r=Nn;var Pe=t=>{let e;return t?e=Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate(),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds(),t.getUTCMilliseconds()):e=Date.now(),Math.floor(e/1e3)},mt=t=>{let e=typeof t=="number"?t:Pe(t),n=Pe();return e-n},On=t=>mt(t)>0,Vn={getUTCSecond:Pe,pastNow:mt,compare:On},we=Vn;var ft=(t,e,n)=>{let o={value:e,expire:n},i=JSON.stringify(o);return localStorage.setItem(t,i),o},Dn=(t,e,n)=>{let i=we.getUTCSecond()+n;return ft(t,e,i)},Bn=(t,e=!1)=>{let n=localStorage.getItem(t);if(!n)return null;try{let o=JSON.parse(n);return e?o:o.expire?we.compare(o.expire)?o.value:null:o.value}catch(o){a.error(o,n,"Storage\u8BFB\u53D6\u6570\u636E\u65F6\uFF0C JSON\u89E3\u6790\u51FA\u9519")}},An=t=>localStorage.removeItem(t),Hn={set:ft,setTimeout:Dn,get:Bn,remove:An},B=Hn;var se;(function(n){n.GET="GET",n.POST="POST"})(se||(se={}));var gt=(t,e)=>p(void 0,null,function*(){let n=new AbortController;if(e.signal&&e.signal.addEventListener("abort",()=>{n.abort()}),e.timeout){let c=setTimeout(()=>{n.abort()},e.timeout);n.signal.addEventListener("abort",()=>{clearTimeout(c)})}let o=e.bodyData,i=o&&(typeof o=="object"?JSON.stringify(o):o),s={credentials:"same-origin",method:e.method,headers:new Headers(R({},e.headers)),signal:n.signal};i&&(s.body=i),a.http("\u53D1\u9001\u8BF7\u6C42\uFF1A",t,U(R({},s),{body:o}));try{let c=yield fetch(t,s);if(a.http("\u8BF7\u6C42\u54CD\u5E94\uFF1A",t,c,yield c.clone().text()),c.ok||c.status>=200&&c.status<300){let m=c.headers.get("content-type")||"";if(/application\/json/i.test(m))return yield c.json()}else throw new Error(`${c.status} ${c.statusText}`)}catch(c){if(c.name==="AbortError"){a.http("\u8BF7\u6C42\u53D6\u6D88\uFF1A",s);return}throw c}}),Wn=(t,e,n)=>p(void 0,null,function*(){let o=e?e.toString():"";return yield gt(t+o,{method:se.GET,headers:n==null?void 0:n.headers})}),$n=(t,e,n)=>p(void 0,null,function*(){return yield gt(t,{method:se.POST,headers:R({"Content-Type":"application/json;charset=UTF-8"},n==null?void 0:n.headers),bodyData:e})}),zn={get:Wn,post:$n},ae=zn;var ht={BVCSP_V1:{path:"/bvcsp/v1",prefix:""}},Ee=t=>{let e=ht[t];return e.prefix+e.path},Un=(t,e)=>{let n=ht[t];return n.prefix=e||"",Ee(t)},Z={setApiPrefix:Un,getApiURL:Ee,bvscpV1:()=>Ee("BVCSP_V1")},Y=t=>{Z.setApiPrefix("BVCSP_V1",t)};var Jn=t=>{if(!t)return null;if(t.nodeType===Node.DOCUMENT_NODE)return t.documentElement;if(t.nodeType===Node.ELEMENT_NODE){let e=t;return e.hasChildNodes()&&e.childNodes.forEach(n=>{let o=n;o.className&&new RegExp(".*bvplayer-core-player.*").test(o.className)&&e.removeChild(o)}),t}return null},Kn=(t,e,n)=>{if(!t)return;let o=document.createDocumentFragment();o.appendChild(t);let i=Jn(e);!i||(i.appendChild(o),n==null||n())},vt=Kn;var le=(...t)=>{let e=[];for(let n=0;n<t.length;n++){let o=t[n];if(!o)continue;let i=typeof o;if(L.isText(o))e.push(o);else if(Array.isArray(o)){if(o.length){let s=le(...o);s&&e.push(s)}}else if(i==="object")if(o.toString==={}.toString)for(let s in o)({}).hasOwnProperty.call(o,s)&&o[s]&&e.push(s);else e.push(o.toString())}return e.join(" ")},yt=t=>t?t.replace(/\s*(;|\{|\})+\s*[\n\r]*/g,"$1"):"",Gn=(t,...e)=>{if(!e.length)return yt(t[0]);let n="";return e.forEach((o,i)=>{n+=t[i]+o}),n+=t[t.length-1],yt(n)},_e="bvplayer-",Xn="common-",bt=t=>new RegExp(_e).test(t),qn=(...t)=>le(t).split(" ").map(e=>bt(e)?e:_e+e).join(" "),Qn=(...t)=>le(t).split(" ").map(e=>bt(e)?e:_e+Xn+e).join(" ");var Zn={cls:le,css:Gn,prefixCls:qn,commonCls:Qn},j=Zn;function Yn(t){return document.createRange().createContextualFragment(t)}function jn(t,e){let n=document.createElement(t);return e&&(n.className=e),n}function Se(){return document.createDocumentFragment()}function eo(t,e){let n=document.createElement(t);return e&&(n.className=e),n}function to(t,...e){if(!t)return;let n=Se();n.append(...e.filter(o=>o)),t.appendChild(n)}function no(t){if(!!t)if(t instanceof Element){t.innerHTML="";return}else for(;t.firstChild;)t.removeChild(t.firstChild)}function oo(t,...e){if(!e.length||!(t==null?void 0:t.parentNode))return;let n=e.filter(o=>o);if(t instanceof Element)t.replaceWith(...n);else{let o=Se();o.append(...n),t.parentNode.replaceChild(o,t)}}function ro(t){var e;if(!!t)if(t instanceof Element){t.remove();return}else(e=t.parentNode)==null||e.removeChild(t)}function io(t){if(!t)return 0;let e=t.offsetLeft,n=t.offsetParent;if(n instanceof HTMLElement){let o=document.body.scrollLeft+document.documentElement.scrollLeft;if(!document.fullscreenElement&&!document.mozFullScreenElement&&!document.webkitFullscreenElement)for(;n!==null;)e+=n.offsetLeft,n=n.offsetParent;else for(;n!==null&&n!==t;)e+=n.offsetLeft,n=n.offsetParent;return e-o}return 0}function so(t){if(!t||!t.props)return t;let{props:e}=t;return e.withCommonNamespace&&(e.className=j.commonCls(e.className),delete e.withCommonNamespace),e.withNamespace&&(e.className=j.prefixCls(e.className),delete e.withNamespace),t}function ao(t){return t?Q(t,so):null}var lo={parseHtml:Yn,create:jn,createFragment:Se,createHtmlElement:eo,createByJsx:ao,append:to,empty:no,replace:oo,removeSelf:ro,getElementViewLeft:io},It=lo;var co="bvplayerCore",uo=t=>co+t,po={createPrefixStorageField:uo},Ct=po;var mo={render:vt,style:j,dom:It,field:Ct},u=mo;var W=u.field.createPrefixStorageField("DialogIds"),fo=(t,e)=>p(void 0,null,function*(){var c;let n={Authorization:e||""},o={id:t.id,index:t.index,sdp:t.sdp},i=yield ae.post(`${Z.bvscpV1()}/dialog/device/webrtc`,o,{headers:n});if(a.api("\u8BBE\u5907\u97F3\u89C6\u9891\u6D41 webrtc\u65B9\u5F0F\u6253\u5F00dialog: ",{params:o,resData:i}),!i||i.code!==0||!((c=i.data)==null?void 0:c.dialogid))throw new Error(`\u6253\u5F00\u4F20\u8F93\u901A\u9053\u5931\u8D25\uFF0C ${i.msg}`);let{data:s}=i;if(s.dialogid){let m=B.get(W)||[];m.push(s.dialogid),B.set(W,m)}return{dialogId:s.dialogid,sdp:s.sdp}}),go=(t,e)=>p(void 0,null,function*(){var m;let n={Authorization:e||""},o={id:t.id,index:t.index,sdp:t.sdp},i=yield ae.post(`${Z.bvscpV1()}/dialog/conference/webrtc`,o,{headers:n});if(a.api("\u4F1A\u8BAE\u97F3\u89C6\u9891\u6D41 webrtc\u65B9\u5F0F\u6253\u5F00dialog: ",{params:o,resData:i}),!i||i.code!==0||!((m=i.data)==null?void 0:m.dialogid))throw new Error(`\u6253\u5F00\u4F20\u8F93\u901A\u9053\u5931\u8D25\uFF0C ${i==null?void 0:i.msg}`);let{data:s}=i,c=B.get(W)||[];return c.push(s.dialogid),B.set(W,c),{dialogId:s.dialogid,sdp:s.sdp}}),ho=(t,e)=>p(void 0,null,function*(){if(!t)return;let n={Authorization:e||""};return a.api("\u5173\u95EDdialog\uFF1A",t),yield ae.post(`${Z.bvscpV1()}/dialog/close/${t}`,{},{headers:n})}),Pt=(t,e)=>p(void 0,null,function*(){let n=B.get(W)||[];D.pullAll(n,t),B.set(W,n,0);let i=(yield Promise.allSettled(t.map(s=>ho(s,e)))).filter(s=>s.status==="rejected");i&&i.length>0&&a.error(new Error(`"\u5173\u95ED\u5B58\u50A8\u7684dialog\u65F6\u5931\u8D25\uFF1A", ${i}`))}),vo=t=>p(void 0,null,function*(){let e=B.get(W);!e||e.length<1||(B.remove(W),yield Pt(e,t))}),yo={getDeviceWebrtc:fo,getConferenceWebrtc:go,closeDialogs:Pt,closeAllStorageDialog:vo},k=yo;var wt=class{constructor(){this._map=new Map}findExecutor(e,n){let o=this._map.get(e);return{index:o?o.findIndex(s=>Object.is(n,s)):-1,que:o}}publish(e,n){let o=this._map.get(e)||[],i=o.length;for(let s=0;s<i;s++){let c=o[s];c&&c(n)}}subscribe(e,n){let{index:o,que:i=[]}=this.findExecutor(e,n);return o>=0?i[o]=n:i.push(n),this._map.set(e,i),{unSubscribe:()=>{this.unSubscribe(e,n)}}}unSubscribe(e,n){let{index:o,que:i=[]}=this.findExecutor(e,n);o<0||(i.splice(o,1),this._map.set(e,i))}},ee=class{constructor(){this._notifier=new wt}addEventListener(e,n){this._notifier.subscribe(e,n)}removeEventListener(e,n){this._notifier.unSubscribe(e,n)}dispatch(e,n){this._notifier.publish(e,n)}};var w=class extends ee{constructor(e,n,o){super();this.name="";let i=n.trim().toLowerCase(),s=o?o.trim():i,c=u.dom.create(e,u.style.prefixCls(s));this.name=i,this.el=c}empty(){u.dom.empty(this.el)}unmount(){var e;a.debug("unmount",this.el,(e=this.el)==null?void 0:e.parentNode),u.dom.removeSelf(this.el)}destroy(){if(this.beforeDestroy(),this.empty(),this.unmount(),this.el=null,this.dispatch("destroy"),!!this){for(let e in this)this[e]=void 0;a.debug("destroy complete",this)}}getEl(){return this.el}};var Et=class extends w{constructor(e){super("div","mask",u.style.cls("mask"));this._visible=!!(e==null?void 0:e.visible),this._text=e==null?void 0:e.text,this._textEl=u.dom.create("span",u.style.cls("text"))}set visible(e){this._visible=e,this.el.style.display=this._visible?"grid":"none"}set text(e){this._text=e,this._textEl.textContent=e}beforeDestroy(){}init(){a.debug("mask visible: ",this._visible);let e=this.el;return e.style.display=this._visible?"block":"none",this._textEl.textContent=this._text||"",u.dom.append(e,this._textEl),e}},_t=Et;var St=class extends w{constructor(e){super("div","spinner",u.style.cls("spinner"));this._spin=!!(e==null?void 0:e.spin)}set spin(e){this._spin=e,this.el.style.display=this._spin?"block":"none"}beforeDestroy(){}init(){a.debug("spinner spin: ",this._spin);let e=this.el;e.style.display=this._spin?"block":"none";let n=u.dom.create("span");return n.style.backgroundColor="#FFF",u.dom.append(e,n),e}},xt=St;var Tt={contain:"contain",fill:"fill"},Mt=class extends w{constructor(e){super("video","video",u.style.cls("video"));this._url=e==null?void 0:e.url,this._srcObject=(e==null?void 0:e.srcObject)||null,this._fit=(e==null?void 0:e.fit)||Tt.contain,this._autoPlay=!!(e==null?void 0:e.autoPlay),this._muted=!!(e==null?void 0:e.muted)}set url(e){typeof this._url!="undefined"&&(this.el.src=this._url),this._url=e}set srcObject(e){this._srcObject=e||null,this.el.srcObject=this._srcObject}set muted(e){let n=this.el;this._muted=e,n.muted=e}set paused(e){let n=this.el;e?n.pause():n.play()}get paused(){var e;return!!((e=this.el)==null?void 0:e.paused)}set volume(e){let n=this.el;n.volume=Number(e)}get volume(){var e;return Number((e=this.el)==null?void 0:e.volume)}set autoPlay(e){if(!e!==this._autoPlay)return;this._autoPlay=e,this.muted=e;let n=this.el;n.autoplay=this._autoPlay}set fit(e){this._fit=Tt[e],this.el.style.objectFit=this._fit}getVideoFit(){return this._fit}init(){a.debug("\u6E32\u67D3VideoPlugin\u89C6\u9891\u5BF9\u8C61dom\u7684children",this,this.el);let e=this.el;return e.addEventListener("play",()=>this.dispatch("play",{target:this})),e.addEventListener("pause",()=>this.dispatch("pause",{target:this})),e.addEventListener("loadedmetadata",n=>{a.debug("video loadedmetadata",n),this.dispatch("loadedmetadata",{target:this})}),typeof this._url!="undefined"&&(e.src=this._url),e.srcObject=this._srcObject,e.autoplay=this._autoPlay,e.muted=this._muted,e.style.objectFit=this._fit,e.playsInline=!0,e}play(){return p(this,null,function*(){let e=this.el;try{a.debug("video \u5C1D\u8BD5\u64AD\u653E"),yield e.play()}catch(n){a.error(n,"video \u64AD\u653E \u5931\u8D25")}})}beforeDestroy(){}},Rt=Mt;function te(t){return class extends t{constructor(...e){super(...e);this._visible=!1}get visible(){return this._visible}set visible(e){let n=!!e;if(this._visible===n)return;this._visible=n;let o=u.style.commonCls("is-visible");this._visible?(this.show&&this.show(),this.el.setAttribute("aria-hidden","false"),this.el.classList.add(o)):(this.hide&&this.hide(),this.el.setAttribute("aria-hidden","true"),this.el.classList.remove(o))}}}function xe({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},r.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),r.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}))}function Te({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},r.h("path",{"fill-rule":"evenodd",d:"M11.49 3.17c-.38-1.56-2.6-1.56-2.98 0a1.532 1.532 0 01-2.286.948c-1.372-.836-2.942.734-2.106 2.106.54.886.061 2.042-.947 2.287-1.561.379-1.561 2.6 0 2.978a1.532 1.532 0 01.947 2.287c-.836 1.372.734 2.942 2.106 2.106a1.532 1.532 0 012.287.947c.379 1.561 2.6 1.561 2.978 0a1.533 1.533 0 012.287-.947c1.372.836 2.942-.734 2.106-2.106a1.533 1.533 0 01.947-2.287c1.561-.379 1.561-2.6 0-2.978a1.532 1.532 0 01-.947-2.287c.836-1.372-.734-2.942-2.106-2.106a1.532 1.532 0 01-2.287-.947zM10 13a3 3 0 100-6 3 3 0 000 6z","clip-rule":"evenodd"}))}function Me({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},r.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M3 9a2 2 0 012-2h.93a2 2 0 001.664-.89l.812-1.22A2 2 0 0110.07 4h3.86a2 2 0 011.664.89l.812 1.22A2 2 0 0018.07 7H19a2 2 0 012 2v9a2 2 0 01-2 2H5a2 2 0 01-2-2V9z"}),r.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 13a3 3 0 11-6 0 3 3 0 016 0z"}))}function Re({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},r.h("path",{"fill-rule":"evenodd",d:"M4 5a2 2 0 00-2 2v8a2 2 0 002 2h12a2 2 0 002-2V7a2 2 0 00-2-2h-1.586a1 1 0 01-.707-.293l-1.121-1.121A2 2 0 0011.172 3H8.828a2 2 0 00-1.414.586L6.293 4.707A1 1 0 015.586 5H4zm6 9a3 3 0 100-6 3 3 0 000 6z","clip-rule":"evenodd"}))}function Le({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},r.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"}))}function ke({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},r.h("path",{"fill-rule":"evenodd",d:"M3 4a1 1 0 011-1h4a1 1 0 010 2H6.414l2.293 2.293a1 1 0 01-1.414 1.414L5 6.414V8a1 1 0 01-2 0V4zm9 1a1 1 0 110-2h4a1 1 0 011 1v4a1 1 0 11-2 0V6.414l-2.293 2.293a1 1 0 11-1.414-1.414L13.586 5H12zm-9 7a1 1 0 112 0v1.586l2.293-2.293a1 1 0 011.414 1.414L6.414 15H8a1 1 0 110 2H4a1 1 0 01-1-1v-4zm13-1a1 1 0 011 1v4a1 1 0 01-1 1h-4a1 1 0 110-2h1.586l-2.293-2.293a1 1 0 011.414-1.414L15 13.586V12a1 1 0 011-1z","clip-rule":"evenodd"}))}function Fe({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},r.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"}))}function Ne({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},r.h("path",{"fill-rule":"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z","clip-rule":"evenodd"}))}function Oe({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},r.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z"}))}function Ve({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},r.h("path",{"fill-rule":"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z","clip-rule":"evenodd"}))}function De({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},r.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"}))}function Be({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},r.h("path",{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z","clip-rule":"evenodd"}))}function Ae({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},r.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15.536 8.464a5 5 0 010 7.072m2.828-9.9a9 9 0 010 12.728M5.586 15H4a1 1 0 01-1-1v-4a1 1 0 011-1h1.586l4.707-4.707C10.923 3.663 12 4.109 12 5v14c0 .891-1.077 1.337-1.707.707L5.586 15z"}))}function He({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},r.h("path",{"fill-rule":"evenodd",d:"M9.383 3.076A1 1 0 0110 4v12a1 1 0 01-1.707.707L4.586 13H2a1 1 0 01-1-1V8a1 1 0 011-1h2.586l3.707-3.707a1 1 0 011.09-.217zM14.657 2.929a1 1 0 011.414 0A9.972 9.972 0 0119 10a9.972 9.972 0 01-2.929 7.071 1 1 0 01-1.414-1.414A7.971 7.971 0 0017 10c0-2.21-.894-4.208-2.343-5.657a1 1 0 010-1.414zm-2.829 2.828a1 1 0 011.415 0A5.983 5.983 0 0115 10a5.984 5.984 0 01-1.757 4.243 1 1 0 01-1.415-1.415A3.984 3.984 0 0013 10a3.983 3.983 0 00-1.172-2.828 1 1 0 010-1.415z","clip-rule":"evenodd"}))}function We({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},r.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5.586 15H4a1 1 0 01-1-1v-4a1 1 0 011-1h1.586l4.707-4.707C10.923 3.663 12 4.109 12 5v14c0 .891-1.077 1.337-1.707.707L5.586 15z","clip-rule":"evenodd"}),r.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M17 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2"}))}function $e({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},r.h("path",{"fill-rule":"evenodd",d:"M9.383 3.076A1 1 0 0110 4v12a1 1 0 01-1.707.707L4.586 13H2a1 1 0 01-1-1V8a1 1 0 011-1h2.586l3.707-3.707a1 1 0 011.09-.217zM12.293 7.293a1 1 0 011.414 0L15 8.586l1.293-1.293a1 1 0 111.414 1.414L16.414 10l1.293 1.293a1 1 0 01-1.414 1.414L15 11.414l-1.293 1.293a1 1 0 01-1.414-1.414L13.586 10l-1.293-1.293a1 1 0 010-1.414z","clip-rule":"evenodd"}))}function ze({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},r.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z"}),r.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M21 12a9 9 0 11-18 0 9 9 0 0118 0z"}))}function Ue({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},r.h("path",{"fill-rule":"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM9.555 7.168A1 1 0 008 8v4a1 1 0 001.555.832l3-2a1 1 0 000-1.664l-3-2z","clip-rule":"evenodd"}))}function Je({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},r.h("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M10 9v6m4-6v6m7-3a9 9 0 11-18 0 9 9 0 0118 0z"}))}function Ke({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},r.h("path",{"fill-rule":"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zM7 8a1 1 0 012 0v4a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v4a1 1 0 102 0V8a1 1 0 00-1-1z","clip-rule":"evenodd"}))}function Ge({className:t}){return r.h("svg",{xmlns:"http://www.w3.org/2000/svg",version:"1.1",viewBox:"0 0 32 33",fill:"currentColor"},r.h("path",{d:"M6.667 28h-5.333c-0.8 0-1.333-0.533-1.333-1.333v-5.333c0-0.8 0.533-1.333 1.333-1.333s1.333 0.533 1.333 1.333v4h4c0.8 0 1.333 0.533 1.333 1.333s-0.533 1.333-1.333 1.333zM30.667 28h-5.333c-0.8 0-1.333-0.533-1.333-1.333s0.533-1.333 1.333-1.333h4v-4c0-0.8 0.533-1.333 1.333-1.333s1.333 0.533 1.333 1.333v5.333c0 0.8-0.533 1.333-1.333 1.333zM30.667 12c-0.8 0-1.333-0.533-1.333-1.333v-4h-4c-0.8 0-1.333-0.533-1.333-1.333s0.533-1.333 1.333-1.333h5.333c0.8 0 1.333 0.533 1.333 1.333v5.333c0 0.8-0.533 1.333-1.333 1.333zM1.333 12c-0.8 0-1.333-0.533-1.333-1.333v-5.333c0-0.8 0.533-1.333 1.333-1.333h5.333c0.8 0 1.333 0.533 1.333 1.333s-0.533 1.333-1.333 1.333h-4v4c0 0.8-0.533 1.333-1.333 1.333z"}))}var F=({children:t,className:e})=>{let n=u.style.cls(["icon",e]);return r.h("span",{className:n,withNamespace:!0},t)},bo=({filled:t})=>r.h(F,null,t?r.h(Te,null):r.h(xe,null)),Io=({filled:t})=>r.h(F,null,t?r.h(Re,null):r.h(Me,null)),Co=({filled:t})=>r.h(F,null,t?r.h(Ne,null):r.h(Fe,null)),Po=({filled:t})=>r.h(F,null,t?r.h(ke,null):r.h(Le,null)),wo=({filled:t,circle:e})=>e?r.h(F,null,t?r.h(Ve,null):r.h(Oe,null)):r.h(F,null,t?r.h(Be,null):r.h(De,null)),Eo=({filled:t,off:e})=>e?r.h(F,null,t?r.h($e,null):r.h(We,null)):r.h(F,null,t?r.h(He,null):r.h(Ae,null)),_o=({filled:t,off:e})=>e?r.h(F,null,t?r.h(Ke,null):r.h(Je,null)):r.h(F,null,t?r.h(Ue,null):r.h(ze,null)),So=()=>r.h(F,null,r.h(Ge,null)),xo={Cog:bo,Camera:Io,Info:Co,ArrowsExpand:Po,X:wo,Volume:Eo,Play:_o,Full:So};var _=xo;var $="modal",Lt=class extends w{constructor(e){super("div",$,u.style.cls([$,e.className,{[`${$}--center`]:e.center}]));this.container=e.container,this.title=e.title,this._content=e.content||u.dom.create("div","test"),this._center=!!e.center}set content(e){let n=u.dom.createByJsx(e);a.debug("modal update content",n,this._content),u.dom.replace(this._content,n),this._content=n}show(){var e;(e=this.el)==null||e.classList.toggle(u.style.prefixCls(`${$}--center`),!!this._center),u.dom.append(this.container,this.el)}hide(){}clear(){!this.el||(this.el.innerHTML="")}beforeDestroy(){}init(){this.clear(),a.debug("\u6E32\u67D3ModalPlugin \u5F39\u7A97\u5BF9\u8C61",this,this.el);let e=this.el,n=u.dom.createByJsx(r.h(r.Fragment,null,r.h("div",{className:`${$}_title-bar`,onClick:()=>this.dispatch("hide"),withNamespace:!0},r.h("span",{className:`${$}_title-bar_title`,withNamespace:!0},this.title),r.h("span",{className:`${$}_title-bar_close`,withNamespace:!0},r.h(_.X,null))),r.h("div",{className:`${$}_body`,withNamespace:!0},this._content)));return u.dom.append(e,n),e}},To=te(Lt),Xe=class extends To{},kt=Xe;var Ft="controller_button",Nt=class extends w{constructor(e,n,o){super("button",Ft,u.style.cls([Ft,o]));this._Children=e,this.title=n}set Children(e){!this.el||(this._Children=e,this.empty(),u.dom.append(this.el,u.dom.createByJsx(e)))}beforeDestroy(){}init(){let e=this.el;return e.addEventListener("click",()=>this.dispatch("click")),e.title=this.title||"",u.dom.append(e,u.dom.createByJsx(this._Children)),e}},K=Nt;var ne="slider",Ot=class extends w{constructor(e){super("div",ne,u.style.cls([ne,e]));this._percent=0;this._anyWidth=35}set percent(e){!this.el||(this._percent=D.restrict(e,0,1),!!this._innerEl&&(this._innerEl.style.width=this._percent*100+"%",!!this._suffixEl&&(this._suffixEl.innerHTML=Number(this._percent).toFixed(1))))}get percent(){return this._percent}beforeDestroy(){}init(e){let n=this.el,o=c=>{a.debug("handleThumbMove");let m=(c.clientX-u.dom.getElementViewLeft(this.el)-5.5)/this._anyWidth;this.dispatch("change",{target:this,percent:D.restrict(m,0,1)}),a.debug("slider handleThumbMove",m)},i=()=>{a.debug("handleThumbMoveEnd"),document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",i),this.dispatch("confirm")},s=()=>{a.debug("handleThumbMoveStart"),document.addEventListener("mousemove",o),document.addEventListener("mouseup",i)};return this._innerEl=u.dom.createByJsx(r.h("div",{className:`${ne}_inner`,style:`width: ${this._percent*100+"%"}`,withNamespace:!0},r.h("span",{className:`${ne}_thumb`,withNamespace:!0}))),this._suffixEl=u.dom.createByJsx(r.h("span",{className:`${ne}_suffix`,withNamespace:!0},this._percent)),u.dom.append(n,this._innerEl,this._suffixEl),n.addEventListener("mousedown",s),n.addEventListener("click",o),n}},Vt=Ot;var oe="controller",Dt=class extends w{constructor(e){super("div",oe,u.style.cls(oe));this._controls=(e==null?void 0:e.controls)||[],this.PlayButton=new K(r.h(_.Play,null)),this.VolumeButton=new K(r.h(_.Volume,{off:!0}),"volume"),this.VolumeSlider=new Vt,this.VolumeSlider.percent=.3,this.InformationButton=new K(r.h(_.Info,null),"information"),this.ScreenshotButton=new K(r.h(_.Camera,null),"screenshot"),this.FullscreenButton=new K(r.h(_.ArrowsExpand,null),"fullscreen"),this.PlayButton.addEventListener("click",()=>{this.dispatch("play")}),this.VolumeButton.addEventListener("click",()=>{this.dispatch("volume")}),this.InformationButton.addEventListener("click",()=>this.dispatch("information")),this.ScreenshotButton.addEventListener("click",()=>this.dispatch("screenshot")),this.FullscreenButton.addEventListener("click",()=>this.dispatch("fullscreen"))}activeVolume(){var e;(e=this._volumeEl)==null||e.classList.add(u.style.prefixCls(`${oe}_volume--active`))}hideVolume(){var e;(e=this._volumeEl)==null||e.classList.remove(u.style.prefixCls(`${oe}_volume--active`))}beforeDestroy(){}init(){a.debug("\u6E32\u67D3ControllerPlugin \u64AD\u653E\u63A7\u5236\u5668\u5BF9\u8C61",this,this.el,this._controls);let e=this.el,n=u.style.cls([`${this.name}_inner_bar`,`${this.name}_inner_left`]),o=u.style.cls([`${this.name}_inner_bar`,`${this.name}_inner_right`]);this._volumeEl=u.dom.createByJsx(r.h("div",{className:`${oe}_volume`,withNamespace:!0},this.VolumeButton.init(),this.VolumeSlider.init()));let i=u.dom.createByJsx(r.h(r.Fragment,null,r.h("div",{className:`${this.name}_mask`,withNamespace:!0}),r.h("div",{className:`${this.name}_inner`,withNamespace:!0},r.h("div",{className:n,withNamespace:!0},this.PlayButton.init(),this._volumeEl),r.h("div",{className:"flex-space",withCommonNamespace:!0}),r.h("div",{className:o,withNamespace:!0},this.InformationButton.init(),this.ScreenshotButton.init(),this.FullscreenButton.init()))));return u.dom.append(e,i),this.VolumeSlider.addEventListener("confirm",this.hideVolume.bind(this)),e}},Mo=te(Dt),qe=class extends Mo{},Bt=qe;var At=class{constructor(){this._els=[];this.disableAutoHide=!1;this._controller=new Bt}init(){let e=this._controller.init();return this._els.push(e),this._els}get els(){return this._els}get controller(){return this._controller}show(){this._controller.visible=!0}hide(){window.clearTimeout(this._autoHideTimeout),this._controller.visible=!1}showThenHide(){this.show(),window.clearTimeout(this._autoHideTimeout),this._autoHideTimeout=window.setTimeout(()=>{this.disableAutoHide||this.hide()},3e3)}},Ht=At;var ce=class{constructor(e){this.pc=e}getReceiversMap(){let e=new Map([["audio",[]],["video",[]]]),n=this.pc.getReceivers();return(n==null?void 0:n.length)&&n.forEach(o=>{let{kind:i}=o.track,s=e.get(i)||[];s.push(o),e.set(i,s)}),e}getStatsInfos(){return p(this,null,function*(){let e=this.getReceiversMap();a.debug("receivers map : ",e);let n=yield Promise.all(e.get("audio").map(i=>p(this,null,function*(){let s={},c=yield i.getStats(),m=[];return c.forEach(l=>{m.push(l),l.type==="codec"&&(s.mimeType=l.mimeType,s.clockRate=l.clockRate,s.channels=l.channels),l.type==="track"&&(s.totalSamplesReceived=l.totalSamplesReceived,s.totalSamplesDuration=l.totalSamplesDuration)}),a.debug("audio stats report: ",m),s}))),o=yield Promise.all(e.get("video").map(i=>p(this,null,function*(){let s={},c=yield i.getStats(),m=[];return c.forEach(l=>{m.push(l),l.type==="codec"&&(s.mimeType=l.mimeType,s.clockRate=l.clockRate),l.type==="inbound-rtp"&&(s.frameWidth=l.frameWidth,s.frameHeight=l.frameHeight,s.framesPerSecond=l.framesPerSecond,s.framesReceived=l.framesReceived,s.framesDecoded=l.framesDecoded,s.totalInterFrameDelay=l.totalInterFrameDelay,s.keyFramesDecoded=l.keyFramesDecoded,s.packetsLost=l.packetsLost,s.lastPacketReceivedTimestamp=l.lastPacketReceivedTimestamp,s.bytesReceived=l.bytesReceived,s.totalDecodeTime=l.totalDecodeTime)}),a.debug("video stats report: ",m),s})));return{audios:n,videos:o}})}};var Ro=(t,e)=>{V.debug(`webrtc my ICE candidate:
|
|
26
|
+
${e.candidate?e.candidate.candidate:"(null)"}`)},Lo=(t,e,n)=>{V.debug("webrtc ICE state change event: ",e),V.debug(`webrtc my ICE state: ${t==null?void 0:t.iceConnectionState}`),t&&t.iceConnectionState==="disconnected"&&n&&n()},ko=(t,e)=>{V.debug("webrtc Connection state change, \u5F53\u524D\u8FDE\u63A5\u72B6\u6001: ",t,t.connectionState)},Fo=(t,e,n)=>{V.debug("webrtc \u5F53\u524D\u7684 stream: ",e.streams[0]);let o=e.streams[0];n(o)},No=(t,e)=>p(void 0,null,function*(){let{offerParam:n,productRemoteSdp:o,customerRTCPeerConnection:i,onConnected:s,onConnectedFailed:c,onIceDisconnected:m,onPcEventAdded:l,onLocalDescriptionReady:g}=t,b=!!i&&i instanceof RTCPeerConnection,I={},y=b?i:new RTCPeerConnection(I);if(y.addEventListener("icecandidate",h=>Ro(y,h)),y.addEventListener("iceconnectionstatechange",h=>Lo(y,h,m)),y.addEventListener("connectionstatechange",h=>ko(y,h)),y.addEventListener("track",h=>Fo(y,h,e)),l&&(yield l(y)),b)return new ce(y);try{let h=yield y.createOffer(n);V.debug("\u521B\u5EFAoffer\uFF0C\u53C2\u6570\uFF1A",n,"\uFF0C \u7ED3\u679C\uFF1A",h),yield y.setLocalDescription(h),g&&g(y);let C=yield o(new RTCSessionDescription(h));V.debug("webrtc recv open answer",C);let M=new RTCSessionDescription({type:"answer",sdp:C});yield y.setRemoteDescription(M),V.debug("getTransceivers",y.getTransceivers()),s&&s(y)}catch(h){throw c&&c(y),V.error(new Error(`webrtc Failed to create session description: ${h.toString()}`)),y.close(),h}return new ce(y)}),Oo=t=>{if(!t)return;let{pc:e}=t;e.close()},Vo={connect:No,disconnect:Oo},Qe=Vo;var G=document.documentElement,de="requestFullscreen",ue="exitFullscreen",pe="fullscreenElement",me="onfullscreenchange";if("webkitRequestFullScreen"in G)de="webkitRequestFullScreen",ue="webkitExitFullscreen",pe="webkitFullscreenElement",me="onwebkitfullscreenchange";else if("msRequestFullscreen"in G)de="msRequestFullscreen",ue="msExitFullscreen",pe="msFullscreenElement",me="MSFullscreenChange";else if("mozRequestFullScreen"in G)de="mozRequestFullScreen",ue="mozCancelFullScreen",pe="mozFullScreenElement",me="onmozfullscreenchange";else if(!("requestFullscreen"in G))throw"\u5F53\u524D\u6D4F\u89C8\u5668\u4E0D\u652F\u6301Fullscreen API !";function Do(t=G,e){return t[de](e)}function Bo(){return document[ue]()}function Wt(t){return t===document[pe]}function Ao(t=G,e){return Wt(t)?Bo():Do(t,e)}function Ho(t,e){let n=()=>{t.onfullscreenchange=null},o=i=>{i.target!==null&&e(Wt(i.target))};return t[me]=o,{cancel:n}}var Wo={toggle:Ao,watch:Ho},fe=Wo;var $o=({label:t,value:e,suffix:n})=>r.h("div",{className:"player_info-modal_list_item",withNamespace:!0},r.h("span",{className:"player_info-modal_list_item_label",withNamespace:!0},t),r.h("span",{className:"player_info-modal_list_item_value",withNamespace:!0},e),r.h("span",{className:"player_info-modal_list_item_suffix",withNamespace:!0},n)),$t=({list:t,factory:e})=>(t==null?void 0:t.length)?e?r.h(r.Fragment,null,t.map(n=>r.h($t,{list:Object.keys(n).map(o=>e[o]?e[o](n[o],n):!1).filter(o=>o!==!1)}))):r.h("div",{className:"player_info-modal_list",withNamespace:!0},t.map(n=>r.h($o,R({},n)))):null,Ze=$t;var N;(function(o){o.DIRECT="direct",o.PLUGIN="plugin",o.REJECT="reject"})(N||(N={}));var ge;(function(s){s.MP4="MP4",s.FLAC="FLAC",s.OGG="OGG",s.WEBM="WEBM",s.AUTO="AUTO"})(ge||(ge={}));var Ye;(function(e){e.WEBRTC="WEBRTC"})(Ye||(Ye={}));var zt="player",Ut=class extends w{constructor(e){super("div",zt);this._lastTotalReceivedBytes=0;this._video=new Rt,this._spinner=new xt({spin:!1}),this._mask=new _t({visible:!1}),this._panel=new Ht,this._infoModal=new kt({container:this.el,title:"Info",center:!0,className:`${zt}_info-modal`}),this._videoOption=e==null?void 0:e.video,this._pluginOption=e==null?void 0:e.pluginOption,this._playerConfig=e==null?void 0:e.playerConfig,this._mode=this._restrictPlayerMode(e==null?void 0:e.video,e==null?void 0:e.pluginOption),a.debug("PlayerMode",this._mode)}justifyVideoType(e,n){if((e==null?void 0:e.url)&&!e.type)return ge.AUTO;let o="".toUpperCase.call((e==null?void 0:e.type)||Object.keys(n||{})[0]||"");return a.debug("justifyVideoType ",e,o),o}_restrictPlayerMode(e,n){let o=this.justifyVideoType(e,n);if(!o&&!(e==null?void 0:e.url))return N.REJECT;if(!o)return N.DIRECT;let i=Object.keys(ge),s=Object.keys(Ye);return i.includes(o)?N.DIRECT:s.includes(o)?N.PLUGIN:N.DIRECT}init(){a.debug("\u6E32\u67D3PlayerPlugin",this.el),this.prepare();let e=this._video.init(),n=this._spinner.init(),o=this._mask.init(),i=this._panel.init(),s=this._infoModal.init();return u.dom.append(this.el,e,n,o,...i,s),this.initEvents(),this.dispatch("init",{name:"initEvent",target:this,mode:this._mode}),this.el}get video(){return this._video}get spinner(){return this._spinner}get mask(){return this._mask}play(e){return p(this,null,function*(){this.mute(!0),yield this._video.play(),this.mute(e)})}mute(e){var n;this._video.muted=!!e,a.debug("player mute: ",(n=this._video.getEl())==null?void 0:n.muted)}setProductRemoteSdp(e){!this._pluginOption||!this._pluginOption.webrtc||(this._pluginOption.webrtc.productRemoteSdp=e)}prepareWebrtc(){return p(this,null,function*(){var n;if(this._mode!==N.PLUGIN)return;a.debug("PuPlayer Plugin prepareWebrtc");let e=(n=this._pluginOption)==null?void 0:n.webrtc;!e||(this._video.autoPlay=!0,this._spinner.spin=!0,this._webrtcConnect=yield Qe.connect(e,o=>{var s;if(!o)return;(s=this.video.getEl())==null||s.addEventListener("canplay",()=>{a.debug("Video canplay"),this.video.play()}),this._video.srcObject=o;let i=o.getTracks()[0];i.onended=c=>{a.debug("\u6D41\u89C6\u9891\u8F68\u9053\u5DF2\u7ECF\u7EC8\u6B62",c)},i.onmute=c=>{a.debug("\u6D41\u89C6\u9891\u8F68\u9053\u6682\u65F6\u65E0\u6CD5\u63D0\u4F9B\u5A92\u4F53",c),this.onMuted()},i.onunmute=c=>{a.debug("\u6D41\u89C6\u9891\u8F68\u9053\u63D0\u4F9B\u5A92\u4F53",c),this.onUnMuted()}}))})}close(){this.closeWebrtc()}beforeDestroy(){this.close()}onMuted(){}onUnMuted(){}loadPlayerConfig(){var e;this.video.autoPlay=!!((e=this._playerConfig)==null?void 0:e.autoPlay)}initEvents(){var o,i,s,c,m;(o=this.video.getEl())==null||o.addEventListener("canplay",()=>{this._spinner.spin=!1,this._mask.visible=!1}),(i=this.video.getEl())==null||i.addEventListener("waiting",()=>{a.debug("Video is waiting for more data."),this._spinner.spin=!0}),(s=this.el)==null||s.addEventListener("mousemove",()=>{this._panel.showThenHide()}),(c=this.el)==null||c.addEventListener("click",()=>{this._panel.showThenHide()});let e=(l=!1)=>{let g=this._panel.controller.PlayButton;l||(this._video.paused=!this._video.paused),console.log("oalyer,",this._video.paused),this._video.paused?g.Children=r.h(_.Play,null):g.Children=r.h(_.Play,{off:!0})};e(!0),this._panel.controller.addEventListener("play",()=>e()),this._video.addEventListener("play",()=>{a.debug("video play"),this._panel.showThenHide();let l=this._panel.controller.PlayButton;l.Children=r.h(_.Play,{off:!0})}),this._video.addEventListener("pause",()=>{a.debug("video pause"),this._panel.showThenHide();let l=this._panel.controller.PlayButton;l.Children=r.h(_.Play,null)}),this._panel.controller.addEventListener("screenshot",()=>{let l=this._video.getEl();if(!l){a.libError("playerPlugin screenshot videoEl\u4E3A\u7A7A\u503C");return}D.screenshot(l,`screenshot_${Date.now()}`)}),this._panel.controller.addEventListener("fullscreen",()=>{if(!this.el){a.libError("playerPlugin fullscreen playerEL\u4E3A\u7A7A\u503C");return}fe.toggle(this.el)}),(m=this._infoModal)==null||m.addEventListener("hide",()=>{this._infoModal.visible=!1,window.clearInterval(this._timer)}),this._panel.controller.addEventListener("information",()=>p(this,null,function*(){if(!this._video.getEl()){a.libError("playerPlugin information videoEl\u4E3A\u7A7A\u503C");return}this.refreshInfoModal()}));let n=(l=!1)=>{var I;let g=this._panel.controller.VolumeButton,b=(I=this._video.getEl())==null?void 0:I.muted;l||(this._video.muted=!b),b?g.Children=r.h(_.Volume,null):g.Children=r.h(_.Volume,{off:!0})};n(!0),this._panel.controller.addEventListener("volume",()=>n()),this._panel.controller.VolumeSlider.percent=this.video.volume,this._panel.controller.VolumeSlider.addEventListener("change",l=>{this._panel.controller.activeVolume(),console.log(l==null?void 0:l.percent,this.video.volume),this.video.volume=Number(l==null?void 0:l.percent),this._panel.controller.VolumeSlider.percent=this.video.volume})}prepare(){if(a.debug("PlayerPlugin mode: ",this._mode),this.loadPlayerConfig(),this._mode===N.REJECT){a.error(new Error("\u4E0D\u652F\u6301\u7684\u89C6\u9891\u7C7B\u578B"),this._mode,this._videoOption);return}if(this._mode===N.DIRECT){this.prepareDirect();return}if(this._mode===N.PLUGIN){switch(this.justifyVideoType(this._videoOption,this._pluginOption)){case"webrtc":break;default:break}return}}prepareDirect(){var e;this._video.url=((e=this._videoOption)==null?void 0:e.url)||"",setTimeout(()=>{this.play()},300)}closeWebrtc(){var e;Qe.disconnect(this._webrtcConnect),this.dispatch("closeWebrtc",{name:"closeWebrtcEvent",target:this,peerConnection:(e=this._webrtcConnect)==null?void 0:e.pc}),this._webrtcConnect=null,this._video.srcObject=null}refreshInfoModal(){return p(this,null,function*(){if(window.clearInterval(this._timer),!this._webrtcConnect)return;let e=3,n=()=>p(this,null,function*(){if(!this._webrtcConnect)return;let o=yield this._webrtcConnect.getStatsInfos();a.debug("player get result: ",o);let i={mimeType:(l="")=>({label:"Mime Type:",value:l}),totalSamplesReceived:(l=0,g)=>{let b={label:"Sample Rate:",value:""};return!l||!g.totalSamplesDuration||(b.value=Number(l/g.totalSamplesDuration).toFixed(3)+"Hz"),b}},s={mimeType:(l="")=>({label:"Mime Type:",value:l}),framesPerSecond:(l,g)=>({label:"Resolution:",value:`${g.frameWidth} x ${g.frameHeight}@${l}`}),bytesReceived:(l,g)=>{let b=l||0,I=(b-this._lastTotalReceivedBytes)*8/(e*1e3);return this._lastTotalReceivedBytes=b,{label:"Data Received:",value:`${Math.round(I)} kbps , lost ${g.packetsLost}`}}},c=r.h(Ze,{list:o.audios,factory:i}),m=r.h(Ze,{list:o.videos,factory:s});a.debug("audioInfoList",u.dom.createByJsx(c)),!!this._infoModal&&(this._infoModal.content=r.h("div",{style:"padding-left: 24px;"},r.h("section",{className:"player_info-modal_section",withNamespace:!0},r.h("span",{className:"player_info-modal_section_title",withNamespace:!0},"Audio"),c),r.h("section",{className:"player_info-modal_section",withNamespace:!0},r.h("span",{className:"player_info-modal_section_title",withNamespace:!0},"Video"),m)),this._infoModal.visible=!0)});n(),this._timer=window.setInterval(n,e*1e3)})}},he=Ut;var zo=(t,e,n)=>o=>p(void 0,null,function*(){if(o.type==="offer"){a.debug("\u8BF7\u6C42\u8FDC\u7AEFsdp\uFF0C \u8BBE\u5907\u914D\u7F6E\u4FE1\u606F\uFF1A",t,"token: ",e),a.debug("\u672C\u5730sdp",o);try{let{id:i,index:s}=t||{},c=yield k.getDeviceWebrtc({id:i,index:s,sdp:o.sdp},e);return n&&n(c.dialogId),c.sdp}catch(i){throw a.error(i,"\u8BF7\u6C42\u8FDC\u7AEFsdp\u65F6\u51FA\u9519"),new Error(`PUPlayer open \u5931\u8D25 , ${i.message}`)}}}),Uo=t=>{let{container:e,token:n,puOption:o,defaultMediaOption:i={audio:!0,video:!0},testUrl:s,videoFit:c="fill",muted:m,apiPrefix:l,onConnected:g,onConnectedFailed:b,onDisConnected:I,fullScreenOnDblclick:y=!0}=t||{},h,C=n,M=o,O=e,S=typeof m=="boolean"?m:!i.audio;Y(l);let P=()=>p(void 0,null,function*(){if(!!h&&(a.debug("PuPlayer close",h),f.mask.visible=!0,f.mask.text="Video Closed",f.close(),h))try{yield k.closeDialogs([h],C)}catch(v){throw a.error(v,"PuPlayer close \u5931\u8D25"),new Error(`PuPlayer close \u5931\u8D25 , ${v.message}`)}}),f=new he({video:{url:s},pluginOption:{webrtc:{offerParam:{offerToReceiveAudio:i.audio,offerToReceiveVideo:i.video},productRemoteSdp:v=>p(void 0,null,function*(){return zo(M,C,z=>{h=z})(v)}),onIceDisconnected:()=>{f.mask.visible=!0,f.mask.text="lost connection",f.close(),I&&I()},onConnected:()=>{g&&g()},onConnectedFailed:()=>{b&&b()}}},playerConfig:{autoPlay:!0}});f.addEventListener("init",v=>{a.debug("\u76D1\u542C\u5230\u4E86 player\u5DF2\u7ECF\u521D\u59CB\u5316",v)}),f.mute(S),f.video.fit=c;let E=f.init();y&&(E==null||E.addEventListener("dblclick",()=>{a.debug("\u53CC\u51FBplayer\uFF1A",E),fe.toggle(E)}));let A={instance:{getVideoElement:()=>f.video.getEl(),getPlayerElement:()=>f.getEl(),open:(v=!1)=>p(void 0,null,function*(){a.debug("PuPlayer open"),yield P(),a.debug("PuPlayer close before open"),f.mask.visible=!1,f.mask.text="connecting",f.mute(!!v);try{yield f.prepareWebrtc()}catch(x){throw f.mask.visible=!0,f.mask.text="connect failed",x}if(typeof v=="boolean"&&v){let x=()=>{a.debug("\u76D1\u542C\u5230\u7528\u6237\u6709click tap\u4EA4\u4E92\uFF0C \u6539\u53D8\u9759\u97F3\uFF0C muted\uFF1A",S),a.debug("\u6B64\u90E8\u5206\u67E5\u770B\uFF1Ahttps://developers.google.com/web/updates/2017/09/autoplay-policy-changes"),f.mute(S),document.removeEventListener("click",x),document.removeEventListener("touchend",x)};document.addEventListener("click",x),document.addEventListener("touchend",x)}}),play:()=>p(void 0,null,function*(){yield f.play(S)}),mute:(v=!1)=>{S=v,f.mute(v)},hidden:v=>p(void 0,null,function*(){let x=E,z=f.video.getEl();x.style.display="none",document.body.appendChild(x),z.muted=!0;try{typeof v!="undefined"&&(S=v),yield f.play(S)}catch(tr){a.debug("player.play() \u64AD\u653E\u672A\u6210\u529F")}a.debug("\u6DFB\u52A0\u5230body\u5E76\u9690\u85CF\uFF0C \u8C03\u7528play\u540E\u7684\u6682\u505C\u72B6\u6001\uFF1A",z.paused)}),display:v=>p(void 0,null,function*(){let x=E,z=f.video.getEl();u.render(x,O,()=>p(void 0,null,function*(){x.style.display="block",typeof v!="undefined"&&(S=v),yield f.play(S)})),a.debug("\u663E\u793A\u5230\u5F53\u524D\u5BB9\u5668\uFF0C \u8C03\u7528play\u540E\u7684\u6682\u505C\u72B6\u6001\uFF1A",z.paused)}),moveTo:v=>{a.debug("\u79FB\u52A8\u81F3\uFF1A",v),O=v,u.render(E,O,()=>p(void 0,null,function*(){}))},getCurrentContainer:()=>O,setPuOption:v=>{M=v},setVideoFit:v=>{a.debug("PuPlayer setVideoFit",v),f.video.fit=v},setToken:v=>{a.debug("PuPlayer setToken",v),C=v},setApiPrefix:Y,close:P,render:f.init,destroy:()=>p(void 0,null,function*(){a.debug("PuPlayer destroy"),yield P(),f.destroy()})},element:E};return O&&(u.render(E,O),A.element=null),A},Jo=Uo;var je=class extends ee{constructor(e,n){super();this._plugin=e,this._el=this._plugin.init(),this._currentContainer=n}moveTo(e,n){a.debug("\u79FB\u52A8\u81F3\uFF1A",e),this._currentContainer=e,u.render(this._el,this._currentContainer,n)}getCurrentContainer(){return this._currentContainer}render(){return this._plugin.init()}destroy(){a.debug("destroy",this._plugin),this._plugin.destroy(),this.dispatch("destroy")}};var ve=class{constructor(e,n,o,i){this.token="";this.fetchSdpFunc=e,this.token=n||"",this.param=o,this.prefix=i}fetch(e){return p(this,null,function*(){a.debug("RemoteSdpFetcher fetch \u8BF7\u6C42\u8FDC\u7AEFsdp\uFF0C param\uFF1A",this.param,"token: ",this.token);let n=yield this.fetchSdpFunc(e,this.param,this.token,this.prefix),{sdp:o,dialogId:i}=n||{};return this.dialogId=i,a.debug(`RemoteSdpFetcher fetch \u83B7\u5F97\u7684remoteSdp ${o}, dialogId: ${i}`),o})}close(){return p(this,null,function*(){a.debug(`remoteSdpFetcher close\uFF0C \u68C0\u67E5dialogId: ${this.dialogId}`),this.dialogId&&(yield k.closeDialogs([this.dialogId]))})}},et=class extends je{constructor(e,n,o,i,s){super(e,s);this._muted=!1;this._videoFit="contain";this.setRemoteSdpFetcher(i),this.setVideoFit(n),this.setMuted(o)}get player(){return this._plugin}getPlayerElement(){return this.player.getEl()}getVideoElement(){return this.player.video.getEl()}setRemoteSdpFetcher(e){this._remoteSdpFetcher=e,this._plugin.setProductRemoteSdp(n=>p(this,null,function*(){var o;return(o=this._remoteSdpFetcher)==null?void 0:o.fetch(n)}))}getRemoteSdpFetcher(){return this._remoteSdpFetcher}setVideoFit(e){a.debug("BvWebrtcInstance setVideoFit",e),this._videoFit=e,this.player.video.fit=e}getVideoFit(){return this._videoFit}setMuted(e=!1){this._muted=e,this.player.mute(e)}getMuted(){return this._muted}mute(e=!1){return this.setMuted(e)}open(e=!1){return p(this,null,function*(){a.debug("BvWebrtc open"),yield this.close(),this.player.mask.visible=!1,this.player.mask.text="connecting",this.player.mute(!!e);try{yield this.player.prepareWebrtc()}catch(n){throw this.player.mask.visible=!0,this.player.mask.text="connect failed",n}if(e){let n=()=>{a.debug("\u76D1\u542C\u5230\u7528\u6237\u6709click tap\u4EA4\u4E92\uFF0C \u6539\u53D8\u9759\u97F3\uFF0C muted\uFF1A",this._muted),a.debug("\u6B64\u90E8\u5206\u67E5\u770B\uFF1Ahttps://developers.google.com/web/updates/2017/09/autoplay-policy-changes"),this.player.mute(this._muted),document.removeEventListener("click",n),document.removeEventListener("touchend",n)};document.addEventListener("click",n),document.addEventListener("touchend",n)}})}play(){return p(this,null,function*(){yield this.player.play(this._muted)})}hidden(e){return p(this,null,function*(){let n=this._el,o=this.player.video.getEl();n.style.display="none",document.body.appendChild(n),o.muted=!0;try{typeof e!="undefined"&&(this._muted=e),yield this.player.play(this._muted)}catch(i){a.debug("player.play() \u64AD\u653E\u672A\u6210\u529F")}a.debug("\u6DFB\u52A0\u5230body\u5E76\u9690\u85CF\uFF0C \u8C03\u7528play\u540E\u7684\u6682\u505C\u72B6\u6001\uFF1A",o.paused)})}display(e){return p(this,null,function*(){let n=this._el,o=this.player.video.getEl();u.render(n,this._currentContainer,()=>p(this,null,function*(){n.style.display="block",typeof e!="undefined"&&(this._muted=e),yield this.player.play(this._muted)})),a.debug("\u663E\u793A\u5230\u5F53\u524D\u5BB9\u5668\uFF0C \u8C03\u7528play\u540E\u7684\u6682\u505C\u72B6\u6001\uFF1A",o.paused)})}close(){return p(this,null,function*(){if(a.debug("BvWebrtcInstance close",`_dialogId: ${this._dialogId}`),this.player.mask.visible=!0,this.player.mask.text="Video Closed",this.player.close(),a.debug("BvWebrtcInstance close\uFF0C player closed\uFF0C\u68C0\u67E5 remoteSdpFetcher: ",this._remoteSdpFetcher),this.dispatch("close"),this._remoteSdpFetcher)try{yield this._remoteSdpFetcher.close()}catch(e){throw a.error(e,"BvWebrtcInstance close \u5931\u8D25"),new Error(`BvWebrtcInstance close \u5931\u8D25 , ${e.message}`)}})}destroy(){a.debug("PuPlayer destroy"),this.close(),this.player.destroy()}};var Ko=t=>{let{container:e,sdpFetcher:n,offerParam:o,videoFit:i,muted:s,autoPlay:c,onConnected:m,onClose:l,onDestroy:g,onConnectedFailed:b,onDisConnected:I,onPcEventAdded:y}=t,h=new he({pluginOption:{webrtc:{offerParam:o,productRemoteSdp:()=>p(void 0,null,function*(){return""}),onIceDisconnected:()=>{h.mask.visible=!0,h.mask.text="lost connection",h.close(),I&&I()},onPcEventAdded:y,onConnected:()=>{h.mask.visible=!1,h.mask.text="connected",m&&m()},onConnectedFailed:()=>{b&&b()}}},playerConfig:{autoPlay:c}}),C=new et(h,i,s,n,e);C.addEventListener("close",()=>{l&&l()}),C.addEventListener("destroy",()=>{g&&g()});let M={open:()=>p(void 0,null,function*(){a.debug("BvWebrtc open"),yield C.open()}),setOption:P=>{a.debug("BvWebrtc setOption");let f=C.getRemoteSdpFetcher();f&&(f.param=P)},setToken:P=>{a.debug("BvWebrtc setToken",P);let f=C.getRemoteSdpFetcher();f&&(f.token=P)},setApiPrefix:P=>{a.debug("BvWebrtc setApiPrefix",P);let f=C.getRemoteSdpFetcher();f&&(f.prefix=P)},getRemoteSdpFetcher:()=>C.getRemoteSdpFetcher(),close:()=>p(void 0,null,function*(){a.debug("BvWebrtc close"),yield C.close()}),render:()=>(a.debug("BvWebrtc render"),C.render()),destroy:()=>{a.debug("BvWebrtc destroy"),C.destroy()}},O=C.render(),S={instance:M,element:O};return e&&(u.render(O,e),S.element=null),S},Jt=Ko;var Go=()=>p(void 0,null,function*(){a.debug("\u8BF7\u6C42\u9EA6\u514B\u98CE...");let t=yield navigator.mediaDevices.getUserMedia({audio:!0,video:!1}),e=t.getAudioTracks();return a.debug("\u9EA6\u514B\u98CE \u97F3\u9891\u8F68\u9053\uFF1A",e),t}),Xo=t=>{let{container:e,token:n,getRemoteSdpParam:o,apiPrefix:i,getRemoteSdpResult:s,onConnected:c,onClose:m,onDestroy:l,onConnectedFailed:g,onDisConnected:b,onGetUserMediaFailed:I}=t||{},y=(P,f,E,be)=>p(void 0,null,function*(){if(a.debug("audioPlayer productRemoteSdp",{param:{localDescription:P,param:f,token:E,prefix:be}}),P.type==="offer"&&(Y(be),a.debug("\u672C\u5730sdp",P),!!s))try{let{sdp:A,dialogId:v}=yield s(P.sdp,E,f);return{sdp:A,dialogId:v}}catch(A){throw a.error(A,"\u8BF7\u6C42\u8FDC\u7AEFsdp\u65F6\u51FA\u9519"),new Error(`productRemoteSdp \u5931\u8D25 , ${A.message}`)}}),h=new ve(y,n,o,i),{instance:C,element:M}=Jt({container:e,sdpFetcher:h,offerParam:{offerToReceiveAudio:!0},videoFit:"contain",muted:!1,autoPlay:!0,onConnected:c,onClose:m,onDestroy:l,onConnectedFailed:g,onDisConnected:b,onPcEventAdded:P=>p(void 0,null,function*(){try{let f=yield Go();f.getTracks().forEach(E=>P.addTrack(E,f))}catch(f){I&&I()}})});return{instance:R({},C),element:M}},ye=Xo;var qo=(t,e,n)=>p(void 0,null,function*(){let{id:o,index:i}=n||{};return yield k.getDeviceWebrtc({id:o,index:i,sdp:t},e)}),Qo=t=>{let{container:e,token:n,puOption:o,apiPrefix:i,onConnected:s,onClose:c,onDestroy:m,onConnectedFailed:l,onDisConnected:g,onGetUserMediaFailed:b}=t||{},{instance:I,element:y}=ye({container:e,token:n,getRemoteSdpParam:o,getRemoteSdpResult:qo,apiPrefix:i,onConnected:s,onClose:c,onDestroy:m,onConnectedFailed:l,onDisConnected:g,onGetUserMediaFailed:b}),h=U(R({},I),{setPuOption:M=>I.setOption&&I.setOption(M)});return delete h.setOption,{instance:h,element:y}},Zo=Qo;var Yo=(t,e,n)=>p(void 0,null,function*(){let{id:o,index:i}=n||{};return yield k.getConferenceWebrtc({id:o,index:i,sdp:t},e)}),jo=t=>{let{container:e,token:n,confOption:o,apiPrefix:i,onConnected:s,onClose:c,onDestroy:m,onConnectedFailed:l,onDisConnected:g,onGetUserMediaFailed:b}=t||{},{instance:I,element:y}=ye({container:e,token:n,getRemoteSdpParam:o,getRemoteSdpResult:Yo,apiPrefix:i,onConnected:s,onClose:c,onDestroy:m,onConnectedFailed:l,onDisConnected:g,onGetUserMediaFailed:b}),h=U(R({},I),{setConfOption:M=>I.setOption&&I.setOption(M)});return delete h.setOption,{instance:h,element:y}},er=jo;var il=k.closeAllStorageDialog;export{er as Conference,Zo as Intercom,Jo as PuPlayer,ve as RemoteSdpFetcher,il as clearAllDialog};
|
package/dist/types/app.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EmptyComponentInstance, Props, SFC } from "./core/types";
|
|
2
2
|
export interface IAppProps extends Props {
|
|
3
3
|
}
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
declare const App: SFC<IAppProps, IAppInstace>;
|
|
4
|
+
declare const App: SFC<IAppProps, EmptyComponentInstance>;
|
|
7
5
|
export default App;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IComponentInstance, Props, RenderTarget, SFC } from "../core/types";
|
|
2
|
-
import { IVideoFits } from "
|
|
2
|
+
import { IVideoFits } from "../plugins/video";
|
|
3
3
|
import { IPuOption } from "./types";
|
|
4
4
|
export interface IPuPlayerProps extends Props {
|
|
5
5
|
container?: RenderTarget;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { RenderTarget } from "./types";
|
|
2
|
+
declare function parseHtml(htmlString: string): DocumentFragment;
|
|
3
|
+
declare function create<K extends keyof HTMLElementTagNameMap>(tag: K, className?: string): HTMLElementTagNameMap[K];
|
|
4
|
+
declare function createFragment(): DocumentFragment;
|
|
5
|
+
declare function createHtmlElement(tag: string, className?: string): HTMLElement;
|
|
6
|
+
declare function append<N extends Node>(parent?: N | null, ...children: (N | null)[]): void;
|
|
7
|
+
declare function empty<N extends Node>(parent?: N | null): void;
|
|
8
|
+
declare function replace<N extends Node>(oldNode: N | null, ...newNodes: (N | null)[]): void;
|
|
9
|
+
declare function removeSelf<N extends Node>(el?: N | null): void;
|
|
10
|
+
declare function getElementViewLeft(element?: HTMLElement | null): number;
|
|
11
|
+
declare function createByJsx(element: JSX.Element | null): RenderTarget;
|
|
12
|
+
declare const dom: {
|
|
13
|
+
parseHtml: typeof parseHtml;
|
|
14
|
+
create: typeof create;
|
|
15
|
+
createFragment: typeof createFragment;
|
|
16
|
+
createHtmlElement: typeof createHtmlElement;
|
|
17
|
+
createByJsx: typeof createByJsx;
|
|
18
|
+
append: typeof append;
|
|
19
|
+
empty: typeof empty;
|
|
20
|
+
replace: typeof replace;
|
|
21
|
+
removeSelf: typeof removeSelf;
|
|
22
|
+
getElementViewLeft: typeof getElementViewLeft;
|
|
23
|
+
};
|
|
24
|
+
export default dom;
|
|
@@ -1,15 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
interface INotifierExecutor<P = any> {
|
|
2
|
+
(param?: P): any;
|
|
3
|
+
}
|
|
4
|
+
interface INotifierSubscription<K, P> {
|
|
5
|
+
unSubscribe(name: K, executor: INotifierExecutor<P>): void;
|
|
6
|
+
}
|
|
7
|
+
interface INotifier<K, P = any> {
|
|
8
|
+
publish(name: K, params?: P): void;
|
|
9
|
+
subscribe(name: K, executor: INotifierExecutor<P>): INotifierSubscription<K, P>;
|
|
10
|
+
unSubscribe(name: K, executor: INotifierExecutor<P>): void;
|
|
11
|
+
}
|
|
2
12
|
export interface IEvent {
|
|
3
|
-
readonly name
|
|
4
|
-
readonly target
|
|
13
|
+
readonly name?: string;
|
|
14
|
+
readonly target?: any;
|
|
5
15
|
}
|
|
6
16
|
export interface IEventMap {
|
|
7
|
-
baseEvent: IEvent;
|
|
8
17
|
}
|
|
9
18
|
export declare class Events<M extends IEventMap> {
|
|
10
|
-
|
|
19
|
+
protected _notifier: INotifier<any, any>;
|
|
11
20
|
constructor();
|
|
12
21
|
addEventListener<K extends keyof M>(name: K, callBack: (event?: M[K]) => any): void;
|
|
13
22
|
removeEventListener<K extends keyof M>(name: K, callBack: (event?: M[K]) => any): void;
|
|
14
23
|
protected dispatch<K extends keyof M>(name: K, event?: M[K]): void;
|
|
15
24
|
}
|
|
25
|
+
export {};
|
|
@@ -1,7 +1,25 @@
|
|
|
1
1
|
declare const core: {
|
|
2
2
|
render: (node: import("./types").RenderTarget, container?: import("./types").RenderTarget | undefined, _callBack?: (() => any) | undefined) => void;
|
|
3
|
-
|
|
3
|
+
style: {
|
|
4
|
+
cls: (...args: any[]) => string;
|
|
5
|
+
css: (literals: TemplateStringsArray, ...values: (string | number)[]) => string;
|
|
6
|
+
prefixCls: (...args: any[]) => string;
|
|
7
|
+
commonCls: (...args: any[]) => string;
|
|
8
|
+
};
|
|
9
|
+
dom: {
|
|
10
|
+
parseHtml: (htmlString: string) => DocumentFragment;
|
|
11
|
+
create: <K extends keyof HTMLElementTagNameMap>(tag: K, className?: string | undefined) => HTMLElementTagNameMap[K];
|
|
12
|
+
createFragment: () => DocumentFragment;
|
|
13
|
+
createHtmlElement: (tag: string, className?: string | undefined) => HTMLElement;
|
|
14
|
+
createByJsx: (element: JSX.Element<any> | null) => import("./types").RenderTarget;
|
|
15
|
+
append: <N extends Node>(parent?: N | null | undefined, ...children: (N | null)[]) => void;
|
|
16
|
+
empty: <N_1 extends Node>(parent?: N_1 | null | undefined) => void;
|
|
17
|
+
replace: <N_2 extends Node>(oldNode: N_2 | null, ...newNodes: (N_2 | null)[]) => void;
|
|
18
|
+
removeSelf: <N_3 extends Node>(el?: N_3 | null | undefined) => void;
|
|
19
|
+
getElementViewLeft: (element?: HTMLElement | null | undefined) => number;
|
|
20
|
+
};
|
|
21
|
+
field: {
|
|
22
|
+
createPrefixStorageField: (field: string) => string;
|
|
23
|
+
};
|
|
4
24
|
};
|
|
5
|
-
export declare const CSS_CLASS_PREFIX: string | undefined;
|
|
6
|
-
export declare const STORAGE_FIELD_PREFIX: string | undefined;
|
|
7
25
|
export default core;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { RenderTarget } from "./types";
|
|
2
|
+
export declare function grow(element: JSX.Element | null, elementFactory?: (element: JSX.Element | null) => JSX.Element | null, xmlns?: string): RenderTarget;
|
|
3
|
+
declare function h<K extends keyof HTMLElementTagNameMap>(type: K | string, elementProps: any, ...childElements: any[]): JSX.Element;
|
|
4
|
+
declare const jsx: {
|
|
5
|
+
h: typeof h;
|
|
6
|
+
Fragment: (props: IJsxProps) => any[] | undefined;
|
|
7
|
+
};
|
|
8
|
+
export default jsx;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare type Text = string | number;
|
|
2
|
+
declare const css: (literals: TemplateStringsArray, ...values: Text[]) => string;
|
|
3
|
+
export { css };
|
|
4
|
+
declare const style: {
|
|
5
|
+
cls: (...args: any[]) => string;
|
|
6
|
+
css: (literals: TemplateStringsArray, ...values: Text[]) => string;
|
|
7
|
+
prefixCls: (...args: any[]) => string;
|
|
8
|
+
commonCls: (...args: any[]) => string;
|
|
9
|
+
};
|
|
10
|
+
export default style;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare type RenderTarget =
|
|
1
|
+
export declare type RenderTarget = HTMLElement | SVGElement | Text | DocumentFragment | null;
|
|
2
2
|
export interface Props {
|
|
3
3
|
children?: RenderTarget;
|
|
4
4
|
}
|
|
@@ -6,6 +6,10 @@ export interface IComponentInstance {
|
|
|
6
6
|
render(): RenderTarget;
|
|
7
7
|
destroy(): void;
|
|
8
8
|
}
|
|
9
|
+
export declare class EmptyComponentInstance implements IComponentInstance {
|
|
10
|
+
render(): RenderTarget;
|
|
11
|
+
destroy(): void;
|
|
12
|
+
}
|
|
9
13
|
export declare type ComponetsResult<I> = {
|
|
10
14
|
instance: I;
|
|
11
15
|
element: RenderTarget;
|
|
@@ -13,3 +17,5 @@ export declare type ComponetsResult<I> = {
|
|
|
13
17
|
export interface SFC<T extends Props, I extends IComponentInstance | null> {
|
|
14
18
|
(props?: T): ComponetsResult<I>;
|
|
15
19
|
}
|
|
20
|
+
export declare type Constructor<T> = new (...args: any[]) => T;
|
|
21
|
+
export declare type AbstractConstructor<T = object> = abstract new (...args: any[]) => T;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import "./styles/
|
|
1
|
+
import "./styles/_index.scss";
|
package/dist/types/main.d.ts
CHANGED
|
@@ -4,5 +4,5 @@ import Conference, { IConferenceProps, IConferenceInstance } from "./components/
|
|
|
4
4
|
import { RemoteSdpFetcher } from './instances/bvWebrtc';
|
|
5
5
|
import { IPuOption, IConfOption } from "./components/types";
|
|
6
6
|
declare const clearAllDialog: (token?: string | undefined) => Promise<void>;
|
|
7
|
-
import "./styles/
|
|
7
|
+
import "./styles/main.scss";
|
|
8
8
|
export { PuPlayer, Intercom, Conference, IPuPlayerProps, IPuPlayerInstance, IIntercomProps, IIntercomInstance, IConferenceProps, IConferenceInstance, IPuOption, IConfOption, RemoteSdpFetcher, clearAllDialog, };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IPluginEventMap, Plugin } from "../types";
|
|
2
|
+
interface IControllerButtonPluginEventMap extends IPluginEventMap {
|
|
3
|
+
click: undefined;
|
|
4
|
+
}
|
|
5
|
+
declare class ControllerButtonPlugin extends Plugin<HTMLButtonElement, IControllerButtonPluginEventMap> {
|
|
6
|
+
private _Children;
|
|
7
|
+
title?: string;
|
|
8
|
+
constructor(Children: JSX.Element, title?: string, className?: string);
|
|
9
|
+
set Children(v: JSX.Element);
|
|
10
|
+
protected beforeDestroy(): void;
|
|
11
|
+
init(): HTMLButtonElement;
|
|
12
|
+
}
|
|
13
|
+
export default ControllerButtonPlugin;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import ControllerPlugin from ".";
|
|
2
|
+
import { IPluginEvent, IPluginEventMap } from "../../plugins/types";
|
|
3
|
+
interface IControllerEvent extends IPluginEvent {
|
|
4
|
+
target: ControllerPlugin;
|
|
5
|
+
}
|
|
6
|
+
export interface IControllerPluginEventMap extends IPluginEventMap {
|
|
7
|
+
screenshot: IControllerEvent;
|
|
8
|
+
fullscreen: IControllerEvent;
|
|
9
|
+
information: IControllerEvent;
|
|
10
|
+
volume: IControllerEvent;
|
|
11
|
+
play: IControllerEvent;
|
|
12
|
+
}
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Plugin } from "../types";
|
|
2
|
+
import { IControllerPluginEventMap } from "./event";
|
|
3
|
+
import { CanVisibleCtor } from "../mixins/visible";
|
|
4
|
+
import ControllerButtonPlugin from "./button";
|
|
5
|
+
import SliderPlugin from "../slider";
|
|
6
|
+
interface IControllerPluginOptions {
|
|
7
|
+
controls?: string[];
|
|
8
|
+
}
|
|
9
|
+
declare class ControllerPluginBase extends Plugin<HTMLDivElement, IControllerPluginEventMap> {
|
|
10
|
+
private _controls;
|
|
11
|
+
private _volumeEl?;
|
|
12
|
+
PlayButton: ControllerButtonPlugin;
|
|
13
|
+
VolumeButton: ControllerButtonPlugin;
|
|
14
|
+
VolumeSlider: SliderPlugin;
|
|
15
|
+
InformationButton: ControllerButtonPlugin;
|
|
16
|
+
ScreenshotButton: ControllerButtonPlugin;
|
|
17
|
+
FullscreenButton: ControllerButtonPlugin;
|
|
18
|
+
constructor(options?: IControllerPluginOptions);
|
|
19
|
+
activeVolume(): void;
|
|
20
|
+
hideVolume(): void;
|
|
21
|
+
protected beforeDestroy(): void;
|
|
22
|
+
init(): HTMLDivElement;
|
|
23
|
+
}
|
|
24
|
+
declare const _mixinsControllerPluginBase: CanVisibleCtor & typeof ControllerPluginBase;
|
|
25
|
+
export default class ControllerPlugin extends _mixinsControllerPluginBase {
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Constructor, AbstractConstructor } from "../../core/types";
|
|
2
|
+
interface SimilarPlugin {
|
|
3
|
+
name: string;
|
|
4
|
+
el?: HTMLElement | null;
|
|
5
|
+
show?(): any;
|
|
6
|
+
hide?(): any;
|
|
7
|
+
}
|
|
8
|
+
interface CanVisible {
|
|
9
|
+
visible: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare type CanVisibleCtor = Constructor<CanVisible> & AbstractConstructor<CanVisible>;
|
|
12
|
+
export default function mixinVisible<T extends Constructor<SimilarPlugin>>(base: T): CanVisibleCtor & T;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { IPluginEvent, IPluginEventMap, Plugin } from "./types";
|
|
2
|
+
import { CanVisibleCtor } from "./mixins/visible";
|
|
3
|
+
interface IModalPluginEvent extends IPluginEvent {
|
|
4
|
+
target: ModalPluginBase;
|
|
5
|
+
}
|
|
6
|
+
interface IControllerPluginEventMap extends IPluginEventMap {
|
|
7
|
+
show: IModalPluginEvent;
|
|
8
|
+
hide: IModalPluginEvent;
|
|
9
|
+
}
|
|
10
|
+
interface IModalPluginOption {
|
|
11
|
+
container: HTMLElement;
|
|
12
|
+
title?: string;
|
|
13
|
+
content?: HTMLElement;
|
|
14
|
+
center?: boolean;
|
|
15
|
+
className?: string;
|
|
16
|
+
}
|
|
17
|
+
declare class ModalPluginBase extends Plugin<HTMLDivElement, IControllerPluginEventMap> {
|
|
18
|
+
container: HTMLElement;
|
|
19
|
+
title?: string;
|
|
20
|
+
private _content;
|
|
21
|
+
private _center;
|
|
22
|
+
constructor(options: IModalPluginOption);
|
|
23
|
+
set content(content: JSX.Element);
|
|
24
|
+
show(): void;
|
|
25
|
+
hide(): void;
|
|
26
|
+
clear(): void;
|
|
27
|
+
protected beforeDestroy(): void;
|
|
28
|
+
init(): HTMLDivElement;
|
|
29
|
+
}
|
|
30
|
+
declare const _mixinsModalPluginBase: CanVisibleCtor & typeof ModalPluginBase;
|
|
31
|
+
export default class ModalPlugin extends _mixinsModalPluginBase {
|
|
32
|
+
}
|
|
33
|
+
export {};
|
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
import { IPluginEventMap } from "../../plugins/types";
|
|
2
|
-
import { PLAYER_MODES } from "./index";
|
|
3
|
-
interface
|
|
1
|
+
import { IPluginEvent, IPluginEventMap } from "../../plugins/types";
|
|
2
|
+
import PlayerPlugin, { PLAYER_MODES } from "./index";
|
|
3
|
+
interface IPlayerEvent extends IPluginEvent {
|
|
4
|
+
target: PlayerPlugin;
|
|
5
|
+
}
|
|
6
|
+
interface IInitEvent extends IPlayerEvent {
|
|
7
|
+
name: "initEvent";
|
|
4
8
|
mode: PLAYER_MODES;
|
|
5
9
|
}
|
|
6
|
-
interface
|
|
10
|
+
interface ICloseWebrtcEvent extends IPlayerEvent {
|
|
11
|
+
name: "closeWebrtcEvent";
|
|
7
12
|
peerConnection?: RTCPeerConnection;
|
|
8
13
|
}
|
|
9
14
|
export interface IPlayerPluginEventMap extends IPluginEventMap {
|
|
10
|
-
init:
|
|
11
|
-
closeWebrtc:
|
|
15
|
+
init: IInitEvent;
|
|
16
|
+
closeWebrtc: ICloseWebrtcEvent;
|
|
12
17
|
}
|
|
13
18
|
export {};
|