trtc-sdk-v5 5.12.0 → 5.12.1-beta.10
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/index.d.ts +41 -0
- package/package.json +1 -1
- package/plugins/cdn-streaming/package.json +1 -1
- package/plugins/cross-room/cross-room.esm.js +1 -1
- package/plugins/cross-room/cross-room.umd.js +1 -1
- package/plugins/cross-room/package.json +1 -1
- package/plugins/custom-encryption/package.json +1 -1
- package/plugins/device-detector/package.json +1 -1
- package/plugins/small-stream-auto-switcher/package.json +1 -1
- package/plugins/video-decoder/package.json +1 -1
- package/plugins/video-decoder/video-decoder.esm.js +1 -1
- package/plugins/video-effect/basic-beauty/basic-beauty.esm.js +1 -1
- package/plugins/video-effect/basic-beauty/basic-beauty.umd.js +1 -1
- package/plugins/video-effect/basic-beauty/package.json +1 -1
- package/plugins/video-effect/beauty/package.json +1 -1
- package/plugins/video-effect/video-mixer/package.json +1 -1
- 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 -1
- package/plugins/video-effect/watermark/package.json +1 -1
- package/plugins/voice-changer/package.json +1 -1
- package/trtc.esm.js +29 -29
- package/trtc.js +1 -1
package/index.d.ts
CHANGED
|
@@ -487,6 +487,15 @@ export declare const enum TRTCDeviceAction {
|
|
|
487
487
|
Add = 'add',
|
|
488
488
|
Active = 'active'
|
|
489
489
|
}
|
|
490
|
+
export declare interface PermissionOption {
|
|
491
|
+
request?: boolean;
|
|
492
|
+
types?: ('camera' | 'microphone')[];
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
export declare interface PermissionResult {
|
|
496
|
+
camera: PermissionState | null;
|
|
497
|
+
microphone: PermissionState | null;
|
|
498
|
+
}
|
|
490
499
|
export declare interface RTCErrorParams {
|
|
491
500
|
code: number;
|
|
492
501
|
extraCode?: number;
|
|
@@ -1176,6 +1185,18 @@ export declare const TRTCEvent: {
|
|
|
1176
1185
|
* })
|
|
1177
1186
|
*/
|
|
1178
1187
|
readonly FIRST_VIDEO_FRAME: 'first-video-frame';
|
|
1188
|
+
|
|
1189
|
+
/**
|
|
1190
|
+
* @since v5.13.0
|
|
1191
|
+
* @description Notification event for device permission changes.
|
|
1192
|
+
* @default 'permission-state-change'
|
|
1193
|
+
* @memberof module:EVENT
|
|
1194
|
+
* @example
|
|
1195
|
+
* trtc.on(TRTC.EVENT.PERMISSION_STATE_CHANGE, event => {
|
|
1196
|
+
* console.log(event.camera, event.microphone); // 'granted' | 'denied' | 'prompt' | null. null means the permission is not supported query.
|
|
1197
|
+
* });
|
|
1198
|
+
*/
|
|
1199
|
+
readonly PERMISSION_STATE_CHANGE: 'permission-state-change';
|
|
1179
1200
|
};
|
|
1180
1201
|
export declare interface TRTCEventTypes {
|
|
1181
1202
|
[TRTCEvent.ERROR]: [RtcError];
|
|
@@ -1262,6 +1283,10 @@ export declare interface TRTCEventTypes {
|
|
|
1262
1283
|
sourceTrack: MediaStreamTrack;
|
|
1263
1284
|
}];
|
|
1264
1285
|
[TRTCEvent.CUSTOM_MESSAGE]: [CustomMessage];
|
|
1286
|
+
[TRTCEvent.PERMISSION_STATE_CHANGE]: [{
|
|
1287
|
+
camera: PermissionState;
|
|
1288
|
+
microphone: PermissionState;
|
|
1289
|
+
}];
|
|
1265
1290
|
}
|
|
1266
1291
|
|
|
1267
1292
|
export declare interface CustomMessageData {
|
|
@@ -2192,6 +2217,22 @@ export declare class TRTC {
|
|
|
2192
2217
|
* | checkResult.detail.isVp8DecodeSupported | boolean | Whether the current browser supports VP8 decoding for downlink |
|
|
2193
2218
|
*/
|
|
2194
2219
|
static isSupported(): Promise<any>;
|
|
2220
|
+
|
|
2221
|
+
/**
|
|
2222
|
+
* Get the permission state of the camera and microphone. Since v5.13.0+.
|
|
2223
|
+
* @param {PermissionOption} option
|
|
2224
|
+
* @param {boolean} [option.request=true] Whether to request permission to use the camera and microphone.
|
|
2225
|
+
* @param {string[]} [option.types=['camera', 'microphone']] The types of permission to request.
|
|
2226
|
+
* @returns {Promise<PermissionResult>} Promise returns the permission state of the camera and microphone
|
|
2227
|
+
* @example
|
|
2228
|
+
* const { camera, microphone } = await TRTC.getPermissions({
|
|
2229
|
+
* request: true, // if true, will request permission to use the camera and microphone.
|
|
2230
|
+
* types: ['camera', 'microphone']
|
|
2231
|
+
* });
|
|
2232
|
+
* console.log(camera, microphone); // 'granted' | 'denied' | 'prompt' | null. null means the permission is not supported query.
|
|
2233
|
+
*/
|
|
2234
|
+
static getPermissions(option: PermissionOption): Promise<PermissionResult>;
|
|
2235
|
+
|
|
2195
2236
|
/**
|
|
2196
2237
|
* Returns the list of camera devices
|
|
2197
2238
|
* <br>
|
package/package.json
CHANGED
|
@@ -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,t
|
|
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 +1 @@
|
|
|
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,i,a){try{var u=t[i](a),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,o)}function r(t){return function(){var r=this,n=arguments;return new Promise((function(o,i){var a=t.apply(r,n);function u(t){e(a,o,i,u,c,"next",t)}function c(t){e(a,o,i,u,c,"throw",t)}u(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,a(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,i=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},u=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",s=a.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,a=Object.create(o.prototype),u=new P(n||[]);return i(a,"_invoke",{value:O(t,r,u)}),a}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,u,(function(){return this}));var S=Object.getPrototypeOf,E=S&&S(S(T([])));E&&E!==r&&n.call(E,u)&&(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,i,a,u){var c=d(t[o],t,i);if("throw"!==c.type){var s=c.arg,l=s.value;return l&&"object"==typeof l&&n.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,a,u)}),(function(t){r("throw",t,a,u)})):e.resolve(l).then((function(t){s.value=t,a(s)}),(function(t){return r("throw",t,a,u)}))}u(c.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,o){r(t,n,e,o)}))}return o=o?o.then(i,i):i()}})}function O(e,r,n){var o=p;return function(i,a){if(o===y)throw Error("Generator is already running");if(o===m){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var u=n.delegate;if(u){var c=L(u,n);if(c){if(c===v)continue;return c}}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 L(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,L(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;var i=d(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,v;var a=i.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function _(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 P(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(_,this),this.reset(!0)}function T(e){if(e||""===e){var r=e[u];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=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 i.next=i}}throw new TypeError(typeof e+" is not iterable")}return b.prototype=w,i(R,"constructor",{value:w,configurable:!0}),i(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,c,(function(){return this})),e.AsyncIterator=k,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new k(f(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},I(R),l(R,s,"Generator"),l(R,u,(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=T,P.prototype={constructor:P,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 u.type="throw",u.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],u=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var c=n.call(a,"catchLoc"),s=n.call(a,"finallyLoc");if(c&&s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.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 i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,v):this.complete(a)},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:T(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),v}},e}function i(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)||c(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 a(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 u(t){return u="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},u(t)}function c(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=c(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 i,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}(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,i=f(e,r),a=t.length-1;a>=0;a--)(o=t[a])&&(i=o(e,r,i)||i);return i&&s(e,r,i),i},w=function(t,e,r){return m(t,"symbol"!==u(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,i=t.onError,a=t.onRetrying,u=t.onRetryFailed,c=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&&c&&c.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(a)&&a.call(t,v,y),g=window.setTimeout((function(){g=-1,w(n,l)}),I(m)?m(v):m)):(y(),I(u)&&u.call(t,r.t0))},I(i)?i.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)}},O=new WeakMap;function L(t){var e=t.settings,r=void 0===e?{retries:5,timeout:2e3}:e,n=t.onError,o=t.onRetrying,i=t.onRetryFailed;return function(t,e,a){var u=k({retryFunction:a.value,settings:r,onError:function(r){var o,i=r.error,a=r.retry,u=r.reject,c=r.retryFuncArgs;n?n.call(this,i,(function(){var r;(null==(r=O.get(t))?void 0:r.has(e))?a():u(i)}),u,c):(null==(o=O.get(t))?void 0:o.has(e))?a():u(i)},onRetrying:function(r,n){var i;I(o)&&o.call(this,r,n),(null==(i=O.get(t))?void 0:i.has(e))&&(O.get(t).get(e).stopRetry=n)},onRetryFailed:i});return a.value=function(){for(var r=O.get(t),n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];return r?r.set(e,{args:o}):O.set(t,new Map([[e,{args:o}]])),u.apply(this,o).finally((function(){var r;return null==(r=O.get(t))?void 0:r.delete(e)}))},a}}var _=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:(c=r(o().mark((function t(e){var r,n,i,a,u,c,s,l;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.roomId,n=e.strRoomId,i=e.userId,a=this.core.errorModule,u=a.RtcError,c=a.ErrorCode,this.core.room.sendSignalMessage){t.next=4;break}throw new u({code:c.ENV_NOT_SUPPORTED});case 4:return s=r||n,t.next=7,this.core.room.sendSignalMessage({command:"connect_other_room",responseCommand:String(8209),data:{roomId:s,userId:i,localRoomId:i?void 0:this.core.room.roomId},retries:3});case 7:if(0===(l=t.sent).data.code){t.next=10;break}throw new u({code:c.SERVER_ERROR,extraCode:l.data.code,message:l.data.message});case 10:i||this.connectedRoomIdSet.add(s);case 11:case"end":return t.stop()}}),t,this)}))),function(t){return c.apply(this,arguments)})},{key:"update",value:(u=r(o().mark((function t(e){var r,n,i,a,u,c,s;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.updateList,i=this.core.errorModule,a=i.RtcError,u=i.ErrorCode,this.core.room.sendSignalMessage){t.next=4;break}throw new a({code:u.ENV_NOT_SUPPORTED});case 4:return c=r.find((function(t){return t.userId}))?0:1,t.next=7,this.core.room.sendSignalMessage({command:"update_other_room_forward_mode",responseCommand:String(8213),data:{seq:++this.updateSeq,operationType:c,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 7:if(!(s=t.sent).data.data.expectSeq){t.next=11;break}return this.updateSeq=s.data.data.expectSeq,t.abrupt("return",this.update({updateList:r}));case 11:if(0===s.data.code){t.next=15;break}throw new a({code:u.SERVER_ERROR,extraCode:s.data.code,message:s.data.message});case 15:if(!((null==(n=s.data.data.errorList)?void 0:n.length)>0)){t.next=17;break}throw new a({code:u.UNKNOWN_ERROR,message:s.data.data.errorList[0].message});case 17:case"end":return t.stop()}}),t,this)}))),function(t){return u.apply(this,arguments)})},{key:"stop",value:(a=r(o().mark((function t(){var e,r,n,a,u,c,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,!(a=r||n)){t.next=7;break}return t.next=5,this.doStop(a);case 5:t.next=20;break;case 7:if(!(this.connectedRoomIdSet.size>0)){t.next=18;break}u=0,c=i(this.connectedRoomIdSet.values());case 9:if(!(u<c.length)){t.next=16;break}return s=c[u],t.next=13,this.doStop(s);case 13:u++,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 a.apply(this,arguments)})},{key:"doStop",value:(e=r(o().mark((function t(e){var r,n,i,a;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=this.core.errorModule,n=r.RtcError,i=r.ErrorCode,this.core.room.sendSignalMessage){t.next=3;break}throw new n({code:i.ENV_NOT_SUPPORTED});case 3:return t.next=5,this.core.room.sendSignalMessage({command:"disconnect_other_room",responseCommand:String(8211),data:{roomId:e,localRoomId:this.core.room.roomId},retries:3});case 5:if(0===(a=t.sent).data.code){t.next=8;break}throw new n({code:i.SERVER_ERROR,extraCode:a.data.code,message:a.data.message});case 8:this.connectedRoomIdSet.delete(e);case 9:case"end":return t.stop()}}),t,this)}))),function(t){return e.apply(this,arguments)})},{key:"destroy",value:function(){}}]);var e,a,u,c}();return w(_,"Name","CrossRoom"),b([L({settings:{retries:3,timeout:1e3},onRetrying:function(t){this._log.warn("retry start: ".concat(t))}})],_.prototype,"start"),b([L({settings:{retries:3,timeout:1e3},onRetrying:function(t){this._log.warn("retry update: ".concat(t))}})],_.prototype,"update"),_}));
|
|
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}));
|