k2-im 0.2.15 → 0.2.16
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/chat-kit-pinia.d.ts +22 -7
- package/dist/chat-kit-vue.d.ts +2 -0
- package/dist/chat-kit.d.ts +37 -12
- package/dist/index.d.ts +38 -13
- package/dist/modules/api-protocol-client/src/client.js +1 -1
- package/dist/modules/api-protocol-client/src/nonce.js +1 -1
- package/dist/modules/crypto/browser.js +1 -1
- package/dist/modules/crypto/driver.js +1 -1
- package/dist/modules/crypto/vendor/crypto/index_bg.js +1 -1
- package/dist/modules/im-browser/src/http/session-favorite-http-adapter.js +1 -1
- package/dist/modules/im-browser/src/media/media-preview-adapter.js +1 -1
- package/dist/modules/im-browser/src/media/media-preview-preparation-executor.js +1 -1
- package/dist/modules/im-browser/src/media/media-transfer-adapter.js +1 -1
- package/dist/modules/im-browser/src/media/webp-encoder.js +1 -0
- package/dist/modules/im-browser/src/media/webp-worker-factory.js +1 -0
- package/dist/modules/im-browser/src/network/browser-connection-ownership.js +1 -1
- package/dist/modules/im-browser/src/storage/indexed-db-storage-adapter.js +1 -1
- package/dist/modules/im-chat-kit/src/pinia/composer.store.js +1 -1
- package/dist/modules/im-chat-kit/src/pinia/expression.store.js +1 -1
- package/dist/modules/im-chat-kit/src/services/media.service.js +1 -1
- package/dist/modules/im-chat-kit/src/utils/emoji/unicode.js +1 -1
- package/dist/modules/im-chat-kit/src/vue/thread/thread-visibility-target-group.js +1 -1
- package/dist/modules/im-chat-kit/src/vue/thread/thread-visibility-targets.js +1 -1
- package/dist/modules/im-core/src/abort.js +1 -1
- package/dist/modules/im-core/src/mapping/message-id.js +1 -1
- package/dist/modules/im-core/src/media-thumbnail-policy.js +1 -1
- package/dist/modules/im-core/src/media-thumbnail.js +1 -1
- package/dist/modules/im-core/src/message-flow/media/media-sender.js +1 -1
- package/dist/modules/im-core/src/state/domain-state.js +1 -1
- package/dist/modules/im-sdk/src/create-im-client.js +1 -1
- package/dist/modules/im-sdk/src/product/conversation-handle.js +1 -1
- package/dist/modules/im-sdk/src/product/diagnostic-memory-buffer.js +1 -1
- package/dist/modules/im-sdk/src/product/media.js +1 -1
- package/dist/modules/im-sdk/src/runtime/local-media-preview.js +1 -1
- package/dist/modules/im-sdk/src/runtime/recent-history-prefetch.js +1 -1
- package/dist/request-crypto.d.ts +3 -2
- package/dist/sdk.d.ts +26 -11
- package/dist/vendor/crypto/index_bg.wasm +0 -0
- package/dist/vendor/webp/LICENSE.jsquash +201 -0
- package/dist/vendor/webp/LICENSE.libwebp +29 -0
- package/dist/vendor/webp/NOTICE +3 -0
- package/dist/webp.worker.js +3 -0
- package/package.json +1 -1
package/dist/chat-kit-pinia.d.ts
CHANGED
|
@@ -3358,13 +3358,13 @@ interface MediaAlbumMessageOptions {
|
|
|
3358
3358
|
* 本地视频的固有尺寸、时长与首帧封面。
|
|
3359
3359
|
*
|
|
3360
3360
|
* @remarks 宿主可从本地 object URL 解码首个可展示帧,使上传占位从首次渲染就使用真实比例和主图。
|
|
3361
|
-
* `posterData`
|
|
3361
|
+
* `posterData` 是等比缩放后的静态 WebP(兼容已有 JPEG/PNG);存在时会作为消息 `thumbData` 随正文发送。宽高必须是有限正数,
|
|
3362
3362
|
* duration 存在时必须是有限正数,posterData 必须是非空且不超过共享单项消息容量的 Uint8Array;合集发送会按项数复核容量。
|
|
3363
3363
|
*/
|
|
3364
3364
|
interface VideoPreviewMetadata extends ImagePreviewMetadata {
|
|
3365
3365
|
/** 秒。 */
|
|
3366
3366
|
duration?: number;
|
|
3367
|
-
/** 本地首个可展示帧生成的
|
|
3367
|
+
/** 本地首个可展示帧生成的 WebP 或已有 JPEG/PNG 字节。 */
|
|
3368
3368
|
posterData?: Uint8Array;
|
|
3369
3369
|
}
|
|
3370
3370
|
/**
|
|
@@ -5397,6 +5397,17 @@ interface ImMessageRef {
|
|
|
5397
5397
|
*/
|
|
5398
5398
|
itemIndex?: number;
|
|
5399
5399
|
}
|
|
5400
|
+
/** 单次媒体下载的等待与调度选项;相同精确消息引用仍共用一次实际下载。 */
|
|
5401
|
+
interface ImMediaDownloadOptions {
|
|
5402
|
+
/**
|
|
5403
|
+
* 只取消本次调用;其它调用者仍需要结果时保留共享下载。
|
|
5404
|
+
* 最后一个可取消调用者退出且没有无 signal 调用者时,才中止底层任务。
|
|
5405
|
+
* 取消以 IM_SDK_MEDIA_DOWNLOAD_CANCELED 拒绝本次 Promise,不返回部分文件。
|
|
5406
|
+
*/
|
|
5407
|
+
signal?: AbortSignal;
|
|
5408
|
+
/** 默认 interactive;background 在空闲名额中排在交互下载之后,不能抢占已发请求。 */
|
|
5409
|
+
priority?: 'background' | 'interactive';
|
|
5410
|
+
}
|
|
5400
5411
|
/**
|
|
5401
5412
|
* 可观察媒体上传/下载任务的只读产品投影。
|
|
5402
5413
|
*
|
|
@@ -5495,7 +5506,8 @@ interface ImMediaTasksApi {
|
|
|
5495
5506
|
*/
|
|
5496
5507
|
subscribe: (listener: (tasks: readonly ImMediaTask[]) => void) => () => void;
|
|
5497
5508
|
/**
|
|
5498
|
-
* 取消 queued/running 任务;上传委托 core
|
|
5509
|
+
* 取消 queued/running 任务;上传委托 core,下载中止共享任务并取消所有调用者。
|
|
5510
|
+
* 只需结束某次下载等待时,应使用 download 的 signal。
|
|
5499
5511
|
* @throws 未知任务、非法状态或底层未受理时以稳定 `IM_SDK_MEDIA_TASK_*` 错误拒绝。
|
|
5500
5512
|
*/
|
|
5501
5513
|
cancel: (taskId: string, options?: {
|
|
@@ -5530,10 +5542,13 @@ interface ImMediaTasksApi {
|
|
|
5530
5542
|
restartDownload?: boolean;
|
|
5531
5543
|
}) => Promise<void>;
|
|
5532
5544
|
/**
|
|
5533
|
-
*
|
|
5545
|
+
* 下载并按消息正文合同解密,同一精确消息引用共用实际下载,成功返回 Blob。
|
|
5546
|
+
* 不带 signal 的并发调用保留共享 Promise;带 signal 的调用独立等待和取消,不影响其它调用者。
|
|
5547
|
+
* 后加入的交互调用会提高共享下载优先级;prioritizeDownload 指定的最近预览仍优先于其它任务。
|
|
5534
5548
|
* @throws 消息不存在/非媒体/无远端 URL/未装配 capability、传输失败、取消或 teardown 均以稳定错误拒绝,不返回空 Blob。
|
|
5549
|
+
* @example const blob = await client.media.download(messageRef, { signal: controller.signal, priority: 'background' })
|
|
5535
5550
|
*/
|
|
5536
|
-
download: (message: ImMessageRef) => Promise<Blob>;
|
|
5551
|
+
download: (message: ImMessageRef, options?: ImMediaDownloadOptions) => Promise<Blob>;
|
|
5537
5552
|
/**
|
|
5538
5553
|
* 将最近预览的精确媒体项设为最高下载优先级,不新建或取消任务。
|
|
5539
5554
|
* 下一空闲任务/分片请求名额优先给该项;已发请求不中断,关闭播放器不撤销优先级。
|
|
@@ -5549,7 +5564,7 @@ interface ImMediaTasksApi {
|
|
|
5549
5564
|
*/
|
|
5550
5565
|
getCached: (message: ImMessageRef) => Promise<Blob | null>;
|
|
5551
5566
|
/**
|
|
5552
|
-
* 为宿主手里的**本地**图片/视频文件预读展示元信息:尺寸、视频时长、视频首帧封面的
|
|
5567
|
+
* 为宿主手里的**本地**图片/视频文件预读展示元信息:尺寸、视频时长、视频首帧封面的 WebP 字节。
|
|
5553
5568
|
*
|
|
5554
5569
|
* 给「发送前预览」这类场景用:宿主要在用户还没点发送时就把缩略图画出来,而浏览器读不出视频的
|
|
5555
5570
|
* 首帧——`<video preload="metadata">` 在 iOS Safari 上只加载元信息、**不解码任何一帧**,
|
|
@@ -5557,7 +5572,7 @@ interface ImMediaTasksApi {
|
|
|
5557
5572
|
*
|
|
5558
5573
|
* 返回的对象可以**原样**作为 `localPreviewMetadata` 交给 `sendImage` / `sendVideo` /
|
|
5559
5574
|
* `sendMediaAlbum`:发送链路会复用可用元信息;合集项超出其可用消息空间时重新生成封面。
|
|
5560
|
-
* posterData 使用共享自适应发送规格(视频
|
|
5575
|
+
* posterData 使用共享自适应发送规格(视频 WebP,长边最多 1440px,目标 16 KiB、硬上限 32 KiB);includeDisplayPoster 可在同一次解码中额外生成
|
|
5561
5576
|
* 仅供页面显示的高清 displayPoster(长边最多 960),不得绕过发送校验直接用它替换 posterData。
|
|
5562
5577
|
*
|
|
5563
5578
|
* @param input.kind 按文件类型选解码路径;`'video'` 才会抽首帧与读时长。
|
package/dist/chat-kit-vue.d.ts
CHANGED
|
@@ -2079,6 +2079,8 @@ interface ThreadVisibilityTargetsOptions<TItem> {
|
|
|
2079
2079
|
onScrollingChange?: (scrolling: boolean) => void;
|
|
2080
2080
|
/** 节点在滚动停止后仍可见时首次触发,适合安排 cache-only 读取。 */
|
|
2081
2081
|
onActivated?: (item: TItem) => void;
|
|
2082
|
+
/** 当前与滚动根有实际交集的目标;滚动中仍更新,不受驻留、近邻范围或稳定数量限制。 */
|
|
2083
|
+
onViewportVisibleChange?: (items: readonly TItem[]) => void;
|
|
2082
2084
|
/** 每次稳定可见集合变化时触发,顺序按节点距离滚动根中心由近到远。 */
|
|
2083
2085
|
onSettledVisibleChange?: (items: readonly TItem[]) => void;
|
|
2084
2086
|
/** 激活和稳定集合要求的最小可见比例;默认只要有交集即可。 */
|
package/dist/chat-kit.d.ts
CHANGED
|
@@ -2853,12 +2853,12 @@ declare function canTransmit(message: ForwardCandidateMessage): boolean;
|
|
|
2853
2853
|
type RecallFailReason = 'not-found' | 'not-own' | 'pinned' | 'not-sent' | 'expired' | 'unsupported' | 'timeout' | 'server-expired' | 'failed' | 'disconnected';
|
|
2854
2854
|
|
|
2855
2855
|
/**
|
|
2856
|
-
* 根据缩略图签名选择 PNG 或 JPEG 的显示类型,供 SDK 和 PC/H5 创建 Blob、data URL。
|
|
2857
|
-
* 输入是消息中的原始字节或纯 base64;旧消息没有独立 MIME
|
|
2856
|
+
* 根据缩略图签名选择 PNG、WebP 或 JPEG 的显示类型,供 SDK 和 PC/H5 创建 Blob、data URL。
|
|
2857
|
+
* 输入是消息中的原始字节或纯 base64;旧消息没有独立 MIME 字段,未知格式沿用 JPEG 解码,
|
|
2858
2858
|
* 损坏数据仍交给图片解码器报告失败。本函数不修改字节,也不将历史 JPEG 转码为 PNG。
|
|
2859
2859
|
* @example resolveMediaThumbnailMimeType(new Uint8Array([137, 80, 78, 71, 13, 10, 26, 10])) // 'image/png'
|
|
2860
2860
|
*/
|
|
2861
|
-
declare function resolveMediaThumbnailMimeType(source: Uint8Array | string): 'image/png' | 'image/jpeg';
|
|
2861
|
+
declare function resolveMediaThumbnailMimeType(source: Uint8Array | string): 'image/png' | 'image/webp' | 'image/jpeg';
|
|
2862
2862
|
|
|
2863
2863
|
/** 浏览器 PushSubscription.toJSON() 的可移植数据;不依赖 DOM 或浏览器全局。 */
|
|
2864
2864
|
interface ImWebPushSubscription {
|
|
@@ -3467,13 +3467,13 @@ interface MediaAlbumMessageOptions {
|
|
|
3467
3467
|
* 本地视频的固有尺寸、时长与首帧封面。
|
|
3468
3468
|
*
|
|
3469
3469
|
* @remarks 宿主可从本地 object URL 解码首个可展示帧,使上传占位从首次渲染就使用真实比例和主图。
|
|
3470
|
-
* `posterData`
|
|
3470
|
+
* `posterData` 是等比缩放后的静态 WebP(兼容已有 JPEG/PNG);存在时会作为消息 `thumbData` 随正文发送。宽高必须是有限正数,
|
|
3471
3471
|
* duration 存在时必须是有限正数,posterData 必须是非空且不超过共享单项消息容量的 Uint8Array;合集发送会按项数复核容量。
|
|
3472
3472
|
*/
|
|
3473
3473
|
interface VideoPreviewMetadata extends ImagePreviewMetadata {
|
|
3474
3474
|
/** 秒。 */
|
|
3475
3475
|
duration?: number;
|
|
3476
|
-
/** 本地首个可展示帧生成的
|
|
3476
|
+
/** 本地首个可展示帧生成的 WebP 或已有 JPEG/PNG 字节。 */
|
|
3477
3477
|
posterData?: Uint8Array;
|
|
3478
3478
|
}
|
|
3479
3479
|
/**
|
|
@@ -5508,6 +5508,17 @@ interface ImMessageRef {
|
|
|
5508
5508
|
*/
|
|
5509
5509
|
itemIndex?: number;
|
|
5510
5510
|
}
|
|
5511
|
+
/** 单次媒体下载的等待与调度选项;相同精确消息引用仍共用一次实际下载。 */
|
|
5512
|
+
interface ImMediaDownloadOptions {
|
|
5513
|
+
/**
|
|
5514
|
+
* 只取消本次调用;其它调用者仍需要结果时保留共享下载。
|
|
5515
|
+
* 最后一个可取消调用者退出且没有无 signal 调用者时,才中止底层任务。
|
|
5516
|
+
* 取消以 IM_SDK_MEDIA_DOWNLOAD_CANCELED 拒绝本次 Promise,不返回部分文件。
|
|
5517
|
+
*/
|
|
5518
|
+
signal?: AbortSignal;
|
|
5519
|
+
/** 默认 interactive;background 在空闲名额中排在交互下载之后,不能抢占已发请求。 */
|
|
5520
|
+
priority?: 'background' | 'interactive';
|
|
5521
|
+
}
|
|
5511
5522
|
/**
|
|
5512
5523
|
* 可观察媒体上传/下载任务的只读产品投影。
|
|
5513
5524
|
*
|
|
@@ -5606,7 +5617,8 @@ interface ImMediaTasksApi {
|
|
|
5606
5617
|
*/
|
|
5607
5618
|
subscribe: (listener: (tasks: readonly ImMediaTask[]) => void) => () => void;
|
|
5608
5619
|
/**
|
|
5609
|
-
* 取消 queued/running 任务;上传委托 core
|
|
5620
|
+
* 取消 queued/running 任务;上传委托 core,下载中止共享任务并取消所有调用者。
|
|
5621
|
+
* 只需结束某次下载等待时,应使用 download 的 signal。
|
|
5610
5622
|
* @throws 未知任务、非法状态或底层未受理时以稳定 `IM_SDK_MEDIA_TASK_*` 错误拒绝。
|
|
5611
5623
|
*/
|
|
5612
5624
|
cancel: (taskId: string, options?: {
|
|
@@ -5641,10 +5653,13 @@ interface ImMediaTasksApi {
|
|
|
5641
5653
|
restartDownload?: boolean;
|
|
5642
5654
|
}) => Promise<void>;
|
|
5643
5655
|
/**
|
|
5644
|
-
*
|
|
5656
|
+
* 下载并按消息正文合同解密,同一精确消息引用共用实际下载,成功返回 Blob。
|
|
5657
|
+
* 不带 signal 的并发调用保留共享 Promise;带 signal 的调用独立等待和取消,不影响其它调用者。
|
|
5658
|
+
* 后加入的交互调用会提高共享下载优先级;prioritizeDownload 指定的最近预览仍优先于其它任务。
|
|
5645
5659
|
* @throws 消息不存在/非媒体/无远端 URL/未装配 capability、传输失败、取消或 teardown 均以稳定错误拒绝,不返回空 Blob。
|
|
5660
|
+
* @example const blob = await client.media.download(messageRef, { signal: controller.signal, priority: 'background' })
|
|
5646
5661
|
*/
|
|
5647
|
-
download: (message: ImMessageRef) => Promise<Blob>;
|
|
5662
|
+
download: (message: ImMessageRef, options?: ImMediaDownloadOptions) => Promise<Blob>;
|
|
5648
5663
|
/**
|
|
5649
5664
|
* 将最近预览的精确媒体项设为最高下载优先级,不新建或取消任务。
|
|
5650
5665
|
* 下一空闲任务/分片请求名额优先给该项;已发请求不中断,关闭播放器不撤销优先级。
|
|
@@ -5660,7 +5675,7 @@ interface ImMediaTasksApi {
|
|
|
5660
5675
|
*/
|
|
5661
5676
|
getCached: (message: ImMessageRef) => Promise<Blob | null>;
|
|
5662
5677
|
/**
|
|
5663
|
-
* 为宿主手里的**本地**图片/视频文件预读展示元信息:尺寸、视频时长、视频首帧封面的
|
|
5678
|
+
* 为宿主手里的**本地**图片/视频文件预读展示元信息:尺寸、视频时长、视频首帧封面的 WebP 字节。
|
|
5664
5679
|
*
|
|
5665
5680
|
* 给「发送前预览」这类场景用:宿主要在用户还没点发送时就把缩略图画出来,而浏览器读不出视频的
|
|
5666
5681
|
* 首帧——`<video preload="metadata">` 在 iOS Safari 上只加载元信息、**不解码任何一帧**,
|
|
@@ -5668,7 +5683,7 @@ interface ImMediaTasksApi {
|
|
|
5668
5683
|
*
|
|
5669
5684
|
* 返回的对象可以**原样**作为 `localPreviewMetadata` 交给 `sendImage` / `sendVideo` /
|
|
5670
5685
|
* `sendMediaAlbum`:发送链路会复用可用元信息;合集项超出其可用消息空间时重新生成封面。
|
|
5671
|
-
* posterData 使用共享自适应发送规格(视频
|
|
5686
|
+
* posterData 使用共享自适应发送规格(视频 WebP,长边最多 1440px,目标 16 KiB、硬上限 32 KiB);includeDisplayPoster 可在同一次解码中额外生成
|
|
5672
5687
|
* 仅供页面显示的高清 displayPoster(长边最多 960),不得绕过发送校验直接用它替换 posterData。
|
|
5673
5688
|
*
|
|
5674
5689
|
* @param input.kind 按文件类型选解码路径;`'video'` 才会抽首帧与读时长。
|
|
@@ -8342,8 +8357,14 @@ declare function loadCachedVideoObjectUrl(runtime: ChatRuntime, message: ImMessa
|
|
|
8342
8357
|
* 返回 `null` 表示下标越界、正文不是合集、内容非法或下载失败,失败原因经 `setNote` 反馈。
|
|
8343
8358
|
* **唯一不反馈的失败是用户自己取消**(点击停止按钮取消这一项的在途下载):同样返回 `null`,但不提示。
|
|
8344
8359
|
* **调用方在不再使用地址时必须 `URL.revokeObjectURL`。**
|
|
8360
|
+
* @param runtime 当前账号的运行时,用于访问 SDK 并阻止切账号后交付旧资源。
|
|
8361
|
+
* @param message 包含媒体合集正文与精确会话身份的消息。
|
|
8362
|
+
* @param itemIndex 要下载的合集项下标,从 0 开始。
|
|
8363
|
+
* @param hooks 失败文案及提示入口;取消不提示失败。
|
|
8364
|
+
* @param onProgress 可选的当前项下载进度回调,范围为 0–100。
|
|
8365
|
+
* @param options 可选的下载优先级与本次调用取消信号;取消不影响同一资源的其它消费者,也不交付迟到的地址。
|
|
8345
8366
|
*/
|
|
8346
|
-
declare function loadMediaAlbumItemObjectUrl(runtime: ChatRuntime, message: ImMessageView, itemIndex: number, hooks: ServiceNoteHooks, onProgress?: (percent: number) => void): Promise<string | null>;
|
|
8367
|
+
declare function loadMediaAlbumItemObjectUrl(runtime: ChatRuntime, message: ImMessageView, itemIndex: number, hooks: ServiceNoteHooks, onProgress?: (percent: number) => void, options?: ImMediaDownloadOptions): Promise<string | null>;
|
|
8347
8368
|
/**
|
|
8348
8369
|
* 只读取合集某一项已持久化的明文资产并创建 object URL。
|
|
8349
8370
|
*
|
|
@@ -8357,8 +8378,12 @@ declare function loadCachedMediaAlbumItemObjectUrl(runtime: ChatRuntime, message
|
|
|
8357
8378
|
*
|
|
8358
8379
|
* 解密结果不是已支持图片、内容为空或下载失败时返回 `null` 并显示明确提示,不把无效二进制交给
|
|
8359
8380
|
* `<img>`。调用方关闭大图后必须撤销成功返回的地址。
|
|
8381
|
+
* @param runtime 当前账号的运行时,用于访问 SDK 并阻止切账号后交付旧资源。
|
|
8382
|
+
* @param message 包含原图正文与精确会话身份的消息。
|
|
8383
|
+
* @param hooks 失败文案及提示入口;取消不提示失败。
|
|
8384
|
+
* @param options 可选的下载优先级与本次调用取消信号;取消只结束本次等待并返回 null,不提示失败。
|
|
8360
8385
|
*/
|
|
8361
|
-
declare function loadImageObjectUrl(runtime: ChatRuntime, message: ImMessageView, hooks: ServiceNoteHooks): Promise<string | null>;
|
|
8386
|
+
declare function loadImageObjectUrl(runtime: ChatRuntime, message: ImMessageView, hooks: ServiceNoteHooks, options?: ImMediaDownloadOptions): Promise<string | null>;
|
|
8362
8387
|
/**
|
|
8363
8388
|
* 仅读取 SDK 已持久化的图片明文资产并创建 object URL。
|
|
8364
8389
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -3079,12 +3079,12 @@ declare function canReactToMessage(message: ReactionParentMessage): boolean;
|
|
|
3079
3079
|
type RecallFailReason = 'not-found' | 'not-own' | 'pinned' | 'not-sent' | 'expired' | 'unsupported' | 'timeout' | 'server-expired' | 'failed' | 'disconnected';
|
|
3080
3080
|
|
|
3081
3081
|
/**
|
|
3082
|
-
* 根据缩略图签名选择 PNG 或 JPEG 的显示类型,供 SDK 和 PC/H5 创建 Blob、data URL。
|
|
3083
|
-
* 输入是消息中的原始字节或纯 base64;旧消息没有独立 MIME
|
|
3082
|
+
* 根据缩略图签名选择 PNG、WebP 或 JPEG 的显示类型,供 SDK 和 PC/H5 创建 Blob、data URL。
|
|
3083
|
+
* 输入是消息中的原始字节或纯 base64;旧消息没有独立 MIME 字段,未知格式沿用 JPEG 解码,
|
|
3084
3084
|
* 损坏数据仍交给图片解码器报告失败。本函数不修改字节,也不将历史 JPEG 转码为 PNG。
|
|
3085
3085
|
* @example resolveMediaThumbnailMimeType(new Uint8Array([137, 80, 78, 71, 13, 10, 26, 10])) // 'image/png'
|
|
3086
3086
|
*/
|
|
3087
|
-
declare function resolveMediaThumbnailMimeType(source: Uint8Array | string): 'image/png' | 'image/jpeg';
|
|
3087
|
+
declare function resolveMediaThumbnailMimeType(source: Uint8Array | string): 'image/png' | 'image/webp' | 'image/jpeg';
|
|
3088
3088
|
|
|
3089
3089
|
/** 浏览器 PushSubscription.toJSON() 的可移植数据;不依赖 DOM 或浏览器全局。 */
|
|
3090
3090
|
interface ImWebPushSubscription {
|
|
@@ -4000,13 +4000,13 @@ interface MediaAlbumMessageOptions {
|
|
|
4000
4000
|
* 本地视频的固有尺寸、时长与首帧封面。
|
|
4001
4001
|
*
|
|
4002
4002
|
* @remarks 宿主可从本地 object URL 解码首个可展示帧,使上传占位从首次渲染就使用真实比例和主图。
|
|
4003
|
-
* `posterData`
|
|
4003
|
+
* `posterData` 是等比缩放后的静态 WebP(兼容已有 JPEG/PNG);存在时会作为消息 `thumbData` 随正文发送。宽高必须是有限正数,
|
|
4004
4004
|
* duration 存在时必须是有限正数,posterData 必须是非空且不超过共享单项消息容量的 Uint8Array;合集发送会按项数复核容量。
|
|
4005
4005
|
*/
|
|
4006
4006
|
interface VideoPreviewMetadata extends ImagePreviewMetadata {
|
|
4007
4007
|
/** 秒。 */
|
|
4008
4008
|
duration?: number;
|
|
4009
|
-
/** 本地首个可展示帧生成的
|
|
4009
|
+
/** 本地首个可展示帧生成的 WebP 或已有 JPEG/PNG 字节。 */
|
|
4010
4010
|
posterData?: Uint8Array;
|
|
4011
4011
|
}
|
|
4012
4012
|
/**
|
|
@@ -6080,6 +6080,17 @@ interface ImMessageRef {
|
|
|
6080
6080
|
*/
|
|
6081
6081
|
itemIndex?: number;
|
|
6082
6082
|
}
|
|
6083
|
+
/** 单次媒体下载的等待与调度选项;相同精确消息引用仍共用一次实际下载。 */
|
|
6084
|
+
interface ImMediaDownloadOptions {
|
|
6085
|
+
/**
|
|
6086
|
+
* 只取消本次调用;其它调用者仍需要结果时保留共享下载。
|
|
6087
|
+
* 最后一个可取消调用者退出且没有无 signal 调用者时,才中止底层任务。
|
|
6088
|
+
* 取消以 IM_SDK_MEDIA_DOWNLOAD_CANCELED 拒绝本次 Promise,不返回部分文件。
|
|
6089
|
+
*/
|
|
6090
|
+
signal?: AbortSignal;
|
|
6091
|
+
/** 默认 interactive;background 在空闲名额中排在交互下载之后,不能抢占已发请求。 */
|
|
6092
|
+
priority?: 'background' | 'interactive';
|
|
6093
|
+
}
|
|
6083
6094
|
/**
|
|
6084
6095
|
* 可观察媒体上传/下载任务的只读产品投影。
|
|
6085
6096
|
*
|
|
@@ -6178,7 +6189,8 @@ interface ImMediaTasksApi {
|
|
|
6178
6189
|
*/
|
|
6179
6190
|
subscribe: (listener: (tasks: readonly ImMediaTask[]) => void) => () => void;
|
|
6180
6191
|
/**
|
|
6181
|
-
* 取消 queued/running 任务;上传委托 core
|
|
6192
|
+
* 取消 queued/running 任务;上传委托 core,下载中止共享任务并取消所有调用者。
|
|
6193
|
+
* 只需结束某次下载等待时,应使用 download 的 signal。
|
|
6182
6194
|
* @throws 未知任务、非法状态或底层未受理时以稳定 `IM_SDK_MEDIA_TASK_*` 错误拒绝。
|
|
6183
6195
|
*/
|
|
6184
6196
|
cancel: (taskId: string, options?: {
|
|
@@ -6213,10 +6225,13 @@ interface ImMediaTasksApi {
|
|
|
6213
6225
|
restartDownload?: boolean;
|
|
6214
6226
|
}) => Promise<void>;
|
|
6215
6227
|
/**
|
|
6216
|
-
*
|
|
6228
|
+
* 下载并按消息正文合同解密,同一精确消息引用共用实际下载,成功返回 Blob。
|
|
6229
|
+
* 不带 signal 的并发调用保留共享 Promise;带 signal 的调用独立等待和取消,不影响其它调用者。
|
|
6230
|
+
* 后加入的交互调用会提高共享下载优先级;prioritizeDownload 指定的最近预览仍优先于其它任务。
|
|
6217
6231
|
* @throws 消息不存在/非媒体/无远端 URL/未装配 capability、传输失败、取消或 teardown 均以稳定错误拒绝,不返回空 Blob。
|
|
6232
|
+
* @example const blob = await client.media.download(messageRef, { signal: controller.signal, priority: 'background' })
|
|
6218
6233
|
*/
|
|
6219
|
-
download: (message: ImMessageRef) => Promise<Blob>;
|
|
6234
|
+
download: (message: ImMessageRef, options?: ImMediaDownloadOptions) => Promise<Blob>;
|
|
6220
6235
|
/**
|
|
6221
6236
|
* 将最近预览的精确媒体项设为最高下载优先级,不新建或取消任务。
|
|
6222
6237
|
* 下一空闲任务/分片请求名额优先给该项;已发请求不中断,关闭播放器不撤销优先级。
|
|
@@ -6232,7 +6247,7 @@ interface ImMediaTasksApi {
|
|
|
6232
6247
|
*/
|
|
6233
6248
|
getCached: (message: ImMessageRef) => Promise<Blob | null>;
|
|
6234
6249
|
/**
|
|
6235
|
-
* 为宿主手里的**本地**图片/视频文件预读展示元信息:尺寸、视频时长、视频首帧封面的
|
|
6250
|
+
* 为宿主手里的**本地**图片/视频文件预读展示元信息:尺寸、视频时长、视频首帧封面的 WebP 字节。
|
|
6236
6251
|
*
|
|
6237
6252
|
* 给「发送前预览」这类场景用:宿主要在用户还没点发送时就把缩略图画出来,而浏览器读不出视频的
|
|
6238
6253
|
* 首帧——`<video preload="metadata">` 在 iOS Safari 上只加载元信息、**不解码任何一帧**,
|
|
@@ -6240,7 +6255,7 @@ interface ImMediaTasksApi {
|
|
|
6240
6255
|
*
|
|
6241
6256
|
* 返回的对象可以**原样**作为 `localPreviewMetadata` 交给 `sendImage` / `sendVideo` /
|
|
6242
6257
|
* `sendMediaAlbum`:发送链路会复用可用元信息;合集项超出其可用消息空间时重新生成封面。
|
|
6243
|
-
* posterData 使用共享自适应发送规格(视频
|
|
6258
|
+
* posterData 使用共享自适应发送规格(视频 WebP,长边最多 1440px,目标 16 KiB、硬上限 32 KiB);includeDisplayPoster 可在同一次解码中额外生成
|
|
6244
6259
|
* 仅供页面显示的高清 displayPoster(长边最多 960),不得绕过发送校验直接用它替换 posterData。
|
|
6245
6260
|
*
|
|
6246
6261
|
* @param input.kind 按文件类型选解码路径;`'video'` 才会抽首帧与读时长。
|
|
@@ -9613,8 +9628,14 @@ declare function loadCachedVideoObjectUrl(runtime: ChatRuntime, message: ImMessa
|
|
|
9613
9628
|
* 返回 `null` 表示下标越界、正文不是合集、内容非法或下载失败,失败原因经 `setNote` 反馈。
|
|
9614
9629
|
* **唯一不反馈的失败是用户自己取消**(点击停止按钮取消这一项的在途下载):同样返回 `null`,但不提示。
|
|
9615
9630
|
* **调用方在不再使用地址时必须 `URL.revokeObjectURL`。**
|
|
9631
|
+
* @param runtime 当前账号的运行时,用于访问 SDK 并阻止切账号后交付旧资源。
|
|
9632
|
+
* @param message 包含媒体合集正文与精确会话身份的消息。
|
|
9633
|
+
* @param itemIndex 要下载的合集项下标,从 0 开始。
|
|
9634
|
+
* @param hooks 失败文案及提示入口;取消不提示失败。
|
|
9635
|
+
* @param onProgress 可选的当前项下载进度回调,范围为 0–100。
|
|
9636
|
+
* @param options 可选的下载优先级与本次调用取消信号;取消不影响同一资源的其它消费者,也不交付迟到的地址。
|
|
9616
9637
|
*/
|
|
9617
|
-
declare function loadMediaAlbumItemObjectUrl(runtime: ChatRuntime, message: ImMessageView, itemIndex: number, hooks: ServiceNoteHooks, onProgress?: (percent: number) => void): Promise<string | null>;
|
|
9638
|
+
declare function loadMediaAlbumItemObjectUrl(runtime: ChatRuntime, message: ImMessageView, itemIndex: number, hooks: ServiceNoteHooks, onProgress?: (percent: number) => void, options?: ImMediaDownloadOptions): Promise<string | null>;
|
|
9618
9639
|
/**
|
|
9619
9640
|
* 只读取合集某一项已持久化的明文资产并创建 object URL。
|
|
9620
9641
|
*
|
|
@@ -9628,8 +9649,12 @@ declare function loadCachedMediaAlbumItemObjectUrl(runtime: ChatRuntime, message
|
|
|
9628
9649
|
*
|
|
9629
9650
|
* 解密结果不是已支持图片、内容为空或下载失败时返回 `null` 并显示明确提示,不把无效二进制交给
|
|
9630
9651
|
* `<img>`。调用方关闭大图后必须撤销成功返回的地址。
|
|
9652
|
+
* @param runtime 当前账号的运行时,用于访问 SDK 并阻止切账号后交付旧资源。
|
|
9653
|
+
* @param message 包含原图正文与精确会话身份的消息。
|
|
9654
|
+
* @param hooks 失败文案及提示入口;取消不提示失败。
|
|
9655
|
+
* @param options 可选的下载优先级与本次调用取消信号;取消只结束本次等待并返回 null,不提示失败。
|
|
9631
9656
|
*/
|
|
9632
|
-
declare function loadImageObjectUrl(runtime: ChatRuntime, message: ImMessageView, hooks: ServiceNoteHooks): Promise<string | null>;
|
|
9657
|
+
declare function loadImageObjectUrl(runtime: ChatRuntime, message: ImMessageView, hooks: ServiceNoteHooks, options?: ImMediaDownloadOptions): Promise<string | null>;
|
|
9633
9658
|
/**
|
|
9634
9659
|
* 仅读取 SDK 已持久化的图片明文资产并创建 object URL。
|
|
9635
9660
|
*
|
|
@@ -10996,4 +11021,4 @@ declare function resampleWaveform(data: readonly number[], targetCount: number):
|
|
|
10996
11021
|
declare function placeholderWaveform(seed: string, count: number): number[];
|
|
10997
11022
|
|
|
10998
11023
|
export { DEFAULT_EMOJI_ASSET_BASE, DEFAULT_LOADING_MINIMUM_VISIBLE_MS, DEFAULT_LOADING_SHOW_DELAY_MS, DEFAULT_LOCALE, EDIT_WINDOW_MS, EMOJI_CATALOG, EMOJI_GAME_DICE_STABLE_KEY, EMOJI_GAME_RPS_STABLE_KEY, EMOJI_TOKEN_RE, IMAGE_MESSAGE_ACCEPT, IM_CHAT_FONT_SCALES, IM_DIAGNOSTIC_CATEGORIES, IM_EMOJI_CATALOG, ImPinnedMessageOperationError, MAX_BATCH_FILES, MAX_RECENT_EMOJI_COUNT, MEDIA_ALBUM_CAPTION_MAX_LENGTH, MEDIA_ALBUM_MAX_ITEMS, MINI_PROGRAM_GAME_PREVIEW_FALLBACK_HEIGHT, MINI_PROGRAM_GAME_PREVIEW_FALLBACK_WIDTH, MINI_PROGRAM_LANG_NUMBERS, MediaTransferError, REACTION_SUPPORTED_CONTENT_TYPES, SPIKE_STEP, UNICODE_EMOJI_CATALOG, blockReasonForChannelSession, blockReasonForChannelState, blockReasonForGroupState, blockReasonForSession, buildSessionFavoritePlainBody, calculateMediaBox, canCopyMessageImage, canEditMessage, canPinChannelMessage, canPinGroupMessage, canPinMessage, canPromoteMediaPresentationSource, canReactToMessage, canRecallMessage, canTransmit, canTransmitByType, canTransmitContent, cancelMediaUpload, captureRuntimeClientOperation, captureRuntimeOperation, channelMiniProgramRelKey, classifyGifFile, classifyMediaFile, classifyStickerImageType, countUnreadConversations, createChatRuntime, createConversationPrefetchController, createDelayedLoadingIndicator, createEmojiMatcher, createFaceToFaceGroupQrPayload, createImClient, createImConsoleDiagnosticSink, createImDiagnosticMemoryBuffer, createImI18n, createImResourceUploader, createImTextSearchMatcher, createLinkMatcher, createMessageImageCopySource, createNewMessageBadgeController, createSdkDiagnosticWriter, createThreadItems, createVoicePlayer, createVoiceRecordingSession, csvIncludes, decideChannelMiniProgramRelOpen, decideConversationAction, decideMemberTargetAction, decideMessageAction, detectVoiceCapabilities, emojiAssetUrl, emojiUrlByCode, extractSearchText, fetchConversationFileBatch, fetchConversationImageBatch, fetchConversationMessageBatch, fetchConversationVideoBatch, fetchConversationVoiceBatch, fetchNextConversationSearchBatch, formatChatDateSeparator, formatConversationDisplayTime, formatConversationUnreadBadge, formatFailure, formatFileSize, formatLastMessageSummary, formatMediaDuration, formatMediaPlaceholder, formatMentionAll, formatServiceText, formatSystemMessage, forward_service as forwardService, getFileExtension, getImTextSearchInitial, getImTimeCatalog, getLocalDayKey, getMessageCopyImageUrl, getMessageCopyText, hasEmojiCandidate, hasLinkCandidate, highlightSegments, isGifFile, isMessageLocateScrollProtected, isMessageTailChangeFromOlderWindowTrim, isMessageViewportMeasurable, isMessageVisibleForNewMessageBadge, isMiniProgramShowTypeOpenable, isPinnedMessageProtected, isSupportedImageFile, isVoiceStorageConfigured, loadOlderUntilBoundary, mediaBatchBudgetBytes, media_service as mediaService, mediaTransferErrorCodeOf, message_service as messageService, migrateImCachePrefix, normalizeImLocale, normalizeLinkHref, normalizeMediaUploadCredentials, parseSessionFavoriteAlbumItems, parseSessionFavoriteFileItems, parseUnicodeEmojiCode, pinnedMessage_service as pinnedMessageService, placeholderWaveform, prependRecentEmoji, profile_service as profileService, read_service as readService, refreshPrependMessageAnchorPosition, registerImCatalogOverrides, replaceInterruptedMediaFile, requiresConversationEncryption, requiresForwardTypeConfirmation, resampleWaveform, resetImCatalogOverrides, resolveBestMediaPresentationSource, resolveCenteredMessageScrollTop, resolveChannelAccess, resolveChannelMemberAvatarUrl, resolveChannelMemberDisplayName, resolveChannelMiniProgramRelIcon, resolveChannelMiniProgramRelName, resolveChannelMiniProgramRelOpenSurface, resolveChannelMiniProgramRelUrl, resolveChannelPinnedGameCopy, resolveConversationListPresentation, resolveDisplayTimestamp, resolveEmojiToken, resolveFriendDisplayName, resolveImEmojiToken, resolveImProfileAccessDestination, resolveImThreadActiveDate, resolveMediaAlbumSendContentType, resolveMediaPresentation, resolveMediaThumbnailMimeType, resolveMediaTransferPresentation, resolveMemberDisplayName, resolveMessageBodyKind, resolveMessageNotificationDecision, resolveMessageSearchPreview, resolveMessageTimelineTimestamp, resolveMiniProgramFloatLinkUrl, resolveMiniProgramGamePreviewLayout, resolveMiniProgramOpenUrl, resolvePrependMessageAnchor, resolvePrependMessageAnchorAdjustment, resolvePrependMessageAnchorPosition, resolvePublicNickname, resolveQuotedMessagePresentation, resolveSenderAvatarUrl, resolveSessionFavoriteAlbumCaption, resolveSessionFavoriteAlbumItemPreviewUrl, resolveSessionFavoriteKindFromMessage, resolveStandaloneEmojiMessage, resolveSurvivingMessageAnchorAdjustment, resolveTextSegments, resolveUnicodeEmoji, resolveVisibleChannelMiniProgramRels, resolveVisibleMessageAnchorPositions, retryMessage, runMediaSendBatch, sendAsFilesBatch, sendBlockReasonForDecision, sendMediaAlbum, sendMediaFile, sendMediaFilesBatch, sendText, sendVoice, shouldCompleteInitialViewport, shouldFillInitialHistoryViewport, shouldFollowIncomingMessage, shouldLoadNewerHistoryPage, shouldPrefetchOlderHistory, shouldRestoreMessageViewportFocus, shouldShowChatDateSeparator, shouldTrackRemoteMessageForBadge, sortChannelMiniProgramFloatingItems, sortSessions, spikeCountForDuration, sumSessionsUnread, supportsConversationMention, unicodeEmojiTextFromCode, voiceErrorCodeOf };
|
|
10999
|
-
export type { ApplySessionResult, BrowseMessagesInput, CanPinMessageInput, CapabilityAvailability, CapabilityDecision, CapabilityReason, CenteredMessageScrollInput, ChannelAccessSnapshot, ChannelBaseSessionState, ChannelConversationCapabilities, ChannelConversationMessageApi, ChannelJoinApplication, ChannelJoinApplicationNotification, ChannelJoinApplicationPage, ChannelMember, ChannelMemberPage, ChannelMentionMember, ChannelMentionMemberPage, ChannelMiniProgramOpenGame, ChannelMiniProgramRel, ChannelMiniProgramRelConfigType, ChannelMiniProgramRelOpenDecision, ChannelMiniProgramRelOpenSurface, ChannelMuteReason, ChannelPermissionSet, ChannelProfile, ChannelRole, ChannelSessionState, ChatMediaMessageRef, ChatProfileAdapter, ChatRuntime, ChatRuntimeCredentials, ChatRuntimeFactories, ChatRuntimeHostDeps, ChatRuntimeOpResult, ContactCardInput, ContactMessageOptions, ConversationBackgroundPreset, ConversationBackgroundSelection, ConversationCapabilityAction, ConversationCapabilitySnapshot, ConversationDraft, ConversationDraftApi, ConversationEntryUnreadNavigation, ConversationEntryUnreadSnapshot, ConversationHandle, ConversationHandleSnapshot, ConversationInitialPosition, ConversationLastMessageSummary, ConversationListItem, ConversationListMention, ConversationListPresentation, ConversationListPresentationLabels, ConversationListPresentationOptions, ConversationListPreviewMediaKind, ConversationListPreviewSegment, ConversationMessageApi, ConversationOpenOptions, ConversationPrefetchController, ConversationPrefetchControllerOptions, ConversationPrefetchOptions, ConversationPrefetchResult, ConversationRef, ConversationSearchCategory, ConversationSearchPage, ConversationSearchResult, ConversationSystemSummary, ConversationType, CreateThreadItemsInput, CustomerServiceConversationCapabilities, DelayedLoadingIndicator, DelayedLoadingIndicatorOptions, DirectConversationCapabilities, DirectConversationMessageApi, DraftInput, EditTextOptions, EmojiEntry, EmojiRecentItem, EmojiSegment, ExpressionMessageOptions, FileMessageOptions, FormatFailureContext, FormatLastMessageContext, FormatMediaPlaceholderContext, FormatServiceTextContext, FormatSystemMessageContext, FormatTimeDisplayContext, ForwardCommandHooks, ForwardFailReason, ForwardItemStatus, ForwardMessageFailure, ForwardMessagesInput, ForwardMessagesResult, ForwardTarget, ForwardedMessageRef, GameMessageOptions, GifFileClassification, GifMessageOptions, GiftMessageOptions, GroupConversationCapabilities, GroupConversationMessageApi, GroupMemberItem, GroupProfile, HighlightSegment, ImAppearanceSettingsApi, ImApplicationItem, ImApplicationRef, ImApplicationsApi, ImAuthIssue, ImAuthProvider, ImBlockedContact, ImCacheOptions, ImCachePrefixMigrationContext, ImCachePrefixMigrator, ImCallKind, ImCallOutcome, ImCallRecordBody, ImCatalog, ImCatalogOverrides, ImChannelConversationAccessSnapshot, ImChannelMemberPresentation, ImChannelMentionApi, ImChannelMentionPresentation, ImChannelMiniProgramRel, ImChannelPermissions, ImChannelPinnedMessage, ImChannelProfile, ImChannelProfilePresentation, ImChannelRole, ImChannelState, ImChannelsApi, ImChatFontScale, ImClientActivityApi, ImClientActivitySnapshot, ImClientOptions, ImConnectionState, ImContactBody, ImContactKind, ImContactProfile, ImContactRelationship, ImContactRemarkPhone, ImContactSearchResult, ImContactsApi, ImConversationBackgroundApi, ImConversationCapabilitiesApi, ImConversationListApi, ImConversationListSnapshot, ImConversationListState, ImConversationSearchApi, ImCoreApiOptions, ImCreateChannelInput, ImCreateChannelResult, ImCreateFaceToFaceGroupResult, ImCreateGroupInput, ImCreateGroupResult, ImCreatedChannel, ImCreatedGroup, ImCustomerServiceApi, ImDebugOptions, ImDiagnosticCategory, ImDiagnosticError, ImDiagnosticLayer, ImDiagnosticLevel, ImDiagnosticMemoryBuffer, ImDiagnosticMemoryBufferFilter, ImDiagnosticMemoryBufferOptions, ImDiagnosticMemoryBufferSnapshot, ImDiagnosticMessage, ImDiagnosticRecord, ImDiagnosticSink, ImDiagnosticWriter, ImDirectCallAnswerResult, ImDirectCallFailReason, ImDirectCallHangupInput, ImDirectCallHangupReason, ImDirectCallInviteInput, ImDirectCallNotifyAudioInput, ImDirectCallTargetInput, ImDirectCallsApi, ImDirectReadReceiptSettings, ImDirectoryApi, ImDirectoryFieldMatch, ImDirectoryItem, ImDirectoryKind, ImDirectoryPage, ImDirectorySearchApi, ImDirectorySearchItem, ImDirectorySearchResult, ImDraftsApi, ImEmojiCatalogEntry, ImEndpointProvider, ImEventsApi, ImExpressionAsset, ImExpressionAssetInput, ImExpressionEmojiRecentInput, ImExpressionFavoriteKind, ImExpressionOptions, ImExpressionRecentInput, ImExpressionRecentItem, ImExpressionRecentItemKind, ImExpressionsApi, ImFaceToFaceGroup, ImFailureCatalog, ImFileBody, ImFilesAlbumBody, ImForwardOperationResult, ImFriendshipRequestResult, ImGameBody, ImGameType, ImGifAssetInput, ImGiftBody, ImGiftSessionType, ImGiftStatus, ImGiftType, ImGiphyAsset, ImGiphyPage, ImGiphyPageOptions, ImGroupCallAnswerInput, ImGroupCallBusyInput, ImGroupCallCreateInput, ImGroupCallJoinInput, ImGroupCallMeetingSnapshot, ImGroupCallMember, ImGroupCallMemberStatus, ImGroupCallStatusInput, ImGroupCallTargetInput, ImGroupCallsApi, ImGroupConversationState, ImGroupMemberPresentation, ImGroupMentionApi, ImGroupPinnedMessage, ImGroupProfile, ImGroupsApi, ImI18n, ImImageBody, ImLastMessageCatalog, ImLifecycleSnapshot, ImLiveRoomBody, ImLiveRoomStatus, ImLiveRoomType, ImLocalDataApi, ImLocalDataInfo, ImLocale, ImLogoutOptions, ImMediaAlbumBody, ImMediaAlbumItem, ImMediaBatchSendResult, ImMediaCatalog, ImMediaConfig, ImMediaTask, ImMediaTasksApi, ImMembershipJoinResult, ImMentionCatalog, ImMessageActionResult, ImMessageBodyKind, ImMessageMention, ImMessageReactionAggregate, ImMessageReactions, ImMessageRef, ImMessageSearchApi, ImMessageView, ImMessageViewBody, ImMessagesByIdResult, ImMiniProgramBody, ImMiniProgramShowType, ImOutboxApi, ImOutboxItem, ImPageToken, ImPartialCatalog, ImPinnedMessageActionResult, ImPinnedMessageErrorKind, ImPinnedMessageOperation, ImPinnedMessageSnapshot, ImProductApplicationUpdate, ImProductAuthInvalidReason, ImProductClient, ImProductEvent, ImProductEventError, ImProductEventMap, ImProductMessage, ImProfileAccessDestination, ImPushApi, ImPushSnapshot, ImQuotedMessagePresentation, ImReactionChangeAction, ImReactionChangeResult, ImReadReceiptSettingsApi, ImRedPacketBody, ImRedPacketType, ImRequestError, ImRequestErrorHandler, ImResourceKind, ImResourceUploadInput, ImResourceUploadProgress, ImResourceUploadResult, ImResourceUploader, ImResourceUploaderConfig, ImRobotBody, ImRobotChatMenuItem, ImRobotCommand, ImRobotConversationBindInput, ImRobotDirectoryItem, ImRobotDirectoryPage, ImRobotDirectoryScope, ImRobotMenuReplyInput, ImRobotModule, ImRobotProfile, ImRobotProfileInput, ImRobotsApi, ImSdkErrorCategory, ImSdkErrorShape, ImSearchApi, ImServiceCatalog, ImServiceTextKey, ImSessionApi, ImSessionFavoriteAlbumItem, ImSessionFavoriteFileItem, ImSessionFavoriteItem, ImSessionFavoriteKind, ImSessionFavoritesApi, ImSessionLifecycleState, ImSettingsApi, ImStickerAssetInput, ImStickerBody, ImStickerPack, ImSupportedConversationRef, ImSystemCatalog, ImTextResolver, ImTextSearchMatch, ImTextSearchMatchOptions, ImTextSearchMatcher, ImTextSearchRange, ImThreadActiveDateSnapshot, ImThreadDateMarkerMetric, ImThreadDecoration, ImThreadEncryptionItem, ImThreadIntent, ImThreadItem, ImThreadPresentationAdapter, ImThreadReadActions, ImThreadReadTargetResolver, ImThreadViewportMetrics, ImTimeCatalog, ImTransferBody, ImTransferSessionType, ImTransferStatus, ImVideoBody, ImVoiceBody, ImWebPushSubscription, ImWeekdayKey, ImageMessageOptions, ImagePreviewMetadata, IncomingMessageFollowInput, InitialHistoryViewportFillInput, InitialViewportCompletionInput, LinkSegment, LiveRoomMessageOptions, LocalConversationHistoryClearResult, LocalMessageDeletionResult, LocalVideoPreviewMetadata, MediaAlbumItemInput, MediaAlbumMessageOptions, MediaBatchBudgetOptions, MediaBatchLimitInfo, MediaFileClassification, MediaLimitItem, MediaObjectUrlLease, MediaPresentationFit, MediaPresentationPolicy, MediaPresentationRule, MediaPresentationSourceCandidate, MediaPresentationSourceQuality, MediaSendBatchResult, MediaTransferErrorCode, MediaTransferPresentation, MediaUploadCredentials, MediaUploadCredentialsProvider, MediaUploadCredentialsRequest, MemberTargetCapabilityAction, MemberTargetCapabilityInput, MentionCandidate, MentionCandidatePage, MentionInput, MessageCapabilityAction, MessageCapabilityInput, MessageContentType, MessageLocateScrollProtectionInput, MessageNotificationDecision, MessageNotificationInput, MessageSearchPreviewOptions, MessageSearchPreviewSegment, MessageWindowInfo, MessageWindowPage, MessagesByIdFailure, MigrateImCachePrefixInput, MiniProgramGamePreviewInput, MiniProgramGamePreviewLayout, MiniProgramHostLocale, MiniProgramMessageOptions, MiniProgramOpenUrlInput, NewMessageBadgeController, NewMessageBadgeCountListener, NewMessageBadgeVisibilityInput, NewerHistoryPageTriggerInput, OlderHistoryPrefetchInput, PrependAnchorCandidate, PrependAnchorViewport, PrependMessageAnchorPosition, ProductConversationListType, ProductHandleConversationType, ProductMessageSearchPage, ProductMessageSearchPreviewPart, ProductMessageSearchResult, RemoteMessageBadgeTrackingInput, ResolveMediaPresentationInput, ResolveTextOptions, ResolvedConversationBackground, ResolvedMediaPresentation, RichExtraSegment, RobotConversationCapabilities, RuntimeClientOperation, RuntimeOperation, SearchBatchResult, SearchFilesInput, SearchMessagesInput, SearchTextMessagesInput, SegmentMatch, SegmentMatcher, SendCapabilityMode, SendCommandHooks, SendMessageResult, SendVoicePayload, SenderProfileEntry, ServiceNoteHooks, StandaloneEmojiMessage, StickerAssetKind, TextMessageOptions, TextSegment, TransferMessageOptions, UnicodeEmojiEntry, UnknownMessageBody, UserProfile, VideoMessageOptions, VideoPreviewMetadata, VisibleChannelMiniProgramRels, VoiceCapabilities, VoiceErrorCode, VoiceMessageMetadata, VoicePlayer, VoicePlayerOptions, VoicePlayerState, VoiceRecordingResult, VoiceRecordingSession, VoiceRecordingSessionOptions, VoiceRecordingState, VoiceToggleOptions };
|
|
11024
|
+
export type { ApplySessionResult, BrowseMessagesInput, CanPinMessageInput, CapabilityAvailability, CapabilityDecision, CapabilityReason, CenteredMessageScrollInput, ChannelAccessSnapshot, ChannelBaseSessionState, ChannelConversationCapabilities, ChannelConversationMessageApi, ChannelJoinApplication, ChannelJoinApplicationNotification, ChannelJoinApplicationPage, ChannelMember, ChannelMemberPage, ChannelMentionMember, ChannelMentionMemberPage, ChannelMiniProgramOpenGame, ChannelMiniProgramRel, ChannelMiniProgramRelConfigType, ChannelMiniProgramRelOpenDecision, ChannelMiniProgramRelOpenSurface, ChannelMuteReason, ChannelPermissionSet, ChannelProfile, ChannelRole, ChannelSessionState, ChatMediaMessageRef, ChatProfileAdapter, ChatRuntime, ChatRuntimeCredentials, ChatRuntimeFactories, ChatRuntimeHostDeps, ChatRuntimeOpResult, ContactCardInput, ContactMessageOptions, ConversationBackgroundPreset, ConversationBackgroundSelection, ConversationCapabilityAction, ConversationCapabilitySnapshot, ConversationDraft, ConversationDraftApi, ConversationEntryUnreadNavigation, ConversationEntryUnreadSnapshot, ConversationHandle, ConversationHandleSnapshot, ConversationInitialPosition, ConversationLastMessageSummary, ConversationListItem, ConversationListMention, ConversationListPresentation, ConversationListPresentationLabels, ConversationListPresentationOptions, ConversationListPreviewMediaKind, ConversationListPreviewSegment, ConversationMessageApi, ConversationOpenOptions, ConversationPrefetchController, ConversationPrefetchControllerOptions, ConversationPrefetchOptions, ConversationPrefetchResult, ConversationRef, ConversationSearchCategory, ConversationSearchPage, ConversationSearchResult, ConversationSystemSummary, ConversationType, CreateThreadItemsInput, CustomerServiceConversationCapabilities, DelayedLoadingIndicator, DelayedLoadingIndicatorOptions, DirectConversationCapabilities, DirectConversationMessageApi, DraftInput, EditTextOptions, EmojiEntry, EmojiRecentItem, EmojiSegment, ExpressionMessageOptions, FileMessageOptions, FormatFailureContext, FormatLastMessageContext, FormatMediaPlaceholderContext, FormatServiceTextContext, FormatSystemMessageContext, FormatTimeDisplayContext, ForwardCommandHooks, ForwardFailReason, ForwardItemStatus, ForwardMessageFailure, ForwardMessagesInput, ForwardMessagesResult, ForwardTarget, ForwardedMessageRef, GameMessageOptions, GifFileClassification, GifMessageOptions, GiftMessageOptions, GroupConversationCapabilities, GroupConversationMessageApi, GroupMemberItem, GroupProfile, HighlightSegment, ImAppearanceSettingsApi, ImApplicationItem, ImApplicationRef, ImApplicationsApi, ImAuthIssue, ImAuthProvider, ImBlockedContact, ImCacheOptions, ImCachePrefixMigrationContext, ImCachePrefixMigrator, ImCallKind, ImCallOutcome, ImCallRecordBody, ImCatalog, ImCatalogOverrides, ImChannelConversationAccessSnapshot, ImChannelMemberPresentation, ImChannelMentionApi, ImChannelMentionPresentation, ImChannelMiniProgramRel, ImChannelPermissions, ImChannelPinnedMessage, ImChannelProfile, ImChannelProfilePresentation, ImChannelRole, ImChannelState, ImChannelsApi, ImChatFontScale, ImClientActivityApi, ImClientActivitySnapshot, ImClientOptions, ImConnectionState, ImContactBody, ImContactKind, ImContactProfile, ImContactRelationship, ImContactRemarkPhone, ImContactSearchResult, ImContactsApi, ImConversationBackgroundApi, ImConversationCapabilitiesApi, ImConversationListApi, ImConversationListSnapshot, ImConversationListState, ImConversationSearchApi, ImCoreApiOptions, ImCreateChannelInput, ImCreateChannelResult, ImCreateFaceToFaceGroupResult, ImCreateGroupInput, ImCreateGroupResult, ImCreatedChannel, ImCreatedGroup, ImCustomerServiceApi, ImDebugOptions, ImDiagnosticCategory, ImDiagnosticError, ImDiagnosticLayer, ImDiagnosticLevel, ImDiagnosticMemoryBuffer, ImDiagnosticMemoryBufferFilter, ImDiagnosticMemoryBufferOptions, ImDiagnosticMemoryBufferSnapshot, ImDiagnosticMessage, ImDiagnosticRecord, ImDiagnosticSink, ImDiagnosticWriter, ImDirectCallAnswerResult, ImDirectCallFailReason, ImDirectCallHangupInput, ImDirectCallHangupReason, ImDirectCallInviteInput, ImDirectCallNotifyAudioInput, ImDirectCallTargetInput, ImDirectCallsApi, ImDirectReadReceiptSettings, ImDirectoryApi, ImDirectoryFieldMatch, ImDirectoryItem, ImDirectoryKind, ImDirectoryPage, ImDirectorySearchApi, ImDirectorySearchItem, ImDirectorySearchResult, ImDraftsApi, ImEmojiCatalogEntry, ImEndpointProvider, ImEventsApi, ImExpressionAsset, ImExpressionAssetInput, ImExpressionEmojiRecentInput, ImExpressionFavoriteKind, ImExpressionOptions, ImExpressionRecentInput, ImExpressionRecentItem, ImExpressionRecentItemKind, ImExpressionsApi, ImFaceToFaceGroup, ImFailureCatalog, ImFileBody, ImFilesAlbumBody, ImForwardOperationResult, ImFriendshipRequestResult, ImGameBody, ImGameType, ImGifAssetInput, ImGiftBody, ImGiftSessionType, ImGiftStatus, ImGiftType, ImGiphyAsset, ImGiphyPage, ImGiphyPageOptions, ImGroupCallAnswerInput, ImGroupCallBusyInput, ImGroupCallCreateInput, ImGroupCallJoinInput, ImGroupCallMeetingSnapshot, ImGroupCallMember, ImGroupCallMemberStatus, ImGroupCallStatusInput, ImGroupCallTargetInput, ImGroupCallsApi, ImGroupConversationState, ImGroupMemberPresentation, ImGroupMentionApi, ImGroupPinnedMessage, ImGroupProfile, ImGroupsApi, ImI18n, ImImageBody, ImLastMessageCatalog, ImLifecycleSnapshot, ImLiveRoomBody, ImLiveRoomStatus, ImLiveRoomType, ImLocalDataApi, ImLocalDataInfo, ImLocale, ImLogoutOptions, ImMediaAlbumBody, ImMediaAlbumItem, ImMediaBatchSendResult, ImMediaCatalog, ImMediaConfig, ImMediaDownloadOptions, ImMediaTask, ImMediaTasksApi, ImMembershipJoinResult, ImMentionCatalog, ImMessageActionResult, ImMessageBodyKind, ImMessageMention, ImMessageReactionAggregate, ImMessageReactions, ImMessageRef, ImMessageSearchApi, ImMessageView, ImMessageViewBody, ImMessagesByIdResult, ImMiniProgramBody, ImMiniProgramShowType, ImOutboxApi, ImOutboxItem, ImPageToken, ImPartialCatalog, ImPinnedMessageActionResult, ImPinnedMessageErrorKind, ImPinnedMessageOperation, ImPinnedMessageSnapshot, ImProductApplicationUpdate, ImProductAuthInvalidReason, ImProductClient, ImProductEvent, ImProductEventError, ImProductEventMap, ImProductMessage, ImProfileAccessDestination, ImPushApi, ImPushSnapshot, ImQuotedMessagePresentation, ImReactionChangeAction, ImReactionChangeResult, ImReadReceiptSettingsApi, ImRedPacketBody, ImRedPacketType, ImRequestError, ImRequestErrorHandler, ImResourceKind, ImResourceUploadInput, ImResourceUploadProgress, ImResourceUploadResult, ImResourceUploader, ImResourceUploaderConfig, ImRobotBody, ImRobotChatMenuItem, ImRobotCommand, ImRobotConversationBindInput, ImRobotDirectoryItem, ImRobotDirectoryPage, ImRobotDirectoryScope, ImRobotMenuReplyInput, ImRobotModule, ImRobotProfile, ImRobotProfileInput, ImRobotsApi, ImSdkErrorCategory, ImSdkErrorShape, ImSearchApi, ImServiceCatalog, ImServiceTextKey, ImSessionApi, ImSessionFavoriteAlbumItem, ImSessionFavoriteFileItem, ImSessionFavoriteItem, ImSessionFavoriteKind, ImSessionFavoritesApi, ImSessionLifecycleState, ImSettingsApi, ImStickerAssetInput, ImStickerBody, ImStickerPack, ImSupportedConversationRef, ImSystemCatalog, ImTextResolver, ImTextSearchMatch, ImTextSearchMatchOptions, ImTextSearchMatcher, ImTextSearchRange, ImThreadActiveDateSnapshot, ImThreadDateMarkerMetric, ImThreadDecoration, ImThreadEncryptionItem, ImThreadIntent, ImThreadItem, ImThreadPresentationAdapter, ImThreadReadActions, ImThreadReadTargetResolver, ImThreadViewportMetrics, ImTimeCatalog, ImTransferBody, ImTransferSessionType, ImTransferStatus, ImVideoBody, ImVoiceBody, ImWebPushSubscription, ImWeekdayKey, ImageMessageOptions, ImagePreviewMetadata, IncomingMessageFollowInput, InitialHistoryViewportFillInput, InitialViewportCompletionInput, LinkSegment, LiveRoomMessageOptions, LocalConversationHistoryClearResult, LocalMessageDeletionResult, LocalVideoPreviewMetadata, MediaAlbumItemInput, MediaAlbumMessageOptions, MediaBatchBudgetOptions, MediaBatchLimitInfo, MediaFileClassification, MediaLimitItem, MediaObjectUrlLease, MediaPresentationFit, MediaPresentationPolicy, MediaPresentationRule, MediaPresentationSourceCandidate, MediaPresentationSourceQuality, MediaSendBatchResult, MediaTransferErrorCode, MediaTransferPresentation, MediaUploadCredentials, MediaUploadCredentialsProvider, MediaUploadCredentialsRequest, MemberTargetCapabilityAction, MemberTargetCapabilityInput, MentionCandidate, MentionCandidatePage, MentionInput, MessageCapabilityAction, MessageCapabilityInput, MessageContentType, MessageLocateScrollProtectionInput, MessageNotificationDecision, MessageNotificationInput, MessageSearchPreviewOptions, MessageSearchPreviewSegment, MessageWindowInfo, MessageWindowPage, MessagesByIdFailure, MigrateImCachePrefixInput, MiniProgramGamePreviewInput, MiniProgramGamePreviewLayout, MiniProgramHostLocale, MiniProgramMessageOptions, MiniProgramOpenUrlInput, NewMessageBadgeController, NewMessageBadgeCountListener, NewMessageBadgeVisibilityInput, NewerHistoryPageTriggerInput, OlderHistoryPrefetchInput, PrependAnchorCandidate, PrependAnchorViewport, PrependMessageAnchorPosition, ProductConversationListType, ProductHandleConversationType, ProductMessageSearchPage, ProductMessageSearchPreviewPart, ProductMessageSearchResult, RemoteMessageBadgeTrackingInput, ResolveMediaPresentationInput, ResolveTextOptions, ResolvedConversationBackground, ResolvedMediaPresentation, RichExtraSegment, RobotConversationCapabilities, RuntimeClientOperation, RuntimeOperation, SearchBatchResult, SearchFilesInput, SearchMessagesInput, SearchTextMessagesInput, SegmentMatch, SegmentMatcher, SendCapabilityMode, SendCommandHooks, SendMessageResult, SendVoicePayload, SenderProfileEntry, ServiceNoteHooks, StandaloneEmojiMessage, StickerAssetKind, TextMessageOptions, TextSegment, TransferMessageOptions, UnicodeEmojiEntry, UnknownMessageBody, UserProfile, VideoMessageOptions, VideoPreviewMetadata, VisibleChannelMiniProgramRels, VoiceCapabilities, VoiceErrorCode, VoiceMessageMetadata, VoicePlayer, VoicePlayerOptions, VoicePlayerState, VoiceRecordingResult, VoiceRecordingSession, VoiceRecordingSessionOptions, VoiceRecordingState, VoiceToggleOptions };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{computeBiFeedbackHeaderSign as t}from"./bi-feedback.js";import{API_PROTOCOL_OS_TYPE as e,API_PROTOCOL_APP_ID as s,API_PROTOCOL_APP_TYPE as n,API_PROTOCOL_BI_FEEDBACK_APP_ID as o,API_PROTOCOL_CLIENT_TYPE as r}from"./constants.js";import{parseApiProtocolJson as a}from"./json.js";import{generateRequestNonce as
|
|
1
|
+
import{computeBiFeedbackHeaderSign as t}from"./bi-feedback.js";import{API_PROTOCOL_OS_TYPE as e,API_PROTOCOL_APP_ID as s,API_PROTOCOL_APP_TYPE as n,API_PROTOCOL_BI_FEEDBACK_APP_ID as o,API_PROTOCOL_CLIENT_TYPE as r}from"./constants.js";import{parseApiProtocolJson as a}from"./json.js";import{generateRequestId as i,generateRequestNonce as c}from"./nonce.js";import{resolveTargetConfig as p,normalizeProtocolParams as u,resolveProtocolLang as d,resolveBrowserInfo as m,formatTimestamp as l,normalizeHeaders as f,appendQueryParams as g,isFormDataBody as y,createRandomAlphaNumericString as w,joinUrlParts as b,collectResponseHeaders as h,readResponseHeader as v,transportDataToUint8Array as S,isJsonResponse as T,isTextResponse as M,transportDataToText as D}from"./utils.js";const C=/* @__PURE__ */new Set(["content-etag","token","req-id"]);function E(t){const e=t.rawBody,s=null!==e&&"object"==typeof e&&"code"in e?e.code:void 0;return{transportStatus:t.transportStatus,...void 0===t.httpStatus?{}:{httpStatus:t.httpStatus},..."number"==typeof s&&Number.isFinite(s)?{businessCode:s}:{}}}function j(t,e){return{code:502,msg:t instanceof Error?t.message:String(t),data:null,time:Math.floor(e/1e3)}}function B(t,e,s,n){if(T(s))return a(D(e.data));if(M(s))return D(e.data);const o=S(e.data),r=n?t.crypto.decryptAes(o):o,i=(new TextDecoder).decode(r);return a(i)}async function _(t,e,s){if(!t.onDebugRecord)return;const n={...e.meta,response:e.response,...s?{error:{name:s instanceof Error?s.name:void 0,message:s instanceof Error?s.message:String(s)}}:{}};try{await t.onDebugRecord(n)}catch{}}async function N(t,e,s,n,o,r,i){const c=h(e.headers),p=v(c,"content-type");if(e.status<200||e.status>=300){let a;if(n)a=void 0;else try{a=B(t,e,p,s)}catch{a=void 0}const u=function(t){if(!t||"object"!=typeof t)return!1;const e=t;return Number.isFinite(e.code)&&"data"in e}(a)?a:function(t,e){return{code:t.status,msg:t.statusText,data:null,time:Math.floor(e/1e3)}}(e,i);return{response:u,meta:{...o,transportStatus:"http_error",httpStatus:e.status,contentType:p,responseHeaders:c,...void 0!==a?{rawBody:a}:{},timings:{totalMs:i-r,upstreamMs:i-r}}}}const u=Date.now();if(n){const t=S(e.data),s=Date.now();return{response:{code:e.status,data:t,time:Math.floor(s/1e3)},meta:{...o,transportStatus:"success",httpStatus:e.status,contentType:p,responseHeaders:c,rawBody:t,timings:{totalMs:s-r,upstreamMs:i-r,parseMs:s-u}}}}try{if(T(p)){const s=B(t,e,p,!1),n=Date.now();return{response:s,meta:{...o,transportStatus:"success",httpStatus:e.status,contentType:p,responseHeaders:c,rawBody:s,timings:{totalMs:n-r,upstreamMs:i-r,parseMs:n-u}}}}if(M(p)){const t=D(e.data),s=Date.now();return{response:{code:e.status,msg:e.statusText,data:t,time:Math.floor(s/1e3)},meta:{...o,transportStatus:"success",httpStatus:e.status,contentType:p,responseHeaders:c,rawBody:t,timings:{totalMs:s-r,upstreamMs:i-r,parseMs:s-u}}}}const n=S(e.data),d=Date.now(),m=s?t.crypto.decryptAes(n):n,l=Date.now(),f=(new TextDecoder).decode(m),g=a(f),y=Date.now();return{response:g,meta:{...o,transportStatus:"success",httpStatus:e.status,contentType:p,responseHeaders:c,rawBody:g,timings:{totalMs:y-r,upstreamMs:i-r,parseMs:y-u,...s?{decryptMs:l-d}:{}}}}}catch(t){const s=Date.now();return{response:{code:(d=e.status,Number.isInteger(d)&&d>=400&&d<=599?d:502),msg:t instanceof Error?t.message:String(t),data:null,time:Math.floor(s/1e3)},meta:{...o,transportStatus:"invalid_response",httpStatus:e.status,contentType:p,responseHeaders:c,timings:{totalMs:s-r,upstreamMs:i-r,parseMs:s-u}}}}var d}function k(a){return async function(h,v={}){const S=a.now??(()=>/* @__PURE__ */new Date),T=a.randomNonce??c,M=a.randomRequestId??i,D=a.randomETag??(()=>w()),B=(v.method??"POST").toUpperCase(),k=v.target??"core",I=p(k,a.config.targets[k]),q=v.prefix??I.prefix??"",P=null!=v.body,R=u(v.data??{}),x="/v1/feedback"===h&&"/bi/h5"===q,H=!x&&(v.encrypt??!P),O=!x&&(v.sign??!P),U=S(),A=D(),V=M(),L=v.token??await(a.getToken?.())??"",J=d(v.locale??a.getLocale?.()),F=a.getBrowserInfo?.()??m(v.userAgent),X={app_id:s,os_type:e,app_version:a.config.appVersion,sign_method:"md5",timestamp:l(U),nonce:T()},G={...X,...R,nonce:X.nonce};let Y=X,z=R,K=G;!x&&O&&(G.sign=a.crypto.generateSign("api",a.config.envType,G,A),X.sign=G.sign);const Q={app_version:a.config.appVersion,"X-ENC-VERSION":a.config.appVersion,"X-APP-TYPE":n,"Client-type":r,"Content-ETag":A,"brand-id":a.config.brandId,"channel-id":v.channelId||a.config.channelId,device_brand:F.deviceBrand,device_info:F.deviceInfo,device_number:F.deviceNumber,device_token:F.deviceToken,lang:J,"mch-id":a.config.merchantId,"req-id":V,token:L},W=f(v.headers);let Z,$=h,tt={...Q,...Object.fromEntries(Object.entries(W).filter(([t])=>!C.has(t.toLowerCase())))};if(P)Z=v.body??void 0,Y=null,z=v.data??null,K=v.data??null;else if(x){const e=String(U.getTime()),s={"app-id":o,"app-version":a.config.appVersion,"sys-type":n,"sys-version":F.deviceNumber,time:e};Y=s,tt={...tt,...s,sign:t(a.crypto,s),"Content-Type":"application/json"},Z=JSON.stringify(R),K=R}else"GET"===B?($=g($,G),K=G):H?(Z=a.crypto.encryptAes((new TextEncoder).encode(JSON.stringify(G))),tt["Content-Type"]=tt["Content-Type"]||"application/octet-stream",K=G):(Z=JSON.stringify(G),tt["Content-Type"]=tt["Content-Type"]||"application/json",K=G);y(Z)&&delete tt["Content-Type"];const et=function(t,e,s,n,o){if(s.customUrl)return t;const r=p(n,e.config.targets[n]),a=s.baseUrl??r.baseUrl;return b(a,o,t)}($,a,v,k,q),st=Date.now(),nt=v.timeoutMs??6e4,ot=function(t,e){const s=new AbortController,n=setTimeout(()=>s.abort(),t),o=()=>s.abort();return e&&(e.aborted?s.abort():e.addEventListener("abort",o,{once:!0})),{signal:s.signal,dispose:()=>{clearTimeout(n),e?.removeEventListener("abort",o)}}}(nt,v.signal),rt={requestId:V,eTag:A,method:B,upstreamUrl:et,requestHeaders:tt,requestCommonParams:Y,requestBusinessParams:z,requestParams:K};let at;try{const t=await a.transport({url:et,method:B,headers:tt,body:Z,signal:ot.signal,timeoutMs:nt,onUploadProgress:v.onUploadProgress}),e=Date.now(),s=await N(a,t,H&&!x,"raw"===v.responseMode,rt,st,e);return v.onResponse&&(at=E(s.meta),s.observation=at),await _(a,s),!v.skipBusinessResponseHandler&&a.onBusinessResponse&&await a.onBusinessResponse(s.response,{request:{path:h,method:B,target:k,url:et},options:v}),s}catch(t){const e=Date.now(),s={response:j(t,e),...void 0===at?{}:{observation:at},meta:{...rt,transportStatus:"network_error",timings:{totalMs:e-st,upstreamMs:e-st}}};return await _(a,s,t),s}finally{ot.dispose()}}}function I(t){const e=k(t);return async function(t,s={}){const n=await e(t,s);return await(s.onResponse?.(n.observation??E(n.meta))),n.response}}export{I as createApiProtocolClient};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const r="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";function n(n){if(!Number.isSafeInteger(n)||n<0)throw new RangeError("随机字符串长度必须是非负整数");const t=new Uint8Array(16);let
|
|
1
|
+
const r="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";function n(n){if(!Number.isSafeInteger(n)||n<0)throw new RangeError("随机字符串长度必须是非负整数");const t=new Uint8Array(16);let o="";for(;o.length<n;){globalThis.crypto.getRandomValues(t);for(const e of t)if(!(e>=248)&&(o+=r.charAt(e%62),o.length===n))return o}return o}function t(){return n(10)}function o(){const r=globalThis.crypto;if("function"==typeof r?.randomUUID)return`req-${r.randomUUID().replace(/-/g,"")}`;if("function"!=typeof r?.getRandomValues)throw new Error("生成请求标识需要系统安全随机源 crypto.getRandomValues");const n=new Uint8Array(16);return r.getRandomValues(n),n[6]=15&n[6]|64,n[8]=63&n[8]|128,`req-${Array.from(n,r=>r.toString(16).padStart(2,"0")).join("")}`}export{o as generateRequestId,t as generateRequestNonce,n as generateSecureRandomString};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{createManagedCryptoDriver as t}from"./driver.js";import{createCryptoModule as e}from"./vendor/crypto/index_bg.js";let n=null,r=null;async function a(){r||(r=async function(){if("undefined"==typeof WebAssembly)throw new ReferenceError("WebAssembly is not defined");const n=e(),r=new URL("../../vendor/crypto/index_bg.wasm",import.meta.url),a=await fetch(r);if(!a.ok)throw new Error(`crypto wasm 加载失败:HTTP ${a.status} (${r.origin}${r.pathname})`);const i={"./index_bg.js":n};let s;const o=a.headers.get("Content-Type");s="function"==typeof WebAssembly.instantiateStreaming&&"application/wasm"===o?await WebAssembly.instantiateStreaming(a,i):await WebAssembly.instantiate(await a.arrayBuffer(),i),n.__wbg_set_wasm(s.instance.exports),s.instance.exports.__wbindgen_start();const c=s.module;return t(n,async()=>{const t=e(),n=await WebAssembly.instantiate(c,{"./index_bg.js":t});return t.__wbg_set_wasm(n.exports),n.exports.__wbindgen_start(),t})}().catch(t=>{throw r=null,t}));const a=await r;return n=await a.ready(),n}function i(){if(!n)throw new Error("crypto driver 尚未初始化,请先 await loadBrowserCryptoDriver()");return n}function s(t){return i().cryptMd5(t)}function o(t,e,n,r=null){return i().generateSign(t,e,n,r)}function c(t){return i().encryptAes(t)}function w(t){return i().decryptAes(t)}await a();export{s as cryptMd5,w as decryptAes,c as encryptAes,o as generateSign,a as loadBrowserCryptoDriver};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function e(e){return{cryptMd5:e.crypt_md5,generateSign:e.generate_sign,encryptAes:e.encrypt_aes,decryptAes:e.decrypt_aes}}export{
|
|
1
|
+
function t(t,e){let r,n,o,i=0,c=!1,f=!1;function s(e){t=e,r=void 0,f=!1,o=void 0}function y(t){c=!0,n=t,f=!1,o=void 0}function a(a){if(c)throw n;if(r)throw r;i++;try{const e=a(t);if(r)throw r;return e}catch(t){throw!r&&t instanceof WebAssembly.RuntimeError&&(r=t),void 0===r?t:r}finally{i--,0===i&&r&&function(){if(!f&&!c){f=!0;try{const t=e();"function"==typeof t.then?o=Promise.resolve(t).then(s,y):s(t)}catch(t){y(t)}}}()}}const d={cryptMd5:t=>a(e=>e.crypt_md5(t)),generateSign:(t,e,r,n)=>a(o=>o.generate_sign(t,e,r,n)),encryptAes:t=>a(e=>e.encrypt_aes(t)),decryptAes:t=>a(e=>e.decrypt_aes(t))};return{driver:d,async ready(){for(let t=o;t;t=o)await t;if(c)throw n;if(r)throw r;return d}}}export{t as createManagedCryptoDriver};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
let n;function
|
|
1
|
+
function e(){if("undefined"==typeof TextEncoder)throw new ReferenceError("TextEncoder is not defined");if("undefined"==typeof TextDecoder)throw new ReferenceError("TextDecoder is not defined");let e,n,t=[null];function r(e){return t.push(e),t.length-1}function _(e){if((e>>>=0)>=t.length)throw new WebAssembly.RuntimeError("crypto reference index out of bounds");return t[e]}function o(n,t){try{return n.apply(this,t)}catch(n){const t=function(n){const t=e.__externref_table_alloc();return e.__wbindgen_export_2.set(t,n),t}(n);e.__wbindgen_exn_store(t)}}function c(e){const n=typeof e;if("number"==n||"boolean"==n||null==e)return`${e}`;if("string"==n)return`"${e}"`;if("symbol"==n){const n=e.description;return null==n?"Symbol":`Symbol(${n})`}if("function"==n){const n=e.name;return"string"==typeof n&&n.length>0?`Function(${n})`:"Function"}if(Array.isArray(e)){const n=e.length;let t="[";n>0&&(t+=c(e[0]));for(let r=1;r<n;r++)t+=`, ${c(e[r])}`;return t+="]",t}const t=/\[object ([^\]]+)\]/.exec(toString.call(e));let r;if(!(t&&t.length>1))return toString.call(e);if(r=t[1],"Object"==r)try{return`Object(${JSON.stringify(e)})`}catch(e){return"Object"}return e instanceof Error?`${e.name}: ${e.message}\n${e.stack}`:r}let i=0,l=null;function u(){return null!==l&&0!==l.byteLength||(l=new Uint8Array(e.memory.buffer)),l}const f=new TextEncoder,g="function"==typeof f.encodeInto?function(e,n){return f.encodeInto(e,n)}:function(e,n){const t=f.encode(e);return n.set(t),{read:e.length,written:t.length}};function s(e,n,t){if(void 0===t){const t=f.encode(e),r=n(t.length,1)>>>0;return u().subarray(r,r+t.length).set(t),i=t.length,r}let r=e.length,_=n(r,1)>>>0;const o=u();let c=0;for(;c<r;c++){const n=e.charCodeAt(c);if(n>127)break;o[_+c]=n}if(c!==r){0!==c&&(e=e.slice(c)),_=t(_,r,r=c+3*e.length,1)>>>0;const n=u().subarray(_+c,_+r);c+=g(e,n).written,_=t(_,r,c,1)>>>0}return i=c,_}let a=null;function b(){return(null===a||!0===a.buffer.detached||void 0===a.buffer.detached&&a.buffer!==e.memory.buffer)&&(a=new DataView(e.memory.buffer)),a}function d(e){return null==e}const w=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});function y(e,n){return e>>>=0,w.decode(u().subarray(e,e+n))}function p(e,n){const t=n(1*e.length,1)>>>0;return u().set(e,t/1),i=e.length,t}function m(e,n){return e>>>=0,u().subarray(e/1,e/1+n)}return w.decode(),{__wbg_set_wasm:function(_){for(const e of["__compat_result_1","__compat_result_2","__compat_result_3"])if("function"!=typeof _[e])throw new Error("crypto WASM ABI mismatch");t=[null],n=function(){const e=Array(128).fill(null),n=n=>{if((n>>>=0)>=e.length)throw new WebAssembly.RuntimeError("crypto reference table index out of bounds");return n};return{get length(){return e.length},get:t=>e[n(t)],set:(t,r)=>{e[n(t)]=r},grow(n,t=null){n>>>=0;const r=e.length;if(n>4294967295-r)throw new RangeError("crypto reference table cannot grow");return e.length+=n,e.fill(t,r),r}}}(),i=0,l=null,a=null;const o=(e,n,o=-1)=>(...c)=>{const i=t.length;try{o>=0&&(c[o]=r(c[o]));const t=_[e](...c);return 2===n?[t,_.__compat_result_1()]:[t,_.__compat_result_1(),_.__compat_result_2(),_.__compat_result_3()]}finally{t.length=i}};e={..._,__wbindgen_export_2:n,crypt_md5:o("crypt_md5",2),generate_sign:o("generate_sign",4,4),encrypt_aes:o("encrypt_aes",2),decrypt_aes:o("decrypt_aes",2)}},__compat_table_get:function(e){return r(n.get(e))},__compat_table_set:function(e,t){n.set(e,_(t))},__compat_table_grow:function(e,t){const r=_(e);try{return n.grow(t,r)}catch(e){if(e instanceof RangeError)return-1;throw e}},crypt_md5:function(n){let t,r;try{const _=s(n,e.__wbindgen_malloc,e.__wbindgen_realloc),o=i,c=e.crypt_md5(_,o);return t=c[0],r=c[1],y(c[0],c[1])}finally{e.__wbindgen_free(t,r,1)}},generate_sign:function(n,t,r,_){let o,c;try{const l=s(n,e.__wbindgen_malloc,e.__wbindgen_realloc),u=i,f=s(t,e.__wbindgen_malloc,e.__wbindgen_realloc),g=i,a=d(_)?0:s(_,e.__wbindgen_malloc,e.__wbindgen_realloc),b=i,w=e.generate_sign(l,u,f,g,r,a,b);let p=w[0],m=w[1];if(w[3])throw p=0,m=0,function(n){const t=e.__wbindgen_export_2.get(n);return e.__externref_table_dealloc(n),t}(w[2]);return o=p,c=m,y(p,m)}finally{e.__wbindgen_free(o,c,1)}},encrypt_aes:function(n){const t=p(n,e.__wbindgen_malloc),r=i,_=e.encrypt_aes(t,r),o=m(_[0],_[1]).slice();return e.__wbindgen_free(_[0],1*_[1],1),o},decrypt_aes:function(n){const t=p(n,e.__wbindgen_malloc),r=i,_=e.decrypt_aes(t,r),o=m(_[0],_[1]).slice();return e.__wbindgen_free(_[0],1*_[1],1),o},__wbg_get_67b2ba62fc30de12:function(){return r(o((e,n)=>Reflect.get(_(e),_(n)),arguments))},__wbg_get_b9b93047fe3cf45b:function(e,n){return r(_(e)[n>>>0])},__wbg_length_e2d2a49132c1b256:function(e){return _(e).length},__wbg_ownKeys_3930041068756f1f:function(){return r(o(e=>Reflect.ownKeys(_(e)),arguments))},__wbindgen_debug_string:function(n,t){const r=s(c(_(t)),e.__wbindgen_malloc,e.__wbindgen_realloc),o=i;b().setInt32(n+4,o,!0),b().setInt32(n+0,r,!0)},__wbindgen_init_externref_table:function(){const n=e.__wbindgen_export_2,t=n.grow(4);n.set(0,void 0),n.set(t+0,void 0),n.set(t+1,null),n.set(t+2,!0),n.set(t+3,!1)},__wbindgen_is_object:function(e){const n=_(e);return"object"==typeof n&&null!==n},__wbindgen_string_get:function(n,t){const r=_(t),o="string"==typeof r?r:void 0,c=d(o)?0:s(o,e.__wbindgen_malloc,e.__wbindgen_realloc),l=i;b().setInt32(n+4,l,!0),b().setInt32(n+0,c,!0)},__wbindgen_string_new:function(e,n){return r(y(e,n))},__wbindgen_throw:function(e,n){throw new Error(y(e,n))}}}const n=/* @__PURE__ */e(),{__wbg_set_wasm:t,__compat_table_get:r,__compat_table_set:_,__compat_table_grow:o,crypt_md5:c,generate_sign:i,encrypt_aes:l,decrypt_aes:u,__wbg_get_67b2ba62fc30de12:f,__wbg_get_b9b93047fe3cf45b:g,__wbg_length_e2d2a49132c1b256:s,__wbg_ownKeys_3930041068756f1f:a,__wbindgen_debug_string:b,__wbindgen_init_externref_table:d,__wbindgen_is_object:w,__wbindgen_string_get:y,__wbindgen_string_new:p,__wbindgen_throw:m}=n;export{r as __compat_table_get,o as __compat_table_grow,_ as __compat_table_set,f as __wbg_get_67b2ba62fc30de12,g as __wbg_get_b9b93047fe3cf45b,s as __wbg_length_e2d2a49132c1b256,a as __wbg_ownKeys_3930041068756f1f,t as __wbg_set_wasm,b as __wbindgen_debug_string,d as __wbindgen_init_externref_table,w as __wbindgen_is_object,y as __wbindgen_string_get,p as __wbindgen_string_new,m as __wbindgen_throw,e as createCryptoModule,c as crypt_md5,u as decrypt_aes,l as encrypt_aes,i as generate_sign};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{encryptCollectTeaBody as e,parseCollectFavoriteMsgBody as r}from"../crypto/collect-tea.js";import{requestCoreJson as t,CoreJsonBusinessError as i}from"./requests/core-json-request.js";import{projectSessionFavoriteFilesBody as n,parseSessionFavoriteFileItems as o}from"../../../im-core/src/session-favorite-files.js";import{resolveSessionFavoriteListImageUrl as a}from"../../../im-core/src/session-favorite-album.js";
|
|
1
|
+
import{encryptCollectTeaBody as e,parseCollectFavoriteMsgBody as r}from"../crypto/collect-tea.js";import{requestCoreJson as t,CoreJsonBusinessError as i}from"./requests/core-json-request.js";import{projectSessionFavoriteFilesBody as n,parseSessionFavoriteFileItems as o}from"../../../im-core/src/session-favorite-files.js";import{resolveSessionFavoriteListImageUrl as a}from"../../../im-core/src/session-favorite-album.js";import{newClientMessageId as s}from"../../../im-core/src/mapping/message-id.js";class c extends Error{constructor(){super("会话收藏 Core API 未配置"),this.name="SessionFavoriteProviderUnavailableError"}}class m extends Error{constructor(e){super(e),this.name="SessionFavoriteMappingError"}}function l(e){return"string"==typeof e?e:null==e?"":String(e)}function d(e,r){const t=l(e).trim();if(""===t)throw new m(`${r} 不能为空`);return t}function f(e){if("direct"===e)return 0;if("group"===e)return 1;if("channel"===e)return 2;throw new m(`favorite conversation type ${e}`)}function u(e,r){return"text"===r||"location"===r?l(e.content).trim():"file"===r?l(e.fileName||e.file_name||e.name).trim():"mediaAlbum"===r||"filesAlbum"===r?l(e.caption).trim():"liveRoom"===r?l(e.liveRoomName).trim()||l(e.broadcasterUserName).trim():""}function v(e,r){const t=l(e.group_id).trim(),i=l(e.radio_id).trim(),n=Number(l(e.msg_type).trim());if(1===n&&""!==t)return{conversationType:"group",conversationId:t};if(2===n&&""!==i)return{conversationType:"channel",conversationId:i};if(""!==t)return{conversationType:"group",conversationId:t};if(""!==i)return{conversationType:"channel",conversationId:i};if(0===n){const t=l(e.from_id).trim(),i=l(e.to_id).trim(),n=t===r.trim()?i:t;if(""!==n)return{conversationType:"direct",conversationId:n}}return null}function p(e,r){const t=e.from_user,i=l(t?.nick_name||t?.nickname||t?.name).trim();return""===i?r:i}function y(e,t){const i=l(e.uu_id).trim(),s=function(e){const r="number"==typeof e?e:Number(String(e??"").trim());return 1===r?"text":2===r?"image":3===r?"video":4===r?"voice":5===r?"location":11===r?"file":28===r?"mediaAlbum":29===r?"filesAlbum":30===r?"liveRoom":null}(e.content_type),c=r(l(e.msg_body),t);if(""===i||null===s||null===c)return null;const m=l(e.from_id).trim();return Object.freeze({collectId:i,msgId:l(e.msg_id).trim(),kind:s,senderId:m,senderName:p(e,m),avatarUrl:l(e.from_user?.avatar).trim(),createdAt:l(e.create_time||e.update_time||e.msg_time).trim(),text:u(c,s),imageUrl:a(s,c),fileName:"filesAlbum"===s?o(c).map(e=>e.fileName).join(" "):"file"===s?u(c,"file"):"",body:"filesAlbum"===s?n(c):Object.freeze({...c}),conversation:v(e,t)})}function g(){if("function"!=typeof globalThis.crypto?.randomUUID&&"function"!=typeof globalThis.crypto?.getRandomValues)throw new m("collect uuid 不可用");return s()}function b(r){async function s(e,n,o){if(void 0===r.coreClient)throw new c;const a=await t(r.coreClient,e,n,{method:"POST",responseMode:"strict",prefix:""});if(!a.ok)throw new i(o,a.code,a.message);return a.data}return{async list(){const e=d(r.getUserId(),"favorite userId"),t=await s("/api/v1/user/favorite/list",{start_time:"1970-01-01 08:00:00",page_size:"2000"},"会话收藏列表");return Object.freeze(function(e){if(null==e)return[];if(Array.isArray(e))return e;if("object"==typeof e&&null!==e&&"list"in e){const r=e.list;if(null==r)return[];if(Array.isArray(r))return r}throw new m("favorite list data 必须是数组或 { list }")}(t).flatMap(r=>{const t=y(r,e);return null===t?[]:[t]}))},async add(t){const i=d(r.getUserId(),"favorite userId"),c=(r.createCollectId??g)(),m={msg_id:d(t.messageId,"favorite msgId"),content_type:(l=t.kind,"text"===l?1:"image"===l?2:"video"===l?3:"voice"===l?4:"location"===l?5:"mediaAlbum"===l?28:"filesAlbum"===l?29:"liveRoom"===l?30:11),msg_type:f(t.conversation.conversationType),msg_time:String(t.createdAt),from_id:d(t.senderId,"favorite fromId"),to_id:d(t.peerId,"favorite toId"),is_hide:!0===t.hide?"1":"0",uu_id:c,msg_body:e(JSON.stringify(t.plainBody),i)};var l,v;return"group"===t.conversation.conversationType&&(m.group_id=t.conversation.conversationId),"channel"===t.conversation.conversationType&&(m.radio_id=t.conversation.conversationId),await s("/api/v1/user/favorite/add",m,"添加会话收藏"),v={collectId:c,msgId:t.messageId.trim(),kind:t.kind,senderId:t.senderId.trim(),senderName:t.senderId.trim(),avatarUrl:"",createdAt:String(t.createdAt),text:u(t.plainBody,t.kind),imageUrl:a(t.kind,t.plainBody),fileName:"filesAlbum"===t.kind?o(t.plainBody).map(e=>e.fileName).join(" "):"file"===t.kind?u(t.plainBody,"file"):"",body:"filesAlbum"===t.kind?n(t.plainBody):t.plainBody,conversation:t.conversation},Object.freeze({...v,body:Object.freeze({...v.body}),conversation:null===v.conversation?null:Object.freeze({...v.conversation})})},async delete(e){const r=[...new Set(e.map(e=>e.trim()).filter(e=>""!==e))];if(0===r.length)throw new m("favorite ids 不能为空");await s("/api/v1/user/favorite/del",{ids:r.join("|")},"删除会话收藏")}}}export{m as SessionFavoriteMappingError,c as SessionFavoriteProviderUnavailableError,b as createSessionFavoriteHttpAdapter};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{fileMd5 as
|
|
1
|
+
import{fileMd5 as e}from"./file-md5.js";import{resolveMediaThumbnailMimeType as t}from"../../../im-core/src/media-thumbnail.js";function i(e,t){return""!==e.type||void 0===t||""===t?e:new Blob([e],{type:t})}function a(a){let r=0;return{fileMd5:e,async imageDimensions(e,t,o){const n=await a.prepare({operationId:"core-image-dimensions-"+ ++r,generation:0,kind:"image",file:i(e,t),includePoster:!1},o);return{width:n.width,height:n.height}},async imageThumbnail(e,o,n){const m=await a.prepare({operationId:"core-image-thumbnail-"+ ++r,generation:0,kind:"image",posterEncoding:"webp",file:i(e,o?.mimeType),...void 0===o?.maxSize?{}:{maxSize:o.maxSize},...void 0===o?.targetBytes?{}:{targetBytes:o.targetBytes},...void 0===o?.maxBytes?{}:{maxBytes:o.maxBytes},...void 0===o?.quality?{}:{quality:o.quality},...void 0===o?.minQuality?{}:{minQuality:o.minQuality}},n);if(void 0===m.posterData)throw new Error("图片缩略图生成失败:执行器未返回 poster");return{data:new Uint8Array(m.posterData),width:m.width,height:m.height,mimeType:t(new Uint8Array(m.posterData))}},async videoPoster(e,o,n){const m=await a.prepare({operationId:"core-video-poster-"+ ++r,generation:0,kind:"video",posterEncoding:"webp",file:i(e,o?.mimeType),...void 0===o?.maxSize?{}:{maxSize:o.maxSize},...void 0===o?.targetBytes?{}:{targetBytes:o.targetBytes},...void 0===o?.maxBytes?{}:{maxBytes:o.maxBytes},...void 0===o?.quality?{}:{quality:o.quality},...void 0===o?.minQuality?{}:{minQuality:o.minQuality},...void 0===o?.atTime?{}:{atTime:o.atTime}},n);if(void 0===m.posterData)throw new Error("视频封面生成失败:执行器未返回 poster");return{data:new Uint8Array(m.posterData),width:m.width,height:m.height,duration:Math.round(m.duration??0),mimeType:t(new Uint8Array(m.posterData))}}}}export{a as createMediaPreviewAdapter};
|