trtc-sdk-v5 5.13.0-beta.15 → 5.13.0-beta.16

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.
Files changed (41) hide show
  1. package/assets/debug-dialog.js +1 -1
  2. package/index.d.ts +45 -1
  3. package/package.json +1 -1
  4. package/plugins/cdn-streaming/cdn-streaming.esm.js +1 -1
  5. package/plugins/cdn-streaming/cdn-streaming.umd.js +1 -1
  6. package/plugins/cdn-streaming/package.json +1 -1
  7. package/plugins/cross-room/cross-room.esm.js +1 -1
  8. package/plugins/cross-room/cross-room.umd.js +1 -1
  9. package/plugins/cross-room/package.json +1 -1
  10. package/plugins/custom-encryption/custom-encryption.esm.js +1 -1
  11. package/plugins/custom-encryption/custom-encryption.umd.js +1 -1
  12. package/plugins/custom-encryption/package.json +1 -1
  13. package/plugins/device-detector/device-detector.esm.js +28 -14
  14. package/plugins/device-detector/device-detector.umd.js +21 -7
  15. package/plugins/device-detector/package.json +1 -1
  16. package/plugins/small-stream-auto-switcher/package.json +1 -1
  17. package/plugins/small-stream-auto-switcher/small-stream-auto-switcher.esm.js +1 -1
  18. package/plugins/small-stream-auto-switcher/small-stream-auto-switcher.umd.js +1 -1
  19. package/plugins/video-decoder/package.json +1 -1
  20. package/plugins/video-decoder/video-decoder.esm.js +1 -1
  21. package/plugins/video-decoder/video-decoder.umd.js +1 -1
  22. package/plugins/video-effect/basic-beauty/basic-beauty.esm.js +1 -1
  23. package/plugins/video-effect/basic-beauty/basic-beauty.umd.js +1 -1
  24. package/plugins/video-effect/basic-beauty/package.json +1 -1
  25. package/plugins/video-effect/beauty/beauty.esm.js +1 -1
  26. package/plugins/video-effect/beauty/beauty.umd.js +1 -1
  27. package/plugins/video-effect/beauty/package.json +1 -1
  28. package/plugins/video-effect/video-mixer/package.json +1 -1
  29. package/plugins/video-effect/video-mixer/video-mixer.esm.js +1 -1
  30. package/plugins/video-effect/video-mixer/video-mixer.umd.js +1 -1
  31. package/plugins/video-effect/virtual-background/package.json +1 -1
  32. package/plugins/video-effect/virtual-background/virtual-background.esm.js +1 -1
  33. package/plugins/video-effect/virtual-background/virtual-background.umd.js +1 -1
  34. package/plugins/video-effect/watermark/package.json +1 -1
  35. package/plugins/video-effect/watermark/watermark.esm.js +1 -1
  36. package/plugins/video-effect/watermark/watermark.umd.js +1 -1
  37. package/plugins/voice-changer/package.json +1 -1
  38. package/plugins/voice-changer/voice-changer.esm.js +1 -1
  39. package/plugins/voice-changer/voice-changer.umd.js +1 -1
  40. package/trtc.esm.js +28 -28
  41. package/trtc.js +1 -1
@@ -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,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}));
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 c=t[i](a),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,i){var a=t.apply(r,n);function c(t){e(a,o,i,c,u,"next",t)}function u(t){e(a,o,i,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,s(n.key),n)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function o(t,e,r){return(e=s(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function i(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function a(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?i(Object(r),!0).forEach((function(e){o(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function c(){c=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},a=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 i=e&&e.prototype instanceof g?e:g,a=Object.create(i.prototype),c=new P(n||[]);return o(a,"_invoke",{value:L(t,r,c)}),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 h="suspendedStart",p="suspendedYield",y="executing",m="completed",v={};function g(){}function b(){}function w(){}var x={};l(x,a,(function(){return this}));var E=Object.getPrototypeOf,R=E&&E(E(A([])));R&&R!==r&&n.call(R,a)&&(x=R);var S=w.prototype=g.prototype=Object.create(x);function O(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,c){var u=d(t[o],t,i);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,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(l).then((function(t){s.value=t,a(s)}),(function(t){return r("throw",t,a,c)}))}c(u.arg)}var i;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return i=i?i.then(o,o):o()}})}function L(e,r,n){var o=h;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 c=n.delegate;if(c){var u=I(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===h)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:p,s.arg===v)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=m,n.method="throw",n.arg=s.arg)}}}function I(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,I(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 A(e){if(e||""===e){var r=e[a];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,o(S,"constructor",{value:w,configurable:!0}),o(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(S),t},e.awrap=function(t){return{__await:t}},O(k.prototype),l(k.prototype,u,(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()}))},O(S),l(S,s,"Generator"),l(S,a,(function(){return this})),l(S,"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=A,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 c.type="throw",c.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],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),s=n.call(a,"finallyLoc");if(u&&s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(u){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:A(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),v}},e}function u(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)||function(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}}(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 s(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"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}var l,f=Object.defineProperty,d=Object.getOwnPropertyDescriptor,h=function(t,e,r,n){for(var o,i=d(e,r),a=t.length-1;a>=0;a--)(o=t[a])&&(i=o(e,r,i)||i);return i&&f(e,r,i),i},p={roomId:{type:"number"},strRoomId:{type:"string"}},y={name:"option",required:!0,properties:a(a({},p),{},{userId:{type:"string"}})},m={name:"option",required:!0,properties:{updateList:{type:"array",required:!0,arrayItem:{required:!0,type:"object",properties:a(a({},y.properties),{},{userId:{required:!1,type:"string"},muteAudio:{type:"boolean"},muteVideo:{type:"boolean"},muteSubStream:{type:"boolean"}})}}}},v={name:"option",properties:a({},p)},g=function(t){return"function"==typeof t};var b=function(t){var e=t.retryFunction,n=t.settings,o=t.onError,i=t.onRetrying,a=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 h=n.retries,p=void 0===h?5:h,y=n.timeout,m=void 0===y?1e3:y,v=0,b=-1,w=0,x=function(){var n=r(c().mark((function r(n,l){var d,h,y,E;return c().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:h=r.sent,v>0&&u&&u.call(t,v),v=0,n(h),r.next=15;break;case 10:r.prev=10,r.t0=r.catch(1),y=function(){clearTimeout(b),v=0,w=2,l(r.t0)},E=function(){2!==w&&v<(g(p)?p():p)?(v++,w=1,g(i)&&i.call(t,v,y),b=window.setTimeout((function(){b=-1,x(n,l)}),g(m)?m(v):m)):(y(),g(a)&&a.call(t,r.t0))},g(o)?o.call(t,{error:r.t0,retry:E,reject:l,retryFuncArgs:f,retriedCount:v}):E();case 15:case"end":return r.stop()}}),r,null,[[1,10]])})));return function(t,e){return n.apply(this,arguments)}}();return new Promise(x)}},w=new WeakMap;function x(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 c=b({retryFunction:a.value,settings:r,onError:function(r){var o,i=r.error,a=r.retry,c=r.reject,u=r.retryFuncArgs;n?n.call(this,i,(function(){var r;null!==(r=w.get(t))&&void 0!==r&&r.has(e)?a():c(i)}),c,u):null!==(o=w.get(t))&&void 0!==o&&o.has(e)?a():c(i)},onRetrying:function(r,n){var i;g(o)&&o.call(this,r,n),null!==(i=w.get(t))&&void 0!==i&&i.has(e)&&(w.get(t).get(e).stopRetry=n)},onRetryFailed:i});return a.value=function(){for(var r=w.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}):w.set(t,new Map([[e,{args:o}]])),c.apply(this,o).finally((function(){var r;return null===(r=w.get(t))||void 0===r?void 0:r.delete(e)}))},a}}var E=(l=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),o(this,"disableRandomCall",!0),o(this,"connectedRoomIdSet",new Set),o(this,"updateSeq",0),o(this,"_log",void 0),this.core=e,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==t||null===(e=t.updateList)||void 0===e?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 y;case"update":return m;case"stop":return v}}},{key:"start",value:(s=r(c().mark((function t(e){var r,n,o,i,a,u,s,l;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.roomId,n=e.strRoomId,o=e.userId,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 s=r||n,t.prev=5,t.next=8,this.core.room.sendSignalMessage({command:"connect_other_room",responseCommand:String(8209),data:{roomId:s,userId:o,localRoomId:o?void 0:this.core.room.roomId},retries:3});case 8:if(0===(l=t.sent).data.code){t.next=11;break}throw new a({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:o||this.connectedRoomIdSet.add(s);case 18:case"end":return t.stop()}}),t,this,[[5,13]])}))),function(t){return s.apply(this,arguments)})},{key:"update",value:(a=r(c().mark((function t(e){var r,n,o,i,a,u,s;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.updateList,n=this.core.errorModule,o=n.RtcError,i=n.ErrorCode,this.core.room.sendSignalMessage){t.next=4;break}throw new o({code:i.ENV_NOT_SUPPORTED});case 4:return a=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:a,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 o({code:i.SERVER_ERROR,extraCode:s.data.code,message:s.data.message});case 16:if(!((null===(u=s.data.data.errorList)||void 0===u?void 0:u.length)>0)){t.next=18;break}throw new o({code:i.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 a.apply(this,arguments)})},{key:"stop",value:(i=r(c().mark((function t(){var e,r,n,o,i,a,s,l=arguments;return c().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,!(o=r||n)){t.next=7;break}return t.next=5,this.doStop(o);case 5:t.next=20;break;case 7:if(!(this.connectedRoomIdSet.size>0)){t.next=18;break}i=0,a=u(this.connectedRoomIdSet.values());case 9:if(!(i<a.length)){t.next=16;break}return s=a[i],t.next=13,this.doStop(s);case 13:i++,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(c().mark((function t(e){var r,n,o,i;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=this.core.errorModule,n=r.RtcError,o=r.ErrorCode,this.core.room.sendSignalMessage){t.next=3;break}throw new n({code:o.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:o.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,a,s}(),o(l,"Name","CrossRoom"),l);return h([x({settings:{retries:3,timeout:1e3},onRetrying:function(t){this._log.warn("retry start: ".concat(t))}})],E.prototype,"start"),h([x({settings:{retries:3,timeout:1e3},onRetrying:function(t){this._log.warn("retry update: ".concat(t))}})],E.prototype,"update"),E}));
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/cross-room",
3
- "version": "5.13.0-beta.15",
3
+ "version": "5.13.0-beta.16",
4
4
  "description": "TRTC Web SDK 5.x Cross Room plugin",
5
5
  "main": "./cross-room.esm.js",
6
6
  "module": "./cross-room.esm.js",