10 lines
43 KiB
JavaScript
10 lines
43 KiB
JavaScript
import{r as U}from"./tim-js-sdk-D6E6n_Uo.js";var V={exports:{}},G;function H(){return G||(G=1,function(F,K){(function(k,C){F.exports=C(U())})(window,function(k){return function(C){var b={};function E(I){if(b[I])return b[I].exports;var m=b[I]={i:I,l:!1,exports:{}};return C[I].call(m.exports,m,m.exports,E),m.l=!0,m.exports}return E.m=C,E.c=b,E.d=function(I,m,_){E.o(I,m)||Object.defineProperty(I,m,{enumerable:!0,get:_})},E.r=function(I){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(I,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(I,"__esModule",{value:!0})},E.t=function(I,m){if(1&m&&(I=E(I)),8&m||4&m&&typeof I=="object"&&I&&I.__esModule)return I;var _=Object.create(null);if(E.r(_),Object.defineProperty(_,"default",{enumerable:!0,value:I}),2&m&&typeof I!="string")for(var a in I)E.d(_,a,(function(o){return I[o]}).bind(null,a));return _},E.n=function(I){var m=I&&I.__esModule?function(){return I.default}:function(){return I};return E.d(m,"a",m),m},E.o=function(I,m){return Object.prototype.hasOwnProperty.call(I,m)},E.p="",E(E.s=7)}([function(C,b,E){E.d(b,"e",function(){return a}),E.d(b,"g",function(){return o}),E.d(b,"c",function(){return s}),E.d(b,"f",function(){return u}),E.d(b,"b",function(){return l}),E.d(b,"d",function(){return D}),E.d(b,"a",function(){return x}),E.d(b,"h",function(){return S});const I=typeof window<"u",m=(typeof wx<"u"&&wx.getSystemInfoSync,I&&window.navigator&&window.navigator.userAgent||""),_=/AppleWebKit\/([\d.]+)/i.exec(m);_&&parseFloat(_.pop()),/iPad/i.test(m),function(){const f=m.match(/OS (\d+)_/i);f&&f[1]&&f[1]}(),/Android/i.test(m),function(){const f=m.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(!f)return null;const N=f[1]&&parseFloat(f[1]),T=f[2]&&parseFloat(f[2]);return N&&T?parseFloat(f[1]+"."+f[2]):N||null}(),function(){const f=m.match(/Chrome\/(\d+)/);f&&f[1]&&parseFloat(f[1])}(),function(){const f=/MSIE\s(\d+)\.\d/.exec(m);f&&parseFloat(f[1])}(),/TBS\/\d+/i.test(m),function(){const f=m.match(/TBS\/(\d+)/i);f&&f[1]&&f[1]}(),E(2),E(1);const a=function(f){return A(f)==="map"},o=function(f){return A(f)==="set"},s=function(f){return A(f)==="file"},u=function(f){if(typeof f!="object"||f===null)return!1;const N=Object.getPrototypeOf(f);if(N===null)return!0;let T=N;for(;Object.getPrototypeOf(T)!==null;)T=Object.getPrototypeOf(T);return N===T},g=function(f){return typeof Array.isArray=="function"?Array.isArray(f):A(f)==="array"},l=function(f){return g(f)||function(N){return N!==null&&typeof N=="object"}(f)},D=function(f){return f instanceof Error},A=function(f){return Object.prototype.toString.call(f).match(/^\[object (.*)\]$/)[1].toLowerCase()};let L=0;Date.now||(Date.now=function(){return new Date().getTime()});const x={now:function(){L===0&&(L=Date.now()-1);const f=Date.now()-L;return f>4294967295?(L+=4294967295,Date.now()-L):f},utc:function(){return Math.round(Date.now()/1e3)}},S=function(f){return JSON.stringify(f,["message","code"])}},function(C,b,E){E.r(b);var I=E(3),m=E(0);let _=0;const a=new Map;function o(){const u=new Date;return"TSignaling "+u.toLocaleTimeString("en-US",{hour12:!1})+"."+function(g){let l;switch(g.toString().length){case 1:l="00"+g;break;case 2:l="0"+g;break;default:l=g}return l}(u.getMilliseconds())+":"}const s={_data:[],_length:0,_visible:!1,arguments2String(u){let g;if(u.length===1)g=o()+u[0];else{g=o();for(let l=0,D=u.length;l<D;l++)Object(m.b)(u[l])?Object(m.d)(u[l])?g+=Object(m.h)(u[l]):g+=JSON.stringify(u[l]):g+=u[l],g+=" "}return g},debug:function(){if(_<=-1){const u=this.arguments2String(arguments);s.record(u,"debug"),I.a.debug(u)}},log:function(){if(_<=0){const u=this.arguments2String(arguments);s.record(u,"log"),I.a.log(u)}},info:function(){if(_<=1){const u=this.arguments2String(arguments);s.record(u,"info"),I.a.info(u)}},warn:function(){if(_<=2){const u=this.arguments2String(arguments);s.record(u,"warn"),I.a.warn(u)}},error:function(){if(_<=3){const u=this.arguments2String(arguments);s.record(u,"error"),I.a.error(u)}},time:function(u){a.set(u,m.a.now())},timeEnd:function(u){if(a.has(u)){const g=m.a.now()-a.get(u);return a.delete(u),g}return I.a.warn(`未找到对应label: ${u}, 请在调用 logger.timeEnd 前,调用 logger.time`),0},setLevel:function(u){u<4&&I.a.log(o()+"set level from "+_+" to "+u),_=u},record:function(u,g){s._length===1100&&(s._data.splice(0,100),s._length=1e3),s._length++,s._data.push(`${u} [${g}]
|
|
`)},getLog:function(){return s._data}};b.default=s},function(C,b,E){E.r(b),b.default={MSG_PRIORITY_HIGH:"High",MSG_PRIORITY_NORMAL:"Normal",MSG_PRIORITY_LOW:"Low",MSG_PRIORITY_LOWEST:"Lowest",KICKED_OUT_MULT_ACCOUNT:"multipleAccount",KICKED_OUT_MULT_DEVICE:"multipleDevice",KICKED_OUT_USERSIG_EXPIRED:"userSigExpired",NET_STATE_CONNECTED:"connected",NET_STATE_CONNECTING:"connecting",NET_STATE_DISCONNECTED:"disconnected",ENTER_ROOM_SUCCESS:"JoinedSuccess",ALREADY_IN_ROOM:"AlreadyInGroup"}},function(C,b,E){(function(I){let m,_;m=typeof console<"u"?console:I!==void 0&&I.console?I.console:typeof window<"u"&&window.console?window.console:{};const a=function(){},o=["assert","clear","count","debug","dir","dirxml","error","group","groupCollapsed","groupEnd","info","log","profile","profileEnd","table","time","timeEnd","timeStamp","trace","warn"];let s=o.length;for(;s--;)_=o[s],console[_]||(m[_]=a);b.a=m}).call(this,E(9))},function(C,b,E){Object.defineProperty(b,"__esModule",{value:!0}),b.default={NEW_INVITATION_RECEIVED:"ts_new_invitation_received",INVITEE_ACCEPTED:"ts_invitee_accepted",INVITEE_REJECTED:"ts_invitee_rejected",INVITATION_CANCELLED:"ts_invitation_cancelled",INVITATION_TIMEOUT:"ts_invitation_timeout",SDK_READY:"ts_im_ready",SDK_NOT_READY:"ts_im_not_ready",TEXT_MESSAGE_RECEIVED:"ts_text_message_received",CUSTOM_MESSAGE_RECEIVED:"ts_custom_message_received",REMOTE_USER_JOIN:"ts_remote_user_join",REMOTE_USER_LEAVE:"ts_remote_user_leave",KICKED_OUT:"ts_kicked_out",NET_STATE_CHANGE:"ts_net_state_change",MESSAGE_SENT_BY_ME:"ts_message_sent_by_me"}},function(C,b,E){var I,m,_;Object.defineProperty(b,"__esModule",{value:!0}),b.ErrorCode=b.BusinessID=b.ActionType=void 0,function(a){a[a.INVITE=1]="INVITE",a[a.CANCEL_INVITE=2]="CANCEL_INVITE",a[a.ACCEPT_INVITE=3]="ACCEPT_INVITE",a[a.REJECT_INVITE=4]="REJECT_INVITE",a[a.INVITE_TIMEOUT=5]="INVITE_TIMEOUT"}(I||(I={})),b.ActionType=I,function(a){a[a.SIGNAL=1]="SIGNAL"}(m||(m={})),b.BusinessID=m,function(a){a[a.ERR_INVALID_PARAMETERS=6017]="ERR_INVALID_PARAMETERS",a[a.ERR_SDK_SIGNALING_INVALID_INVITE_ID=8010]="ERR_SDK_SIGNALING_INVALID_INVITE_ID",a[a.ERR_SDK_SIGNALING_NO_PERMISSION=8011]="ERR_SDK_SIGNALING_NO_PERMISSION"}(_||(_={})),b.ErrorCode=_},function(C,b){C.exports=k},function(C,b,E){var I=this&&this.__assign||function(){return(I=Object.assign||function(c){for(var e,t=1,i=arguments.length;t<i;t++)for(var n in e=arguments[t])Object.prototype.hasOwnProperty.call(e,n)&&(c[n]=e[n]);return c}).apply(this,arguments)},m=this&&this.__awaiter||function(c,e,t,i){return new(t||(t=Promise))(function(n,d){function r(v){try{y(i.next(v))}catch(p){d(p)}}function h(v){try{y(i.throw(v))}catch(p){d(p)}}function y(v){var p;v.done?n(v.value):(p=v.value,p instanceof t?p:new t(function(w){w(p)})).then(r,h)}y((i=i.apply(c,e||[])).next())})},_=this&&this.__generator||function(c,e){var t,i,n,d,r={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return d={next:h(0),throw:h(1),return:h(2)},typeof Symbol=="function"&&(d[Symbol.iterator]=function(){return this}),d;function h(y){return function(v){return function(p){if(t)throw new TypeError("Generator is already executing.");for(;r;)try{if(t=1,i&&(n=2&p[0]?i.return:p[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,p[1])).done)return n;switch(i=0,n&&(p=[2&p[0],n.value]),p[0]){case 0:case 1:n=p;break;case 4:return r.label++,{value:p[1],done:!1};case 5:r.label++,i=p[1],p=[0];continue;case 7:p=r.ops.pop(),r.trys.pop();continue;default:if(n=r.trys,!((n=n.length>0&&n[n.length-1])||p[0]!==6&&p[0]!==2)){r=0;continue}if(p[0]===3&&(!n||p[1]>n[0]&&p[1]<n[3])){r.label=p[1];break}if(p[0]===6&&r.label<n[1]){r.label=n[1],n=p;break}if(n&&r.label<n[2]){r.label=n[2],r.ops.push(p);break}n[2]&&r.ops.pop(),r.trys.pop();continue}p=e.call(c,r)}catch(w){p=[6,w],i=0}finally{t=n=0}if(5&p[0])throw p[1];return{value:p[0]?p[1]:void 0,done:!0}}([y,v])}}},a=this&&this.__spreadArrays||function(){for(var c=0,e=0,t=arguments.length;e<t;e++)c+=arguments[e].length;var i=Array(c),n=0;for(e=0;e<t;e++)for(var d=arguments[e],r=0,h=d.length;r<h;r++,n++)i[n]=d[r];return i};Object.defineProperty(b,"__esModule",{value:!0});var o=E(5),s=E(8),u=E(4),g=E(2),l=E(1),D=E(10),A=E(11),L=E(12),x=E(13),S=E(6),f=E(15).version,N=E(16),T=function(){function c(e){if(this._outerEmitter=null,this._safetyCallbackFactory=null,this._tim=null,this._imSDKAppID=0,this._userID=null,this._groupID="",this._isHandling=!1,this._inviteInfoMap=new Map,this._isRejectNotifyAll=!1,this.offlineSupport=!0,l.default.info("TSignaling version:"+f),D.default(e.SDKAppID))return l.default.error("TSignaling 请传入 SDKAppID !!!"),null;D.default(e.offlineSupport)||typeof e.offlineSupport!="boolean"?this.offlineSupport=!0:this.offlineSupport=e.offlineSupport,this._outerEmitter=new s.default,this._outerEmitter._emit=this._outerEmitter.emit,this._outerEmitter.emit=(function(){for(var t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];var n=t[0],d=[n,{name:t[0],data:t[1]}];this._outerEmitter._emit.apply(this._outerEmitter,a(d))}).bind(this),this._safetyCallbackFactory=new L.default,e.tim?this._tim=e.tim:this._tim=S.create({SDKAppID:e.SDKAppID,scene:"TSignaling"}),e.isRejectNotifyAll&&(this._isRejectNotifyAll=!0),this.messageClient=new N.default({tim:this._tim}),this._imSDKAppID=e.SDKAppID,this._tim.on(S.EVENT.SDK_READY,this._onIMReady.bind(this)),this._tim.on(S.EVENT.SDK_NOT_READY,this._onIMNotReady.bind(this)),this._tim.on(S.EVENT.KICKED_OUT,this._onKickedOut.bind(this)),this._tim.on(S.EVENT.NET_STATE_CHANGE,this._onNetStateChange.bind(this)),this._tim.on(S.EVENT.MESSAGE_RECEIVED,this._onMessageReceived.bind(this))}return c.prototype.setLogLevel=function(e){l.default.setLevel(e),this._tim.setLogLevel(e)},c.prototype.login=function(e){return m(this,void 0,void 0,function(){return _(this,function(t){return l.default.log("TSignaling.login",e),this._userID=e.userID,[2,this._tim.login(e)]})})},c.prototype.logout=function(){return m(this,void 0,void 0,function(){return _(this,function(e){return l.default.log("TSignaling.logout"),this._userID="",this._inviteInfoMap.clear(),[2,this._tim.logout()]})})},c.prototype.on=function(e,t,i){l.default.log("TSignaling.on eventName:"+e),this._outerEmitter.on(e,this._safetyCallbackFactory.defense(e,t,i),i)},c.prototype.off=function(e,t){l.default.log("TSignaling.off eventName:"+e);var i=this._safetyCallbackFactory.find(e,t);i!==null&&(this._outerEmitter.off(e,i),this._safetyCallbackFactory.delete(e,t))},c.prototype.joinGroup=function(e){return m(this,void 0,void 0,function(){return _(this,function(t){return l.default.log("TSignaling.joinGroup groupID:"+e),this._groupID=e,[2,this._tim.joinGroup({groupID:e})]})})},c.prototype.quitGroup=function(e){return m(this,void 0,void 0,function(){return _(this,function(t){return l.default.log("TSignaling.quitGroup groupID:"+e),[2,this._tim.quitGroup(e)]})})},c.prototype.sendTextMessage=function(e){return m(this,void 0,void 0,function(){var t;return _(this,function(i){return t=this._tim.createTextMessage({to:e.to,conversationType:e.groupFlag===!0?S.TYPES.CONV_GROUP:S.TYPES.CONV_C2C,priority:e.priority||S.TYPES.MSG_PRIORITY_NORMAL,payload:{text:e.text}}),[2,this._tim.sendMessage(t)]})})},c.prototype.sendCustomMessage=function(e){return m(this,void 0,void 0,function(){var t;return _(this,function(i){return t=this._tim.createCustomMessage({to:e.to,conversationType:e.groupFlag===!0?S.TYPES.CONV_GROUP:S.TYPES.CONV_C2C,priority:e.priority||S.TYPES.MSG_PRIORITY_NORMAL,payload:{data:e.data||"",description:e.description||"",extension:e.extension||""}}),[2,this._tim.sendMessage(t)]})})},c.prototype.invite=function(e){return m(this,void 0,void 0,function(){var t,i,n,d,r,h,y,v,p,w;return _(this,function(M){switch(M.label){case 0:if(t=x.generate(),l.default.log("TSignaling.invite",e,"inviteID="+t),D.default(e)||D.default(e.userID))return[2,Promise.reject(new A.default({code:o.ErrorCode.ERR_INVALID_PARAMETERS,message:"userID is invalid"}))];i=e.userID,n=e.data,d=e.timeout,r=e.offlinePushInfo,h=e.onlineUserOnly,y=h!==void 0&&h,v={businessID:o.BusinessID.SIGNAL,inviteID:t,inviter:this._userID,actionType:o.ActionType.INVITE,inviteeList:[i],data:n,timeout:D.default(d)?0:d,groupID:"",onlineUserOnly:y},M.label=1;case 1:return M.trys.push([1,3,,4]),[4,this._sendCustomMessage(i,v,r)];case 2:return(p=M.sent()).code===0?(l.default.log("TSignaling.invite ok"),this._inviteInfoMap.set(t,I(I({},v),{message:p.data.message})),this._startTimer(v,!0),[2,{inviteID:t,code:p.code,data:p.data}]):[2,p];case 3:return w=M.sent(),[2,Promise.reject(new A.default(w))];case 4:return[2]}})})},c.prototype.inviteSync=function(e,t,i){var n=x.generate();l.default.log("TSignaling.inviteSync",e,"inviteID="+n),(D.default(e)||D.default(e.userID))&&i&&i(o.ErrorCode.ERR_INVALID_PARAMETERS,"userID is missing");var d=e.userID,r=e.data,h=e.timeout,y=e.offlinePushInfo,v=e.onlineUserOnly,p=v!==void 0&&v,w={businessID:o.BusinessID.SIGNAL,inviteID:n,inviter:this._userID,actionType:o.ActionType.INVITE,inviteeList:[d],data:r,timeout:D.default(h)?0:h,groupID:"",onlineUserOnly:p};return this._sendCustomMessageSync(d,w,function(){l.default.log("TSignaling.inviteSync ok"),t&&t()},function(M,O){i&&i(M,O)},y),n},c.prototype.inviteInGroup=function(e){return m(this,void 0,void 0,function(){var t,i,n,d,r,h,y,v,p,w,M;return _(this,function(O){switch(O.label){case 0:if(t=x.generate(),l.default.log("TSignaling.inviteInGroup",e,"inviteID="+t),D.default(e)||D.default(e.groupID))return[2,Promise.reject(new A.default({code:o.ErrorCode.ERR_INVALID_PARAMETERS,message:"groupID is invalid"}))];i=e.groupID,n=e.inviteeList,d=e.data,r=e.timeout,h=e.offlinePushInfo,y=e.onlineUserOnly,v=y!==void 0&&y,p={businessID:o.BusinessID.SIGNAL,inviteID:t,inviter:this._userID,actionType:o.ActionType.INVITE,inviteeList:n,data:d,timeout:D.default(r)?0:r,groupID:i,onlineUserOnly:v},O.label=1;case 1:return O.trys.push([1,3,,4]),[4,this._sendCustomMessage(i,p,h)];case 2:return(w=O.sent()).code===0?(l.default.log("TSignaling.inviteInGroup ok"),this._inviteInfoMap.set(t,I(I({},p),{message:w.data.message})),this._startTimer(p,!0),[2,{inviteID:t,code:w.code,data:w.data}]):[2,w];case 3:return M=O.sent(),[2,Promise.reject(new A.default(M))];case 4:return[2]}})})},c.prototype.inviteInGroupSync=function(e,t,i){var n=x.generate();l.default.log("TSignaling.inviteInGroupSync",e,"inviteID="+n),(D.default(e)||D.default(e.groupID))&&i&&i(o.ErrorCode.ERR_INVALID_PARAMETERS,"groupID is missing");var d=e.groupID,r=e.inviteeList,h=e.data,y=e.timeout,v=e.offlinePushInfo,p=e.onlineUserOnly,w=p!==void 0&&p,M={businessID:o.BusinessID.SIGNAL,inviteID:n,inviter:this._userID,actionType:o.ActionType.INVITE,inviteeList:r,data:h,timeout:D.default(y)?0:y,groupID:d,onlineUserOnly:w};return this._sendCustomMessageSync(d,M,function(){l.default.log("TSignaling.inviteInGroupSync ok"),t&&t()},function(O,R){i&&i(O,R)},v),n},c.prototype.cancel=function(e){return m(this,void 0,void 0,function(){var t,i,n,d,r,h,y,v,p,w;return _(this,function(M){switch(M.label){case 0:if(l.default.log("TSignaling.cancel",e),D.default(e)||D.default(e.inviteID)||!this._inviteInfoMap.has(e.inviteID)||this._isHandling)return[2,Promise.reject(new A.default({code:o.ErrorCode.ERR_SDK_SIGNALING_INVALID_INVITE_ID,message:"inviteID is invalid or invitation has been processed"}))];if(this._isHandling=!0,t=e.inviteID,i=e.data,n=this._inviteInfoMap.get(t),d=n.inviter,r=n.groupID,h=n.inviteeList,d!==this._userID)return[3,4];y={businessID:o.BusinessID.SIGNAL,inviteID:t,inviter:d,actionType:o.ActionType.CANCEL_INVITE,inviteeList:h,data:i,timeout:0,groupID:r},v=r||h[0],M.label=1;case 1:return M.trys.push([1,3,,4]),[4,this._sendCustomMessage(v,y)];case 2:return p=M.sent(),this._isHandling=!1,p&&p.code===0?(l.default.log("TSignaling.cancel ok"),this._deleteInviteInfoByID(t),[2,{inviteID:t,code:p.code,data:p.data}]):[2,p];case 3:return w=M.sent(),[2,Promise.reject(new A.default(w))];case 4:return l.default.error("TSignaling.cancel unmatched inviter="+d+" and userID="+this._userID),this._isHandling=!1,[2,Promise.reject(new A.default({code:o.ErrorCode.ERR_SDK_SIGNALING_NO_PERMISSION,message:"信令请求无权限,比如取消非自己发起的邀请,接受或则拒绝非发给自己的邀请"}))]}})})},c.prototype.accept=function(e){return m(this,void 0,void 0,function(){var t,i,n,d,r,h,y,v,p;return _(this,function(w){switch(w.label){case 0:if(l.default.log("TSignaling.accept",e),D.default(e)||D.default(e.inviteID)||!this._inviteInfoMap.has(e.inviteID)||this._isHandling)return[2,Promise.reject(new A.default({code:o.ErrorCode.ERR_SDK_SIGNALING_INVALID_INVITE_ID,message:"inviteID is invalid or invitation has been processed"}))];if(this._isHandling=!0,t=e.inviteID,i=e.data,n=this._inviteInfoMap.get(t),d=n.inviter,r=n.groupID,!n.inviteeList.includes(this._userID))return[3,4];h={businessID:o.BusinessID.SIGNAL,inviteID:t,inviter:d,actionType:o.ActionType.ACCEPT_INVITE,inviteeList:[this._userID],data:i,timeout:0,groupID:r},y=r||d,w.label=1;case 1:return w.trys.push([1,3,,4]),[4,this._sendCustomMessage(y,h)];case 2:return v=w.sent(),this._isHandling=!1,v&&v.code===0?(l.default.log("TSignaling.accept ok"),this._updateLocalInviteInfo(h),[2,{inviteID:t,code:v.code,data:v.data}]):[2,v];case 3:return p=w.sent(),[2,Promise.reject(new A.default(p))];case 4:return l.default.error("TSignaling.accept inviteeList do not include userID="+this._userID+". inviteID="+t+" groupID="+r),this._isHandling=!1,[2,Promise.reject(new A.default({code:o.ErrorCode.ERR_SDK_SIGNALING_INVALID_INVITE_ID,message:"inviteID is invalid or invitation has been processed"}))]}})})},c.prototype.reject=function(e){return m(this,void 0,void 0,function(){var t,i,n,d,r,h,y,v,p;return _(this,function(w){switch(w.label){case 0:if(l.default.log("TSignaling.reject",e),D.default(e)||D.default(e.inviteID)||!this._inviteInfoMap.has(e.inviteID)||this._isHandling)return[2,Promise.reject(new A.default({code:o.ErrorCode.ERR_SDK_SIGNALING_INVALID_INVITE_ID,message:"inviteID is invalid or invitation has been processed"}))];if(this._isHandling=!0,t=e.inviteID,i=e.data,n=this._inviteInfoMap.get(t),d=n.inviter,r=n.groupID,!n.inviteeList.includes(this._userID))return[3,4];h={businessID:o.BusinessID.SIGNAL,inviteID:t,inviter:d,actionType:o.ActionType.REJECT_INVITE,inviteeList:[this._userID],data:i,timeout:0,groupID:r},y=r||d,w.label=1;case 1:return w.trys.push([1,3,,4]),[4,this._sendCustomMessage(y,h)];case 2:return v=w.sent(),this._isHandling=!1,v&&v.code===0?(l.default.log("TSignaling.reject ok"),this._updateLocalInviteInfo(h),[2,{inviteID:t,code:v.code,data:v.data}]):[2,v];case 3:return p=w.sent(),[2,Promise.reject(new A.default(p))];case 4:return l.default.error("TSignaling.reject inviteeList do not include userID="+this._userID+". inviteID="+t+" groupID="+r),this._isHandling=!1,[2,Promise.reject(new A.default({code:o.ErrorCode.ERR_SDK_SIGNALING_INVALID_INVITE_ID,message:"inviteID is invalid or invitation has been processed"}))]}})})},c.prototype._onIMReady=function(e){return m(this,void 0,void 0,function(){var t;return _(this,function(i){switch(i.label){case 0:return l.default.log("TSignaling._onIMReady"),this._outerEmitter.emit(u.default.SDK_READY),this.offlineSupport!==!0?[3,2]:[4,this.messageClient.getHistoricalSignaling()];case 1:t=i.sent(),!D.default(t)&&this._onMessageReceived({data:t}),i.label=2;case 2:return[2]}})})},c.prototype._onIMNotReady=function(e){l.default.log("TSignaling.onSdkNotReady"),this._outerEmitter.emit(u.default.SDK_NOT_READY)},c.prototype._onKickedOut=function(e){l.default.log("TSignaling._onKickedOut"),this._outerEmitter.emit(u.default.KICKED_OUT,e.data)},c.prototype._onNetStateChange=function(e){l.default.log("TSignaling._onNetStateChange"),this._outerEmitter.emit(u.default.NET_STATE_CHANGE,e.data)},c.prototype._onMessageReceived=function(e){var t=this;l.default.log("TSignaling._onMessageReceived inviteID="+JSON.stringify(e));var i=e.data,n=i.filter(function(v){return v.type===S.TYPES.MSG_TEXT});l.default.log("TSignaling._onMessageReceived textMessages"+JSON.stringify(n)),D.default(n)||this._outerEmitter.emit(u.default.TEXT_MESSAGE_RECEIVED,n);var d=i.filter(function(v){return v.type===S.TYPES.MSG_GRP_TIP&&v.payload.operationType===S.TYPES.GRP_TIP_MBR_JOIN});D.default(d)||this._outerEmitter.emit(u.default.REMOTE_USER_JOIN,d);var r=i.filter(function(v){return v.type===S.TYPES.MSG_GRP_TIP&&v.payload.operationType===S.TYPES.GRP_TIP_MBR_QUIT});D.default(r)||this._outerEmitter.emit(u.default.REMOTE_USER_LEAVE,r);var h=i.filter(function(v){return v.type===S.TYPES.MSG_CUSTOM}),y=[];h.forEach(function(v){var p,w=v.payload.data,M=!0;try{p=JSON.parse(w)}catch{M=!1}if(M){var O=p.businessID,R=p.actionType;if(O===1)switch(R){case o.ActionType.INVITE:t._onNewInvitationReceived(p,v);break;case o.ActionType.REJECT_INVITE:t._onInviteeRejected(p);break;case o.ActionType.ACCEPT_INVITE:t._onInviteeAccepted(p);break;case o.ActionType.CANCEL_INVITE:t._onInvitationCancelled(p);break;case o.ActionType.INVITE_TIMEOUT:t._onInvitationTimeout(p)}else{if(O==="av_call")return!0;l.default.warn("TSignaling._onMessageReceived unknown businessID="+O),y.push(v)}}else y.push(v)}),D.default(y)||this._outerEmitter.emit(u.default.CUSTOM_MESSAGE_RECEIVED,y)},c.prototype._hasLocalInviteInfo=function(e,t){var i=e.inviteID,n=e.groupID;if(l.default.log("TSignaling._hasLocalInviteInfo inviteID="+i+" groupID="+n),!this._inviteInfoMap.has(i))return!1;var d=this._inviteInfoMap.get(i).inviteeList;return!n||(t?d.length>0:d.length>0&&d.includes(this._userID))},c.prototype._startTimer=function(e,t){var i=this;t===void 0&&(t=!0);var n=e.timeout;if(l.default.log("TSignaling._startTimer timeout="+n+" isInvitator="+t+" timeoutStatus="+(n===0)),n!==0)var d=t?n+5:n,r=1,h=setInterval(function(){var y=i._hasLocalInviteInfo(e,t);l.default.log("TSignaling.setInterval hasInviteInfo="+y),r<d&&y?++r:(y&&i._sendTimeoutNotice(e,t),clearInterval(h))},1e3)},c.prototype._sendTimeoutNotice=function(e,t){return m(this,void 0,void 0,function(){var i,n,d,r,h,y,v,p;return _(this,function(w){switch(w.label){case 0:return i=e.inviteID,n=e.groupID,d=e.inviteeList,r=e.inviter,h=e.data,y=t?n||d[0]:n||r,l.default.log("TSignaling._sendTimeoutNotice inviteID="+i+" to="+y+" isInvitator="+t),v={businessID:o.BusinessID.SIGNAL,inviteID:i,inviter:r,actionType:o.ActionType.INVITE_TIMEOUT,inviteeList:t?d:[this._userID],data:h,timeout:0,groupID:n},[4,this._sendCustomMessage(y,v)];case 1:return(p=w.sent())&&p.code===0&&(this._outerEmitter.emit(u.default.INVITATION_TIMEOUT,{inviter:r,inviteID:i,groupID:n,inviteeList:v.inviteeList,isSelfTimeout:!0}),t?this._deleteInviteInfoByID(i):this._updateLocalInviteInfo(v)),[2,p]}})})},c.prototype._onNewInvitationReceived=function(e,t){var i=e.inviteID,n=e.inviter,d=e.inviteeList,r=e.groupID,h=d.includes(this._userID);l.default.log("TSignaling._onNewInvitationReceived",e,"myselfIncluded="+h),(r&&h||!r)&&(this._inviteInfoMap.has(i)||this._inviteInfoMap.set(i,I(I({},e),{message:t})),this._outerEmitter.emit(c.EVENT.NEW_INVITATION_RECEIVED,{inviteID:i,inviter:n,groupID:r,inviteeList:d,data:e.data||""}),this._startTimer(e,!1))},c.prototype._onInviteeRejected=function(e){var t=e.inviteID,i=e.inviter,n=e.groupID,d=this._inviteInfoMap.has(t);l.default.log("TSignaling._onInviteeRejected inviteID="+t+" hasInviteID="+d+" inviter="+i+" groupID="+n+" _isRejectNotifyAll="+this._isRejectNotifyAll),(n&&d||!n||this._isRejectNotifyAll)&&(this._updateLocalInviteInfo(e),this._outerEmitter.emit(u.default.INVITEE_REJECTED,{inviteID:t,inviter:i,groupID:n,invitee:e.inviteeList[0],data:e.data||""}))},c.prototype._onInviteeAccepted=function(e){var t=e.inviteID,i=e.inviter,n=e.groupID,d=this._inviteInfoMap.has(t);l.default.log("TSignaling._onInviteeAccepted inviteID="+t+" hasInviteID="+d+" inviter="+i+" groupID="+n),(n&&d||!n)&&(this._updateLocalInviteInfo(e),this._outerEmitter.emit(u.default.INVITEE_ACCEPTED,{inviteID:t,inviter:i,groupID:n,invitee:e.inviteeList[0],data:e.data||""}))},c.prototype._onInvitationCancelled=function(e){var t=e.inviteID,i=e.inviter,n=e.groupID,d=this._inviteInfoMap.has(t);l.default.log("TSignaling._onInvitationCancelled inviteID="+t+" hasInviteID="+d+" inviter="+i+" groupID="+n),(n&&d||!n)&&(this._deleteInviteInfoByID(t),this._outerEmitter.emit(u.default.INVITATION_CANCELLED,{inviteID:t,inviter:i,groupID:n,data:e.data||""}))},c.prototype._onInvitationTimeout=function(e){var t=e.inviteID,i=e.inviter,n=e.groupID,d=e.data,r=this._inviteInfoMap.has(t);l.default.log("TSignaling._onInvitationTimeout inviteID="+t+" hasInviteID="+r+" inviter="+i+" groupID="+n),l.default.log("TSignaling._onInvitationTimeout data="+e.data);var h=JSON.parse(d),y=n&&(h.call_end===0||D.default(h.room_id));D.default(h.room_id)&&h.call_end>0||y||(n&&r||!n)&&(this._updateLocalInviteInfo(e),this._outerEmitter.emit(u.default.INVITATION_TIMEOUT,{inviteID:t,inviter:i,groupID:n,inviteeList:e.inviteeList,isSelfTimeout:!1}))},c.prototype._updateLocalInviteInfo=function(e){var t=e.inviteID,i=e.inviter,n=e.inviteeList,d=e.groupID;if(l.default.log("TSignaling._updateLocalInviteInfo inviteID="+t+" inviter="+i+" groupID="+d),d){if(this._inviteInfoMap.has(t)){var r=n[0],h=this._inviteInfoMap.get(t).inviteeList;h.includes(r)&&(h.splice(h.indexOf(r),1),l.default.log("TSignaling._updateLocalInviteInfo remove "+r+" from localInviteeList. "+h.length+" invitees left")),h.length===0&&this._deleteInviteInfoByID(t)}}else this._deleteInviteInfoByID(t)},c.prototype._deleteInviteInfoByID=function(e){this._inviteInfoMap.has(e)&&(l.default.log("TSignaling._deleteInviteInfoByID remove "+e+" from inviteInfoMap."),this._inviteInfoMap.delete(e))},c.prototype._genMessageControlInfo=function(e){e===void 0&&(e={});var t=e.data,i=t===void 0?"":t,n=e.onlineUserOnly,d=e.inviteID,r=d===void 0?"":d,h=e.actionType,y={_onlineOnlyFlag:!1};r&&this._inviteInfoMap.get(r)&&(y=this._inviteInfoMap.get(r).message);var v={onlineUserOnly:y._onlineOnlyFlag||n||!1,messageControlInfo:{excludedFromContentModeration:!0,excludedFromUnreadCount:!1,excludedFromLastMessage:!1}};if(h===o.ActionType.INVITE_TIMEOUT){var p=!!i.match(/excludeTimeoutSignalingFromHistoryMessage/);return v.messageControlInfo.excludedFromUnreadCount=p,v.messageControlInfo.excludedFromLastMessage=p,v}var w=!!i.match(/excludeFromHistoryMessage/),M=!!i.match(/excludeOriginalSignalingFromHistoryMessage/);return v.messageControlInfo.excludedFromUnreadCount=w||M,v.messageControlInfo.excludedFromLastMessage=w||M,v},c.prototype._sendCustomMessage=function(e,t,i){var n,d,r,h;return m(this,void 0,void 0,function(){var y,v,p,w,M,O,R,P;return _(this,function(j){switch(j.label){case 0:y=t.groupID,v=this._tim.createCustomMessage({to:e,conversationType:y?S.TYPES.CONV_GROUP:S.TYPES.CONV_C2C,priority:S.TYPES.MSG_PRIORITY_HIGH,payload:{data:JSON.stringify(t)}}),p=this._genMessageControlInfo(t),j.label=1;case 1:return j.trys.push([1,5,,6]),t.actionType!==o.ActionType.INVITE?[3,3]:(M={title:(w=i||{}).title||"",description:w.description||"您有一个通话请求",androidOPPOChannelID:w.androidOPPOChannelID||"",extension:this._handleOfflineInfo(t,w.extension||"")},l.default.log("TSignaling.offlinePushInfo "+JSON.stringify(M)),[4,this._tim.sendMessage(v,I({offlinePushInfo:{title:M.title,description:M.description,androidOPPOChannelID:M.androidOPPOChannelID,extension:M.extension}},p))]);case 2:return O=j.sent(),!((n=O==null?void 0:O.data)===null||n===void 0)&&n.message&&this._outerEmitter.emit(u.default.MESSAGE_SENT_BY_ME,(d=O==null?void 0:O.data)===null||d===void 0?void 0:d.message),[2,O];case 3:return[4,this._tim.sendMessage(v,p)];case 4:return R=j.sent(),!((r=R==null?void 0:R.data)===null||r===void 0)&&r.message&&this._outerEmitter.emit(u.default.MESSAGE_SENT_BY_ME,(h=R==null?void 0:R.data)===null||h===void 0?void 0:h.message),[2,R];case 5:return P=j.sent(),[2,Promise.reject(new A.default(P))];case 6:return[2]}})})},c.prototype._sendCustomMessageSync=function(e,t,i,n,d){return m(this,void 0,void 0,function(){var r,h;return _(this,function(y){switch(y.label){case 0:return y.trys.push([0,2,,3]),[4,this._sendCustomMessage(e,t,d)];case 1:return(r=y.sent()).code===0?(this._inviteInfoMap.set(t.inviteID,I(I({},t),{message:r.data.message})),this._startTimer(t,!0),i()):n(r.code,r.message||""),[3,3];case 2:return h=y.sent(),n(h.code,h.message||""),[3,3];case 3:return[2]}})})},c.prototype._handleOfflineInfo=function(e,t){var i=JSON.parse(e.data),n={action:e.actionType,call_type:i.call_type,room_id:i.room_id,call_id:e.inviteID,timeout:i.timeout,version:4,invited_list:e.inviteeList};e.groupID&&(n.group_id=e.groupID);var d={entity:{action:2,chatType:e.groupID?2:1,content:JSON.stringify(n),sendTime:parseInt(Date.now()/1e3+""),sender:e.inviter,version:1},userData:t||""},r=JSON.stringify(d);return l.default.log("TSignaling._handleOfflineInfo "+r),r},c.EVENT=u.default,c.TYPES=g.default,c}();b.default=T},function(C,b,E){E.r(b),E.d(b,"default",function(){return a});const I=Function.prototype.apply,m=new WeakMap;function _(o){return m.has(o)||m.set(o,{}),m.get(o)}class a{constructor(s=null,u=console){const g=_(this);return g._events=new Set,g._callbacks={},g._console=u,g._maxListeners=s===null?null:parseInt(s,10),this}_addCallback(s,u,g,l){return this._getCallbacks(s).push({callback:u,context:g,weight:l}),this._getCallbacks(s).sort((D,A)=>D.weight>A.weight),this}_getCallbacks(s){return _(this)._callbacks[s]}_getCallbackIndex(s,u){return this._has(s)?this._getCallbacks(s).findIndex(g=>g.callback===u):null}_achieveMaxListener(s){return _(this)._maxListeners!==null&&_(this)._maxListeners<=this.listenersNumber(s)}_callbackIsExists(s,u,g){const l=this._getCallbackIndex(s,u),D=l!==-1?this._getCallbacks(s)[l]:void 0;return l!==-1&&D&&D.context===g}_has(s){return _(this)._events.has(s)}on(s,u,g=null,l=1){const D=_(this);if(typeof u!="function")throw new TypeError(u+" is not a function");return this._has(s)?(this._achieveMaxListener(s)&&D._console.warn(`Max listeners (${D._maxListeners}) for event "${s}" is reached!`),this._callbackIsExists(...arguments)&&D._console.warn(`Event "${s}" already has the callback ${u}.`)):(D._events.add(s),D._callbacks[s]=[]),this._addCallback(...arguments),this}once(s,u,g=null,l=1){const D=(...A)=>(this.off(s,D),I.call(u,g,A));return this.on(s,D,g,l)}off(s,u=null){const g=_(this);let l;return this._has(s)&&(u===null?(g._events.delete(s),g._callbacks[s]=null):(l=this._getCallbackIndex(s,u),l!==-1&&(g._callbacks[s].splice(l,1),this.off(...arguments)))),this}emit(s,...u){return this._has(s)&&this._getCallbacks(s).forEach(g=>I.call(g.callback,g.context,u)),this}clear(){const s=_(this);return s._events.clear(),s._callbacks={},this}listenersNumber(s){return this._has(s)?this._getCallbacks(s).length:null}}},function(C,b){var E;E=function(){return this}();try{E=E||new Function("return this")()}catch{typeof window=="object"&&(E=window)}C.exports=E},function(C,b,E){E.r(b);var I=E(0);const m=Object.prototype.hasOwnProperty;b.default=function(_){if(_==null)return!0;if(typeof _=="boolean")return!1;if(typeof _=="number")return _===0;if(typeof _=="string"||typeof _=="function"||Array.isArray(_))return _.length===0;if(_ instanceof Error)return _.message==="";if(Object(I.f)(_)){for(const a in _)if(m.call(_,a))return!1;return!0}return!!(Object(I.e)(_)||Object(I.g)(_)||Object(I.c)(_))&&_.size===0}},function(C,b,E){E.r(b);class I extends Error{constructor(_){super(),this.code=_.code,this.message=_.message,this.data=_.data||{}}}b.default=I},function(C,b,E){E.r(b);var I=E(1),m=E(4),_=E.n(m);b.default=class{constructor(){this._funcMap=new Map}defense(a,o,s){if(typeof a!="string"||a.length===0||typeof o!="function")return null;if(this._funcMap.has(a)&&this._funcMap.get(a).has(o))return this._funcMap.get(a).get(o);this._funcMap.has(a)||this._funcMap.set(a,new Map);let u=null;return this._funcMap.get(a).has(o)?u=this._funcMap.get(a).get(o):(u=this._pack(a,o,s),this._funcMap.get(a).set(o,u)),u}defenseOnce(a,o,s){return typeof o!="function"?null:this._pack(a,o,s)}find(a,o){return typeof a!="string"||a.length===0||typeof o!="function"?null:this._funcMap.has(a)?this._funcMap.get(a).has(o)?this._funcMap.get(a).get(o):(I.default.log(`SafetyCallback.find: 找不到 func —— ${a}/${o.name!==""?o.name:"[anonymous]"}`),null):(I.default.log(`SafetyCallback.find: 找不到 eventName-${a} 对应的 func`),null)}delete(a,o){return typeof o=="function"&&!!this._funcMap.has(a)&&!!this._funcMap.get(a).has(o)&&(this._funcMap.get(a).delete(o),this._funcMap.get(a).size===0&&this._funcMap.delete(a),!0)}_pack(a,o,s){return function(){try{o.apply(s,Array.from(arguments))}catch(u){const g=Object.values(_.a).indexOf(a),l=Object.keys(_.a)[g];I.default.error(`接入侧事件 EVENT.${l} 对应的回调函数逻辑存在问题,请检查!`,u)}}}}},function(C,b,E){/**
|
|
* UUID.js - RFC-compliant UUID Generator for JavaScript
|
|
*
|
|
* @file
|
|
* @author LiosK
|
|
* @version v4.2.12
|
|
* @license Apache License 2.0: Copyright (c) 2010-2022 LiosK
|
|
*/var I;I=function(m){function _(){var o=a._getRandomInt;this.timestamp=0,this.tick=0,this.sequence=o(14),this.node=1099511627776*(1|o(8))+o(40)}function a(){}return a.generate=function(){var o=a._getRandomInt,s=a._hexAligner;return s(o(32),8)+"-"+s(o(16),4)+"-"+s(16384|o(12),4)+"-"+s(32768|o(14),4)+"-"+s(o(48),12)},a._getRandomInt=function(o){if(o<0||o>53)return NaN;var s=0|1073741824*Math.random();return o>30?s+1073741824*(0|Math.random()*(1<<o-30)):s>>>30-o},a._hexAligner=function(o,s){for(var u=o.toString(16),g=s-u.length,l="0";g>0;g>>>=1,l+=l)1&g&&(u=l+u);return u},a.overwrittenUUID=m,function(){var o=a._getRandomInt;a.useMathRandom=function(){a._getRandomInt=o};var s=null,u=o;typeof window<"u"&&(s=window.crypto||window.msCrypto)?s.getRandomValues&&typeof Uint32Array<"u"&&(u=function(g){if(g<0||g>53)return NaN;var l=new Uint32Array(g>32?2:1);return l=s.getRandomValues(l)||l,g>32?l[0]+4294967296*(l[1]>>>64-g):l[0]>>>32-g}):(s=E(14))&&s.randomBytes&&(u=function(g){if(g<0||g>53)return NaN;var l=s.randomBytes(g>32?8:4),D=l.readUInt32BE(0);return g>32?D+4294967296*(l.readUInt32BE(4)>>>64-g):D>>>32-g}),a._getRandomInt=u}(),a.FIELD_NAMES=["timeLow","timeMid","timeHiAndVersion","clockSeqHiAndReserved","clockSeqLow","node"],a.FIELD_SIZES=[32,16,16,8,8,48],a.genV4=function(){var o=a._getRandomInt;return new a()._init(o(32),o(16),16384|o(12),128|o(6),o(8),o(48))},a.parse=function(o){var s;if(s=/^\s*(urn:uuid:|\{)?([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{2})([0-9a-f]{2})-([0-9a-f]{12})(\})?\s*$/i.exec(o)){var u=s[1]||"",g=s[8]||"";if(u+g===""||u==="{"&&g==="}"||u.toLowerCase()==="urn:uuid:"&&g==="")return new a()._init(parseInt(s[2],16),parseInt(s[3],16),parseInt(s[4],16),parseInt(s[5],16),parseInt(s[6],16),parseInt(s[7],16))}return null},a.prototype._init=function(){var o=a.FIELD_NAMES,s=a.FIELD_SIZES,u=a._binAligner,g=a._hexAligner;this.intFields=new Array(6),this.bitFields=new Array(6),this.hexFields=new Array(6);for(var l=0;l<6;l++){var D=parseInt(arguments[l]||0);this.intFields[l]=this.intFields[o[l]]=D,this.bitFields[l]=this.bitFields[o[l]]=u(D,s[l]),this.hexFields[l]=this.hexFields[o[l]]=g(D,s[l]>>>2)}return this.version=this.intFields.timeHiAndVersion>>>12&15,this.bitString=this.bitFields.join(""),this.hexNoDelim=this.hexFields.join(""),this.hexString=this.hexFields[0]+"-"+this.hexFields[1]+"-"+this.hexFields[2]+"-"+this.hexFields[3]+this.hexFields[4]+"-"+this.hexFields[5],this.urn="urn:uuid:"+this.hexString,this},a._binAligner=function(o,s){for(var u=o.toString(2),g=s-u.length,l="0";g>0;g>>>=1,l+=l)1&g&&(u=l+u);return u},a.prototype.toString=function(){return this.hexString},a.prototype.equals=function(o){if(!(o instanceof a))return!1;for(var s=0;s<6;s++)if(this.intFields[s]!==o.intFields[s])return!1;return!0},a.NIL=new a()._init(0,0,0,0,0,0),a.genV1=function(){a._state==null&&a.resetState();var o=new Date().getTime(),s=a._state;o!=s.timestamp?(o<s.timestamp&&s.sequence++,s.timestamp=o,s.tick=a._getRandomInt(12)):s.tick<9992?s.tick+=1+a._getRandomInt(3):s.sequence++;var u=a._getTimeFieldValues(s.timestamp),g=u.low+s.tick,l=4095&u.hi|4096;s.sequence&=16383;var D=s.sequence>>>8|128,A=255&s.sequence;return new a()._init(g,u.mid,l,D,A,s.node)},a.resetState=function(){a._state=new _},a._tsRatio=1/4,a._state=null,a._getTimeFieldValues=function(o){var s=o-Date.UTC(1582,9,15),u=s/4294967296*1e4&268435455;return{low:1e4*(268435455&s)%4294967296,mid:65535&u,hi:u>>>16,timestamp:s}},typeof C.exports=="object"&&(C.exports=a),a}(I)},function(C,b){},function(C){C.exports=JSON.parse('{"name":"tsignaling","version":"1.0.8","description":"腾讯云 Web 信令 SDK","main":"./src/index.ts","scripts":{"lint":"./node_modules/.bin/eslint ./src","fix":"./node_modules/.bin/eslint --fix ./src","ts2js":"tsc src/index.ts --outDir build/ts2js","doc":"npm run ts2js && npm run doc:clean && npm run doc:build","doc:build":"./node_modules/.bin/jsdoc -c build/jsdoc/jsdoc.json && node ./build/jsdoc/fix-doc.js","doc:clean":"node ./build/jsdoc/clean-doc.js","build:wx":"cross-env NODE_ENV=wx webpack --config webpack.prod.config.js","build:web":"node node_modules/cross-env/src/bin/cross-env.js NODE_ENV=web node_modules/webpack/bin/webpack.js --config webpack.prod.config.js","build:package":"node build/package-bundle.js","prerelease":"npm run changelog && npm run build:web && npm run build:wx && npm run build:package && node ./build/copy.js","start:wx":"cross-env NODE_ENV=wx webpack-dev-server --config webpack.config.js","start:web":"node node_modules/cross-env/src/bin/cross-env.js NODE_ENV=web node_modules/webpack-dev-server/bin/webpack-dev-server.js --config webpack.dev.config.js","build_withcopy":"npm run build:web && cp dist/npm/tsignaling-js.js ../TIM-demo-web/node_modules/tsignaling/tsignaling-js.js","build_withcopy:mp":"npm run build:wx && cp dist/npm/tsignaling-wx.js ../TIM-demo-mini/static/component/TRTCCalling/utils/tsignaling-wx.js","changelog":"cp CHANGELOG.md build/jsdoc/tutorials/CHANGELOG.md"},"husky":{"hooks":{"pre-commit":"npm run lint"}},"lint-staged":{"*.{.ts,.tsx}":["eslint","git add"]},"keywords":["腾讯云","即时通信","信令"],"author":"","license":"ISC","devDependencies":{"conventional-changelog-cli":"^2.1.1","cross-env":"^7.0.2","fs-extra":"^9.0.1","html-webpack-plugin":"^4.3.0","ts-loader":"^7.0.5","typescript":"^3.9.9","webpack":"^4.43.0","@types/node":"18.11.9","webpack-cli":"^3.3.11","webpack-dev-server":"^3.11.0"},"dependencies":{"@typescript-eslint/eslint-plugin":"^4.22.1","@typescript-eslint/parser":"^4.22.1","EventEmitter":"^1.0.0","docdash-blue":"1.1.9","eslint":"^5.16.0","eslint-config-google":"^0.13.0","eslint-plugin-classes":"^0.1.1","jsdoc":"^3.6.4","jsdoc-plugin-typescript":"^2.0.5","pretty":"^2.0.0","replace":"^1.2.0","uuidjs":"^4.2.5"}}')},function(C,b,E){var I,m=this&&this.__extends||(I=function(S,f){return(I=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(N,T){N.__proto__=T}||function(N,T){for(var c in T)T.hasOwnProperty(c)&&(N[c]=T[c])})(S,f)},function(S,f){function N(){this.constructor=S}I(S,f),S.prototype=f===null?Object.create(f):(N.prototype=f.prototype,new N)}),_=this&&this.__awaiter||function(S,f,N,T){return new(N||(N=Promise))(function(c,e){function t(d){try{n(T.next(d))}catch(r){e(r)}}function i(d){try{n(T.throw(d))}catch(r){e(r)}}function n(d){var r;d.done?c(d.value):(r=d.value,r instanceof N?r:new N(function(h){h(r)})).then(t,i)}n((T=T.apply(S,f||[])).next())})},a=this&&this.__generator||function(S,f){var N,T,c,e,t={label:0,sent:function(){if(1&c[0])throw c[1];return c[1]},trys:[],ops:[]};return e={next:i(0),throw:i(1),return:i(2)},typeof Symbol=="function"&&(e[Symbol.iterator]=function(){return this}),e;function i(n){return function(d){return function(r){if(N)throw new TypeError("Generator is already executing.");for(;t;)try{if(N=1,T&&(c=2&r[0]?T.return:r[0]?T.throw||((c=T.return)&&c.call(T),0):T.next)&&!(c=c.call(T,r[1])).done)return c;switch(T=0,c&&(r=[2&r[0],c.value]),r[0]){case 0:case 1:c=r;break;case 4:return t.label++,{value:r[1],done:!1};case 5:t.label++,T=r[1],r=[0];continue;case 7:r=t.ops.pop(),t.trys.pop();continue;default:if(c=t.trys,!((c=c.length>0&&c[c.length-1])||r[0]!==6&&r[0]!==2)){t=0;continue}if(r[0]===3&&(!c||r[1]>c[0]&&r[1]<c[3])){t.label=r[1];break}if(r[0]===6&&t.label<c[1]){t.label=c[1],c=r;break}if(c&&t.label<c[2]){t.label=c[2],t.ops.push(r);break}c[2]&&t.ops.pop(),t.trys.pop();continue}r=f.call(S,t)}catch(h){r=[6,h],T=0}finally{N=c=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([n,d])}}};Object.defineProperty(b,"__esModule",{value:!0});var o=E(5),s=E(6),u=function(){function S(){Object.defineProperty(this,"currentTime",{get:function(){return new Date().getTime()}})}return S.prototype.doFilter=function(f){return _(this,void 0,void 0,function(){return a(this,function(N){return[2]})})},S}(),g=function(){function S(){this.filterList=[],this.result=[]}return S.prototype.register=function(f){this.filterList.push(f)},S.prototype.run=function(f){return f===void 0&&(f=[]),_(this,void 0,void 0,function(){var N,T;return a(this,function(c){switch(c.label){case 0:this.result=f,N=0,c.label=1;case 1:return N<this.filterList.length?(T=this,[4,this.filterList[N].doFilter(this.result)]):[3,4];case 2:T.result=c.sent(),c.label=3;case 3:return N++,[3,1];case 4:return[2,this.result]}})})},S}(),l=function(S){function f(N){var T=S.call(this)||this;return T.tim=null,T.expiredTime=3e4,T.maxCircleLength=20,T.tim=N.tim,T}return m(f,S),f.prototype.doFilter=function(N){return _(this,void 0,void 0,function(){var T,c,e,t,i,n,d,r;return a(this,function(h){switch(h.label){case 0:return T=[],[4,this.tim.getConversationList()];case 1:if(c=h.sent(),e=c.code,t=c.data,i=t.conversationList.length,n=i<=20?i:this.maxCircleLength,e===0)for(d=0;d<n;d++)(r=t.conversationList[d]).unreadCount>0&&r.lastMessage.lastTime&&1e3*r.lastMessage.lastTime>this.currentTime-this.expiredTime&&T.push(r);return[2,T]}})})},f}(u),D=function(S){function f(N){var T=S.call(this)||this;return T.tim=null,T.expiredTime=3e4,T.tim=N.tim,T}return m(f,S),f.prototype.doFilter=function(N){return _(this,void 0,void 0,function(){var T,c,e,t,i,n,d,r,h=this;return a(this,function(y){switch(y.label){case 0:T=[],c=0,y.label=1;case 1:return c<N.length?(e=N[c],t=e.conversationID,i=e.unreadCount,[4,this.tim.getMessageList({conversationID:t,count:i<=15?i:15})]):[3,4];case 2:n=y.sent(),d=n.code,r=n.data,d===0&&T.push(r.messageList.filter(function(v){return v.type===s.TYPES.MSG_CUSTOM&&v.time&&1e3*v.time>h.currentTime-h.expiredTime})),y.label=3;case 3:return c++,[3,1];case 4:return[2,T.flat().sort(function(v,p){return v.time-p.time})]}})})},f}(u),A=function(S){function f(){return S.call(this)||this}return m(f,S),f.prototype.doFilter=function(N){return _(this,void 0,void 0,function(){return a(this,function(T){return[2,N.filter(function(c){var e=!1;try{e=JSON.parse(c.payload.data).businessID===o.BusinessID.SIGNAL}catch{}return e})]})})},f}(u),L=function(S){function f(){return S.call(this)||this}return m(f,S),f.prototype.doFilter=function(N){return _(this,void 0,void 0,function(){var T,c,e;return a(this,function(t){return Array.isArray(N)?N.length===0?[2,[]]:(T=new Map,N.forEach(function(i,n){var d=JSON.parse(i.payload.data),r=d.inviteID,h=d.actionType;!T.has(r)||T.get(r).actionType!==o.ActionType.INVITE||h!==o.ActionType.CANCEL_INVITE&&h!==o.ActionType.ACCEPT_INVITE&&h!==o.ActionType.REJECT_INVITE&&h!==o.ActionType.INVITE_TIMEOUT?T.set(r,{index:n,actionType:h}):T.delete(r)}),c=[],T.forEach(function(i){i.actionType===o.ActionType.INVITE&&c.push(i.index)}),c.length===0?[2,[]]:(e=[],c.sort(function(i,n){return i-n}).forEach(function(i){e.push(N[i])}),[2,e])):[2,[]]})})},f}(u),x=function(){function S(f){this.tim=null;var N=f.tim;this.tim=N}return S.prototype.getHistoricalSignaling=function(){return _(this,void 0,void 0,function(){var f;return a(this,function(N){return(f=new g).register(new l({tim:this.tim})),f.register(new D({tim:this.tim})),f.register(new A),f.register(new L),[2,f.run()]})})},S}();b.default=x}]).default})}(V)),V.exports}export{H as r};
|