k2-im 0.1.37 → 0.1.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.js +1 -1
- package/dist/chat-kit-pinia.d.ts +94 -15
- package/dist/chat-kit-pinia.js +1 -1
- package/dist/chat-kit-vue.js +1 -1
- package/dist/chat-kit.d.ts +98 -12
- package/dist/chat-kit.js +1 -1
- package/dist/chunk-3ST5E6YS.js +1 -0
- package/dist/chunk-4I23ADH2.js +2 -0
- package/dist/{chunk-32UUIS7N.js → chunk-GHFHAGJ7.js} +1 -1
- package/dist/{chunk-NWBEXP2C.js → chunk-HWA7NOXG.js} +1 -1
- package/dist/chunk-ITOAFWZU.js +2 -0
- package/dist/chunk-LMP34HNC.js +2 -0
- package/dist/chunk-ZERTVCH2.js +7 -0
- package/dist/i18n.js +1 -1
- package/dist/index.d.ts +100 -13
- package/dist/index.js +1 -1
- package/dist/sdk.d.ts +49 -7
- package/dist/sdk.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-75GNCLQQ.js +0 -2
- package/dist/chunk-CLO7E7BU.js +0 -1
- package/dist/chunk-HUSCO5JM.js +0 -7
- package/dist/chunk-MSYNU72L.js +0 -2
- package/dist/chunk-QT3PJWLT.js +0 -2
package/dist/chat-kit-vue.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {h,C,p,i,q,m,z,B,o,j,g}from'./chunk-NWBEXP2C.js';import {f,h as h$2,i as i$1,g as g$1}from'./chunk-32UUIS7N.js';import'./chunk-QT3PJWLT.js';import'./chunk-HUSCO5JM.js';import'./chunk-75GNCLQQ.js';import'./chunk-WOT6VMZA.js';import {defineComponent,h as h$1,ref,provide,watch,nextTick,onMounted,onBeforeUnmount,computed,inject,isVNode,cloneVNode,Fragment,reactive}from'vue';function $t(t){let a=0,y=0;for(let c of t)c.kind==="video"?y+=1:a+=1;return {imageCount:a,videoCount:y}}function Xt(t){return {systemMessage:a=>a.body.system!==void 0?g$1(a.body.system,{locale:t.locale(),resolveName:t.resolveName,selfId:t.selfId()}):"",mediaPlaceholder:a=>i$1(a.contentType,{locale:t.locale(),durationMs:a.body.voice?.durationMs,stickerImageType:a.body.sticker?.imageType,gameType:a.body.game?.gameType,callKind:a.body.call?.callKind,...a.body.filesAlbum===void 0?{}:{filesAlbum:{count:a.body.filesAlbum.items.length,caption:a.body.filesAlbum.caption}},...a.body.mediaAlbum===void 0?{}:{mediaAlbum:$t(a.body.mediaAlbum.items)}}),lastMessage:a=>a.lastMessageSummary!==void 0?h$2(a.lastMessageSummary,{locale:t.locale(),resolveName:t.resolveName,selfId:t.selfId()}):a.lastMessagePreview,failureText:a=>a.failure?.displayCode!==void 0?f(a.failure.displayCode,{locale:t.locale(),mediaKind:a.failure.mediaKind,params:a.failure.params}):a.failure?.message??""}}var Ct=Symbol("ImThreadReadActions");function Nt(t){provide(Ct,t);}function Zt(){return inject(Ct,void 0)}var rt=defineComponent({name:"ImThreadBodySwitch",inheritAttrs:false,props:{message:{type:Object,required:true},rendererRegistry:{type:Object,required:true},presentation:{type:Object,default:void 0},readActions:{type:Object,default:void 0}},setup(t,{attrs:a,slots:y}){return Nt(t.readActions),()=>{let c=h(t.message),m=t.rendererRegistry.resolve(c);return m!==void 0?h$1(m,{...a,message:t.message,presentation:t.presentation}):y["unsupported-body"]!==void 0?y["unsupported-body"]({kind:c,message:t.message}):h$1("span",{"data-im-thread-unsupported-body":c,"aria-hidden":"true"})}}});var ot=Symbol("ImThreadViewportRegistration");function Ht(){return inject(ot,void 0)}var it=defineComponent({name:"ImThreadItems",props:{items:{type:Array,required:true},rendererRegistry:{type:Object,required:true},presentation:{type:Object,default:void 0},readActions:{type:Object,default:void 0}},setup(t,{slots:a}){let y=Ht();function c(o,h){let C=Array.isArray(h)?h:[h];return C.length===1&&isVNode(C[0])?cloneVNode(C[0],{key:o}):h$1(Fragment,{key:o},C)}function m(o){return h=>{y?.registerMessageNode(o,h instanceof HTMLElement?h:null);}}function N(o,h){return C=>{y?.registerDateNode(o,h,C instanceof HTMLElement?C:null);}}function U(o){return a.encryption?.({item:o})??h$1("div",{"data-im-thread-encryption":o.key})}function T(o){let h=N(o.key,o.label);return a["date-separator"]?.({item:o,setElement:h})??h$1("div",{ref:h,"data-im-thread-date-separator":o.key},o.label)}function V(o){y?.registerEntryUnreadNode(o instanceof HTMLElement?o:null);}function w(o){return a["entry-unread"]?.({item:o,setElement:V})??h$1("div",{ref:V,"data-im-thread-entry-unread":o.key,...o.count===void 0?{}:{"data-count":String(o.count)}})}function k(o){let h=m(o.message.id);return a.item!==void 0?a.item({item:o,setElement:h}):a.message!==void 0?a.message({item:o,setElement:h}):o.message.deletedForEveryone!==void 0?a["deleted-message"]?.({item:o,setElement:h})??h$1("article",{ref:h,"data-im-thread-message-id":o.message.id,"data-im-thread-message-terminal":"deleted-for-everyone"},[h$1("span",{"data-im-thread-anchor-point":""})]):o.message.recalled!==void 0?a["recalled-message"]?.({item:o,setElement:h})??h$1("article",{ref:h,"data-im-thread-message-id":o.message.id,"data-im-thread-message-terminal":"recalled"},[h$1("span",{"data-im-thread-anchor-point":""})]):o.kind==="system"&&a.system!==void 0?a.system({item:o,setElement:h}):h$1("article",{ref:h,"data-im-thread-message-id":o.message.id,"data-first-of-run":o.kind==="message"?String(o.firstOfRun):void 0},[h$1("span",{"data-im-thread-anchor-point":""}),h$1(rt,{message:o.message,rendererRegistry:t.rendererRegistry,presentation:t.presentation,readActions:t.readActions},{"unsupported-body":a["unsupported-body"]===void 0?void 0:C=>a["unsupported-body"]?.(C)})])}return ()=>h$1("div",{"data-im-thread-items":""},t.items.map(o=>{switch(o.kind){case "encryption":return a.item!==void 0?c(o.key,a.item({item:o})):c(o.key,U(o));case "date-separator":return a.item!==void 0?c(o.key,a.item({item:o,setElement:N(o.key,o.label)})):c(o.key,T(o));case "entry-unread":return a.item!==void 0?c(o.key,a.item({item:o,setElement:V})):c(o.key,w(o));case "system":case "message":return c(o.key,k(o))}return o}))}});var Ft=120,fn=500,Le=.5,mn=8;function at(t){let a=t.ownerDocument.defaultView?.devicePixelRatio;return 1+1/(a!==void 0&&Number.isFinite(a)&&a>0?a:1)}var st=defineComponent({name:"ImThreadViewport",props:{messageIds:{type:Array,required:true},contentKey:{type:String,default:""},loadingOlder:{type:Boolean,default:false},hasNewer:{type:Boolean,default:false},loadingNewer:{type:Boolean,default:false},followThreshold:{type:Number,default:120},olderPrefetchThreshold:{type:Number,default:120},followNewMessages:{type:Boolean,default:true},shouldFollowAppendedMessage:{type:Function,default:void 0},visibleMargin:{type:Number,default:8},resizeFollowEnabled:{type:Boolean,default:true},activeDateOffset:{type:Number,default:16},activeDateEnabled:{type:Boolean,default:false}},emits:{"reach-start":()=>true,"reach-end":()=>true,"visible-range":t=>true,settled:t=>true,"new-message-count":t=>true,"user-scroll":()=>true,"active-date-change":t=>true},setup(t,{emit:a,expose:y,slots:c}){let m$1=ref(null),N=ref(null),U=new Map,T,V=new Map,w=new Set,k=new Map,o$1=0,h=[],C$1,S,E,_,G=false,L,J=new Set,K=false,D,re="",Z=1,Y=false,H=false,ee=true,q$1=false,Q=false,oe=false,i=0,he=-1,ie=-1,A,z$1,te,M,ne,f=ref(true),P=ref(0),p$1=C(e=>{P.value=e,a("new-message-count",e);});function j$1(e){let r=Number.isFinite(t.followThreshold)?Math.max(0,t.followThreshold):0;return e.scrollHeight-e.clientHeight-e.scrollTop<=r}function v(e=t.messageIds){return e.flatMap(r=>{let s=U.get(r);if(s===void 0)return [];let g=s.getBoundingClientRect(),R=s.querySelector("[data-im-thread-anchor-point]");return [{id:r,top:g.top,bottom:g.bottom,anchorTop:R?.getBoundingClientRect().top??g.top}]})}function $(e="",r=1){let s=Math.min(1,Math.max(0,r));re!==""&&re!==e&&k.get(re)?.element.style.removeProperty("opacity"),re=e,Z=s,e!==""&&k.get(e)?.element.style.setProperty("opacity",String(s));}function x(){$();}function W(){let e=m$1.value;if(K||e===null||!t.activeDateEnabled)return;let r=[...k.entries()].filter(([,B])=>e.contains(B.element)).map(([B,O])=>{let de=O.element.getBoundingClientRect();return {key:B,label:O.label,top:de.top,height:de.height}}).sort((B,O)=>B.top-O.top),s=e.getBoundingClientRect(),g$1=r.find(B=>B.height>0)?.height??28,R=g({markers:r,viewportTop:s.top,overlayTop:Number.isFinite(t.activeDateOffset)?Math.max(0,t.activeDateOffset):0,overlayHeight:g$1});if(R===null){x(),a("active-date-change",null);return}$(R.inlineDateKey,R.inlineOpacity),a("active-date-change",R);}function De(e){S={scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,width:e.clientWidth,height:e.clientHeight};}function Fe(e){let r=S;if(r===void 0)return false;let s=Math.max(0,e.scrollHeight-e.clientHeight);return s<r.scrollHeight-r.height&&r.scrollTop>s&&Math.abs(e.scrollTop-s)<=at(e)}function Xe(e){return Fe(e)||D!==void 0&&(D.behavior==="smooth"||Math.abs(e.scrollTop-D.targetTop)<=at(e))?0:e.scrollTop-o$1}function Be(e,r){r!==0&&(o$1=e.scrollTop-r,D=void 0,_e());}function Je(e,r){let s=Xe(e);if(M!==void 0)return M.expectedOffset-=s,je(),Be(e,s),q$1||Ne(),false;let g=S;if(g===void 0)return false;let R=C$1,B=R===void 0?void 0:v([R.id])[0],O=e.scrollTop-g.scrollTop,de=Fe(e)?0:O,Ie=R===void 0||B===void 0?0:(B.anchorTop??B.top)-r.top-R.offset+O;return g.scrollHeight!==e.scrollHeight||g.width!==e.clientWidth||g.height!==e.clientHeight||Math.abs(Ie)>Le?(S=void 0,!Y&&!t.loadingNewer&&t.resizeFollowEnabled&&f.value&&Math.abs(de)<=Le?(Ge(),true):(R!==void 0&&ge({...R,offset:R.offset-de}),Be(e,s),false)):false}function pe(){let e=m$1.value;if(K||e===null)return;let r=e.getBoundingClientRect();if(Je(e,r))return;let s=_!==void 0&&G?t.messageIds.filter(O=>w.has(O)):t.messageIds,g=v(s);if(_!==void 0&&G&&g.length===0){f.value=j$1(e);return}let R=g.filter(O=>B({viewportTop:r.top,viewportBottom:r.bottom,messageTop:O.top,messageBottom:O.bottom,margin:t.visibleMargin})).map(O=>O.id),B$1=R.length!==h.length||R.some((O,de)=>h[de]!==O);h=Object.freeze(R),C$1=o(g,{top:r.top,bottom:r.bottom}),De(e),p$1.acknowledgeVisible(R),f.value=j$1(e),B$1&&a("visible-range",h),a("settled",{visibleMessageIds:h,...h.length===0?{}:{newestVisibleMessageId:h[h.length-1]},isAtBottom:f.value,newMessageCount:P.value});}function fe(e){if(J.add(e),L!==void 0)return;let r=()=>{L=void 0;let s=[...J];J.clear(),s.forEach(g=>g());};typeof globalThis.requestAnimationFrame=="function"?L=globalThis.requestAnimationFrame(r):L=globalThis.setTimeout(r,0);}function Qe(){L!==void 0&&(typeof L=="number"&&typeof globalThis.cancelAnimationFrame=="function"?globalThis.cancelAnimationFrame(L):globalThis.clearTimeout(L),L=void 0,J.clear());}function me(){fe(pe);}function Ze(){let e=m$1.value;if(e===null)return;let r=e.getBoundingClientRect(),s=o(v(),{top:r.top,bottom:r.bottom});s!==void 0&&(C$1=s,De(e));}function Ke(){return ee&&M===void 0&&!H&&!t.loadingOlder}function Ue(){Ze(),ee=false,he=i,H=true,a("reach-start"),fe(()=>{t.loadingOlder||(H=false);});}function X(e){return t.hasNewer&&!Y&&!t.loadingOlder&&!t.loadingNewer&&j$1(e)}function Ve(){Y=true,f.value=false,ie=i,a("reach-end"),fe(()=>{t.loadingNewer||(Y=false);});}function Ce(){let e=m$1.value;e===null||i===ie||!X(e)||Ve();}function _e(){let e=m$1.value;if(K||e===null)return;let r=e.scrollTop,s=Fe(e),g=D,R=false;if(g!==void 0){let O=Math.abs(r-g.targetTop)<=at(e);R=g.behavior==="smooth"||O,(g.behavior!=="smooth"||O)&&(D=void 0);}!R&&!s&&!q$1&&M===void 0&&r!==o$1&&(q$1=true,Q=true,i+=1);let B=q$1&&!R&&!s&&r!==o$1;if(B&&(a("user-scroll"),fe(W)),q$1&&!oe&&u(),!ee&&Q&&i!==he&&r<o$1&&r>qe()&&(ee=true),M!==void 0&&!R)if(q$1){let O=ae();O!==void 0&&(M.expectedOffset=O);}else je(),Ne();Ke()&&B&&r>=0&&m({previousScrollTop:o$1,currentScrollTop:r,topThreshold:t.olderPrefetchThreshold})&&Ue(),B&&X(e)&&z({previousScrollTop:o$1,currentScrollTop:r,isAtBottom:j$1(e),isHistoryWindow:t.hasNewer,isPageSettling:R})&&Ve(),o$1=r,me();}function Pe(e,r="auto"){D={targetTop:e,behavior:r};}function Se(e){let r=M,s=N.value;if(!(r===void 0||s===null)){if(r.visualOffset=Math.abs(e)<=Le?0:e,r.visualOffset===0){s.style.removeProperty("transform"),s.style.removeProperty("will-change");return}s.style.setProperty("transform",`translate3d(0, ${r.visualOffset}px, 0)`),s.style.setProperty("will-change","transform");}}function ye(){ne!==void 0&&(clearTimeout(ne),ne=void 0),M!==void 0&&M.visualOffset!==0&&(C$1=void 0,S=void 0);let e=N.value;e?.style.removeProperty("transform"),e?.style.removeProperty("will-change"),M=void 0,D=void 0;}function ae(){let e=m$1.value,r=M;if(e===null||r===void 0)return;let s=v().find(g=>g.id===r.anchor.id);if(s!==void 0)return (s.anchorTop??s.top)-e.getBoundingClientRect().top}function je(){let e=M,r=ae();if(e===void 0||r===void 0)return;let s=e.expectedOffset-r;Math.abs(s)<=Le||(Se(e.visualOffset+s),e.committed=false,e.attempts=0);}function Te(){ne!==void 0&&clearTimeout(ne),ne=setTimeout(()=>{ne=void 0,!(q$1||M?.committed!==true)&&ye();},fn);}function Ee(){let e=m$1.value,r=M;if(K||e===null||r===void 0||q$1)return;let s=r.visualOffset;if(Math.abs(s)<=Le){r.committed=true,Te();return}let g=Math.max(0,e.scrollHeight-e.clientHeight),R=Math.min(g,Math.max(0,e.scrollTop-s));if(Pe(R),e.scrollTop=R,Math.abs(e.scrollTop-R)>Le){D=void 0,r.committed=false,r.attempts+=1,r.attempts<mn?Ne():(ye(),D=void 0,o$1=e.scrollTop);return}Se(0),o$1=e.scrollTop,r.expectedOffset=ae()??r.expectedOffset,r.committed=true,r.attempts=0,Te();}function Ne(){ne!==void 0&&clearTimeout(ne),ne=setTimeout(()=>{ne=void 0,Ee();},Ft);}function ke(e){e!==void 0&&(M===void 0&&(M={anchor:e,expectedOffset:e.offset,visualOffset:0,committed:false,attempts:0}),je(),!q$1&&Ee());}function ge(e){let r=m$1.value;if(r===null||e===void 0)return;let s=r.getBoundingClientRect(),g=q(e,v(),{top:s.top,bottom:s.bottom});if(g!==void 0){let R=Math.max(0,r.scrollHeight-r.clientHeight),B=Math.min(R,Math.max(0,r.scrollTop+g));Pe(B),r.scrollTop=B,o$1=r.scrollTop,S=void 0;}}function qe(){return Number.isFinite(t.olderPrefetchThreshold)?Math.max(0,t.olderPrefetchThreshold):0}function Oe(){D?.behavior==="smooth"&&(D=void 0),Q=false,q$1||(q$1=true,i+=1),A!==void 0&&(clearTimeout(A),A=void 0);}function n(){let e=m$1.value;e===null||i===he||(M!==void 0&&ye(),ee=true,e.scrollTop<=qe()&&Ke()&&Ue());}function l(){C$1=void 0,S=void 0,A!==void 0&&(clearTimeout(A),A=void 0),ye(),q$1=false,Q=false,oe=false,z$1=void 0,te=void 0,i+=1,he=-1,ie=-1,ee=true,H=false,Y=false,D=void 0;}function d(){oe||(A!==void 0&&(clearTimeout(A),A=void 0),q$1=false,Q=false,M!==void 0&&(M.attempts=0),Ee());}function u(){oe||(A!==void 0&&clearTimeout(A),A=setTimeout(()=>{A=void 0,d();},Ft));}function b(){D=void 0,d();}function I(e){oe=true,Oe(),z$1=e.touches?.[0]?.clientY;}function F(e){let r=e.touches?.[0]?.clientY;r!==void 0&&(z$1!==void 0&&r>z$1?n():z$1!==void 0&&r<z$1&&Ce(),z$1=r);}function le(){oe=false,z$1=void 0,u();}function ve(e){Oe(),e.deltaY<0?n():e.deltaY>0&&Ce(),u();}function Ae(e){e.pointerType!=="touch"&&(Oe(),te=e.clientY,u());}function be(e){e.pointerType==="touch"||!q$1||te===void 0||(e.clientY<te?n():e.clientY>te&&Ce(),te=e.clientY,u());}function we(e){e.pointerType!=="touch"&&(te=void 0,u());}function We(e){["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "].includes(e.key)&&(Oe(),e.key==="ArrowUp"||e.key==="PageUp"||e.key==="Home"||e.key===" "&&e.shiftKey?n():Ce(),u());}function Ge(e="auto"){let r=m$1.value;if(r===null)return;S=void 0,ye();let s=Math.max(0,r.scrollHeight-r.clientHeight);Pe(s,e),r.scrollTo?.({top:s,behavior:e}),r.scrollTop!==s&&(r.scrollTop=s),o$1=r.scrollTop,p$1.clear(),pe();}function gt(){let e=m$1.value;return e!==null&&e.clientWidth>0&&e.clientHeight>0}function Ut(){let e=m$1.value;return gt()&&e!==null&&e.scrollHeight>e.clientHeight+1}function _t(e,r={}){return vt(U.get(e),r)}function vt(e,r){let s=m$1.value;if(s===null||e===void 0||!s.contains(e)||s.clientHeight<=0)return false;ye();let g=s.getBoundingClientRect(),R=e.getBoundingClientRect(),B=r.block??"center",O;B==="start"?O=s.scrollTop+R.top-g.top:B==="end"?O=s.scrollTop+R.bottom-g.bottom:B==="nearest"?R.top>=g.top&&R.bottom<=g.bottom?O=s.scrollTop:R.top<g.top?O=s.scrollTop+R.top-g.top:O=s.scrollTop+R.bottom-g.bottom:O=j({currentScrollTop:s.scrollTop,scrollHeight:s.scrollHeight,targetHeight:R.height,targetTop:R.top,viewportHeight:s.clientHeight,viewportTop:g.top});let de=Math.max(0,s.scrollHeight-s.clientHeight),Ie=Math.min(de,Math.max(0,O));S=void 0;let He=r.behavior??"auto";return Pe(Ie,He),s.scrollTo?.({top:Ie,behavior:He}),s.scrollTop!==Ie&&(s.scrollTop=Ie),o$1=s.scrollTop,pe(),true}function jt(){let e=m$1.value;if(e===null||T===void 0||!e.contains(T)||e.clientHeight<=0)return null;let r=T.getBoundingClientRect(),s=e.scrollTop+r.top-e.getBoundingClientRect().top+r.height/2,g=e.clientHeight/2;return {older:s<g-1,newer:e.scrollHeight-s<g-1}}function Kt(){p$1.clear();}function qt(){Y=true,f.value=false;}function Wt(){Y=false,me();}function Gt(e,r){let s=U.get(e);if(s!==void 0&&s!==r&&(_?.unobserve(s),E?.unobserve?.(s),V.delete(s),w.delete(e)),r===null){U.delete(e),w.delete(e);return}U.set(e,r),V.set(r,e),_?.observe(r),E?.observe(r),me();}function zt(e,r,s){let g=k.get(e);if(s===null){k.delete(e);return}k.set(e,{element:s,label:r}),re===e&&s.style.setProperty("opacity",String(Z)),g?.element!==s&&(s.dataset.imThreadDateSeparator=e);}return provide(ot,{registerMessageNode:Gt,registerDateNode:zt,registerEntryUnreadNode:e=>{T=e??void 0;}}),watch(()=>t.contentKey,(e,r)=>{if(e===r)return;l();let s=m$1.value;s!==null&&(o$1=s.scrollTop);},{flush:"sync"}),watch(()=>t.messageIds,async(e,r)=>{let s=m$1.value;if(s===null)return;let g=new Set(r);r.length>0&&e.length>0&&!e.some(xe=>g.has(xe))&&l();let B=s.getBoundingClientRect(),O=p(C$1,v(),{top:B.top,bottom:B.bottom}),de=f.value,Ie=r[r.length-1],He=Ie===void 0?-1:e.indexOf(Ie),et=He<0?[]:e.slice(He+1).filter(xe=>!g.has(xe)),ht=Y||t.loadingNewer,Yt=e.length===r.length&&e.every(xe=>g.has(xe))&&e.some((xe,tt)=>xe!==r[tt]);if(await nextTick(),K)return;if(Yt&&de&&t.followNewMessages&&t.resizeFollowEnabled&&!t.hasNewer&&!ht){Ge();return}let pt=r[0];if(pt!==void 0&&e.indexOf(pt)>0&&(H=false,ke(O)),et.length>0){if(ht){Y=false,M===void 0&&ge(O),f.value=false,me();return}(de||et.some(tt=>t.shouldFollowAppendedMessage?.(tt)===true))&&t.followNewMessages?Ge():p$1.add(et);}me();},{flush:"pre"}),watch(()=>t.loadingNewer,(e,r)=>{e||!r||!Y||fe(()=>{t.loadingNewer||(Y=false);});},{flush:"pre"}),watch(()=>t.loadingOlder,(e,r)=>{e||!r||!H||fe(()=>{t.loadingOlder||(H=false);});},{flush:"pre"}),onMounted(()=>{let e=m$1.value;if(e!==null){if(o$1=e.scrollTop,e.addEventListener("scroll",_e,{passive:true}),e.addEventListener("scrollend",b,{passive:true}),e.addEventListener("touchstart",I,{passive:true}),e.addEventListener("touchmove",F,{passive:true}),e.addEventListener("touchend",le,{passive:true}),e.addEventListener("touchcancel",le,{passive:true}),e.addEventListener("wheel",ve,{passive:true}),e.addEventListener("pointerdown",Ae,{passive:true}),e.addEventListener("pointermove",be,{passive:true}),e.addEventListener("pointerup",we,{passive:true}),e.addEventListener("pointercancel",we,{passive:true}),e.addEventListener("keydown",We),typeof globalThis.ResizeObserver=="function"){E=new globalThis.ResizeObserver(()=>{K||m$1.value===null||pe();}),E.observe(e),N.value!==null&&E.observe(N.value);for(let r of U.values())E.observe(r);}if(typeof globalThis.IntersectionObserver=="function"){_=new globalThis.IntersectionObserver(r=>{for(let s of r){let g=V.get(s.target);g!==void 0&&(s.isIntersecting?w.add(g):w.delete(g));}G=true,me();},{root:e,rootMargin:`${Number.isFinite(t.visibleMargin)?Math.max(0,t.visibleMargin):0}px 0px`});for(let r of U.values())_.observe(r);}me();}}),onBeforeUnmount(()=>{K=true;let e=m$1.value;e!==null&&e.removeEventListener("scroll",_e),e!==null&&(e.removeEventListener("scrollend",b),e.removeEventListener("touchstart",I),e.removeEventListener("touchmove",F),e.removeEventListener("touchend",le),e.removeEventListener("touchcancel",le),e.removeEventListener("wheel",ve),e.removeEventListener("pointerdown",Ae),e.removeEventListener("pointermove",be),e.removeEventListener("pointerup",we),e.removeEventListener("pointercancel",we),e.removeEventListener("keydown",We)),A!==void 0&&clearTimeout(A),ye(),Qe(),E?.disconnect(),_?.disconnect(),x(),T=void 0,U.clear(),V.clear(),w.clear(),k.clear(),p$1.clear();}),y({getViewportElement:()=>m$1.value,clearNewMessageBadge:Kt,clearActiveDate:x,isAtBottom:computed(()=>f.value),isMeasurable:gt,isScrollable:Ut,newMessageCount:computed(()=>P.value),prepareHistoryPageAppend:qt,cancelHistoryPageAppend:Wt,trackRemoteMessageIds:(e,r)=>p$1.trackRemote(e,r),scrollToLatest:Ge,scrollToMessage:_t,scrollToEntryUnread:()=>vt(T,{block:"center",behavior:"auto"}),getEntryUnreadCenteringNeeds:jt,focusViewport:()=>m$1.value?.focus({preventScroll:true})}),()=>h$1("div",{ref:m$1,"data-im-thread-viewport":"",role:"log",tabindex:-1},[h$1("div",{ref:N,"data-im-thread-viewport-content":""},c.default?.())])}});var Bt=Symbol("ImThreadSurfaceContext");function hn(t){if(typeof t.getState!="function")throw new TypeError("ImThreadSurfaceContext.getState \u5FC5\u987B\u662F\u51FD\u6570");if(typeof t.actions?.loadOlder!="function")throw new TypeError("ImThreadSurfaceContext.actions.loadOlder \u5FC5\u987B\u662F\u51FD\u6570");if(typeof t.formatDate!="function")throw new TypeError("ImThreadSurfaceContext.formatDate \u5FC5\u987B\u662F\u51FD\u6570");return Object.freeze({...t,actions:Object.freeze({...t.actions})})}function pn(t){provide(Bt,t);}function lt(){let t=inject(Bt);if(t===void 0)throw new Error("ImThreadSurface \u9700\u8981\u663E\u5F0F context prop \u6216 provideImThreadSurfaceContext");return t}var ut=Object.freeze({followThreshold:120,olderPrefetchThreshold:120,visibleReadDelay:300,visibleMargin:8,activeDateOffset:16,activeDateIdleDelay:1500}),ct=Object.freeze({enabled:true,maxFillPages:8}),bn=8,wn=160;function In(t,a){return t?.conversationType===a.conversationType&&t.conversationId===a.conversationId}var Mn=defineComponent({name:"ImThreadSurface",props:{conversation:{type:Object,required:true},context:{type:Object,default:void 0},rendererRegistry:{type:Object,required:true},presentation:{type:Object,default:void 0},readActions:{type:Object,default:void 0},viewportOptions:{type:Object,default:()=>({})},initialViewportOptions:{type:Object,default:()=>({})},hooks:{type:Object,default:void 0}},setup(t,{expose:a,slots:y}){let c=t.context??lt(),m=ref(null),N=ref(0),U=ref(false),T=ref(false),V,w=ref(false),k=ref(false),o=ref(false),h=false,C,S=ref(true),E=[],_,G=0,L=0,J=null,K="",D="",re="",Z=false,Y=false,H=ref(false),ee=ref(""),q=ref(false),Q,oe,i$1=computed(()=>c.getState()),he=computed(()=>i$1.value.pageVisible??c.isPageVisible?.()??true),ie=computed(()=>i$1.value.pageEngaged??c.isPageEngaged?.()??true),A=computed(()=>In(i$1.value.activeConversation,t.conversation)),z=computed(()=>({...ut,...t.viewportOptions})),te=computed(()=>{let n=t.initialViewportOptions.maxFillPages??ct.maxFillPages;return {enabled:t.initialViewportOptions.enabled??ct.enabled,maxFillPages:Number.isFinite(n)?Math.max(0,Math.floor(n)):ct.maxFillPages}}),M=computed(()=>!A.value||!i$1.value.ready?"":`${t.conversation.conversationType}\0${t.conversation.conversationId}`),ne=computed(()=>A.value?i({messages:i$1.value.messages,entryUnread:i$1.value.entryUnread,formatDate:c.formatDate,leadingItems:c.leadingItems?.(),beforeMessageItems:c.beforeMessageItems}):[]),f=computed(()=>ne.value.flatMap(n=>n.kind==="message"||n.kind==="system"?[n.message.id]:[]));function P(){Q!==void 0&&(clearTimeout(Q),Q=void 0),oe!==void 0&&(clearTimeout(oe),oe=void 0);}function p(n=false){if(P(),q.value=false,n){m.value?.clearActiveDate(),ee.value="";return}oe=setTimeout(()=>{oe=void 0,!q.value&&(m.value?.clearActiveDate(),ee.value="");},wn);}function j(n){if(n===null){p();return}P(),ee.value=n.label,q.value=true;let l=z.value.activeDateIdleDelay,d=Number.isFinite(l)?Math.max(0,l):ut.activeDateIdleDelay;Q=setTimeout(()=>{Q=void 0,p();},d);}async function v(n,l,d){t.hooks?.beforeAction?.(n);try{let u=await l();return d?.()!==!1&&t.hooks?.afterAction?.(n,u),u}catch(u){throw d?.()!==false&&t.hooks?.onError?.(n,u),u}}function $(n="automatic",l){return !A.value||i$1.value.loading||!i$1.value.hasOlder?Promise.resolve(0):v({kind:"load-older",source:n},()=>c.actions.loadOlder(),l)}function x(){return W()}function W(n){let l=c.actions.loadNewer,d=i$1.value.loadingNewer??i$1.value.loading;return !A.value||d||!i$1.value.hasNewer||l===void 0?Promise.resolve(0):v({kind:"load-newer"},()=>l(),n)}async function De(n){for(let l=0;l<bn;l+=1){if(!A.value)return;let d=n==="older"?i$1.value.hasOlder:i$1.value.hasNewer,u=n==="older"?i$1.value.olderError:i$1.value.newerError;if(!d||u!==null||(n==="older"?await $("user-scroll"):await x())>0)return;let I=n==="older"?i$1.value.hasOlder:i$1.value.hasNewer,F=n==="older"?i$1.value.olderError:i$1.value.newerError;if(!I||F!==null)return}}async function Fe(){return !A.value||c.actions.loadNewer===void 0?0:Be({kind:"load-newer"},()=>c.actions.retryNewer?.()??c.actions.loadNewer?.({force:true})??Promise.resolve(0))}async function Xe(){return A.value?Be({kind:"retry-older"},()=>c.actions.retryOlder?.()??c.actions.loadOlder({force:true})):0}async function Be(n,l){let d=M.value,u=++G;J=null,re="";let b;try{b=await v(n,l);}catch(I){throw ae(d,u)&&(re=d),I}return ae(d,u)&&!H.value&&(J=null,ke()),b}async function Je(){if(!A.value)return false;let n=M.value,l=++L;return ge(true),Z=true,K=n,D=Ee(Te()),!await v({kind:"jump-to-latest"},()=>c.actions.jumpToLatest?.()??Promise.resolve(!i$1.value.isHistoryWindow))||!X(n,l)||(await nextTick(),!X(n,l))?false:(m.value?.scrollToLatest(),U.value=true,o.value=false,fe(),true)}function pe(n=false){let l=m.value,d=l?.getViewportElement();k.value=l?.isScrollable()===true;let u=i$1.value.entryUnreadNavigation;w.value=u?.state==="located"&&E.includes(u.firstMessageId),H.value&&w.value&&(U.value=true);let b=d==null?0:Math.max(0,d.scrollHeight-d.clientHeight-d.scrollTop);o.value=u!==void 0&&b>50,n&&u!==void 0&&d!==null&&d!==void 0&&d.clientHeight>0&&b>=d.clientHeight&&(U.value=true);}function fe(){let n=c.actions.markConversationRead;if(n===void 0||!ie.value||!A.value||!H.value||T.value||h&&(!S.value||i$1.value.hasNewer)||C!==void 0||i$1.value.error!==null)return;let l=M.value,d=n().then(()=>{C===d&&l===M.value&&(h=true);}).catch(u=>{!Y&&C===d&&l===M.value&&t.hooks?.onError?.({kind:"mark-conversation-read"},u);}).finally(()=>{C===d&&(C=void 0);});C=d;}async function Qe(){let n=c.actions.loadEntryUnread;if(!A.value||T.value||n===void 0)return "cancelled";let l=M.value,d=++L;V=d,T.value=true,ge(true),Z=true;try{let u=await v({kind:"jump-to-entry-unread"},n,()=>X(l,d));if(!X(l,d))return "cancelled";if(!u||i$1.value.entryUnread.state!=="located")return "unavailable";let I=await Ze(l,d);return I&&(U.value=!0),I?"located":X(l,d)?"unavailable":"cancelled"}catch(u){if(!X(l,d))return "cancelled";throw u}finally{V===d&&(V=void 0,T.value=false);}}async function me(n,l){for(let d=0;d<60;d+=1){if(!X(n,l))return false;if(m.value?.scrollToEntryUnread())return true;await nextTick(),typeof window<"u"&&typeof window.requestAnimationFrame=="function"&&await new Promise(u=>window.requestAnimationFrame(()=>u()));}return false}async function Ze(n,l){let d=()=>X(n,l);if(!await me(n,l))return false;for(let u=0;u<te.value.maxFillPages;u+=1){if(!X(n,l))return false;let b=m.value,I=b?.getEntryUnreadCenteringNeeds();if(b===null||!I)return false;if(I.older&&i$1.value.hasOlder)await $("automatic",d);else if(I.newer&&i$1.value.hasNewer&&c.actions.loadNewer!==void 0){b.prepareHistoryPageAppend();try{await W(d)<=0&&X(n,l)&&b.cancelHistoryPageAppend();}catch(F){throw X(n,l)&&b.cancelHistoryPageAppend(),F}}else return true;if(await nextTick(),await nextTick(),!await me(n,l))return false}return X(n,l)}function Ke(n){S.value=n.isAtBottom,N.value=n.newMessageCount,pe(),ke();}function Ue(n,l){return m.value?.scrollToMessage(n,l)??false}function X(n,l){return !Y&&L===l&&M.value===n&&A.value}async function Ve(n,l,d,u){for(let b=0;b<60;b+=1){if(!X(n,l))return false;if(Ue(d,u))return true;await nextTick(),typeof window<"u"&&typeof window.requestAnimationFrame=="function"&&await new Promise(I=>window.requestAnimationFrame(()=>I()));}return false}async function Ce(n,l,d){let u=m.value;if(u===null||!u.isMeasurable()||u.isScrollable())return true;let b=0,I=!i$1.value.hasOlder,F=!i$1.value.hasNewer||c.actions.loadNewer===void 0,le=async()=>(await nextTick(),await nextTick(),Ve(n,l,d,{behavior:"auto",block:"center"})),ve=async be=>{if(!X(n,l)||b>=te.value.maxFillPages)return false;let we=0;if(be==="older"){if(I||!i$1.value.hasOlder)return false;we=await $(),I=!i$1.value.hasOlder;}else {if(F||!i$1.value.hasNewer)return false;u.prepareHistoryPageAppend();try{we=await x();}catch(We){throw u.cancelHistoryPageAppend(),We}we<=0&&!i$1.value.hasNewer&&u.cancelHistoryPageAppend(),F=!i$1.value.hasNewer;}return b+=1,we>0?le():!(be==="older"?I:F)};!I&&!await ve("older")&&(I=true),!F&&!await ve("newer")&&(F=true);let Ae="older";for(;X(n,l)&&b<te.value.maxFillPages&&u.isMeasurable()&&!u.isScrollable()&&(!I||!F);){let be=Ae==="older"?I?"newer":"older":F?"older":"newer";Ae=be==="older"?"newer":"older",await ve(be)||(be==="older"?I=true:F=true);}return X(n,l)}async function _e(n,l={behavior:"auto",block:"center"}){if(!A.value||n==="")return false;let d=M.value,u=++L;if(!f.value.includes(n)){let F=c.actions.loadAround;if(F===void 0||!await v({kind:"locate-message",messageId:n},()=>F(n))||!X(d,u))return false}return !await Ve(d,u,n,{...l,behavior:"auto"})||!await Ce(d,u,n)?false:Ve(d,u,n,l)}function Pe(){_!==void 0&&(clearTimeout(_),_=void 0);}function Se(){if(Pe(),!H.value)return;let n=t.readActions;if(n===void 0&&c.actions.markVisibleMessages===void 0)return;let l=Number.isFinite(z.value.visibleReadDelay)?Math.max(0,z.value.visibleReadDelay):ut.visibleReadDelay;_=setTimeout(()=>{if(_=void 0,!A.value||!ie.value)return;fe();let d=c.actions.markVisibleMessages;if(d!==void 0){let I=E;d(I).catch(F=>{t.hooks?.onError?.({kind:"visible-range",messageIds:I},F);});return}if(n===void 0)return;let u=E[E.length-1];if(u===void 0)return;let b=n.resolveTarget===void 0?u:n.resolveTarget(u);b!=null&&Promise.resolve(n.markRead(b)).catch(I=>{t.hooks?.onError?.({kind:"visible-range",messageIds:E},I);});},l);}function ye(n){E=Object.freeze([...n]),pe();let l={kind:"visible-range",messageIds:E};t.hooks?.beforeAction?.(l);try{c.actions.onVisibleRange?.(E),t.hooks?.afterAction?.(l,void 0);}catch(d){throw t.hooks?.onError?.(l,d),d}H.value?Se():ke();}function ae(n,l){return !Y&&G===l&&M.value===n&&!Z}function je(n,l){ae(n,l)&&(K=n,D=Ee(Te()),H.value=true,pe(),fe(),Se());}function Te(){return i$1.value.entryUnreadNavigation===void 0?i$1.value.entryUnread:{state:"none"}}function Ee(n){return n.state!=="located"?n.state:`${n.state}:${n.firstMessageId}`}async function Ne(n,l,d){for(let u=0;u<60;u+=1){if(!ae(n,l))return false;if(m.value?.scrollToMessage(d,{behavior:"auto",block:"center"})===true)return true;await nextTick(),typeof window<"u"&&typeof window.requestAnimationFrame=="function"&&await new Promise(I=>window.requestAnimationFrame(()=>I()));}return false}function ke(){let n=M.value,l=Ee(Te());if(n===""||i$1.value.loading||i$1.value.error!==null&&i$1.value.messages.length===0||K===n&&(D===l||D.startsWith("located:")||Z)||re===n||J!==null)return;if(!te.value.enabled){K=n,D=l,H.value=true,Se();return}let d=++G;Z=false,H.value=false;let u=(async()=>{if(await nextTick(),!ae(n,d))return;let b=m.value;if(b===null||!b.isMeasurable())return;let I=Te();if(I.state==="located"&&!f.value.includes(I.firstMessageId))return;let F=I.state==="located"?await Ne(n,d,I.firstMessageId):false;if(I.state==="located"&&!F)return;F||b.scrollToLatest();let le=0;for(;ae(n,d)&&le<te.value.maxFillPages&&i$1.value.error===null&&(i$1.value.hasOlder||i$1.value.hasNewer&&c.actions.loadNewer!==void 0)&&b.isMeasurable()&&!b.isScrollable();){if(i$1.value.hasNewer&&c.actions.loadNewer!==void 0&&(i$1.value.messages.length===0||!i$1.value.hasOlder)){let Ae=L;b.prepareHistoryPageAppend();try{await x(),await nextTick();}finally{M.value===n&&L===Ae&&(G===d||Z)&&b.cancelHistoryPageAppend();}}else await $();if(!ae(n,d)||(le+=1,await nextTick(),await nextTick(),!b.isMeasurable()))return}if(!ae(n,d)||!b.isMeasurable())return;let ve=Te();if(ve.state==="located"){if(!f.value.includes(ve.firstMessageId)||!await Ne(n,d,ve.firstMessageId))return}else b.scrollToLatest();await nextTick(),je(n,d);})().catch(()=>{ae(n,d)&&(re=n);}).finally(()=>{J===u&&(J=null);});J=u;}function ge(n,l=false){G+=1,J=null,Z=false,H.value=n,n||(K="",D="",l||(re="")),Pe();}function qe(){if(pe(true),T.value&&(L+=1),Z=true,H.value)return;let n=M.value;G+=1,J=null,K=n,H.value=true,Se();}let Oe=Object.freeze({getViewportElement:()=>m.value?.getViewportElement()??null,loadOlder:$,retryOlder:Xe,loadNewer:x,retryNewer:Fe,jumpToLatest:Je,jumpToEntryUnread:Qe,scrollToMessage:Ue,locateMessage:_e,focusViewport:()=>m.value?.focusViewport()});return a(Oe),watch(ie,n=>{n&&H.value?Se():Pe();}),watch([()=>i$1.value.activeRemoteMessageRevision??0,m,M],()=>{let n=m.value;if(n===null||!A.value)return;let l=c.actions.drainActiveRemoteMessageIds?.()??[];n.trackRemoteMessageIds(l,{isAtBottom:S.value,isHistoryWindow:i$1.value.isHistoryWindow,isPageVisible:he.value})&&(S.value=false);},{flush:"post"}),watch([M,()=>i$1.value.loading,()=>i$1.value.error,()=>f.value.length,()=>i$1.value.hasOlder,()=>Ee(Te()),te,()=>i$1.value.hasNewer],([n,l,d,u,,b],[I,,,F,,le])=>{if(n!==I&&(L+=1,ge(false),p(true),m.value?.clearNewMessageBadge(),N.value=0,S.value=true,E=[],U.value=false,w.value=false,k.value=false,o.value=false,T.value=false,V=void 0,h=false,C=void 0),n!==""&&n===I&&F!==void 0&&F>0&&u===0&&(i$1.value.hasOlder||i$1.value.hasNewer)&&H.value&&ge(false,true),n!==""&&n===I&&b!==le&&!D.startsWith("located:")&&!Z&&b.startsWith("located:")&&(K="",D="",H.value=false),n===""){ge(false);return}if(d!==null&&i$1.value.messages.length===0){H.value||ge(false,true);return}l||ke();},{flush:"post",immediate:true}),onBeforeUnmount(()=>{Y=true,L+=1,ge(false),p(true);}),()=>{let n={conversation:t.conversation,state:i$1.value,items:ne.value,actions:Oe,initialViewportSettled:M.value!==""&&(i$1.value.messages.length===0?!i$1.value.loading&&i$1.value.error===null&&!i$1.value.hasOlder&&!i$1.value.hasNewer:H.value&&K===M.value)},l=[y.header?.(n),y["before-list"]?.(n)];if(!A.value)l.push(y.unsupported?.(n)??h$1("div",{"data-im-thread-unsupported":""}));else if(!i$1.value.ready&&i$1.value.loading)l.push(y.loading?.(n)??h$1("div",{"data-im-thread-loading":""}));else if(i$1.value.error!==null&&i$1.value.messages.length===0)l.push(y.error?.(n)??h$1("div",{"data-im-thread-error":""}));else if(i$1.value.ready&&i$1.value.messages.length===0&&!i$1.value.hasOlder&&!i$1.value.hasNewer)l.push(y.empty?.(n)??h$1("div",{"data-im-thread-empty":""}));else {let d=h$1(st,{ref:m,messageIds:f.value,contentKey:`${t.conversation.conversationType}\0${t.conversation.conversationId}`,loadingOlder:i$1.value.loadingOlder??i$1.value.loading,hasNewer:i$1.value.hasNewer,loadingNewer:i$1.value.loadingNewer??i$1.value.loading,followThreshold:z.value.followThreshold,olderPrefetchThreshold:z.value.olderPrefetchThreshold,visibleMargin:z.value.visibleMargin,activeDateOffset:z.value.activeDateOffset,activeDateEnabled:y["active-date"]!==void 0,resizeFollowEnabled:H.value,followNewMessages:he.value,shouldFollowAppendedMessage:u=>{let b=i$1.value.messages.find(I=>I.id===u);return b===void 0?false:c.shouldFollowMessage?.(b)===true},onReachStart:()=>{De("older").catch(()=>{});},onReachEnd:()=>{De("newer").catch(()=>{});},onSettled:Ke,onUserScroll:qe,onActiveDateChange:j,onVisibleRange:ye,onNewMessageCount:u=>{N.value=u;}},{default:()=>[y["viewport-before"]?.(n),h$1(it,{items:ne.value,rendererRegistry:t.rendererRegistry,presentation:t.presentation,readActions:t.readActions},{item:y.item,"date-separator":y["date-separator"],"entry-unread":y["entry-unread"],encryption:y.encryption,system:y.system,message:y.message,"recalled-message":y["recalled-message"],"deleted-message":y["deleted-message"],"unsupported-body":y["unsupported-body"]}),y["viewport-after"]?.(n)]});l.push(h$1("div",{"data-im-thread-viewport-shell":""},[y["active-date"]?.({label:ee.value,visible:q.value&&ee.value!==""}),d,y["entry-unread-navigation"]?.({...n,count:i$1.value.entryUnreadNavigation?.state==="none"?0:i$1.value.entryUnreadNavigation?.count??0,loading:T.value,visible:n.initialViewportSettled&&!U.value&&!w.value&&!i$1.value.isHistoryWindow&&i$1.value.entryUnreadNavigation!==void 0&&i$1.value.entryUnreadNavigation.state!=="none"&&i$1.value.entryUnreadNavigation.count>0&&(k.value||i$1.value.hasOlder)})])),i$1.value.error!==null&&l.push(y.error?.(n)??h$1("div",{"data-im-thread-error":""}));}return l.push(y["after-list"]?.(n),y["jump-to-latest"]?.({...n,count:N.value,visible:o.value||!S.value||i$1.value.isHistoryWindow}),y["context-menu"]?.(n),y.composer?.(n)),h$1("section",{"data-im-thread-surface":"","data-conversation-type":t.conversation.conversationType,"data-conversation-id":t.conversation.conversationId},l)}}});function Rn(t){let a=new Map;for(let c of t){if(a.has(c.kind))throw new Error(`\u6D88\u606F renderer kind \u91CD\u590D\u6CE8\u518C\uFF1A${c.kind}`);a.set(c.kind,c.component);}let y=Object.freeze([...a.keys()]);return Object.freeze({kinds:y,resolve:c=>a.get(c)})}var Sn=140,En=120;function $e(t,a){if(t.width<=0||t.height<=0)return 0;let y=Math.max(0,Math.min(t.right,a.right)-Math.max(t.left,a.left)),c=Math.max(0,Math.min(t.bottom,a.bottom)-Math.max(t.top,a.top));return Math.min(1,y*c/(t.width*t.height))}function ft(t,a){return {x:t.x,y:t.top-a,top:t.top-a,bottom:t.bottom+a,left:t.left,right:t.right,width:t.width,height:t.height+a*2,toJSON:()=>({})}}function mt(t){let a=Math.max(0,t.scrollIdleMs??Sn),y=Math.max(0,t.visibilityDwellMs??En),c=Math.min(1,Math.max(0,t.minimumIntersectionRatio??.01)),m=Math.max(0,t.revealMarginPx??0),N=Math.max(0,t.preloadMarginPx??0),U=Math.max(m,N),T=Math.max(0,t.maxPreloadTargets??Number.POSITIVE_INFINITY),V=Math.max(1,t.maxSettledVisible??Number.POSITIVE_INFINITY),w=new Map,k=new Map,o=reactive(new Set),h=new Set,C=new Set,S=[],E=null,_=null,G=null,L=false,J=false,K=false,D=false,re,Z;function Y(){re!==void 0&&clearTimeout(re),re=void 0;}function H(){Z!==void 0&&clearTimeout(Z),Z=void 0;}function ee(f=false){if(!f&&_!==null||E===null)return;let P=E.getBoundingClientRect(),p=ft(P,U);for(let[j,v]of w){let $=j.getBoundingClientRect();v.ratio=$e($,P),v.intersecting=v.ratio>0,v.revealIntersecting=U>0?$e($,p)>0:v.intersecting&&v.ratio>=c;}}function q(f){return f.intersecting&&f.ratio>=c}function Q(){for(let[f,P]of w)!P.revealIntersecting||o.has(P.key)||U>m&&(m===0&&!q(P)||m>0&&(E===null||$e(f.getBoundingClientRect(),ft(E.getBoundingClientRect(),m))<=0))||(o.add(P.key),t.onRevealed?.(P.item));}function oe(f,P=false){let p=new Set(f.map(v=>v.key));if(!(!(p.size!==C.size||[...p].some(v=>!C.has(v)))&&!P)){C.clear();for(let v of p)C.add(v);t.onSettledVisibleChange?.(f.map(v=>v.item));}}function i(f,P=false){!P&&f.length===S.length&&f.every((p,j)=>p.key===S[j]?.key&&p.item===S[j]?.item)||(S=f,t.onSettledPreloadChange?.(f.map(p=>p.item)));}function he(){if(K||L)return;let f=J;J=false,ee(),Q();let P=E?.getBoundingClientRect(),p=P===void 0?0:(P.top+P.bottom)/2,j=[...w.entries()].filter(([,v])=>q(v)).sort(([v],[$])=>{let x=v.getBoundingClientRect(),W=$.getBoundingClientRect();return Math.abs((x.top+x.bottom)/2-p)-Math.abs((W.top+W.bottom)/2-p)}).slice(0,V).map(([,v])=>v);if(oe(j,f),t.onSettledPreloadChange!==void 0&&P!==void 0){let v=ft(P,N),$=[...w.entries()].filter(([,x])=>x.revealIntersecting).map(([x,W])=>({target:W,rect:x.getBoundingClientRect()})).filter(({target:x,rect:W})=>q(x)||N>0&&$e(W,v)>0).sort((x,W)=>Number(q(W.target))-Number(q(x.target))||Math.abs((x.rect.top+x.rect.bottom)/2-p)-Math.abs((W.rect.top+W.rect.bottom)/2-p)).slice(0,T).map(({target:x})=>x);i($,f);}for(let v of j)h.has(v.key)||(h.add(v.key),t.onActivated?.(v.item));}function ie(){K||L||(H(),Z=setTimeout(()=>{Z=void 0,he();},y));}function A(){K||(J=true,z(true),i([]),ee(),Q(),oe([]),H(),Y(),re=setTimeout(()=>{re=void 0,z(false),ie();},a));}function z(f){L!==f&&(L=f,t.onScrollingChange?.(f));}function te(){E?.removeEventListener("scroll",A),_?.disconnect(),G?.disconnect(),_=null,G=null,E=null;}function M(f=true){if(K)return;let P=t.getRoot();if(!(P===E&&E!==null)){if(i([]),te(),E=P,E===null){f&&!D&&(D=true,Promise.resolve().then(()=>{D=false,K||(M(false),ie());}));return}if(E.addEventListener("scroll",A,{passive:true}),typeof IntersectionObserver<"u"){_=new IntersectionObserver(p=>{for(let j of p){let v=w.get(j.target);v!==void 0&&(v.intersecting=j.isIntersecting,v.ratio=j.intersectionRatio,U===0&&(v.revealIntersecting=j.isIntersecting&&j.intersectionRatio>=c));}Q(),ie();},{root:E,threshold:[0,c,1]}),U>0&&(G=new IntersectionObserver(p=>{for(let j of p){let v=w.get(j.target);v!==void 0&&(v.revealIntersecting=j.isIntersecting);}Q(),ie();},{root:E,rootMargin:`${U}px 0px`,threshold:0}));for(let p of w.keys())_.observe(p);for(let p of w.keys())G?.observe(p);}else ee(),Q();}}function ne(f){i(S.filter(P=>P.key!==f)),o.delete(f),h.delete(f),C.delete(f);}return {register(f,P){if(K)return;let p=t.getKey(f),j=o.has(p),v=h.has(p),$=P===null?void 0:w.get(P);$!==void 0&&$.key!==p&&(k.delete($.key),w.delete(P),ne($.key));let x=k.get(p);if(x!==void 0&&x!==P&&(_?.unobserve(x),G?.unobserve(x),w.delete(x),k.delete(p)),P===null){x!==void 0&&(_?.unobserve(x),G?.unobserve(x),w.delete(x),k.delete(p)),ne(p);return}let W=w.get(P);if(W?.key===p&&W.item===f){M();return}w.set(P,{item:f,key:p,intersecting:W?.key===p?W.intersecting:false,ratio:W?.key===p?W.ratio:0,revealIntersecting:W?.key===p?W.revealIntersecting:false}),k.set(p,P),M(),_?.observe(P),G?.observe(P),ee(true),Q(),j&&t.onRevealed?.(f),v&&t.onActivated?.(f),ie();},isRevealed:f=>o.has(t.getKey(f)),isActivated:f=>h.has(t.getKey(f)),isSettledVisible:f=>C.has(t.getKey(f)),isScrolling:()=>L,notifyScroll:A,refresh(){M(),ee(true),Q(),ie();},reset(){Y(),H(),z(false),J=false,oe([]),i([]),te(),w.clear(),k.clear(),o.clear(),h.clear();},dispose(){K||(Y(),H(),z(false),J=false,oe([]),i([]),te(),w.clear(),k.clear(),o.clear(),h.clear(),K=true);}}}function An(t){let a=new Map,y=new Map,c=false,m=T=>{let V=a.get(T.channel);return V===void 0?T.channel:`${T.channel}\0${V.getKey(T.item)}`},N=mt({getRoot:t.getRoot,getKey:m,revealMarginPx:t.revealMarginPx,preloadMarginPx:t.preloadMarginPx,minimumIntersectionRatio:t.minimumIntersectionRatio,scrollIdleMs:t.scrollIdleMs,visibilityDwellMs:t.visibilityDwellMs,onScrollingChange:T=>{for(let V of a.values())V.onScrollingChange?.(T);},onRevealed:T=>a.get(T.channel)?.onRevealed?.(T.item),onActivated:T=>a.get(T.channel)?.onActivated?.(T.item),onSettledPreloadChange:T=>{for(let[V,w]of a){let k=T.filter(o=>o.channel===V).map(o=>o.item);w.onSettledPreloadChange?.(k.slice(0,Math.max(0,w.maxPreloadTargets??Number.POSITIVE_INFINITY)));}},onSettledVisibleChange:T=>{for(let[V,w]of a){let k=T.filter(h=>h.channel===V).map(h=>h.item),o=w.maxSettledVisible===void 0?k:k.slice(0,w.maxSettledVisible);w.onSettledVisibleChange?.(o);}}});function U(T){return V=>{if(c)throw new Error("Thread visibility target group \u5DF2\u91CA\u653E");if(a.has(T))throw new Error(`Thread visibility channel \u5DF2\u5B58\u5728: ${T}`);a.set(T,V);let w=new Map;y.set(T,w);let k=false,o=S=>({channel:T,item:S});function h(){for(let S of w.values())N.register(S.target,null);w.clear(),V.onScrollingChange?.(false),V.onSettledVisibleChange?.([]),V.onSettledPreloadChange?.([]);}return {register(S,E){if(k||c)return;let _=V.getKey(S),G=w.get(_);if(E===null){G!==void 0&&(N.register(G.target,null),w.delete(_));return}let L=G?.target.item===S?G.target:o(S);w.set(_,{target:L,element:E}),N.register(L,E);},isRevealed:S=>N.isRevealed(o(S)),isActivated:S=>N.isActivated(o(S)),isSettledVisible:S=>N.isSettledVisible(o(S)),isScrolling:N.isScrolling,notifyScroll:N.notifyScroll,refresh:N.refresh,reset:h,dispose(){k||(h(),k=true,a.delete(T),y.delete(T));}}}}return {createFactory:U,refresh:N.refresh,dispose(){if(!c){for(let T of y.values())for(let V of T.values())N.register(V.target,null);for(let T of a.values())T.onSettledPreloadChange?.([]);y.clear(),a.clear(),N.dispose(),c=true;}}}}export{rt as ImThreadBodySwitch,it as ImThreadItems,Mn as ImThreadSurface,st as ImThreadViewport,hn as createImThreadSurfaceContext,Rn as createMessageRendererRegistry,An as createThreadVisibilityTargetGroup,mt as createThreadVisibilityTargets,pn as provideImThreadSurfaceContext,Xt as useImText,lt as useImThreadSurfaceContext,Zt as useOptionalImThreadReadActions};
|
|
1
|
+
import {h,C,p,i,q,m,z,B,o,j,g}from'./chunk-HWA7NOXG.js';import {f,h as h$2,i as i$1,g as g$1}from'./chunk-GHFHAGJ7.js';import'./chunk-LMP34HNC.js';import'./chunk-ZERTVCH2.js';import'./chunk-4I23ADH2.js';import'./chunk-WOT6VMZA.js';import {defineComponent,h as h$1,ref,provide,watch,nextTick,onMounted,onBeforeUnmount,computed,inject,isVNode,cloneVNode,Fragment,reactive}from'vue';function $t(t){let a=0,y=0;for(let c of t)c.kind==="video"?y+=1:a+=1;return {imageCount:a,videoCount:y}}function Xt(t){return {systemMessage:a=>a.body.system!==void 0?g$1(a.body.system,{locale:t.locale(),resolveName:t.resolveName,selfId:t.selfId()}):"",mediaPlaceholder:a=>i$1(a.contentType,{locale:t.locale(),durationMs:a.body.voice?.durationMs,stickerImageType:a.body.sticker?.imageType,gameType:a.body.game?.gameType,callKind:a.body.call?.callKind,...a.body.filesAlbum===void 0?{}:{filesAlbum:{count:a.body.filesAlbum.items.length,caption:a.body.filesAlbum.caption}},...a.body.mediaAlbum===void 0?{}:{mediaAlbum:$t(a.body.mediaAlbum.items)}}),lastMessage:a=>a.lastMessageSummary!==void 0?h$2(a.lastMessageSummary,{locale:t.locale(),resolveName:t.resolveName,selfId:t.selfId()}):a.lastMessagePreview,failureText:a=>a.failure?.displayCode!==void 0?f(a.failure.displayCode,{locale:t.locale(),mediaKind:a.failure.mediaKind,params:a.failure.params}):a.failure?.message??""}}var Ct=Symbol("ImThreadReadActions");function Nt(t){provide(Ct,t);}function Zt(){return inject(Ct,void 0)}var rt=defineComponent({name:"ImThreadBodySwitch",inheritAttrs:false,props:{message:{type:Object,required:true},rendererRegistry:{type:Object,required:true},presentation:{type:Object,default:void 0},readActions:{type:Object,default:void 0}},setup(t,{attrs:a,slots:y}){return Nt(t.readActions),()=>{let c=h(t.message),m=t.rendererRegistry.resolve(c);return m!==void 0?h$1(m,{...a,message:t.message,presentation:t.presentation}):y["unsupported-body"]!==void 0?y["unsupported-body"]({kind:c,message:t.message}):h$1("span",{"data-im-thread-unsupported-body":c,"aria-hidden":"true"})}}});var ot=Symbol("ImThreadViewportRegistration");function Ht(){return inject(ot,void 0)}var it=defineComponent({name:"ImThreadItems",props:{items:{type:Array,required:true},rendererRegistry:{type:Object,required:true},presentation:{type:Object,default:void 0},readActions:{type:Object,default:void 0}},setup(t,{slots:a}){let y=Ht();function c(o,h){let C=Array.isArray(h)?h:[h];return C.length===1&&isVNode(C[0])?cloneVNode(C[0],{key:o}):h$1(Fragment,{key:o},C)}function m(o){return h=>{y?.registerMessageNode(o,h instanceof HTMLElement?h:null);}}function N(o,h){return C=>{y?.registerDateNode(o,h,C instanceof HTMLElement?C:null);}}function U(o){return a.encryption?.({item:o})??h$1("div",{"data-im-thread-encryption":o.key})}function T(o){let h=N(o.key,o.label);return a["date-separator"]?.({item:o,setElement:h})??h$1("div",{ref:h,"data-im-thread-date-separator":o.key},o.label)}function V(o){y?.registerEntryUnreadNode(o instanceof HTMLElement?o:null);}function w(o){return a["entry-unread"]?.({item:o,setElement:V})??h$1("div",{ref:V,"data-im-thread-entry-unread":o.key,...o.count===void 0?{}:{"data-count":String(o.count)}})}function k(o){let h=m(o.message.id);return a.item!==void 0?a.item({item:o,setElement:h}):a.message!==void 0?a.message({item:o,setElement:h}):o.message.deletedForEveryone!==void 0?a["deleted-message"]?.({item:o,setElement:h})??h$1("article",{ref:h,"data-im-thread-message-id":o.message.id,"data-im-thread-message-terminal":"deleted-for-everyone"},[h$1("span",{"data-im-thread-anchor-point":""})]):o.message.recalled!==void 0?a["recalled-message"]?.({item:o,setElement:h})??h$1("article",{ref:h,"data-im-thread-message-id":o.message.id,"data-im-thread-message-terminal":"recalled"},[h$1("span",{"data-im-thread-anchor-point":""})]):o.kind==="system"&&a.system!==void 0?a.system({item:o,setElement:h}):h$1("article",{ref:h,"data-im-thread-message-id":o.message.id,"data-first-of-run":o.kind==="message"?String(o.firstOfRun):void 0},[h$1("span",{"data-im-thread-anchor-point":""}),h$1(rt,{message:o.message,rendererRegistry:t.rendererRegistry,presentation:t.presentation,readActions:t.readActions},{"unsupported-body":a["unsupported-body"]===void 0?void 0:C=>a["unsupported-body"]?.(C)})])}return ()=>h$1("div",{"data-im-thread-items":""},t.items.map(o=>{switch(o.kind){case "encryption":return a.item!==void 0?c(o.key,a.item({item:o})):c(o.key,U(o));case "date-separator":return a.item!==void 0?c(o.key,a.item({item:o,setElement:N(o.key,o.label)})):c(o.key,T(o));case "entry-unread":return a.item!==void 0?c(o.key,a.item({item:o,setElement:V})):c(o.key,w(o));case "system":case "message":return c(o.key,k(o))}return o}))}});var Ft=120,fn=500,Le=.5,mn=8;function at(t){let a=t.ownerDocument.defaultView?.devicePixelRatio;return 1+1/(a!==void 0&&Number.isFinite(a)&&a>0?a:1)}var st=defineComponent({name:"ImThreadViewport",props:{messageIds:{type:Array,required:true},contentKey:{type:String,default:""},loadingOlder:{type:Boolean,default:false},hasNewer:{type:Boolean,default:false},loadingNewer:{type:Boolean,default:false},followThreshold:{type:Number,default:120},olderPrefetchThreshold:{type:Number,default:120},followNewMessages:{type:Boolean,default:true},shouldFollowAppendedMessage:{type:Function,default:void 0},visibleMargin:{type:Number,default:8},resizeFollowEnabled:{type:Boolean,default:true},activeDateOffset:{type:Number,default:16},activeDateEnabled:{type:Boolean,default:false}},emits:{"reach-start":()=>true,"reach-end":()=>true,"visible-range":t=>true,settled:t=>true,"new-message-count":t=>true,"user-scroll":()=>true,"active-date-change":t=>true},setup(t,{emit:a,expose:y,slots:c}){let m$1=ref(null),N=ref(null),U=new Map,T,V=new Map,w=new Set,k=new Map,o$1=0,h=[],C$1,S,E,_,G=false,L,J=new Set,K=false,D,re="",Z=1,Y=false,H=false,ee=true,q$1=false,Q=false,oe=false,i=0,he=-1,ie=-1,A,z$1,te,M,ne,f=ref(true),P=ref(0),p$1=C(e=>{P.value=e,a("new-message-count",e);});function j$1(e){let r=Number.isFinite(t.followThreshold)?Math.max(0,t.followThreshold):0;return e.scrollHeight-e.clientHeight-e.scrollTop<=r}function v(e=t.messageIds){return e.flatMap(r=>{let s=U.get(r);if(s===void 0)return [];let g=s.getBoundingClientRect(),R=s.querySelector("[data-im-thread-anchor-point]");return [{id:r,top:g.top,bottom:g.bottom,anchorTop:R?.getBoundingClientRect().top??g.top}]})}function $(e="",r=1){let s=Math.min(1,Math.max(0,r));re!==""&&re!==e&&k.get(re)?.element.style.removeProperty("opacity"),re=e,Z=s,e!==""&&k.get(e)?.element.style.setProperty("opacity",String(s));}function x(){$();}function W(){let e=m$1.value;if(K||e===null||!t.activeDateEnabled)return;let r=[...k.entries()].filter(([,B])=>e.contains(B.element)).map(([B,O])=>{let de=O.element.getBoundingClientRect();return {key:B,label:O.label,top:de.top,height:de.height}}).sort((B,O)=>B.top-O.top),s=e.getBoundingClientRect(),g$1=r.find(B=>B.height>0)?.height??28,R=g({markers:r,viewportTop:s.top,overlayTop:Number.isFinite(t.activeDateOffset)?Math.max(0,t.activeDateOffset):0,overlayHeight:g$1});if(R===null){x(),a("active-date-change",null);return}$(R.inlineDateKey,R.inlineOpacity),a("active-date-change",R);}function De(e){S={scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,width:e.clientWidth,height:e.clientHeight};}function Fe(e){let r=S;if(r===void 0)return false;let s=Math.max(0,e.scrollHeight-e.clientHeight);return s<r.scrollHeight-r.height&&r.scrollTop>s&&Math.abs(e.scrollTop-s)<=at(e)}function Xe(e){return Fe(e)||D!==void 0&&(D.behavior==="smooth"||Math.abs(e.scrollTop-D.targetTop)<=at(e))?0:e.scrollTop-o$1}function Be(e,r){r!==0&&(o$1=e.scrollTop-r,D=void 0,_e());}function Je(e,r){let s=Xe(e);if(M!==void 0)return M.expectedOffset-=s,je(),Be(e,s),q$1||Ne(),false;let g=S;if(g===void 0)return false;let R=C$1,B=R===void 0?void 0:v([R.id])[0],O=e.scrollTop-g.scrollTop,de=Fe(e)?0:O,Ie=R===void 0||B===void 0?0:(B.anchorTop??B.top)-r.top-R.offset+O;return g.scrollHeight!==e.scrollHeight||g.width!==e.clientWidth||g.height!==e.clientHeight||Math.abs(Ie)>Le?(S=void 0,!Y&&!t.loadingNewer&&t.resizeFollowEnabled&&f.value&&Math.abs(de)<=Le?(Ge(),true):(R!==void 0&&ge({...R,offset:R.offset-de}),Be(e,s),false)):false}function pe(){let e=m$1.value;if(K||e===null)return;let r=e.getBoundingClientRect();if(Je(e,r))return;let s=_!==void 0&&G?t.messageIds.filter(O=>w.has(O)):t.messageIds,g=v(s);if(_!==void 0&&G&&g.length===0){f.value=j$1(e);return}let R=g.filter(O=>B({viewportTop:r.top,viewportBottom:r.bottom,messageTop:O.top,messageBottom:O.bottom,margin:t.visibleMargin})).map(O=>O.id),B$1=R.length!==h.length||R.some((O,de)=>h[de]!==O);h=Object.freeze(R),C$1=o(g,{top:r.top,bottom:r.bottom}),De(e),p$1.acknowledgeVisible(R),f.value=j$1(e),B$1&&a("visible-range",h),a("settled",{visibleMessageIds:h,...h.length===0?{}:{newestVisibleMessageId:h[h.length-1]},isAtBottom:f.value,newMessageCount:P.value});}function fe(e){if(J.add(e),L!==void 0)return;let r=()=>{L=void 0;let s=[...J];J.clear(),s.forEach(g=>g());};typeof globalThis.requestAnimationFrame=="function"?L=globalThis.requestAnimationFrame(r):L=globalThis.setTimeout(r,0);}function Qe(){L!==void 0&&(typeof L=="number"&&typeof globalThis.cancelAnimationFrame=="function"?globalThis.cancelAnimationFrame(L):globalThis.clearTimeout(L),L=void 0,J.clear());}function me(){fe(pe);}function Ze(){let e=m$1.value;if(e===null)return;let r=e.getBoundingClientRect(),s=o(v(),{top:r.top,bottom:r.bottom});s!==void 0&&(C$1=s,De(e));}function Ke(){return ee&&M===void 0&&!H&&!t.loadingOlder}function Ue(){Ze(),ee=false,he=i,H=true,a("reach-start"),fe(()=>{t.loadingOlder||(H=false);});}function X(e){return t.hasNewer&&!Y&&!t.loadingOlder&&!t.loadingNewer&&j$1(e)}function Ve(){Y=true,f.value=false,ie=i,a("reach-end"),fe(()=>{t.loadingNewer||(Y=false);});}function Ce(){let e=m$1.value;e===null||i===ie||!X(e)||Ve();}function _e(){let e=m$1.value;if(K||e===null)return;let r=e.scrollTop,s=Fe(e),g=D,R=false;if(g!==void 0){let O=Math.abs(r-g.targetTop)<=at(e);R=g.behavior==="smooth"||O,(g.behavior!=="smooth"||O)&&(D=void 0);}!R&&!s&&!q$1&&M===void 0&&r!==o$1&&(q$1=true,Q=true,i+=1);let B=q$1&&!R&&!s&&r!==o$1;if(B&&(a("user-scroll"),fe(W)),q$1&&!oe&&u(),!ee&&Q&&i!==he&&r<o$1&&r>qe()&&(ee=true),M!==void 0&&!R)if(q$1){let O=ae();O!==void 0&&(M.expectedOffset=O);}else je(),Ne();Ke()&&B&&r>=0&&m({previousScrollTop:o$1,currentScrollTop:r,topThreshold:t.olderPrefetchThreshold})&&Ue(),B&&X(e)&&z({previousScrollTop:o$1,currentScrollTop:r,isAtBottom:j$1(e),isHistoryWindow:t.hasNewer,isPageSettling:R})&&Ve(),o$1=r,me();}function Pe(e,r="auto"){D={targetTop:e,behavior:r};}function Se(e){let r=M,s=N.value;if(!(r===void 0||s===null)){if(r.visualOffset=Math.abs(e)<=Le?0:e,r.visualOffset===0){s.style.removeProperty("transform"),s.style.removeProperty("will-change");return}s.style.setProperty("transform",`translate3d(0, ${r.visualOffset}px, 0)`),s.style.setProperty("will-change","transform");}}function ye(){ne!==void 0&&(clearTimeout(ne),ne=void 0),M!==void 0&&M.visualOffset!==0&&(C$1=void 0,S=void 0);let e=N.value;e?.style.removeProperty("transform"),e?.style.removeProperty("will-change"),M=void 0,D=void 0;}function ae(){let e=m$1.value,r=M;if(e===null||r===void 0)return;let s=v().find(g=>g.id===r.anchor.id);if(s!==void 0)return (s.anchorTop??s.top)-e.getBoundingClientRect().top}function je(){let e=M,r=ae();if(e===void 0||r===void 0)return;let s=e.expectedOffset-r;Math.abs(s)<=Le||(Se(e.visualOffset+s),e.committed=false,e.attempts=0);}function Te(){ne!==void 0&&clearTimeout(ne),ne=setTimeout(()=>{ne=void 0,!(q$1||M?.committed!==true)&&ye();},fn);}function Ee(){let e=m$1.value,r=M;if(K||e===null||r===void 0||q$1)return;let s=r.visualOffset;if(Math.abs(s)<=Le){r.committed=true,Te();return}let g=Math.max(0,e.scrollHeight-e.clientHeight),R=Math.min(g,Math.max(0,e.scrollTop-s));if(Pe(R),e.scrollTop=R,Math.abs(e.scrollTop-R)>Le){D=void 0,r.committed=false,r.attempts+=1,r.attempts<mn?Ne():(ye(),D=void 0,o$1=e.scrollTop);return}Se(0),o$1=e.scrollTop,r.expectedOffset=ae()??r.expectedOffset,r.committed=true,r.attempts=0,Te();}function Ne(){ne!==void 0&&clearTimeout(ne),ne=setTimeout(()=>{ne=void 0,Ee();},Ft);}function ke(e){e!==void 0&&(M===void 0&&(M={anchor:e,expectedOffset:e.offset,visualOffset:0,committed:false,attempts:0}),je(),!q$1&&Ee());}function ge(e){let r=m$1.value;if(r===null||e===void 0)return;let s=r.getBoundingClientRect(),g=q(e,v(),{top:s.top,bottom:s.bottom});if(g!==void 0){let R=Math.max(0,r.scrollHeight-r.clientHeight),B=Math.min(R,Math.max(0,r.scrollTop+g));Pe(B),r.scrollTop=B,o$1=r.scrollTop,S=void 0;}}function qe(){return Number.isFinite(t.olderPrefetchThreshold)?Math.max(0,t.olderPrefetchThreshold):0}function Oe(){D?.behavior==="smooth"&&(D=void 0),Q=false,q$1||(q$1=true,i+=1),A!==void 0&&(clearTimeout(A),A=void 0);}function n(){let e=m$1.value;e===null||i===he||(M!==void 0&&ye(),ee=true,e.scrollTop<=qe()&&Ke()&&Ue());}function l(){C$1=void 0,S=void 0,A!==void 0&&(clearTimeout(A),A=void 0),ye(),q$1=false,Q=false,oe=false,z$1=void 0,te=void 0,i+=1,he=-1,ie=-1,ee=true,H=false,Y=false,D=void 0;}function d(){oe||(A!==void 0&&(clearTimeout(A),A=void 0),q$1=false,Q=false,M!==void 0&&(M.attempts=0),Ee());}function u(){oe||(A!==void 0&&clearTimeout(A),A=setTimeout(()=>{A=void 0,d();},Ft));}function b(){D=void 0,d();}function I(e){oe=true,Oe(),z$1=e.touches?.[0]?.clientY;}function F(e){let r=e.touches?.[0]?.clientY;r!==void 0&&(z$1!==void 0&&r>z$1?n():z$1!==void 0&&r<z$1&&Ce(),z$1=r);}function le(){oe=false,z$1=void 0,u();}function ve(e){Oe(),e.deltaY<0?n():e.deltaY>0&&Ce(),u();}function Ae(e){e.pointerType!=="touch"&&(Oe(),te=e.clientY,u());}function be(e){e.pointerType==="touch"||!q$1||te===void 0||(e.clientY<te?n():e.clientY>te&&Ce(),te=e.clientY,u());}function we(e){e.pointerType!=="touch"&&(te=void 0,u());}function We(e){["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "].includes(e.key)&&(Oe(),e.key==="ArrowUp"||e.key==="PageUp"||e.key==="Home"||e.key===" "&&e.shiftKey?n():Ce(),u());}function Ge(e="auto"){let r=m$1.value;if(r===null)return;S=void 0,ye();let s=Math.max(0,r.scrollHeight-r.clientHeight);Pe(s,e),r.scrollTo?.({top:s,behavior:e}),r.scrollTop!==s&&(r.scrollTop=s),o$1=r.scrollTop,p$1.clear(),pe();}function gt(){let e=m$1.value;return e!==null&&e.clientWidth>0&&e.clientHeight>0}function Ut(){let e=m$1.value;return gt()&&e!==null&&e.scrollHeight>e.clientHeight+1}function _t(e,r={}){return vt(U.get(e),r)}function vt(e,r){let s=m$1.value;if(s===null||e===void 0||!s.contains(e)||s.clientHeight<=0)return false;ye();let g=s.getBoundingClientRect(),R=e.getBoundingClientRect(),B=r.block??"center",O;B==="start"?O=s.scrollTop+R.top-g.top:B==="end"?O=s.scrollTop+R.bottom-g.bottom:B==="nearest"?R.top>=g.top&&R.bottom<=g.bottom?O=s.scrollTop:R.top<g.top?O=s.scrollTop+R.top-g.top:O=s.scrollTop+R.bottom-g.bottom:O=j({currentScrollTop:s.scrollTop,scrollHeight:s.scrollHeight,targetHeight:R.height,targetTop:R.top,viewportHeight:s.clientHeight,viewportTop:g.top});let de=Math.max(0,s.scrollHeight-s.clientHeight),Ie=Math.min(de,Math.max(0,O));S=void 0;let He=r.behavior??"auto";return Pe(Ie,He),s.scrollTo?.({top:Ie,behavior:He}),s.scrollTop!==Ie&&(s.scrollTop=Ie),o$1=s.scrollTop,pe(),true}function jt(){let e=m$1.value;if(e===null||T===void 0||!e.contains(T)||e.clientHeight<=0)return null;let r=T.getBoundingClientRect(),s=e.scrollTop+r.top-e.getBoundingClientRect().top+r.height/2,g=e.clientHeight/2;return {older:s<g-1,newer:e.scrollHeight-s<g-1}}function Kt(){p$1.clear();}function qt(){Y=true,f.value=false;}function Wt(){Y=false,me();}function Gt(e,r){let s=U.get(e);if(s!==void 0&&s!==r&&(_?.unobserve(s),E?.unobserve?.(s),V.delete(s),w.delete(e)),r===null){U.delete(e),w.delete(e);return}U.set(e,r),V.set(r,e),_?.observe(r),E?.observe(r),me();}function zt(e,r,s){let g=k.get(e);if(s===null){k.delete(e);return}k.set(e,{element:s,label:r}),re===e&&s.style.setProperty("opacity",String(Z)),g?.element!==s&&(s.dataset.imThreadDateSeparator=e);}return provide(ot,{registerMessageNode:Gt,registerDateNode:zt,registerEntryUnreadNode:e=>{T=e??void 0;}}),watch(()=>t.contentKey,(e,r)=>{if(e===r)return;l();let s=m$1.value;s!==null&&(o$1=s.scrollTop);},{flush:"sync"}),watch(()=>t.messageIds,async(e,r)=>{let s=m$1.value;if(s===null)return;let g=new Set(r);r.length>0&&e.length>0&&!e.some(xe=>g.has(xe))&&l();let B=s.getBoundingClientRect(),O=p(C$1,v(),{top:B.top,bottom:B.bottom}),de=f.value,Ie=r[r.length-1],He=Ie===void 0?-1:e.indexOf(Ie),et=He<0?[]:e.slice(He+1).filter(xe=>!g.has(xe)),ht=Y||t.loadingNewer,Yt=e.length===r.length&&e.every(xe=>g.has(xe))&&e.some((xe,tt)=>xe!==r[tt]);if(await nextTick(),K)return;if(Yt&&de&&t.followNewMessages&&t.resizeFollowEnabled&&!t.hasNewer&&!ht){Ge();return}let pt=r[0];if(pt!==void 0&&e.indexOf(pt)>0&&(H=false,ke(O)),et.length>0){if(ht){Y=false,M===void 0&&ge(O),f.value=false,me();return}(de||et.some(tt=>t.shouldFollowAppendedMessage?.(tt)===true))&&t.followNewMessages?Ge():p$1.add(et);}me();},{flush:"pre"}),watch(()=>t.loadingNewer,(e,r)=>{e||!r||!Y||fe(()=>{t.loadingNewer||(Y=false);});},{flush:"pre"}),watch(()=>t.loadingOlder,(e,r)=>{e||!r||!H||fe(()=>{t.loadingOlder||(H=false);});},{flush:"pre"}),onMounted(()=>{let e=m$1.value;if(e!==null){if(o$1=e.scrollTop,e.addEventListener("scroll",_e,{passive:true}),e.addEventListener("scrollend",b,{passive:true}),e.addEventListener("touchstart",I,{passive:true}),e.addEventListener("touchmove",F,{passive:true}),e.addEventListener("touchend",le,{passive:true}),e.addEventListener("touchcancel",le,{passive:true}),e.addEventListener("wheel",ve,{passive:true}),e.addEventListener("pointerdown",Ae,{passive:true}),e.addEventListener("pointermove",be,{passive:true}),e.addEventListener("pointerup",we,{passive:true}),e.addEventListener("pointercancel",we,{passive:true}),e.addEventListener("keydown",We),typeof globalThis.ResizeObserver=="function"){E=new globalThis.ResizeObserver(()=>{K||m$1.value===null||pe();}),E.observe(e),N.value!==null&&E.observe(N.value);for(let r of U.values())E.observe(r);}if(typeof globalThis.IntersectionObserver=="function"){_=new globalThis.IntersectionObserver(r=>{for(let s of r){let g=V.get(s.target);g!==void 0&&(s.isIntersecting?w.add(g):w.delete(g));}G=true,me();},{root:e,rootMargin:`${Number.isFinite(t.visibleMargin)?Math.max(0,t.visibleMargin):0}px 0px`});for(let r of U.values())_.observe(r);}me();}}),onBeforeUnmount(()=>{K=true;let e=m$1.value;e!==null&&e.removeEventListener("scroll",_e),e!==null&&(e.removeEventListener("scrollend",b),e.removeEventListener("touchstart",I),e.removeEventListener("touchmove",F),e.removeEventListener("touchend",le),e.removeEventListener("touchcancel",le),e.removeEventListener("wheel",ve),e.removeEventListener("pointerdown",Ae),e.removeEventListener("pointermove",be),e.removeEventListener("pointerup",we),e.removeEventListener("pointercancel",we),e.removeEventListener("keydown",We)),A!==void 0&&clearTimeout(A),ye(),Qe(),E?.disconnect(),_?.disconnect(),x(),T=void 0,U.clear(),V.clear(),w.clear(),k.clear(),p$1.clear();}),y({getViewportElement:()=>m$1.value,clearNewMessageBadge:Kt,clearActiveDate:x,isAtBottom:computed(()=>f.value),isMeasurable:gt,isScrollable:Ut,newMessageCount:computed(()=>P.value),prepareHistoryPageAppend:qt,cancelHistoryPageAppend:Wt,trackRemoteMessageIds:(e,r)=>p$1.trackRemote(e,r),scrollToLatest:Ge,scrollToMessage:_t,scrollToEntryUnread:()=>vt(T,{block:"center",behavior:"auto"}),getEntryUnreadCenteringNeeds:jt,focusViewport:()=>m$1.value?.focus({preventScroll:true})}),()=>h$1("div",{ref:m$1,"data-im-thread-viewport":"",role:"log",tabindex:-1},[h$1("div",{ref:N,"data-im-thread-viewport-content":""},c.default?.())])}});var Bt=Symbol("ImThreadSurfaceContext");function hn(t){if(typeof t.getState!="function")throw new TypeError("ImThreadSurfaceContext.getState \u5FC5\u987B\u662F\u51FD\u6570");if(typeof t.actions?.loadOlder!="function")throw new TypeError("ImThreadSurfaceContext.actions.loadOlder \u5FC5\u987B\u662F\u51FD\u6570");if(typeof t.formatDate!="function")throw new TypeError("ImThreadSurfaceContext.formatDate \u5FC5\u987B\u662F\u51FD\u6570");return Object.freeze({...t,actions:Object.freeze({...t.actions})})}function pn(t){provide(Bt,t);}function lt(){let t=inject(Bt);if(t===void 0)throw new Error("ImThreadSurface \u9700\u8981\u663E\u5F0F context prop \u6216 provideImThreadSurfaceContext");return t}var ut=Object.freeze({followThreshold:120,olderPrefetchThreshold:120,visibleReadDelay:300,visibleMargin:8,activeDateOffset:16,activeDateIdleDelay:1500}),ct=Object.freeze({enabled:true,maxFillPages:8}),bn=8,wn=160;function In(t,a){return t?.conversationType===a.conversationType&&t.conversationId===a.conversationId}var Mn=defineComponent({name:"ImThreadSurface",props:{conversation:{type:Object,required:true},context:{type:Object,default:void 0},rendererRegistry:{type:Object,required:true},presentation:{type:Object,default:void 0},readActions:{type:Object,default:void 0},viewportOptions:{type:Object,default:()=>({})},initialViewportOptions:{type:Object,default:()=>({})},hooks:{type:Object,default:void 0}},setup(t,{expose:a,slots:y}){let c=t.context??lt(),m=ref(null),N=ref(0),U=ref(false),T=ref(false),V,w=ref(false),k=ref(false),o=ref(false),h=false,C,S=ref(true),E=[],_,G=0,L=0,J=null,K="",D="",re="",Z=false,Y=false,H=ref(false),ee=ref(""),q=ref(false),Q,oe,i$1=computed(()=>c.getState()),he=computed(()=>i$1.value.pageVisible??c.isPageVisible?.()??true),ie=computed(()=>i$1.value.pageEngaged??c.isPageEngaged?.()??true),A=computed(()=>In(i$1.value.activeConversation,t.conversation)),z=computed(()=>({...ut,...t.viewportOptions})),te=computed(()=>{let n=t.initialViewportOptions.maxFillPages??ct.maxFillPages;return {enabled:t.initialViewportOptions.enabled??ct.enabled,maxFillPages:Number.isFinite(n)?Math.max(0,Math.floor(n)):ct.maxFillPages}}),M=computed(()=>!A.value||!i$1.value.ready?"":`${t.conversation.conversationType}\0${t.conversation.conversationId}`),ne=computed(()=>A.value?i({messages:i$1.value.messages,entryUnread:i$1.value.entryUnread,formatDate:c.formatDate,leadingItems:c.leadingItems?.(),beforeMessageItems:c.beforeMessageItems}):[]),f=computed(()=>ne.value.flatMap(n=>n.kind==="message"||n.kind==="system"?[n.message.id]:[]));function P(){Q!==void 0&&(clearTimeout(Q),Q=void 0),oe!==void 0&&(clearTimeout(oe),oe=void 0);}function p(n=false){if(P(),q.value=false,n){m.value?.clearActiveDate(),ee.value="";return}oe=setTimeout(()=>{oe=void 0,!q.value&&(m.value?.clearActiveDate(),ee.value="");},wn);}function j(n){if(n===null){p();return}P(),ee.value=n.label,q.value=true;let l=z.value.activeDateIdleDelay,d=Number.isFinite(l)?Math.max(0,l):ut.activeDateIdleDelay;Q=setTimeout(()=>{Q=void 0,p();},d);}async function v(n,l,d){t.hooks?.beforeAction?.(n);try{let u=await l();return d?.()!==!1&&t.hooks?.afterAction?.(n,u),u}catch(u){throw d?.()!==false&&t.hooks?.onError?.(n,u),u}}function $(n="automatic",l){return !A.value||i$1.value.loading||!i$1.value.hasOlder?Promise.resolve(0):v({kind:"load-older",source:n},()=>c.actions.loadOlder(),l)}function x(){return W()}function W(n){let l=c.actions.loadNewer,d=i$1.value.loadingNewer??i$1.value.loading;return !A.value||d||!i$1.value.hasNewer||l===void 0?Promise.resolve(0):v({kind:"load-newer"},()=>l(),n)}async function De(n){for(let l=0;l<bn;l+=1){if(!A.value)return;let d=n==="older"?i$1.value.hasOlder:i$1.value.hasNewer,u=n==="older"?i$1.value.olderError:i$1.value.newerError;if(!d||u!==null||(n==="older"?await $("user-scroll"):await x())>0)return;let I=n==="older"?i$1.value.hasOlder:i$1.value.hasNewer,F=n==="older"?i$1.value.olderError:i$1.value.newerError;if(!I||F!==null)return}}async function Fe(){return !A.value||c.actions.loadNewer===void 0?0:Be({kind:"load-newer"},()=>c.actions.retryNewer?.()??c.actions.loadNewer?.({force:true})??Promise.resolve(0))}async function Xe(){return A.value?Be({kind:"retry-older"},()=>c.actions.retryOlder?.()??c.actions.loadOlder({force:true})):0}async function Be(n,l){let d=M.value,u=++G;J=null,re="";let b;try{b=await v(n,l);}catch(I){throw ae(d,u)&&(re=d),I}return ae(d,u)&&!H.value&&(J=null,ke()),b}async function Je(){if(!A.value)return false;let n=M.value,l=++L;return ge(true),Z=true,K=n,D=Ee(Te()),!await v({kind:"jump-to-latest"},()=>c.actions.jumpToLatest?.()??Promise.resolve(!i$1.value.isHistoryWindow))||!X(n,l)||(await nextTick(),!X(n,l))?false:(m.value?.scrollToLatest(),U.value=true,o.value=false,fe(),true)}function pe(n=false){let l=m.value,d=l?.getViewportElement();k.value=l?.isScrollable()===true;let u=i$1.value.entryUnreadNavigation;w.value=u?.state==="located"&&E.includes(u.firstMessageId),H.value&&w.value&&(U.value=true);let b=d==null?0:Math.max(0,d.scrollHeight-d.clientHeight-d.scrollTop);o.value=u!==void 0&&b>50,n&&u!==void 0&&d!==null&&d!==void 0&&d.clientHeight>0&&b>=d.clientHeight&&(U.value=true);}function fe(){let n=c.actions.markConversationRead;if(n===void 0||!ie.value||!A.value||!H.value||T.value||h&&(!S.value||i$1.value.hasNewer)||C!==void 0||i$1.value.error!==null)return;let l=M.value,d=n().then(()=>{C===d&&l===M.value&&(h=true);}).catch(u=>{!Y&&C===d&&l===M.value&&t.hooks?.onError?.({kind:"mark-conversation-read"},u);}).finally(()=>{C===d&&(C=void 0);});C=d;}async function Qe(){let n=c.actions.loadEntryUnread;if(!A.value||T.value||n===void 0)return "cancelled";let l=M.value,d=++L;V=d,T.value=true,ge(true),Z=true;try{let u=await v({kind:"jump-to-entry-unread"},n,()=>X(l,d));if(!X(l,d))return "cancelled";if(!u||i$1.value.entryUnread.state!=="located")return "unavailable";let I=await Ze(l,d);return I&&(U.value=!0),I?"located":X(l,d)?"unavailable":"cancelled"}catch(u){if(!X(l,d))return "cancelled";throw u}finally{V===d&&(V=void 0,T.value=false);}}async function me(n,l){for(let d=0;d<60;d+=1){if(!X(n,l))return false;if(m.value?.scrollToEntryUnread())return true;await nextTick(),typeof window<"u"&&typeof window.requestAnimationFrame=="function"&&await new Promise(u=>window.requestAnimationFrame(()=>u()));}return false}async function Ze(n,l){let d=()=>X(n,l);if(!await me(n,l))return false;for(let u=0;u<te.value.maxFillPages;u+=1){if(!X(n,l))return false;let b=m.value,I=b?.getEntryUnreadCenteringNeeds();if(b===null||!I)return false;if(I.older&&i$1.value.hasOlder)await $("automatic",d);else if(I.newer&&i$1.value.hasNewer&&c.actions.loadNewer!==void 0){b.prepareHistoryPageAppend();try{await W(d)<=0&&X(n,l)&&b.cancelHistoryPageAppend();}catch(F){throw X(n,l)&&b.cancelHistoryPageAppend(),F}}else return true;if(await nextTick(),await nextTick(),!await me(n,l))return false}return X(n,l)}function Ke(n){S.value=n.isAtBottom,N.value=n.newMessageCount,pe(),ke();}function Ue(n,l){return m.value?.scrollToMessage(n,l)??false}function X(n,l){return !Y&&L===l&&M.value===n&&A.value}async function Ve(n,l,d,u){for(let b=0;b<60;b+=1){if(!X(n,l))return false;if(Ue(d,u))return true;await nextTick(),typeof window<"u"&&typeof window.requestAnimationFrame=="function"&&await new Promise(I=>window.requestAnimationFrame(()=>I()));}return false}async function Ce(n,l,d){let u=m.value;if(u===null||!u.isMeasurable()||u.isScrollable())return true;let b=0,I=!i$1.value.hasOlder,F=!i$1.value.hasNewer||c.actions.loadNewer===void 0,le=async()=>(await nextTick(),await nextTick(),Ve(n,l,d,{behavior:"auto",block:"center"})),ve=async be=>{if(!X(n,l)||b>=te.value.maxFillPages)return false;let we=0;if(be==="older"){if(I||!i$1.value.hasOlder)return false;we=await $(),I=!i$1.value.hasOlder;}else {if(F||!i$1.value.hasNewer)return false;u.prepareHistoryPageAppend();try{we=await x();}catch(We){throw u.cancelHistoryPageAppend(),We}we<=0&&!i$1.value.hasNewer&&u.cancelHistoryPageAppend(),F=!i$1.value.hasNewer;}return b+=1,we>0?le():!(be==="older"?I:F)};!I&&!await ve("older")&&(I=true),!F&&!await ve("newer")&&(F=true);let Ae="older";for(;X(n,l)&&b<te.value.maxFillPages&&u.isMeasurable()&&!u.isScrollable()&&(!I||!F);){let be=Ae==="older"?I?"newer":"older":F?"older":"newer";Ae=be==="older"?"newer":"older",await ve(be)||(be==="older"?I=true:F=true);}return X(n,l)}async function _e(n,l={behavior:"auto",block:"center"}){if(!A.value||n==="")return false;let d=M.value,u=++L;if(!f.value.includes(n)){let F=c.actions.loadAround;if(F===void 0||!await v({kind:"locate-message",messageId:n},()=>F(n))||!X(d,u))return false}return !await Ve(d,u,n,{...l,behavior:"auto"})||!await Ce(d,u,n)?false:Ve(d,u,n,l)}function Pe(){_!==void 0&&(clearTimeout(_),_=void 0);}function Se(){if(Pe(),!H.value)return;let n=t.readActions;if(n===void 0&&c.actions.markVisibleMessages===void 0)return;let l=Number.isFinite(z.value.visibleReadDelay)?Math.max(0,z.value.visibleReadDelay):ut.visibleReadDelay;_=setTimeout(()=>{if(_=void 0,!A.value||!ie.value)return;fe();let d=c.actions.markVisibleMessages;if(d!==void 0){let I=E;d(I).catch(F=>{t.hooks?.onError?.({kind:"visible-range",messageIds:I},F);});return}if(n===void 0)return;let u=E[E.length-1];if(u===void 0)return;let b=n.resolveTarget===void 0?u:n.resolveTarget(u);b!=null&&Promise.resolve(n.markRead(b)).catch(I=>{t.hooks?.onError?.({kind:"visible-range",messageIds:E},I);});},l);}function ye(n){E=Object.freeze([...n]),pe();let l={kind:"visible-range",messageIds:E};t.hooks?.beforeAction?.(l);try{c.actions.onVisibleRange?.(E),t.hooks?.afterAction?.(l,void 0);}catch(d){throw t.hooks?.onError?.(l,d),d}H.value?Se():ke();}function ae(n,l){return !Y&&G===l&&M.value===n&&!Z}function je(n,l){ae(n,l)&&(K=n,D=Ee(Te()),H.value=true,pe(),fe(),Se());}function Te(){return i$1.value.entryUnreadNavigation===void 0?i$1.value.entryUnread:{state:"none"}}function Ee(n){return n.state!=="located"?n.state:`${n.state}:${n.firstMessageId}`}async function Ne(n,l,d){for(let u=0;u<60;u+=1){if(!ae(n,l))return false;if(m.value?.scrollToMessage(d,{behavior:"auto",block:"center"})===true)return true;await nextTick(),typeof window<"u"&&typeof window.requestAnimationFrame=="function"&&await new Promise(I=>window.requestAnimationFrame(()=>I()));}return false}function ke(){let n=M.value,l=Ee(Te());if(n===""||i$1.value.loading||i$1.value.error!==null&&i$1.value.messages.length===0||K===n&&(D===l||D.startsWith("located:")||Z)||re===n||J!==null)return;if(!te.value.enabled){K=n,D=l,H.value=true,Se();return}let d=++G;Z=false,H.value=false;let u=(async()=>{if(await nextTick(),!ae(n,d))return;let b=m.value;if(b===null||!b.isMeasurable())return;let I=Te();if(I.state==="located"&&!f.value.includes(I.firstMessageId))return;let F=I.state==="located"?await Ne(n,d,I.firstMessageId):false;if(I.state==="located"&&!F)return;F||b.scrollToLatest();let le=0;for(;ae(n,d)&&le<te.value.maxFillPages&&i$1.value.error===null&&(i$1.value.hasOlder||i$1.value.hasNewer&&c.actions.loadNewer!==void 0)&&b.isMeasurable()&&!b.isScrollable();){if(i$1.value.hasNewer&&c.actions.loadNewer!==void 0&&(i$1.value.messages.length===0||!i$1.value.hasOlder)){let Ae=L;b.prepareHistoryPageAppend();try{await x(),await nextTick();}finally{M.value===n&&L===Ae&&(G===d||Z)&&b.cancelHistoryPageAppend();}}else await $();if(!ae(n,d)||(le+=1,await nextTick(),await nextTick(),!b.isMeasurable()))return}if(!ae(n,d)||!b.isMeasurable())return;let ve=Te();if(ve.state==="located"){if(!f.value.includes(ve.firstMessageId)||!await Ne(n,d,ve.firstMessageId))return}else b.scrollToLatest();await nextTick(),je(n,d);})().catch(()=>{ae(n,d)&&(re=n);}).finally(()=>{J===u&&(J=null);});J=u;}function ge(n,l=false){G+=1,J=null,Z=false,H.value=n,n||(K="",D="",l||(re="")),Pe();}function qe(){if(pe(true),T.value&&(L+=1),Z=true,H.value)return;let n=M.value;G+=1,J=null,K=n,H.value=true,Se();}let Oe=Object.freeze({getViewportElement:()=>m.value?.getViewportElement()??null,loadOlder:$,retryOlder:Xe,loadNewer:x,retryNewer:Fe,jumpToLatest:Je,jumpToEntryUnread:Qe,scrollToMessage:Ue,locateMessage:_e,focusViewport:()=>m.value?.focusViewport()});return a(Oe),watch(ie,n=>{n&&H.value?Se():Pe();}),watch([()=>i$1.value.activeRemoteMessageRevision??0,m,M],()=>{let n=m.value;if(n===null||!A.value)return;let l=c.actions.drainActiveRemoteMessageIds?.()??[];n.trackRemoteMessageIds(l,{isAtBottom:S.value,isHistoryWindow:i$1.value.isHistoryWindow,isPageVisible:he.value})&&(S.value=false);},{flush:"post"}),watch([M,()=>i$1.value.loading,()=>i$1.value.error,()=>f.value.length,()=>i$1.value.hasOlder,()=>Ee(Te()),te,()=>i$1.value.hasNewer],([n,l,d,u,,b],[I,,,F,,le])=>{if(n!==I&&(L+=1,ge(false),p(true),m.value?.clearNewMessageBadge(),N.value=0,S.value=true,E=[],U.value=false,w.value=false,k.value=false,o.value=false,T.value=false,V=void 0,h=false,C=void 0),n!==""&&n===I&&F!==void 0&&F>0&&u===0&&(i$1.value.hasOlder||i$1.value.hasNewer)&&H.value&&ge(false,true),n!==""&&n===I&&b!==le&&!D.startsWith("located:")&&!Z&&b.startsWith("located:")&&(K="",D="",H.value=false),n===""){ge(false);return}if(d!==null&&i$1.value.messages.length===0){H.value||ge(false,true);return}l||ke();},{flush:"post",immediate:true}),onBeforeUnmount(()=>{Y=true,L+=1,ge(false),p(true);}),()=>{let n={conversation:t.conversation,state:i$1.value,items:ne.value,actions:Oe,initialViewportSettled:M.value!==""&&(i$1.value.messages.length===0?!i$1.value.loading&&i$1.value.error===null&&!i$1.value.hasOlder&&!i$1.value.hasNewer:H.value&&K===M.value)},l=[y.header?.(n),y["before-list"]?.(n)];if(!A.value)l.push(y.unsupported?.(n)??h$1("div",{"data-im-thread-unsupported":""}));else if(!i$1.value.ready&&i$1.value.loading)l.push(y.loading?.(n)??h$1("div",{"data-im-thread-loading":""}));else if(i$1.value.error!==null&&i$1.value.messages.length===0)l.push(y.error?.(n)??h$1("div",{"data-im-thread-error":""}));else if(i$1.value.ready&&i$1.value.messages.length===0&&!i$1.value.hasOlder&&!i$1.value.hasNewer)l.push(y.empty?.(n)??h$1("div",{"data-im-thread-empty":""}));else {let d=h$1(st,{ref:m,messageIds:f.value,contentKey:`${t.conversation.conversationType}\0${t.conversation.conversationId}`,loadingOlder:i$1.value.loadingOlder??i$1.value.loading,hasNewer:i$1.value.hasNewer,loadingNewer:i$1.value.loadingNewer??i$1.value.loading,followThreshold:z.value.followThreshold,olderPrefetchThreshold:z.value.olderPrefetchThreshold,visibleMargin:z.value.visibleMargin,activeDateOffset:z.value.activeDateOffset,activeDateEnabled:y["active-date"]!==void 0,resizeFollowEnabled:H.value,followNewMessages:he.value,shouldFollowAppendedMessage:u=>{let b=i$1.value.messages.find(I=>I.id===u);return b===void 0?false:c.shouldFollowMessage?.(b)===true},onReachStart:()=>{De("older").catch(()=>{});},onReachEnd:()=>{De("newer").catch(()=>{});},onSettled:Ke,onUserScroll:qe,onActiveDateChange:j,onVisibleRange:ye,onNewMessageCount:u=>{N.value=u;}},{default:()=>[y["viewport-before"]?.(n),h$1(it,{items:ne.value,rendererRegistry:t.rendererRegistry,presentation:t.presentation,readActions:t.readActions},{item:y.item,"date-separator":y["date-separator"],"entry-unread":y["entry-unread"],encryption:y.encryption,system:y.system,message:y.message,"recalled-message":y["recalled-message"],"deleted-message":y["deleted-message"],"unsupported-body":y["unsupported-body"]}),y["viewport-after"]?.(n)]});l.push(h$1("div",{"data-im-thread-viewport-shell":""},[y["active-date"]?.({label:ee.value,visible:q.value&&ee.value!==""}),d,y["entry-unread-navigation"]?.({...n,count:i$1.value.entryUnreadNavigation?.state==="none"?0:i$1.value.entryUnreadNavigation?.count??0,loading:T.value,visible:n.initialViewportSettled&&!U.value&&!w.value&&!i$1.value.isHistoryWindow&&i$1.value.entryUnreadNavigation!==void 0&&i$1.value.entryUnreadNavigation.state!=="none"&&i$1.value.entryUnreadNavigation.count>0&&(k.value||i$1.value.hasOlder)})])),i$1.value.error!==null&&l.push(y.error?.(n)??h$1("div",{"data-im-thread-error":""}));}return l.push(y["after-list"]?.(n),y["jump-to-latest"]?.({...n,count:N.value,visible:o.value||!S.value||i$1.value.isHistoryWindow}),y["context-menu"]?.(n),y.composer?.(n)),h$1("section",{"data-im-thread-surface":"","data-conversation-type":t.conversation.conversationType,"data-conversation-id":t.conversation.conversationId},l)}}});function Rn(t){let a=new Map;for(let c of t){if(a.has(c.kind))throw new Error(`\u6D88\u606F renderer kind \u91CD\u590D\u6CE8\u518C\uFF1A${c.kind}`);a.set(c.kind,c.component);}let y=Object.freeze([...a.keys()]);return Object.freeze({kinds:y,resolve:c=>a.get(c)})}var Sn=140,En=120;function $e(t,a){if(t.width<=0||t.height<=0)return 0;let y=Math.max(0,Math.min(t.right,a.right)-Math.max(t.left,a.left)),c=Math.max(0,Math.min(t.bottom,a.bottom)-Math.max(t.top,a.top));return Math.min(1,y*c/(t.width*t.height))}function ft(t,a){return {x:t.x,y:t.top-a,top:t.top-a,bottom:t.bottom+a,left:t.left,right:t.right,width:t.width,height:t.height+a*2,toJSON:()=>({})}}function mt(t){let a=Math.max(0,t.scrollIdleMs??Sn),y=Math.max(0,t.visibilityDwellMs??En),c=Math.min(1,Math.max(0,t.minimumIntersectionRatio??.01)),m=Math.max(0,t.revealMarginPx??0),N=Math.max(0,t.preloadMarginPx??0),U=Math.max(m,N),T=Math.max(0,t.maxPreloadTargets??Number.POSITIVE_INFINITY),V=Math.max(1,t.maxSettledVisible??Number.POSITIVE_INFINITY),w=new Map,k=new Map,o=reactive(new Set),h=new Set,C=new Set,S=[],E=null,_=null,G=null,L=false,J=false,K=false,D=false,re,Z;function Y(){re!==void 0&&clearTimeout(re),re=void 0;}function H(){Z!==void 0&&clearTimeout(Z),Z=void 0;}function ee(f=false){if(!f&&_!==null||E===null)return;let P=E.getBoundingClientRect(),p=ft(P,U);for(let[j,v]of w){let $=j.getBoundingClientRect();v.ratio=$e($,P),v.intersecting=v.ratio>0,v.revealIntersecting=U>0?$e($,p)>0:v.intersecting&&v.ratio>=c;}}function q(f){return f.intersecting&&f.ratio>=c}function Q(){for(let[f,P]of w)!P.revealIntersecting||o.has(P.key)||U>m&&(m===0&&!q(P)||m>0&&(E===null||$e(f.getBoundingClientRect(),ft(E.getBoundingClientRect(),m))<=0))||(o.add(P.key),t.onRevealed?.(P.item));}function oe(f,P=false){let p=new Set(f.map(v=>v.key));if(!(!(p.size!==C.size||[...p].some(v=>!C.has(v)))&&!P)){C.clear();for(let v of p)C.add(v);t.onSettledVisibleChange?.(f.map(v=>v.item));}}function i(f,P=false){!P&&f.length===S.length&&f.every((p,j)=>p.key===S[j]?.key&&p.item===S[j]?.item)||(S=f,t.onSettledPreloadChange?.(f.map(p=>p.item)));}function he(){if(K||L)return;let f=J;J=false,ee(),Q();let P=E?.getBoundingClientRect(),p=P===void 0?0:(P.top+P.bottom)/2,j=[...w.entries()].filter(([,v])=>q(v)).sort(([v],[$])=>{let x=v.getBoundingClientRect(),W=$.getBoundingClientRect();return Math.abs((x.top+x.bottom)/2-p)-Math.abs((W.top+W.bottom)/2-p)}).slice(0,V).map(([,v])=>v);if(oe(j,f),t.onSettledPreloadChange!==void 0&&P!==void 0){let v=ft(P,N),$=[...w.entries()].filter(([,x])=>x.revealIntersecting).map(([x,W])=>({target:W,rect:x.getBoundingClientRect()})).filter(({target:x,rect:W})=>q(x)||N>0&&$e(W,v)>0).sort((x,W)=>Number(q(W.target))-Number(q(x.target))||Math.abs((x.rect.top+x.rect.bottom)/2-p)-Math.abs((W.rect.top+W.rect.bottom)/2-p)).slice(0,T).map(({target:x})=>x);i($,f);}for(let v of j)h.has(v.key)||(h.add(v.key),t.onActivated?.(v.item));}function ie(){K||L||(H(),Z=setTimeout(()=>{Z=void 0,he();},y));}function A(){K||(J=true,z(true),i([]),ee(),Q(),oe([]),H(),Y(),re=setTimeout(()=>{re=void 0,z(false),ie();},a));}function z(f){L!==f&&(L=f,t.onScrollingChange?.(f));}function te(){E?.removeEventListener("scroll",A),_?.disconnect(),G?.disconnect(),_=null,G=null,E=null;}function M(f=true){if(K)return;let P=t.getRoot();if(!(P===E&&E!==null)){if(i([]),te(),E=P,E===null){f&&!D&&(D=true,Promise.resolve().then(()=>{D=false,K||(M(false),ie());}));return}if(E.addEventListener("scroll",A,{passive:true}),typeof IntersectionObserver<"u"){_=new IntersectionObserver(p=>{for(let j of p){let v=w.get(j.target);v!==void 0&&(v.intersecting=j.isIntersecting,v.ratio=j.intersectionRatio,U===0&&(v.revealIntersecting=j.isIntersecting&&j.intersectionRatio>=c));}Q(),ie();},{root:E,threshold:[0,c,1]}),U>0&&(G=new IntersectionObserver(p=>{for(let j of p){let v=w.get(j.target);v!==void 0&&(v.revealIntersecting=j.isIntersecting);}Q(),ie();},{root:E,rootMargin:`${U}px 0px`,threshold:0}));for(let p of w.keys())_.observe(p);for(let p of w.keys())G?.observe(p);}else ee(),Q();}}function ne(f){i(S.filter(P=>P.key!==f)),o.delete(f),h.delete(f),C.delete(f);}return {register(f,P){if(K)return;let p=t.getKey(f),j=o.has(p),v=h.has(p),$=P===null?void 0:w.get(P);$!==void 0&&$.key!==p&&(k.delete($.key),w.delete(P),ne($.key));let x=k.get(p);if(x!==void 0&&x!==P&&(_?.unobserve(x),G?.unobserve(x),w.delete(x),k.delete(p)),P===null){x!==void 0&&(_?.unobserve(x),G?.unobserve(x),w.delete(x),k.delete(p)),ne(p);return}let W=w.get(P);if(W?.key===p&&W.item===f){M();return}w.set(P,{item:f,key:p,intersecting:W?.key===p?W.intersecting:false,ratio:W?.key===p?W.ratio:0,revealIntersecting:W?.key===p?W.revealIntersecting:false}),k.set(p,P),M(),_?.observe(P),G?.observe(P),ee(true),Q(),j&&t.onRevealed?.(f),v&&t.onActivated?.(f),ie();},isRevealed:f=>o.has(t.getKey(f)),isActivated:f=>h.has(t.getKey(f)),isSettledVisible:f=>C.has(t.getKey(f)),isScrolling:()=>L,notifyScroll:A,refresh(){M(),ee(true),Q(),ie();},reset(){Y(),H(),z(false),J=false,oe([]),i([]),te(),w.clear(),k.clear(),o.clear(),h.clear();},dispose(){K||(Y(),H(),z(false),J=false,oe([]),i([]),te(),w.clear(),k.clear(),o.clear(),h.clear(),K=true);}}}function An(t){let a=new Map,y=new Map,c=false,m=T=>{let V=a.get(T.channel);return V===void 0?T.channel:`${T.channel}\0${V.getKey(T.item)}`},N=mt({getRoot:t.getRoot,getKey:m,revealMarginPx:t.revealMarginPx,preloadMarginPx:t.preloadMarginPx,minimumIntersectionRatio:t.minimumIntersectionRatio,scrollIdleMs:t.scrollIdleMs,visibilityDwellMs:t.visibilityDwellMs,onScrollingChange:T=>{for(let V of a.values())V.onScrollingChange?.(T);},onRevealed:T=>a.get(T.channel)?.onRevealed?.(T.item),onActivated:T=>a.get(T.channel)?.onActivated?.(T.item),onSettledPreloadChange:T=>{for(let[V,w]of a){let k=T.filter(o=>o.channel===V).map(o=>o.item);w.onSettledPreloadChange?.(k.slice(0,Math.max(0,w.maxPreloadTargets??Number.POSITIVE_INFINITY)));}},onSettledVisibleChange:T=>{for(let[V,w]of a){let k=T.filter(h=>h.channel===V).map(h=>h.item),o=w.maxSettledVisible===void 0?k:k.slice(0,w.maxSettledVisible);w.onSettledVisibleChange?.(o);}}});function U(T){return V=>{if(c)throw new Error("Thread visibility target group \u5DF2\u91CA\u653E");if(a.has(T))throw new Error(`Thread visibility channel \u5DF2\u5B58\u5728: ${T}`);a.set(T,V);let w=new Map;y.set(T,w);let k=false,o=S=>({channel:T,item:S});function h(){for(let S of w.values())N.register(S.target,null);w.clear(),V.onScrollingChange?.(false),V.onSettledVisibleChange?.([]),V.onSettledPreloadChange?.([]);}return {register(S,E){if(k||c)return;let _=V.getKey(S),G=w.get(_);if(E===null){G!==void 0&&(N.register(G.target,null),w.delete(_));return}let L=G?.target.item===S?G.target:o(S);w.set(_,{target:L,element:E}),N.register(L,E);},isRevealed:S=>N.isRevealed(o(S)),isActivated:S=>N.isActivated(o(S)),isSettledVisible:S=>N.isSettledVisible(o(S)),isScrolling:N.isScrolling,notifyScroll:N.notifyScroll,refresh:N.refresh,reset:h,dispose(){k||(h(),k=true,a.delete(T),y.delete(T));}}}}return {createFactory:U,refresh:N.refresh,dispose(){if(!c){for(let T of y.values())for(let V of T.values())N.register(V.target,null);for(let T of a.values())T.onSettledPreloadChange?.([]);y.clear(),a.clear(),N.dispose(),c=true;}}}}export{rt as ImThreadBodySwitch,it as ImThreadItems,Mn as ImThreadSurface,st as ImThreadViewport,hn as createImThreadSurfaceContext,Rn as createMessageRendererRegistry,An as createThreadVisibilityTargetGroup,mt as createThreadVisibilityTargets,pn as provideImThreadSurfaceContext,Xt as useImText,lt as useImThreadSurfaceContext,Zt as useOptionalImThreadReadActions};
|
package/dist/chat-kit.d.ts
CHANGED
|
@@ -710,7 +710,7 @@ interface MediaTaskUpdate {
|
|
|
710
710
|
* upload 任务子阶段。
|
|
711
711
|
*
|
|
712
712
|
* `waiting-upload-slot` 与 `state: 'queued'` 同时出现,表示还没开始传字节(在生成缩略图或在等上传槽位),
|
|
713
|
-
*
|
|
713
|
+
* 首发 percent 为 0,断点恢复时保留已有进度;`transferring` 正在传字节;`finalizing` 是等待远端 URL 最终确认。
|
|
714
714
|
*/
|
|
715
715
|
phase?: 'waiting-upload-slot' | 'waiting-retry' | 'transferring' | 'finalizing';
|
|
716
716
|
/** 当前发送意图的尝试序号与总上限。 */
|
|
@@ -719,6 +719,18 @@ interface MediaTaskUpdate {
|
|
|
719
719
|
/** 已传与总字节数,供共享展示层估算速度。 */
|
|
720
720
|
bytesTransferred?: number;
|
|
721
721
|
bytesTotal?: number;
|
|
722
|
+
/** 上传合集的逐项真实字节快照;整组发送仍由外层任务控制,不为每格创建独立发送。 */
|
|
723
|
+
items?: readonly Readonly<{
|
|
724
|
+
/** 从零开始的合集位置。 */
|
|
725
|
+
itemIndex: number;
|
|
726
|
+
/** 本项实际上传字节与源文件总字节。 */
|
|
727
|
+
bytesTransferred: number;
|
|
728
|
+
bytesTotal: number;
|
|
729
|
+
/** 远端资源确认完成前最多 99%。 */
|
|
730
|
+
percent: number;
|
|
731
|
+
/** 本项状态;已完成项不随兄弟项取消或失败回退。 */
|
|
732
|
+
state: 'queued' | 'running' | 'completed' | 'failed' | 'canceled';
|
|
733
|
+
}>[];
|
|
722
734
|
/** 跨刷新恢复可用性;缺省尚未建立恢复记录。 */
|
|
723
735
|
recovery?: 'available' | 'session-only';
|
|
724
736
|
recoveryReason?: string;
|
|
@@ -1857,6 +1869,8 @@ interface MediaAssetCacheStrategy {
|
|
|
1857
1869
|
softMaxBytes: number;
|
|
1858
1870
|
maxEntries: number;
|
|
1859
1871
|
maxEntryBytes: number;
|
|
1872
|
+
/** 完整媒体副本允许连续未访问的最长毫秒数;省略时不按时间过期,仍执行容量限制。 */
|
|
1873
|
+
maxIdleMs?: number;
|
|
1860
1874
|
}
|
|
1861
1875
|
/** 精确按 kind 解析策略;未注册返回 undefined,不提供默认策略。 */
|
|
1862
1876
|
interface MediaAssetCacheStrategyRegistry {
|
|
@@ -1870,8 +1884,12 @@ interface MediaAssetCacheStrategyRegistry {
|
|
|
1870
1884
|
*/
|
|
1871
1885
|
interface MediaAssetCachePort {
|
|
1872
1886
|
get: (key: MediaAssetCacheKey) => Promise<MediaAssetCacheEntry | null>;
|
|
1887
|
+
/** 按输入顺序检查完整资源是否存在且未过期;不读取 Blob、不延长闲置期限,存储故障必须抛出。 */
|
|
1888
|
+
hasMany?: (keys: readonly MediaAssetCacheKey[]) => Promise<readonly boolean[]>;
|
|
1873
1889
|
put: (entry: MediaAssetCacheEntry) => Promise<'stored' | 'skipped'>;
|
|
1874
1890
|
clear: () => Promise<void>;
|
|
1891
|
+
/** 删除超过闲置期限的完整持久副本;不撤销已经返回的 Blob 或宿主持有的播放地址。 */
|
|
1892
|
+
prune?: () => Promise<void>;
|
|
1875
1893
|
}
|
|
1876
1894
|
|
|
1877
1895
|
interface ImProfilePort {
|
|
@@ -3064,8 +3082,8 @@ interface IndexedDbStorageAdapterOptions {
|
|
|
3064
3082
|
maxPendingWriteBytes?: number;
|
|
3065
3083
|
};
|
|
3066
3084
|
}
|
|
3067
|
-
/** 官方浏览器 adapter
|
|
3068
|
-
type IndexedDbStorageAdapter = ImStoragePort & MediaAssetCachePort & Required<Pick<ImStoragePort, 'getConversationBackground' | 'recentHistoryCache' | 'saveConversationBackground' | 'deleteConversationBackground' | 'getDefaultConversationBackground' | 'saveDefaultConversationBackground' | 'deleteDefaultConversationBackground'>>;
|
|
3085
|
+
/** 官方浏览器 adapter 始终提供背景、最近历史和媒体缓存维护;通用端口为其它实现保留可选能力。 */
|
|
3086
|
+
type IndexedDbStorageAdapter = ImStoragePort & MediaAssetCachePort & Required<Pick<MediaAssetCachePort, 'prune' | 'hasMany'>> & Required<Pick<ImStoragePort, 'getConversationBackground' | 'recentHistoryCache' | 'saveConversationBackground' | 'deleteConversationBackground' | 'getDefaultConversationBackground' | 'saveDefaultConversationBackground' | 'deleteDefaultConversationBackground'>>;
|
|
3069
3087
|
/**
|
|
3070
3088
|
* 创建 IndexedDB 存储 adapter(实现 ImStoragePort)。
|
|
3071
3089
|
* 生命周期:先 `open({ namespace })`(幂等,跑 schema 迁移),再读写;`close()` 释放句柄。
|
|
@@ -5167,9 +5185,9 @@ interface ConversationHandle<TType extends ProductHandleConversationType = Produ
|
|
|
5167
5185
|
/**
|
|
5168
5186
|
* 按稳定消息 id 打开目标附近的连续历史窗口。
|
|
5169
5187
|
*
|
|
5170
|
-
* @remarks
|
|
5171
|
-
*
|
|
5172
|
-
* @throws
|
|
5188
|
+
* @remarks GROUP 完整置顶预览可按消息时间定位;CHANNEL 置顶未缓存时先按 ID 取回正式历史记录,
|
|
5189
|
+
* 以服务端游标继续双向分页。短期搜索结果只作为只读锚点;partial 置顶和过期搜索结果明确拒绝定位。
|
|
5190
|
+
* @throws 没有可用锚点、远端确认缺失或目标不属于当前复合会话时,抛出稳定 `IM_SDK_MESSAGE_NOT_FOUND`
|
|
5173
5191
|
* (`category: 'state'`、`retryable: false`、`details.messageId`)。这是常见产品结果而非链路异常,
|
|
5174
5192
|
* 调用方应据此与真正的存储/协议失败区分反馈,不要解析错误文案。
|
|
5175
5193
|
*/
|
|
@@ -5305,6 +5323,8 @@ interface ImMediaTask {
|
|
|
5305
5323
|
* 上传任务不带下标:一条合集整体只有一条上传进度(所有项都传完才算这条消息发出去)。
|
|
5306
5324
|
*/
|
|
5307
5325
|
itemIndex?: number;
|
|
5326
|
+
/** 合集各项的真实上传快照;控制动作仍作用于整条消息,不包含资源或传输凭据。 */
|
|
5327
|
+
items?: MediaTaskUpdate['items'];
|
|
5308
5328
|
/** upload 来自发送链路,download 来自本产品 API。 */
|
|
5309
5329
|
direction: 'upload' | 'download';
|
|
5310
5330
|
/** 终态 completed/failed/canceled 不会被同一尝试的迟到 progress 回退。 */
|
|
@@ -5350,6 +5370,20 @@ interface ImMediaTask {
|
|
|
5350
5370
|
* ```
|
|
5351
5371
|
*/
|
|
5352
5372
|
interface ImMediaTasksApi {
|
|
5373
|
+
/** 清除当前账号完整媒体缓存及下载断点;保留消息、草稿、上传源和已交付的播放资源,在途下载仍可完成。 */
|
|
5374
|
+
clearCache: () => Promise<void>;
|
|
5375
|
+
/**
|
|
5376
|
+
* 按输入顺序查询完整本机媒体是否可用;不下载、不读取 Blob、不续缓存期限或创建任务。
|
|
5377
|
+
* 仅支持图片/视频(含媒体合集);未配置持久缓存时只检查内存。
|
|
5378
|
+
* @throws 不支持轻量查询或存储读取失败时明确拒绝,不伪装成未命中。
|
|
5379
|
+
* @example const [available] = await client.media.probeCached([messageRef])
|
|
5380
|
+
*/
|
|
5381
|
+
probeCached: (messages: readonly ImMessageRef[]) => Promise<readonly boolean[]>;
|
|
5382
|
+
/**
|
|
5383
|
+
* 缓存写入、清理或过期后通知消费者重新查询;账号销毁后自动退订。
|
|
5384
|
+
* @example const stop = client.media.subscribeCacheChanges(() => refreshVisibleMedia())
|
|
5385
|
+
*/
|
|
5386
|
+
subscribeCacheChanges: (listener: () => void) => () => void;
|
|
5353
5387
|
/**
|
|
5354
5388
|
* 返回当前账号全部活跃任务与近期终态任务的冻结快照;总量超过 128 时只淘汰终态,极端并发活跃可暂时超过上限。
|
|
5355
5389
|
* @throws runtime 已 logout/dispose 时抛 `IM_SDK_MEDIA_RUNTIME_INACTIVE`。
|
|
@@ -5364,7 +5398,10 @@ interface ImMediaTasksApi {
|
|
|
5364
5398
|
* 取消 queued/running 任务;上传委托 core,下载中止当前 AbortController。
|
|
5365
5399
|
* @throws 未知任务、非法状态或底层未受理时以稳定 `IM_SDK_MEDIA_TASK_*` 错误拒绝。
|
|
5366
5400
|
*/
|
|
5367
|
-
cancel: (taskId: string
|
|
5401
|
+
cancel: (taskId: string, options?: {
|
|
5402
|
+
/** 取消发送但保留已确认上传分片与原文件,只有用户显式重试才继续。默认取消仍清理。 */
|
|
5403
|
+
retainCheckpoint?: boolean;
|
|
5404
|
+
}) => Promise<void>;
|
|
5368
5405
|
/** 暂停上传,等待请求收尾后返回;下载不支持暂停。 */
|
|
5369
5406
|
pause: (taskId: string) => Promise<void>;
|
|
5370
5407
|
/** 恢复已暂停上传,复用同一原文件与消息。 */
|
|
@@ -5382,19 +5419,28 @@ interface ImMediaTasksApi {
|
|
|
5382
5419
|
/**
|
|
5383
5420
|
* 重试 failed/canceled 任务;上传复用保留原文件,下载重新解析同一精确消息引用。
|
|
5384
5421
|
* 续传不可用或清理未确认时,必须先征得用户同意重新上传,再传 restartUpload:true。
|
|
5385
|
-
*
|
|
5422
|
+
* 保留式取消后的重发复用已确认分片和原密钥;默认清理式取消不保证保有原文件。
|
|
5386
5423
|
* 下载取消已受理后即可创建新尝试,不复用旧取消 Promise;旧 loader 结束前仍占用并发槽,但不能覆盖新任务。
|
|
5387
5424
|
* @throws 原文件已淘汰、任务仍在途或消息/下载 capability 不可用时显式拒绝。
|
|
5388
5425
|
*/
|
|
5389
5426
|
retry: (taskId: string, options?: {
|
|
5390
5427
|
/** 用户已确认放弃旧进度并重新上传;仅上传任务接受,清理失败时仍停止。 */
|
|
5391
5428
|
restartUpload?: boolean;
|
|
5429
|
+
/** 下载断点已失效或超出缓存预算时,用户确认从头下载。 */
|
|
5430
|
+
restartDownload?: boolean;
|
|
5392
5431
|
}) => Promise<void>;
|
|
5393
5432
|
/**
|
|
5394
5433
|
* 下载并按消息正文合同解密,同一消息并发调用复用同一 Promise,成功返回 Blob。
|
|
5395
5434
|
* @throws 消息不存在/非媒体/无远端 URL/未装配 capability、传输失败、取消或 teardown 均以稳定错误拒绝,不返回空 Blob。
|
|
5396
5435
|
*/
|
|
5397
5436
|
download: (message: ImMessageRef) => Promise<Blob>;
|
|
5437
|
+
/**
|
|
5438
|
+
* 将最近预览的精确媒体项设为最高下载优先级,不新建或取消任务。
|
|
5439
|
+
* 下一空闲任务/分片请求名额优先给该项;已发请求不中断,关闭播放器不撤销优先级。
|
|
5440
|
+
* 后续调用替换上一个目标;账号退出后不可调用。
|
|
5441
|
+
* @example client.media.prioritizeDownload({ conversation, messageId, itemIndex: 1 })
|
|
5442
|
+
*/
|
|
5443
|
+
prioritizeDownload: (message: ImMessageRef) => void;
|
|
5398
5444
|
/**
|
|
5399
5445
|
* 仅读取当前账号内存或持久媒体资产缓存;命中返回 Blob,未缓存或类型未注册返回 `null`。
|
|
5400
5446
|
*
|
|
@@ -6192,6 +6238,7 @@ interface ImClientOptions {
|
|
|
6192
6238
|
/** 显式开启视频/文件跨刷新续传。最多 3 条、24 小时,保存加密密钥但不保存文件副本;注销清除。 */
|
|
6193
6239
|
uploadRecovery?: {
|
|
6194
6240
|
enabled: boolean;
|
|
6241
|
+
retainFailedUploads?: boolean;
|
|
6195
6242
|
};
|
|
6196
6243
|
}
|
|
6197
6244
|
/**
|
|
@@ -7080,6 +7127,7 @@ interface ChatRuntimeHostDeps {
|
|
|
7080
7127
|
/** 显式启用账号隔离的跨刷新恢复记录;保存密钥、不保存原文件,注销清除。 */
|
|
7081
7128
|
uploadRecovery?: {
|
|
7082
7129
|
enabled: boolean;
|
|
7130
|
+
retainFailedUploads?: boolean;
|
|
7083
7131
|
};
|
|
7084
7132
|
/** 获取 GIF provider 配置;API key 只留在宿主闭包与 SDK adapter,不进入共享 Store。 */
|
|
7085
7133
|
getExpressionOptions?: () => ImExpressionOptions | undefined;
|
|
@@ -7357,7 +7405,11 @@ interface ChatRuntime {
|
|
|
7357
7405
|
resolveMediaPreviewToRemote: (ref: ChatMediaMessageRef, contentType: 'image' | 'video' | 'sticker', byteSize?: number) => void;
|
|
7358
7406
|
/** 为指定消息取得本地媒体播放租约;没有本地缓存时返回 `undefined`,调用方应改用远端资源。 */
|
|
7359
7407
|
acquireMediaBlob: (ref: ChatMediaMessageRef) => MediaObjectUrlLease | undefined;
|
|
7408
|
+
/** 只读检查完整本地媒体是否可用,不取得租约、不改变缓存淘汰顺序。 */
|
|
7409
|
+
hasMediaBlob: (ref: ChatMediaMessageRef) => boolean;
|
|
7360
7410
|
/** 撤销当前账号创建的全部媒体预览地址并释放 Blob 内存,切账号、退出或销毁时调用。 */
|
|
7411
|
+
/** 清理当前账号完整媒体缓存和下载断点;上传源保留,正在使用的播放地址在释放后才撤销。 */
|
|
7412
|
+
clearMediaCache: () => Promise<void>;
|
|
7361
7413
|
cleanupLocalMediaBlobs: () => void;
|
|
7362
7414
|
/** 删除会话时释放该会话绑定的本地媒体预览/播放缓存。 */
|
|
7363
7415
|
cleanupConversationMediaBlobs: (conversation: ConversationRef<'direct' | 'group' | 'channel' | 'robot'>) => void;
|
|
@@ -7739,6 +7791,12 @@ type GifFileClassification = 'gif' | 'not-gif' | 'invalid-gif';
|
|
|
7739
7791
|
declare function classifyGifFile(file: Blob): Promise<GifFileClassification>;
|
|
7740
7792
|
declare function isGifFile(file: Blob): Promise<boolean>;
|
|
7741
7793
|
|
|
7794
|
+
/**
|
|
7795
|
+
* 将用户最后预览的媒体项交给 SDK 提高下载优先级,不创建任务或持有页面资源。
|
|
7796
|
+
* 在异步查缓存、加载 URL 之前调用,重复打开已有下载也会更新优先级。
|
|
7797
|
+
* @example mediaService.prioritizeMediaDownload(runtime, message, 1)
|
|
7798
|
+
*/
|
|
7799
|
+
declare function prioritizeMediaDownload(runtime: ChatRuntime, message: ImMessageView, itemIndex?: number): void;
|
|
7742
7800
|
/**
|
|
7743
7801
|
* 为宿主手里的本地图片/视频文件预读展示元信息(尺寸、视频时长、视频首帧封面 JPEG 字节)。
|
|
7744
7802
|
*
|
|
@@ -7802,7 +7860,7 @@ declare function loadCachedVideoObjectUrl(runtime: ChatRuntime, message: ImMessa
|
|
|
7802
7860
|
* 同一条门槛),不把无效二进制交给 `<img>`。
|
|
7803
7861
|
*
|
|
7804
7862
|
* 返回 `null` 表示下标越界、正文不是合集、内容非法或下载失败,失败原因经 `setNote` 反馈。
|
|
7805
|
-
*
|
|
7863
|
+
* **唯一不反馈的失败是用户自己取消**(点击停止按钮取消这一项的在途下载):同样返回 `null`,但不提示。
|
|
7806
7864
|
* **调用方在不再使用地址时必须 `URL.revokeObjectURL`。**
|
|
7807
7865
|
*/
|
|
7808
7866
|
declare function loadMediaAlbumItemObjectUrl(runtime: ChatRuntime, message: ImMessageView, itemIndex: number, hooks: ServiceNoteHooks, onProgress?: (percent: number) => void): Promise<string | null>;
|
|
@@ -7847,6 +7905,7 @@ declare const media_service_loadMediaAlbumItemObjectUrl: typeof loadMediaAlbumIt
|
|
|
7847
7905
|
declare const media_service_loadVideoObjectUrl: typeof loadVideoObjectUrl;
|
|
7848
7906
|
declare const media_service_loadVoiceBytes: typeof loadVoiceBytes;
|
|
7849
7907
|
declare const media_service_prepareLocalMediaPreview: typeof prepareLocalMediaPreview;
|
|
7908
|
+
declare const media_service_prioritizeMediaDownload: typeof prioritizeMediaDownload;
|
|
7850
7909
|
declare namespace media_service {
|
|
7851
7910
|
export {
|
|
7852
7911
|
media_service_acquireMediaBlob as acquireMediaBlob,
|
|
@@ -7861,6 +7920,7 @@ declare namespace media_service {
|
|
|
7861
7920
|
media_service_loadVideoObjectUrl as loadVideoObjectUrl,
|
|
7862
7921
|
media_service_loadVoiceBytes as loadVoiceBytes,
|
|
7863
7922
|
media_service_prepareLocalMediaPreview as prepareLocalMediaPreview,
|
|
7923
|
+
media_service_prioritizeMediaDownload as prioritizeMediaDownload,
|
|
7864
7924
|
};
|
|
7865
7925
|
}
|
|
7866
7926
|
|
|
@@ -8503,7 +8563,7 @@ declare function cancelMediaUpload(runtime: ChatRuntime, messageId: string, hook
|
|
|
8503
8563
|
/**
|
|
8504
8564
|
* 重试当前线程中的一条失败消息。
|
|
8505
8565
|
*
|
|
8506
|
-
*
|
|
8566
|
+
* 上传失败及保留式取消时尝试续传;restartUpload 只接受宿主明确确认后的完整重传。
|
|
8507
8567
|
* 已经完成媒体上传但消息发送失败,或普通文本失败时,重试
|
|
8508
8568
|
* SDK 待发送队列。两种路径都复用原消息 ID,不新增气泡。只有账号未变化且 SDK 接受重试时返回 `true`。
|
|
8509
8569
|
*/
|
|
@@ -9181,6 +9241,32 @@ declare function formatFileSize(bytes: number): string;
|
|
|
9181
9241
|
*/
|
|
9182
9242
|
declare function getFileExtension(fileName: string): string;
|
|
9183
9243
|
|
|
9244
|
+
/** 列表和预览共用的传输展示;不持有任务、网络请求或页面资源。 */
|
|
9245
|
+
interface MediaTransferPresentation {
|
|
9246
|
+
/** 取消上传作用于整条消息,取消下载只作用于当前项。 */
|
|
9247
|
+
direction: 'upload' | 'download';
|
|
9248
|
+
/** completed 只保留视频时长,其余状态由宿主渲染同一胶囊。 */
|
|
9249
|
+
state: 'waiting' | 'running' | 'paused' | 'failed' | 'completed';
|
|
9250
|
+
/** 真实字节可计算时才提供百分比,缺少大小时不能用等权平均替代。 */
|
|
9251
|
+
percent?: number;
|
|
9252
|
+
/** 当前正在核对完整缓存;宿主暂不把 waiting 显示为确定的下载入口。 */
|
|
9253
|
+
resolving?: boolean;
|
|
9254
|
+
}
|
|
9255
|
+
/** 从 SDK 快照投影某一媒体格,折叠格按固定范围内全部项的字节数加权。 */
|
|
9256
|
+
declare function resolveMediaTransferPresentation(input: {
|
|
9257
|
+
message: ImMessageView;
|
|
9258
|
+
uploadTask?: ImMediaTask;
|
|
9259
|
+
downloadTasks: readonly ImMediaTask[];
|
|
9260
|
+
itemIndex?: number;
|
|
9261
|
+
aggregateFrom?: number;
|
|
9262
|
+
/** 宿主确实持有的完整本地资源;单条媒体以 undefined 表示,缩略图不属于完整资源。 */
|
|
9263
|
+
availableItemIndices?: readonly (number | undefined)[];
|
|
9264
|
+
/** SDK 明确查到完整缓存已不存在;历史 completed 任务不能替代当前资源证据。 */
|
|
9265
|
+
unavailableItemIndices?: readonly (number | undefined)[];
|
|
9266
|
+
/** 当前窗口正在查询的媒体项,不表示未下载。 */
|
|
9267
|
+
pendingItemIndices?: readonly (number | undefined)[];
|
|
9268
|
+
}): MediaTransferPresentation;
|
|
9269
|
+
|
|
9184
9270
|
/**
|
|
9185
9271
|
* 消息正文中由 Chat Kit 额外识别的可渲染片段类型。
|
|
9186
9272
|
*
|
|
@@ -9282,5 +9368,5 @@ declare function resampleWaveform(data: readonly number[], targetCount: number):
|
|
|
9282
9368
|
*/
|
|
9283
9369
|
declare function placeholderWaveform(seed: string, count: number): number[];
|
|
9284
9370
|
|
|
9285
|
-
export { DEFAULT_EMOJI_ASSET_BASE, DEFAULT_LOADING_MINIMUM_VISIBLE_MS, DEFAULT_LOADING_SHOW_DELAY_MS, EMOJI_CATALOG, EMOJI_GAME_DICE_STABLE_KEY, EMOJI_GAME_RPS_STABLE_KEY, EMOJI_TOKEN_RE, MAX_BATCH_FILES, MAX_RECENT_EMOJI_COUNT, MINI_PROGRAM_GAME_PREVIEW_FALLBACK_HEIGHT, MINI_PROGRAM_GAME_PREVIEW_FALLBACK_WIDTH, MINI_PROGRAM_LANG_NUMBERS, SPIKE_STEP, UNICODE_EMOJI_CATALOG, blockReasonForChannelSession, blockReasonForChannelState, blockReasonForGroupState, blockReasonForSession, calculateMediaBox, canCopyMessageImage, canEditMessage, canPinChannelMessage, canPinGroupMessage, canPinMessage, canPromoteMediaPresentationSource, canRecallMessage, canTransmit, canTransmitByType, canTransmitContent, cancelMediaUpload, captureRuntimeClientOperation, captureRuntimeOperation, channelMiniProgramRelKey, classifyGifFile, classifyMediaFile, countUnreadConversations, createChatRuntime, createConversationPrefetchController, createDelayedLoadingIndicator, createEmojiMatcher, createLinkMatcher, createMessageImageCopySource, createNewMessageBadgeController, createThreadItems, csvIncludes, decideChannelMiniProgramRelOpen, decideConversationAction, decideMemberTargetAction, decideMessageAction, emojiAssetUrl, emojiUrlByCode, fetchConversationFileBatch, fetchConversationImageBatch, fetchConversationMessageBatch, fetchConversationVideoBatch, fetchConversationVoiceBatch, fetchNextConversationSearchBatch, formatChatDateSeparator, formatConversationDisplayTime, formatConversationUnreadBadge, formatFileSize, formatMediaDuration, forward_service as forwardService, getFileExtension, getLocalDayKey, getMessageCopyImageUrl, getMessageCopyText, hasEmojiCandidate, hasLinkCandidate, highlightSegments, isGifFile, isMessageLocateScrollProtected, isMessageTailChangeFromOlderWindowTrim, isMessageViewportMeasurable, isMessageVisibleForNewMessageBadge, isMiniProgramShowTypeOpenable, isPinnedMessageProtected, isVoiceStorageConfigured, loadOlderUntilBoundary, mediaBatchBudgetBytes, media_service as mediaService, message_service as messageService, normalizeLinkHref, parseUnicodeEmojiCode, pinnedMessage_service as pinnedMessageService, placeholderWaveform, prependRecentEmoji, profile_service as profileService, read_service as readService, refreshPrependMessageAnchorPosition, replaceInterruptedMediaFile, requiresConversationEncryption, requiresForwardTypeConfirmation, resampleWaveform, resolveBestMediaPresentationSource, resolveCenteredMessageScrollTop, resolveChannelMemberAvatarUrl, resolveChannelMemberDisplayName, resolveChannelMiniProgramRelIcon, resolveChannelMiniProgramRelName, resolveChannelMiniProgramRelOpenSurface, resolveChannelMiniProgramRelUrl, resolveChannelPinnedGameCopy, resolveConversationListPresentation, resolveDisplayTimestamp, resolveEmojiToken, resolveFriendDisplayName, resolveImProfileAccessDestination, resolveImThreadActiveDate, resolveMediaPresentation, resolveMemberDisplayName, resolveMessageBodyKind, resolveMessageNotificationDecision, resolveMessageTimelineTimestamp, resolveMiniProgramFloatLinkUrl, resolveMiniProgramGamePreviewLayout, resolveMiniProgramOpenUrl, resolvePrependMessageAnchor, resolvePrependMessageAnchorAdjustment, resolvePrependMessageAnchorPosition, resolvePublicNickname, resolveQuotedMessagePresentation, resolveSenderAvatarUrl, resolveStandaloneEmojiMessage, resolveSurvivingMessageAnchorAdjustment, resolveUnicodeEmoji, resolveVisibleChannelMiniProgramRels, resolveVisibleMessageAnchorPositions, retryMessage, runMediaSendBatch, sendAsFilesBatch, sendBlockReasonForDecision, sendMediaAlbum, sendMediaFile, sendMediaFilesBatch, sendText, sendVoice, shouldCompleteInitialViewport, shouldFillInitialHistoryViewport, shouldFollowIncomingMessage, shouldLoadNewerHistoryPage, shouldPrefetchOlderHistory, shouldRestoreMessageViewportFocus, shouldShowChatDateSeparator, shouldTrackRemoteMessageForBadge, sortChannelMiniProgramFloatingItems, spikeCountForDuration, supportsConversationMention, unicodeEmojiTextFromCode };
|
|
9286
|
-
export type { ApplySessionResult, BrowseMessagesInput, CanPinMessageInput, CenteredMessageScrollInput, ChannelMiniProgramOpenGame, ChannelMiniProgramRelOpenDecision, ChannelMiniProgramRelOpenSurface, ChatMediaMessageRef, ChatProfileAdapter, ChatRuntime, ChatRuntimeCredentials, ChatRuntimeFactories, ChatRuntimeHostDeps, ChatRuntimeOpResult, ConversationCapabilityAction, ConversationListPresentation, ConversationListPresentationLabels, ConversationListPresentationOptions, ConversationListPreviewMediaKind, ConversationListPreviewSegment, ConversationPrefetchController, ConversationPrefetchControllerOptions, ConversationSearchCategory, CreateThreadItemsInput, DelayedLoadingIndicator, DelayedLoadingIndicatorOptions, EmojiEntry, EmojiRecentItem, EmojiSegment, FormatTimeDisplayContext, ForwardCommandHooks, GifFileClassification, HighlightSegment, ImChannelMemberPresentation, ImChannelMentionPresentation, ImChannelProfilePresentation, ImForwardOperationResult, ImGroupMemberPresentation, ImMediaBatchSendResult, ImMessageActionResult, ImMessageBodyKind, ImMessageView, ImPinnedMessageActionResult, ImPinnedMessageSnapshot, ImProfileAccessDestination, ImQuotedMessagePresentation, ImTextResolver, ImThreadActiveDateSnapshot, ImThreadDateMarkerMetric, ImThreadDecoration, ImThreadEncryptionItem, ImThreadIntent, ImThreadItem, ImThreadPresentationAdapter, ImThreadReadActions, ImThreadReadTargetResolver, ImThreadViewportMetrics, IncomingMessageFollowInput, InitialHistoryViewportFillInput, InitialViewportCompletionInput, LinkSegment, MediaBatchBudgetOptions, MediaBatchLimitInfo, MediaFileClassification, MediaLimitItem, MediaObjectUrlLease, MediaPresentationFit, MediaPresentationPolicy, MediaPresentationRule, MediaPresentationSourceCandidate, MediaPresentationSourceQuality, MediaSendBatchResult, MemberTargetCapabilityAction, MemberTargetCapabilityInput, MessageCapabilityAction, MessageCapabilityInput, MessageLocateScrollProtectionInput, MessageNotificationDecision, MessageNotificationInput, MiniProgramGamePreviewInput, MiniProgramGamePreviewLayout, MiniProgramHostLocale, MiniProgramOpenUrlInput, NewMessageBadgeController, NewMessageBadgeCountListener, NewMessageBadgeVisibilityInput, NewerHistoryPageTriggerInput, OlderHistoryPrefetchInput, PrependAnchorCandidate, PrependAnchorViewport, PrependMessageAnchorPosition, RemoteMessageBadgeTrackingInput, ResolveMediaPresentationInput, ResolvedMediaPresentation, RichExtraSegment, RuntimeClientOperation, RuntimeOperation, SearchBatchResult, SearchFilesInput, SearchMessagesInput, SearchTextMessagesInput, SendCapabilityMode, SendCommandHooks, SendVoicePayload, SenderProfileEntry, ServiceNoteHooks, StandaloneEmojiMessage, UnicodeEmojiEntry, VisibleChannelMiniProgramRels };
|
|
9371
|
+
export { DEFAULT_EMOJI_ASSET_BASE, DEFAULT_LOADING_MINIMUM_VISIBLE_MS, DEFAULT_LOADING_SHOW_DELAY_MS, EMOJI_CATALOG, EMOJI_GAME_DICE_STABLE_KEY, EMOJI_GAME_RPS_STABLE_KEY, EMOJI_TOKEN_RE, MAX_BATCH_FILES, MAX_RECENT_EMOJI_COUNT, MINI_PROGRAM_GAME_PREVIEW_FALLBACK_HEIGHT, MINI_PROGRAM_GAME_PREVIEW_FALLBACK_WIDTH, MINI_PROGRAM_LANG_NUMBERS, SPIKE_STEP, UNICODE_EMOJI_CATALOG, blockReasonForChannelSession, blockReasonForChannelState, blockReasonForGroupState, blockReasonForSession, calculateMediaBox, canCopyMessageImage, canEditMessage, canPinChannelMessage, canPinGroupMessage, canPinMessage, canPromoteMediaPresentationSource, canRecallMessage, canTransmit, canTransmitByType, canTransmitContent, cancelMediaUpload, captureRuntimeClientOperation, captureRuntimeOperation, channelMiniProgramRelKey, classifyGifFile, classifyMediaFile, countUnreadConversations, createChatRuntime, createConversationPrefetchController, createDelayedLoadingIndicator, createEmojiMatcher, createLinkMatcher, createMessageImageCopySource, createNewMessageBadgeController, createThreadItems, csvIncludes, decideChannelMiniProgramRelOpen, decideConversationAction, decideMemberTargetAction, decideMessageAction, emojiAssetUrl, emojiUrlByCode, fetchConversationFileBatch, fetchConversationImageBatch, fetchConversationMessageBatch, fetchConversationVideoBatch, fetchConversationVoiceBatch, fetchNextConversationSearchBatch, formatChatDateSeparator, formatConversationDisplayTime, formatConversationUnreadBadge, formatFileSize, formatMediaDuration, forward_service as forwardService, getFileExtension, getLocalDayKey, getMessageCopyImageUrl, getMessageCopyText, hasEmojiCandidate, hasLinkCandidate, highlightSegments, isGifFile, isMessageLocateScrollProtected, isMessageTailChangeFromOlderWindowTrim, isMessageViewportMeasurable, isMessageVisibleForNewMessageBadge, isMiniProgramShowTypeOpenable, isPinnedMessageProtected, isVoiceStorageConfigured, loadOlderUntilBoundary, mediaBatchBudgetBytes, media_service as mediaService, message_service as messageService, normalizeLinkHref, parseUnicodeEmojiCode, pinnedMessage_service as pinnedMessageService, placeholderWaveform, prependRecentEmoji, profile_service as profileService, read_service as readService, refreshPrependMessageAnchorPosition, replaceInterruptedMediaFile, requiresConversationEncryption, requiresForwardTypeConfirmation, resampleWaveform, resolveBestMediaPresentationSource, resolveCenteredMessageScrollTop, resolveChannelMemberAvatarUrl, resolveChannelMemberDisplayName, resolveChannelMiniProgramRelIcon, resolveChannelMiniProgramRelName, resolveChannelMiniProgramRelOpenSurface, resolveChannelMiniProgramRelUrl, resolveChannelPinnedGameCopy, resolveConversationListPresentation, resolveDisplayTimestamp, resolveEmojiToken, resolveFriendDisplayName, resolveImProfileAccessDestination, resolveImThreadActiveDate, resolveMediaPresentation, resolveMediaTransferPresentation, resolveMemberDisplayName, resolveMessageBodyKind, resolveMessageNotificationDecision, resolveMessageTimelineTimestamp, resolveMiniProgramFloatLinkUrl, resolveMiniProgramGamePreviewLayout, resolveMiniProgramOpenUrl, resolvePrependMessageAnchor, resolvePrependMessageAnchorAdjustment, resolvePrependMessageAnchorPosition, resolvePublicNickname, resolveQuotedMessagePresentation, resolveSenderAvatarUrl, resolveStandaloneEmojiMessage, resolveSurvivingMessageAnchorAdjustment, resolveUnicodeEmoji, resolveVisibleChannelMiniProgramRels, resolveVisibleMessageAnchorPositions, retryMessage, runMediaSendBatch, sendAsFilesBatch, sendBlockReasonForDecision, sendMediaAlbum, sendMediaFile, sendMediaFilesBatch, sendText, sendVoice, shouldCompleteInitialViewport, shouldFillInitialHistoryViewport, shouldFollowIncomingMessage, shouldLoadNewerHistoryPage, shouldPrefetchOlderHistory, shouldRestoreMessageViewportFocus, shouldShowChatDateSeparator, shouldTrackRemoteMessageForBadge, sortChannelMiniProgramFloatingItems, spikeCountForDuration, supportsConversationMention, unicodeEmojiTextFromCode };
|
|
9372
|
+
export type { ApplySessionResult, BrowseMessagesInput, CanPinMessageInput, CenteredMessageScrollInput, ChannelMiniProgramOpenGame, ChannelMiniProgramRelOpenDecision, ChannelMiniProgramRelOpenSurface, ChatMediaMessageRef, ChatProfileAdapter, ChatRuntime, ChatRuntimeCredentials, ChatRuntimeFactories, ChatRuntimeHostDeps, ChatRuntimeOpResult, ConversationCapabilityAction, ConversationListPresentation, ConversationListPresentationLabels, ConversationListPresentationOptions, ConversationListPreviewMediaKind, ConversationListPreviewSegment, ConversationPrefetchController, ConversationPrefetchControllerOptions, ConversationSearchCategory, CreateThreadItemsInput, DelayedLoadingIndicator, DelayedLoadingIndicatorOptions, EmojiEntry, EmojiRecentItem, EmojiSegment, FormatTimeDisplayContext, ForwardCommandHooks, GifFileClassification, HighlightSegment, ImChannelMemberPresentation, ImChannelMentionPresentation, ImChannelProfilePresentation, ImForwardOperationResult, ImGroupMemberPresentation, ImMediaBatchSendResult, ImMessageActionResult, ImMessageBodyKind, ImMessageView, ImPinnedMessageActionResult, ImPinnedMessageSnapshot, ImProfileAccessDestination, ImQuotedMessagePresentation, ImTextResolver, ImThreadActiveDateSnapshot, ImThreadDateMarkerMetric, ImThreadDecoration, ImThreadEncryptionItem, ImThreadIntent, ImThreadItem, ImThreadPresentationAdapter, ImThreadReadActions, ImThreadReadTargetResolver, ImThreadViewportMetrics, IncomingMessageFollowInput, InitialHistoryViewportFillInput, InitialViewportCompletionInput, LinkSegment, MediaBatchBudgetOptions, MediaBatchLimitInfo, MediaFileClassification, MediaLimitItem, MediaObjectUrlLease, MediaPresentationFit, MediaPresentationPolicy, MediaPresentationRule, MediaPresentationSourceCandidate, MediaPresentationSourceQuality, MediaSendBatchResult, MediaTransferPresentation, MemberTargetCapabilityAction, MemberTargetCapabilityInput, MessageCapabilityAction, MessageCapabilityInput, MessageLocateScrollProtectionInput, MessageNotificationDecision, MessageNotificationInput, MiniProgramGamePreviewInput, MiniProgramGamePreviewLayout, MiniProgramHostLocale, MiniProgramOpenUrlInput, NewMessageBadgeController, NewMessageBadgeCountListener, NewMessageBadgeVisibilityInput, NewerHistoryPageTriggerInput, OlderHistoryPrefetchInput, PrependAnchorCandidate, PrependAnchorViewport, PrependMessageAnchorPosition, RemoteMessageBadgeTrackingInput, ResolveMediaPresentationInput, ResolvedMediaPresentation, RichExtraSegment, RuntimeClientOperation, RuntimeOperation, SearchBatchResult, SearchFilesInput, SearchMessagesInput, SearchTextMessagesInput, SendCapabilityMode, SendCommandHooks, SendVoicePayload, SenderProfileEntry, ServiceNoteHooks, StandaloneEmojiMessage, UnicodeEmojiEntry, VisibleChannelMiniProgramRels };
|
package/dist/chat-kit.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{q as DEFAULT_LOADING_MINIMUM_VISIBLE_MS,p as DEFAULT_LOADING_SHOW_DELAY_MS,v as MINI_PROGRAM_GAME_PREVIEW_FALLBACK_HEIGHT,u as MINI_PROGRAM_GAME_PREVIEW_FALLBACK_WIDTH,e as MINI_PROGRAM_LANG_NUMBERS,
|
|
1
|
+
export{q as DEFAULT_LOADING_MINIMUM_VISIBLE_MS,p as DEFAULT_LOADING_SHOW_DELAY_MS,v as MINI_PROGRAM_GAME_PREVIEW_FALLBACK_HEIGHT,u as MINI_PROGRAM_GAME_PREVIEW_FALLBACK_WIDTH,e as MINI_PROGRAM_LANG_NUMBERS,R as SPIKE_STEP,M as calculateMediaBox,C as canCopyMessageImage,t as canPromoteMediaPresentationSource,z as captureRuntimeClientOperation,y as captureRuntimeOperation,n as channelMiniProgramRelKey,x as createConversationPrefetchController,r as createDelayedLoadingIndicator,K as createLinkMatcher,D as createMessageImageCopySource,f as csvIncludes,d as decideChannelMiniProgramRelOpen,O as formatFileSize,N as formatMediaDuration,P as getFileExtension,B as getMessageCopyImageUrl,A as getMessageCopyText,J as hasLinkCandidate,H as highlightSegments,a as isMiniProgramShowTypeOpenable,E as mediaService,I as normalizeLinkHref,U as placeholderWaveform,F as readService,T as resampleWaveform,s as resolveBestMediaPresentationSource,h as resolveChannelMiniProgramRelIcon,g as resolveChannelMiniProgramRelName,j as resolveChannelMiniProgramRelOpenSurface,i as resolveChannelMiniProgramRelUrl,k as resolveChannelPinnedGameCopy,o as resolveConversationListPresentation,L as resolveMediaPresentation,Q as resolveMediaTransferPresentation,c as resolveMiniProgramFloatLinkUrl,w as resolveMiniProgramGamePreviewLayout,b as resolveMiniProgramOpenUrl,G as resolveQuotedMessagePresentation,m as resolveVisibleChannelMiniProgramRels,l as sortChannelMiniProgramFloatingItems,S as spikeCountForDuration}from'./chunk-ITOAFWZU.js';export{j as DEFAULT_EMOJI_ASSET_BASE,i as EMOJI_CATALOG,c as EMOJI_GAME_DICE_STABLE_KEY,b as EMOJI_GAME_RPS_STABLE_KEY,m as EMOJI_TOKEN_RE,N as MAX_BATCH_FILES,a as MAX_RECENT_EMOJI_COUNT,g as UNICODE_EMOJI_CATALOG,M as blockReasonForChannelSession,L as blockReasonForChannelState,T as blockReasonForGroupState,W as blockReasonForSession,G as canEditMessage,w as canPinChannelMessage,v as canPinGroupMessage,x as canPinMessage,F as canRecallMessage,da as cancelMediaUpload,R as classifyGifFile,Q as classifyMediaFile,s as countUnreadConversations,u as createChatRuntime,p as createEmojiMatcher,I as decideConversationAction,K as decideMemberTargetAction,J as decideMessageAction,l as emojiAssetUrl,n as emojiUrlByCode,Da as fetchConversationFileBatch,Ea as fetchConversationImageBatch,Ba as fetchConversationMessageBatch,Fa as fetchConversationVideoBatch,Ga as fetchConversationVoiceBatch,Ha as fetchNextConversationSearchBatch,r as formatConversationUnreadBadge,ga as forwardService,o as hasEmojiCandidate,S as isGifFile,y as isPinnedMessageProtected,_ as isVoiceStorageConfigured,O as mediaBatchBudgetBytes,la as messageService,e as parseUnicodeEmojiCode,qa as pinnedMessageService,d as prependRecentEmoji,Aa as profileService,Z as replaceInterruptedMediaFile,U as requiresConversationEncryption,B as resolveChannelMemberAvatarUrl,A as resolveChannelMemberDisplayName,k as resolveEmojiToken,E as resolveFriendDisplayName,ra as resolveImProfileAccessDestination,z as resolveMemberDisplayName,t as resolveMessageNotificationDecision,D as resolvePublicNickname,C as resolveSenderAvatarUrl,q as resolveStandaloneEmojiMessage,h as resolveUnicodeEmoji,ea as retryMessage,P as runMediaSendBatch,ca as sendAsFilesBatch,H as sendBlockReasonForDecision,aa as sendMediaAlbum,Y as sendMediaFile,ba as sendMediaFilesBatch,X as sendText,$ as sendVoice,V as supportsConversationMention,f as unicodeEmojiTextFromCode}from'./chunk-3ST5E6YS.js';export{C as createNewMessageBadgeController,i as createThreadItems,f as formatChatDateSeparator,e as formatConversationDisplayTime,c as getLocalDayKey,l as isMessageLocateScrollProtected,v as isMessageTailChangeFromOlderWindowTrim,k as isMessageViewportMeasurable,B as isMessageVisibleForNewMessageBadge,x as loadOlderUntilBoundary,p as refreshPrependMessageAnchorPosition,j as resolveCenteredMessageScrollTop,a as resolveDisplayTimestamp,g as resolveImThreadActiveDate,h as resolveMessageBodyKind,b as resolveMessageTimelineTimestamp,n as resolvePrependMessageAnchor,q as resolvePrependMessageAnchorAdjustment,o as resolvePrependMessageAnchorPosition,s as resolveSurvivingMessageAnchorAdjustment,r as resolveVisibleMessageAnchorPositions,t as shouldCompleteInitialViewport,y as shouldFillInitialHistoryViewport,u as shouldFollowIncomingMessage,z as shouldLoadNewerHistoryPage,m as shouldPrefetchOlderHistory,w as shouldRestoreMessageViewportFocus,d as shouldShowChatDateSeparator,A as shouldTrackRemoteMessageForBadge}from'./chunk-HWA7NOXG.js';import'./chunk-GHFHAGJ7.js';import'./chunk-LMP34HNC.js';import'./chunk-ZERTVCH2.js';export{va as canTransmit,ta as canTransmitByType,ua as canTransmitContent,sa as requiresForwardTypeConfirmation}from'./chunk-4I23ADH2.js';import'./chunk-WOT6VMZA.js';
|