trtc-sdk-v5 5.15.0 → 5.15.1-beta.1
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/assets/debug-dialog.js +2 -2
- package/index.d.ts +1 -105
- package/package.json +1 -1
- package/plugins/cdn-streaming/cdn-streaming.esm.js +1 -1
- package/plugins/cdn-streaming/cdn-streaming.umd.js +1 -3
- package/plugins/cdn-streaming/package.json +1 -1
- package/plugins/chorus/chorus.esm.d.ts +0 -2
- package/plugins/chorus/chorus.esm.js +1 -1
- package/plugins/chorus/chorus.umd.js +1 -3
- package/plugins/chorus/package.json +1 -1
- package/plugins/cross-room/cross-room.esm.d.ts +0 -2
- package/plugins/cross-room/cross-room.esm.js +1 -1
- package/plugins/cross-room/cross-room.umd.js +1 -3
- package/plugins/cross-room/package.json +1 -1
- package/plugins/custom-encryption/custom-encryption.esm.js +1 -1
- package/plugins/custom-encryption/custom-encryption.umd.js +1 -3
- package/plugins/custom-encryption/package.json +1 -1
- package/plugins/device-detector/device-detector.esm.js +56 -44
- package/plugins/device-detector/device-detector.umd.js +14 -4
- package/plugins/device-detector/package.json +1 -1
- package/plugins/fast-webrtc/fast-webrtc.esm.d.ts +27 -0
- package/plugins/fast-webrtc/fast-webrtc.esm.js +1 -0
- package/plugins/fast-webrtc/fast-webrtc.umd.js +1 -0
- package/plugins/{video-effect/face-detection → fast-webrtc}/package.json +8 -8
- package/plugins/lebplayer/lebplayer.esm.d.ts +0 -7
- package/plugins/lebplayer/lebplayer.esm.js +1 -1
- package/plugins/lebplayer/lebplayer.umd.js +1 -3
- package/plugins/lebplayer/package.json +1 -1
- package/plugins/small-stream-auto-switcher/package.json +1 -1
- package/plugins/small-stream-auto-switcher/small-stream-auto-switcher.esm.js +1 -1
- package/plugins/small-stream-auto-switcher/small-stream-auto-switcher.umd.js +1 -1
- package/plugins/video-decoder/package.json +1 -1
- package/plugins/video-decoder/video-decoder.esm.d.ts +1 -2
- package/plugins/video-decoder/video-decoder.esm.js +1 -1
- package/plugins/video-decoder/video-decoder.umd.js +1 -3
- package/plugins/video-effect/basic-beauty/basic-beauty.esm.js +1 -1
- package/plugins/video-effect/basic-beauty/basic-beauty.umd.js +1 -3
- package/plugins/video-effect/basic-beauty/package.json +1 -1
- package/plugins/video-effect/beauty/beauty.esm.js +1 -1
- package/plugins/video-effect/beauty/beauty.umd.js +1 -3
- package/plugins/video-effect/beauty/package.json +1 -1
- package/plugins/video-effect/video-mixer/package.json +1 -1
- package/plugins/video-effect/video-mixer/video-mixer.esm.d.ts +4 -0
- package/plugins/video-effect/video-mixer/video-mixer.esm.js +1 -1
- package/plugins/video-effect/video-mixer/video-mixer.umd.js +1 -3
- package/plugins/video-effect/virtual-background/package.json +1 -1
- package/plugins/video-effect/virtual-background/virtual-background.esm.js +1 -1
- package/plugins/video-effect/virtual-background/virtual-background.umd.js +1 -3
- package/plugins/video-effect/watermark/package.json +1 -1
- package/plugins/video-effect/watermark/watermark.umd.js +1 -3
- package/plugins/voice-changer/package.json +1 -1
- package/plugins/voice-changer/voice-changer.esm.js +1 -1
- package/plugins/voice-changer/voice-changer.umd.js +1 -3
- package/trtc.esm.js +39 -35
- package/trtc.js +1 -1
- package/plugins/realtime-transcriber/package.json +0 -29
- package/plugins/realtime-transcriber/realtime-transcriber.esm.d.ts +0 -16
- package/plugins/realtime-transcriber/realtime-transcriber.esm.js +0 -1
- package/plugins/realtime-transcriber/realtime-transcriber.umd.js +0 -3
- package/plugins/video-effect/face-detection/face-detection.esm.d.ts +0 -22
- package/plugins/video-effect/face-detection/face-detection.esm.js +0 -1
- package/plugins/video-effect/face-detection/face-detection.umd.js +0 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
var __defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,r,t)=>r in e?__defProp(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,__spreadValues=(e,r)=>{for(var t in r||(r={}))__hasOwnProp.call(r,t)&&__defNormalProp(e,t,r[t]);if(__getOwnPropSymbols)for(var t of __getOwnPropSymbols(r))__propIsEnum.call(r,t)&&__defNormalProp(e,t,r[t]);return e},__spreadProps=(e,r)=>__defProps(e,__getOwnPropDescs(r)),__decorateClass=(e,r,t,o)=>{for(var s,a=o>1?void 0:o?__getOwnPropDesc(r,t):r,i=e.length-1;i>=0;i--)(s=e[i])&&(a=(o?s(r,t,a):s(a))||a);return o&&a&&__defProp(r,t,a),a},__publicField=(e,r,t)=>__defNormalProp(e,"symbol"!=typeof r?r+"":r,t),roomIValidate={properties:{roomId:{type:"number"},strRoomId:{type:"string"}}},StartValidateRule={name:"option",required:!0,properties:__spreadProps(__spreadValues({},roomIValidate.properties),{userId:{type:"string"}})},UpdateValidateRule={name:"option",required:!0,properties:{updateList:{type:"array",required:!0,arrayItem:{required:!0,type:"object",properties:__spreadProps(__spreadValues({},StartValidateRule.properties),{userId:{required:!1,type:"string"},muteAudio:{type:"boolean"},muteVideo:{type:"boolean"},muteSubStream:{type:"boolean"}})}}}},StopValidateRule={name:"option",properties:__spreadValues({},roomIValidate.properties)},isFunction=e=>"function"==typeof e,RETRY_STATE_NOT_START=0,RETRY_STATE_STARTED=1,RETRY_STATE_STOPPED=2;function promiseRetry({retryFunction:e,settings:r,onError:t,onRetrying:o,onRetryFailed:s,onRetrySuccess:a,context:i}){return function(...d){const{retries:n=5,timeout:c=1e3}=r;let p=0,l=-1,u=RETRY_STATE_NOT_START;const _=async(r,m)=>{const R=i||this;try{const t=await e.apply(R,d);p>0&&a&&a.call(this,p),p=0,r(t)}catch(e){const a=()=>{clearTimeout(l),p=0,u=RETRY_STATE_STOPPED,m(e)},i=()=>{u!==RETRY_STATE_STOPPED&&p<(isFunction(n)?n():n)?(p++,u=RETRY_STATE_STARTED,isFunction(o)&&o.call(this,p,a),l=window.setTimeout(()=>{l=-1,_(r,m)},isFunction(c)?c(p):c)):(a(),isFunction(s)&&s.call(this,e))};isFunction(t)?t.call(this,{error:e,retry:i,reject:m,retryFuncArgs:d,retriedCount:p}):i()}};return new Promise(_)}}var retry_default=promiseRetry,retryingMap=new WeakMap;function addPromiseRetry({settings:e={retries:5,timeout:2e3},onError:r,onRetrying:t,onRetryFailed:o}){return function(s,a,i){const d=retry_default({retryFunction:i.value,settings:e,onError({error:e,retry:t,reject:o,retryFuncArgs:i}){var d;r?r.call(this,e,()=>{var r;(null==(r=retryingMap.get(s))?void 0:r.has(a))?t():o(e)},o,i):(null==(d=retryingMap.get(s))?void 0:d.has(a))?t():o(e)},onRetrying(e,r){var o;isFunction(t)&&t.call(this,e,r),(null==(o=retryingMap.get(s))?void 0:o.has(a))&&(retryingMap.get(s).get(a).stopRetry=r)},onRetryFailed:o});return i.value=function(...e){const r=retryingMap.get(s);return r?r.set(a,{args:e}):retryingMap.set(s,new Map([[a,{args:e}]])),d.apply(this,e).finally(()=>{var e;return null==(e=retryingMap.get(s))?void 0:e.delete(a)})},i}}var _CrossRoom=class e{constructor(e){this.core=e,__publicField(this,"disableRandomCall",!0),__publicField(this,"connectedRoomIdSet",new Set),__publicField(this,"updateSeq",0),__publicField(this,"_log"),this._log=this.core.log.createChild({id:`${this.getAlias()}`})}getName(){return e.Name}getAlias(){return"crs-r"}getGroup(e){var r;const t=(null==e?void 0:e.userId)||(null==(r=null==e?void 0:e.updateList)?void 0:r[0].userId)||"";return t||(e?e.updateList?String(e.updateList[0].roomId)||e.updateList[0].strRoomId||"":String(e.roomId)||e.strRoomId||"":"*")}getValidateRule(e){switch(e){case"start":return StartValidateRule;case"update":return UpdateValidateRule;case"stop":return StopValidateRule}}async start({roomId:e,strRoomId:r,userId:t}){const{RtcError:o,ErrorCode:s}=this.core.errorModule;if(!this.core.room.sendSignalMessage)throw new o({code:s.ENV_NOT_SUPPORTED});const a=e||r;try{const e=await this.core.room.sendSignalMessage({command:"connect_other_room",responseCommand:String(8209),data:{roomId:a,userId:t,localRoomId:t?void 0:this.core.room.roomId},retries:3});if(0!==e.data.code)throw new o({code:s.SERVER_ERROR,extraCode:e.data.code,message:e.data.message})}catch(e){if(e.code!==this.core.errorModule.CoreErrorCode.API_CALL_ABORTED)throw e}t||this.connectedRoomIdSet.add(a)}async update({updateList:e}){var r;const{RtcError:t,ErrorCode:o}=this.core.errorModule;if(!this.core.room.sendSignalMessage)throw new t({code:o.ENV_NOT_SUPPORTED});const s=e.find(e=>e.userId)?0:1;try{const a=await this.core.room.sendSignalMessage({command:"update_other_room_forward_mode",responseCommand:String(8213),data:{seq:++this.updateSeq,operationType:s,updateList:e.map(({roomId:e,strRoomId:r,userId:t,muteAudio:o,muteVideo:s,muteSubStream:a})=>({roomId:e||r,userId:t,muteAudio:o,muteVideo:s,muteSubStream:a}))},retries:3});if(a.data.data.expectSeq)return this.updateSeq=a.data.data.expectSeq,this.update({updateList:e});if(0!==a.data.code)throw new t({code:o.SERVER_ERROR,extraCode:a.data.code,message:a.data.message});if((null==(r=a.data.data.errorList)?void 0:r.length)>0)throw new t({code:o.UNKNOWN_ERROR,message:a.data.data.errorList[0].message})}catch(e){if(e.code!==this.core.errorModule.CoreErrorCode.API_CALL_ABORTED)throw e}}async stop({roomId:e,strRoomId:r}={}){const t=e||r;if(t)await this.doStop(t);else if(this.connectedRoomIdSet.size>0)for(const e of[...this.connectedRoomIdSet.values()])await this.doStop(e);else await this.doStop()}async doStop(e){const{RtcError:r,ErrorCode:t}=this.core.errorModule;if(!this.core.room.sendSignalMessage)throw new r({code:t.ENV_NOT_SUPPORTED});try{const o=await this.core.room.sendSignalMessage({command:"disconnect_other_room",responseCommand:String(8211),data:{roomId:e,localRoomId:this.core.room.roomId},retries:3});if(0!==o.data.code)throw new r({code:t.SERVER_ERROR,extraCode:o.data.code,message:o.data.message})}catch(e){if(e.code!==this.core.errorModule.CoreErrorCode.API_CALL_ABORTED)throw e}this.connectedRoomIdSet.delete(e)}destroy(){}};__publicField(_CrossRoom,"Name","CrossRoom"),__decorateClass([addPromiseRetry({settings:{retries:3,timeout:1e3},onRetrying(e){this._log.warn(`retry start: ${e}`)}})],_CrossRoom.prototype,"start",1),__decorateClass([addPromiseRetry({settings:{retries:3,timeout:1e3},onRetrying(e){this._log.warn(`retry update: ${e}`)}})],_CrossRoom.prototype,"update",1);var CrossRoom=_CrossRoom,index_default=CrossRoom;export{index_default as default};export{CrossRoom};
|
|
1
|
+
var __defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,r,t)=>r in e?__defProp(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,__spreadValues=(e,r)=>{for(var t in r||(r={}))__hasOwnProp.call(r,t)&&__defNormalProp(e,t,r[t]);if(__getOwnPropSymbols)for(var t of __getOwnPropSymbols(r))__propIsEnum.call(r,t)&&__defNormalProp(e,t,r[t]);return e},__spreadProps=(e,r)=>__defProps(e,__getOwnPropDescs(r)),__decorateClass=(e,r,t,o)=>{for(var s,a=o>1?void 0:o?__getOwnPropDesc(r,t):r,i=e.length-1;i>=0;i--)(s=e[i])&&(a=(o?s(r,t,a):s(a))||a);return o&&a&&__defProp(r,t,a),a},__publicField=(e,r,t)=>__defNormalProp(e,"symbol"!=typeof r?r+"":r,t),roomIValidate={properties:{roomId:{type:"number"},strRoomId:{type:"string"}}},StartValidateRule={name:"option",required:!0,properties:__spreadProps(__spreadValues({},roomIValidate.properties),{userId:{type:"string"}})},UpdateValidateRule={name:"option",required:!0,properties:{updateList:{type:"array",required:!0,arrayItem:{required:!0,type:"object",properties:__spreadProps(__spreadValues({},StartValidateRule.properties),{userId:{required:!1,type:"string"},muteAudio:{type:"boolean"},muteVideo:{type:"boolean"},muteSubStream:{type:"boolean"}})}}}},StopValidateRule={name:"option",properties:__spreadValues({},roomIValidate.properties)},isFunction=e=>"function"==typeof e,RETRY_STATE_NOT_START=0,RETRY_STATE_STARTED=1,RETRY_STATE_STOPPED=2;function promiseRetry({retryFunction:e,settings:r,onError:t,onRetrying:o,onRetryFailed:s,onRetrySuccess:a,context:i}){return function(...d){const{retries:n=5,timeout:c=1e3}=r;let p=0,l=-1,u=RETRY_STATE_NOT_START;const _=async(r,m)=>{const R=i||this;try{const t=await e.apply(R,d);p>0&&a&&a.call(this,p),p=0,r(t)}catch(e){const a=()=>{clearTimeout(l),p=0,u=RETRY_STATE_STOPPED,m(e)},i=()=>{u!==RETRY_STATE_STOPPED&&p<(isFunction(n)?n():n)?(p++,u=RETRY_STATE_STARTED,isFunction(o)&&o.call(this,p,a),l=window.setTimeout((()=>{l=-1,_(r,m)}),isFunction(c)?c(p):c)):(a(),isFunction(s)&&s.call(this,e))};isFunction(t)?t.call(this,{error:e,retry:i,reject:m,retryFuncArgs:d,retriedCount:p}):i()}};return new Promise(_)}}var retry_default=promiseRetry,retryingMap=new WeakMap;function addPromiseRetry({settings:e={retries:5,timeout:2e3},onError:r,onRetrying:t,onRetryFailed:o}){return function(s,a,i){const d=retry_default({retryFunction:i.value,settings:e,onError({error:e,retry:t,reject:o,retryFuncArgs:i}){var d;r?r.call(this,e,(()=>{var r;(null==(r=retryingMap.get(s))?void 0:r.has(a))?t():o(e)}),o,i):(null==(d=retryingMap.get(s))?void 0:d.has(a))?t():o(e)},onRetrying(e,r){var o;isFunction(t)&&t.call(this,e,r),(null==(o=retryingMap.get(s))?void 0:o.has(a))&&(retryingMap.get(s).get(a).stopRetry=r)},onRetryFailed:o});return i.value=function(...e){const r=retryingMap.get(s);return r?r.set(a,{args:e}):retryingMap.set(s,new Map([[a,{args:e}]])),d.apply(this,e).finally((()=>{var e;return null==(e=retryingMap.get(s))?void 0:e.delete(a)}))},i}}var _CrossRoom=class e{constructor(e){this.core=e,__publicField(this,"disableRandomCall",!0),__publicField(this,"connectedRoomIdSet",new Set),__publicField(this,"updateSeq",0),__publicField(this,"_log"),this._log=this.core.log.createChild({id:`${this.getAlias()}`})}getName(){return e.Name}getAlias(){return"crs-r"}getGroup(e){var r;const t=(null==e?void 0:e.userId)||(null==(r=null==e?void 0:e.updateList)?void 0:r[0].userId)||"";return t||(e?e.updateList?String(e.updateList[0].roomId)||e.updateList[0].strRoomId||"":String(e.roomId)||e.strRoomId||"":"*")}getValidateRule(e){switch(e){case"start":return StartValidateRule;case"update":return UpdateValidateRule;case"stop":return StopValidateRule}}async start({roomId:e,strRoomId:r,userId:t}){const{RtcError:o,ErrorCode:s}=this.core.errorModule;if(!this.core.room.sendSignalMessage)throw new o({code:s.ENV_NOT_SUPPORTED});const a=e||r;try{const e=await this.core.room.sendSignalMessage({command:"connect_other_room",responseCommand:String(8209),data:{roomId:a,userId:t,localRoomId:t?void 0:this.core.room.roomId},retries:3});if(0!==e.data.code)throw new o({code:s.SERVER_ERROR,extraCode:e.data.code,message:e.data.message})}catch(e){if(e.code!==this.core.errorModule.CoreErrorCode.API_CALL_ABORTED)throw e}t||this.connectedRoomIdSet.add(a)}async update({updateList:e}){var r;const{RtcError:t,ErrorCode:o}=this.core.errorModule;if(!this.core.room.sendSignalMessage)throw new t({code:o.ENV_NOT_SUPPORTED});const s=e.find((e=>e.userId))?0:1;try{const a=await this.core.room.sendSignalMessage({command:"update_other_room_forward_mode",responseCommand:String(8213),data:{seq:++this.updateSeq,operationType:s,updateList:e.map((({roomId:e,strRoomId:r,userId:t,muteAudio:o,muteVideo:s,muteSubStream:a})=>({roomId:e||r,userId:t,muteAudio:o,muteVideo:s,muteSubStream:a})))},retries:3});if(a.data.data.expectSeq)return this.updateSeq=a.data.data.expectSeq,this.update({updateList:e});if(0!==a.data.code)throw new t({code:o.SERVER_ERROR,extraCode:a.data.code,message:a.data.message});if((null==(r=a.data.data.errorList)?void 0:r.length)>0)throw new t({code:o.UNKNOWN_ERROR,message:a.data.data.errorList[0].message})}catch(e){if(e.code!==this.core.errorModule.CoreErrorCode.API_CALL_ABORTED)throw e}}async stop({roomId:e,strRoomId:r}={}){const t=e||r;if(t)await this.doStop(t);else if(this.connectedRoomIdSet.size>0)for(const e of[...this.connectedRoomIdSet.values()])await this.doStop(e);else await this.doStop()}async doStop(e){const{RtcError:r,ErrorCode:t}=this.core.errorModule;if(!this.core.room.sendSignalMessage)throw new r({code:t.ENV_NOT_SUPPORTED});try{const o=await this.core.room.sendSignalMessage({command:"disconnect_other_room",responseCommand:String(8211),data:{roomId:e,localRoomId:this.core.room.roomId},retries:3});if(0!==o.data.code)throw new r({code:t.SERVER_ERROR,extraCode:o.data.code,message:o.data.message})}catch(e){if(e.code!==this.core.errorModule.CoreErrorCode.API_CALL_ABORTED)throw e}this.connectedRoomIdSet.delete(e)}destroy(){}};__publicField(_CrossRoom,"Name","CrossRoom"),__decorateClass([addPromiseRetry({settings:{retries:3,timeout:1e3},onRetrying(e){this._log.warn(`retry start: ${e}`)}})],_CrossRoom.prototype,"start",1),__decorateClass([addPromiseRetry({settings:{retries:3,timeout:1e3},onRetrying(e){this._log.warn(`retry update: ${e}`)}})],_CrossRoom.prototype,"update",1);var CrossRoom=_CrossRoom,index_default=CrossRoom;export{index_default as default};export{CrossRoom};
|
|
@@ -1,3 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).CrossRoom=t()}(this,function(){"use strict";function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,o=Array(t);r<t;r++)o[r]=e[r];return o}function t(e,t,r,o,n,a,i){try{var u=e[a](i),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(o,n)}function r(e){return function(){var r=this,o=arguments;return new Promise(function(n,a){var i=e.apply(r,o);function u(e){t(i,n,a,u,c,"next",e)}function c(e){t(i,n,a,u,c,"throw",e)}u(void 0)})}}function o(e,t,r){return t&&function(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,u(o.key),o)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function n(){
|
|
2
|
-
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
3
|
-
var e,t,r="function"==typeof Symbol?Symbol:{},o=r.iterator||"@@iterator",i=r.toStringTag||"@@toStringTag";function u(r,o,n,i){var u=o&&o.prototype instanceof s?o:s,d=Object.create(u.prototype);return a(d,"_invoke",function(r,o,n){var a,i,u,s=0,d=n||[],f=!1,l={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,r){return a=t,i=0,u=e,l.n=r,c}};function p(r,o){for(i=r,u=o,t=0;!f&&s&&!n&&t<d.length;t++){var n,a=d[t],p=l.p,y=a[2];r>3?(n=y===o)&&(u=a[(i=a[4])?5:(i=3,3)],a[4]=a[5]=e):a[0]<=p&&((n=r<2&&p<a[1])?(i=0,l.v=o,l.n=a[1]):p<y&&(n=r<3||a[0]>o||o>y)&&(a[4]=r,a[5]=o,l.n=y,i=0))}if(n||r>1)return c;throw f=!0,o}return function(n,d,y){if(s>1)throw TypeError("Generator is already running");for(f&&1===d&&p(d,y),i=d,u=y;(t=i<2?e:u)||!f;){a||(i?i<3?(i>1&&(l.n=-1),p(i,u)):l.n=u:l.v=u);try{if(s=2,a){if(i||(n="next"),t=a[n]){if(!(t=t.call(a,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,i<2&&(i=0)}else 1===i&&(t=a.return)&&t.call(a),i<2&&(u=TypeError("The iterator does not provide a '"+n+"' method"),i=1);a=e}else if((t=(f=l.n<0)?u:r.call(o,l))!==c)break}catch(t){a=e,i=1,u=t}finally{s=1}}return{value:t,done:f}}}(r,n,i),!0),d}var c={};function s(){}function d(){}function f(){}t=Object.getPrototypeOf;var l=[][o]?t(t([][o]())):(a(t={},o,function(){return this}),t),p=f.prototype=s.prototype=Object.create(l);function y(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,f):(e.__proto__=f,a(e,i,"GeneratorFunction")),e.prototype=Object.create(p),e}return d.prototype=f,a(p,"constructor",f),a(f,"constructor",d),d.displayName="GeneratorFunction",a(f,i,"GeneratorFunction"),a(p),a(p,i,"Generator"),a(p,o,function(){return this}),a(p,"toString",function(){return"[object Generator]"}),(n=function(){return{w:u,m:y}})()}function a(e,t,r,o){var n=Object.defineProperty;try{n({},"",{})}catch(e){n=0}a=function(e,t,r,o){function i(t,r){a(e,t,function(e){return this._invoke(t,r,e)})}t?n?n(e,t,{value:r,enumerable:!o,configurable:!o,writable:!o}):e[t]=r:(i("next",0),i("throw",1),i("return",2))},a(e,t,r,o)}function i(t){return function(t){if(Array.isArray(t))return e(t)}(t)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||s(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,t);if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:t+""}function c(e){return c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},c(e)}function s(t,r){if(t){if("string"==typeof t)return e(t,r);var o={}.toString.call(t).slice(8,-1);return"Object"===o&&t.constructor&&(o=t.constructor.name),"Map"===o||"Set"===o?Array.from(t):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?e(t,r):void 0}}var d=Object.defineProperty,f=Object.defineProperties,l=Object.getOwnPropertyDescriptor,p=Object.getOwnPropertyDescriptors,y=Object.getOwnPropertySymbols,m=Object.prototype.hasOwnProperty,h=Object.prototype.propertyIsEnumerable,v=function(e,t,r){return t in e?d(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r},b=function(e,t){for(var r in t||(t={}))m.call(t,r)&&v(e,r,t[r]);if(y){var o,n=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=s(e))||t){r&&(e=r);var o=0,n=function(){};return{s:n,n:function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,u=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return i=e.done,e},e:function(e){u=!0,a=e},f:function(){try{i||null==r.return||r.return()}finally{if(u)throw a}}}}(y(t));try{for(n.s();!(o=n.n()).done;){r=o.value;h.call(t,r)&&v(e,r,t[r])}}catch(e){n.e(e)}finally{n.f()}}return e},g=function(e,t){return f(e,p(t))},w=function(e,t,r,o){for(var n,a=l(t,r),i=e.length-1;i>=0;i--)(n=e[i])&&(a=n(t,r,a)||a);return a&&d(t,r,a),a},S=function(e,t,r){return v(e,"symbol"!==c(t)?t+"":t,r)},R={roomId:{type:"number"},strRoomId:{type:"string"}},I={name:"option",required:!0,properties:g(b({},R),{userId:{type:"string"}})},E={name:"option",required:!0,properties:{updateList:{type:"array",required:!0,arrayItem:{required:!0,type:"object",properties:g(b({},I.properties),{userId:{required:!1,type:"string"},muteAudio:{type:"boolean"},muteVideo:{type:"boolean"},muteSubStream:{type:"boolean"}})}}}},O={name:"option",properties:b({},R)},k=function(e){return"function"==typeof e};var _=function(e){var t=e.retryFunction,o=e.settings,a=e.onError,i=e.onRetrying,u=e.onRetryFailed,c=e.onRetrySuccess,s=e.context;return function(){for(var e=this,d=arguments.length,f=new Array(d),l=0;l<d;l++)f[l]=arguments[l];var p=o.retries,y=void 0===p?5:p,m=o.timeout,h=void 0===m?1e3:m,v=0,b=-1,g=0,w=function(){var o=r(n().m(function r(o,d){var l,p,m,S,R;return n().w(function(r){for(;;)switch(r.p=r.n){case 0:return l=s||e,r.p=1,r.n=2,t.apply(l,f);case 2:p=r.v,v>0&&c&&c.call(e,v),v=0,o(p),r.n=4;break;case 3:r.p=3,R=r.v,m=function(){clearTimeout(b),v=0,g=2,d(R)},S=function(){2!==g&&v<(k(y)?y():y)?(v++,g=1,k(i)&&i.call(e,v,m),b=window.setTimeout(function(){b=-1,w(o,d)},k(h)?h(v):h)):(m(),k(u)&&u.call(e,R))},k(a)?a.call(e,{error:R,retry:S,reject:d,retryFuncArgs:f,retriedCount:v}):S();case 4:return r.a(2)}},r,null,[[1,3]])}));return function(e,t){return o.apply(this,arguments)}}();return new Promise(w)}},j=new WeakMap;function A(e){var t=e.settings,r=void 0===t?{retries:5,timeout:2e3}:t,o=e.onError,n=e.onRetrying,a=e.onRetryFailed;return function(e,t,i){var u=_({retryFunction:i.value,settings:r,onError:function(r){var n,a=r.error,i=r.retry,u=r.reject,c=r.retryFuncArgs;o?o.call(this,a,function(){var r;(null==(r=j.get(e))?void 0:r.has(t))?i():u(a)},u,c):(null==(n=j.get(e))?void 0:n.has(t))?i():u(a)},onRetrying:function(r,o){var a;k(n)&&n.call(this,r,o),(null==(a=j.get(e))?void 0:a.has(t))&&(j.get(e).get(t).stopRetry=o)},onRetryFailed:a});return i.value=function(){for(var r=j.get(e),o=arguments.length,n=new Array(o),a=0;a<o;a++)n[a]=arguments[a];return r?r.set(t,{args:n}):j.set(e,new Map([[t,{args:n}]])),u.apply(this,n).finally(function(){var r;return null==(r=j.get(e))?void 0:r.delete(t)})},i}}var P=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.core=t,S(this,"disableRandomCall",!0),S(this,"connectedRoomIdSet",new Set),S(this,"updateSeq",0),S(this,"_log"),this._log=this.core.log.createChild({id:"".concat(this.getAlias())})}return o(e,[{key:"getName",value:function(){return e.Name}},{key:"getAlias",value:function(){return"crs-r"}},{key:"getGroup",value:function(e){var t,r=(null==e?void 0:e.userId)||(null==(t=null==e?void 0:e.updateList)?void 0:t[0].userId)||"";return r||(e?e.updateList?String(e.updateList[0].roomId)||e.updateList[0].strRoomId||"":String(e.roomId)||e.strRoomId||"":"*")}},{key:"getValidateRule",value:function(e){switch(e){case"start":return I;case"update":return E;case"stop":return O}}},{key:"start",value:(c=r(n().m(function e(t){var r,o,a,i,u,c,s,d,f;return n().w(function(e){for(;;)switch(e.p=e.n){case 0:if(r=t.roomId,o=t.strRoomId,a=t.userId,i=this.core.errorModule,u=i.RtcError,c=i.ErrorCode,this.core.room.sendSignalMessage){e.n=1;break}throw new u({code:c.ENV_NOT_SUPPORTED});case 1:return s=r||o,e.p=2,e.n=3,this.core.room.sendSignalMessage({command:"connect_other_room",responseCommand:String(8209),data:{roomId:s,userId:a,localRoomId:a?void 0:this.core.room.roomId},retries:3});case 3:if(0===(d=e.v).data.code){e.n=4;break}throw new u({code:c.SERVER_ERROR,extraCode:d.data.code,message:d.data.message});case 4:e.n=6;break;case 5:if(e.p=5,(f=e.v).code===this.core.errorModule.CoreErrorCode.API_CALL_ABORTED){e.n=6;break}throw f;case 6:a||this.connectedRoomIdSet.add(s);case 7:return e.a(2)}},e,this,[[2,5]])})),function(e){return c.apply(this,arguments)})},{key:"update",value:(u=r(n().m(function e(t){var r,o,a,i,u,c,s,d;return n().w(function(e){for(;;)switch(e.p=e.n){case 0:if(r=t.updateList,a=this.core.errorModule,i=a.RtcError,u=a.ErrorCode,this.core.room.sendSignalMessage){e.n=1;break}throw new i({code:u.ENV_NOT_SUPPORTED});case 1:return c=r.find(function(e){return e.userId})?0:1,e.p=2,e.n=3,this.core.room.sendSignalMessage({command:"update_other_room_forward_mode",responseCommand:String(8213),data:{seq:++this.updateSeq,operationType:c,updateList:r.map(function(e){var t=e.roomId,r=e.strRoomId;return{roomId:t||r,userId:e.userId,muteAudio:e.muteAudio,muteVideo:e.muteVideo,muteSubStream:e.muteSubStream}})},retries:3});case 3:if(!(s=e.v).data.data.expectSeq){e.n=4;break}return this.updateSeq=s.data.data.expectSeq,e.a(2,this.update({updateList:r}));case 4:if(0===s.data.code){e.n=5;break}throw new i({code:u.SERVER_ERROR,extraCode:s.data.code,message:s.data.message});case 5:if(!((null==(o=s.data.data.errorList)?void 0:o.length)>0)){e.n=6;break}throw new i({code:u.UNKNOWN_ERROR,message:s.data.data.errorList[0].message});case 6:e.n=8;break;case 7:if(e.p=7,(d=e.v).code===this.core.errorModule.CoreErrorCode.API_CALL_ABORTED){e.n=8;break}throw d;case 8:return e.a(2)}},e,this,[[2,7]])})),function(e){return u.apply(this,arguments)})},{key:"stop",value:(a=r(n().m(function e(){var t,r,o,a,u,c,s,d=arguments;return n().w(function(e){for(;;)switch(e.n){case 0:if(r=(t=d.length>0&&void 0!==d[0]?d[0]:{}).roomId,o=t.strRoomId,!(a=r||o)){e.n=2;break}return e.n=1,this.doStop(a);case 1:e.n=7;break;case 2:if(!(this.connectedRoomIdSet.size>0)){e.n=6;break}u=0,c=i(this.connectedRoomIdSet.values());case 3:if(!(u<c.length)){e.n=5;break}return s=c[u],e.n=4,this.doStop(s);case 4:u++,e.n=3;break;case 5:e.n=7;break;case 6:return e.n=7,this.doStop();case 7:return e.a(2)}},e,this)})),function(){return a.apply(this,arguments)})},{key:"doStop",value:(t=r(n().m(function e(t){var r,o,a,i,u;return n().w(function(e){for(;;)switch(e.p=e.n){case 0:if(r=this.core.errorModule,o=r.RtcError,a=r.ErrorCode,this.core.room.sendSignalMessage){e.n=1;break}throw new o({code:a.ENV_NOT_SUPPORTED});case 1:return e.p=1,e.n=2,this.core.room.sendSignalMessage({command:"disconnect_other_room",responseCommand:String(8211),data:{roomId:t,localRoomId:this.core.room.roomId},retries:3});case 2:if(0===(i=e.v).data.code){e.n=3;break}throw new o({code:a.SERVER_ERROR,extraCode:i.data.code,message:i.data.message});case 3:e.n=5;break;case 4:if(e.p=4,(u=e.v).code===this.core.errorModule.CoreErrorCode.API_CALL_ABORTED){e.n=5;break}throw u;case 5:this.connectedRoomIdSet.delete(t);case 6:return e.a(2)}},e,this,[[1,4]])})),function(e){return t.apply(this,arguments)})},{key:"destroy",value:function(){}}]);var t,a,u,c}();return S(P,"Name","CrossRoom"),w([A({settings:{retries:3,timeout:1e3},onRetrying:function(e){this._log.warn("retry start: ".concat(e))}})],P.prototype,"start"),w([A({settings:{retries:3,timeout:1e3},onRetrying:function(e){this._log.warn("retry update: ".concat(e))}})],P.prototype,"update"),P});
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).CrossRoom=e()}(this,(function(){"use strict";function t(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function e(t,e,r,n,o,a,i){try{var c=t[a](i),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function r(t){return function(){var r=this,n=arguments;return new Promise((function(o,a){var i=t.apply(r,n);function c(t){e(i,o,a,c,u,"next",t)}function u(t){e(i,o,a,c,u,"throw",t)}c(void 0)}))}}function n(t,e,r){return e&&function(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,i(n.key),n)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function o(){o=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,a=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},c=i.iterator||"@@iterator",u=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function l(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var o=e&&e.prototype instanceof g?e:g,i=Object.create(o.prototype),c=new A(n||[]);return a(i,"_invoke",{value:L(t,r,c)}),i}function d(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var p="suspendedStart",h="suspendedYield",y="executing",m="completed",v={};function g(){}function b(){}function w(){}var x={};l(x,c,(function(){return this}));var S=Object.getPrototypeOf,E=S&&S(S(P([])));E&&E!==r&&n.call(E,c)&&(x=E);var R=w.prototype=g.prototype=Object.create(x);function I(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function k(t,e){function r(o,a,i,c){var u=d(t[o],t,a);if("throw"!==u.type){var s=u.arg,l=s.value;return l&&"object"==typeof l&&n.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,i,c)}),(function(t){r("throw",t,i,c)})):e.resolve(l).then((function(t){s.value=t,i(s)}),(function(t){return r("throw",t,i,c)}))}c(u.arg)}var o;a(this,"_invoke",{value:function(t,n){function a(){return new e((function(e,o){r(t,n,e,o)}))}return o=o?o.then(a,a):a()}})}function L(e,r,n){var o=p;return function(a,i){if(o===y)throw Error("Generator is already running");if(o===m){if("throw"===a)throw i;return{value:t,done:!0}}for(n.method=a,n.arg=i;;){var c=n.delegate;if(c){var u=_(c,n);if(u){if(u===v)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=y;var s=d(e,r,n);if("normal"===s.type){if(o=n.done?m:h,s.arg===v)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=m,n.method="throw",n.arg=s.arg)}}}function _(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,_(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;var a=d(o,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,v;var i=a.arg;return i?i.done?(r[e.resultName]=i.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function O(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function j(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function A(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(O,this),this.reset(!0)}function P(e){if(e||""===e){var r=e[c];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,a=function r(){for(;++o<e.length;)if(n.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}throw new TypeError(typeof e+" is not iterable")}return b.prototype=w,a(R,"constructor",{value:w,configurable:!0}),a(w,"constructor",{value:b,configurable:!0}),b.displayName=l(w,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===b||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,l(t,s,"GeneratorFunction")),t.prototype=Object.create(R),t},e.awrap=function(t){return{__await:t}},I(k.prototype),l(k.prototype,u,(function(){return this})),e.AsyncIterator=k,e.async=function(t,r,n,o,a){void 0===a&&(a=Promise);var i=new k(f(t,r,n,o),a);return e.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},I(R),l(R,s,"Generator"),l(R,c,(function(){return this})),l(R,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=P,A.prototype={constructor:A,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(j),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function o(n,o){return c.type="throw",c.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],c=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=e,a?(this.method="next",this.next=a.finallyLoc,v):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;j(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:P(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),v}},e}function a(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(e)||u(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t,"string");return"symbol"==typeof e?e:e+""}function c(t){return c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},c(t)}function u(e,r){if(e){if("string"==typeof e)return t(e,r);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?t(e,r):void 0}}var s=Object.defineProperty,l=Object.defineProperties,f=Object.getOwnPropertyDescriptor,d=Object.getOwnPropertyDescriptors,p=Object.getOwnPropertySymbols,h=Object.prototype.hasOwnProperty,y=Object.prototype.propertyIsEnumerable,m=function(t,e,r){return e in t?s(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r},v=function(t,e){for(var r in e||(e={}))h.call(e,r)&&m(t,r,e[r]);if(p){var n,o=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=u(t))||e){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return i=t.done,t},e:function(t){c=!0,a=t},f:function(){try{i||null==r.return||r.return()}finally{if(c)throw a}}}}(p(e));try{for(o.s();!(n=o.n()).done;){r=n.value;y.call(e,r)&&m(t,r,e[r])}}catch(t){o.e(t)}finally{o.f()}}return t},g=function(t,e){return l(t,d(e))},b=function(t,e,r,n){for(var o,a=f(e,r),i=t.length-1;i>=0;i--)(o=t[i])&&(a=o(e,r,a)||a);return a&&s(e,r,a),a},w=function(t,e,r){return m(t,"symbol"!==c(e)?e+"":e,r)},x={roomId:{type:"number"},strRoomId:{type:"string"}},S={name:"option",required:!0,properties:g(v({},x),{userId:{type:"string"}})},E={name:"option",required:!0,properties:{updateList:{type:"array",required:!0,arrayItem:{required:!0,type:"object",properties:g(v({},S.properties),{userId:{required:!1,type:"string"},muteAudio:{type:"boolean"},muteVideo:{type:"boolean"},muteSubStream:{type:"boolean"}})}}}},R={name:"option",properties:v({},x)},I=function(t){return"function"==typeof t};var k=function(t){var e=t.retryFunction,n=t.settings,a=t.onError,i=t.onRetrying,c=t.onRetryFailed,u=t.onRetrySuccess,s=t.context;return function(){for(var t=this,l=arguments.length,f=new Array(l),d=0;d<l;d++)f[d]=arguments[d];var p=n.retries,h=void 0===p?5:p,y=n.timeout,m=void 0===y?1e3:y,v=0,g=-1,b=0,w=function(){var n=r(o().mark((function r(n,l){var d,p,y,x;return o().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return d=s||t,r.prev=1,r.next=4,e.apply(d,f);case 4:p=r.sent,v>0&&u&&u.call(t,v),v=0,n(p),r.next=15;break;case 10:r.prev=10,r.t0=r.catch(1),y=function(){clearTimeout(g),v=0,b=2,l(r.t0)},x=function(){2!==b&&v<(I(h)?h():h)?(v++,b=1,I(i)&&i.call(t,v,y),g=window.setTimeout((function(){g=-1,w(n,l)}),I(m)?m(v):m)):(y(),I(c)&&c.call(t,r.t0))},I(a)?a.call(t,{error:r.t0,retry:x,reject:l,retryFuncArgs:f,retriedCount:v}):x();case 15:case"end":return r.stop()}}),r,null,[[1,10]])})));return function(t,e){return n.apply(this,arguments)}}();return new Promise(w)}},L=new WeakMap;function _(t){var e=t.settings,r=void 0===e?{retries:5,timeout:2e3}:e,n=t.onError,o=t.onRetrying,a=t.onRetryFailed;return function(t,e,i){var c=k({retryFunction:i.value,settings:r,onError:function(r){var o,a=r.error,i=r.retry,c=r.reject,u=r.retryFuncArgs;n?n.call(this,a,(function(){var r;(null==(r=L.get(t))?void 0:r.has(e))?i():c(a)}),c,u):(null==(o=L.get(t))?void 0:o.has(e))?i():c(a)},onRetrying:function(r,n){var a;I(o)&&o.call(this,r,n),(null==(a=L.get(t))?void 0:a.has(e))&&(L.get(t).get(e).stopRetry=n)},onRetryFailed:a});return i.value=function(){for(var r=L.get(t),n=arguments.length,o=new Array(n),a=0;a<n;a++)o[a]=arguments[a];return r?r.set(e,{args:o}):L.set(t,new Map([[e,{args:o}]])),c.apply(this,o).finally((function(){var r;return null==(r=L.get(t))?void 0:r.delete(e)}))},i}}var O=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.core=e,w(this,"disableRandomCall",!0),w(this,"connectedRoomIdSet",new Set),w(this,"updateSeq",0),w(this,"_log"),this._log=this.core.log.createChild({id:"".concat(this.getAlias())})}return n(t,[{key:"getName",value:function(){return t.Name}},{key:"getAlias",value:function(){return"crs-r"}},{key:"getGroup",value:function(t){var e,r=(null==t?void 0:t.userId)||(null==(e=null==t?void 0:t.updateList)?void 0:e[0].userId)||"";return r||(t?t.updateList?String(t.updateList[0].roomId)||t.updateList[0].strRoomId||"":String(t.roomId)||t.strRoomId||"":"*")}},{key:"getValidateRule",value:function(t){switch(t){case"start":return S;case"update":return E;case"stop":return R}}},{key:"start",value:(u=r(o().mark((function t(e){var r,n,a,i,c,u,s,l;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.roomId,n=e.strRoomId,a=e.userId,i=this.core.errorModule,c=i.RtcError,u=i.ErrorCode,this.core.room.sendSignalMessage){t.next=4;break}throw new c({code:u.ENV_NOT_SUPPORTED});case 4:return s=r||n,t.prev=5,t.next=8,this.core.room.sendSignalMessage({command:"connect_other_room",responseCommand:String(8209),data:{roomId:s,userId:a,localRoomId:a?void 0:this.core.room.roomId},retries:3});case 8:if(0===(l=t.sent).data.code){t.next=11;break}throw new c({code:u.SERVER_ERROR,extraCode:l.data.code,message:l.data.message});case 11:t.next=17;break;case 13:if(t.prev=13,t.t0=t.catch(5),t.t0.code===this.core.errorModule.CoreErrorCode.API_CALL_ABORTED){t.next=17;break}throw t.t0;case 17:a||this.connectedRoomIdSet.add(s);case 18:case"end":return t.stop()}}),t,this,[[5,13]])}))),function(t){return u.apply(this,arguments)})},{key:"update",value:(c=r(o().mark((function t(e){var r,n,a,i,c,u,s;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.updateList,a=this.core.errorModule,i=a.RtcError,c=a.ErrorCode,this.core.room.sendSignalMessage){t.next=4;break}throw new i({code:c.ENV_NOT_SUPPORTED});case 4:return u=r.find((function(t){return t.userId}))?0:1,t.prev=5,t.next=8,this.core.room.sendSignalMessage({command:"update_other_room_forward_mode",responseCommand:String(8213),data:{seq:++this.updateSeq,operationType:u,updateList:r.map((function(t){var e=t.roomId,r=t.strRoomId;return{roomId:e||r,userId:t.userId,muteAudio:t.muteAudio,muteVideo:t.muteVideo,muteSubStream:t.muteSubStream}}))},retries:3});case 8:if(!(s=t.sent).data.data.expectSeq){t.next=12;break}return this.updateSeq=s.data.data.expectSeq,t.abrupt("return",this.update({updateList:r}));case 12:if(0===s.data.code){t.next=16;break}throw new i({code:c.SERVER_ERROR,extraCode:s.data.code,message:s.data.message});case 16:if(!((null==(n=s.data.data.errorList)?void 0:n.length)>0)){t.next=18;break}throw new i({code:c.UNKNOWN_ERROR,message:s.data.data.errorList[0].message});case 18:t.next=24;break;case 20:if(t.prev=20,t.t0=t.catch(5),t.t0.code===this.core.errorModule.CoreErrorCode.API_CALL_ABORTED){t.next=24;break}throw t.t0;case 24:case"end":return t.stop()}}),t,this,[[5,20]])}))),function(t){return c.apply(this,arguments)})},{key:"stop",value:(i=r(o().mark((function t(){var e,r,n,i,c,u,s,l=arguments;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=(e=l.length>0&&void 0!==l[0]?l[0]:{}).roomId,n=e.strRoomId,!(i=r||n)){t.next=7;break}return t.next=5,this.doStop(i);case 5:t.next=20;break;case 7:if(!(this.connectedRoomIdSet.size>0)){t.next=18;break}c=0,u=a(this.connectedRoomIdSet.values());case 9:if(!(c<u.length)){t.next=16;break}return s=u[c],t.next=13,this.doStop(s);case 13:c++,t.next=9;break;case 16:t.next=20;break;case 18:return t.next=20,this.doStop();case 20:case"end":return t.stop()}}),t,this)}))),function(){return i.apply(this,arguments)})},{key:"doStop",value:(e=r(o().mark((function t(e){var r,n,a,i;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=this.core.errorModule,n=r.RtcError,a=r.ErrorCode,this.core.room.sendSignalMessage){t.next=3;break}throw new n({code:a.ENV_NOT_SUPPORTED});case 3:return t.prev=3,t.next=6,this.core.room.sendSignalMessage({command:"disconnect_other_room",responseCommand:String(8211),data:{roomId:e,localRoomId:this.core.room.roomId},retries:3});case 6:if(0===(i=t.sent).data.code){t.next=9;break}throw new n({code:a.SERVER_ERROR,extraCode:i.data.code,message:i.data.message});case 9:t.next=15;break;case 11:if(t.prev=11,t.t0=t.catch(3),t.t0.code===this.core.errorModule.CoreErrorCode.API_CALL_ABORTED){t.next=15;break}throw t.t0;case 15:this.connectedRoomIdSet.delete(e);case 16:case"end":return t.stop()}}),t,this,[[3,11]])}))),function(t){return e.apply(this,arguments)})},{key:"destroy",value:function(){}}]);var e,i,c,u}();return w(O,"Name","CrossRoom"),b([_({settings:{retries:3,timeout:1e3},onRetrying:function(t){this._log.warn("retry start: ".concat(t))}})],O.prototype,"start"),b([_({settings:{retries:3,timeout:1e3},onRetrying:function(t){this._log.warn("retry update: ".concat(t))}})],O.prototype,"update"),O}));
|