@bddh/starling-realtime-client 1.0.9 → 1.0.11
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/cjs/BrtcClient.js +1 -1
- package/cjs/DomControl.js +1 -1
- package/es/BrtcClient.js +1 -1
- package/es/DomControl.js +1 -1
- package/package.json +2 -2
package/cjs/BrtcClient.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./_virtual/_rollupPluginBabelHelpers.js"),t=require("@bddh/starling-brtc"),o=require("@bddh/starling-timeout-controller"),n=require("@bddh/starling-json"),c=require("lodash/isEmpty"),r=require("lodash/isFunction"),i=require("./interface.js"),a=e.createClass((function a(l){var s=this;e.classCallCheck(this,a),e.defineProperty(this,"client",void 0),e.defineProperty(this,"isRtcVideoOn",!1),e.defineProperty(this,"rtcConnection",void 0),e.defineProperty(this,"rtcConfig",void 0),e.defineProperty(this,"bizConfig",void 0),e.defineProperty(this,"rtcCallback",void 0),e.defineProperty(this,"restarting",!1),e.defineProperty(this,"timeoutEvent",void 0),e.defineProperty(this,"reopenTimer",void 0),e.defineProperty(this,"restartCount",0),e.defineProperty(this,"closeLog",!0),e.defineProperty(this,"haveVideoOn",!1),e.defineProperty(this,"rtcStateCallback",null),e.defineProperty(this,"openRtc",(function(e){if(s.restarting)!s.closeLog&&console.warn("rtc restarting");else if(e&&(s.rtcConnection=e),s.rtcConnection&&!c(s.rtcConnection)){var o=s.rtcConnection,a=o.server,l=o.appId,d=o.token,u=o.roomName,C=o.userId,m=s.rtcCallback||{},f=m.onRemotedata,b=m.onLocalStream,g=m.onRemoteVideoComing,y=m.onLocalVideoPublished,v=m.onLocalVideoPublishing,R=m.onRemoteVideoOn,h=m.onRemoteVideoOff,p=m.onRemoteVideoLoading,L=m.onSuccess,S=m.onError,k=m.onLocalVideoConnected,E=m.onRemoteVideoConnected,V=m.onRemoteMediaState,P=m.onPlayingError,_=m.onDigitalHumanCallback;s.timeoutEvent.start(),s.rtcStateCallback=function(e){var t=e.body,o=e.action;_&&_({status:i.statusEnum.DH_LIB_FULL_STATUS,content:{type:"rtcState",action:o,body:t}})},s.client=new t({roomName:u,token:d,userId:C,appId:l,server:a,rtcConfig:s.rtcConfig,callback:{onRemoteVideoConnected:function(t,o){if(!o&&!s.haveVideoOn)var n=setTimeout((function(){s.restartCount<3?(s.restartCount=++s.restartCount,s.restartRtc&&s.restartRtc(e)):(s.restartCount=0,s.closeRtc()),clearTimeout(n)}),500);if(o){var c=document.getElementById("remotevideo500");c.muted=!1;var a=c.play();void 0!==a&&a.catch((function(){c.muted=!0,c.play().catch((function(e){!s.closeLog&&console.info("videoElement play error",e),P&&P(c),_&&_({status:i.statusEnum.DH_LIB_ERROR,content:{type:i.errorTypeEnum.LOCAL_VIDEO_ERROR}})})),_&&_({status:i.statusEnum.DH_LIB_STATUS,content:{type:i.errorTypeEnum.LOCAL_VIDEO_MUTED}})}))}!s.closeLog&&console.info("remoteVideoConnected",t,o,s.restartCount),s.rtcStateCallback&&s.rtcStateCallback({action:"remoteVideoConnected",body:{id:t,connected:o,restartCount:s.restartCount}}),r(E)&&E(t,o)},onRemoteVideoOn:function(e){s.haveVideoOn=!0,!s.closeLog&&console.info("remotevideoon by id: ",e),s.timeoutEvent.clear();var t=document.querySelector("#starlingRtcContainer"),o=t&&t.lastChild;o&&(o.style.display="none"),s.rtcStateCallback&&s.rtcStateCallback({action:"remotevideoon",body:e}),_&&_({status:i.statusEnum.DH_LIB_OPEN}),r(R)&&R(e)},onRemoteMediaState:function(e,t,o){!s.closeLog&&console.info("remoteMediaState",e,t,o),s.rtcStateCallback&&s.rtcStateCallback({action:"remoteMediaState",body:{id:e,medium:t,connected:o}}),r(V)&&V(e,t,o)},onLocalVideoConnected:function(e){!s.closeLog&&console.info("localVideoConnected",e),s.rtcStateCallback&&s.rtcStateCallback({action:"localVideoConnected",body:{connected:e}}),r(k)&&k(e)},onRemotedata:function(e){if(s.rtcConfig&&s.rtcConfig.usingdatachannel){var t=n.parse(e);!s.closeLog&&console.info("RTC - receive:",t),r(f)&&f(t)}},onLocalStream:function(e,t){!s.closeLog&&console.info("rtc - onlocalstream by name: "+t),s.rtcStateCallback&&s.rtcStateCallback({action:"onlocalstream",body:{stream:e,name:t}}),r(b)&&b(e,t)},onLocalVideoPublished:function(){!s.closeLog&&console.info("LocalVideoPublished 本地视频发布成功"),s.rtcStateCallback&&s.rtcStateCallback({action:"localvideopublished_ok",body:!0}),r(y)&&y()},onLocalVideoPublishing:function(){!s.closeLog&&console.info("LocalVideoPublishing 本地视频发布成功"),s.rtcStateCallback&&s.rtcStateCallback({action:"localvideopublishing",body:!0}),r(v)&&v()},onRemoteVideoComing:function(e){!s.closeLog&&console.info("remotevideocoming",e),s.rtcStateCallback&&s.rtcStateCallback({action:"remotevideocoming",body:e}),r(g)&&g(e)},onRemoteVideoLoading:function(e){!s.closeLog&&console.info("remotevideoloading by id: ",e),s.rtcStateCallback&&s.rtcStateCallback({action:"remotevideoloading",body:e}),r(p)&&p(e)},onRemoteVideoOff:function(e){var t=document.getElementById("remotevideo500");t&&t.pause(),!s.closeLog&&console.info("remotevideooff: ",e),s.isRtcVideoOn=!1,s.rtcStateCallback&&s.rtcStateCallback({action:"remotevideooff",body:e}),_&&_({status:i.statusEnum.DH_LIB_CLOSE}),r(h)&&h(e),s.timeoutEvent.start()},onSuccess:function(){!s.closeLog&&console.info("rtc - success"),s.rtcStateCallback&&s.rtcStateCallback({action:"success",body:!0}),r(L)&&L()},onError:function(t){s.isRtcVideoOn=!1,!s.closeLog&&console.error("rtc - error:",t),s.rtcStateCallback&&s.rtcStateCallback({action:"error",body:t}),_&&_({status:i.statusEnum.DH_LIB_ERROR,content:{type:i.errorTypeEnum.RTC_ERROR}}),r(S)&&S(t),(t.includes("Lost connection to the server")||t.includes("Is the server down"))&&s.restartRtc&&s.restartRtc(e)}}})}})),e.defineProperty(this,"closeRtc",(function(){s.timeoutEvent.clear(),clearTimeout(s.reopenTimer),s.client&&s.client.destroy(),s.restarting=!1})),e.defineProperty(this,"restartRtc",(function(e){!s.restarting&&s.bizConfig&&s.bizConfig.autoReConnect&&(s.rtcStateCallback&&s.rtcStateCallback({action:"restartRtc",body:e}),s.restarting=!0,s.closeRtc(),s.reopenTimer=setTimeout((function(){!s.closeLog&&console.error("拉流失败,开始重启"),s.restarting=!1,s.openRtc(e)}),2e3))}));var d=l.rtcConnection,u=l.rtcConfig,C=l.closeLog,m=void 0===C||C,f=l.rtcCallback;this.rtcConnection=d,this.rtcConfig=u,this.rtcCallback=f,this.closeLog=m,this.timeoutEvent=new o.TimeoutController(6e4,(function(){if(!s.rtcConnection)return!s.closeLog&&console.warn("remotevideoon事件超时, rtcConnectionRef is null");s.timeoutEvent.clear(),s.restartRtc&&s.restartRtc(s.rtcConnection)}))}));exports.default=a;
|
package/cjs/DomControl.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var t="starling-cutout-canvas",e="cloud-brtc-player-wrapper",n="remotevideo500";exports.DEFAULT_CANVAS_ID=t,exports.HUMAN_WRAPPER_ID=e,exports.RTC_VIDEO_ID=n,exports.appendRtcDomStyle=function(){var t=document.createElement("style");t.appendChild(document.createTextNode('\n [id^="videoremote1-"] {\n display: none !important;\n }\n \n video#remotevideo500 {\n width: auto !important;\n height: auto !important;\n max-width: 100% !important;\n max-height: 100% !important;\n width: 100% !important;\n height: 100% !important;\n object-fit: cover;\n }\n\n .cloud-brtc-player-wrapper {\n width: inherit !important;\n background-size: cover;\n height: inherit;\n display: flex;\n justify-content: center;\n }\n\n #starling-cutout-canvas {\n object-fit: cover;\n }\n ')),document.head.appendChild(t)},exports.checkIsHuawei=function(){var t=navigator.userAgent||navigator.vendor;return/huawei/i.test(t)||/honor/i.test(t)},exports.createHumanDom=function(i){var o=i.autoChromaKey,r=void 0!==o&&o,a=i.autoplay,d=void 0===a||a;if(document.getElementById(n))return console.error('DOM with id "'.concat(n,'" already exists.')),null;var u=document.createElement("div");u.className=e,u.id=e,u.style.position="relative";var c=document.createElement("video");c.id=n,c.width=0,c.height=0,c.setAttribute("width","100%"),c.setAttribute("height","100%"),c.setAttribute("data-playing","true"),c.setAttribute("playsinline","");var p=document.createElement("canvas");return p.id=t,Object.assign(p.style,{position:"absolute",top:"0",left:"0",height:"100%",width:"100%",zIndex:"1",display:r?"block":"none"}),d&&c.setAttribute("autoplay",""),r&&(c.style.visibility="hidden"),u.appendChild(c),u.appendChild(p),{playerWrapper:u,video:c}},exports.muteHumanVideo=function(t){var e=document.getElementById(n);return e&&(e.muted=t),e},exports.playHumanVideo=function(t){var e=document.getElementById(n);try{if(e)return t?e.play():e.pause()}catch(t){console.info(t)}},exports.removeHumanDom=function(){var t=document.getElementById(e);t&&t.parentNode&&t.parentNode.removeChild(t)};
|
package/es/BrtcClient.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createClass as t,classCallCheck as o,defineProperty as e}from"./_virtual/_rollupPluginBabelHelpers.js";import n from"@bddh/starling-brtc";import{TimeoutController as c}from"@bddh/starling-timeout-controller";import
|
|
1
|
+
import{createClass as t,classCallCheck as o,defineProperty as e}from"./_virtual/_rollupPluginBabelHelpers.js";import n from"@bddh/starling-brtc";import{TimeoutController as c}from"@bddh/starling-timeout-controller";import a from"@bddh/starling-json";import i from"lodash/isEmpty";import r from"lodash/isFunction";import{statusEnum as l,errorTypeEnum as s}from"./interface.js";var d=t((function t(d){var m=this;o(this,t),e(this,"client",void 0),e(this,"isRtcVideoOn",!1),e(this,"rtcConnection",void 0),e(this,"rtcConfig",void 0),e(this,"bizConfig",void 0),e(this,"rtcCallback",void 0),e(this,"restarting",!1),e(this,"timeoutEvent",void 0),e(this,"reopenTimer",void 0),e(this,"restartCount",0),e(this,"closeLog",!0),e(this,"haveVideoOn",!1),e(this,"rtcStateCallback",null),e(this,"openRtc",(function(t){if(m.restarting)!m.closeLog&&console.warn("rtc restarting");else if(t&&(m.rtcConnection=t),m.rtcConnection&&!i(m.rtcConnection)){var o=m.rtcConnection,e=o.server,c=o.appId,d=o.token,u=o.roomName,C=o.userId,f=m.rtcCallback||{},b=f.onRemotedata,g=f.onLocalStream,v=f.onRemoteVideoComing,R=f.onLocalVideoPublished,h=f.onLocalVideoPublishing,L=f.onRemoteVideoOn,S=f.onRemoteVideoOff,k=f.onRemoteVideoLoading,y=f.onSuccess,p=f.onError,V=f.onLocalVideoConnected,E=f.onRemoteVideoConnected,_=f.onRemoteMediaState,O=f.onPlayingError,I=f.onDigitalHumanCallback;m.timeoutEvent.start(),m.rtcStateCallback=function(t){var o=t.body,e=t.action;I&&I({status:l.DH_LIB_FULL_STATUS,content:{type:"rtcState",action:e,body:o}})},m.client=new n({roomName:u,token:d,userId:C,appId:c,server:e,rtcConfig:m.rtcConfig,callback:{onRemoteVideoConnected:function(o,e){if(!e&&!m.haveVideoOn)var n=setTimeout((function(){m.restartCount<3?(m.restartCount=++m.restartCount,m.restartRtc&&m.restartRtc(t)):(m.restartCount=0,m.closeRtc()),clearTimeout(n)}),500);if(e){var c=document.getElementById("remotevideo500");c.muted=!1;var a=c.play();void 0!==a&&a.catch((function(){c.muted=!0,c.play().catch((function(t){!m.closeLog&&console.info("videoElement play error",t),O&&O(c),I&&I({status:l.DH_LIB_ERROR,content:{type:s.LOCAL_VIDEO_ERROR}})})),I&&I({status:l.DH_LIB_STATUS,content:{type:s.LOCAL_VIDEO_MUTED}})}))}!m.closeLog&&console.info("remoteVideoConnected",o,e,m.restartCount),m.rtcStateCallback&&m.rtcStateCallback({action:"remoteVideoConnected",body:{id:o,connected:e,restartCount:m.restartCount}}),r(E)&&E(o,e)},onRemoteVideoOn:function(t){m.haveVideoOn=!0,!m.closeLog&&console.info("remotevideoon by id: ",t),m.timeoutEvent.clear();var o=document.querySelector("#starlingRtcContainer"),e=o&&o.lastChild;e&&(e.style.display="none"),m.rtcStateCallback&&m.rtcStateCallback({action:"remotevideoon",body:t}),I&&I({status:l.DH_LIB_OPEN}),r(L)&&L(t)},onRemoteMediaState:function(t,o,e){!m.closeLog&&console.info("remoteMediaState",t,o,e),m.rtcStateCallback&&m.rtcStateCallback({action:"remoteMediaState",body:{id:t,medium:o,connected:e}}),r(_)&&_(t,o,e)},onLocalVideoConnected:function(t){!m.closeLog&&console.info("localVideoConnected",t),m.rtcStateCallback&&m.rtcStateCallback({action:"localVideoConnected",body:{connected:t}}),r(V)&&V(t)},onRemotedata:function(t){if(m.rtcConfig&&m.rtcConfig.usingdatachannel){var o=a.parse(t);!m.closeLog&&console.info("RTC - receive:",o),r(b)&&b(o)}},onLocalStream:function(t,o){!m.closeLog&&console.info("rtc - onlocalstream by name: "+o),m.rtcStateCallback&&m.rtcStateCallback({action:"onlocalstream",body:{stream:t,name:o}}),r(g)&&g(t,o)},onLocalVideoPublished:function(){!m.closeLog&&console.info("LocalVideoPublished 本地视频发布成功"),m.rtcStateCallback&&m.rtcStateCallback({action:"localvideopublished_ok",body:!0}),r(R)&&R()},onLocalVideoPublishing:function(){!m.closeLog&&console.info("LocalVideoPublishing 本地视频发布成功"),m.rtcStateCallback&&m.rtcStateCallback({action:"localvideopublishing",body:!0}),r(h)&&h()},onRemoteVideoComing:function(t){!m.closeLog&&console.info("remotevideocoming",t),m.rtcStateCallback&&m.rtcStateCallback({action:"remotevideocoming",body:t}),r(v)&&v(t)},onRemoteVideoLoading:function(t){!m.closeLog&&console.info("remotevideoloading by id: ",t),m.rtcStateCallback&&m.rtcStateCallback({action:"remotevideoloading",body:t}),r(k)&&k(t)},onRemoteVideoOff:function(t){var o=document.getElementById("remotevideo500");o&&o.pause(),!m.closeLog&&console.info("remotevideooff: ",t),m.isRtcVideoOn=!1,m.rtcStateCallback&&m.rtcStateCallback({action:"remotevideooff",body:t}),I&&I({status:l.DH_LIB_CLOSE}),r(S)&&S(t),m.timeoutEvent.start()},onSuccess:function(){!m.closeLog&&console.info("rtc - success"),m.rtcStateCallback&&m.rtcStateCallback({action:"success",body:!0}),r(y)&&y()},onError:function(o){m.isRtcVideoOn=!1,!m.closeLog&&console.error("rtc - error:",o),m.rtcStateCallback&&m.rtcStateCallback({action:"error",body:o}),I&&I({status:l.DH_LIB_ERROR,content:{type:s.RTC_ERROR}}),r(p)&&p(o),(o.includes("Lost connection to the server")||o.includes("Is the server down"))&&m.restartRtc&&m.restartRtc(t)}}})}})),e(this,"closeRtc",(function(){m.timeoutEvent.clear(),clearTimeout(m.reopenTimer),m.client&&m.client.destroy(),m.restarting=!1})),e(this,"restartRtc",(function(t){!m.restarting&&m.bizConfig&&m.bizConfig.autoReConnect&&(m.rtcStateCallback&&m.rtcStateCallback({action:"restartRtc",body:t}),m.restarting=!0,m.closeRtc(),m.reopenTimer=setTimeout((function(){!m.closeLog&&console.error("拉流失败,开始重启"),m.restarting=!1,m.openRtc(t)}),2e3))}));var u=d.rtcConnection,C=d.rtcConfig,f=d.closeLog,b=void 0===f||f,g=d.rtcCallback;this.rtcConnection=u,this.rtcConfig=C,this.rtcCallback=g,this.closeLog=b,this.timeoutEvent=new c(6e4,(function(){if(!m.rtcConnection)return!m.closeLog&&console.warn("remotevideoon事件超时, rtcConnectionRef is null");m.timeoutEvent.clear(),m.restartRtc&&m.restartRtc(m.rtcConnection)}))}));export{d as default};
|
package/es/DomControl.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var t="starling-cutout-canvas",e="cloud-brtc-player-wrapper",n="remotevideo500";function i(i){var a=i.
|
|
1
|
+
var t="starling-cutout-canvas",e="cloud-brtc-player-wrapper",n="remotevideo500";function i(i){var a=i.autoChromaKey,o=void 0!==a&&a,r=i.autoplay,d=void 0===r||r;if(document.getElementById(n))return console.error('DOM with id "'.concat(n,'" already exists.')),null;var c=document.createElement("div");c.className=e,c.id=e,c.style.position="relative";var u=document.createElement("video");u.id=n,u.width=0,u.height=0,u.setAttribute("width","100%"),u.setAttribute("height","100%"),u.setAttribute("data-playing","true"),u.setAttribute("playsinline","");var l=document.createElement("canvas");return l.id=t,Object.assign(l.style,{position:"absolute",top:"0",left:"0",height:"100%",width:"100%",zIndex:"1",display:o?"block":"none"}),d&&u.setAttribute("autoplay",""),o&&(u.style.visibility="hidden"),c.appendChild(u),c.appendChild(l),{playerWrapper:c,video:u}}function a(){var t=document.getElementById(e);t&&t.parentNode&&t.parentNode.removeChild(t)}function o(t){var e=document.getElementById(n);return e&&(e.muted=t),e}function r(t){var e=document.getElementById(n);try{if(e)return t?e.play():e.pause()}catch(t){console.info(t)}}function d(){var t=navigator.userAgent||navigator.vendor;return/huawei/i.test(t)||/honor/i.test(t)}function c(){var t=document.createElement("style");t.appendChild(document.createTextNode('\n [id^="videoremote1-"] {\n display: none !important;\n }\n \n video#remotevideo500 {\n width: auto !important;\n height: auto !important;\n max-width: 100% !important;\n max-height: 100% !important;\n width: 100% !important;\n height: 100% !important;\n object-fit: cover;\n }\n\n .cloud-brtc-player-wrapper {\n width: inherit !important;\n background-size: cover;\n height: inherit;\n display: flex;\n justify-content: center;\n }\n\n #starling-cutout-canvas {\n object-fit: cover;\n }\n ')),document.head.appendChild(t)}export{t as DEFAULT_CANVAS_ID,e as HUMAN_WRAPPER_ID,n as RTC_VIDEO_ID,c as appendRtcDomStyle,d as checkIsHuawei,i as createHumanDom,o as muteHumanVideo,r as playHumanVideo,a as removeHumanDom};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bddh/starling-realtime-client",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.11",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"react",
|
|
6
6
|
"indexDB"
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"lodash": "^4.17.21",
|
|
45
45
|
"uuid": "^9.0.0"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "1fb3029720c63874413631a26bb84d4a50071148"
|
|
48
48
|
}
|