Files
zyt/server/public/admin/assets/@tencentcloud/tui-core-8M7p1XHw.js
T
2026-07-02 14:47:53 +08:00

2 lines
11 KiB
JavaScript

import{T as h}from"./chat-AC2Y2r2A.js";import{t as p}from"../tim-upload-plugin-HO4N4AW9.js";import{s as _}from"../tim-profanity-filter-plugin-Dn_Cf-mP.js";class v{constructor(){this.serviceMap=new Map}registerService(e,t){this.serviceMap.has(e)||(console.log(`TUIServiceManager.registerService serviceName:${e}`),this.serviceMap.set(e,t))}unregisterService(e){this.serviceMap.has(e)&&(console.log(`TUIServiceManager.unregisterService serviceName:${e}`),this.serviceMap.delete(e))}getService(e){return this.serviceMap.get(e)}callService(e){const{serviceName:t,method:n,params:i,callback:o}=e,s=this.getService(t);if(console.log(`TUIServiceManager.callService serviceName:${t}, service:`,s),s)return s.onCall(n,i,o)}}class R{constructor(){this.extensionMap=new Map}registerExtension(e,t){if(console.log(`TUIExtensionManager.registerExtension extensionID:${e}`),!this.extensionMap.has(e)){const i=[];this.extensionMap.set(e,i)}const n=this.extensionMap.get(e);n.indexOf(t)===-1&&n.push(t)}unregisterExtension(e,t){if(console.log(`TUIExtensionManager.unregisterExtension extensionID:${e}`),this.extensionMap.has(e)){const n=this.extensionMap.get(e),i=n.indexOf(t);i>-1&&n.splice(i,1)}}getExtensionList(e,t){const n=t?`params:${JSON.stringify(t)}`:"";console.log(`TUIExtensionManager.getExtensionList extensionID:${e} ${n}`);let i=[],o=[];if(this.extensionMap.has(e)){i=this.extensionMap.get(e);for(let s=0;s<i.length;s++){const a=i[s].onGetExtension(e,t);o=o.concat(a)}}return o}}const A=["vue2","vue3","rn"],E={TUILogin:{EVENT:{LOGIN_STATE_CHANGED:"loginStateChanged"},EVENT_SUB_KEY:{USER_LOGIN_SUCCESS:"userLoginSuccess",USER_LOGOUT_SUCCESS:"userLogoutSuccess",USER_KICKED_OFFLINE:"userKickedOffline",USER_SIG_EXPIRED:"userSigExpired"}},TUIConversation:{SERVICE:{NAME:"TUIConversationService",METHOD:{CREATE_CONVERSATION:"createConversation",HIDE_CONVERSATION_HEADER:"hideConversationHeader"}},EXTENSION:{CONV_POP_MENU:{EXT_ID:"conversationPopMenu"},CONV_GROUP:{EXT_ID:"conversationGroup"}}},TUIChat:{SERVICE:{NAME:"TUIChatService",METHOD:{UPDATE_MESSAGE_LIST:"updateMessageList",CLOSE_MESSAGE_POP_MENU:"closeMessagePopMenu",SEND_CUSTOM_MESSAGE:"sendCustomMessage",SEND_TEXT_MESSAGE:"sendTextMessage",SET_CHAT_TYPE:"setChatType",UPDATE_MESSAGE_INFO:"updateMessageInfo"}},EXTENSION:{INPUT_MORE:{EXT_ID:"inputToolBarMore"},MSG_POP_MENU:{EXT_ID:"messagePopMenu"},CHAT_HEADER:{EXT_ID:"chatHeader"}},TYPE:{C2C:"C2C",GROUP:"GROUP",CUSTOMER_SERVICE:"customerService",ROOM:"room"},EVENT:{CHAT_STATE_CHANGED:"chatStateChanged",CHAT_TYPE_CHANGED:"chatTypeChanged"},EVENT_SUB_KEY:{CHAT_OPENED:"chatOpened",CHANGE_SUCCESS:"changeSuccess"},FEATURE:{DownloadFile:"DownloadFile",CopyMessage:"CopyMessage",DeleteMessage:"DeleteMessage",RevokeMessage:"RevokeMessage",QuoteMessage:"QuoteMessage",ForwardMessage:"ForwardMessage",TranslateMessage:"TranslateMessage",VoiceToText:"VoiceToText",MultiSelection:"MultiSelection",EmojiReaction:"EmojiReaction",InputEmoji:"InputEmoji",InputStickers:"InputStickers",InputImage:"InputImage",InputVoice:"InputVoice",InputVideo:"InputVideo",InputFile:"InputFile",InputEvaluation:"InputEvaluation",InputQuickReplies:"InputQuickReplies",InputMention:"InputMention",MessageSearch:"MessageSearch",ReadStatus:"ReadStatus"}},TUIGroup:{SERVICE:{NAME:"TUIGroupService",METHOD:{CREATE_GROUP:"createGroup",OPEN_GROUP_MANAGEMENT:"openGroupManagement",SELECT_GROUP_MEMBER:"selectGroupMember"}}},TUIContact:{SERVICE:{NAME:"TUIContactService",METHOD:{SELECT_FRIEND:"selectFriend"}},EXTENSION:{CONTACT_LIST:{EXT_ID:"contactList"}}},TUISearch:{SERVICE:{NAME:"TUISearchService",METHOD:{SEARCH_GROUP:"searchGroup",SEARCH_USER:"searchUser",SEARCH_FRIEND:"searchFriend",SEARCH_GROUP_MEMBER:"searchGroupMember"}},EXTENSION:{SEARCH_MORE:{EXT_ID:"searchMore"}}},TUICalling:{SERVICE:{NAME:"TUICallingService",METHOD:{START_CALL:"startCall"}}},TUIRoom:{SERVICE:{NAME:"TUIRoomService"}},TUIEmojiPlugin:{SERVICE:{NAME:"TUIEmojiPluginService",METHOD:{CLOSE_EMOJI_DETAIL:"closeEmojiDetail"}}},TUITranslate:{EVENT:{LANGUAGE_CHANGED:"languageChanged"},EVENT_SUB_KEY:{CHANGE_SUCCESS:"changeSuccess"}},TUITranslatePlugin:{SERVICE:{NAME:"TUITranslatePluginService"}},TUIVoiceToTextPlugin:{SERVICE:{NAME:"TUIVoiceToTextPluginService"}},TUICustomerServicePlugin:{SERVICE:{NAME:"TUICustomerServicePlugin",METHOD:{ACTIVE_CONVERSATION:"activeConversation",FILTER_MESSAGE:"filterMessage"}},EXTENSION:{}},TUIPushPlugin:{SERVICE:{NAME:"TUIPushPluginService"}},TUIChatbotPlugin:{SERVICE:{NAME:"TUIChatbotPluginService"}},TUITheme:{EVENT:{THEME_CHANGED:"themeChanged"},EVENT_SUB_KEY:{CHANGE_SUCCESS:"changeSuccess"}}},c=typeof wx<"u"&&typeof wx.getSystemInfoSync=="function"&&!!wx.getSystemInfoSync().fontSizeSetting,M=typeof uni<"u"&&typeof window>"u",f=c||M,U=typeof uni<"u",N=(typeof uni<"u"||typeof window<"u")&&!f;c?wx:U&&uni;const S=N&&window&&window.navigator&&window.navigator.userAgent||"",O=/Android/i.test(S),D=/(?:Windows Phone)/.test(S),P=/(?:SymbianOS)/.test(S),d=/iPad/i.test(S)||/iPhone/i.test(S)||/iPod/i.test(S),u=O||D||P||d,l=N&&!u,T=M&&!c,C={[E.TUITranslatePlugin.SERVICE.NAME]:Math.pow(2,38),[E.TUIVoiceToTextPlugin.SERVICE.NAME]:Math.pow(2,39),[E.TUICustomerServicePlugin.SERVICE.NAME]:Math.pow(2,40),[E.TUIPushPlugin.SERVICE.NAME]:Math.pow(2,41),[E.TUIChatbotPlugin.SERVICE.NAME]:Math.pow(2,42),[E.TUIEmojiPlugin.SERVICE.NAME]:Math.pow(2,48)};class r{constructor(e){this.loginStatusPromise=new Map,this.SDKAppID=0,this.userID="",this.userSig="",this.TUICore=e,this.isOnChatEvent=!1}static getInstance(e){return!r.instance&&e&&(r.instance=new r(e)),r.instance}login(e){const{SDKAppID:t,userID:n,userSig:i,framework:o,scene:s}=e,a=Object.assign(Object.assign({},e),{scene:s||this.getStatScene(o)});return this.chat=h.create(a),this.EVENT=h.EVENT,this.TYPES=h.TYPES,this.SDKAppID=t,this.userID=n,this.userSig=i,this.offChatEvent(),this.onChatEvent(),this.registerPlugin(e),this.loginChat(e)}logout(){return this.chat.logout().then(e=>(this.userID="",this.userSig="",this.TUICore.notifyEvent(E.TUILogin.EVENT.LOGIN_STATE_CHANGED,E.TUILogin.EVENT_SUB_KEY.USER_LOGOUT_SUCCESS),Promise.resolve(e)))}destroy(){return this.chat.destroy().then(e=>(this.userID="",this.userSig="",this.TUICore.notifyEvent(E.TUILogin.EVENT.LOGIN_STATE_CHANGED,E.TUILogin.EVENT_SUB_KEY.USER_LOGOUT_SUCCESS),Promise.resolve(e)))}setLogLevel(e){return this.chat.setLogLevel(e)}getContext(){return{chat:this.chat,SDKAppID:this.SDKAppID,userID:this.userID,userSig:this.userSig}}reportPlugin(){var e;for(const t in C)this.TUICore.getService(t)&&((e=this.chat.callExperimentalAPI("isFeatureEnabledForStat",C[t]))===null||e===void 0||e.catch(()=>{}))}loginChat(e){const{userID:t,userSig:n}=e;return new Promise((i,o)=>{this.chat.login({userID:t,userSig:n}).then(s=>{s.data.repeatLogin&&this.chat.isReady()&&i(s),this.reportPlugin(),this.loginStatusPromise.set("login",{resolve:i,reject:o,imResponse:s})}).catch(s=>{o(s)})})}onChatEvent(){this.chat.on(this.EVENT.SDK_READY,this.onSDKReady,this),this.chat.on(this.EVENT.SDK_NOT_READY,this.onSDKNotReady,this),this.chat.on(this.EVENT.KICKED_OUT,this.onUserKicked,this),this.isOnChatEvent=!0}offChatEvent(){this.isOnChatEvent&&(this.chat.off(this.EVENT.SDK_READY,this.onSDKReady,this),this.chat.off(this.EVENT.SDK_NOT_READY,this.onSDKNotReady,this),this.chat.off(this.EVENT.KICKED_OUT,this.onUserKicked,this),this.isOnChatEvent=!1)}onSDKReady(){if(this.loginStatusPromise.has("login")){this.TUICore.notifyEvent(E.TUILogin.EVENT.LOGIN_STATE_CHANGED,E.TUILogin.EVENT_SUB_KEY.USER_LOGIN_SUCCESS);const e=setTimeout(()=>{const t=this.loginStatusPromise.get("login");t.resolve(t.imResponse),clearTimeout(e),this.loginStatusPromise.delete("login")},500)}}onSDKNotReady(){this.loginStatusPromise.has("login")&&this.loginStatusPromise.get("login").reject(new Error("sdk not ready")),this.loginStatusPromise.delete("login")}onUserKicked(e){e.data.type!==this.TYPES.KICKED_OUT_USERSIG_EXPIRED?this.TUICore.notifyEvent(E.TUILogin.EVENT.LOGIN_STATE_CHANGED,E.TUILogin.EVENT_SUB_KEY.USER_KICKED_OFFLINE):this.TUICore.notifyEvent(E.TUILogin.EVENT.LOGIN_STATE_CHANGED,E.TUILogin.EVENT_SUB_KEY.USER_SIG_EXPIRED)}registerPlugin(e){const{useUploadPlugin:t=!1,useProfanityFilterPlugin:n=!1,TUIOfflinePush:i,offlinePushConfig:o,TIMPush:s,pushConfig:a}=e;t===!0&&this.chat.registerPlugin({"tim-upload-plugin":p}),n===!0&&this.chat.registerPlugin({"tim-profanity-filter-plugin":_}),T&&s&&a&&this.chat.registerPlugin({"tim-push":s,pushConfig:a}),T&&i&&o&&this.chat.registerPlugin({"tim-offline-push-plugin":i,offlinePushConfig:o})}getStatScene(e){let t;return e&&A.indexOf(e)>-1&&(t=this.genStatScene(e)),t}genStatScene(e){if(e==="rn")return"k-rn";let t="";return U?(l&&(t=`k-${e}-pc-uni`),u&&(t=`k-${e}-h5-uni`),T&&(t=`k-${e}-app-uni`),c&&(t=`k-${e}-mp-uni`),t):(l&&(t=`k-${e}-pc`),u&&(t=`k-${e}-h5`),t)}}class m{constructor(){this.eventMap=new Map}registerEvent(e,t,n){const i=this.getKey(e,t);if(console.log(`TUIEventManager.registerEvent eventName:${e} subKey:${t}`),!this.eventMap.has(i)){const s=[];this.eventMap.set(i,s)}const o=this.eventMap.get(i);o.indexOf(n)===-1&&(o.push(n),this.renotify(e,t,n))}unregisterEvent(e,t,n){console.log(`TUIEventManager.unregisterEvent eventName:${e} subKey:${t}`);const i=this.getKey(e,t);if(this.eventMap.has(i)){const o=this.eventMap.get(i),s=o.indexOf(n);s>-1&&o.splice(s,1)}}notifyEvent(e,t,n){const i=this.getKey(e,t),o=n?`params:${JSON.stringify(n)}`:"";console.log(`TUIEventManager.notifyEvent eventName:${e} subKey:${t} ${o}`),this.eventMap.has(i)&&this.eventMap.get(i).forEach(s=>{s.onNotifyEvent(e,t,n)})}getKey(e,t){let n=e;return t&&(n=`${e}-${n}`),n}renotify(e,t,n){if(e===E.TUILogin.EVENT.LOGIN_STATE_CHANGED&&t===E.TUILogin.EVENT_SUB_KEY.USER_LOGIN_SUCCESS){const{chat:i}=r.getInstance().getContext();i&&i.isReady()&&(n.onNotifyEvent(E.TUILogin.EVENT.LOGIN_STATE_CHANGED,E.TUILogin.EVENT_SUB_KEY.USER_LOGIN_SUCCESS),console.log("TUIEventManager.renotify success."))}}}class g{constructor(){this.serviceManager=new v,this.extensionManager=new R,this.eventManager=new m}static getInstance(){return g.instance||(console.log("TUICore.getInstance ok."),g.instance=new g),g.instance}registerService(e,t){return this.serviceManager.registerService(e,t)}unregisterService(e){return this.serviceManager.unregisterService(e)}getService(e){return this.serviceManager.getService(e)}callService(e){return this.serviceManager.callService(e)}registerExtension(e,t){return this.extensionManager.registerExtension(e,t)}unregisterExtension(e,t){return this.extensionManager.unregisterExtension(e,t)}getExtensionList(e,t){return this.extensionManager.getExtensionList(e,t)}registerEvent(e,t,n){return this.eventManager.registerEvent(e,t,n)}unregisterEvent(e,t,n){return this.eventManager.unregisterEvent(e,t,n)}notifyEvent(e,t,n){return this.eventManager.notifyEvent(e,t,n)}}console.log("TUICore.VERSION:2.5.1");const V=g.getInstance(),x=r.getInstance(V);export{x as A,E,V as R};