yjz-web-sdk 1.0.4-beta.7 → 1.0.5-beta.0
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/lib/yjz-web-sdk.js +2 -2
- package/lib/yjz-web-sdk.umd.cjs +1 -1
- package/package.json +1 -3
package/lib/yjz-web-sdk.js
CHANGED
|
@@ -4261,8 +4261,8 @@ function useRemoteVideo(videoContainer, remoteVideoElement, videoAngle, emit) {
|
|
|
4261
4261
|
let height = 0;
|
|
4262
4262
|
const containerWidth = isRotated.value ? dimensions.value.height : dimensions.value.width;
|
|
4263
4263
|
const containerHeight = isRotated.value ? dimensions.value.width : dimensions.value.height;
|
|
4264
|
-
const vWidth = remoteVideo.value.width ??
|
|
4265
|
-
const vHeight = remoteVideo.value.height ??
|
|
4264
|
+
const vWidth = remoteVideo.value.width ?? 720;
|
|
4265
|
+
const vHeight = remoteVideo.value.height ?? 1280;
|
|
4266
4266
|
const aspect = vWidth / vHeight;
|
|
4267
4267
|
const videoHeight = containerWidth / aspect;
|
|
4268
4268
|
if (videoHeight > containerHeight) {
|
package/lib/yjz-web-sdk.umd.cjs
CHANGED
|
@@ -110,7 +110,7 @@ Insert:124,Delete:112,Home:122,End:123,PageUp:92,PageDown:93,ScrollLock:116,Paus
|
|
|
110
110
|
* @param visible
|
|
111
111
|
*/setViewIds(e,t){this.visibility.clear(),e.forEach((e=>{this.visibility.set(e,t)}))}getChanges(){const e=[];return this.visibility.forEach(((t,n)=>{const r=this.prevVisibility.get(n)??!1;e.push({viewId:n,nowVisible:t,wasVisible:r}),this.prevVisibility.set(n,t)})),e}clear(){this.visibility.clear(),this.prevVisibility.clear()}}class We{constructor(e,t){r(this,"timer",null),this.interval=e,this.callback=t}start(){this.timer||(this.timer=setInterval(this.callback,this.interval))}stop(){this.timer&&(clearInterval(this.timer),this.timer=null)}}class Je extends d{constructor(e){super(),r(this,"sdk"),r(this,"config"),this.config=e,this.sdk=new Ne(this.config),this.initSdk()}initSdk(){const e=this.config.roomId;this.sdk.removeAllListeners(),this.config.isControl?(this.sdk.on(m.streamTrack,(e=>{const t="video"===e.kind;this.emit(m.streamTrack,t,e)})),this.sdk.on(m.cloudStatusChanged,(e=>{this.emit(m.cloudStatusChanged,e)}))):this.sdk.on(m.screenshot,(t=>this.emit(m.screenshot,e,t))),this.sdk.on(m.iceConnectionState,(t=>this.emit(m.iceConnectionState,e,t))),this.sdk.on(m.webrtcError,(t=>{this.emit(m.webrtcError,e,t),this.stop()}))}
|
|
112
112
|
// 动态更新 isControl 值
|
|
113
|
-
setIsControl(e){this.config.isControl!==e&&(this.config.isControl=e,this.initSdk())}start(){this.sdk.startConnection()}stop(){this.sdk.stop(),this.sdk.removeAllListeners()}sendData(e,t){(this.config.canOperate||this.config.isControl)&&1===this.config.connectStatus&&this.sdk.sendChannelData(e,t)}sendControlData(e){(this.config.canOperate||this.config.isControl)&&1===this.config.connectStatus&&this.sdk.sendControlEvent(e)}requestScreenshot(e){this.sdk.sendRequestScreenshot(e)}}function Be(e,n,r,i){const o=t.ref(!1),s=t.ref({}),a=t.ref({width:0,height:0}),c=t.ref(0),d=t.ref(0),l=t.ref(null),p=t.ref(0),h=t.computed((()=>r.value%180!=0)),u=t.computed((()=>{let e=0,t=0;const n=h.value?a.value.height:a.value.width,r=h.value?a.value.width:a.value.height,i=s.value.width??
|
|
113
|
+
setIsControl(e){this.config.isControl!==e&&(this.config.isControl=e,this.initSdk())}start(){this.sdk.startConnection()}stop(){this.sdk.stop(),this.sdk.removeAllListeners()}sendData(e,t){(this.config.canOperate||this.config.isControl)&&1===this.config.connectStatus&&this.sdk.sendChannelData(e,t)}sendControlData(e){(this.config.canOperate||this.config.isControl)&&1===this.config.connectStatus&&this.sdk.sendControlEvent(e)}requestScreenshot(e){this.sdk.sendRequestScreenshot(e)}}function Be(e,n,r,i){const o=t.ref(!1),s=t.ref({}),a=t.ref({width:0,height:0}),c=t.ref(0),d=t.ref(0),l=t.ref(null),p=t.ref(0),h=t.computed((()=>r.value%180!=0)),u=t.computed((()=>{let e=0,t=0;const n=h.value?a.value.height:a.value.width,r=h.value?a.value.width:a.value.height,i=s.value.width??720,o=s.value.height??1280,l=i/o,p=n/l;return p>r?(t=r,e=t*l):(e=n,t=p),c.value=i/e,d.value=o/t,{width:e,height:t}})),f=()=>{o.value=!1;const e=n.value;e&&e.srcObject&&(e.srcObject.getTracks().forEach((e=>e.stop())),e.srcObject=null,e.cancelVideoFrameCallback(p.value))};return t.onBeforeUnmount((()=>{l.value&&e.value&&l.value.unobserve(e.value),f()})),{videoSize:u,remoteVideo:s,dimensions:a,widthRadio:c,heightRadio:d,screenStatus:o,initVideoContainer:()=>{e.value&&(l.value=new ResizeObserver((([e])=>{const{width:t,height:n}=e.contentRect;a.value={width:t,height:n}})),l.value.observe(e.value)),(()=>{const e=n.value;if(!e)return;const r=()=>{s.value={width:e.videoWidth,height:e.videoHeight},o.value=!0,i("loadedSuccess")};e.addEventListener("loadedmetadata",r),t.onBeforeUnmount((()=>{e.removeEventListener("loadedmetadata",r)}))})()},startPlay:e=>{const t=n.value;t&&(t.srcObject||(t.srcObject=new MediaStream),t.playsInline=!0,t.setAttribute("webkit-playsinline","true"),t.srcObject.addTrack(e))},stopPlay:f}}const Ge=((e,t)=>{const n=e.__vccOpts||e;for(const[r,i]of t)n[r]=i;return n})(t.defineComponent({__name:"index",props:{streamAngle:{default:0},videoAngle:{default:0},cursorType:{default:0},cloudDeviceSize:{default:()=>({width:0,height:0})},disabled:{type:Boolean,default:!0},bgColor:{default:"transparent"}},emits:["channelEvent","groupControlEvent","loadedSuccess"],setup(e,{expose:n,emit:r}){const i=r,o=e,{streamAngle:s,videoAngle:a,cursorType:c,cloudDeviceSize:d,disabled:l,bgColor:p}=t.toRefs(o),h=t.ref(null),u=t.ref(null),{isMobile:f,checkDeviceMode:m,checkTouchSupport:C,handleUp:g}=function(){const e=t.ref(!1);return{isMobile:e,checkDeviceMode:()=>{e.value=/Android|iPhone|iPad|iPod|Mobile/i.test(navigator.userAgent)},checkTouchSupport:()=>{navigator.maxTouchPoints>0&&(e.value=!0)},handleUp:()=>{}}}(),v=function(e){return t.computed((()=>{switch(e.value){case 1:return"circle-cursor";case 2:return"triangle-cursor";default:return"default-cursor"}}))}(c),{videoSize:y,dimensions:S,widthRadio:T,initVideoContainer:R,startPlay:b,stopPlay:P}=Be(h,u,a,i),{onTouchStart:w,onTouchMove:E,onTouchEnd:k,handleMouseDown:_,handleMouseMove:A,handleMouseEnter:D,handleMouseUp:I,handleMouseLeave:O,handleWheel:M}=function(e){const{isMobile:n,remoteVideoElement:r,cloudDeviceSize:i,streamAngle:o,videoAngle:s,widthRadio:a,emit:c}=e,d=t.ref(!1),l=t.ref(0),p=t.ref(new Array(20).fill(0)),h=t.ref(new Array(10).fill(0)),u=t.ref(0),f=t.ref(0),m=(e,t)=>{if(!r.value)return;const n=Math.trunc(e.timeStamp-h.value[0]),a=r.value.getBoundingClientRect();let d=e.clientX-a.left,u=e.clientY-a.top;const f=i.value.width,m=i.value.height,C=Fe(a.width,a.height,f,m,s.value,o.value,d,u);if(!C||C.length<2)return;if(d=C[0],u=C[1],t===_e.ACTION_MOVE){const e=p.value[10]-u,t=p.value[0]-d;if(Math.abs(e)<l.value&&Math.abs(t)<l.value)return}p.value[0]=d,p.value[10]=u;const g=Ve(a.width,a.height,f,m,s.value,o.value,d,u),v=new Ie(t,0,g[0],g[1],n);c("channelEvent",Ee.ClickData,v)},C=e=>{!n.value&&d.value&&(d.value=!1,m(e,_e.ACTION_UP),r.value&&r.value.releasePointerCapture(e.pointerId))};return{isPointerDown:d,onTouchStart:e=>{if(!n.value)return;const t=Array.from(e.touches);if(t.length>0){h.value[0]=e.timeStamp,l.value=Math.trunc(4/a.value),u.value=t[0].clientX,f.value=t[0].clientY;const n={clientX:u.value,clientY:f.value,timeStamp:e.timeStamp};m(n,_e.ACTION_DOWN)}},onTouchMove:e=>{if(!n.value)return;const t=Array.from(e.touches);if(t.length>0){u.value=t[0].clientX,f.value=t[0].clientY;const n={clientX:u.value,clientY:f.value,timeStamp:e.timeStamp};m(n,_e.ACTION_MOVE)}},onTouchEnd:e=>{if(!n.value)return;const t={clientX:u.value,clientY:f.value,timeStamp:e.timeStamp};m(t,_e.ACTION_UP)},handleMouseDown:e=>{n.value||(d.value=!0,r.value&&r.value.setPointerCapture(e.pointerId),h.value[0]=e.timeStamp,l.value=Math.trunc(4/a.value),m(e,_e.ACTION_DOWN))},handleMouseMove:e=>{if(n.value||!d.value)return;if(m(e,_e.ACTION_MOVE),!r.value)return;const t=r.value.getBoundingClientRect(),{clientX:i,clientY:o}=e;(i<t.left||i>t.right||o<t.top||o>t.bottom)&&C(e)},handleMouseEnter:e=>{n.value||1!==e.buttons||d.value||(d.value=!0,r.value&&r.value.setPointerCapture(e.pointerId),h.value[0]=e.timeStamp,l.value=Math.trunc(4/a.value),m(e,_e.ACTION_DOWN))},handleMouseUp:C,handleMouseLeave:e=>{d.value&&(m(e,_e.ACTION_UP),d.value=!1,r.value&&r.value.releasePointerCapture(e.pointerId))},handleWheel:e=>{const t=-1*Math.sign(e.deltaY),n=new Oe(t);c("channelEvent",Ee.ActionWheel,n)}}}({isMobile:f,remoteVideoElement:u,cloudDeviceSize:d,streamAngle:s,videoAngle:a,widthRadio:T,emit:i}),{startListening:x,stopListening:L}=function(e,n){const r=t.ref(!1),i=e=>{const t=Ue(e);n("channelEvent",Ee.ActionInput,t)};return{startListening:()=>{e&&(r.value=!0,document.addEventListener("keydown",i))},stopListening:()=>{e&&(r.value=!1,document.removeEventListener("keydown",i))}}}(l,i);!function(e,n){let r=null;t.onMounted((()=>{e.value&&(r=new ResizeObserver((e=>{for(const t of e){const{width:e,height:r}=t.contentRect;n.value={width:e,height:r}}})),r.observe(e.value))})),t.onUnmounted((()=>{null==r||r.disconnect()}))}(h,S);const N=()=>{var e;(null==(e=u.value)?void 0:e.srcObject)&&(u.value.muted=!1)};return t.onMounted((()=>{m(),window.addEventListener("resize",m),window.addEventListener("pointerdown",C),window.addEventListener("pointerup",g),document.addEventListener("click",N),R()})),t.onUnmounted((()=>{window.removeEventListener("resize",m),window.removeEventListener("pointerdown",C),window.removeEventListener("pointerup",g),document.removeEventListener("click",N)})),n({startPlay:b,stopPlay:P}),(e,n)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"videoContainer",ref:h,class:"flex flex-1 items-center justify-center",style:{width:"100%",height:"100%",position:"relative",overflow:"hidden"}},[t.createElementVNode("div",{ref:"keyboardArea",onPointerenter:n[9]||(n[9]=//@ts-ignore
|
|
114
114
|
(...e)=>t.unref(x)&&t.unref(x)(...e)),onPointerleave:n[10]||(n[10]=//@ts-ignore
|
|
115
115
|
(...e)=>t.unref(L)&&t.unref(L)(...e)),class:"vContainer",style:t.normalizeStyle([{height:t.unref(y).height+"px",width:t.unref(y).width+"px",transform:`rotate(${t.unref(a)}deg)`},{position:"relative",overflow:"hidden"}])},[t.createElementVNode("video",{ref_key:"remoteVideoElement",ref:u,class:t.normalizeClass(["video-control",[t.unref(v),{"no-events":t.unref(l)}]]),onTouchstart:n[0]||(n[0]=//@ts-ignore
|
|
116
116
|
(...e)=>t.unref(w)&&t.unref(w)(...e)),onTouchmove:n[1]||(n[1]=//@ts-ignore
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yjz-web-sdk",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.5-beta.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "针对于亚矩阵项目的云手机投屏和屏幕控制",
|
|
7
7
|
"license": "Apache-2.0",
|
|
@@ -32,10 +32,8 @@
|
|
|
32
32
|
"preview": "vite preview"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"element-plus": "^2.9.9",
|
|
36
35
|
"eventemitter3": "^5.0.1",
|
|
37
36
|
"terser": "^5.39.0",
|
|
38
|
-
"vite-svg-loader": "^5.1.0",
|
|
39
37
|
"vue": "^3.5.13",
|
|
40
38
|
"webrtc-adapter": "^9.0.1"
|
|
41
39
|
},
|