k2-im 0.1.20 → 0.1.22

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 CHANGED
@@ -1 +1 @@
1
- export{A as createLazyBrowserApiProtocolClient}from'./chunk-4RG5NHIL.js';import'./chunk-ZDD7A2BS.js';import'./chunk-WOT6VMZA.js';
1
+ export{A as createLazyBrowserApiProtocolClient}from'./chunk-GZEX4V3P.js';import'./chunk-VKNZ76EP.js';import'./chunk-WOT6VMZA.js';
@@ -126,12 +126,17 @@ type LastMessageSummary = {
126
126
  *
127
127
  * 只给结构化计数与配文,**不在这里拼「2 张照片, 1 个视频」这种文案**——中英文的量词、复数与
128
128
  * 连接符各不相同,必须由 im-i18n 按 locale 组装。`caption` 非空时宿主优先显示配文(对齐三端)。
129
+ *
130
+ * `firstItemKind` 是第一项是照片还是视频。有配文时列表显示的是配文,光看计数无法决定该配
131
+ * 照片图标还是视频图标,三端统一按第一项取(对齐 iOS `IMMediaAlbumMessageBody`)。
132
+ * 入站解析后所有项都被丢弃时缺省,宿主据此不显示类型图标。
129
133
  */
130
134
  | {
131
135
  kind: 'mediaAlbum';
132
136
  imageCount: number;
133
137
  videoCount: number;
134
138
  caption?: string;
139
+ firstItemKind?: 'image' | 'video';
135
140
  } | {
136
141
  kind: 'encrypted';
137
142
  } | {
@@ -4036,12 +4041,16 @@ type ConversationLastMessageSummary = {
4036
4041
  *
4037
4042
  * 只给计数与配文,数量文案由宿主经 im-i18n 按 locale 组装;有配文时优先显示配文。
4038
4043
  * 两个计数都为 0 表示入站正文残缺(所有项都无法解析),宿主应按未知正文处理。
4044
+ *
4045
+ * `firstItemKind` 是第一项是照片还是视频。有配文时列表显示的是配文,光看计数决定不了该配
4046
+ * 照片图标还是视频图标,三端统一按第一项取;正文残缺时缺省,宿主据此不显示类型图标。
4039
4047
  */
4040
4048
  | {
4041
4049
  kind: 'mediaAlbum';
4042
4050
  imageCount: number;
4043
4051
  videoCount: number;
4044
4052
  caption?: string;
4053
+ firstItemKind?: 'image' | 'video';
4045
4054
  } | {
4046
4055
  kind: 'encrypted';
4047
4056
  } | {
@@ -4417,6 +4426,12 @@ interface ConversationOpenOptions {
4417
4426
  * 后续 read 事件或新消息不会移动分隔线。
4418
4427
  */
4419
4428
  initialPosition?: ConversationInitialPosition;
4429
+ /**
4430
+ * 默认 blocking 等待整个初始窗口;local-first 在本地窗口可读后返回,远端补齐和未读定位后台继续。
4431
+ * local-first 调用方必须订阅 loading/error:加载失败保留本地窗口并写入 error,允许通过 history 重试;
4432
+ * loading 结束前不要提交可见已读或最终首屏定位。本地存储打开失败仍会拒绝 openConversation。
4433
+ */
4434
+ initialLoad?: 'blocking' | 'local-first';
4420
4435
  }
4421
4436
  /**
4422
4437
  * 产品会话的连续窗口快照;协议 cursor、窗口 id 与 generation 始终保持在 SDK 内部。
@@ -4928,6 +4943,31 @@ interface ImMediaTasksApi {
4928
4943
  * @throws 持久缓存读取失败时抛 `IM_SDK_MEDIA_CACHE_READ_FAILED`,不能把存储故障伪装成 cache miss。
4929
4944
  */
4930
4945
  getCached: (message: ImMessageRef) => Promise<Blob | null>;
4946
+ /**
4947
+ * 为宿主手里的**本地**图片/视频文件预读展示元信息:尺寸、视频时长、视频首帧封面的 JPEG 字节。
4948
+ *
4949
+ * 给「发送前预览」这类场景用:宿主要在用户还没点发送时就把缩略图画出来,而浏览器读不出视频的
4950
+ * 首帧——`<video preload="metadata">` 在 iOS Safari 上只加载元信息、**不解码任何一帧**,
4951
+ * 拿它当缩略图会得到一个空白格子(还会白占一路解码)。
4952
+ *
4953
+ * 返回的对象可以**原样**作为 `localPreviewMetadata` 交给 `sendImage` / `sendVideo` /
4954
+ * `sendMediaAlbum`:发送链路会跳过重复解码,上传中的气泡也从第一帧就有封面。
4955
+ * 视频封面用的就是发送链路那套规格(长边 320、JPEG),所以弹层里看到的与最终发出去的是同一张。
4956
+ *
4957
+ * @param input.kind 按文件类型选解码路径;`'video'` 才会抽首帧与读时长。
4958
+ * @param input.file 本地文件;不会被上传,也不会进任何缓存。
4959
+ * @param input.signal 宿主放弃时中止解码(例如预览弹层被关掉)。
4960
+ * @returns 解码成功返回元信息;**浏览器确实读不出这个文件**(格式不支持、解码超时)时返回 `null`,
4961
+ * 调用方应当显式呈现「这个文件读不出来」,不要拿空白格子糊过去。失败原因会记入 SDK 结构化诊断。
4962
+ * @throws 宿主通过 `signal` 中止时抛 `AbortError`——那是调用方自己的取消,不能和「读不出来」混为一谈。
4963
+ * @throws runtime 已 logout/dispose 时抛 `IM_SDK_MEDIA_RUNTIME_INACTIVE`;
4964
+ * 未装配预览端口时抛 `IM_SDK_MEDIA_PREVIEW_UNAVAILABLE`,不静默返回 `null`。
4965
+ */
4966
+ prepareLocalPreview: <TKind extends 'image' | 'video'>(input: {
4967
+ kind: TKind;
4968
+ file: Blob;
4969
+ signal?: AbortSignal;
4970
+ }) => Promise<(TKind extends 'video' ? VideoPreviewMetadata : ImagePreviewMetadata) | null>;
4931
4971
  }
4932
4972
 
4933
4973
  /**
@@ -5376,14 +5416,8 @@ interface ImSearchApi {
5376
5416
  readonly messages: ImMessageSearchApi;
5377
5417
  }
5378
5418
 
5379
- /**
5380
- * 会话收藏稳定产品门面。
5381
- *
5382
- * 本模块不缓存服务端列表;每次 list/add/delete 都以当前账号 provider 为准。
5383
- * 收藏快照与原聊天消息解耦:原消息删除、撤回或编辑不会回写收藏。
5384
- */
5385
-
5386
5419
  type ImSessionFavoriteItem = Readonly<ImSessionFavoriteItem$1>;
5420
+
5387
5421
  /** 产品层会话收藏 API。 */
5388
5422
  interface ImSessionFavoritesApi {
5389
5423
  list: () => Promise<readonly ImSessionFavoriteItem[]>;
@@ -6712,22 +6746,23 @@ declare function getImChatKitContext(pinia: Pinia): ImChatKitContext;
6712
6746
  /** 释放指定 Pinia 下全部 IM Store 和 Runtime;未安装时不执行任何操作。 */
6713
6747
  declare function disposeImChatKit(pinia: Pinia): void;
6714
6748
 
6715
- type ProductConversationRef$5 = ConversationRef<ProductHandleConversationType>;
6749
+ type ProductConversationRef$6 = ConversationRef<ProductHandleConversationType>;
6716
6750
  /** 宿主可据此决定反馈的安全错误;底层 cause/details 只允许进入统一诊断。 */
6717
6751
  type ImConversationActivationError = Readonly<Omit<ImSdkErrorShape, 'cause' | 'details'>>;
6718
6752
  /**
6719
6753
  * 共享会话激活的稳定结果。
6720
6754
  *
6721
- * 成功后宿主才提交路由/面板选择;`stale` 表示该意图已被更新点击、切账号或 Context dispose 取代。
6755
+ * 成功表示已绑定目标句柄,后台历史加载状态仍从 Thread Store 读取;宿主可提前展示路由外壳与骨架。
6756
+ * `stale` 表示该意图已被更新点击、切账号或 Context dispose 取代。
6722
6757
  */
6723
6758
  type ImConversationActivationResult = Readonly<{
6724
6759
  ok: true;
6725
6760
  status: 'opened';
6726
- conversation: ProductConversationRef$5;
6761
+ conversation: ProductConversationRef$6;
6727
6762
  } | {
6728
6763
  ok: false;
6729
6764
  reason: 'draft-save-failed' | 'open-failed';
6730
- conversation: ProductConversationRef$5;
6765
+ conversation: ProductConversationRef$6;
6731
6766
  error: ImConversationActivationError;
6732
6767
  } | {
6733
6768
  ok: false;
@@ -6736,29 +6771,32 @@ type ImConversationActivationResult = Readonly<{
6736
6771
  }>;
6737
6772
  /** 按单个 Pinia 串联 Composer 与 Thread Store 的无 UI coordinator。 */
6738
6773
  interface ImConversationActivationCoordinator {
6739
- activate: (conversation: ConversationRef) => Promise<ImConversationActivationResult>;
6774
+ /** signal 取消本次在途激活;保留已显示线程,不影响之后开始的激活。 */
6775
+ activate: (conversation: ConversationRef, options?: {
6776
+ signal?: AbortSignal;
6777
+ }) => Promise<ImConversationActivationResult>;
6740
6778
  }
6741
6779
  /**
6742
6780
  * 取得当前 Vue setup 或显式 Pinia 的会话激活 coordinator。
6743
6781
  *
6744
6782
  * coordinator 没有响应式产品状态;每个 Pinia 只持有 operation epoch,用于在草稿 flush 和 Thread open
6745
- * 之间判定新点击、账号 generation 变化与 dispose。调用方不得根据 Thread 中间态提前提交宿主选择。
6783
+ * 之间判定新点击、账号 generation 变化与 dispose。宿主可先展示目标页,但只有 exact handle 成功后才能展示线程内容。
6746
6784
  */
6747
6785
  declare function useImConversationActivationCoordinator(pinia?: Pinia): ImConversationActivationCoordinator;
6748
6786
 
6749
- type ProductConversationRef$4 = ConversationRef<ProductConversationListType>;
6787
+ type ProductConversationRef$5 = ConversationRef<ProductConversationListType>;
6750
6788
  /** 删除失败时提供给宿主映射反馈的安全错误,不暴露底层 cause/details。 */
6751
6789
  type ImConversationDeletionError = Readonly<Omit<ImSdkErrorShape, 'cause' | 'details'>>;
6752
6790
  /** local-only 删除的稳定结果;成功只代表 SDK 已同步提交当前内存删除,不代表 durable 存储已完成。 */
6753
6791
  type ImConversationDeletionResult = Readonly<{
6754
6792
  ok: true;
6755
6793
  status: 'deleted';
6756
- conversation: ProductConversationRef$4;
6794
+ conversation: ProductConversationRef$5;
6757
6795
  activeConversationCleared: boolean;
6758
6796
  } | {
6759
6797
  ok: false;
6760
6798
  reason: 'delete-failed';
6761
- conversation: ProductConversationRef$4;
6799
+ conversation: ProductConversationRef$5;
6762
6800
  error: ImConversationDeletionError;
6763
6801
  } | {
6764
6802
  ok: false;
@@ -6777,7 +6815,7 @@ interface ImConversationDeletionCoordinator {
6777
6815
  */
6778
6816
  declare function useImConversationDeletionCoordinator(pinia?: Pinia): ImConversationDeletionCoordinator;
6779
6817
 
6780
- type ProductConversationRef$3 = ConversationRef<ProductConversationListType>;
6818
+ type ProductConversationRef$4 = ConversationRef<ProductConversationListType>;
6781
6819
  type ImConversationListMutationOperation = 'set-pinned' | 'set-muted' | 'mark-read' | 'mark-unread' | 'delete-local';
6782
6820
  /** 会话列表动作失败时返回给宿主的安全错误;底层 cause/details 不跨出共享 Store。 */
6783
6821
  type ImConversationListActionError = Readonly<Omit<ImSdkErrorShape, 'cause' | 'details'>>;
@@ -6804,11 +6842,11 @@ interface ImConversationListStore {
6804
6842
  start: () => void;
6805
6843
  reset: () => void;
6806
6844
  refresh: () => Promise<ImConversationListRefreshResult>;
6807
- setPinned: (ref: ProductConversationRef$3, pinned: boolean) => ImConversationListMutationResult;
6808
- setMuted: (ref: ProductConversationRef$3, muted: boolean) => Promise<ImConversationListMutationResult>;
6809
- markRead: (ref: ProductConversationRef$3) => Promise<ImConversationListMutationResult>;
6810
- markUnread: (ref: ProductConversationRef$3) => ImConversationListMutationResult;
6811
- deleteLocal: (ref: ProductConversationRef$3) => ImConversationListMutationResult;
6845
+ setPinned: (ref: ProductConversationRef$4, pinned: boolean) => ImConversationListMutationResult;
6846
+ setMuted: (ref: ProductConversationRef$4, muted: boolean) => Promise<ImConversationListMutationResult>;
6847
+ markRead: (ref: ProductConversationRef$4) => Promise<ImConversationListMutationResult>;
6848
+ markUnread: (ref: ProductConversationRef$4) => ImConversationListMutationResult;
6849
+ deleteLocal: (ref: ProductConversationRef$4) => ImConversationListMutationResult;
6812
6850
  dispose: () => void;
6813
6851
  }
6814
6852
  /**
@@ -6820,17 +6858,17 @@ interface ImConversationListStore {
6820
6858
  type ImConversationListMutationResult = Readonly<{
6821
6859
  ok: true;
6822
6860
  operation: ImConversationListMutationOperation;
6823
- conversation: ProductConversationRef$3;
6861
+ conversation: ProductConversationRef$4;
6824
6862
  } | {
6825
6863
  ok: false;
6826
6864
  operation: ImConversationListMutationOperation;
6827
6865
  reason: 'stale';
6828
- conversation: ProductConversationRef$3;
6866
+ conversation: ProductConversationRef$4;
6829
6867
  } | {
6830
6868
  ok: false;
6831
6869
  operation: ImConversationListMutationOperation;
6832
6870
  reason: 'failed';
6833
- conversation: ProductConversationRef$3;
6871
+ conversation: ProductConversationRef$4;
6834
6872
  error: ImConversationListActionError;
6835
6873
  }>;
6836
6874
  declare function defineImConversationListStore(pinia: Pinia): pinia.StoreDefinition<"k2-im-conversation-list", Pick<{
@@ -6841,11 +6879,11 @@ declare function defineImConversationListStore(pinia: Pinia): pinia.StoreDefinit
6841
6879
  start: () => void;
6842
6880
  reset: () => void;
6843
6881
  refresh: () => Promise<ImConversationListRefreshResult>;
6844
- setPinned: (ref: ProductConversationRef$3, pinned: boolean) => ImConversationListMutationResult;
6845
- setMuted: (ref: ProductConversationRef$3, muted: boolean) => Promise<ImConversationListMutationResult>;
6846
- markRead: (ref: ProductConversationRef$3) => Promise<ImConversationListMutationResult>;
6847
- markUnread: (ref: ProductConversationRef$3) => ImConversationListMutationResult;
6848
- deleteLocal: (ref: ProductConversationRef$3) => ImConversationListMutationResult;
6882
+ setPinned: (ref: ProductConversationRef$4, pinned: boolean) => ImConversationListMutationResult;
6883
+ setMuted: (ref: ProductConversationRef$4, muted: boolean) => Promise<ImConversationListMutationResult>;
6884
+ markRead: (ref: ProductConversationRef$4) => Promise<ImConversationListMutationResult>;
6885
+ markUnread: (ref: ProductConversationRef$4) => ImConversationListMutationResult;
6886
+ deleteLocal: (ref: ProductConversationRef$4) => ImConversationListMutationResult;
6849
6887
  dispose: () => void;
6850
6888
  }, any>, Pick<{
6851
6889
  items: any;
@@ -6855,11 +6893,11 @@ declare function defineImConversationListStore(pinia: Pinia): pinia.StoreDefinit
6855
6893
  start: () => void;
6856
6894
  reset: () => void;
6857
6895
  refresh: () => Promise<ImConversationListRefreshResult>;
6858
- setPinned: (ref: ProductConversationRef$3, pinned: boolean) => ImConversationListMutationResult;
6859
- setMuted: (ref: ProductConversationRef$3, muted: boolean) => Promise<ImConversationListMutationResult>;
6860
- markRead: (ref: ProductConversationRef$3) => Promise<ImConversationListMutationResult>;
6861
- markUnread: (ref: ProductConversationRef$3) => ImConversationListMutationResult;
6862
- deleteLocal: (ref: ProductConversationRef$3) => ImConversationListMutationResult;
6896
+ setPinned: (ref: ProductConversationRef$4, pinned: boolean) => ImConversationListMutationResult;
6897
+ setMuted: (ref: ProductConversationRef$4, muted: boolean) => Promise<ImConversationListMutationResult>;
6898
+ markRead: (ref: ProductConversationRef$4) => Promise<ImConversationListMutationResult>;
6899
+ markUnread: (ref: ProductConversationRef$4) => ImConversationListMutationResult;
6900
+ deleteLocal: (ref: ProductConversationRef$4) => ImConversationListMutationResult;
6863
6901
  dispose: () => void;
6864
6902
  }, any>, Pick<{
6865
6903
  items: any;
@@ -6869,11 +6907,11 @@ declare function defineImConversationListStore(pinia: Pinia): pinia.StoreDefinit
6869
6907
  start: () => void;
6870
6908
  reset: () => void;
6871
6909
  refresh: () => Promise<ImConversationListRefreshResult>;
6872
- setPinned: (ref: ProductConversationRef$3, pinned: boolean) => ImConversationListMutationResult;
6873
- setMuted: (ref: ProductConversationRef$3, muted: boolean) => Promise<ImConversationListMutationResult>;
6874
- markRead: (ref: ProductConversationRef$3) => Promise<ImConversationListMutationResult>;
6875
- markUnread: (ref: ProductConversationRef$3) => ImConversationListMutationResult;
6876
- deleteLocal: (ref: ProductConversationRef$3) => ImConversationListMutationResult;
6910
+ setPinned: (ref: ProductConversationRef$4, pinned: boolean) => ImConversationListMutationResult;
6911
+ setMuted: (ref: ProductConversationRef$4, muted: boolean) => Promise<ImConversationListMutationResult>;
6912
+ markRead: (ref: ProductConversationRef$4) => Promise<ImConversationListMutationResult>;
6913
+ markUnread: (ref: ProductConversationRef$4) => ImConversationListMutationResult;
6914
+ deleteLocal: (ref: ProductConversationRef$4) => ImConversationListMutationResult;
6877
6915
  dispose: () => void;
6878
6916
  }, any>>;
6879
6917
  type InternalImConversationListStore = ReturnType<ReturnType<typeof defineImConversationListStore>>;
@@ -7033,7 +7071,7 @@ type ImExpressionStore = Store<'k2-im-expression', ImExpressionStoreState, ImExp
7033
7071
  */
7034
7072
  declare function useImExpressionStore(pinia?: Pinia): ImExpressionStore;
7035
7073
 
7036
- type ProductConversationRef$2 = ConversationRef<ProductHandleConversationType>;
7074
+ type ProductConversationRef$3 = ConversationRef<ProductHandleConversationType>;
7037
7075
  /** 返回最新页失败时给宿主的安全错误;底层 cause/details 只进入统一诊断。 */
7038
7076
  type ImHistoryReturnError = Readonly<Omit<ImSdkErrorShape, 'cause' | 'details'>>;
7039
7077
  /** 历史窗口发送后的稳定结算;宿主只在 `applied` 时执行自己的 DOM 滚动。 */
@@ -7041,10 +7079,10 @@ type ImHistoryReturnResult = Readonly<{
7041
7079
  status: 'not-needed';
7042
7080
  } | {
7043
7081
  status: 'applied' | 'stale';
7044
- conversation: ProductConversationRef$2;
7082
+ conversation: ProductConversationRef$3;
7045
7083
  } | {
7046
7084
  status: 'failed';
7047
- conversation: ProductConversationRef$2;
7085
+ conversation: ProductConversationRef$3;
7048
7086
  error: ImHistoryReturnError;
7049
7087
  }>;
7050
7088
  /** 保留原发送动作的返回值,并把独立的历史窗口结算交给宿主消费。 */
@@ -7064,30 +7102,6 @@ interface ImHistoryReturnAfterSendCoordinator {
7064
7102
  */
7065
7103
  declare function useImHistoryReturnAfterSendCoordinator(pinia?: Pinia): ImHistoryReturnAfterSendCoordinator;
7066
7104
 
7067
- /**
7068
- * 为页面展示当前账号的媒体上传/下载进度,并提供取消、重试和重新选择原文件入口。
7069
- *
7070
- * 【状态从哪里来】
7071
- * Store 订阅 SDK 的完整媒体任务列表,向页面提供任务、当前线程每条消息的上传百分比、是否还在排队等
7072
- * 上传槽位、是否正在完成最后处理以及稳定错误。传输、任务状态、消息状态、取消和重试都由 SDK 维护;Store 不模拟进度,也不
7073
- * 创建第二套上传队列。
7074
- *
7075
- * 【提供的能力】
7076
- * - `start` / `reset`:开始监听当前 SDK Client,或切账号时退订并清空旧任务。
7077
- * - `cancel` / `retry`:按 SDK 给出的任务 ID 取消或重试。
7078
- * - `cancelUpload`:根据当前会话类型、会话 ID 和消息 ID 找到唯一上传任务后取消。
7079
- * - `requestReplacement` / `takeReplacementRequest`:视频或文件刷新后失去本地源时,生成一次重新选择请求;
7080
- * 宿主取走意图后自行打开平台文件选择器,File 本身不会写入 Store。
7081
- *
7082
- * 【安全、并发与资源边界】
7083
- * 页面任务会删除 SDK 错误中的底层原因和详情,只保留错误码、分类和是否可重试。File、Blob、本地地址、
7084
- * 播放器、中止控制器、传输能力、Client 和订阅函数都不能进入 `$state`。Store 同时核对当前 Client、
7085
- * 账号版本号和绑定序号;旧账号任务或旧操作晚返回时只得到 `stale`,不会更新新页面。
7086
- *
7087
- * 【明确不负责】
7088
- * 文件选择、预览、录音权限、播放器、Blob URL 生命周期、toast 和页面布局属于浏览器或宿主平台能力。
7089
- */
7090
-
7091
7105
  /** 页面可保存和判断的媒体错误;底层响应、异常对象和详情只进入统一诊断,不进入 Pinia。 */
7092
7106
  type ImMediaStoreError = Readonly<Omit<ImSdkErrorShape, 'cause' | 'details'>>;
7093
7107
  /** 页面可展示的只读媒体任务;不含文件字节、本地地址、密钥、中止控制器或传输对象。 */
@@ -7119,8 +7133,67 @@ type ImMediaOperationResult = Readonly<{
7119
7133
  * 宿主既有的 `downloadProgress[message.id]` 读法不受影响。
7120
7134
  */
7121
7135
  declare function imMediaDownloadKey(messageId: string, itemIndex?: number): string;
7136
+ declare function defineImMediaStore(pinia: Pinia): pinia.StoreDefinition<"k2-im-media", Pick<{
7137
+ tasks: any;
7138
+ error: any;
7139
+ uploadProgress: any;
7140
+ downloadTasks: any;
7141
+ downloadProgress: any;
7142
+ uploadWaiting: any;
7143
+ uploadFinalizing: any;
7144
+ replacementRequest: any;
7145
+ start: () => void;
7146
+ reset: () => void;
7147
+ cancel: (taskId: string) => Promise<ImMediaOperationResult>;
7148
+ retry: (taskId: string) => Promise<ImMediaOperationResult>;
7149
+ cancelUpload: (messageId: string) => Promise<ImMediaOperationResult>;
7150
+ cancelDownload: (messageId: string, itemIndex?: number) => Promise<ImMediaOperationResult>;
7151
+ requestReplacement: (message: ImMessageView) => boolean;
7152
+ takeReplacementRequest: () => ImMediaReplacementRequest | null;
7153
+ clearReplacementRequest: () => void;
7154
+ dispose: () => void;
7155
+ }, any>, Pick<{
7156
+ tasks: any;
7157
+ error: any;
7158
+ uploadProgress: any;
7159
+ downloadTasks: any;
7160
+ downloadProgress: any;
7161
+ uploadWaiting: any;
7162
+ uploadFinalizing: any;
7163
+ replacementRequest: any;
7164
+ start: () => void;
7165
+ reset: () => void;
7166
+ cancel: (taskId: string) => Promise<ImMediaOperationResult>;
7167
+ retry: (taskId: string) => Promise<ImMediaOperationResult>;
7168
+ cancelUpload: (messageId: string) => Promise<ImMediaOperationResult>;
7169
+ cancelDownload: (messageId: string, itemIndex?: number) => Promise<ImMediaOperationResult>;
7170
+ requestReplacement: (message: ImMessageView) => boolean;
7171
+ takeReplacementRequest: () => ImMediaReplacementRequest | null;
7172
+ clearReplacementRequest: () => void;
7173
+ dispose: () => void;
7174
+ }, any>, Pick<{
7175
+ tasks: any;
7176
+ error: any;
7177
+ uploadProgress: any;
7178
+ downloadTasks: any;
7179
+ downloadProgress: any;
7180
+ uploadWaiting: any;
7181
+ uploadFinalizing: any;
7182
+ replacementRequest: any;
7183
+ start: () => void;
7184
+ reset: () => void;
7185
+ cancel: (taskId: string) => Promise<ImMediaOperationResult>;
7186
+ retry: (taskId: string) => Promise<ImMediaOperationResult>;
7187
+ cancelUpload: (messageId: string) => Promise<ImMediaOperationResult>;
7188
+ cancelDownload: (messageId: string, itemIndex?: number) => Promise<ImMediaOperationResult>;
7189
+ requestReplacement: (message: ImMessageView) => boolean;
7190
+ takeReplacementRequest: () => ImMediaReplacementRequest | null;
7191
+ clearReplacementRequest: () => void;
7192
+ dispose: () => void;
7193
+ }, any>>;
7194
+ type ImMediaStore = ReturnType<ReturnType<typeof defineImMediaStore>>;
7122
7195
  /** 取得当前 Vue setup 或显式 Pinia 的媒体任务 Store;不会隐式创建 Runtime。 */
7123
- declare function useImMediaStore(pinia?: Pinia): any;
7196
+ declare function useImMediaStore(pinia?: Pinia): ImMediaStore;
7124
7197
 
7125
7198
  /**
7126
7199
  * 执行“把当前会话中的一条或多条消息转发到若干目标会话”。
@@ -8320,30 +8393,20 @@ type ImReactionStore = Store<'k2-im-reaction', ImReactionStoreState, Record<stri
8320
8393
  declare function useImReactionStore(pinia?: Pinia): ImReactionStore;
8321
8394
 
8322
8395
  /**
8323
- * 为当前聊天线程提供关键词搜索、分类媒体浏览、结果续页和跳转到原消息。
8324
- *
8325
- * 【对外状态】
8326
- * Store 暴露关键词、全部/文件/图片/视频/语音分类、结果列表、搜索状态、是否还有下一页、正在定位的
8327
- * 消息 ID、短暂高亮 ID 与稳定错误。SDK 仍维护搜索索引、消息历史窗口和真实分页位置,Pinia 只保存
8328
- * 当前搜索面板需要展示的状态。
8396
+ * 读取当前会话的消息搜索结果和分类媒体列表。
8329
8397
  *
8330
- * 【提供的能力】
8331
- * - `search`:更新关键词,用户停止输入 250ms 后执行,避免每个按键都发请求。
8332
- * - `setCategory`:切换消息、文件、图片、视频或语音产品入口。
8333
- * - `loadMore`:使用闭包中不可解析的分页凭证继续同一次查询。
8334
- * - `locate`:让当前线程加载目标消息附近的历史并发布定位 ID;宿主完成实际滚动后,高亮 ID 再保留 2 秒。
8335
- * - `clearLocation` / `reset`:结束定位或作废当前查询生命周期;`reset({ preserveLocation: true })` 可在关闭搜索面板时保留刚写入的高亮。
8398
+ * 全部消息按关键词搜索;文件既可按名称搜索也可浏览;图片、视频和语音按分类浏览。单聊、普通群和
8399
+ * 社群会调用各自的 SDK 搜索能力。分页位置由 SDK 封装成 `ImPageToken`,调用方只能原样传回续页,
8400
+ * 不能解析或修改其中的账号、会话和查询条件。
8336
8401
  *
8337
- * 【并发与身份隔离】
8338
- * 分页凭证、定时器、会话句柄、请求序号和账号版本号全部留在闭包。切查询、分类、会话、账号或
8339
- * 销毁 Store 会把等待/在途任务结算为 `stale`;同 ID 的单聊、普通群和社群始终按类型 + ID 隔离。旧任务
8340
- * 不能关闭新任务的 loading,也不能覆盖新结果、错误或高亮。
8341
- *
8342
- * 【明确不负责】
8343
- * Store 不访问滚动容器,不决定搜索面板、空态和反馈文案。宿主监听 `highlightMessageId` 后完成实际
8344
- * DOM 居中/高亮;分页凭证、协议续页位置与底层响应不会暴露给宿主。
8402
+ * 防抖、当前查询状态、切账号/切会话后的旧结果丢弃由 Search Store 负责。本 Service 只取一批结果,
8403
+ * 并在底层出现稀疏空页时有限地向后查找,避免页面误显示“没有结果”。
8345
8404
  */
8346
8405
 
8406
+ /** 搜索面板可选择的业务分类:全部/文本走关键词;文件可空词浏览;图/音/视频按类型浏览。 */
8407
+ type ConversationSearchCategory = 'all' | 'text' | 'image' | 'video' | 'file' | 'voice';
8408
+
8409
+ type ProductConversationRef$2 = ConversationRef<ProductHandleConversationType>;
8347
8410
  type SearchOperation = 'search' | 'load-more' | 'locate';
8348
8411
  /** 搜索、续页或定位结果;宿主只按操作和原因决定反馈,不解析 SDK 底层异常。 */
8349
8412
  type ImSearchOperationResult = Readonly<{
@@ -8355,8 +8418,67 @@ type ImSearchOperationResult = Readonly<{
8355
8418
  reason: 'not-ready' | 'no-condition' | 'busy' | 'exhausted' | 'stale' | 'failed';
8356
8419
  error?: ImSdkErrorShape;
8357
8420
  }>;
8421
+ declare function defineImSearchStore(pinia: Pinia): pinia.StoreDefinition<"k2-im-search", Pick<{
8422
+ keyword: any;
8423
+ results: any;
8424
+ searching: any;
8425
+ hasMore: any;
8426
+ category: any;
8427
+ locatingMessageId: any;
8428
+ highlightMessageId: any;
8429
+ error: any;
8430
+ search: (nextKeyword: string) => Promise<ImSearchOperationResult>;
8431
+ setCategory: (nextCategory: ConversationSearchCategory) => Promise<ImSearchOperationResult>;
8432
+ loadMore: () => Promise<ImSearchOperationResult>;
8433
+ locate: (ref: ProductConversationRef$2, messageId: string) => Promise<ImSearchOperationResult>;
8434
+ completeLocation: (messageId: string) => boolean;
8435
+ clearLocation: () => void;
8436
+ reset: (options?: {
8437
+ preserveLocation?: boolean;
8438
+ }) => void;
8439
+ dispose: () => void;
8440
+ }, any>, Pick<{
8441
+ keyword: any;
8442
+ results: any;
8443
+ searching: any;
8444
+ hasMore: any;
8445
+ category: any;
8446
+ locatingMessageId: any;
8447
+ highlightMessageId: any;
8448
+ error: any;
8449
+ search: (nextKeyword: string) => Promise<ImSearchOperationResult>;
8450
+ setCategory: (nextCategory: ConversationSearchCategory) => Promise<ImSearchOperationResult>;
8451
+ loadMore: () => Promise<ImSearchOperationResult>;
8452
+ locate: (ref: ProductConversationRef$2, messageId: string) => Promise<ImSearchOperationResult>;
8453
+ completeLocation: (messageId: string) => boolean;
8454
+ clearLocation: () => void;
8455
+ reset: (options?: {
8456
+ preserveLocation?: boolean;
8457
+ }) => void;
8458
+ dispose: () => void;
8459
+ }, any>, Pick<{
8460
+ keyword: any;
8461
+ results: any;
8462
+ searching: any;
8463
+ hasMore: any;
8464
+ category: any;
8465
+ locatingMessageId: any;
8466
+ highlightMessageId: any;
8467
+ error: any;
8468
+ search: (nextKeyword: string) => Promise<ImSearchOperationResult>;
8469
+ setCategory: (nextCategory: ConversationSearchCategory) => Promise<ImSearchOperationResult>;
8470
+ loadMore: () => Promise<ImSearchOperationResult>;
8471
+ locate: (ref: ProductConversationRef$2, messageId: string) => Promise<ImSearchOperationResult>;
8472
+ completeLocation: (messageId: string) => boolean;
8473
+ clearLocation: () => void;
8474
+ reset: (options?: {
8475
+ preserveLocation?: boolean;
8476
+ }) => void;
8477
+ dispose: () => void;
8478
+ }, any>>;
8479
+ type ImSearchStore = ReturnType<ReturnType<typeof defineImSearchStore>>;
8358
8480
  /** 取得当前 Vue setup 或显式 Pinia 的搜索 Store;不同宿主实例不会共享查询或定位状态。 */
8359
- declare function useImSearchStore(pinia?: Pinia): any;
8481
+ declare function useImSearchStore(pinia?: Pinia): ImSearchStore;
8360
8482
 
8361
8483
  /**
8362
8484
  * 为 PC/H5 提供同一套会话收藏列表和已收藏标记。
@@ -8621,4 +8743,4 @@ type MessageNotificationDecision = {
8621
8743
  declare function resolveMessageNotificationDecision(input: MessageNotificationInput): MessageNotificationDecision;
8622
8744
 
8623
8745
  export { applicationKey, createAndInstallImChatKit, createImChatKitContext, disposeImChatKit, ensureImChatKitSelfProfile, getImChatKitContext, imMediaDownloadKey, installImChatKit, resolveMessageNotificationDecision, useImApplicationsStore, useImCapabilitiesStore, useImComposerStore, useImConversationActivationCoordinator, useImConversationDeletionCoordinator, useImConversationListStore, useImExpressionStore, useImHistoryReturnAfterSendCoordinator, useImMediaStore, useImMessageOperationsStore, useImProfileDirectoryStore, useImQuotedMessageStore, useImReactionStore, useImSearchStore, useImSessionFavoritesStore, useImSessionStore, useImThreadPagingStore, useImThreadReturnToLatestCoordinator, useImThreadStore };
8624
- export type { ApplyImSessionInput, ChatRuntimeFactories, ChatRuntimeHostDeps, ImApplicationDomainCounts, ImApplicationReviewOperation, ImApplicationReviewResult, ImApplicationsReloadResult, ImApplicationsStoreError, ImCapabilitiesStore, ImChannelManagementMemberTarget, ImChannelMemberManagementOperation, ImChannelMemberManagementResult, ImChannelMemberManagementResultFor, ImChannelProfileActionResult, ImChannelProfileActionResultFor, ImChannelProfileOperation, ImChatKitContext, ImChatKitInstallation, ImComposerStore, ImComposerStoreActions, ImComposerStoreState, ImComposerSubmitResult, ImConversationActivationCoordinator, ImConversationActivationError, ImConversationActivationResult, ImConversationDeletionCoordinator, ImConversationDeletionError, ImConversationDeletionResult, ImConversationListActionError, ImConversationListMutationOperation, ImConversationListMutationResult, ImConversationListRefreshResult, ImConversationListStore, ImDirectContactActionResult, ImDirectContactActionResultFor, ImDirectContactOperation, ImDirectoryState, ImEmojiPanelRecentEntry, ImEmojiRecentEntry, ImExpressionLoadStatus, ImExpressionOperation, ImExpressionOperationResult, ImExpressionRecentPersistencePort, ImExpressionRecentPersistenceSnapshot, ImExpressionRecentViewItem, ImExpressionResetOptions, ImExpressionSendResult, ImExpressionStore, ImExpressionStoreActions, ImExpressionStoreError, ImExpressionStoreGetters, ImExpressionStoreState, ImForwardPreparationResult, ImGameRecentEntry, ImGroupMemberManagementOperation, ImGroupMemberManagementResult, ImGroupMemberManagementResultFor, ImGroupProfileActionResult, ImGroupProfileActionResultFor, ImGroupProfileOperation, ImHistoryReturnAfterSendCoordinator, ImHistoryReturnError, ImHistoryReturnExecution, ImHistoryReturnResult, ImMediaOperationResult, ImMediaReplacementRequest, ImMediaStoreError, ImMediaTaskPresentation, ImMembershipJoinActionResult, ImMembershipJoinOperation, ImMessageOperationsStore, ImMessageOperationsStoreActions, ImMessageOperationsStoreState, ImMessageSelectionResult, ImPersistedEmojiPanelRecentEntry, ImPersistedEmojiRecentEntry, ImPersistedExpressionAssetRecentEntry, ImPersistedGameRecentEntry, ImProfileAccessDestination, ImProfileAccessResult, ImProfileDirectoryResult, ImQuotedMessageState, ImQuotedMessageStore, ImQuotedMessageStoreActions, ImQuotedMessageStoreState, ImReactionOperationResult, ImReactionStore, ImReactionStoreActions, ImReactionStoreError, ImReactionStoreState, ImSearchOperationResult, ImSessionFavoritesReloadResult, ImSessionFavoritesStoreError, ImSessionFavoritesWriteResult, ImSessionPhase, ImSessionStore, ImThreadPagingActions, ImThreadPagingState, ImThreadPagingStore, ImThreadReturnToLatestCoordinator, ImThreadStore, ImThreadStoreActions, ImThreadStoreState };
8746
+ export type { ApplyImSessionInput, ChatRuntimeFactories, ChatRuntimeHostDeps, ImApplicationDomainCounts, ImApplicationReviewOperation, ImApplicationReviewResult, ImApplicationsReloadResult, ImApplicationsStoreError, ImCapabilitiesStore, ImChannelManagementMemberTarget, ImChannelMemberManagementOperation, ImChannelMemberManagementResult, ImChannelMemberManagementResultFor, ImChannelProfileActionResult, ImChannelProfileActionResultFor, ImChannelProfileOperation, ImChatKitContext, ImChatKitInstallation, ImComposerStore, ImComposerStoreActions, ImComposerStoreState, ImComposerSubmitResult, ImConversationActivationCoordinator, ImConversationActivationError, ImConversationActivationResult, ImConversationDeletionCoordinator, ImConversationDeletionError, ImConversationDeletionResult, ImConversationListActionError, ImConversationListMutationOperation, ImConversationListMutationResult, ImConversationListRefreshResult, ImConversationListStore, ImDirectContactActionResult, ImDirectContactActionResultFor, ImDirectContactOperation, ImDirectoryState, ImEmojiPanelRecentEntry, ImEmojiRecentEntry, ImExpressionLoadStatus, ImExpressionOperation, ImExpressionOperationResult, ImExpressionRecentPersistencePort, ImExpressionRecentPersistenceSnapshot, ImExpressionRecentViewItem, ImExpressionResetOptions, ImExpressionSendResult, ImExpressionStore, ImExpressionStoreActions, ImExpressionStoreError, ImExpressionStoreGetters, ImExpressionStoreState, ImForwardPreparationResult, ImGameRecentEntry, ImGroupMemberManagementOperation, ImGroupMemberManagementResult, ImGroupMemberManagementResultFor, ImGroupProfileActionResult, ImGroupProfileActionResultFor, ImGroupProfileOperation, ImHistoryReturnAfterSendCoordinator, ImHistoryReturnError, ImHistoryReturnExecution, ImHistoryReturnResult, ImMediaOperationResult, ImMediaReplacementRequest, ImMediaStore, ImMediaStoreError, ImMediaTaskPresentation, ImMembershipJoinActionResult, ImMembershipJoinOperation, ImMessageOperationsStore, ImMessageOperationsStoreActions, ImMessageOperationsStoreState, ImMessageSelectionResult, ImPersistedEmojiPanelRecentEntry, ImPersistedEmojiRecentEntry, ImPersistedExpressionAssetRecentEntry, ImPersistedGameRecentEntry, ImProfileAccessDestination, ImProfileAccessResult, ImProfileDirectoryResult, ImQuotedMessageState, ImQuotedMessageStore, ImQuotedMessageStoreActions, ImQuotedMessageStoreState, ImReactionOperationResult, ImReactionStore, ImReactionStoreActions, ImReactionStoreError, ImReactionStoreState, ImSearchOperationResult, ImSearchStore, ImSessionFavoritesReloadResult, ImSessionFavoritesStoreError, ImSessionFavoritesWriteResult, ImSessionPhase, ImSessionStore, ImThreadPagingActions, ImThreadPagingState, ImThreadPagingStore, ImThreadReturnToLatestCoordinator, ImThreadStore, ImThreadStoreActions, ImThreadStoreState };