k2-im 0.1.36 → 0.1.37

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{Ta as canCopyImageToClipboard,Ua as copyImageToClipboard,B as createLazyBrowserApiProtocolClient}from'./chunk-4CH72T6I.js';import'./chunk-ANHUDX3C.js';import'./chunk-WOT6VMZA.js';
1
+ export{Ta as canCopyImageToClipboard,Ua as copyImageToClipboard,B as createLazyBrowserApiProtocolClient}from'./chunk-HUSCO5JM.js';import'./chunk-75GNCLQQ.js';import'./chunk-WOT6VMZA.js';
@@ -202,6 +202,8 @@ interface ImVideoBody {
202
202
  width: number;
203
203
  /** 视频像素高(BMessage.height)。 */
204
204
  height: number;
205
+ /** 发送方显式选择了 HD 原视频(BMessage.hd);不按分辨率猜测。 */
206
+ hd?: boolean;
205
207
  /** 时长(秒,可含小数);移动端旧消息的毫秒值由 SDK 转换,宿主不得猜单位。 */
206
208
  duration?: number;
207
209
  /** SDK 已确认时长为秒的标记;兼容旧缓存时防止重复转换。缺省仍按公开 API 的秒约定传入。 */
@@ -774,7 +776,7 @@ interface ImMessage {
774
776
  };
775
777
  /**
776
778
  * CHANNEL 管理员/社群主全员删除终态。它与发送者本人撤回、`deleteLocal` 完全不同:服务端通过
777
- * `RADIO_ADMIN_CANCEL_*` 同步给全员,正文不可逆清空,产品统一展示“管理员删除了一条消息”。
779
+ * `RADIO_ADMIN_CANCEL_*` 同步给全员,正文不可逆清空;线程与会话摘要仅向群主、管理员展示删除提示,普通成员及未知角色隐藏。
778
780
  */
779
781
  deletedForEveryone?: {
780
782
  by: string;
@@ -956,6 +958,15 @@ interface ImSession {
956
958
  * 派生展示字段(随最新消息变化,会话列表据此显示发送中 loading / 失败图标);运行期真相,不持久化(persistSession 落盘时剔除)。
957
959
  */
958
960
  lastMessageSendState?: 'sending' | 'failed';
961
+ /**
962
+ * 最新一条己方已发送消息的回执态。
963
+ *
964
+ * 只在自己发出且 `status='sent'` 时投影;发送中/失败、对端消息、撤回、全员删除和系统提示都不给。
965
+ * `delivered` 与尚未回执一样投影为 `unread`;当前协议没有送达通知,不能把 `sent` 当作对端已收到。
966
+ * 该字段随最新消息变化,并随会话落盘,避免冷启动后
967
+ * 因「盘中缺字段 / 内存有字段」反复广播;对端已读变化必须刷新会话行。
968
+ */
969
+ lastMessageReceipt?: 'unread' | 'read';
959
970
  /** P0 我方已读游标(见 §4.3)。 */
960
971
  readCursor?: string;
961
972
  /** 群受限状态(仅 group;来自 0x2204 群通知 side-effect)。缺省视为 'active'(可正常发送)。 */
@@ -1057,8 +1068,8 @@ interface UserProfile {
1057
1068
  /** 用户自设昵称(后端 `nick_name`)。 */
1058
1069
  nickname: string;
1059
1070
  /**
1060
- * 好友备注名(后端 `/user/info/friend` 的 `remark_name`,仅好友关系有)。
1061
- * 与 `nickname` 并存:展示名优先级 = 备注名 > 昵称(安卓 SessionUtils.getShowUserName 实证)。
1071
+ * 好友展示备注(后端 `/user/info/friend` 的 `remark_name`,无备注时回退 `contact_name`,仅好友关系有)。
1072
+ * 与 `nickname` 并存:展示名优先级 = 备注名/通讯录名 > 昵称(安卓 SessionUtils.getShowUserName 实证)。
1062
1073
  */
1063
1074
  remark?: string;
1064
1075
  avatar?: string;
@@ -2109,6 +2120,11 @@ type StoredConversationBackground = {
2109
2120
  * 失败经 `error` 事件(scope:'storage')暴露、不静默吞、不阻塞内存主流程。
2110
2121
  */
2111
2122
  interface ImStoragePort {
2123
+ /**
2124
+ * 显式支持 CHANNEL 持久同步位置。声明 true 的 adapter 必须在删除会话正文/清历史事务中
2125
+ * 同时删除 channelSyncCheckpointKey 对应 meta;旧 adapter 缺省不启用跨运行续传。
2126
+ */
2127
+ readonly supportsChannelSyncCheckpoint?: true;
2112
2128
  /** 可选的最近页持久缓存;缺少该能力时 SDK 必须明确跳过持久预取。 */
2113
2129
  recentHistoryCache?: ImRecentHistoryCachePort;
2114
2130
  /** 打开/创建账号库并跑迁移(幂等)。open 前的读写应视为未就绪并抛错(不静默兜底)。 */
@@ -2174,12 +2190,13 @@ interface ImStoragePort {
2174
2190
  deleteSession: (conversation: ImStorageConversation) => Promise<void>;
2175
2191
  /** 删除单会话已读态(删除会话用)。 */
2176
2192
  deleteReadState: (conversation: ImStorageConversation) => Promise<void>;
2177
- /** 删除某会话全部本地消息(删除会话用)。 */
2193
+ /** 删除某会话全部本地消息及对应 CHANNEL 同步位置,二者须在同一事务内清理。 */
2178
2194
  deleteConversationMessages: (conversation: ImStorageConversation) => Promise<void>;
2179
2195
  /**
2180
2196
  * 原子清空精确会话的本机历史,并同步写入清空后的会话摘要与本机读态。
2181
2197
  *
2182
2198
  * @remarks 这是可选 capability,供产品 `history.clearLocal()` 使用;自定义 adapter 未实现时必须显式拒绝,不能退化为多次写入制造半清理状态。
2199
+ * 同一事务还须删除 channelSyncCheckpointKey(conversation) 对应同步位置,避免正文已清而继续跳过旧页。
2183
2200
  * 不删除会话行、草稿、Outbox、置顶消息或任何远端数据。
2184
2201
  */
2185
2202
  clearConversationHistory?: (conversation: ConversationRef, nextSession?: ImSession, nextReadState?: ReadState) => Promise<void>;
@@ -4350,6 +4367,13 @@ interface ConversationListItem {
4350
4367
  by: string;
4351
4368
  }>;
4352
4369
  lastMessageSendState?: 'sending' | 'failed';
4370
+ /**
4371
+ * 最新一条己方已发送消息的对端已读态。
4372
+ *
4373
+ * 只在自己发出且已发送成功时出现;发送中/失败、对端消息、撤回和系统提示都不给。
4374
+ * 单聊会话列表用它在摘要前画灰色单勾/绿色双勾;群组与社群即使有该字段也不展示。
4375
+ */
4376
+ lastMessageReceipt?: 'unread' | 'read';
4353
4377
  timestamp: number;
4354
4378
  unreadCount: number;
4355
4379
  /** 是否为用户手工添加的本地未读提醒;此时 `unreadCount` 至少投影为 1。 */
@@ -4538,6 +4562,21 @@ type ConversationEntryUnreadSnapshot = Readonly<{
4538
4562
  }> | Readonly<{
4539
4563
  state: 'unavailable';
4540
4564
  }>;
4565
+ /** 进入时冻结的导航提示;数量独立于会话已读,不暴露内部历史排序边界。 */
4566
+ type ConversationEntryUnreadNavigation = Readonly<{
4567
+ state: 'none';
4568
+ }> | Readonly<{
4569
+ state: 'pending' | 'unavailable';
4570
+ count: number;
4571
+ }> | Readonly<{
4572
+ state: 'located';
4573
+ count: number;
4574
+ firstMessageId: string;
4575
+ }> | Readonly<{
4576
+ state: 'failed';
4577
+ count: number;
4578
+ error: ImSdkErrorShape;
4579
+ }>;
4541
4580
 
4542
4581
  /**
4543
4582
  * Emoji、GIF 与贴图稳定产品门面。
@@ -4701,6 +4740,8 @@ interface ConversationOpenOptions {
4701
4740
  * 后续 read 事件或新消息不会移动分隔线。
4702
4741
  */
4703
4742
  initialPosition?: ConversationInitialPosition;
4743
+ /** 冻结进入时未读导航,独立于初始位置;清会话未读后仍可定位原边界。 */
4744
+ captureEntryUnread?: boolean;
4704
4745
  /**
4705
4746
  * 初始历史加载方式,默认 `blocking`。
4706
4747
  *
@@ -4728,6 +4769,8 @@ interface ConversationHandleSnapshot<TType extends ProductHandleConversationType
4728
4769
  messages: readonly ImMessageView[];
4729
4770
  /** 本次打开时冻结的未读入口;只用于产品 UI 分隔线,不作为 SDK 已读真相。 */
4730
4771
  entryUnread: ConversationEntryUnreadSnapshot;
4772
+ /** 显式请求的进入导航快照;旧消费者不请求时省略。 */
4773
+ entryUnreadNavigation?: ConversationEntryUnreadNavigation;
4731
4774
  /** 当前账号本机草稿;不承诺跨端同步。 */
4732
4775
  draft: ConversationDraft | null;
4733
4776
  loading: boolean;
@@ -5028,6 +5071,8 @@ interface ConversationHandle<TType extends ProductHandleConversationType = Produ
5028
5071
  resolveMessage: (messageId: string) => Promise<ImMessageView | null>;
5029
5072
  history: {
5030
5073
  loadLatest: () => Promise<void>;
5074
+ /** 有限加载进入时冻结边界;成功才替换窗口,不可定位返回 false,网络失败抛错并保留数量。 */
5075
+ loadEntryUnread: () => Promise<boolean>;
5031
5076
  loadOlder: () => Promise<void>;
5032
5077
  /** 历史定位窗口向更新方向连续翻页;接回最新端后 `hasNewer` 变为 false。 */
5033
5078
  loadNewer: () => Promise<void>;
@@ -5058,6 +5103,10 @@ interface ConversationHandle<TType extends ProductHandleConversationType = Produ
5058
5103
  draft: ConversationDraftApi;
5059
5104
  /** 标记窗口最新消息或显式可见消息为已读;SDK 按精确 sibling 解析真实 read cursor。 */
5060
5105
  markRead: (messageId?: string) => Promise<void>;
5106
+ /** 结算最新可信边界的会话未读;不会将整个范围登记为对端可见回执。 */
5107
+ markConversationRead: () => Promise<void>;
5108
+ /** 只登记实际可见的消息 ID;历史消息也可补报,媒体消费继续使用独立动作。 */
5109
+ markVisibleMessages: (messageIds: readonly string[]) => Promise<void>;
5061
5110
  setMuted: (muted: boolean) => Promise<void>;
5062
5111
  close: () => void;
5063
5112
  }
@@ -9209,6 +9258,8 @@ interface ImThreadStoreState {
9209
9258
  display: ConversationHandleSnapshot['display'] | null;
9210
9259
  messages: readonly ImMessageView[];
9211
9260
  entryUnread: ConversationEntryUnreadSnapshot;
9261
+ /** 本次进入前的数量与定位状态;列表清零后仍保留。 */
9262
+ entryUnreadNavigation: ConversationHandleSnapshot['entryUnreadNavigation'];
9212
9263
  draft: ConversationDraft | null;
9213
9264
  loading: boolean;
9214
9265
  ready: boolean;
@@ -9224,6 +9275,14 @@ interface ImThreadStoreActions {
9224
9275
  open: (ref: ConversationRef<ProductHandleConversationType>) => Promise<ProductConversationHandle | undefined>;
9225
9276
  invalidatePendingOpen: () => void;
9226
9277
  loadLatest: () => Promise<boolean>;
9278
+ /** 读取本次进入时冻结的首未读窗口。 */
9279
+ loadEntryUnread: () => Promise<boolean>;
9280
+ /** 页面确认可阅读后结算整会话;不会自动扩大可见消息回执。 */
9281
+ markConversationRead: () => Promise<void>;
9282
+ /** 只上报当前线程实际显示的消息集合。 */
9283
+ markVisibleMessages: (messageIds: readonly string[]) => Promise<void>;
9284
+ /** 明确业务离开;账号销毁和页面卸载仍使用无副作用的 close/reset。 */
9285
+ leave: () => void;
9227
9286
  loadOlder: () => Promise<boolean>;
9228
9287
  loadNewer: () => Promise<boolean>;
9229
9288
  loadAround: (messageId: string) => Promise<boolean>;