@bddh/starling-realtime-client 2.0.11-beta.3 → 2.0.11-beta.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/cjs/BrtcClient.js +1 -1
- package/es/BrtcClient.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 t=require("./_virtual/_rollupPluginBabelHelpers.js"),e=require("@bddh/starling-brtc"),o=require("@bddh/starling-timeout-controller"),n=require("@bddh/starling-json"),i=require("lodash/isEmpty"),c=require("lodash/isFunction"),r=require("./interface.js"),a=function(){function a(l){var s=this;t.classCallCheck(this,a),t.defineProperty(this,"client",void 0),t.defineProperty(this,"isRtcVideoOn",!1),t.defineProperty(this,"rtcConnection",void 0),t.defineProperty(this,"rtcConfig",void 0),t.defineProperty(this,"bizConfig",void 0),t.defineProperty(this,"rtcCallback",void 0),t.defineProperty(this,"restarting",!1),t.defineProperty(this,"timeoutEvent",void 0),t.defineProperty(this,"timeoutStarted",!1),t.defineProperty(this,"reopenTimer",void 0),t.defineProperty(this,"restartCount",0),t.defineProperty(this,"closeLog",!0),t.defineProperty(this,"stopped",!1),t.defineProperty(this,"haveVideoOn",!1),t.defineProperty(this,"rtcStateCallback",null),t.defineProperty(this,"startRtcTimeout",(function(){s.timeoutStarted||(s.timeoutEvent.start(),s.timeoutStarted=!0)})),t.defineProperty(this,"clearRtcTimeout",(function(){s.timeoutStarted&&(s.timeoutEvent.clear(),s.timeoutStarted=!1)})),t.defineProperty(this,"mergeRtcConfig",(function(t){s.rtcConfig&&t&&Object.keys(t).length&&Object.assign(s.rtcConfig,t)})),t.defineProperty(this,"openRtc",(function(t){if(s.stopped=!1,s.restarting)!s.closeLog&&console.warn("rtc restarting");else if(t&&(s.rtcConnection=t),s.rtcConnection&&!i(s.rtcConnection)){var o,a=s.rtcConnection,l=a.server,d=a.appId,u=a.token,f=a.roomName,m=a.userId,C=s.rtcCallback||{},b=C.onRemotedata,g=C.onLocalStream,p=C.onRemoteVideoComing,y=C.onLocalVideoPublished,h=C.onLocalVideoPublishing,v=C.onRemoteVideoOn,R=C.onRemoteVideoOff,S=C.onRemoteVideoLoading,L=C.onSuccess,k=C.onError,P=C.onLocalVideoConnected,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("./_virtual/_rollupPluginBabelHelpers.js"),e=require("@bddh/starling-brtc"),o=require("@bddh/starling-timeout-controller"),n=require("@bddh/starling-json"),i=require("lodash/isEmpty"),c=require("lodash/isFunction"),r=require("./interface.js"),a=function(){function a(l){var s=this;t.classCallCheck(this,a),t.defineProperty(this,"client",void 0),t.defineProperty(this,"isRtcVideoOn",!1),t.defineProperty(this,"rtcConnection",void 0),t.defineProperty(this,"rtcConfig",void 0),t.defineProperty(this,"bizConfig",void 0),t.defineProperty(this,"rtcCallback",void 0),t.defineProperty(this,"restarting",!1),t.defineProperty(this,"timeoutEvent",void 0),t.defineProperty(this,"timeoutStarted",!1),t.defineProperty(this,"reopenTimer",void 0),t.defineProperty(this,"restartCount",0),t.defineProperty(this,"closeLog",!0),t.defineProperty(this,"stopped",!1),t.defineProperty(this,"haveVideoOn",!1),t.defineProperty(this,"rtcStateCallback",null),t.defineProperty(this,"startRtcTimeout",(function(){s.timeoutStarted||(s.timeoutEvent.start(),s.timeoutStarted=!0)})),t.defineProperty(this,"clearRtcTimeout",(function(){s.timeoutStarted&&(s.timeoutEvent.clear(),s.timeoutStarted=!1)})),t.defineProperty(this,"mergeRtcConfig",(function(t){s.rtcConfig&&t&&Object.keys(t).length&&Object.assign(s.rtcConfig,t)})),t.defineProperty(this,"openRtc",(function(t){if(s.stopped=!1,s.restarting)!s.closeLog&&console.warn("rtc restarting");else if(t&&(s.rtcConnection=t),s.rtcConnection&&!i(s.rtcConnection)){var o,a=s.rtcConnection,l=a.server,d=a.appId,u=a.token,f=a.roomName,m=a.userId,C=s.rtcCallback||{},b=C.onRemotedata,g=C.onLocalStream,p=C.onRemoteVideoComing,y=C.onLocalVideoPublished,h=C.onLocalVideoPublishing,v=C.onRemoteVideoOn,R=C.onRemoteVideoOff,S=C.onRemoteVideoLoading,L=C.onSuccess,k=C.onError,P=C.onLocalVideoConnected,V=C.onRemoteVideoConnected,E=C.onRemoteMediaState,T=C.onPlayingError,O=C.onDigitalHumanCallback;null===(o=s.client)||void 0===o||o.destroy(),s.client=void 0,s.startRtcTimeout(),s.rtcStateCallback=function(t){var e=t.body,o=t.action;O&&O({status:r.statusEnum.DH_LIB_FULL_STATUS,content:{type:"rtcState",action:o,body:e}})},s.client=new e({roomName:f,token:u,userId:m,appId:d,server:l,rtcConfig:s.rtcConfig,callback:{onRemoteVideoConnected:function(e,o){var n;if(!o&&!s.haveVideoOn)var i=setTimeout((function(){s.restartCount<3?(s.restartCount=++s.restartCount,s.restartRtc&&s.restartRtc(t)):(s.restartCount=0,s.closeRtc()),clearTimeout(i)}),500);if(o&&!1!==(null===(n=s.bizConfig)||void 0===n?void 0:n.remoteAutoPlay)){var a=document.getElementById("remotevideo500");if(a){a.muted=!1;var l=a.play();void 0!==l&&l.catch((function(){a.muted=!0,a.play().catch((function(t){!s.closeLog&&console.info("videoElement play error",t),T&&T(a),O&&O({status:r.statusEnum.DH_LIB_ERROR,content:{type:r.errorTypeEnum.LOCAL_VIDEO_ERROR}}),s.rtcStateCallback&&s.rtcStateCallback({action:"localVideoError",body:!0})})),O&&O({status:r.statusEnum.DH_LIB_STATUS,content:{type:r.errorTypeEnum.LOCAL_VIDEO_MUTED}}),s.rtcStateCallback&&s.rtcStateCallback({action:"localVideoMuted",body:!0})}))}else!s.closeLog&&console.error("videoElement is null!")}!s.closeLog&&console.info("remoteVideoConnected",e,o,s.restartCount),s.rtcStateCallback&&s.rtcStateCallback({action:"remoteVideoConnected",body:{id:e,connected:o,restartCount:s.restartCount}}),c(V)&&V(e,o)},onRemoteVideoOn:function(t){s.haveVideoOn=!0,!s.closeLog&&console.info("remotevideoon by id: ",t),s.clearRtcTimeout();var e=document.querySelector("#starlingRtcContainer"),o=e&&e.lastChild;o&&(o.style.display="none"),s.rtcStateCallback&&s.rtcStateCallback({action:"remotevideoon",body:t}),O&&O({status:r.statusEnum.DH_LIB_OPEN}),c(v)&&v(t)},onRemoteMediaState:function(t,e,o){!s.closeLog&&console.info("remoteMediaState",t,e,o),s.rtcStateCallback&&s.rtcStateCallback({action:"remoteMediaState",body:{id:t,medium:e,connected:o}}),c(E)&&E(t,e,o)},onLocalVideoConnected:function(t){!s.closeLog&&console.info("localVideoConnected",t),s.rtcStateCallback&&s.rtcStateCallback({action:"localVideoConnected",body:{connected:t}}),c(P)&&P(t)},onRemotedata:function(t){if(s.rtcConfig&&s.rtcConfig.usingdatachannel){var e=n.parse(t);!s.closeLog&&console.info("RTC - receive:",e),c(b)&&b(e)}},onLocalStream:function(t,e){!s.closeLog&&console.info("rtc - onlocalstream by name: "+e),s.rtcStateCallback&&s.rtcStateCallback({action:"onlocalstream",body:{stream:t,name:e}}),c(g)&&g(t,e)},onLocalVideoPublished:function(){!s.closeLog&&console.info("LocalVideoPublished 本地视频发布成功"),s.rtcStateCallback&&s.rtcStateCallback({action:"localvideopublished_ok",body:!0}),c(y)&&y()},onLocalVideoPublishing:function(){!s.closeLog&&console.info("LocalVideoPublishing 本地视频发布成功"),s.rtcStateCallback&&s.rtcStateCallback({action:"localvideopublishing",body:!0}),c(h)&&h()},onRemoteVideoComing:function(t){!s.closeLog&&console.info("remotevideocoming",t),s.rtcStateCallback&&s.rtcStateCallback({action:"remotevideocoming",body:t}),c(p)&&p(t)},onRemoteVideoLoading:function(t){!s.closeLog&&console.info("remotevideoloading by id: ",t),s.rtcStateCallback&&s.rtcStateCallback({action:"remotevideoloading",body:t}),c(S)&&S(t)},onRemoteVideoOff:function(t){if(!s.stopped){var e=document.getElementById("remotevideo500");e&&e.pause(),!s.closeLog&&console.info("remotevideooff: ",t),s.isRtcVideoOn=!1,s.rtcStateCallback&&s.rtcStateCallback({action:"remotevideooff",body:t}),O&&O({status:r.statusEnum.DH_LIB_CLOSE}),c(R)&&R(t),s.startRtcTimeout()}},onSuccess:function(){!s.closeLog&&console.info("rtc - success"),s.rtcStateCallback&&s.rtcStateCallback({action:"success",body:!0}),c(L)&&L()},onError:function(e){s.stopped||(s.isRtcVideoOn=!1,!s.closeLog&&console.error("rtc - error:",e),s.rtcStateCallback&&s.rtcStateCallback({action:"error",body:e}),O&&O({status:r.statusEnum.DH_LIB_ERROR,content:{type:r.errorTypeEnum.RTC_ERROR}}),c(k)&&k(e),(e.includes("Lost connection to the server")||e.includes("Is the server down"))&&s.restartRtc&&s.restartRtc(t))}}})}})),t.defineProperty(this,"closeRtc",(function(){var t;s.stopped=!0,s.clearRtcTimeout(),clearTimeout(s.reopenTimer),null===(t=s.client)||void 0===t||t.destroy(),s.client=void 0,s.restarting=!1})),t.defineProperty(this,"restartRtc",(function(t){s.stopped||!s.restarting&&s.bizConfig&&s.bizConfig.autoReConnect&&(s.rtcStateCallback&&s.rtcStateCallback({action:"restartRtc",body:t}),s.restarting=!0,s.closeRtc(),s.reopenTimer=setTimeout((function(){!s.closeLog&&console.error("拉流失败,开始重启"),s.restarting=!1,s.openRtc(t)}),2e3))}));var d=l.rtcConnection,u=l.rtcConfig,f=l.closeLog,m=void 0===f||f,C=l.rtcCallback,b=l.bizConfig;this.rtcConnection=d,this.rtcConfig=u,this.rtcCallback=C,this.closeLog=m,this.bizConfig=b,this.timeoutEvent=new o.TimeoutController(6e4,(function(){if(s.timeoutStarted=!1,!s.stopped)return s.rtcConnection?void(s.restartRtc&&s.restartRtc(s.rtcConnection)):!s.closeLog&&console.warn("remotevideoon事件超时, rtcConnectionRef is null")}))}return t.createClass(a,[{key:"muteMicphone",value:function(t){this.client&&this.client.muteMicphone&&this.client.muteMicphone(t)}}]),a}();exports.default=a;
|
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 i from"@bddh/starling-json";import a from"lodash/isEmpty";import r from"lodash/isFunction";import{statusEnum as l,errorTypeEnum as s}from"./interface.js";var d=function(){function d(t){var u=this;o(this,d),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,"timeoutStarted",!1),e(this,"reopenTimer",void 0),e(this,"restartCount",0),e(this,"closeLog",!0),e(this,"stopped",!1),e(this,"haveVideoOn",!1),e(this,"rtcStateCallback",null),e(this,"startRtcTimeout",(function(){u.timeoutStarted||(u.timeoutEvent.start(),u.timeoutStarted=!0)})),e(this,"clearRtcTimeout",(function(){u.timeoutStarted&&(u.timeoutEvent.clear(),u.timeoutStarted=!1)})),e(this,"mergeRtcConfig",(function(t){u.rtcConfig&&t&&Object.keys(t).length&&Object.assign(u.rtcConfig,t)})),e(this,"openRtc",(function(t){if(u.stopped=!1,u.restarting)!u.closeLog&&console.warn("rtc restarting");else if(t&&(u.rtcConnection=t),u.rtcConnection&&!a(u.rtcConnection)){var o,e=u.rtcConnection,c=e.server,d=e.appId,m=e.token,C=e.roomName,f=e.userId,b=u.rtcCallback||{},g=b.onRemotedata,h=b.onLocalStream,v=b.onRemoteVideoComing,R=b.onLocalVideoPublished,
|
|
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 i from"@bddh/starling-json";import a from"lodash/isEmpty";import r from"lodash/isFunction";import{statusEnum as l,errorTypeEnum as s}from"./interface.js";var d=function(){function d(t){var u=this;o(this,d),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,"timeoutStarted",!1),e(this,"reopenTimer",void 0),e(this,"restartCount",0),e(this,"closeLog",!0),e(this,"stopped",!1),e(this,"haveVideoOn",!1),e(this,"rtcStateCallback",null),e(this,"startRtcTimeout",(function(){u.timeoutStarted||(u.timeoutEvent.start(),u.timeoutStarted=!0)})),e(this,"clearRtcTimeout",(function(){u.timeoutStarted&&(u.timeoutEvent.clear(),u.timeoutStarted=!1)})),e(this,"mergeRtcConfig",(function(t){u.rtcConfig&&t&&Object.keys(t).length&&Object.assign(u.rtcConfig,t)})),e(this,"openRtc",(function(t){if(u.stopped=!1,u.restarting)!u.closeLog&&console.warn("rtc restarting");else if(t&&(u.rtcConnection=t),u.rtcConnection&&!a(u.rtcConnection)){var o,e=u.rtcConnection,c=e.server,d=e.appId,m=e.token,C=e.roomName,f=e.userId,b=u.rtcCallback||{},g=b.onRemotedata,h=b.onLocalStream,v=b.onRemoteVideoComing,R=b.onLocalVideoPublished,S=b.onLocalVideoPublishing,p=b.onRemoteVideoOn,L=b.onRemoteVideoOff,k=b.onRemoteVideoLoading,y=b.onSuccess,V=b.onError,E=b.onLocalVideoConnected,O=b.onRemoteVideoConnected,_=b.onRemoteMediaState,T=b.onPlayingError,I=b.onDigitalHumanCallback;null===(o=u.client)||void 0===o||o.destroy(),u.client=void 0,u.startRtcTimeout(),u.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}})},u.client=new n({roomName:C,token:m,userId:f,appId:d,server:c,rtcConfig:u.rtcConfig,callback:{onRemoteVideoConnected:function(o,e){var n;if(!e&&!u.haveVideoOn)var c=setTimeout((function(){u.restartCount<3?(u.restartCount=++u.restartCount,u.restartRtc&&u.restartRtc(t)):(u.restartCount=0,u.closeRtc()),clearTimeout(c)}),500);if(e&&!1!==(null===(n=u.bizConfig)||void 0===n?void 0:n.remoteAutoPlay)){var i=document.getElementById("remotevideo500");if(i){i.muted=!1;var a=i.play();void 0!==a&&a.catch((function(){i.muted=!0,i.play().catch((function(t){!u.closeLog&&console.info("videoElement play error",t),T&&T(i),I&&I({status:l.DH_LIB_ERROR,content:{type:s.LOCAL_VIDEO_ERROR}}),u.rtcStateCallback&&u.rtcStateCallback({action:"localVideoError",body:!0})})),I&&I({status:l.DH_LIB_STATUS,content:{type:s.LOCAL_VIDEO_MUTED}}),u.rtcStateCallback&&u.rtcStateCallback({action:"localVideoMuted",body:!0})}))}else!u.closeLog&&console.error("videoElement is null!")}!u.closeLog&&console.info("remoteVideoConnected",o,e,u.restartCount),u.rtcStateCallback&&u.rtcStateCallback({action:"remoteVideoConnected",body:{id:o,connected:e,restartCount:u.restartCount}}),r(O)&&O(o,e)},onRemoteVideoOn:function(t){u.haveVideoOn=!0,!u.closeLog&&console.info("remotevideoon by id: ",t),u.clearRtcTimeout();var o=document.querySelector("#starlingRtcContainer"),e=o&&o.lastChild;e&&(e.style.display="none"),u.rtcStateCallback&&u.rtcStateCallback({action:"remotevideoon",body:t}),I&&I({status:l.DH_LIB_OPEN}),r(p)&&p(t)},onRemoteMediaState:function(t,o,e){!u.closeLog&&console.info("remoteMediaState",t,o,e),u.rtcStateCallback&&u.rtcStateCallback({action:"remoteMediaState",body:{id:t,medium:o,connected:e}}),r(_)&&_(t,o,e)},onLocalVideoConnected:function(t){!u.closeLog&&console.info("localVideoConnected",t),u.rtcStateCallback&&u.rtcStateCallback({action:"localVideoConnected",body:{connected:t}}),r(E)&&E(t)},onRemotedata:function(t){if(u.rtcConfig&&u.rtcConfig.usingdatachannel){var o=i.parse(t);!u.closeLog&&console.info("RTC - receive:",o),r(g)&&g(o)}},onLocalStream:function(t,o){!u.closeLog&&console.info("rtc - onlocalstream by name: "+o),u.rtcStateCallback&&u.rtcStateCallback({action:"onlocalstream",body:{stream:t,name:o}}),r(h)&&h(t,o)},onLocalVideoPublished:function(){!u.closeLog&&console.info("LocalVideoPublished 本地视频发布成功"),u.rtcStateCallback&&u.rtcStateCallback({action:"localvideopublished_ok",body:!0}),r(R)&&R()},onLocalVideoPublishing:function(){!u.closeLog&&console.info("LocalVideoPublishing 本地视频发布成功"),u.rtcStateCallback&&u.rtcStateCallback({action:"localvideopublishing",body:!0}),r(S)&&S()},onRemoteVideoComing:function(t){!u.closeLog&&console.info("remotevideocoming",t),u.rtcStateCallback&&u.rtcStateCallback({action:"remotevideocoming",body:t}),r(v)&&v(t)},onRemoteVideoLoading:function(t){!u.closeLog&&console.info("remotevideoloading by id: ",t),u.rtcStateCallback&&u.rtcStateCallback({action:"remotevideoloading",body:t}),r(k)&&k(t)},onRemoteVideoOff:function(t){if(!u.stopped){var o=document.getElementById("remotevideo500");o&&o.pause(),!u.closeLog&&console.info("remotevideooff: ",t),u.isRtcVideoOn=!1,u.rtcStateCallback&&u.rtcStateCallback({action:"remotevideooff",body:t}),I&&I({status:l.DH_LIB_CLOSE}),r(L)&&L(t),u.startRtcTimeout()}},onSuccess:function(){!u.closeLog&&console.info("rtc - success"),u.rtcStateCallback&&u.rtcStateCallback({action:"success",body:!0}),r(y)&&y()},onError:function(o){u.stopped||(u.isRtcVideoOn=!1,!u.closeLog&&console.error("rtc - error:",o),u.rtcStateCallback&&u.rtcStateCallback({action:"error",body:o}),I&&I({status:l.DH_LIB_ERROR,content:{type:s.RTC_ERROR}}),r(V)&&V(o),(o.includes("Lost connection to the server")||o.includes("Is the server down"))&&u.restartRtc&&u.restartRtc(t))}}})}})),e(this,"closeRtc",(function(){var t;u.stopped=!0,u.clearRtcTimeout(),clearTimeout(u.reopenTimer),null===(t=u.client)||void 0===t||t.destroy(),u.client=void 0,u.restarting=!1})),e(this,"restartRtc",(function(t){u.stopped||!u.restarting&&u.bizConfig&&u.bizConfig.autoReConnect&&(u.rtcStateCallback&&u.rtcStateCallback({action:"restartRtc",body:t}),u.restarting=!0,u.closeRtc(),u.reopenTimer=setTimeout((function(){!u.closeLog&&console.error("拉流失败,开始重启"),u.restarting=!1,u.openRtc(t)}),2e3))}));var m=t.rtcConnection,C=t.rtcConfig,f=t.closeLog,b=void 0===f||f,g=t.rtcCallback,h=t.bizConfig;this.rtcConnection=m,this.rtcConfig=C,this.rtcCallback=g,this.closeLog=b,this.bizConfig=h,this.timeoutEvent=new c(6e4,(function(){if(u.timeoutStarted=!1,!u.stopped)return u.rtcConnection?void(u.restartRtc&&u.restartRtc(u.rtcConnection)):!u.closeLog&&console.warn("remotevideoon事件超时, rtcConnectionRef is null")}))}return t(d,[{key:"muteMicphone",value:function(t){this.client&&this.client.muteMicphone&&this.client.muteMicphone(t)}}]),d}();export{d as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bddh/starling-realtime-client",
|
|
3
|
-
"version": "2.0.11-beta.
|
|
3
|
+
"version": "2.0.11-beta.4",
|
|
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": "efeca9e279f20628feaad2de1ef9725b4db27998"
|
|
48
48
|
}
|