k2-im 0.1.33 → 0.1.34

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-OFXCH5DZ.js';import'./chunk-F6DQBWJW.js';import'./chunk-WOT6VMZA.js';
1
+ export{Ta as canCopyImageToClipboard,Ua as copyImageToClipboard,B as createLazyBrowserApiProtocolClient}from'./chunk-IEFK5A7T.js';import'./chunk-PJ2PW42T.js';import'./chunk-WOT6VMZA.js';
@@ -679,7 +679,7 @@ type ImMessageFailureReason = 'timeout' | 'rejected' | 'encrypt_failed' | 'netwo
679
679
  * 失败**展示语义**码(强类型枚举,非裸串):供 im-i18n 按 locale 渲染失败气泡文案。
680
680
  * 由 `reason` / `SendMediaFailReason` / ACK errcode 穷尽映射而来,与 im-i18n failure catalog 键一一对应(media.* 带 mediaKind 参数)。
681
681
  */
682
- type ImFailureDisplayCode = 'media.empty' | 'media.noCrypto' | 'media.previewFailed' | 'media.encryptFailed' | 'media.resumeUnavailable' | 'media.cleanupUnconfirmed' | 'media.uploadFailed' | 'media.cancelled' | 'media.invalidDuration' | 'media.uploadInterrupted' | 'media.contentTooLarge' | 'contactRequired' | 'messageRefused' | 'forbiddenOrLeft' | 'contentRejected' | 'groupDismissed' | 'groupUnavailable' | 'channelDismissed' | 'channelMuted' | 'channelNotMember' | 'channelAdminRequired' | 'conversationUnsupported' | 'sendCanceled' | 'sessionLoggedOut' | 'timeout' | 'network' | 'unknown';
682
+ type ImFailureDisplayCode = 'media.empty' | 'media.noCrypto' | 'media.previewFailed' | 'media.encryptFailed' | 'media.resumeUnavailable' | 'media.cleanupUnconfirmed' | 'media.uploadFailed' | 'media.uploadTimeout' | 'media.cancelled' | 'media.invalidDuration' | 'media.uploadInterrupted' | 'media.contentTooLarge' | 'contactRequired' | 'messageRefused' | 'forbiddenOrLeft' | 'contentRejected' | 'groupDismissed' | 'groupUnavailable' | 'channelDismissed' | 'channelMuted' | 'channelNotMember' | 'channelAdminRequired' | 'conversationUnsupported' | 'sendCanceled' | 'sessionLoggedOut' | 'timeout' | 'network' | 'unknown';
683
683
  interface ImMessageFailure {
684
684
  /** 归一后的错误码(来自 MESChatAck.errcode 或本地失败码,本地码用负值)。 */
685
685
  code: number;
@@ -705,7 +705,7 @@ interface MediaTaskUpdate {
705
705
  messageId: string;
706
706
  ref: ConversationRef;
707
707
  direction: 'upload' | 'download';
708
- state: 'queued' | 'running' | 'completed' | 'failed' | 'canceled';
708
+ state: 'queued' | 'running' | 'paused' | 'completed' | 'failed' | 'canceled';
709
709
  percent: number;
710
710
  /**
711
711
  * upload 任务子阶段。
@@ -713,7 +713,16 @@ interface MediaTaskUpdate {
713
713
  * `waiting-upload-slot` 与 `state: 'queued'` 同时出现,表示还没开始传字节(在生成缩略图或在等上传槽位),
714
714
  * 此时 percent 恒为 0;`transferring` 正在传字节;`finalizing` 是等待远端 URL 最终确认。
715
715
  */
716
- phase?: 'waiting-upload-slot' | 'transferring' | 'finalizing';
716
+ phase?: 'waiting-upload-slot' | 'waiting-retry' | 'transferring' | 'finalizing';
717
+ /** 当前发送意图的尝试序号与总上限。 */
718
+ attempt?: number;
719
+ maxAttempts?: number;
720
+ /** 已传与总字节数,供共享展示层估算速度。 */
721
+ bytesTransferred?: number;
722
+ bytesTotal?: number;
723
+ /** 跨刷新恢复可用性;缺省尚未建立恢复记录。 */
724
+ recovery?: 'available' | 'session-only';
725
+ recoveryReason?: string;
717
726
  failure?: ImMessageFailure;
718
727
  }
719
728
  interface ImMessageEncryption {
@@ -4819,9 +4828,9 @@ interface ConversationMessageApi {
4819
4828
  /** 显式添加/替换或移除,供参与者详情等不能用 toggle 猜动作的产品交互。 */
4820
4829
  setReaction: (messageId: string, emoji: string, action: ImReactionChangeAction) => Promise<ImReactionChangeResult>;
4821
4830
  /**
4822
- * 为刷新后上传中断的视频重新选择源文件,并原地替换同一条消息。
4831
+ * 为源文件已释放的视频重新选择源文件,并原地替换同一条消息。
4823
4832
  *
4824
- * @remarks 只接受当前 handle 中 `media.uploadInterrupted` 的失败视频。SDK 复用原消息 id 与排序时间,
4833
+ * @remarks 只接受上传中断、已取消或超时耗尽后的失败视频;必须重新选择文件。SDK 复用原消息 id 与排序时间,
4825
4834
  * 不清理当前 Composer 草稿;重新上传失败仍更新同一条消息。
4826
4835
  * @example
4827
4836
  * ```ts
@@ -4830,9 +4839,9 @@ interface ConversationMessageApi {
4830
4839
  */
4831
4840
  replaceInterruptedVideo: (messageId: string, file: File | Blob, options?: VideoMessageOptions) => Promise<SendMessageResult>;
4832
4841
  /**
4833
- * 为刷新后上传中断的文件重新选择源文件,并原地替换同一条消息。
4842
+ * 为源文件已释放的文件重新选择源文件,并原地替换同一条消息。
4834
4843
  *
4835
- * @remarks 只接受当前 handle 中 `media.uploadInterrupted` 的失败文件。SDK 复用原消息 id 与排序时间,
4844
+ * @remarks 只接受上传中断、已取消或超时耗尽后的失败文件或单项 filesAlbum;保留原配文。SDK 复用原消息 id 与排序时间,
4836
4845
  * 不清理当前 Composer 草稿;Blob 没有 name 时仍必须传 `fileName`。
4837
4846
  * @example
4838
4847
  * ```ts
@@ -5160,7 +5169,7 @@ interface ImMediaTask {
5160
5169
  /** upload 来自发送链路,download 来自本产品 API。 */
5161
5170
  direction: 'upload' | 'download';
5162
5171
  /** 终态 completed/failed/canceled 不会被同一尝试的迟到 progress 回退。 */
5163
- state: 'queued' | 'running' | 'completed' | 'failed' | 'canceled';
5172
+ state: 'queued' | 'running' | 'paused' | 'completed' | 'failed' | 'canceled';
5164
5173
  /** 0-100 的归一化整数。 */
5165
5174
  percent: number;
5166
5175
  /**
@@ -5170,7 +5179,16 @@ interface ImMediaTask {
5170
5179
  * 等上传槽位),此时 `percent` 恒为 0——宿主应显示「等待中」而不是把 0 当成停住的进度。
5171
5180
  * `transferring` 是正在传字节,`finalizing` 是字节已传完、在等对象存储确认。
5172
5181
  */
5173
- phase?: 'waiting-upload-slot' | 'transferring' | 'finalizing';
5182
+ phase?: 'waiting-upload-slot' | 'waiting-retry' | 'transferring' | 'finalizing';
5183
+ /** 当前发送意图的尝试序号与总上限。 */
5184
+ attempt?: number;
5185
+ maxAttempts?: number;
5186
+ /** 已传与总字节数,供共享展示层估算速度。 */
5187
+ bytesTransferred?: number;
5188
+ bytesTotal?: number;
5189
+ /** 跨刷新恢复可用性;缺省尚未建立恢复记录。 */
5190
+ recovery?: 'available' | 'session-only';
5191
+ recoveryReason?: string;
5174
5192
  /** 可供产品按 code/category 决策的稳定错误;不含底层 URL、密钥或响应正文。 */
5175
5193
  error?: ImSdkErrorShape;
5176
5194
  }
@@ -5208,6 +5226,20 @@ interface ImMediaTasksApi {
5208
5226
  * @throws 未知任务、非法状态或底层未受理时以稳定 `IM_SDK_MEDIA_TASK_*` 错误拒绝。
5209
5227
  */
5210
5228
  cancel: (taskId: string) => Promise<void>;
5229
+ /** 暂停上传,等待请求收尾后返回;下载不支持暂停。 */
5230
+ pause: (taskId: string) => Promise<void>;
5231
+ /** 恢复已暂停上传,复用同一原文件与消息。 */
5232
+ resume: (taskId: string) => Promise<void>;
5233
+ /** 只暴露恢复可用性,不返回文件密钥或远端分片凭据。 */
5234
+ getUploadRecovery: (message: ImMessageRef) => Promise<{
5235
+ available: boolean;
5236
+ reason?: string;
5237
+ expiresAt?: number;
5238
+ }>;
5239
+ /** 用户重选原文件并通过完整内容校验后恢复原消息。 */
5240
+ resumeUpload: (message: ImMessageRef, input: {
5241
+ file: Blob;
5242
+ }) => Promise<void>;
5211
5243
  /**
5212
5244
  * 重试 failed/canceled 任务;上传复用保留原文件,下载重新解析同一精确消息引用。
5213
5245
  * 续传不可用或清理未确认时,必须先征得用户同意重新上传,再传 restartUpload:true。
@@ -6011,6 +6043,10 @@ interface ImClientOptions {
6011
6043
  * 缺省则**不装配媒体传输端口** → `sendImage`/`sendVideo`/`loadImage`/`loadVideo` 显式不可用(connection 层 reject,非静默);预览(Canvas 缩略图/封面)不依赖此配置、恒可用。
6012
6044
  */
6013
6045
  media?: ImMediaConfig;
6046
+ /** 显式开启视频/文件跨刷新续传。最多 3 条、24 小时,保存加密密钥但不保存文件副本;注销清除。 */
6047
+ uploadRecovery?: {
6048
+ enabled: boolean;
6049
+ };
6014
6050
  }
6015
6051
  /**
6016
6052
  * 官方 UI Kit、调试工具与高级宿主的装配参数。
@@ -6623,6 +6659,10 @@ interface ChatRuntimeHostDeps {
6623
6659
  clientType: number;
6624
6660
  /** 获取当前环境的媒体上传下载配置;未启用媒体能力时返回 `undefined`。 */
6625
6661
  getMediaConfig: () => ImMediaConfig | undefined;
6662
+ /** 显式启用账号隔离的跨刷新恢复记录;保存密钥、不保存原文件,注销清除。 */
6663
+ uploadRecovery?: {
6664
+ enabled: boolean;
6665
+ };
6626
6666
  /** 获取 GIF provider 配置;API key 只留在宿主闭包与 SDK adapter,不进入共享 Store。 */
6627
6667
  getExpressionOptions?: () => ImExpressionOptions | undefined;
6628
6668
  }
@@ -7517,10 +7557,16 @@ interface ImHistoryReturnAfterSendCoordinator {
7517
7557
  */
7518
7558
  declare function useImHistoryReturnAfterSendCoordinator(pinia?: Pinia): ImHistoryReturnAfterSendCoordinator;
7519
7559
 
7560
+ /** 展示层估算,不表示服务端确认进度或最终处理耗时。 */
7561
+ interface MediaTransferEstimate {
7562
+ readonly bytesPerSecond: number;
7563
+ readonly estimatedRemainingMs: number;
7564
+ }
7565
+
7520
7566
  /** 页面可保存和判断的媒体错误;底层响应、异常对象和详情只进入统一诊断,不进入 Pinia。 */
7521
7567
  type ImMediaStoreError = Readonly<Omit<ImSdkErrorShape, 'cause' | 'details'>>;
7522
7568
  /** 页面可展示的只读媒体任务;不含文件字节、本地地址、密钥、中止控制器或传输对象。 */
7523
- type ImMediaTaskPresentation = Readonly<Omit<ImMediaTask, 'error'> & {
7569
+ type ImMediaTaskPresentation = Readonly<Omit<ImMediaTask, 'error'> & Partial<MediaTransferEstimate> & {
7524
7570
  error?: ImMediaStoreError;
7525
7571
  }>;
7526
7572
  /** 刷新页面导致上传源丢失后,通知宿主重新打开文件选择器所需的信息;File 本身不进入 Store。 */
@@ -7530,14 +7576,14 @@ interface ImMediaReplacementRequest {
7530
7576
  conversationType: ProductHandleConversationType;
7531
7577
  kind: 'video' | 'file';
7532
7578
  }
7533
- /** 取消/重试结果;`stale` 表示期间已切账号,宿主不应显示旧任务反馈。 */
7579
+ /** 媒体控制结果;`stale` 表示期间已切账号,宿主不应显示旧任务反馈。 */
7534
7580
  type ImMediaOperationResult = Readonly<{
7535
7581
  ok: true;
7536
- operation: 'cancel' | 'retry';
7582
+ operation: 'cancel' | 'retry' | 'pause' | 'resume' | 'resumeUpload';
7537
7583
  } | {
7538
7584
  ok: false;
7539
- operation: 'cancel' | 'retry';
7540
- reason: 'not-ready' | 'not-found' | 'failed' | 'stale';
7585
+ operation: 'cancel' | 'retry' | 'pause' | 'resume' | 'resumeUpload';
7586
+ reason: 'not-ready' | 'not-found' | 'ambiguous' | 'failed' | 'stale';
7541
7587
  error?: ImMediaStoreError;
7542
7588
  }>;
7543
7589
  /**
@@ -7552,6 +7598,7 @@ declare function defineImMediaStore(pinia: Pinia): pinia.StoreDefinition<"k2-im-
7552
7598
  tasks: any;
7553
7599
  error: any;
7554
7600
  uploadProgress: any;
7601
+ uploadTasks: any;
7555
7602
  downloadTasks: any;
7556
7603
  downloadProgress: any;
7557
7604
  uploadWaiting: any;
@@ -7563,8 +7610,18 @@ declare function defineImMediaStore(pinia: Pinia): pinia.StoreDefinition<"k2-im-
7563
7610
  retry: (taskId: string, options?: {
7564
7611
  restartUpload?: boolean;
7565
7612
  }) => Promise<ImMediaOperationResult>;
7613
+ pause: (taskId: string) => Promise<ImMediaOperationResult>;
7614
+ resume: (taskId: string) => Promise<ImMediaOperationResult>;
7615
+ getUploadRecovery: (message: ImMessageRef) => Promise<{
7616
+ available: boolean;
7617
+ reason?: string;
7618
+ expiresAt?: number;
7619
+ }>;
7620
+ resumeUpload: (message: ImMessageRef, input: {
7621
+ file: Blob;
7622
+ }) => Promise<ImMediaOperationResult>;
7566
7623
  cancelUpload: (messageId: string) => Promise<ImMediaOperationResult>;
7567
- cancelDownload: (messageId: string, itemIndex?: number) => Promise<ImMediaOperationResult>;
7624
+ cancelDownload: (message: string | ImMessageRef, itemIndex?: number) => Promise<ImMediaOperationResult>;
7568
7625
  requestReplacement: (message: ImMessageView) => boolean;
7569
7626
  takeReplacementRequest: () => ImMediaReplacementRequest | null;
7570
7627
  clearReplacementRequest: () => void;
@@ -7573,6 +7630,7 @@ declare function defineImMediaStore(pinia: Pinia): pinia.StoreDefinition<"k2-im-
7573
7630
  tasks: any;
7574
7631
  error: any;
7575
7632
  uploadProgress: any;
7633
+ uploadTasks: any;
7576
7634
  downloadTasks: any;
7577
7635
  downloadProgress: any;
7578
7636
  uploadWaiting: any;
@@ -7584,8 +7642,18 @@ declare function defineImMediaStore(pinia: Pinia): pinia.StoreDefinition<"k2-im-
7584
7642
  retry: (taskId: string, options?: {
7585
7643
  restartUpload?: boolean;
7586
7644
  }) => Promise<ImMediaOperationResult>;
7645
+ pause: (taskId: string) => Promise<ImMediaOperationResult>;
7646
+ resume: (taskId: string) => Promise<ImMediaOperationResult>;
7647
+ getUploadRecovery: (message: ImMessageRef) => Promise<{
7648
+ available: boolean;
7649
+ reason?: string;
7650
+ expiresAt?: number;
7651
+ }>;
7652
+ resumeUpload: (message: ImMessageRef, input: {
7653
+ file: Blob;
7654
+ }) => Promise<ImMediaOperationResult>;
7587
7655
  cancelUpload: (messageId: string) => Promise<ImMediaOperationResult>;
7588
- cancelDownload: (messageId: string, itemIndex?: number) => Promise<ImMediaOperationResult>;
7656
+ cancelDownload: (message: string | ImMessageRef, itemIndex?: number) => Promise<ImMediaOperationResult>;
7589
7657
  requestReplacement: (message: ImMessageView) => boolean;
7590
7658
  takeReplacementRequest: () => ImMediaReplacementRequest | null;
7591
7659
  clearReplacementRequest: () => void;
@@ -7594,6 +7662,7 @@ declare function defineImMediaStore(pinia: Pinia): pinia.StoreDefinition<"k2-im-
7594
7662
  tasks: any;
7595
7663
  error: any;
7596
7664
  uploadProgress: any;
7665
+ uploadTasks: any;
7597
7666
  downloadTasks: any;
7598
7667
  downloadProgress: any;
7599
7668
  uploadWaiting: any;
@@ -7605,8 +7674,18 @@ declare function defineImMediaStore(pinia: Pinia): pinia.StoreDefinition<"k2-im-
7605
7674
  retry: (taskId: string, options?: {
7606
7675
  restartUpload?: boolean;
7607
7676
  }) => Promise<ImMediaOperationResult>;
7677
+ pause: (taskId: string) => Promise<ImMediaOperationResult>;
7678
+ resume: (taskId: string) => Promise<ImMediaOperationResult>;
7679
+ getUploadRecovery: (message: ImMessageRef) => Promise<{
7680
+ available: boolean;
7681
+ reason?: string;
7682
+ expiresAt?: number;
7683
+ }>;
7684
+ resumeUpload: (message: ImMessageRef, input: {
7685
+ file: Blob;
7686
+ }) => Promise<ImMediaOperationResult>;
7608
7687
  cancelUpload: (messageId: string) => Promise<ImMediaOperationResult>;
7609
- cancelDownload: (messageId: string, itemIndex?: number) => Promise<ImMediaOperationResult>;
7688
+ cancelDownload: (message: string | ImMessageRef, itemIndex?: number) => Promise<ImMediaOperationResult>;
7610
7689
  requestReplacement: (message: ImMessageView) => boolean;
7611
7690
  takeReplacementRequest: () => ImMediaReplacementRequest | null;
7612
7691
  clearReplacementRequest: () => void;