k2-im 0.1.29 → 0.1.30
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 +78 -7
- package/dist/chat-kit-pinia.js +1 -1
- package/dist/chat-kit-vue.d.ts +17 -7
- package/dist/chat-kit-vue.js +1 -1
- package/dist/chat-kit.d.ts +126 -9
- package/dist/chat-kit.js +1 -1
- package/dist/chunk-37HOEWMF.js +1 -0
- package/dist/chunk-4KPJTXQN.js +2 -0
- package/dist/chunk-GHZUH7RB.js +7 -0
- package/dist/chunk-MNWNUGIV.js +2 -0
- package/dist/{chunk-BZFBUHDE.js → chunk-SLFKCTEX.js} +1 -1
- package/dist/chunk-VRGWQLDM.js +1 -0
- package/dist/chunk-XA4W5PWT.js +2 -0
- package/dist/i18n.d.ts +1 -1
- package/dist/i18n.js +1 -1
- package/dist/index.d.ts +128 -10
- package/dist/index.js +1 -1
- package/dist/sdk.d.ts +34 -5
- package/dist/sdk.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-AFLOPH2O.js +0 -1
- package/dist/chunk-AULYARAI.js +0 -2
- package/dist/chunk-HZD2QAZB.js +0 -2
- package/dist/chunk-R6BJQWPW.js +0 -1
- package/dist/chunk-TKWU3IO7.js +0 -7
- package/dist/chunk-XICYFDN4.js +0 -2
package/dist/chat-kit-vue.d.ts
CHANGED
|
@@ -1153,10 +1153,11 @@ interface MediaTransferAdapterConfig {
|
|
|
1153
1153
|
*/
|
|
1154
1154
|
rangeDownload?: boolean;
|
|
1155
1155
|
/**
|
|
1156
|
-
* 媒体发送阶段的并发上限;由 im-core
|
|
1156
|
+
* 媒体发送阶段的并发上限;由 im-core 消费,限制媒体任务数而非分片请求数。
|
|
1157
1157
|
*
|
|
1158
|
-
*
|
|
1159
|
-
* 缺省 5
|
|
1158
|
+
* 并发按媒体体积分两档:不超过分片阈值(16 MiB)的非视频媒体走小文件档,
|
|
1159
|
+
* 缺省 5;视频与超过阈值(或字节数未知)的内容走大文件档,缺省 3。
|
|
1160
|
+
* 分档只限制媒体任务数;实际 PUT/UploadPart 另受 adapter 的六路数据请求限制。
|
|
1160
1161
|
* 两档都只接受 1-6 的整数,超出范围由 core 显式报错。
|
|
1161
1162
|
* - 传一个数字:所有媒体共用这一个并发数,与分档前的语义一致。
|
|
1162
1163
|
* - 传 `{ total, largeFiles }`:显式分档,`largeFiles` 不得超过 `total`。
|
|
@@ -1452,7 +1453,7 @@ interface ImHostEnvironment {
|
|
|
1452
1453
|
getSession?: () => ImHostSession | null;
|
|
1453
1454
|
/** 清除宿主自己的登录态;Chat Kit 完成 IM 退出后,由页面按产品流程调用。 */
|
|
1454
1455
|
clearSession: () => void;
|
|
1455
|
-
/**
|
|
1456
|
+
/** 返回当前页面的稳定设备标识;服务端仍可能按 clientType 互踢,多页面互斥由 SDK 负责。 */
|
|
1456
1457
|
getDeviceToken: () => string;
|
|
1457
1458
|
/** 返回实时消息 WebSocket 地址和 IM 业务 HTTP 地址;缺失或非法时连接会明确失败。 */
|
|
1458
1459
|
getEndpoints: () => {
|
|
@@ -1776,6 +1777,12 @@ interface ThreadVisibilityTargetsOptions<TItem> {
|
|
|
1776
1777
|
onRevealed?: (item: TItem) => void;
|
|
1777
1778
|
/** 轻量资源在进入视口前多少像素开始准备;不会扩大稳定可见或高清缓存读取范围。 */
|
|
1778
1779
|
revealMarginPx?: number;
|
|
1780
|
+
/** 停稳后允许 cache-only 工作提前准备的上下近邻距离;不代表实际可见,默认 0。 */
|
|
1781
|
+
preloadMarginPx?: number;
|
|
1782
|
+
/** 预加载候选数量上限;可见目标优先,再按距视口中心的距离排序,默认不限制。 */
|
|
1783
|
+
maxPreloadTargets?: number;
|
|
1784
|
+
/** 停稳并驻留后报告可见与近邻候选;开始滚动、注销或释放时撤回对应候选。 */
|
|
1785
|
+
onSettledPreloadChange?: (items: readonly TItem[]) => void;
|
|
1779
1786
|
/** 用户开始或停止滚动时触发;宿主可据此暂停高频占位动画。 */
|
|
1780
1787
|
onScrollingChange?: (scrolling: boolean) => void;
|
|
1781
1788
|
/** 节点在滚动停止后仍可见时首次触发,适合安排 cache-only 读取。 */
|
|
@@ -1803,10 +1810,11 @@ interface ThreadVisibilityTargets<TItem> {
|
|
|
1803
1810
|
}
|
|
1804
1811
|
type ThreadVisibilityTargetsFactory<TItem> = (options: ThreadVisibilityTargetsOptions<TItem>) => ThreadVisibilityTargets<TItem>;
|
|
1805
1812
|
/**
|
|
1806
|
-
* 管理 Thread Surface
|
|
1813
|
+
* 管理 Thread Surface 子节点的揭示、稳定可见与缓存近邻候选。
|
|
1807
1814
|
*
|
|
1808
|
-
*
|
|
1809
|
-
*
|
|
1815
|
+
* 首次进入揭示范围立即准备轻量资源;滚动停止并持续可见后才激活较重工作。
|
|
1816
|
+
* 可选近邻回调允许宿主提前安排 cache-only 读取,但不会授予离屏节点可见或激活状态。
|
|
1817
|
+
* IntersectionObserver 不可用时仍按真实几何计算,不会把整个消息窗口误判为可见。
|
|
1810
1818
|
*/
|
|
1811
1819
|
declare function createThreadVisibilityTargets<TItem>(options: ThreadVisibilityTargetsOptions<TItem>): ThreadVisibilityTargets<TItem>;
|
|
1812
1820
|
|
|
@@ -1815,6 +1823,8 @@ interface ThreadVisibilityTargetGroupOptions {
|
|
|
1815
1823
|
getRoot: () => HTMLElement | null;
|
|
1816
1824
|
/** 所有通道共享的轻量资源预热距离。 */
|
|
1817
1825
|
revealMarginPx?: number;
|
|
1826
|
+
/** 所有通道共享的停稳后 cache-only 近邻距离,不扩大实际可见范围。 */
|
|
1827
|
+
preloadMarginPx?: number;
|
|
1818
1828
|
/** 所有通道共享的稳定激活最小可见比例。 */
|
|
1819
1829
|
minimumIntersectionRatio?: number;
|
|
1820
1830
|
scrollIdleMs?: number;
|
package/dist/chat-kit-vue.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {h,C,p,i,q,m,z,B,o,j,g}from'./chunk-BZFBUHDE.js';import {f,h as h$2,i as i$1,g as g$1}from'./chunk-R6BJQWPW.js';import'./chunk-HZD2QAZB.js';import'./chunk-TKWU3IO7.js';import'./chunk-XICYFDN4.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 qt(t){let a=0,v=0;for(let f of t)f.kind==="video"?v+=1:a+=1;return {imageCount:a,videoCount:v}}function Gt(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.mediaAlbum===void 0?{}:{mediaAlbum:qt(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 Et=Symbol("ImThreadReadActions");function At(t){provide(Et,t);}function Yt(){return inject(Et,void 0)}var Ge=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:v}){return At(t.readActions),()=>{let f=h(t.message),g=t.rendererRegistry.resolve(f);return g!==void 0?h$1(g,{...a,message:t.message,presentation:t.presentation}):v["unsupported-body"]!==void 0?v["unsupported-body"]({kind:f,message:t.message}):h$1("span",{"data-im-thread-unsupported-body":f,"aria-hidden":"true"})}}});var We=Symbol("ImThreadViewportRegistration");function xt(){return inject(We,void 0)}var ze=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 v=xt();function f(o,d){let y=Array.isArray(d)?d:[d];return y.length===1&&isVNode(y[0])?cloneVNode(y[0],{key:o}):h$1(Fragment,{key:o},y)}function g(o){return d=>{v?.registerMessageNode(o,d instanceof HTMLElement?d:null);}}function k(o,d){return y=>{v?.registerDateNode(o,d,y instanceof HTMLElement?y:null);}}function M(o){return a.encryption?.({item:o})??h$1("div",{"data-im-thread-encryption":o.key})}function p(o){let d=k(o.key,o.label);return a["date-separator"]?.({item:o,setElement:d})??h$1("div",{ref:d,"data-im-thread-date-separator":o.key},o.label)}function w(o){return a["entry-unread"]?.({item:o})??h$1("div",{"data-im-thread-entry-unread":o.key,...o.count===void 0?{}:{"data-count":String(o.count)}})}function R(o){let d=g(o.message.id);return a.item!==void 0?a.item({item:o,setElement:d}):a.message!==void 0?a.message({item:o,setElement:d}):o.message.deletedForEveryone!==void 0?a["deleted-message"]?.({item:o,setElement:d})??h$1("article",{ref:d,"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:d})??h$1("article",{ref:d,"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:d}):h$1("article",{ref:d,"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(Ge,{message:o.message,rendererRegistry:t.rendererRegistry,presentation:t.presentation,readActions:t.readActions},{"unsupported-body":a["unsupported-body"]===void 0?void 0:y=>a["unsupported-body"]?.(y)})])}return ()=>h$1("div",{"data-im-thread-items":""},t.items.map(o=>{switch(o.kind){case "encryption":return a.item!==void 0?f(o.key,a.item({item:o})):f(o.key,M(o));case "date-separator":return a.item!==void 0?f(o.key,a.item({item:o,setElement:k(o.key,o.label)})):f(o.key,p(o));case "entry-unread":return a.item!==void 0?f(o.key,a.item({item:o})):f(o.key,w(o));case "system":case "message":return f(o.key,R(o))}return o}))}});var kt=120,ar=500,le=.5,sr=8,Ye=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:v,slots:f}){let g$1=ref(null),k=ref(null),M=new Map,p$1=new Map,w=new Set,R=new Map,o$1=0,d=[],y,L,x,N,X=false,E,U=new Set,Y=false,H,W="",s=1,_=false,J=false,j$1=true,D=false,Q=false,B$1=false,$=0,Z=-1,ae=-1,u,S,T,c,P,F=ref(true),q$1=ref(0),z$1=C(e=>{q$1.value=e,a("new-message-count",e);});function be(e){let n=Number.isFinite(t.followThreshold)?Math.max(0,t.followThreshold):0;return e.scrollHeight-e.clientHeight-e.scrollTop<=n}function fe(e=t.messageIds){return e.flatMap(n=>{let i=M.get(n);if(i===void 0)return [];let h=i.getBoundingClientRect(),b=i.querySelector("[data-im-thread-anchor-point]");return [{id:n,top:h.top,bottom:h.bottom,anchorTop:b?.getBoundingClientRect().top??h.top}]})}function Ee(e="",n=1){let i=Math.min(1,Math.max(0,n));W!==""&&W!==e&&R.get(W)?.element.style.removeProperty("opacity"),W=e,s=i,e!==""&&R.get(e)?.element.style.setProperty("opacity",String(i));}function re(){Ee();}function Ae(){let e=g$1.value;if(Y||e===null||!t.activeDateEnabled)return;let n=[...R.entries()].filter(([,O])=>e.contains(O.element)).map(([O,C])=>{let G=C.element.getBoundingClientRect();return {key:O,label:C.label,top:G.top,height:G.height}}).sort((O,C)=>O.top-C.top),i=e.getBoundingClientRect(),h=n.find(O=>O.height>0)?.height??28,b=g({markers:n,viewportTop:i.top,overlayTop:Number.isFinite(t.activeDateOffset)?Math.max(0,t.activeDateOffset):0,overlayHeight:h});if(b===null){re(),a("active-date-change",null);return}Ee(b.inlineDateKey,b.inlineOpacity),a("active-date-change",b);}function Ce(e){L={scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,width:e.clientWidth,height:e.clientHeight};}function Oe(e){let n=L;if(n===void 0)return false;let i=Math.max(0,e.scrollHeight-e.clientHeight);return i<n.scrollHeight-n.height&&n.scrollTop>i&&Math.abs(e.scrollTop-i)<=le}function xe(e){return Oe(e)||H!==void 0&&(H.behavior==="smooth"||Math.abs(e.scrollTop-H.targetTop)<=le)?0:e.scrollTop-o$1}function me(e,n){n!==0&&(o$1=e.scrollTop-n,H=void 0,m$1());}function Ke(e,n){let i=xe(e);if(c!==void 0)return c.expectedOffset-=i,se(),me(e,i),D||ie(),false;let h=L;if(h===void 0)return false;let b=y,O=b===void 0?void 0:fe([b.id])[0],C=e.scrollTop-h.scrollTop,G=Oe(e)?0:C,Re=b===void 0||O===void 0?0:(O.anchorTop??O.top)-n.top-b.offset+C;return h.scrollHeight!==e.scrollHeight||h.width!==e.clientWidth||h.height!==e.clientHeight||Math.abs(Re)>le?(L=void 0,!_&&!t.loadingNewer&&t.resizeFollowEnabled&&F.value&&Math.abs(G)<=le?(Fe(),true):(b!==void 0&&Ne({...b,offset:b.offset-G}),me(e,i),false)):false}function ee(){let e=g$1.value;if(Y||e===null)return;let n=e.getBoundingClientRect();if(Ke(e,n))return;let i=N!==void 0&&X?t.messageIds.filter(C=>w.has(C)):t.messageIds,h=fe(i);if(N!==void 0&&X&&h.length===0){F.value=be(e);return}let b=h.filter(C=>B({viewportTop:n.top,viewportBottom:n.bottom,messageTop:C.top,messageBottom:C.bottom,margin:t.visibleMargin})).map(C=>C.id),O=b.length!==d.length||b.some((C,G)=>d[G]!==C);d=Object.freeze(b),y=o(h,{top:n.top,bottom:n.bottom}),Ce(e),z$1.acknowledgeVisible(b),F.value=be(e),O&&a("visible-range",d),a("settled",{visibleMessageIds:d,...d.length===0?{}:{newestVisibleMessageId:d[d.length-1]},isAtBottom:F.value,newMessageCount:q$1.value});}function ge(e){if(U.add(e),E!==void 0)return;let n=()=>{E=void 0;let i=[...U];U.clear(),i.forEach(h=>h());};typeof globalThis.requestAnimationFrame=="function"?E=globalThis.requestAnimationFrame(n):E=globalThis.setTimeout(n,0);}function Ie(){E!==void 0&&(typeof E=="number"&&typeof globalThis.cancelAnimationFrame=="function"?globalThis.cancelAnimationFrame(E):globalThis.clearTimeout(E),E=void 0,U.clear());}function ne(){ge(ee);}function we(){let e=g$1.value;if(e===null)return;let n=e.getBoundingClientRect(),i=o(fe(),{top:n.top,bottom:n.bottom});i!==void 0&&(y=i,Ce(e));}function pe(){return j$1&&c===void 0&&!J&&!t.loadingOlder}function ke(){we(),j$1=false,Z=$,J=true,a("reach-start"),ge(()=>{t.loadingOlder||(J=false);});}function Ve(e){return t.hasNewer&&!_&&!t.loadingOlder&&!t.loadingNewer&&be(e)}function r(){_=true,F.value=false,ae=$,a("reach-end"),ge(()=>{t.loadingNewer||(_=false);});}function l(){let e=g$1.value;e===null||$===ae||!Ve(e)||r();}function m$1(){let e=g$1.value;if(Y||e===null)return;let n=e.scrollTop,i=Oe(e),h=H,b=false;if(h!==void 0){let C=Math.abs(n-h.targetTop)<=le;b=h.behavior==="smooth"||C,(h.behavior!=="smooth"||C)&&(H=void 0);}!b&&!i&&!D&&c===void 0&&n!==o$1&&(D=true,Q=true,$+=1);let O=D&&!b&&!i&&n!==o$1;if(O&&(a("user-scroll"),ge(Ae)),D&&!B$1&&ye(),!j$1&&Q&&$!==Z&&n<o$1&&n>et()&&(j$1=true),c!==void 0&&!b)if(D){let C=K();C!==void 0&&(c.expectedOffset=C);}else se(),ie();pe()&&O&&n>=0&&m({previousScrollTop:o$1,currentScrollTop:n,topThreshold:t.olderPrefetchThreshold})&&ke(),O&&Ve(e)&&z({previousScrollTop:o$1,currentScrollTop:n,isAtBottom:be(e),isHistoryWindow:t.hasNewer,isPageSettling:b})&&r(),o$1=n,ne();}function I(e,n="auto"){H={targetTop:e,behavior:n};}function V(e){let n=c,i=k.value;if(!(n===void 0||i===null)){if(n.visualOffset=Math.abs(e)<=le?0:e,n.visualOffset===0){i.style.removeProperty("transform"),i.style.removeProperty("will-change");return}i.style.setProperty("transform",`translate3d(0, ${n.visualOffset}px, 0)`),i.style.setProperty("will-change","transform");}}function A(){P!==void 0&&(clearTimeout(P),P=void 0),c!==void 0&&c.visualOffset!==0&&(y=void 0,L=void 0);let e=k.value;e?.style.removeProperty("transform"),e?.style.removeProperty("will-change"),c=void 0,H=void 0;}function K(){let e=g$1.value,n=c;if(e===null||n===void 0)return;let i=fe().find(h=>h.id===n.anchor.id);if(i!==void 0)return (i.anchorTop??i.top)-e.getBoundingClientRect().top}function se(){let e=c,n=K();if(e===void 0||n===void 0)return;let i=e.expectedOffset-n;Math.abs(i)<=le||(V(e.visualOffset+i),e.committed=false,e.attempts=0);}function oe(){P!==void 0&&clearTimeout(P),P=setTimeout(()=>{P=void 0,!(D||c?.committed!==true)&&A();},ar);}function Te(){let e=g$1.value,n=c;if(Y||e===null||n===void 0||D)return;let i=n.visualOffset;if(Math.abs(i)<=le){n.committed=true,oe();return}let h=Math.max(0,e.scrollHeight-e.clientHeight),b=Math.min(h,Math.max(0,e.scrollTop-i));if(I(b),e.scrollTop=b,Math.abs(e.scrollTop-b)>le){H=void 0,n.committed=false,n.attempts+=1,n.attempts<sr?ie():(A(),H=void 0,o$1=e.scrollTop);return}V(0),o$1=e.scrollTop,n.expectedOffset=K()??n.expectedOffset,n.committed=true,n.attempts=0,oe();}function ie(){P!==void 0&&clearTimeout(P),P=setTimeout(()=>{P=void 0,Te();},kt);}function Me(e){e!==void 0&&(c===void 0&&(c={anchor:e,expectedOffset:e.offset,visualOffset:0,committed:false,attempts:0}),se(),!D&&Te());}function Ne(e){let n=g$1.value;if(n===null||e===void 0)return;let i=n.getBoundingClientRect(),h=q(e,fe(),{top:i.top,bottom:i.bottom});if(h!==void 0){let b=Math.max(0,n.scrollHeight-n.clientHeight),O=Math.min(b,Math.max(0,n.scrollTop+h));I(O),n.scrollTop=O,o$1=n.scrollTop,L=void 0;}}function et(){return Number.isFinite(t.olderPrefetchThreshold)?Math.max(0,t.olderPrefetchThreshold):0}function De(){H?.behavior==="smooth"&&(H=void 0),Q=false,D||(D=true,$+=1),u!==void 0&&(clearTimeout(u),u=void 0);}function Le(){let e=g$1.value;e===null||$===Z||(c!==void 0&&A(),j$1=true,e.scrollTop<=et()&&pe()&&ke());}function tt(){y=void 0,L=void 0,u!==void 0&&(clearTimeout(u),u=void 0),A(),D=false,Q=false,B$1=false,S=void 0,T=void 0,$+=1,Z=-1,ae=-1,j$1=true,J=false,_=false,H=void 0;}function rt(){B$1||(u!==void 0&&(clearTimeout(u),u=void 0),D=false,Q=false,c!==void 0&&(c.attempts=0),Te());}function ye(){B$1||(u!==void 0&&clearTimeout(u),u=setTimeout(()=>{u=void 0,rt();},kt));}function nt(){H=void 0,rt();}function ot(e){B$1=true,De(),S=e.touches?.[0]?.clientY;}function it(e){let n=e.touches?.[0]?.clientY;n!==void 0&&(S!==void 0&&n>S?Le():S!==void 0&&n<S&&l(),S=n);}function He(){B$1=false,S=void 0,ye();}function at(e){De(),e.deltaY<0?Le():e.deltaY>0&&l(),ye();}function st(e){e.pointerType!=="touch"&&(De(),T=e.clientY,ye());}function lt(e){e.pointerType==="touch"||!D||T===void 0||(e.clientY<T?Le():e.clientY>T&&l(),T=e.clientY,ye());}function Be(e){e.pointerType!=="touch"&&(T=void 0,ye());}function dt(e){["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "].includes(e.key)&&(De(),e.key==="ArrowUp"||e.key==="PageUp"||e.key==="Home"||e.key===" "&&e.shiftKey?Le():l(),ye());}function Fe(e="auto"){let n=g$1.value;if(n===null)return;L=void 0,A();let i=Math.max(0,n.scrollHeight-n.clientHeight);I(i,e),n.scrollTo?.({top:i,behavior:e}),n.scrollTop!==i&&(n.scrollTop=i),o$1=n.scrollTop,z$1.clear(),ee();}function ut(){let e=g$1.value;return e!==null&&e.clientWidth>0&&e.clientHeight>0}function Lt(){let e=g$1.value;return ut()&&e!==null&&e.scrollHeight>e.clientHeight+1}function Ht(e,n={}){let i=g$1.value,h=M.get(e);if(i===null||h===void 0||!i.contains(h)||i.clientHeight<=0)return false;A();let b=i.getBoundingClientRect(),O=h.getBoundingClientRect(),C=n.block??"center",G;C==="start"?G=i.scrollTop+O.top-b.top:C==="end"?G=i.scrollTop+O.bottom-b.bottom:C==="nearest"?O.top>=b.top&&O.bottom<=b.bottom?G=i.scrollTop:O.top<b.top?G=i.scrollTop+O.top-b.top:G=i.scrollTop+O.bottom-b.bottom:G=j({currentScrollTop:i.scrollTop,scrollHeight:i.scrollHeight,targetHeight:O.height,targetTop:O.top,viewportHeight:i.clientHeight,viewportTop:b.top});let Re=Math.max(0,i.scrollHeight-i.clientHeight),ve=Math.min(Re,Math.max(0,G));L=void 0;let Se=n.behavior??"auto";return I(ve,Se),i.scrollTo?.({top:ve,behavior:Se}),i.scrollTop!==ve&&(i.scrollTop=ve),o$1=i.scrollTop,ee(),true}function Bt(){z$1.clear();}function Ft(){_=true,F.value=false;}function _t(){_=false,ne();}function jt(e,n){let i=M.get(e);if(i!==void 0&&i!==n&&(N?.unobserve(i),x?.unobserve?.(i),p$1.delete(i),w.delete(e)),n===null){M.delete(e),w.delete(e);return}M.set(e,n),p$1.set(n,e),N?.observe(n),x?.observe(n),ne();}function Kt(e,n,i){let h=R.get(e);if(i===null){R.delete(e);return}R.set(e,{element:i,label:n}),W===e&&i.style.setProperty("opacity",String(s)),h?.element!==i&&(i.dataset.imThreadDateSeparator=e);}return provide(We,{registerMessageNode:jt,registerDateNode:Kt}),watch(()=>t.contentKey,(e,n)=>{if(e===n)return;tt();let i=g$1.value;i!==null&&(o$1=i.scrollTop);},{flush:"sync"}),watch(()=>t.messageIds,async(e,n)=>{let i=g$1.value;if(i===null)return;let h=new Set(n);n.length>0&&e.length>0&&!e.some(he=>h.has(he))&&tt();let O=i.getBoundingClientRect(),C=p(y,fe(),{top:O.top,bottom:O.bottom}),G=F.value,Re=n[n.length-1],ve=Re===void 0?-1:e.indexOf(Re),Se=ve<0?[]:e.slice(ve+1).filter(he=>!h.has(he)),ct=_||t.loadingNewer,Ut=e.length===n.length&&e.every(he=>h.has(he))&&e.some((he,Ue)=>he!==n[Ue]);if(await nextTick(),Y)return;if(Ut&&G&&t.followNewMessages&&t.resizeFollowEnabled&&!t.hasNewer&&!ct){Fe();return}let ft=n[0];if(ft!==void 0&&e.indexOf(ft)>0&&(J=false,Me(C)),Se.length>0){if(ct){_=false,c===void 0&&Ne(C),F.value=false,ne();return}(G||Se.some(Ue=>t.shouldFollowAppendedMessage?.(Ue)===true))&&t.followNewMessages?Fe():z$1.add(Se);}ne();},{flush:"pre"}),watch(()=>t.loadingNewer,(e,n)=>{e||!n||!_||ge(()=>{t.loadingNewer||(_=false);});},{flush:"pre"}),watch(()=>t.loadingOlder,(e,n)=>{e||!n||!J||ge(()=>{t.loadingOlder||(J=false);});},{flush:"pre"}),onMounted(()=>{let e=g$1.value;if(e!==null){if(o$1=e.scrollTop,e.addEventListener("scroll",m$1,{passive:true}),e.addEventListener("scrollend",nt,{passive:true}),e.addEventListener("touchstart",ot,{passive:true}),e.addEventListener("touchmove",it,{passive:true}),e.addEventListener("touchend",He,{passive:true}),e.addEventListener("touchcancel",He,{passive:true}),e.addEventListener("wheel",at,{passive:true}),e.addEventListener("pointerdown",st,{passive:true}),e.addEventListener("pointermove",lt,{passive:true}),e.addEventListener("pointerup",Be,{passive:true}),e.addEventListener("pointercancel",Be,{passive:true}),e.addEventListener("keydown",dt),typeof globalThis.ResizeObserver=="function"){x=new globalThis.ResizeObserver(()=>{Y||g$1.value===null||ee();}),x.observe(e),k.value!==null&&x.observe(k.value);for(let n of M.values())x.observe(n);}if(typeof globalThis.IntersectionObserver=="function"){N=new globalThis.IntersectionObserver(n=>{for(let i of n){let h=p$1.get(i.target);h!==void 0&&(i.isIntersecting?w.add(h):w.delete(h));}X=true,ne();},{root:e,rootMargin:`${Number.isFinite(t.visibleMargin)?Math.max(0,t.visibleMargin):0}px 0px`});for(let n of M.values())N.observe(n);}ne();}}),onBeforeUnmount(()=>{Y=true;let e=g$1.value;e!==null&&e.removeEventListener("scroll",m$1),e!==null&&(e.removeEventListener("scrollend",nt),e.removeEventListener("touchstart",ot),e.removeEventListener("touchmove",it),e.removeEventListener("touchend",He),e.removeEventListener("touchcancel",He),e.removeEventListener("wheel",at),e.removeEventListener("pointerdown",st),e.removeEventListener("pointermove",lt),e.removeEventListener("pointerup",Be),e.removeEventListener("pointercancel",Be),e.removeEventListener("keydown",dt)),u!==void 0&&clearTimeout(u),A(),Ie(),x?.disconnect(),N?.disconnect(),re(),M.clear(),p$1.clear(),w.clear(),R.clear(),z$1.clear();}),v({getViewportElement:()=>g$1.value,clearNewMessageBadge:Bt,clearActiveDate:re,isAtBottom:computed(()=>F.value),isMeasurable:ut,isScrollable:Lt,newMessageCount:computed(()=>q$1.value),prepareHistoryPageAppend:Ft,cancelHistoryPageAppend:_t,trackRemoteMessageIds:(e,n)=>z$1.trackRemote(e,n),scrollToLatest:Fe,scrollToMessage:Ht,focusViewport:()=>g$1.value?.focus({preventScroll:true})}),()=>h$1("div",{ref:g$1,"data-im-thread-viewport":"",role:"log",tabindex:-1},[h$1("div",{ref:k,"data-im-thread-viewport-content":""},f.default?.())])}});var Nt=Symbol("ImThreadSurfaceContext");function ur(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 cr(t){provide(Nt,t);}function $e(){let t=inject(Nt);if(t===void 0)throw new Error("ImThreadSurface \u9700\u8981\u663E\u5F0F context prop \u6216 provideImThreadSurfaceContext");return t}var Je=Object.freeze({followThreshold:120,olderPrefetchThreshold:120,visibleReadDelay:300,visibleMargin:8,activeDateOffset:16,activeDateIdleDelay:1500}),Qe=Object.freeze({enabled:true,maxFillPages:8}),gr=8,pr=160;function vr(t,a){return t?.conversationType===a.conversationType&&t.conversationId===a.conversationId}var hr=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:v}){let f=t.context??$e(),g=ref(null),k=ref(0),M=ref(true),p=[],w,R=0,o=0,d=null,y="",L="",x="",N=false,X=false,E=ref(false),U=ref(""),Y=ref(false),H,W,s=computed(()=>f.getState()),_=computed(()=>s.value.pageVisible??f.isPageVisible?.()??true),J=computed(()=>s.value.pageEngaged??f.isPageEngaged?.()??true),j=computed(()=>vr(s.value.activeConversation,t.conversation)),D=computed(()=>({...Je,...t.viewportOptions})),Q=computed(()=>{let r=t.initialViewportOptions.maxFillPages??Qe.maxFillPages;return {enabled:t.initialViewportOptions.enabled??Qe.enabled,maxFillPages:Number.isFinite(r)?Math.max(0,Math.floor(r)):Qe.maxFillPages}}),B=computed(()=>!j.value||!s.value.ready?"":`${t.conversation.conversationType}\0${t.conversation.conversationId}`),$=computed(()=>j.value?i({messages:s.value.messages,entryUnread:s.value.entryUnread,formatDate:f.formatDate,leadingItems:f.leadingItems?.(),beforeMessageItems:f.beforeMessageItems}):[]),Z=computed(()=>$.value.flatMap(r=>r.kind==="message"||r.kind==="system"?[r.message.id]:[]));function ae(){H!==void 0&&(clearTimeout(H),H=void 0),W!==void 0&&(clearTimeout(W),W=void 0);}function u(r=false){if(ae(),Y.value=false,r){g.value?.clearActiveDate(),U.value="";return}W=setTimeout(()=>{W=void 0,!Y.value&&(g.value?.clearActiveDate(),U.value="");},pr);}function S(r){if(r===null){u();return}ae(),U.value=r.label,Y.value=true;let l=D.value.activeDateIdleDelay,m=Number.isFinite(l)?Math.max(0,l):Je.activeDateIdleDelay;H=setTimeout(()=>{H=void 0,u();},m);}async function T(r,l){t.hooks?.beforeAction?.(r);try{let m=await l();return t.hooks?.afterAction?.(r,m),m}catch(m){throw t.hooks?.onError?.(r,m),m}}function c(r="automatic"){return !j.value||s.value.loading||!s.value.hasOlder?Promise.resolve(0):T({kind:"load-older",source:r},()=>f.actions.loadOlder())}function P(){let r=f.actions.loadNewer,l=s.value.loadingNewer??s.value.loading;return !j.value||l||!s.value.hasNewer||r===void 0?Promise.resolve(0):T({kind:"load-newer"},()=>r())}async function F(r){for(let l=0;l<gr;l+=1){if(!j.value)return;let m=r==="older"?s.value.hasOlder:s.value.hasNewer,I=r==="older"?s.value.olderError:s.value.newerError;if(!m||I!==null||(r==="older"?await c("user-scroll"):await P())>0)return;let A=r==="older"?s.value.hasOlder:s.value.hasNewer,K=r==="older"?s.value.olderError:s.value.newerError;if(!A||K!==null)return}}async function q(){return !j.value||f.actions.loadNewer===void 0?0:T({kind:"load-newer"},()=>f.actions.retryNewer?.()??f.actions.loadNewer?.({force:!0})??Promise.resolve(0))}async function z(){if(!j.value)return 0;let r=B.value,l=++R;d=null,x="";let m;try{m=await T({kind:"retry-older"},()=>f.actions.retryOlder?.()??f.actions.loadOlder({force:!0}));}catch(I){throw ee(r,l)&&(x=r),I}return ee(r,l)&&!E.value&&(d=null,we()),m}async function be(){if(!j.value)return false;let r=B.value,l=++o;return pe(true),N=true,y=r,L=Ie(s.value.entryUnread),!await T({kind:"jump-to-latest"},()=>f.actions.jumpToLatest?.()??Promise.resolve(!s.value.isHistoryWindow))||!re(r,l)||(await nextTick(),!re(r,l))?false:(g.value?.scrollToLatest(),true)}function fe(r){M.value=r.isAtBottom,k.value=r.newMessageCount,we();}function Ee(r,l){return g.value?.scrollToMessage(r,l)??false}function re(r,l){return !X&&o===l&&B.value===r&&j.value}async function Ae(r,l,m,I){for(let V=0;V<60;V+=1){if(!re(r,l))return false;if(Ee(m,I))return true;await nextTick(),typeof window<"u"&&typeof window.requestAnimationFrame=="function"&&await new Promise(A=>window.requestAnimationFrame(()=>A()));}return false}async function Ce(r,l,m){let I=g.value;if(I===null||!I.isMeasurable()||I.isScrollable())return true;let V=0,A=!s.value.hasOlder,K=!s.value.hasNewer||f.actions.loadNewer===void 0,se=async()=>(await nextTick(),await nextTick(),Ae(r,l,m,{behavior:"auto",block:"center"})),oe=async ie=>{if(!re(r,l)||V>=Q.value.maxFillPages)return false;let Me=0;if(ie==="older"){if(A||!s.value.hasOlder)return false;Me=await c(),A=!s.value.hasOlder;}else {if(K||!s.value.hasNewer)return false;I.prepareHistoryPageAppend();try{Me=await P();}catch(Ne){throw I.cancelHistoryPageAppend(),Ne}Me<=0&&!s.value.hasNewer&&I.cancelHistoryPageAppend(),K=!s.value.hasNewer;}return V+=1,Me>0?se():!(ie==="older"?A:K)};!A&&!await oe("older")&&(A=true),!K&&!await oe("newer")&&(K=true);let Te="older";for(;re(r,l)&&V<Q.value.maxFillPages&&I.isMeasurable()&&!I.isScrollable()&&(!A||!K);){let ie=Te==="older"?A?"newer":"older":K?"older":"newer";Te=ie==="older"?"newer":"older",await oe(ie)||(ie==="older"?A=true:K=true);}return re(r,l)}async function Oe(r,l={behavior:"auto",block:"center"}){if(!j.value||r==="")return false;let m=B.value,I=++o;if(!Z.value.includes(r)){let K=f.actions.loadAround;if(K===void 0||!await T({kind:"locate-message",messageId:r},()=>K(r))||!re(m,I))return false}return !await Ae(m,I,r,{...l,behavior:"auto"})||!await Ce(m,I,r)?false:Ae(m,I,r,l)}function xe(){w!==void 0&&(clearTimeout(w),w=void 0);}function me(){if(xe(),!E.value)return;let r=t.readActions;if(r===void 0||p.length===0)return;let l=Number.isFinite(D.value.visibleReadDelay)?Math.max(0,D.value.visibleReadDelay):Je.visibleReadDelay;w=setTimeout(()=>{if(w=void 0,!j.value||!J.value)return;let m=p[p.length-1];if(m===void 0)return;let I=r.resolveTarget===void 0?m:r.resolveTarget(m);I!=null&&Promise.resolve(r.markRead(I)).catch(V=>{t.hooks?.onError?.({kind:"visible-range",messageIds:p},V);});},l);}function Ke(r){p=Object.freeze([...r]);let l={kind:"visible-range",messageIds:p};t.hooks?.beforeAction?.(l);try{f.actions.onVisibleRange?.(p),t.hooks?.afterAction?.(l,void 0);}catch(m){throw t.hooks?.onError?.(l,m),m}E.value?me():we();}function ee(r,l){return !X&&R===l&&B.value===r&&!N}function ge(r,l){ee(r,l)&&(y=r,L=Ie(s.value.entryUnread),E.value=true,me());}function Ie(r){return r.state!=="located"?r.state:`${r.state}:${r.firstMessageId}`}async function ne(r,l,m){for(let I=0;I<60;I+=1){if(!ee(r,l))return false;if(g.value?.scrollToMessage(m,{behavior:"auto",block:"center"})===true)return true;await nextTick(),typeof window<"u"&&typeof window.requestAnimationFrame=="function"&&await new Promise(A=>window.requestAnimationFrame(()=>A()));}return false}function we(){let r=B.value,l=Ie(s.value.entryUnread);if(r===""||s.value.loading||s.value.error!==null&&s.value.messages.length===0||y===r&&(L===l||N)||x===r||d!==null)return;if(!Q.value.enabled){y=r,L=l,E.value=true,me();return}let m=++R;N=false,E.value=false;let I=(async()=>{if(await nextTick(),!ee(r,m))return;let V=g.value;if(V===null||!V.isMeasurable())return;let A=s.value.entryUnread;if(A.state==="located"&&!Z.value.includes(A.firstMessageId))return;let K=A.state==="located"?await ne(r,m,A.firstMessageId):false;if(A.state==="located"&&!K)return;K||V.scrollToLatest();let se=0;for(;ee(r,m)&&se<Q.value.maxFillPages&&s.value.error===null&&s.value.hasOlder&&V.isMeasurable()&&!V.isScrollable();)if(await c(),!ee(r,m)||(se+=1,await nextTick(),await nextTick(),!V.isMeasurable()))return;if(!ee(r,m)||!V.isMeasurable())return;let oe=s.value.entryUnread;if(oe.state==="located"){if(!Z.value.includes(oe.firstMessageId)||!await ne(r,m,oe.firstMessageId))return}else V.scrollToLatest();await nextTick(),ge(r,m);})().catch(()=>{ee(r,m)&&(x=r);}).finally(()=>{d===I&&(d=null);});d=I;}function pe(r,l=false){R+=1,d=null,N=false,E.value=r,r||(y="",L="",l||(x="")),xe();}function ke(){if(E.value)return;let r=B.value;N=true,R+=1,d=null,y=r,E.value=true,me();}let Ve=Object.freeze({getViewportElement:()=>g.value?.getViewportElement()??null,loadOlder:c,retryOlder:z,loadNewer:P,retryNewer:q,jumpToLatest:be,scrollToMessage:Ee,locateMessage:Oe,focusViewport:()=>g.value?.focusViewport()});return a(Ve),watch(J,r=>{r&&E.value?me():xe();}),watch([()=>s.value.activeRemoteMessageRevision??0,g,B],()=>{let r=g.value;if(r===null||!j.value)return;let l=f.actions.drainActiveRemoteMessageIds?.()??[];r.trackRemoteMessageIds(l,{isAtBottom:M.value,isHistoryWindow:s.value.isHistoryWindow,isPageVisible:_.value})&&(M.value=false);},{flush:"post"}),watch([B,()=>s.value.loading,()=>s.value.error,()=>Z.value.length,()=>s.value.hasOlder,()=>Ie(s.value.entryUnread),Q],([r,l,m,,,I],[V,,,,,A])=>{if(r!==V&&(o+=1,pe(false),u(true),g.value?.clearNewMessageBadge(),k.value=0,M.value=true),r!==""&&r===V&&I!==A&&!N&&I.startsWith("located:")&&(y="",L="",E.value=false),r===""){pe(false);return}if(m!==null&&s.value.messages.length===0){E.value||pe(false,true);return}l||we();},{flush:"post",immediate:true}),onBeforeUnmount(()=>{X=true,o+=1,pe(false),u(true);}),()=>{let r={conversation:t.conversation,state:s.value,items:$.value,actions:Ve,initialViewportSettled:B.value!==""&&(s.value.messages.length===0?!s.value.loading&&s.value.error===null&&!s.value.hasOlder:E.value&&y===B.value)},l=[v.header?.(r),v["before-list"]?.(r)];if(!j.value)l.push(v.unsupported?.(r)??h$1("div",{"data-im-thread-unsupported":""}));else if(!s.value.ready&&s.value.loading)l.push(v.loading?.(r)??h$1("div",{"data-im-thread-loading":""}));else if(s.value.error!==null&&s.value.messages.length===0)l.push(v.error?.(r)??h$1("div",{"data-im-thread-error":""}));else if(s.value.ready&&s.value.messages.length===0&&!s.value.hasOlder)l.push(v.empty?.(r)??h$1("div",{"data-im-thread-empty":""}));else {let m=h$1(Ye,{ref:g,messageIds:Z.value,contentKey:`${t.conversation.conversationType}\0${t.conversation.conversationId}`,loadingOlder:s.value.loadingOlder??s.value.loading,hasNewer:s.value.hasNewer,loadingNewer:s.value.loadingNewer??s.value.loading,followThreshold:D.value.followThreshold,olderPrefetchThreshold:D.value.olderPrefetchThreshold,visibleMargin:D.value.visibleMargin,activeDateOffset:D.value.activeDateOffset,activeDateEnabled:v["active-date"]!==void 0,resizeFollowEnabled:E.value,followNewMessages:_.value,shouldFollowAppendedMessage:I=>{let V=s.value.messages.find(A=>A.id===I);return V===void 0?false:f.shouldFollowMessage?.(V)===true},onReachStart:()=>{F("older").catch(()=>{});},onReachEnd:()=>{F("newer").catch(()=>{});},onSettled:fe,onUserScroll:ke,onActiveDateChange:S,onVisibleRange:Ke,onNewMessageCount:I=>{k.value=I;}},{default:()=>[v["viewport-before"]?.(r),h$1(ze,{items:$.value,rendererRegistry:t.rendererRegistry,presentation:t.presentation,readActions:t.readActions},{item:v.item,"date-separator":v["date-separator"],"entry-unread":v["entry-unread"],encryption:v.encryption,system:v.system,message:v.message,"recalled-message":v["recalled-message"],"deleted-message":v["deleted-message"],"unsupported-body":v["unsupported-body"]}),v["viewport-after"]?.(r)]});l.push(h$1("div",{"data-im-thread-viewport-shell":""},[v["active-date"]?.({label:U.value,visible:Y.value&&U.value!==""}),m])),s.value.error!==null&&l.push(v.error?.(r)??h$1("div",{"data-im-thread-error":""}));}return l.push(v["after-list"]?.(r),v["jump-to-latest"]?.({...r,count:k.value,visible:!M.value||s.value.isHistoryWindow}),v["context-menu"]?.(r),v.composer?.(r)),h$1("section",{"data-im-thread-surface":"","data-conversation-type":t.conversation.conversationType,"data-conversation-id":t.conversation.conversationId},l)}}});function Tr(t){let a=new Map;for(let f of t){if(a.has(f.kind))throw new Error(`\u6D88\u606F renderer kind \u91CD\u590D\u6CE8\u518C\uFF1A${f.kind}`);a.set(f.kind,f.component);}let v=Object.freeze([...a.keys()]);return Object.freeze({kinds:v,resolve:f=>a.get(f)})}var br=140,Ir=120;function Dt(t,a){if(t.width<=0||t.height<=0)return 0;let v=Math.max(0,Math.min(t.right,a.right)-Math.max(t.left,a.left)),f=Math.max(0,Math.min(t.bottom,a.bottom)-Math.max(t.top,a.top));return Math.min(1,v*f/(t.width*t.height))}function wr(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 Ze(t){let a=Math.max(0,t.scrollIdleMs??br),v=Math.max(0,t.visibilityDwellMs??Ir),f=Math.min(1,Math.max(0,t.minimumIntersectionRatio??.01)),g=Math.max(0,t.revealMarginPx??0),k=Math.max(1,t.maxSettledVisible??Number.POSITIVE_INFINITY),M=new Map,p=new Map,w=reactive(new Set),R=new Set,o=new Set,d=null,y=null,L=null,x=false,N=false,X=false,E,U;function Y(){E!==void 0&&clearTimeout(E),E=void 0;}function H(){U!==void 0&&clearTimeout(U),U=void 0;}function W(u=false){if(!u&&y!==null||d===null)return;let S=d.getBoundingClientRect(),T=wr(S,g);for(let[c,P]of M){let F=c.getBoundingClientRect();P.ratio=Dt(F,S),P.intersecting=P.ratio>0,P.revealIntersecting=g>0?Dt(F,T)>0:P.intersecting&&P.ratio>=f;}}function s(u){return u.intersecting&&u.ratio>=f}function _(){for(let u of M.values())!u.revealIntersecting||w.has(u.key)||(w.add(u.key),t.onRevealed?.(u.item));}function J(u){let S=new Set(u.map(c=>c.key));if(S.size!==o.size||[...S].some(c=>!o.has(c))){o.clear();for(let c of S)o.add(c);t.onSettledVisibleChange?.(u.map(c=>c.item));}}function j(){if(N||x)return;W(),_();let u=d?.getBoundingClientRect(),S=u===void 0?0:(u.top+u.bottom)/2,T=[...M.entries()].filter(([,c])=>s(c)).sort(([c],[P])=>{let F=c.getBoundingClientRect(),q=P.getBoundingClientRect();return Math.abs((F.top+F.bottom)/2-S)-Math.abs((q.top+q.bottom)/2-S)}).slice(0,k).map(([,c])=>c);J(T);for(let c of T)R.has(c.key)||(R.add(c.key),t.onActivated?.(c.item));}function D(){N||x||(H(),U=setTimeout(()=>{U=void 0,j();},v));}function Q(){N||(B(true),W(),_(),J([]),H(),Y(),E=setTimeout(()=>{E=void 0,B(false),D();},a));}function B(u){x!==u&&(x=u,t.onScrollingChange?.(u));}function $(){d?.removeEventListener("scroll",Q),y?.disconnect(),L?.disconnect(),y=null,L=null,d=null;}function Z(u=true){if(N)return;let S=t.getRoot();if(!(S===d&&d!==null)){if($(),d=S,d===null){u&&!X&&(X=true,Promise.resolve().then(()=>{X=false,N||(Z(false),D());}));return}if(d.addEventListener("scroll",Q,{passive:true}),typeof IntersectionObserver<"u"){y=new IntersectionObserver(T=>{for(let c of T){let P=M.get(c.target);P!==void 0&&(P.intersecting=c.isIntersecting,P.ratio=c.intersectionRatio,g===0&&(P.revealIntersecting=c.isIntersecting&&c.intersectionRatio>=f));}_(),D();},{root:d,threshold:[0,f,1]}),g>0&&(L=new IntersectionObserver(T=>{for(let c of T){let P=M.get(c.target);P!==void 0&&(P.revealIntersecting=c.isIntersecting);}_();},{root:d,rootMargin:`${g}px 0px`,threshold:0}));for(let T of M.keys())y.observe(T);for(let T of M.keys())L?.observe(T);}else W(),_();}}function ae(u){w.delete(u),R.delete(u),o.delete(u);}return {register(u,S){if(N)return;let T=t.getKey(u),c=w.has(T),P=R.has(T),F=S===null?void 0:M.get(S);F!==void 0&&F.key!==T&&(p.delete(F.key),M.delete(S),ae(F.key));let q=p.get(T);if(q!==void 0&&q!==S&&(y?.unobserve(q),L?.unobserve(q),M.delete(q),p.delete(T)),S===null){q!==void 0&&(y?.unobserve(q),L?.unobserve(q),M.delete(q),p.delete(T)),ae(T);return}let z=M.get(S);if(z?.key===T&&z.item===u){Z();return}M.set(S,{item:u,key:T,intersecting:z?.key===T?z.intersecting:false,ratio:z?.key===T?z.ratio:0,revealIntersecting:z?.key===T?z.revealIntersecting:false}),p.set(T,S),Z(),y?.observe(S),L?.observe(S),W(true),_(),c&&t.onRevealed?.(u),P?t.onActivated?.(u):D();},isRevealed:u=>w.has(t.getKey(u)),isActivated:u=>R.has(t.getKey(u)),isSettledVisible:u=>o.has(t.getKey(u)),isScrolling:()=>x,notifyScroll:Q,refresh(){Z(),W(true),_(),D();},reset(){Y(),H(),B(false),J([]),$(),M.clear(),p.clear(),w.clear(),R.clear();},dispose(){N||(Y(),H(),B(false),J([]),$(),M.clear(),p.clear(),w.clear(),R.clear(),N=true);}}}function Mr(t){let a=new Map,v=new Map,f=false,g=p=>{let w=a.get(p.channel);return w===void 0?p.channel:`${p.channel}\0${w.getKey(p.item)}`},k=Ze({getRoot:t.getRoot,getKey:g,revealMarginPx:t.revealMarginPx,minimumIntersectionRatio:t.minimumIntersectionRatio,scrollIdleMs:t.scrollIdleMs,visibilityDwellMs:t.visibilityDwellMs,onScrollingChange:p=>{for(let w of a.values())w.onScrollingChange?.(p);},onRevealed:p=>a.get(p.channel)?.onRevealed?.(p.item),onActivated:p=>a.get(p.channel)?.onActivated?.(p.item),onSettledVisibleChange:p=>{for(let[w,R]of a){let o=p.filter(y=>y.channel===w).map(y=>y.item),d=R.maxSettledVisible===void 0?o:o.slice(0,R.maxSettledVisible);R.onSettledVisibleChange?.(d);}}});function M(p){return w=>{if(f)throw new Error("Thread visibility target group \u5DF2\u91CA\u653E");if(a.has(p))throw new Error(`Thread visibility channel \u5DF2\u5B58\u5728: ${p}`);a.set(p,w);let R=new Map;v.set(p,R);let o=false,d=x=>({channel:p,item:x});function y(){for(let x of R.values())k.register(x.target,null);R.clear(),w.onScrollingChange?.(false),w.onSettledVisibleChange?.([]);}return {register(x,N){if(o||f)return;let X=w.getKey(x),E=R.get(X);if(N===null){E!==void 0&&(k.register(E.target,null),R.delete(X));return}let U=d(x);R.set(X,{target:U,element:N}),k.register(U,N);},isRevealed:x=>k.isRevealed(d(x)),isActivated:x=>k.isActivated(d(x)),isSettledVisible:x=>k.isSettledVisible(d(x)),isScrolling:k.isScrolling,notifyScroll:k.notifyScroll,refresh:k.refresh,reset:y,dispose(){o||(y(),o=true,a.delete(p),v.delete(p));}}}}return {createFactory:M,refresh:k.refresh,dispose(){if(!f){for(let p of v.values())for(let w of p.values())k.register(w.target,null);v.clear(),a.clear(),k.dispose(),f=true;}}}}export{Ge as ImThreadBodySwitch,ze as ImThreadItems,hr as ImThreadSurface,Ye as ImThreadViewport,ur as createImThreadSurfaceContext,Tr as createMessageRendererRegistry,Mr as createThreadVisibilityTargetGroup,Ze as createThreadVisibilityTargets,cr as provideImThreadSurfaceContext,Gt as useImText,$e as useImThreadSurfaceContext,Yt as useOptionalImThreadReadActions};
|
|
1
|
+
import {h,C,p,i,q,m,z,B,o,j,g}from'./chunk-SLFKCTEX.js';import {f,h as h$2,i as i$1,g as g$1}from'./chunk-37HOEWMF.js';import'./chunk-MNWNUGIV.js';import'./chunk-GHZUH7RB.js';import'./chunk-4KPJTXQN.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 Gt(t){let a=0,m=0;for(let u of t)u.kind==="video"?m+=1:a+=1;return {imageCount:a,videoCount:m}}function Wt(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.mediaAlbum===void 0?{}:{mediaAlbum:Gt(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 At=Symbol("ImThreadReadActions");function Ot(t){provide(At,t);}function $t(){return inject(At,void 0)}var We=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:m}){return Ot(t.readActions),()=>{let u=h(t.message),f=t.rendererRegistry.resolve(u);return f!==void 0?h$1(f,{...a,message:t.message,presentation:t.presentation}):m["unsupported-body"]!==void 0?m["unsupported-body"]({kind:u,message:t.message}):h$1("span",{"data-im-thread-unsupported-body":u,"aria-hidden":"true"})}}});var ze=Symbol("ImThreadViewportRegistration");function Ct(){return inject(ze,void 0)}var Ye=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 m=Ct();function u(o,d){let w=Array.isArray(d)?d:[d];return w.length===1&&isVNode(w[0])?cloneVNode(w[0],{key:o}):h$1(Fragment,{key:o},w)}function f(o){return d=>{m?.registerMessageNode(o,d instanceof HTMLElement?d:null);}}function O(o,d){return w=>{m?.registerDateNode(o,d,w instanceof HTMLElement?w:null);}}function _(o){return a.encryption?.({item:o})??h$1("div",{"data-im-thread-encryption":o.key})}function h(o){let d=O(o.key,o.label);return a["date-separator"]?.({item:o,setElement:d})??h$1("div",{ref:d,"data-im-thread-date-separator":o.key},o.label)}function P(o){return a["entry-unread"]?.({item:o})??h$1("div",{"data-im-thread-entry-unread":o.key,...o.count===void 0?{}:{"data-count":String(o.count)}})}function g(o){let d=f(o.message.id);return a.item!==void 0?a.item({item:o,setElement:d}):a.message!==void 0?a.message({item:o,setElement:d}):o.message.deletedForEveryone!==void 0?a["deleted-message"]?.({item:o,setElement:d})??h$1("article",{ref:d,"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:d})??h$1("article",{ref:d,"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:d}):h$1("article",{ref:d,"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(We,{message:o.message,rendererRegistry:t.rendererRegistry,presentation:t.presentation,readActions:t.readActions},{"unsupported-body":a["unsupported-body"]===void 0?void 0:w=>a["unsupported-body"]?.(w)})])}return ()=>h$1("div",{"data-im-thread-items":""},t.items.map(o=>{switch(o.kind){case "encryption":return a.item!==void 0?u(o.key,a.item({item:o})):u(o.key,_(o));case "date-separator":return a.item!==void 0?u(o.key,a.item({item:o,setElement:O(o.key,o.label)})):u(o.key,h(o));case "entry-unread":return a.item!==void 0?u(o.key,a.item({item:o})):u(o.key,P(o));case "system":case "message":return u(o.key,g(o))}return o}))}});var Dt=120,sr=500,fe=.5,lr=8,$e=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:m$1,slots:u}){let f=ref(null),O=ref(null),_=new Map,h=new Map,P=new Set,g$1=new Map,o$1=0,d=[],w,K,E,R,G=false,S,$=new Set,J=false,C$1,re="",s=1,W=false,oe=false,j$1=true,L=false,Z=false,F=false,ee=0,te=-1,he=-1,B$1,ie,X,k,z$1,ne=ref(true),p$1=ref(0),T=C(e=>{p$1.value=e,a("new-message-count",e);});function v(e){let n=Number.isFinite(t.followThreshold)?Math.max(0,t.followThreshold):0;return e.scrollHeight-e.clientHeight-e.scrollTop<=n}function H(e=t.messageIds){return e.flatMap(n=>{let i=_.get(n);if(i===void 0)return [];let y=i.getBoundingClientRect(),I=i.querySelector("[data-im-thread-anchor-point]");return [{id:n,top:y.top,bottom:y.bottom,anchorTop:I?.getBoundingClientRect().top??y.top}]})}function b(e="",n=1){let i=Math.min(1,Math.max(0,n));re!==""&&re!==e&&g$1.get(re)?.element.style.removeProperty("opacity"),re=e,s=i,e!==""&&g$1.get(e)?.element.style.setProperty("opacity",String(i));}function q$1(){b();}function V(){let e=f.value;if(J||e===null||!t.activeDateEnabled)return;let n=[...g$1.entries()].filter(([,A])=>e.contains(A.element)).map(([A,D])=>{let Q=D.element.getBoundingClientRect();return {key:A,label:D.label,top:Q.top,height:Q.height}}).sort((A,D)=>A.top-D.top),i=e.getBoundingClientRect(),y=n.find(A=>A.height>0)?.height??28,I=g({markers:n,viewportTop:i.top,overlayTop:Number.isFinite(t.activeDateOffset)?Math.max(0,t.activeDateOffset):0,overlayHeight:y});if(I===null){q$1(),a("active-date-change",null);return}b(I.inlineDateKey,I.inlineOpacity),a("active-date-change",I);}function U(e){K={scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,width:e.clientWidth,height:e.clientHeight};}function Oe(e){let n=K;if(n===void 0)return false;let i=Math.max(0,e.scrollHeight-e.clientHeight);return i<n.scrollHeight-n.height&&n.scrollTop>i&&Math.abs(e.scrollTop-i)<=fe}function Ve(e){return Oe(e)||C$1!==void 0&&(C$1.behavior==="smooth"||Math.abs(e.scrollTop-C$1.targetTop)<=fe)?0:e.scrollTop-o$1}function ve(e,n){n!==0&&(o$1=e.scrollTop-n,C$1=void 0,c());}function Ue(e,n){let i=Ve(e);if(k!==void 0)return k.expectedOffset-=i,ce(),ve(e,i),L||ue(),false;let y=K;if(y===void 0)return false;let I=w,A=I===void 0?void 0:H([I.id])[0],D=e.scrollTop-y.scrollTop,Q=Oe(e)?0:D,Ee=I===void 0||A===void 0?0:(A.anchorTop??A.top)-n.top-I.offset+D;return y.scrollHeight!==e.scrollHeight||y.width!==e.clientWidth||y.height!==e.clientHeight||Math.abs(Ee)>fe?(K=void 0,!W&&!t.loadingNewer&&t.resizeFollowEnabled&&ne.value&&Math.abs(Q)<=fe?(Fe(),true):(I!==void 0&&Ne({...I,offset:I.offset-Q}),ve(e,i),false)):false}function ae(){let e=f.value;if(J||e===null)return;let n=e.getBoundingClientRect();if(Ue(e,n))return;let i=R!==void 0&&G?t.messageIds.filter(D=>P.has(D)):t.messageIds,y=H(i);if(R!==void 0&&G&&y.length===0){ne.value=v(e);return}let I=y.filter(D=>B({viewportTop:n.top,viewportBottom:n.bottom,messageTop:D.top,messageBottom:D.bottom,margin:t.visibleMargin})).map(D=>D.id),A=I.length!==d.length||I.some((D,Q)=>d[Q]!==D);d=Object.freeze(I),w=o(y,{top:n.top,bottom:n.bottom}),U(e),T.acknowledgeVisible(I),ne.value=v(e),A&&a("visible-range",d),a("settled",{visibleMessageIds:d,...d.length===0?{}:{newestVisibleMessageId:d[d.length-1]},isAtBottom:ne.value,newMessageCount:p$1.value});}function Te(e){if($.add(e),S!==void 0)return;let n=()=>{S=void 0;let i=[...$];$.clear(),i.forEach(y=>y());};typeof globalThis.requestAnimationFrame=="function"?S=globalThis.requestAnimationFrame(n):S=globalThis.setTimeout(n,0);}function Se(){S!==void 0&&(typeof S=="number"&&typeof globalThis.cancelAnimationFrame=="function"?globalThis.cancelAnimationFrame(S):globalThis.clearTimeout(S),S=void 0,$.clear());}function le(){Te(ae);}function Re(){let e=f.value;if(e===null)return;let n=e.getBoundingClientRect(),i=o(H(),{top:n.top,bottom:n.bottom});i!==void 0&&(w=i,U(e));}function ye(){return j$1&&k===void 0&&!oe&&!t.loadingOlder}function ke(){Re(),j$1=false,te=ee,oe=true,a("reach-start"),Te(()=>{t.loadingOlder||(oe=false);});}function Ce(e){return t.hasNewer&&!W&&!t.loadingOlder&&!t.loadingNewer&&v(e)}function r(){W=true,ne.value=false,he=ee,a("reach-end"),Te(()=>{t.loadingNewer||(W=false);});}function l(){let e=f.value;e===null||ee===he||!Ce(e)||r();}function c(){let e=f.value;if(J||e===null)return;let n=e.scrollTop,i=Oe(e),y=C$1,I=false;if(y!==void 0){let D=Math.abs(n-y.targetTop)<=fe;I=y.behavior==="smooth"||D,(y.behavior!=="smooth"||D)&&(C$1=void 0);}!I&&!i&&!L&&k===void 0&&n!==o$1&&(L=true,Z=true,ee+=1);let A=L&&!I&&!i&&n!==o$1;if(A&&(a("user-scroll"),Te(V)),L&&!F&&Me(),!j$1&&Z&&ee!==te&&n<o$1&&n>rt()&&(j$1=true),k!==void 0&&!I)if(L){let D=Y();D!==void 0&&(k.expectedOffset=D);}else ce(),ue();ye()&&A&&n>=0&&m({previousScrollTop:o$1,currentScrollTop:n,topThreshold:t.olderPrefetchThreshold})&&ke(),A&&Ce(e)&&z({previousScrollTop:o$1,currentScrollTop:n,isAtBottom:v(e),isHistoryWindow:t.hasNewer,isPageSettling:I})&&r(),o$1=n,le();}function M(e,n="auto"){C$1={targetTop:e,behavior:n};}function N(e){let n=k,i=O.value;if(!(n===void 0||i===null)){if(n.visualOffset=Math.abs(e)<=fe?0:e,n.visualOffset===0){i.style.removeProperty("transform"),i.style.removeProperty("will-change");return}i.style.setProperty("transform",`translate3d(0, ${n.visualOffset}px, 0)`),i.style.setProperty("will-change","transform");}}function x(){z$1!==void 0&&(clearTimeout(z$1),z$1=void 0),k!==void 0&&k.visualOffset!==0&&(w=void 0,K=void 0);let e=O.value;e?.style.removeProperty("transform"),e?.style.removeProperty("will-change"),k=void 0,C$1=void 0;}function Y(){let e=f.value,n=k;if(e===null||n===void 0)return;let i=H().find(y=>y.id===n.anchor.id);if(i!==void 0)return (i.anchorTop??i.top)-e.getBoundingClientRect().top}function ce(){let e=k,n=Y();if(e===void 0||n===void 0)return;let i=e.expectedOffset-n;Math.abs(i)<=fe||(N(e.visualOffset+i),e.committed=false,e.attempts=0);}function de(){z$1!==void 0&&clearTimeout(z$1),z$1=setTimeout(()=>{z$1=void 0,!(L||k?.committed!==true)&&x();},sr);}function we(){let e=f.value,n=k;if(J||e===null||n===void 0||L)return;let i=n.visualOffset;if(Math.abs(i)<=fe){n.committed=true,de();return}let y=Math.max(0,e.scrollHeight-e.clientHeight),I=Math.min(y,Math.max(0,e.scrollTop-i));if(M(I),e.scrollTop=I,Math.abs(e.scrollTop-I)>fe){C$1=void 0,n.committed=false,n.attempts+=1,n.attempts<lr?ue():(x(),C$1=void 0,o$1=e.scrollTop);return}N(0),o$1=e.scrollTop,n.expectedOffset=Y()??n.expectedOffset,n.committed=true,n.attempts=0,de();}function ue(){z$1!==void 0&&clearTimeout(z$1),z$1=setTimeout(()=>{z$1=void 0,we();},Dt);}function Pe(e){e!==void 0&&(k===void 0&&(k={anchor:e,expectedOffset:e.offset,visualOffset:0,committed:false,attempts:0}),ce(),!L&&we());}function Ne(e){let n=f.value;if(n===null||e===void 0)return;let i=n.getBoundingClientRect(),y=q(e,H(),{top:i.top,bottom:i.bottom});if(y!==void 0){let I=Math.max(0,n.scrollHeight-n.clientHeight),A=Math.min(I,Math.max(0,n.scrollTop+y));M(A),n.scrollTop=A,o$1=n.scrollTop,K=void 0;}}function rt(){return Number.isFinite(t.olderPrefetchThreshold)?Math.max(0,t.olderPrefetchThreshold):0}function De(){C$1?.behavior==="smooth"&&(C$1=void 0),Z=false,L||(L=true,ee+=1),B$1!==void 0&&(clearTimeout(B$1),B$1=void 0);}function Le(){let e=f.value;e===null||ee===te||(k!==void 0&&x(),j$1=true,e.scrollTop<=rt()&&ye()&&ke());}function nt(){w=void 0,K=void 0,B$1!==void 0&&(clearTimeout(B$1),B$1=void 0),x(),L=false,Z=false,F=false,ie=void 0,X=void 0,ee+=1,te=-1,he=-1,j$1=true,oe=false,W=false,C$1=void 0;}function ot(){F||(B$1!==void 0&&(clearTimeout(B$1),B$1=void 0),L=false,Z=false,k!==void 0&&(k.attempts=0),we());}function Me(){F||(B$1!==void 0&&clearTimeout(B$1),B$1=setTimeout(()=>{B$1=void 0,ot();},Dt));}function it(){C$1=void 0,ot();}function at(e){F=true,De(),ie=e.touches?.[0]?.clientY;}function st(e){let n=e.touches?.[0]?.clientY;n!==void 0&&(ie!==void 0&&n>ie?Le():ie!==void 0&&n<ie&&l(),ie=n);}function He(){F=false,ie=void 0,Me();}function lt(e){De(),e.deltaY<0?Le():e.deltaY>0&&l(),Me();}function dt(e){e.pointerType!=="touch"&&(De(),X=e.clientY,Me());}function ut(e){e.pointerType==="touch"||!L||X===void 0||(e.clientY<X?Le():e.clientY>X&&l(),X=e.clientY,Me());}function Be(e){e.pointerType!=="touch"&&(X=void 0,Me());}function ct(e){["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "].includes(e.key)&&(De(),e.key==="ArrowUp"||e.key==="PageUp"||e.key==="Home"||e.key===" "&&e.shiftKey?Le():l(),Me());}function Fe(e="auto"){let n=f.value;if(n===null)return;K=void 0,x();let i=Math.max(0,n.scrollHeight-n.clientHeight);M(i,e),n.scrollTo?.({top:i,behavior:e}),n.scrollTop!==i&&(n.scrollTop=i),o$1=n.scrollTop,T.clear(),ae();}function ft(){let e=f.value;return e!==null&&e.clientWidth>0&&e.clientHeight>0}function Ht(){let e=f.value;return ft()&&e!==null&&e.scrollHeight>e.clientHeight+1}function Bt(e,n={}){let i=f.value,y=_.get(e);if(i===null||y===void 0||!i.contains(y)||i.clientHeight<=0)return false;x();let I=i.getBoundingClientRect(),A=y.getBoundingClientRect(),D=n.block??"center",Q;D==="start"?Q=i.scrollTop+A.top-I.top:D==="end"?Q=i.scrollTop+A.bottom-I.bottom:D==="nearest"?A.top>=I.top&&A.bottom<=I.bottom?Q=i.scrollTop:A.top<I.top?Q=i.scrollTop+A.top-I.top:Q=i.scrollTop+A.bottom-I.bottom:Q=j({currentScrollTop:i.scrollTop,scrollHeight:i.scrollHeight,targetHeight:A.height,targetTop:A.top,viewportHeight:i.clientHeight,viewportTop:I.top});let Ee=Math.max(0,i.scrollHeight-i.clientHeight),be=Math.min(Ee,Math.max(0,Q));K=void 0;let xe=n.behavior??"auto";return M(be,xe),i.scrollTo?.({top:be,behavior:xe}),i.scrollTop!==be&&(i.scrollTop=be),o$1=i.scrollTop,ae(),true}function Ft(){T.clear();}function _t(){W=true,ne.value=false;}function jt(){W=false,le();}function Kt(e,n){let i=_.get(e);if(i!==void 0&&i!==n&&(R?.unobserve(i),E?.unobserve?.(i),h.delete(i),P.delete(e)),n===null){_.delete(e),P.delete(e);return}_.set(e,n),h.set(n,e),R?.observe(n),E?.observe(n),le();}function Ut(e,n,i){let y=g$1.get(e);if(i===null){g$1.delete(e);return}g$1.set(e,{element:i,label:n}),re===e&&i.style.setProperty("opacity",String(s)),y?.element!==i&&(i.dataset.imThreadDateSeparator=e);}return provide(ze,{registerMessageNode:Kt,registerDateNode:Ut}),watch(()=>t.contentKey,(e,n)=>{if(e===n)return;nt();let i=f.value;i!==null&&(o$1=i.scrollTop);},{flush:"sync"}),watch(()=>t.messageIds,async(e,n)=>{let i=f.value;if(i===null)return;let y=new Set(n);n.length>0&&e.length>0&&!e.some(Ie=>y.has(Ie))&&nt();let A=i.getBoundingClientRect(),D=p(w,H(),{top:A.top,bottom:A.bottom}),Q=ne.value,Ee=n[n.length-1],be=Ee===void 0?-1:e.indexOf(Ee),xe=be<0?[]:e.slice(be+1).filter(Ie=>!y.has(Ie)),mt=W||t.loadingNewer,qt=e.length===n.length&&e.every(Ie=>y.has(Ie))&&e.some((Ie,qe)=>Ie!==n[qe]);if(await nextTick(),J)return;if(qt&&Q&&t.followNewMessages&&t.resizeFollowEnabled&&!t.hasNewer&&!mt){Fe();return}let gt=n[0];if(gt!==void 0&&e.indexOf(gt)>0&&(oe=false,Pe(D)),xe.length>0){if(mt){W=false,k===void 0&&Ne(D),ne.value=false,le();return}(Q||xe.some(qe=>t.shouldFollowAppendedMessage?.(qe)===true))&&t.followNewMessages?Fe():T.add(xe);}le();},{flush:"pre"}),watch(()=>t.loadingNewer,(e,n)=>{e||!n||!W||Te(()=>{t.loadingNewer||(W=false);});},{flush:"pre"}),watch(()=>t.loadingOlder,(e,n)=>{e||!n||!oe||Te(()=>{t.loadingOlder||(oe=false);});},{flush:"pre"}),onMounted(()=>{let e=f.value;if(e!==null){if(o$1=e.scrollTop,e.addEventListener("scroll",c,{passive:true}),e.addEventListener("scrollend",it,{passive:true}),e.addEventListener("touchstart",at,{passive:true}),e.addEventListener("touchmove",st,{passive:true}),e.addEventListener("touchend",He,{passive:true}),e.addEventListener("touchcancel",He,{passive:true}),e.addEventListener("wheel",lt,{passive:true}),e.addEventListener("pointerdown",dt,{passive:true}),e.addEventListener("pointermove",ut,{passive:true}),e.addEventListener("pointerup",Be,{passive:true}),e.addEventListener("pointercancel",Be,{passive:true}),e.addEventListener("keydown",ct),typeof globalThis.ResizeObserver=="function"){E=new globalThis.ResizeObserver(()=>{J||f.value===null||ae();}),E.observe(e),O.value!==null&&E.observe(O.value);for(let n of _.values())E.observe(n);}if(typeof globalThis.IntersectionObserver=="function"){R=new globalThis.IntersectionObserver(n=>{for(let i of n){let y=h.get(i.target);y!==void 0&&(i.isIntersecting?P.add(y):P.delete(y));}G=true,le();},{root:e,rootMargin:`${Number.isFinite(t.visibleMargin)?Math.max(0,t.visibleMargin):0}px 0px`});for(let n of _.values())R.observe(n);}le();}}),onBeforeUnmount(()=>{J=true;let e=f.value;e!==null&&e.removeEventListener("scroll",c),e!==null&&(e.removeEventListener("scrollend",it),e.removeEventListener("touchstart",at),e.removeEventListener("touchmove",st),e.removeEventListener("touchend",He),e.removeEventListener("touchcancel",He),e.removeEventListener("wheel",lt),e.removeEventListener("pointerdown",dt),e.removeEventListener("pointermove",ut),e.removeEventListener("pointerup",Be),e.removeEventListener("pointercancel",Be),e.removeEventListener("keydown",ct)),B$1!==void 0&&clearTimeout(B$1),x(),Se(),E?.disconnect(),R?.disconnect(),q$1(),_.clear(),h.clear(),P.clear(),g$1.clear(),T.clear();}),m$1({getViewportElement:()=>f.value,clearNewMessageBadge:Ft,clearActiveDate:q$1,isAtBottom:computed(()=>ne.value),isMeasurable:ft,isScrollable:Ht,newMessageCount:computed(()=>p$1.value),prepareHistoryPageAppend:_t,cancelHistoryPageAppend:jt,trackRemoteMessageIds:(e,n)=>T.trackRemote(e,n),scrollToLatest:Fe,scrollToMessage:Bt,focusViewport:()=>f.value?.focus({preventScroll:true})}),()=>h$1("div",{ref:f,"data-im-thread-viewport":"",role:"log",tabindex:-1},[h$1("div",{ref:O,"data-im-thread-viewport-content":""},u.default?.())])}});var Lt=Symbol("ImThreadSurfaceContext");function cr(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 fr(t){provide(Lt,t);}function Xe(){let t=inject(Lt);if(t===void 0)throw new Error("ImThreadSurface \u9700\u8981\u663E\u5F0F context prop \u6216 provideImThreadSurfaceContext");return t}var Qe=Object.freeze({followThreshold:120,olderPrefetchThreshold:120,visibleReadDelay:300,visibleMargin:8,activeDateOffset:16,activeDateIdleDelay:1500}),Ze=Object.freeze({enabled:true,maxFillPages:8}),pr=8,hr=160;function vr(t,a){return t?.conversationType===a.conversationType&&t.conversationId===a.conversationId}var Tr=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:m}){let u=t.context??Xe(),f=ref(null),O=ref(0),_=ref(true),h=[],P,g=0,o=0,d=null,w="",K="",E="",R=false,G=false,S=ref(false),$=ref(""),J=ref(false),C,re,s=computed(()=>u.getState()),W=computed(()=>s.value.pageVisible??u.isPageVisible?.()??true),oe=computed(()=>s.value.pageEngaged??u.isPageEngaged?.()??true),j=computed(()=>vr(s.value.activeConversation,t.conversation)),L=computed(()=>({...Qe,...t.viewportOptions})),Z=computed(()=>{let r=t.initialViewportOptions.maxFillPages??Ze.maxFillPages;return {enabled:t.initialViewportOptions.enabled??Ze.enabled,maxFillPages:Number.isFinite(r)?Math.max(0,Math.floor(r)):Ze.maxFillPages}}),F=computed(()=>!j.value||!s.value.ready?"":`${t.conversation.conversationType}\0${t.conversation.conversationId}`),ee=computed(()=>j.value?i({messages:s.value.messages,entryUnread:s.value.entryUnread,formatDate:u.formatDate,leadingItems:u.leadingItems?.(),beforeMessageItems:u.beforeMessageItems}):[]),te=computed(()=>ee.value.flatMap(r=>r.kind==="message"||r.kind==="system"?[r.message.id]:[]));function he(){C!==void 0&&(clearTimeout(C),C=void 0),re!==void 0&&(clearTimeout(re),re=void 0);}function B(r=false){if(he(),J.value=false,r){f.value?.clearActiveDate(),$.value="";return}re=setTimeout(()=>{re=void 0,!J.value&&(f.value?.clearActiveDate(),$.value="");},hr);}function ie(r){if(r===null){B();return}he(),$.value=r.label,J.value=true;let l=L.value.activeDateIdleDelay,c=Number.isFinite(l)?Math.max(0,l):Qe.activeDateIdleDelay;C=setTimeout(()=>{C=void 0,B();},c);}async function X(r,l){t.hooks?.beforeAction?.(r);try{let c=await l();return t.hooks?.afterAction?.(r,c),c}catch(c){throw t.hooks?.onError?.(r,c),c}}function k(r="automatic"){return !j.value||s.value.loading||!s.value.hasOlder?Promise.resolve(0):X({kind:"load-older",source:r},()=>u.actions.loadOlder())}function z(){let r=u.actions.loadNewer,l=s.value.loadingNewer??s.value.loading;return !j.value||l||!s.value.hasNewer||r===void 0?Promise.resolve(0):X({kind:"load-newer"},()=>r())}async function ne(r){for(let l=0;l<pr;l+=1){if(!j.value)return;let c=r==="older"?s.value.hasOlder:s.value.hasNewer,M=r==="older"?s.value.olderError:s.value.newerError;if(!c||M!==null||(r==="older"?await k("user-scroll"):await z())>0)return;let x=r==="older"?s.value.hasOlder:s.value.hasNewer,Y=r==="older"?s.value.olderError:s.value.newerError;if(!x||Y!==null)return}}async function p(){return !j.value||u.actions.loadNewer===void 0?0:X({kind:"load-newer"},()=>u.actions.retryNewer?.()??u.actions.loadNewer?.({force:!0})??Promise.resolve(0))}async function T(){if(!j.value)return 0;let r=F.value,l=++g;d=null,E="";let c;try{c=await X({kind:"retry-older"},()=>u.actions.retryOlder?.()??u.actions.loadOlder({force:!0}));}catch(M){throw ae(r,l)&&(E=r),M}return ae(r,l)&&!S.value&&(d=null,Re()),c}async function v(){if(!j.value)return false;let r=F.value,l=++o;return ye(true),R=true,w=r,K=Se(s.value.entryUnread),!await X({kind:"jump-to-latest"},()=>u.actions.jumpToLatest?.()??Promise.resolve(!s.value.isHistoryWindow))||!q(r,l)||(await nextTick(),!q(r,l))?false:(f.value?.scrollToLatest(),true)}function H(r){_.value=r.isAtBottom,O.value=r.newMessageCount,Re();}function b(r,l){return f.value?.scrollToMessage(r,l)??false}function q(r,l){return !G&&o===l&&F.value===r&&j.value}async function V(r,l,c,M){for(let N=0;N<60;N+=1){if(!q(r,l))return false;if(b(c,M))return true;await nextTick(),typeof window<"u"&&typeof window.requestAnimationFrame=="function"&&await new Promise(x=>window.requestAnimationFrame(()=>x()));}return false}async function U(r,l,c){let M=f.value;if(M===null||!M.isMeasurable()||M.isScrollable())return true;let N=0,x=!s.value.hasOlder,Y=!s.value.hasNewer||u.actions.loadNewer===void 0,ce=async()=>(await nextTick(),await nextTick(),V(r,l,c,{behavior:"auto",block:"center"})),de=async ue=>{if(!q(r,l)||N>=Z.value.maxFillPages)return false;let Pe=0;if(ue==="older"){if(x||!s.value.hasOlder)return false;Pe=await k(),x=!s.value.hasOlder;}else {if(Y||!s.value.hasNewer)return false;M.prepareHistoryPageAppend();try{Pe=await z();}catch(Ne){throw M.cancelHistoryPageAppend(),Ne}Pe<=0&&!s.value.hasNewer&&M.cancelHistoryPageAppend(),Y=!s.value.hasNewer;}return N+=1,Pe>0?ce():!(ue==="older"?x:Y)};!x&&!await de("older")&&(x=true),!Y&&!await de("newer")&&(Y=true);let we="older";for(;q(r,l)&&N<Z.value.maxFillPages&&M.isMeasurable()&&!M.isScrollable()&&(!x||!Y);){let ue=we==="older"?x?"newer":"older":Y?"older":"newer";we=ue==="older"?"newer":"older",await de(ue)||(ue==="older"?x=true:Y=true);}return q(r,l)}async function Oe(r,l={behavior:"auto",block:"center"}){if(!j.value||r==="")return false;let c=F.value,M=++o;if(!te.value.includes(r)){let Y=u.actions.loadAround;if(Y===void 0||!await X({kind:"locate-message",messageId:r},()=>Y(r))||!q(c,M))return false}return !await V(c,M,r,{...l,behavior:"auto"})||!await U(c,M,r)?false:V(c,M,r,l)}function Ve(){P!==void 0&&(clearTimeout(P),P=void 0);}function ve(){if(Ve(),!S.value)return;let r=t.readActions;if(r===void 0||h.length===0)return;let l=Number.isFinite(L.value.visibleReadDelay)?Math.max(0,L.value.visibleReadDelay):Qe.visibleReadDelay;P=setTimeout(()=>{if(P=void 0,!j.value||!oe.value)return;let c=h[h.length-1];if(c===void 0)return;let M=r.resolveTarget===void 0?c:r.resolveTarget(c);M!=null&&Promise.resolve(r.markRead(M)).catch(N=>{t.hooks?.onError?.({kind:"visible-range",messageIds:h},N);});},l);}function Ue(r){h=Object.freeze([...r]);let l={kind:"visible-range",messageIds:h};t.hooks?.beforeAction?.(l);try{u.actions.onVisibleRange?.(h),t.hooks?.afterAction?.(l,void 0);}catch(c){throw t.hooks?.onError?.(l,c),c}S.value?ve():Re();}function ae(r,l){return !G&&g===l&&F.value===r&&!R}function Te(r,l){ae(r,l)&&(w=r,K=Se(s.value.entryUnread),S.value=true,ve());}function Se(r){return r.state!=="located"?r.state:`${r.state}:${r.firstMessageId}`}async function le(r,l,c){for(let M=0;M<60;M+=1){if(!ae(r,l))return false;if(f.value?.scrollToMessage(c,{behavior:"auto",block:"center"})===true)return true;await nextTick(),typeof window<"u"&&typeof window.requestAnimationFrame=="function"&&await new Promise(x=>window.requestAnimationFrame(()=>x()));}return false}function Re(){let r=F.value,l=Se(s.value.entryUnread);if(r===""||s.value.loading||s.value.error!==null&&s.value.messages.length===0||w===r&&(K===l||R)||E===r||d!==null)return;if(!Z.value.enabled){w=r,K=l,S.value=true,ve();return}let c=++g;R=false,S.value=false;let M=(async()=>{if(await nextTick(),!ae(r,c))return;let N=f.value;if(N===null||!N.isMeasurable())return;let x=s.value.entryUnread;if(x.state==="located"&&!te.value.includes(x.firstMessageId))return;let Y=x.state==="located"?await le(r,c,x.firstMessageId):false;if(x.state==="located"&&!Y)return;Y||N.scrollToLatest();let ce=0;for(;ae(r,c)&&ce<Z.value.maxFillPages&&s.value.error===null&&s.value.hasOlder&&N.isMeasurable()&&!N.isScrollable();)if(await k(),!ae(r,c)||(ce+=1,await nextTick(),await nextTick(),!N.isMeasurable()))return;if(!ae(r,c)||!N.isMeasurable())return;let de=s.value.entryUnread;if(de.state==="located"){if(!te.value.includes(de.firstMessageId)||!await le(r,c,de.firstMessageId))return}else N.scrollToLatest();await nextTick(),Te(r,c);})().catch(()=>{ae(r,c)&&(E=r);}).finally(()=>{d===M&&(d=null);});d=M;}function ye(r,l=false){g+=1,d=null,R=false,S.value=r,r||(w="",K="",l||(E="")),Ve();}function ke(){if(S.value)return;let r=F.value;R=true,g+=1,d=null,w=r,S.value=true,ve();}let Ce=Object.freeze({getViewportElement:()=>f.value?.getViewportElement()??null,loadOlder:k,retryOlder:T,loadNewer:z,retryNewer:p,jumpToLatest:v,scrollToMessage:b,locateMessage:Oe,focusViewport:()=>f.value?.focusViewport()});return a(Ce),watch(oe,r=>{r&&S.value?ve():Ve();}),watch([()=>s.value.activeRemoteMessageRevision??0,f,F],()=>{let r=f.value;if(r===null||!j.value)return;let l=u.actions.drainActiveRemoteMessageIds?.()??[];r.trackRemoteMessageIds(l,{isAtBottom:_.value,isHistoryWindow:s.value.isHistoryWindow,isPageVisible:W.value})&&(_.value=false);},{flush:"post"}),watch([F,()=>s.value.loading,()=>s.value.error,()=>te.value.length,()=>s.value.hasOlder,()=>Se(s.value.entryUnread),Z],([r,l,c,,,M],[N,,,,,x])=>{if(r!==N&&(o+=1,ye(false),B(true),f.value?.clearNewMessageBadge(),O.value=0,_.value=true),r!==""&&r===N&&M!==x&&!R&&M.startsWith("located:")&&(w="",K="",S.value=false),r===""){ye(false);return}if(c!==null&&s.value.messages.length===0){S.value||ye(false,true);return}l||Re();},{flush:"post",immediate:true}),onBeforeUnmount(()=>{G=true,o+=1,ye(false),B(true);}),()=>{let r={conversation:t.conversation,state:s.value,items:ee.value,actions:Ce,initialViewportSettled:F.value!==""&&(s.value.messages.length===0?!s.value.loading&&s.value.error===null&&!s.value.hasOlder:S.value&&w===F.value)},l=[m.header?.(r),m["before-list"]?.(r)];if(!j.value)l.push(m.unsupported?.(r)??h$1("div",{"data-im-thread-unsupported":""}));else if(!s.value.ready&&s.value.loading)l.push(m.loading?.(r)??h$1("div",{"data-im-thread-loading":""}));else if(s.value.error!==null&&s.value.messages.length===0)l.push(m.error?.(r)??h$1("div",{"data-im-thread-error":""}));else if(s.value.ready&&s.value.messages.length===0&&!s.value.hasOlder)l.push(m.empty?.(r)??h$1("div",{"data-im-thread-empty":""}));else {let c=h$1($e,{ref:f,messageIds:te.value,contentKey:`${t.conversation.conversationType}\0${t.conversation.conversationId}`,loadingOlder:s.value.loadingOlder??s.value.loading,hasNewer:s.value.hasNewer,loadingNewer:s.value.loadingNewer??s.value.loading,followThreshold:L.value.followThreshold,olderPrefetchThreshold:L.value.olderPrefetchThreshold,visibleMargin:L.value.visibleMargin,activeDateOffset:L.value.activeDateOffset,activeDateEnabled:m["active-date"]!==void 0,resizeFollowEnabled:S.value,followNewMessages:W.value,shouldFollowAppendedMessage:M=>{let N=s.value.messages.find(x=>x.id===M);return N===void 0?false:u.shouldFollowMessage?.(N)===true},onReachStart:()=>{ne("older").catch(()=>{});},onReachEnd:()=>{ne("newer").catch(()=>{});},onSettled:H,onUserScroll:ke,onActiveDateChange:ie,onVisibleRange:Ue,onNewMessageCount:M=>{O.value=M;}},{default:()=>[m["viewport-before"]?.(r),h$1(Ye,{items:ee.value,rendererRegistry:t.rendererRegistry,presentation:t.presentation,readActions:t.readActions},{item:m.item,"date-separator":m["date-separator"],"entry-unread":m["entry-unread"],encryption:m.encryption,system:m.system,message:m.message,"recalled-message":m["recalled-message"],"deleted-message":m["deleted-message"],"unsupported-body":m["unsupported-body"]}),m["viewport-after"]?.(r)]});l.push(h$1("div",{"data-im-thread-viewport-shell":""},[m["active-date"]?.({label:$.value,visible:J.value&&$.value!==""}),c])),s.value.error!==null&&l.push(m.error?.(r)??h$1("div",{"data-im-thread-error":""}));}return l.push(m["after-list"]?.(r),m["jump-to-latest"]?.({...r,count:O.value,visible:!_.value||s.value.isHistoryWindow}),m["context-menu"]?.(r),m.composer?.(r)),h$1("section",{"data-im-thread-surface":"","data-conversation-type":t.conversation.conversationType,"data-conversation-id":t.conversation.conversationId},l)}}});function yr(t){let a=new Map;for(let u of t){if(a.has(u.kind))throw new Error(`\u6D88\u606F renderer kind \u91CD\u590D\u6CE8\u518C\uFF1A${u.kind}`);a.set(u.kind,u.component);}let m=Object.freeze([...a.keys()]);return Object.freeze({kinds:m,resolve:u=>a.get(u)})}var Ir=140,wr=120;function Ke(t,a){if(t.width<=0||t.height<=0)return 0;let m=Math.max(0,Math.min(t.right,a.right)-Math.max(t.left,a.left)),u=Math.max(0,Math.min(t.bottom,a.bottom)-Math.max(t.top,a.top));return Math.min(1,m*u/(t.width*t.height))}function et(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 tt(t){let a=Math.max(0,t.scrollIdleMs??Ir),m=Math.max(0,t.visibilityDwellMs??wr),u=Math.min(1,Math.max(0,t.minimumIntersectionRatio??.01)),f=Math.max(0,t.revealMarginPx??0),O=Math.max(0,t.preloadMarginPx??0),_=Math.max(f,O),h=Math.max(0,t.maxPreloadTargets??Number.POSITIVE_INFINITY),P=Math.max(1,t.maxSettledVisible??Number.POSITIVE_INFINITY),g=new Map,o=new Map,d=reactive(new Set),w=new Set,K=new Set,E=[],R=null,G=null,S=null,$=false,J=false,C=false,re=false,s,W;function oe(){s!==void 0&&clearTimeout(s),s=void 0;}function j(){W!==void 0&&clearTimeout(W),W=void 0;}function L(p=false){if(!p&&G!==null||R===null)return;let T=R.getBoundingClientRect(),v=et(T,_);for(let[H,b]of g){let q=H.getBoundingClientRect();b.ratio=Ke(q,T),b.intersecting=b.ratio>0,b.revealIntersecting=_>0?Ke(q,v)>0:b.intersecting&&b.ratio>=u;}}function Z(p){return p.intersecting&&p.ratio>=u}function F(){for(let[p,T]of g)!T.revealIntersecting||d.has(T.key)||_>f&&(f===0&&!Z(T)||f>0&&(R===null||Ke(p.getBoundingClientRect(),et(R.getBoundingClientRect(),f))<=0))||(d.add(T.key),t.onRevealed?.(T.item));}function ee(p,T=false){let v=new Set(p.map(b=>b.key));if(!(!(v.size!==K.size||[...v].some(b=>!K.has(b)))&&!T)){K.clear();for(let b of v)K.add(b);t.onSettledVisibleChange?.(p.map(b=>b.item));}}function te(p,T=false){!T&&p.length===E.length&&p.every((v,H)=>v.key===E[H]?.key&&v.item===E[H]?.item)||(E=p,t.onSettledPreloadChange?.(p.map(v=>v.item)));}function he(){if(C||$)return;let p=J;J=false,L(),F();let T=R?.getBoundingClientRect(),v=T===void 0?0:(T.top+T.bottom)/2,H=[...g.entries()].filter(([,b])=>Z(b)).sort(([b],[q])=>{let V=b.getBoundingClientRect(),U=q.getBoundingClientRect();return Math.abs((V.top+V.bottom)/2-v)-Math.abs((U.top+U.bottom)/2-v)}).slice(0,P).map(([,b])=>b);if(ee(H,p),t.onSettledPreloadChange!==void 0&&T!==void 0){let b=et(T,O),q=[...g.entries()].filter(([,V])=>V.revealIntersecting).map(([V,U])=>({target:U,rect:V.getBoundingClientRect()})).filter(({target:V,rect:U})=>Z(V)||O>0&&Ke(U,b)>0).sort((V,U)=>Number(Z(U.target))-Number(Z(V.target))||Math.abs((V.rect.top+V.rect.bottom)/2-v)-Math.abs((U.rect.top+U.rect.bottom)/2-v)).slice(0,h).map(({target:V})=>V);te(q,p);}for(let b of H)w.has(b.key)||(w.add(b.key),t.onActivated?.(b.item));}function B(){C||$||(j(),W=setTimeout(()=>{W=void 0,he();},m));}function ie(){C||(J=true,X(true),te([]),L(),F(),ee([]),j(),oe(),s=setTimeout(()=>{s=void 0,X(false),B();},a));}function X(p){$!==p&&($=p,t.onScrollingChange?.(p));}function k(){R?.removeEventListener("scroll",ie),G?.disconnect(),S?.disconnect(),G=null,S=null,R=null;}function z(p=true){if(C)return;let T=t.getRoot();if(!(T===R&&R!==null)){if(te([]),k(),R=T,R===null){p&&!re&&(re=true,Promise.resolve().then(()=>{re=false,C||(z(false),B());}));return}if(R.addEventListener("scroll",ie,{passive:true}),typeof IntersectionObserver<"u"){G=new IntersectionObserver(v=>{for(let H of v){let b=g.get(H.target);b!==void 0&&(b.intersecting=H.isIntersecting,b.ratio=H.intersectionRatio,_===0&&(b.revealIntersecting=H.isIntersecting&&H.intersectionRatio>=u));}F(),B();},{root:R,threshold:[0,u,1]}),_>0&&(S=new IntersectionObserver(v=>{for(let H of v){let b=g.get(H.target);b!==void 0&&(b.revealIntersecting=H.isIntersecting);}F(),B();},{root:R,rootMargin:`${_}px 0px`,threshold:0}));for(let v of g.keys())G.observe(v);for(let v of g.keys())S?.observe(v);}else L(),F();}}function ne(p){te(E.filter(T=>T.key!==p)),d.delete(p),w.delete(p),K.delete(p);}return {register(p,T){if(C)return;let v=t.getKey(p),H=d.has(v),b=w.has(v),q=T===null?void 0:g.get(T);q!==void 0&&q.key!==v&&(o.delete(q.key),g.delete(T),ne(q.key));let V=o.get(v);if(V!==void 0&&V!==T&&(G?.unobserve(V),S?.unobserve(V),g.delete(V),o.delete(v)),T===null){V!==void 0&&(G?.unobserve(V),S?.unobserve(V),g.delete(V),o.delete(v)),ne(v);return}let U=g.get(T);if(U?.key===v&&U.item===p){z();return}g.set(T,{item:p,key:v,intersecting:U?.key===v?U.intersecting:false,ratio:U?.key===v?U.ratio:0,revealIntersecting:U?.key===v?U.revealIntersecting:false}),o.set(v,T),z(),G?.observe(T),S?.observe(T),L(true),F(),H&&t.onRevealed?.(p),b&&t.onActivated?.(p),B();},isRevealed:p=>d.has(t.getKey(p)),isActivated:p=>w.has(t.getKey(p)),isSettledVisible:p=>K.has(t.getKey(p)),isScrolling:()=>$,notifyScroll:ie,refresh(){z(),L(true),F(),B();},reset(){oe(),j(),X(false),J=false,ee([]),te([]),k(),g.clear(),o.clear(),d.clear(),w.clear();},dispose(){C||(oe(),j(),X(false),J=false,ee([]),te([]),k(),g.clear(),o.clear(),d.clear(),w.clear(),C=true);}}}function Mr(t){let a=new Map,m=new Map,u=false,f=h=>{let P=a.get(h.channel);return P===void 0?h.channel:`${h.channel}\0${P.getKey(h.item)}`},O=tt({getRoot:t.getRoot,getKey:f,revealMarginPx:t.revealMarginPx,preloadMarginPx:t.preloadMarginPx,minimumIntersectionRatio:t.minimumIntersectionRatio,scrollIdleMs:t.scrollIdleMs,visibilityDwellMs:t.visibilityDwellMs,onScrollingChange:h=>{for(let P of a.values())P.onScrollingChange?.(h);},onRevealed:h=>a.get(h.channel)?.onRevealed?.(h.item),onActivated:h=>a.get(h.channel)?.onActivated?.(h.item),onSettledPreloadChange:h=>{for(let[P,g]of a){let o=h.filter(d=>d.channel===P).map(d=>d.item);g.onSettledPreloadChange?.(o.slice(0,Math.max(0,g.maxPreloadTargets??Number.POSITIVE_INFINITY)));}},onSettledVisibleChange:h=>{for(let[P,g]of a){let o=h.filter(w=>w.channel===P).map(w=>w.item),d=g.maxSettledVisible===void 0?o:o.slice(0,g.maxSettledVisible);g.onSettledVisibleChange?.(d);}}});function _(h){return P=>{if(u)throw new Error("Thread visibility target group \u5DF2\u91CA\u653E");if(a.has(h))throw new Error(`Thread visibility channel \u5DF2\u5B58\u5728: ${h}`);a.set(h,P);let g=new Map;m.set(h,g);let o=false,d=E=>({channel:h,item:E});function w(){for(let E of g.values())O.register(E.target,null);g.clear(),P.onScrollingChange?.(false),P.onSettledVisibleChange?.([]),P.onSettledPreloadChange?.([]);}return {register(E,R){if(o||u)return;let G=P.getKey(E),S=g.get(G);if(R===null){S!==void 0&&(O.register(S.target,null),g.delete(G));return}let $=S?.target.item===E?S.target:d(E);g.set(G,{target:$,element:R}),O.register($,R);},isRevealed:E=>O.isRevealed(d(E)),isActivated:E=>O.isActivated(d(E)),isSettledVisible:E=>O.isSettledVisible(d(E)),isScrolling:O.isScrolling,notifyScroll:O.notifyScroll,refresh:O.refresh,reset:w,dispose(){o||(w(),o=true,a.delete(h),m.delete(h));}}}}return {createFactory:_,refresh:O.refresh,dispose(){if(!u){for(let h of m.values())for(let P of h.values())O.register(P.target,null);for(let h of a.values())h.onSettledPreloadChange?.([]);m.clear(),a.clear(),O.dispose(),u=true;}}}}export{We as ImThreadBodySwitch,Ye as ImThreadItems,Tr as ImThreadSurface,$e as ImThreadViewport,cr as createImThreadSurfaceContext,yr as createMessageRendererRegistry,Mr as createThreadVisibilityTargetGroup,tt as createThreadVisibilityTargets,fr as provideImThreadSurfaceContext,Wt as useImText,Xe as useImThreadSurfaceContext,$t as useOptionalImThreadReadActions};
|
package/dist/chat-kit.d.ts
CHANGED
|
@@ -1849,6 +1849,41 @@ interface ImSessionFavoritePort {
|
|
|
1849
1849
|
delete: (collectIds: readonly string[]) => Promise<void>;
|
|
1850
1850
|
}
|
|
1851
1851
|
|
|
1852
|
+
/**
|
|
1853
|
+
* SDK 已取得的最近一页请求结果;只是可重建缓存,不代表消息已进入 DomainState 或处理过入站副作用。
|
|
1854
|
+
* 消息、Reaction 与分页边界必须整页原子保存,只有前台实际消费时才进入正常消息流程。
|
|
1855
|
+
*/
|
|
1856
|
+
interface ImRecentHistoryPage {
|
|
1857
|
+
/** 缓存记录格式版本;不认识的版本不能当作有效页使用。 */
|
|
1858
|
+
version: 1;
|
|
1859
|
+
/** 当前账号内的精确 GROUP/CHANNEL 会话;direct 没有此远端最近页能力。 */
|
|
1860
|
+
conversation: ConversationRef<'group' | 'channel'>;
|
|
1861
|
+
/** 成功获取页面的毫秒时间,用于保留期限和按获取时间淘汰。 */
|
|
1862
|
+
fetchedAt: number;
|
|
1863
|
+
/** SDK 生成的请求与会话状态指纹;存储层不解释其内容。 */
|
|
1864
|
+
fingerprint: string;
|
|
1865
|
+
/** 已净化的消息事实,缓存保存不得发布消息或已读事件。 */
|
|
1866
|
+
messages: readonly ImMessage[];
|
|
1867
|
+
/** 解码时暂存的 Reaction 事实,预取阶段不得提前应用。 */
|
|
1868
|
+
reactions: readonly ImReactionEvent[];
|
|
1869
|
+
/** 服务端是否明确没有更早一页,空页也保留这一结果。 */
|
|
1870
|
+
exhausted: boolean;
|
|
1871
|
+
/** 服务端返回的向旧游标,存储层仅原样保存。 */
|
|
1872
|
+
nextCursor?: string;
|
|
1873
|
+
/** SDK 按净化后的整页计算的字节数,用于存储预算。 */
|
|
1874
|
+
byteLength: number;
|
|
1875
|
+
}
|
|
1876
|
+
/** 账号隔离的最近页缓存;过期、淘汰或清理后重新请求即可,不影响消息真相。 */
|
|
1877
|
+
interface ImRecentHistoryCachePort {
|
|
1878
|
+
/** 读取精确会话的整页;不存在或超过保留期限时返回 null。 */
|
|
1879
|
+
get: (conversation: ConversationRef<'group' | 'channel'>) => Promise<ImRecentHistoryPage | null>;
|
|
1880
|
+
/** 原子保存整页;仅 durable 事务提交后返回 true,预算或保留期限不允许时返回 false。 */
|
|
1881
|
+
put: (page: ImRecentHistoryPage) => Promise<boolean>;
|
|
1882
|
+
/** 删除精确会话的缓存页,不删除正常历史或会话。 */
|
|
1883
|
+
delete: (conversation: ConversationRef<'group' | 'channel'>) => Promise<void>;
|
|
1884
|
+
/** 清空当前账号的最近页缓存。 */
|
|
1885
|
+
clear: () => Promise<void>;
|
|
1886
|
+
}
|
|
1852
1887
|
/** 迁移期存储会话入参;新代码使用 ref,string 仅兼容唯一命中的旧调用。 */
|
|
1853
1888
|
type ImStorageConversation = ConversationRef | string;
|
|
1854
1889
|
/** 打开账号库的选项。namespace = 账号隔离键(登录 userId)。 */
|
|
@@ -1997,6 +2032,8 @@ type StoredConversationBackground = {
|
|
|
1997
2032
|
* 失败经 `error` 事件(scope:'storage')暴露、不静默吞、不阻塞内存主流程。
|
|
1998
2033
|
*/
|
|
1999
2034
|
interface ImStoragePort {
|
|
2035
|
+
/** 可选的最近页持久缓存;缺少该能力时 SDK 必须明确跳过持久预取。 */
|
|
2036
|
+
recentHistoryCache?: ImRecentHistoryCachePort;
|
|
2000
2037
|
/** 打开/创建账号库并跑迁移(幂等)。open 前的读写应视为未就绪并抛错(不静默兜底)。 */
|
|
2001
2038
|
open: (options: ImStorageOpenOptions) => Promise<void>;
|
|
2002
2039
|
/** 关闭库句柄(登出/切账号)。 */
|
|
@@ -2158,6 +2195,10 @@ interface ImStoragePort {
|
|
|
2158
2195
|
type ImEvent = {
|
|
2159
2196
|
type: 'connection:changed';
|
|
2160
2197
|
state: ImConnectionState;
|
|
2198
|
+
}
|
|
2199
|
+
/** 同账号已由另一个浏览器页面接管;本页会话不可复用,但宿主登录仍有效。 */
|
|
2200
|
+
| {
|
|
2201
|
+
type: 'session:replaced';
|
|
2161
2202
|
} | {
|
|
2162
2203
|
type: 'message:received';
|
|
2163
2204
|
message: ImMessage;
|
|
@@ -2869,10 +2910,11 @@ interface MediaTransferAdapterConfig {
|
|
|
2869
2910
|
*/
|
|
2870
2911
|
rangeDownload?: boolean;
|
|
2871
2912
|
/**
|
|
2872
|
-
* 媒体发送阶段的并发上限;由 im-core
|
|
2913
|
+
* 媒体发送阶段的并发上限;由 im-core 消费,限制媒体任务数而非分片请求数。
|
|
2873
2914
|
*
|
|
2874
|
-
*
|
|
2875
|
-
* 缺省 5
|
|
2915
|
+
* 并发按媒体体积分两档:不超过分片阈值(16 MiB)的非视频媒体走小文件档,
|
|
2916
|
+
* 缺省 5;视频与超过阈值(或字节数未知)的内容走大文件档,缺省 3。
|
|
2917
|
+
* 分档只限制媒体任务数;实际 PUT/UploadPart 另受 adapter 的六路数据请求限制。
|
|
2876
2918
|
* 两档都只接受 1-6 的整数,超出范围由 core 显式报错。
|
|
2877
2919
|
* - 传一个数字:所有媒体共用这一个并发数,与分档前的语义一致。
|
|
2878
2920
|
* - 传 `{ total, largeFiles }`:显式分档,`largeFiles` 不得超过 `total`。
|
|
@@ -2921,8 +2963,8 @@ interface IndexedDbStorageAdapterOptions {
|
|
|
2921
2963
|
maxPendingWriteBytes?: number;
|
|
2922
2964
|
};
|
|
2923
2965
|
}
|
|
2924
|
-
/** 官方浏览器 adapter
|
|
2925
|
-
type IndexedDbStorageAdapter = ImStoragePort & MediaAssetCachePort & Required<Pick<ImStoragePort, 'getConversationBackground' | 'saveConversationBackground' | 'deleteConversationBackground' | 'getDefaultConversationBackground' | 'saveDefaultConversationBackground' | 'deleteDefaultConversationBackground'>>;
|
|
2966
|
+
/** 官方浏览器 adapter 始终提供背景和最近历史缓存;可选只存在于通用 `ImStoragePort` 兼容边界。 */
|
|
2967
|
+
type IndexedDbStorageAdapter = ImStoragePort & MediaAssetCachePort & Required<Pick<ImStoragePort, 'getConversationBackground' | 'recentHistoryCache' | 'saveConversationBackground' | 'deleteConversationBackground' | 'getDefaultConversationBackground' | 'saveDefaultConversationBackground' | 'deleteDefaultConversationBackground'>>;
|
|
2926
2968
|
/**
|
|
2927
2969
|
* 创建 IndexedDB 存储 adapter(实现 ImStoragePort)。
|
|
2928
2970
|
* 生命周期:先 `open({ namespace })`(幂等,跑 schema 迁移),再读写;`close()` 释放句柄。
|
|
@@ -3524,6 +3566,21 @@ interface ImContactApi extends ImDirectoryApi<'individual'> {
|
|
|
3524
3566
|
deleteFriendship: (userId: string) => Promise<void>;
|
|
3525
3567
|
}
|
|
3526
3568
|
|
|
3569
|
+
/** 后台最近页预取的取消条件;取消不影响正在复用同一请求的前台会话。 */
|
|
3570
|
+
interface ConversationPrefetchOptions {
|
|
3571
|
+
signal?: AbortSignal;
|
|
3572
|
+
}
|
|
3573
|
+
/**
|
|
3574
|
+
* 单个会话的后台预取结果。ready 只在完整页面已写入当前账号缓存后返回。
|
|
3575
|
+
* skipped 表示当前类型、权限、存储或预算不允许预取;失败不改变正常打开会话的行为。
|
|
3576
|
+
*/
|
|
3577
|
+
interface ConversationPrefetchResult {
|
|
3578
|
+
ref: ConversationRef<'direct' | 'group' | 'channel'>;
|
|
3579
|
+
status: 'ready' | 'skipped' | 'failed' | 'cancelled';
|
|
3580
|
+
reason?: 'unsupported' | 'unavailable' | 'storage-unavailable' | 'budget' | 'page-too-large' | 'decrypt-failed' | 'invalidated' | 'cancelled';
|
|
3581
|
+
error?: ImSdkErrorShape;
|
|
3582
|
+
}
|
|
3583
|
+
|
|
3527
3584
|
/**
|
|
3528
3585
|
* 当前账号草稿的产品 DTO、跨组件 API 与 handle 绑定门面。
|
|
3529
3586
|
* 草稿按复合会话身份串行持久化,SDK DomainState 是唯一真相;附件尚未闭合时非空输入明确拒绝。
|
|
@@ -3613,6 +3670,8 @@ interface ImConversationsApi {
|
|
|
3613
3670
|
pullOffline: () => Promise<ImMessage[]>;
|
|
3614
3671
|
/** 运行 direct/GROUP/CHANNEL sibling 离线同步。 */
|
|
3615
3672
|
sync: () => Promise<void>;
|
|
3673
|
+
/** 静默准备最近页;结果成功表示当前账号缓存事务已提交。 */
|
|
3674
|
+
prefetchRecent: (refs: readonly ImSupportedConversationRef[], options?: ConversationPrefetchOptions) => Promise<readonly ConversationPrefetchResult[]>;
|
|
3616
3675
|
/** 聚合总未读;默认排除 muted 会话。 */
|
|
3617
3676
|
getTotalUnread: (options?: {
|
|
3618
3677
|
includeMuted?: boolean;
|
|
@@ -4320,6 +4379,8 @@ interface ImConversationListApi extends ImConversationBackgroundApi {
|
|
|
4320
4379
|
subscribe: (listener: (snapshot: ImConversationListSnapshot) => void) => () => void;
|
|
4321
4380
|
/** 显式运行 direct/GROUP/CHANNEL sibling 同步;失败抛稳定产品错误并进入 error 快照。 */
|
|
4322
4381
|
refresh: () => Promise<void>;
|
|
4382
|
+
/** 静默预取各会话最近一页;不激活线程,ready 只表示持久缓存已完成。 */
|
|
4383
|
+
prefetchRecent: (refs: readonly ConversationRef<ProductConversationListType>[], options?: ConversationPrefetchOptions) => Promise<readonly ConversationPrefetchResult[]>;
|
|
4323
4384
|
/** 读取总未读;默认排除 muted 会话。 */
|
|
4324
4385
|
getTotalUnread: (options?: {
|
|
4325
4386
|
includeMuted?: boolean;
|
|
@@ -4605,6 +4666,8 @@ type ConversationInitialPosition = 'latest' | 'first-unread';
|
|
|
4605
4666
|
* @remarks 选项只影响初始连续窗口和 `entryUnread` 快照;发送、历史分页、已读和 close 语义保持不变。
|
|
4606
4667
|
*/
|
|
4607
4668
|
interface ConversationOpenOptions {
|
|
4669
|
+
/** 取消尚未交付的会话打开及其历史请求;句柄交付后由 close 管理生命周期。 */
|
|
4670
|
+
signal?: AbortSignal;
|
|
4608
4671
|
/**
|
|
4609
4672
|
* 初始连续窗口位置。
|
|
4610
4673
|
*
|
|
@@ -5234,6 +5297,8 @@ interface ImProductEventMap {
|
|
|
5234
5297
|
'connection:changed': Readonly<{
|
|
5235
5298
|
snapshot: ImLifecycleSnapshot;
|
|
5236
5299
|
}>;
|
|
5300
|
+
/** 另一个页面接管聊天;宿主可提示刷新此页重新接管,不应退出业务登录。 */
|
|
5301
|
+
'session:replaced': Readonly<Record<never, never>>;
|
|
5237
5302
|
'message:received': Readonly<{
|
|
5238
5303
|
ref: ConversationRef<ProductConversationListType>;
|
|
5239
5304
|
message: ImProductMessage;
|
|
@@ -6381,7 +6446,7 @@ type ImLocale = 'en-US' | 'th-TH' | 'vi-VN' | 'zh-CN' | 'zh-TW';
|
|
|
6381
6446
|
* 二期收敛:kit 框架无关层不再直接产中文,改产本联合里的码 + 参数(如 {reason}/{label}/{size}),由宿主经 im-i18n 渲染。
|
|
6382
6447
|
* 动态原始报错(error.message)作为 `{reason}` 参数拼接,不入 catalog(属诊断,不翻译)。
|
|
6383
6448
|
*/
|
|
6384
|
-
type ImServiceTextKey = 'common.notConnected' | 'common.selectOrOpenConversation' | 'common.conversationTypeNotReady' | 'common.conversationNotReady' | `recall.${RecallFailReason}` | `edit.${EditFailReason}` | 'localDelete.done' | 'localDelete.notFound' | 'localDelete.inFlight' | 'localDelete.failed' | 'channelDelete.notFound' | 'channelDelete.unsupported' | 'channelDelete.notSent' | 'channelDelete.unavailable' | 'channelDelete.forbidden' | 'channelDelete.timeout' | 'channelDelete.failed' | 'channelDelete.disconnected' | 'directBlock.contactRequired' | 'groupBlock.left' | 'groupBlock.removed' | 'groupBlock.dismissed' | 'groupBlock.unknownRestricted' | 'channelBlock.guest' | 'channelBlock.left' | 'channelBlock.removed' | 'channelBlock.dismissed' | 'channelBlock.muted' | 'channelBlock.allMembersMuted' | 'channelBlock.currentUserMuted' | 'channelBlock.blacklisted' | 'channelBlock.unknownRestricted' | 'channelProfile.loadFailed' | 'channelProfile.notFound' | 'channelProfile.retryAction' | 'channelMembers.title' | 'channelMembers.searchPlaceholder' | 'channelMembers.loading' | 'channelMembers.loadFailed' | 'channelMembers.retryAction' | 'channelMembers.empty' | 'channelMembers.loadingMore' | 'channelMembers.loadMoreFailed' | 'channelMembers.exhausted' | 'channelMembers.loadMoreAction' | 'label.image' | 'label.video' | 'label.file' | 'label.sticker' | 'send.failed' | 'send.retryFailed' | 'send.cancelFailed' | 'send.mediaFailed' | 'send.mediaEmpty' | 'send.mediaCancelled' | 'send.mediaCountLimit' | 'send.mediaTooLarge' | 'send.mediaFormatMismatch' | 'send.imageFormatUnsupported' | 'send.videoTooLong' | 'send.videoDurationUnavailable' | 'send.voiceEmpty' | 'send.voiceStorageNotConfigured' | 'send.voiceCancelled' | 'send.voiceFailed' | 'media.uploadWaiting' | 'media.voiceNotReady' | 'media.voiceLoadEmpty' | 'media.voiceLoadFailed' | 'media.videoOpenEmpty' | 'media.videoLoadFailed' | 'media.imageInvalid' | 'media.imageLoadFailed' | 'media.fileDownloadEmpty' | 'media.fileDownloadFailed' | 'conversation.muteEnableFailed' | 'conversation.muteDisableFailed' | 'conversation.backgroundLoadFailed' | 'read.markReadFailed' | 'storage.failed' | 'sync.failed' | 'draft.saveFailed' | 'history.returnLatestFailed' | 'pinned.forbidden' | 'pinned.network' | 'pinned.contract' | 'pinned.unsupported' | 'pinned.failed' | 'pinned.previewUnavailable' | 'pinned.locateFailed' | 'pinned.recalled' | 'pinned.deleted' | 'pinned.protected' | 'pinned.pinAction' | 'pinned.unpinAction' | 'pinned.unpinConfirm' | 'pinned.cancelAction' | 'lifecycle.missingLoginState' | 'lifecycle.prepareFailed' | 'lifecycle.missingConnectParams' | 'lifecycle.connectFailed' | 'lifecycle.disposed' | 'forward.emptyInput' | 'forward.allSkipped' | 'forward.partialSkipped' | 'forward.done' | 'forward.failed';
|
|
6449
|
+
type ImServiceTextKey = 'common.notConnected' | 'common.selectOrOpenConversation' | 'common.conversationTypeNotReady' | 'common.conversationNotReady' | `recall.${RecallFailReason}` | `edit.${EditFailReason}` | 'localDelete.done' | 'localDelete.notFound' | 'localDelete.inFlight' | 'localDelete.failed' | 'channelDelete.notFound' | 'channelDelete.unsupported' | 'channelDelete.notSent' | 'channelDelete.unavailable' | 'channelDelete.forbidden' | 'channelDelete.timeout' | 'channelDelete.failed' | 'channelDelete.disconnected' | 'directBlock.contactRequired' | 'groupBlock.left' | 'groupBlock.removed' | 'groupBlock.dismissed' | 'groupBlock.unknownRestricted' | 'channelBlock.guest' | 'channelBlock.left' | 'channelBlock.removed' | 'channelBlock.dismissed' | 'channelBlock.muted' | 'channelBlock.allMembersMuted' | 'channelBlock.currentUserMuted' | 'channelBlock.blacklisted' | 'channelBlock.unknownRestricted' | 'channelProfile.loadFailed' | 'channelProfile.notFound' | 'channelProfile.retryAction' | 'channelMembers.title' | 'channelMembers.searchPlaceholder' | 'channelMembers.loading' | 'channelMembers.loadFailed' | 'channelMembers.retryAction' | 'channelMembers.empty' | 'channelMembers.loadingMore' | 'channelMembers.loadMoreFailed' | 'channelMembers.exhausted' | 'channelMembers.loadMoreAction' | 'label.image' | 'label.video' | 'label.file' | 'label.sticker' | 'send.failed' | 'send.retryFailed' | 'send.cancelFailed' | 'send.mediaFailed' | 'send.mediaEmpty' | 'send.mediaCancelled' | 'send.mediaCountLimit' | 'send.mediaTooLarge' | 'send.mediaFormatMismatch' | 'send.imageFormatUnsupported' | 'send.videoTooLong' | 'send.videoDurationUnavailable' | 'send.voiceEmpty' | 'send.voiceStorageNotConfigured' | 'send.voiceCancelled' | 'send.voiceFailed' | 'media.uploadWaiting' | 'media.voiceNotReady' | 'media.voiceLoadEmpty' | 'media.voiceLoadFailed' | 'media.videoOpenEmpty' | 'media.videoLoadFailed' | 'media.imageInvalid' | 'media.imageLoadFailed' | 'media.fileDownloadEmpty' | 'media.fileDownloadFailed' | 'conversation.muteEnableFailed' | 'conversation.muteDisableFailed' | 'conversation.backgroundLoadFailed' | 'read.markReadFailed' | 'storage.failed' | 'sync.failed' | 'draft.saveFailed' | 'history.returnLatestFailed' | 'pinned.forbidden' | 'pinned.network' | 'pinned.contract' | 'pinned.unsupported' | 'pinned.failed' | 'pinned.previewUnavailable' | 'pinned.locateFailed' | 'pinned.recalled' | 'pinned.deleted' | 'pinned.protected' | 'pinned.pinAction' | 'pinned.unpinAction' | 'pinned.unpinConfirm' | 'pinned.cancelAction' | 'lifecycle.missingLoginState' | 'lifecycle.prepareFailed' | 'lifecycle.missingConnectParams' | 'lifecycle.connectFailed' | 'lifecycle.disposed' | 'lifecycle.connectionOccupied' | 'lifecycle.connectionCoordinationUnavailable' | 'forward.emptyInput' | 'forward.allSkipped' | 'forward.partialSkipped' | 'forward.done' | 'forward.failed';
|
|
6385
6450
|
|
|
6386
6451
|
/** 会话列表摘要的框架无关分段;宿主可自行决定表情使用图片、文本或其它组件呈现。 */
|
|
6387
6452
|
type ConversationListPreviewSegment = {
|
|
@@ -6472,6 +6537,20 @@ interface ConversationListPresentation {
|
|
|
6472
6537
|
*/
|
|
6473
6538
|
declare function resolveConversationListPresentation(item: ConversationListItem, options: ConversationListPresentationOptions): ConversationListPresentation;
|
|
6474
6539
|
|
|
6540
|
+
/**
|
|
6541
|
+
* PC/H5 会话行与菜单角标共用的显示规则;不修改 SDK 未读消息条数。
|
|
6542
|
+
*
|
|
6543
|
+
* @example `999 → '999'`、`1249 → '1k'`、`10000 → '10k'`、`10001 → '10k+'`。
|
|
6544
|
+
* 会话内的未读提示有独立的 999+ 规则,不使用本函数。
|
|
6545
|
+
*/
|
|
6546
|
+
declare function formatConversationUnreadBadge(count: number): string;
|
|
6547
|
+
/**
|
|
6548
|
+
* 从 SDK 完整会话列表计算菜单未读会话数:每个非免打扰且有未读的会话只计一次。
|
|
6549
|
+
*
|
|
6550
|
+
* SDK 已把手动未读提醒投影到 unreadCount;这里不重新解释消息状态,也不使用宿主筛选后的列表。
|
|
6551
|
+
*/
|
|
6552
|
+
declare function countUnreadConversations(items: readonly Pick<ConversationListItem, 'unreadCount' | 'muted'>[]): number;
|
|
6553
|
+
|
|
6475
6554
|
interface DelayedLoadingIndicatorOptions {
|
|
6476
6555
|
/** loading 持续超过该时间后才显示,缓存快速命中不会闪出提示。 */
|
|
6477
6556
|
showDelayMs?: number;
|
|
@@ -6888,7 +6967,8 @@ interface ChatRuntime {
|
|
|
6888
6967
|
/**
|
|
6889
6968
|
* 在账号或 token 发生变化时,立即停止并清理旧账号运行资源。
|
|
6890
6969
|
*
|
|
6891
|
-
*
|
|
6970
|
+
* 它会立即停止旧连接并丢弃页面资源,异步销毁 SDK Client、关闭消息库和释放浏览器锁;
|
|
6971
|
+
* 新 prepare/connect 等待清理完成,账号版本号同步递增;
|
|
6892
6972
|
* 已注册的 Store 监听器会保留,以便新账号重新连接后继续接收事件。通常由 `applySession` 自动调用。
|
|
6893
6973
|
*/
|
|
6894
6974
|
resetForAuthChange: () => void;
|
|
@@ -6970,6 +7050,43 @@ interface ChatRuntime {
|
|
|
6970
7050
|
*/
|
|
6971
7051
|
declare function createChatRuntime(factories: ChatRuntimeFactories): ChatRuntime;
|
|
6972
7052
|
|
|
7053
|
+
type PrefetchClient = Pick<ImProductClient, 'conversations'>;
|
|
7054
|
+
/** 宿主只提供当前投影和调度许可;请求去重、网络预算与持久化仍由 SDK 管理。 */
|
|
7055
|
+
interface ConversationPrefetchControllerOptions {
|
|
7056
|
+
/** 当前账号公开 Client;未准备好时返回 null,不在后台主动创建 Client。 */
|
|
7057
|
+
getClient: () => PrefetchClient | null;
|
|
7058
|
+
/** SDK 会话列表当前顺序;控制器只挑常用会话,不维护消息副本。 */
|
|
7059
|
+
getCandidates: () => readonly ConversationListItem[];
|
|
7060
|
+
/** 前台正在阅读的精确会话;它的历史由正常打开流程负责。 */
|
|
7061
|
+
getActiveRef: () => ConversationRef | null;
|
|
7062
|
+
/** 宿主判断开关、账号、连接、页面可见性和网络策略是否允许预取。 */
|
|
7063
|
+
getRunnable: () => boolean;
|
|
7064
|
+
/** 在首屏绘制后的浏览器空闲期执行,返回取消尚未开始任务的函数。 */
|
|
7065
|
+
scheduleIdle: (task: () => void) => () => void;
|
|
7066
|
+
/** 意外拒绝的结构化诊断出口;预取失败不能转成前台通知。 */
|
|
7067
|
+
onError: (cause: unknown) => void;
|
|
7068
|
+
/** 可选的统一诊断端口;只记录调度状态,不存消息,也不作为运行许可。 */
|
|
7069
|
+
diagnostics?: ImDiagnosticWriter;
|
|
7070
|
+
}
|
|
7071
|
+
/** 应用级常用会话预取控制器;不依赖 Vue、Pinia 或浏览器页面资源。 */
|
|
7072
|
+
interface ConversationPrefetchController {
|
|
7073
|
+
/** 列表、活动会话或运行条件改变时调用;普通刷新复用在途请求。 */
|
|
7074
|
+
refresh: () => void;
|
|
7075
|
+
/** 换账号或退出时取消任务并清除本轮请求记录;后续 refresh 可重新开始。 */
|
|
7076
|
+
reset: () => void;
|
|
7077
|
+
/** 应用卸载时永久释放;后续 refresh 不再调度。 */
|
|
7078
|
+
dispose: () => void;
|
|
7079
|
+
}
|
|
7080
|
+
/**
|
|
7081
|
+
* 创建常用会话预取编排:每次空闲只提交一个候选,完成后重读列表再选下一项。
|
|
7082
|
+
*
|
|
7083
|
+
* 页间重新等待宿主空闲调度,使置顶、未读、删除和活动会话变化及时影响下一页,
|
|
7084
|
+
* SDK 仍负责请求去重、前台优先与本次账号 Runtime 的网络总预算。
|
|
7085
|
+
* 同一 Client 下完成或失败的候选本轮不自动重试;取消项可在运行条件恢复后重新排队。
|
|
7086
|
+
* reset/client 更换会作废旧请求,旧 Promise 完成后不能修改新账号的请求记录。
|
|
7087
|
+
*/
|
|
7088
|
+
declare function createConversationPrefetchController(options: ConversationPrefetchControllerOptions): ConversationPrefetchController;
|
|
7089
|
+
|
|
6973
7090
|
/**
|
|
6974
7091
|
* 一次异步业务操作发起时捕获的账号生命周期。
|
|
6975
7092
|
*
|
|
@@ -8797,5 +8914,5 @@ declare function resampleWaveform(data: readonly number[], targetCount: number):
|
|
|
8797
8914
|
*/
|
|
8798
8915
|
declare function placeholderWaveform(seed: string, count: number): number[];
|
|
8799
8916
|
|
|
8800
|
-
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_LANG_NUMBERS, SPIKE_STEP, UNICODE_EMOJI_CATALOG, blockReasonForChannelSession, blockReasonForChannelState, blockReasonForGroupState, blockReasonForSession, calculateMediaBox, canEditMessage, canPinChannelMessage, canPinGroupMessage, canPinMessage, canPromoteMediaPresentationSource, canRecallMessage, canTransmit, canTransmitByType, canTransmitContent, cancelMediaUpload, captureRuntimeClientOperation, captureRuntimeOperation, channelMiniProgramRelKey, classifyGifFile, classifyMediaFile, createChatRuntime, createDelayedLoadingIndicator, createEmojiMatcher, createLinkMatcher, createNewMessageBadgeController, createThreadItems, csvIncludes, decideChannelMiniProgramRelOpen, decideConversationAction, decideMemberTargetAction, decideMessageAction, emojiAssetUrl, emojiUrlByCode, fetchConversationFileBatch, fetchConversationImageBatch, fetchConversationMessageBatch, fetchConversationVideoBatch, fetchConversationVoiceBatch, fetchNextConversationSearchBatch, formatChatDateSeparator, formatConversationDisplayTime, formatFileSize, formatMediaDuration, forward_service as forwardService, getFileExtension, getLocalDayKey, hasEmojiCandidate, hasLinkCandidate, highlightSegments, isGifFile, isMessageLocateScrollProtected, isMessageTailChangeFromOlderWindowTrim, isMessageViewportMeasurable, isMessageVisibleForNewMessageBadge, 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, 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 };
|
|
8801
|
-
export type { ApplySessionResult, BrowseMessagesInput, CanPinMessageInput, CenteredMessageScrollInput, ChannelMiniProgramOpenGame, ChannelMiniProgramRelOpenDecision, ChannelMiniProgramRelOpenSurface, ChatMediaMessageRef, ChatProfileAdapter, ChatRuntime, ChatRuntimeCredentials, ChatRuntimeFactories, ChatRuntimeHostDeps, ChatRuntimeOpResult, ConversationCapabilityAction, ConversationListPresentation, ConversationListPresentationLabels, ConversationListPresentationOptions, ConversationListPreviewMediaKind, ConversationListPreviewSegment, 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, 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 };
|
|
8917
|
+
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_LANG_NUMBERS, SPIKE_STEP, UNICODE_EMOJI_CATALOG, blockReasonForChannelSession, blockReasonForChannelState, blockReasonForGroupState, blockReasonForSession, calculateMediaBox, canEditMessage, canPinChannelMessage, canPinGroupMessage, canPinMessage, canPromoteMediaPresentationSource, canRecallMessage, canTransmit, canTransmitByType, canTransmitContent, cancelMediaUpload, captureRuntimeClientOperation, captureRuntimeOperation, channelMiniProgramRelKey, classifyGifFile, classifyMediaFile, countUnreadConversations, createChatRuntime, createConversationPrefetchController, createDelayedLoadingIndicator, createEmojiMatcher, createLinkMatcher, 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, hasEmojiCandidate, hasLinkCandidate, highlightSegments, isGifFile, isMessageLocateScrollProtected, isMessageTailChangeFromOlderWindowTrim, isMessageViewportMeasurable, isMessageVisibleForNewMessageBadge, 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, 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 };
|
|
8918
|
+
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, 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{p as DEFAULT_LOADING_MINIMUM_VISIBLE_MS,o as DEFAULT_LOADING_SHOW_DELAY_MS,d as MINI_PROGRAM_LANG_NUMBERS,
|
|
1
|
+
export{p as DEFAULT_LOADING_MINIMUM_VISIBLE_MS,o as DEFAULT_LOADING_SHOW_DELAY_MS,d as MINI_PROGRAM_LANG_NUMBERS,I as SPIKE_STEP,E as calculateMediaBox,s as canPromoteMediaPresentationSource,v as captureRuntimeClientOperation,u as captureRuntimeOperation,m as channelMiniProgramRelKey,t as createConversationPrefetchController,q as createDelayedLoadingIndicator,C as createLinkMatcher,e as csvIncludes,c as decideChannelMiniProgramRelOpen,G as formatFileSize,F as formatMediaDuration,H as getFileExtension,B as hasLinkCandidate,z as highlightSegments,w as mediaService,A as normalizeLinkHref,L as placeholderWaveform,x as readService,K as resampleWaveform,r as resolveBestMediaPresentationSource,g as resolveChannelMiniProgramRelIcon,f as resolveChannelMiniProgramRelName,i as resolveChannelMiniProgramRelOpenSurface,h as resolveChannelMiniProgramRelUrl,j as resolveChannelPinnedGameCopy,n as resolveConversationListPresentation,D as resolveMediaPresentation,b as resolveMiniProgramFloatLinkUrl,a as resolveMiniProgramOpenUrl,y as resolveQuotedMessagePresentation,l as resolveVisibleChannelMiniProgramRels,k as sortChannelMiniProgramFloatingItems,J as spikeCountForDuration}from'./chunk-XA4W5PWT.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-VRGWQLDM.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-SLFKCTEX.js';import'./chunk-37HOEWMF.js';import'./chunk-MNWNUGIV.js';import'./chunk-GHZUH7RB.js';export{ta as canTransmit,ra as canTransmitByType,sa as canTransmitContent,qa as requiresForwardTypeConfirmation}from'./chunk-4KPJTXQN.js';import'./chunk-WOT6VMZA.js';
|